@vela-ui/react
Version:
Vela UI React components
140 lines (136 loc) • 5.36 kB
JavaScript
;
"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/dropdown.tsx
var dropdown_exports = {};
__export(dropdown_exports, {
DropdownDescription: () => DropdownDescription,
DropdownItem: () => DropdownItem,
DropdownLabel: () => DropdownLabel,
DropdownSection: () => DropdownSection,
DropdownSeparator: () => DropdownSeparator,
dropdownItemVariants: () => dropdownItemVariants
});
module.exports = __toCommonJS(dropdown_exports);
var import_react_aria_components = require("react-aria-components");
var import_tailwind_merge = 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_components.ListBoxSection, { className, children: [
"title" in props && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_aria_components.Header, { className: "text-muted-foreground px-2 py-1.5 text-xs", children: props.title }),
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_aria_components.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_components.ListBoxItem,
{
textValue,
className: (0, import_react_aria_components.composeRenderProps)(
className,
(className2, renderProps) => dropdownItemVariants({ ...renderProps, variant, className: className2 })
),
...props,
children: (0, import_react_aria_components.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_components.Text, { slot: "label", className, ...props });
}
function DropdownDescription({ className, ...props }) {
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
import_react_aria_components.Text,
{
slot: "description",
className: (0, import_tailwind_merge.twMerge)("text-muted-foreground text-sm", className),
...props
}
);
}
function DropdownSeparator({ className, ...props }) {
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
import_react_aria_components.Separator,
{
orientation: "horizontal",
className: (0, import_tailwind_merge.twMerge)("bg-border -mx-1 my-1 h-px", className),
...props
}
);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DropdownDescription,
DropdownItem,
DropdownLabel,
DropdownSection,
DropdownSeparator,
dropdownItemVariants
});