@aster-ui/prefixed 0.12.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +40 -0
- package/dist/chart.d.ts +2 -0
- package/dist/chart.js +5 -0
- package/dist/chart.js.map +1 -0
- package/dist/components/Affix.d.ts +14 -0
- package/dist/components/Affix.js +57 -0
- package/dist/components/Affix.js.map +1 -0
- package/dist/components/Alert.d.ts +10 -0
- package/dist/components/Alert.js +31 -0
- package/dist/components/Alert.js.map +1 -0
- package/dist/components/Anchor.d.ts +55 -0
- package/dist/components/Anchor.js +116 -0
- package/dist/components/Anchor.js.map +1 -0
- package/dist/components/Autocomplete.d.ts +38 -0
- package/dist/components/Autocomplete.js +186 -0
- package/dist/components/Autocomplete.js.map +1 -0
- package/dist/components/Avatar.d.ts +28 -0
- package/dist/components/Avatar.js +65 -0
- package/dist/components/Avatar.js.map +1 -0
- package/dist/components/Badge.d.ts +39 -0
- package/dist/components/Badge.js +220 -0
- package/dist/components/Badge.js.map +1 -0
- package/dist/components/Breadcrumb.d.ts +32 -0
- package/dist/components/Breadcrumb.js +39 -0
- package/dist/components/Breadcrumb.js.map +1 -0
- package/dist/components/Browser.d.ts +7 -0
- package/dist/components/Browser.js +15 -0
- package/dist/components/Browser.js.map +1 -0
- package/dist/components/Button.d.ts +38 -0
- package/dist/components/Button.js +114 -0
- package/dist/components/Button.js.map +1 -0
- package/dist/components/Card.d.ts +57 -0
- package/dist/components/Card.js +202 -0
- package/dist/components/Card.js.map +1 -0
- package/dist/components/Carousel.d.ts +55 -0
- package/dist/components/Carousel.js +205 -0
- package/dist/components/Carousel.js.map +1 -0
- package/dist/components/Cascader.d.ts +71 -0
- package/dist/components/Cascader.js +416 -0
- package/dist/components/Cascader.js.map +1 -0
- package/dist/components/Chart.d.ts +19 -0
- package/dist/components/Chart.js +153 -0
- package/dist/components/Chart.js.map +1 -0
- package/dist/components/Chat.d.ts +11 -0
- package/dist/components/Chat.js +33 -0
- package/dist/components/Chat.js.map +1 -0
- package/dist/components/Checkbox.d.ts +42 -0
- package/dist/components/Checkbox.js +156 -0
- package/dist/components/Checkbox.js.map +1 -0
- package/dist/components/Code.d.ts +16 -0
- package/dist/components/Code.js +60 -0
- package/dist/components/Code.js.map +1 -0
- package/dist/components/Collapse.d.ts +45 -0
- package/dist/components/Collapse.js +115 -0
- package/dist/components/Collapse.js.map +1 -0
- package/dist/components/ColorPicker.d.ts +16 -0
- package/dist/components/ColorPicker.js +368 -0
- package/dist/components/ColorPicker.js.map +1 -0
- package/dist/components/Command.d.ts +65 -0
- package/dist/components/Command.js +422 -0
- package/dist/components/Command.js.map +1 -0
- package/dist/components/ConfigProvider.d.ts +59 -0
- package/dist/components/ConfigProvider.js +46 -0
- package/dist/components/ConfigProvider.js.map +1 -0
- package/dist/components/Container.d.ts +12 -0
- package/dist/components/Container.js +28 -0
- package/dist/components/Container.js.map +1 -0
- package/dist/components/ContextMenu.d.ts +59 -0
- package/dist/components/ContextMenu.js +206 -0
- package/dist/components/ContextMenu.js.map +1 -0
- package/dist/components/CopyButton.d.ts +37 -0
- package/dist/components/CopyButton.js +123 -0
- package/dist/components/CopyButton.js.map +1 -0
- package/dist/components/Countdown.d.ts +27 -0
- package/dist/components/Countdown.js +118 -0
- package/dist/components/Countdown.js.map +1 -0
- package/dist/components/DatePicker.d.ts +11 -0
- package/dist/components/DatePicker.js +188 -0
- package/dist/components/DatePicker.js.map +1 -0
- package/dist/components/Descriptions.d.ts +84 -0
- package/dist/components/Descriptions.js +234 -0
- package/dist/components/Descriptions.js.map +1 -0
- package/dist/components/Diff.d.ts +12 -0
- package/dist/components/Diff.js +22 -0
- package/dist/components/Diff.js.map +1 -0
- package/dist/components/Divider.d.ts +8 -0
- package/dist/components/Divider.js +36 -0
- package/dist/components/Divider.js.map +1 -0
- package/dist/components/Dock.d.ts +38 -0
- package/dist/components/Dock.js +47 -0
- package/dist/components/Dock.js.map +1 -0
- package/dist/components/Drawer.d.ts +81 -0
- package/dist/components/Drawer.js +246 -0
- package/dist/components/Drawer.js.map +1 -0
- package/dist/components/Dropdown.d.ts +104 -0
- package/dist/components/Dropdown.js +407 -0
- package/dist/components/Dropdown.js.map +1 -0
- package/dist/components/Empty.d.ts +17 -0
- package/dist/components/Empty.js +145 -0
- package/dist/components/Empty.js.map +1 -0
- package/dist/components/Fieldset.d.ts +21 -0
- package/dist/components/Fieldset.js +21 -0
- package/dist/components/Fieldset.js.map +1 -0
- package/dist/components/FileInput.d.ts +9 -0
- package/dist/components/FileInput.js +38 -0
- package/dist/components/FileInput.js.map +1 -0
- package/dist/components/Filter.d.ts +27 -0
- package/dist/components/Filter.js +57 -0
- package/dist/components/Filter.js.map +1 -0
- package/dist/components/Flex.d.ts +14 -0
- package/dist/components/Flex.js +66 -0
- package/dist/components/Flex.js.map +1 -0
- package/dist/components/FloatButton.d.ts +73 -0
- package/dist/components/FloatButton.js +187 -0
- package/dist/components/FloatButton.js.map +1 -0
- package/dist/components/Footer.d.ts +16 -0
- package/dist/components/Footer.js +22 -0
- package/dist/components/Footer.js.map +1 -0
- package/dist/components/Form.d.ts +107 -0
- package/dist/components/Form.js +277 -0
- package/dist/components/Form.js.map +1 -0
- package/dist/components/Grid.d.ts +26 -0
- package/dist/components/Grid.js +1090 -0
- package/dist/components/Grid.js.map +1 -0
- package/dist/components/Hero.d.ts +11 -0
- package/dist/components/Hero.js +21 -0
- package/dist/components/Hero.js.map +1 -0
- package/dist/components/HoverGallery.d.ts +10 -0
- package/dist/components/HoverGallery.js +20 -0
- package/dist/components/HoverGallery.js.map +1 -0
- package/dist/components/Image.d.ts +26 -0
- package/dist/components/Image.js +172 -0
- package/dist/components/Image.js.map +1 -0
- package/dist/components/Input.d.ts +36 -0
- package/dist/components/Input.js +263 -0
- package/dist/components/Input.js.map +1 -0
- package/dist/components/InputNumber.d.ts +19 -0
- package/dist/components/InputNumber.js +158 -0
- package/dist/components/InputNumber.js.map +1 -0
- package/dist/components/Join.d.ts +6 -0
- package/dist/components/Join.js +19 -0
- package/dist/components/Join.js.map +1 -0
- package/dist/components/Kbd.d.ts +9 -0
- package/dist/components/Kbd.js +20 -0
- package/dist/components/Kbd.js.map +1 -0
- package/dist/components/Layout.d.ts +67 -0
- package/dist/components/Layout.js +188 -0
- package/dist/components/Layout.js.map +1 -0
- package/dist/components/List.d.ts +79 -0
- package/dist/components/List.js +128 -0
- package/dist/components/List.js.map +1 -0
- package/dist/components/Loading.d.ts +9 -0
- package/dist/components/Loading.js +40 -0
- package/dist/components/Loading.js.map +1 -0
- package/dist/components/Mask.d.ts +14 -0
- package/dist/components/Mask.js +37 -0
- package/dist/components/Mask.js.map +1 -0
- package/dist/components/Masonry.d.ts +15 -0
- package/dist/components/Masonry.js +84 -0
- package/dist/components/Masonry.js.map +1 -0
- package/dist/components/Mention.d.ts +30 -0
- package/dist/components/Mention.js +179 -0
- package/dist/components/Mention.js.map +1 -0
- package/dist/components/Menu.d.ts +72 -0
- package/dist/components/Menu.js +163 -0
- package/dist/components/Menu.js.map +1 -0
- package/dist/components/Message.d.ts +20 -0
- package/dist/components/Message.js +57 -0
- package/dist/components/Message.js.map +1 -0
- package/dist/components/Modal.d.ts +57 -0
- package/dist/components/Modal.js +338 -0
- package/dist/components/Modal.js.map +1 -0
- package/dist/components/MonthCalendar.d.ts +31 -0
- package/dist/components/MonthCalendar.js +205 -0
- package/dist/components/MonthCalendar.js.map +1 -0
- package/dist/components/Navbar.d.ts +22 -0
- package/dist/components/Navbar.js +50 -0
- package/dist/components/Navbar.js.map +1 -0
- package/dist/components/Notification.d.ts +50 -0
- package/dist/components/Notification.js +150 -0
- package/dist/components/Notification.js.map +1 -0
- package/dist/components/OTPInput.d.ts +32 -0
- package/dist/components/OTPInput.js +114 -0
- package/dist/components/OTPInput.js.map +1 -0
- package/dist/components/Pagination.d.ts +18 -0
- package/dist/components/Pagination.js +175 -0
- package/dist/components/Pagination.js.map +1 -0
- package/dist/components/Phone.d.ts +8 -0
- package/dist/components/Phone.js +17 -0
- package/dist/components/Phone.js.map +1 -0
- package/dist/components/Popconfirm.d.ts +17 -0
- package/dist/components/Popconfirm.js +125 -0
- package/dist/components/Popconfirm.js.map +1 -0
- package/dist/components/Popover.d.ts +15 -0
- package/dist/components/Popover.js +89 -0
- package/dist/components/Popover.js.map +1 -0
- package/dist/components/Progress.d.ts +5 -0
- package/dist/components/Progress.js +23 -0
- package/dist/components/Progress.js.map +1 -0
- package/dist/components/QRCode.d.ts +19 -0
- package/dist/components/QRCode.js +75 -0
- package/dist/components/QRCode.js.map +1 -0
- package/dist/components/RadialProgress.d.ts +10 -0
- package/dist/components/RadialProgress.js +48 -0
- package/dist/components/RadialProgress.js.map +1 -0
- package/dist/components/Radio.d.ts +26 -0
- package/dist/components/Radio.js +61 -0
- package/dist/components/Radio.js.map +1 -0
- package/dist/components/Range.d.ts +16 -0
- package/dist/components/Range.js +57 -0
- package/dist/components/Range.js.map +1 -0
- package/dist/components/Rating.d.ts +30 -0
- package/dist/components/Rating.js +127 -0
- package/dist/components/Rating.js.map +1 -0
- package/dist/components/Responsive.d.ts +18 -0
- package/dist/components/Responsive.js +17 -0
- package/dist/components/Responsive.js.map +1 -0
- package/dist/components/ResponsiveDrawer.d.ts +34 -0
- package/dist/components/ResponsiveDrawer.js +75 -0
- package/dist/components/ResponsiveDrawer.js.map +1 -0
- package/dist/components/Result.d.ts +12 -0
- package/dist/components/Result.js +110 -0
- package/dist/components/Result.js.map +1 -0
- package/dist/components/RichTextEditor.d.ts +32 -0
- package/dist/components/RichTextEditor.js +335 -0
- package/dist/components/RichTextEditor.js.map +1 -0
- package/dist/components/Segmented.d.ts +37 -0
- package/dist/components/Segmented.js +73 -0
- package/dist/components/Segmented.js.map +1 -0
- package/dist/components/Select.d.ts +18 -0
- package/dist/components/Select.js +78 -0
- package/dist/components/Select.js.map +1 -0
- package/dist/components/Skeleton.d.ts +9 -0
- package/dist/components/Skeleton.js +24 -0
- package/dist/components/Skeleton.js.map +1 -0
- package/dist/components/Space.d.ts +11 -0
- package/dist/components/Space.js +61 -0
- package/dist/components/Space.js.map +1 -0
- package/dist/components/Splitter.d.ts +29 -0
- package/dist/components/Splitter.js +257 -0
- package/dist/components/Splitter.js.map +1 -0
- package/dist/components/Stat.d.ts +18 -0
- package/dist/components/Stat.js +26 -0
- package/dist/components/Stat.js.map +1 -0
- package/dist/components/Status.d.ts +18 -0
- package/dist/components/Status.js +34 -0
- package/dist/components/Status.js.map +1 -0
- package/dist/components/Steps.d.ts +52 -0
- package/dist/components/Steps.js +97 -0
- package/dist/components/Steps.js.map +1 -0
- package/dist/components/Table.d.ts +105 -0
- package/dist/components/Table.js +637 -0
- package/dist/components/Table.js.map +1 -0
- package/dist/components/Tabs.d.ts +45 -0
- package/dist/components/Tabs.js +86 -0
- package/dist/components/Tabs.js.map +1 -0
- package/dist/components/Tag.d.ts +34 -0
- package/dist/components/Tag.js +210 -0
- package/dist/components/Tag.js.map +1 -0
- package/dist/components/TextRotate.d.ts +13 -0
- package/dist/components/TextRotate.js +26 -0
- package/dist/components/TextRotate.js.map +1 -0
- package/dist/components/Textarea.d.ts +9 -0
- package/dist/components/Textarea.js +44 -0
- package/dist/components/Textarea.js.map +1 -0
- package/dist/components/ThemeController.d.ts +28 -0
- package/dist/components/ThemeController.js +162 -0
- package/dist/components/ThemeController.js.map +1 -0
- package/dist/components/TimePicker.d.ts +20 -0
- package/dist/components/TimePicker.js +304 -0
- package/dist/components/TimePicker.js.map +1 -0
- package/dist/components/Timeline.d.ts +79 -0
- package/dist/components/Timeline.js +151 -0
- package/dist/components/Timeline.js.map +1 -0
- package/dist/components/Toggle.d.ts +7 -0
- package/dist/components/Toggle.js +39 -0
- package/dist/components/Toggle.js.map +1 -0
- package/dist/components/Tooltip.d.ts +9 -0
- package/dist/components/Tooltip.js +37 -0
- package/dist/components/Tooltip.js.map +1 -0
- package/dist/components/Tour.d.ts +123 -0
- package/dist/components/Tour.js +400 -0
- package/dist/components/Tour.js.map +1 -0
- package/dist/components/Transfer.d.ts +22 -0
- package/dist/components/Transfer.js +214 -0
- package/dist/components/Transfer.js.map +1 -0
- package/dist/components/Tree.d.ts +118 -0
- package/dist/components/Tree.js +444 -0
- package/dist/components/Tree.js.map +1 -0
- package/dist/components/TreeSelect.d.ts +84 -0
- package/dist/components/TreeSelect.js +755 -0
- package/dist/components/TreeSelect.js.map +1 -0
- package/dist/components/Typography.d.ts +53 -0
- package/dist/components/Typography.js +182 -0
- package/dist/components/Typography.js.map +1 -0
- package/dist/components/Upload.d.ts +38 -0
- package/dist/components/Upload.js +261 -0
- package/dist/components/Upload.js.map +1 -0
- package/dist/components/VirtualList.d.ts +29 -0
- package/dist/components/VirtualList.js +69 -0
- package/dist/components/VirtualList.js.map +1 -0
- package/dist/components/Watermark.d.ts +40 -0
- package/dist/components/Watermark.js +129 -0
- package/dist/components/Watermark.js.map +1 -0
- package/dist/components/WeekCalendar.d.ts +35 -0
- package/dist/components/WeekCalendar.js +204 -0
- package/dist/components/WeekCalendar.js.map +1 -0
- package/dist/components/Window.d.ts +7 -0
- package/dist/components/Window.js +10 -0
- package/dist/components/Window.js.map +1 -0
- package/dist/contexts/IconSizeContext.d.ts +2 -0
- package/dist/contexts/IconSizeContext.js +6 -0
- package/dist/contexts/IconSizeContext.js.map +1 -0
- package/dist/editor.d.ts +1 -0
- package/dist/editor.js +5 -0
- package/dist/editor.js.map +1 -0
- package/dist/hooks/useBreakpoint.d.ts +10 -0
- package/dist/hooks/useBreakpoint.js +36 -0
- package/dist/hooks/useBreakpoint.js.map +1 -0
- package/dist/hooks/useClickOutside.d.ts +17 -0
- package/dist/hooks/useClickOutside.js +18 -0
- package/dist/hooks/useClickOutside.js.map +1 -0
- package/dist/hooks/useClipboard.d.ts +20 -0
- package/dist/hooks/useClipboard.js +17 -0
- package/dist/hooks/useClipboard.js.map +1 -0
- package/dist/hooks/useDebounce.d.ts +18 -0
- package/dist/hooks/useDebounce.js +16 -0
- package/dist/hooks/useDebounce.js.map +1 -0
- package/dist/hooks/useDisclosure.d.ts +20 -0
- package/dist/hooks/useDisclosure.js +9 -0
- package/dist/hooks/useDisclosure.js.map +1 -0
- package/dist/hooks/useHover.d.ts +18 -0
- package/dist/hooks/useHover.js +16 -0
- package/dist/hooks/useHover.js.map +1 -0
- package/dist/hooks/useKeyPress.d.ts +40 -0
- package/dist/hooks/useKeyPress.js +34 -0
- package/dist/hooks/useKeyPress.js.map +1 -0
- package/dist/hooks/useLocalStorage.d.ts +12 -0
- package/dist/hooks/useLocalStorage.js +49 -0
- package/dist/hooks/useLocalStorage.js.map +1 -0
- package/dist/hooks/usePrevious.d.ts +15 -0
- package/dist/hooks/usePrevious.js +11 -0
- package/dist/hooks/usePrevious.js.map +1 -0
- package/dist/hooks/useWindowSize.d.ts +21 -0
- package/dist/hooks/useWindowSize.js +21 -0
- package/dist/hooks/useWindowSize.js.map +1 -0
- package/dist/index.d.ts +216 -0
- package/dist/index.js +256 -0
- package/dist/index.js.map +1 -0
- package/dist/locale/de-DE.d.ts +3 -0
- package/dist/locale/de-DE.js +100 -0
- package/dist/locale/de-DE.js.map +1 -0
- package/dist/locale/en-CA.d.ts +3 -0
- package/dist/locale/en-CA.js +11 -0
- package/dist/locale/en-CA.js.map +1 -0
- package/dist/locale/en-GB.d.ts +3 -0
- package/dist/locale/en-GB.js +11 -0
- package/dist/locale/en-GB.js.map +1 -0
- package/dist/locale/en-US.d.ts +3 -0
- package/dist/locale/en-US.js +100 -0
- package/dist/locale/en-US.js.map +1 -0
- package/dist/locale/es-ES.d.ts +3 -0
- package/dist/locale/es-ES.js +100 -0
- package/dist/locale/es-ES.js.map +1 -0
- package/dist/locale/fr-FR.d.ts +3 -0
- package/dist/locale/fr-FR.js +100 -0
- package/dist/locale/fr-FR.js.map +1 -0
- package/dist/locale/index.d.ts +107 -0
- package/dist/locale/ja-JP.d.ts +3 -0
- package/dist/locale/ja-JP.js +100 -0
- package/dist/locale/ja-JP.js.map +1 -0
- package/dist/locale/ko-KR.d.ts +3 -0
- package/dist/locale/ko-KR.js +100 -0
- package/dist/locale/ko-KR.js.map +1 -0
- package/dist/locale/pt-BR.d.ts +3 -0
- package/dist/locale/pt-BR.js +100 -0
- package/dist/locale/pt-BR.js.map +1 -0
- package/dist/locale/zh-CN.d.ts +3 -0
- package/dist/locale/zh-CN.js +100 -0
- package/dist/locale/zh-CN.js.map +1 -0
- package/dist/qrcode.d.ts +2 -0
- package/dist/qrcode.js +5 -0
- package/dist/qrcode.js.map +1 -0
- package/dist/virtuallist.d.ts +2 -0
- package/dist/virtuallist.js +5 -0
- package/dist/virtuallist.js.map +1 -0
- package/package.json +130 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { jsxs as h, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as H, useState as Y } from "react";
|
|
3
|
+
const A = {
|
|
4
|
+
locale: "en",
|
|
5
|
+
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
6
|
+
monthsLong: [
|
|
7
|
+
"January",
|
|
8
|
+
"February",
|
|
9
|
+
"March",
|
|
10
|
+
"April",
|
|
11
|
+
"May",
|
|
12
|
+
"June",
|
|
13
|
+
"July",
|
|
14
|
+
"August",
|
|
15
|
+
"September",
|
|
16
|
+
"October",
|
|
17
|
+
"November",
|
|
18
|
+
"December"
|
|
19
|
+
],
|
|
20
|
+
moreText: "more"
|
|
21
|
+
}, M = (t) => C(t, /* @__PURE__ */ new Date()), C = (t, e) => {
|
|
22
|
+
const n = new Date(t), r = new Date(e);
|
|
23
|
+
return n.setHours(0, 0, 0, 0), r.setHours(0, 0, 0, 0), r.getTime() === n.getTime();
|
|
24
|
+
}, J = (t) => {
|
|
25
|
+
const e = /* @__PURE__ */ new Date(), n = new Date(t);
|
|
26
|
+
return e.setHours(0, 0, 0, 0), n.setHours(0, 0, 0, 0), n > e;
|
|
27
|
+
}, L = (t) => {
|
|
28
|
+
const e = /* @__PURE__ */ new Date(), n = new Date(t);
|
|
29
|
+
return e.setHours(0, 0, 0, 0), n.setHours(0, 0, 0, 0), n < e;
|
|
30
|
+
}, I = (t, e) => t.filter(
|
|
31
|
+
(n) => n.date.getDate() === e.getDate() && n.date.getMonth() === e.getMonth() && n.date.getFullYear() === e.getFullYear()
|
|
32
|
+
), $ = (t, e) => new Date(t, e + 1, 0).getDate(), q = (t, e) => new Date(t, e, 1).getDay(), z = (t, e) => {
|
|
33
|
+
const n = $(t, e), r = q(t, e), p = [];
|
|
34
|
+
if (r > 0) {
|
|
35
|
+
const o = e === 0 ? 11 : e - 1, a = e === 0 ? t - 1 : t, i = $(a, o);
|
|
36
|
+
for (let g = 0; g < r; g++) {
|
|
37
|
+
const x = i - r + g + 1;
|
|
38
|
+
p.push({
|
|
39
|
+
day: x,
|
|
40
|
+
month: o,
|
|
41
|
+
year: a,
|
|
42
|
+
isCurrentMonth: !1,
|
|
43
|
+
date: new Date(a, o, x)
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const d = [];
|
|
48
|
+
for (let o = 1; o <= n; o++)
|
|
49
|
+
d.push({
|
|
50
|
+
day: o,
|
|
51
|
+
month: e,
|
|
52
|
+
year: t,
|
|
53
|
+
isCurrentMonth: !0,
|
|
54
|
+
date: new Date(t, e, o)
|
|
55
|
+
});
|
|
56
|
+
const m = [], u = 42 - (p.length + d.length);
|
|
57
|
+
if (u > 0) {
|
|
58
|
+
const o = e === 11 ? 0 : e + 1, a = e === 11 ? t + 1 : t;
|
|
59
|
+
for (let i = 1; i <= u; i++)
|
|
60
|
+
m.push({
|
|
61
|
+
day: i,
|
|
62
|
+
month: o,
|
|
63
|
+
year: a,
|
|
64
|
+
isCurrentMonth: !1,
|
|
65
|
+
date: new Date(a, o, i)
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return [...p, ...d, ...m];
|
|
69
|
+
}, G = H(
|
|
70
|
+
({
|
|
71
|
+
date: t = /* @__PURE__ */ new Date(),
|
|
72
|
+
events: e = [],
|
|
73
|
+
maxEventsPerDay: n = 5,
|
|
74
|
+
onEventClick: r,
|
|
75
|
+
onDayClick: p,
|
|
76
|
+
onMoreEventsClick: d,
|
|
77
|
+
header: m,
|
|
78
|
+
daySelector: D,
|
|
79
|
+
locale: u = A,
|
|
80
|
+
ellipsis: o,
|
|
81
|
+
allowPastInteraction: a = !1,
|
|
82
|
+
className: i = "",
|
|
83
|
+
...g
|
|
84
|
+
}, x) => {
|
|
85
|
+
const [v, T] = Y(/* @__PURE__ */ new Date()), w = t.getFullYear(), N = t.getMonth();
|
|
86
|
+
return /* @__PURE__ */ h(
|
|
87
|
+
"div",
|
|
88
|
+
{
|
|
89
|
+
ref: x,
|
|
90
|
+
className: `flex h-full w-full flex-col bg-base-100 ${i}`,
|
|
91
|
+
...g,
|
|
92
|
+
children: [
|
|
93
|
+
m && /* @__PURE__ */ l("div", { className: "mb-4 flex items-center justify-between", children: /* @__PURE__ */ l("div", { children: /* @__PURE__ */ h("h2", { className: "m-0 text-lg font-medium text-base-content", children: [
|
|
94
|
+
u.monthsLong[N],
|
|
95
|
+
" ",
|
|
96
|
+
w
|
|
97
|
+
] }) }) }),
|
|
98
|
+
/* @__PURE__ */ l("div", { className: "grid grid-cols-7 border-b border-base-300", children: u.daysShort.map((s, b) => /* @__PURE__ */ l(
|
|
99
|
+
"div",
|
|
100
|
+
{
|
|
101
|
+
className: "py-1 text-center text-xs font-medium uppercase text-base-content/60",
|
|
102
|
+
children: s
|
|
103
|
+
},
|
|
104
|
+
b
|
|
105
|
+
)) }),
|
|
106
|
+
/* @__PURE__ */ l("div", { className: "grid flex-1 grid-cols-7 grid-rows-6 border-l border-base-300", children: z(w, N).map((s, b) => {
|
|
107
|
+
const f = I(e, s.date), y = L(s.date) && !M(s.date), F = D && C(s.date, v);
|
|
108
|
+
return /* @__PURE__ */ h(
|
|
109
|
+
"div",
|
|
110
|
+
{
|
|
111
|
+
className: `
|
|
112
|
+
relative cursor-pointer overflow-hidden border-b border-r border-base-300 p-1
|
|
113
|
+
hover:bg-base-200
|
|
114
|
+
${s.isCurrentMonth ? "" : "bg-base-200"}
|
|
115
|
+
${M(s.date) ? "bg-primary/10" : ""}
|
|
116
|
+
${y ? "opacity-60" : ""}
|
|
117
|
+
${y && !a ? "cursor-not-allowed" : ""}
|
|
118
|
+
${F ? "z-10 outline outline-2 outline-primary" : ""}
|
|
119
|
+
`,
|
|
120
|
+
onClick: () => {
|
|
121
|
+
y && !a || (D && T(s.date), setTimeout(() => {
|
|
122
|
+
p?.(s.date);
|
|
123
|
+
}, 0));
|
|
124
|
+
},
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ l("div", { className: "mb-0.5 flex justify-center", children: /* @__PURE__ */ l(
|
|
127
|
+
"span",
|
|
128
|
+
{
|
|
129
|
+
className: `
|
|
130
|
+
flex items-center justify-center text-xs leading-none
|
|
131
|
+
${M(s.date) ? "font-bold text-primary" : "text-base-content"}
|
|
132
|
+
${s.isCurrentMonth ? "" : "text-base-content/40"}
|
|
133
|
+
${y && s.isCurrentMonth ? "text-base-content/40" : ""}
|
|
134
|
+
`,
|
|
135
|
+
children: s.day
|
|
136
|
+
}
|
|
137
|
+
) }),
|
|
138
|
+
/* @__PURE__ */ h("div", { className: "flex flex-col", children: [
|
|
139
|
+
f.slice(
|
|
140
|
+
0,
|
|
141
|
+
f.length > n ? n - 1 : n
|
|
142
|
+
).map((c, k) => /* @__PURE__ */ h(
|
|
143
|
+
"div",
|
|
144
|
+
{
|
|
145
|
+
className: `
|
|
146
|
+
flex cursor-pointer items-center rounded px-1 py-0.5 text-xs leading-none
|
|
147
|
+
transition-colors hover:bg-base-content/5
|
|
148
|
+
${J(c.date), "text-base-content"}
|
|
149
|
+
${c.strikethrough ? "line-through" : ""}
|
|
150
|
+
`,
|
|
151
|
+
style: c.style,
|
|
152
|
+
onClick: (S) => {
|
|
153
|
+
S.stopPropagation(), r && r(c);
|
|
154
|
+
},
|
|
155
|
+
title: c.title,
|
|
156
|
+
children: [
|
|
157
|
+
/* @__PURE__ */ l(
|
|
158
|
+
"span",
|
|
159
|
+
{
|
|
160
|
+
className: "mr-1.5 inline-block h-2 w-2 shrink-0 rounded-full",
|
|
161
|
+
style: { backgroundColor: c.color }
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
/* @__PURE__ */ l(
|
|
165
|
+
"span",
|
|
166
|
+
{
|
|
167
|
+
className: `overflow-hidden whitespace-nowrap ${o ? "text-ellipsis" : ""}`,
|
|
168
|
+
children: c.title
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
k
|
|
174
|
+
)),
|
|
175
|
+
f.length > n && /* @__PURE__ */ h(
|
|
176
|
+
"div",
|
|
177
|
+
{
|
|
178
|
+
className: "cursor-pointer rounded px-1 py-0.5 text-[11px] text-base-content/60 hover:bg-base-content/5",
|
|
179
|
+
onClick: (c) => {
|
|
180
|
+
c.stopPropagation(), d && d(s.date, f);
|
|
181
|
+
},
|
|
182
|
+
children: [
|
|
183
|
+
"+",
|
|
184
|
+
f.length - n + 1,
|
|
185
|
+
" ",
|
|
186
|
+
u.moreText
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
] })
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
b
|
|
194
|
+
);
|
|
195
|
+
}) })
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
G.displayName = "MonthCalendar";
|
|
202
|
+
export {
|
|
203
|
+
G as MonthCalendar
|
|
204
|
+
};
|
|
205
|
+
//# sourceMappingURL=MonthCalendar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MonthCalendar.js","sources":["../../src/components/MonthCalendar.tsx"],"sourcesContent":["import React, { useState, forwardRef } from 'react'\n\n// DaisyUI classes\n// (No DaisyUI classes used in this component)\n\n// Types\nexport type CalendarEvent = {\n date: Date\n title: string\n color: string\n strikethrough?: boolean\n style?: React.CSSProperties\n}\n\nexport type CalendarLocale = {\n locale: string\n daysShort: string[]\n monthsLong: string[]\n moreText: string\n formatTime?: (date: Date) => string\n}\n\n// Default English locale\nconst defaultLocale: CalendarLocale = {\n locale: 'en',\n daysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],\n monthsLong: [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ],\n moreText: 'more',\n}\n\n// Utility functions\nconst isToday = (date: Date) => isEqual(date, new Date())\n\nconst isEqual = (a: Date, b: Date) => {\n const acopy = new Date(a)\n const bcopy = new Date(b)\n acopy.setHours(0, 0, 0, 0)\n bcopy.setHours(0, 0, 0, 0)\n return bcopy.getTime() === acopy.getTime()\n}\n\nconst isFutureDate = (date: Date) => {\n const today = new Date()\n const checkDate = new Date(date)\n today.setHours(0, 0, 0, 0)\n checkDate.setHours(0, 0, 0, 0)\n return checkDate > today\n}\n\nconst isPastDate = (date: Date) => {\n const today = new Date()\n const checkDate = new Date(date)\n today.setHours(0, 0, 0, 0)\n checkDate.setHours(0, 0, 0, 0)\n return checkDate < today\n}\n\nconst getEventsForDate = <T extends CalendarEvent>(events: T[], date: Date) => {\n return events.filter(\n (event) =>\n event.date.getDate() === date.getDate() &&\n event.date.getMonth() === date.getMonth() &&\n event.date.getFullYear() === date.getFullYear()\n )\n}\n\nconst getDaysInMonth = (year: number, month: number) => {\n return new Date(year, month + 1, 0).getDate()\n}\n\nconst getFirstDayOfMonth = (year: number, month: number) => {\n return new Date(year, month, 1).getDay()\n}\n\nconst generateCalendarGrid = (year: number, month: number) => {\n const daysInMonth = getDaysInMonth(year, month)\n const firstDayOfMonth = getFirstDayOfMonth(year, month)\n\n const prevMonthDays = []\n\n if (firstDayOfMonth > 0) {\n const prevMonth = month === 0 ? 11 : month - 1\n const prevMonthYear = month === 0 ? year - 1 : year\n const daysInPrevMonth = getDaysInMonth(prevMonthYear, prevMonth)\n\n for (let i = 0; i < firstDayOfMonth; i++) {\n const day = daysInPrevMonth - firstDayOfMonth + i + 1\n prevMonthDays.push({\n day,\n month: prevMonth,\n year: prevMonthYear,\n isCurrentMonth: false,\n date: new Date(prevMonthYear, prevMonth, day),\n })\n }\n }\n\n const currentMonthDays = []\n\n for (let day = 1; day <= daysInMonth; day++) {\n currentMonthDays.push({\n day,\n month,\n year,\n isCurrentMonth: true,\n date: new Date(year, month, day),\n })\n }\n\n const nextMonthDays = []\n const totalDaysDisplayed = prevMonthDays.length + currentMonthDays.length\n const daysToAdd = 6 * 7 - totalDaysDisplayed\n\n if (daysToAdd > 0) {\n const nextMonth = month === 11 ? 0 : month + 1\n const nextMonthYear = month === 11 ? year + 1 : year\n\n for (let day = 1; day <= daysToAdd; day++) {\n nextMonthDays.push({\n day,\n month: nextMonth,\n year: nextMonthYear,\n isCurrentMonth: false,\n date: new Date(nextMonthYear, nextMonth, day),\n })\n }\n }\n\n return [...prevMonthDays, ...currentMonthDays, ...nextMonthDays]\n}\n\nexport interface MonthCalendarProps<T extends CalendarEvent = CalendarEvent>\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n date?: Date\n events?: T[]\n onEventClick?: (event: T) => void\n onDayClick?: (date: Date) => void\n locale?: CalendarLocale\n allowPastInteraction?: boolean\n maxEventsPerDay?: number\n onMoreEventsClick?: (date: Date, events: T[]) => void\n header?: boolean\n daySelector?: boolean\n ellipsis?: boolean\n}\n\nexport const MonthCalendar = forwardRef<HTMLDivElement, MonthCalendarProps>(\n <T extends CalendarEvent>(\n {\n date = new Date(),\n events = [],\n maxEventsPerDay = 5,\n onEventClick,\n onDayClick,\n onMoreEventsClick,\n header,\n daySelector,\n locale = defaultLocale,\n ellipsis,\n allowPastInteraction = false,\n className = '',\n ...rest\n }: MonthCalendarProps<T>,\n ref: React.ForwardedRef<HTMLDivElement>\n ) => {\n const [selectedDate, setSelectedDate] = useState(new Date())\n\n const year = date.getFullYear()\n const month = date.getMonth()\n\n return (\n <div\n ref={ref}\n className={`flex h-full w-full flex-col bg-base-100 ${className}`}\n {...rest}\n >\n {header && (\n <div className=\"mb-4 flex items-center justify-between\">\n <div>\n <h2 className=\"m-0 text-lg font-medium text-base-content\">\n {locale.monthsLong[month]} {year}\n </h2>\n </div>\n </div>\n )}\n\n {/* Weekday header */}\n <div className=\"grid grid-cols-7 border-b border-base-300\">\n {locale.daysShort.map((day, index) => (\n <div\n key={index}\n className=\"py-1 text-center text-xs font-medium uppercase text-base-content/60\"\n >\n {day}\n </div>\n ))}\n </div>\n\n {/* Calendar grid */}\n <div className=\"grid flex-1 grid-cols-7 grid-rows-6 border-l border-base-300\">\n {generateCalendarGrid(year, month).map((dateObj, index) => {\n const dateEvents = getEventsForDate(events as T[], dateObj.date)\n const isPast = isPastDate(dateObj.date) && !isToday(dateObj.date)\n const isSelected = daySelector && isEqual(dateObj.date, selectedDate)\n\n return (\n <div\n key={index}\n className={`\n relative cursor-pointer overflow-hidden border-b border-r border-base-300 p-1\n hover:bg-base-200\n ${!dateObj.isCurrentMonth ? 'bg-base-200' : ''}\n ${isToday(dateObj.date) ? 'bg-primary/10' : ''}\n ${isPast ? 'opacity-60' : ''}\n ${isPast && !allowPastInteraction ? 'cursor-not-allowed' : ''}\n ${isSelected ? 'z-10 outline outline-2 outline-primary' : ''}\n `}\n onClick={() => {\n if (isPast && !allowPastInteraction) {\n return\n }\n\n if (daySelector) {\n setSelectedDate(dateObj.date)\n }\n\n setTimeout(() => {\n onDayClick?.(dateObj.date)\n }, 0)\n }}\n >\n {/* Date number */}\n <div className=\"mb-0.5 flex justify-center\">\n <span\n className={`\n flex items-center justify-center text-xs leading-none\n ${isToday(dateObj.date) ? 'font-bold text-primary' : 'text-base-content'}\n ${!dateObj.isCurrentMonth ? 'text-base-content/40' : ''}\n ${isPast && dateObj.isCurrentMonth ? 'text-base-content/40' : ''}\n `}\n >\n {dateObj.day}\n </span>\n </div>\n\n {/* Events container */}\n <div className=\"flex flex-col\">\n {dateEvents\n .slice(\n 0,\n dateEvents.length > maxEventsPerDay\n ? maxEventsPerDay - 1\n : maxEventsPerDay\n )\n .map((event, eventIndex) => (\n <div\n key={eventIndex}\n className={`\n flex cursor-pointer items-center rounded px-1 py-0.5 text-xs leading-none\n transition-colors hover:bg-base-content/5\n ${isFutureDate(event.date) ? 'text-base-content' : 'text-base-content'}\n ${event.strikethrough ? 'line-through' : ''}\n `}\n style={event.style}\n onClick={(e) => {\n e.stopPropagation()\n if (onEventClick) {\n onEventClick(event)\n }\n }}\n title={event.title}\n >\n <span\n className=\"mr-1.5 inline-block h-2 w-2 shrink-0 rounded-full\"\n style={{ backgroundColor: event.color }}\n />\n <span\n className={`overflow-hidden whitespace-nowrap ${ellipsis ? 'text-ellipsis' : ''}`}\n >\n {event.title}\n </span>\n </div>\n ))}\n {dateEvents.length > maxEventsPerDay && (\n <div\n className=\"cursor-pointer rounded px-1 py-0.5 text-[11px] text-base-content/60 hover:bg-base-content/5\"\n onClick={(e) => {\n e.stopPropagation()\n if (onMoreEventsClick) {\n onMoreEventsClick(dateObj.date, dateEvents)\n }\n }}\n >\n +{dateEvents.length - maxEventsPerDay + 1} {locale.moreText}\n </div>\n )}\n </div>\n </div>\n )\n })}\n </div>\n </div>\n )\n }\n) as <T extends CalendarEvent = CalendarEvent>(\n props: MonthCalendarProps<T> & { ref?: React.ForwardedRef<HTMLDivElement> }\n) => React.ReactElement\n\n;(MonthCalendar as React.FC).displayName = 'MonthCalendar'\n"],"names":["defaultLocale","isToday","date","isEqual","a","b","acopy","bcopy","isFutureDate","today","checkDate","isPastDate","getEventsForDate","events","event","getDaysInMonth","year","month","getFirstDayOfMonth","generateCalendarGrid","daysInMonth","firstDayOfMonth","prevMonthDays","prevMonth","prevMonthYear","daysInPrevMonth","i","day","currentMonthDays","nextMonthDays","daysToAdd","nextMonth","nextMonthYear","MonthCalendar","forwardRef","maxEventsPerDay","onEventClick","onDayClick","onMoreEventsClick","header","daySelector","locale","ellipsis","allowPastInteraction","className","rest","ref","selectedDate","setSelectedDate","useState","jsxs","jsx","index","dateObj","dateEvents","isPast","isSelected","eventIndex","e"],"mappings":";;AAuBA,MAAMA,IAAgC;AAAA,EACpC,QAAQ;AAAA,EACR,WAAW,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAAA,EAC3D,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF,UAAU;AACZ,GAGMC,IAAU,CAACC,MAAeC,EAAQD,GAAM,oBAAI,MAAM,GAElDC,IAAU,CAACC,GAASC,MAAY;AACpC,QAAMC,IAAQ,IAAI,KAAKF,CAAC,GAClBG,IAAQ,IAAI,KAAKF,CAAC;AACxB,SAAAC,EAAM,SAAS,GAAG,GAAG,GAAG,CAAC,GACzBC,EAAM,SAAS,GAAG,GAAG,GAAG,CAAC,GAClBA,EAAM,cAAcD,EAAM,QAAA;AACnC,GAEME,IAAe,CAACN,MAAe;AACnC,QAAMO,wBAAY,KAAA,GACZC,IAAY,IAAI,KAAKR,CAAI;AAC/B,SAAAO,EAAM,SAAS,GAAG,GAAG,GAAG,CAAC,GACzBC,EAAU,SAAS,GAAG,GAAG,GAAG,CAAC,GACtBA,IAAYD;AACrB,GAEME,IAAa,CAACT,MAAe;AACjC,QAAMO,wBAAY,KAAA,GACZC,IAAY,IAAI,KAAKR,CAAI;AAC/B,SAAAO,EAAM,SAAS,GAAG,GAAG,GAAG,CAAC,GACzBC,EAAU,SAAS,GAAG,GAAG,GAAG,CAAC,GACtBA,IAAYD;AACrB,GAEMG,IAAmB,CAA0BC,GAAaX,MACvDW,EAAO;AAAA,EACZ,CAACC,MACCA,EAAM,KAAK,cAAcZ,EAAK,aAC9BY,EAAM,KAAK,eAAeZ,E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AAA;AAAA,cAzFKW;AAAA,YAAA;AAAA,UA4FX,CAAC,EAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAIEnB,EAA2B,cAAc;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type NavbarColor = 'base' | 'neutral' | 'primary' | 'secondary' | 'accent';
|
|
3
|
+
export type NavbarShadow = 'none' | 'sm' | 'md' | 'lg' | 'xl';
|
|
4
|
+
export type NavbarRounded = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
5
|
+
export interface NavbarProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'> {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
/** Content for the start section of the navbar (typically logo/brand) */
|
|
8
|
+
start?: React.ReactNode;
|
|
9
|
+
/** Content for the center section of the navbar */
|
|
10
|
+
center?: React.ReactNode;
|
|
11
|
+
/** Content for the end section of the navbar (typically actions/menu) */
|
|
12
|
+
end?: React.ReactNode;
|
|
13
|
+
/** Background color variant */
|
|
14
|
+
color?: NavbarColor;
|
|
15
|
+
/** Make navbar sticky at the top */
|
|
16
|
+
sticky?: boolean;
|
|
17
|
+
/** Shadow depth */
|
|
18
|
+
shadow?: NavbarShadow;
|
|
19
|
+
/** Border radius */
|
|
20
|
+
rounded?: NavbarRounded;
|
|
21
|
+
}
|
|
22
|
+
export declare const Navbar: React.FC<NavbarProps>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as a, jsxs as v } from "react/jsx-runtime";
|
|
2
|
+
const i = "d-navbar", u = "d-navbar-start", x = "d-navbar-center", N = "d-navbar-end", g = {
|
|
3
|
+
base: "bg-base-100",
|
|
4
|
+
neutral: "bg-neutral text-neutral-content",
|
|
5
|
+
primary: "bg-primary text-primary-content",
|
|
6
|
+
secondary: "bg-secondary text-secondary-content",
|
|
7
|
+
accent: "bg-accent text-accent-content"
|
|
8
|
+
}, h = {
|
|
9
|
+
none: "",
|
|
10
|
+
sm: "shadow-sm",
|
|
11
|
+
md: "shadow-md",
|
|
12
|
+
lg: "shadow-lg",
|
|
13
|
+
xl: "shadow-xl"
|
|
14
|
+
}, y = {
|
|
15
|
+
none: "",
|
|
16
|
+
sm: "rounded-sm",
|
|
17
|
+
md: "rounded-md",
|
|
18
|
+
lg: "rounded-lg",
|
|
19
|
+
xl: "rounded-xl",
|
|
20
|
+
full: "rounded-full"
|
|
21
|
+
}, p = ({
|
|
22
|
+
children: n,
|
|
23
|
+
start: s,
|
|
24
|
+
center: e,
|
|
25
|
+
end: r,
|
|
26
|
+
color: d = "base",
|
|
27
|
+
sticky: c = !1,
|
|
28
|
+
shadow: l = "none",
|
|
29
|
+
rounded: b = "none",
|
|
30
|
+
className: m = "",
|
|
31
|
+
...o
|
|
32
|
+
}) => {
|
|
33
|
+
const t = [
|
|
34
|
+
i,
|
|
35
|
+
g[d],
|
|
36
|
+
c && "sticky top-0 z-50",
|
|
37
|
+
h[l],
|
|
38
|
+
y[b],
|
|
39
|
+
m
|
|
40
|
+
].filter(Boolean).join(" ");
|
|
41
|
+
return n ? /* @__PURE__ */ a("nav", { className: t, ...o, children: n }) : /* @__PURE__ */ v("nav", { className: t, ...o, children: [
|
|
42
|
+
s && /* @__PURE__ */ a("div", { className: u, children: s }),
|
|
43
|
+
e && /* @__PURE__ */ a("div", { className: x, children: e }),
|
|
44
|
+
r && /* @__PURE__ */ a("div", { className: N, children: r })
|
|
45
|
+
] });
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
p as Navbar
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=Navbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Navbar.js","sources":["../../src/components/Navbar.tsx"],"sourcesContent":["import React from 'react'\n\n// DaisyUI classes\nconst dNavbar = 'd-navbar'\nconst dNavbarStart = 'd-navbar-start'\nconst dNavbarCenter = 'd-navbar-center'\nconst dNavbarEnd = 'd-navbar-end'\n\nexport type NavbarColor = 'base' | 'neutral' | 'primary' | 'secondary' | 'accent'\nexport type NavbarShadow = 'none' | 'sm' | 'md' | 'lg' | 'xl'\nexport type NavbarRounded = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full'\n\nexport interface NavbarProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'> {\n children?: React.ReactNode\n /** Content for the start section of the navbar (typically logo/brand) */\n start?: React.ReactNode\n /** Content for the center section of the navbar */\n center?: React.ReactNode\n /** Content for the end section of the navbar (typically actions/menu) */\n end?: React.ReactNode\n /** Background color variant */\n color?: NavbarColor\n /** Make navbar sticky at the top */\n sticky?: boolean\n /** Shadow depth */\n shadow?: NavbarShadow\n /** Border radius */\n rounded?: NavbarRounded\n}\n\nconst colorClasses: Record<NavbarColor, string> = {\n base: 'bg-base-100',\n neutral: 'bg-neutral text-neutral-content',\n primary: 'bg-primary text-primary-content',\n secondary: 'bg-secondary text-secondary-content',\n accent: 'bg-accent text-accent-content',\n}\n\nconst shadowClasses: Record<NavbarShadow, string> = {\n none: '',\n sm: 'shadow-sm',\n md: 'shadow-md',\n lg: 'shadow-lg',\n xl: 'shadow-xl',\n}\n\nconst roundedClasses: Record<NavbarRounded, string> = {\n none: '',\n sm: 'rounded-sm',\n md: 'rounded-md',\n lg: 'rounded-lg',\n xl: 'rounded-xl',\n full: 'rounded-full',\n}\n\nexport const Navbar: React.FC<NavbarProps> = ({\n children,\n start,\n center,\n end,\n color = 'base',\n sticky = false,\n shadow = 'none',\n rounded = 'none',\n className = '',\n ...rest\n}) => {\n const navbarClasses = [\n dNavbar,\n colorClasses[color],\n sticky && 'sticky top-0 z-50',\n shadowClasses[shadow],\n roundedClasses[rounded],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n if (children) {\n return <nav className={navbarClasses} {...rest}>{children}</nav>\n }\n\n return (\n <nav className={navbarClasses} {...rest}>\n {start && <div className={dNavbarStart}>{start}</div>}\n {center && <div className={dNavbarCenter}>{center}</div>}\n {end && <div className={dNavbarEnd}>{end}</div>}\n </nav>\n )\n}\n"],"names":["dNavbar","dNavbarStart","dNavbarCenter","dNavbarEnd","colorClasses","shadowClasses","roundedClasses","Navbar","children","start","center","end","color","sticky","shadow","rounded","className","rest","navbarClasses","jsxs","jsx"],"mappings":";AAGA,MAAMA,IAAU,YACVC,IAAe,kBACfC,IAAgB,mBAChBC,IAAa,gBAwBbC,IAA4C;AAAA,EAChD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,WAAW;AAAA,EACX,QAAQ;AACV,GAEMC,IAA8C;AAAA,EAClD,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAEMC,IAAgD;AAAA,EACpD,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AACR,GAEaC,IAAgC,CAAC;AAAA,EAC5C,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,KAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,QAAAC,IAAS;AAAA,EACT,QAAAC,IAAS;AAAA,EACT,SAAAC,IAAU;AAAA,EACV,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,MAAM;AACJ,QAAMC,IAAgB;AAAA,IACpBlB;AAAA,IACAI,EAAaQ,CAAK;AAAA,IAClBC,KAAU;AAAA,IACVR,EAAcS,CAAM;AAAA,IACpBR,EAAeS,CAAO;AAAA,IACtBC;AAAA,EAAA,EAEC,OAAO,OAAO,EACd,KAAK,GAAG;AAEX,SAAIR,sBACM,OAAA,EAAI,WAAWU,GAAgB,GAAGD,GAAO,UAAAT,GAAS,IAI1D,gBAAAW,EAAC,OAAA,EAAI,WAAWD,GAAgB,GAAGD,GAChC,UAAA;AAAA,IAAAR,KAAS,gBAAAW,EAAC,OAAA,EAAI,WAAWnB,GAAe,UAAAQ,GAAM;AAAA,IAC9CC,KAAU,gBAAAU,EAAC,OAAA,EAAI,WAAWlB,GAAgB,UAAAQ,GAAO;AAAA,IACjDC,KAAO,gBAAAS,EAAC,OAAA,EAAI,WAAWjB,GAAa,UAAAQ,EAAA,CAAI;AAAA,EAAA,GAC3C;AAEJ;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type NotificationType = 'success' | 'info' | 'warning' | 'error';
|
|
3
|
+
export type NotificationPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'topCenter' | 'bottomCenter';
|
|
4
|
+
export type NotificationVariant = 'default' | 'compact';
|
|
5
|
+
export interface NotificationConfig {
|
|
6
|
+
message: React.ReactNode;
|
|
7
|
+
description?: React.ReactNode;
|
|
8
|
+
type?: NotificationType;
|
|
9
|
+
duration?: number;
|
|
10
|
+
placement?: NotificationPlacement;
|
|
11
|
+
variant?: NotificationVariant;
|
|
12
|
+
closable?: boolean;
|
|
13
|
+
icon?: React.ReactNode;
|
|
14
|
+
key?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
'data-testid'?: string;
|
|
18
|
+
onClick?: () => void;
|
|
19
|
+
onClose?: () => void;
|
|
20
|
+
}
|
|
21
|
+
interface NotificationItem extends NotificationConfig {
|
|
22
|
+
id: string;
|
|
23
|
+
createdAt: number;
|
|
24
|
+
}
|
|
25
|
+
type Listener = () => void;
|
|
26
|
+
declare class NotificationManager {
|
|
27
|
+
private notifications;
|
|
28
|
+
private listeners;
|
|
29
|
+
private container;
|
|
30
|
+
private root;
|
|
31
|
+
private idCounter;
|
|
32
|
+
subscribe(listener: Listener): () => void;
|
|
33
|
+
getNotifications(): NotificationItem[];
|
|
34
|
+
private emit;
|
|
35
|
+
private ensureContainer;
|
|
36
|
+
open(config: NotificationConfig): string;
|
|
37
|
+
close(id: string): void;
|
|
38
|
+
success(config: Omit<NotificationConfig, 'type'>): string;
|
|
39
|
+
error(config: Omit<NotificationConfig, 'type'>): string;
|
|
40
|
+
info(config: Omit<NotificationConfig, 'type'>): string;
|
|
41
|
+
warning(config: Omit<NotificationConfig, 'type'>): string;
|
|
42
|
+
destroy(): void;
|
|
43
|
+
}
|
|
44
|
+
interface NotificationItemProps {
|
|
45
|
+
notification: NotificationItem;
|
|
46
|
+
onClose: () => void;
|
|
47
|
+
}
|
|
48
|
+
declare function NotificationItem({ notification, onClose }: NotificationItemProps): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
export declare const notification: NotificationManager;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { jsx as s, Fragment as f, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import { useState as $, useEffect as C } from "react";
|
|
3
|
+
import g from "react-dom/client";
|
|
4
|
+
const l = "d-toast", h = "d-toast-top", p = "d-toast-bottom", u = "d-toast-start", m = "d-toast-end", v = "d-toast-center", w = "d-alert", b = "d-alert-success", x = "d-alert-error", N = "d-alert-info", y = "d-alert-warning", z = "d-btn", R = "d-btn-xs", B = "d-btn-ghost", L = "d-btn-circle";
|
|
5
|
+
class M {
|
|
6
|
+
notifications = [];
|
|
7
|
+
listeners = [];
|
|
8
|
+
container = null;
|
|
9
|
+
root = null;
|
|
10
|
+
idCounter = 0;
|
|
11
|
+
subscribe(e) {
|
|
12
|
+
return this.listeners.push(e), () => {
|
|
13
|
+
this.listeners = this.listeners.filter((o) => o !== e);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
getNotifications() {
|
|
17
|
+
return this.notifications;
|
|
18
|
+
}
|
|
19
|
+
emit() {
|
|
20
|
+
this.listeners.forEach((e) => e());
|
|
21
|
+
}
|
|
22
|
+
ensureContainer() {
|
|
23
|
+
this.container || (this.container = document.createElement("div"), document.body.appendChild(this.container), this.root = g.createRoot(this.container), this.root.render(/* @__PURE__ */ s(T, { manager: this })));
|
|
24
|
+
}
|
|
25
|
+
open(e) {
|
|
26
|
+
this.ensureContainer();
|
|
27
|
+
const o = e.key ?? `notification-${++this.idCounter}`, n = e.variant === "compact", i = {
|
|
28
|
+
...e,
|
|
29
|
+
id: o,
|
|
30
|
+
createdAt: Date.now(),
|
|
31
|
+
duration: e.duration ?? (n ? 3 : 4.5),
|
|
32
|
+
placement: e.placement ?? (n ? "topCenter" : "topRight"),
|
|
33
|
+
variant: e.variant ?? "default",
|
|
34
|
+
closable: e.closable ?? !n,
|
|
35
|
+
type: e.type ?? "info"
|
|
36
|
+
}, r = this.notifications.findIndex((a) => a.id === o);
|
|
37
|
+
return r !== -1 ? this.notifications[r] = i : this.notifications.push(i), this.emit(), i.duration && i.duration > 0 && setTimeout(() => {
|
|
38
|
+
this.close(o);
|
|
39
|
+
}, i.duration * 1e3), o;
|
|
40
|
+
}
|
|
41
|
+
close(e) {
|
|
42
|
+
const o = this.notifications.find((n) => n.id === e);
|
|
43
|
+
this.notifications = this.notifications.filter((n) => n.id !== e), this.emit(), o?.onClose && o.onClose();
|
|
44
|
+
}
|
|
45
|
+
success(e) {
|
|
46
|
+
return this.open({ ...e, type: "success" });
|
|
47
|
+
}
|
|
48
|
+
error(e) {
|
|
49
|
+
return this.open({ ...e, type: "error" });
|
|
50
|
+
}
|
|
51
|
+
info(e) {
|
|
52
|
+
return this.open({ ...e, type: "info" });
|
|
53
|
+
}
|
|
54
|
+
warning(e) {
|
|
55
|
+
return this.open({ ...e, type: "warning" });
|
|
56
|
+
}
|
|
57
|
+
destroy() {
|
|
58
|
+
this.notifications = [], this.emit();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function T({ manager: t }) {
|
|
62
|
+
const [, e] = $({});
|
|
63
|
+
C(() => t.subscribe(() => {
|
|
64
|
+
e({});
|
|
65
|
+
}), [t]);
|
|
66
|
+
const o = t.getNotifications(), n = {
|
|
67
|
+
topLeft: [],
|
|
68
|
+
topRight: [],
|
|
69
|
+
topCenter: [],
|
|
70
|
+
bottomLeft: [],
|
|
71
|
+
bottomRight: [],
|
|
72
|
+
bottomCenter: []
|
|
73
|
+
};
|
|
74
|
+
o.forEach((r) => {
|
|
75
|
+
n[r.placement].push(r);
|
|
76
|
+
});
|
|
77
|
+
const i = {
|
|
78
|
+
topRight: `${l} ${h} ${m} z-[9999]`,
|
|
79
|
+
topLeft: `${l} ${h} ${u} z-[9999]`,
|
|
80
|
+
topCenter: `${l} ${h} ${v} z-[9999]`,
|
|
81
|
+
bottomRight: `${l} ${p} ${m} z-[9999]`,
|
|
82
|
+
bottomLeft: `${l} ${p} ${u} z-[9999]`,
|
|
83
|
+
bottomCenter: `${l} ${p} ${v} z-[9999]`
|
|
84
|
+
};
|
|
85
|
+
return /* @__PURE__ */ s(f, { children: Object.entries(n).map(([r, a]) => a.length === 0 ? null : /* @__PURE__ */ s("div", { className: i[r], children: a.map((c) => /* @__PURE__ */ s(
|
|
86
|
+
k,
|
|
87
|
+
{
|
|
88
|
+
notification: c,
|
|
89
|
+
onClose: () => t.close(c.id)
|
|
90
|
+
},
|
|
91
|
+
c.id
|
|
92
|
+
)) }, r)) });
|
|
93
|
+
}
|
|
94
|
+
function k({ notification: t, onClose: e }) {
|
|
95
|
+
const o = t.variant === "compact", n = {
|
|
96
|
+
success: b,
|
|
97
|
+
error: x,
|
|
98
|
+
info: N,
|
|
99
|
+
warning: y
|
|
100
|
+
}, i = {
|
|
101
|
+
success: /* @__PURE__ */ s("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-5 w-5", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ s("path", { fillRule: "evenodd", d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z", clipRule: "evenodd" }) }),
|
|
102
|
+
error: /* @__PURE__ */ s("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-5 w-5", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ s("path", { fillRule: "evenodd", d: "M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z", clipRule: "evenodd" }) }),
|
|
103
|
+
info: /* @__PURE__ */ s("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-5 w-5", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ s("path", { fillRule: "evenodd", d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z", clipRule: "evenodd" }) }),
|
|
104
|
+
warning: /* @__PURE__ */ s("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-5 w-5", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ s("path", { fillRule: "evenodd", d: "M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z", clipRule: "evenodd" }) })
|
|
105
|
+
}, r = () => {
|
|
106
|
+
t.onClick && t.onClick();
|
|
107
|
+
}, a = t.icon ?? i[t.type];
|
|
108
|
+
return o ? /* @__PURE__ */ s(
|
|
109
|
+
"div",
|
|
110
|
+
{
|
|
111
|
+
className: `${w} ${n[t.type]} shadow-md py-2 px-4 cursor-pointer${t.className ? ` ${t.className}` : ""}`,
|
|
112
|
+
style: t.style,
|
|
113
|
+
"data-testid": t["data-testid"],
|
|
114
|
+
onClick: r,
|
|
115
|
+
children: /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
|
|
116
|
+
a,
|
|
117
|
+
/* @__PURE__ */ s("span", { children: t.message })
|
|
118
|
+
] })
|
|
119
|
+
}
|
|
120
|
+
) : /* @__PURE__ */ d(
|
|
121
|
+
"div",
|
|
122
|
+
{
|
|
123
|
+
className: `${w} ${n[t.type]} shadow-lg cursor-pointer min-w-[300px] max-w-[400px] relative${t.className ? ` ${t.className}` : ""}`,
|
|
124
|
+
style: t.style,
|
|
125
|
+
"data-testid": t["data-testid"],
|
|
126
|
+
onClick: r,
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ d("div", { className: t.closable ? "pr-8" : "", children: [
|
|
129
|
+
t.message && /* @__PURE__ */ s("div", { className: "font-bold", children: t.message }),
|
|
130
|
+
t.description && /* @__PURE__ */ s("div", { className: "text-sm", children: t.description })
|
|
131
|
+
] }),
|
|
132
|
+
t.closable && /* @__PURE__ */ s(
|
|
133
|
+
"button",
|
|
134
|
+
{
|
|
135
|
+
className: `${z} ${R} ${B} ${L} absolute top-2 right-2`,
|
|
136
|
+
onClick: (c) => {
|
|
137
|
+
c.stopPropagation(), e();
|
|
138
|
+
},
|
|
139
|
+
children: "✕"
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
const j = new M();
|
|
147
|
+
export {
|
|
148
|
+
j as notification
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=Notification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Notification.js","sources":["../../src/components/Notification.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react'\nimport ReactDOM from 'react-dom/client'\n\n// DaisyUI classes\nconst dToast = 'd-toast'\nconst dToastTop = 'd-toast-top'\nconst dToastBottom = 'd-toast-bottom'\nconst dToastStart = 'd-toast-start'\nconst dToastEnd = 'd-toast-end'\nconst dToastCenter = 'd-toast-center'\nconst dAlert = 'd-alert'\nconst dAlertSuccess = 'd-alert-success'\nconst dAlertError = 'd-alert-error'\nconst dAlertInfo = 'd-alert-info'\nconst dAlertWarning = 'd-alert-warning'\nconst dBtn = 'd-btn'\nconst dBtnXs = 'd-btn-xs'\nconst dBtnGhost = 'd-btn-ghost'\nconst dBtnCircle = 'd-btn-circle'\n\nexport type NotificationType = 'success' | 'info' | 'warning' | 'error'\nexport type NotificationPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'topCenter' | 'bottomCenter'\nexport type NotificationVariant = 'default' | 'compact'\n\nexport interface NotificationConfig {\n message: React.ReactNode\n description?: React.ReactNode\n type?: NotificationType\n duration?: number // in seconds, 0 = no auto close\n placement?: NotificationPlacement\n variant?: NotificationVariant\n closable?: boolean\n icon?: React.ReactNode\n key?: string\n className?: string\n style?: React.CSSProperties\n 'data-testid'?: string\n onClick?: () => void\n onClose?: () => void\n}\n\ninterface NotificationItem extends NotificationConfig {\n id: string\n createdAt: number\n}\n\ntype Listener = () => void\n\nclass NotificationManager {\n private notifications: NotificationItem[] = []\n private listeners: Listener[] = []\n private container: HTMLDivElement | null = null\n private root: ReactDOM.Root | null = null\n private idCounter = 0\n\n subscribe(listener: Listener) {\n this.listeners.push(listener)\n return () => {\n this.listeners = this.listeners.filter((l) => l !== listener)\n }\n }\n\n getNotifications() {\n return this.notifications\n }\n\n private emit() {\n this.listeners.forEach((listener) => listener())\n }\n\n private ensureContainer() {\n if (!this.container) {\n this.container = document.createElement('div')\n document.body.appendChild(this.container)\n this.root = ReactDOM.createRoot(this.container)\n this.root.render(<NotificationContainer manager={this} />)\n }\n }\n\n open(config: NotificationConfig) {\n this.ensureContainer()\n\n const id = config.key ?? `notification-${++this.idCounter}`\n const isCompact = config.variant === 'compact'\n const notificationItem: NotificationItem = {\n ...config,\n id,\n createdAt: Date.now(),\n duration: config.duration ?? (isCompact ? 3 : 4.5),\n placement: config.placement ?? (isCompact ? 'topCenter' : 'topRight'),\n variant: config.variant ?? 'default',\n closable: config.closable ?? !isCompact,\n type: config.type ?? 'info',\n }\n\n // If key exists, update the existing notification\n const existingIndex = this.notifications.findIndex((n) => n.id === id)\n if (existingIndex !== -1) {\n this.notifications[existingIndex] = notificationItem\n } else {\n this.notifications.push(notificationItem)\n }\n this.emit()\n\n // Auto-dismiss\n if (notificationItem.duration && notificationItem.duration > 0) {\n setTimeout(() => {\n this.close(id)\n }, notificationItem.duration * 1000)\n }\n\n return id\n }\n\n close(id: string) {\n const notification = this.notifications.find((n) => n.id === id)\n this.notifications = this.notifications.filter((n) => n.id !== id)\n this.emit()\n\n if (notification?.onClose) {\n notification.onClose()\n }\n }\n\n success(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'success' })\n }\n\n error(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'error' })\n }\n\n info(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'info' })\n }\n\n warning(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'warning' })\n }\n\n destroy() {\n this.notifications = []\n this.emit()\n }\n}\n\ninterface NotificationContainerProps {\n manager: NotificationManager\n}\n\nfunction NotificationContainer({ manager }: NotificationContainerProps) {\n const [, forceUpdate] = useState({})\n\n useEffect(() => {\n const unsubscribe = manager.subscribe(() => {\n forceUpdate({})\n })\n return unsubscribe\n }, [manager])\n\n const notifications = manager.getNotifications()\n\n // Group by placement\n const grouped: Record<NotificationPlacement, NotificationItem[]> = {\n topLeft: [],\n topRight: [],\n topCenter: [],\n bottomLeft: [],\n bottomRight: [],\n bottomCenter: [],\n }\n\n notifications.forEach((notification) => {\n grouped[notification.placement!].push(notification)\n })\n\n const placementClasses: Record<NotificationPlacement, string> = {\n topRight: `${dToast} ${dToastTop} ${dToastEnd} z-[9999]`,\n topLeft: `${dToast} ${dToastTop} ${dToastStart} z-[9999]`,\n topCenter: `${dToast} ${dToastTop} ${dToastCenter} z-[9999]`,\n bottomRight: `${dToast} ${dToastBottom} ${dToastEnd} z-[9999]`,\n bottomLeft: `${dToast} ${dToastBottom} ${dToastStart} z-[9999]`,\n bottomCenter: `${dToast} ${dToastBottom} ${dToastCenter} z-[9999]`,\n }\n\n return (\n <>\n {Object.entries(grouped).map(([placement, items]) => {\n if (items.length === 0) return null\n\n return (\n <div key={placement} className={placementClasses[placement as NotificationPlacement]}>\n {items.map((notification) => (\n <NotificationItem\n key={notification.id}\n notification={notification}\n onClose={() => manager.close(notification.id)}\n />\n ))}\n </div>\n )\n })}\n </>\n )\n}\n\ninterface NotificationItemProps {\n notification: NotificationItem\n onClose: () => void\n}\n\nfunction NotificationItem({ notification, onClose }: NotificationItemProps) {\n const isCompact = notification.variant === 'compact'\n\n const alertTypeClasses: Record<NotificationType, string> = {\n success: dAlertSuccess,\n error: dAlertError,\n info: dAlertInfo,\n warning: dAlertWarning,\n }\n\n const typeIcons: Record<NotificationType, React.ReactNode> = {\n success: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z\" clipRule=\"evenodd\" /></svg>,\n error: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z\" clipRule=\"evenodd\" /></svg>,\n info: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z\" clipRule=\"evenodd\" /></svg>,\n warning: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z\" clipRule=\"evenodd\" /></svg>,\n }\n\n const handleClick = () => {\n if (notification.onClick) {\n notification.onClick()\n }\n }\n\n const icon = notification.icon ?? typeIcons[notification.type!]\n\n if (isCompact) {\n return (\n <div\n className={`${dAlert} ${alertTypeClasses[notification.type!]} shadow-md py-2 px-4 cursor-pointer${notification.className ? ` ${notification.className}` : ''}`}\n style={notification.style}\n data-testid={notification['data-testid']}\n onClick={handleClick}\n >\n <div className=\"flex items-center gap-2\">\n {icon}\n <span>{notification.message}</span>\n </div>\n </div>\n )\n }\n\n return (\n <div\n className={`${dAlert} ${alertTypeClasses[notification.type!]} shadow-lg cursor-pointer min-w-[300px] max-w-[400px] relative${notification.className ? ` ${notification.className}` : ''}`}\n style={notification.style}\n data-testid={notification['data-testid']}\n onClick={handleClick}\n >\n <div className={notification.closable ? 'pr-8' : ''}>\n {notification.message && <div className=\"font-bold\">{notification.message}</div>}\n {notification.description && <div className=\"text-sm\">{notification.description}</div>}\n </div>\n {notification.closable && (\n <button\n className={`${dBtn} ${dBtnXs} ${dBtnGhost} ${dBtnCircle} absolute top-2 right-2`}\n onClick={(e) => {\n e.stopPropagation()\n onClose()\n }}\n >\n ✕\n </button>\n )}\n </div>\n )\n}\n\nexport const notification = new NotificationManager()\n"],"names":["dToast","dToastTop","dToastBottom","dToastStart","dToastEnd","dToastCenter","dAlert","dAlertSuccess","dAlertError","dAlertInfo","dAlertWarning","dBtn","dBtnXs","dBtnGhost","dBtnCircle","NotificationManager","listener","l","ReactDOM","jsx","NotificationContainer","config","id","isCompact","notificationItem","existingIndex","n","notification","manager","forceUpdate","useState","useEffect","notifications","grouped","placementClasses","Fragment","placement","items","NotificationItem","onClose","alertTypeClasses","typeIcons","handleClick","icon","jsxs","e"],"mappings":";;;AAIA,MAAMA,IAAS,WACTC,IAAY,eACZC,IAAe,kBACfC,IAAc,iBACdC,IAAY,eACZC,IAAe,kBACfC,IAAS,WACTC,IAAgB,mBAChBC,IAAc,iBACdC,IAAa,gBACbC,IAAgB,mBAChBC,IAAO,SACPC,IAAS,YACTC,IAAY,eACZC,IAAa;AA8BnB,MAAMC,EAAoB;AAAA,EAChB,gBAAoC,CAAA;AAAA,EACpC,YAAwB,CAAA;AAAA,EACxB,YAAmC;AAAA,EACnC,OAA6B;AAAA,EAC7B,YAAY;AAAA,EAEpB,UAAUC,GAAoB;AAC5B,gBAAK,UAAU,KAAKA,CAAQ,GACrB,MAAM;AACX,WAAK,YAAY,KAAK,UAAU,OAAO,CAACC,MAAMA,MAAMD,CAAQ;AAAA,IAC9D;AAAA,EACF;AAAA,EAEA,mBAAmB;AACjB,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ,OAAO;AACb,SAAK,UAAU,QAAQ,CAACA,MAAaA,GAAU;AAAA,EACjD;AAAA,EAEQ,kBAAkB;AACxB,IAAK,KAAK,cACR,KAAK,YAAY,SAAS,cAAc,KAAK,GAC7C,SAAS,KAAK,YAAY,KAAK,SAAS,GACxC,KAAK,OAAOE,EAAS,WAAW,KAAK,SAAS,GAC9C,KAAK,KAAK,OAAO,gBAAAC,EAACC,GAAA,EAAsB,SAAS,MAAM,CAAE;AAAA,EAE7D;AAAA,EAEA,KAAKC,GAA4B;AAC/B,SAAK,gBAAA;A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AAAA,IAAA;AAAA,EAAA;AAIR;AAEO,MAAMZ,IAAe,IAAIZ,EAAA;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface OTPInputProps {
|
|
3
|
+
/** Number of input fields */
|
|
4
|
+
length?: number;
|
|
5
|
+
/** Current value */
|
|
6
|
+
value?: string;
|
|
7
|
+
/** Callback when value changes */
|
|
8
|
+
onChange?: (value: string) => void;
|
|
9
|
+
/** Callback when all fields are filled */
|
|
10
|
+
onComplete?: (value: string) => void;
|
|
11
|
+
/** Input size */
|
|
12
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
13
|
+
/** Input type - number only or alphanumeric */
|
|
14
|
+
type?: 'number' | 'text';
|
|
15
|
+
/** Mask input (show dots instead of characters) */
|
|
16
|
+
mask?: boolean;
|
|
17
|
+
/** Disabled state */
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** Error state */
|
|
20
|
+
error?: boolean;
|
|
21
|
+
/** Auto focus first input on mount */
|
|
22
|
+
autoFocus?: boolean;
|
|
23
|
+
/** Placeholder character */
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
/** Additional CSS classes */
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface OTPInputRef {
|
|
29
|
+
focus: () => void;
|
|
30
|
+
clear: () => void;
|
|
31
|
+
}
|
|
32
|
+
export declare const OTPInput: React.ForwardRefExoticComponent<OTPInputProps & React.RefAttributes<OTPInputRef>>;
|