UNPKG

@vela-ui/react

Version:

Vela UI React components

148 lines (142 loc) 4.77 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/checkbox.tsx var checkbox_exports = {}; __export(checkbox_exports, { Checkbox: () => Checkbox }); module.exports = __toCommonJS(checkbox_exports); var import_react_aria_components = require("react-aria-components"); var import_tailwind_variants2 = 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/icons/minus.tsx var import_jsx_runtime2 = require("react/jsx-runtime"); var MinusIcon = (props) => { return /* @__PURE__ */ (0, import_jsx_runtime2.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_runtime2.jsx)("path", { d: "M5 12h14" }) } ); }; // src/lib/classes.ts var import_tailwind_variants = require("tailwind-variants"); var focusRing = (0, import_tailwind_variants.tv)({ base: "outline-hidden", variants: { isFocusVisible: { true: "border-ring ring-ring/50 ring-[3px]" }, isInvalid: { true: "ring-destructive/20 dark:ring-destructive/40 border-destructive" } } }); // src/components/checkbox.tsx var import_jsx_runtime3 = require("react/jsx-runtime"); var checkboxVariants = (0, import_tailwind_variants2.tv)({ base: "group relative flex items-center gap-2 text-sm transition", variants: { isDisabled: { true: "cursor-not-allowed opacity-50" } } }); var checkboxIndicatorVariants = (0, import_tailwind_variants2.tv)({ extend: focusRing, base: "peer border-input dark:bg-input/30 flex shrink-0 items-center justify-center rounded-[4px] border shadow-xs transition-shadow [&_svg]:size-full", variants: { size: { sm: "size-4", md: "size-5 p-0.5", lg: "size-6 p-0.5" }, isSelected: { true: "bg-primary dark:bg-primary text-primary-foreground border-primary" }, isDisabled: { true: "cursor-not-allowed opacity-50" } }, defaultVariants: { size: "md" } }); function Checkbox({ className, children, indicatorClassName, size, ...props }) { return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)( import_react_aria_components.Checkbox, { className: (0, import_react_aria_components.composeRenderProps)( className, (className2, renderProps) => checkboxVariants({ ...renderProps, className: className2 }) ), ...props, children: (0, import_react_aria_components.composeRenderProps)(children, (children2, { isSelected, isIndeterminate, ...renderProps }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)( "div", { "data-slot": "checkbox-indicator", className: checkboxIndicatorVariants({ isSelected: isSelected || isIndeterminate, size, ...renderProps, className: indicatorClassName }), children: isIndeterminate ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MinusIcon, {}) : isSelected ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CheckIcon, {}) : null } ), children2 ] })) } ); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Checkbox });