linkedunion-design-kit 1.8.6 → 1.8.8
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/dist/src/components/Accordion/accordion.js +2 -2
- package/dist/src/components/ImageUploader/ImageUploader.stories.d.ts +2 -0
- package/dist/src/components/ImageUploader/ImageUploader.stories.js +28 -0
- package/dist/src/components/ImageUploader/imageUploader.d.ts +1 -1
- package/dist/src/components/ImageUploader/imageUploader.js +5 -1
- package/dist/src/components/ImageUploader/type.d.ts +1 -0
- package/dist/src/components/Tabs/tabs.js +1 -1
- package/dist/src/components/ui/accordion.d.ts +7 -0
- package/dist/src/components/ui/accordion.js +64 -0
- package/dist/src/components/ui/caption.d.ts +8 -0
- package/dist/src/components/ui/caption.js +34 -0
- package/dist/src/components/ui/checkbox.d.ts +4 -0
- package/dist/src/components/ui/checkbox.js +31 -0
- package/dist/src/components/ui/input.d.ts +3 -0
- package/dist/src/components/ui/input.js +29 -0
- package/dist/src/components/ui/switch.d.ts +22 -0
- package/dist/src/components/ui/switch.js +70 -0
- package/dist/styles/global.css +2 -2
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ function Accordion(_a) {
|
|
|
31
31
|
}
|
|
32
32
|
function AccordionItem(_a) {
|
|
33
33
|
var className = _a.className, props = __rest(_a, ["className"]);
|
|
34
|
-
return (_jsx(AccordionPrimitive.Item, __assign({ "data-slot": "accordion-item", className: cn("!py-
|
|
34
|
+
return (_jsx(AccordionPrimitive.Item, __assign({ "data-slot": "accordion-item", className: cn("!py-5 !border-b last:!border-b !border-gray-100", className) }, props)));
|
|
35
35
|
}
|
|
36
36
|
function AccordionTrigger(_a) {
|
|
37
37
|
var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
|
|
@@ -55,7 +55,7 @@ function AccordionTrigger(_a) {
|
|
|
55
55
|
}
|
|
56
56
|
return function () { return observer.disconnect(); };
|
|
57
57
|
}, []);
|
|
58
|
-
return (_jsx(AccordionPrimitive.Header, { className: "flex", children: _jsxs(AccordionPrimitive.Trigger, __assign({ ref: ref, "data-slot": "accordion-trigger", className: cn("flex items-center gap-2 cursor-pointer !text-sm !font-normal !leading-normal grow", className) }, props, { children: [_jsx(LUIcon, { color: "dark-gray", icon: isOpen ? "minus" : "plus", size: "md", className: "pointer-events-none shrink-0" }), children] })) }));
|
|
58
|
+
return (_jsx(AccordionPrimitive.Header, { className: "flex", children: _jsxs(AccordionPrimitive.Trigger, __assign({ ref: ref, "data-slot": "accordion-trigger", className: cn("flex items-center gap-2 cursor-pointer !text-sm !font-normal !leading-normal grow m-0", className) }, props, { children: [_jsx(LUIcon, { color: "dark-gray", icon: isOpen ? "minus" : "plus", size: "md", className: "pointer-events-none shrink-0" }), children] })) }));
|
|
59
59
|
}
|
|
60
60
|
function AccordionContent(_a) {
|
|
61
61
|
var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import ImageUploader from "./imageUploader";
|
|
2
|
+
import { Dummy_Image } from "../../utils/constants";
|
|
2
3
|
var meta = {
|
|
3
4
|
title: "Components/ImageUploader",
|
|
4
5
|
component: ImageUploader,
|
|
5
6
|
tags: ["autodocs"],
|
|
6
7
|
argTypes: {
|
|
7
8
|
onChange: { action: "changed" }, // For logging in the Storybook actions panel
|
|
9
|
+
onRemove: { action: "removed" }, // For logging removal actions
|
|
8
10
|
},
|
|
9
11
|
};
|
|
10
12
|
export default meta;
|
|
@@ -14,5 +16,31 @@ export var Default = {
|
|
|
14
16
|
onChange: function (previewUrl, file) {
|
|
15
17
|
console.log("Selected file:", file);
|
|
16
18
|
},
|
|
19
|
+
onRemove: function () {
|
|
20
|
+
console.log("Image removed");
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
export var WithRequired = {
|
|
25
|
+
args: {
|
|
26
|
+
value: null,
|
|
27
|
+
required: true,
|
|
28
|
+
onChange: function (previewUrl, file) {
|
|
29
|
+
console.log("Selected file:", file);
|
|
30
|
+
},
|
|
31
|
+
onRemove: function () {
|
|
32
|
+
console.log("Image removed from required uploader");
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
export var WithPreloadedImage = {
|
|
37
|
+
args: {
|
|
38
|
+
value: Dummy_Image,
|
|
39
|
+
onChange: function (previewUrl, file) {
|
|
40
|
+
console.log("Selected file:", file);
|
|
41
|
+
},
|
|
42
|
+
onRemove: function () {
|
|
43
|
+
console.log("Preloaded image removed");
|
|
44
|
+
},
|
|
17
45
|
},
|
|
18
46
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ImageUploaderProps } from "../ImageUploader/type";
|
|
2
|
-
declare const ImageUploader: ({ value, onChange, required, className, maxFileSizeMB, acceptedTypes, }: ImageUploaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const ImageUploader: ({ value, onChange, onRemove, required, className, maxFileSizeMB, acceptedTypes, }: ImageUploaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default ImageUploader;
|
|
@@ -19,7 +19,7 @@ import LuImage from "../Images/LuImage";
|
|
|
19
19
|
import { Body } from "../Typography/Body/body";
|
|
20
20
|
import { Button } from "../Button/Button";
|
|
21
21
|
var ImageUploader = function (_a) {
|
|
22
|
-
var value = _a.value, onChange = _a.onChange, required = _a.required, className = _a.className, _b = _a.maxFileSizeMB, maxFileSizeMB = _b === void 0 ? 6 : _b, _c = _a.acceptedTypes, acceptedTypes = _c === void 0 ? ["image/png", "image/jpeg", "image/jpg", "image/svg+xml"] : _c;
|
|
22
|
+
var value = _a.value, onChange = _a.onChange, onRemove = _a.onRemove, required = _a.required, className = _a.className, _b = _a.maxFileSizeMB, maxFileSizeMB = _b === void 0 ? 6 : _b, _c = _a.acceptedTypes, acceptedTypes = _c === void 0 ? ["image/png", "image/jpeg", "image/jpg", "image/svg+xml"] : _c;
|
|
23
23
|
var _d = useState(null), preview = _d[0], setPreview = _d[1];
|
|
24
24
|
var _e = useState(""), fileError = _e[0], setFileError = _e[1];
|
|
25
25
|
useEffect(function () {
|
|
@@ -55,6 +55,10 @@ var ImageUploader = function (_a) {
|
|
|
55
55
|
setPreview(null);
|
|
56
56
|
setFileError("");
|
|
57
57
|
onChange(null, null);
|
|
58
|
+
// If onRemove prop is provided, call it after internal cleanup
|
|
59
|
+
if (onRemove) {
|
|
60
|
+
onRemove();
|
|
61
|
+
}
|
|
58
62
|
};
|
|
59
63
|
var _f = useDropzone({
|
|
60
64
|
onDrop: onDrop,
|
|
@@ -26,7 +26,7 @@ import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
|
26
26
|
import { cn } from "../../lib/utils";
|
|
27
27
|
function Tabs(_a) {
|
|
28
28
|
var className = _a.className, props = __rest(_a, ["className"]);
|
|
29
|
-
return (_jsx(TabsPrimitive.Root, __assign({ "data-slot": "tabs", className: cn("flex flex-col gap-
|
|
29
|
+
return (_jsx(TabsPrimitive.Root, __assign({ "data-slot": "tabs", className: cn("flex flex-col gap-6", className) }, props)));
|
|
30
30
|
}
|
|
31
31
|
function TabsList(_a) {
|
|
32
32
|
var className = _a.className, props = __rest(_a, ["className"]);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
3
|
+
declare function Accordion({ ...props }: React.ComponentProps<typeof AccordionPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function AccordionItem({ className, ...props }: React.ComponentProps<typeof AccordionPrimitive.Item>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function AccordionTrigger({ className, children, ...props }: React.ComponentProps<typeof AccordionPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function AccordionContent({ className, children, ...props }: React.ComponentProps<typeof AccordionPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
import * as React from "react";
|
|
25
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
26
|
+
import { cn } from "../../lib/utils";
|
|
27
|
+
import LUIcon from "../Icons/LUIcon";
|
|
28
|
+
function Accordion(_a) {
|
|
29
|
+
var props = __rest(_a, []);
|
|
30
|
+
return _jsx(AccordionPrimitive.Root, __assign({ "data-slot": "accordion" }, props));
|
|
31
|
+
}
|
|
32
|
+
function AccordionItem(_a) {
|
|
33
|
+
var className = _a.className, props = __rest(_a, ["className"]);
|
|
34
|
+
return (_jsx(AccordionPrimitive.Item, __assign({ "data-slot": "accordion-item", className: cn("!py-5 !border-b last:!border-b !border-gray-100", className) }, props)));
|
|
35
|
+
}
|
|
36
|
+
function AccordionTrigger(_a) {
|
|
37
|
+
var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
|
|
38
|
+
var ref = React.useRef(null);
|
|
39
|
+
var _b = React.useState(false), isOpen = _b[0], setIsOpen = _b[1];
|
|
40
|
+
React.useEffect(function () {
|
|
41
|
+
var updateOpenState = function () {
|
|
42
|
+
if (ref.current) {
|
|
43
|
+
var state = ref.current.getAttribute("data-state");
|
|
44
|
+
setIsOpen(state === "open");
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
updateOpenState();
|
|
48
|
+
// Create a mutation observer to watch for attribute changes
|
|
49
|
+
var observer = new MutationObserver(updateOpenState);
|
|
50
|
+
if (ref.current) {
|
|
51
|
+
observer.observe(ref.current, {
|
|
52
|
+
attributes: true,
|
|
53
|
+
attributeFilter: ["data-state"],
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return function () { return observer.disconnect(); };
|
|
57
|
+
}, []);
|
|
58
|
+
return (_jsx(AccordionPrimitive.Header, { className: "flex", children: _jsxs(AccordionPrimitive.Trigger, __assign({ ref: ref, "data-slot": "accordion-trigger", className: cn("flex items-center gap-2 cursor-pointer !text-sm !font-normal !leading-normal grow m-0", className) }, props, { children: [_jsx(LUIcon, { color: "dark-gray", icon: isOpen ? "minus" : "plus", size: "md", className: "pointer-events-none shrink-0" }), children] })) }));
|
|
59
|
+
}
|
|
60
|
+
function AccordionContent(_a) {
|
|
61
|
+
var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
|
|
62
|
+
return (_jsx(AccordionPrimitive.Content, __assign({ "data-slot": "accordion-content", className: "data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down !overflow-visible !text-sm !py-2" }, props, { children: _jsx("div", { className: cn(className), children: children }) })));
|
|
63
|
+
}
|
|
64
|
+
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
type CaptionVariant = "sm" | "md" | "lg";
|
|
3
|
+
type CaptionProps = React.HTMLAttributes<HTMLTableCaptionElement> & {
|
|
4
|
+
variant?: CaptionVariant;
|
|
5
|
+
};
|
|
6
|
+
export declare const variantClasses: Record<CaptionVariant, string>;
|
|
7
|
+
declare function Caption({ className, children, variant, ...props }: CaptionProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export { Caption };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import { cn } from "../../lib/utils";
|
|
25
|
+
export var variantClasses = {
|
|
26
|
+
sm: "text-xs",
|
|
27
|
+
md: "text-sm",
|
|
28
|
+
lg: "text-base",
|
|
29
|
+
};
|
|
30
|
+
function Caption(_a) {
|
|
31
|
+
var className = _a.className, children = _a.children, _b = _a.variant, variant = _b === void 0 ? "md" : _b, props = __rest(_a, ["className", "children", "variant"]);
|
|
32
|
+
return (_jsx("p", __assign({ className: cn("!font-normal !leading-normal m-0 inline", variantClasses[variant], className) }, props, { children: children })));
|
|
33
|
+
}
|
|
34
|
+
export { Caption };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
25
|
+
import { CheckIcon } from "lucide-react";
|
|
26
|
+
import { cn } from "../../lib/utils";
|
|
27
|
+
function Checkbox(_a) {
|
|
28
|
+
var className = _a.className, props = __rest(_a, ["className"]);
|
|
29
|
+
return (_jsx(CheckboxPrimitive.Root, __assign({ "data-slot": "checkbox", className: cn("peer border-input dark:bg-input/30 data-[state=checked]:bg-blue-600 data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-blue-600 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4.5 shrink-0 !rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", className) }, props, { children: _jsx(CheckboxPrimitive.Indicator, { "data-slot": "checkbox-indicator", className: "flex items-center justify-center text-current transition-none", children: _jsx(CheckIcon, { className: "size-3.5" }) }) })));
|
|
30
|
+
}
|
|
31
|
+
export { Checkbox };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import { cn } from "../../lib/utils";
|
|
25
|
+
function Input(_a) {
|
|
26
|
+
var className = _a.className, type = _a.type, props = __rest(_a, ["className", "type"]);
|
|
27
|
+
return (_jsx("input", __assign({ type: type, "data-slot": "input", className: cn("file:text-foreground placeholder:text-muted-foreground rounded selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-11 w-full min-w-0 border bg-transparent !px-3 !py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "focus-visible:shadow-outline-primary focus-visible:outline-none", "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", className) }, props)));
|
|
28
|
+
}
|
|
29
|
+
export { Input };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
3
|
+
import { type VariantProps } from "class-variance-authority";
|
|
4
|
+
export declare const size: {
|
|
5
|
+
sm: string;
|
|
6
|
+
md: string;
|
|
7
|
+
lg: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const variant: {
|
|
10
|
+
default: string;
|
|
11
|
+
primary: string;
|
|
12
|
+
success: string;
|
|
13
|
+
danger: string;
|
|
14
|
+
};
|
|
15
|
+
declare const switchVariants: (props?: ({
|
|
16
|
+
size?: "sm" | "md" | "lg" | null | undefined;
|
|
17
|
+
variant?: "default" | "primary" | "success" | "danger" | null | undefined;
|
|
18
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
19
|
+
export interface SwitchProps extends React.ComponentPropsWithoutRef<typeof SwitchPrimitive.Root>, VariantProps<typeof switchVariants> {
|
|
20
|
+
}
|
|
21
|
+
declare function Switch({ className, size, variant, ...props }: SwitchProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export { Switch };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
25
|
+
import { cva } from "class-variance-authority";
|
|
26
|
+
import { cn } from "../../lib/utils";
|
|
27
|
+
export var size = {
|
|
28
|
+
sm: "h-4 w-6",
|
|
29
|
+
md: "w-12 h-6", // default
|
|
30
|
+
lg: "h-6 w-14",
|
|
31
|
+
};
|
|
32
|
+
export var variant = {
|
|
33
|
+
default: "data-[state=checked]:bg-blue-600 data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80 focus-visible:ring-ring/50 focus-visible:border-ring",
|
|
34
|
+
primary: "data-[state=checked]:bg-blue-600 data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80 focus-visible:ring-ring/50 focus-visible:border-ring",
|
|
35
|
+
success: "data-[state=checked]:bg-green-500 data-[state=unchecked]:bg-input focus-visible:ring-green-500",
|
|
36
|
+
danger: "data-[state=checked]:bg-red-500 data-[state=unchecked]:bg-input focus-visible:ring-red-500",
|
|
37
|
+
};
|
|
38
|
+
var switchVariants = cva("peer inline-flex shrink-0 items-center !rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", {
|
|
39
|
+
variants: {
|
|
40
|
+
size: size,
|
|
41
|
+
variant: variant,
|
|
42
|
+
},
|
|
43
|
+
defaultVariants: {
|
|
44
|
+
size: "md",
|
|
45
|
+
variant: "default",
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
var thumbVariants = cva("pointer-events-none block !rounded-full ring-0 transition-transform", {
|
|
49
|
+
variants: {
|
|
50
|
+
size: {
|
|
51
|
+
sm: "size-3",
|
|
52
|
+
md: "size-4", // default
|
|
53
|
+
lg: "size-5",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
defaultVariants: {
|
|
57
|
+
size: "md",
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
// Define translate distance for each size
|
|
61
|
+
var thumbTranslateVariants = {
|
|
62
|
+
sm: "data-[state=unchecked]:translate-x-0 data-[state=checked]:translate-x-2",
|
|
63
|
+
md: "data-[state=unchecked]:translate-x-0.5 data-[state=checked]:translate-x-7",
|
|
64
|
+
lg: "data-[state=unchecked]:translate-x-0.5 data-[state=checked]:translate-x-8",
|
|
65
|
+
};
|
|
66
|
+
function Switch(_a) {
|
|
67
|
+
var className = _a.className, size = _a.size, variant = _a.variant, props = __rest(_a, ["className", "size", "variant"]);
|
|
68
|
+
return (_jsx(SwitchPrimitive.Root, __assign({ "data-slot": "switch", className: cn(switchVariants({ size: size, variant: variant }), className) }, props, { children: _jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: cn(thumbVariants({ size: size }), size ? thumbTranslateVariants[size] : "", "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground") }) })));
|
|
69
|
+
}
|
|
70
|
+
export { Switch };
|
package/dist/styles/global.css
CHANGED
|
@@ -1168,8 +1168,8 @@
|
|
|
1168
1168
|
.\!py-3\.5 {
|
|
1169
1169
|
padding-block: calc(var(--spacing) * 3.5) !important;
|
|
1170
1170
|
}
|
|
1171
|
-
.\!py-
|
|
1172
|
-
padding-block: calc(var(--spacing) *
|
|
1171
|
+
.\!py-5 {
|
|
1172
|
+
padding-block: calc(var(--spacing) * 5) !important;
|
|
1173
1173
|
}
|
|
1174
1174
|
.py-2 {
|
|
1175
1175
|
padding-block: calc(var(--spacing) * 2);
|