@jbpark/ui-kit 10.1.0 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Alert.d.mts +24 -0
- package/dist/Alert.d.mts.map +1 -0
- package/dist/Alert.mjs +68 -0
- package/dist/Alert.mjs.map +1 -0
- package/dist/Anchor.d.mts +29 -0
- package/dist/Anchor.d.mts.map +1 -0
- package/dist/Anchor.mjs +120 -0
- package/dist/Anchor.mjs.map +1 -0
- package/dist/AutoComplete.d.mts +34 -0
- package/dist/AutoComplete.d.mts.map +1 -0
- package/dist/AutoComplete.mjs +82 -0
- package/dist/AutoComplete.mjs.map +1 -0
- package/dist/Avatar.d.mts +19 -0
- package/dist/Avatar.d.mts.map +1 -0
- package/dist/Avatar.mjs +43 -0
- package/dist/Avatar.mjs.map +1 -0
- package/dist/Badge.d.mts +23 -0
- package/dist/Badge.d.mts.map +1 -0
- package/dist/Badge.mjs +41 -0
- package/dist/Badge.mjs.map +1 -0
- package/dist/Breadcrumb.d.mts +3 -3
- package/dist/Breadcrumb.d.mts.map +1 -1
- package/dist/Breadcrumb.mjs +1 -1
- package/dist/Breadcrumb.mjs.map +1 -1
- package/dist/Button.d.mts +3 -3
- package/dist/Button.d.mts.map +1 -1
- package/dist/Button.mjs +1 -1
- package/dist/Calendar.d.mts +28 -0
- package/dist/Calendar.d.mts.map +1 -0
- package/dist/Calendar.mjs +64 -0
- package/dist/Calendar.mjs.map +1 -0
- package/dist/Card.d.mts +2 -2
- package/dist/Card.d.mts.map +1 -1
- package/dist/Cascader.d.mts +34 -0
- package/dist/Cascader.d.mts.map +1 -0
- package/dist/Cascader.mjs +144 -0
- package/dist/Cascader.mjs.map +1 -0
- package/dist/CodeEditor.d.mts +2 -2
- package/dist/CodeEditor.d.mts.map +1 -1
- package/dist/ContextMenu.d.mts +33 -0
- package/dist/ContextMenu.d.mts.map +1 -0
- package/dist/ContextMenu.mjs +92 -0
- package/dist/ContextMenu.mjs.map +1 -0
- package/dist/Descriptions.d.mts +31 -0
- package/dist/Descriptions.d.mts.map +1 -0
- package/dist/Descriptions.mjs +67 -0
- package/dist/Descriptions.mjs.map +1 -0
- package/dist/Divider.d.mts +18 -0
- package/dist/Divider.d.mts.map +1 -0
- package/dist/Divider.mjs +44 -0
- package/dist/Divider.mjs.map +1 -0
- package/dist/Form.d.mts +12 -0
- package/dist/Form.d.mts.map +1 -0
- package/dist/Form.mjs +11 -0
- package/dist/Form.mjs.map +1 -0
- package/dist/Layout.d.mts.map +1 -1
- package/dist/Mentions.d.mts +34 -0
- package/dist/Mentions.d.mts.map +1 -0
- package/dist/Mentions.mjs +207 -0
- package/dist/Mentions.mjs.map +1 -0
- package/dist/Menu.mjs +1 -2
- package/dist/Pagination.d.mts +2 -2
- package/dist/Pagination.d.mts.map +1 -1
- package/dist/Pagination.mjs +1 -1
- package/dist/Popconfirm.d.mts +33 -0
- package/dist/Popconfirm.d.mts.map +1 -0
- package/dist/Popconfirm.mjs +119 -0
- package/dist/Popconfirm.mjs.map +1 -0
- package/dist/Rate.d.mts +27 -0
- package/dist/Rate.d.mts.map +1 -0
- package/dist/Rate.mjs +81 -0
- package/dist/Rate.mjs.map +1 -0
- package/dist/Reveals.d.mts.map +1 -1
- package/dist/ScrollArea.d.mts +8 -0
- package/dist/ScrollArea.d.mts.map +1 -0
- package/dist/ScrollArea.mjs +11 -0
- package/dist/ScrollArea.mjs.map +1 -0
- package/dist/Segmented.d.mts +26 -0
- package/dist/Segmented.d.mts.map +1 -0
- package/dist/Segmented.mjs +57 -0
- package/dist/Segmented.mjs.map +1 -0
- package/dist/Space.d.mts +2 -2
- package/dist/Space.d.mts.map +1 -1
- package/dist/Statistic.d.mts +22 -0
- package/dist/Statistic.d.mts.map +1 -0
- package/dist/Statistic.mjs +53 -0
- package/dist/Statistic.mjs.map +1 -0
- package/dist/Steps.d.mts +28 -0
- package/dist/Steps.d.mts.map +1 -0
- package/dist/Steps.mjs +70 -0
- package/dist/Steps.mjs.map +1 -0
- package/dist/Table.d.mts +4 -4
- package/dist/Table.d.mts.map +1 -1
- package/dist/Tag.d.mts +3 -3
- package/dist/Tag.d.mts.map +1 -1
- package/dist/TimePicker.d.mts +26 -0
- package/dist/TimePicker.d.mts.map +1 -0
- package/dist/TimePicker.mjs +77 -0
- package/dist/TimePicker.mjs.map +1 -0
- package/dist/Timeline.d.mts +35 -0
- package/dist/Timeline.d.mts.map +1 -0
- package/dist/Timeline.mjs +59 -0
- package/dist/Timeline.mjs.map +1 -0
- package/dist/Tour.d.mts +37 -0
- package/dist/Tour.d.mts.map +1 -0
- package/dist/Tour.mjs +192 -0
- package/dist/Tour.mjs.map +1 -0
- package/dist/Transfer.d.mts +36 -0
- package/dist/Transfer.d.mts.map +1 -0
- package/dist/Transfer.mjs +147 -0
- package/dist/Transfer.mjs.map +1 -0
- package/dist/Tree.d.mts +62 -0
- package/dist/Tree.d.mts.map +1 -0
- package/dist/Tree.mjs +462 -0
- package/dist/Tree.mjs.map +1 -0
- package/dist/TreeSelect.d.mts +34 -0
- package/dist/TreeSelect.d.mts.map +1 -0
- package/dist/TreeSelect.mjs +135 -0
- package/dist/TreeSelect.mjs.map +1 -0
- package/dist/Typography.d.mts.map +1 -1
- package/dist/components/atoms/checkbox/checkbox.d.mts +5 -3
- package/dist/components/atoms/checkbox/checkbox.d.mts.map +1 -1
- package/dist/components/atoms/checkbox/checkbox.mjs +8 -4
- package/dist/components/atoms/checkbox/checkbox.mjs.map +1 -1
- package/dist/components/atoms/checkbox/group.d.mts +2 -2
- package/dist/components/atoms/checkbox/group.d.mts.map +1 -1
- package/dist/components/atoms/checkbox/index.d.mts.map +1 -1
- package/dist/components/atoms/color-picker.d.mts +2 -2
- package/dist/components/atoms/color-picker.d.mts.map +1 -1
- package/dist/components/atoms/date-picker.d.mts +5 -1
- package/dist/components/atoms/date-picker.d.mts.map +1 -1
- package/dist/components/atoms/date-picker.mjs +54 -10
- package/dist/components/atoms/date-picker.mjs.map +1 -1
- package/dist/components/atoms/float-button/back-top.d.mts +2 -2
- package/dist/components/atoms/float-button/back-top.d.mts.map +1 -1
- package/dist/components/atoms/float-button/back-top.mjs +1 -1
- package/dist/components/atoms/float-button/float-button.d.mts +2 -2
- package/dist/components/atoms/float-button/float-button.d.mts.map +1 -1
- package/dist/components/atoms/float-button/index.d.mts.map +1 -1
- package/dist/components/atoms/index.d.mts +13 -2
- package/dist/components/atoms/input/index.d.mts +5 -1
- package/dist/components/atoms/input/index.d.mts.map +1 -1
- package/dist/components/atoms/input/index.mjs +5 -1
- package/dist/components/atoms/input/index.mjs.map +1 -1
- package/dist/components/atoms/input/number.d.mts +23 -0
- package/dist/components/atoms/input/number.d.mts.map +1 -0
- package/dist/components/atoms/input/number.mjs +71 -0
- package/dist/components/atoms/input/number.mjs.map +1 -0
- package/dist/components/atoms/input/otp.d.mts +26 -0
- package/dist/components/atoms/input/otp.d.mts.map +1 -0
- package/dist/components/atoms/input/otp.mjs +52 -0
- package/dist/components/atoms/input/otp.mjs.map +1 -0
- package/dist/components/atoms/input/search.d.mts +2 -7
- package/dist/components/atoms/input/search.d.mts.map +1 -1
- package/dist/components/atoms/input/search.mjs +6 -8
- package/dist/components/atoms/input/search.mjs.map +1 -1
- package/dist/components/atoms/mentions-token.mjs +31 -0
- package/dist/components/atoms/mentions-token.mjs.map +1 -0
- package/dist/components/atoms/option-group.d.mts +4 -5
- package/dist/components/atoms/option-group.d.mts.map +1 -1
- package/dist/components/atoms/popover.d.mts +2 -2
- package/dist/components/atoms/popover.d.mts.map +1 -1
- package/dist/components/atoms/progress.d.mts +5 -3
- package/dist/components/atoms/progress.d.mts.map +1 -1
- package/dist/components/atoms/progress.mjs +2 -2
- package/dist/components/atoms/progress.mjs.map +1 -1
- package/dist/components/atoms/radio/group.d.mts +2 -2
- package/dist/components/atoms/radio/group.d.mts.map +1 -1
- package/dist/components/atoms/radio/group.mjs +1 -1
- package/dist/components/atoms/radio/index.d.mts.map +1 -1
- package/dist/components/atoms/radio/radio.d.mts +2 -2
- package/dist/components/atoms/radio/radio.d.mts.map +1 -1
- package/dist/components/atoms/radio/radio.mjs +1 -1
- package/dist/components/atoms/rich-text-editor/rich-text-editor.d.mts +8 -3
- package/dist/components/atoms/rich-text-editor/rich-text-editor.d.mts.map +1 -1
- package/dist/components/atoms/rich-text-editor/rich-text-editor.mjs +7 -2
- package/dist/components/atoms/rich-text-editor/rich-text-editor.mjs.map +1 -1
- package/dist/components/atoms/rich-text-editor/toolbar-presets.mjs +2 -2
- package/dist/components/atoms/rich-text-editor/types.d.mts +2 -3
- package/dist/components/atoms/rich-text-editor/types.d.mts.map +1 -1
- package/dist/components/atoms/select-multiple.d.mts +2 -3
- package/dist/components/atoms/select-multiple.d.mts.map +1 -1
- package/dist/components/atoms/select-multiple.mjs +4 -3
- package/dist/components/atoms/select-multiple.mjs.map +1 -1
- package/dist/components/atoms/select-searchable-options.d.mts +3 -4
- package/dist/components/atoms/select-searchable-options.d.mts.map +1 -1
- package/dist/components/atoms/select-searchable.d.mts +2 -3
- package/dist/components/atoms/select-searchable.d.mts.map +1 -1
- package/dist/components/atoms/select-searchable.mjs +4 -3
- package/dist/components/atoms/select-searchable.mjs.map +1 -1
- package/dist/components/atoms/select.d.mts +4 -4
- package/dist/components/atoms/select.d.mts.map +1 -1
- package/dist/components/atoms/select.mjs +1 -1
- package/dist/components/atoms/select.mjs.map +1 -1
- package/dist/components/atoms/skeleton/button.d.mts.map +1 -1
- package/dist/components/atoms/skeleton/index.d.mts.map +1 -1
- package/dist/components/atoms/skeleton/node.d.mts.map +1 -1
- package/dist/components/atoms/skeleton/skeleton.d.mts +5 -3
- package/dist/components/atoms/skeleton/skeleton.d.mts.map +1 -1
- package/dist/components/atoms/skeleton/skeleton.mjs +2 -2
- package/dist/components/atoms/skeleton/skeleton.mjs.map +1 -1
- package/dist/components/atoms/slider/slider.d.mts +3 -3
- package/dist/components/atoms/slider/slider.d.mts.map +1 -1
- package/dist/components/atoms/spin.d.mts +2 -2
- package/dist/components/atoms/spin.d.mts.map +1 -1
- package/dist/components/atoms/spin.mjs +1 -1
- package/dist/components/atoms/switch.d.mts +2 -2
- package/dist/components/atoms/switch.d.mts.map +1 -1
- package/dist/components/atoms/tooltip.d.mts +2 -2
- package/dist/components/atoms/tooltip.d.mts.map +1 -1
- package/dist/components/atoms/typography/link.d.mts +2 -2
- package/dist/components/atoms/typography/link.d.mts.map +1 -1
- package/dist/components/atoms/typography/paragraph.d.mts +2 -2
- package/dist/components/atoms/typography/paragraph.d.mts.map +1 -1
- package/dist/components/atoms/typography/text.d.mts +2 -2
- package/dist/components/atoms/typography/text.d.mts.map +1 -1
- package/dist/components/atoms/typography/title.d.mts +2 -2
- package/dist/components/atoms/typography/title.d.mts.map +1 -1
- package/dist/components/atoms/typography/typography.d.mts +2 -2
- package/dist/components/atoms/typography/typography.d.mts.map +1 -1
- package/dist/components/molecules/collapse.d.mts +9 -9
- package/dist/components/molecules/collapse.d.mts.map +1 -1
- package/dist/components/molecules/collapse.mjs +11 -2
- package/dist/components/molecules/collapse.mjs.map +1 -1
- package/dist/components/molecules/dropdown.d.mts +2 -2
- package/dist/components/molecules/dropdown.d.mts.map +1 -1
- package/dist/components/molecules/index.d.mts +23 -13
- package/dist/components/molecules/marquees/index.d.mts.map +1 -1
- package/dist/components/molecules/marquees/item.d.mts +4 -4
- package/dist/components/molecules/marquees/item.d.mts.map +1 -1
- package/dist/components/molecules/marquees/item.mjs +5 -5
- package/dist/components/molecules/marquees/item.mjs.map +1 -1
- package/dist/components/molecules/marquees/marquees.d.mts +2 -2
- package/dist/components/molecules/marquees/marquees.d.mts.map +1 -1
- package/dist/components/molecules/marquees/marquees.mjs +4 -5
- package/dist/components/molecules/marquees/marquees.mjs.map +1 -1
- package/dist/components/molecules/menu/item/item.mjs +1 -1
- package/dist/components/molecules/menu/menu.d.mts +9 -9
- package/dist/components/molecules/menu/menu.d.mts.map +1 -1
- package/dist/components/molecules/menu/menu.mjs +3 -1
- package/dist/components/molecules/menu/menu.mjs.map +1 -1
- package/dist/components/molecules/reveals/item.d.mts +2 -2
- package/dist/components/molecules/reveals/item.d.mts.map +1 -1
- package/dist/components/molecules/reveals/reveals.d.mts +5 -5
- package/dist/components/molecules/reveals/reveals.d.mts.map +1 -1
- package/dist/components/molecules/splitter/index.d.mts.map +1 -1
- package/dist/components/molecules/splitter/panel.d.mts +3 -3
- package/dist/components/molecules/splitter/panel.d.mts.map +1 -1
- package/dist/components/molecules/splitter/splitter.d.mts +3 -3
- package/dist/components/molecules/splitter/splitter.d.mts.map +1 -1
- package/dist/components/molecules/tabs.d.mts +9 -5
- package/dist/components/molecules/tabs.d.mts.map +1 -1
- package/dist/components/molecules/tabs.mjs +5 -1
- package/dist/components/molecules/tabs.mjs.map +1 -1
- package/dist/components/molecules/upload.d.mts +3 -3
- package/dist/components/molecules/upload.d.mts.map +1 -1
- package/dist/components/molecules/upload.mjs +1 -1
- package/dist/components/organisms/drawer.d.mts +3 -3
- package/dist/components/organisms/drawer.d.mts.map +1 -1
- package/dist/components/organisms/drawer.mjs +4 -3
- package/dist/components/organisms/drawer.mjs.map +1 -1
- package/dist/components/organisms/form/context.d.mts +4 -0
- package/dist/components/organisms/form/context.d.mts.map +1 -0
- package/dist/components/organisms/form/context.mjs +9 -0
- package/dist/components/organisms/form/context.mjs.map +1 -0
- package/dist/components/organisms/form/control.d.mts +11 -0
- package/dist/components/organisms/form/control.d.mts.map +1 -0
- package/dist/components/organisms/form/control.mjs +19 -0
- package/dist/components/organisms/form/control.mjs.map +1 -0
- package/dist/components/organisms/form/field.d.mts +25 -0
- package/dist/components/organisms/form/field.d.mts.map +1 -0
- package/dist/components/organisms/form/field.mjs +54 -0
- package/dist/components/organisms/form/field.mjs.map +1 -0
- package/dist/components/organisms/form/form.d.mts +14 -0
- package/dist/components/organisms/form/form.d.mts.map +1 -0
- package/dist/components/organisms/form/form.mjs +23 -0
- package/dist/components/organisms/form/form.mjs.map +1 -0
- package/dist/components/organisms/index.d.mts +14 -6
- package/dist/components/organisms/list/index.d.mts.map +1 -1
- package/dist/components/organisms/list/list.d.mts +2 -2
- package/dist/components/organisms/list/list.d.mts.map +1 -1
- package/dist/components/organisms/modal.d.mts +6 -3
- package/dist/components/organisms/modal.d.mts.map +1 -1
- package/dist/components/organisms/modal.mjs +25 -18
- package/dist/components/organisms/modal.mjs.map +1 -1
- package/dist/components/organisms/swiper/index.d.mts.map +1 -1
- package/dist/components/organisms/swiper/swiper.d.mts +2 -2
- package/dist/components/organisms/swiper/swiper.d.mts.map +1 -1
- package/dist/components/organisms/toast.d.mts +2 -2
- package/dist/components/organisms/toast.d.mts.map +1 -1
- package/dist/components/organisms/toast.mjs +1 -1
- package/dist/components/templates/container.d.mts +2 -2
- package/dist/components/templates/container.d.mts.map +1 -1
- package/dist/components/templates/empty.d.mts +2 -2
- package/dist/components/templates/empty.d.mts.map +1 -1
- package/dist/components/templates/empty.mjs +1 -1
- package/dist/components/templates/grid/col.d.mts +2 -2
- package/dist/components/templates/grid/col.d.mts.map +1 -1
- package/dist/components/templates/grid/row.d.mts +2 -2
- package/dist/components/templates/grid/row.d.mts.map +1 -1
- package/dist/components/templates/layout/content.d.mts +2 -2
- package/dist/components/templates/layout/content.d.mts.map +1 -1
- package/dist/components/templates/layout/footer.d.mts +2 -2
- package/dist/components/templates/layout/footer.d.mts.map +1 -1
- package/dist/components/templates/layout/header.d.mts +2 -2
- package/dist/components/templates/layout/header.d.mts.map +1 -1
- package/dist/components/templates/layout/layout.d.mts +2 -2
- package/dist/components/templates/layout/layout.d.mts.map +1 -1
- package/dist/components/templates/layout/sider.d.mts +2 -2
- package/dist/components/templates/layout/sider.d.mts.map +1 -1
- package/dist/components/templates/layout/sider.mjs +1 -1
- package/dist/components/templates/page-header.d.mts +2 -2
- package/dist/components/templates/page-header.d.mts.map +1 -1
- package/dist/components/templates/page-header.mjs +1 -1
- package/dist/components/templates/result.d.mts +2 -2
- package/dist/components/templates/result.d.mts.map +1 -1
- package/dist/components/templates/result.mjs +1 -1
- package/dist/core/accordion.mjs +1 -1
- package/dist/core/autocomplete.d.mts +2 -0
- package/dist/core/autocomplete.mjs +48 -0
- package/dist/core/autocomplete.mjs.map +1 -0
- package/dist/core/badge.d.mts +5 -3
- package/dist/core/badge.d.mts.map +1 -1
- package/dist/core/button.d.mts +6 -4
- package/dist/core/button.d.mts.map +1 -1
- package/dist/core/calendar.d.mts +13 -3
- package/dist/core/calendar.d.mts.map +1 -0
- package/dist/core/calendar.mjs +1 -1
- package/dist/core/checkbox.mjs +11 -8
- package/dist/core/checkbox.mjs.map +1 -1
- package/dist/core/combobox.d.mts +26 -4
- package/dist/core/combobox.d.mts.map +1 -1
- package/dist/core/combobox.mjs +2 -2
- package/dist/core/combobox.mjs.map +1 -1
- package/dist/core/dialog.mjs +2 -2
- package/dist/core/dialog.mjs.map +1 -1
- package/dist/core/form.d.mts +8 -0
- package/dist/core/form.d.mts.map +1 -0
- package/dist/core/form.mjs +3 -0
- package/dist/core/index.d.mts +13 -9
- package/dist/core/popover.mjs +10 -2
- package/dist/core/popover.mjs.map +1 -1
- package/dist/core/radio-group.mjs +1 -1
- package/dist/core/resizable.d.mts +7 -2
- package/dist/core/resizable.d.mts.map +1 -1
- package/dist/core/resizable.mjs +1 -1
- package/dist/core/scroll-area.d.mts +20 -0
- package/dist/core/scroll-area.d.mts.map +1 -0
- package/dist/core/scroll-area.mjs +57 -0
- package/dist/core/scroll-area.mjs.map +1 -0
- package/dist/core/select.d.mts +24 -2
- package/dist/core/select.d.mts.map +1 -1
- package/dist/core/select.mjs +1 -1
- package/dist/core/separator.d.mts +13 -2
- package/dist/core/separator.d.mts.map +1 -0
- package/dist/core/tabs.d.mts +16 -2
- package/dist/core/tabs.d.mts.map +1 -1
- package/dist/index.d.mts +63 -34
- package/dist/index.mjs +29 -5
- package/dist/lib/colors.d.mts +2 -3
- package/dist/lib/colors.d.mts.map +1 -1
- package/dist/providers/config/context.d.mts +2 -3
- package/dist/providers/config/context.d.mts.map +1 -1
- package/dist/providers/config/context.mjs +3 -1
- package/dist/providers/config/context.mjs.map +1 -1
- package/dist/providers/config/registry.d.mts +2 -3
- package/dist/providers/config/registry.d.mts.map +1 -1
- package/dist/providers/config/types.d.mts +8 -7
- package/dist/providers/config/types.d.mts.map +1 -1
- package/dist/style.css +838 -288
- package/dist/utils.d.mts +2 -3
- package/dist/utils.d.mts.map +1 -1
- package/package.json +147 -26
- package/dist/components/molecules/marquees/use-pause-on-hover.mjs +0 -26
- package/dist/components/molecules/marquees/use-pause-on-hover.mjs.map +0 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "./utils.mjs";
|
|
3
|
+
import Button from "./Button.mjs";
|
|
4
|
+
import Typography from "./Typography.mjs";
|
|
5
|
+
import Popover from "./components/atoms/popover.mjs";
|
|
6
|
+
import * as React$1 from "react";
|
|
7
|
+
import { useControllableState } from "@jbpark/use-hooks";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/molecules/popconfirm.tsx
|
|
10
|
+
const Popconfirm = ({ children, title, description, onConfirm, onCancel, onConfirmError, errorMessage = "Unable to complete the action. Please try again.", confirmText = "Confirm", cancelText = "Cancel", disabled = false, confirmButtonProps, cancelButtonProps, className, classNames, open: controlledOpen, defaultOpen, onOpenChange, ...props }) => {
|
|
11
|
+
const [open, setOpen] = useControllableState({
|
|
12
|
+
value: controlledOpen,
|
|
13
|
+
defaultValue: defaultOpen ?? false,
|
|
14
|
+
onChange: onOpenChange
|
|
15
|
+
});
|
|
16
|
+
const [pending, setPending] = React$1.useState(false);
|
|
17
|
+
const [failed, setFailed] = React$1.useState(false);
|
|
18
|
+
const busy = React$1.useRef(false);
|
|
19
|
+
const mounted = React$1.useRef(false);
|
|
20
|
+
const generation = React$1.useRef(0);
|
|
21
|
+
const descriptionId = React$1.useId();
|
|
22
|
+
const titleId = React$1.useId();
|
|
23
|
+
React$1.useEffect(() => {
|
|
24
|
+
mounted.current = true;
|
|
25
|
+
return () => {
|
|
26
|
+
mounted.current = false;
|
|
27
|
+
generation.current += 1;
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
30
|
+
React$1.useEffect(() => {
|
|
31
|
+
if (!open || disabled) generation.current += 1;
|
|
32
|
+
}, [open, disabled]);
|
|
33
|
+
const handleOpenChange = (nextOpen) => {
|
|
34
|
+
if (busy.current || disabled && nextOpen) return;
|
|
35
|
+
setFailed(false);
|
|
36
|
+
setOpen(nextOpen);
|
|
37
|
+
};
|
|
38
|
+
const handleConfirm = async () => {
|
|
39
|
+
if (busy.current || disabled) return;
|
|
40
|
+
busy.current = true;
|
|
41
|
+
setPending(true);
|
|
42
|
+
setFailed(false);
|
|
43
|
+
const request = generation.current;
|
|
44
|
+
try {
|
|
45
|
+
await onConfirm?.();
|
|
46
|
+
if (mounted.current && request === generation.current) setOpen(false);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (mounted.current && request === generation.current) {
|
|
49
|
+
setFailed(true);
|
|
50
|
+
onConfirmError?.(error);
|
|
51
|
+
}
|
|
52
|
+
} finally {
|
|
53
|
+
busy.current = false;
|
|
54
|
+
if (mounted.current) setPending(false);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return /* @__PURE__ */ jsx(Popover, {
|
|
58
|
+
...props,
|
|
59
|
+
open: open && !disabled,
|
|
60
|
+
onOpenChange: handleOpenChange,
|
|
61
|
+
className: cn("max-w-[calc(100vw-2rem)]", className),
|
|
62
|
+
"aria-labelledby": titleId,
|
|
63
|
+
"aria-describedby": description ? descriptionId : void 0,
|
|
64
|
+
content: /* @__PURE__ */ jsxs("div", {
|
|
65
|
+
"data-slot": "popconfirm",
|
|
66
|
+
"aria-busy": pending,
|
|
67
|
+
className: "space-y-3",
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ jsx(Typography.Title, {
|
|
70
|
+
level: 6,
|
|
71
|
+
id: titleId,
|
|
72
|
+
className: classNames?.title,
|
|
73
|
+
children: title
|
|
74
|
+
}),
|
|
75
|
+
description && /* @__PURE__ */ jsx("div", {
|
|
76
|
+
id: descriptionId,
|
|
77
|
+
className: cn("text-muted-foreground text-sm", classNames?.description),
|
|
78
|
+
children: description
|
|
79
|
+
}),
|
|
80
|
+
failed && /* @__PURE__ */ jsx("div", {
|
|
81
|
+
role: "alert",
|
|
82
|
+
className: cn("text-destructive text-sm", classNames?.error),
|
|
83
|
+
children: errorMessage
|
|
84
|
+
}),
|
|
85
|
+
/* @__PURE__ */ jsxs("div", {
|
|
86
|
+
className: cn("flex justify-end gap-2", classNames?.actions),
|
|
87
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
88
|
+
size: "small",
|
|
89
|
+
...cancelButtonProps,
|
|
90
|
+
htmlType: "button",
|
|
91
|
+
disabled: pending,
|
|
92
|
+
className: cn(cancelButtonProps?.className, classNames?.cancel),
|
|
93
|
+
onClick: () => {
|
|
94
|
+
if (busy.current) return;
|
|
95
|
+
setFailed(false);
|
|
96
|
+
setOpen(false);
|
|
97
|
+
onCancel?.();
|
|
98
|
+
},
|
|
99
|
+
children: cancelText
|
|
100
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
101
|
+
size: "small",
|
|
102
|
+
type: "primary",
|
|
103
|
+
...confirmButtonProps,
|
|
104
|
+
htmlType: "button",
|
|
105
|
+
loading: pending,
|
|
106
|
+
className: cn(confirmButtonProps?.className, classNames?.confirm),
|
|
107
|
+
onClick: () => void handleConfirm(),
|
|
108
|
+
children: confirmText
|
|
109
|
+
})]
|
|
110
|
+
})
|
|
111
|
+
]
|
|
112
|
+
}),
|
|
113
|
+
children
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
//#endregion
|
|
117
|
+
export { Popconfirm as default };
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=Popconfirm.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popconfirm.mjs","names":["React"],"sources":["../src/components/molecules/popconfirm.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { useControllableState } from '@jbpark/use-hooks';\n\nimport { cn } from '@repo/ui/utils';\n\nimport Button, { type Props as ButtonProps } from '../atoms/button';\nimport Popover, { type Props as PopoverProps } from '../atoms/popover';\nimport Typography from '../atoms/typography';\n\ntype ActionProps = Omit<\n ButtonProps,\n 'children' | 'onClick' | 'loading' | 'disabled'\n>;\n\nexport interface Props extends Omit<\n PopoverProps,\n 'content' | 'title' | 'children'\n> {\n children: React.ReactElement;\n title: React.ReactNode;\n description?: React.ReactNode;\n /** A fulfilled promise closes the popup; a thrown error keeps it open. */\n onConfirm?: () => void | Promise<void>;\n /** Only the Cancel button invokes this callback. */\n onCancel?: () => void;\n onConfirmError?: (error: unknown) => void;\n errorMessage?: React.ReactNode;\n confirmText?: React.ReactNode;\n cancelText?: React.ReactNode;\n disabled?: boolean;\n confirmButtonProps?: ActionProps;\n cancelButtonProps?: ActionProps;\n classNames?: {\n title?: string;\n description?: string;\n actions?: string;\n confirm?: string;\n cancel?: string;\n error?: string;\n };\n}\n\nconst Popconfirm = ({\n children,\n title,\n description,\n onConfirm,\n onCancel,\n onConfirmError,\n errorMessage = 'Unable to complete the action. Please try again.',\n confirmText = 'Confirm',\n cancelText = 'Cancel',\n disabled = false,\n confirmButtonProps,\n cancelButtonProps,\n className,\n classNames,\n open: controlledOpen,\n defaultOpen,\n onOpenChange,\n ...props\n}: Props) => {\n const [open, setOpen] = useControllableState<boolean>({\n value: controlledOpen,\n defaultValue: defaultOpen ?? false,\n onChange: onOpenChange,\n });\n const [pending, setPending] = React.useState(false);\n const [failed, setFailed] = React.useState(false);\n const busy = React.useRef(false);\n const mounted = React.useRef(false);\n const generation = React.useRef(0);\n const descriptionId = React.useId();\n const titleId = React.useId();\n\n React.useEffect(() => {\n mounted.current = true;\n\n return () => {\n mounted.current = false;\n generation.current += 1;\n };\n }, []);\n\n React.useEffect(() => {\n if (!open || disabled) {\n generation.current += 1;\n }\n }, [open, disabled]);\n\n const handleOpenChange = (nextOpen: boolean) => {\n if (busy.current || (disabled && nextOpen)) {\n return;\n }\n\n setFailed(false);\n setOpen(nextOpen);\n };\n\n const handleConfirm = async () => {\n if (busy.current || disabled) {\n return;\n }\n\n busy.current = true;\n setPending(true);\n setFailed(false);\n const request = generation.current;\n\n try {\n await onConfirm?.();\n\n if (mounted.current && request === generation.current) {\n setOpen(false);\n }\n } catch (error) {\n if (mounted.current && request === generation.current) {\n setFailed(true);\n onConfirmError?.(error);\n }\n } finally {\n busy.current = false;\n\n if (mounted.current) {\n setPending(false);\n }\n }\n };\n\n return (\n <Popover\n {...props}\n open={open && !disabled}\n onOpenChange={handleOpenChange}\n className={cn(\n 'max-w-[calc(100vw-2rem)]',\n className, //\n )}\n aria-labelledby={titleId}\n aria-describedby={description ? descriptionId : undefined}\n content={\n <div data-slot=\"popconfirm\" aria-busy={pending} className=\"space-y-3\">\n <Typography.Title\n level={6}\n id={titleId}\n className={classNames?.title}\n >\n {title}\n </Typography.Title>\n {description && (\n <div\n id={descriptionId}\n className={cn(\n 'text-muted-foreground text-sm',\n classNames?.description, //\n )}\n >\n {description}\n </div>\n )}\n {failed && (\n <div\n role=\"alert\"\n className={cn(\n 'text-destructive text-sm',\n classNames?.error, //\n )}\n >\n {errorMessage}\n </div>\n )}\n <div\n className={cn(\n 'flex justify-end gap-2',\n classNames?.actions, //\n )}\n >\n <Button\n size=\"small\"\n {...cancelButtonProps}\n htmlType=\"button\"\n disabled={pending}\n className={cn(\n cancelButtonProps?.className,\n classNames?.cancel, //\n )}\n onClick={() => {\n if (busy.current) {\n return;\n }\n\n setFailed(false);\n setOpen(false);\n onCancel?.();\n }}\n >\n {cancelText}\n </Button>\n <Button\n size=\"small\"\n type=\"primary\"\n {...confirmButtonProps}\n htmlType=\"button\"\n loading={pending}\n className={cn(\n confirmButtonProps?.className,\n classNames?.confirm, //\n )}\n onClick={() => void handleConfirm()}\n >\n {confirmText}\n </Button>\n </div>\n </div>\n }\n >\n {children}\n </Popover>\n );\n};\n\nexport default Popconfirm;\n"],"mappings":";;;;;;;;;AA6CA,MAAM,cAAc,EAClB,UACA,OACA,aACA,WACA,UACA,gBACA,eAAe,oDACf,cAAc,WACd,aAAa,UACb,WAAW,OACX,oBACA,mBACA,WACA,YACA,MAAM,gBACN,aACA,cACA,GAAG,YACQ;CACX,MAAM,CAAC,MAAM,WAAW,qBAA8B;EACpD,OAAO;EACP,cAAc,eAAe;EAC7B,UAAU;CACZ,CAAC;CACD,MAAM,CAAC,SAAS,cAAcA,QAAM,SAAS,KAAK;CAClD,MAAM,CAAC,QAAQ,aAAaA,QAAM,SAAS,KAAK;CAChD,MAAM,OAAOA,QAAM,OAAO,KAAK;CAC/B,MAAM,UAAUA,QAAM,OAAO,KAAK;CAClC,MAAM,aAAaA,QAAM,OAAO,CAAC;CACjC,MAAM,gBAAgBA,QAAM,MAAM;CAClC,MAAM,UAAUA,QAAM,MAAM;CAE5B,QAAM,gBAAgB;EACpB,QAAQ,UAAU;EAElB,aAAa;GACX,QAAQ,UAAU;GAClB,WAAW,WAAW;EACxB;CACF,GAAG,CAAC,CAAC;CAEL,QAAM,gBAAgB;EACpB,IAAI,CAAC,QAAQ,UACX,WAAW,WAAW;CAE1B,GAAG,CAAC,MAAM,QAAQ,CAAC;CAEnB,MAAM,oBAAoB,aAAsB;EAC9C,IAAI,KAAK,WAAY,YAAY,UAC/B;EAGF,UAAU,KAAK;EACf,QAAQ,QAAQ;CAClB;CAEA,MAAM,gBAAgB,YAAY;EAChC,IAAI,KAAK,WAAW,UAClB;EAGF,KAAK,UAAU;EACf,WAAW,IAAI;EACf,UAAU,KAAK;EACf,MAAM,UAAU,WAAW;EAE3B,IAAI;GACF,MAAM,YAAY;GAElB,IAAI,QAAQ,WAAW,YAAY,WAAW,SAC5C,QAAQ,KAAK;EAEjB,SAAS,OAAO;GACd,IAAI,QAAQ,WAAW,YAAY,WAAW,SAAS;IACrD,UAAU,IAAI;IACd,iBAAiB,KAAK;GACxB;EACF,UAAU;GACR,KAAK,UAAU;GAEf,IAAI,QAAQ,SACV,WAAW,KAAK;EAEpB;CACF;CAEA,OACE,oBAAC,SAAD;EACE,GAAI;EACJ,MAAM,QAAQ,CAAC;EACf,cAAc;EACd,WAAW,GACT,4BACA,SACF;EACA,mBAAiB;EACjB,oBAAkB,cAAc,gBAAgB,KAAA;EAChD,SACE,qBAAC,OAAD;GAAK,aAAU;GAAa,aAAW;GAAS,WAAU;GAA1D,UAAA;IACE,oBAAC,WAAW,OAAZ;KACE,OAAO;KACP,IAAI;KACJ,WAAW,YAAY;KAEtB,UAAA;IACe,CAAA;IACjB,eACC,oBAAC,OAAD;KACE,IAAI;KACJ,WAAW,GACT,iCACA,YAAY,WACd;KAEC,UAAA;IACE,CAAA;IAEN,UACC,oBAAC,OAAD;KACE,MAAK;KACL,WAAW,GACT,4BACA,YAAY,KACd;KAEC,UAAA;IACE,CAAA;IAEP,qBAAC,OAAD;KACE,WAAW,GACT,0BACA,YAAY,OACd;KAJF,UAAA,CAME,oBAAC,QAAD;MACE,MAAK;MACL,GAAI;MACJ,UAAS;MACT,UAAU;MACV,WAAW,GACT,mBAAmB,WACnB,YAAY,MACd;MACA,eAAe;OACb,IAAI,KAAK,SACP;OAGF,UAAU,KAAK;OACf,QAAQ,KAAK;OACb,WAAW;MACb;MAEC,UAAA;KACK,CAAA,GACR,oBAAC,QAAD;MACE,MAAK;MACL,MAAK;MACL,GAAI;MACJ,UAAS;MACT,SAAS;MACT,WAAW,GACT,oBAAoB,WACpB,YAAY,OACd;MACA,eAAe,KAAK,cAAc;MAEjC,UAAA;KACK,CAAA,CACL;;GACF;;EAGN;CACM,CAAA;AAEb"}
|
package/dist/Rate.d.mts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
|
+
//#region src/components/atoms/rate.d.ts
|
|
3
|
+
export interface Props extends Omit<ComponentPropsWithRef<'div'>, 'children' | 'value' | 'defaultValue' | 'onChange'> {
|
|
4
|
+
/** Positive whole-step count. Defaults to five. */
|
|
5
|
+
count?: number;
|
|
6
|
+
/** Zero means no rating. Values are rounded down and clamped to 0–count. */
|
|
7
|
+
value?: number;
|
|
8
|
+
defaultValue?: number;
|
|
9
|
+
onChange?: (value: number) => void;
|
|
10
|
+
/** Activating the selected score clears it to zero. Defaults to true. */
|
|
11
|
+
allowClear?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
readOnly?: boolean;
|
|
14
|
+
name?: string;
|
|
15
|
+
icon?: ReactNode;
|
|
16
|
+
getItemLabel?: (score: number, count: number) => string;
|
|
17
|
+
getValueText?: (value: number, count: number) => string;
|
|
18
|
+
classNames?: {
|
|
19
|
+
item?: string;
|
|
20
|
+
filledItem?: string;
|
|
21
|
+
icon?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
declare const Rate: ({ count, value, defaultValue, onChange, allowClear, disabled, readOnly, name, icon, getItemLabel, getValueText, className, classNames, dir, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...props }: Props) => import("react").JSX.Element;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { Rate as default };
|
|
27
|
+
//# sourceMappingURL=Rate.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rate.d.mts","names":[],"sources":["../src/components/atoms/rate.tsx"],"mappings":";;iBAmBiB,cAAc,KAC7B;;EAIA;;EAEA;EACA;EACA,YAAY;;EAEZ;EACA;EACA;EACA;EACA,OAAO;EACP,gBAAgB,eAAe;EAC/B,gBAAgB,eAAe;EAC/B;IAAe;IAAe;IAAqB;;;cAG/C,SAAQ,OAAA,OAAA,cAAA,UAAA,YAAA,UAAA,UAAA,MAAA,MAAA,cAAA,cAAA,WAAA,YAAA,mBAAA,8BAAA,oCAAA,oBAAA,SAoBX,0BAAK,IAAA"}
|
package/dist/Rate.mjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "./utils.mjs";
|
|
3
|
+
import { useConfig } from "./providers/config/context.mjs";
|
|
4
|
+
import Button from "./Button.mjs";
|
|
5
|
+
import { useId, useState } from "react";
|
|
6
|
+
import { DirectionProvider } from "@base-ui/react/direction-provider";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Star } from "lucide-react";
|
|
9
|
+
import { Radio } from "@base-ui/react/radio";
|
|
10
|
+
import { RadioGroup } from "@base-ui/react/radio-group";
|
|
11
|
+
//#region src/components/atoms/rate.tsx
|
|
12
|
+
const Rate = ({ count = 5, value, defaultValue = 0, onChange, allowClear = true, disabled = false, readOnly = false, name, icon, getItemLabel = (score, total) => `${score} of ${total} stars`, getValueText = (score, total) => score === 0 ? "No rating" : `${score} of ${total} stars`, className, classNames, dir, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...props }) => {
|
|
13
|
+
const total = Number.isFinite(count) ? Math.max(1, Math.floor(count)) : 5;
|
|
14
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
15
|
+
const rawValue = value ?? internalValue;
|
|
16
|
+
const score = Number.isFinite(rawValue) ? Math.min(total, Math.max(0, Math.floor(rawValue))) : 0;
|
|
17
|
+
const { direction } = useConfig();
|
|
18
|
+
const resolvedDirection = dir === "ltr" || dir === "rtl" ? dir : direction;
|
|
19
|
+
const statusId = useId();
|
|
20
|
+
const changeValue = (next) => {
|
|
21
|
+
if (disabled || readOnly || next === score) return;
|
|
22
|
+
if (value === void 0) setInternalValue(next);
|
|
23
|
+
onChange?.(next);
|
|
24
|
+
};
|
|
25
|
+
return /* @__PURE__ */ jsx(DirectionProvider, {
|
|
26
|
+
direction: resolvedDirection,
|
|
27
|
+
children: /* @__PURE__ */ jsxs(RadioGroup, {
|
|
28
|
+
...props,
|
|
29
|
+
"data-slot": "rate",
|
|
30
|
+
dir: dir ?? resolvedDirection,
|
|
31
|
+
"aria-label": ariaLabel ?? (ariaLabelledBy ? void 0 : "Rating"),
|
|
32
|
+
"aria-labelledby": ariaLabelledBy,
|
|
33
|
+
"aria-describedby": [ariaDescribedBy, statusId].filter(Boolean).join(" "),
|
|
34
|
+
disabled,
|
|
35
|
+
readOnly,
|
|
36
|
+
name,
|
|
37
|
+
value: score === 0 ? "" : String(score),
|
|
38
|
+
onValueChange: (next) => changeValue(Number(next)),
|
|
39
|
+
className: cn("inline-flex w-fit max-w-full flex-wrap items-center gap-1", className),
|
|
40
|
+
children: [Array.from({ length: total }, (_, index) => {
|
|
41
|
+
const itemScore = index + 1;
|
|
42
|
+
const isFilled = itemScore <= score;
|
|
43
|
+
return /* @__PURE__ */ jsx(Radio.Root, {
|
|
44
|
+
value: String(itemScore),
|
|
45
|
+
nativeButton: true,
|
|
46
|
+
"data-slot": "rate-item",
|
|
47
|
+
"data-filled": isFilled ? "" : void 0,
|
|
48
|
+
"aria-label": getItemLabel(itemScore, total),
|
|
49
|
+
onClick: (event) => {
|
|
50
|
+
if (allowClear && itemScore === score && !disabled && !readOnly) {
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
changeValue(0);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
56
|
+
variant: "text",
|
|
57
|
+
size: "small",
|
|
58
|
+
disabled,
|
|
59
|
+
className: cn("text-muted-foreground size-8 shrink-0 p-1", readOnly && "cursor-default", isFilled && "text-primary", classNames?.item, isFilled && classNames?.filledItem)
|
|
60
|
+
}),
|
|
61
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
62
|
+
"data-slot": "rate-icon",
|
|
63
|
+
"aria-hidden": "true",
|
|
64
|
+
className: cn("flex size-5 items-center justify-center [&>svg]:size-full", isFilled && "[&>svg]:fill-current", classNames?.icon),
|
|
65
|
+
children: icon ?? /* @__PURE__ */ jsx(Star, {})
|
|
66
|
+
})
|
|
67
|
+
}, itemScore);
|
|
68
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
69
|
+
id: statusId,
|
|
70
|
+
"data-slot": "rate-status",
|
|
71
|
+
className: "sr-only",
|
|
72
|
+
"aria-live": "polite",
|
|
73
|
+
children: getValueText(score, total)
|
|
74
|
+
})]
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
//#endregion
|
|
79
|
+
export { Rate as default };
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=Rate.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rate.mjs","names":[],"sources":["../src/components/atoms/rate.tsx"],"sourcesContent":["'use client';\n\nimport {\n type ComponentPropsWithRef,\n type ReactNode,\n useId,\n useState,\n} from 'react';\n\nimport { DirectionProvider } from '@base-ui/react/direction-provider';\nimport { Radio } from '@base-ui/react/radio';\nimport { RadioGroup } from '@base-ui/react/radio-group';\nimport { Star } from 'lucide-react';\n\nimport { useConfig } from '@repo/ui/providers';\nimport { cn } from '@repo/ui/utils';\n\nimport Button from './button';\n\nexport interface Props extends Omit<\n ComponentPropsWithRef<'div'>,\n 'children' | 'value' | 'defaultValue' | 'onChange'\n> {\n /** Positive whole-step count. Defaults to five. */\n count?: number;\n /** Zero means no rating. Values are rounded down and clamped to 0–count. */\n value?: number;\n defaultValue?: number;\n onChange?: (value: number) => void;\n /** Activating the selected score clears it to zero. Defaults to true. */\n allowClear?: boolean;\n disabled?: boolean;\n readOnly?: boolean;\n name?: string;\n icon?: ReactNode;\n getItemLabel?: (score: number, count: number) => string;\n getValueText?: (value: number, count: number) => string;\n classNames?: { item?: string; filledItem?: string; icon?: string };\n}\n\nconst Rate = ({\n count = 5,\n value,\n defaultValue = 0,\n onChange,\n allowClear = true,\n disabled = false,\n readOnly = false,\n name,\n icon,\n getItemLabel = (score, total) => `${score} of ${total} stars`,\n getValueText = (score, total) =>\n score === 0 ? 'No rating' : `${score} of ${total} stars`,\n className,\n classNames,\n dir,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...props\n}: Props) => {\n const total = Number.isFinite(count) ? Math.max(1, Math.floor(count)) : 5;\n const [internalValue, setInternalValue] = useState(defaultValue);\n const rawValue = value ?? internalValue;\n const score = Number.isFinite(rawValue)\n ? Math.min(total, Math.max(0, Math.floor(rawValue)))\n : 0;\n const { direction } = useConfig();\n const resolvedDirection = dir === 'ltr' || dir === 'rtl' ? dir : direction;\n const statusId = useId();\n\n const changeValue = (next: number) => {\n if (disabled || readOnly || next === score) {\n return;\n }\n\n if (value === undefined) {\n setInternalValue(next);\n }\n\n onChange?.(next);\n };\n\n return (\n <DirectionProvider direction={resolvedDirection}>\n <RadioGroup\n {...props}\n data-slot=\"rate\"\n dir={dir ?? resolvedDirection}\n aria-label={ariaLabel ?? (ariaLabelledBy ? undefined : 'Rating')}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={[ariaDescribedBy, statusId].filter(Boolean).join(' ')}\n disabled={disabled}\n readOnly={readOnly}\n name={name}\n value={score === 0 ? '' : String(score)}\n onValueChange={next => changeValue(Number(next))}\n className={cn(\n 'inline-flex w-fit max-w-full flex-wrap items-center gap-1',\n className, //\n )}\n >\n {Array.from({ length: total }, (_, index) => {\n const itemScore = index + 1;\n const isFilled = itemScore <= score;\n\n return (\n <Radio.Root\n key={itemScore}\n value={String(itemScore)}\n nativeButton\n data-slot=\"rate-item\"\n data-filled={isFilled ? '' : undefined}\n aria-label={getItemLabel(itemScore, total)}\n onClick={event => {\n if (\n allowClear &&\n itemScore === score &&\n !disabled &&\n !readOnly\n ) {\n event.preventDefault();\n changeValue(0);\n }\n }}\n render={\n <Button\n variant=\"text\"\n size=\"small\"\n disabled={disabled}\n className={cn(\n 'text-muted-foreground size-8 shrink-0 p-1',\n readOnly && 'cursor-default',\n isFilled && 'text-primary',\n classNames?.item,\n isFilled && classNames?.filledItem, //\n )}\n />\n }\n >\n <span\n data-slot=\"rate-icon\"\n aria-hidden=\"true\"\n className={cn(\n 'flex size-5 items-center justify-center [&>svg]:size-full',\n isFilled && '[&>svg]:fill-current',\n classNames?.icon, //\n )}\n >\n {icon ?? <Star />}\n </span>\n </Radio.Root>\n );\n })}\n <span\n id={statusId}\n data-slot=\"rate-status\"\n className=\"sr-only\"\n aria-live=\"polite\"\n >\n {getValueText(score, total)}\n </span>\n </RadioGroup>\n </DirectionProvider>\n );\n};\n\nexport default Rate;\n"],"mappings":";;;;;;;;;;;AAwCA,MAAM,QAAQ,EACZ,QAAQ,GACR,OACA,eAAe,GACf,UACA,aAAa,MACb,WAAW,OACX,WAAW,OACX,MACA,MACA,gBAAgB,OAAO,UAAU,GAAG,MAAM,MAAM,MAAM,SACtD,gBAAgB,OAAO,UACrB,UAAU,IAAI,cAAc,GAAG,MAAM,MAAM,MAAM,SACnD,WACA,YACA,KACA,cAAc,WACd,mBAAmB,gBACnB,oBAAoB,iBACpB,GAAG,YACQ;CACX,MAAM,QAAQ,OAAO,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,CAAC,IAAI;CACxE,MAAM,CAAC,eAAe,oBAAoB,SAAS,YAAY;CAC/D,MAAM,WAAW,SAAS;CAC1B,MAAM,QAAQ,OAAO,SAAS,QAAQ,IAClC,KAAK,IAAI,OAAO,KAAK,IAAI,GAAG,KAAK,MAAM,QAAQ,CAAC,CAAC,IACjD;CACJ,MAAM,EAAE,cAAc,UAAU;CAChC,MAAM,oBAAoB,QAAQ,SAAS,QAAQ,QAAQ,MAAM;CACjE,MAAM,WAAW,MAAM;CAEvB,MAAM,eAAe,SAAiB;EACpC,IAAI,YAAY,YAAY,SAAS,OACnC;EAGF,IAAI,UAAU,KAAA,GACZ,iBAAiB,IAAI;EAGvB,WAAW,IAAI;CACjB;CAEA,OACE,oBAAC,mBAAD;EAAmB,WAAW;EAC5B,UAAA,qBAAC,YAAD;GACE,GAAI;GACJ,aAAU;GACV,KAAK,OAAO;GACZ,cAAY,cAAc,iBAAiB,KAAA,IAAY;GACvD,mBAAiB;GACjB,oBAAkB,CAAC,iBAAiB,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;GAC5D;GACA;GACJ;GACN,OAAO,UAAU,IAAI,KAAK,OAAO,KAAK;GACtC,gBAAe,SAAQ,YAAY,OAAO,IAAI,CAAC;GAC/C,WAAW,GACT,6DACA,SACF;GAfF,UAAA,CAiBG,MAAM,KAAK,EAAE,QAAQ,MAAM,IAAI,GAAG,UAAU;IAC3C,MAAM,YAAY,QAAQ;IAC1B,MAAM,WAAW,aAAa;IAE9B,OACE,oBAAC,MAAM,MAAP;KAEE,OAAO,OAAO,SAAS;KACvB,cAAA;KACA,aAAU;KACV,eAAa,WAAW,KAAK,KAAA;KAC7B,cAAY,aAAa,WAAW,KAAK;KACzC,UAAS,UAAS;MAChB,IACE,cACA,cAAc,SACd,CAAC,YACD,CAAC,UACD;OACA,MAAM,eAAe;OACrB,YAAY,CAAC;MACf;KACF;KACA,QACE,oBAAC,QAAD;MACE,SAAQ;MACR,MAAK;MACK;MACV,WAAW,GACT,6CACA,YAAY,kBACZ,YAAY,gBACZ,YAAY,MACZ,YAAY,YAAY,UAC1B;KACD,CAAA;KAGH,UAAA,oBAAC,QAAD;MACE,aAAU;MACV,eAAY;MACZ,WAAW,GACT,6DACA,YAAY,wBACZ,YAAY,IACd;MAEC,UAAA,QAAQ,oBAAC,MAAD,CAAO,CAAA;KACZ,CAAA;IACI,GA3CL,SA2CK;GAEhB,CAAC,GACD,oBAAC,QAAD;IACE,IAAI;IACJ,aAAU;IACV,WAAU;IACV,aAAU;IAET,UAAA,aAAa,OAAO,KAAK;GACtB,CAAA,CACI;;CACK,CAAA;AAEvB"}
|
package/dist/Reveals.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Reveals.d.mts","names":[],"sources":["../src/components/molecules/reveals/index.ts"],"mappings":";;;KAGK,
|
|
1
|
+
{"version":3,"file":"Reveals.d.mts","names":["RevealsImpl"],"sources":["../src/components/molecules/reveals/index.ts"],"mappings":";;;KAGK,0BAA0BA;EAAgB,aAAa;;cAEtD,SAAyB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Props as Props$1 } from "./core/scroll-area.mjs";
|
|
2
|
+
import "./core/index.mjs";
|
|
3
|
+
//#region src/components/molecules/scroll-area.d.ts
|
|
4
|
+
export interface Props extends Props$1 {}
|
|
5
|
+
declare const ScrollArea: (props: Props) => import("react").JSX.Element;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { ScrollArea as default };
|
|
8
|
+
//# sourceMappingURL=ScrollArea.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollArea.d.mts","names":["scrollArea.Props"],"sources":["../src/components/molecules/scroll-area.tsx"],"mappings":";;;iBAIiB,cAAcA;cAEzB,aAAc,OAAO,0BAAK,IAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ScrollArea as ScrollArea$1 } from "./core/scroll-area.mjs";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/molecules/scroll-area.tsx
|
|
5
|
+
const ScrollArea = (props) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(ScrollArea$1, { ...props });
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { ScrollArea as default };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=ScrollArea.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollArea.mjs","names":["scrollArea.ScrollArea"],"sources":["../src/components/molecules/scroll-area.tsx"],"sourcesContent":["'use client';\n\nimport { scrollArea } from '../../core';\n\nexport interface Props extends scrollArea.Props {}\n\nconst ScrollArea = (props: Props) => {\n return <scrollArea.ScrollArea {...props} />;\n};\n\nexport default ScrollArea;\n"],"mappings":";;;;AAMA,MAAM,cAAc,UAAiB;CACnC,OAAO,oBAACA,cAAD,EAAuB,GAAI,MAAQ,CAAA;AAC5C"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ComponentSize } from "./providers/config/types.mjs";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
import { ToggleGroup } from "@base-ui/react/toggle-group";
|
|
4
|
+
//#region src/components/atoms/segmented.d.ts
|
|
5
|
+
export interface Option {
|
|
6
|
+
label: string;
|
|
7
|
+
value: string;
|
|
8
|
+
icon?: React$1.ReactNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface Props extends Omit<ToggleGroup.Props, 'children' | 'value' | 'defaultValue' | 'onValueChange' | 'onChange' | 'multiple'> {
|
|
12
|
+
options: readonly (string | Option)[];
|
|
13
|
+
value?: string;
|
|
14
|
+
defaultValue?: string;
|
|
15
|
+
/** Clicking the selected item keeps it selected. */
|
|
16
|
+
onChange?: (value: string) => void;
|
|
17
|
+
size?: ComponentSize;
|
|
18
|
+
classNames?: {
|
|
19
|
+
item?: string;
|
|
20
|
+
activeItem?: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
declare const Segmented: ({ options, value, defaultValue, onChange, size, className, classNames, disabled, orientation, ...props }: Props) => React$1.JSX.Element;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { Segmented as default };
|
|
26
|
+
//# sourceMappingURL=Segmented.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Segmented.d.mts","names":["React"],"sources":["../src/components/atoms/segmented.tsx"],"mappings":";;;;iBAUiB;EACf;EACA;EACA,OAAOA,QAAM;EACb;;iBASe,cAAc,KAC7B,YAAY;EAGZ,4BAA4B;EAC5B;EACA;;EAEA,YAAY;EACZ,OAAO;EACP;IACE;IACA;;;cAIE,cAAa,SAAA,OAAA,cAAA,UAAA,MAAA,WAAA,YAAA,UAAA,gBAAA,SAWhB,UAAKA,QAAA,IAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "./utils.mjs";
|
|
3
|
+
import { useConfig } from "./providers/config/context.mjs";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Toggle } from "@base-ui/react/toggle";
|
|
7
|
+
import { ToggleGroup } from "@base-ui/react/toggle-group";
|
|
8
|
+
//#region src/components/atoms/segmented.tsx
|
|
9
|
+
const sizeClasses = {
|
|
10
|
+
small: "min-h-7 px-2 text-xs",
|
|
11
|
+
middle: "min-h-8 px-3 text-sm",
|
|
12
|
+
large: "min-h-10 px-4 text-base"
|
|
13
|
+
};
|
|
14
|
+
const Segmented = ({ options, value, defaultValue, onChange, size, className, classNames, disabled, orientation = "horizontal", ...props }) => {
|
|
15
|
+
const normalizedOptions = options.map((option) => typeof option === "string" ? {
|
|
16
|
+
label: option,
|
|
17
|
+
value: option,
|
|
18
|
+
disabled: false,
|
|
19
|
+
icon: null
|
|
20
|
+
} : option);
|
|
21
|
+
const firstEnabled = normalizedOptions.find((option) => !option.disabled)?.value;
|
|
22
|
+
const [internalValue, setInternalValue] = React$1.useState(defaultValue ?? firstEnabled);
|
|
23
|
+
const selectedValue = value !== void 0 ? value : internalValue;
|
|
24
|
+
const { componentSize } = useConfig();
|
|
25
|
+
const resolvedSize = size ?? componentSize ?? "middle";
|
|
26
|
+
const handleValueChange = (values) => {
|
|
27
|
+
const nextValue = values[0];
|
|
28
|
+
if (nextValue === void 0 || nextValue === selectedValue) return;
|
|
29
|
+
if (value === void 0) setInternalValue(nextValue);
|
|
30
|
+
onChange?.(nextValue);
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ jsx(ToggleGroup, {
|
|
33
|
+
...props,
|
|
34
|
+
"data-slot": "segmented",
|
|
35
|
+
disabled,
|
|
36
|
+
orientation,
|
|
37
|
+
value: selectedValue === void 0 ? [] : [selectedValue],
|
|
38
|
+
onValueChange: handleValueChange,
|
|
39
|
+
className: cn(`bg-muted inline-flex w-fit gap-0.5 rounded-lg p-1
|
|
40
|
+
data-[orientation=vertical]:flex-col`, className),
|
|
41
|
+
children: normalizedOptions.map((option) => /* @__PURE__ */ jsxs(Toggle, {
|
|
42
|
+
value: option.value,
|
|
43
|
+
disabled: option.disabled,
|
|
44
|
+
className: cn(`text-muted-foreground hover:text-foreground
|
|
45
|
+
focus-visible:ring-ring/50 data-pressed:bg-background
|
|
46
|
+
data-pressed:text-foreground inline-flex items-center justify-center
|
|
47
|
+
gap-1.5 rounded-md font-medium whitespace-nowrap outline-none
|
|
48
|
+
focus-visible:ring-[3px] disabled:cursor-not-allowed
|
|
49
|
+
disabled:opacity-50 data-pressed:shadow-xs`, sizeClasses[resolvedSize], classNames?.item, selectedValue === option.value && classNames?.activeItem),
|
|
50
|
+
children: [option.icon, option.label]
|
|
51
|
+
}, option.value))
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { Segmented as default };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=Segmented.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Segmented.mjs","names":["React"],"sources":["../src/components/atoms/segmented.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { Toggle } from '@base-ui/react/toggle';\nimport { ToggleGroup } from '@base-ui/react/toggle-group';\n\nimport { type ComponentSize, useConfig } from '@repo/ui/providers';\nimport { cn } from '@repo/ui/utils';\n\nexport interface Option {\n label: string;\n value: string;\n icon?: React.ReactNode;\n disabled?: boolean;\n}\n\nconst sizeClasses: Record<ComponentSize, string> = {\n small: 'min-h-7 px-2 text-xs',\n middle: 'min-h-8 px-3 text-sm',\n large: 'min-h-10 px-4 text-base',\n};\n\nexport interface Props extends Omit<\n ToggleGroup.Props,\n 'children' | 'value' | 'defaultValue' | 'onValueChange' | 'onChange' | 'multiple'\n> {\n options: readonly (string | Option)[];\n value?: string;\n defaultValue?: string;\n /** Clicking the selected item keeps it selected. */\n onChange?: (value: string) => void;\n size?: ComponentSize;\n classNames?: {\n item?: string;\n activeItem?: string;\n };\n}\n\nconst Segmented = ({\n options,\n value,\n defaultValue,\n onChange,\n size,\n className,\n classNames,\n disabled,\n orientation = 'horizontal',\n ...props\n}: Props) => {\n const normalizedOptions = options.map(option =>\n typeof option === 'string'\n ? { label: option, value: option, disabled: false, icon: null }\n : option,\n );\n const firstEnabled = normalizedOptions.find(\n option => !option.disabled,\n )?.value;\n const [internalValue, setInternalValue] = React.useState(\n defaultValue ?? firstEnabled,\n );\n const selectedValue = value !== undefined ? value : internalValue;\n const { componentSize } = useConfig();\n const resolvedSize = size ?? componentSize ?? 'middle';\n\n const handleValueChange = (values: string[]) => {\n const nextValue = values[0];\n\n if (nextValue === undefined || nextValue === selectedValue) {\n return;\n }\n\n if (value === undefined) {\n setInternalValue(nextValue);\n }\n\n onChange?.(nextValue);\n };\n\n return (\n <ToggleGroup\n {...props}\n data-slot=\"segmented\"\n disabled={disabled}\n orientation={orientation}\n value={selectedValue === undefined ? [] : [selectedValue]}\n onValueChange={handleValueChange}\n className={cn(\n `bg-muted inline-flex w-fit gap-0.5 rounded-lg p-1\n data-[orientation=vertical]:flex-col`,\n className,\n //\n )}\n >\n {normalizedOptions.map(option => (\n <Toggle\n key={option.value}\n value={option.value}\n disabled={option.disabled}\n className={cn(\n `text-muted-foreground hover:text-foreground\n focus-visible:ring-ring/50 data-pressed:bg-background\n data-pressed:text-foreground inline-flex items-center justify-center\n gap-1.5 rounded-md font-medium whitespace-nowrap outline-none\n focus-visible:ring-[3px] disabled:cursor-not-allowed\n disabled:opacity-50 data-pressed:shadow-xs`,\n sizeClasses[resolvedSize],\n classNames?.item,\n selectedValue === option.value && classNames?.activeItem,\n //\n )}\n >\n {option.icon}\n {option.label}\n </Toggle>\n ))}\n </ToggleGroup>\n );\n};\n\nexport default Segmented;\n"],"mappings":";;;;;;;;AAiBA,MAAM,cAA6C;CACjD,OAAO;CACP,QAAQ;CACR,OAAO;AACT;AAkBA,MAAM,aAAa,EACjB,SACA,OACA,cACA,UACA,MACA,WACA,YACA,UACA,cAAc,cACd,GAAG,YACQ;CACX,MAAM,oBAAoB,QAAQ,KAAI,WACpC,OAAO,WAAW,WACd;EAAE,OAAO;EAAQ,OAAO;EAAQ,UAAU;EAAO,MAAM;CAAK,IAC5D,MACN;CACA,MAAM,eAAe,kBAAkB,MACrC,WAAU,CAAC,OAAO,QACpB,CAAC,EAAE;CACH,MAAM,CAAC,eAAe,oBAAoBA,QAAM,SAC9C,gBAAgB,YAClB;CACA,MAAM,gBAAgB,UAAU,KAAA,IAAY,QAAQ;CACpD,MAAM,EAAE,kBAAkB,UAAU;CACpC,MAAM,eAAe,QAAQ,iBAAiB;CAE9C,MAAM,qBAAqB,WAAqB;EAC9C,MAAM,YAAY,OAAO;EAEzB,IAAI,cAAc,KAAA,KAAa,cAAc,eAC3C;EAGF,IAAI,UAAU,KAAA,GACZ,iBAAiB,SAAS;EAG5B,WAAW,SAAS;CACtB;CAEA,OACE,oBAAC,aAAD;EACE,GAAI;EACJ,aAAU;EACA;EACG;EACb,OAAO,kBAAkB,KAAA,IAAY,CAAC,IAAI,CAAC,aAAa;EACxD,eAAe;EACf,WAAW,GACT;+CAEA,SAEF;EAEC,UAAA,kBAAkB,KAAI,WACrB,qBAAC,QAAD;GAEE,OAAO,OAAO;GACd,UAAU,OAAO;GACjB,WAAW,GACT;;;;;yDAMA,YAAY,eACZ,YAAY,MACZ,kBAAkB,OAAO,SAAS,YAAY,UAEhD;GAfF,UAAA,CAiBG,OAAO,MACP,OAAO,KACF;EAlBD,GAAA,OAAO,KAkBN,CACT;CACU,CAAA;AAEjB"}
|
package/dist/Space.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/components/molecules/space.d.ts
|
|
2
|
-
interface Props extends React.ComponentPropsWithRef<'div'> {
|
|
2
|
+
export interface Props extends React.ComponentPropsWithRef<'div'> {
|
|
3
3
|
loading?: boolean;
|
|
4
4
|
loader?: React.ReactNode;
|
|
5
5
|
orientation?: 'horizontal' | 'vertical';
|
|
@@ -14,5 +14,5 @@ interface Props extends React.ComponentPropsWithRef<'div'> {
|
|
|
14
14
|
}
|
|
15
15
|
declare const Space: ({ loading, loader, children, size, orientation, align, wrap, split, className, grid, hidden, style, ...props }: Props) => import("react").JSX.Element;
|
|
16
16
|
//#endregion
|
|
17
|
-
export {
|
|
17
|
+
export { Space as default };
|
|
18
18
|
//# sourceMappingURL=Space.d.mts.map
|
package/dist/Space.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Space.d.mts","names":[],"sources":["../src/components/molecules/space.tsx"],"mappings":";
|
|
1
|
+
{"version":3,"file":"Space.d.mts","names":[],"sources":["../src/components/molecules/space.tsx"],"mappings":";iBASiB,cAAc,MAAM;EACnC;EACA,SAAS,MAAM;EACf;EACA;EACA;EACA;EACA,QAAQ,MAAM;EACd;IACE;IACA;;;cAiBE,UAAS,SAAA,QAAA,UAAA,MAAA,aAAA,OAAA,MAAA,OAAA,WAAA,MAAA,QAAA,UAAA,SAcZ,0BAAK,IAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from "react";
|
|
2
|
+
//#region src/components/molecules/statistic.d.ts
|
|
3
|
+
export interface Props extends Omit<ComponentProps<'div'>, 'title' | 'children' | 'prefix'> {
|
|
4
|
+
title?: ReactNode;
|
|
5
|
+
value?: string | number;
|
|
6
|
+
prefix?: ReactNode;
|
|
7
|
+
suffix?: ReactNode;
|
|
8
|
+
precision?: number;
|
|
9
|
+
locale?: string;
|
|
10
|
+
formatter?: (value: string | number) => ReactNode;
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
classNames?: {
|
|
13
|
+
title?: string;
|
|
14
|
+
value?: string;
|
|
15
|
+
prefix?: string;
|
|
16
|
+
suffix?: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
declare const Statistic: ({ title, value, prefix, suffix, precision, locale, formatter, loading, className, classNames, ...props }: Props) => import("react").JSX.Element;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { Statistic as default };
|
|
22
|
+
//# sourceMappingURL=Statistic.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Statistic.d.mts","names":[],"sources":["../src/components/molecules/statistic.tsx"],"mappings":";;iBAQiB,cAAc,KAC7B;EAGA,QAAQ;EACR;EACA,SAAS;EACT,SAAS;EACT;EACA;EACA,aAAa,2BAA2B;EACxC;EACA;IACE;IACA;IACA;IACA;;;cAIE,cAAa,OAAA,OAAA,QAAA,QAAA,WAAA,QAAA,WAAA,SAAA,WAAA,eAAA,SAYhB,0BAAK,IAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "./utils.mjs";
|
|
3
|
+
import Skeleton from "./components/atoms/skeleton/index.mjs";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/molecules/statistic.tsx
|
|
6
|
+
const Statistic = ({ title, value, prefix, suffix, precision, locale = "en-US", formatter, loading = false, className, classNames, ...props }) => {
|
|
7
|
+
const hasValue = value !== void 0 && value !== "" && (typeof value !== "number" || Number.isFinite(value));
|
|
8
|
+
let formatted = "—";
|
|
9
|
+
if (!loading && hasValue && value !== void 0) {
|
|
10
|
+
if (formatter) formatted = formatter(value);
|
|
11
|
+
else if (typeof value === "string") formatted = value;
|
|
12
|
+
else {
|
|
13
|
+
const digits = precision !== void 0 && Number.isFinite(precision) ? Math.min(20, Math.max(0, Math.trunc(precision))) : void 0;
|
|
14
|
+
const options = digits === void 0 ? void 0 : {
|
|
15
|
+
minimumFractionDigits: digits,
|
|
16
|
+
maximumFractionDigits: digits
|
|
17
|
+
};
|
|
18
|
+
try {
|
|
19
|
+
formatted = new Intl.NumberFormat(locale, options).format(value);
|
|
20
|
+
} catch {
|
|
21
|
+
formatted = new Intl.NumberFormat("en-US", options).format(value);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
26
|
+
...props,
|
|
27
|
+
"data-slot": "statistic",
|
|
28
|
+
"aria-busy": loading || void 0,
|
|
29
|
+
className: cn("min-w-0", className),
|
|
30
|
+
children: [title !== void 0 && title !== null && /* @__PURE__ */ jsx("div", {
|
|
31
|
+
className: cn("text-muted-foreground mb-1 text-sm", classNames?.title),
|
|
32
|
+
children: title
|
|
33
|
+
}), loading ? /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-24" }) : /* @__PURE__ */ jsxs("div", {
|
|
34
|
+
className: cn(`text-foreground flex flex-wrap items-baseline gap-1 text-2xl
|
|
35
|
+
font-semibold [overflow-wrap:anywhere] tabular-nums`, classNames?.value),
|
|
36
|
+
children: [
|
|
37
|
+
prefix !== void 0 && prefix !== null && /* @__PURE__ */ jsx("span", {
|
|
38
|
+
className: classNames?.prefix,
|
|
39
|
+
children: prefix
|
|
40
|
+
}),
|
|
41
|
+
/* @__PURE__ */ jsx("span", { children: formatted }),
|
|
42
|
+
suffix !== void 0 && suffix !== null && /* @__PURE__ */ jsx("span", {
|
|
43
|
+
className: cn("text-base font-normal", classNames?.suffix),
|
|
44
|
+
children: suffix
|
|
45
|
+
})
|
|
46
|
+
]
|
|
47
|
+
})]
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { Statistic as default };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=Statistic.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Statistic.mjs","names":[],"sources":["../src/components/molecules/statistic.tsx"],"sourcesContent":["'use client';\n\nimport type { ComponentProps, ReactNode } from 'react';\n\nimport { cn } from '@repo/ui/utils';\n\nimport Skeleton from '../atoms/skeleton';\n\nexport interface Props extends Omit<\n ComponentProps<'div'>,\n 'title' | 'children' | 'prefix'\n> {\n title?: ReactNode;\n value?: string | number;\n prefix?: ReactNode;\n suffix?: ReactNode;\n precision?: number;\n locale?: string;\n formatter?: (value: string | number) => ReactNode;\n loading?: boolean;\n classNames?: {\n title?: string;\n value?: string;\n prefix?: string;\n suffix?: string;\n };\n}\n\nconst Statistic = ({\n title,\n value,\n prefix,\n suffix,\n precision,\n locale = 'en-US',\n formatter,\n loading = false,\n className,\n classNames,\n ...props\n}: Props) => {\n const hasValue =\n value !== undefined &&\n value !== '' &&\n (typeof value !== 'number' || Number.isFinite(value));\n let formatted: ReactNode = '—';\n\n if (!loading && hasValue && value !== undefined) {\n if (formatter) {\n formatted = formatter(value);\n } else if (typeof value === 'string') {\n formatted = value;\n } else {\n const digits =\n precision !== undefined && Number.isFinite(precision)\n ? Math.min(20, Math.max(0, Math.trunc(precision)))\n : undefined;\n const options =\n digits === undefined\n ? undefined\n : {\n minimumFractionDigits: digits,\n maximumFractionDigits: digits,\n };\n\n try {\n formatted = new Intl.NumberFormat(locale, options).format(value);\n } catch {\n formatted = new Intl.NumberFormat('en-US', options).format(value);\n }\n }\n }\n\n return (\n <div\n {...props}\n data-slot=\"statistic\"\n aria-busy={loading || undefined}\n className={cn(\n 'min-w-0',\n className,\n //\n )}\n >\n {title !== undefined && title !== null && (\n <div\n className={cn(\n 'text-muted-foreground mb-1 text-sm',\n classNames?.title,\n //\n )}\n >\n {title}\n </div>\n )}\n {loading ? (\n <Skeleton className=\"h-8 w-24\" />\n ) : (\n <div\n className={cn(\n `text-foreground flex flex-wrap items-baseline gap-1 text-2xl\n font-semibold [overflow-wrap:anywhere] tabular-nums`,\n classNames?.value,\n //\n )}\n >\n {prefix !== undefined && prefix !== null && (\n <span className={classNames?.prefix}>{prefix}</span>\n )}\n <span>{formatted}</span>\n {suffix !== undefined && suffix !== null && (\n <span\n className={cn(\n 'text-base font-normal',\n classNames?.suffix,\n //\n )}\n >\n {suffix}\n </span>\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport default Statistic;\n"],"mappings":";;;;;AA4BA,MAAM,aAAa,EACjB,OACA,OACA,QACA,QACA,WACA,SAAS,SACT,WACA,UAAU,OACV,WACA,YACA,GAAG,YACQ;CACX,MAAM,WACJ,UAAU,KAAA,KACV,UAAU,OACT,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK;CACrD,IAAI,YAAuB;CAE3B,IAAI,CAAC,WAAW,YAAY,UAAU,KAAA,GAAW;EAC/C,IAAI,WACF,YAAY,UAAU,KAAK;OACtB,IAAI,OAAO,UAAU,UAC1B,YAAY;OACP;GACL,MAAM,SACJ,cAAc,KAAA,KAAa,OAAO,SAAS,SAAS,IAChD,KAAK,IAAI,IAAI,KAAK,IAAI,GAAG,KAAK,MAAM,SAAS,CAAC,CAAC,IAC/C,KAAA;GACN,MAAM,UACJ,WAAW,KAAA,IACP,KAAA,IACA;IACE,uBAAuB;IACvB,uBAAuB;GACzB;GAEN,IAAI;IACF,YAAY,IAAI,KAAK,aAAa,QAAQ,OAAO,CAAC,CAAC,OAAO,KAAK;GACjE,QAAQ;IACN,YAAY,IAAI,KAAK,aAAa,SAAS,OAAO,CAAC,CAAC,OAAO,KAAK;GAClE;EACF;CACF;CAEA,OACE,qBAAC,OAAD;EACE,GAAI;EACJ,aAAU;EACV,aAAW,WAAW,KAAA;EACtB,WAAW,GACT,WACA,SAEF;EARF,UAAA,CAUG,UAAU,KAAA,KAAa,UAAU,QAChC,oBAAC,OAAD;GACE,WAAW,GACT,sCACA,YAAY,KAEd;GAEC,UAAA;EACE,CAAA,GAEN,UACC,oBAAC,UAAD,EAAU,WAAU,WAAY,CAAA,IAEhC,qBAAC,OAAD;GACE,WAAW,GACT;oEAEA,YAAY,KAEd;GANF,UAAA;IAQG,WAAW,KAAA,KAAa,WAAW,QAClC,oBAAC,QAAD;KAAM,WAAW,YAAY;KAAS,UAAA;IAAa,CAAA;IAErD,oBAAC,QAAD,EAAA,UAAO,UAAgB,CAAA;IACtB,WAAW,KAAA,KAAa,WAAW,QAClC,oBAAC,QAAD;KACE,WAAW,GACT,yBACA,YAAY,MAEd;KAEC,UAAA;IACG,CAAA;GAEL;EAEJ,CAAA,CAAA;;AAET"}
|
package/dist/Steps.d.mts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
//#region src/components/molecules/steps.d.ts
|
|
3
|
+
export interface Item {
|
|
4
|
+
key?: React$1.Key;
|
|
5
|
+
title: React$1.ReactNode;
|
|
6
|
+
description?: React$1.ReactNode;
|
|
7
|
+
icon?: React$1.ReactNode;
|
|
8
|
+
/** Mark a failed step regardless of its position. */
|
|
9
|
+
status?: 'error';
|
|
10
|
+
}
|
|
11
|
+
export interface Props extends Omit<React$1.ComponentPropsWithoutRef<'nav'>, 'children'> {
|
|
12
|
+
items: readonly Item[];
|
|
13
|
+
/** Zero-based index of the current step. */
|
|
14
|
+
current?: number;
|
|
15
|
+
orientation?: 'horizontal' | 'vertical';
|
|
16
|
+
classNames?: {
|
|
17
|
+
list?: string;
|
|
18
|
+
item?: string;
|
|
19
|
+
indicator?: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
connector?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
declare const Steps: ({ items, current, orientation, className, classNames, dir, "aria-label": ariaLabel, ...props }: Props) => React$1.JSX.Element;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { Steps as default };
|
|
28
|
+
//# sourceMappingURL=Steps.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Steps.d.mts","names":["React"],"sources":["../src/components/molecules/steps.tsx"],"mappings":";;iBASiB;EACf,MAAMA,QAAM;EACZ,OAAOA,QAAM;EACb,cAAcA,QAAM;EACpB,OAAOA,QAAM;;EAEb;;iBAGe,cAAc,KAC7BA,QAAM;EAGN,gBAAgB;;EAEhB;EACA;EACA;IACE;IACA;IACA;IACA;IACA;IACA;;;cAIE,UAAS,OAAA,SAAA,aAAA,WAAA,YAAA,mBAAA,cAAA,SASZ,UAAKA,QAAA,IAAA"}
|
package/dist/Steps.mjs
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "./utils.mjs";
|
|
3
|
+
import { useConfig } from "./providers/config/context.mjs";
|
|
4
|
+
import "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Check, TriangleAlert } from "lucide-react";
|
|
7
|
+
//#region src/components/molecules/steps.tsx
|
|
8
|
+
const Steps = ({ items, current = 0, orientation = "horizontal", className, classNames, dir, "aria-label": ariaLabel, ...props }) => {
|
|
9
|
+
const { direction } = useConfig();
|
|
10
|
+
const currentIndex = items.length ? Math.min(Math.max(Number.isFinite(current) ? Math.floor(current) : 0, 0), items.length - 1) : -1;
|
|
11
|
+
return /* @__PURE__ */ jsx("nav", {
|
|
12
|
+
...props,
|
|
13
|
+
"data-slot": "steps",
|
|
14
|
+
"data-orientation": orientation,
|
|
15
|
+
dir: dir ?? direction,
|
|
16
|
+
"aria-label": ariaLabel ?? "Progress",
|
|
17
|
+
className: cn("w-full", className),
|
|
18
|
+
children: /* @__PURE__ */ jsx("ol", {
|
|
19
|
+
"data-slot": "steps-list",
|
|
20
|
+
className: cn("m-0 flex list-none p-0", orientation === "vertical" && "flex-col", classNames?.list),
|
|
21
|
+
children: items.map((item, index) => {
|
|
22
|
+
const status = item.status === "error" ? "error" : index < currentIndex ? "complete" : index === currentIndex ? "current" : "upcoming";
|
|
23
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
24
|
+
"data-slot": "steps-item",
|
|
25
|
+
"data-status": status,
|
|
26
|
+
"aria-current": index === currentIndex ? "step" : void 0,
|
|
27
|
+
className: cn("m-0 flex min-w-0", orientation === "horizontal" ? "flex-1 items-start" : "flex-col", classNames?.item),
|
|
28
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
29
|
+
className: "flex min-w-0 items-start gap-2.5",
|
|
30
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
31
|
+
"data-slot": "steps-indicator",
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
className: cn(`border-border text-muted-foreground flex size-7 shrink-0
|
|
34
|
+
items-center justify-center rounded-full border text-sm
|
|
35
|
+
font-medium`, status === "complete" && "border-primary bg-primary text-primary-foreground", status === "current" && "border-primary text-primary", status === "error" && `border-destructive bg-destructive
|
|
36
|
+
text-destructive-foreground`, classNames?.indicator),
|
|
37
|
+
children: item.icon ?? (status === "complete" ? /* @__PURE__ */ jsx(Check, { className: "size-4" }) : status === "error" ? /* @__PURE__ */ jsx(TriangleAlert, { className: "size-4" }) : index + 1)
|
|
38
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
39
|
+
className: "min-w-0",
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ jsx("span", {
|
|
42
|
+
"data-slot": "steps-title",
|
|
43
|
+
className: cn("block text-sm font-medium", status === "upcoming" ? "text-muted-foreground" : status === "error" ? "text-destructive" : "text-foreground", classNames?.title),
|
|
44
|
+
children: item.title
|
|
45
|
+
}),
|
|
46
|
+
item.description != null && /* @__PURE__ */ jsx("span", {
|
|
47
|
+
"data-slot": "steps-description",
|
|
48
|
+
className: cn("text-muted-foreground block text-xs", classNames?.description),
|
|
49
|
+
children: item.description
|
|
50
|
+
}),
|
|
51
|
+
/* @__PURE__ */ jsx("span", {
|
|
52
|
+
className: "sr-only",
|
|
53
|
+
children: status === "complete" ? "Completed" : status === "current" ? "Current step" : status === "error" ? "Error" : "Upcoming"
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
})]
|
|
57
|
+
}), index < items.length - 1 && /* @__PURE__ */ jsx("span", {
|
|
58
|
+
"data-slot": "steps-connector",
|
|
59
|
+
"aria-hidden": "true",
|
|
60
|
+
className: cn("bg-border shrink-0", orientation === "horizontal" ? "mx-3 mt-3.5 h-px min-w-3 flex-1" : "my-2 ms-3.5 h-7 w-px", index < currentIndex && "bg-primary", classNames?.connector)
|
|
61
|
+
})]
|
|
62
|
+
}, item.key ?? index);
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { Steps as default };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=Steps.mjs.map
|