@helpwave/hightide 0.1.26 → 0.1.28
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/coloring/index.d.mts +2 -0
- package/dist/coloring/index.d.ts +2 -0
- package/dist/coloring/index.js +85 -0
- package/dist/coloring/index.js.map +1 -0
- package/dist/coloring/index.mjs +48 -0
- package/dist/coloring/index.mjs.map +1 -0
- package/dist/components/branding/index.d.mts +3 -0
- package/dist/components/branding/index.d.ts +3 -0
- package/dist/components/branding/index.js +140 -0
- package/dist/components/branding/index.js.map +1 -0
- package/dist/components/branding/index.mjs +104 -0
- package/dist/components/branding/index.mjs.map +1 -0
- package/dist/components/date/DatePicker.js +1 -1
- package/dist/components/date/DatePicker.js.map +1 -1
- package/dist/components/date/DatePicker.mjs +1 -1
- package/dist/components/date/DatePicker.mjs.map +1 -1
- package/dist/components/date/YearMonthPicker.js +1 -1
- package/dist/components/date/YearMonthPicker.js.map +1 -1
- package/dist/components/date/YearMonthPicker.mjs +1 -1
- package/dist/components/date/YearMonthPicker.mjs.map +1 -1
- package/dist/components/date/index.d.mts +10 -0
- package/dist/components/date/index.d.ts +10 -0
- package/dist/components/date/index.js +1168 -0
- package/dist/components/date/index.js.map +1 -0
- package/dist/components/date/index.mjs +1124 -0
- package/dist/components/date/index.mjs.map +1 -0
- package/dist/components/dialog/ConfirmDialog.d.mts +1 -1
- package/dist/components/dialog/ConfirmDialog.d.ts +1 -1
- package/dist/components/dialog/ConfirmDialog.js +2 -2
- package/dist/components/dialog/ConfirmDialog.js.map +1 -1
- package/dist/components/dialog/ConfirmDialog.mjs +2 -2
- package/dist/components/dialog/ConfirmDialog.mjs.map +1 -1
- package/dist/components/dialog/Dialog.d.mts +1 -1
- package/dist/components/dialog/Dialog.d.ts +1 -1
- package/dist/components/dialog/Dialog.js +2 -2
- package/dist/components/dialog/Dialog.js.map +1 -1
- package/dist/components/dialog/Dialog.mjs +2 -2
- package/dist/components/dialog/Dialog.mjs.map +1 -1
- package/dist/components/dialog/DiscardChangesDialog.d.mts +1 -1
- package/dist/components/dialog/DiscardChangesDialog.d.ts +1 -1
- package/dist/components/dialog/DiscardChangesDialog.js +2 -2
- package/dist/components/dialog/DiscardChangesDialog.js.map +1 -1
- package/dist/components/dialog/DiscardChangesDialog.mjs +2 -2
- package/dist/components/dialog/DiscardChangesDialog.mjs.map +1 -1
- package/dist/components/dialog/InputDialog.d.mts +1 -1
- package/dist/components/dialog/InputDialog.d.ts +1 -1
- package/dist/components/dialog/InputDialog.js +2 -2
- package/dist/components/dialog/InputDialog.js.map +1 -1
- package/dist/components/dialog/InputDialog.mjs +2 -2
- package/dist/components/dialog/InputDialog.mjs.map +1 -1
- package/dist/components/dialog/LanguageDialog.d.mts +1 -1
- package/dist/components/dialog/LanguageDialog.d.ts +1 -1
- package/dist/components/dialog/LanguageDialog.js +28 -15
- package/dist/components/dialog/LanguageDialog.js.map +1 -1
- package/dist/components/dialog/LanguageDialog.mjs +28 -15
- package/dist/components/dialog/LanguageDialog.mjs.map +1 -1
- package/dist/components/dialog/ThemeDialog.d.mts +1 -1
- package/dist/components/dialog/ThemeDialog.d.ts +1 -1
- package/dist/components/dialog/ThemeDialog.js +69 -33
- package/dist/components/dialog/ThemeDialog.js.map +1 -1
- package/dist/components/dialog/ThemeDialog.mjs +60 -24
- package/dist/components/dialog/ThemeDialog.mjs.map +1 -1
- package/dist/components/dialog/index.d.mts +1 -1
- package/dist/components/dialog/index.d.ts +1 -1
- package/dist/components/dialog/index.js +61 -25
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/dialog/index.mjs +61 -25
- package/dist/components/dialog/index.mjs.map +1 -1
- package/dist/components/form/index.d.mts +5 -0
- package/dist/components/form/index.d.ts +5 -0
- package/dist/components/form/index.js +100 -0
- package/dist/components/form/index.js.map +1 -0
- package/dist/components/form/index.mjs +64 -0
- package/dist/components/form/index.mjs.map +1 -0
- package/dist/components/icons-and-geometry/index.d.mts +7 -0
- package/dist/components/icons-and-geometry/index.d.ts +7 -0
- package/dist/components/icons-and-geometry/index.js +3955 -0
- package/dist/components/icons-and-geometry/index.js.map +1 -0
- package/dist/components/icons-and-geometry/index.mjs +3939 -0
- package/dist/components/icons-and-geometry/index.mjs.map +1 -0
- package/dist/components/index.d.mts +83 -0
- package/dist/components/index.d.ts +83 -0
- package/dist/components/index.js +15471 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +15377 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/components/layout/Carousel.d.mts +33 -0
- package/dist/components/layout/Carousel.d.ts +33 -0
- package/dist/components/layout/Carousel.js +684 -0
- package/dist/components/layout/Carousel.js.map +1 -0
- package/dist/components/layout/Carousel.mjs +659 -0
- package/dist/components/layout/Carousel.mjs.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/Chip.js +1 -1
- package/dist/components/layout/Chip.js.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/Chip.mjs +1 -1
- package/dist/components/layout/Chip.mjs.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/DividerInserter.js +1 -1
- package/dist/components/layout/DividerInserter.js.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/DividerInserter.mjs +1 -1
- package/dist/components/layout/DividerInserter.mjs.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/Expandable.js +2 -2
- package/dist/components/layout/Expandable.js.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/Expandable.mjs +2 -2
- package/dist/components/layout/Expandable.mjs.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/FAQSection.js +5 -5
- package/dist/components/layout/FAQSection.js.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/FAQSection.mjs +5 -5
- package/dist/components/layout/FAQSection.mjs.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/FloatingContainer.js +2 -2
- package/dist/components/layout/FloatingContainer.js.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/FloatingContainer.mjs +2 -2
- package/dist/components/layout/FloatingContainer.mjs.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/ListBox.js +2 -2
- package/dist/components/layout/ListBox.js.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/ListBox.mjs +2 -2
- package/dist/components/layout/ListBox.mjs.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/MarkdownInterpreter.js +1 -1
- package/dist/components/layout/MarkdownInterpreter.js.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/MarkdownInterpreter.mjs +1 -1
- package/dist/components/layout/MarkdownInterpreter.mjs.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/ScrollArea.js +2 -2
- package/dist/components/layout/ScrollArea.js.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/ScrollArea.mjs +1 -1
- package/dist/components/layout/ScrollArea.mjs.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/TextImage.js +3 -3
- package/dist/components/layout/TextImage.js.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/TextImage.mjs +2 -2
- package/dist/components/layout/TextImage.mjs.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/VerticalDivider.js +1 -1
- package/dist/components/layout/VerticalDivider.js.map +1 -0
- package/dist/components/{layout-and-navigation → layout}/VerticalDivider.mjs +1 -1
- package/dist/components/layout/VerticalDivider.mjs.map +1 -0
- package/dist/components/layout/index.d.mts +18 -0
- package/dist/components/layout/index.d.ts +18 -0
- package/dist/components/layout/index.js +3111 -0
- package/dist/components/layout/index.js.map +1 -0
- package/dist/components/layout/index.mjs +3064 -0
- package/dist/components/layout/index.mjs.map +1 -0
- package/dist/components/loading-states/index.d.mts +12 -0
- package/dist/components/loading-states/index.d.ts +12 -0
- package/dist/components/loading-states/index.js +614 -0
- package/dist/components/loading-states/index.js.map +1 -0
- package/dist/components/loading-states/index.mjs +573 -0
- package/dist/components/loading-states/index.mjs.map +1 -0
- package/dist/components/{layout-and-navigation → navigation}/BreadCrumb.js +1 -1
- package/dist/components/navigation/BreadCrumb.js.map +1 -0
- package/dist/components/{layout-and-navigation → navigation}/BreadCrumb.mjs +1 -1
- package/dist/components/navigation/BreadCrumb.mjs.map +1 -0
- package/dist/components/navigation/Navigation.d.mts +21 -0
- package/dist/components/navigation/Navigation.d.ts +21 -0
- package/dist/components/navigation/Navigation.js +4018 -0
- package/dist/components/navigation/Navigation.js.map +1 -0
- package/dist/components/navigation/Navigation.mjs +4012 -0
- package/dist/components/navigation/Navigation.mjs.map +1 -0
- package/dist/components/{layout-and-navigation → navigation}/Pagination.js +3 -3
- package/dist/components/navigation/Pagination.js.map +1 -0
- package/dist/components/{layout-and-navigation → navigation}/Pagination.mjs +3 -3
- package/dist/components/navigation/Pagination.mjs.map +1 -0
- package/dist/components/{layout-and-navigation → navigation}/StepperBar.js +3 -3
- package/dist/components/navigation/StepperBar.js.map +1 -0
- package/dist/components/{layout-and-navigation → navigation}/StepperBar.mjs +3 -3
- package/dist/components/navigation/StepperBar.mjs.map +1 -0
- package/dist/components/navigation/index.d.mts +9 -0
- package/dist/components/navigation/index.d.ts +9 -0
- package/dist/components/navigation/index.js +4660 -0
- package/dist/components/navigation/index.js.map +1 -0
- package/dist/components/navigation/index.mjs +4648 -0
- package/dist/components/navigation/index.mjs.map +1 -0
- package/dist/components/properties/MultiSelectProperty.js +27 -14
- package/dist/components/properties/MultiSelectProperty.js.map +1 -1
- package/dist/components/properties/MultiSelectProperty.mjs +27 -14
- package/dist/components/properties/MultiSelectProperty.mjs.map +1 -1
- package/dist/components/properties/SelectProperty.js +27 -14
- package/dist/components/properties/SelectProperty.js.map +1 -1
- package/dist/components/properties/SelectProperty.mjs +27 -14
- package/dist/components/properties/SelectProperty.mjs.map +1 -1
- package/dist/components/properties/index.d.mts +12 -0
- package/dist/components/properties/index.d.ts +12 -0
- package/dist/components/properties/index.js +2983 -0
- package/dist/components/properties/index.js.map +1 -0
- package/dist/components/properties/index.mjs +2951 -0
- package/dist/components/properties/index.mjs.map +1 -0
- package/dist/components/table/Table.js +1 -1
- package/dist/components/table/Table.js.map +1 -1
- package/dist/components/table/Table.mjs +1 -1
- package/dist/components/table/Table.mjs.map +1 -1
- package/dist/components/table/index.d.mts +10 -0
- package/dist/components/table/index.d.ts +10 -0
- package/dist/components/table/index.js +2329 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/table/index.mjs +2293 -0
- package/dist/components/table/index.mjs.map +1 -0
- package/dist/components/user-action/DateAndTimePicker.js +1 -1
- package/dist/components/user-action/DateAndTimePicker.js.map +1 -1
- package/dist/components/user-action/DateAndTimePicker.mjs +1 -1
- package/dist/components/user-action/DateAndTimePicker.mjs.map +1 -1
- package/dist/components/user-action/index.d.mts +30 -0
- package/dist/components/user-action/index.d.ts +30 -0
- package/dist/components/user-action/index.js +4257 -0
- package/dist/components/user-action/index.js.map +1 -0
- package/dist/components/user-action/index.mjs +4195 -0
- package/dist/components/user-action/index.mjs.map +1 -0
- package/dist/components/user-action/input/index.d.mts +6 -0
- package/dist/components/user-action/input/index.d.ts +6 -0
- package/dist/components/user-action/input/index.js +398 -0
- package/dist/components/user-action/input/index.js.map +1 -0
- package/dist/components/user-action/input/index.mjs +357 -0
- package/dist/components/user-action/input/index.mjs.map +1 -0
- package/dist/components/user-action/select/Select.d.mts +5 -1
- package/dist/components/user-action/select/Select.d.ts +5 -1
- package/dist/components/user-action/select/Select.js +27 -14
- package/dist/components/user-action/select/Select.js.map +1 -1
- package/dist/components/user-action/select/Select.mjs +27 -14
- package/dist/components/user-action/select/Select.mjs.map +1 -1
- package/dist/components/user-action/select/index.d.mts +4 -0
- package/dist/components/user-action/select/index.d.ts +4 -0
- package/dist/components/user-action/select/index.js +1369 -0
- package/dist/components/user-action/select/index.js.map +1 -0
- package/dist/components/user-action/select/index.mjs +1333 -0
- package/dist/components/user-action/select/index.mjs.map +1 -0
- package/dist/components/utils/index.d.mts +4 -0
- package/dist/components/utils/index.d.ts +4 -0
- package/dist/components/utils/index.js +302 -0
- package/dist/components/utils/index.js.map +1 -0
- package/dist/components/utils/index.mjs +275 -0
- package/dist/components/utils/index.mjs.map +1 -0
- package/dist/hooks/focus/index.d.mts +6 -0
- package/dist/hooks/focus/index.d.ts +6 -0
- package/dist/hooks/focus/index.js +379 -0
- package/dist/hooks/focus/index.js.map +1 -0
- package/dist/hooks/focus/index.mjs +339 -0
- package/dist/hooks/focus/index.mjs.map +1 -0
- package/dist/hooks/index.d.mts +16 -0
- package/dist/hooks/index.d.ts +16 -0
- package/dist/hooks/index.js +844 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +794 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/index.d.mts +110 -0
- package/dist/index.d.ts +110 -0
- package/dist/index.js +16101 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +15941 -0
- package/dist/index.mjs.map +1 -0
- package/dist/localization/defaults/index.d.mts +4 -0
- package/dist/localization/defaults/index.d.ts +4 -0
- package/dist/localization/defaults/index.js +223 -0
- package/dist/localization/defaults/index.js.map +1 -0
- package/dist/localization/defaults/index.mjs +195 -0
- package/dist/localization/defaults/index.mjs.map +1 -0
- package/dist/localization/index.d.mts +7 -0
- package/dist/localization/index.d.ts +7 -0
- package/dist/localization/index.js +415 -0
- package/dist/localization/index.js.map +1 -0
- package/dist/localization/index.mjs +380 -0
- package/dist/localization/index.mjs.map +1 -0
- package/dist/style/globals.css +63 -10
- package/dist/style/uncompiled/globals.css +5 -4
- package/dist/style/uncompiled/utitlity/shadow.css +4 -0
- package/dist/theming/index.d.mts +5 -0
- package/dist/theming/index.d.ts +5 -0
- package/dist/theming/index.js +174 -0
- package/dist/theming/index.js.map +1 -0
- package/dist/theming/index.mjs +145 -0
- package/dist/theming/index.mjs.map +1 -0
- package/dist/theming/useTheme.d.mts +3 -1
- package/dist/theming/useTheme.d.ts +3 -1
- package/dist/theming/useTheme.js +40 -17
- package/dist/theming/useTheme.js.map +1 -1
- package/dist/theming/useTheme.mjs +38 -15
- package/dist/theming/useTheme.mjs.map +1 -1
- package/dist/utils/index.d.mts +15 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.js +553 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +493 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +25 -24
- package/dist/components/layout-and-navigation/BreadCrumb.js.map +0 -1
- package/dist/components/layout-and-navigation/BreadCrumb.mjs.map +0 -1
- package/dist/components/layout-and-navigation/Carousel.d.mts +0 -25
- package/dist/components/layout-and-navigation/Carousel.d.ts +0 -25
- package/dist/components/layout-and-navigation/Carousel.js +0 -643
- package/dist/components/layout-and-navigation/Carousel.js.map +0 -1
- package/dist/components/layout-and-navigation/Carousel.mjs +0 -609
- package/dist/components/layout-and-navigation/Carousel.mjs.map +0 -1
- package/dist/components/layout-and-navigation/Chip.js.map +0 -1
- package/dist/components/layout-and-navigation/Chip.mjs.map +0 -1
- package/dist/components/layout-and-navigation/DividerInserter.js.map +0 -1
- package/dist/components/layout-and-navigation/DividerInserter.mjs.map +0 -1
- package/dist/components/layout-and-navigation/Expandable.js.map +0 -1
- package/dist/components/layout-and-navigation/Expandable.mjs.map +0 -1
- package/dist/components/layout-and-navigation/FAQSection.js.map +0 -1
- package/dist/components/layout-and-navigation/FAQSection.mjs.map +0 -1
- package/dist/components/layout-and-navigation/FloatingContainer.js.map +0 -1
- package/dist/components/layout-and-navigation/FloatingContainer.mjs.map +0 -1
- package/dist/components/layout-and-navigation/ListBox.js.map +0 -1
- package/dist/components/layout-and-navigation/ListBox.mjs.map +0 -1
- package/dist/components/layout-and-navigation/MarkdownInterpreter.js.map +0 -1
- package/dist/components/layout-and-navigation/MarkdownInterpreter.mjs.map +0 -1
- package/dist/components/layout-and-navigation/Pagination.js.map +0 -1
- package/dist/components/layout-and-navigation/Pagination.mjs.map +0 -1
- package/dist/components/layout-and-navigation/ScrollArea.js.map +0 -1
- package/dist/components/layout-and-navigation/ScrollArea.mjs.map +0 -1
- package/dist/components/layout-and-navigation/StepperBar.js.map +0 -1
- package/dist/components/layout-and-navigation/StepperBar.mjs.map +0 -1
- package/dist/components/layout-and-navigation/TextImage.js.map +0 -1
- package/dist/components/layout-and-navigation/TextImage.mjs.map +0 -1
- package/dist/components/layout-and-navigation/VerticalDivider.js.map +0 -1
- package/dist/components/layout-and-navigation/VerticalDivider.mjs.map +0 -1
- /package/dist/components/{layout-and-navigation → layout}/Chip.d.mts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/Chip.d.ts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/DividerInserter.d.mts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/DividerInserter.d.ts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/Expandable.d.mts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/Expandable.d.ts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/FAQSection.d.mts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/FAQSection.d.ts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/FloatingContainer.d.mts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/FloatingContainer.d.ts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/ListBox.d.mts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/ListBox.d.ts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/MarkdownInterpreter.d.mts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/MarkdownInterpreter.d.ts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/ScrollArea.d.mts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/ScrollArea.d.ts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/TextImage.d.mts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/TextImage.d.ts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/VerticalDivider.d.mts +0 -0
- /package/dist/components/{layout-and-navigation → layout}/VerticalDivider.d.ts +0 -0
- /package/dist/components/{layout-and-navigation → navigation}/BreadCrumb.d.mts +0 -0
- /package/dist/components/{layout-and-navigation → navigation}/BreadCrumb.d.ts +0 -0
- /package/dist/components/{layout-and-navigation → navigation}/Pagination.d.mts +0 -0
- /package/dist/components/{layout-and-navigation → navigation}/Pagination.d.ts +0 -0
- /package/dist/components/{layout-and-navigation → navigation}/StepperBar.d.mts +0 -0
- /package/dist/components/{layout-and-navigation → navigation}/StepperBar.d.ts +0 -0
|
@@ -0,0 +1,4195 @@
|
|
|
1
|
+
// src/components/user-action/Button.tsx
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
var ButtonColorUtil = {
|
|
6
|
+
solid: ["primary", "secondary", "tertiary", "positive", "warning", "negative", "neutral"],
|
|
7
|
+
text: ["primary", "negative", "neutral"],
|
|
8
|
+
outline: ["primary"]
|
|
9
|
+
};
|
|
10
|
+
var IconButtonUtil = {
|
|
11
|
+
icon: [...ButtonColorUtil.solid, "transparent"]
|
|
12
|
+
};
|
|
13
|
+
var paddingMapping = {
|
|
14
|
+
small: "btn-sm",
|
|
15
|
+
medium: "btn-md",
|
|
16
|
+
large: "btn-lg"
|
|
17
|
+
};
|
|
18
|
+
var iconPaddingMapping = {
|
|
19
|
+
tiny: "icon-btn-xs",
|
|
20
|
+
small: "icon-btn-sm",
|
|
21
|
+
medium: "icon-btn-md",
|
|
22
|
+
large: "icon-btn-lg"
|
|
23
|
+
};
|
|
24
|
+
var ButtonUtil = {
|
|
25
|
+
paddingMapping,
|
|
26
|
+
iconPaddingMapping
|
|
27
|
+
};
|
|
28
|
+
var SolidButton = forwardRef(function SolidButton2({
|
|
29
|
+
children,
|
|
30
|
+
color = "primary",
|
|
31
|
+
size = "medium",
|
|
32
|
+
startIcon,
|
|
33
|
+
endIcon,
|
|
34
|
+
onClick,
|
|
35
|
+
className,
|
|
36
|
+
...restProps
|
|
37
|
+
}, ref) {
|
|
38
|
+
const colorClasses = {
|
|
39
|
+
primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
|
|
40
|
+
secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
|
|
41
|
+
tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
|
|
42
|
+
positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
|
|
43
|
+
warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
|
|
44
|
+
negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
|
|
45
|
+
neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text"
|
|
46
|
+
}[color];
|
|
47
|
+
const iconColorClasses = {
|
|
48
|
+
primary: "not-group-disabled:text-button-solid-primary-icon",
|
|
49
|
+
secondary: "not-group-disabled:text-button-solid-secondary-icon",
|
|
50
|
+
tertiary: "not-group-disabled:text-button-solid-tertiary-icon",
|
|
51
|
+
positive: "not-group-disabled:text-button-solid-positive-icon",
|
|
52
|
+
warning: "not-group-disabled:text-button-solid-warning-icon",
|
|
53
|
+
negative: "not-group-disabled:text-button-solid-negative-icon",
|
|
54
|
+
neutral: "not-group-disabled:text-button-solid-neutral-icon"
|
|
55
|
+
}[color];
|
|
56
|
+
return /* @__PURE__ */ jsxs(
|
|
57
|
+
"button",
|
|
58
|
+
{
|
|
59
|
+
ref,
|
|
60
|
+
onClick,
|
|
61
|
+
className: clsx(
|
|
62
|
+
"group font-semibold",
|
|
63
|
+
colorClasses,
|
|
64
|
+
"not-disabled:hover:brightness-90",
|
|
65
|
+
"disabled:text-disabled-text disabled:bg-disabled-background",
|
|
66
|
+
ButtonUtil.paddingMapping[size],
|
|
67
|
+
className
|
|
68
|
+
),
|
|
69
|
+
...restProps,
|
|
70
|
+
children: [
|
|
71
|
+
startIcon && /* @__PURE__ */ jsx(
|
|
72
|
+
"span",
|
|
73
|
+
{
|
|
74
|
+
className: clsx(
|
|
75
|
+
iconColorClasses,
|
|
76
|
+
"group-disabled:text-disabled-icon"
|
|
77
|
+
),
|
|
78
|
+
children: startIcon
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
children,
|
|
82
|
+
endIcon && /* @__PURE__ */ jsx(
|
|
83
|
+
"span",
|
|
84
|
+
{
|
|
85
|
+
className: clsx(
|
|
86
|
+
iconColorClasses,
|
|
87
|
+
"group-disabled:text-disabled-icon"
|
|
88
|
+
),
|
|
89
|
+
children: endIcon
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
var OutlineButton = ({
|
|
97
|
+
children,
|
|
98
|
+
color = "primary",
|
|
99
|
+
size = "medium",
|
|
100
|
+
startIcon,
|
|
101
|
+
endIcon,
|
|
102
|
+
onClick,
|
|
103
|
+
className,
|
|
104
|
+
...restProps
|
|
105
|
+
}) => {
|
|
106
|
+
const colorClasses = {
|
|
107
|
+
primary: "not-disabled:border-button-outline-primary-text not-disabled:text-button-outline-primary-text"
|
|
108
|
+
}[color];
|
|
109
|
+
const iconColorClasses = {
|
|
110
|
+
primary: "not-group-disabled:text-button-outline-primary-icon"
|
|
111
|
+
}[color];
|
|
112
|
+
return /* @__PURE__ */ jsxs(
|
|
113
|
+
"button",
|
|
114
|
+
{
|
|
115
|
+
onClick,
|
|
116
|
+
className: clsx(
|
|
117
|
+
"group font-semibold bg-transparent border-2 ",
|
|
118
|
+
"not-disabled:hover:brightness-80",
|
|
119
|
+
colorClasses,
|
|
120
|
+
"disabled:text-disabled-text disabled:border-disabled-outline",
|
|
121
|
+
ButtonUtil.paddingMapping[size],
|
|
122
|
+
className
|
|
123
|
+
),
|
|
124
|
+
...restProps,
|
|
125
|
+
children: [
|
|
126
|
+
startIcon && /* @__PURE__ */ jsx(
|
|
127
|
+
"span",
|
|
128
|
+
{
|
|
129
|
+
className: clsx(
|
|
130
|
+
iconColorClasses,
|
|
131
|
+
"group-disabled:text-disabled-icon"
|
|
132
|
+
),
|
|
133
|
+
children: startIcon
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
children,
|
|
137
|
+
endIcon && /* @__PURE__ */ jsx(
|
|
138
|
+
"span",
|
|
139
|
+
{
|
|
140
|
+
className: clsx(
|
|
141
|
+
iconColorClasses,
|
|
142
|
+
"group-disabled:text-disabled-icon"
|
|
143
|
+
),
|
|
144
|
+
children: endIcon
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
var TextButton = ({
|
|
152
|
+
children,
|
|
153
|
+
color = "neutral",
|
|
154
|
+
size = "medium",
|
|
155
|
+
startIcon,
|
|
156
|
+
endIcon,
|
|
157
|
+
onClick,
|
|
158
|
+
coloredHoverBackground = true,
|
|
159
|
+
className,
|
|
160
|
+
...restProps
|
|
161
|
+
}) => {
|
|
162
|
+
const colorClasses = {
|
|
163
|
+
primary: "not-disabled:bg-transparent not-disabled:text-button-text-primary-text focus-style-none focus-visible:ring-2 not-disabled:focus-visible:ring-button-text-primary-text",
|
|
164
|
+
negative: "not-disabled:bg-transparent not-disabled:text-button-text-negative-text focus-style-none focus-visible:ring-2 not-disabled:focus-visible:ring-button-text-negative-text",
|
|
165
|
+
neutral: "not-disabled:bg-transparent not-disabled:text-button-text-neutral-text focus-style-none focus-visible:ring-2 not-disabled:focus-visible:ring-button-text-neutral-text"
|
|
166
|
+
}[color];
|
|
167
|
+
const backgroundColor = {
|
|
168
|
+
primary: "not-disabled:hover:bg-button-text-primary-text/20 not-disabled:focus-visible:bg-button-text-primary-text/20",
|
|
169
|
+
negative: "not-disabled:hover:bg-button-text-negative-text/20 not-disabled:focus-visible:bg-button-text-negative-text/20",
|
|
170
|
+
neutral: "not-disabled:hover:bg-button-text-neutral-text/20 not-disabled:focus-visible:bg-button-text-neutral-text/20"
|
|
171
|
+
}[color];
|
|
172
|
+
const iconColorClasses = {
|
|
173
|
+
primary: "not-group-disabled:text-button-text-primary-icon",
|
|
174
|
+
negative: "not-group-disabled:text-button-text-negative-icon",
|
|
175
|
+
neutral: "not-group-disabled:text-button-text-neutral-icon"
|
|
176
|
+
}[color];
|
|
177
|
+
return /* @__PURE__ */ jsxs(
|
|
178
|
+
"button",
|
|
179
|
+
{
|
|
180
|
+
onClick,
|
|
181
|
+
className: clsx(
|
|
182
|
+
"group font-semibold",
|
|
183
|
+
"disabled:text-disabled-text",
|
|
184
|
+
colorClasses,
|
|
185
|
+
{
|
|
186
|
+
[backgroundColor]: coloredHoverBackground,
|
|
187
|
+
"not-disabled:hover:bg-button-text-hover-background": !coloredHoverBackground
|
|
188
|
+
},
|
|
189
|
+
ButtonUtil.paddingMapping[size],
|
|
190
|
+
className
|
|
191
|
+
),
|
|
192
|
+
...restProps,
|
|
193
|
+
children: [
|
|
194
|
+
startIcon && /* @__PURE__ */ jsx(
|
|
195
|
+
"span",
|
|
196
|
+
{
|
|
197
|
+
className: clsx(
|
|
198
|
+
iconColorClasses,
|
|
199
|
+
"group-disabled:text-disabled-icon"
|
|
200
|
+
),
|
|
201
|
+
children: startIcon
|
|
202
|
+
}
|
|
203
|
+
),
|
|
204
|
+
children,
|
|
205
|
+
endIcon && /* @__PURE__ */ jsx(
|
|
206
|
+
"span",
|
|
207
|
+
{
|
|
208
|
+
className: clsx(
|
|
209
|
+
iconColorClasses,
|
|
210
|
+
"group-disabled:text-disabled-icon"
|
|
211
|
+
),
|
|
212
|
+
children: endIcon
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
};
|
|
219
|
+
var IconButton = forwardRef(function IconButton2({
|
|
220
|
+
children,
|
|
221
|
+
color = "primary",
|
|
222
|
+
size = "medium",
|
|
223
|
+
className,
|
|
224
|
+
...restProps
|
|
225
|
+
}, ref) {
|
|
226
|
+
const colorClasses = {
|
|
227
|
+
primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
|
|
228
|
+
secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
|
|
229
|
+
tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
|
|
230
|
+
positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
|
|
231
|
+
warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
|
|
232
|
+
negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
|
|
233
|
+
neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text",
|
|
234
|
+
transparent: "not-disabled:bg-transparent"
|
|
235
|
+
}[color];
|
|
236
|
+
return /* @__PURE__ */ jsx(
|
|
237
|
+
"button",
|
|
238
|
+
{
|
|
239
|
+
ref,
|
|
240
|
+
className: clsx(
|
|
241
|
+
colorClasses,
|
|
242
|
+
"not-disabled:hover:brightness-90",
|
|
243
|
+
"disabled:text-disabled-text",
|
|
244
|
+
{
|
|
245
|
+
"disabled:bg-disabled-background": color !== "transparent",
|
|
246
|
+
"disabled:opacity-70": color === "transparent",
|
|
247
|
+
"not-disabled:hover:bg-button-text-hover-background": color === "transparent"
|
|
248
|
+
},
|
|
249
|
+
ButtonUtil.iconPaddingMapping[size],
|
|
250
|
+
className
|
|
251
|
+
),
|
|
252
|
+
...restProps,
|
|
253
|
+
children
|
|
254
|
+
}
|
|
255
|
+
);
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// src/components/user-action/Checkbox.tsx
|
|
259
|
+
import { useEffect as useEffect5, useState as useState5 } from "react";
|
|
260
|
+
import { Check, Minus } from "lucide-react";
|
|
261
|
+
import clsx2 from "clsx";
|
|
262
|
+
|
|
263
|
+
// node_modules/@radix-ui/react-checkbox/dist/index.mjs
|
|
264
|
+
import * as React10 from "react";
|
|
265
|
+
|
|
266
|
+
// node_modules/@radix-ui/react-compose-refs/dist/index.mjs
|
|
267
|
+
import * as React from "react";
|
|
268
|
+
function setRef(ref, value) {
|
|
269
|
+
if (typeof ref === "function") {
|
|
270
|
+
return ref(value);
|
|
271
|
+
} else if (ref !== null && ref !== void 0) {
|
|
272
|
+
ref.current = value;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function composeRefs(...refs) {
|
|
276
|
+
return (node) => {
|
|
277
|
+
let hasCleanup = false;
|
|
278
|
+
const cleanups = refs.map((ref) => {
|
|
279
|
+
const cleanup = setRef(ref, node);
|
|
280
|
+
if (!hasCleanup && typeof cleanup == "function") {
|
|
281
|
+
hasCleanup = true;
|
|
282
|
+
}
|
|
283
|
+
return cleanup;
|
|
284
|
+
});
|
|
285
|
+
if (hasCleanup) {
|
|
286
|
+
return () => {
|
|
287
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
288
|
+
const cleanup = cleanups[i];
|
|
289
|
+
if (typeof cleanup == "function") {
|
|
290
|
+
cleanup();
|
|
291
|
+
} else {
|
|
292
|
+
setRef(refs[i], null);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function useComposedRefs(...refs) {
|
|
300
|
+
return React.useCallback(composeRefs(...refs), refs);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// node_modules/@radix-ui/react-context/dist/index.mjs
|
|
304
|
+
import * as React2 from "react";
|
|
305
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
306
|
+
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
307
|
+
let defaultContexts = [];
|
|
308
|
+
function createContext32(rootComponentName, defaultContext) {
|
|
309
|
+
const BaseContext = React2.createContext(defaultContext);
|
|
310
|
+
const index = defaultContexts.length;
|
|
311
|
+
defaultContexts = [...defaultContexts, defaultContext];
|
|
312
|
+
const Provider = (props) => {
|
|
313
|
+
const { scope, children, ...context } = props;
|
|
314
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
315
|
+
const value = React2.useMemo(() => context, Object.values(context));
|
|
316
|
+
return /* @__PURE__ */ jsx2(Context.Provider, { value, children });
|
|
317
|
+
};
|
|
318
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
319
|
+
function useContext22(consumerName, scope) {
|
|
320
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
321
|
+
const context = React2.useContext(Context);
|
|
322
|
+
if (context) return context;
|
|
323
|
+
if (defaultContext !== void 0) return defaultContext;
|
|
324
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
325
|
+
}
|
|
326
|
+
return [Provider, useContext22];
|
|
327
|
+
}
|
|
328
|
+
const createScope = () => {
|
|
329
|
+
const scopeContexts = defaultContexts.map((defaultContext) => {
|
|
330
|
+
return React2.createContext(defaultContext);
|
|
331
|
+
});
|
|
332
|
+
return function useScope(scope) {
|
|
333
|
+
const contexts = scope?.[scopeName] || scopeContexts;
|
|
334
|
+
return React2.useMemo(
|
|
335
|
+
() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
|
|
336
|
+
[scope, contexts]
|
|
337
|
+
);
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
createScope.scopeName = scopeName;
|
|
341
|
+
return [createContext32, composeContextScopes(createScope, ...createContextScopeDeps)];
|
|
342
|
+
}
|
|
343
|
+
function composeContextScopes(...scopes) {
|
|
344
|
+
const baseScope = scopes[0];
|
|
345
|
+
if (scopes.length === 1) return baseScope;
|
|
346
|
+
const createScope = () => {
|
|
347
|
+
const scopeHooks = scopes.map((createScope2) => ({
|
|
348
|
+
useScope: createScope2(),
|
|
349
|
+
scopeName: createScope2.scopeName
|
|
350
|
+
}));
|
|
351
|
+
return function useComposedScopes(overrideScopes) {
|
|
352
|
+
const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
|
|
353
|
+
const scopeProps = useScope(overrideScopes);
|
|
354
|
+
const currentScope = scopeProps[`__scope${scopeName}`];
|
|
355
|
+
return { ...nextScopes2, ...currentScope };
|
|
356
|
+
}, {});
|
|
357
|
+
return React2.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
|
|
358
|
+
};
|
|
359
|
+
};
|
|
360
|
+
createScope.scopeName = baseScope.scopeName;
|
|
361
|
+
return createScope;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// node_modules/@radix-ui/primitive/dist/index.mjs
|
|
365
|
+
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
366
|
+
return function handleEvent(event) {
|
|
367
|
+
originalEventHandler?.(event);
|
|
368
|
+
if (checkForDefaultPrevented === false || !event.defaultPrevented) {
|
|
369
|
+
return ourEventHandler?.(event);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
|
|
375
|
+
import * as React4 from "react";
|
|
376
|
+
|
|
377
|
+
// node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs
|
|
378
|
+
import * as React3 from "react";
|
|
379
|
+
var useLayoutEffect2 = globalThis?.document ? React3.useLayoutEffect : () => {
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
// node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
|
|
383
|
+
import * as React22 from "react";
|
|
384
|
+
var useInsertionEffect = React4[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
|
|
385
|
+
function useControllableState({
|
|
386
|
+
prop,
|
|
387
|
+
defaultProp,
|
|
388
|
+
onChange = () => {
|
|
389
|
+
},
|
|
390
|
+
caller
|
|
391
|
+
}) {
|
|
392
|
+
const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
|
|
393
|
+
defaultProp,
|
|
394
|
+
onChange
|
|
395
|
+
});
|
|
396
|
+
const isControlled = prop !== void 0;
|
|
397
|
+
const value = isControlled ? prop : uncontrolledProp;
|
|
398
|
+
if (true) {
|
|
399
|
+
const isControlledRef = React4.useRef(prop !== void 0);
|
|
400
|
+
React4.useEffect(() => {
|
|
401
|
+
const wasControlled = isControlledRef.current;
|
|
402
|
+
if (wasControlled !== isControlled) {
|
|
403
|
+
const from = wasControlled ? "controlled" : "uncontrolled";
|
|
404
|
+
const to = isControlled ? "controlled" : "uncontrolled";
|
|
405
|
+
console.warn(
|
|
406
|
+
`${caller} is changing from ${from} to ${to}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
isControlledRef.current = isControlled;
|
|
410
|
+
}, [isControlled, caller]);
|
|
411
|
+
}
|
|
412
|
+
const setValue = React4.useCallback(
|
|
413
|
+
(nextValue) => {
|
|
414
|
+
if (isControlled) {
|
|
415
|
+
const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
|
|
416
|
+
if (value2 !== prop) {
|
|
417
|
+
onChangeRef.current?.(value2);
|
|
418
|
+
}
|
|
419
|
+
} else {
|
|
420
|
+
setUncontrolledProp(nextValue);
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
[isControlled, prop, setUncontrolledProp, onChangeRef]
|
|
424
|
+
);
|
|
425
|
+
return [value, setValue];
|
|
426
|
+
}
|
|
427
|
+
function useUncontrolledState({
|
|
428
|
+
defaultProp,
|
|
429
|
+
onChange
|
|
430
|
+
}) {
|
|
431
|
+
const [value, setValue] = React4.useState(defaultProp);
|
|
432
|
+
const prevValueRef = React4.useRef(value);
|
|
433
|
+
const onChangeRef = React4.useRef(onChange);
|
|
434
|
+
useInsertionEffect(() => {
|
|
435
|
+
onChangeRef.current = onChange;
|
|
436
|
+
}, [onChange]);
|
|
437
|
+
React4.useEffect(() => {
|
|
438
|
+
if (prevValueRef.current !== value) {
|
|
439
|
+
onChangeRef.current?.(value);
|
|
440
|
+
prevValueRef.current = value;
|
|
441
|
+
}
|
|
442
|
+
}, [value, prevValueRef]);
|
|
443
|
+
return [value, setValue, onChangeRef];
|
|
444
|
+
}
|
|
445
|
+
function isFunction(value) {
|
|
446
|
+
return typeof value === "function";
|
|
447
|
+
}
|
|
448
|
+
var SYNC_STATE = Symbol("RADIX:SYNC_STATE");
|
|
449
|
+
|
|
450
|
+
// node_modules/@radix-ui/react-use-previous/dist/index.mjs
|
|
451
|
+
import * as React5 from "react";
|
|
452
|
+
function usePrevious(value) {
|
|
453
|
+
const ref = React5.useRef({ value, previous: value });
|
|
454
|
+
return React5.useMemo(() => {
|
|
455
|
+
if (ref.current.value !== value) {
|
|
456
|
+
ref.current.previous = ref.current.value;
|
|
457
|
+
ref.current.value = value;
|
|
458
|
+
}
|
|
459
|
+
return ref.current.previous;
|
|
460
|
+
}, [value]);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// node_modules/@radix-ui/react-use-size/dist/index.mjs
|
|
464
|
+
import * as React6 from "react";
|
|
465
|
+
function useSize(element) {
|
|
466
|
+
const [size, setSize] = React6.useState(void 0);
|
|
467
|
+
useLayoutEffect2(() => {
|
|
468
|
+
if (element) {
|
|
469
|
+
setSize({ width: element.offsetWidth, height: element.offsetHeight });
|
|
470
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
471
|
+
if (!Array.isArray(entries)) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (!entries.length) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
const entry = entries[0];
|
|
478
|
+
let width;
|
|
479
|
+
let height;
|
|
480
|
+
if ("borderBoxSize" in entry) {
|
|
481
|
+
const borderSizeEntry = entry["borderBoxSize"];
|
|
482
|
+
const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
|
|
483
|
+
width = borderSize["inlineSize"];
|
|
484
|
+
height = borderSize["blockSize"];
|
|
485
|
+
} else {
|
|
486
|
+
width = element.offsetWidth;
|
|
487
|
+
height = element.offsetHeight;
|
|
488
|
+
}
|
|
489
|
+
setSize({ width, height });
|
|
490
|
+
});
|
|
491
|
+
resizeObserver.observe(element, { box: "border-box" });
|
|
492
|
+
return () => resizeObserver.unobserve(element);
|
|
493
|
+
} else {
|
|
494
|
+
setSize(void 0);
|
|
495
|
+
}
|
|
496
|
+
}, [element]);
|
|
497
|
+
return size;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// node_modules/@radix-ui/react-presence/dist/index.mjs
|
|
501
|
+
import * as React23 from "react";
|
|
502
|
+
import * as React7 from "react";
|
|
503
|
+
function useStateMachine(initialState, machine) {
|
|
504
|
+
return React7.useReducer((state, event) => {
|
|
505
|
+
const nextState = machine[state][event];
|
|
506
|
+
return nextState ?? state;
|
|
507
|
+
}, initialState);
|
|
508
|
+
}
|
|
509
|
+
var Presence = (props) => {
|
|
510
|
+
const { present, children } = props;
|
|
511
|
+
const presence = usePresence(present);
|
|
512
|
+
const child = typeof children === "function" ? children({ present: presence.isPresent }) : React23.Children.only(children);
|
|
513
|
+
const ref = useComposedRefs(presence.ref, getElementRef(child));
|
|
514
|
+
const forceMount = typeof children === "function";
|
|
515
|
+
return forceMount || presence.isPresent ? React23.cloneElement(child, { ref }) : null;
|
|
516
|
+
};
|
|
517
|
+
Presence.displayName = "Presence";
|
|
518
|
+
function usePresence(present) {
|
|
519
|
+
const [node, setNode] = React23.useState();
|
|
520
|
+
const stylesRef = React23.useRef(null);
|
|
521
|
+
const prevPresentRef = React23.useRef(present);
|
|
522
|
+
const prevAnimationNameRef = React23.useRef("none");
|
|
523
|
+
const initialState = present ? "mounted" : "unmounted";
|
|
524
|
+
const [state, send] = useStateMachine(initialState, {
|
|
525
|
+
mounted: {
|
|
526
|
+
UNMOUNT: "unmounted",
|
|
527
|
+
ANIMATION_OUT: "unmountSuspended"
|
|
528
|
+
},
|
|
529
|
+
unmountSuspended: {
|
|
530
|
+
MOUNT: "mounted",
|
|
531
|
+
ANIMATION_END: "unmounted"
|
|
532
|
+
},
|
|
533
|
+
unmounted: {
|
|
534
|
+
MOUNT: "mounted"
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
React23.useEffect(() => {
|
|
538
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
539
|
+
prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
|
|
540
|
+
}, [state]);
|
|
541
|
+
useLayoutEffect2(() => {
|
|
542
|
+
const styles = stylesRef.current;
|
|
543
|
+
const wasPresent = prevPresentRef.current;
|
|
544
|
+
const hasPresentChanged = wasPresent !== present;
|
|
545
|
+
if (hasPresentChanged) {
|
|
546
|
+
const prevAnimationName = prevAnimationNameRef.current;
|
|
547
|
+
const currentAnimationName = getAnimationName(styles);
|
|
548
|
+
if (present) {
|
|
549
|
+
send("MOUNT");
|
|
550
|
+
} else if (currentAnimationName === "none" || styles?.display === "none") {
|
|
551
|
+
send("UNMOUNT");
|
|
552
|
+
} else {
|
|
553
|
+
const isAnimating = prevAnimationName !== currentAnimationName;
|
|
554
|
+
if (wasPresent && isAnimating) {
|
|
555
|
+
send("ANIMATION_OUT");
|
|
556
|
+
} else {
|
|
557
|
+
send("UNMOUNT");
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
prevPresentRef.current = present;
|
|
561
|
+
}
|
|
562
|
+
}, [present, send]);
|
|
563
|
+
useLayoutEffect2(() => {
|
|
564
|
+
if (node) {
|
|
565
|
+
let timeoutId;
|
|
566
|
+
const ownerWindow = node.ownerDocument.defaultView ?? window;
|
|
567
|
+
const handleAnimationEnd = (event) => {
|
|
568
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
569
|
+
const isCurrentAnimation = currentAnimationName.includes(event.animationName);
|
|
570
|
+
if (event.target === node && isCurrentAnimation) {
|
|
571
|
+
send("ANIMATION_END");
|
|
572
|
+
if (!prevPresentRef.current) {
|
|
573
|
+
const currentFillMode = node.style.animationFillMode;
|
|
574
|
+
node.style.animationFillMode = "forwards";
|
|
575
|
+
timeoutId = ownerWindow.setTimeout(() => {
|
|
576
|
+
if (node.style.animationFillMode === "forwards") {
|
|
577
|
+
node.style.animationFillMode = currentFillMode;
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
const handleAnimationStart = (event) => {
|
|
584
|
+
if (event.target === node) {
|
|
585
|
+
prevAnimationNameRef.current = getAnimationName(stylesRef.current);
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
node.addEventListener("animationstart", handleAnimationStart);
|
|
589
|
+
node.addEventListener("animationcancel", handleAnimationEnd);
|
|
590
|
+
node.addEventListener("animationend", handleAnimationEnd);
|
|
591
|
+
return () => {
|
|
592
|
+
ownerWindow.clearTimeout(timeoutId);
|
|
593
|
+
node.removeEventListener("animationstart", handleAnimationStart);
|
|
594
|
+
node.removeEventListener("animationcancel", handleAnimationEnd);
|
|
595
|
+
node.removeEventListener("animationend", handleAnimationEnd);
|
|
596
|
+
};
|
|
597
|
+
} else {
|
|
598
|
+
send("ANIMATION_END");
|
|
599
|
+
}
|
|
600
|
+
}, [node, send]);
|
|
601
|
+
return {
|
|
602
|
+
isPresent: ["mounted", "unmountSuspended"].includes(state),
|
|
603
|
+
ref: React23.useCallback((node2) => {
|
|
604
|
+
stylesRef.current = node2 ? getComputedStyle(node2) : null;
|
|
605
|
+
setNode(node2);
|
|
606
|
+
}, [])
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
function getAnimationName(styles) {
|
|
610
|
+
return styles?.animationName || "none";
|
|
611
|
+
}
|
|
612
|
+
function getElementRef(element) {
|
|
613
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
614
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
615
|
+
if (mayWarn) {
|
|
616
|
+
return element.ref;
|
|
617
|
+
}
|
|
618
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
619
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
620
|
+
if (mayWarn) {
|
|
621
|
+
return element.props.ref;
|
|
622
|
+
}
|
|
623
|
+
return element.props.ref || element.ref;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
627
|
+
import * as React9 from "react";
|
|
628
|
+
import * as ReactDOM from "react-dom";
|
|
629
|
+
|
|
630
|
+
// node_modules/@radix-ui/react-slot/dist/index.mjs
|
|
631
|
+
import * as React8 from "react";
|
|
632
|
+
import { Fragment as Fragment2, jsx as jsx3 } from "react/jsx-runtime";
|
|
633
|
+
// @__NO_SIDE_EFFECTS__
|
|
634
|
+
function createSlot(ownerName) {
|
|
635
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
636
|
+
const Slot2 = React8.forwardRef((props, forwardedRef) => {
|
|
637
|
+
const { children, ...slotProps } = props;
|
|
638
|
+
const childrenArray = React8.Children.toArray(children);
|
|
639
|
+
const slottable = childrenArray.find(isSlottable);
|
|
640
|
+
if (slottable) {
|
|
641
|
+
const newElement = slottable.props.children;
|
|
642
|
+
const newChildren = childrenArray.map((child) => {
|
|
643
|
+
if (child === slottable) {
|
|
644
|
+
if (React8.Children.count(newElement) > 1) return React8.Children.only(null);
|
|
645
|
+
return React8.isValidElement(newElement) ? newElement.props.children : null;
|
|
646
|
+
} else {
|
|
647
|
+
return child;
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
return /* @__PURE__ */ jsx3(SlotClone, { ...slotProps, ref: forwardedRef, children: React8.isValidElement(newElement) ? React8.cloneElement(newElement, void 0, newChildren) : null });
|
|
651
|
+
}
|
|
652
|
+
return /* @__PURE__ */ jsx3(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
653
|
+
});
|
|
654
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
655
|
+
return Slot2;
|
|
656
|
+
}
|
|
657
|
+
// @__NO_SIDE_EFFECTS__
|
|
658
|
+
function createSlotClone(ownerName) {
|
|
659
|
+
const SlotClone = React8.forwardRef((props, forwardedRef) => {
|
|
660
|
+
const { children, ...slotProps } = props;
|
|
661
|
+
if (React8.isValidElement(children)) {
|
|
662
|
+
const childrenRef = getElementRef2(children);
|
|
663
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
664
|
+
if (children.type !== React8.Fragment) {
|
|
665
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
666
|
+
}
|
|
667
|
+
return React8.cloneElement(children, props2);
|
|
668
|
+
}
|
|
669
|
+
return React8.Children.count(children) > 1 ? React8.Children.only(null) : null;
|
|
670
|
+
});
|
|
671
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
672
|
+
return SlotClone;
|
|
673
|
+
}
|
|
674
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
675
|
+
function isSlottable(child) {
|
|
676
|
+
return React8.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
677
|
+
}
|
|
678
|
+
function mergeProps(slotProps, childProps) {
|
|
679
|
+
const overrideProps = { ...childProps };
|
|
680
|
+
for (const propName in childProps) {
|
|
681
|
+
const slotPropValue = slotProps[propName];
|
|
682
|
+
const childPropValue = childProps[propName];
|
|
683
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
684
|
+
if (isHandler) {
|
|
685
|
+
if (slotPropValue && childPropValue) {
|
|
686
|
+
overrideProps[propName] = (...args) => {
|
|
687
|
+
const result = childPropValue(...args);
|
|
688
|
+
slotPropValue(...args);
|
|
689
|
+
return result;
|
|
690
|
+
};
|
|
691
|
+
} else if (slotPropValue) {
|
|
692
|
+
overrideProps[propName] = slotPropValue;
|
|
693
|
+
}
|
|
694
|
+
} else if (propName === "style") {
|
|
695
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
696
|
+
} else if (propName === "className") {
|
|
697
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
return { ...slotProps, ...overrideProps };
|
|
701
|
+
}
|
|
702
|
+
function getElementRef2(element) {
|
|
703
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
704
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
705
|
+
if (mayWarn) {
|
|
706
|
+
return element.ref;
|
|
707
|
+
}
|
|
708
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
709
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
710
|
+
if (mayWarn) {
|
|
711
|
+
return element.props.ref;
|
|
712
|
+
}
|
|
713
|
+
return element.props.ref || element.ref;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
// node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
717
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
718
|
+
var NODES = [
|
|
719
|
+
"a",
|
|
720
|
+
"button",
|
|
721
|
+
"div",
|
|
722
|
+
"form",
|
|
723
|
+
"h2",
|
|
724
|
+
"h3",
|
|
725
|
+
"img",
|
|
726
|
+
"input",
|
|
727
|
+
"label",
|
|
728
|
+
"li",
|
|
729
|
+
"nav",
|
|
730
|
+
"ol",
|
|
731
|
+
"p",
|
|
732
|
+
"select",
|
|
733
|
+
"span",
|
|
734
|
+
"svg",
|
|
735
|
+
"ul"
|
|
736
|
+
];
|
|
737
|
+
var Primitive = NODES.reduce((primitive, node) => {
|
|
738
|
+
const Slot = createSlot(`Primitive.${node}`);
|
|
739
|
+
const Node2 = React9.forwardRef((props, forwardedRef) => {
|
|
740
|
+
const { asChild, ...primitiveProps } = props;
|
|
741
|
+
const Comp = asChild ? Slot : node;
|
|
742
|
+
if (typeof window !== "undefined") {
|
|
743
|
+
window[Symbol.for("radix-ui")] = true;
|
|
744
|
+
}
|
|
745
|
+
return /* @__PURE__ */ jsx4(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
746
|
+
});
|
|
747
|
+
Node2.displayName = `Primitive.${node}`;
|
|
748
|
+
return { ...primitive, [node]: Node2 };
|
|
749
|
+
}, {});
|
|
750
|
+
|
|
751
|
+
// node_modules/@radix-ui/react-checkbox/dist/index.mjs
|
|
752
|
+
import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
753
|
+
var CHECKBOX_NAME = "Checkbox";
|
|
754
|
+
var [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME);
|
|
755
|
+
var [CheckboxProviderImpl, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
|
|
756
|
+
function CheckboxProvider(props) {
|
|
757
|
+
const {
|
|
758
|
+
__scopeCheckbox,
|
|
759
|
+
checked: checkedProp,
|
|
760
|
+
children,
|
|
761
|
+
defaultChecked,
|
|
762
|
+
disabled,
|
|
763
|
+
form,
|
|
764
|
+
name,
|
|
765
|
+
onCheckedChange,
|
|
766
|
+
required,
|
|
767
|
+
value = "on",
|
|
768
|
+
// @ts-expect-error
|
|
769
|
+
internal_do_not_use_render
|
|
770
|
+
} = props;
|
|
771
|
+
const [checked, setChecked] = useControllableState({
|
|
772
|
+
prop: checkedProp,
|
|
773
|
+
defaultProp: defaultChecked ?? false,
|
|
774
|
+
onChange: onCheckedChange,
|
|
775
|
+
caller: CHECKBOX_NAME
|
|
776
|
+
});
|
|
777
|
+
const [control, setControl] = React10.useState(null);
|
|
778
|
+
const [bubbleInput, setBubbleInput] = React10.useState(null);
|
|
779
|
+
const hasConsumerStoppedPropagationRef = React10.useRef(false);
|
|
780
|
+
const isFormControl = control ? !!form || !!control.closest("form") : (
|
|
781
|
+
// We set this to true by default so that events bubble to forms without JS (SSR)
|
|
782
|
+
true
|
|
783
|
+
);
|
|
784
|
+
const context = {
|
|
785
|
+
checked,
|
|
786
|
+
disabled,
|
|
787
|
+
setChecked,
|
|
788
|
+
control,
|
|
789
|
+
setControl,
|
|
790
|
+
name,
|
|
791
|
+
form,
|
|
792
|
+
value,
|
|
793
|
+
hasConsumerStoppedPropagationRef,
|
|
794
|
+
required,
|
|
795
|
+
defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,
|
|
796
|
+
isFormControl,
|
|
797
|
+
bubbleInput,
|
|
798
|
+
setBubbleInput
|
|
799
|
+
};
|
|
800
|
+
return /* @__PURE__ */ jsx5(
|
|
801
|
+
CheckboxProviderImpl,
|
|
802
|
+
{
|
|
803
|
+
scope: __scopeCheckbox,
|
|
804
|
+
...context,
|
|
805
|
+
children: isFunction2(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
|
|
806
|
+
}
|
|
807
|
+
);
|
|
808
|
+
}
|
|
809
|
+
var TRIGGER_NAME = "CheckboxTrigger";
|
|
810
|
+
var CheckboxTrigger = React10.forwardRef(
|
|
811
|
+
({ __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }, forwardedRef) => {
|
|
812
|
+
const {
|
|
813
|
+
control,
|
|
814
|
+
value,
|
|
815
|
+
disabled,
|
|
816
|
+
checked,
|
|
817
|
+
required,
|
|
818
|
+
setControl,
|
|
819
|
+
setChecked,
|
|
820
|
+
hasConsumerStoppedPropagationRef,
|
|
821
|
+
isFormControl,
|
|
822
|
+
bubbleInput
|
|
823
|
+
} = useCheckboxContext(TRIGGER_NAME, __scopeCheckbox);
|
|
824
|
+
const composedRefs = useComposedRefs(forwardedRef, setControl);
|
|
825
|
+
const initialCheckedStateRef = React10.useRef(checked);
|
|
826
|
+
React10.useEffect(() => {
|
|
827
|
+
const form = control?.form;
|
|
828
|
+
if (form) {
|
|
829
|
+
const reset = () => setChecked(initialCheckedStateRef.current);
|
|
830
|
+
form.addEventListener("reset", reset);
|
|
831
|
+
return () => form.removeEventListener("reset", reset);
|
|
832
|
+
}
|
|
833
|
+
}, [control, setChecked]);
|
|
834
|
+
return /* @__PURE__ */ jsx5(
|
|
835
|
+
Primitive.button,
|
|
836
|
+
{
|
|
837
|
+
type: "button",
|
|
838
|
+
role: "checkbox",
|
|
839
|
+
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
|
840
|
+
"aria-required": required,
|
|
841
|
+
"data-state": getState(checked),
|
|
842
|
+
"data-disabled": disabled ? "" : void 0,
|
|
843
|
+
disabled,
|
|
844
|
+
value,
|
|
845
|
+
...checkboxProps,
|
|
846
|
+
ref: composedRefs,
|
|
847
|
+
onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
848
|
+
if (event.key === "Enter") event.preventDefault();
|
|
849
|
+
}),
|
|
850
|
+
onClick: composeEventHandlers(onClick, (event) => {
|
|
851
|
+
setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
|
|
852
|
+
if (bubbleInput && isFormControl) {
|
|
853
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
854
|
+
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
855
|
+
}
|
|
856
|
+
})
|
|
857
|
+
}
|
|
858
|
+
);
|
|
859
|
+
}
|
|
860
|
+
);
|
|
861
|
+
CheckboxTrigger.displayName = TRIGGER_NAME;
|
|
862
|
+
var Checkbox = React10.forwardRef(
|
|
863
|
+
(props, forwardedRef) => {
|
|
864
|
+
const {
|
|
865
|
+
__scopeCheckbox,
|
|
866
|
+
name,
|
|
867
|
+
checked,
|
|
868
|
+
defaultChecked,
|
|
869
|
+
required,
|
|
870
|
+
disabled,
|
|
871
|
+
value,
|
|
872
|
+
onCheckedChange,
|
|
873
|
+
form,
|
|
874
|
+
...checkboxProps
|
|
875
|
+
} = props;
|
|
876
|
+
return /* @__PURE__ */ jsx5(
|
|
877
|
+
CheckboxProvider,
|
|
878
|
+
{
|
|
879
|
+
__scopeCheckbox,
|
|
880
|
+
checked,
|
|
881
|
+
defaultChecked,
|
|
882
|
+
disabled,
|
|
883
|
+
required,
|
|
884
|
+
onCheckedChange,
|
|
885
|
+
name,
|
|
886
|
+
form,
|
|
887
|
+
value,
|
|
888
|
+
internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ jsxs2(Fragment3, { children: [
|
|
889
|
+
/* @__PURE__ */ jsx5(
|
|
890
|
+
CheckboxTrigger,
|
|
891
|
+
{
|
|
892
|
+
...checkboxProps,
|
|
893
|
+
ref: forwardedRef,
|
|
894
|
+
__scopeCheckbox
|
|
895
|
+
}
|
|
896
|
+
),
|
|
897
|
+
isFormControl && /* @__PURE__ */ jsx5(
|
|
898
|
+
CheckboxBubbleInput,
|
|
899
|
+
{
|
|
900
|
+
__scopeCheckbox
|
|
901
|
+
}
|
|
902
|
+
)
|
|
903
|
+
] })
|
|
904
|
+
}
|
|
905
|
+
);
|
|
906
|
+
}
|
|
907
|
+
);
|
|
908
|
+
Checkbox.displayName = CHECKBOX_NAME;
|
|
909
|
+
var INDICATOR_NAME = "CheckboxIndicator";
|
|
910
|
+
var CheckboxIndicator = React10.forwardRef(
|
|
911
|
+
(props, forwardedRef) => {
|
|
912
|
+
const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
|
|
913
|
+
const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
|
|
914
|
+
return /* @__PURE__ */ jsx5(
|
|
915
|
+
Presence,
|
|
916
|
+
{
|
|
917
|
+
present: forceMount || isIndeterminate(context.checked) || context.checked === true,
|
|
918
|
+
children: /* @__PURE__ */ jsx5(
|
|
919
|
+
Primitive.span,
|
|
920
|
+
{
|
|
921
|
+
"data-state": getState(context.checked),
|
|
922
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
923
|
+
...indicatorProps,
|
|
924
|
+
ref: forwardedRef,
|
|
925
|
+
style: { pointerEvents: "none", ...props.style }
|
|
926
|
+
}
|
|
927
|
+
)
|
|
928
|
+
}
|
|
929
|
+
);
|
|
930
|
+
}
|
|
931
|
+
);
|
|
932
|
+
CheckboxIndicator.displayName = INDICATOR_NAME;
|
|
933
|
+
var BUBBLE_INPUT_NAME = "CheckboxBubbleInput";
|
|
934
|
+
var CheckboxBubbleInput = React10.forwardRef(
|
|
935
|
+
({ __scopeCheckbox, ...props }, forwardedRef) => {
|
|
936
|
+
const {
|
|
937
|
+
control,
|
|
938
|
+
hasConsumerStoppedPropagationRef,
|
|
939
|
+
checked,
|
|
940
|
+
defaultChecked,
|
|
941
|
+
required,
|
|
942
|
+
disabled,
|
|
943
|
+
name,
|
|
944
|
+
value,
|
|
945
|
+
form,
|
|
946
|
+
bubbleInput,
|
|
947
|
+
setBubbleInput
|
|
948
|
+
} = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);
|
|
949
|
+
const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);
|
|
950
|
+
const prevChecked = usePrevious(checked);
|
|
951
|
+
const controlSize = useSize(control);
|
|
952
|
+
React10.useEffect(() => {
|
|
953
|
+
const input = bubbleInput;
|
|
954
|
+
if (!input) return;
|
|
955
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
956
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
957
|
+
inputProto,
|
|
958
|
+
"checked"
|
|
959
|
+
);
|
|
960
|
+
const setChecked = descriptor.set;
|
|
961
|
+
const bubbles = !hasConsumerStoppedPropagationRef.current;
|
|
962
|
+
if (prevChecked !== checked && setChecked) {
|
|
963
|
+
const event = new Event("click", { bubbles });
|
|
964
|
+
input.indeterminate = isIndeterminate(checked);
|
|
965
|
+
setChecked.call(input, isIndeterminate(checked) ? false : checked);
|
|
966
|
+
input.dispatchEvent(event);
|
|
967
|
+
}
|
|
968
|
+
}, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);
|
|
969
|
+
const defaultCheckedRef = React10.useRef(isIndeterminate(checked) ? false : checked);
|
|
970
|
+
return /* @__PURE__ */ jsx5(
|
|
971
|
+
Primitive.input,
|
|
972
|
+
{
|
|
973
|
+
type: "checkbox",
|
|
974
|
+
"aria-hidden": true,
|
|
975
|
+
defaultChecked: defaultChecked ?? defaultCheckedRef.current,
|
|
976
|
+
required,
|
|
977
|
+
disabled,
|
|
978
|
+
name,
|
|
979
|
+
value,
|
|
980
|
+
form,
|
|
981
|
+
...props,
|
|
982
|
+
tabIndex: -1,
|
|
983
|
+
ref: composedRefs,
|
|
984
|
+
style: {
|
|
985
|
+
...props.style,
|
|
986
|
+
...controlSize,
|
|
987
|
+
position: "absolute",
|
|
988
|
+
pointerEvents: "none",
|
|
989
|
+
opacity: 0,
|
|
990
|
+
margin: 0,
|
|
991
|
+
// We transform because the input is absolutely positioned but we have
|
|
992
|
+
// rendered it **after** the button. This pulls it back to sit on top
|
|
993
|
+
// of the button.
|
|
994
|
+
transform: "translateX(-100%)"
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
);
|
|
998
|
+
}
|
|
999
|
+
);
|
|
1000
|
+
CheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;
|
|
1001
|
+
function isFunction2(value) {
|
|
1002
|
+
return typeof value === "function";
|
|
1003
|
+
}
|
|
1004
|
+
function isIndeterminate(checked) {
|
|
1005
|
+
return checked === "indeterminate";
|
|
1006
|
+
}
|
|
1007
|
+
function getState(checked) {
|
|
1008
|
+
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
// src/components/user-action/Checkbox.tsx
|
|
1012
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1013
|
+
var checkboxSizeMapping = {
|
|
1014
|
+
sm: "size-5 border-1",
|
|
1015
|
+
md: "size-6 border-1",
|
|
1016
|
+
lg: "size-8 border-2"
|
|
1017
|
+
};
|
|
1018
|
+
var checkboxIconSizeMapping = {
|
|
1019
|
+
sm: "size-4 stroke-3",
|
|
1020
|
+
md: "size-5 stroke-3",
|
|
1021
|
+
lg: "size-7 stroke-3"
|
|
1022
|
+
};
|
|
1023
|
+
var Checkbox2 = ({
|
|
1024
|
+
disabled,
|
|
1025
|
+
checked = false,
|
|
1026
|
+
indeterminate = false,
|
|
1027
|
+
onChange,
|
|
1028
|
+
size = "md",
|
|
1029
|
+
className = "",
|
|
1030
|
+
...props
|
|
1031
|
+
}) => {
|
|
1032
|
+
const usedSizeClass = checkboxSizeMapping[size];
|
|
1033
|
+
const innerIconSize = checkboxIconSizeMapping[size];
|
|
1034
|
+
return /* @__PURE__ */ jsx6(
|
|
1035
|
+
Checkbox,
|
|
1036
|
+
{
|
|
1037
|
+
...props,
|
|
1038
|
+
disabled,
|
|
1039
|
+
checked: indeterminate ? "indeterminate" : checked,
|
|
1040
|
+
onCheckedChange: onChange,
|
|
1041
|
+
className: clsx2(
|
|
1042
|
+
usedSizeClass,
|
|
1043
|
+
`flex-col-0 items-center justify-center rounded outline-none`,
|
|
1044
|
+
{
|
|
1045
|
+
"text-disabled-text border-disabled-outline bg-disabled-background cursor-not-allowed": disabled,
|
|
1046
|
+
"hover:border-primary": !disabled,
|
|
1047
|
+
"bg-input-background": !disabled && !checked,
|
|
1048
|
+
"bg-primary/30 border-primary text-primary": !disabled && (checked || indeterminate)
|
|
1049
|
+
},
|
|
1050
|
+
className
|
|
1051
|
+
),
|
|
1052
|
+
children: /* @__PURE__ */ jsxs3(CheckboxIndicator, { children: [
|
|
1053
|
+
!checked && !indeterminate && /* @__PURE__ */ jsx6("div", { className: clsx2("bg-input-background", innerIconSize) }),
|
|
1054
|
+
checked && !indeterminate && /* @__PURE__ */ jsx6(Check, { className: innerIconSize }),
|
|
1055
|
+
indeterminate && /* @__PURE__ */ jsx6(Minus, { className: innerIconSize })
|
|
1056
|
+
] })
|
|
1057
|
+
}
|
|
1058
|
+
);
|
|
1059
|
+
};
|
|
1060
|
+
var CheckboxUncontrolled = ({
|
|
1061
|
+
checked: initialChecked,
|
|
1062
|
+
onChange,
|
|
1063
|
+
...props
|
|
1064
|
+
}) => {
|
|
1065
|
+
const [checked, setChecked] = useState5(initialChecked);
|
|
1066
|
+
useEffect5(() => {
|
|
1067
|
+
setChecked(initialChecked);
|
|
1068
|
+
}, [initialChecked]);
|
|
1069
|
+
return /* @__PURE__ */ jsx6(
|
|
1070
|
+
Checkbox2,
|
|
1071
|
+
{
|
|
1072
|
+
...props,
|
|
1073
|
+
checked,
|
|
1074
|
+
onChange: (value) => {
|
|
1075
|
+
setChecked(value);
|
|
1076
|
+
if (onChange) {
|
|
1077
|
+
onChange(value);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
);
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1084
|
+
// src/components/user-action/CopyToClipboardWrapper.tsx
|
|
1085
|
+
import { useState as useState8 } from "react";
|
|
1086
|
+
import { clsx as clsx3 } from "clsx";
|
|
1087
|
+
|
|
1088
|
+
// src/localization/defaults/form.ts
|
|
1089
|
+
var formTranslation = {
|
|
1090
|
+
en: {
|
|
1091
|
+
add: "Add",
|
|
1092
|
+
all: "All",
|
|
1093
|
+
apply: "Apply",
|
|
1094
|
+
back: "Back",
|
|
1095
|
+
cancel: "Cancel",
|
|
1096
|
+
change: "Change",
|
|
1097
|
+
clear: "Clear",
|
|
1098
|
+
click: "Click",
|
|
1099
|
+
clickToCopy: "Click to Copy",
|
|
1100
|
+
close: "Close",
|
|
1101
|
+
confirm: "Confirm",
|
|
1102
|
+
copy: "Copy",
|
|
1103
|
+
copied: "Copied",
|
|
1104
|
+
create: "Create",
|
|
1105
|
+
decline: "Decline",
|
|
1106
|
+
delete: "Delete",
|
|
1107
|
+
discard: "Discard",
|
|
1108
|
+
discardChanges: "Discard Changes",
|
|
1109
|
+
done: "Done",
|
|
1110
|
+
edit: "Edit",
|
|
1111
|
+
enterText: "Enter text here",
|
|
1112
|
+
error: "Error",
|
|
1113
|
+
exit: "Exit",
|
|
1114
|
+
fieldRequiredError: "This field is required.",
|
|
1115
|
+
invalidEmailError: "Please enter a valid email address.",
|
|
1116
|
+
less: "Less",
|
|
1117
|
+
loading: "Loading",
|
|
1118
|
+
maxLengthError: "Maximum length exceeded.",
|
|
1119
|
+
minLengthError: "Minimum length not met.",
|
|
1120
|
+
more: "More",
|
|
1121
|
+
next: "Next",
|
|
1122
|
+
no: "No",
|
|
1123
|
+
none: "None",
|
|
1124
|
+
nothingFound: "Nothing found",
|
|
1125
|
+
of: "of",
|
|
1126
|
+
optional: "Optional",
|
|
1127
|
+
pleaseWait: "Please wait...",
|
|
1128
|
+
previous: "Previous",
|
|
1129
|
+
remove: "Remove",
|
|
1130
|
+
required: "Required",
|
|
1131
|
+
reset: "Reset",
|
|
1132
|
+
save: "Save",
|
|
1133
|
+
saved: "Saved",
|
|
1134
|
+
search: "Search",
|
|
1135
|
+
select: "Select",
|
|
1136
|
+
selectOption: "Select an option",
|
|
1137
|
+
show: "Show",
|
|
1138
|
+
showMore: "Show more",
|
|
1139
|
+
showLess: "Show less",
|
|
1140
|
+
submit: "Submit",
|
|
1141
|
+
success: "Success",
|
|
1142
|
+
update: "Update",
|
|
1143
|
+
unsavedChanges: "Unsaved Changes",
|
|
1144
|
+
unsavedChangesSaveQuestion: "Do you want to save your changes?",
|
|
1145
|
+
yes: "Yes"
|
|
1146
|
+
},
|
|
1147
|
+
de: {
|
|
1148
|
+
add: "Hinzuf\xFCgen",
|
|
1149
|
+
all: "Alle",
|
|
1150
|
+
apply: "Anwenden",
|
|
1151
|
+
back: "Zur\xFCck",
|
|
1152
|
+
cancel: "Abbrechen",
|
|
1153
|
+
change: "\xC4ndern",
|
|
1154
|
+
clear: "L\xF6schen",
|
|
1155
|
+
click: "Klicken",
|
|
1156
|
+
clickToCopy: "Zum kopieren klicken",
|
|
1157
|
+
close: "Schlie\xDFen",
|
|
1158
|
+
confirm: "Best\xE4tigen",
|
|
1159
|
+
copy: "Kopieren",
|
|
1160
|
+
copied: "Kopiert",
|
|
1161
|
+
create: "Erstellen",
|
|
1162
|
+
decline: "Ablehnen",
|
|
1163
|
+
delete: "L\xF6schen",
|
|
1164
|
+
discard: "Verwerfen",
|
|
1165
|
+
discardChanges: "\xC4nderungen Verwerfen",
|
|
1166
|
+
done: "Fertig",
|
|
1167
|
+
edit: "Bearbeiten",
|
|
1168
|
+
enterText: "Text hier eingeben",
|
|
1169
|
+
error: "Fehler",
|
|
1170
|
+
exit: "Beenden",
|
|
1171
|
+
fieldRequiredError: "Dieses Feld ist erforderlich.",
|
|
1172
|
+
invalidEmailError: "Bitte geben Sie eine g\xFCltige E-Mail-Adresse ein.",
|
|
1173
|
+
less: "Weniger",
|
|
1174
|
+
loading: "L\xE4dt",
|
|
1175
|
+
maxLengthError: "Maximale L\xE4nge \xFCberschritten.",
|
|
1176
|
+
minLengthError: "Mindestl\xE4nge nicht erreicht.",
|
|
1177
|
+
more: "Mehr",
|
|
1178
|
+
next: "Weiter",
|
|
1179
|
+
no: "Nein",
|
|
1180
|
+
none: "Nichts",
|
|
1181
|
+
nothingFound: "Nichts gefunden",
|
|
1182
|
+
of: "von",
|
|
1183
|
+
optional: "Optional",
|
|
1184
|
+
pleaseWait: "Bitte warten...",
|
|
1185
|
+
previous: "Vorherige",
|
|
1186
|
+
remove: "Entfernen",
|
|
1187
|
+
required: "Erforderlich",
|
|
1188
|
+
reset: "Zur\xFCcksetzen",
|
|
1189
|
+
save: "Speichern",
|
|
1190
|
+
saved: "Gespeichert",
|
|
1191
|
+
search: "Suche",
|
|
1192
|
+
select: "Select",
|
|
1193
|
+
selectOption: "Option ausw\xE4hlen",
|
|
1194
|
+
show: "Anzeigen",
|
|
1195
|
+
showMore: "Mehr anzeigen",
|
|
1196
|
+
showLess: "Weniger anzeigen",
|
|
1197
|
+
submit: "Abschicken",
|
|
1198
|
+
success: "Erfolg",
|
|
1199
|
+
update: "Update",
|
|
1200
|
+
unsavedChanges: "Ungespeicherte \xC4nderungen",
|
|
1201
|
+
unsavedChangesSaveQuestion: "M\xF6chtest du die \xC4nderungen speichern?",
|
|
1202
|
+
yes: "Ja"
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
|
|
1206
|
+
// src/localization/LanguageProvider.tsx
|
|
1207
|
+
import { createContext as createContext2, useContext as useContext2, useEffect as useEffect6, useState as useState7 } from "react";
|
|
1208
|
+
|
|
1209
|
+
// src/hooks/useLocalStorage.ts
|
|
1210
|
+
import { useCallback as useCallback4, useState as useState6 } from "react";
|
|
1211
|
+
|
|
1212
|
+
// src/localization/util.ts
|
|
1213
|
+
var languages = ["en", "de"];
|
|
1214
|
+
var languagesLocalNames = {
|
|
1215
|
+
en: "English",
|
|
1216
|
+
de: "Deutsch"
|
|
1217
|
+
};
|
|
1218
|
+
var DEFAULT_LANGUAGE = "en";
|
|
1219
|
+
var LanguageUtil = {
|
|
1220
|
+
languages,
|
|
1221
|
+
DEFAULT_LANGUAGE,
|
|
1222
|
+
languagesLocalNames
|
|
1223
|
+
};
|
|
1224
|
+
|
|
1225
|
+
// src/localization/LanguageProvider.tsx
|
|
1226
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1227
|
+
var LanguageContext = createContext2({
|
|
1228
|
+
language: LanguageUtil.DEFAULT_LANGUAGE,
|
|
1229
|
+
setLanguage: (v) => v
|
|
1230
|
+
});
|
|
1231
|
+
var useLanguage = () => useContext2(LanguageContext);
|
|
1232
|
+
var useLocale = (overWriteLanguage) => {
|
|
1233
|
+
const { language } = useLanguage();
|
|
1234
|
+
const mapping = {
|
|
1235
|
+
en: "en-US",
|
|
1236
|
+
de: "de-DE"
|
|
1237
|
+
};
|
|
1238
|
+
return mapping[overWriteLanguage ?? language];
|
|
1239
|
+
};
|
|
1240
|
+
|
|
1241
|
+
// src/localization/useTranslation.ts
|
|
1242
|
+
var TranslationPluralCount = {
|
|
1243
|
+
zero: 0,
|
|
1244
|
+
one: 1,
|
|
1245
|
+
two: 2,
|
|
1246
|
+
few: 3,
|
|
1247
|
+
many: 11,
|
|
1248
|
+
other: -1
|
|
1249
|
+
};
|
|
1250
|
+
var useTranslation = (translations, overwriteTranslation = {}) => {
|
|
1251
|
+
const { language: languageProp, translation: overwrite } = overwriteTranslation;
|
|
1252
|
+
const { language: inferredLanguage } = useLanguage();
|
|
1253
|
+
const usedLanguage = languageProp ?? inferredLanguage;
|
|
1254
|
+
const usedTranslations = [...translations];
|
|
1255
|
+
if (overwrite) {
|
|
1256
|
+
usedTranslations.push(overwrite);
|
|
1257
|
+
}
|
|
1258
|
+
return (key, options) => {
|
|
1259
|
+
const { count, replacements } = { ...{ count: 0, replacements: {} }, ...options };
|
|
1260
|
+
try {
|
|
1261
|
+
for (let i = translations.length - 1; i >= 0; i--) {
|
|
1262
|
+
const translation = translations[i];
|
|
1263
|
+
const localizedTranslation = translation[usedLanguage];
|
|
1264
|
+
if (!localizedTranslation) {
|
|
1265
|
+
continue;
|
|
1266
|
+
}
|
|
1267
|
+
const value = localizedTranslation[key];
|
|
1268
|
+
if (!value) {
|
|
1269
|
+
continue;
|
|
1270
|
+
}
|
|
1271
|
+
let forProcessing;
|
|
1272
|
+
if (typeof value !== "string") {
|
|
1273
|
+
if (count === TranslationPluralCount.zero && value?.zero) {
|
|
1274
|
+
forProcessing = value.zero;
|
|
1275
|
+
} else if (count === TranslationPluralCount.one && value?.one) {
|
|
1276
|
+
forProcessing = value.one;
|
|
1277
|
+
} else if (count === TranslationPluralCount.two && value?.two) {
|
|
1278
|
+
forProcessing = value.two;
|
|
1279
|
+
} else if (TranslationPluralCount.few <= count && count < TranslationPluralCount.many && value?.few) {
|
|
1280
|
+
forProcessing = value.few;
|
|
1281
|
+
} else if (count > TranslationPluralCount.many && value?.many) {
|
|
1282
|
+
forProcessing = value.many;
|
|
1283
|
+
} else {
|
|
1284
|
+
forProcessing = value.other;
|
|
1285
|
+
}
|
|
1286
|
+
} else {
|
|
1287
|
+
forProcessing = value;
|
|
1288
|
+
}
|
|
1289
|
+
forProcessing = forProcessing.replace(/\{\{(\w+)}}/g, (_, placeholder) => {
|
|
1290
|
+
return replacements[placeholder] ?? `{{key:${placeholder}}}`;
|
|
1291
|
+
});
|
|
1292
|
+
return forProcessing;
|
|
1293
|
+
}
|
|
1294
|
+
} catch (e) {
|
|
1295
|
+
console.error(e);
|
|
1296
|
+
}
|
|
1297
|
+
return `{{${usedLanguage}:${key}}}`;
|
|
1298
|
+
};
|
|
1299
|
+
};
|
|
1300
|
+
|
|
1301
|
+
// src/utils/writeToClipboard.ts
|
|
1302
|
+
var writeToClipboard = (text) => {
|
|
1303
|
+
return navigator.clipboard.writeText(text);
|
|
1304
|
+
};
|
|
1305
|
+
|
|
1306
|
+
// src/components/user-action/CopyToClipboardWrapper.tsx
|
|
1307
|
+
import { CheckIcon, Copy } from "lucide-react";
|
|
1308
|
+
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1309
|
+
var CopyToClipboardWrapper = ({
|
|
1310
|
+
children,
|
|
1311
|
+
textToCopy,
|
|
1312
|
+
tooltipClassName = "",
|
|
1313
|
+
containerClassName = "",
|
|
1314
|
+
position = "bottom",
|
|
1315
|
+
zIndex = 10
|
|
1316
|
+
}) => {
|
|
1317
|
+
const translation = useTranslation([formTranslation]);
|
|
1318
|
+
const [isShowingIndication, setIsShowingIndication] = useState8(false);
|
|
1319
|
+
const [isShowingConfirmation, setIsShowingConfirmation] = useState8(false);
|
|
1320
|
+
const positionClasses = {
|
|
1321
|
+
top: `bottom-full left-1/2 -translate-x-1/2 mb-[6px]`,
|
|
1322
|
+
bottom: `top-full left-1/2 -translate-x-1/2 mt-[6px]`,
|
|
1323
|
+
left: `right-full top-1/2 -translate-y-1/2 mr-[6px]`,
|
|
1324
|
+
right: `left-full top-1/2 -translate-y-1/2 ml-[6px]`
|
|
1325
|
+
};
|
|
1326
|
+
const triangleSize = 6;
|
|
1327
|
+
const triangleClasses = {
|
|
1328
|
+
top: `top-full left-1/2 -translate-x-1/2 border-t-tooltip-background border-l-transparent border-r-transparent`,
|
|
1329
|
+
bottom: `bottom-full left-1/2 -translate-x-1/2 border-b-tooltip-background border-l-transparent border-r-transparent`,
|
|
1330
|
+
left: `left-full top-1/2 -translate-y-1/2 border-l-tooltip-background border-t-transparent border-b-transparent`,
|
|
1331
|
+
right: `right-full top-1/2 -translate-y-1/2 border-r-tooltip-background border-t-transparent border-b-transparent`
|
|
1332
|
+
};
|
|
1333
|
+
const triangleStyle = {
|
|
1334
|
+
top: { borderWidth: `${triangleSize}px ${triangleSize}px 0 ${triangleSize}px` },
|
|
1335
|
+
bottom: { borderWidth: `0 ${triangleSize}px ${triangleSize}px ${triangleSize}px` },
|
|
1336
|
+
left: { borderWidth: `${triangleSize}px 0 ${triangleSize}px ${triangleSize}px` },
|
|
1337
|
+
right: { borderWidth: `${triangleSize}px ${triangleSize}px ${triangleSize}px 0` }
|
|
1338
|
+
};
|
|
1339
|
+
return /* @__PURE__ */ jsxs4(
|
|
1340
|
+
"div",
|
|
1341
|
+
{
|
|
1342
|
+
className: clsx3("relative inline-block cursor-copy", containerClassName),
|
|
1343
|
+
onMouseEnter: () => {
|
|
1344
|
+
setIsShowingIndication(true);
|
|
1345
|
+
},
|
|
1346
|
+
onMouseLeave: () => {
|
|
1347
|
+
setIsShowingIndication(false);
|
|
1348
|
+
setIsShowingConfirmation(false);
|
|
1349
|
+
},
|
|
1350
|
+
onClick: () => {
|
|
1351
|
+
writeToClipboard(textToCopy).catch(console.error);
|
|
1352
|
+
setIsShowingIndication(false);
|
|
1353
|
+
setIsShowingConfirmation(true);
|
|
1354
|
+
},
|
|
1355
|
+
children: [
|
|
1356
|
+
children,
|
|
1357
|
+
/* @__PURE__ */ jsxs4(
|
|
1358
|
+
"div",
|
|
1359
|
+
{
|
|
1360
|
+
className: clsx3(
|
|
1361
|
+
`absolute text-xs font-semibold text-tooltip-text px-2 py-1 rounded whitespace-nowrap
|
|
1362
|
+
shadow-around-md bg-tooltip-background cursor-default pointer-events-none`,
|
|
1363
|
+
"transition-opacity duration-200",
|
|
1364
|
+
positionClasses[position],
|
|
1365
|
+
tooltipClassName
|
|
1366
|
+
),
|
|
1367
|
+
style: {
|
|
1368
|
+
zIndex,
|
|
1369
|
+
opacity: isShowingIndication || isShowingConfirmation ? 1 : 0
|
|
1370
|
+
},
|
|
1371
|
+
children: [
|
|
1372
|
+
isShowingConfirmation && /* @__PURE__ */ jsxs4("div", { className: "flex-row-1", children: [
|
|
1373
|
+
/* @__PURE__ */ jsx8(CheckIcon, { size: 16, className: "text-positive" }),
|
|
1374
|
+
translation("copied")
|
|
1375
|
+
] }),
|
|
1376
|
+
isShowingIndication && /* @__PURE__ */ jsxs4("div", { className: "flex-row-1 text-description", children: [
|
|
1377
|
+
/* @__PURE__ */ jsx8(Copy, { size: 16 }),
|
|
1378
|
+
translation("clickToCopy")
|
|
1379
|
+
] }),
|
|
1380
|
+
/* @__PURE__ */ jsx8(
|
|
1381
|
+
"div",
|
|
1382
|
+
{
|
|
1383
|
+
className: clsx3(`absolute w-0 h-0`, triangleClasses[position]),
|
|
1384
|
+
style: { ...triangleStyle[position], zIndex: zIndex + 1 }
|
|
1385
|
+
}
|
|
1386
|
+
)
|
|
1387
|
+
]
|
|
1388
|
+
}
|
|
1389
|
+
)
|
|
1390
|
+
]
|
|
1391
|
+
}
|
|
1392
|
+
);
|
|
1393
|
+
};
|
|
1394
|
+
|
|
1395
|
+
// src/components/user-action/DateAndTimePicker.tsx
|
|
1396
|
+
import clsx9 from "clsx";
|
|
1397
|
+
|
|
1398
|
+
// src/utils/noop.ts
|
|
1399
|
+
var noop = () => void 0;
|
|
1400
|
+
|
|
1401
|
+
// src/utils/array.ts
|
|
1402
|
+
var equalSizeGroups = (array, groupSize) => {
|
|
1403
|
+
if (groupSize <= 0) {
|
|
1404
|
+
console.warn(`group size should be greater than 0: groupSize = ${groupSize}`);
|
|
1405
|
+
return [[...array]];
|
|
1406
|
+
}
|
|
1407
|
+
const groups = [];
|
|
1408
|
+
for (let i = 0; i < array.length; i += groupSize) {
|
|
1409
|
+
groups.push(array.slice(i, Math.min(i + groupSize, array.length)));
|
|
1410
|
+
}
|
|
1411
|
+
return groups;
|
|
1412
|
+
};
|
|
1413
|
+
var defaultRangeOptions = {
|
|
1414
|
+
allowEmptyRange: false,
|
|
1415
|
+
stepSize: 1,
|
|
1416
|
+
exclusiveStart: false,
|
|
1417
|
+
exclusiveEnd: true
|
|
1418
|
+
};
|
|
1419
|
+
var range = (endOrRange, options) => {
|
|
1420
|
+
const { allowEmptyRange, stepSize, exclusiveStart, exclusiveEnd } = { ...defaultRangeOptions, ...options };
|
|
1421
|
+
let start = 0;
|
|
1422
|
+
let end;
|
|
1423
|
+
if (typeof endOrRange === "number") {
|
|
1424
|
+
end = endOrRange;
|
|
1425
|
+
} else {
|
|
1426
|
+
start = endOrRange[0];
|
|
1427
|
+
end = endOrRange[1];
|
|
1428
|
+
}
|
|
1429
|
+
if (!exclusiveEnd) {
|
|
1430
|
+
end -= 1;
|
|
1431
|
+
}
|
|
1432
|
+
if (exclusiveStart) {
|
|
1433
|
+
start += 1;
|
|
1434
|
+
}
|
|
1435
|
+
if (end - 1 < start) {
|
|
1436
|
+
if (!allowEmptyRange) {
|
|
1437
|
+
console.warn(`range: end (${end}) < start (${start}) should be allowed explicitly, set options.allowEmptyRange to true`);
|
|
1438
|
+
}
|
|
1439
|
+
return [];
|
|
1440
|
+
}
|
|
1441
|
+
return Array.from({ length: end - start }, (_, index) => index * stepSize + start);
|
|
1442
|
+
};
|
|
1443
|
+
var closestMatch = (list, firstCloser) => {
|
|
1444
|
+
return list.reduce((item1, item2) => {
|
|
1445
|
+
return firstCloser(item1, item2) ? item1 : item2;
|
|
1446
|
+
});
|
|
1447
|
+
};
|
|
1448
|
+
var getNeighbours = (list, item, neighbourDistance = 2) => {
|
|
1449
|
+
const index = list.indexOf(item);
|
|
1450
|
+
const totalItems = neighbourDistance * 2 + 1;
|
|
1451
|
+
if (list.length < totalItems) {
|
|
1452
|
+
console.warn("List is to short");
|
|
1453
|
+
return list;
|
|
1454
|
+
}
|
|
1455
|
+
if (index === -1) {
|
|
1456
|
+
console.error("item not found in list");
|
|
1457
|
+
return list.splice(0, totalItems);
|
|
1458
|
+
}
|
|
1459
|
+
let start = index - neighbourDistance;
|
|
1460
|
+
if (start < 0) {
|
|
1461
|
+
start += list.length;
|
|
1462
|
+
}
|
|
1463
|
+
const end = (index + neighbourDistance + 1) % list.length;
|
|
1464
|
+
const result = [];
|
|
1465
|
+
let ignoreOnce = list.length === totalItems;
|
|
1466
|
+
for (let i = start; i !== end || ignoreOnce; i = (i + 1) % list.length) {
|
|
1467
|
+
result.push(list[i]);
|
|
1468
|
+
if (end === i && ignoreOnce) {
|
|
1469
|
+
ignoreOnce = false;
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
return result;
|
|
1473
|
+
};
|
|
1474
|
+
|
|
1475
|
+
// src/utils/date.ts
|
|
1476
|
+
var monthsList = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
|
|
1477
|
+
var weekDayList = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
|
|
1478
|
+
var changeDuration = (date, duration, isAdding) => {
|
|
1479
|
+
const {
|
|
1480
|
+
years = 0,
|
|
1481
|
+
months = 0,
|
|
1482
|
+
days = 0,
|
|
1483
|
+
hours = 0,
|
|
1484
|
+
minutes = 0,
|
|
1485
|
+
seconds = 0,
|
|
1486
|
+
milliseconds = 0
|
|
1487
|
+
} = duration;
|
|
1488
|
+
if (years < 0) {
|
|
1489
|
+
console.error(`Range error years must be greater than 0: received ${years}`);
|
|
1490
|
+
return new Date(date);
|
|
1491
|
+
}
|
|
1492
|
+
if (months < 0 || months > 11) {
|
|
1493
|
+
console.error(`Range error month must be 0 <= month <= 11: received ${months}`);
|
|
1494
|
+
return new Date(date);
|
|
1495
|
+
}
|
|
1496
|
+
if (days < 0) {
|
|
1497
|
+
console.error(`Range error days must be greater than 0: received ${days}`);
|
|
1498
|
+
return new Date(date);
|
|
1499
|
+
}
|
|
1500
|
+
if (hours < 0 || hours > 23) {
|
|
1501
|
+
console.error(`Range error hours must be 0 <= hours <= 23: received ${hours}`);
|
|
1502
|
+
return new Date(date);
|
|
1503
|
+
}
|
|
1504
|
+
if (minutes < 0 || minutes > 59) {
|
|
1505
|
+
console.error(`Range error minutes must be 0 <= minutes <= 59: received ${minutes}`);
|
|
1506
|
+
return new Date(date);
|
|
1507
|
+
}
|
|
1508
|
+
if (seconds < 0 || seconds > 59) {
|
|
1509
|
+
console.error(`Range error seconds must be 0 <= seconds <= 59: received ${seconds}`);
|
|
1510
|
+
return new Date(date);
|
|
1511
|
+
}
|
|
1512
|
+
if (milliseconds < 0) {
|
|
1513
|
+
console.error(`Range error seconds must be greater than 0: received ${milliseconds}`);
|
|
1514
|
+
return new Date(date);
|
|
1515
|
+
}
|
|
1516
|
+
const multiplier = isAdding ? 1 : -1;
|
|
1517
|
+
const newDate = new Date(date);
|
|
1518
|
+
newDate.setFullYear(newDate.getFullYear() + multiplier * years);
|
|
1519
|
+
newDate.setMonth(newDate.getMonth() + multiplier * months);
|
|
1520
|
+
newDate.setDate(newDate.getDate() + multiplier * days);
|
|
1521
|
+
newDate.setHours(newDate.getHours() + multiplier * hours);
|
|
1522
|
+
newDate.setMinutes(newDate.getMinutes() + multiplier * minutes);
|
|
1523
|
+
newDate.setSeconds(newDate.getSeconds() + multiplier * seconds);
|
|
1524
|
+
newDate.setMilliseconds(newDate.getMilliseconds() + multiplier * milliseconds);
|
|
1525
|
+
return newDate;
|
|
1526
|
+
};
|
|
1527
|
+
var addDuration = (date, duration) => {
|
|
1528
|
+
return changeDuration(date, duration, true);
|
|
1529
|
+
};
|
|
1530
|
+
var subtractDuration = (date, duration) => {
|
|
1531
|
+
return changeDuration(date, duration, false);
|
|
1532
|
+
};
|
|
1533
|
+
var isInTimeSpan = (value, startDate, endDate) => {
|
|
1534
|
+
if (startDate && endDate) {
|
|
1535
|
+
console.assert(startDate <= endDate);
|
|
1536
|
+
return startDate <= value && value <= endDate;
|
|
1537
|
+
} else if (startDate) {
|
|
1538
|
+
return startDate <= value;
|
|
1539
|
+
} else if (endDate) {
|
|
1540
|
+
return endDate >= value;
|
|
1541
|
+
} else {
|
|
1542
|
+
return true;
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
var equalDate = (date1, date2) => {
|
|
1546
|
+
return date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth() && date1.getDate() === date2.getDate();
|
|
1547
|
+
};
|
|
1548
|
+
var getWeeksForCalenderMonth = (date, weekStart, weeks = 6) => {
|
|
1549
|
+
const month = date.getMonth();
|
|
1550
|
+
const year = date.getFullYear();
|
|
1551
|
+
const dayList = [];
|
|
1552
|
+
let currentDate = new Date(year, month, 1);
|
|
1553
|
+
const weekStartIndex = weekDayList.indexOf(weekStart);
|
|
1554
|
+
while (currentDate.getDay() !== weekStartIndex) {
|
|
1555
|
+
currentDate = subtractDuration(currentDate, { days: 1 });
|
|
1556
|
+
}
|
|
1557
|
+
while (dayList.length < 7 * weeks) {
|
|
1558
|
+
const date2 = new Date(currentDate);
|
|
1559
|
+
date2.setHours(date2.getHours(), date2.getMinutes());
|
|
1560
|
+
dayList.push(date2);
|
|
1561
|
+
currentDate = addDuration(currentDate, { days: 1 });
|
|
1562
|
+
}
|
|
1563
|
+
return equalSizeGroups(dayList, 7);
|
|
1564
|
+
};
|
|
1565
|
+
|
|
1566
|
+
// src/components/date/TimePicker.tsx
|
|
1567
|
+
import { useEffect as useEffect7, useRef as useRef6, useState as useState9 } from "react";
|
|
1568
|
+
import { Scrollbars } from "react-custom-scrollbars-2";
|
|
1569
|
+
import clsx4 from "clsx";
|
|
1570
|
+
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1571
|
+
var TimePicker = ({
|
|
1572
|
+
time = /* @__PURE__ */ new Date(),
|
|
1573
|
+
onChange = noop,
|
|
1574
|
+
is24HourFormat = true,
|
|
1575
|
+
minuteIncrement = "5min",
|
|
1576
|
+
maxHeight = 300,
|
|
1577
|
+
className = ""
|
|
1578
|
+
}) => {
|
|
1579
|
+
const minuteRef = useRef6(null);
|
|
1580
|
+
const hourRef = useRef6(null);
|
|
1581
|
+
const isPM = time.getHours() >= 11;
|
|
1582
|
+
const hours = is24HourFormat ? range(24) : range([1, 12], { exclusiveEnd: false });
|
|
1583
|
+
let minutes = range(60);
|
|
1584
|
+
useEffect7(() => {
|
|
1585
|
+
const scrollToItem = () => {
|
|
1586
|
+
if (minuteRef.current) {
|
|
1587
|
+
const container = minuteRef.current.parentElement;
|
|
1588
|
+
const hasOverflow = container.scrollHeight > maxHeight;
|
|
1589
|
+
if (hasOverflow) {
|
|
1590
|
+
minuteRef.current.scrollIntoView({
|
|
1591
|
+
behavior: "instant",
|
|
1592
|
+
block: "nearest"
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
};
|
|
1597
|
+
scrollToItem();
|
|
1598
|
+
}, [minuteRef, minuteRef.current]);
|
|
1599
|
+
useEffect7(() => {
|
|
1600
|
+
const scrollToItem = () => {
|
|
1601
|
+
if (hourRef.current) {
|
|
1602
|
+
const container = hourRef.current.parentElement;
|
|
1603
|
+
const hasOverflow = container.scrollHeight > maxHeight;
|
|
1604
|
+
if (hasOverflow) {
|
|
1605
|
+
hourRef.current.scrollIntoView({
|
|
1606
|
+
behavior: "instant",
|
|
1607
|
+
block: "nearest"
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
};
|
|
1612
|
+
scrollToItem();
|
|
1613
|
+
}, [hourRef, hourRef.current]);
|
|
1614
|
+
switch (minuteIncrement) {
|
|
1615
|
+
case "5min":
|
|
1616
|
+
minutes = minutes.filter((value) => value % 5 === 0);
|
|
1617
|
+
break;
|
|
1618
|
+
case "10min":
|
|
1619
|
+
minutes = minutes.filter((value) => value % 10 === 0);
|
|
1620
|
+
break;
|
|
1621
|
+
case "15min":
|
|
1622
|
+
minutes = minutes.filter((value) => value % 15 === 0);
|
|
1623
|
+
break;
|
|
1624
|
+
case "30min":
|
|
1625
|
+
minutes = minutes.filter((value) => value % 30 === 0);
|
|
1626
|
+
break;
|
|
1627
|
+
}
|
|
1628
|
+
const closestMinute = closestMatch(minutes, (item1, item2) => Math.abs(item1 - time.getMinutes()) < Math.abs(item2 - time.getMinutes()));
|
|
1629
|
+
const style = (selected) => clsx4(
|
|
1630
|
+
"chip-full hover:brightness-90 hover:bg-primary hover:text-on-primary rounded-md mr-3",
|
|
1631
|
+
{ "bg-primary text-on-primary": selected, "bg-white text-black": !selected }
|
|
1632
|
+
);
|
|
1633
|
+
const onChangeWrapper = (transformer) => {
|
|
1634
|
+
const newDate = new Date(time);
|
|
1635
|
+
transformer(newDate);
|
|
1636
|
+
onChange(newDate);
|
|
1637
|
+
};
|
|
1638
|
+
return /* @__PURE__ */ jsxs5("div", { className: clsx4("flex-row-2 w-fit min-w-[150px] select-none", className), children: [
|
|
1639
|
+
/* @__PURE__ */ jsx9(Scrollbars, { autoHeight: true, autoHeightMax: maxHeight, style: { height: "100%" }, children: /* @__PURE__ */ jsx9("div", { className: "flex-col-1 h-full", children: hours.map((hour) => {
|
|
1640
|
+
const currentHour = hour === time.getHours() - (!is24HourFormat && isPM ? 12 : 0);
|
|
1641
|
+
return /* @__PURE__ */ jsx9(
|
|
1642
|
+
"button",
|
|
1643
|
+
{
|
|
1644
|
+
ref: currentHour ? hourRef : void 0,
|
|
1645
|
+
className: style(currentHour),
|
|
1646
|
+
onClick: () => onChangeWrapper((newDate) => newDate.setHours(hour + (!is24HourFormat && isPM ? 12 : 0))),
|
|
1647
|
+
children: hour.toString().padStart(2, "0")
|
|
1648
|
+
},
|
|
1649
|
+
hour
|
|
1650
|
+
);
|
|
1651
|
+
}) }) }),
|
|
1652
|
+
/* @__PURE__ */ jsx9(Scrollbars, { autoHeight: true, autoHeightMax: maxHeight, style: { height: "100%" }, children: /* @__PURE__ */ jsx9("div", { className: "flex-col-1 h-full", children: minutes.map((minute) => {
|
|
1653
|
+
const currentMinute = minute === closestMinute;
|
|
1654
|
+
return /* @__PURE__ */ jsx9(
|
|
1655
|
+
"button",
|
|
1656
|
+
{
|
|
1657
|
+
ref: currentMinute ? minuteRef : void 0,
|
|
1658
|
+
className: style(currentMinute),
|
|
1659
|
+
onClick: () => onChangeWrapper((newDate) => newDate.setMinutes(minute)),
|
|
1660
|
+
children: minute.toString().padStart(2, "0")
|
|
1661
|
+
},
|
|
1662
|
+
minute + minuteIncrement
|
|
1663
|
+
);
|
|
1664
|
+
}) }) }),
|
|
1665
|
+
!is24HourFormat && /* @__PURE__ */ jsxs5("div", { className: "flex-col-1", children: [
|
|
1666
|
+
/* @__PURE__ */ jsx9(
|
|
1667
|
+
"button",
|
|
1668
|
+
{
|
|
1669
|
+
className: style(!isPM),
|
|
1670
|
+
onClick: () => onChangeWrapper((newDate) => isPM && newDate.setHours(newDate.getHours() - 12)),
|
|
1671
|
+
children: "AM"
|
|
1672
|
+
}
|
|
1673
|
+
),
|
|
1674
|
+
/* @__PURE__ */ jsx9(
|
|
1675
|
+
"button",
|
|
1676
|
+
{
|
|
1677
|
+
className: style(isPM),
|
|
1678
|
+
onClick: () => onChangeWrapper((newDate) => !isPM && newDate.setHours(newDate.getHours() + 12)),
|
|
1679
|
+
children: "PM"
|
|
1680
|
+
}
|
|
1681
|
+
)
|
|
1682
|
+
] })
|
|
1683
|
+
] });
|
|
1684
|
+
};
|
|
1685
|
+
|
|
1686
|
+
// src/components/date/DatePicker.tsx
|
|
1687
|
+
import { useEffect as useEffect11, useState as useState13 } from "react";
|
|
1688
|
+
import { ArrowDown, ArrowUp, ChevronDown as ChevronDown2 } from "lucide-react";
|
|
1689
|
+
import clsx8 from "clsx";
|
|
1690
|
+
|
|
1691
|
+
// src/components/date/YearMonthPicker.tsx
|
|
1692
|
+
import { useEffect as useEffect9, useRef as useRef7, useState as useState11 } from "react";
|
|
1693
|
+
import { Scrollbars as Scrollbars2 } from "react-custom-scrollbars-2";
|
|
1694
|
+
import clsx6 from "clsx";
|
|
1695
|
+
|
|
1696
|
+
// src/components/layout/Expandable.tsx
|
|
1697
|
+
import { forwardRef as forwardRef5, useCallback as useCallback5, useEffect as useEffect8, useId, useState as useState10 } from "react";
|
|
1698
|
+
import { ChevronDown } from "lucide-react";
|
|
1699
|
+
import clsx5 from "clsx";
|
|
1700
|
+
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1701
|
+
var ExpansionIcon = ({ isExpanded, className }) => {
|
|
1702
|
+
return /* @__PURE__ */ jsx10(
|
|
1703
|
+
ChevronDown,
|
|
1704
|
+
{
|
|
1705
|
+
"aria-hidden": true,
|
|
1706
|
+
className: clsx5(
|
|
1707
|
+
"min-w-6 w-6 min-h-6 h-6 transition-transform motion-safe:duration-200 motion-reduce:duration-0 ease-in-out",
|
|
1708
|
+
{ "rotate-180": isExpanded },
|
|
1709
|
+
className
|
|
1710
|
+
)
|
|
1711
|
+
}
|
|
1712
|
+
);
|
|
1713
|
+
};
|
|
1714
|
+
var Expandable = forwardRef5(function Expandable2({
|
|
1715
|
+
children,
|
|
1716
|
+
id: providedId,
|
|
1717
|
+
label,
|
|
1718
|
+
icon,
|
|
1719
|
+
isExpanded = false,
|
|
1720
|
+
onChange = noop,
|
|
1721
|
+
clickOnlyOnHeader = true,
|
|
1722
|
+
disabled = false,
|
|
1723
|
+
className,
|
|
1724
|
+
headerClassName,
|
|
1725
|
+
contentClassName,
|
|
1726
|
+
contentExpandedClassName
|
|
1727
|
+
}, ref) {
|
|
1728
|
+
const defaultIcon = useCallback5((expanded) => /* @__PURE__ */ jsx10(ExpansionIcon, { isExpanded: expanded }), []);
|
|
1729
|
+
icon ??= defaultIcon;
|
|
1730
|
+
const generatedId = useId();
|
|
1731
|
+
const id = providedId ?? generatedId;
|
|
1732
|
+
return /* @__PURE__ */ jsxs6(
|
|
1733
|
+
"div",
|
|
1734
|
+
{
|
|
1735
|
+
ref,
|
|
1736
|
+
onClick: () => !clickOnlyOnHeader && !disabled && onChange(!isExpanded),
|
|
1737
|
+
className: clsx5(
|
|
1738
|
+
"flex-col-0 bg-surface text-on-surface group rounded-lg shadow-sm",
|
|
1739
|
+
{ "cursor-pointer": !clickOnlyOnHeader && !disabled },
|
|
1740
|
+
className
|
|
1741
|
+
),
|
|
1742
|
+
children: [
|
|
1743
|
+
/* @__PURE__ */ jsxs6(
|
|
1744
|
+
"button",
|
|
1745
|
+
{
|
|
1746
|
+
onClick: () => clickOnlyOnHeader && !disabled && onChange(!isExpanded),
|
|
1747
|
+
className: clsx5(
|
|
1748
|
+
"flex-row-2 py-2 px-4 rounded-lg justify-between items-center bg-surface text-on-surface select-none",
|
|
1749
|
+
{
|
|
1750
|
+
"group-hover:brightness-97": !isExpanded,
|
|
1751
|
+
"hover:brightness-97": isExpanded && !disabled,
|
|
1752
|
+
"cursor-pointer": clickOnlyOnHeader && !disabled
|
|
1753
|
+
},
|
|
1754
|
+
headerClassName
|
|
1755
|
+
),
|
|
1756
|
+
"aria-expanded": isExpanded,
|
|
1757
|
+
"aria-controls": `${id}-content`,
|
|
1758
|
+
"aria-disabled": disabled ?? void 0,
|
|
1759
|
+
children: [
|
|
1760
|
+
label,
|
|
1761
|
+
icon(isExpanded)
|
|
1762
|
+
]
|
|
1763
|
+
}
|
|
1764
|
+
),
|
|
1765
|
+
/* @__PURE__ */ jsx10(
|
|
1766
|
+
"div",
|
|
1767
|
+
{
|
|
1768
|
+
id: `${id}-content`,
|
|
1769
|
+
className: clsx5(
|
|
1770
|
+
"flex-col-2 px-4 transition-all duration-300 ease-in-out",
|
|
1771
|
+
{
|
|
1772
|
+
[clsx5("max-h-96 opacity-100 pb-2 overflow-y-auto", contentExpandedClassName)]: isExpanded,
|
|
1773
|
+
"max-h-0 opacity-0 overflow-hidden": !isExpanded
|
|
1774
|
+
},
|
|
1775
|
+
contentClassName
|
|
1776
|
+
),
|
|
1777
|
+
role: "region",
|
|
1778
|
+
children
|
|
1779
|
+
}
|
|
1780
|
+
)
|
|
1781
|
+
]
|
|
1782
|
+
}
|
|
1783
|
+
);
|
|
1784
|
+
});
|
|
1785
|
+
var ExpandableUncontrolled = forwardRef5(function ExpandableUncontrolled2({
|
|
1786
|
+
isExpanded,
|
|
1787
|
+
onChange = noop,
|
|
1788
|
+
...props
|
|
1789
|
+
}, ref) {
|
|
1790
|
+
const [usedIsExpanded, setUsedIsExpanded] = useState10(isExpanded);
|
|
1791
|
+
useEffect8(() => {
|
|
1792
|
+
setUsedIsExpanded(isExpanded);
|
|
1793
|
+
}, [isExpanded]);
|
|
1794
|
+
return /* @__PURE__ */ jsx10(
|
|
1795
|
+
Expandable,
|
|
1796
|
+
{
|
|
1797
|
+
...props,
|
|
1798
|
+
ref,
|
|
1799
|
+
isExpanded: usedIsExpanded,
|
|
1800
|
+
onChange: (value) => {
|
|
1801
|
+
onChange(value);
|
|
1802
|
+
setUsedIsExpanded(value);
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
);
|
|
1806
|
+
});
|
|
1807
|
+
|
|
1808
|
+
// src/components/date/YearMonthPicker.tsx
|
|
1809
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1810
|
+
var YearMonthPicker = ({
|
|
1811
|
+
displayedYearMonth = /* @__PURE__ */ new Date(),
|
|
1812
|
+
start = subtractDuration(/* @__PURE__ */ new Date(), { years: 50 }),
|
|
1813
|
+
end = addDuration(/* @__PURE__ */ new Date(), { years: 50 }),
|
|
1814
|
+
onChange = noop,
|
|
1815
|
+
className = "",
|
|
1816
|
+
maxHeight = 300,
|
|
1817
|
+
showValueOpen = true
|
|
1818
|
+
}) => {
|
|
1819
|
+
const locale = useLocale();
|
|
1820
|
+
const ref = useRef7(null);
|
|
1821
|
+
useEffect9(() => {
|
|
1822
|
+
const scrollToItem = () => {
|
|
1823
|
+
if (ref.current) {
|
|
1824
|
+
ref.current.scrollIntoView({
|
|
1825
|
+
behavior: "instant",
|
|
1826
|
+
block: "center"
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
scrollToItem();
|
|
1831
|
+
}, [ref]);
|
|
1832
|
+
if (end < start) {
|
|
1833
|
+
console.error(`startYear: (${start}) less than endYear: (${end})`);
|
|
1834
|
+
return null;
|
|
1835
|
+
}
|
|
1836
|
+
const years = range([start.getFullYear(), end.getFullYear()], { exclusiveEnd: false });
|
|
1837
|
+
return /* @__PURE__ */ jsx11("div", { className: clsx6("flex-col-0 select-none", className), children: /* @__PURE__ */ jsx11(Scrollbars2, { autoHeight: true, autoHeightMax: maxHeight, style: { height: "100%" }, children: /* @__PURE__ */ jsx11("div", { className: "flex-col-1 mr-3", children: years.map((year) => {
|
|
1838
|
+
const selectedYear = displayedYearMonth.getFullYear() === year;
|
|
1839
|
+
return /* @__PURE__ */ jsx11(
|
|
1840
|
+
ExpandableUncontrolled,
|
|
1841
|
+
{
|
|
1842
|
+
ref: (displayedYearMonth.getFullYear() ?? (/* @__PURE__ */ new Date()).getFullYear()) === year ? ref : void 0,
|
|
1843
|
+
label: /* @__PURE__ */ jsx11("span", { className: clsx6({ "text-primary font-bold": selectedYear }), children: year }),
|
|
1844
|
+
isExpanded: showValueOpen && selectedYear,
|
|
1845
|
+
contentClassName: "gap-y-1",
|
|
1846
|
+
children: equalSizeGroups([...monthsList], 3).map((monthList, index) => /* @__PURE__ */ jsx11("div", { className: "flex-row-1", children: monthList.map((month) => {
|
|
1847
|
+
const monthIndex = monthsList.indexOf(month);
|
|
1848
|
+
const newDate = new Date(year, monthIndex);
|
|
1849
|
+
const selectedMonth = selectedYear && monthIndex === displayedYearMonth.getMonth();
|
|
1850
|
+
const firstOfMonth = new Date(year, monthIndex, 1);
|
|
1851
|
+
const lastOfMonth = new Date(year, monthIndex, 1);
|
|
1852
|
+
const isAfterStart = start === void 0 || start <= addDuration(subtractDuration(lastOfMonth, { days: 1 }), { months: 1 });
|
|
1853
|
+
const isBeforeEnd = end === void 0 || firstOfMonth <= end;
|
|
1854
|
+
const isValid = isAfterStart && isBeforeEnd;
|
|
1855
|
+
return /* @__PURE__ */ jsx11(
|
|
1856
|
+
SolidButton,
|
|
1857
|
+
{
|
|
1858
|
+
disabled: !isValid,
|
|
1859
|
+
color: selectedMonth && isValid ? "primary" : "neutral",
|
|
1860
|
+
className: "flex-1",
|
|
1861
|
+
size: "small",
|
|
1862
|
+
onClick: () => {
|
|
1863
|
+
onChange(newDate);
|
|
1864
|
+
},
|
|
1865
|
+
children: new Intl.DateTimeFormat(locale, { month: "short" }).format(newDate)
|
|
1866
|
+
},
|
|
1867
|
+
month
|
|
1868
|
+
);
|
|
1869
|
+
}) }, index))
|
|
1870
|
+
},
|
|
1871
|
+
year
|
|
1872
|
+
);
|
|
1873
|
+
}) }) }) });
|
|
1874
|
+
};
|
|
1875
|
+
|
|
1876
|
+
// src/components/date/DayPicker.tsx
|
|
1877
|
+
import clsx7 from "clsx";
|
|
1878
|
+
import { useEffect as useEffect10, useState as useState12 } from "react";
|
|
1879
|
+
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1880
|
+
var DayPicker = ({
|
|
1881
|
+
displayedMonth,
|
|
1882
|
+
selected,
|
|
1883
|
+
start,
|
|
1884
|
+
end,
|
|
1885
|
+
onChange = noop,
|
|
1886
|
+
weekStart = "monday",
|
|
1887
|
+
markToday = true,
|
|
1888
|
+
className = ""
|
|
1889
|
+
}) => {
|
|
1890
|
+
const locale = useLocale();
|
|
1891
|
+
const month = displayedMonth.getMonth();
|
|
1892
|
+
const weeks = getWeeksForCalenderMonth(displayedMonth, weekStart);
|
|
1893
|
+
return /* @__PURE__ */ jsxs7("div", { className: clsx7("flex-col-1 min-w-[220px] select-none", className), children: [
|
|
1894
|
+
/* @__PURE__ */ jsx12("div", { className: "flex-row-2 text-center", children: weeks[0].map((weekDay, index) => /* @__PURE__ */ jsx12("div", { className: "flex-1 font-semibold", children: new Intl.DateTimeFormat(locale, { weekday: "long" }).format(weekDay).substring(0, 2) }, index)) }),
|
|
1895
|
+
weeks.map((week, index) => /* @__PURE__ */ jsx12("div", { className: "flex-row-2 text-center", children: week.map((date) => {
|
|
1896
|
+
const isSelected = !!selected && equalDate(selected, date);
|
|
1897
|
+
const isToday = equalDate(/* @__PURE__ */ new Date(), date);
|
|
1898
|
+
const isSameMonth = date.getMonth() === month;
|
|
1899
|
+
const isDayValid = isInTimeSpan(date, start, end);
|
|
1900
|
+
return /* @__PURE__ */ jsx12(
|
|
1901
|
+
"button",
|
|
1902
|
+
{
|
|
1903
|
+
disabled: !isDayValid,
|
|
1904
|
+
className: clsx7(
|
|
1905
|
+
"flex-1 rounded-full border-2",
|
|
1906
|
+
{
|
|
1907
|
+
"text-description": !isSameMonth && !isSelected && isDayValid,
|
|
1908
|
+
"text-button-solid-neutral-text bg-button-solid-neutral-background": !isSelected && isSameMonth && isDayValid,
|
|
1909
|
+
"text-button-solid-primary-text bg-button-solid-primary-background": isSelected && isDayValid,
|
|
1910
|
+
"hover:brightness-90 hover:bg-button-solid-primary-background hover:text-button-solid-primary-text": isDayValid,
|
|
1911
|
+
"text-disabled-text bg-disabled-background cursor-not-allowed": !isDayValid,
|
|
1912
|
+
"border-secondary": isToday && markToday,
|
|
1913
|
+
"border-transparent": !isToday || !markToday
|
|
1914
|
+
}
|
|
1915
|
+
),
|
|
1916
|
+
onClick: () => onChange(date),
|
|
1917
|
+
children: date.getDate()
|
|
1918
|
+
},
|
|
1919
|
+
date.getDate()
|
|
1920
|
+
);
|
|
1921
|
+
}) }, index))
|
|
1922
|
+
] });
|
|
1923
|
+
};
|
|
1924
|
+
|
|
1925
|
+
// src/localization/defaults/time.ts
|
|
1926
|
+
var monthTranslation = {
|
|
1927
|
+
en: {
|
|
1928
|
+
january: "January",
|
|
1929
|
+
february: "Febuary",
|
|
1930
|
+
march: "March",
|
|
1931
|
+
april: "April",
|
|
1932
|
+
may: "May",
|
|
1933
|
+
june: "June",
|
|
1934
|
+
july: "July",
|
|
1935
|
+
august: "August",
|
|
1936
|
+
september: "September",
|
|
1937
|
+
october: "October",
|
|
1938
|
+
november: "November",
|
|
1939
|
+
december: "December"
|
|
1940
|
+
},
|
|
1941
|
+
de: {
|
|
1942
|
+
january: "Januar",
|
|
1943
|
+
february: "Febuar",
|
|
1944
|
+
march: "M\xE4rz",
|
|
1945
|
+
april: "April",
|
|
1946
|
+
may: "Mai",
|
|
1947
|
+
june: "Juni",
|
|
1948
|
+
july: "Juli",
|
|
1949
|
+
august: "August",
|
|
1950
|
+
september: "September",
|
|
1951
|
+
october: "October",
|
|
1952
|
+
november: "November",
|
|
1953
|
+
december: "December"
|
|
1954
|
+
}
|
|
1955
|
+
};
|
|
1956
|
+
var timeTranslation = {
|
|
1957
|
+
en: {
|
|
1958
|
+
...monthTranslation.en,
|
|
1959
|
+
century: { one: "Century", other: "Centuries" },
|
|
1960
|
+
decade: { one: "Decade", other: "Decades" },
|
|
1961
|
+
year: { one: "Year", other: "Years" },
|
|
1962
|
+
month: { one: "Month", other: "Months" },
|
|
1963
|
+
day: { one: "Day", other: "Days" },
|
|
1964
|
+
hour: { one: "Hour", other: "Hours" },
|
|
1965
|
+
minute: { one: "Minute", other: "Minutes" },
|
|
1966
|
+
second: { one: "Second", other: "Seconds" },
|
|
1967
|
+
millisecond: { one: "Millisecond", other: "Milliseconds" },
|
|
1968
|
+
microsecond: { one: "Microsecond", other: "Microseconds" },
|
|
1969
|
+
nanosecond: { one: "Nanosecond", other: "Nanoseconds" },
|
|
1970
|
+
yesterday: "Yesterday",
|
|
1971
|
+
today: "Today",
|
|
1972
|
+
tomorrow: "Tomorrow",
|
|
1973
|
+
in: "in",
|
|
1974
|
+
ago: "ago"
|
|
1975
|
+
},
|
|
1976
|
+
de: {
|
|
1977
|
+
...monthTranslation.de,
|
|
1978
|
+
century: { one: "Jahrhundert", other: "Jahrhunderte" },
|
|
1979
|
+
decade: { one: "Jahrzehnt", other: "Jahrzehnte" },
|
|
1980
|
+
year: { one: "Jahr", other: "Jahre" },
|
|
1981
|
+
month: { one: "Monat", other: "Monate" },
|
|
1982
|
+
day: { one: "Tag", other: "Tage" },
|
|
1983
|
+
hour: { one: "Stunde", other: "Stunden" },
|
|
1984
|
+
minute: { one: "Minute", other: "Minuten" },
|
|
1985
|
+
second: { one: "Sekunde", other: "Sekunden" },
|
|
1986
|
+
millisecond: { one: "Millisekunde", other: "Millisekunden" },
|
|
1987
|
+
microsecond: { one: "Mikrosekunde", other: "Mikrosekunden" },
|
|
1988
|
+
nanosecond: { one: "Nanosekunde", other: "Nanosekunden" },
|
|
1989
|
+
yesterday: "Gestern",
|
|
1990
|
+
today: "Heute",
|
|
1991
|
+
tomorrow: "Morgen",
|
|
1992
|
+
in: "in",
|
|
1993
|
+
ago: "vor"
|
|
1994
|
+
}
|
|
1995
|
+
};
|
|
1996
|
+
|
|
1997
|
+
// src/components/date/DatePicker.tsx
|
|
1998
|
+
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1999
|
+
var DatePicker = ({
|
|
2000
|
+
overwriteTranslation,
|
|
2001
|
+
value = /* @__PURE__ */ new Date(),
|
|
2002
|
+
start = subtractDuration(/* @__PURE__ */ new Date(), { years: 50 }),
|
|
2003
|
+
end = addDuration(/* @__PURE__ */ new Date(), { years: 50 }),
|
|
2004
|
+
initialDisplay = "day",
|
|
2005
|
+
onChange = noop,
|
|
2006
|
+
yearMonthPickerProps,
|
|
2007
|
+
dayPickerProps,
|
|
2008
|
+
className = ""
|
|
2009
|
+
}) => {
|
|
2010
|
+
const locale = useLocale();
|
|
2011
|
+
const translation = useTranslation([timeTranslation], overwriteTranslation);
|
|
2012
|
+
const [displayedMonth, setDisplayedMonth] = useState13(value);
|
|
2013
|
+
const [displayMode, setDisplayMode] = useState13(initialDisplay);
|
|
2014
|
+
useEffect11(() => {
|
|
2015
|
+
setDisplayedMonth(value);
|
|
2016
|
+
}, [value]);
|
|
2017
|
+
return /* @__PURE__ */ jsxs8("div", { className: clsx8("flex-col-4", className), children: [
|
|
2018
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex-row-2 items-center justify-between h-7", children: [
|
|
2019
|
+
/* @__PURE__ */ jsxs8(
|
|
2020
|
+
TextButton,
|
|
2021
|
+
{
|
|
2022
|
+
className: clsx8("flex-row-1 items-center cursor-pointer select-none", {
|
|
2023
|
+
"text-disabled-text": displayMode !== "day"
|
|
2024
|
+
}),
|
|
2025
|
+
onClick: () => setDisplayMode(displayMode === "day" ? "yearMonth" : "day"),
|
|
2026
|
+
children: [
|
|
2027
|
+
`${new Intl.DateTimeFormat(locale, { month: "long" }).format(displayedMonth)} ${displayedMonth.getFullYear()}`,
|
|
2028
|
+
/* @__PURE__ */ jsx13(ChevronDown2, { size: 16 })
|
|
2029
|
+
]
|
|
2030
|
+
}
|
|
2031
|
+
),
|
|
2032
|
+
displayMode === "day" && /* @__PURE__ */ jsxs8("div", { className: "flex-row-2 justify-end", children: [
|
|
2033
|
+
/* @__PURE__ */ jsx13(
|
|
2034
|
+
SolidButton,
|
|
2035
|
+
{
|
|
2036
|
+
size: "small",
|
|
2037
|
+
color: "primary",
|
|
2038
|
+
disabled: !isInTimeSpan(subtractDuration(displayedMonth, { months: 1 }), start, end),
|
|
2039
|
+
onClick: () => {
|
|
2040
|
+
setDisplayedMonth(subtractDuration(displayedMonth, { months: 1 }));
|
|
2041
|
+
},
|
|
2042
|
+
children: /* @__PURE__ */ jsx13(ArrowUp, { size: 20 })
|
|
2043
|
+
}
|
|
2044
|
+
),
|
|
2045
|
+
/* @__PURE__ */ jsx13(
|
|
2046
|
+
SolidButton,
|
|
2047
|
+
{
|
|
2048
|
+
size: "small",
|
|
2049
|
+
color: "primary",
|
|
2050
|
+
disabled: !isInTimeSpan(addDuration(displayedMonth, { months: 1 }), start, end),
|
|
2051
|
+
onClick: () => {
|
|
2052
|
+
setDisplayedMonth(addDuration(displayedMonth, { months: 1 }));
|
|
2053
|
+
},
|
|
2054
|
+
children: /* @__PURE__ */ jsx13(ArrowDown, { size: 20 })
|
|
2055
|
+
}
|
|
2056
|
+
)
|
|
2057
|
+
] })
|
|
2058
|
+
] }),
|
|
2059
|
+
displayMode === "yearMonth" ? /* @__PURE__ */ jsx13(
|
|
2060
|
+
YearMonthPicker,
|
|
2061
|
+
{
|
|
2062
|
+
...yearMonthPickerProps,
|
|
2063
|
+
displayedYearMonth: value,
|
|
2064
|
+
start,
|
|
2065
|
+
end,
|
|
2066
|
+
onChange: (newDate) => {
|
|
2067
|
+
setDisplayedMonth(newDate);
|
|
2068
|
+
setDisplayMode("day");
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
) : /* @__PURE__ */ jsxs8("div", { children: [
|
|
2072
|
+
/* @__PURE__ */ jsx13(
|
|
2073
|
+
DayPicker,
|
|
2074
|
+
{
|
|
2075
|
+
...dayPickerProps,
|
|
2076
|
+
displayedMonth,
|
|
2077
|
+
start,
|
|
2078
|
+
end,
|
|
2079
|
+
selected: value,
|
|
2080
|
+
onChange: (date) => {
|
|
2081
|
+
onChange(date);
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
),
|
|
2085
|
+
/* @__PURE__ */ jsx13("div", { className: "mt-2", children: /* @__PURE__ */ jsx13(
|
|
2086
|
+
TextButton,
|
|
2087
|
+
{
|
|
2088
|
+
color: "primary",
|
|
2089
|
+
onClick: () => {
|
|
2090
|
+
const newDate = /* @__PURE__ */ new Date();
|
|
2091
|
+
newDate.setHours(value.getHours(), value.getMinutes());
|
|
2092
|
+
onChange(newDate);
|
|
2093
|
+
},
|
|
2094
|
+
children: translation("today")
|
|
2095
|
+
}
|
|
2096
|
+
) })
|
|
2097
|
+
] })
|
|
2098
|
+
] });
|
|
2099
|
+
};
|
|
2100
|
+
|
|
2101
|
+
// src/components/user-action/DateAndTimePicker.tsx
|
|
2102
|
+
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2103
|
+
var DateTimePicker = ({
|
|
2104
|
+
overwriteTranslation,
|
|
2105
|
+
value = /* @__PURE__ */ new Date(),
|
|
2106
|
+
start = subtractDuration(/* @__PURE__ */ new Date(), { years: 50 }),
|
|
2107
|
+
end = addDuration(/* @__PURE__ */ new Date(), { years: 50 }),
|
|
2108
|
+
mode = "dateTime",
|
|
2109
|
+
onFinish = noop,
|
|
2110
|
+
onChange = noop,
|
|
2111
|
+
onRemove = noop,
|
|
2112
|
+
timePickerProps,
|
|
2113
|
+
datePickerProps
|
|
2114
|
+
}) => {
|
|
2115
|
+
const translation = useTranslation([formTranslation, timeTranslation], overwriteTranslation);
|
|
2116
|
+
const useDate = mode === "dateTime" || mode === "date";
|
|
2117
|
+
const useTime = mode === "dateTime" || mode === "time";
|
|
2118
|
+
let dateDisplay;
|
|
2119
|
+
let timeDisplay;
|
|
2120
|
+
if (useDate) {
|
|
2121
|
+
dateDisplay = /* @__PURE__ */ jsx14(
|
|
2122
|
+
DatePicker,
|
|
2123
|
+
{
|
|
2124
|
+
...datePickerProps,
|
|
2125
|
+
className: "min-w-[320px] min-h-[250px]",
|
|
2126
|
+
yearMonthPickerProps: { maxHeight: 218 },
|
|
2127
|
+
value,
|
|
2128
|
+
start,
|
|
2129
|
+
end,
|
|
2130
|
+
onChange
|
|
2131
|
+
}
|
|
2132
|
+
);
|
|
2133
|
+
}
|
|
2134
|
+
if (useTime) {
|
|
2135
|
+
timeDisplay = /* @__PURE__ */ jsx14(
|
|
2136
|
+
TimePicker,
|
|
2137
|
+
{
|
|
2138
|
+
...timePickerProps,
|
|
2139
|
+
className: clsx9("h-full", { "justify-between w-full": mode === "time" }),
|
|
2140
|
+
maxHeight: 250,
|
|
2141
|
+
time: value,
|
|
2142
|
+
onChange
|
|
2143
|
+
}
|
|
2144
|
+
);
|
|
2145
|
+
}
|
|
2146
|
+
return /* @__PURE__ */ jsxs9("div", { className: "flex-col-2 w-fit", children: [
|
|
2147
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex-row-4", children: [
|
|
2148
|
+
dateDisplay,
|
|
2149
|
+
timeDisplay
|
|
2150
|
+
] }),
|
|
2151
|
+
/* @__PURE__ */ jsx14("div", { className: "flex-row-2 justify-end", children: /* @__PURE__ */ jsxs9("div", { className: "flex-row-2 mt-1", children: [
|
|
2152
|
+
/* @__PURE__ */ jsx14(SolidButton, { size: "medium", color: "negative", onClick: onRemove, children: translation("clear") }),
|
|
2153
|
+
/* @__PURE__ */ jsx14(
|
|
2154
|
+
SolidButton,
|
|
2155
|
+
{
|
|
2156
|
+
size: "medium",
|
|
2157
|
+
onClick: () => onFinish(value),
|
|
2158
|
+
children: translation("change")
|
|
2159
|
+
}
|
|
2160
|
+
)
|
|
2161
|
+
] }) })
|
|
2162
|
+
] });
|
|
2163
|
+
};
|
|
2164
|
+
|
|
2165
|
+
// src/components/user-action/Label.tsx
|
|
2166
|
+
import clsx10 from "clsx";
|
|
2167
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
2168
|
+
var styleMapping = {
|
|
2169
|
+
sm: "typography-label-xs color-label-text",
|
|
2170
|
+
md: "typography-label-md color-label-text"
|
|
2171
|
+
};
|
|
2172
|
+
var Label = ({
|
|
2173
|
+
children,
|
|
2174
|
+
size = "md",
|
|
2175
|
+
className,
|
|
2176
|
+
...props
|
|
2177
|
+
}) => {
|
|
2178
|
+
return /* @__PURE__ */ jsx15("label", { ...props, className: clsx10(styleMapping[size], className), children });
|
|
2179
|
+
};
|
|
2180
|
+
|
|
2181
|
+
// src/components/user-action/Menu.tsx
|
|
2182
|
+
import { useEffect as useEffect14, useRef as useRef8, useState as useState15 } from "react";
|
|
2183
|
+
import clsx11 from "clsx";
|
|
2184
|
+
|
|
2185
|
+
// src/hooks/useOutsideClick.ts
|
|
2186
|
+
import { useEffect as useEffect12 } from "react";
|
|
2187
|
+
var useOutsideClick = (refs, handler) => {
|
|
2188
|
+
useEffect12(() => {
|
|
2189
|
+
const listener = (event) => {
|
|
2190
|
+
if (event.target === null) return;
|
|
2191
|
+
if (refs.some((ref) => !ref.current || ref.current.contains(event.target))) {
|
|
2192
|
+
return;
|
|
2193
|
+
}
|
|
2194
|
+
handler();
|
|
2195
|
+
};
|
|
2196
|
+
document.addEventListener("mousedown", listener);
|
|
2197
|
+
document.addEventListener("touchstart", listener);
|
|
2198
|
+
return () => {
|
|
2199
|
+
document.removeEventListener("mousedown", listener);
|
|
2200
|
+
document.removeEventListener("touchstart", listener);
|
|
2201
|
+
};
|
|
2202
|
+
}, [refs, handler]);
|
|
2203
|
+
};
|
|
2204
|
+
|
|
2205
|
+
// src/hooks/useHoverState.ts
|
|
2206
|
+
import { useEffect as useEffect13, useState as useState14 } from "react";
|
|
2207
|
+
var defaultUseHoverStateProps = {
|
|
2208
|
+
closingDelay: 200,
|
|
2209
|
+
isDisabled: false
|
|
2210
|
+
};
|
|
2211
|
+
var useHoverState = (props = void 0) => {
|
|
2212
|
+
const { closingDelay, isDisabled } = { ...defaultUseHoverStateProps, ...props };
|
|
2213
|
+
const [isHovered, setIsHovered] = useState14(false);
|
|
2214
|
+
const [timer, setTimer] = useState14();
|
|
2215
|
+
const onMouseEnter = () => {
|
|
2216
|
+
if (isDisabled) {
|
|
2217
|
+
return;
|
|
2218
|
+
}
|
|
2219
|
+
clearTimeout(timer);
|
|
2220
|
+
setIsHovered(true);
|
|
2221
|
+
};
|
|
2222
|
+
const onMouseLeave = () => {
|
|
2223
|
+
if (isDisabled) {
|
|
2224
|
+
return;
|
|
2225
|
+
}
|
|
2226
|
+
setTimer(setTimeout(() => {
|
|
2227
|
+
setIsHovered(false);
|
|
2228
|
+
}, closingDelay));
|
|
2229
|
+
};
|
|
2230
|
+
useEffect13(() => {
|
|
2231
|
+
if (timer) {
|
|
2232
|
+
return () => {
|
|
2233
|
+
clearTimeout(timer);
|
|
2234
|
+
};
|
|
2235
|
+
}
|
|
2236
|
+
});
|
|
2237
|
+
useEffect13(() => {
|
|
2238
|
+
if (timer) {
|
|
2239
|
+
clearTimeout(timer);
|
|
2240
|
+
}
|
|
2241
|
+
}, [isDisabled]);
|
|
2242
|
+
return {
|
|
2243
|
+
isHovered,
|
|
2244
|
+
setIsHovered,
|
|
2245
|
+
handlers: { onMouseEnter, onMouseLeave }
|
|
2246
|
+
};
|
|
2247
|
+
};
|
|
2248
|
+
|
|
2249
|
+
// src/utils/bagFunctions.ts
|
|
2250
|
+
var resolve = (children, bag) => {
|
|
2251
|
+
if (typeof children === "function") {
|
|
2252
|
+
return children(bag);
|
|
2253
|
+
}
|
|
2254
|
+
return children ?? void 0;
|
|
2255
|
+
};
|
|
2256
|
+
var BagFunctionUtil = {
|
|
2257
|
+
resolve
|
|
2258
|
+
};
|
|
2259
|
+
|
|
2260
|
+
// src/hooks/usePopoverPosition.ts
|
|
2261
|
+
var defaultPopoverPositionOptions = {
|
|
2262
|
+
edgePadding: 16,
|
|
2263
|
+
outerGap: 4,
|
|
2264
|
+
horizontalAlignment: "leftInside",
|
|
2265
|
+
verticalAlignment: "bottomOutside",
|
|
2266
|
+
disabled: false
|
|
2267
|
+
};
|
|
2268
|
+
var usePopoverPosition = (trigger, options) => {
|
|
2269
|
+
const {
|
|
2270
|
+
edgePadding,
|
|
2271
|
+
outerGap,
|
|
2272
|
+
verticalAlignment,
|
|
2273
|
+
horizontalAlignment,
|
|
2274
|
+
disabled
|
|
2275
|
+
} = { ...defaultPopoverPositionOptions, ...options };
|
|
2276
|
+
if (disabled || !trigger) {
|
|
2277
|
+
return {};
|
|
2278
|
+
}
|
|
2279
|
+
const left = {
|
|
2280
|
+
leftOutside: trigger.left - outerGap,
|
|
2281
|
+
leftInside: trigger.left,
|
|
2282
|
+
rightOutside: trigger.right + outerGap,
|
|
2283
|
+
rightInside: trigger.right,
|
|
2284
|
+
center: trigger.left + trigger.width / 2
|
|
2285
|
+
}[horizontalAlignment];
|
|
2286
|
+
const top = {
|
|
2287
|
+
topOutside: trigger.top - outerGap,
|
|
2288
|
+
topInside: trigger.top,
|
|
2289
|
+
bottomOutside: trigger.bottom + outerGap,
|
|
2290
|
+
bottomInside: trigger.bottom,
|
|
2291
|
+
center: trigger.top + trigger.height / 2
|
|
2292
|
+
}[verticalAlignment];
|
|
2293
|
+
const translateX = {
|
|
2294
|
+
leftOutside: "-100%",
|
|
2295
|
+
leftInside: void 0,
|
|
2296
|
+
rightOutside: void 0,
|
|
2297
|
+
rightInside: "-100%",
|
|
2298
|
+
center: "-50%"
|
|
2299
|
+
}[horizontalAlignment];
|
|
2300
|
+
const translateY = {
|
|
2301
|
+
topOutside: "-100%",
|
|
2302
|
+
topInside: void 0,
|
|
2303
|
+
bottomOutside: void 0,
|
|
2304
|
+
bottomInside: "-100%",
|
|
2305
|
+
center: "-50%"
|
|
2306
|
+
}[verticalAlignment];
|
|
2307
|
+
return {
|
|
2308
|
+
left: Math.max(left, edgePadding),
|
|
2309
|
+
top: Math.max(top, edgePadding),
|
|
2310
|
+
translate: [translateX ?? "0", translateY ?? "0"].join(" ")
|
|
2311
|
+
};
|
|
2312
|
+
};
|
|
2313
|
+
|
|
2314
|
+
// src/components/user-action/Menu.tsx
|
|
2315
|
+
import { createPortal } from "react-dom";
|
|
2316
|
+
import { Fragment as Fragment4, jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2317
|
+
var MenuItem = ({
|
|
2318
|
+
children,
|
|
2319
|
+
onClick,
|
|
2320
|
+
alignment = "left",
|
|
2321
|
+
isDisabled = false,
|
|
2322
|
+
className
|
|
2323
|
+
}) => /* @__PURE__ */ jsx16(
|
|
2324
|
+
"div",
|
|
2325
|
+
{
|
|
2326
|
+
className: clsx11("block px-3 py-1.5 first:rounded-t-md last:rounded-b-md text-sm font-semibold text-nowrap", {
|
|
2327
|
+
"text-right": alignment === "right",
|
|
2328
|
+
"text-left": alignment === "left",
|
|
2329
|
+
"text-disabled-text cursor-not-allowed": isDisabled,
|
|
2330
|
+
"text-menu-text hover:bg-primary/20": !isDisabled,
|
|
2331
|
+
"cursor-pointer": !!onClick
|
|
2332
|
+
}, className),
|
|
2333
|
+
onClick,
|
|
2334
|
+
children
|
|
2335
|
+
}
|
|
2336
|
+
);
|
|
2337
|
+
function getScrollableParents(element) {
|
|
2338
|
+
const scrollables = [];
|
|
2339
|
+
let parent = element.parentElement;
|
|
2340
|
+
while (parent) {
|
|
2341
|
+
scrollables.push(parent);
|
|
2342
|
+
parent = parent.parentElement;
|
|
2343
|
+
}
|
|
2344
|
+
return scrollables;
|
|
2345
|
+
}
|
|
2346
|
+
var Menu = ({
|
|
2347
|
+
trigger,
|
|
2348
|
+
children,
|
|
2349
|
+
alignmentHorizontal = "leftInside",
|
|
2350
|
+
alignmentVertical = "bottomOutside",
|
|
2351
|
+
showOnHover = false,
|
|
2352
|
+
disabled = false,
|
|
2353
|
+
menuClassName = ""
|
|
2354
|
+
}) => {
|
|
2355
|
+
const { isHovered: isOpen, setIsHovered: setIsOpen } = useHoverState({ isDisabled: !showOnHover || disabled });
|
|
2356
|
+
const triggerRef = useRef8(null);
|
|
2357
|
+
const menuRef = useRef8(null);
|
|
2358
|
+
useOutsideClick([triggerRef, menuRef], () => setIsOpen(false));
|
|
2359
|
+
const [isHidden, setIsHidden] = useState15(true);
|
|
2360
|
+
const bag = {
|
|
2361
|
+
isOpen,
|
|
2362
|
+
close: () => setIsOpen(false),
|
|
2363
|
+
toggleOpen: () => setIsOpen((prevState) => !prevState),
|
|
2364
|
+
disabled
|
|
2365
|
+
};
|
|
2366
|
+
const menuPosition = usePopoverPosition(
|
|
2367
|
+
triggerRef.current?.getBoundingClientRect(),
|
|
2368
|
+
{ verticalAlignment: alignmentVertical, horizontalAlignment: alignmentHorizontal, disabled }
|
|
2369
|
+
);
|
|
2370
|
+
useEffect14(() => {
|
|
2371
|
+
if (!isOpen) return;
|
|
2372
|
+
const triggerEl = triggerRef.current;
|
|
2373
|
+
if (!triggerEl) return;
|
|
2374
|
+
const scrollableParents = getScrollableParents(triggerEl);
|
|
2375
|
+
const close = () => setIsOpen(false);
|
|
2376
|
+
scrollableParents.forEach((parent) => {
|
|
2377
|
+
parent.addEventListener("scroll", close);
|
|
2378
|
+
});
|
|
2379
|
+
window.addEventListener("resize", close);
|
|
2380
|
+
return () => {
|
|
2381
|
+
scrollableParents.forEach((parent) => {
|
|
2382
|
+
parent.removeEventListener("scroll", close);
|
|
2383
|
+
});
|
|
2384
|
+
window.removeEventListener("resize", close);
|
|
2385
|
+
};
|
|
2386
|
+
}, [isOpen, setIsOpen]);
|
|
2387
|
+
useEffect14(() => {
|
|
2388
|
+
if (isOpen) {
|
|
2389
|
+
setIsHidden(false);
|
|
2390
|
+
}
|
|
2391
|
+
}, [isOpen]);
|
|
2392
|
+
return /* @__PURE__ */ jsxs10(Fragment4, { children: [
|
|
2393
|
+
trigger(bag, triggerRef),
|
|
2394
|
+
createPortal(/* @__PURE__ */ jsx16(
|
|
2395
|
+
"div",
|
|
2396
|
+
{
|
|
2397
|
+
ref: menuRef,
|
|
2398
|
+
onClick: (e) => e.stopPropagation(),
|
|
2399
|
+
className: clsx11(
|
|
2400
|
+
"absolute rounded-md bg-menu-background text-menu-text shadow-around-lg shadow-strong z-[300]",
|
|
2401
|
+
{
|
|
2402
|
+
"animate-pop-in": isOpen,
|
|
2403
|
+
"animate-pop-out": !isOpen,
|
|
2404
|
+
"hidden": isHidden
|
|
2405
|
+
},
|
|
2406
|
+
menuClassName
|
|
2407
|
+
),
|
|
2408
|
+
onAnimationEnd: () => {
|
|
2409
|
+
if (!isOpen) {
|
|
2410
|
+
setIsHidden(true);
|
|
2411
|
+
}
|
|
2412
|
+
},
|
|
2413
|
+
style: {
|
|
2414
|
+
...menuPosition
|
|
2415
|
+
},
|
|
2416
|
+
children: BagFunctionUtil.resolve(children, bag)
|
|
2417
|
+
}
|
|
2418
|
+
), document.body)
|
|
2419
|
+
] });
|
|
2420
|
+
};
|
|
2421
|
+
|
|
2422
|
+
// src/components/user-action/ScrollPicker.tsx
|
|
2423
|
+
import { useCallback as useCallback6, useEffect as useEffect15, useState as useState16 } from "react";
|
|
2424
|
+
import clsx12 from "clsx";
|
|
2425
|
+
|
|
2426
|
+
// src/utils/math.ts
|
|
2427
|
+
var clamp = (value, range2 = [0, 1]) => {
|
|
2428
|
+
const [min, max] = range2;
|
|
2429
|
+
return Math.min(Math.max(value, min), max);
|
|
2430
|
+
};
|
|
2431
|
+
|
|
2432
|
+
// src/components/user-action/ScrollPicker.tsx
|
|
2433
|
+
import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2434
|
+
var up = 1;
|
|
2435
|
+
var down = -1;
|
|
2436
|
+
var ScrollPicker = ({
|
|
2437
|
+
options,
|
|
2438
|
+
mapping,
|
|
2439
|
+
selected,
|
|
2440
|
+
onChange = noop,
|
|
2441
|
+
disabled = false
|
|
2442
|
+
}) => {
|
|
2443
|
+
let selectedIndex = 0;
|
|
2444
|
+
if (selected && options.indexOf(selected) !== -1) {
|
|
2445
|
+
selectedIndex = options.indexOf(selected);
|
|
2446
|
+
}
|
|
2447
|
+
const [{
|
|
2448
|
+
currentIndex,
|
|
2449
|
+
transition,
|
|
2450
|
+
items,
|
|
2451
|
+
lastTimeStamp
|
|
2452
|
+
}, setAnimation] = useState16({
|
|
2453
|
+
targetIndex: selectedIndex,
|
|
2454
|
+
currentIndex: disabled ? selectedIndex : 0,
|
|
2455
|
+
velocity: 0,
|
|
2456
|
+
animationVelocity: Math.floor(options.length / 2),
|
|
2457
|
+
transition: 0,
|
|
2458
|
+
items: options
|
|
2459
|
+
});
|
|
2460
|
+
const itemsShownCount = 5;
|
|
2461
|
+
const shownItems = getNeighbours(range(items.length), currentIndex).map((index) => ({
|
|
2462
|
+
name: mapping(items[index]),
|
|
2463
|
+
index
|
|
2464
|
+
}));
|
|
2465
|
+
const itemHeight = 40;
|
|
2466
|
+
const distance = 8;
|
|
2467
|
+
const containerHeight = itemHeight * (itemsShownCount - 2) + distance * (itemsShownCount - 2 + 1);
|
|
2468
|
+
const getDirection = useCallback6((targetIndex, currentIndex2, transition2, length) => {
|
|
2469
|
+
if (targetIndex === currentIndex2) {
|
|
2470
|
+
return transition2 > 0 ? up : down;
|
|
2471
|
+
}
|
|
2472
|
+
let distanceForward = targetIndex - currentIndex2;
|
|
2473
|
+
if (distanceForward < 0) {
|
|
2474
|
+
distanceForward += length;
|
|
2475
|
+
}
|
|
2476
|
+
return distanceForward >= length / 2 ? down : up;
|
|
2477
|
+
}, []);
|
|
2478
|
+
const animate = useCallback6((timestamp, startTime) => {
|
|
2479
|
+
setAnimation((prevState) => {
|
|
2480
|
+
const {
|
|
2481
|
+
targetIndex,
|
|
2482
|
+
currentIndex: currentIndex2,
|
|
2483
|
+
transition: transition2,
|
|
2484
|
+
animationVelocity,
|
|
2485
|
+
velocity,
|
|
2486
|
+
items: items2,
|
|
2487
|
+
lastScrollTimeStamp
|
|
2488
|
+
} = prevState;
|
|
2489
|
+
if (disabled) {
|
|
2490
|
+
return { ...prevState, currentIndex: targetIndex, velocity: 0, lastTimeStamp: timestamp };
|
|
2491
|
+
}
|
|
2492
|
+
if (targetIndex === currentIndex2 && velocity === 0 && transition2 === 0 || !startTime) {
|
|
2493
|
+
return { ...prevState, lastTimeStamp: timestamp };
|
|
2494
|
+
}
|
|
2495
|
+
const progress = (timestamp - startTime) / 1e3;
|
|
2496
|
+
const direction = getDirection(targetIndex, currentIndex2, transition2, items2.length);
|
|
2497
|
+
let newVelocity = velocity;
|
|
2498
|
+
let usedVelocity;
|
|
2499
|
+
let newCurrentIndex = currentIndex2;
|
|
2500
|
+
const isAutoScrolling = velocity <= 10 && (!lastScrollTimeStamp || timestamp - lastScrollTimeStamp > 50);
|
|
2501
|
+
const newLastScrollTimeStamp = velocity !== 0 ? timestamp : lastScrollTimeStamp;
|
|
2502
|
+
if (isAutoScrolling) {
|
|
2503
|
+
usedVelocity = direction * animationVelocity;
|
|
2504
|
+
} else {
|
|
2505
|
+
usedVelocity = velocity;
|
|
2506
|
+
newVelocity = velocity * 0.5;
|
|
2507
|
+
if (Math.abs(newVelocity) <= 0.05) {
|
|
2508
|
+
newVelocity = 0;
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
let newTransition = transition2 + usedVelocity * progress;
|
|
2512
|
+
const changeThreshold = 0.5;
|
|
2513
|
+
while (newTransition >= changeThreshold) {
|
|
2514
|
+
if (newCurrentIndex === targetIndex && newTransition >= changeThreshold && isAutoScrolling) {
|
|
2515
|
+
newTransition = 0;
|
|
2516
|
+
break;
|
|
2517
|
+
}
|
|
2518
|
+
newCurrentIndex = (currentIndex2 + 1) % items2.length;
|
|
2519
|
+
newTransition -= 1;
|
|
2520
|
+
}
|
|
2521
|
+
if (newTransition >= changeThreshold) {
|
|
2522
|
+
newTransition = 0;
|
|
2523
|
+
}
|
|
2524
|
+
while (newTransition <= -changeThreshold) {
|
|
2525
|
+
if (newCurrentIndex === targetIndex && newTransition <= -changeThreshold && isAutoScrolling) {
|
|
2526
|
+
newTransition = 0;
|
|
2527
|
+
break;
|
|
2528
|
+
}
|
|
2529
|
+
newCurrentIndex = currentIndex2 === 0 ? items2.length - 1 : currentIndex2 - 1;
|
|
2530
|
+
newTransition += 1;
|
|
2531
|
+
}
|
|
2532
|
+
let newTargetIndex = targetIndex;
|
|
2533
|
+
if (!isAutoScrolling) {
|
|
2534
|
+
newTargetIndex = newCurrentIndex;
|
|
2535
|
+
}
|
|
2536
|
+
if ((currentIndex2 !== newTargetIndex || newTargetIndex !== targetIndex) && newTargetIndex === newCurrentIndex) {
|
|
2537
|
+
onChange(items2[newCurrentIndex]);
|
|
2538
|
+
}
|
|
2539
|
+
return {
|
|
2540
|
+
targetIndex: newTargetIndex,
|
|
2541
|
+
currentIndex: newCurrentIndex,
|
|
2542
|
+
animationVelocity,
|
|
2543
|
+
transition: newTransition,
|
|
2544
|
+
velocity: newVelocity,
|
|
2545
|
+
items: items2,
|
|
2546
|
+
lastTimeStamp: timestamp,
|
|
2547
|
+
lastScrollTimeStamp: newLastScrollTimeStamp
|
|
2548
|
+
};
|
|
2549
|
+
});
|
|
2550
|
+
}, [disabled, getDirection, onChange]);
|
|
2551
|
+
useEffect15(() => {
|
|
2552
|
+
requestAnimationFrame((timestamp) => animate(timestamp, lastTimeStamp));
|
|
2553
|
+
});
|
|
2554
|
+
const opacity = (transition2, index, itemsCount) => {
|
|
2555
|
+
const max = 100;
|
|
2556
|
+
const min = 0;
|
|
2557
|
+
const distance2 = max - min;
|
|
2558
|
+
let opacityValue = min;
|
|
2559
|
+
const unitTransition = clamp(transition2 / 0.5);
|
|
2560
|
+
if (index === 1 || index === itemsCount - 2) {
|
|
2561
|
+
if (index === 1 && transition2 > 0) {
|
|
2562
|
+
opacityValue += Math.floor(unitTransition * distance2);
|
|
2563
|
+
}
|
|
2564
|
+
if (index === itemsCount - 2 && transition2 < 0) {
|
|
2565
|
+
opacityValue += Math.floor(unitTransition * distance2);
|
|
2566
|
+
}
|
|
2567
|
+
} else {
|
|
2568
|
+
opacityValue = max;
|
|
2569
|
+
}
|
|
2570
|
+
return clamp(1 - opacityValue / max);
|
|
2571
|
+
};
|
|
2572
|
+
return /* @__PURE__ */ jsx17(
|
|
2573
|
+
"div",
|
|
2574
|
+
{
|
|
2575
|
+
className: "relative overflow-hidden",
|
|
2576
|
+
style: { height: containerHeight },
|
|
2577
|
+
onWheel: (event) => {
|
|
2578
|
+
if (event.deltaY !== 0) {
|
|
2579
|
+
const deltaY = clamp(event.deltaY, [-itemHeight * 2 / 3, itemHeight * 2 / 3]);
|
|
2580
|
+
setAnimation(({ velocity, ...animationData }) => ({ ...animationData, velocity: velocity + deltaY }));
|
|
2581
|
+
}
|
|
2582
|
+
},
|
|
2583
|
+
children: /* @__PURE__ */ jsxs11("div", { className: "absolute top-1/2 -translate-y-1/2 -translate-x-1/2 left-1/2", children: [
|
|
2584
|
+
/* @__PURE__ */ jsx17(
|
|
2585
|
+
"div",
|
|
2586
|
+
{
|
|
2587
|
+
className: "absolute z-[1] top-1/2 -translate-y-1/2 -translate-x-1/2 left-1/2 w-full min-w-[40px] border border-divider/50 border-y-2 border-x-0 ",
|
|
2588
|
+
style: { height: `${itemHeight}px` }
|
|
2589
|
+
}
|
|
2590
|
+
),
|
|
2591
|
+
/* @__PURE__ */ jsx17(
|
|
2592
|
+
"div",
|
|
2593
|
+
{
|
|
2594
|
+
className: "flex-col-2 select-none",
|
|
2595
|
+
style: {
|
|
2596
|
+
transform: `translateY(${-transition * (distance + itemHeight)}px)`,
|
|
2597
|
+
columnGap: `${distance}px`
|
|
2598
|
+
},
|
|
2599
|
+
children: shownItems.map(({ name, index }, arrayIndex) => /* @__PURE__ */ jsx17(
|
|
2600
|
+
"div",
|
|
2601
|
+
{
|
|
2602
|
+
className: clsx12(
|
|
2603
|
+
`flex-col-2 items-center justify-center rounded-md`,
|
|
2604
|
+
{
|
|
2605
|
+
"text-primary font-bold": currentIndex === index,
|
|
2606
|
+
"text-on-background": currentIndex === index,
|
|
2607
|
+
"cursor-pointer": !disabled,
|
|
2608
|
+
"cursor-not-allowed": disabled
|
|
2609
|
+
}
|
|
2610
|
+
),
|
|
2611
|
+
style: {
|
|
2612
|
+
opacity: currentIndex !== index ? opacity(transition, arrayIndex, shownItems.length) : void 0,
|
|
2613
|
+
height: `${itemHeight}px`,
|
|
2614
|
+
maxHeight: `${itemHeight}px`
|
|
2615
|
+
},
|
|
2616
|
+
onClick: () => !disabled && setAnimation((prevState) => ({ ...prevState, targetIndex: index })),
|
|
2617
|
+
children: name
|
|
2618
|
+
},
|
|
2619
|
+
index
|
|
2620
|
+
))
|
|
2621
|
+
}
|
|
2622
|
+
)
|
|
2623
|
+
] })
|
|
2624
|
+
}
|
|
2625
|
+
);
|
|
2626
|
+
};
|
|
2627
|
+
|
|
2628
|
+
// src/components/user-action/input/Input.tsx
|
|
2629
|
+
import { forwardRef as forwardRef6, useEffect as useEffect17, useImperativeHandle, useRef as useRef9, useState as useState18 } from "react";
|
|
2630
|
+
import clsx13 from "clsx";
|
|
2631
|
+
|
|
2632
|
+
// src/hooks/useDelay.ts
|
|
2633
|
+
import { useEffect as useEffect16, useState as useState17 } from "react";
|
|
2634
|
+
var defaultOptions = {
|
|
2635
|
+
delay: 3e3,
|
|
2636
|
+
disabled: false
|
|
2637
|
+
};
|
|
2638
|
+
function useDelay(options) {
|
|
2639
|
+
const [timer, setTimer] = useState17(void 0);
|
|
2640
|
+
const { delay, disabled } = {
|
|
2641
|
+
...defaultOptions,
|
|
2642
|
+
...options
|
|
2643
|
+
};
|
|
2644
|
+
const clearTimer = () => {
|
|
2645
|
+
clearTimeout(timer);
|
|
2646
|
+
setTimer(void 0);
|
|
2647
|
+
};
|
|
2648
|
+
const restartTimer = (onDelayFinish) => {
|
|
2649
|
+
if (disabled) {
|
|
2650
|
+
return;
|
|
2651
|
+
}
|
|
2652
|
+
clearTimeout(timer);
|
|
2653
|
+
setTimer(setTimeout(() => {
|
|
2654
|
+
onDelayFinish();
|
|
2655
|
+
setTimer(void 0);
|
|
2656
|
+
}, delay));
|
|
2657
|
+
};
|
|
2658
|
+
useEffect16(() => {
|
|
2659
|
+
return () => {
|
|
2660
|
+
clearTimeout(timer);
|
|
2661
|
+
};
|
|
2662
|
+
}, [timer]);
|
|
2663
|
+
useEffect16(() => {
|
|
2664
|
+
if (disabled) {
|
|
2665
|
+
clearTimeout(timer);
|
|
2666
|
+
setTimer(void 0);
|
|
2667
|
+
}
|
|
2668
|
+
}, [disabled, timer]);
|
|
2669
|
+
return { restartTimer, clearTimer, hasActiveTimer: !!timer };
|
|
2670
|
+
}
|
|
2671
|
+
|
|
2672
|
+
// src/hooks/focus/useFocusManagement.ts
|
|
2673
|
+
import { useCallback as useCallback7 } from "react";
|
|
2674
|
+
function useFocusManagement() {
|
|
2675
|
+
const getFocusableElements = useCallback7(() => {
|
|
2676
|
+
return Array.from(
|
|
2677
|
+
document.querySelectorAll(
|
|
2678
|
+
'input, button, select, textarea, a[href], [tabindex]:not([tabindex="-1"])'
|
|
2679
|
+
)
|
|
2680
|
+
).filter(
|
|
2681
|
+
(el) => el instanceof HTMLElement && !el.hasAttribute("disabled") && !el.hasAttribute("hidden") && el.tabIndex !== -1
|
|
2682
|
+
);
|
|
2683
|
+
}, []);
|
|
2684
|
+
const getNextFocusElement = useCallback7(() => {
|
|
2685
|
+
const elements = getFocusableElements();
|
|
2686
|
+
if (elements.length === 0) {
|
|
2687
|
+
return void 0;
|
|
2688
|
+
}
|
|
2689
|
+
let nextElement = elements[0];
|
|
2690
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
2691
|
+
const currentIndex = elements.indexOf(document.activeElement);
|
|
2692
|
+
nextElement = elements[(currentIndex + 1) % elements.length];
|
|
2693
|
+
}
|
|
2694
|
+
return nextElement;
|
|
2695
|
+
}, [getFocusableElements]);
|
|
2696
|
+
const focusNext = useCallback7(() => {
|
|
2697
|
+
const nextElement = getNextFocusElement();
|
|
2698
|
+
nextElement?.focus();
|
|
2699
|
+
}, [getNextFocusElement]);
|
|
2700
|
+
const getPreviousFocusElement = useCallback7(() => {
|
|
2701
|
+
const elements = getFocusableElements();
|
|
2702
|
+
if (elements.length === 0) {
|
|
2703
|
+
return void 0;
|
|
2704
|
+
}
|
|
2705
|
+
let previousElement = elements[0];
|
|
2706
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
2707
|
+
const currentIndex = elements.indexOf(document.activeElement);
|
|
2708
|
+
if (currentIndex === 0) {
|
|
2709
|
+
previousElement = elements[elements.length - 1];
|
|
2710
|
+
} else {
|
|
2711
|
+
previousElement = elements[currentIndex - 1];
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
return previousElement;
|
|
2715
|
+
}, [getFocusableElements]);
|
|
2716
|
+
const focusPrevious = useCallback7(() => {
|
|
2717
|
+
const previousElement = getPreviousFocusElement();
|
|
2718
|
+
if (previousElement) previousElement.focus();
|
|
2719
|
+
}, [getPreviousFocusElement]);
|
|
2720
|
+
return {
|
|
2721
|
+
getFocusableElements,
|
|
2722
|
+
getNextFocusElement,
|
|
2723
|
+
getPreviousFocusElement,
|
|
2724
|
+
focusNext,
|
|
2725
|
+
focusPrevious
|
|
2726
|
+
};
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2729
|
+
// src/components/user-action/input/Input.tsx
|
|
2730
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
2731
|
+
var defaultEditCompleteOptions = {
|
|
2732
|
+
allowEnterComplete: false,
|
|
2733
|
+
onBlur: true,
|
|
2734
|
+
afterDelay: true,
|
|
2735
|
+
delay: 2500
|
|
2736
|
+
};
|
|
2737
|
+
var Input = forwardRef6(function Input2({
|
|
2738
|
+
value,
|
|
2739
|
+
onChange,
|
|
2740
|
+
onChangeText,
|
|
2741
|
+
onEditCompleted,
|
|
2742
|
+
editCompleteOptions,
|
|
2743
|
+
disabled = false,
|
|
2744
|
+
invalid = false,
|
|
2745
|
+
defaultStyle = true,
|
|
2746
|
+
className,
|
|
2747
|
+
...props
|
|
2748
|
+
}, forwardedRef) {
|
|
2749
|
+
const {
|
|
2750
|
+
onBlur: allowEditCompleteOnBlur,
|
|
2751
|
+
afterDelay,
|
|
2752
|
+
delay,
|
|
2753
|
+
allowEnterComplete
|
|
2754
|
+
} = { ...defaultEditCompleteOptions, ...editCompleteOptions };
|
|
2755
|
+
const {
|
|
2756
|
+
restartTimer,
|
|
2757
|
+
clearTimer
|
|
2758
|
+
} = useDelay({ delay, disabled: !afterDelay });
|
|
2759
|
+
const innerRef = useRef9(null);
|
|
2760
|
+
useImperativeHandle(forwardedRef, () => innerRef.current);
|
|
2761
|
+
const { focusNext } = useFocusManagement();
|
|
2762
|
+
return /* @__PURE__ */ jsx18(
|
|
2763
|
+
"input",
|
|
2764
|
+
{
|
|
2765
|
+
...props,
|
|
2766
|
+
ref: innerRef,
|
|
2767
|
+
value,
|
|
2768
|
+
disabled,
|
|
2769
|
+
className: defaultStyle ? clsx13(
|
|
2770
|
+
"px-2.5 py-1.75 rounded-md border-1 text-sm",
|
|
2771
|
+
{
|
|
2772
|
+
"bg-input-background text-input-text hover:border-primary focus:border-primary": !disabled && !invalid,
|
|
2773
|
+
"bg-on-negative text-negative border-negative-border hover:border-negative-border-hover focus-visible:ring-negative-border": !disabled && invalid,
|
|
2774
|
+
"bg-disabled-background text-disabled-text border-disabled-border": disabled
|
|
2775
|
+
},
|
|
2776
|
+
className
|
|
2777
|
+
) : className,
|
|
2778
|
+
onKeyDown: (event) => {
|
|
2779
|
+
props.onKeyDown?.(event);
|
|
2780
|
+
if (!allowEnterComplete) {
|
|
2781
|
+
return;
|
|
2782
|
+
}
|
|
2783
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
2784
|
+
event.preventDefault();
|
|
2785
|
+
innerRef.current?.blur();
|
|
2786
|
+
onEditCompleted?.(event.target.value);
|
|
2787
|
+
focusNext();
|
|
2788
|
+
}
|
|
2789
|
+
},
|
|
2790
|
+
onBlur: (event) => {
|
|
2791
|
+
props.onBlur?.(event);
|
|
2792
|
+
if (allowEditCompleteOnBlur) {
|
|
2793
|
+
onEditCompleted?.(event.target.value);
|
|
2794
|
+
clearTimer();
|
|
2795
|
+
}
|
|
2796
|
+
},
|
|
2797
|
+
onChange: (event) => {
|
|
2798
|
+
onChange?.(event);
|
|
2799
|
+
const value2 = event.target.value;
|
|
2800
|
+
restartTimer(() => {
|
|
2801
|
+
innerRef.current?.blur();
|
|
2802
|
+
onEditCompleted?.(value2);
|
|
2803
|
+
});
|
|
2804
|
+
onChangeText?.(value2);
|
|
2805
|
+
},
|
|
2806
|
+
"aria-invalid": props["aria-invalid"] ?? invalid,
|
|
2807
|
+
"aria-disabled": props["aria-disabled"] ?? disabled
|
|
2808
|
+
}
|
|
2809
|
+
);
|
|
2810
|
+
});
|
|
2811
|
+
var InputUncontrolled = ({
|
|
2812
|
+
value = "",
|
|
2813
|
+
onChangeText,
|
|
2814
|
+
...props
|
|
2815
|
+
}) => {
|
|
2816
|
+
const [usedValue, setUsedValue] = useState18(value);
|
|
2817
|
+
useEffect17(() => {
|
|
2818
|
+
setUsedValue(value);
|
|
2819
|
+
}, [value]);
|
|
2820
|
+
return /* @__PURE__ */ jsx18(
|
|
2821
|
+
Input,
|
|
2822
|
+
{
|
|
2823
|
+
...props,
|
|
2824
|
+
value: usedValue,
|
|
2825
|
+
onChangeText: (text) => {
|
|
2826
|
+
onChangeText?.(text);
|
|
2827
|
+
setUsedValue(text);
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
);
|
|
2831
|
+
};
|
|
2832
|
+
|
|
2833
|
+
// src/components/user-action/SearchBar.tsx
|
|
2834
|
+
import { Search } from "lucide-react";
|
|
2835
|
+
import { clsx as clsx14 } from "clsx";
|
|
2836
|
+
import { jsx as jsx19, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2837
|
+
var SearchBar = ({
|
|
2838
|
+
placeholder,
|
|
2839
|
+
onSearch,
|
|
2840
|
+
disableOnSearch,
|
|
2841
|
+
containerClassName,
|
|
2842
|
+
...inputProps
|
|
2843
|
+
}) => {
|
|
2844
|
+
const translation = useTranslation([formTranslation]);
|
|
2845
|
+
return /* @__PURE__ */ jsxs12("div", { className: clsx14("flex-row-2 justify-between items-center", containerClassName), children: [
|
|
2846
|
+
/* @__PURE__ */ jsx19(
|
|
2847
|
+
Input,
|
|
2848
|
+
{
|
|
2849
|
+
...inputProps,
|
|
2850
|
+
placeholder: placeholder ?? translation("search")
|
|
2851
|
+
}
|
|
2852
|
+
),
|
|
2853
|
+
onSearch && /* @__PURE__ */ jsx19(IconButton, { color: "neutral", disabled: disableOnSearch, onClick: onSearch, children: /* @__PURE__ */ jsx19(Search, { className: "w-full h-full" }) })
|
|
2854
|
+
] });
|
|
2855
|
+
};
|
|
2856
|
+
|
|
2857
|
+
// src/components/user-action/Textarea.tsx
|
|
2858
|
+
import { forwardRef as forwardRef7, useEffect as useEffect18, useId as useId2, useState as useState19 } from "react";
|
|
2859
|
+
import clsx15 from "clsx";
|
|
2860
|
+
import { jsx as jsx20, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2861
|
+
var Textarea = forwardRef7(function Textarea2({
|
|
2862
|
+
id,
|
|
2863
|
+
onChange,
|
|
2864
|
+
onChangeText,
|
|
2865
|
+
onBlur,
|
|
2866
|
+
onEditCompleted,
|
|
2867
|
+
saveDelayOptions,
|
|
2868
|
+
defaultStyle = true,
|
|
2869
|
+
invalid = false,
|
|
2870
|
+
disabled = false,
|
|
2871
|
+
className,
|
|
2872
|
+
...props
|
|
2873
|
+
}, ref) {
|
|
2874
|
+
const { restartTimer, clearTimer } = useDelay(saveDelayOptions);
|
|
2875
|
+
const onEditCompletedWrapper = (text) => {
|
|
2876
|
+
onEditCompleted?.(text);
|
|
2877
|
+
clearTimer();
|
|
2878
|
+
};
|
|
2879
|
+
return /* @__PURE__ */ jsx20(
|
|
2880
|
+
"textarea",
|
|
2881
|
+
{
|
|
2882
|
+
ref,
|
|
2883
|
+
id,
|
|
2884
|
+
className: clsx15(
|
|
2885
|
+
"resize-none w-full h-32 overflow-y-scroll",
|
|
2886
|
+
"py-2 px-3 rounded-md border-1",
|
|
2887
|
+
{
|
|
2888
|
+
"bg-input-background text-input-text hover:border-primary focus-within:border-primary focus-within:ring-2 ring-focus": !disabled && !invalid,
|
|
2889
|
+
"bg-on-negative text-negative border-negative-border hover:border-negative-border-hover focus-visible:ring-negative-border": invalid && !disabled && defaultStyle,
|
|
2890
|
+
"text-disabled-text bg-disabled-background border-disabled-border": disabled && defaultStyle
|
|
2891
|
+
},
|
|
2892
|
+
className
|
|
2893
|
+
),
|
|
2894
|
+
onChange: (event) => {
|
|
2895
|
+
const value = event.target.value;
|
|
2896
|
+
restartTimer(() => {
|
|
2897
|
+
onEditCompletedWrapper(value);
|
|
2898
|
+
});
|
|
2899
|
+
onChange?.(event);
|
|
2900
|
+
onChangeText?.(value);
|
|
2901
|
+
},
|
|
2902
|
+
onBlur: (event) => {
|
|
2903
|
+
onBlur?.(event);
|
|
2904
|
+
onEditCompletedWrapper(event.target.value);
|
|
2905
|
+
},
|
|
2906
|
+
disabled,
|
|
2907
|
+
...props
|
|
2908
|
+
}
|
|
2909
|
+
);
|
|
2910
|
+
});
|
|
2911
|
+
var TextareaUncontrolled = ({
|
|
2912
|
+
value = "",
|
|
2913
|
+
onChangeText = noop,
|
|
2914
|
+
...props
|
|
2915
|
+
}) => {
|
|
2916
|
+
const [text, setText] = useState19(value);
|
|
2917
|
+
useEffect18(() => {
|
|
2918
|
+
setText(value);
|
|
2919
|
+
}, [value]);
|
|
2920
|
+
return /* @__PURE__ */ jsx20(
|
|
2921
|
+
Textarea,
|
|
2922
|
+
{
|
|
2923
|
+
...props,
|
|
2924
|
+
value: text,
|
|
2925
|
+
onChangeText: (text2) => {
|
|
2926
|
+
setText(text2);
|
|
2927
|
+
onChangeText(text2);
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
);
|
|
2931
|
+
};
|
|
2932
|
+
var TextareaWithHeadline = ({
|
|
2933
|
+
id,
|
|
2934
|
+
headline,
|
|
2935
|
+
headlineProps,
|
|
2936
|
+
disabled,
|
|
2937
|
+
className,
|
|
2938
|
+
containerClassName,
|
|
2939
|
+
...props
|
|
2940
|
+
}) => {
|
|
2941
|
+
const genId = useId2();
|
|
2942
|
+
const usedId = id ?? genId;
|
|
2943
|
+
return /* @__PURE__ */ jsxs13(
|
|
2944
|
+
"div",
|
|
2945
|
+
{
|
|
2946
|
+
className: clsx15(
|
|
2947
|
+
"group flex-col-3 border-2 rounded-lg",
|
|
2948
|
+
{
|
|
2949
|
+
"bg-input-background text-input-text hover:border-primary focus-within:border-primary": !disabled,
|
|
2950
|
+
"border-disabled-border bg-disabled-background cursor-not-allowed": disabled
|
|
2951
|
+
},
|
|
2952
|
+
containerClassName
|
|
2953
|
+
),
|
|
2954
|
+
children: [
|
|
2955
|
+
headline && /* @__PURE__ */ jsx20(Label, { size: "md", ...headlineProps, htmlFor: usedId, children: headline }),
|
|
2956
|
+
/* @__PURE__ */ jsx20(
|
|
2957
|
+
Textarea,
|
|
2958
|
+
{
|
|
2959
|
+
...props,
|
|
2960
|
+
id: usedId,
|
|
2961
|
+
className: clsx15(
|
|
2962
|
+
"border-transparent focus:ring-0 focus-visible:ring-0 resize-none h-32",
|
|
2963
|
+
className
|
|
2964
|
+
),
|
|
2965
|
+
defaultStyle: false
|
|
2966
|
+
}
|
|
2967
|
+
)
|
|
2968
|
+
]
|
|
2969
|
+
}
|
|
2970
|
+
);
|
|
2971
|
+
};
|
|
2972
|
+
|
|
2973
|
+
// src/components/user-action/Tooltip.tsx
|
|
2974
|
+
import { clsx as clsx16 } from "clsx";
|
|
2975
|
+
import { jsx as jsx21, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2976
|
+
var Tooltip = ({
|
|
2977
|
+
tooltip,
|
|
2978
|
+
children,
|
|
2979
|
+
animationDelay = 650,
|
|
2980
|
+
tooltipClassName = "",
|
|
2981
|
+
containerClassName = "",
|
|
2982
|
+
position = "bottom",
|
|
2983
|
+
zIndex = 10
|
|
2984
|
+
}) => {
|
|
2985
|
+
const { isHovered, handlers } = useHoverState();
|
|
2986
|
+
const positionClasses = {
|
|
2987
|
+
top: `bottom-full left-1/2 -translate-x-1/2 mb-[6px]`,
|
|
2988
|
+
bottom: `top-full left-1/2 -translate-x-1/2 mt-[6px]`,
|
|
2989
|
+
left: `right-full top-1/2 -translate-y-1/2 mr-[6px]`,
|
|
2990
|
+
right: `left-full top-1/2 -translate-y-1/2 ml-[6px]`
|
|
2991
|
+
};
|
|
2992
|
+
const triangleSize = 6;
|
|
2993
|
+
const triangleClasses = {
|
|
2994
|
+
top: `top-full left-1/2 -translate-x-1/2 border-t-tooltip-background border-l-transparent border-r-transparent`,
|
|
2995
|
+
bottom: `bottom-full left-1/2 -translate-x-1/2 border-b-tooltip-background border-l-transparent border-r-transparent`,
|
|
2996
|
+
left: `left-full top-1/2 -translate-y-1/2 border-l-tooltip-background border-t-transparent border-b-transparent`,
|
|
2997
|
+
right: `right-full top-1/2 -translate-y-1/2 border-r-tooltip-background border-t-transparent border-b-transparent`
|
|
2998
|
+
};
|
|
2999
|
+
const triangleStyle = {
|
|
3000
|
+
top: { borderWidth: `${triangleSize}px ${triangleSize}px 0 ${triangleSize}px` },
|
|
3001
|
+
bottom: { borderWidth: `0 ${triangleSize}px ${triangleSize}px ${triangleSize}px` },
|
|
3002
|
+
left: { borderWidth: `${triangleSize}px 0 ${triangleSize}px ${triangleSize}px` },
|
|
3003
|
+
right: { borderWidth: `${triangleSize}px ${triangleSize}px ${triangleSize}px 0` }
|
|
3004
|
+
};
|
|
3005
|
+
return /* @__PURE__ */ jsxs14(
|
|
3006
|
+
"div",
|
|
3007
|
+
{
|
|
3008
|
+
className: clsx16("relative inline-block", containerClassName),
|
|
3009
|
+
...handlers,
|
|
3010
|
+
children: [
|
|
3011
|
+
children,
|
|
3012
|
+
isHovered && /* @__PURE__ */ jsxs14(
|
|
3013
|
+
"div",
|
|
3014
|
+
{
|
|
3015
|
+
className: clsx16(
|
|
3016
|
+
`opacity-0 absolute text-xs font-semibold text-tooltip-text px-2 py-1 rounded whitespace-nowrap
|
|
3017
|
+
animate-tooltip-fade-in shadow-around-md bg-tooltip-background`,
|
|
3018
|
+
positionClasses[position],
|
|
3019
|
+
tooltipClassName
|
|
3020
|
+
),
|
|
3021
|
+
style: { zIndex, animationDelay: animationDelay + "ms" },
|
|
3022
|
+
children: [
|
|
3023
|
+
tooltip,
|
|
3024
|
+
/* @__PURE__ */ jsx21(
|
|
3025
|
+
"div",
|
|
3026
|
+
{
|
|
3027
|
+
className: clsx16(`absolute w-0 h-0`, triangleClasses[position]),
|
|
3028
|
+
style: { ...triangleStyle[position], zIndex: zIndex + 1 }
|
|
3029
|
+
}
|
|
3030
|
+
)
|
|
3031
|
+
]
|
|
3032
|
+
}
|
|
3033
|
+
)
|
|
3034
|
+
]
|
|
3035
|
+
}
|
|
3036
|
+
);
|
|
3037
|
+
};
|
|
3038
|
+
|
|
3039
|
+
// src/components/user-action/input/InsideLabelInput.tsx
|
|
3040
|
+
import { useId as useId3 } from "react";
|
|
3041
|
+
import { forwardRef as forwardRef8, useEffect as useEffect19, useState as useState20 } from "react";
|
|
3042
|
+
import clsx17 from "clsx";
|
|
3043
|
+
import { jsx as jsx22, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3044
|
+
var InsideLabelInput = forwardRef8(function InsideLabelInput2({
|
|
3045
|
+
id: customId,
|
|
3046
|
+
label,
|
|
3047
|
+
...props
|
|
3048
|
+
}, forwardedRef) {
|
|
3049
|
+
const { value } = props;
|
|
3050
|
+
const [isFocused, setIsFocused] = useState20(false);
|
|
3051
|
+
const generatedId = useId3();
|
|
3052
|
+
const id = customId ?? generatedId;
|
|
3053
|
+
return /* @__PURE__ */ jsxs15("div", { className: clsx17("relative"), children: [
|
|
3054
|
+
/* @__PURE__ */ jsx22(
|
|
3055
|
+
Input,
|
|
3056
|
+
{
|
|
3057
|
+
...props,
|
|
3058
|
+
id,
|
|
3059
|
+
className: clsx17("h-14 px-4 pb-2 py-6.5", props.className),
|
|
3060
|
+
ref: forwardedRef,
|
|
3061
|
+
"aria-labelledby": id + "-label",
|
|
3062
|
+
onFocus: (event) => {
|
|
3063
|
+
props.onFocus?.(event);
|
|
3064
|
+
setIsFocused(true);
|
|
3065
|
+
},
|
|
3066
|
+
onBlur: (event) => {
|
|
3067
|
+
props.onBlur?.(event);
|
|
3068
|
+
setIsFocused(false);
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3071
|
+
),
|
|
3072
|
+
/* @__PURE__ */ jsx22(
|
|
3073
|
+
"label",
|
|
3074
|
+
{
|
|
3075
|
+
id: id + "-label",
|
|
3076
|
+
"aria-hidden": true,
|
|
3077
|
+
"data-display": isFocused || !!value ? "small" : "full",
|
|
3078
|
+
className: clsx17(
|
|
3079
|
+
"absolute left-4 top-2 transition-all pointer-events-none touch-none",
|
|
3080
|
+
"data-[display=small]:top-2 data-[display=small]:h-force-4.5 data-[display=small]:typography-caption-sm-regular data-[display=small]:overflow-y-hidden",
|
|
3081
|
+
"data-[display=full]:top-1/2 data-[display=full]:-translate-y-1/2 data-[display=full]:typography-body-md-regular"
|
|
3082
|
+
),
|
|
3083
|
+
children: label
|
|
3084
|
+
}
|
|
3085
|
+
)
|
|
3086
|
+
] });
|
|
3087
|
+
});
|
|
3088
|
+
var InsideLabelInputUncontrolled = ({
|
|
3089
|
+
value: initialValue,
|
|
3090
|
+
...props
|
|
3091
|
+
}) => {
|
|
3092
|
+
const [value, setValue] = useState20(initialValue);
|
|
3093
|
+
useEffect19(() => {
|
|
3094
|
+
setValue(initialValue);
|
|
3095
|
+
}, [initialValue]);
|
|
3096
|
+
return /* @__PURE__ */ jsx22(
|
|
3097
|
+
InsideLabelInput,
|
|
3098
|
+
{
|
|
3099
|
+
...props,
|
|
3100
|
+
value,
|
|
3101
|
+
onChangeText: (text) => {
|
|
3102
|
+
props.onChangeText?.(text);
|
|
3103
|
+
setValue(text);
|
|
3104
|
+
}
|
|
3105
|
+
}
|
|
3106
|
+
);
|
|
3107
|
+
};
|
|
3108
|
+
|
|
3109
|
+
// src/components/user-action/input/ToggleableInput.tsx
|
|
3110
|
+
import { forwardRef as forwardRef9, useEffect as useEffect20, useImperativeHandle as useImperativeHandle2, useRef as useRef10, useState as useState21 } from "react";
|
|
3111
|
+
import { Pencil } from "lucide-react";
|
|
3112
|
+
import clsx18 from "clsx";
|
|
3113
|
+
import { jsx as jsx23, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3114
|
+
var ToggleableInput = forwardRef9(function ToggleableInput2({
|
|
3115
|
+
value,
|
|
3116
|
+
initialState = "display",
|
|
3117
|
+
editCompleteOptions,
|
|
3118
|
+
...props
|
|
3119
|
+
}, forwardedRef) {
|
|
3120
|
+
const [isEditing, setIsEditing] = useState21(initialState !== "display");
|
|
3121
|
+
const innerRef = useRef10(null);
|
|
3122
|
+
useImperativeHandle2(forwardedRef, () => innerRef.current);
|
|
3123
|
+
useEffect20(() => {
|
|
3124
|
+
if (isEditing) {
|
|
3125
|
+
innerRef.current?.focus();
|
|
3126
|
+
}
|
|
3127
|
+
}, [isEditing]);
|
|
3128
|
+
return /* @__PURE__ */ jsxs16("div", { className: clsx18("relative flex-row-2", { "flex-1": isEditing }), children: [
|
|
3129
|
+
/* @__PURE__ */ jsx23(
|
|
3130
|
+
Input,
|
|
3131
|
+
{
|
|
3132
|
+
...props,
|
|
3133
|
+
ref: innerRef,
|
|
3134
|
+
value,
|
|
3135
|
+
onEditCompleted: (text) => {
|
|
3136
|
+
props.onEditCompleted?.(text);
|
|
3137
|
+
setIsEditing(false);
|
|
3138
|
+
},
|
|
3139
|
+
onFocus: (event) => {
|
|
3140
|
+
props.onFocus?.(event);
|
|
3141
|
+
setIsEditing(true);
|
|
3142
|
+
event.target.select();
|
|
3143
|
+
},
|
|
3144
|
+
editCompleteOptions: {
|
|
3145
|
+
...editCompleteOptions,
|
|
3146
|
+
allowEnterComplete: true
|
|
3147
|
+
},
|
|
3148
|
+
className: clsx18(`w-full ring-0 outline-0 decoration-primary underline-offset-4`, {
|
|
3149
|
+
"underline": isEditing,
|
|
3150
|
+
"text-transparent": !isEditing
|
|
3151
|
+
}),
|
|
3152
|
+
defaultStyle: false
|
|
3153
|
+
}
|
|
3154
|
+
),
|
|
3155
|
+
!isEditing && /* @__PURE__ */ jsxs16("div", { className: "absolute left-0 flex-row-2 items-center pointer-events-none touch-none w-full overflow-hidden", children: [
|
|
3156
|
+
/* @__PURE__ */ jsx23("span", { className: clsx18(" truncate"), children: value }),
|
|
3157
|
+
/* @__PURE__ */ jsx23(Pencil, { className: clsx18(`size-force-4`, { "text-transparent": isEditing }) })
|
|
3158
|
+
] })
|
|
3159
|
+
] });
|
|
3160
|
+
});
|
|
3161
|
+
var ToggleableInputUncontrolled = ({
|
|
3162
|
+
value: initialValue,
|
|
3163
|
+
onChangeText,
|
|
3164
|
+
...restProps
|
|
3165
|
+
}) => {
|
|
3166
|
+
const [value, setValue] = useState21(initialValue);
|
|
3167
|
+
useEffect20(() => {
|
|
3168
|
+
setValue(initialValue);
|
|
3169
|
+
}, [initialValue]);
|
|
3170
|
+
return /* @__PURE__ */ jsx23(
|
|
3171
|
+
ToggleableInput,
|
|
3172
|
+
{
|
|
3173
|
+
value,
|
|
3174
|
+
onChangeText: (text) => {
|
|
3175
|
+
onChangeText?.(text);
|
|
3176
|
+
setValue(text);
|
|
3177
|
+
},
|
|
3178
|
+
...restProps
|
|
3179
|
+
}
|
|
3180
|
+
);
|
|
3181
|
+
};
|
|
3182
|
+
|
|
3183
|
+
// src/components/user-action/select/Select.tsx
|
|
3184
|
+
import {
|
|
3185
|
+
createContext as createContext3,
|
|
3186
|
+
forwardRef as forwardRef10,
|
|
3187
|
+
useCallback as useCallback10,
|
|
3188
|
+
useContext as useContext3,
|
|
3189
|
+
useEffect as useEffect24,
|
|
3190
|
+
useId as useId5,
|
|
3191
|
+
useImperativeHandle as useImperativeHandle3,
|
|
3192
|
+
useRef as useRef12,
|
|
3193
|
+
useState as useState25
|
|
3194
|
+
} from "react";
|
|
3195
|
+
import clsx20 from "clsx";
|
|
3196
|
+
|
|
3197
|
+
// src/hooks/focus/useFocusTrap.ts
|
|
3198
|
+
import { useCallback as useCallback8, useEffect as useEffect22, useId as useId4, useRef as useRef11, useState as useState23 } from "react";
|
|
3199
|
+
|
|
3200
|
+
// src/hooks/focus/useIsMounted.ts
|
|
3201
|
+
import { useEffect as useEffect21, useLayoutEffect as useLayoutEffect3, useState as useState22 } from "react";
|
|
3202
|
+
var isClient = typeof window !== "undefined" && typeof document !== "undefined";
|
|
3203
|
+
var useIsomorphicEffect = isClient ? useLayoutEffect3 : useEffect21;
|
|
3204
|
+
var useIsMounted = () => {
|
|
3205
|
+
const [isMounted, setIsMounted] = useState22(false);
|
|
3206
|
+
useIsomorphicEffect(() => {
|
|
3207
|
+
setIsMounted(true);
|
|
3208
|
+
return () => {
|
|
3209
|
+
setIsMounted(false);
|
|
3210
|
+
};
|
|
3211
|
+
}, []);
|
|
3212
|
+
return isMounted;
|
|
3213
|
+
};
|
|
3214
|
+
|
|
3215
|
+
// src/hooks/focus/useFocusTrap.ts
|
|
3216
|
+
var createFocusGuard = () => {
|
|
3217
|
+
const div = document.createElement("div");
|
|
3218
|
+
Object.assign(div.style, {
|
|
3219
|
+
opacity: "0",
|
|
3220
|
+
outline: "none",
|
|
3221
|
+
boxShadow: "none",
|
|
3222
|
+
position: "fixed",
|
|
3223
|
+
pointerEvents: "none",
|
|
3224
|
+
touchAction: "none"
|
|
3225
|
+
});
|
|
3226
|
+
div.tabIndex = 0;
|
|
3227
|
+
div.setAttribute("data-hw-focus-guard", "");
|
|
3228
|
+
document.body.appendChild(div);
|
|
3229
|
+
return div;
|
|
3230
|
+
};
|
|
3231
|
+
function getContainedFocusableElements(element) {
|
|
3232
|
+
return element?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
3233
|
+
}
|
|
3234
|
+
var FocusTrapService = class {
|
|
3235
|
+
constructor() {
|
|
3236
|
+
// The last entry is always the active one
|
|
3237
|
+
this.listeners = [];
|
|
3238
|
+
this.onFocusIn = (event) => {
|
|
3239
|
+
const active = this.getActive();
|
|
3240
|
+
if (!active || !active.container.current) return;
|
|
3241
|
+
const { container } = active;
|
|
3242
|
+
if (!container.current.contains(event.target)) {
|
|
3243
|
+
this.focusElement();
|
|
3244
|
+
}
|
|
3245
|
+
};
|
|
3246
|
+
}
|
|
3247
|
+
getActive() {
|
|
3248
|
+
if (this.listeners.length === 0) return void 0;
|
|
3249
|
+
return this.listeners[this.listeners.length - 1];
|
|
3250
|
+
}
|
|
3251
|
+
focusElement() {
|
|
3252
|
+
const active = this.getActive();
|
|
3253
|
+
if (!active) return;
|
|
3254
|
+
const { container, initialFocusElement } = active;
|
|
3255
|
+
const containerElement = container.current;
|
|
3256
|
+
if (initialFocusElement?.current) {
|
|
3257
|
+
initialFocusElement.current.focus();
|
|
3258
|
+
} else {
|
|
3259
|
+
const elements = getContainedFocusableElements(containerElement);
|
|
3260
|
+
if (elements && elements.length > 0) {
|
|
3261
|
+
const first = elements.item(0);
|
|
3262
|
+
first.focus();
|
|
3263
|
+
} else {
|
|
3264
|
+
containerElement.focus();
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
removeGuards() {
|
|
3269
|
+
document.querySelectorAll("[data-hw-focus-guard]").forEach((node) => node.remove());
|
|
3270
|
+
}
|
|
3271
|
+
addGuards() {
|
|
3272
|
+
document.body.insertAdjacentElement("afterbegin", createFocusGuard());
|
|
3273
|
+
document.body.insertAdjacentElement("beforeend", createFocusGuard());
|
|
3274
|
+
}
|
|
3275
|
+
activate() {
|
|
3276
|
+
document.addEventListener("focusin", this.onFocusIn);
|
|
3277
|
+
this.addGuards();
|
|
3278
|
+
}
|
|
3279
|
+
deactivate() {
|
|
3280
|
+
document.removeEventListener("focusin", this.onFocusIn);
|
|
3281
|
+
this.removeGuards();
|
|
3282
|
+
}
|
|
3283
|
+
register(listener) {
|
|
3284
|
+
this.listeners.push(listener);
|
|
3285
|
+
if (this.listeners.length === 1) {
|
|
3286
|
+
this.activate();
|
|
3287
|
+
}
|
|
3288
|
+
const active = listener;
|
|
3289
|
+
this.listeners.forEach((listener2) => {
|
|
3290
|
+
const { focus, pause } = listener2;
|
|
3291
|
+
if (listener2 === active) {
|
|
3292
|
+
focus();
|
|
3293
|
+
} else {
|
|
3294
|
+
pause();
|
|
3295
|
+
}
|
|
3296
|
+
});
|
|
3297
|
+
}
|
|
3298
|
+
unregister(id) {
|
|
3299
|
+
const index = this.listeners.findIndex((trap) => trap.id === id);
|
|
3300
|
+
if (index !== -1) {
|
|
3301
|
+
const isActive = index === this.listeners.length - 1;
|
|
3302
|
+
const listener = this.listeners[index];
|
|
3303
|
+
this.listeners = this.listeners.filter((listener2) => listener2.id !== id);
|
|
3304
|
+
if (isActive) {
|
|
3305
|
+
this.deactivate();
|
|
3306
|
+
listener.focusLast();
|
|
3307
|
+
const active = this.getActive();
|
|
3308
|
+
this.listeners.forEach((listener2) => {
|
|
3309
|
+
const { pause, unpause } = listener2;
|
|
3310
|
+
if (listener2 === active) {
|
|
3311
|
+
unpause();
|
|
3312
|
+
} else {
|
|
3313
|
+
pause();
|
|
3314
|
+
}
|
|
3315
|
+
});
|
|
3316
|
+
if (this.listeners.length > 0) {
|
|
3317
|
+
this.activate();
|
|
3318
|
+
}
|
|
3319
|
+
}
|
|
3320
|
+
} else {
|
|
3321
|
+
console.warn(`Unable to unregister id ${id}: not found`);
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
};
|
|
3325
|
+
var service = new FocusTrapService();
|
|
3326
|
+
var useFocusTrap = ({
|
|
3327
|
+
container,
|
|
3328
|
+
active = true,
|
|
3329
|
+
initialFocus,
|
|
3330
|
+
focusFirst = true
|
|
3331
|
+
}) => {
|
|
3332
|
+
const lastFocusRef = useRef11(null);
|
|
3333
|
+
const [paused, setPaused] = useState23(false);
|
|
3334
|
+
const isMounted = useIsMounted();
|
|
3335
|
+
const id = useId4();
|
|
3336
|
+
const focusElement = useCallback8(() => {
|
|
3337
|
+
const containerElement = container.current;
|
|
3338
|
+
if (initialFocus?.current) {
|
|
3339
|
+
initialFocus.current.focus();
|
|
3340
|
+
} else {
|
|
3341
|
+
const elements = getContainedFocusableElements(containerElement);
|
|
3342
|
+
if (elements && elements.length > 0) {
|
|
3343
|
+
const first = elements.item(0);
|
|
3344
|
+
first.focus();
|
|
3345
|
+
} else {
|
|
3346
|
+
containerElement.focus();
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3349
|
+
}, [container, initialFocus]);
|
|
3350
|
+
useEffect22(() => {
|
|
3351
|
+
if (active && isMounted) {
|
|
3352
|
+
let pause = function() {
|
|
3353
|
+
setPaused(true);
|
|
3354
|
+
}, unpause = function() {
|
|
3355
|
+
setPaused(false);
|
|
3356
|
+
if (!container.current.contains(document.activeElement)) {
|
|
3357
|
+
focusElement();
|
|
3358
|
+
}
|
|
3359
|
+
}, focus = function() {
|
|
3360
|
+
focusElement();
|
|
3361
|
+
setPaused(false);
|
|
3362
|
+
}, focusLast = function() {
|
|
3363
|
+
lastFocusRef.current?.focus();
|
|
3364
|
+
};
|
|
3365
|
+
if (!lastFocusRef.current) {
|
|
3366
|
+
lastFocusRef.current = document.activeElement;
|
|
3367
|
+
}
|
|
3368
|
+
service.register({ id, pause, focus, focusLast, unpause, container, initialFocusElement: initialFocus });
|
|
3369
|
+
return () => {
|
|
3370
|
+
service.unregister(id);
|
|
3371
|
+
lastFocusRef.current = void 0;
|
|
3372
|
+
};
|
|
3373
|
+
}
|
|
3374
|
+
}, [active, container, focusElement, id, initialFocus, isMounted]);
|
|
3375
|
+
useEffect22(() => {
|
|
3376
|
+
if (active && !paused && isMounted) {
|
|
3377
|
+
let onKeyDown = function(event) {
|
|
3378
|
+
const key = event.key;
|
|
3379
|
+
const elements = getContainedFocusableElements(containerElement);
|
|
3380
|
+
const active2 = document.activeElement;
|
|
3381
|
+
const index = [...elements].findIndex((value) => value === active2);
|
|
3382
|
+
if (index === -1 || event.altKey || event.ctrlKey || event.metaKey) {
|
|
3383
|
+
return;
|
|
3384
|
+
}
|
|
3385
|
+
if (key === "Tab") {
|
|
3386
|
+
const next = event.shiftKey ? -1 : 1;
|
|
3387
|
+
const nextIndex = (index + next + elements.length) % elements.length;
|
|
3388
|
+
const nextElement = elements[nextIndex];
|
|
3389
|
+
nextElement.focus();
|
|
3390
|
+
event.preventDefault();
|
|
3391
|
+
}
|
|
3392
|
+
};
|
|
3393
|
+
const containerElement = container.current;
|
|
3394
|
+
containerElement.addEventListener("keydown", onKeyDown);
|
|
3395
|
+
return () => {
|
|
3396
|
+
containerElement.removeEventListener("keydown", onKeyDown);
|
|
3397
|
+
};
|
|
3398
|
+
}
|
|
3399
|
+
}, [active, paused, isMounted, container, initialFocus, focusFirst, focusElement]);
|
|
3400
|
+
};
|
|
3401
|
+
|
|
3402
|
+
// src/utils/match.ts
|
|
3403
|
+
var match = (key, values) => {
|
|
3404
|
+
return values[key];
|
|
3405
|
+
};
|
|
3406
|
+
|
|
3407
|
+
// src/components/user-action/select/Select.tsx
|
|
3408
|
+
import { CheckIcon as CheckIcon2, Plus, XIcon } from "lucide-react";
|
|
3409
|
+
|
|
3410
|
+
// src/components/layout/Chip.tsx
|
|
3411
|
+
import clsx19 from "clsx";
|
|
3412
|
+
import { jsx as jsx24, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3413
|
+
var Chip = ({
|
|
3414
|
+
children,
|
|
3415
|
+
trailingIcon,
|
|
3416
|
+
color = "default",
|
|
3417
|
+
size = "md",
|
|
3418
|
+
icon = false,
|
|
3419
|
+
variant = "normal",
|
|
3420
|
+
className = "",
|
|
3421
|
+
...restProps
|
|
3422
|
+
}) => {
|
|
3423
|
+
const colorMapping = {
|
|
3424
|
+
default: "text-tag-default-text bg-tag-default-background",
|
|
3425
|
+
dark: "text-tag-dark-text bg-tag-dark-background",
|
|
3426
|
+
red: "text-tag-red-text bg-tag-red-background",
|
|
3427
|
+
yellow: "text-tag-yellow-text bg-tag-yellow-background",
|
|
3428
|
+
green: "text-tag-green-text bg-tag-green-background",
|
|
3429
|
+
blue: "text-tag-blue-text bg-tag-blue-background",
|
|
3430
|
+
pink: "text-tag-pink-text bg-tag-pink-background",
|
|
3431
|
+
orange: "text-tag-orange-text bg-tag-orange-background"
|
|
3432
|
+
}[color];
|
|
3433
|
+
const colorMappingIcon = {
|
|
3434
|
+
default: "text-tag-default-icon",
|
|
3435
|
+
dark: "text-tag-dark-icon",
|
|
3436
|
+
red: "text-tag-red-icon",
|
|
3437
|
+
yellow: "text-tag-yellow-icon",
|
|
3438
|
+
green: "text-tag-green-icon",
|
|
3439
|
+
blue: "text-tag-blue-icon",
|
|
3440
|
+
pink: "text-tag-pink-icon",
|
|
3441
|
+
orange: "text-tag-orange-icon"
|
|
3442
|
+
}[color];
|
|
3443
|
+
return /* @__PURE__ */ jsxs17(
|
|
3444
|
+
"div",
|
|
3445
|
+
{
|
|
3446
|
+
...restProps,
|
|
3447
|
+
className: clsx19(
|
|
3448
|
+
`flex-row-0 w-fit font-semibold`,
|
|
3449
|
+
colorMapping,
|
|
3450
|
+
!icon ? {
|
|
3451
|
+
"px-1 py-0.5": size === "sm",
|
|
3452
|
+
"px-2 py-1": size === "md",
|
|
3453
|
+
"px-4 py-2": size === "lg"
|
|
3454
|
+
} : {
|
|
3455
|
+
"p-0.5": size === "sm",
|
|
3456
|
+
"p-1": size === "md",
|
|
3457
|
+
"p-2": size === "lg"
|
|
3458
|
+
},
|
|
3459
|
+
{
|
|
3460
|
+
"rounded-md": variant === "normal",
|
|
3461
|
+
"rounded-full": variant === "fullyRounded"
|
|
3462
|
+
},
|
|
3463
|
+
className
|
|
3464
|
+
),
|
|
3465
|
+
children: [
|
|
3466
|
+
children,
|
|
3467
|
+
trailingIcon && /* @__PURE__ */ jsx24("span", { className: colorMappingIcon, children: trailingIcon })
|
|
3468
|
+
]
|
|
3469
|
+
}
|
|
3470
|
+
);
|
|
3471
|
+
};
|
|
3472
|
+
|
|
3473
|
+
// src/hooks/useFloatingElement.ts
|
|
3474
|
+
import { useCallback as useCallback9, useEffect as useEffect23, useState as useState24 } from "react";
|
|
3475
|
+
function calculatePosition({
|
|
3476
|
+
windowRect,
|
|
3477
|
+
containerRect,
|
|
3478
|
+
anchorRect,
|
|
3479
|
+
options
|
|
3480
|
+
}) {
|
|
3481
|
+
const { verticalAlignment, horizontalAlignment, gap, screenPadding } = options;
|
|
3482
|
+
const windowWidth = windowRect.width;
|
|
3483
|
+
const windowHeight = windowRect.height;
|
|
3484
|
+
const maxWidth = windowWidth - 2 * screenPadding;
|
|
3485
|
+
const maxHeight = windowHeight - 2 * screenPadding;
|
|
3486
|
+
const width = Math.min(containerRect.width, maxWidth);
|
|
3487
|
+
const height = Math.min(containerRect.height, maxHeight);
|
|
3488
|
+
const leftSuggestion = {
|
|
3489
|
+
beforeStart: anchorRect.left - width - gap,
|
|
3490
|
+
afterStart: anchorRect.left,
|
|
3491
|
+
center: anchorRect.left + anchorRect.width / 2 - width / 2,
|
|
3492
|
+
beforeEnd: anchorRect.right - width,
|
|
3493
|
+
afterEnd: anchorRect.right + gap
|
|
3494
|
+
}[horizontalAlignment];
|
|
3495
|
+
const topSuggestion = {
|
|
3496
|
+
beforeStart: anchorRect.top - height - gap,
|
|
3497
|
+
afterStart: anchorRect.top,
|
|
3498
|
+
center: anchorRect.top + anchorRect.height / 2 - height / 2,
|
|
3499
|
+
beforeEnd: anchorRect.bottom - height,
|
|
3500
|
+
afterEnd: anchorRect.bottom + gap
|
|
3501
|
+
}[verticalAlignment];
|
|
3502
|
+
const left = clamp(leftSuggestion, [
|
|
3503
|
+
screenPadding,
|
|
3504
|
+
windowWidth - screenPadding - width
|
|
3505
|
+
]);
|
|
3506
|
+
const top = clamp(topSuggestion, [
|
|
3507
|
+
screenPadding,
|
|
3508
|
+
windowHeight - screenPadding - height
|
|
3509
|
+
]);
|
|
3510
|
+
return {
|
|
3511
|
+
left,
|
|
3512
|
+
top,
|
|
3513
|
+
maxWidth,
|
|
3514
|
+
maxHeight
|
|
3515
|
+
};
|
|
3516
|
+
}
|
|
3517
|
+
function useFloatingElement({
|
|
3518
|
+
active = true,
|
|
3519
|
+
windowRef,
|
|
3520
|
+
anchorRef,
|
|
3521
|
+
containerRef,
|
|
3522
|
+
isPolling = false,
|
|
3523
|
+
pollingInterval = 100,
|
|
3524
|
+
verticalAlignment = "afterEnd",
|
|
3525
|
+
horizontalAlignment = "afterStart",
|
|
3526
|
+
screenPadding = 16,
|
|
3527
|
+
gap = 4
|
|
3528
|
+
}) {
|
|
3529
|
+
const [style, setStyle] = useState24();
|
|
3530
|
+
const isMounted = useIsMounted();
|
|
3531
|
+
const calculate = useCallback9(() => {
|
|
3532
|
+
const containerRect = containerRef.current.getBoundingClientRect();
|
|
3533
|
+
const windowRect = windowRef?.current.getBoundingClientRect() ?? {
|
|
3534
|
+
top: 0,
|
|
3535
|
+
bottom: window.innerHeight,
|
|
3536
|
+
left: 0,
|
|
3537
|
+
right: window.innerWidth,
|
|
3538
|
+
width: window.innerWidth,
|
|
3539
|
+
height: window.innerHeight
|
|
3540
|
+
};
|
|
3541
|
+
const anchorElement = anchorRef?.current;
|
|
3542
|
+
if (anchorRef && !anchorElement) {
|
|
3543
|
+
console.warn("FloatingContainer anchor provided, but its value is undefined");
|
|
3544
|
+
}
|
|
3545
|
+
const anchorRect = anchorElement?.getBoundingClientRect() ?? windowRect;
|
|
3546
|
+
const calculateProps = {
|
|
3547
|
+
windowRect,
|
|
3548
|
+
anchorRect,
|
|
3549
|
+
containerRect,
|
|
3550
|
+
options: {
|
|
3551
|
+
horizontalAlignment,
|
|
3552
|
+
verticalAlignment,
|
|
3553
|
+
screenPadding,
|
|
3554
|
+
gap
|
|
3555
|
+
}
|
|
3556
|
+
};
|
|
3557
|
+
setStyle(calculatePosition(calculateProps));
|
|
3558
|
+
}, [anchorRef, containerRef, gap, horizontalAlignment, screenPadding, verticalAlignment, windowRef]);
|
|
3559
|
+
const height = containerRef.current?.getBoundingClientRect().height;
|
|
3560
|
+
const width = containerRef.current?.getBoundingClientRect().width;
|
|
3561
|
+
useEffect23(() => {
|
|
3562
|
+
if (active && isMounted) {
|
|
3563
|
+
calculate();
|
|
3564
|
+
} else {
|
|
3565
|
+
setStyle(void 0);
|
|
3566
|
+
}
|
|
3567
|
+
}, [calculate, active, isMounted, height, width]);
|
|
3568
|
+
useEffect23(() => {
|
|
3569
|
+
window.addEventListener("resize", calculate);
|
|
3570
|
+
let timeout;
|
|
3571
|
+
if (isPolling) {
|
|
3572
|
+
timeout = setInterval(calculate, pollingInterval);
|
|
3573
|
+
}
|
|
3574
|
+
return () => {
|
|
3575
|
+
window.removeEventListener("resize", calculate);
|
|
3576
|
+
if (timeout) {
|
|
3577
|
+
clearInterval(timeout);
|
|
3578
|
+
}
|
|
3579
|
+
};
|
|
3580
|
+
}, [calculate, isPolling, pollingInterval]);
|
|
3581
|
+
return style;
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3584
|
+
// src/components/user-action/select/Select.tsx
|
|
3585
|
+
import { createPortal as createPortal2 } from "react-dom";
|
|
3586
|
+
import { Fragment as Fragment5, jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3587
|
+
var defaultToggleOpenOptions = {
|
|
3588
|
+
highlightStartPosition: "first"
|
|
3589
|
+
};
|
|
3590
|
+
var SelectContext = createContext3(null);
|
|
3591
|
+
function useSelectContext() {
|
|
3592
|
+
const ctx = useContext3(SelectContext);
|
|
3593
|
+
if (!ctx) {
|
|
3594
|
+
throw new Error("SelectContext must be used within a ListBoxPrimitive");
|
|
3595
|
+
}
|
|
3596
|
+
return ctx;
|
|
3597
|
+
}
|
|
3598
|
+
var SelectRoot = ({
|
|
3599
|
+
children,
|
|
3600
|
+
id,
|
|
3601
|
+
value,
|
|
3602
|
+
onValueChanged,
|
|
3603
|
+
values,
|
|
3604
|
+
onValuesChanged,
|
|
3605
|
+
isOpen = false,
|
|
3606
|
+
disabled = false,
|
|
3607
|
+
invalid = false,
|
|
3608
|
+
isMultiSelect = false,
|
|
3609
|
+
iconAppearance = "left"
|
|
3610
|
+
}) => {
|
|
3611
|
+
const optionsRef = useRef12([]);
|
|
3612
|
+
const triggerRef = useRef12(null);
|
|
3613
|
+
const generatedId = useId5();
|
|
3614
|
+
const usedId = id ?? generatedId;
|
|
3615
|
+
const [internalState, setInternalState] = useState25({
|
|
3616
|
+
isOpen
|
|
3617
|
+
});
|
|
3618
|
+
const state = {
|
|
3619
|
+
...internalState,
|
|
3620
|
+
id: usedId,
|
|
3621
|
+
disabled,
|
|
3622
|
+
invalid,
|
|
3623
|
+
value: isMultiSelect ? values ?? [] : [value].filter(Boolean)
|
|
3624
|
+
};
|
|
3625
|
+
const config = {
|
|
3626
|
+
isMultiSelect,
|
|
3627
|
+
iconAppearance
|
|
3628
|
+
};
|
|
3629
|
+
const registerItem = useCallback10((item) => {
|
|
3630
|
+
optionsRef.current.push(item);
|
|
3631
|
+
optionsRef.current.sort((a, b) => {
|
|
3632
|
+
const aEl = a.ref.current;
|
|
3633
|
+
const bEl = b.ref.current;
|
|
3634
|
+
if (!aEl || !bEl) return 0;
|
|
3635
|
+
return aEl.compareDocumentPosition(bEl) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
3636
|
+
});
|
|
3637
|
+
}, []);
|
|
3638
|
+
const unregisterItem = useCallback10((value2) => {
|
|
3639
|
+
optionsRef.current = optionsRef.current.filter((i) => i.value !== value2);
|
|
3640
|
+
}, []);
|
|
3641
|
+
const toggleSelection = (value2, isSelected) => {
|
|
3642
|
+
if (disabled) {
|
|
3643
|
+
return;
|
|
3644
|
+
}
|
|
3645
|
+
const option = optionsRef.current.find((i) => i.value === value2);
|
|
3646
|
+
if (!option) {
|
|
3647
|
+
console.error(`SelectOption with value: ${value2} not found`);
|
|
3648
|
+
return;
|
|
3649
|
+
}
|
|
3650
|
+
let newValue;
|
|
3651
|
+
if (isMultiSelect) {
|
|
3652
|
+
const isSelectedBefore = state.value.includes(value2);
|
|
3653
|
+
const isSelectedAfter = isSelected ?? !isSelectedBefore;
|
|
3654
|
+
if (!isSelectedAfter) {
|
|
3655
|
+
newValue = state.value.filter((v) => v !== value2);
|
|
3656
|
+
} else {
|
|
3657
|
+
newValue = [...state.value, value2];
|
|
3658
|
+
}
|
|
3659
|
+
} else {
|
|
3660
|
+
newValue = [value2];
|
|
3661
|
+
}
|
|
3662
|
+
if (!isMultiSelect) {
|
|
3663
|
+
onValueChanged?.(newValue[0]);
|
|
3664
|
+
} else {
|
|
3665
|
+
onValuesChanged?.(newValue);
|
|
3666
|
+
}
|
|
3667
|
+
setInternalState((prevState) => ({
|
|
3668
|
+
...prevState,
|
|
3669
|
+
highlightedValue: value2
|
|
3670
|
+
}));
|
|
3671
|
+
};
|
|
3672
|
+
const highlightItem = (value2) => {
|
|
3673
|
+
if (disabled) {
|
|
3674
|
+
return;
|
|
3675
|
+
}
|
|
3676
|
+
setInternalState((prevState) => ({
|
|
3677
|
+
...prevState,
|
|
3678
|
+
highlightedValue: value2
|
|
3679
|
+
}));
|
|
3680
|
+
};
|
|
3681
|
+
const registerTrigger = useCallback10((ref) => {
|
|
3682
|
+
triggerRef.current = ref.current;
|
|
3683
|
+
}, []);
|
|
3684
|
+
const unregisterTrigger = useCallback10(() => {
|
|
3685
|
+
triggerRef.current = null;
|
|
3686
|
+
}, []);
|
|
3687
|
+
const toggleOpen = (isOpen2, options) => {
|
|
3688
|
+
const { highlightStartPosition } = { ...defaultToggleOpenOptions, ...options };
|
|
3689
|
+
let highlightedIndex;
|
|
3690
|
+
if (highlightStartPosition === "first") {
|
|
3691
|
+
highlightedIndex = optionsRef.current.findIndex((option) => !option.disabled);
|
|
3692
|
+
} else {
|
|
3693
|
+
highlightedIndex = optionsRef.current.length - 1 - [...optionsRef.current].reverse().findIndex((option) => !option.disabled);
|
|
3694
|
+
}
|
|
3695
|
+
if (highlightedIndex === -1 || highlightedIndex === optionsRef.current.length) {
|
|
3696
|
+
highlightedIndex = 0;
|
|
3697
|
+
}
|
|
3698
|
+
setInternalState((prevState) => ({
|
|
3699
|
+
...prevState,
|
|
3700
|
+
isOpen: isOpen2 ?? !prevState.isOpen,
|
|
3701
|
+
highlightedValue: optionsRef.current[highlightedIndex].value
|
|
3702
|
+
}));
|
|
3703
|
+
};
|
|
3704
|
+
const moveHighlightedIndex = (delta) => {
|
|
3705
|
+
let highlightedIndex = optionsRef.current.findIndex((value2) => value2.value === internalState.highlightedValue);
|
|
3706
|
+
if (highlightedIndex === -1) {
|
|
3707
|
+
highlightedIndex = 0;
|
|
3708
|
+
}
|
|
3709
|
+
const optionLength = optionsRef.current.length;
|
|
3710
|
+
const startIndex = (highlightedIndex + delta % optionLength + optionLength) % optionLength;
|
|
3711
|
+
const isForward = delta >= 0;
|
|
3712
|
+
let highlightedValue = optionsRef.current[startIndex].value;
|
|
3713
|
+
for (let i = 0; i < optionsRef.current.length; i++) {
|
|
3714
|
+
const index = (startIndex + (isForward ? i : -i) + optionLength) % optionLength;
|
|
3715
|
+
if (!optionsRef.current[index].disabled) {
|
|
3716
|
+
highlightedValue = optionsRef.current[index].value;
|
|
3717
|
+
break;
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
setInternalState((prevState) => ({
|
|
3721
|
+
...prevState,
|
|
3722
|
+
highlightedValue
|
|
3723
|
+
}));
|
|
3724
|
+
};
|
|
3725
|
+
useEffect24(() => {
|
|
3726
|
+
if (!internalState.highlightedValue) return;
|
|
3727
|
+
const highlighted = optionsRef.current.find((value2) => value2.value === internalState.highlightedValue);
|
|
3728
|
+
if (highlighted) {
|
|
3729
|
+
highlighted.ref.current.scrollIntoView({ behavior: "instant", block: "nearest" });
|
|
3730
|
+
} else {
|
|
3731
|
+
console.error(`SelectRoot: Could not find highlighted value (${internalState.highlightedValue})`);
|
|
3732
|
+
}
|
|
3733
|
+
}, [internalState.highlightedValue]);
|
|
3734
|
+
const contextValue = {
|
|
3735
|
+
state,
|
|
3736
|
+
config,
|
|
3737
|
+
item: {
|
|
3738
|
+
register: registerItem,
|
|
3739
|
+
unregister: unregisterItem,
|
|
3740
|
+
toggleSelection,
|
|
3741
|
+
highlightItem,
|
|
3742
|
+
moveHighlightedIndex
|
|
3743
|
+
},
|
|
3744
|
+
trigger: {
|
|
3745
|
+
ref: triggerRef,
|
|
3746
|
+
register: registerTrigger,
|
|
3747
|
+
unregister: unregisterTrigger,
|
|
3748
|
+
toggleOpen
|
|
3749
|
+
}
|
|
3750
|
+
};
|
|
3751
|
+
return /* @__PURE__ */ jsx25(SelectContext.Provider, { value: contextValue, children });
|
|
3752
|
+
};
|
|
3753
|
+
var SelectOption = forwardRef10(
|
|
3754
|
+
function SelectOption2({ children, value, disabled = false, iconAppearance, className, ...restProps }, ref) {
|
|
3755
|
+
const { state, config, item, trigger } = useSelectContext();
|
|
3756
|
+
const { register, unregister, toggleSelection, highlightItem } = item;
|
|
3757
|
+
const itemRef = useRef12(null);
|
|
3758
|
+
iconAppearance ??= config.iconAppearance;
|
|
3759
|
+
useEffect24(() => {
|
|
3760
|
+
register({
|
|
3761
|
+
value,
|
|
3762
|
+
disabled,
|
|
3763
|
+
ref: itemRef
|
|
3764
|
+
});
|
|
3765
|
+
return () => unregister(value);
|
|
3766
|
+
}, [value, disabled, register, unregister, children]);
|
|
3767
|
+
const isHighlighted = state.highlightedValue === value;
|
|
3768
|
+
const isSelected = state.value.includes(value);
|
|
3769
|
+
return /* @__PURE__ */ jsxs18(
|
|
3770
|
+
"li",
|
|
3771
|
+
{
|
|
3772
|
+
...restProps,
|
|
3773
|
+
ref: (node) => {
|
|
3774
|
+
itemRef.current = node;
|
|
3775
|
+
if (typeof ref === "function") ref(node);
|
|
3776
|
+
else if (ref) ref.current = node;
|
|
3777
|
+
},
|
|
3778
|
+
id: value,
|
|
3779
|
+
role: "option",
|
|
3780
|
+
"aria-disabled": disabled,
|
|
3781
|
+
"aria-selected": isSelected,
|
|
3782
|
+
"data-highlighted": isHighlighted ? "" : void 0,
|
|
3783
|
+
"data-selected": isSelected ? "" : void 0,
|
|
3784
|
+
"data-disabled": disabled ? "" : void 0,
|
|
3785
|
+
className: clsx20(
|
|
3786
|
+
"flex-row-1 items-center px-2 py-1 rounded-md",
|
|
3787
|
+
"data-highlighted:bg-primary/20",
|
|
3788
|
+
"data-disabled:text-disabled data-disabled:cursor-not-allowed",
|
|
3789
|
+
"not-data-disabled:cursor-pointer",
|
|
3790
|
+
className
|
|
3791
|
+
),
|
|
3792
|
+
onClick: (event) => {
|
|
3793
|
+
if (!disabled) {
|
|
3794
|
+
toggleSelection(value);
|
|
3795
|
+
if (!config.isMultiSelect) {
|
|
3796
|
+
trigger.toggleOpen(false);
|
|
3797
|
+
}
|
|
3798
|
+
restProps.onClick?.(event);
|
|
3799
|
+
}
|
|
3800
|
+
},
|
|
3801
|
+
onMouseEnter: (event) => {
|
|
3802
|
+
if (!disabled) {
|
|
3803
|
+
highlightItem(value);
|
|
3804
|
+
restProps.onMouseEnter?.(event);
|
|
3805
|
+
}
|
|
3806
|
+
},
|
|
3807
|
+
children: [
|
|
3808
|
+
iconAppearance === "left" && /* @__PURE__ */ jsx25(
|
|
3809
|
+
CheckIcon2,
|
|
3810
|
+
{
|
|
3811
|
+
className: clsx20("w-4 h-4", { "opacity-0": !isSelected || disabled }),
|
|
3812
|
+
"aria-hidden": true
|
|
3813
|
+
}
|
|
3814
|
+
),
|
|
3815
|
+
children ?? value,
|
|
3816
|
+
iconAppearance === "right" && /* @__PURE__ */ jsx25(
|
|
3817
|
+
CheckIcon2,
|
|
3818
|
+
{
|
|
3819
|
+
className: clsx20("w-4 h-4", { "opacity-0": !isSelected || disabled }),
|
|
3820
|
+
"aria-hidden": true
|
|
3821
|
+
}
|
|
3822
|
+
)
|
|
3823
|
+
]
|
|
3824
|
+
}
|
|
3825
|
+
);
|
|
3826
|
+
}
|
|
3827
|
+
);
|
|
3828
|
+
var defaultSelectButtonTranslation = {
|
|
3829
|
+
en: {
|
|
3830
|
+
clickToSelect: "Click to select"
|
|
3831
|
+
},
|
|
3832
|
+
de: {
|
|
3833
|
+
clickToSelect: "Zum ausw\xE4hlen dr\xFCcken"
|
|
3834
|
+
}
|
|
3835
|
+
};
|
|
3836
|
+
var SelectButton = forwardRef10(function SelectButton2({ placeholder, selectedDisplay, ...props }, ref) {
|
|
3837
|
+
const translation = useTranslation([defaultSelectButtonTranslation]);
|
|
3838
|
+
const { state, trigger } = useSelectContext();
|
|
3839
|
+
const { register, unregister, toggleOpen } = trigger;
|
|
3840
|
+
const innerRef = useRef12(null);
|
|
3841
|
+
useImperativeHandle3(ref, () => innerRef.current);
|
|
3842
|
+
useEffect24(() => {
|
|
3843
|
+
register(innerRef);
|
|
3844
|
+
return () => unregister();
|
|
3845
|
+
}, [register, unregister]);
|
|
3846
|
+
const disabled = !!props?.disabled || !!state.disabled;
|
|
3847
|
+
const invalid = state.invalid;
|
|
3848
|
+
const hasValue = state.value.length > 0;
|
|
3849
|
+
return /* @__PURE__ */ jsxs18(
|
|
3850
|
+
"button",
|
|
3851
|
+
{
|
|
3852
|
+
...props,
|
|
3853
|
+
ref: innerRef,
|
|
3854
|
+
id: state.id,
|
|
3855
|
+
className: clsx20(
|
|
3856
|
+
"flex-row-2 items-center justify-between bg-input-background text-input-text rounded-md px-2.5 py-2.5",
|
|
3857
|
+
"data-placeholder:text-description",
|
|
3858
|
+
props.className
|
|
3859
|
+
),
|
|
3860
|
+
onClick: () => toggleOpen(!state.isOpen),
|
|
3861
|
+
onKeyDown: (event) => {
|
|
3862
|
+
switch (event.key) {
|
|
3863
|
+
case "ArrowDown":
|
|
3864
|
+
toggleOpen(true, { highlightStartPosition: "first" });
|
|
3865
|
+
break;
|
|
3866
|
+
case "ArrowUp":
|
|
3867
|
+
toggleOpen(true, { highlightStartPosition: "last" });
|
|
3868
|
+
break;
|
|
3869
|
+
}
|
|
3870
|
+
},
|
|
3871
|
+
"data-placeholder": !hasValue ? "" : void 0,
|
|
3872
|
+
"data-disabled": disabled ? "" : void 0,
|
|
3873
|
+
"data-invalid": invalid ? "" : void 0,
|
|
3874
|
+
"aria-invalid": invalid,
|
|
3875
|
+
"aria-disabled": disabled,
|
|
3876
|
+
"aria-haspopup": "listbox",
|
|
3877
|
+
"aria-expanded": state.isOpen,
|
|
3878
|
+
"aria-controls": state.isOpen ? `${state.id}-listbox` : void 0,
|
|
3879
|
+
children: [
|
|
3880
|
+
hasValue ? selectedDisplay?.(state.value) ?? state.value.join(", ") : placeholder ?? translation("clickToSelect"),
|
|
3881
|
+
/* @__PURE__ */ jsx25(ExpansionIcon, { isExpanded: state.isOpen })
|
|
3882
|
+
]
|
|
3883
|
+
}
|
|
3884
|
+
);
|
|
3885
|
+
});
|
|
3886
|
+
var SelectChipDisplay = forwardRef10(function SelectChipDisplay2({ ...props }, ref) {
|
|
3887
|
+
const { state, trigger, item } = useSelectContext();
|
|
3888
|
+
const { register, unregister, toggleOpen } = trigger;
|
|
3889
|
+
const innerRef = useRef12(null);
|
|
3890
|
+
useImperativeHandle3(ref, () => innerRef.current);
|
|
3891
|
+
useEffect24(() => {
|
|
3892
|
+
register(innerRef);
|
|
3893
|
+
return () => unregister();
|
|
3894
|
+
}, [register, unregister]);
|
|
3895
|
+
const disabled = !!props?.disabled || !!state.disabled;
|
|
3896
|
+
const invalid = state.invalid;
|
|
3897
|
+
return /* @__PURE__ */ jsxs18(
|
|
3898
|
+
"div",
|
|
3899
|
+
{
|
|
3900
|
+
...props,
|
|
3901
|
+
ref: innerRef,
|
|
3902
|
+
className: clsx20(
|
|
3903
|
+
"flex flex-wrap flex-row gap-2 items-center bg-input-background text-input-text rounded-md px-2.5 py-2.5",
|
|
3904
|
+
props.className
|
|
3905
|
+
),
|
|
3906
|
+
"data-disabled": disabled ? "" : void 0,
|
|
3907
|
+
"data-invalid": invalid ? "" : void 0,
|
|
3908
|
+
"aria-invalid": invalid,
|
|
3909
|
+
"aria-disabled": disabled,
|
|
3910
|
+
children: [
|
|
3911
|
+
state.value.map((value) => /* @__PURE__ */ jsxs18(Chip, { className: "gap-x-2", children: [
|
|
3912
|
+
value,
|
|
3913
|
+
/* @__PURE__ */ jsx25(
|
|
3914
|
+
"button",
|
|
3915
|
+
{
|
|
3916
|
+
onClick: () => {
|
|
3917
|
+
item.toggleSelection(value, false);
|
|
3918
|
+
},
|
|
3919
|
+
className: "focus-within:text-negative hover:bg-negative/20 hover:text-negative rounded-md focus-style-none focus-visible:ring-2 focus-visible:ring-negative focus-visible:bg-negative/20",
|
|
3920
|
+
children: /* @__PURE__ */ jsx25(XIcon, {})
|
|
3921
|
+
}
|
|
3922
|
+
)
|
|
3923
|
+
] }, value)),
|
|
3924
|
+
/* @__PURE__ */ jsx25(
|
|
3925
|
+
IconButton,
|
|
3926
|
+
{
|
|
3927
|
+
id: state.id,
|
|
3928
|
+
onClick: () => toggleOpen(),
|
|
3929
|
+
onKeyDown: (event) => {
|
|
3930
|
+
switch (event.key) {
|
|
3931
|
+
case "ArrowDown":
|
|
3932
|
+
toggleOpen(true, { highlightStartPosition: "first" });
|
|
3933
|
+
break;
|
|
3934
|
+
case "ArrowUp":
|
|
3935
|
+
toggleOpen(true, { highlightStartPosition: "last" });
|
|
3936
|
+
}
|
|
3937
|
+
},
|
|
3938
|
+
size: "small",
|
|
3939
|
+
color: "neutral",
|
|
3940
|
+
"aria-invalid": invalid,
|
|
3941
|
+
"aria-disabled": disabled,
|
|
3942
|
+
"aria-haspopup": "listbox",
|
|
3943
|
+
"aria-expanded": state.isOpen,
|
|
3944
|
+
"aria-controls": state.isOpen ? `${state.id}-listbox` : void 0,
|
|
3945
|
+
children: /* @__PURE__ */ jsx25(Plus, {})
|
|
3946
|
+
}
|
|
3947
|
+
)
|
|
3948
|
+
]
|
|
3949
|
+
}
|
|
3950
|
+
);
|
|
3951
|
+
});
|
|
3952
|
+
var SelectContent = forwardRef10(
|
|
3953
|
+
function SelectContent2({
|
|
3954
|
+
alignment,
|
|
3955
|
+
orientation = "vertical",
|
|
3956
|
+
...props
|
|
3957
|
+
}, ref) {
|
|
3958
|
+
const innerRef = useRef12(null);
|
|
3959
|
+
useImperativeHandle3(ref, () => innerRef.current);
|
|
3960
|
+
const { trigger, state, config, item } = useSelectContext();
|
|
3961
|
+
const position = useFloatingElement({
|
|
3962
|
+
active: state.isOpen,
|
|
3963
|
+
anchorRef: trigger.ref,
|
|
3964
|
+
containerRef: innerRef,
|
|
3965
|
+
...alignment
|
|
3966
|
+
});
|
|
3967
|
+
useFocusTrap({
|
|
3968
|
+
container: innerRef,
|
|
3969
|
+
active: state.isOpen && !!position
|
|
3970
|
+
});
|
|
3971
|
+
return createPortal2(
|
|
3972
|
+
/* @__PURE__ */ jsxs18(Fragment5, { children: [
|
|
3973
|
+
/* @__PURE__ */ jsx25(
|
|
3974
|
+
"div",
|
|
3975
|
+
{
|
|
3976
|
+
hidden: !state.isOpen,
|
|
3977
|
+
onClick: () => trigger.toggleOpen(false),
|
|
3978
|
+
className: clsx20("fixed w-screen h-screen inset-0")
|
|
3979
|
+
}
|
|
3980
|
+
),
|
|
3981
|
+
/* @__PURE__ */ jsx25(
|
|
3982
|
+
"ul",
|
|
3983
|
+
{
|
|
3984
|
+
...props,
|
|
3985
|
+
id: `${state.id}-listbox`,
|
|
3986
|
+
ref: innerRef,
|
|
3987
|
+
hidden: !state.isOpen,
|
|
3988
|
+
onKeyDown: (event) => {
|
|
3989
|
+
switch (event.key) {
|
|
3990
|
+
case "Escape":
|
|
3991
|
+
trigger.toggleOpen(false);
|
|
3992
|
+
event.preventDefault();
|
|
3993
|
+
event.stopPropagation();
|
|
3994
|
+
break;
|
|
3995
|
+
case match(orientation, {
|
|
3996
|
+
vertical: "ArrowDown",
|
|
3997
|
+
horizontal: "ArrowUp"
|
|
3998
|
+
}):
|
|
3999
|
+
item.moveHighlightedIndex(1);
|
|
4000
|
+
event.preventDefault();
|
|
4001
|
+
break;
|
|
4002
|
+
case match(orientation, {
|
|
4003
|
+
vertical: "ArrowUp",
|
|
4004
|
+
horizontal: "ArrowDown"
|
|
4005
|
+
}):
|
|
4006
|
+
item.moveHighlightedIndex(-1);
|
|
4007
|
+
event.preventDefault();
|
|
4008
|
+
break;
|
|
4009
|
+
case "Home":
|
|
4010
|
+
event.preventDefault();
|
|
4011
|
+
break;
|
|
4012
|
+
case "End":
|
|
4013
|
+
event.preventDefault();
|
|
4014
|
+
break;
|
|
4015
|
+
case "Enter":
|
|
4016
|
+
// Fall through
|
|
4017
|
+
case " ":
|
|
4018
|
+
if (state.highlightedValue) {
|
|
4019
|
+
item.toggleSelection(state.highlightedValue);
|
|
4020
|
+
if (!config.isMultiSelect) {
|
|
4021
|
+
trigger.toggleOpen(false);
|
|
4022
|
+
}
|
|
4023
|
+
event.preventDefault();
|
|
4024
|
+
}
|
|
4025
|
+
break;
|
|
4026
|
+
}
|
|
4027
|
+
},
|
|
4028
|
+
className: clsx20("flex-col-0 p-2 bg-menu-background text-menu-text rounded-md shadow-hw-bottom focus-style-within overflow-auto", props.className),
|
|
4029
|
+
style: {
|
|
4030
|
+
opacity: position ? void 0 : 0,
|
|
4031
|
+
position: "fixed",
|
|
4032
|
+
...position
|
|
4033
|
+
},
|
|
4034
|
+
role: "listbox",
|
|
4035
|
+
"aria-multiselectable": config.isMultiSelect,
|
|
4036
|
+
"aria-orientation": orientation,
|
|
4037
|
+
tabIndex: position ? 0 : void 0,
|
|
4038
|
+
children: props.children
|
|
4039
|
+
}
|
|
4040
|
+
)
|
|
4041
|
+
] }),
|
|
4042
|
+
document.body
|
|
4043
|
+
);
|
|
4044
|
+
}
|
|
4045
|
+
);
|
|
4046
|
+
var Select = forwardRef10(function Select2({
|
|
4047
|
+
children,
|
|
4048
|
+
contentPanelProps,
|
|
4049
|
+
buttonProps,
|
|
4050
|
+
...props
|
|
4051
|
+
}, ref) {
|
|
4052
|
+
return /* @__PURE__ */ jsxs18(SelectRoot, { ...props, isMultiSelect: false, children: [
|
|
4053
|
+
/* @__PURE__ */ jsx25(
|
|
4054
|
+
SelectButton,
|
|
4055
|
+
{
|
|
4056
|
+
ref,
|
|
4057
|
+
...buttonProps,
|
|
4058
|
+
selectedDisplay: (values) => {
|
|
4059
|
+
const value = values[0];
|
|
4060
|
+
if (!buttonProps?.selectedDisplay) return void 0;
|
|
4061
|
+
return buttonProps.selectedDisplay(value);
|
|
4062
|
+
}
|
|
4063
|
+
}
|
|
4064
|
+
),
|
|
4065
|
+
/* @__PURE__ */ jsx25(SelectContent, { ...contentPanelProps, children })
|
|
4066
|
+
] });
|
|
4067
|
+
});
|
|
4068
|
+
var SelectUncontrolled = forwardRef10(function SelectUncontrolled2({
|
|
4069
|
+
value: initialValue,
|
|
4070
|
+
onValueChanged,
|
|
4071
|
+
...props
|
|
4072
|
+
}, ref) {
|
|
4073
|
+
const [value, setValue] = useState25(initialValue);
|
|
4074
|
+
useEffect24(() => {
|
|
4075
|
+
setValue(initialValue);
|
|
4076
|
+
}, [initialValue]);
|
|
4077
|
+
return /* @__PURE__ */ jsx25(
|
|
4078
|
+
Select,
|
|
4079
|
+
{
|
|
4080
|
+
...props,
|
|
4081
|
+
ref,
|
|
4082
|
+
value,
|
|
4083
|
+
onValueChanged: (value2) => {
|
|
4084
|
+
setValue(value2);
|
|
4085
|
+
onValueChanged?.(value2);
|
|
4086
|
+
}
|
|
4087
|
+
}
|
|
4088
|
+
);
|
|
4089
|
+
});
|
|
4090
|
+
var MultiSelect = forwardRef10(function MultiSelect2({
|
|
4091
|
+
children,
|
|
4092
|
+
contentPanelProps,
|
|
4093
|
+
buttonProps,
|
|
4094
|
+
...props
|
|
4095
|
+
}, ref) {
|
|
4096
|
+
return /* @__PURE__ */ jsxs18(SelectRoot, { ...props, isMultiSelect: true, children: [
|
|
4097
|
+
/* @__PURE__ */ jsx25(SelectButton, { ref, ...buttonProps }),
|
|
4098
|
+
/* @__PURE__ */ jsx25(SelectContent, { ...contentPanelProps, children })
|
|
4099
|
+
] });
|
|
4100
|
+
});
|
|
4101
|
+
var MultiSelectUncontrolled = forwardRef10(function MultiSelectUncontrolled2({
|
|
4102
|
+
values: initialValues,
|
|
4103
|
+
onValuesChanged,
|
|
4104
|
+
...props
|
|
4105
|
+
}, ref) {
|
|
4106
|
+
const [values, setValues] = useState25(initialValues);
|
|
4107
|
+
useEffect24(() => {
|
|
4108
|
+
setValues(initialValues);
|
|
4109
|
+
}, [initialValues]);
|
|
4110
|
+
return /* @__PURE__ */ jsx25(
|
|
4111
|
+
MultiSelect,
|
|
4112
|
+
{
|
|
4113
|
+
...props,
|
|
4114
|
+
ref,
|
|
4115
|
+
values,
|
|
4116
|
+
onValuesChanged: (value) => {
|
|
4117
|
+
setValues(value);
|
|
4118
|
+
onValuesChanged?.(value);
|
|
4119
|
+
}
|
|
4120
|
+
}
|
|
4121
|
+
);
|
|
4122
|
+
});
|
|
4123
|
+
var MultiSelectChipDisplay = forwardRef10(function MultiSelectChipDisplay2({
|
|
4124
|
+
children,
|
|
4125
|
+
contentPanelProps,
|
|
4126
|
+
chipDisplayProps,
|
|
4127
|
+
...props
|
|
4128
|
+
}, ref) {
|
|
4129
|
+
return /* @__PURE__ */ jsxs18(SelectRoot, { ...props, isMultiSelect: true, children: [
|
|
4130
|
+
/* @__PURE__ */ jsx25(SelectChipDisplay, { ref, ...chipDisplayProps }),
|
|
4131
|
+
/* @__PURE__ */ jsx25(SelectContent, { ...contentPanelProps, children })
|
|
4132
|
+
] });
|
|
4133
|
+
});
|
|
4134
|
+
var MultiSelectChipDisplayUncontrolled = forwardRef10(function MultiSelectChipDisplayUncontrolled2({
|
|
4135
|
+
values: initialValues,
|
|
4136
|
+
onValuesChanged,
|
|
4137
|
+
...props
|
|
4138
|
+
}, ref) {
|
|
4139
|
+
const [values, setValues] = useState25(initialValues);
|
|
4140
|
+
useEffect24(() => {
|
|
4141
|
+
setValues(initialValues);
|
|
4142
|
+
}, [initialValues]);
|
|
4143
|
+
return /* @__PURE__ */ jsx25(
|
|
4144
|
+
MultiSelectChipDisplay,
|
|
4145
|
+
{
|
|
4146
|
+
...props,
|
|
4147
|
+
ref,
|
|
4148
|
+
values,
|
|
4149
|
+
onValuesChanged: (value) => {
|
|
4150
|
+
setValues(value);
|
|
4151
|
+
onValuesChanged?.(value);
|
|
4152
|
+
}
|
|
4153
|
+
}
|
|
4154
|
+
);
|
|
4155
|
+
});
|
|
4156
|
+
export {
|
|
4157
|
+
ButtonColorUtil,
|
|
4158
|
+
ButtonUtil,
|
|
4159
|
+
Checkbox2 as Checkbox,
|
|
4160
|
+
CheckboxUncontrolled,
|
|
4161
|
+
CopyToClipboardWrapper,
|
|
4162
|
+
DateTimePicker,
|
|
4163
|
+
IconButton,
|
|
4164
|
+
IconButtonUtil,
|
|
4165
|
+
Input,
|
|
4166
|
+
InputUncontrolled,
|
|
4167
|
+
InsideLabelInput,
|
|
4168
|
+
InsideLabelInputUncontrolled,
|
|
4169
|
+
Label,
|
|
4170
|
+
Menu,
|
|
4171
|
+
MenuItem,
|
|
4172
|
+
MultiSelect,
|
|
4173
|
+
MultiSelectChipDisplay,
|
|
4174
|
+
MultiSelectChipDisplayUncontrolled,
|
|
4175
|
+
MultiSelectUncontrolled,
|
|
4176
|
+
OutlineButton,
|
|
4177
|
+
ScrollPicker,
|
|
4178
|
+
SearchBar,
|
|
4179
|
+
Select,
|
|
4180
|
+
SelectButton,
|
|
4181
|
+
SelectChipDisplay,
|
|
4182
|
+
SelectContent,
|
|
4183
|
+
SelectOption,
|
|
4184
|
+
SelectRoot,
|
|
4185
|
+
SelectUncontrolled,
|
|
4186
|
+
SolidButton,
|
|
4187
|
+
TextButton,
|
|
4188
|
+
Textarea,
|
|
4189
|
+
TextareaUncontrolled,
|
|
4190
|
+
TextareaWithHeadline,
|
|
4191
|
+
ToggleableInput,
|
|
4192
|
+
ToggleableInputUncontrolled,
|
|
4193
|
+
Tooltip
|
|
4194
|
+
};
|
|
4195
|
+
//# sourceMappingURL=index.mjs.map
|