@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,115 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkS7VEND5Z_cjs = require('./chunk-S7VEND5Z.cjs');
|
|
4
|
+
var chunkL5VQZZVR_cjs = require('./chunk-L5VQZZVR.cjs');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
var Image = react.forwardRef(function Image2({
|
|
9
|
+
src,
|
|
10
|
+
alt,
|
|
11
|
+
fallback,
|
|
12
|
+
loadingComponent,
|
|
13
|
+
showSkeleton = true,
|
|
14
|
+
aspectRatio,
|
|
15
|
+
objectFit = "cover",
|
|
16
|
+
className,
|
|
17
|
+
containerClassName,
|
|
18
|
+
onLoad,
|
|
19
|
+
onError,
|
|
20
|
+
style,
|
|
21
|
+
...props
|
|
22
|
+
}, ref) {
|
|
23
|
+
const [isLoading, setIsLoading] = react.useState(true);
|
|
24
|
+
const [hasError, setHasError] = react.useState(false);
|
|
25
|
+
const [prevSrc, setPrevSrc] = react.useState(src);
|
|
26
|
+
if (src !== prevSrc) {
|
|
27
|
+
setPrevSrc(src);
|
|
28
|
+
setIsLoading(true);
|
|
29
|
+
setHasError(false);
|
|
30
|
+
}
|
|
31
|
+
const handleLoad = (event) => {
|
|
32
|
+
setIsLoading(false);
|
|
33
|
+
onLoad?.(event);
|
|
34
|
+
};
|
|
35
|
+
const handleError = (event) => {
|
|
36
|
+
setIsLoading(false);
|
|
37
|
+
setHasError(true);
|
|
38
|
+
onError?.(event);
|
|
39
|
+
};
|
|
40
|
+
const renderFallback = () => {
|
|
41
|
+
const imgStyleClasses = chunkL5VQZZVR_cjs.cn(
|
|
42
|
+
"h-full w-full",
|
|
43
|
+
objectFit === "cover" && "object-cover",
|
|
44
|
+
objectFit === "contain" && "object-contain",
|
|
45
|
+
objectFit === "fill" && "object-fill",
|
|
46
|
+
objectFit === "none" && "object-none",
|
|
47
|
+
objectFit === "scale-down" && "object-scale-down",
|
|
48
|
+
className
|
|
49
|
+
);
|
|
50
|
+
if (typeof fallback === "string") {
|
|
51
|
+
return /* @__PURE__ */ jsxRuntime.jsx("img", { src: fallback, alt, className: imgStyleClasses, ...props });
|
|
52
|
+
}
|
|
53
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: imgStyleClasses, children: fallback ?? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full w-full items-center justify-center bg-surface-secondary text-text-tertiary", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
54
|
+
"svg",
|
|
55
|
+
{
|
|
56
|
+
className: "h-1/3 w-1/3 opacity-20",
|
|
57
|
+
fill: "none",
|
|
58
|
+
viewBox: "0 0 24 24",
|
|
59
|
+
stroke: "currentColor",
|
|
60
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
61
|
+
"path",
|
|
62
|
+
{
|
|
63
|
+
strokeLinecap: "round",
|
|
64
|
+
strokeLinejoin: "round",
|
|
65
|
+
strokeWidth: 1.5,
|
|
66
|
+
d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
) }) });
|
|
71
|
+
};
|
|
72
|
+
const containerStyle = {
|
|
73
|
+
aspectRatio,
|
|
74
|
+
...style
|
|
75
|
+
};
|
|
76
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
77
|
+
"div",
|
|
78
|
+
{
|
|
79
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
80
|
+
"relative overflow-hidden",
|
|
81
|
+
!aspectRatio && "h-full w-full",
|
|
82
|
+
containerClassName
|
|
83
|
+
),
|
|
84
|
+
style: containerStyle,
|
|
85
|
+
children: [
|
|
86
|
+
isLoading && showSkeleton && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 z-10", children: loadingComponent ?? /* @__PURE__ */ jsxRuntime.jsx(chunkS7VEND5Z_cjs.Skeleton, { className: "h-full w-full", variant: "wave" }) }),
|
|
87
|
+
hasError ? renderFallback() : /* @__PURE__ */ jsxRuntime.jsx(
|
|
88
|
+
"img",
|
|
89
|
+
{
|
|
90
|
+
ref,
|
|
91
|
+
src,
|
|
92
|
+
alt,
|
|
93
|
+
onLoad: handleLoad,
|
|
94
|
+
onError: handleError,
|
|
95
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
96
|
+
"transition-opacity duration-500 ease-in-out",
|
|
97
|
+
isLoading ? "opacity-0" : "opacity-100",
|
|
98
|
+
objectFit === "cover" && "object-cover",
|
|
99
|
+
objectFit === "contain" && "object-contain",
|
|
100
|
+
objectFit === "fill" && "object-fill",
|
|
101
|
+
objectFit === "none" && "object-none",
|
|
102
|
+
objectFit === "scale-down" && "object-scale-down",
|
|
103
|
+
"h-full w-full",
|
|
104
|
+
className
|
|
105
|
+
),
|
|
106
|
+
...props
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
Image.displayName = "Image";
|
|
114
|
+
|
|
115
|
+
exports.Image = Image;
|
|
@@ -0,0 +1,202 @@
|
|
|
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 Sidebar = ({
|
|
9
|
+
groups,
|
|
10
|
+
isCollapsed: controlledIsCollapsed,
|
|
11
|
+
onToggleCollapse,
|
|
12
|
+
logo,
|
|
13
|
+
footer,
|
|
14
|
+
className,
|
|
15
|
+
glass = false,
|
|
16
|
+
width = 288,
|
|
17
|
+
collapsedWidth = 80,
|
|
18
|
+
showToggleButton = false,
|
|
19
|
+
togglePosition = "center",
|
|
20
|
+
position = "left",
|
|
21
|
+
centerIcons = true,
|
|
22
|
+
classNames = {},
|
|
23
|
+
styles = {},
|
|
24
|
+
renderItem
|
|
25
|
+
}) => {
|
|
26
|
+
const [internalIsCollapsed, setInternalIsCollapsed] = react.useState(false);
|
|
27
|
+
const [expandedItems, setExpandedItems] = react.useState({});
|
|
28
|
+
const isCollapsed = controlledIsCollapsed ?? internalIsCollapsed;
|
|
29
|
+
const handleToggle = () => {
|
|
30
|
+
const newState = !isCollapsed;
|
|
31
|
+
if (onToggleCollapse) {
|
|
32
|
+
onToggleCollapse(newState);
|
|
33
|
+
} else {
|
|
34
|
+
setInternalIsCollapsed(newState);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const toggleItemExpanded = (id) => {
|
|
38
|
+
setExpandedItems((prev) => ({
|
|
39
|
+
...prev,
|
|
40
|
+
[id]: !prev[id]
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
const sidebarWidth = isCollapsed ? collapsedWidth : width;
|
|
44
|
+
const renderSidebarItem = (item, level = 0) => {
|
|
45
|
+
if (item.hidden) return null;
|
|
46
|
+
if (renderItem) {
|
|
47
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: renderItem(item, isCollapsed) }, item.id);
|
|
48
|
+
}
|
|
49
|
+
const hasChildren = item.items && item.items.length > 0;
|
|
50
|
+
const isExpanded = expandedItems[item.id] ?? !!item.isExpanded;
|
|
51
|
+
const Component = item.component ?? "button";
|
|
52
|
+
const itemContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
53
|
+
item.icon && /* @__PURE__ */ jsxRuntime.jsx(
|
|
54
|
+
"span",
|
|
55
|
+
{
|
|
56
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
57
|
+
"shrink-0 transition-colors duration-normal",
|
|
58
|
+
item.isActive ? "text-text-inverse" : "text-text-muted group-hover:text-text",
|
|
59
|
+
isCollapsed && centerIcons && "mx-auto",
|
|
60
|
+
classNames.itemIcon
|
|
61
|
+
),
|
|
62
|
+
style: styles.itemIcon,
|
|
63
|
+
children: item.icon
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
!isCollapsed && /* @__PURE__ */ jsxRuntime.jsx("span", { className: chunkL5VQZZVR_cjs.cn("truncate", classNames.itemLabel), style: styles.itemLabel, children: item.label }),
|
|
67
|
+
!isCollapsed && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-auto flex items-center gap-2", children: [
|
|
68
|
+
item.badge && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0", children: item.badge }),
|
|
69
|
+
hasChildren && /* @__PURE__ */ jsxRuntime.jsx(
|
|
70
|
+
outline.ChevronDownIcon,
|
|
71
|
+
{
|
|
72
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
73
|
+
"w-4 h-4 transition-transform duration-normal",
|
|
74
|
+
isExpanded && "rotate-180"
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
] }),
|
|
79
|
+
isCollapsed && /* @__PURE__ */ jsxRuntime.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 })
|
|
80
|
+
] });
|
|
81
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full", children: [
|
|
82
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
83
|
+
Component,
|
|
84
|
+
{
|
|
85
|
+
type: Component === "button" ? "button" : void 0,
|
|
86
|
+
onClick: (e) => {
|
|
87
|
+
if (hasChildren && !isCollapsed) {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
toggleItemExpanded(item.id);
|
|
90
|
+
}
|
|
91
|
+
item.onClick?.();
|
|
92
|
+
},
|
|
93
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
94
|
+
"w-full flex items-center gap-4 transition-all duration-normal group relative text-base rounded-lg",
|
|
95
|
+
level === 0 ? "px-4 py-3" : "px-3 py-2 pl-10",
|
|
96
|
+
item.isActive ? "bg-black text-text-inverse shadow-md shadow-black/20 font-bold" : "text-text-secondary hover:bg-hover hover:text-text",
|
|
97
|
+
isCollapsed && "justify-center px-0",
|
|
98
|
+
item.isActive && classNames.itemActive,
|
|
99
|
+
isCollapsed && classNames.itemCollapsed,
|
|
100
|
+
classNames.item
|
|
101
|
+
),
|
|
102
|
+
style: styles.item,
|
|
103
|
+
title: isCollapsed ? item.label : void 0,
|
|
104
|
+
...item.componentProps ?? {},
|
|
105
|
+
children: itemContent
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
hasChildren && isExpanded && !isCollapsed && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 space-y-1", children: item.items?.map((child) => renderSidebarItem(child, level + 1)) })
|
|
109
|
+
] }, item.id);
|
|
110
|
+
};
|
|
111
|
+
const toggleBtn = showToggleButton && /* @__PURE__ */ jsxRuntime.jsx(
|
|
112
|
+
"button",
|
|
113
|
+
{
|
|
114
|
+
onClick: handleToggle,
|
|
115
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
116
|
+
"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",
|
|
117
|
+
position === "left" ? "-right-4" : "-left-4",
|
|
118
|
+
togglePosition === "top" && "top-12",
|
|
119
|
+
togglePosition === "center" && "top-1/2 -translate-y-1/2",
|
|
120
|
+
togglePosition === "bottom" && "bottom-12",
|
|
121
|
+
classNames.toggleButton
|
|
122
|
+
),
|
|
123
|
+
style: styles.toggleButton,
|
|
124
|
+
"aria-label": isCollapsed ? "Expand sidebar" : "Collapse sidebar",
|
|
125
|
+
children: isCollapsed ? position === "left" ? /* @__PURE__ */ jsxRuntime.jsx(outline.ChevronRightIcon, { className: "w-4 h-4" }) : /* @__PURE__ */ jsxRuntime.jsx(outline.ChevronLeftIcon, { className: "w-4 h-4" }) : position === "left" ? /* @__PURE__ */ jsxRuntime.jsx(outline.ChevronLeftIcon, { className: "w-4 h-4" }) : /* @__PURE__ */ jsxRuntime.jsx(outline.ChevronRightIcon, { className: "w-4 h-4" })
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
129
|
+
"aside",
|
|
130
|
+
{
|
|
131
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
132
|
+
"flex flex-col h-full bg-surface transition-all duration-slow ease-in-out z-index-sticky shadow-premium relative",
|
|
133
|
+
position === "right" && "border-l border-border",
|
|
134
|
+
position === "left" && "border-r border-border",
|
|
135
|
+
glass && "glass",
|
|
136
|
+
classNames.root,
|
|
137
|
+
className
|
|
138
|
+
),
|
|
139
|
+
style: {
|
|
140
|
+
width: sidebarWidth,
|
|
141
|
+
...styles.root
|
|
142
|
+
},
|
|
143
|
+
children: [
|
|
144
|
+
toggleBtn,
|
|
145
|
+
logo && /* @__PURE__ */ jsxRuntime.jsx(
|
|
146
|
+
"div",
|
|
147
|
+
{
|
|
148
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
149
|
+
"flex items-center px-6 pt-10 pb-6",
|
|
150
|
+
isCollapsed && "justify-center px-0",
|
|
151
|
+
classNames.header
|
|
152
|
+
),
|
|
153
|
+
style: styles.header,
|
|
154
|
+
children: logo
|
|
155
|
+
}
|
|
156
|
+
),
|
|
157
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
158
|
+
"div",
|
|
159
|
+
{
|
|
160
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
161
|
+
"flex-1 overflow-y-auto overflow-x-hidden px-4 py-6 space-y-10 custom-scrollbar",
|
|
162
|
+
classNames.content
|
|
163
|
+
),
|
|
164
|
+
style: styles.content,
|
|
165
|
+
children: groups.map((group) => {
|
|
166
|
+
if (group.hidden) return null;
|
|
167
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkL5VQZZVR_cjs.cn("space-y-4", classNames.group), style: styles.group, children: [
|
|
168
|
+
group.label && !isCollapsed && /* @__PURE__ */ jsxRuntime.jsx(
|
|
169
|
+
"h3",
|
|
170
|
+
{
|
|
171
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
172
|
+
"px-2 text-xs font-bold text-text-muted uppercase tracking-wider",
|
|
173
|
+
classNames.groupLabel
|
|
174
|
+
),
|
|
175
|
+
style: styles.groupLabel,
|
|
176
|
+
children: group.label
|
|
177
|
+
}
|
|
178
|
+
),
|
|
179
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1", children: group.items.map((item) => renderSidebarItem(item)) })
|
|
180
|
+
] }, group.id);
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
footer && /* @__PURE__ */ jsxRuntime.jsx(
|
|
185
|
+
"div",
|
|
186
|
+
{
|
|
187
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
188
|
+
"p-6 mt-auto border-t border-border/50",
|
|
189
|
+
isCollapsed && "flex justify-center px-0",
|
|
190
|
+
classNames.footer
|
|
191
|
+
),
|
|
192
|
+
style: styles.footer,
|
|
193
|
+
children: footer
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
};
|
|
200
|
+
Sidebar.displayName = "Sidebar";
|
|
201
|
+
|
|
202
|
+
exports.Sidebar = Sidebar;
|
|
@@ -0,0 +1,314 @@
|
|
|
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 jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
var EXIT_DURATION_MS = 150;
|
|
9
|
+
var placementClasses = {
|
|
10
|
+
top: "-translate-x-1/2 -translate-y-full",
|
|
11
|
+
bottom: "-translate-x-1/2",
|
|
12
|
+
left: "-translate-x-full -translate-y-1/2",
|
|
13
|
+
right: "-translate-y-1/2"
|
|
14
|
+
};
|
|
15
|
+
var arrowPositionClasses = {
|
|
16
|
+
top: "top-full left-1/2 -translate-x-1/2",
|
|
17
|
+
bottom: "bottom-full left-1/2 -translate-x-1/2",
|
|
18
|
+
left: "left-full top-1/2 -translate-y-1/2",
|
|
19
|
+
right: "right-full top-1/2 -translate-y-1/2"
|
|
20
|
+
};
|
|
21
|
+
var arrowBorderClasses = {
|
|
22
|
+
top: "border-l-transparent border-r-transparent border-b-transparent",
|
|
23
|
+
bottom: "border-l-transparent border-r-transparent border-t-transparent",
|
|
24
|
+
left: "border-t-transparent border-b-transparent border-r-transparent",
|
|
25
|
+
right: "border-t-transparent border-b-transparent border-l-transparent"
|
|
26
|
+
};
|
|
27
|
+
var entryTranslateClass = {
|
|
28
|
+
top: "translate-y-1",
|
|
29
|
+
bottom: "-translate-y-1",
|
|
30
|
+
left: "translate-x-1",
|
|
31
|
+
right: "-translate-x-1"
|
|
32
|
+
};
|
|
33
|
+
var sizeClasses = {
|
|
34
|
+
sm: "px-2 py-1 text-xs rounded-md",
|
|
35
|
+
md: "px-3 py-1.5 text-sm rounded-lg",
|
|
36
|
+
lg: "px-4 py-2 text-sm rounded-xl"
|
|
37
|
+
};
|
|
38
|
+
var variantBubbleClasses = {
|
|
39
|
+
dark: [
|
|
40
|
+
"bg-gray-900 text-gray-50",
|
|
41
|
+
"shadow-[0_4px_16px_rgba(0,0,0,0.35)]",
|
|
42
|
+
"ring-1 ring-white/10"
|
|
43
|
+
].join(" "),
|
|
44
|
+
primary: [
|
|
45
|
+
"bg-gradient-to-b from-blue-500 to-blue-600 text-white",
|
|
46
|
+
"shadow-[0_4px_16px_rgba(59,130,246,0.45)]",
|
|
47
|
+
"ring-1 ring-blue-400/30"
|
|
48
|
+
].join(" "),
|
|
49
|
+
light: [
|
|
50
|
+
"bg-white text-gray-800",
|
|
51
|
+
"border border-gray-200/80",
|
|
52
|
+
"shadow-[0_4px_16px_rgba(0,0,0,0.10)]"
|
|
53
|
+
].join(" ")
|
|
54
|
+
};
|
|
55
|
+
var arrowVariantColor = {
|
|
56
|
+
dark: {
|
|
57
|
+
top: "border-t-gray-900",
|
|
58
|
+
bottom: "border-b-gray-900",
|
|
59
|
+
left: "border-l-gray-900",
|
|
60
|
+
right: "border-r-gray-900"
|
|
61
|
+
},
|
|
62
|
+
primary: {
|
|
63
|
+
top: "border-t-blue-600",
|
|
64
|
+
bottom: "border-b-blue-500",
|
|
65
|
+
left: "border-l-blue-600",
|
|
66
|
+
right: "border-r-blue-500"
|
|
67
|
+
},
|
|
68
|
+
light: {
|
|
69
|
+
top: "border-t-gray-200",
|
|
70
|
+
bottom: "border-b-gray-200",
|
|
71
|
+
left: "border-l-gray-200",
|
|
72
|
+
right: "border-r-gray-200"
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
function Tooltip({
|
|
76
|
+
content,
|
|
77
|
+
children,
|
|
78
|
+
placement = "top",
|
|
79
|
+
trigger = "hover",
|
|
80
|
+
showDelay = 0,
|
|
81
|
+
hideDelay = 100,
|
|
82
|
+
size = "md",
|
|
83
|
+
variant = "dark",
|
|
84
|
+
open: controlledOpen,
|
|
85
|
+
disabled = false,
|
|
86
|
+
maxWidth = 240,
|
|
87
|
+
className,
|
|
88
|
+
wrapperClassName
|
|
89
|
+
}) {
|
|
90
|
+
const [internalOpen, setInternalOpen] = react.useState(false);
|
|
91
|
+
const [mounted, setMounted] = react.useState(false);
|
|
92
|
+
const [visible, setVisible] = react.useState(false);
|
|
93
|
+
const [coords, setCoords] = react.useState({ top: 0, left: 0 });
|
|
94
|
+
const [actualPlacement, setActualPlacement] = react.useState(placement);
|
|
95
|
+
const isControlled = controlledOpen !== void 0;
|
|
96
|
+
const isOpen = isControlled ? controlledOpen : internalOpen;
|
|
97
|
+
const triggerRef = react.useRef(null);
|
|
98
|
+
const tooltipRef = react.useRef(null);
|
|
99
|
+
const showTimer = react.useRef(null);
|
|
100
|
+
const hideTimer = react.useRef(null);
|
|
101
|
+
const exitTimer = react.useRef(null);
|
|
102
|
+
const tooltipId = react.useId();
|
|
103
|
+
const clearTimers = react.useCallback(() => {
|
|
104
|
+
if (showTimer.current) clearTimeout(showTimer.current);
|
|
105
|
+
if (hideTimer.current) clearTimeout(hideTimer.current);
|
|
106
|
+
if (exitTimer.current) clearTimeout(exitTimer.current);
|
|
107
|
+
}, []);
|
|
108
|
+
const show = react.useCallback(() => {
|
|
109
|
+
if (disabled || isControlled) return;
|
|
110
|
+
clearTimers();
|
|
111
|
+
const open = () => {
|
|
112
|
+
setInternalOpen(true);
|
|
113
|
+
};
|
|
114
|
+
if (showDelay > 0) {
|
|
115
|
+
showTimer.current = setTimeout(open, showDelay);
|
|
116
|
+
} else {
|
|
117
|
+
open();
|
|
118
|
+
}
|
|
119
|
+
}, [disabled, isControlled, clearTimers, showDelay]);
|
|
120
|
+
const hide = react.useCallback(() => {
|
|
121
|
+
if (isControlled) return;
|
|
122
|
+
clearTimers();
|
|
123
|
+
hideTimer.current = setTimeout(() => {
|
|
124
|
+
setInternalOpen(false);
|
|
125
|
+
}, hideDelay);
|
|
126
|
+
}, [isControlled, clearTimers, hideDelay]);
|
|
127
|
+
const toggle = react.useCallback(() => {
|
|
128
|
+
if (disabled || isControlled) return;
|
|
129
|
+
setInternalOpen((prev) => !prev);
|
|
130
|
+
}, [disabled, isControlled]);
|
|
131
|
+
react.useEffect(() => {
|
|
132
|
+
let rafId = null;
|
|
133
|
+
if (isOpen && !disabled) {
|
|
134
|
+
clearTimers();
|
|
135
|
+
rafId = requestAnimationFrame(() => {
|
|
136
|
+
setMounted(true);
|
|
137
|
+
rafId = requestAnimationFrame(() => {
|
|
138
|
+
setVisible(true);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
} else {
|
|
142
|
+
rafId = requestAnimationFrame(() => {
|
|
143
|
+
setVisible(false);
|
|
144
|
+
});
|
|
145
|
+
exitTimer.current = setTimeout(() => {
|
|
146
|
+
setMounted(false);
|
|
147
|
+
}, EXIT_DURATION_MS);
|
|
148
|
+
}
|
|
149
|
+
return () => {
|
|
150
|
+
if (rafId) cancelAnimationFrame(rafId);
|
|
151
|
+
if (exitTimer.current) clearTimeout(exitTimer.current);
|
|
152
|
+
};
|
|
153
|
+
}, [isOpen, disabled, clearTimers]);
|
|
154
|
+
const updatePosition = react.useCallback(() => {
|
|
155
|
+
if (!triggerRef.current || !isOpen) return;
|
|
156
|
+
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
157
|
+
const tooltipElement = tooltipRef.current;
|
|
158
|
+
const gap = 8;
|
|
159
|
+
let nextPlacement = placement;
|
|
160
|
+
const calculateBaseCoords = (p) => {
|
|
161
|
+
switch (p) {
|
|
162
|
+
case "top":
|
|
163
|
+
return { t: triggerRect.top - gap, l: triggerRect.left + triggerRect.width / 2 };
|
|
164
|
+
case "bottom":
|
|
165
|
+
return { t: triggerRect.bottom + gap, l: triggerRect.left + triggerRect.width / 2 };
|
|
166
|
+
case "left":
|
|
167
|
+
return { t: triggerRect.top + triggerRect.height / 2, l: triggerRect.left - gap };
|
|
168
|
+
case "right":
|
|
169
|
+
return { t: triggerRect.top + triggerRect.height / 2, l: triggerRect.right + gap };
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
const base = calculateBaseCoords(placement);
|
|
173
|
+
let top = base.t;
|
|
174
|
+
let left = base.l;
|
|
175
|
+
if (tooltipElement) {
|
|
176
|
+
const tooltipRect = tooltipElement.getBoundingClientRect();
|
|
177
|
+
const padding = 12;
|
|
178
|
+
if (placement === "top" && triggerRect.top - tooltipRect.height - gap < padding) {
|
|
179
|
+
nextPlacement = "bottom";
|
|
180
|
+
} else if (placement === "bottom" && triggerRect.bottom + tooltipRect.height + gap > window.innerHeight - padding) {
|
|
181
|
+
nextPlacement = "top";
|
|
182
|
+
} else if (placement === "left" && triggerRect.left - tooltipRect.width - gap < padding) {
|
|
183
|
+
nextPlacement = "right";
|
|
184
|
+
} else if (placement === "right" && triggerRect.right + tooltipRect.width + gap > window.innerWidth - padding) {
|
|
185
|
+
nextPlacement = "left";
|
|
186
|
+
}
|
|
187
|
+
if (nextPlacement !== placement) {
|
|
188
|
+
const flippedBase = calculateBaseCoords(nextPlacement);
|
|
189
|
+
top = flippedBase.t;
|
|
190
|
+
left = flippedBase.l;
|
|
191
|
+
}
|
|
192
|
+
const halfWidth = tooltipRect.width / 2;
|
|
193
|
+
const halfHeight = tooltipRect.height / 2;
|
|
194
|
+
if (nextPlacement === "top" || nextPlacement === "bottom") {
|
|
195
|
+
left = Math.max(
|
|
196
|
+
padding + halfWidth,
|
|
197
|
+
Math.min(window.innerWidth - padding - halfWidth, left)
|
|
198
|
+
);
|
|
199
|
+
} else {
|
|
200
|
+
top = Math.max(
|
|
201
|
+
padding + halfHeight,
|
|
202
|
+
Math.min(window.innerHeight - padding - halfHeight, top)
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
setActualPlacement(nextPlacement);
|
|
207
|
+
setCoords({ top, left });
|
|
208
|
+
}, [isOpen, placement]);
|
|
209
|
+
react.useLayoutEffect(() => {
|
|
210
|
+
if (!isOpen) return;
|
|
211
|
+
let rafId = null;
|
|
212
|
+
const handleUpdate = () => {
|
|
213
|
+
rafId = requestAnimationFrame(updatePosition);
|
|
214
|
+
};
|
|
215
|
+
handleUpdate();
|
|
216
|
+
window.addEventListener("resize", handleUpdate);
|
|
217
|
+
window.addEventListener("scroll", handleUpdate, true);
|
|
218
|
+
return () => {
|
|
219
|
+
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
220
|
+
window.removeEventListener("resize", handleUpdate);
|
|
221
|
+
window.removeEventListener("scroll", handleUpdate, true);
|
|
222
|
+
};
|
|
223
|
+
}, [isOpen, updatePosition]);
|
|
224
|
+
react.useEffect(() => {
|
|
225
|
+
if (!isOpen) return;
|
|
226
|
+
const handleKey = (e) => {
|
|
227
|
+
if (e.key === "Escape") {
|
|
228
|
+
clearTimers();
|
|
229
|
+
setInternalOpen(false);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
document.addEventListener("keydown", handleKey);
|
|
233
|
+
return () => {
|
|
234
|
+
document.removeEventListener("keydown", handleKey);
|
|
235
|
+
};
|
|
236
|
+
}, [isOpen, clearTimers]);
|
|
237
|
+
react.useEffect(() => clearTimers, [clearTimers]);
|
|
238
|
+
const triggerProps = {};
|
|
239
|
+
if (trigger === "hover" || trigger === "focus") {
|
|
240
|
+
triggerProps.onFocus = show;
|
|
241
|
+
triggerProps.onBlur = hide;
|
|
242
|
+
}
|
|
243
|
+
if (trigger === "hover") {
|
|
244
|
+
triggerProps.onMouseEnter = show;
|
|
245
|
+
triggerProps.onMouseLeave = hide;
|
|
246
|
+
} else if (trigger === "click") {
|
|
247
|
+
triggerProps.onClick = toggle;
|
|
248
|
+
}
|
|
249
|
+
triggerProps.onKeyDown = (e) => {
|
|
250
|
+
if (e.key === "Enter" || e.key === " ") toggle();
|
|
251
|
+
};
|
|
252
|
+
const child = children;
|
|
253
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
254
|
+
"span",
|
|
255
|
+
{
|
|
256
|
+
ref: triggerRef,
|
|
257
|
+
className: chunkL5VQZZVR_cjs.cn("relative inline-flex isolate z-0", wrapperClassName),
|
|
258
|
+
"aria-describedby": isOpen && !disabled ? tooltipId : void 0,
|
|
259
|
+
...triggerProps,
|
|
260
|
+
children: [
|
|
261
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "relative z-0", children: child }),
|
|
262
|
+
mounted && !disabled && reactDom.createPortal(
|
|
263
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
264
|
+
"div",
|
|
265
|
+
{
|
|
266
|
+
ref: tooltipRef,
|
|
267
|
+
className: chunkL5VQZZVR_cjs.cn("pointer-events-none fixed z-[9999]", placementClasses[actualPlacement]),
|
|
268
|
+
style: { top: coords.top, left: coords.left },
|
|
269
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
270
|
+
"div",
|
|
271
|
+
{
|
|
272
|
+
id: tooltipId,
|
|
273
|
+
role: "tooltip",
|
|
274
|
+
style: { maxWidth, transitionDuration: `${EXIT_DURATION_MS.toString()}ms` },
|
|
275
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
276
|
+
// Layout & typography
|
|
277
|
+
"relative min-w-max whitespace-normal break-words",
|
|
278
|
+
"font-sans font-medium tracking-tight text-center leading-snug",
|
|
279
|
+
// Smooth enter/exit transition
|
|
280
|
+
"transition-[opacity,transform] ease-out",
|
|
281
|
+
visible ? "opacity-100 translate-x-0 translate-y-0" : ["opacity-0", entryTranslateClass[actualPlacement]].join(" "),
|
|
282
|
+
// Visual styles
|
|
283
|
+
variantBubbleClasses[variant],
|
|
284
|
+
sizeClasses[size],
|
|
285
|
+
className
|
|
286
|
+
),
|
|
287
|
+
children: [
|
|
288
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
289
|
+
"div",
|
|
290
|
+
{
|
|
291
|
+
"aria-hidden": "true",
|
|
292
|
+
className: chunkL5VQZZVR_cjs.cn(
|
|
293
|
+
"absolute border-[6px]",
|
|
294
|
+
"drop-shadow-sm",
|
|
295
|
+
arrowPositionClasses[actualPlacement],
|
|
296
|
+
arrowBorderClasses[actualPlacement],
|
|
297
|
+
arrowVariantColor[variant][actualPlacement]
|
|
298
|
+
)
|
|
299
|
+
}
|
|
300
|
+
),
|
|
301
|
+
content
|
|
302
|
+
]
|
|
303
|
+
}
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
),
|
|
307
|
+
document.body
|
|
308
|
+
)
|
|
309
|
+
]
|
|
310
|
+
}
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
exports.Tooltip = Tooltip;
|