@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,187 @@
|
|
|
1
|
+
import { cn } from './chunk-OCPFOFJ4.mjs';
|
|
2
|
+
import { useRef, useCallback, useEffect } from 'react';
|
|
3
|
+
import { XMarkIcon } from '@heroicons/react/24/outline';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var sizeClasses = {
|
|
8
|
+
xs: "max-w-xs",
|
|
9
|
+
sm: "max-w-sm",
|
|
10
|
+
md: "max-w-md",
|
|
11
|
+
lg: "max-w-lg",
|
|
12
|
+
xl: "max-w-xl",
|
|
13
|
+
"2xl": "max-w-2xl",
|
|
14
|
+
"3xl": "max-w-3xl",
|
|
15
|
+
"4xl": "max-w-4xl",
|
|
16
|
+
"5xl": "max-w-5xl",
|
|
17
|
+
"6xl": "max-w-6xl",
|
|
18
|
+
"7xl": "max-w-7xl",
|
|
19
|
+
full: "max-w-full m-0 rounded-none h-full"
|
|
20
|
+
};
|
|
21
|
+
function Dialog({
|
|
22
|
+
isOpen,
|
|
23
|
+
onClose,
|
|
24
|
+
children,
|
|
25
|
+
size = "md",
|
|
26
|
+
isCentered = false,
|
|
27
|
+
closeOnOverlayClick = true,
|
|
28
|
+
closeOnEsc = true,
|
|
29
|
+
trapFocus = true,
|
|
30
|
+
lockScroll = true,
|
|
31
|
+
contentClassName,
|
|
32
|
+
overlayClassName,
|
|
33
|
+
showBackdrop = true,
|
|
34
|
+
isModal = true,
|
|
35
|
+
ariaLabel,
|
|
36
|
+
ariaLabelledby,
|
|
37
|
+
ariaDescribedby
|
|
38
|
+
}) {
|
|
39
|
+
const dialogRef = useRef(null);
|
|
40
|
+
const previousFocusRef = useRef(null);
|
|
41
|
+
const handleClose = useCallback(() => {
|
|
42
|
+
onClose();
|
|
43
|
+
}, [onClose]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (isOpen) {
|
|
46
|
+
previousFocusRef.current = document.activeElement;
|
|
47
|
+
if (isModal && lockScroll) {
|
|
48
|
+
document.body.style.overflow = "hidden";
|
|
49
|
+
}
|
|
50
|
+
const handleKeyDown = (e) => {
|
|
51
|
+
if (closeOnEsc && e.key === "Escape") {
|
|
52
|
+
handleClose();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (isModal && trapFocus && e.key === "Tab") {
|
|
56
|
+
const focusableElements = dialogRef.current?.querySelectorAll(
|
|
57
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
58
|
+
);
|
|
59
|
+
if (!focusableElements || focusableElements.length === 0) return;
|
|
60
|
+
const firstElement = focusableElements[0];
|
|
61
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
62
|
+
if (e.shiftKey) {
|
|
63
|
+
if (document.activeElement === firstElement) {
|
|
64
|
+
lastElement.focus();
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
if (document.activeElement === lastElement) {
|
|
69
|
+
firstElement.focus();
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
76
|
+
if (isModal) {
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
const firstFocusable = dialogRef.current?.querySelector(
|
|
79
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
80
|
+
);
|
|
81
|
+
if (firstFocusable != null) {
|
|
82
|
+
firstFocusable.focus();
|
|
83
|
+
} else {
|
|
84
|
+
dialogRef.current?.focus();
|
|
85
|
+
}
|
|
86
|
+
}, 0);
|
|
87
|
+
}
|
|
88
|
+
return () => {
|
|
89
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
90
|
+
if (isModal && lockScroll) {
|
|
91
|
+
document.body.style.overflow = "";
|
|
92
|
+
}
|
|
93
|
+
previousFocusRef.current?.focus();
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return void 0;
|
|
97
|
+
}, [isOpen, closeOnEsc, handleClose, lockScroll, trapFocus, isModal]);
|
|
98
|
+
if (!isOpen) return null;
|
|
99
|
+
return createPortal(
|
|
100
|
+
/* @__PURE__ */ jsx(
|
|
101
|
+
"div",
|
|
102
|
+
{
|
|
103
|
+
role: "presentation",
|
|
104
|
+
className: cn(
|
|
105
|
+
"fixed inset-0 z-50 flex items-start justify-center p-4 sm:p-6 overflow-y-auto transition-opacity duration-300",
|
|
106
|
+
showBackdrop && "bg-black/60 backdrop-blur-sm",
|
|
107
|
+
!isModal && "pointer-events-none",
|
|
108
|
+
isCentered && "items-center",
|
|
109
|
+
overlayClassName
|
|
110
|
+
),
|
|
111
|
+
onClick: (e) => {
|
|
112
|
+
if (closeOnOverlayClick && e.target === e.currentTarget) {
|
|
113
|
+
handleClose();
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
children: /* @__PURE__ */ jsx(
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
ref: dialogRef,
|
|
120
|
+
role: "dialog",
|
|
121
|
+
tabIndex: -1,
|
|
122
|
+
"aria-modal": isModal ? "true" : "false",
|
|
123
|
+
"aria-label": ariaLabel,
|
|
124
|
+
"aria-labelledby": ariaLabelledby,
|
|
125
|
+
"aria-describedby": ariaDescribedby,
|
|
126
|
+
className: cn(
|
|
127
|
+
"relative w-full mx-auto bg-surface rounded-xl shadow-lg border border-border transition-all duration-300 transform scale-100 opacity-100 flex flex-col",
|
|
128
|
+
size !== "full" && "max-h-[90vh]",
|
|
129
|
+
!isModal && "pointer-events-auto",
|
|
130
|
+
sizeClasses[size],
|
|
131
|
+
contentClassName
|
|
132
|
+
),
|
|
133
|
+
children
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
),
|
|
138
|
+
document.body
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
function DialogHeader({ children, className }) {
|
|
142
|
+
return /* @__PURE__ */ jsx("div", { className: cn("px-6 py-5 border-b border-border/60", className), children: /* @__PURE__ */ jsx("h2", { className: "text-xl font-bold text-text uppercase tracking-wider", children }) });
|
|
143
|
+
}
|
|
144
|
+
function DialogBody({ children, className }) {
|
|
145
|
+
return /* @__PURE__ */ jsx(
|
|
146
|
+
"div",
|
|
147
|
+
{
|
|
148
|
+
className: cn(
|
|
149
|
+
"px-6 py-6 overflow-y-auto flex-1 text-text-secondary leading-relaxed font-medium",
|
|
150
|
+
className
|
|
151
|
+
),
|
|
152
|
+
children
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
function DialogFooter({ children, className }) {
|
|
157
|
+
return /* @__PURE__ */ jsx(
|
|
158
|
+
"div",
|
|
159
|
+
{
|
|
160
|
+
className: cn(
|
|
161
|
+
"px-6 py-4 bg-surface-secondary border-t border-border flex items-center justify-end gap-3 rounded-b-xl",
|
|
162
|
+
className
|
|
163
|
+
),
|
|
164
|
+
children
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
function DialogCloseButton({
|
|
169
|
+
onClick,
|
|
170
|
+
className
|
|
171
|
+
}) {
|
|
172
|
+
return /* @__PURE__ */ jsx(
|
|
173
|
+
"button",
|
|
174
|
+
{
|
|
175
|
+
type: "button",
|
|
176
|
+
onClick,
|
|
177
|
+
className: cn(
|
|
178
|
+
"absolute top-4 right-4 p-2 text-text-muted hover:text-text hover:bg-hover rounded-lg transition-all duration-fast",
|
|
179
|
+
className
|
|
180
|
+
),
|
|
181
|
+
"aria-label": "Close dialog",
|
|
182
|
+
children: /* @__PURE__ */ jsx(XMarkIcon, { className: "w-5 h-5" })
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export { Dialog, DialogBody, DialogCloseButton, DialogFooter, DialogHeader };
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkL5VQZZVR_cjs = require('./chunk-L5VQZZVR.cjs');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var reactDom = require('react-dom');
|
|
6
|
+
var outline = require('@heroicons/react/24/outline');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
var sizeClasses = {
|
|
10
|
+
xs: "max-w-xs",
|
|
11
|
+
sm: "max-w-sm",
|
|
12
|
+
md: "max-w-md",
|
|
13
|
+
lg: "max-w-lg",
|
|
14
|
+
xl: "max-w-xl",
|
|
15
|
+
"2xl": "max-w-2xl",
|
|
16
|
+
"3xl": "max-w-3xl",
|
|
17
|
+
"4xl": "max-w-4xl",
|
|
18
|
+
"5xl": "max-w-5xl",
|
|
19
|
+
"6xl": "max-w-6xl",
|
|
20
|
+
"7xl": "max-w-7xl",
|
|
21
|
+
full: "max-w-full w-full h-full m-0 rounded-none"
|
|
22
|
+
};
|
|
23
|
+
var sideSheetWidthClasses = {
|
|
24
|
+
xs: "w-64",
|
|
25
|
+
sm: "w-80",
|
|
26
|
+
md: "w-96",
|
|
27
|
+
lg: "w-[30rem]",
|
|
28
|
+
xl: "w-[36rem]",
|
|
29
|
+
"2xl": "w-[42rem]",
|
|
30
|
+
"3xl": "w-[48rem]",
|
|
31
|
+
"4xl": "w-[56rem]",
|
|
32
|
+
"5xl": "w-[64rem]",
|
|
33
|
+
"6xl": "w-[72rem]",
|
|
34
|
+
"7xl": "w-[80rem]",
|
|
35
|
+
full: "w-full"
|
|
36
|
+
};
|
|
37
|
+
var variantClasses = {
|
|
38
|
+
default: "bg-surface border border-border shadow-[0_20px_60px_-10px_rgba(0,0,0,0.2),0_8px_20px_-8px_rgba(0,0,0,0.1)]",
|
|
39
|
+
glass: "bg-white/10 dark:bg-black/20 backdrop-blur-xl border border-white/20 dark:border-white/10 shadow-[0_25px_50px_-12px_rgba(0,0,0,0.4)]",
|
|
40
|
+
flat: "bg-surface shadow-[0_4px_24px_rgba(0,0,0,0.08)]"
|
|
41
|
+
};
|
|
42
|
+
var overlayPositionClasses = {
|
|
43
|
+
top: "items-start pt-16",
|
|
44
|
+
center: "items-center",
|
|
45
|
+
bottom: "items-end pb-0",
|
|
46
|
+
left: "items-stretch justify-start p-0",
|
|
47
|
+
right: "items-stretch justify-end p-0"
|
|
48
|
+
};
|
|
49
|
+
var contentPositionClasses = {
|
|
50
|
+
top: "",
|
|
51
|
+
center: "",
|
|
52
|
+
bottom: "rounded-b-none w-full max-w-full",
|
|
53
|
+
left: "rounded-l-none rounded-r-2xl h-full max-h-full my-0",
|
|
54
|
+
right: "rounded-r-none rounded-l-2xl h-full max-h-full my-0"
|
|
55
|
+
};
|
|
56
|
+
var Modal = function Modal2({
|
|
57
|
+
isOpen,
|
|
58
|
+
onClose,
|
|
59
|
+
children,
|
|
60
|
+
size = "md",
|
|
61
|
+
variant = "default",
|
|
62
|
+
position = "center",
|
|
63
|
+
closeOnOverlayClick = true,
|
|
64
|
+
closeOnEsc = true,
|
|
65
|
+
trapFocus = true,
|
|
66
|
+
lockScroll = true,
|
|
67
|
+
contentClassName,
|
|
68
|
+
overlayClassName,
|
|
69
|
+
showBackdrop = true,
|
|
70
|
+
ariaLabel,
|
|
71
|
+
ariaLabelledby,
|
|
72
|
+
ariaDescribedby
|
|
73
|
+
}) {
|
|
74
|
+
const modalRef = react.useRef(null);
|
|
75
|
+
const previousFocusRef = react.useRef(null);
|
|
76
|
+
const handleClose = react.useCallback(() => {
|
|
77
|
+
onClose();
|
|
78
|
+
}, [onClose]);
|
|
79
|
+
react.useEffect(() => {
|
|
80
|
+
if (isOpen) {
|
|
81
|
+
previousFocusRef.current = document.activeElement;
|
|
82
|
+
if (lockScroll) {
|
|
83
|
+
document.body.style.overflow = "hidden";
|
|
84
|
+
}
|
|
85
|
+
const handleKeyDown = (e) => {
|
|
86
|
+
if (closeOnEsc && e.key === "Escape") {
|
|
87
|
+
handleClose();
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (trapFocus && e.key === "Tab") {
|
|
91
|
+
const focusableElements = modalRef.current?.querySelectorAll(
|
|
92
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
93
|
+
);
|
|
94
|
+
if (!focusableElements || focusableElements.length === 0) return;
|
|
95
|
+
const firstElement = focusableElements[0];
|
|
96
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
97
|
+
if (e.shiftKey) {
|
|
98
|
+
if (document.activeElement === firstElement) {
|
|
99
|
+
lastElement.focus();
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
if (document.activeElement === lastElement) {
|
|
104
|
+
firstElement.focus();
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
111
|
+
setTimeout(() => {
|
|
112
|
+
const firstFocusable = modalRef.current?.querySelector(
|
|
113
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
114
|
+
);
|
|
115
|
+
if (firstFocusable != null) {
|
|
116
|
+
firstFocusable.focus();
|
|
117
|
+
} else {
|
|
118
|
+
modalRef.current?.focus();
|
|
119
|
+
}
|
|
120
|
+
}, 50);
|
|
121
|
+
return () => {
|
|
122
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
123
|
+
if (lockScroll) {
|
|
124
|
+
document.body.style.overflow = "";
|
|
125
|
+
}
|
|
126
|
+
previousFocusRef.current?.focus();
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return void 0;
|
|
130
|
+
}, [isOpen, closeOnEsc, handleClose, lockScroll, trapFocus]);
|
|
131
|
+
if (!isOpen) return null;
|
|
132
|
+
const isBottomSheet = position === "bottom";
|
|
133
|
+
const isLeftSheet = position === "left";
|
|
134
|
+
const isRightSheet = position === "right";
|
|
135
|
+
const isSideSheet = isLeftSheet || isRightSheet;
|
|
136
|
+
let entryAnimation = "animate-[modal-zoom-in_200ms_cubic-bezier(0.34,1.56,0.64,1)_forwards]";
|
|
137
|
+
if (isBottomSheet)
|
|
138
|
+
entryAnimation = "animate-[modal-slide-up_250ms_cubic-bezier(0.32,0.72,0,1)_forwards]";
|
|
139
|
+
if (isLeftSheet)
|
|
140
|
+
entryAnimation = "animate-[modal-slide-right_250ms_cubic-bezier(0.32,0.72,0,1)_forwards]";
|
|
141
|
+
if (isRightSheet)
|
|
142
|
+
entryAnimation = "animate-[modal-slide-left_250ms_cubic-bezier(0.32,0.72,0,1)_forwards]";
|
|
143
|
+
const sizeClass = isSideSheet ? sideSheetWidthClasses[size] : sizeClasses[size];
|
|
144
|
+
return reactDom.createPortal(
|
|
145
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
146
|
+
"div",
|
|
147
|
+
{
|
|
148
|
+
role: "presentation",
|
|
149
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
150
|
+
"fixed inset-0 z-[1050] flex justify-center",
|
|
151
|
+
// Side sheets don't scroll — they're full-height
|
|
152
|
+
!isSideSheet && "overflow-y-auto p-4",
|
|
153
|
+
showBackdrop && "bg-black/50 backdrop-blur-[3px]",
|
|
154
|
+
"animate-[modal-overlay-in_200ms_ease-out_forwards]",
|
|
155
|
+
overlayPositionClasses[position],
|
|
156
|
+
overlayClassName
|
|
157
|
+
),
|
|
158
|
+
onClick: (e) => {
|
|
159
|
+
if (closeOnOverlayClick && e.target === e.currentTarget) {
|
|
160
|
+
handleClose();
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
164
|
+
"div",
|
|
165
|
+
{
|
|
166
|
+
ref: modalRef,
|
|
167
|
+
role: "dialog",
|
|
168
|
+
tabIndex: -1,
|
|
169
|
+
"aria-modal": "true",
|
|
170
|
+
"aria-label": ariaLabel,
|
|
171
|
+
"aria-labelledby": ariaLabelledby,
|
|
172
|
+
"aria-describedby": ariaDescribedby,
|
|
173
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
174
|
+
// Base
|
|
175
|
+
"relative flex flex-col",
|
|
176
|
+
// Standard dialogs are centered with max-height
|
|
177
|
+
!isSideSheet && !isBottomSheet && size !== "full" && "w-full mx-auto max-h-[90vh] my-4 rounded-2xl",
|
|
178
|
+
// Bottom sheet
|
|
179
|
+
isBottomSheet && "rounded-2xl",
|
|
180
|
+
// Side sheets: no mx-auto, no max-height
|
|
181
|
+
isSideSheet && "mx-0",
|
|
182
|
+
// Entry animation
|
|
183
|
+
entryAnimation,
|
|
184
|
+
// Variant
|
|
185
|
+
variantClasses[variant],
|
|
186
|
+
// Size (width for side sheets, max-width otherwise)
|
|
187
|
+
sizeClass,
|
|
188
|
+
// Position-specific shape overrides
|
|
189
|
+
contentPositionClasses[position],
|
|
190
|
+
contentClassName
|
|
191
|
+
),
|
|
192
|
+
children
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
),
|
|
197
|
+
document.body
|
|
198
|
+
);
|
|
199
|
+
};
|
|
200
|
+
function ModalHeader({
|
|
201
|
+
children,
|
|
202
|
+
className,
|
|
203
|
+
icon,
|
|
204
|
+
description
|
|
205
|
+
}) {
|
|
206
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkL5VQZZVR_cjs.cn("relative px-6 py-5 border-b border-border/60 flex-shrink-0", className), children: [
|
|
207
|
+
icon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-3 w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary", children: icon }),
|
|
208
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold text-text leading-tight tracking-tight", children }),
|
|
209
|
+
description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-text-muted leading-relaxed", children: description })
|
|
210
|
+
] });
|
|
211
|
+
}
|
|
212
|
+
function ModalBody({
|
|
213
|
+
children,
|
|
214
|
+
className,
|
|
215
|
+
noPadding = false
|
|
216
|
+
}) {
|
|
217
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
218
|
+
"div",
|
|
219
|
+
{
|
|
220
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
221
|
+
"flex-1 overflow-y-auto text-text-secondary text-sm leading-relaxed",
|
|
222
|
+
!noPadding && "px-6 py-5",
|
|
223
|
+
className
|
|
224
|
+
),
|
|
225
|
+
children
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
var footerAlignClasses = {
|
|
230
|
+
left: "justify-start",
|
|
231
|
+
center: "justify-center",
|
|
232
|
+
right: "justify-end"
|
|
233
|
+
};
|
|
234
|
+
function ModalFooter({
|
|
235
|
+
children,
|
|
236
|
+
className,
|
|
237
|
+
align = "right"
|
|
238
|
+
}) {
|
|
239
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
240
|
+
"div",
|
|
241
|
+
{
|
|
242
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
243
|
+
"flex-shrink-0 px-6 py-4 border-t border-border/60 bg-surface-secondary/30 flex flex-wrap items-center gap-3 rounded-b-2xl",
|
|
244
|
+
footerAlignClasses[align],
|
|
245
|
+
className
|
|
246
|
+
),
|
|
247
|
+
children
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
function ModalCloseButton({ onClick, className }) {
|
|
252
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
253
|
+
"button",
|
|
254
|
+
{
|
|
255
|
+
type: "button",
|
|
256
|
+
onClick,
|
|
257
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
258
|
+
"absolute top-4 right-4 z-10",
|
|
259
|
+
"w-8 h-8 flex items-center justify-center rounded-lg",
|
|
260
|
+
"text-text-muted hover:text-text",
|
|
261
|
+
"bg-transparent hover:bg-hover",
|
|
262
|
+
"transition-all duration-150",
|
|
263
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",
|
|
264
|
+
className
|
|
265
|
+
),
|
|
266
|
+
"aria-label": "Close modal",
|
|
267
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(outline.XMarkIcon, { className: "w-4 h-4", strokeWidth: 2 })
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
Modal.Header = ModalHeader;
|
|
272
|
+
Modal.Body = ModalBody;
|
|
273
|
+
Modal.Footer = ModalFooter;
|
|
274
|
+
Modal.CloseButton = ModalCloseButton;
|
|
275
|
+
|
|
276
|
+
exports.Modal = Modal;
|
|
277
|
+
exports.ModalBody = ModalBody;
|
|
278
|
+
exports.ModalCloseButton = ModalCloseButton;
|
|
279
|
+
exports.ModalFooter = ModalFooter;
|
|
280
|
+
exports.ModalHeader = ModalHeader;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { cn } from './chunk-OCPFOFJ4.mjs';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { ChevronRightIcon, ChevronLeftIcon, ChevronDownIcon } from '@heroicons/react/24/outline';
|
|
4
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var Sidebar = ({
|
|
7
|
+
groups,
|
|
8
|
+
isCollapsed: controlledIsCollapsed,
|
|
9
|
+
onToggleCollapse,
|
|
10
|
+
logo,
|
|
11
|
+
footer,
|
|
12
|
+
className,
|
|
13
|
+
glass = false,
|
|
14
|
+
width = 288,
|
|
15
|
+
collapsedWidth = 80,
|
|
16
|
+
showToggleButton = false,
|
|
17
|
+
togglePosition = "center",
|
|
18
|
+
position = "left",
|
|
19
|
+
centerIcons = true,
|
|
20
|
+
classNames = {},
|
|
21
|
+
styles = {},
|
|
22
|
+
renderItem
|
|
23
|
+
}) => {
|
|
24
|
+
const [internalIsCollapsed, setInternalIsCollapsed] = useState(false);
|
|
25
|
+
const [expandedItems, setExpandedItems] = useState({});
|
|
26
|
+
const isCollapsed = controlledIsCollapsed ?? internalIsCollapsed;
|
|
27
|
+
const handleToggle = () => {
|
|
28
|
+
const newState = !isCollapsed;
|
|
29
|
+
if (onToggleCollapse) {
|
|
30
|
+
onToggleCollapse(newState);
|
|
31
|
+
} else {
|
|
32
|
+
setInternalIsCollapsed(newState);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const toggleItemExpanded = (id) => {
|
|
36
|
+
setExpandedItems((prev) => ({
|
|
37
|
+
...prev,
|
|
38
|
+
[id]: !prev[id]
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
41
|
+
const sidebarWidth = isCollapsed ? collapsedWidth : width;
|
|
42
|
+
const renderSidebarItem = (item, level = 0) => {
|
|
43
|
+
if (item.hidden) return null;
|
|
44
|
+
if (renderItem) {
|
|
45
|
+
return /* @__PURE__ */ jsx("div", { children: renderItem(item, isCollapsed) }, item.id);
|
|
46
|
+
}
|
|
47
|
+
const hasChildren = item.items && item.items.length > 0;
|
|
48
|
+
const isExpanded = expandedItems[item.id] ?? !!item.isExpanded;
|
|
49
|
+
const Component = item.component ?? "button";
|
|
50
|
+
const itemContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
51
|
+
item.icon && /* @__PURE__ */ jsx(
|
|
52
|
+
"span",
|
|
53
|
+
{
|
|
54
|
+
className: cn(
|
|
55
|
+
"shrink-0 transition-colors duration-normal",
|
|
56
|
+
item.isActive ? "text-text-inverse" : "text-text-muted group-hover:text-text",
|
|
57
|
+
isCollapsed && centerIcons && "mx-auto",
|
|
58
|
+
classNames.itemIcon
|
|
59
|
+
),
|
|
60
|
+
style: styles.itemIcon,
|
|
61
|
+
children: item.icon
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
!isCollapsed && /* @__PURE__ */ jsx("span", { className: cn("truncate", classNames.itemLabel), style: styles.itemLabel, children: item.label }),
|
|
65
|
+
!isCollapsed && /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-2", children: [
|
|
66
|
+
item.badge && /* @__PURE__ */ jsx("span", { className: "shrink-0", children: item.badge }),
|
|
67
|
+
hasChildren && /* @__PURE__ */ jsx(
|
|
68
|
+
ChevronDownIcon,
|
|
69
|
+
{
|
|
70
|
+
className: cn(
|
|
71
|
+
"w-4 h-4 transition-transform duration-normal",
|
|
72
|
+
isExpanded && "rotate-180"
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
] }),
|
|
77
|
+
isCollapsed && /* @__PURE__ */ jsx("div", { className: "absolute left-full ml-2 px-2 py-1 bg-surface-secondary border border-border rounded shadow-lg text-xs opacity-0 pointer-events-none group-hover:opacity-100 transition-opacity z-index-tooltip whitespace-nowrap text-text", children: item.label })
|
|
78
|
+
] });
|
|
79
|
+
return /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
80
|
+
/* @__PURE__ */ jsx(
|
|
81
|
+
Component,
|
|
82
|
+
{
|
|
83
|
+
type: Component === "button" ? "button" : void 0,
|
|
84
|
+
onClick: (e) => {
|
|
85
|
+
if (hasChildren && !isCollapsed) {
|
|
86
|
+
e.preventDefault();
|
|
87
|
+
toggleItemExpanded(item.id);
|
|
88
|
+
}
|
|
89
|
+
item.onClick?.();
|
|
90
|
+
},
|
|
91
|
+
className: cn(
|
|
92
|
+
"w-full flex items-center gap-4 transition-all duration-normal group relative text-base rounded-lg",
|
|
93
|
+
level === 0 ? "px-4 py-3" : "px-3 py-2 pl-10",
|
|
94
|
+
item.isActive ? "bg-black text-text-inverse shadow-md shadow-black/20 font-bold" : "text-text-secondary hover:bg-hover hover:text-text",
|
|
95
|
+
isCollapsed && "justify-center px-0",
|
|
96
|
+
item.isActive && classNames.itemActive,
|
|
97
|
+
isCollapsed && classNames.itemCollapsed,
|
|
98
|
+
classNames.item
|
|
99
|
+
),
|
|
100
|
+
style: styles.item,
|
|
101
|
+
title: isCollapsed ? item.label : void 0,
|
|
102
|
+
...item.componentProps ?? {},
|
|
103
|
+
children: itemContent
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
hasChildren && isExpanded && !isCollapsed && /* @__PURE__ */ jsx("div", { className: "mt-1 space-y-1", children: item.items?.map((child) => renderSidebarItem(child, level + 1)) })
|
|
107
|
+
] }, item.id);
|
|
108
|
+
};
|
|
109
|
+
const toggleBtn = showToggleButton && /* @__PURE__ */ jsx(
|
|
110
|
+
"button",
|
|
111
|
+
{
|
|
112
|
+
onClick: handleToggle,
|
|
113
|
+
className: cn(
|
|
114
|
+
"absolute z-index-popover flex items-center justify-center w-8 h-8 rounded-full bg-surface border border-border shadow-sm hover:shadow-md transition-all duration-normal hover:bg-hover text-text-muted hover:text-text",
|
|
115
|
+
position === "left" ? "-right-4" : "-left-4",
|
|
116
|
+
togglePosition === "top" && "top-12",
|
|
117
|
+
togglePosition === "center" && "top-1/2 -translate-y-1/2",
|
|
118
|
+
togglePosition === "bottom" && "bottom-12",
|
|
119
|
+
classNames.toggleButton
|
|
120
|
+
),
|
|
121
|
+
style: styles.toggleButton,
|
|
122
|
+
"aria-label": isCollapsed ? "Expand sidebar" : "Collapse sidebar",
|
|
123
|
+
children: isCollapsed ? position === "left" ? /* @__PURE__ */ jsx(ChevronRightIcon, { className: "w-4 h-4" }) : /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "w-4 h-4" }) : position === "left" ? /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "w-4 h-4" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "w-4 h-4" })
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
return /* @__PURE__ */ jsxs(
|
|
127
|
+
"aside",
|
|
128
|
+
{
|
|
129
|
+
className: cn(
|
|
130
|
+
"flex flex-col h-full bg-surface transition-all duration-slow ease-in-out z-index-sticky shadow-premium relative",
|
|
131
|
+
position === "right" && "border-l border-border",
|
|
132
|
+
position === "left" && "border-r border-border",
|
|
133
|
+
glass && "glass",
|
|
134
|
+
classNames.root,
|
|
135
|
+
className
|
|
136
|
+
),
|
|
137
|
+
style: {
|
|
138
|
+
width: sidebarWidth,
|
|
139
|
+
...styles.root
|
|
140
|
+
},
|
|
141
|
+
children: [
|
|
142
|
+
toggleBtn,
|
|
143
|
+
logo && /* @__PURE__ */ jsx(
|
|
144
|
+
"div",
|
|
145
|
+
{
|
|
146
|
+
className: cn(
|
|
147
|
+
"flex items-center px-6 pt-10 pb-6",
|
|
148
|
+
isCollapsed && "justify-center px-0",
|
|
149
|
+
classNames.header
|
|
150
|
+
),
|
|
151
|
+
style: styles.header,
|
|
152
|
+
children: logo
|
|
153
|
+
}
|
|
154
|
+
),
|
|
155
|
+
/* @__PURE__ */ jsx(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
className: cn(
|
|
159
|
+
"flex-1 overflow-y-auto overflow-x-hidden px-4 py-6 space-y-10 custom-scrollbar",
|
|
160
|
+
classNames.content
|
|
161
|
+
),
|
|
162
|
+
style: styles.content,
|
|
163
|
+
children: groups.map((group) => {
|
|
164
|
+
if (group.hidden) return null;
|
|
165
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("space-y-4", classNames.group), style: styles.group, children: [
|
|
166
|
+
group.label && !isCollapsed && /* @__PURE__ */ jsx(
|
|
167
|
+
"h3",
|
|
168
|
+
{
|
|
169
|
+
className: cn(
|
|
170
|
+
"px-2 text-xs font-bold text-text-muted uppercase tracking-wider",
|
|
171
|
+
classNames.groupLabel
|
|
172
|
+
),
|
|
173
|
+
style: styles.groupLabel,
|
|
174
|
+
children: group.label
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1", children: group.items.map((item) => renderSidebarItem(item)) })
|
|
178
|
+
] }, group.id);
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
),
|
|
182
|
+
footer && /* @__PURE__ */ jsx(
|
|
183
|
+
"div",
|
|
184
|
+
{
|
|
185
|
+
className: cn(
|
|
186
|
+
"p-6 mt-auto border-t border-border/50",
|
|
187
|
+
isCollapsed && "flex justify-center px-0",
|
|
188
|
+
classNames.footer
|
|
189
|
+
),
|
|
190
|
+
style: styles.footer,
|
|
191
|
+
children: footer
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
};
|
|
198
|
+
Sidebar.displayName = "Sidebar";
|
|
199
|
+
|
|
200
|
+
export { Sidebar };
|