jenosize-ui 0.1.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/LICENSE +28 -0
- package/README.md +100 -0
- package/THIRD-PARTY-NOTICES.md +163 -0
- package/dist/Button-Bt7pzM4R.d.ts +82 -0
- package/dist/PaymentInput-CKPIPNWH.d.ts +141 -0
- package/dist/Select-CVbEQ2Ep.d.ts +118 -0
- package/dist/TagInput-CTJYOB4J.d.ts +90 -0
- package/dist/avatar.d.ts +161 -0
- package/dist/avatar.js +11 -0
- package/dist/badge.d.ts +109 -0
- package/dist/badge.js +10 -0
- package/dist/breadcrumb.d.ts +58 -0
- package/dist/breadcrumb.js +7 -0
- package/dist/button.d.ts +54 -0
- package/dist/button.js +14 -0
- package/dist/calendar.d.ts +368 -0
- package/dist/calendar.js +21 -0
- package/dist/callout.d.ts +70 -0
- package/dist/callout.js +16 -0
- package/dist/card-nWicloNi.d.ts +80 -0
- package/dist/card.d.ts +2 -0
- package/dist/card.js +7 -0
- package/dist/checkbox.d.ts +133 -0
- package/dist/checkbox.js +11 -0
- package/dist/chunk-24TO7E32.js +42 -0
- package/dist/chunk-3Y5X7B5C.js +146 -0
- package/dist/chunk-4OLULPQG.js +202 -0
- package/dist/chunk-4P2NBLBW.js +103 -0
- package/dist/chunk-52IFGFTL.js +11 -0
- package/dist/chunk-5FATN5YD.js +115 -0
- package/dist/chunk-5NOBSXJN.js +297 -0
- package/dist/chunk-5RAPA22E.js +106 -0
- package/dist/chunk-7EUAMHMU.js +16 -0
- package/dist/chunk-7EWQKTNQ.js +1336 -0
- package/dist/chunk-7HOIZ3UO.js +110 -0
- package/dist/chunk-7IU5TMFL.js +452 -0
- package/dist/chunk-7JBNLEJ7.js +29 -0
- package/dist/chunk-7S2TBALK.js +23 -0
- package/dist/chunk-BJUZVYQC.js +188 -0
- package/dist/chunk-BVJWBYIG.js +66 -0
- package/dist/chunk-CME4DIML.js +65 -0
- package/dist/chunk-CYPPEUX5.js +73 -0
- package/dist/chunk-D5BTFSL7.js +71 -0
- package/dist/chunk-D6TPWNRK.js +387 -0
- package/dist/chunk-DJSXIAFH.js +66 -0
- package/dist/chunk-DRZCJCBO.js +46 -0
- package/dist/chunk-DWKILXHE.js +17 -0
- package/dist/chunk-E7ZSWBAK.js +70 -0
- package/dist/chunk-EDSK6FEH.js +8 -0
- package/dist/chunk-F2K7VJUV.js +114 -0
- package/dist/chunk-F6NLE6XJ.js +40 -0
- package/dist/chunk-FHHAPGCR.js +32 -0
- package/dist/chunk-FXIBGTS5.js +14 -0
- package/dist/chunk-GCVA3OIV.js +72 -0
- package/dist/chunk-GFOAJVW5.js +336 -0
- package/dist/chunk-GRLSUQQE.js +136 -0
- package/dist/chunk-GTHJWR3Q.js +77 -0
- package/dist/chunk-HMUZE6EK.js +67 -0
- package/dist/chunk-I7WU4GTY.js +503 -0
- package/dist/chunk-J2BCKBHC.js +151 -0
- package/dist/chunk-J36M3KRX.js +1315 -0
- package/dist/chunk-J7ZQQFPT.js +113 -0
- package/dist/chunk-JP26LPCY.js +234 -0
- package/dist/chunk-JTNFJLIY.js +1046 -0
- package/dist/chunk-JVJRHBTD.js +50 -0
- package/dist/chunk-JYGR44ZC.js +133 -0
- package/dist/chunk-KDLPXXD2.js +173 -0
- package/dist/chunk-KMSYEE23.js +224 -0
- package/dist/chunk-KNYKWUYX.js +52 -0
- package/dist/chunk-LME57Z6J.js +138 -0
- package/dist/chunk-MFJP5FA7.js +20 -0
- package/dist/chunk-MKC5HNA7.js +1692 -0
- package/dist/chunk-MQGD2OUF.js +39 -0
- package/dist/chunk-MUFHLP4S.js +566 -0
- package/dist/chunk-O2LG3PNI.js +74 -0
- package/dist/chunk-O4GRKO3I.js +66 -0
- package/dist/chunk-OHUFNYGN.js +791 -0
- package/dist/chunk-PWKWNDBS.js +243 -0
- package/dist/chunk-QA74ITR4.js +103 -0
- package/dist/chunk-R6RGJF4L.js +170 -0
- package/dist/chunk-S7NNXWIN.js +7 -0
- package/dist/chunk-SV56BSUQ.js +162 -0
- package/dist/chunk-T7FCG7XV.js +435 -0
- package/dist/chunk-THC2ISYP.js +57 -0
- package/dist/chunk-VWC72TR3.js +115 -0
- package/dist/chunk-W46K56XU.js +216 -0
- package/dist/chunk-W5GGOUUI.js +75 -0
- package/dist/chunk-WEUJYDCV.js +269 -0
- package/dist/chunk-WFY7DKQD.js +279 -0
- package/dist/chunk-WZQFC7ZN.js +448 -0
- package/dist/chunk-Z3ETJN5G.js +136 -0
- package/dist/chunk-ZOOX3TUB.js +192 -0
- package/dist/chunk-ZSNJ6UA3.js +42 -0
- package/dist/chunk-ZZA2LUTL.js +130 -0
- package/dist/chunk-ZZT2E5VT.js +24 -0
- package/dist/color-CtSxc1Rh.d.ts +6 -0
- package/dist/combobox.d.ts +184 -0
- package/dist/combobox.js +21 -0
- package/dist/date-input.d.ts +83 -0
- package/dist/date-input.js +16 -0
- package/dist/date-picker.d.ts +249 -0
- package/dist/date-picker.js +29 -0
- package/dist/date-utils-7hTFTXNK.d.ts +34 -0
- package/dist/date-vMJBKAFK.d.ts +22 -0
- package/dist/dialog.d.ts +86 -0
- package/dist/dialog.js +15 -0
- package/dist/drawer.d.ts +77 -0
- package/dist/drawer.js +14 -0
- package/dist/dropdown-menu.d.ts +218 -0
- package/dist/dropdown-menu.js +10 -0
- package/dist/file-trigger.d.ts +42 -0
- package/dist/file-trigger.js +3 -0
- package/dist/form.d.ts +487 -0
- package/dist/form.js +1179 -0
- package/dist/header-navigation.d.ts +74 -0
- package/dist/header-navigation.js +23 -0
- package/dist/icons/app.d.ts +48 -0
- package/dist/icons/app.js +282 -0
- package/dist/icons/flag.d.ts +817 -0
- package/dist/icons/flag.js +58336 -0
- package/dist/icons/integration.d.ts +36 -0
- package/dist/icons/integration.js +531 -0
- package/dist/icons/payment.d.ts +116 -0
- package/dist/icons/payment.js +2418 -0
- package/dist/icons.d.ts +2013 -0
- package/dist/icons.js +2012 -0
- package/dist/illustration.d.ts +48 -0
- package/dist/illustration.js +4 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.js +73 -0
- package/dist/indicator.d.ts +51 -0
- package/dist/indicator.js +7 -0
- package/dist/input.d.ts +66 -0
- package/dist/input.js +15 -0
- package/dist/multi-value-CJb_tnvi.d.ts +8 -0
- package/dist/nav-Bla0o_-1.d.ts +98 -0
- package/dist/number-input.d.ts +80 -0
- package/dist/number-input.js +15 -0
- package/dist/options-CPEIgjtd.d.ts +68 -0
- package/dist/overflow-Df0h42Oi.d.ts +29 -0
- package/dist/pagination.d.ts +77 -0
- package/dist/pagination.js +17 -0
- package/dist/payment-input.d.ts +7 -0
- package/dist/payment-input.js +15 -0
- package/dist/popover.d.ts +60 -0
- package/dist/popover.js +14 -0
- package/dist/progress.d.ts +87 -0
- package/dist/progress.js +5 -0
- package/dist/radio.d.ts +77 -0
- package/dist/radio.js +12 -0
- package/dist/select.d.ts +68 -0
- package/dist/select.js +24 -0
- package/dist/shared-BNXAdgh2.d.ts +9 -0
- package/dist/shared-BYXJPnsN.d.ts +11 -0
- package/dist/shared-Dc-GgA16.d.ts +42 -0
- package/dist/sidebar-navigation.d.ts +129 -0
- package/dist/sidebar-navigation.js +15 -0
- package/dist/styles.css +2 -0
- package/dist/switch.d.ts +23 -0
- package/dist/switch.js +7 -0
- package/dist/table.d.ts +692 -0
- package/dist/table.js +44 -0
- package/dist/tabs.d.ts +111 -0
- package/dist/tabs.js +8 -0
- package/dist/tag-input.d.ts +12 -0
- package/dist/tag-input.js +19 -0
- package/dist/tag.d.ts +98 -0
- package/dist/tag.js +9 -0
- package/dist/textarea.d.ts +40 -0
- package/dist/textarea.js +12 -0
- package/dist/theme-script.d.ts +29 -0
- package/dist/theme-script.js +15 -0
- package/dist/theme.css +929 -0
- package/dist/theme.d.ts +71 -0
- package/dist/theme.js +15 -0
- package/dist/toast.d.ts +242 -0
- package/dist/toast.js +15 -0
- package/dist/tooltip.d.ts +70 -0
- package/dist/tooltip.js +6 -0
- package/dist/tree.d.ts +308 -0
- package/dist/tree.js +11 -0
- package/package.json +352 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { Button } from './chunk-W46K56XU.js';
|
|
2
|
+
import { MoonIcon, SunIcon } from './chunk-24TO7E32.js';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var ThemeContext = React.createContext(null);
|
|
7
|
+
var THEMES = /* @__PURE__ */ new Set(["light", "dark", "system"]);
|
|
8
|
+
function readSystemTheme() {
|
|
9
|
+
try {
|
|
10
|
+
return globalThis.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
11
|
+
} catch {
|
|
12
|
+
return "light";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function readStoredTheme(storageKey, fallback) {
|
|
16
|
+
if (typeof window === "undefined") return fallback;
|
|
17
|
+
try {
|
|
18
|
+
const stored = localStorage.getItem(storageKey);
|
|
19
|
+
if (stored && THEMES.has(stored)) return stored;
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
return fallback;
|
|
23
|
+
}
|
|
24
|
+
function applyTheme(resolvedTheme) {
|
|
25
|
+
const el = document.documentElement;
|
|
26
|
+
const wantDark = resolvedTheme === "dark";
|
|
27
|
+
const alreadyApplied = el.classList.contains("dark") === wantDark && el.style.colorScheme === resolvedTheme;
|
|
28
|
+
if (alreadyApplied) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const style = document.createElement("style");
|
|
32
|
+
style.append(document.createTextNode("*,*::before,*::after{transition:none !important}"));
|
|
33
|
+
document.head.append(style);
|
|
34
|
+
el.classList.toggle("dark", resolvedTheme === "dark");
|
|
35
|
+
el.style.colorScheme = resolvedTheme;
|
|
36
|
+
void globalThis.getComputedStyle(document.body).transitionProperty;
|
|
37
|
+
globalThis.setTimeout(() => style.remove(), 0);
|
|
38
|
+
}
|
|
39
|
+
function ThemeProvider(props) {
|
|
40
|
+
const { defaultTheme = "system", storageKey = "jz-theme", children } = props;
|
|
41
|
+
const [theme, setThemeState] = React.useState(() => readStoredTheme(storageKey, defaultTheme));
|
|
42
|
+
const [systemTheme, setSystemTheme] = React.useState(() => typeof window === "undefined" ? "light" : readSystemTheme());
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
setSystemTheme(readSystemTheme());
|
|
45
|
+
try {
|
|
46
|
+
const stored = localStorage.getItem(storageKey);
|
|
47
|
+
if (stored && THEMES.has(stored)) setThemeState(stored);
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
}, [storageKey]);
|
|
51
|
+
React.useEffect(() => {
|
|
52
|
+
let mq;
|
|
53
|
+
try {
|
|
54
|
+
mq = globalThis.matchMedia("(prefers-color-scheme: dark)");
|
|
55
|
+
} catch {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const onChange = () => setSystemTheme(mq.matches ? "dark" : "light");
|
|
59
|
+
mq.addEventListener("change", onChange);
|
|
60
|
+
return () => mq.removeEventListener("change", onChange);
|
|
61
|
+
}, []);
|
|
62
|
+
React.useEffect(() => {
|
|
63
|
+
const onStorage = (event) => {
|
|
64
|
+
if (event.key === storageKey && event.newValue && THEMES.has(event.newValue)) {
|
|
65
|
+
setThemeState(event.newValue);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
globalThis.addEventListener("storage", onStorage);
|
|
69
|
+
return () => globalThis.removeEventListener("storage", onStorage);
|
|
70
|
+
}, [storageKey]);
|
|
71
|
+
const resolvedTheme = theme === "system" ? systemTheme : theme;
|
|
72
|
+
React.useEffect(() => {
|
|
73
|
+
applyTheme(resolvedTheme);
|
|
74
|
+
}, [resolvedTheme]);
|
|
75
|
+
const setTheme = React.useCallback(
|
|
76
|
+
(next) => {
|
|
77
|
+
setThemeState(next);
|
|
78
|
+
try {
|
|
79
|
+
localStorage.setItem(storageKey, next);
|
|
80
|
+
} catch {
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
[storageKey]
|
|
84
|
+
);
|
|
85
|
+
const toggle = React.useCallback(() => {
|
|
86
|
+
setTheme(resolvedTheme === "dark" ? "light" : "dark");
|
|
87
|
+
}, [resolvedTheme, setTheme]);
|
|
88
|
+
const value = React.useMemo(
|
|
89
|
+
() => ({ theme, resolvedTheme, systemTheme, setTheme, toggle }),
|
|
90
|
+
[theme, resolvedTheme, systemTheme, setTheme, toggle]
|
|
91
|
+
);
|
|
92
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children });
|
|
93
|
+
}
|
|
94
|
+
function useTheme() {
|
|
95
|
+
const ctx = React.useContext(ThemeContext);
|
|
96
|
+
if (!ctx) {
|
|
97
|
+
throw new Error("[jenosize-ui] useTheme must be used within <ThemeProvider>.");
|
|
98
|
+
}
|
|
99
|
+
return ctx;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// src/theme/script.ts
|
|
103
|
+
function buildThemeScript(options = {}) {
|
|
104
|
+
const storageKey = JSON.stringify(options.storageKey ?? "jz-theme");
|
|
105
|
+
const defaultTheme = JSON.stringify(options.defaultTheme ?? "system");
|
|
106
|
+
return `(function(){try{var k=${storageKey},d=${defaultTheme};var t=localStorage.getItem(k);if(t!=="light"&&t!=="dark"&&t!=="system"){t=d;}var s=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";var r=t==="system"?s:t;var e=document.documentElement;e.classList.toggle("dark",r==="dark");e.style.colorScheme=r;}catch(e){}})();`;
|
|
107
|
+
}
|
|
108
|
+
function ThemeScript({ storageKey, defaultTheme, nonce }) {
|
|
109
|
+
return /* @__PURE__ */ jsx("script", { nonce, dangerouslySetInnerHTML: { __html: buildThemeScript({ storageKey, defaultTheme }) } });
|
|
110
|
+
}
|
|
111
|
+
function ThemeToggle({ size = "sm", className }) {
|
|
112
|
+
const { resolvedTheme, toggle } = useTheme();
|
|
113
|
+
const [mounted, setMounted] = React.useState(false);
|
|
114
|
+
React.useEffect(() => setMounted(true), []);
|
|
115
|
+
const label = mounted ? resolvedTheme === "dark" ? "Switch to light theme" : "Switch to dark theme" : "Toggle theme";
|
|
116
|
+
return /* @__PURE__ */ jsx(
|
|
117
|
+
Button,
|
|
118
|
+
{
|
|
119
|
+
variant: "secondary",
|
|
120
|
+
size,
|
|
121
|
+
iconOnly: true,
|
|
122
|
+
"aria-label": label,
|
|
123
|
+
onClick: toggle,
|
|
124
|
+
className,
|
|
125
|
+
leading: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
126
|
+
/* @__PURE__ */ jsx(MoonIcon, { className: "block dark:hidden" }),
|
|
127
|
+
/* @__PURE__ */ jsx(SunIcon, { className: "hidden dark:block" })
|
|
128
|
+
] }),
|
|
129
|
+
children: label
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { ThemeProvider, ThemeScript, ThemeToggle, buildThemeScript, useTheme };
|
|
135
|
+
//# sourceMappingURL=chunk-GRLSUQQE.js.map
|
|
136
|
+
//# sourceMappingURL=chunk-GRLSUQQE.js.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { SURFACE_BASE, SURFACE_VARIANT, SURFACE_PADDING } from './chunk-MFJP5FA7.js';
|
|
2
|
+
import { cn } from './chunk-ZSNJ6UA3.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var OPTION_ROW_GAP = {
|
|
7
|
+
md: "gap-2",
|
|
8
|
+
lg: "gap-3"
|
|
9
|
+
};
|
|
10
|
+
var OPTION_TEXT_GAP = {
|
|
11
|
+
md: "",
|
|
12
|
+
lg: "gap-0.5"
|
|
13
|
+
};
|
|
14
|
+
var OPTION_TEXT_SIZE = {
|
|
15
|
+
md: "text-sm",
|
|
16
|
+
lg: "text-md"
|
|
17
|
+
};
|
|
18
|
+
function optionLabelClass(size) {
|
|
19
|
+
return cn("font-medium text-secondary", OPTION_TEXT_SIZE[size]);
|
|
20
|
+
}
|
|
21
|
+
function optionHintClass(size) {
|
|
22
|
+
return cn("font-normal text-tertiary", OPTION_TEXT_SIZE[size]);
|
|
23
|
+
}
|
|
24
|
+
function optionCardClasses(size, opts = {}) {
|
|
25
|
+
return cn(
|
|
26
|
+
SURFACE_BASE,
|
|
27
|
+
SURFACE_VARIANT.outlined,
|
|
28
|
+
"w-full transition-colors duration-100 ease-linear",
|
|
29
|
+
size === "md" ? SURFACE_PADDING.sm : SURFACE_PADDING.md,
|
|
30
|
+
"has-[[data-checked]]:ring-2 has-[[data-checked]]:ring-brand",
|
|
31
|
+
opts.disabled && "cursor-not-allowed"
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function ControlText(props) {
|
|
35
|
+
const { size, label, hint, labelId, hintId, className } = props;
|
|
36
|
+
const hasLabel = label != null && label !== "";
|
|
37
|
+
const hasHint = hint != null && hint !== "";
|
|
38
|
+
if (!hasLabel && !hasHint) return null;
|
|
39
|
+
return /* @__PURE__ */ jsxs("span", { className: cn("flex flex-col", OPTION_TEXT_GAP[size], className), children: [
|
|
40
|
+
hasLabel ? /* @__PURE__ */ jsx("span", { id: labelId, className: optionLabelClass(size), children: label }) : null,
|
|
41
|
+
hasHint ? /* @__PURE__ */ jsx(
|
|
42
|
+
"span",
|
|
43
|
+
{
|
|
44
|
+
id: hintId,
|
|
45
|
+
"aria-hidden": hasLabel ? void 0 : true,
|
|
46
|
+
className: optionHintClass(size),
|
|
47
|
+
children: hint
|
|
48
|
+
}
|
|
49
|
+
) : null
|
|
50
|
+
] });
|
|
51
|
+
}
|
|
52
|
+
ControlText.displayName = "ControlText";
|
|
53
|
+
function OptionRow(props) {
|
|
54
|
+
const { size, control, label, hint, labelId, hintId, bordered = false, disabled = false, className, ...labelProps } = props;
|
|
55
|
+
return /* @__PURE__ */ jsxs(
|
|
56
|
+
"label",
|
|
57
|
+
{
|
|
58
|
+
className: cn(
|
|
59
|
+
"inline-flex items-start select-none",
|
|
60
|
+
OPTION_ROW_GAP[size],
|
|
61
|
+
disabled ? "cursor-not-allowed" : "cursor-pointer",
|
|
62
|
+
bordered && optionCardClasses(size, { disabled }),
|
|
63
|
+
className
|
|
64
|
+
),
|
|
65
|
+
...labelProps,
|
|
66
|
+
children: [
|
|
67
|
+
control,
|
|
68
|
+
/* @__PURE__ */ jsx(ControlText, { size, label, hint, labelId, hintId })
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
OptionRow.displayName = "OptionRow";
|
|
74
|
+
|
|
75
|
+
export { OptionRow };
|
|
76
|
+
//# sourceMappingURL=chunk-GTHJWR3Q.js.map
|
|
77
|
+
//# sourceMappingURL=chunk-GTHJWR3Q.js.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { OptionRow } from './chunk-GTHJWR3Q.js';
|
|
2
|
+
import { warnNeedsName } from './chunk-GCVA3OIV.js';
|
|
3
|
+
import { cn } from './chunk-ZSNJ6UA3.js';
|
|
4
|
+
import { Switch as Switch$1 } from '@base-ui/react/switch';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
var SIZE = {
|
|
9
|
+
md: {
|
|
10
|
+
track: "h-5 w-9",
|
|
11
|
+
thumb: "size-4 data-[checked]:translate-x-4"
|
|
12
|
+
},
|
|
13
|
+
lg: {
|
|
14
|
+
track: "h-6 w-11",
|
|
15
|
+
thumb: "size-5 data-[checked]:translate-x-5"
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var TRACK_BASE = "relative inline-flex shrink-0 items-center rounded-full p-0.5 transition-colors duration-150 ease-linear bg-tertiary ring-[0.5px] ring-inset ring-secondary data-[checked]:bg-brand-solid outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2";
|
|
19
|
+
var THUMB_BASE = "pointer-events-none block translate-x-0 rounded-full bg-fg-white shadow-sm transition-transform duration-150 ease-in-out";
|
|
20
|
+
function Switch(props) {
|
|
21
|
+
const { size = "md", label, hint, bordered = false, onCheckedChange, disabled = false, id, className, ...rest } = props;
|
|
22
|
+
const reactId = React.useId();
|
|
23
|
+
const resolvedId = id ?? reactId;
|
|
24
|
+
const labelId = `${reactId}-label`;
|
|
25
|
+
const hintId = `${reactId}-hint`;
|
|
26
|
+
const hasLabel = label != null && label !== "";
|
|
27
|
+
const hasHint = hint != null && hint !== "";
|
|
28
|
+
warnNeedsName("Switch", Boolean(label) || "aria-label" in rest || "aria-labelledby" in rest, "a `label`, `aria-label`, or `aria-labelledby`");
|
|
29
|
+
const track = cn(
|
|
30
|
+
TRACK_BASE,
|
|
31
|
+
SIZE[size].track,
|
|
32
|
+
// Untitled UI's only interactive fill change is checked + hover; no unchecked-hover
|
|
33
|
+
// and no press/active state.
|
|
34
|
+
disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer data-[checked]:hover:bg-brand-solid_hover"
|
|
35
|
+
);
|
|
36
|
+
const thumb = cn(THUMB_BASE, SIZE[size].thumb);
|
|
37
|
+
return /* @__PURE__ */ jsx(
|
|
38
|
+
OptionRow,
|
|
39
|
+
{
|
|
40
|
+
size,
|
|
41
|
+
bordered,
|
|
42
|
+
disabled,
|
|
43
|
+
label,
|
|
44
|
+
hint,
|
|
45
|
+
labelId,
|
|
46
|
+
hintId,
|
|
47
|
+
className,
|
|
48
|
+
control: /* @__PURE__ */ jsx(
|
|
49
|
+
Switch$1.Root,
|
|
50
|
+
{
|
|
51
|
+
...rest,
|
|
52
|
+
id: resolvedId,
|
|
53
|
+
disabled,
|
|
54
|
+
"aria-labelledby": hasLabel ? labelId : void 0,
|
|
55
|
+
"aria-describedby": hasHint ? hintId : void 0,
|
|
56
|
+
onCheckedChange: onCheckedChange ? (checked, details) => onCheckedChange(checked, details.event) : void 0,
|
|
57
|
+
className: track,
|
|
58
|
+
children: /* @__PURE__ */ jsx(Switch$1.Thumb, { className: thumb })
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { Switch };
|
|
66
|
+
//# sourceMappingURL=chunk-HMUZE6EK.js.map
|
|
67
|
+
//# sourceMappingURL=chunk-HMUZE6EK.js.map
|