@vela-ui/react
Version:
Vela UI React components
103 lines (98 loc) • 3.69 kB
JavaScript
;
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/native-select.tsx
var native_select_exports = {};
__export(native_select_exports, {
NativeSelect: () => NativeSelect
});
module.exports = __toCommonJS(native_select_exports);
var import_tailwind_variants = require("tailwind-variants");
// src/icons/chevron-down.tsx
var import_jsx_runtime = require("react/jsx-runtime");
var ChevronDownIcon = (props) => {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
"svg",
{
fill: "none",
stroke: "currentColor",
strokeWidth: 2,
strokeLinecap: "round",
strokeLinejoin: "round",
width: "24",
height: "24",
viewBox: "0 0 24 24",
xmlns: "http://www.w3.org/2000/svg",
...props,
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m6 9 6 6 6-6" })
}
);
};
// 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");
var cn = (...inputs) => (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(...inputs));
// src/components/native-select.tsx
var import_jsx_runtime2 = require("react/jsx-runtime");
var selectVariants = (0, import_tailwind_variants.tv)({
base: [
"border-input dark:bg-input/30 dark:hover:bg-input/50 w-full appearance-none rounded-md border bg-transparent px-3 pr-9 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow]",
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] focus-visible:outline-none",
"disabled:cursor-not-allowed disabled:opacity-50",
"aria-invalid:ring-destructive/20 aria-invalid:dark:ring-destructive/40 aria-invalid:border-destructive"
],
variants: {
size: {
xs: "h-8",
sm: "h-9",
md: "h-10",
lg: "h-11"
}
},
defaultVariants: {
size: "md"
}
});
function NativeSelect({
className,
wrapperClassName,
placeholder,
size = "md",
...props
}) {
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: cn("relative flex h-fit w-full", wrapperClassName), children: [
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("select", { className: selectVariants({ className, size }), ...props, children: [
placeholder && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: placeholder }),
props.children
] }),
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "pointer-events-none absolute top-1/2 right-3 -translate-y-1/2", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
ChevronDownIcon,
{
className: cn("text-muted-foreground size-4 opacity-50", {
"size-3.5": size === "xs",
"size-5": size === "lg"
})
}
) })
] });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
NativeSelect
});