luan-ui 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/dist/components/accordion/accordion.d.ts +14 -15
- package/dist/components/accordion/accordion.js +11 -9
- package/dist/components/accordion/accordion.js.map +1 -1
- package/dist/components/alert/alert.d.ts +19 -18
- package/dist/components/alert/alert.js +35 -15
- package/dist/components/alert/alert.js.map +1 -1
- package/dist/components/alert-dialog/alert-dialog.d.ts +14 -9
- package/dist/components/alert-dialog/alert-dialog.js +21 -15
- package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/avatar/avatar-group.d.ts +3 -2
- package/dist/components/avatar/avatar-group.js +4 -4
- package/dist/components/avatar/avatar-group.js.map +1 -1
- package/dist/components/avatar/avatar.d.ts +8 -4
- package/dist/components/avatar/avatar.js +10 -8
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/badge/badge.d.ts +12 -5
- package/dist/components/badge/badge.js +18 -7
- package/dist/components/badge/badge.js.map +1 -1
- package/dist/components/button/button.d.ts +24 -18
- package/dist/components/button/button.js +30 -15
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/card/card.d.ts +32 -19
- package/dist/components/card/card.js +52 -20
- package/dist/components/card/card.js.map +1 -1
- package/dist/components/checkbox/checkbox.d.ts +6 -7
- package/dist/components/checkbox/checkbox.js +6 -8
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/dialog/dialog.d.ts +16 -9
- package/dist/components/dialog/dialog.js +23 -18
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/drawer/drawer.d.ts +19 -9
- package/dist/components/drawer/drawer.js +31 -25
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +30 -21
- package/dist/components/dropdown-menu/dropdown-menu.js +35 -30
- package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -1
- package/dist/components/form-field/form-field.d.ts +4 -8
- package/dist/components/form-field/form-field.js +3 -4
- package/dist/components/form-field/form-field.js.map +1 -1
- package/dist/components/form-helper/form-helper.d.ts +4 -6
- package/dist/components/form-helper/form-helper.js +2 -3
- package/dist/components/form-helper/form-helper.js.map +1 -1
- package/dist/components/icon/icon.d.ts +9 -15
- package/dist/components/icon/icon.js +20 -19
- package/dist/components/icon/icon.js.map +1 -1
- package/dist/components/input/input.d.ts +4 -4
- package/dist/components/input/input.js +2 -4
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/label/label.d.ts +3 -4
- package/dist/components/label/label.js +5 -6
- package/dist/components/label/label.js.map +1 -1
- package/dist/components/pagination/pagination.d.ts +25 -21
- package/dist/components/pagination/pagination.js +30 -19
- package/dist/components/pagination/pagination.js.map +1 -1
- package/dist/components/popover/popover.d.ts +30 -14
- package/dist/components/popover/popover.js +30 -22
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/progress/progress.d.ts +4 -6
- package/dist/components/progress/progress.js +4 -6
- package/dist/components/progress/progress.js.map +1 -1
- package/dist/components/radio-group/radio-group.d.ts +8 -7
- package/dist/components/radio-group/radio-group.js +8 -35
- package/dist/components/radio-group/radio-group.js.map +1 -1
- package/dist/components/select/select.d.ts +26 -15
- package/dist/components/select/select.js +28 -50
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/skeleton/skeleton.d.ts +3 -1
- package/dist/components/skeleton/skeleton.js +3 -6
- package/dist/components/skeleton/skeleton.js.map +1 -1
- package/dist/components/slider/slider.d.ts +7 -14
- package/dist/components/slider/slider.js +23 -13
- package/dist/components/slider/slider.js.map +1 -1
- package/dist/components/switch/switch.d.ts +7 -7
- package/dist/components/switch/switch.js +9 -11
- package/dist/components/switch/switch.js.map +1 -1
- package/dist/components/table/table.d.ts +17 -8
- package/dist/components/table/table.js +24 -41
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/tabs/tabs.d.ts +9 -5
- package/dist/components/tabs/tabs.js +10 -8
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/text-area/text-area.d.ts +3 -5
- package/dist/components/text-area/text-area.js +2 -4
- package/dist/components/text-area/text-area.js.map +1 -1
- package/dist/components/toast/toast.d.ts +4 -10
- package/dist/components/toast/toast.js +4 -7
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/tooltip/tooltip.d.ts +18 -9
- package/dist/components/tooltip/tooltip.js +21 -20
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/styles/index.css +2 -2
- package/dist/utilities/merge-refs/merge-refs.d.ts +2 -2
- package/dist/utilities/merge-refs/merge-refs.js +1 -1
- package/dist/utilities/merge-refs/merge-refs.js.map +1 -1
- package/dist/utilities/responsive/responsive.d.ts +14 -10
- package/package.json +71 -72
- package/dist/components/slot/slot.d.ts +0 -13
- package/dist/components/slot/slot.js +0 -70
- package/dist/components/slot/slot.js.map +0 -1
|
@@ -1,65 +1,43 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Select as SelectPrimitive } from "@base-ui/react/select";
|
|
2
3
|
import { useFormContext } from "../form-field/form-field-context";
|
|
3
4
|
import { Icon } from "../icon/icon";
|
|
4
5
|
import { CheckIcon, ChevronDownIcon, ChevronUpIcon, } from "@radix-ui/react-icons";
|
|
5
6
|
import { cn } from "../../utilities/cn/cn";
|
|
6
|
-
|
|
7
|
-
import { forwardRef, } from "react";
|
|
8
|
-
/**
|
|
9
|
-
* Select
|
|
10
|
-
*/
|
|
11
|
-
const Select = ({ disabled: initialDisabled, required: initialRequired, ...props }) => {
|
|
7
|
+
function Select({ disabled: initialDisabled, required: initialRequired, ...props }) {
|
|
12
8
|
const { disabled, required } = useFormContext({
|
|
13
9
|
disabled: initialDisabled,
|
|
14
10
|
required: initialRequired,
|
|
15
11
|
});
|
|
16
12
|
return (_jsx(SelectPrimitive.Root, { disabled: disabled, required: required, ...props }));
|
|
17
|
-
}
|
|
13
|
+
}
|
|
18
14
|
/**
|
|
19
15
|
* SelectGroup
|
|
20
16
|
*/
|
|
21
17
|
const SelectGroup = SelectPrimitive.Group;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
SelectPrimitive.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"), children: children }), _jsx(SelectScrollDownButton, {})] }) })));
|
|
48
|
-
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
49
|
-
/**
|
|
50
|
-
* SelectLabel
|
|
51
|
-
*/
|
|
52
|
-
const SelectLabel = forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.Label, { ref: ref, className: cn("px-2 py-1.5 font-semibold text-sm", className), ...props })));
|
|
53
|
-
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
54
|
-
/**
|
|
55
|
-
* SelectItem
|
|
56
|
-
*/
|
|
57
|
-
const SelectItem = forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Item, { ref: ref, className: cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none focus-visible:bg-gray-700 focus-visible:text-white data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className), ...props, children: [_jsx("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(SelectPrimitive.ItemIndicator, { children: _jsx(Icon, { asChild: true, size: "small", children: _jsx(CheckIcon, {}) }) }) }), _jsx(SelectPrimitive.ItemText, { children: children })] })));
|
|
58
|
-
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
59
|
-
/**
|
|
60
|
-
* SelectSeparator
|
|
61
|
-
*/
|
|
62
|
-
const SelectSeparator = forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.Separator, { ref: ref, className: cn("my-2 h-px bg-gray-200", className), ...props })));
|
|
63
|
-
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
64
|
-
export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, };
|
|
18
|
+
function SelectValue({ ref, ...props }) {
|
|
19
|
+
return _jsx(SelectPrimitive.Value, { ref: ref, ...props });
|
|
20
|
+
}
|
|
21
|
+
function SelectTrigger({ className, children, ref, ...props }) {
|
|
22
|
+
return (_jsxs(SelectPrimitive.Trigger, { ref: ref, className: cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-gray-400 bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-placeholder:text-gray-500 [&>span]:line-clamp-1", className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { render: _jsx(Icon, { size: "small", className: "opacity-50", children: _jsx(ChevronDownIcon, {}) }) })] }));
|
|
23
|
+
}
|
|
24
|
+
function SelectScrollUpArrow({ className, ref, ...props }) {
|
|
25
|
+
return (_jsx(SelectPrimitive.ScrollUpArrow, { ref: ref, className: cn("flex cursor-default items-center justify-center py-1", className), ...props, children: _jsx(Icon, { size: "small", className: "opacity-50", children: _jsx(ChevronUpIcon, {}) }) }));
|
|
26
|
+
}
|
|
27
|
+
function SelectScrollDownArrow({ className, ref, ...props }) {
|
|
28
|
+
return (_jsx(SelectPrimitive.ScrollDownArrow, { ref: ref, className: cn("flex cursor-default items-center justify-center py-1", className), ...props, children: _jsx(Icon, { size: "small", className: "opacity-50", children: _jsx(ChevronDownIcon, {}) }) }));
|
|
29
|
+
}
|
|
30
|
+
function SelectContent({ className, children, sideOffset = 4, ref, ...props }) {
|
|
31
|
+
return (_jsx(SelectPrimitive.Portal, { children: _jsxs(SelectPrimitive.Positioner, { sideOffset: sideOffset, alignItemWithTrigger: false, children: [_jsx(SelectScrollUpArrow, {}), _jsx(SelectPrimitive.Popup, { ref: ref, className: cn("data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-closed:fade-out data-closed:zoom-out-95 data-open:fade-in data-open:zoom-in-95 relative z-50 max-h-(--available-height) min-w-32 origin-(--transform-origin) overflow-y-auto overflow-x-hidden rounded-md border border-gray-400 bg-white text-gray-700 shadow-md transition-all data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1 data-closed:animate-out data-open:animate-in", className), ...props, children: _jsx(SelectPrimitive.List, { className: "w-full min-w-(--anchor-width) p-1", children: children }) }), _jsx(SelectScrollDownArrow, {})] }) }));
|
|
32
|
+
}
|
|
33
|
+
function SelectLabel({ className, ref, ...props }) {
|
|
34
|
+
return (_jsx(SelectPrimitive.GroupLabel, { ref: ref, className: cn("px-2 py-1.5 font-semibold text-sm", className), ...props }));
|
|
35
|
+
}
|
|
36
|
+
function SelectItem({ className, children, ref, ...props }) {
|
|
37
|
+
return (_jsxs(SelectPrimitive.Item, { ref: ref, className: cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none data-disabled:pointer-events-none data-highlighted:bg-gray-700 data-highlighted:text-white data-disabled:opacity-50", className), ...props, children: [_jsx("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(SelectPrimitive.ItemIndicator, { children: _jsx(Icon, { size: "small", children: _jsx(CheckIcon, {}) }) }) }), _jsx(SelectPrimitive.ItemText, { children: children })] }));
|
|
38
|
+
}
|
|
39
|
+
function SelectSeparator({ className, ref, ...props }) {
|
|
40
|
+
return (_jsx(SelectPrimitive.Separator, { ref: ref, className: cn("my-2 h-px bg-gray-200", className), ...props }));
|
|
41
|
+
}
|
|
42
|
+
export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpArrow, SelectScrollDownArrow, };
|
|
65
43
|
//# sourceMappingURL=select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sourceRoot":"/","sources":["components/select/select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EACN,SAAS,EACT,eAAe,EACf,aAAa,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAGN,UAAU,GACV,MAAM,OAAO,CAAC;AAEf;;GAEG;AAEH,MAAM,MAAM,GAAG,CAAC,EACf,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,eAAe,EACzB,GAAG,KAAK,EAC+C,EAAE,EAAE;IAC3D,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC;QAC7C,QAAQ,EAAE,eAAe;QACzB,QAAQ,EAAE,eAAe;KACzB,CAAC,CAAC;IACH,OAAO,CACN,KAAC,eAAe,CAAC,IAAI,IAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,KAAM,KAAK,GAAI,CAC3E,CAAC;AACH,CAAC,CAAC;AAEF;;GAEG;AAEH,MAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC;AAE1C;;GAEG;AAEH,MAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC;AAE1C;;GAEG;AAE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Q,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAC7C,MAAC,eAAe,CAAC,IAAI,IACpB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACZ,iOAAiO,EACjO,SAAS,CACT,KACG,KAAK,aAET,eAAM,SAAS,EAAC,+DAA+D,YAC9E,KAAC,eAAe,CAAC,aAAa,cAC7B,KAAC,IAAI,IAAC,OAAO,QAAC,IAAI,EAAC,OAAO,YACzB,KAAC,SAAS,KAAG,GACP,GACwB,GAC1B,EACP,KAAC,eAAe,CAAC,QAAQ,cAAE,QAAQ,GAA4B,IACzC,CACvB,CAAC,CAAC;AACH,UAAU,CAAC,WAAW,GAAG,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC;AAE1D;;GAEG;AAEH,MAAM,eAAe,GAAG,UAAU,CAGhC,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CACnC,KAAC,eAAe,CAAC,SAAS,IACzB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,uBAAuB,EAAE,SAAS,CAAC,KAC7C,KAAK,GACR,CACF,CAAC,CAAC;AACH,eAAe,CAAC,WAAW,GAAG,eAAe,CAAC,SAAS,CAAC,WAAW,CAAC;AAEpE,OAAO,EACN,MAAM,EACN,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,WAAW,EACX,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,sBAAsB,GACtB,CAAC","sourcesContent":["import { useFormContext } from \"@components/form-field/form-field-context\";\nimport { Icon } from \"@components/icon/icon\";\nimport {\n\tCheckIcon,\n\tChevronDownIcon,\n\tChevronUpIcon,\n} from \"@radix-ui/react-icons\";\nimport { cn } from \"@utilities/cn/cn\";\nimport { Select as SelectPrimitive } from \"radix-ui\";\nimport {\n\ttype ComponentPropsWithoutRef,\n\ttype ComponentRef,\n\tforwardRef,\n} from \"react\";\n\n/**\n * Select\n */\n\nconst Select = ({\n\tdisabled: initialDisabled,\n\trequired: initialRequired,\n\t...props\n}: ComponentPropsWithoutRef<typeof SelectPrimitive.Root>) => {\n\tconst { disabled, required } = useFormContext({\n\t\tdisabled: initialDisabled,\n\t\trequired: initialRequired,\n\t});\n\treturn (\n\t\t<SelectPrimitive.Root disabled={disabled} required={required} {...props} />\n\t);\n};\n\n/**\n * SelectGroup\n */\n\nconst SelectGroup = SelectPrimitive.Group;\n\n/**\n * SelectValue\n */\n\nconst SelectValue = SelectPrimitive.Value;\n\n/**\n * SelectTrigger\n */\n\nconst SelectTrigger = forwardRef<\n\tComponentRef<typeof SelectPrimitive.Trigger>,\n\tComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>\n>(({ className, children, ...props }, ref) => (\n\t<SelectPrimitive.Trigger\n\t\tref={ref}\n\t\tclassName={cn(\n\t\t\t\"flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-gray-400 bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-gray-500 [&>span]:line-clamp-1\",\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t>\n\t\t{children}\n\t\t<SelectPrimitive.Icon asChild>\n\t\t\t<Icon asChild size=\"small\" className=\"opacity-50\">\n\t\t\t\t<ChevronDownIcon />\n\t\t\t</Icon>\n\t\t</SelectPrimitive.Icon>\n\t</SelectPrimitive.Trigger>\n));\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName;\n\n/**\n * SelectScrollUpButton\n */\n\nconst SelectScrollUpButton = forwardRef<\n\tComponentRef<typeof SelectPrimitive.ScrollUpButton>,\n\tComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n\t<SelectPrimitive.ScrollUpButton\n\t\tref={ref}\n\t\tclassName={cn(\n\t\t\t\"flex cursor-default items-center justify-center py-1\",\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t>\n\t\t<Icon asChild size=\"small\" className=\"opacity-50\">\n\t\t\t<ChevronUpIcon />\n\t\t</Icon>\n\t</SelectPrimitive.ScrollUpButton>\n));\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;\n\n/**\n * SelectScrollDownButton\n */\n\nconst SelectScrollDownButton = forwardRef<\n\tComponentRef<typeof SelectPrimitive.ScrollDownButton>,\n\tComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n\t<SelectPrimitive.ScrollDownButton\n\t\tref={ref}\n\t\tclassName={cn(\n\t\t\t\"flex cursor-default items-center justify-center py-1\",\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t>\n\t\t<Icon asChild size=\"small\" className=\"opacity-50\">\n\t\t\t<ChevronDownIcon />\n\t\t</Icon>\n\t</SelectPrimitive.ScrollDownButton>\n));\nSelectScrollDownButton.displayName =\n\tSelectPrimitive.ScrollDownButton.displayName;\n\n/**\n * SelectContent\n */\n\nconst SelectContent = forwardRef<\n\tComponentRef<typeof SelectPrimitive.Content>,\n\tComponentPropsWithoutRef<typeof SelectPrimitive.Content>\n>(({ className, children, position = \"popper\", ...props }, ref) => (\n\t<SelectPrimitive.Portal>\n\t\t<SelectPrimitive.Content\n\t\t\tref={ref}\n\t\t\tclassName={cn(\n\t\t\t\t\"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] origin-[--radix-select-content-transform-origin] overflow-y-auto overflow-x-hidden rounded-md border border-gray-400 bg-white text-gray-700 shadow-md data-[state=closed]:animate-fade-out data-[state=closed]:animate-out data-[state=open]:animate-fade-in data-[state=open]:animate-in\",\n\t\t\t\tposition === \"popper\" &&\n\t\t\t\t\t\"data-[side=left]:-translate-x-1 data-[side=top]:-translate-y-1 data-[side=right]:translate-x-1 data-[side=bottom]:translate-y-1\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\tposition={position}\n\t\t\t{...props}\n\t\t>\n\t\t\t<SelectScrollUpButton />\n\t\t\t<SelectPrimitive.Viewport\n\t\t\t\tclassName={cn(\n\t\t\t\t\t\"p-1\",\n\t\t\t\t\tposition === \"popper\" &&\n\t\t\t\t\t\t\"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]\",\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</SelectPrimitive.Viewport>\n\t\t\t<SelectScrollDownButton />\n\t\t</SelectPrimitive.Content>\n\t</SelectPrimitive.Portal>\n));\nSelectContent.displayName = SelectPrimitive.Content.displayName;\n\n/**\n * SelectLabel\n */\n\nconst SelectLabel = forwardRef<\n\tComponentRef<typeof SelectPrimitive.Label>,\n\tComponentPropsWithoutRef<typeof SelectPrimitive.Label>\n>(({ className, ...props }, ref) => (\n\t<SelectPrimitive.Label\n\t\tref={ref}\n\t\tclassName={cn(\"px-2 py-1.5 font-semibold text-sm\", className)}\n\t\t{...props}\n\t/>\n));\nSelectLabel.displayName = SelectPrimitive.Label.displayName;\n\n/**\n * SelectItem\n */\n\nconst SelectItem = forwardRef<\n\tComponentRef<typeof SelectPrimitive.Item>,\n\tComponentPropsWithoutRef<typeof SelectPrimitive.Item>\n>(({ className, children, ...props }, ref) => (\n\t<SelectPrimitive.Item\n\t\tref={ref}\n\t\tclassName={cn(\n\t\t\t\"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none focus-visible:bg-gray-700 focus-visible:text-white data-[disabled]:pointer-events-none data-[disabled]:opacity-50\",\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t>\n\t\t<span className=\"absolute right-2 flex h-3.5 w-3.5 items-center justify-center\">\n\t\t\t<SelectPrimitive.ItemIndicator>\n\t\t\t\t<Icon asChild size=\"small\">\n\t\t\t\t\t<CheckIcon />\n\t\t\t\t</Icon>\n\t\t\t</SelectPrimitive.ItemIndicator>\n\t\t</span>\n\t\t<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n\t</SelectPrimitive.Item>\n));\nSelectItem.displayName = SelectPrimitive.Item.displayName;\n\n/**\n * SelectSeparator\n */\n\nconst SelectSeparator = forwardRef<\n\tComponentRef<typeof SelectPrimitive.Separator>,\n\tComponentPropsWithoutRef<typeof SelectPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n\t<SelectPrimitive.Separator\n\t\tref={ref}\n\t\tclassName={cn(\"my-2 h-px bg-gray-200\", className)}\n\t\t{...props}\n\t/>\n));\nSelectSeparator.displayName = SelectPrimitive.Separator.displayName;\n\nexport {\n\tSelect,\n\tSelectGroup,\n\tSelectValue,\n\tSelectTrigger,\n\tSelectContent,\n\tSelectLabel,\n\tSelectItem,\n\tSelectSeparator,\n\tSelectScrollUpButton,\n\tSelectScrollDownButton,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"/","sources":["components/select/select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EACN,SAAS,EACT,eAAe,EACf,aAAa,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAStC,SAAS,MAAM,CAAC,EACf,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,eAAe,EACzB,GAAG,KAAK,EACK;IACb,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC;QAC7C,QAAQ,EAAE,eAAe;QACzB,QAAQ,EAAE,eAAe;KACzB,CAAC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C,IAAI,EAAC,OAAO,YACjB,KAAC,SAAS,KAAG,GACP,GACwB,GAC1B,EACP,KAAC,eAAe,CAAC,QAAQ,cAAE,QAAQ,GAA4B,IACzC,CACvB,CAAC;AACH,CAAC;AAUD,SAAS,eAAe,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,KAAK,EAAwB;IAC1E,OAAO,CACN,KAAC,eAAe,CAAC,SAAS,IACzB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,uBAAuB,EAAE,SAAS,CAAC,KAC7C,KAAK,GACR,CACF,CAAC;AACH,CAAC;AAED,OAAO,EACN,MAAM,EACN,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,WAAW,EACX,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,qBAAqB,GACrB,CAAC","sourcesContent":["import { Select as SelectPrimitive } from \"@base-ui/react/select\";\nimport { useFormContext } from \"@components/form-field/form-field-context\";\nimport { Icon } from \"@components/icon/icon\";\nimport {\n\tCheckIcon,\n\tChevronDownIcon,\n\tChevronUpIcon,\n} from \"@radix-ui/react-icons\";\nimport { cn } from \"@utilities/cn/cn\";\nimport type { ComponentProps } from \"react\";\n\n/**\n * Select\n */\n\nexport type SelectProps = ComponentProps<typeof SelectPrimitive.Root>;\n\nfunction Select({\n\tdisabled: initialDisabled,\n\trequired: initialRequired,\n\t...props\n}: SelectProps) {\n\tconst { disabled, required } = useFormContext({\n\t\tdisabled: initialDisabled,\n\t\trequired: initialRequired,\n\t});\n\treturn (\n\t\t<SelectPrimitive.Root disabled={disabled} required={required} {...props} />\n\t);\n}\n\n/**\n * SelectGroup\n */\n\nconst SelectGroup = SelectPrimitive.Group;\n\n/**\n * SelectValue\n */\n\nexport type SelectValueProps = ComponentProps<typeof SelectPrimitive.Value>;\n\nfunction SelectValue({ ref, ...props }: SelectValueProps) {\n\treturn <SelectPrimitive.Value ref={ref} {...props} />;\n}\n\n/**\n * SelectTrigger\n */\n\nexport type SelectTriggerProps = ComponentProps<typeof SelectPrimitive.Trigger>;\n\nfunction SelectTrigger({\n\tclassName,\n\tchildren,\n\tref,\n\t...props\n}: SelectTriggerProps) {\n\treturn (\n\t\t<SelectPrimitive.Trigger\n\t\t\tref={ref}\n\t\t\tclassName={cn(\n\t\t\t\t\"flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-gray-400 bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-placeholder:text-gray-500 [&>span]:line-clamp-1\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t>\n\t\t\t{children}\n\t\t\t<SelectPrimitive.Icon\n\t\t\t\trender={\n\t\t\t\t\t<Icon size=\"small\" className=\"opacity-50\">\n\t\t\t\t\t\t<ChevronDownIcon />\n\t\t\t\t\t</Icon>\n\t\t\t\t}\n\t\t\t/>\n\t\t</SelectPrimitive.Trigger>\n\t);\n}\n\n/**\n * SelectScrollUpArrow\n */\n\nexport type SelectScrollUpArrowProps = ComponentProps<\n\ttypeof SelectPrimitive.ScrollUpArrow\n>;\n\nfunction SelectScrollUpArrow({\n\tclassName,\n\tref,\n\t...props\n}: SelectScrollUpArrowProps) {\n\treturn (\n\t\t<SelectPrimitive.ScrollUpArrow\n\t\t\tref={ref}\n\t\t\tclassName={cn(\n\t\t\t\t\"flex cursor-default items-center justify-center py-1\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t>\n\t\t\t<Icon size=\"small\" className=\"opacity-50\">\n\t\t\t\t<ChevronUpIcon />\n\t\t\t</Icon>\n\t\t</SelectPrimitive.ScrollUpArrow>\n\t);\n}\n\n/**\n * SelectScrollDownArrow\n */\n\nexport type SelectScrollDownArrowProps = ComponentProps<\n\ttypeof SelectPrimitive.ScrollDownArrow\n>;\n\nfunction SelectScrollDownArrow({\n\tclassName,\n\tref,\n\t...props\n}: SelectScrollDownArrowProps) {\n\treturn (\n\t\t<SelectPrimitive.ScrollDownArrow\n\t\t\tref={ref}\n\t\t\tclassName={cn(\n\t\t\t\t\"flex cursor-default items-center justify-center py-1\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t>\n\t\t\t<Icon size=\"small\" className=\"opacity-50\">\n\t\t\t\t<ChevronDownIcon />\n\t\t\t</Icon>\n\t\t</SelectPrimitive.ScrollDownArrow>\n\t);\n}\n\n/**\n * SelectContent\n */\n\nexport type SelectContentProps = ComponentProps<\n\ttypeof SelectPrimitive.Popup\n> & {\n\tsideOffset?: number;\n};\n\nfunction SelectContent({\n\tclassName,\n\tchildren,\n\tsideOffset = 4,\n\tref,\n\t...props\n}: SelectContentProps) {\n\treturn (\n\t\t<SelectPrimitive.Portal>\n\t\t\t<SelectPrimitive.Positioner\n\t\t\t\tsideOffset={sideOffset}\n\t\t\t\talignItemWithTrigger={false}\n\t\t\t>\n\t\t\t\t<SelectScrollUpArrow />\n\t\t\t\t<SelectPrimitive.Popup\n\t\t\t\t\tref={ref}\n\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-closed:fade-out data-closed:zoom-out-95 data-open:fade-in data-open:zoom-in-95 relative z-50 max-h-(--available-height) min-w-32 origin-(--transform-origin) overflow-y-auto overflow-x-hidden rounded-md border border-gray-400 bg-white text-gray-700 shadow-md transition-all data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1 data-closed:animate-out data-open:animate-in\",\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t)}\n\t\t\t\t\t{...props}\n\t\t\t\t>\n\t\t\t\t\t<SelectPrimitive.List className=\"w-full min-w-(--anchor-width) p-1\">\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</SelectPrimitive.List>\n\t\t\t\t</SelectPrimitive.Popup>\n\t\t\t\t<SelectScrollDownArrow />\n\t\t\t</SelectPrimitive.Positioner>\n\t\t</SelectPrimitive.Portal>\n\t);\n}\n\n/**\n * SelectLabel\n */\n\nexport type SelectLabelProps = ComponentProps<\n\ttypeof SelectPrimitive.GroupLabel\n>;\n\nfunction SelectLabel({ className, ref, ...props }: SelectLabelProps) {\n\treturn (\n\t\t<SelectPrimitive.GroupLabel\n\t\t\tref={ref}\n\t\t\tclassName={cn(\"px-2 py-1.5 font-semibold text-sm\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\n/**\n * SelectItem\n */\n\nexport type SelectItemProps = ComponentProps<typeof SelectPrimitive.Item>;\n\nfunction SelectItem({ className, children, ref, ...props }: SelectItemProps) {\n\treturn (\n\t\t<SelectPrimitive.Item\n\t\t\tref={ref}\n\t\t\tclassName={cn(\n\t\t\t\t\"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none data-disabled:pointer-events-none data-highlighted:bg-gray-700 data-highlighted:text-white data-disabled:opacity-50\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t>\n\t\t\t<span className=\"absolute right-2 flex h-3.5 w-3.5 items-center justify-center\">\n\t\t\t\t<SelectPrimitive.ItemIndicator>\n\t\t\t\t\t<Icon size=\"small\">\n\t\t\t\t\t\t<CheckIcon />\n\t\t\t\t\t</Icon>\n\t\t\t\t</SelectPrimitive.ItemIndicator>\n\t\t\t</span>\n\t\t\t<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n\t\t</SelectPrimitive.Item>\n\t);\n}\n\n/**\n * SelectSeparator\n */\n\nexport type SelectSeparatorProps = ComponentProps<\n\ttypeof SelectPrimitive.Separator\n>;\n\nfunction SelectSeparator({ className, ref, ...props }: SelectSeparatorProps) {\n\treturn (\n\t\t<SelectPrimitive.Separator\n\t\t\tref={ref}\n\t\t\tclassName={cn(\"my-2 h-px bg-gray-200\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nexport {\n\tSelect,\n\tSelectGroup,\n\tSelectValue,\n\tSelectTrigger,\n\tSelectContent,\n\tSelectLabel,\n\tSelectItem,\n\tSelectSeparator,\n\tSelectScrollUpArrow,\n\tSelectScrollDownArrow,\n};\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
1
2
|
/**
|
|
2
3
|
* Skeleton
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
+
export type SkeletonProps = ComponentProps<"div">;
|
|
6
|
+
declare function Skeleton({ className, ref, ...props }: SkeletonProps): import("react/jsx-runtime").JSX.Element;
|
|
5
7
|
export { Skeleton };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../../utilities/cn/cn";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
const Skeleton = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("animate-pulse rounded-md bg-gray-200", className), ...props })));
|
|
8
|
-
Skeleton.displayName = "Skeleton";
|
|
3
|
+
function Skeleton({ className, ref, ...props }) {
|
|
4
|
+
return (_jsx("div", { ref: ref, className: cn("animate-pulse rounded-md bg-gray-200", className), ...props }));
|
|
5
|
+
}
|
|
9
6
|
export { Skeleton };
|
|
10
7
|
//# sourceMappingURL=skeleton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton.js","sourceRoot":"/","sources":["components/skeleton/skeleton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"skeleton.js","sourceRoot":"/","sources":["components/skeleton/skeleton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAStC,SAAS,QAAQ,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,KAAK,EAAiB;IAC5D,OAAO,CACN,cACC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,sCAAsC,EAAE,SAAS,CAAC,KAC5D,KAAK,GACR,CACF,CAAC;AACH,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import { cn } from \"@utilities/cn/cn\";\nimport type { ComponentProps } from \"react\";\n\n/**\n * Skeleton\n */\n\nexport type SkeletonProps = ComponentProps<\"div\">;\n\nfunction Skeleton({ className, ref, ...props }: SkeletonProps) {\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tclassName={cn(\"animate-pulse rounded-md bg-gray-200\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nexport { Skeleton };\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Slider as
|
|
2
|
-
import {
|
|
3
|
-
export type SliderProps =
|
|
1
|
+
import { Slider as SliderPrimitive } from "@base-ui/react/slider";
|
|
2
|
+
import type { ComponentProps } from "react";
|
|
3
|
+
export type SliderProps = ComponentProps<typeof SliderPrimitive.Root> & {
|
|
4
4
|
/**
|
|
5
5
|
* Whether to show the minimum and maximum values below the slider
|
|
6
6
|
* @default true
|
|
@@ -8,32 +8,25 @@ export type SliderProps = ComponentPropsWithoutRef<typeof RadixSlider.Root> & {
|
|
|
8
8
|
showMinMax?: boolean;
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
* A customizable slider component built on top of
|
|
11
|
+
* A customizable slider component built on top of Base UI's slider primitive.
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```tsx
|
|
15
15
|
* <Slider
|
|
16
16
|
* min={0}
|
|
17
17
|
* max={100}
|
|
18
|
-
* defaultValue={
|
|
18
|
+
* defaultValue={50}
|
|
19
19
|
* showMinMax={true}
|
|
20
20
|
* />
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
23
23
|
* @param {Object} props - The props for the Slider component
|
|
24
|
-
* @param {number[]} [props.defaultValue] - The initial value of the slider
|
|
24
|
+
* @param {number | number[]} [props.defaultValue] - The initial value of the slider
|
|
25
25
|
* @param {number} [props.min=0] - The minimum value of the slider
|
|
26
26
|
* @param {number} [props.max=100] - The maximum value of the slider
|
|
27
27
|
* @param {boolean} [props.showMinMax=true] - Whether to show min/max values below the slider
|
|
28
28
|
* @param {string} [props.className] - Additional CSS classes to apply to the slider
|
|
29
|
-
* @param {React.Ref<ComponentRef<typeof RadixSlider.Root>>} ref - Forwarded ref for the slider root element
|
|
30
29
|
* @returns {JSX.Element} A slider component with optional tooltips and min/max display
|
|
31
30
|
*/
|
|
32
|
-
declare
|
|
33
|
-
/**
|
|
34
|
-
* Whether to show the minimum and maximum values below the slider
|
|
35
|
-
* @default true
|
|
36
|
-
*/
|
|
37
|
-
showMinMax?: boolean;
|
|
38
|
-
} & import("react").RefAttributes<HTMLSpanElement>>;
|
|
31
|
+
declare function Slider({ className, defaultValue, min, max, showMinMax, disabled: initialDisabled, onValueChange, ref, ...props }: SliderProps): import("react/jsx-runtime").JSX.Element;
|
|
39
32
|
export { Slider };
|
|
@@ -1,40 +1,50 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Slider as SliderPrimitive } from "@base-ui/react/slider";
|
|
2
3
|
import { useFormContext } from "../form-field/form-field-context";
|
|
3
4
|
import { Tooltip, TooltipContent, TooltipTrigger, } from "../tooltip/tooltip";
|
|
4
5
|
import { cn } from "../../utilities/cn/cn";
|
|
5
|
-
import {
|
|
6
|
-
import { forwardRef, useState, } from "react";
|
|
6
|
+
import { useState } from "react";
|
|
7
7
|
/**
|
|
8
|
-
* A customizable slider component built on top of
|
|
8
|
+
* A customizable slider component built on top of Base UI's slider primitive.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* ```tsx
|
|
12
12
|
* <Slider
|
|
13
13
|
* min={0}
|
|
14
14
|
* max={100}
|
|
15
|
-
* defaultValue={
|
|
15
|
+
* defaultValue={50}
|
|
16
16
|
* showMinMax={true}
|
|
17
17
|
* />
|
|
18
18
|
* ```
|
|
19
19
|
*
|
|
20
20
|
* @param {Object} props - The props for the Slider component
|
|
21
|
-
* @param {number[]} [props.defaultValue] - The initial value of the slider
|
|
21
|
+
* @param {number | number[]} [props.defaultValue] - The initial value of the slider
|
|
22
22
|
* @param {number} [props.min=0] - The minimum value of the slider
|
|
23
23
|
* @param {number} [props.max=100] - The maximum value of the slider
|
|
24
24
|
* @param {boolean} [props.showMinMax=true] - Whether to show min/max values below the slider
|
|
25
25
|
* @param {string} [props.className] - Additional CSS classes to apply to the slider
|
|
26
|
-
* @param {React.Ref<ComponentRef<typeof RadixSlider.Root>>} ref - Forwarded ref for the slider root element
|
|
27
26
|
* @returns {JSX.Element} A slider component with optional tooltips and min/max display
|
|
28
27
|
*/
|
|
29
|
-
|
|
30
|
-
const
|
|
28
|
+
function Slider({ className, defaultValue, min = 0, max = 100, showMinMax = true, disabled: initialDisabled, onValueChange, ref, ...props }) {
|
|
29
|
+
const normalizedDefault = Array.isArray(defaultValue)
|
|
30
|
+
? defaultValue
|
|
31
|
+
: defaultValue !== undefined
|
|
32
|
+
? [defaultValue]
|
|
33
|
+
: [0];
|
|
34
|
+
const [value, setValue] = useState(normalizedDefault);
|
|
31
35
|
const { disabled } = useFormContext({
|
|
32
36
|
disabled: initialDisabled,
|
|
33
37
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
const handleValueChange = (newValue, event) => {
|
|
39
|
+
const normalizedValue = Array.isArray(newValue)
|
|
40
|
+
? [...newValue]
|
|
41
|
+
: [newValue];
|
|
42
|
+
setValue(normalizedValue);
|
|
43
|
+
onValueChange?.(newValue, event);
|
|
44
|
+
};
|
|
45
|
+
return (_jsxs(_Fragment, { children: [_jsx(SliderPrimitive.Root, { ref: ref, value: value, onValueChange: handleValueChange, className: cn("relative flex w-full touch-none select-none flex-col items-center", className), disabled: disabled, min: min, max: max, ...props, children: _jsx(SliderPrimitive.Control, { className: "flex w-full items-center", children: _jsxs(SliderPrimitive.Track, { className: "relative h-1.5 w-full grow rounded-full bg-gray-700/20 data-disabled:opacity-50", children: [_jsx(SliderPrimitive.Indicator, { className: "absolute h-full bg-gray-700" }), value.map((thumbValue, index) => (
|
|
46
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: index is the only stable identifier for thumbs
|
|
47
|
+
_jsxs(Tooltip, { delayDuration: 0, children: [_jsx(TooltipTrigger, { render: _jsx(SliderPrimitive.Thumb, { index: index, className: "block h-4 w-4 rounded-full border border-gray-700 bg-white shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-gray-700 data-disabled:pointer-events-none" }) }), _jsx(TooltipContent, { children: _jsx("p", { children: thumbValue }) })] }, index)))] }) }) }), showMinMax && (_jsxs("div", { className: "mt-2 flex w-full flex-row justify-between", children: [_jsx("p", { children: min }), _jsx("p", { children: max })] }))] }));
|
|
48
|
+
}
|
|
39
49
|
export { Slider };
|
|
40
50
|
//# sourceMappingURL=slider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider.js","sourceRoot":"/","sources":["components/slider/slider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EACN,OAAO,EACP,cAAc,EACd,cAAc,GACd,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"slider.js","sourceRoot":"/","sources":["components/slider/slider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EACN,OAAO,EACP,cAAc,E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ACD,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,KACJ,KAAK,YAET,KAAC,eAAe,CAAC,OAAO,IAAC,SAAS,EAAC,0BAA0B,YAC5D,MAAC,eAAe,CAAC,KAAK,IAAC,SAAS,EAAC,iFAAiF,aACjH,KAAC,eAAe,CAAC,SAAS,IAAC,SAAS,EAAC,6BAA6B,GAAG,EACpE,KAAK,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC;4BACjC,+FAA+F;4BAC/F,MAAC,OAAO,IAAa,aAAa,EAAE,CAAC,aACpC,KAAC,cAAc,IACd,MAAM,EACL,KAAC,eAAe,CAAC,KAAK,IACrB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAC,mMAAmM,GAC5M,GAEF,EACF,KAAC,cAAc,cACd,sBAAI,UAAU,GAAK,GACH,KAXJ,KAAK,CAYT,CACV,CAAC,IACqB,GACC,GACJ,EACtB,UAAU,IAAI,CACd,eAAK,SAAS,EAAC,2CAA2C,aACzD,sBAAI,GAAG,GAAK,EACZ,sBAAI,GAAG,GAAK,IACP,CACN,IACC,CACH,CAAC;AACH,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["import { Slider as SliderPrimitive } from \"@base-ui/react/slider\";\nimport { useFormContext } from \"@components/form-field/form-field-context\";\nimport {\n\tTooltip,\n\tTooltipContent,\n\tTooltipTrigger,\n} from \"@components/tooltip/tooltip\";\nimport { cn } from \"@utilities/cn/cn\";\nimport type { ComponentProps } from \"react\";\nimport { useState } from \"react\";\n\nexport type SliderProps = ComponentProps<typeof SliderPrimitive.Root> & {\n\t/**\n\t * Whether to show the minimum and maximum values below the slider\n\t * @default true\n\t */\n\tshowMinMax?: boolean;\n};\n\n/**\n * A customizable slider component built on top of Base UI's slider primitive.\n *\n * @example\n * ```tsx\n * <Slider\n * min={0}\n * max={100}\n * defaultValue={50}\n * showMinMax={true}\n * />\n * ```\n *\n * @param {Object} props - The props for the Slider component\n * @param {number | number[]} [props.defaultValue] - The initial value of the slider\n * @param {number} [props.min=0] - The minimum value of the slider\n * @param {number} [props.max=100] - The maximum value of the slider\n * @param {boolean} [props.showMinMax=true] - Whether to show min/max values below the slider\n * @param {string} [props.className] - Additional CSS classes to apply to the slider\n * @returns {JSX.Element} A slider component with optional tooltips and min/max display\n */\nfunction Slider({\n\tclassName,\n\tdefaultValue,\n\tmin = 0,\n\tmax = 100,\n\tshowMinMax = true,\n\tdisabled: initialDisabled,\n\tonValueChange,\n\tref,\n\t...props\n}: SliderProps) {\n\tconst normalizedDefault = Array.isArray(defaultValue)\n\t\t? defaultValue\n\t\t: defaultValue !== undefined\n\t\t\t? [defaultValue]\n\t\t\t: [0];\n\n\tconst [value, setValue] = useState<number[]>(normalizedDefault);\n\tconst { disabled } = useFormContext({\n\t\tdisabled: initialDisabled,\n\t});\n\n\tconst handleValueChange = (\n\t\tnewValue: number | readonly number[],\n\t\tevent: SliderPrimitive.Root.ChangeEventDetails,\n\t) => {\n\t\tconst normalizedValue = Array.isArray(newValue)\n\t\t\t? [...newValue]\n\t\t\t: [newValue];\n\t\tsetValue(normalizedValue);\n\t\tonValueChange?.(newValue, event);\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<SliderPrimitive.Root\n\t\t\t\tref={ref}\n\t\t\t\tvalue={value}\n\t\t\t\tonValueChange={handleValueChange}\n\t\t\t\tclassName={cn(\n\t\t\t\t\t\"relative flex w-full touch-none select-none flex-col items-center\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tdisabled={disabled}\n\t\t\t\tmin={min}\n\t\t\t\tmax={max}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t<SliderPrimitive.Control className=\"flex w-full items-center\">\n\t\t\t\t\t<SliderPrimitive.Track className=\"relative h-1.5 w-full grow rounded-full bg-gray-700/20 data-disabled:opacity-50\">\n\t\t\t\t\t\t<SliderPrimitive.Indicator className=\"absolute h-full bg-gray-700\" />\n\t\t\t\t\t\t{value.map((thumbValue, index) => (\n\t\t\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: index is the only stable identifier for thumbs\n\t\t\t\t\t\t\t<Tooltip key={index} delayDuration={0}>\n\t\t\t\t\t\t\t\t<TooltipTrigger\n\t\t\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t\t\t<SliderPrimitive.Thumb\n\t\t\t\t\t\t\t\t\t\t\tindex={index}\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block h-4 w-4 rounded-full border border-gray-700 bg-white shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-gray-700 data-disabled:pointer-events-none\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<TooltipContent>\n\t\t\t\t\t\t\t\t\t<p>{thumbValue}</p>\n\t\t\t\t\t\t\t\t</TooltipContent>\n\t\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</SliderPrimitive.Track>\n\t\t\t\t</SliderPrimitive.Control>\n\t\t\t</SliderPrimitive.Root>\n\t\t\t{showMinMax && (\n\t\t\t\t<div className=\"mt-2 flex w-full flex-row justify-between\">\n\t\t\t\t\t<p>{min}</p>\n\t\t\t\t\t<p>{max}</p>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</>\n\t);\n}\n\nexport { Slider };\n"]}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import { Switch as SwitchPrimitive } from "@base-ui/react/switch";
|
|
1
2
|
import type { ResponsiveValue } from "../../utilities/responsive/responsive";
|
|
2
|
-
import {
|
|
3
|
-
export type SwitchProps =
|
|
3
|
+
import type { Ref } from "react";
|
|
4
|
+
export type SwitchProps = Omit<SwitchPrimitive.Root.Props, "className"> & {
|
|
4
5
|
size?: ResponsiveValue<"small" | "medium" | "large">;
|
|
5
6
|
error?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
ref?: Ref<HTMLButtonElement>;
|
|
6
9
|
};
|
|
7
10
|
/**
|
|
8
11
|
* A switch component that toggles between on and off states.
|
|
9
|
-
* Built on top of
|
|
12
|
+
* Built on top of Base UI's Switch primitive.
|
|
10
13
|
*
|
|
11
14
|
* @param {SwitchProps} props - The props for the Switch component
|
|
12
15
|
* @param {ResponsiveValue<"small" | "medium" | "large">} [props.size="medium"] - The size of the switch
|
|
@@ -35,7 +38,4 @@ export type SwitchProps = RadixSwitch.SwitchProps & {
|
|
|
35
38
|
* @param {boolean} [props.disabled] - Whether the switch is disabled
|
|
36
39
|
* @param {string} [props.className] - Additional CSS classes to apply
|
|
37
40
|
*/
|
|
38
|
-
export declare
|
|
39
|
-
size?: ResponsiveValue<"small" | "medium" | "large">;
|
|
40
|
-
error?: boolean;
|
|
41
|
-
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
41
|
+
export declare function Switch({ className, disabled: initialDisabled, size, error: initialError, ref, ...props }: SwitchProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Switch as SwitchPrimitive } from "@base-ui/react/switch";
|
|
2
3
|
import { useFormContext } from "../form-field/form-field-context";
|
|
3
4
|
import { getVariants } from "../../utilities/responsive/responsive";
|
|
4
|
-
import { Switch as RadixSwitch } from "radix-ui";
|
|
5
|
-
import { forwardRef } from "react";
|
|
6
5
|
const thumbStyles = getVariants({
|
|
7
6
|
slots: {
|
|
8
|
-
root: "relative flex cursor-pointer appearance-none items-center rounded-full bg-gray-500 transition-colors duration-500 ease-out focus:outline-none focus-visible:ring-2 focus-visible:ring-light-blue-300 data-[
|
|
9
|
-
thumb: "absolute left-1 h-5 w-5 rounded-full transition-transform duration-500 ease-out data-[
|
|
7
|
+
root: "relative flex cursor-pointer appearance-none items-center rounded-full bg-gray-500 transition-colors duration-500 ease-out focus:outline-none focus-visible:ring-2 focus-visible:ring-light-blue-300 data-[checked]:bg-green-500",
|
|
8
|
+
thumb: "absolute left-1 h-5 w-5 rounded-full transition-transform duration-500 ease-out data-[checked]:translate-x-[1.125rem]",
|
|
10
9
|
},
|
|
11
10
|
variants: {
|
|
12
11
|
disabled: {
|
|
@@ -21,7 +20,7 @@ const thumbStyles = getVariants({
|
|
|
21
20
|
},
|
|
22
21
|
error: {
|
|
23
22
|
true: {
|
|
24
|
-
root: "bg-red-600 data-[
|
|
23
|
+
root: "bg-red-600 data-[checked]:bg-red-600",
|
|
25
24
|
thumb: "bg-red-600",
|
|
26
25
|
},
|
|
27
26
|
},
|
|
@@ -41,10 +40,10 @@ const thumbStyles = getVariants({
|
|
|
41
40
|
},
|
|
42
41
|
},
|
|
43
42
|
});
|
|
44
|
-
const { root, thumb } = thumbStyles;
|
|
43
|
+
const { root, thumb } = thumbStyles();
|
|
45
44
|
/**
|
|
46
45
|
* A switch component that toggles between on and off states.
|
|
47
|
-
* Built on top of
|
|
46
|
+
* Built on top of Base UI's Switch primitive.
|
|
48
47
|
*
|
|
49
48
|
* @param {SwitchProps} props - The props for the Switch component
|
|
50
49
|
* @param {ResponsiveValue<"small" | "medium" | "large">} [props.size="medium"] - The size of the switch
|
|
@@ -73,12 +72,11 @@ const { root, thumb } = thumbStyles;
|
|
|
73
72
|
* @param {boolean} [props.disabled] - Whether the switch is disabled
|
|
74
73
|
* @param {string} [props.className] - Additional CSS classes to apply
|
|
75
74
|
*/
|
|
76
|
-
export
|
|
75
|
+
export function Switch({ className, disabled: initialDisabled, size = "medium", error: initialError, ref, ...props }) {
|
|
77
76
|
const { disabled, error } = useFormContext({
|
|
78
77
|
disabled: initialDisabled,
|
|
79
78
|
error: initialError,
|
|
80
79
|
});
|
|
81
|
-
return (_jsx(
|
|
82
|
-
}
|
|
83
|
-
Switch.displayName = "Switch";
|
|
80
|
+
return (_jsx(SwitchPrimitive.Root, { className: root({ disabled, size, error, className }), disabled: disabled, ...props, ref: ref, children: _jsx(SwitchPrimitive.Thumb, { className: thumb({ disabled, size }) }) }));
|
|
81
|
+
}
|
|
84
82
|
//# sourceMappingURL=switch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.js","sourceRoot":"/","sources":["components/switch/switch.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"switch.js","sourceRoot":"/","sources":["components/switch/switch.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAU/D,MAAM,WAAW,GAAG,WAAW,CAAC;IAC/B,KAAK,EAAE;QACN,IAAI,EAAE,kOAAkO;QACxO,KAAK,EACJ,uHAAuH;KACxH;IACD,QAAQ,EAAE;QACT,QAAQ,EAAE;YACT,IAAI,EAAE;gBACL,IAAI,EAAE,+BAA+B;gBACrC,KAAK,EAAE,aAAa;aACpB;YACD,KAAK,EAAE;gBACN,IAAI,EAAE,4BAA4B;gBAClC,KAAK,EAAE,UAAU;aACjB;SACD;QACD,KAAK,EAAE;YACN,IAAI,EAAE;gBACL,IAAI,EAAE,sCAAsC;gBAC5C,KAAK,EAAE,YAAY;aACnB;SACD;QACD,IAAI,EAAE;YACL,KAAK,EAAE;gBACN,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,SAAS;aAChB;YACD,MAAM,EAAE;gBACP,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,SAAS;aAChB;YACD,KAAK,EAAE;gBACN,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,SAAS;aAChB;SACD;KACD;CACD,CAAC,CAAC;AAEH,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,WAAW,EAAE,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,MAAM,CAAC,EACtB,SAAS,EACT,QAAQ,EAAE,eAAe,EACzB,IAAI,GAAG,QAAQ,EACf,KAAK,EAAE,YAAY,EACnB,GAAG,EACH,GAAG,KAAK,EACK;IACb,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,cAAc,CAAC;QAC1C,QAAQ,EAAE,eAAe;QACzB,KAAK,EAAE,YAAY;KACnB,CAAC,CAAC;IACH,OAAO,CACN,KAAC,eAAe,CAAC,IAAI,IACpB,SAAS,EAAE,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EACrD,QAAQ,EAAE,QAAQ,KACd,KAAK,EACT,GAAG,EAAE,GAAG,YAER,KAAC,eAAe,CAAC,KAAK,IAAC,SAAS,EAAE,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,GAAI,GACzC,CACvB,CAAC;AACH,CAAC","sourcesContent":["import { Switch as SwitchPrimitive } from \"@base-ui/react/switch\";\nimport { useFormContext } from \"@components/form-field/form-field-context\";\nimport type { ResponsiveValue } from \"@utilities/responsive/responsive\";\nimport { getVariants } from \"@utilities/responsive/responsive\";\nimport type { Ref } from \"react\";\n\nexport type SwitchProps = Omit<SwitchPrimitive.Root.Props, \"className\"> & {\n\tsize?: ResponsiveValue<\"small\" | \"medium\" | \"large\">;\n\terror?: boolean;\n\tclassName?: string;\n\tref?: Ref<HTMLButtonElement>;\n};\n\nconst thumbStyles = getVariants({\n\tslots: {\n\t\troot: \"relative flex cursor-pointer appearance-none items-center rounded-full bg-gray-500 transition-colors duration-500 ease-out focus:outline-none focus-visible:ring-2 focus-visible:ring-light-blue-300 data-[checked]:bg-green-500\",\n\t\tthumb:\n\t\t\t\"absolute left-1 h-5 w-5 rounded-full transition-transform duration-500 ease-out data-[checked]:translate-x-[1.125rem]\",\n\t},\n\tvariants: {\n\t\tdisabled: {\n\t\t\ttrue: {\n\t\t\t\troot: \"cursor-not-allowed opacity-50\",\n\t\t\t\tthumb: \"bg-gray-300\",\n\t\t\t},\n\t\t\tfalse: {\n\t\t\t\troot: \"cursor-pointer opacity-100\",\n\t\t\t\tthumb: \"bg-white\",\n\t\t\t},\n\t\t},\n\t\terror: {\n\t\t\ttrue: {\n\t\t\t\troot: \"bg-red-600 data-[checked]:bg-red-600\",\n\t\t\t\tthumb: \"bg-red-600\",\n\t\t\t},\n\t\t},\n\t\tsize: {\n\t\t\tsmall: {\n\t\t\t\troot: \"h-5 w-10\",\n\t\t\t\tthumb: \"h-3 w-3\",\n\t\t\t},\n\t\t\tmedium: {\n\t\t\t\troot: \"h-7 w-12\",\n\t\t\t\tthumb: \"h-5 w-5\",\n\t\t\t},\n\t\t\tlarge: {\n\t\t\t\troot: \"h-9 w-14\",\n\t\t\t\tthumb: \"h-7 w-7\",\n\t\t\t},\n\t\t},\n\t},\n});\n\nconst { root, thumb } = thumbStyles();\n\n/**\n * A switch component that toggles between on and off states.\n * Built on top of Base UI's Switch primitive.\n *\n * @param {SwitchProps} props - The props for the Switch component\n * @param {ResponsiveValue<\"small\" | \"medium\" | \"large\">} [props.size=\"medium\"] - The size of the switch\n * @param {boolean} [props.disabled] - Whether the switch is disabled\n * @param {string} [props.className] - Additional CSS classes to apply\n *\n * @example\n * // Basic usage\n * <Switch />\n *\n * @example\n * // With different sizes\n * <Switch size=\"small\" />\n * <Switch size=\"medium\" />\n * <Switch size=\"large\" />\n *\n * @example\n * // Disabled state\n * <Switch disabled />\n *\n * @example\n * // With onChange handler\n * <Switch onCheckedChange={(checked) => console.log(checked)} />\n *\n * @param {ResponsiveValue<\"small\" | \"medium\" | \"large\">} [props.size=\"medium\"] - The size of the switch\n * @param {boolean} [props.disabled] - Whether the switch is disabled\n * @param {string} [props.className] - Additional CSS classes to apply\n */\nexport function Switch({\n\tclassName,\n\tdisabled: initialDisabled,\n\tsize = \"medium\",\n\terror: initialError,\n\tref,\n\t...props\n}: SwitchProps) {\n\tconst { disabled, error } = useFormContext({\n\t\tdisabled: initialDisabled,\n\t\terror: initialError,\n\t});\n\treturn (\n\t\t<SwitchPrimitive.Root\n\t\t\tclassName={root({ disabled, size, error, className })}\n\t\t\tdisabled={disabled}\n\t\t\t{...props}\n\t\t\tref={ref}\n\t\t>\n\t\t\t<SwitchPrimitive.Thumb className={thumb({ disabled, size })} />\n\t\t</SwitchPrimitive.Root>\n\t);\n}\n"]}
|
|
@@ -1,33 +1,42 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
1
2
|
/**
|
|
2
3
|
* Table
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
+
export type TableProps = ComponentProps<"table">;
|
|
6
|
+
declare function Table({ className, ref, ...props }: TableProps): import("react/jsx-runtime").JSX.Element;
|
|
5
7
|
/**
|
|
6
8
|
* TableHeader
|
|
7
9
|
*/
|
|
8
|
-
|
|
10
|
+
export type TableHeaderProps = ComponentProps<"thead">;
|
|
11
|
+
declare function TableHeader({ className, ref, ...props }: TableHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
9
12
|
/**
|
|
10
13
|
* TableBody
|
|
11
14
|
*/
|
|
12
|
-
|
|
15
|
+
export type TableBodyProps = ComponentProps<"tbody">;
|
|
16
|
+
declare function TableBody({ className, ref, ...props }: TableBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
13
17
|
/**
|
|
14
18
|
* TableFooter
|
|
15
19
|
*/
|
|
16
|
-
|
|
20
|
+
export type TableFooterProps = ComponentProps<"tfoot">;
|
|
21
|
+
declare function TableFooter({ className, ref, ...props }: TableFooterProps): import("react/jsx-runtime").JSX.Element;
|
|
17
22
|
/**
|
|
18
23
|
* TableRow
|
|
19
24
|
*/
|
|
20
|
-
|
|
25
|
+
export type TableRowProps = ComponentProps<"tr">;
|
|
26
|
+
declare function TableRow({ className, ref, ...props }: TableRowProps): import("react/jsx-runtime").JSX.Element;
|
|
21
27
|
/**
|
|
22
28
|
* TableHead
|
|
23
29
|
*/
|
|
24
|
-
|
|
30
|
+
export type TableHeadProps = ComponentProps<"th">;
|
|
31
|
+
declare function TableHead({ className, ref, ...props }: TableHeadProps): import("react/jsx-runtime").JSX.Element;
|
|
25
32
|
/**
|
|
26
33
|
* TableCell
|
|
27
34
|
*/
|
|
28
|
-
|
|
35
|
+
export type TableCellProps = ComponentProps<"td">;
|
|
36
|
+
declare function TableCell({ className, ref, ...props }: TableCellProps): import("react/jsx-runtime").JSX.Element;
|
|
29
37
|
/**
|
|
30
38
|
* TableCaption
|
|
31
39
|
*/
|
|
32
|
-
|
|
40
|
+
export type TableCaptionProps = ComponentProps<"caption">;
|
|
41
|
+
declare function TableCaption({ className, ref, ...props }: TableCaptionProps): import("react/jsx-runtime").JSX.Element;
|
|
33
42
|
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, };
|
|
@@ -1,45 +1,28 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../../utilities/cn/cn";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const TableRow = forwardRef(({ className, ...props }, ref) => (_jsx("tr", { ref: ref, className: cn("border-b transition-colors hover:bg-gray-400 hover:text-white data-[state=selected]:bg-gray-500 data-[state=selected]:text-white", className), ...props })));
|
|
28
|
-
TableRow.displayName = "TableRow";
|
|
29
|
-
/**
|
|
30
|
-
* TableHead
|
|
31
|
-
*/
|
|
32
|
-
const TableHead = forwardRef(({ className, ...props }, ref) => (_jsx("th", { ref: ref, className: cn("h-10 px-2 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className), ...props })));
|
|
33
|
-
TableHead.displayName = "TableHead";
|
|
34
|
-
/**
|
|
35
|
-
* TableCell
|
|
36
|
-
*/
|
|
37
|
-
const TableCell = forwardRef(({ className, ...props }, ref) => (_jsx("td", { ref: ref, className: cn("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className), ...props })));
|
|
38
|
-
TableCell.displayName = "TableCell";
|
|
39
|
-
/**
|
|
40
|
-
* TableCaption
|
|
41
|
-
*/
|
|
42
|
-
const TableCaption = forwardRef(({ className, ...props }, ref) => (_jsx("caption", { ref: ref, className: cn("mt-4 text-start text-gray-500 text-sm", className), ...props })));
|
|
43
|
-
TableCaption.displayName = "TableCaption";
|
|
3
|
+
function Table({ className, ref, ...props }) {
|
|
4
|
+
return (_jsx("div", { className: "relative w-full overflow-auto", children: _jsx("table", { ref: ref, className: cn("w-full caption-bottom text-sm", className), ...props }) }));
|
|
5
|
+
}
|
|
6
|
+
function TableHeader({ className, ref, ...props }) {
|
|
7
|
+
return (_jsx("thead", { ref: ref, className: cn("[&_tr]:border-b [&_tr]:bg-gray-700! [&_tr]:text-white [&_tr]:hover:bg-gray-700! [&_tr]:hover:text-white!", className), ...props }));
|
|
8
|
+
}
|
|
9
|
+
function TableBody({ className, ref, ...props }) {
|
|
10
|
+
return (_jsx("tbody", { ref: ref, className: cn("[&_tr:last-child]:border-0", className), ...props }));
|
|
11
|
+
}
|
|
12
|
+
function TableFooter({ className, ref, ...props }) {
|
|
13
|
+
return (_jsx("tfoot", { ref: ref, className: cn("border-t bg-gray-100 font-medium [&>tr]:bg-gray-100! [&>tr]:text-gray-700! [&>tr]:last:border-b-0", className), ...props }));
|
|
14
|
+
}
|
|
15
|
+
function TableRow({ className, ref, ...props }) {
|
|
16
|
+
return (_jsx("tr", { ref: ref, className: cn("border-b transition-colors hover:bg-gray-400 hover:text-white data-[state=selected]:bg-gray-500 data-[state=selected]:text-white", className), ...props }));
|
|
17
|
+
}
|
|
18
|
+
function TableHead({ className, ref, ...props }) {
|
|
19
|
+
return (_jsx("th", { ref: ref, className: cn("h-10 px-2 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className), ...props }));
|
|
20
|
+
}
|
|
21
|
+
function TableCell({ className, ref, ...props }) {
|
|
22
|
+
return (_jsx("td", { ref: ref, className: cn("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className), ...props }));
|
|
23
|
+
}
|
|
24
|
+
function TableCaption({ className, ref, ...props }) {
|
|
25
|
+
return (_jsx("caption", { ref: ref, className: cn("mt-4 text-start text-gray-500 text-sm", className), ...props }));
|
|
26
|
+
}
|
|
44
27
|
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, };
|
|
45
28
|
//# sourceMappingURL=table.js.map
|