@health-samurai/react-components 0.0.0-alpha.15 → 0.0.0-alpha.16
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/bundle.css +3 -0
- package/dist/src/shadcn/components/ui/switch.d.ts +3 -1
- package/dist/src/shadcn/components/ui/switch.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/switch.js +11 -2
- package/dist/src/shadcn/components/ui/switch.js.map +1 -1
- package/package.json +1 -1
- package/src/shadcn/components/ui/switch.tsx +19 -3
package/dist/bundle.css
CHANGED
|
@@ -4,6 +4,8 @@ import type * as React from "react";
|
|
|
4
4
|
declare const switchRootVariants: (props?: ({
|
|
5
5
|
size?: "small" | "regular" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
-
declare function Switch({ className, size, disabled, ...props }: React.ComponentProps<typeof SwitchPrimitive.Root> & VariantProps<typeof switchRootVariants>
|
|
7
|
+
declare function Switch({ className, size, disabled, locked, ...props }: React.ComponentProps<typeof SwitchPrimitive.Root> & VariantProps<typeof switchRootVariants> & {
|
|
8
|
+
locked?: boolean;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
10
|
export { Switch };
|
|
9
11
|
//# sourceMappingURL=switch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../../../src/shadcn/components/ui/switch.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../../../src/shadcn/components/ui/switch.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAiCpC,QAAA,MAAM,kBAAkB;;8EAUtB,CAAC;AA6BH,iBAAS,MAAM,CAAC,EACf,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,GAAG,KAAK,EACR,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,GACnD,YAAY,CAAC,OAAO,kBAAkB,CAAC,GAAG;IACzC,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,2CA0BD;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
4
4
|
import { cva } from "class-variance-authority";
|
|
5
|
+
import { Lock } from "lucide-react";
|
|
5
6
|
import { cn } from "../../lib/utils.js";
|
|
6
7
|
// Switch root base styles
|
|
7
8
|
const baseSwitchRootStyles = cn(// Layout
|
|
@@ -39,7 +40,7 @@ const switchThumbVariants = cva(baseSwitchThumbStyles, {
|
|
|
39
40
|
size: "regular"
|
|
40
41
|
}
|
|
41
42
|
});
|
|
42
|
-
function Switch({ className, size, disabled, ...props }) {
|
|
43
|
+
function Switch({ className, size, disabled, locked, ...props }) {
|
|
43
44
|
return /*#__PURE__*/ _jsx(SwitchPrimitive.Root, {
|
|
44
45
|
"data-slot": "switch",
|
|
45
46
|
className: cn(switchRootVariants({
|
|
@@ -49,8 +50,16 @@ function Switch({ className, size, disabled, ...props }) {
|
|
|
49
50
|
...props,
|
|
50
51
|
children: /*#__PURE__*/ _jsx(SwitchPrimitive.Thumb, {
|
|
51
52
|
"data-slot": "switch-thumb",
|
|
52
|
-
className: switchThumbVariants({
|
|
53
|
+
className: cn(switchThumbVariants({
|
|
53
54
|
size
|
|
55
|
+
}), locked && "flex items-center justify-center"),
|
|
56
|
+
children: locked && /*#__PURE__*/ _jsx(Lock, {
|
|
57
|
+
size: size === "small" ? 8 : 10,
|
|
58
|
+
strokeWidth: 2.5,
|
|
59
|
+
style: {
|
|
60
|
+
strokeWidth: 2.5
|
|
61
|
+
},
|
|
62
|
+
className: "text-neutral-600"
|
|
54
63
|
})
|
|
55
64
|
})
|
|
56
65
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/shadcn/components/ui/switch.tsx"],"sourcesContent":["\"use client\";\nimport * as SwitchPrimitive from \"@radix-ui/react-switch\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport type * as React from \"react\";\n\nimport { cn } from \"#shadcn/lib/utils\";\n\n// Switch root base styles\nconst baseSwitchRootStyles = cn(\n\t// Layout\n\t\"peer\",\n\t\"inline-flex\",\n\t\"items-center\",\n\t\"shrink-0\",\n\t// Shape\n\t\"rounded-full\",\n\t// Interaction\n\t\"transition-all\",\n\t\"outline-none\",\n\t\"cursor-pointer\",\n\t// States\n\t\"data-[state=unchecked]:bg-bg-secondary_inverse\",\n\t\"data-[state=checked]:bg-bg-link\",\n\t\"hover:data-[state=unchecked]:bg-bg-secondary_inverse_hover\",\n\t\"hover:data-[state=checked]:bg-bg-link_hover\",\n\t// Focus\n\t\"focus-visible:ring-4\",\n\t\"focus-visible:ring-ring-blue\",\n\t// Disabled\n\t\"disabled:cursor-not-allowed\",\n\t\"disabled:hover:data-[state=unchecked]:bg-bg-disabled\",\n\t\"disabled:hover:data-[state=checked]:bg-bg-link_disabled\",\n\t\"disabled:data-[state=checked]:bg-bg-link_disabled\",\n\t\"disabled:data-[state=unchecked]:bg-bg-disabled\",\n);\n\nconst switchRootVariants = cva(baseSwitchRootStyles, {\n\tvariants: {\n\t\tsize: {\n\t\t\tregular: cn(\"h-6\", \"w-10\"),\n\t\t\tsmall: cn(\"h-4\", \"w-7\"),\n\t\t},\n\t},\n\tdefaultVariants: {\n\t\tsize: \"regular\",\n\t},\n});\n\n// Switch thumb base styles\nconst baseSwitchThumbStyles = cn(\n\t// Layout\n\t\"pointer-events-none\",\n\t\"block\",\n\t// Shape\n\t\"rounded-full\",\n\t\"ring-0\",\n\t// Color\n\t\"bg-bg-primary\",\n\t// Animation\n\t\"transition-transform\",\n\t\"data-[state=unchecked]:translate-x-0.5\",\n);\n\nconst switchThumbVariants = cva(baseSwitchThumbStyles, {\n\tvariants: {\n\t\tsize: {\n\t\t\tregular: cn(\"size-5\", \"data-[state=checked]:translate-x-[1.125rem]\"),\n\t\t\tsmall: cn(\"size-3\", \"data-[state=checked]:translate-x-[0.875rem]\"),\n\t\t},\n\t},\n\tdefaultVariants: {\n\t\tsize: \"regular\",\n\t},\n});\n\nfunction Switch({\n\tclassName,\n\tsize,\n\tdisabled,\n\t...props\n}: React.ComponentProps<typeof SwitchPrimitive.Root> &\n\tVariantProps<typeof switchRootVariants>) {\n\treturn (\n\t\t<SwitchPrimitive.Root\n\t\t\tdata-slot=\"switch\"\n\t\t\tclassName={cn(switchRootVariants({ size }), className)}\n\t\t\tdisabled={disabled}\n\t\t\t{...props}\n\t\t>\n\t\t\t<SwitchPrimitive.Thumb\n\t\t\t\tdata-slot=\"switch-thumb\"\n\t\t\t\tclassName={
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shadcn/components/ui/switch.tsx"],"sourcesContent":["\"use client\";\nimport * as SwitchPrimitive from \"@radix-ui/react-switch\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { Lock } from \"lucide-react\";\nimport type * as React from \"react\";\n\nimport { cn } from \"#shadcn/lib/utils\";\n\n// Switch root base styles\nconst baseSwitchRootStyles = cn(\n\t// Layout\n\t\"peer\",\n\t\"inline-flex\",\n\t\"items-center\",\n\t\"shrink-0\",\n\t// Shape\n\t\"rounded-full\",\n\t// Interaction\n\t\"transition-all\",\n\t\"outline-none\",\n\t\"cursor-pointer\",\n\t// States\n\t\"data-[state=unchecked]:bg-bg-secondary_inverse\",\n\t\"data-[state=checked]:bg-bg-link\",\n\t\"hover:data-[state=unchecked]:bg-bg-secondary_inverse_hover\",\n\t\"hover:data-[state=checked]:bg-bg-link_hover\",\n\t// Focus\n\t\"focus-visible:ring-4\",\n\t\"focus-visible:ring-ring-blue\",\n\t// Disabled\n\t\"disabled:cursor-not-allowed\",\n\t\"disabled:hover:data-[state=unchecked]:bg-bg-disabled\",\n\t\"disabled:hover:data-[state=checked]:bg-bg-link_disabled\",\n\t\"disabled:data-[state=checked]:bg-bg-link_disabled\",\n\t\"disabled:data-[state=unchecked]:bg-bg-disabled\",\n);\n\nconst switchRootVariants = cva(baseSwitchRootStyles, {\n\tvariants: {\n\t\tsize: {\n\t\t\tregular: cn(\"h-6\", \"w-10\"),\n\t\t\tsmall: cn(\"h-4\", \"w-7\"),\n\t\t},\n\t},\n\tdefaultVariants: {\n\t\tsize: \"regular\",\n\t},\n});\n\n// Switch thumb base styles\nconst baseSwitchThumbStyles = cn(\n\t// Layout\n\t\"pointer-events-none\",\n\t\"block\",\n\t// Shape\n\t\"rounded-full\",\n\t\"ring-0\",\n\t// Color\n\t\"bg-bg-primary\",\n\t// Animation\n\t\"transition-transform\",\n\t\"data-[state=unchecked]:translate-x-0.5\",\n);\n\nconst switchThumbVariants = cva(baseSwitchThumbStyles, {\n\tvariants: {\n\t\tsize: {\n\t\t\tregular: cn(\"size-5\", \"data-[state=checked]:translate-x-[1.125rem]\"),\n\t\t\tsmall: cn(\"size-3\", \"data-[state=checked]:translate-x-[0.875rem]\"),\n\t\t},\n\t},\n\tdefaultVariants: {\n\t\tsize: \"regular\",\n\t},\n});\n\nfunction Switch({\n\tclassName,\n\tsize,\n\tdisabled,\n\tlocked,\n\t...props\n}: React.ComponentProps<typeof SwitchPrimitive.Root> &\n\tVariantProps<typeof switchRootVariants> & {\n\t\tlocked?: boolean;\n\t}) {\n\treturn (\n\t\t<SwitchPrimitive.Root\n\t\t\tdata-slot=\"switch\"\n\t\t\tclassName={cn(switchRootVariants({ size }), className)}\n\t\t\tdisabled={disabled}\n\t\t\t{...props}\n\t\t>\n\t\t\t<SwitchPrimitive.Thumb\n\t\t\t\tdata-slot=\"switch-thumb\"\n\t\t\t\tclassName={cn(\n\t\t\t\t\tswitchThumbVariants({ size }),\n\t\t\t\t\tlocked && \"flex items-center justify-center\",\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{locked && (\n\t\t\t\t\t<Lock\n\t\t\t\t\t\tsize={size === \"small\" ? 8 : 10}\n\t\t\t\t\t\tstrokeWidth={2.5}\n\t\t\t\t\t\tstyle={{ strokeWidth: 2.5 }}\n\t\t\t\t\t\tclassName=\"text-neutral-600\"\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</SwitchPrimitive.Thumb>\n\t\t</SwitchPrimitive.Root>\n\t);\n}\n\nexport { Switch };\n"],"names":["SwitchPrimitive","cva","Lock","cn","baseSwitchRootStyles","switchRootVariants","variants","size","regular","small","defaultVariants","baseSwitchThumbStyles","switchThumbVariants","Switch","className","disabled","locked","props","Root","data-slot","Thumb","strokeWidth","style"],"mappings":"AAAA;;AACA,YAAYA,qBAAqB,yBAAyB;AAC1D,SAASC,GAAG,QAA2B,2BAA2B;AAClE,SAASC,IAAI,QAAQ,eAAe;AAGpC,SAASC,EAAE,QAAQ,qBAAoB;AAEvC,0BAA0B;AAC1B,MAAMC,uBAAuBD,GAC5B,SAAS;AACT,QACA,eACA,gBACA,YACA,QAAQ;AACR,gBACA,cAAc;AACd,kBACA,gBACA,kBACA,SAAS;AACT,kDACA,mCACA,8DACA,+CACA,QAAQ;AACR,wBACA,gCACA,WAAW;AACX,+BACA,wDACA,2DACA,qDACA;AAGD,MAAME,qBAAqBJ,IAAIG,sBAAsB;IACpDE,UAAU;QACTC,MAAM;YACLC,SAASL,GAAG,OAAO;YACnBM,OAAON,GAAG,OAAO;QAClB;IACD;IACAO,iBAAiB;QAChBH,MAAM;IACP;AACD;AAEA,2BAA2B;AAC3B,MAAMI,wBAAwBR,GAC7B,SAAS;AACT,uBACA,SACA,QAAQ;AACR,gBACA,UACA,QAAQ;AACR,iBACA,YAAY;AACZ,wBACA;AAGD,MAAMS,sBAAsBX,IAAIU,uBAAuB;IACtDL,UAAU;QACTC,MAAM;YACLC,SAASL,GAAG,UAAU;YACtBM,OAAON,GAAG,UAAU;QACrB;IACD;IACAO,iBAAiB;QAChBH,MAAM;IACP;AACD;AAEA,SAASM,OAAO,EACfC,SAAS,EACTP,IAAI,EACJQ,QAAQ,EACRC,MAAM,EACN,GAAGC,OAIF;IACD,qBACC,KAACjB,gBAAgBkB,IAAI;QACpBC,aAAU;QACVL,WAAWX,GAAGE,mBAAmB;YAAEE;QAAK,IAAIO;QAC5CC,UAAUA;QACT,GAAGE,KAAK;kBAET,cAAA,KAACjB,gBAAgBoB,KAAK;YACrBD,aAAU;YACVL,WAAWX,GACVS,oBAAoB;gBAAEL;YAAK,IAC3BS,UAAU;sBAGVA,wBACA,KAACd;gBACAK,MAAMA,SAAS,UAAU,IAAI;gBAC7Bc,aAAa;gBACbC,OAAO;oBAAED,aAAa;gBAAI;gBAC1BP,WAAU;;;;AAMhB;AAEA,SAASD,MAAM,GAAG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
3
3
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
4
|
+
import { Lock } from "lucide-react";
|
|
4
5
|
import type * as React from "react";
|
|
5
6
|
|
|
6
7
|
import { cn } from "#shadcn/lib/utils";
|
|
@@ -77,9 +78,12 @@ function Switch({
|
|
|
77
78
|
className,
|
|
78
79
|
size,
|
|
79
80
|
disabled,
|
|
81
|
+
locked,
|
|
80
82
|
...props
|
|
81
83
|
}: React.ComponentProps<typeof SwitchPrimitive.Root> &
|
|
82
|
-
VariantProps<typeof switchRootVariants>
|
|
84
|
+
VariantProps<typeof switchRootVariants> & {
|
|
85
|
+
locked?: boolean;
|
|
86
|
+
}) {
|
|
83
87
|
return (
|
|
84
88
|
<SwitchPrimitive.Root
|
|
85
89
|
data-slot="switch"
|
|
@@ -89,8 +93,20 @@ function Switch({
|
|
|
89
93
|
>
|
|
90
94
|
<SwitchPrimitive.Thumb
|
|
91
95
|
data-slot="switch-thumb"
|
|
92
|
-
className={
|
|
93
|
-
|
|
96
|
+
className={cn(
|
|
97
|
+
switchThumbVariants({ size }),
|
|
98
|
+
locked && "flex items-center justify-center",
|
|
99
|
+
)}
|
|
100
|
+
>
|
|
101
|
+
{locked && (
|
|
102
|
+
<Lock
|
|
103
|
+
size={size === "small" ? 8 : 10}
|
|
104
|
+
strokeWidth={2.5}
|
|
105
|
+
style={{ strokeWidth: 2.5 }}
|
|
106
|
+
className="text-neutral-600"
|
|
107
|
+
/>
|
|
108
|
+
)}
|
|
109
|
+
</SwitchPrimitive.Thumb>
|
|
94
110
|
</SwitchPrimitive.Root>
|
|
95
111
|
);
|
|
96
112
|
}
|