@bricks-toolkit/toolkit 0.1.1 → 0.1.2
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 +9 -9
- package/dist/avatar/index.cjs +11 -1
- package/dist/avatar/index.mjs +2 -1
- package/dist/badge/index.cjs +11 -1
- package/dist/badge/index.mjs +2 -1
- package/dist/breadcrumbs/index.cjs +11 -1
- package/dist/breadcrumbs/index.mjs +2 -1
- package/dist/button/index.cjs +13 -2
- package/dist/button/index.mjs +4 -2
- package/dist/card/index.cjs +31 -1
- package/dist/card/index.mjs +2 -1
- package/dist/checkbox/index.cjs +11 -1
- package/dist/checkbox/index.mjs +2 -1
- package/dist/chunk-2POU3NX4.mjs +192 -0
- package/dist/chunk-32SKYPQW.mjs +156 -0
- package/dist/chunk-446OJWC6.mjs +285 -0
- package/dist/chunk-4DA7CRNV.mjs +376 -0
- package/dist/chunk-4DR57X7U.mjs +182 -0
- package/dist/chunk-4QSDPHPI.mjs +285 -0
- package/dist/chunk-56ILK7Y4.cjs +315 -0
- package/dist/chunk-5J3OMAO4.cjs +222 -0
- package/dist/chunk-5RKET2JO.cjs +287 -0
- package/dist/chunk-65UZC3FK.mjs +312 -0
- package/dist/chunk-6CC5KIA5.cjs +148 -0
- package/dist/chunk-6R3OYBQ6.cjs +209 -0
- package/dist/chunk-6UO72EJA.cjs +2 -0
- package/dist/chunk-6ZCY4O5M.mjs +63 -0
- package/dist/chunk-7364SUK6.mjs +359 -0
- package/dist/chunk-7DDDQ3RH.cjs +66 -0
- package/dist/chunk-7PDGAIC3.cjs +189 -0
- package/dist/chunk-7R5JRJ2W.cjs +255 -0
- package/dist/chunk-7WNJ7L4Z.mjs +335 -0
- package/dist/chunk-AJXVELXK.cjs +218 -0
- package/dist/chunk-ARTXRQO6.mjs +1 -0
- package/dist/chunk-B4OV5GRT.cjs +510 -0
- package/dist/chunk-B5MYGYJY.mjs +122 -0
- package/dist/chunk-BBVWG5GH.cjs +75 -0
- package/dist/chunk-BVBCAAES.mjs +35 -0
- package/dist/chunk-CBA54EY4.mjs +508 -0
- package/dist/chunk-CMER5LO3.mjs +330 -0
- package/dist/chunk-DHC5LI2P.cjs +338 -0
- package/dist/chunk-DMLPA65B.mjs +107 -0
- package/dist/chunk-DN2GFJF4.mjs +175 -0
- package/dist/chunk-ECLNLPOR.cjs +70 -0
- package/dist/chunk-EV463QT5.cjs +53 -0
- package/dist/chunk-FOVJHEWH.mjs +51 -0
- package/dist/chunk-G4HVY6FM.mjs +203 -0
- package/dist/chunk-H77YWN3L.mjs +220 -0
- package/dist/chunk-HIWJDLIS.cjs +124 -0
- package/dist/chunk-HQGDSOSN.mjs +274 -0
- package/dist/chunk-JKPNJ4PZ.mjs +313 -0
- package/dist/chunk-JV6AWBN5.mjs +113 -0
- package/dist/chunk-KA35BV7V.mjs +207 -0
- package/dist/chunk-KLBABQEJ.cjs +378 -0
- package/dist/chunk-L5VQZZVR.cjs +3197 -0
- package/dist/chunk-LTG6YP5I.cjs +69 -0
- package/dist/chunk-MVUNJPGH.cjs +184 -0
- package/dist/chunk-NMJ5CVZH.cjs +2 -0
- package/dist/chunk-NRCNRHXL.cjs +109 -0
- package/dist/chunk-NRZIXK35.cjs +276 -0
- package/dist/chunk-OCPFOFJ4.mjs +3195 -0
- package/dist/chunk-OEU5VG3D.cjs +362 -0
- package/dist/chunk-OPOCCRJG.cjs +193 -0
- package/dist/chunk-OQPCL5XX.mjs +187 -0
- package/dist/chunk-PCYGJNEQ.cjs +280 -0
- package/dist/chunk-PJH2KEWK.mjs +200 -0
- package/dist/chunk-PJWELBN2.cjs +115 -0
- package/dist/chunk-Q3IFXFFD.cjs +202 -0
- package/dist/chunk-R72GDCWE.cjs +314 -0
- package/dist/chunk-RAD5VJHR.mjs +146 -0
- package/dist/chunk-RYWDZHKG.mjs +274 -0
- package/dist/chunk-S7VEND5Z.cjs +162 -0
- package/dist/chunk-SBNNV6FE.mjs +1 -0
- package/dist/chunk-SFUOCZJY.mjs +187 -0
- package/dist/chunk-SHQ2MPBE.mjs +73 -0
- package/dist/chunk-TIVSMCXZ.mjs +253 -0
- package/dist/chunk-TNGW5YHA.cjs +37 -0
- package/dist/chunk-VC7MOPU6.cjs +287 -0
- package/dist/chunk-VHVFRWF5.mjs +64 -0
- package/dist/chunk-VKQDW7C2.mjs +336 -0
- package/dist/chunk-VRZFAKSV.cjs +177 -0
- package/dist/chunk-W2ZAPLQH.cjs +337 -0
- package/dist/chunk-XFNRKHHF.cjs +332 -0
- package/dist/chunk-Y3NTKFUE.mjs +66 -0
- package/dist/chunk-Y6AN7AWX.cjs +205 -0
- package/dist/chunk-YMMNWJT6.cjs +134 -0
- package/dist/chunk-YOTCXSXL.mjs +132 -0
- package/dist/combo-box/index.cjs +11 -1
- package/dist/combo-box/index.mjs +2 -1
- package/dist/date-picker/index.cjs +11 -2
- package/dist/date-picker/index.mjs +2 -2
- package/dist/dialog/index.cjs +27 -1
- package/dist/dialog/index.mjs +2 -1
- package/dist/dropdown-menu/index.cjs +27 -1
- package/dist/dropdown-menu/index.mjs +2 -1
- package/dist/email/index.cjs +11 -2
- package/dist/email/index.mjs +2 -2
- package/dist/file-upload/index.cjs +11 -1
- package/dist/file-upload/index.mjs +2 -1
- package/dist/header/index.cjs +14 -2
- package/dist/header/index.mjs +5 -2
- package/dist/icon-button/index.cjs +13 -2
- package/dist/icon-button/index.mjs +4 -2
- package/dist/image/index.cjs +12 -1
- package/dist/image/index.mjs +3 -1
- package/dist/index.cjs +839 -2
- package/dist/index.d.ts +141 -75
- package/dist/index.mjs +601 -2
- package/dist/link/index.cjs +11 -1
- package/dist/link/index.mjs +2 -1
- package/dist/loader/index.cjs +11 -2
- package/dist/loader/index.mjs +2 -2
- package/dist/modal/index.cjs +27 -1
- package/dist/modal/index.mjs +2 -1
- package/dist/multi-select/index.cjs +11 -2
- package/dist/multi-select/index.mjs +2 -2
- package/dist/otp-input/index.cjs +11 -1
- package/dist/otp-input/index.mjs +2 -1
- package/dist/password-input/index.cjs +11 -2
- package/dist/password-input/index.mjs +2 -2
- package/dist/phone/index.cjs +11 -2
- package/dist/phone/index.mjs +2 -2
- package/dist/radio-button/index.cjs +11 -1
- package/dist/radio-button/index.mjs +2 -1
- package/dist/search-input/index.cjs +12 -2
- package/dist/search-input/index.mjs +3 -2
- package/dist/select/index.cjs +11 -2
- package/dist/select/index.mjs +2 -2
- package/dist/sidebar/index.cjs +11 -1
- package/dist/sidebar/index.mjs +2 -1
- package/dist/skeleton/index.cjs +27 -1
- package/dist/skeleton/index.mjs +2 -1
- package/dist/styles.css +5074 -1
- package/dist/table/index.cjs +15 -1
- package/dist/table/index.mjs +2 -1
- package/dist/tabs/index.cjs +14 -2
- package/dist/tabs/index.mjs +5 -2
- package/dist/text-input/index.cjs +11 -2
- package/dist/text-input/index.mjs +2 -2
- package/dist/theme-provider/index.cjs +14 -1
- package/dist/theme-provider/index.mjs +1 -1
- package/dist/time-picker/index.cjs +11 -2
- package/dist/time-picker/index.mjs +2 -2
- package/dist/toaster/index.cjs +11 -1
- package/dist/toaster/index.mjs +2 -1
- package/dist/tooltip/index.cjs +12 -1
- package/dist/tooltip/index.mjs +3 -1
- package/package.json +122 -141
- package/dist/components/Accordion/Accordion.d.ts +0 -5
- package/dist/components/Accordion/Accordion.types.d.ts +0 -32
- package/dist/components/Accordion/index.d.ts +0 -2
- package/dist/components/Avatar/Avatar.d.ts +0 -2
- package/dist/components/Avatar/Avatar.stories.d.ts +0 -11
- package/dist/components/Avatar/Avatar.test.d.ts +0 -1
- package/dist/components/Avatar/Avatar.types.d.ts +0 -24
- package/dist/components/Avatar/index.d.ts +0 -2
- package/dist/components/Badge/Badge.d.ts +0 -11
- package/dist/components/Badge/Badge.stories.d.ts +0 -21
- package/dist/components/Badge/Badge.test.d.ts +0 -1
- package/dist/components/Badge/Badge.types.d.ts +0 -43
- package/dist/components/Badge/index.d.ts +0 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +0 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.stories.d.ts +0 -13
- package/dist/components/Breadcrumbs/Breadcrumbs.test.d.ts +0 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +0 -27
- package/dist/components/Breadcrumbs/index.d.ts +0 -2
- package/dist/components/Button/Button.d.ts +0 -2
- package/dist/components/Button/Button.stories.d.ts +0 -20
- package/dist/components/Button/Button.test.d.ts +0 -1
- package/dist/components/Button/Button.types.d.ts +0 -24
- package/dist/components/Button/index.d.ts +0 -2
- package/dist/components/Card/Card.d.ts +0 -25
- package/dist/components/Card/Card.stories.d.ts +0 -8
- package/dist/components/Card/Card.test.d.ts +0 -1
- package/dist/components/Card/Card.types.d.ts +0 -14
- package/dist/components/Card/index.d.ts +0 -2
- package/dist/components/Checkbox/Checkbox.d.ts +0 -2
- package/dist/components/Checkbox/Checkbox.stories.d.ts +0 -16
- package/dist/components/Checkbox/Checkbox.test.d.ts +0 -1
- package/dist/components/Checkbox/Checkbox.types.d.ts +0 -31
- package/dist/components/Checkbox/index.d.ts +0 -2
- package/dist/components/ComboBox/ComboBox.d.ts +0 -2
- package/dist/components/ComboBox/ComboBox.stories.d.ts +0 -12
- package/dist/components/ComboBox/ComboBox.test.d.ts +0 -1
- package/dist/components/ComboBox/ComboBox.types.d.ts +0 -57
- package/dist/components/ComboBox/index.d.ts +0 -2
- package/dist/components/DatePicker/DatePicker.d.ts +0 -2
- package/dist/components/DatePicker/DatePicker.stories.d.ts +0 -25
- package/dist/components/DatePicker/DatePicker.test.d.ts +0 -1
- package/dist/components/DatePicker/DatePicker.types.d.ts +0 -27
- package/dist/components/DatePicker/index.d.ts +0 -2
- package/dist/components/Dialog/Dialog.d.ts +0 -6
- package/dist/components/Dialog/Dialog.stories.d.ts +0 -9
- package/dist/components/Dialog/Dialog.test.d.ts +0 -1
- package/dist/components/Dialog/Dialog.types.d.ts +0 -52
- package/dist/components/Dialog/index.d.ts +0 -2
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +0 -7
- package/dist/components/DropdownMenu/DropdownMenu.stories.d.ts +0 -9
- package/dist/components/DropdownMenu/DropdownMenu.test.d.ts +0 -1
- package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +0 -24
- package/dist/components/DropdownMenu/index.d.ts +0 -2
- package/dist/components/Email/Email.d.ts +0 -2
- package/dist/components/Email/Email.stories.d.ts +0 -11
- package/dist/components/Email/Email.test.d.ts +0 -1
- package/dist/components/Email/Email.types.d.ts +0 -33
- package/dist/components/Email/index.d.ts +0 -2
- package/dist/components/FileUpload/FileUpload.d.ts +0 -2
- package/dist/components/FileUpload/FileUpload.stories.d.ts +0 -10
- package/dist/components/FileUpload/FileUpload.test.d.ts +0 -1
- package/dist/components/FileUpload/FileUpload.types.d.ts +0 -22
- package/dist/components/FileUpload/index.d.ts +0 -2
- package/dist/components/Header/Header.d.ts +0 -7
- package/dist/components/Header/Header.stories.d.ts +0 -8
- package/dist/components/Header/Header.test.d.ts +0 -1
- package/dist/components/Header/Header.types.d.ts +0 -19
- package/dist/components/Header/index.d.ts +0 -2
- package/dist/components/IconButton/IconButton.d.ts +0 -2
- package/dist/components/IconButton/IconButton.stories.d.ts +0 -17
- package/dist/components/IconButton/IconButton.types.d.ts +0 -10
- package/dist/components/IconButton/index.d.ts +0 -2
- package/dist/components/Image/Image.d.ts +0 -6
- package/dist/components/Image/Image.stories.d.ts +0 -13
- package/dist/components/Image/Image.test.d.ts +0 -1
- package/dist/components/Image/Image.types.d.ts +0 -40
- package/dist/components/Image/index.d.ts +0 -2
- package/dist/components/Link/Link.d.ts +0 -2
- package/dist/components/Link/Link.stories.d.ts +0 -15
- package/dist/components/Link/Link.test.d.ts +0 -1
- package/dist/components/Link/Link.types.d.ts +0 -20
- package/dist/components/Link/index.d.ts +0 -2
- package/dist/components/Loader/Loader.d.ts +0 -2
- package/dist/components/Loader/Loader.stories.d.ts +0 -12
- package/dist/components/Loader/Loader.test.d.ts +0 -1
- package/dist/components/Loader/Loader.types.d.ts +0 -17
- package/dist/components/Loader/index.d.ts +0 -2
- package/dist/components/Modal/Modal.d.ts +0 -14
- package/dist/components/Modal/Modal.stories.d.ts +0 -14
- package/dist/components/Modal/Modal.test.d.ts +0 -1
- package/dist/components/Modal/Modal.types.d.ts +0 -100
- package/dist/components/Modal/index.d.ts +0 -2
- package/dist/components/MultiSelect/MultiSelect.d.ts +0 -2
- package/dist/components/MultiSelect/MultiSelect.stories.d.ts +0 -15
- package/dist/components/MultiSelect/MultiSelect.test.d.ts +0 -1
- package/dist/components/MultiSelect/MultiSelect.types.d.ts +0 -55
- package/dist/components/MultiSelect/index.d.ts +0 -2
- package/dist/components/OtpInput/OtpInput.d.ts +0 -2
- package/dist/components/OtpInput/OtpInput.stories.d.ts +0 -10
- package/dist/components/OtpInput/OtpInput.test.d.ts +0 -1
- package/dist/components/OtpInput/OtpInput.types.d.ts +0 -53
- package/dist/components/OtpInput/index.d.ts +0 -2
- package/dist/components/PasswordInput/PasswordInput.d.ts +0 -2
- package/dist/components/PasswordInput/PasswordInput.stories.d.ts +0 -23
- package/dist/components/PasswordInput/PasswordInput.test.d.ts +0 -1
- package/dist/components/PasswordInput/PasswordInput.types.d.ts +0 -27
- package/dist/components/PasswordInput/index.d.ts +0 -2
- package/dist/components/Phone/Phone.d.ts +0 -2
- package/dist/components/Phone/Phone.stories.d.ts +0 -11
- package/dist/components/Phone/Phone.test.d.ts +0 -1
- package/dist/components/Phone/Phone.types.d.ts +0 -36
- package/dist/components/Phone/countries.d.ts +0 -8
- package/dist/components/Phone/index.d.ts +0 -2
- package/dist/components/RadioButton/RadioButton.d.ts +0 -2
- package/dist/components/RadioButton/RadioButton.stories.d.ts +0 -21
- package/dist/components/RadioButton/RadioButton.test.d.ts +0 -1
- package/dist/components/RadioButton/RadioButton.types.d.ts +0 -51
- package/dist/components/RadioButton/index.d.ts +0 -2
- package/dist/components/SearchInput/SearchInput.d.ts +0 -6
- package/dist/components/SearchInput/SearchInput.stories.d.ts +0 -8
- package/dist/components/SearchInput/SearchInput.test.d.ts +0 -1
- package/dist/components/SearchInput/SearchInput.types.d.ts +0 -12
- package/dist/components/SearchInput/index.d.ts +0 -2
- package/dist/components/Select/Select.d.ts +0 -2
- package/dist/components/Select/Select.stories.d.ts +0 -12
- package/dist/components/Select/Select.test.d.ts +0 -1
- package/dist/components/Select/Select.types.d.ts +0 -31
- package/dist/components/Select/index.d.ts +0 -2
- package/dist/components/Sidebar/Sidebar.d.ts +0 -7
- package/dist/components/Sidebar/Sidebar.stories.d.ts +0 -10
- package/dist/components/Sidebar/Sidebar.test.d.ts +0 -1
- package/dist/components/Sidebar/Sidebar.types.d.ts +0 -87
- package/dist/components/Sidebar/index.d.ts +0 -2
- package/dist/components/Skeleton/Skeleton.d.ts +0 -26
- package/dist/components/Skeleton/Skeleton.stories.d.ts +0 -13
- package/dist/components/Skeleton/Skeleton.types.d.ts +0 -47
- package/dist/components/Skeleton/index.d.ts +0 -2
- package/dist/components/Stepper/Stepper.d.ts +0 -2
- package/dist/components/Stepper/Stepper.stories.d.ts +0 -23
- package/dist/components/Stepper/Stepper.test.d.ts +0 -1
- package/dist/components/Stepper/Stepper.types.d.ts +0 -47
- package/dist/components/Stepper/index.d.ts +0 -2
- package/dist/components/Table/Pagination.d.ts +0 -3
- package/dist/components/Table/Table.d.ts +0 -3
- package/dist/components/Table/Table.stories.d.ts +0 -13
- package/dist/components/Table/Table.test.d.ts +0 -1
- package/dist/components/Table/Table.types.d.ts +0 -85
- package/dist/components/Table/index.d.ts +0 -3
- package/dist/components/Tabs/Tabs.d.ts +0 -2
- package/dist/components/Tabs/Tabs.stories.d.ts +0 -17
- package/dist/components/Tabs/Tabs.test.d.ts +0 -1
- package/dist/components/Tabs/Tabs.types.d.ts +0 -21
- package/dist/components/Tabs/index.d.ts +0 -2
- package/dist/components/TextInput/TextInput.d.ts +0 -2
- package/dist/components/TextInput/TextInput.stories.d.ts +0 -25
- package/dist/components/TextInput/TextInput.test.d.ts +0 -1
- package/dist/components/TextInput/TextInput.types.d.ts +0 -29
- package/dist/components/TextInput/index.d.ts +0 -2
- package/dist/components/ThemeProvider/ThemeProvider.d.ts +0 -8
- package/dist/components/ThemeProvider/ThemeProvider.stories.d.ts +0 -16
- package/dist/components/ThemeProvider/ThemeProvider.test.d.ts +0 -1
- package/dist/components/ThemeProvider/ThemeProvider.types.d.ts +0 -112
- package/dist/components/ThemeProvider/index.d.ts +0 -2
- package/dist/components/TimePicker/TimePicker.d.ts +0 -2
- package/dist/components/TimePicker/TimePicker.stories.d.ts +0 -23
- package/dist/components/TimePicker/TimePicker.test.d.ts +0 -1
- package/dist/components/TimePicker/TimePicker.types.d.ts +0 -27
- package/dist/components/TimePicker/index.d.ts +0 -2
- package/dist/components/Toaster/Toaster.d.ts +0 -2
- package/dist/components/Toaster/Toaster.stories.d.ts +0 -13
- package/dist/components/Toaster/Toaster.test.d.ts +0 -1
- package/dist/components/Toaster/Toaster.types.d.ts +0 -23
- package/dist/components/Toaster/index.d.ts +0 -2
- package/dist/components/Toggle/Toggle.d.ts +0 -2
- package/dist/components/Toggle/Toggle.stories.d.ts +0 -11
- package/dist/components/Toggle/Toggle.types.d.ts +0 -10
- package/dist/components/Toggle/index.d.ts +0 -2
- package/dist/components/Tooltip/Tooltip.d.ts +0 -2
- package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -13
- package/dist/components/Tooltip/Tooltip.test.d.ts +0 -1
- package/dist/components/Tooltip/Tooltip.types.d.ts +0 -33
- package/dist/components/Tooltip/index.d.ts +0 -2
- package/dist/utils/cn.d.ts +0 -2
- package/dist/utils/index.d.ts +0 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
// src/components/ThemeProvider/ThemeProvider.tsx
|
|
7
|
+
var ThemeProviderContext = react.createContext(void 0);
|
|
8
|
+
var ThemeProvider = ({
|
|
9
|
+
children,
|
|
10
|
+
defaultTheme = "system",
|
|
11
|
+
storageKey = "ui-theme",
|
|
12
|
+
themeConfig,
|
|
13
|
+
...props
|
|
14
|
+
}) => {
|
|
15
|
+
const [theme, setTheme] = react.useState(() => {
|
|
16
|
+
if (typeof window === "undefined") return defaultTheme;
|
|
17
|
+
const stored = localStorage.getItem(storageKey);
|
|
18
|
+
return stored ? stored : defaultTheme;
|
|
19
|
+
});
|
|
20
|
+
react.useEffect(() => {
|
|
21
|
+
const root = window.document.documentElement;
|
|
22
|
+
const applyTheme = () => {
|
|
23
|
+
root.classList.remove("light", "dark");
|
|
24
|
+
const currentTheme = theme === "system" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : theme;
|
|
25
|
+
root.classList.add(currentTheme);
|
|
26
|
+
if (themeConfig) {
|
|
27
|
+
const config = themeConfig[currentTheme] ?? {};
|
|
28
|
+
Object.entries(config).forEach(([key, value2]) => {
|
|
29
|
+
if (value2) {
|
|
30
|
+
const variableName = `--${key.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()}`;
|
|
31
|
+
root.style.setProperty(variableName, value2);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
applyTheme();
|
|
37
|
+
if (theme === "system") {
|
|
38
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
39
|
+
const listener = () => {
|
|
40
|
+
applyTheme();
|
|
41
|
+
};
|
|
42
|
+
mediaQuery.addEventListener("change", listener);
|
|
43
|
+
return () => {
|
|
44
|
+
mediaQuery.removeEventListener("change", listener);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return void 0;
|
|
48
|
+
}, [theme, themeConfig]);
|
|
49
|
+
const value = {
|
|
50
|
+
theme,
|
|
51
|
+
setTheme: (newTheme) => {
|
|
52
|
+
localStorage.setItem(storageKey, newTheme);
|
|
53
|
+
setTheme(newTheme);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
if (themeConfig !== void 0) {
|
|
57
|
+
value.themeConfig = themeConfig;
|
|
58
|
+
}
|
|
59
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ThemeProviderContext.Provider, { ...props, value, children });
|
|
60
|
+
};
|
|
61
|
+
var useTheme = () => {
|
|
62
|
+
const context = react.useContext(ThemeProviderContext);
|
|
63
|
+
if (context === void 0) throw new Error("useTheme must be used within a ThemeProvider");
|
|
64
|
+
return context;
|
|
65
|
+
};
|
|
66
|
+
ThemeProvider.displayName = "ThemeProvider";
|
|
67
|
+
|
|
68
|
+
exports.ThemeProvider = ThemeProvider;
|
|
69
|
+
exports.useTheme = useTheme;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkL5VQZZVR_cjs = require('./chunk-L5VQZZVR.cjs');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
var containerSize = {
|
|
7
|
+
xs: "w-3 h-3",
|
|
8
|
+
sm: "w-4 h-4",
|
|
9
|
+
md: "w-6 h-6",
|
|
10
|
+
lg: "w-9 h-9",
|
|
11
|
+
xl: "w-12 h-12"
|
|
12
|
+
};
|
|
13
|
+
var dotSize = {
|
|
14
|
+
xs: "w-1 h-1",
|
|
15
|
+
sm: "w-1.5 h-1.5",
|
|
16
|
+
md: "w-2 h-2",
|
|
17
|
+
lg: "w-3 h-3",
|
|
18
|
+
xl: "w-4 h-4"
|
|
19
|
+
};
|
|
20
|
+
var barHeight = {
|
|
21
|
+
xs: "h-0.5 w-16",
|
|
22
|
+
sm: "h-1 w-24",
|
|
23
|
+
md: "h-1.5 w-32",
|
|
24
|
+
lg: "h-2 w-48",
|
|
25
|
+
xl: "h-2.5 w-64"
|
|
26
|
+
};
|
|
27
|
+
var pulseSize = {
|
|
28
|
+
xs: "w-5 h-5",
|
|
29
|
+
sm: "w-7 h-7",
|
|
30
|
+
md: "w-10 h-10",
|
|
31
|
+
lg: "w-14 h-14",
|
|
32
|
+
xl: "w-20 h-20"
|
|
33
|
+
};
|
|
34
|
+
var colorClass = {
|
|
35
|
+
primary: "text-primary",
|
|
36
|
+
secondary: "text-secondary",
|
|
37
|
+
success: "text-success",
|
|
38
|
+
error: "text-error",
|
|
39
|
+
warning: "text-warning",
|
|
40
|
+
white: "text-text-inverse",
|
|
41
|
+
current: "text-current"
|
|
42
|
+
};
|
|
43
|
+
var bgColorClass = {
|
|
44
|
+
primary: "bg-primary",
|
|
45
|
+
secondary: "bg-secondary",
|
|
46
|
+
success: "bg-success",
|
|
47
|
+
error: "bg-error",
|
|
48
|
+
warning: "bg-warning",
|
|
49
|
+
white: "bg-text-inverse",
|
|
50
|
+
current: "bg-current"
|
|
51
|
+
};
|
|
52
|
+
function Spinner({ size, color }) {
|
|
53
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkL5VQZZVR_cjs.cn("relative flex items-center justify-center", containerSize[size]), children: [
|
|
54
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
55
|
+
"div",
|
|
56
|
+
{
|
|
57
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
58
|
+
"absolute inset-0 rounded-full border-2 border-current opacity-20 animate-ping",
|
|
59
|
+
colorClass[color]
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
64
|
+
"svg",
|
|
65
|
+
{
|
|
66
|
+
className: chunkL5VQZZVR_cjs.cn("animate-spin relative z-10", containerSize[size], colorClass[color]),
|
|
67
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
68
|
+
fill: "none",
|
|
69
|
+
viewBox: "0 0 24 24",
|
|
70
|
+
"aria-hidden": "true",
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
73
|
+
"circle",
|
|
74
|
+
{
|
|
75
|
+
className: "opacity-25",
|
|
76
|
+
cx: "12",
|
|
77
|
+
cy: "12",
|
|
78
|
+
r: "10",
|
|
79
|
+
stroke: "currentColor",
|
|
80
|
+
strokeWidth: "3"
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
84
|
+
"path",
|
|
85
|
+
{
|
|
86
|
+
className: "opacity-90",
|
|
87
|
+
fill: "currentColor",
|
|
88
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
] });
|
|
95
|
+
}
|
|
96
|
+
function Dots({ size, color }) {
|
|
97
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-1", "aria-hidden": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
98
|
+
"span",
|
|
99
|
+
{
|
|
100
|
+
style: { animationDelay: `${String(i * 160)}ms` },
|
|
101
|
+
className: chunkL5VQZZVR_cjs.cn("rounded-full animate-bounce", dotSize[size], bgColorClass[color])
|
|
102
|
+
},
|
|
103
|
+
i
|
|
104
|
+
)) });
|
|
105
|
+
}
|
|
106
|
+
function Pulse({ size, color }) {
|
|
107
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
108
|
+
"span",
|
|
109
|
+
{
|
|
110
|
+
"aria-hidden": "true",
|
|
111
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
112
|
+
"rounded-full animate-ping",
|
|
113
|
+
pulseSize[size],
|
|
114
|
+
bgColorClass[color],
|
|
115
|
+
"opacity-75"
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
function Bar({ size, color }) {
|
|
121
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
122
|
+
"div",
|
|
123
|
+
{
|
|
124
|
+
"aria-hidden": "true",
|
|
125
|
+
className: chunkL5VQZZVR_cjs.cn("rounded-full overflow-hidden bg-divider", barHeight[size]),
|
|
126
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
127
|
+
"div",
|
|
128
|
+
{
|
|
129
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
130
|
+
"h-full rounded-full animate-[bar-slide_1.4s_ease-in-out_infinite]",
|
|
131
|
+
bgColorClass[color]
|
|
132
|
+
),
|
|
133
|
+
style: { width: "40%", animation: "bar-slide 1.4s ease-in-out infinite" }
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
var VARIANTS = {
|
|
140
|
+
spinner: Spinner,
|
|
141
|
+
dots: Dots,
|
|
142
|
+
pulse: Pulse,
|
|
143
|
+
bar: Bar
|
|
144
|
+
};
|
|
145
|
+
function Loader({
|
|
146
|
+
variant = "spinner",
|
|
147
|
+
size = "md",
|
|
148
|
+
color = "primary",
|
|
149
|
+
label = "Loading\u2026",
|
|
150
|
+
fullscreen = false,
|
|
151
|
+
className
|
|
152
|
+
}) {
|
|
153
|
+
const VariantComponent = VARIANTS[variant];
|
|
154
|
+
const inner = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
155
|
+
"div",
|
|
156
|
+
{
|
|
157
|
+
role: "status",
|
|
158
|
+
"aria-label": label,
|
|
159
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
160
|
+
"inline-flex flex-col items-center justify-center gap-2",
|
|
161
|
+
!fullscreen && className
|
|
162
|
+
),
|
|
163
|
+
children: [
|
|
164
|
+
/* @__PURE__ */ jsxRuntime.jsx(VariantComponent, { size, color }),
|
|
165
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: label })
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
if (fullscreen) {
|
|
170
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
171
|
+
"div",
|
|
172
|
+
{
|
|
173
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
174
|
+
"fixed inset-0 z-50 flex items-center justify-center bg-surface/80 backdrop-blur-md",
|
|
175
|
+
className
|
|
176
|
+
),
|
|
177
|
+
children: inner
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
return inner;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
exports.Loader = Loader;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkL5VQZZVR_cjs = require('./chunk-L5VQZZVR.cjs');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var solid = require('@heroicons/react/20/solid');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
var sizeClasses = {
|
|
9
|
+
xs: "text-xs",
|
|
10
|
+
sm: "text-sm",
|
|
11
|
+
md: "text-base",
|
|
12
|
+
lg: "text-lg"
|
|
13
|
+
};
|
|
14
|
+
var SEPARATORS = {
|
|
15
|
+
slash: /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "select-none text-text-muted/60", children: "/" }),
|
|
16
|
+
chevron: /* @__PURE__ */ jsxRuntime.jsx(solid.ChevronRightIcon, { "aria-hidden": "true", className: "w-4 h-4 text-text-muted/60 shrink-0" }),
|
|
17
|
+
dot: /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "select-none text-text-muted/60", children: "\xB7" })
|
|
18
|
+
};
|
|
19
|
+
function resolveSeparator(sep) {
|
|
20
|
+
if (typeof sep === "string" && sep in SEPARATORS) return SEPARATORS[sep];
|
|
21
|
+
return sep;
|
|
22
|
+
}
|
|
23
|
+
function Crumb({ item, isCurrent, size }) {
|
|
24
|
+
const baseClass = chunkL5VQZZVR_cjs.cn(
|
|
25
|
+
"inline-flex items-center gap-1 transition-colors leading-none",
|
|
26
|
+
sizeClasses[size],
|
|
27
|
+
isCurrent ? "font-bold text-text cursor-default" : item.disabled ? "text-text-muted cursor-not-allowed" : "text-primary hover:text-primary-hover hover:underline underline-offset-4 cursor-pointer"
|
|
28
|
+
);
|
|
29
|
+
if (isCurrent) {
|
|
30
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: baseClass, "aria-current": "page", children: item.label });
|
|
31
|
+
}
|
|
32
|
+
if (item.disabled) {
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: baseClass, children: item.label });
|
|
34
|
+
}
|
|
35
|
+
if (item.onClick != null) {
|
|
36
|
+
return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: item.onClick, className: baseClass, children: item.label });
|
|
37
|
+
}
|
|
38
|
+
if (item.href != null) {
|
|
39
|
+
return /* @__PURE__ */ jsxRuntime.jsx("a", { href: item.href, className: baseClass, children: item.label });
|
|
40
|
+
}
|
|
41
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: baseClass, children: item.label });
|
|
42
|
+
}
|
|
43
|
+
function Breadcrumbs({
|
|
44
|
+
items,
|
|
45
|
+
separator = "chevron",
|
|
46
|
+
size = "sm",
|
|
47
|
+
collapsible = false,
|
|
48
|
+
maxItems = 4,
|
|
49
|
+
className
|
|
50
|
+
}) {
|
|
51
|
+
const [expanded, setExpanded] = react.useState(false);
|
|
52
|
+
if (items.length === 0) return null;
|
|
53
|
+
const sep = resolveSeparator(separator);
|
|
54
|
+
let visibleItems;
|
|
55
|
+
let showEllipsis = false;
|
|
56
|
+
if (collapsible && !expanded && items.length > maxItems) {
|
|
57
|
+
const keep = Math.max(1, maxItems - 1);
|
|
58
|
+
visibleItems = items.slice(0, keep);
|
|
59
|
+
showEllipsis = true;
|
|
60
|
+
} else {
|
|
61
|
+
visibleItems = items;
|
|
62
|
+
}
|
|
63
|
+
const segments = [];
|
|
64
|
+
visibleItems.forEach((item, idx) => {
|
|
65
|
+
const isCurrent = !showEllipsis && idx === items.length - 1;
|
|
66
|
+
if (idx > 0) {
|
|
67
|
+
segments.push(
|
|
68
|
+
/* @__PURE__ */ jsxRuntime.jsx("li", { role: "presentation", className: "flex items-center", children: sep }, `sep-${String(idx)}`)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
segments.push(
|
|
72
|
+
/* @__PURE__ */ jsxRuntime.jsx("li", { className: "flex items-center", children: /* @__PURE__ */ jsxRuntime.jsx(Crumb, { item, isCurrent, size }) }, `item-${String(idx)}`)
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
if (showEllipsis) {
|
|
76
|
+
segments.push(
|
|
77
|
+
/* @__PURE__ */ jsxRuntime.jsx("li", { role: "presentation", className: "flex items-center", children: sep }, "sep-ellipsis")
|
|
78
|
+
);
|
|
79
|
+
segments.push(
|
|
80
|
+
/* @__PURE__ */ jsxRuntime.jsx("li", { className: "flex items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
81
|
+
"button",
|
|
82
|
+
{
|
|
83
|
+
type: "button",
|
|
84
|
+
"aria-label": "Show full path",
|
|
85
|
+
onClick: () => {
|
|
86
|
+
setExpanded(true);
|
|
87
|
+
},
|
|
88
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
89
|
+
"text-text-muted hover:text-text-secondary transition-colors leading-none px-1",
|
|
90
|
+
sizeClasses[size]
|
|
91
|
+
),
|
|
92
|
+
children: "\xB7\xB7\xB7"
|
|
93
|
+
}
|
|
94
|
+
) }, "ellipsis")
|
|
95
|
+
);
|
|
96
|
+
const last = items[items.length - 1];
|
|
97
|
+
if (last != null) {
|
|
98
|
+
segments.push(
|
|
99
|
+
/* @__PURE__ */ jsxRuntime.jsx("li", { role: "presentation", className: "flex items-center", children: sep }, "sep-last")
|
|
100
|
+
);
|
|
101
|
+
segments.push(
|
|
102
|
+
/* @__PURE__ */ jsxRuntime.jsx("li", { className: "flex items-center", children: /* @__PURE__ */ jsxRuntime.jsx(Crumb, { item: last, isCurrent: true, size }) }, "item-last")
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return /* @__PURE__ */ jsxRuntime.jsx("nav", { "aria-label": "Breadcrumb", className: chunkL5VQZZVR_cjs.cn("w-full", className), children: /* @__PURE__ */ jsxRuntime.jsx("ol", { className: chunkL5VQZZVR_cjs.cn("flex flex-wrap items-center gap-1", sizeClasses[size]), children: segments }) });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
exports.Breadcrumbs = Breadcrumbs;
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkL5VQZZVR_cjs = require('./chunk-L5VQZZVR.cjs');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var outline = require('@heroicons/react/24/outline');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
var sizeClasses = {
|
|
9
|
+
xs: "w-8 h-8 text-sm",
|
|
10
|
+
sm: "w-10 h-10 text-base",
|
|
11
|
+
md: "w-12 h-12 text-lg",
|
|
12
|
+
lg: "w-14 h-14 text-xl",
|
|
13
|
+
xl: "w-16 h-16 text-2xl"
|
|
14
|
+
};
|
|
15
|
+
var labelSizeClasses = {
|
|
16
|
+
xs: "text-xs",
|
|
17
|
+
sm: "text-xs",
|
|
18
|
+
md: "text-sm",
|
|
19
|
+
lg: "text-sm",
|
|
20
|
+
xl: "text-base"
|
|
21
|
+
};
|
|
22
|
+
var variantClasses = {
|
|
23
|
+
default: "rounded-md border border-border bg-surface shadow-sm focus:outline-none focus:ring-2 focus:ring-primary/40 focus:ring-offset-0",
|
|
24
|
+
filled: "rounded-md border border-transparent bg-surface-secondary focus:bg-surface focus:outline-none focus:ring-2 focus:ring-primary/40 focus:ring-offset-0",
|
|
25
|
+
flushed: "rounded-none border-0 border-b border-border bg-transparent focus:outline-none focus:ring-0",
|
|
26
|
+
unstyled: "border-0 bg-transparent p-0 focus:outline-none focus:ring-0"
|
|
27
|
+
};
|
|
28
|
+
var stateVariantClasses = {
|
|
29
|
+
default: {
|
|
30
|
+
default: "border-border focus:border-primary focus:ring-primary/40",
|
|
31
|
+
filled: "focus:border-primary focus:ring-primary/40",
|
|
32
|
+
flushed: "border-border focus:border-primary",
|
|
33
|
+
unstyled: ""
|
|
34
|
+
},
|
|
35
|
+
error: {
|
|
36
|
+
default: "border-error focus:border-error focus:ring-error/20",
|
|
37
|
+
filled: "bg-error/5 focus:border-error focus:ring-error/20",
|
|
38
|
+
flushed: "border-error focus:border-error",
|
|
39
|
+
unstyled: ""
|
|
40
|
+
},
|
|
41
|
+
success: {
|
|
42
|
+
default: "border-success focus:border-success focus:ring-success/20",
|
|
43
|
+
filled: "bg-success/5 focus:border-success focus:ring-success/20",
|
|
44
|
+
flushed: "border-success focus:border-success",
|
|
45
|
+
unstyled: ""
|
|
46
|
+
},
|
|
47
|
+
warning: {
|
|
48
|
+
default: "border-warning focus:border-warning focus:ring-warning/20",
|
|
49
|
+
filled: "bg-warning/5 focus:border-warning focus:ring-warning/20",
|
|
50
|
+
flushed: "border-warning focus:border-warning",
|
|
51
|
+
unstyled: ""
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var stateMessageClasses = {
|
|
55
|
+
default: "text-text-muted",
|
|
56
|
+
error: "text-error font-medium",
|
|
57
|
+
success: "text-success font-medium",
|
|
58
|
+
warning: "text-warning font-medium"
|
|
59
|
+
};
|
|
60
|
+
var disabledClasses = "disabled:cursor-not-allowed disabled:opacity-50 disabled:bg-surface-secondary";
|
|
61
|
+
function getStateMessage(state, errorMessage, successMessage, warningMessage) {
|
|
62
|
+
if (state === "error" && errorMessage) return errorMessage;
|
|
63
|
+
if (state === "success" && successMessage) return successMessage;
|
|
64
|
+
if (state === "warning" && warningMessage) return warningMessage;
|
|
65
|
+
return void 0;
|
|
66
|
+
}
|
|
67
|
+
var OtpInput = react.forwardRef(function OtpInput2({
|
|
68
|
+
length = 4,
|
|
69
|
+
value = "",
|
|
70
|
+
onChange,
|
|
71
|
+
onComplete,
|
|
72
|
+
label,
|
|
73
|
+
required = false,
|
|
74
|
+
helperText,
|
|
75
|
+
errorMessage,
|
|
76
|
+
successMessage,
|
|
77
|
+
warningMessage,
|
|
78
|
+
variant = "default",
|
|
79
|
+
size = "md",
|
|
80
|
+
state = "default",
|
|
81
|
+
className,
|
|
82
|
+
wrapperClassName,
|
|
83
|
+
inputGroupClassName,
|
|
84
|
+
inputClassName,
|
|
85
|
+
labelClassName,
|
|
86
|
+
helperClassName,
|
|
87
|
+
id: idProp,
|
|
88
|
+
disabled = false,
|
|
89
|
+
isLoading = false,
|
|
90
|
+
mask = false,
|
|
91
|
+
alphanumeric = false
|
|
92
|
+
}, ref) {
|
|
93
|
+
const generatedId = react.useId();
|
|
94
|
+
const componentId = idProp ?? generatedId;
|
|
95
|
+
const helperId = `${componentId}-helper`;
|
|
96
|
+
const stateMessageId = `${componentId}-state`;
|
|
97
|
+
const [otpValues, setOtpValues] = react.useState(Array.from({ length }, () => ""));
|
|
98
|
+
const inputRefs = react.useRef([]);
|
|
99
|
+
react.useEffect(() => {
|
|
100
|
+
const charArray = value.split("").slice(0, length);
|
|
101
|
+
const newOtpValues = Array.from({ length }, () => "");
|
|
102
|
+
for (let i = 0; i < charArray.length; i++) {
|
|
103
|
+
newOtpValues[i] = charArray[i] ?? "";
|
|
104
|
+
}
|
|
105
|
+
requestAnimationFrame(() => {
|
|
106
|
+
setOtpValues((prev) => {
|
|
107
|
+
const isDifferent = newOtpValues.some((v, idx) => v !== prev[idx]);
|
|
108
|
+
return isDifferent ? newOtpValues : prev;
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}, [value, length]);
|
|
112
|
+
const triggerChange = (newValues) => {
|
|
113
|
+
const stringValue = newValues.join("");
|
|
114
|
+
if (onChange) {
|
|
115
|
+
onChange(stringValue);
|
|
116
|
+
}
|
|
117
|
+
if (onComplete && stringValue.length === length && !newValues.includes("")) {
|
|
118
|
+
onComplete(stringValue);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const focusInput = (index) => {
|
|
122
|
+
if (index >= 0 && index < length) {
|
|
123
|
+
inputRefs.current[index]?.focus();
|
|
124
|
+
setTimeout(() => {
|
|
125
|
+
inputRefs.current[index]?.setSelectionRange(1, 1);
|
|
126
|
+
}, 0);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const handleInputChange = (e, index) => {
|
|
130
|
+
let safeChar = e.target.value;
|
|
131
|
+
if (safeChar.length > 1) {
|
|
132
|
+
safeChar = safeChar.slice(-1);
|
|
133
|
+
}
|
|
134
|
+
if (!alphanumeric && safeChar && !/^\d+$/.test(safeChar)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (alphanumeric && safeChar && !/^[a-zA-Z0-9]+$/.test(safeChar)) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const newValues = [...otpValues];
|
|
141
|
+
newValues[index] = safeChar;
|
|
142
|
+
setOtpValues(newValues);
|
|
143
|
+
triggerChange(newValues);
|
|
144
|
+
if (safeChar && index < length - 1) {
|
|
145
|
+
focusInput(index + 1);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const handleKeyDown = (e, index) => {
|
|
149
|
+
if (e.key === "Backspace") {
|
|
150
|
+
if (!otpValues[index] && index > 0) {
|
|
151
|
+
e.preventDefault();
|
|
152
|
+
const newValues = [...otpValues];
|
|
153
|
+
newValues[index - 1] = "";
|
|
154
|
+
setOtpValues(newValues);
|
|
155
|
+
triggerChange(newValues);
|
|
156
|
+
focusInput(index - 1);
|
|
157
|
+
}
|
|
158
|
+
} else if (e.key === "ArrowLeft" && index > 0) {
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
focusInput(index - 1);
|
|
161
|
+
} else if (e.key === "ArrowRight" && index < length - 1) {
|
|
162
|
+
e.preventDefault();
|
|
163
|
+
focusInput(index + 1);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const handlePaste = (e) => {
|
|
167
|
+
e.preventDefault();
|
|
168
|
+
let pastedData = e.clipboardData.getData("text/plain").trim();
|
|
169
|
+
if (!alphanumeric) {
|
|
170
|
+
pastedData = pastedData.replace(/[^\d]/g, "");
|
|
171
|
+
} else {
|
|
172
|
+
pastedData = pastedData.replace(/[^a-zA-Z0-9]/g, "");
|
|
173
|
+
}
|
|
174
|
+
if (!pastedData) return;
|
|
175
|
+
const newValues = [...otpValues];
|
|
176
|
+
let focusIndex = -1;
|
|
177
|
+
for (let i = 0; i < length; i++) {
|
|
178
|
+
if (i < pastedData.length) {
|
|
179
|
+
newValues[i] = pastedData[i] ?? "";
|
|
180
|
+
focusIndex = i;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
setOtpValues(newValues);
|
|
184
|
+
triggerChange(newValues);
|
|
185
|
+
if (focusIndex > -1) {
|
|
186
|
+
focusInput(Math.min(focusIndex + 1, length - 1));
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
const stateMessage = getStateMessage(state, errorMessage, successMessage, warningMessage);
|
|
190
|
+
const isComponentDisabled = disabled || isLoading;
|
|
191
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
192
|
+
"div",
|
|
193
|
+
{
|
|
194
|
+
ref,
|
|
195
|
+
id: componentId,
|
|
196
|
+
className: chunkL5VQZZVR_cjs.cn("flex flex-col gap-2 w-fit", wrapperClassName, className),
|
|
197
|
+
children: [
|
|
198
|
+
label !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
199
|
+
"label",
|
|
200
|
+
{
|
|
201
|
+
htmlFor: `${componentId}-0`,
|
|
202
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
203
|
+
"font-black leading-none text-text uppercase tracking-widest",
|
|
204
|
+
labelSizeClasses[size],
|
|
205
|
+
labelClassName
|
|
206
|
+
),
|
|
207
|
+
children: [
|
|
208
|
+
label,
|
|
209
|
+
required && /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "ml-1 text-error", children: "*" })
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
),
|
|
213
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkL5VQZZVR_cjs.cn("flex items-center gap-2", inputGroupClassName), children: [
|
|
214
|
+
otpValues.map((digit, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
215
|
+
"input",
|
|
216
|
+
{
|
|
217
|
+
id: `${componentId}-${String(index)}`,
|
|
218
|
+
ref: (el) => {
|
|
219
|
+
inputRefs.current[index] = el;
|
|
220
|
+
},
|
|
221
|
+
type: mask ? "password" : "text",
|
|
222
|
+
inputMode: !alphanumeric ? "numeric" : "text",
|
|
223
|
+
autoComplete: "one-time-code",
|
|
224
|
+
maxLength: 1,
|
|
225
|
+
disabled: isComponentDisabled,
|
|
226
|
+
value: digit,
|
|
227
|
+
onChange: (e) => {
|
|
228
|
+
handleInputChange(e, index);
|
|
229
|
+
},
|
|
230
|
+
onKeyDown: (e) => {
|
|
231
|
+
handleKeyDown(e, index);
|
|
232
|
+
},
|
|
233
|
+
onPaste: handlePaste,
|
|
234
|
+
"aria-invalid": state === "error" ? true : void 0,
|
|
235
|
+
"aria-describedby": [helperId, stateMessageId].filter(Boolean).join(" ") || void 0,
|
|
236
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
237
|
+
"text-center transition-colors duration-150",
|
|
238
|
+
sizeClasses[size],
|
|
239
|
+
variantClasses[variant],
|
|
240
|
+
stateVariantClasses[state][variant],
|
|
241
|
+
disabledClasses,
|
|
242
|
+
inputClassName
|
|
243
|
+
)
|
|
244
|
+
},
|
|
245
|
+
`${componentId}-${String(index)}`
|
|
246
|
+
)),
|
|
247
|
+
isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-2", children: /* @__PURE__ */ jsxRuntime.jsx(outline.ArrowPathIcon, { className: "animate-spin h-5 w-5 text-gray-400" }) })
|
|
248
|
+
] }),
|
|
249
|
+
helperText !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
250
|
+
"p",
|
|
251
|
+
{
|
|
252
|
+
id: helperId,
|
|
253
|
+
className: chunkL5VQZZVR_cjs.cn("text-xs leading-tight text-text-muted font-medium", helperClassName),
|
|
254
|
+
children: helperText
|
|
255
|
+
}
|
|
256
|
+
),
|
|
257
|
+
stateMessage !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
258
|
+
"p",
|
|
259
|
+
{
|
|
260
|
+
id: stateMessageId,
|
|
261
|
+
role: state === "error" ? "alert" : void 0,
|
|
262
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
263
|
+
"text-xs leading-tight font-medium",
|
|
264
|
+
stateMessageClasses[state],
|
|
265
|
+
helperClassName
|
|
266
|
+
),
|
|
267
|
+
children: stateMessage
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
});
|
|
274
|
+
OtpInput.displayName = "OtpInput";
|
|
275
|
+
|
|
276
|
+
exports.OtpInput = OtpInput;
|