UNPKG

@vela-ui/react

Version:

Vela UI React components

158 lines (151 loc) 6.11 kB
"use strict"; "use client"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/components/list-box.tsx var list_box_exports = {}; __export(list_box_exports, { ListBox: () => ListBox, ListBoxDescription: () => ListBoxDescription, ListBoxItem: () => ListBoxItem, ListBoxLabel: () => ListBoxLabel, ListBoxSection: () => ListBoxSection2 }); module.exports = __toCommonJS(list_box_exports); var import_react_aria_components3 = require("react-aria-components"); // src/lib/utils.ts var import_clsx = require("clsx"); var import_react_aria_components = require("react-aria-components"); var import_tailwind_merge = require("tailwind-merge"); function composeTailwindRenderProps(className, tailwind) { return (0, import_react_aria_components.composeRenderProps)(className, (className2) => (0, import_tailwind_merge.twMerge)(tailwind, className2)); } // src/components/dropdown.tsx var import_react_aria_components2 = require("react-aria-components"); var import_tailwind_merge2 = require("tailwind-merge"); var import_tailwind_variants = require("tailwind-variants"); // src/icons/check.tsx var import_jsx_runtime = require("react/jsx-runtime"); var CheckIcon = (props) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( "svg", { fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", width: "1em", height: "1em", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M20 6 9 17l-5-5" }) } ); }; // src/components/dropdown.tsx var import_jsx_runtime2 = require("react/jsx-runtime"); var dropdownItemVariants = (0, import_tailwind_variants.tv)({ base: "relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[selection-mode]:pr-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", variants: { variant: { default: "", destructive: "text-destructive *:[svg]:!text-destructive" }, isFocused: { true: "bg-accent text-accent-foreground" }, isHovered: { true: "bg-accent text-accent-foreground" }, isDisabled: { true: "pointer-events-none opacity-50" } }, compoundVariants: [ { variant: "destructive", isFocused: true, className: "bg-destructive/10 dark:bg-destructive/20 text-destructive" } ] }); function DropdownSection({ className, ...props }) { return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_aria_components2.ListBoxSection, { className, children: [ "title" in props && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_aria_components2.Header, { className: "text-muted-foreground px-2 py-1.5 text-xs", children: props.title }), /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_aria_components2.Collection, { items: props.items, children: props.children }) ] }); } function DropdownItem({ className, variant, ...props }) { const textValue = props.textValue || (typeof props.children === "string" ? props.children : void 0); return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( import_react_aria_components2.ListBoxItem, { textValue, className: (0, import_react_aria_components2.composeRenderProps)( className, (className2, renderProps) => dropdownItemVariants({ ...renderProps, variant, className: className2 }) ), ...props, children: (0, import_react_aria_components2.composeRenderProps)(props.children, (children, { isSelected }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [ isSelected && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "pointer-events-none absolute right-2 flex size-4 items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CheckIcon, {}) }), children ] })) } ); } function DropdownLabel({ className, ...props }) { return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_aria_components2.Text, { slot: "label", className, ...props }); } function DropdownDescription({ className, ...props }) { return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( import_react_aria_components2.Text, { slot: "description", className: (0, import_tailwind_merge2.twMerge)("text-muted-foreground text-sm", className), ...props } ); } // src/components/list-box.tsx var import_jsx_runtime3 = require("react/jsx-runtime"); function ListBox({ className, ...props }) { return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)( import_react_aria_components3.ListBox, { className: composeTailwindRenderProps( className, "group bg-popover text-popover-foreground min-w-[8rem] overflow-auto rounded-md border p-1 shadow-md outline-hidden data-[empty]:p-6 data-[empty]:text-center data-[empty]:text-sm" ), ...props } ); } var ListBoxItem = DropdownItem; var ListBoxSection2 = DropdownSection; var ListBoxLabel = DropdownLabel; var ListBoxDescription = DropdownDescription; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { ListBox, ListBoxDescription, ListBoxItem, ListBoxLabel, ListBoxSection });