@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,1124 @@
|
|
|
1
|
+
// src/components/date/DatePicker.tsx
|
|
2
|
+
import { useEffect as useEffect5, useState as useState6 } from "react";
|
|
3
|
+
import { ArrowDown, ArrowUp, ChevronDown as ChevronDown2 } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
// src/localization/LanguageProvider.tsx
|
|
6
|
+
import { createContext, useContext, useEffect, useState as useState2 } from "react";
|
|
7
|
+
|
|
8
|
+
// src/hooks/useLocalStorage.ts
|
|
9
|
+
import { useCallback, useState } from "react";
|
|
10
|
+
|
|
11
|
+
// src/localization/util.ts
|
|
12
|
+
var languages = ["en", "de"];
|
|
13
|
+
var languagesLocalNames = {
|
|
14
|
+
en: "English",
|
|
15
|
+
de: "Deutsch"
|
|
16
|
+
};
|
|
17
|
+
var DEFAULT_LANGUAGE = "en";
|
|
18
|
+
var LanguageUtil = {
|
|
19
|
+
languages,
|
|
20
|
+
DEFAULT_LANGUAGE,
|
|
21
|
+
languagesLocalNames
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// src/localization/LanguageProvider.tsx
|
|
25
|
+
import { jsx } from "react/jsx-runtime";
|
|
26
|
+
var LanguageContext = createContext({
|
|
27
|
+
language: LanguageUtil.DEFAULT_LANGUAGE,
|
|
28
|
+
setLanguage: (v) => v
|
|
29
|
+
});
|
|
30
|
+
var useLanguage = () => useContext(LanguageContext);
|
|
31
|
+
var useLocale = (overWriteLanguage) => {
|
|
32
|
+
const { language } = useLanguage();
|
|
33
|
+
const mapping = {
|
|
34
|
+
en: "en-US",
|
|
35
|
+
de: "de-DE"
|
|
36
|
+
};
|
|
37
|
+
return mapping[overWriteLanguage ?? language];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/localization/useTranslation.ts
|
|
41
|
+
var TranslationPluralCount = {
|
|
42
|
+
zero: 0,
|
|
43
|
+
one: 1,
|
|
44
|
+
two: 2,
|
|
45
|
+
few: 3,
|
|
46
|
+
many: 11,
|
|
47
|
+
other: -1
|
|
48
|
+
};
|
|
49
|
+
var useTranslation = (translations, overwriteTranslation = {}) => {
|
|
50
|
+
const { language: languageProp, translation: overwrite } = overwriteTranslation;
|
|
51
|
+
const { language: inferredLanguage } = useLanguage();
|
|
52
|
+
const usedLanguage = languageProp ?? inferredLanguage;
|
|
53
|
+
const usedTranslations = [...translations];
|
|
54
|
+
if (overwrite) {
|
|
55
|
+
usedTranslations.push(overwrite);
|
|
56
|
+
}
|
|
57
|
+
return (key, options) => {
|
|
58
|
+
const { count, replacements } = { ...{ count: 0, replacements: {} }, ...options };
|
|
59
|
+
try {
|
|
60
|
+
for (let i = translations.length - 1; i >= 0; i--) {
|
|
61
|
+
const translation = translations[i];
|
|
62
|
+
const localizedTranslation = translation[usedLanguage];
|
|
63
|
+
if (!localizedTranslation) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const value = localizedTranslation[key];
|
|
67
|
+
if (!value) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
let forProcessing;
|
|
71
|
+
if (typeof value !== "string") {
|
|
72
|
+
if (count === TranslationPluralCount.zero && value?.zero) {
|
|
73
|
+
forProcessing = value.zero;
|
|
74
|
+
} else if (count === TranslationPluralCount.one && value?.one) {
|
|
75
|
+
forProcessing = value.one;
|
|
76
|
+
} else if (count === TranslationPluralCount.two && value?.two) {
|
|
77
|
+
forProcessing = value.two;
|
|
78
|
+
} else if (TranslationPluralCount.few <= count && count < TranslationPluralCount.many && value?.few) {
|
|
79
|
+
forProcessing = value.few;
|
|
80
|
+
} else if (count > TranslationPluralCount.many && value?.many) {
|
|
81
|
+
forProcessing = value.many;
|
|
82
|
+
} else {
|
|
83
|
+
forProcessing = value.other;
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
forProcessing = value;
|
|
87
|
+
}
|
|
88
|
+
forProcessing = forProcessing.replace(/\{\{(\w+)}}/g, (_, placeholder) => {
|
|
89
|
+
return replacements[placeholder] ?? `{{key:${placeholder}}}`;
|
|
90
|
+
});
|
|
91
|
+
return forProcessing;
|
|
92
|
+
}
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.error(e);
|
|
95
|
+
}
|
|
96
|
+
return `{{${usedLanguage}:${key}}}`;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// src/utils/noop.ts
|
|
101
|
+
var noop = () => void 0;
|
|
102
|
+
|
|
103
|
+
// src/utils/array.ts
|
|
104
|
+
var equalSizeGroups = (array, groupSize) => {
|
|
105
|
+
if (groupSize <= 0) {
|
|
106
|
+
console.warn(`group size should be greater than 0: groupSize = ${groupSize}`);
|
|
107
|
+
return [[...array]];
|
|
108
|
+
}
|
|
109
|
+
const groups = [];
|
|
110
|
+
for (let i = 0; i < array.length; i += groupSize) {
|
|
111
|
+
groups.push(array.slice(i, Math.min(i + groupSize, array.length)));
|
|
112
|
+
}
|
|
113
|
+
return groups;
|
|
114
|
+
};
|
|
115
|
+
var defaultRangeOptions = {
|
|
116
|
+
allowEmptyRange: false,
|
|
117
|
+
stepSize: 1,
|
|
118
|
+
exclusiveStart: false,
|
|
119
|
+
exclusiveEnd: true
|
|
120
|
+
};
|
|
121
|
+
var range = (endOrRange, options) => {
|
|
122
|
+
const { allowEmptyRange, stepSize, exclusiveStart, exclusiveEnd } = { ...defaultRangeOptions, ...options };
|
|
123
|
+
let start = 0;
|
|
124
|
+
let end;
|
|
125
|
+
if (typeof endOrRange === "number") {
|
|
126
|
+
end = endOrRange;
|
|
127
|
+
} else {
|
|
128
|
+
start = endOrRange[0];
|
|
129
|
+
end = endOrRange[1];
|
|
130
|
+
}
|
|
131
|
+
if (!exclusiveEnd) {
|
|
132
|
+
end -= 1;
|
|
133
|
+
}
|
|
134
|
+
if (exclusiveStart) {
|
|
135
|
+
start += 1;
|
|
136
|
+
}
|
|
137
|
+
if (end - 1 < start) {
|
|
138
|
+
if (!allowEmptyRange) {
|
|
139
|
+
console.warn(`range: end (${end}) < start (${start}) should be allowed explicitly, set options.allowEmptyRange to true`);
|
|
140
|
+
}
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
return Array.from({ length: end - start }, (_, index) => index * stepSize + start);
|
|
144
|
+
};
|
|
145
|
+
var closestMatch = (list, firstCloser) => {
|
|
146
|
+
return list.reduce((item1, item2) => {
|
|
147
|
+
return firstCloser(item1, item2) ? item1 : item2;
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// src/utils/date.ts
|
|
152
|
+
var monthsList = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
|
|
153
|
+
var weekDayList = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
|
|
154
|
+
var changeDuration = (date, duration, isAdding) => {
|
|
155
|
+
const {
|
|
156
|
+
years = 0,
|
|
157
|
+
months = 0,
|
|
158
|
+
days = 0,
|
|
159
|
+
hours = 0,
|
|
160
|
+
minutes = 0,
|
|
161
|
+
seconds = 0,
|
|
162
|
+
milliseconds = 0
|
|
163
|
+
} = duration;
|
|
164
|
+
if (years < 0) {
|
|
165
|
+
console.error(`Range error years must be greater than 0: received ${years}`);
|
|
166
|
+
return new Date(date);
|
|
167
|
+
}
|
|
168
|
+
if (months < 0 || months > 11) {
|
|
169
|
+
console.error(`Range error month must be 0 <= month <= 11: received ${months}`);
|
|
170
|
+
return new Date(date);
|
|
171
|
+
}
|
|
172
|
+
if (days < 0) {
|
|
173
|
+
console.error(`Range error days must be greater than 0: received ${days}`);
|
|
174
|
+
return new Date(date);
|
|
175
|
+
}
|
|
176
|
+
if (hours < 0 || hours > 23) {
|
|
177
|
+
console.error(`Range error hours must be 0 <= hours <= 23: received ${hours}`);
|
|
178
|
+
return new Date(date);
|
|
179
|
+
}
|
|
180
|
+
if (minutes < 0 || minutes > 59) {
|
|
181
|
+
console.error(`Range error minutes must be 0 <= minutes <= 59: received ${minutes}`);
|
|
182
|
+
return new Date(date);
|
|
183
|
+
}
|
|
184
|
+
if (seconds < 0 || seconds > 59) {
|
|
185
|
+
console.error(`Range error seconds must be 0 <= seconds <= 59: received ${seconds}`);
|
|
186
|
+
return new Date(date);
|
|
187
|
+
}
|
|
188
|
+
if (milliseconds < 0) {
|
|
189
|
+
console.error(`Range error seconds must be greater than 0: received ${milliseconds}`);
|
|
190
|
+
return new Date(date);
|
|
191
|
+
}
|
|
192
|
+
const multiplier = isAdding ? 1 : -1;
|
|
193
|
+
const newDate = new Date(date);
|
|
194
|
+
newDate.setFullYear(newDate.getFullYear() + multiplier * years);
|
|
195
|
+
newDate.setMonth(newDate.getMonth() + multiplier * months);
|
|
196
|
+
newDate.setDate(newDate.getDate() + multiplier * days);
|
|
197
|
+
newDate.setHours(newDate.getHours() + multiplier * hours);
|
|
198
|
+
newDate.setMinutes(newDate.getMinutes() + multiplier * minutes);
|
|
199
|
+
newDate.setSeconds(newDate.getSeconds() + multiplier * seconds);
|
|
200
|
+
newDate.setMilliseconds(newDate.getMilliseconds() + multiplier * milliseconds);
|
|
201
|
+
return newDate;
|
|
202
|
+
};
|
|
203
|
+
var addDuration = (date, duration) => {
|
|
204
|
+
return changeDuration(date, duration, true);
|
|
205
|
+
};
|
|
206
|
+
var subtractDuration = (date, duration) => {
|
|
207
|
+
return changeDuration(date, duration, false);
|
|
208
|
+
};
|
|
209
|
+
var isInTimeSpan = (value, startDate, endDate) => {
|
|
210
|
+
if (startDate && endDate) {
|
|
211
|
+
console.assert(startDate <= endDate);
|
|
212
|
+
return startDate <= value && value <= endDate;
|
|
213
|
+
} else if (startDate) {
|
|
214
|
+
return startDate <= value;
|
|
215
|
+
} else if (endDate) {
|
|
216
|
+
return endDate >= value;
|
|
217
|
+
} else {
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
var equalDate = (date1, date2) => {
|
|
222
|
+
return date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth() && date1.getDate() === date2.getDate();
|
|
223
|
+
};
|
|
224
|
+
var getWeeksForCalenderMonth = (date, weekStart, weeks = 6) => {
|
|
225
|
+
const month = date.getMonth();
|
|
226
|
+
const year = date.getFullYear();
|
|
227
|
+
const dayList = [];
|
|
228
|
+
let currentDate = new Date(year, month, 1);
|
|
229
|
+
const weekStartIndex = weekDayList.indexOf(weekStart);
|
|
230
|
+
while (currentDate.getDay() !== weekStartIndex) {
|
|
231
|
+
currentDate = subtractDuration(currentDate, { days: 1 });
|
|
232
|
+
}
|
|
233
|
+
while (dayList.length < 7 * weeks) {
|
|
234
|
+
const date2 = new Date(currentDate);
|
|
235
|
+
date2.setHours(date2.getHours(), date2.getMinutes());
|
|
236
|
+
dayList.push(date2);
|
|
237
|
+
currentDate = addDuration(currentDate, { days: 1 });
|
|
238
|
+
}
|
|
239
|
+
return equalSizeGroups(dayList, 7);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// src/components/date/DatePicker.tsx
|
|
243
|
+
import clsx5 from "clsx";
|
|
244
|
+
|
|
245
|
+
// src/components/user-action/Button.tsx
|
|
246
|
+
import { forwardRef } from "react";
|
|
247
|
+
import clsx from "clsx";
|
|
248
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
249
|
+
var ButtonColorUtil = {
|
|
250
|
+
solid: ["primary", "secondary", "tertiary", "positive", "warning", "negative", "neutral"],
|
|
251
|
+
text: ["primary", "negative", "neutral"],
|
|
252
|
+
outline: ["primary"]
|
|
253
|
+
};
|
|
254
|
+
var IconButtonUtil = {
|
|
255
|
+
icon: [...ButtonColorUtil.solid, "transparent"]
|
|
256
|
+
};
|
|
257
|
+
var paddingMapping = {
|
|
258
|
+
small: "btn-sm",
|
|
259
|
+
medium: "btn-md",
|
|
260
|
+
large: "btn-lg"
|
|
261
|
+
};
|
|
262
|
+
var iconPaddingMapping = {
|
|
263
|
+
tiny: "icon-btn-xs",
|
|
264
|
+
small: "icon-btn-sm",
|
|
265
|
+
medium: "icon-btn-md",
|
|
266
|
+
large: "icon-btn-lg"
|
|
267
|
+
};
|
|
268
|
+
var ButtonUtil = {
|
|
269
|
+
paddingMapping,
|
|
270
|
+
iconPaddingMapping
|
|
271
|
+
};
|
|
272
|
+
var SolidButton = forwardRef(function SolidButton2({
|
|
273
|
+
children,
|
|
274
|
+
color = "primary",
|
|
275
|
+
size = "medium",
|
|
276
|
+
startIcon,
|
|
277
|
+
endIcon,
|
|
278
|
+
onClick,
|
|
279
|
+
className,
|
|
280
|
+
...restProps
|
|
281
|
+
}, ref) {
|
|
282
|
+
const colorClasses = {
|
|
283
|
+
primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
|
|
284
|
+
secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
|
|
285
|
+
tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
|
|
286
|
+
positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
|
|
287
|
+
warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
|
|
288
|
+
negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
|
|
289
|
+
neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text"
|
|
290
|
+
}[color];
|
|
291
|
+
const iconColorClasses = {
|
|
292
|
+
primary: "not-group-disabled:text-button-solid-primary-icon",
|
|
293
|
+
secondary: "not-group-disabled:text-button-solid-secondary-icon",
|
|
294
|
+
tertiary: "not-group-disabled:text-button-solid-tertiary-icon",
|
|
295
|
+
positive: "not-group-disabled:text-button-solid-positive-icon",
|
|
296
|
+
warning: "not-group-disabled:text-button-solid-warning-icon",
|
|
297
|
+
negative: "not-group-disabled:text-button-solid-negative-icon",
|
|
298
|
+
neutral: "not-group-disabled:text-button-solid-neutral-icon"
|
|
299
|
+
}[color];
|
|
300
|
+
return /* @__PURE__ */ jsxs(
|
|
301
|
+
"button",
|
|
302
|
+
{
|
|
303
|
+
ref,
|
|
304
|
+
onClick,
|
|
305
|
+
className: clsx(
|
|
306
|
+
"group font-semibold",
|
|
307
|
+
colorClasses,
|
|
308
|
+
"not-disabled:hover:brightness-90",
|
|
309
|
+
"disabled:text-disabled-text disabled:bg-disabled-background",
|
|
310
|
+
ButtonUtil.paddingMapping[size],
|
|
311
|
+
className
|
|
312
|
+
),
|
|
313
|
+
...restProps,
|
|
314
|
+
children: [
|
|
315
|
+
startIcon && /* @__PURE__ */ jsx2(
|
|
316
|
+
"span",
|
|
317
|
+
{
|
|
318
|
+
className: clsx(
|
|
319
|
+
iconColorClasses,
|
|
320
|
+
"group-disabled:text-disabled-icon"
|
|
321
|
+
),
|
|
322
|
+
children: startIcon
|
|
323
|
+
}
|
|
324
|
+
),
|
|
325
|
+
children,
|
|
326
|
+
endIcon && /* @__PURE__ */ jsx2(
|
|
327
|
+
"span",
|
|
328
|
+
{
|
|
329
|
+
className: clsx(
|
|
330
|
+
iconColorClasses,
|
|
331
|
+
"group-disabled:text-disabled-icon"
|
|
332
|
+
),
|
|
333
|
+
children: endIcon
|
|
334
|
+
}
|
|
335
|
+
)
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
);
|
|
339
|
+
});
|
|
340
|
+
var TextButton = ({
|
|
341
|
+
children,
|
|
342
|
+
color = "neutral",
|
|
343
|
+
size = "medium",
|
|
344
|
+
startIcon,
|
|
345
|
+
endIcon,
|
|
346
|
+
onClick,
|
|
347
|
+
coloredHoverBackground = true,
|
|
348
|
+
className,
|
|
349
|
+
...restProps
|
|
350
|
+
}) => {
|
|
351
|
+
const colorClasses = {
|
|
352
|
+
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",
|
|
353
|
+
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",
|
|
354
|
+
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"
|
|
355
|
+
}[color];
|
|
356
|
+
const backgroundColor = {
|
|
357
|
+
primary: "not-disabled:hover:bg-button-text-primary-text/20 not-disabled:focus-visible:bg-button-text-primary-text/20",
|
|
358
|
+
negative: "not-disabled:hover:bg-button-text-negative-text/20 not-disabled:focus-visible:bg-button-text-negative-text/20",
|
|
359
|
+
neutral: "not-disabled:hover:bg-button-text-neutral-text/20 not-disabled:focus-visible:bg-button-text-neutral-text/20"
|
|
360
|
+
}[color];
|
|
361
|
+
const iconColorClasses = {
|
|
362
|
+
primary: "not-group-disabled:text-button-text-primary-icon",
|
|
363
|
+
negative: "not-group-disabled:text-button-text-negative-icon",
|
|
364
|
+
neutral: "not-group-disabled:text-button-text-neutral-icon"
|
|
365
|
+
}[color];
|
|
366
|
+
return /* @__PURE__ */ jsxs(
|
|
367
|
+
"button",
|
|
368
|
+
{
|
|
369
|
+
onClick,
|
|
370
|
+
className: clsx(
|
|
371
|
+
"group font-semibold",
|
|
372
|
+
"disabled:text-disabled-text",
|
|
373
|
+
colorClasses,
|
|
374
|
+
{
|
|
375
|
+
[backgroundColor]: coloredHoverBackground,
|
|
376
|
+
"not-disabled:hover:bg-button-text-hover-background": !coloredHoverBackground
|
|
377
|
+
},
|
|
378
|
+
ButtonUtil.paddingMapping[size],
|
|
379
|
+
className
|
|
380
|
+
),
|
|
381
|
+
...restProps,
|
|
382
|
+
children: [
|
|
383
|
+
startIcon && /* @__PURE__ */ jsx2(
|
|
384
|
+
"span",
|
|
385
|
+
{
|
|
386
|
+
className: clsx(
|
|
387
|
+
iconColorClasses,
|
|
388
|
+
"group-disabled:text-disabled-icon"
|
|
389
|
+
),
|
|
390
|
+
children: startIcon
|
|
391
|
+
}
|
|
392
|
+
),
|
|
393
|
+
children,
|
|
394
|
+
endIcon && /* @__PURE__ */ jsx2(
|
|
395
|
+
"span",
|
|
396
|
+
{
|
|
397
|
+
className: clsx(
|
|
398
|
+
iconColorClasses,
|
|
399
|
+
"group-disabled:text-disabled-icon"
|
|
400
|
+
),
|
|
401
|
+
children: endIcon
|
|
402
|
+
}
|
|
403
|
+
)
|
|
404
|
+
]
|
|
405
|
+
}
|
|
406
|
+
);
|
|
407
|
+
};
|
|
408
|
+
var IconButton = forwardRef(function IconButton2({
|
|
409
|
+
children,
|
|
410
|
+
color = "primary",
|
|
411
|
+
size = "medium",
|
|
412
|
+
className,
|
|
413
|
+
...restProps
|
|
414
|
+
}, ref) {
|
|
415
|
+
const colorClasses = {
|
|
416
|
+
primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
|
|
417
|
+
secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
|
|
418
|
+
tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
|
|
419
|
+
positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
|
|
420
|
+
warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
|
|
421
|
+
negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
|
|
422
|
+
neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text",
|
|
423
|
+
transparent: "not-disabled:bg-transparent"
|
|
424
|
+
}[color];
|
|
425
|
+
return /* @__PURE__ */ jsx2(
|
|
426
|
+
"button",
|
|
427
|
+
{
|
|
428
|
+
ref,
|
|
429
|
+
className: clsx(
|
|
430
|
+
colorClasses,
|
|
431
|
+
"not-disabled:hover:brightness-90",
|
|
432
|
+
"disabled:text-disabled-text",
|
|
433
|
+
{
|
|
434
|
+
"disabled:bg-disabled-background": color !== "transparent",
|
|
435
|
+
"disabled:opacity-70": color === "transparent",
|
|
436
|
+
"not-disabled:hover:bg-button-text-hover-background": color === "transparent"
|
|
437
|
+
},
|
|
438
|
+
ButtonUtil.iconPaddingMapping[size],
|
|
439
|
+
className
|
|
440
|
+
),
|
|
441
|
+
...restProps,
|
|
442
|
+
children
|
|
443
|
+
}
|
|
444
|
+
);
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
// src/components/date/YearMonthPicker.tsx
|
|
448
|
+
import { useEffect as useEffect3, useRef, useState as useState4 } from "react";
|
|
449
|
+
import { Scrollbars } from "react-custom-scrollbars-2";
|
|
450
|
+
import clsx3 from "clsx";
|
|
451
|
+
|
|
452
|
+
// src/components/layout/Expandable.tsx
|
|
453
|
+
import { forwardRef as forwardRef2, useCallback as useCallback2, useEffect as useEffect2, useId, useState as useState3 } from "react";
|
|
454
|
+
import { ChevronDown } from "lucide-react";
|
|
455
|
+
import clsx2 from "clsx";
|
|
456
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
457
|
+
var ExpansionIcon = ({ isExpanded, className }) => {
|
|
458
|
+
return /* @__PURE__ */ jsx3(
|
|
459
|
+
ChevronDown,
|
|
460
|
+
{
|
|
461
|
+
"aria-hidden": true,
|
|
462
|
+
className: clsx2(
|
|
463
|
+
"min-w-6 w-6 min-h-6 h-6 transition-transform motion-safe:duration-200 motion-reduce:duration-0 ease-in-out",
|
|
464
|
+
{ "rotate-180": isExpanded },
|
|
465
|
+
className
|
|
466
|
+
)
|
|
467
|
+
}
|
|
468
|
+
);
|
|
469
|
+
};
|
|
470
|
+
var Expandable = forwardRef2(function Expandable2({
|
|
471
|
+
children,
|
|
472
|
+
id: providedId,
|
|
473
|
+
label,
|
|
474
|
+
icon,
|
|
475
|
+
isExpanded = false,
|
|
476
|
+
onChange = noop,
|
|
477
|
+
clickOnlyOnHeader = true,
|
|
478
|
+
disabled = false,
|
|
479
|
+
className,
|
|
480
|
+
headerClassName,
|
|
481
|
+
contentClassName,
|
|
482
|
+
contentExpandedClassName
|
|
483
|
+
}, ref) {
|
|
484
|
+
const defaultIcon = useCallback2((expanded) => /* @__PURE__ */ jsx3(ExpansionIcon, { isExpanded: expanded }), []);
|
|
485
|
+
icon ??= defaultIcon;
|
|
486
|
+
const generatedId = useId();
|
|
487
|
+
const id = providedId ?? generatedId;
|
|
488
|
+
return /* @__PURE__ */ jsxs2(
|
|
489
|
+
"div",
|
|
490
|
+
{
|
|
491
|
+
ref,
|
|
492
|
+
onClick: () => !clickOnlyOnHeader && !disabled && onChange(!isExpanded),
|
|
493
|
+
className: clsx2(
|
|
494
|
+
"flex-col-0 bg-surface text-on-surface group rounded-lg shadow-sm",
|
|
495
|
+
{ "cursor-pointer": !clickOnlyOnHeader && !disabled },
|
|
496
|
+
className
|
|
497
|
+
),
|
|
498
|
+
children: [
|
|
499
|
+
/* @__PURE__ */ jsxs2(
|
|
500
|
+
"button",
|
|
501
|
+
{
|
|
502
|
+
onClick: () => clickOnlyOnHeader && !disabled && onChange(!isExpanded),
|
|
503
|
+
className: clsx2(
|
|
504
|
+
"flex-row-2 py-2 px-4 rounded-lg justify-between items-center bg-surface text-on-surface select-none",
|
|
505
|
+
{
|
|
506
|
+
"group-hover:brightness-97": !isExpanded,
|
|
507
|
+
"hover:brightness-97": isExpanded && !disabled,
|
|
508
|
+
"cursor-pointer": clickOnlyOnHeader && !disabled
|
|
509
|
+
},
|
|
510
|
+
headerClassName
|
|
511
|
+
),
|
|
512
|
+
"aria-expanded": isExpanded,
|
|
513
|
+
"aria-controls": `${id}-content`,
|
|
514
|
+
"aria-disabled": disabled ?? void 0,
|
|
515
|
+
children: [
|
|
516
|
+
label,
|
|
517
|
+
icon(isExpanded)
|
|
518
|
+
]
|
|
519
|
+
}
|
|
520
|
+
),
|
|
521
|
+
/* @__PURE__ */ jsx3(
|
|
522
|
+
"div",
|
|
523
|
+
{
|
|
524
|
+
id: `${id}-content`,
|
|
525
|
+
className: clsx2(
|
|
526
|
+
"flex-col-2 px-4 transition-all duration-300 ease-in-out",
|
|
527
|
+
{
|
|
528
|
+
[clsx2("max-h-96 opacity-100 pb-2 overflow-y-auto", contentExpandedClassName)]: isExpanded,
|
|
529
|
+
"max-h-0 opacity-0 overflow-hidden": !isExpanded
|
|
530
|
+
},
|
|
531
|
+
contentClassName
|
|
532
|
+
),
|
|
533
|
+
role: "region",
|
|
534
|
+
children
|
|
535
|
+
}
|
|
536
|
+
)
|
|
537
|
+
]
|
|
538
|
+
}
|
|
539
|
+
);
|
|
540
|
+
});
|
|
541
|
+
var ExpandableUncontrolled = forwardRef2(function ExpandableUncontrolled2({
|
|
542
|
+
isExpanded,
|
|
543
|
+
onChange = noop,
|
|
544
|
+
...props
|
|
545
|
+
}, ref) {
|
|
546
|
+
const [usedIsExpanded, setUsedIsExpanded] = useState3(isExpanded);
|
|
547
|
+
useEffect2(() => {
|
|
548
|
+
setUsedIsExpanded(isExpanded);
|
|
549
|
+
}, [isExpanded]);
|
|
550
|
+
return /* @__PURE__ */ jsx3(
|
|
551
|
+
Expandable,
|
|
552
|
+
{
|
|
553
|
+
...props,
|
|
554
|
+
ref,
|
|
555
|
+
isExpanded: usedIsExpanded,
|
|
556
|
+
onChange: (value) => {
|
|
557
|
+
onChange(value);
|
|
558
|
+
setUsedIsExpanded(value);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
);
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
// src/components/date/YearMonthPicker.tsx
|
|
565
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
566
|
+
var YearMonthPicker = ({
|
|
567
|
+
displayedYearMonth = /* @__PURE__ */ new Date(),
|
|
568
|
+
start = subtractDuration(/* @__PURE__ */ new Date(), { years: 50 }),
|
|
569
|
+
end = addDuration(/* @__PURE__ */ new Date(), { years: 50 }),
|
|
570
|
+
onChange = noop,
|
|
571
|
+
className = "",
|
|
572
|
+
maxHeight = 300,
|
|
573
|
+
showValueOpen = true
|
|
574
|
+
}) => {
|
|
575
|
+
const locale = useLocale();
|
|
576
|
+
const ref = useRef(null);
|
|
577
|
+
useEffect3(() => {
|
|
578
|
+
const scrollToItem = () => {
|
|
579
|
+
if (ref.current) {
|
|
580
|
+
ref.current.scrollIntoView({
|
|
581
|
+
behavior: "instant",
|
|
582
|
+
block: "center"
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
scrollToItem();
|
|
587
|
+
}, [ref]);
|
|
588
|
+
if (end < start) {
|
|
589
|
+
console.error(`startYear: (${start}) less than endYear: (${end})`);
|
|
590
|
+
return null;
|
|
591
|
+
}
|
|
592
|
+
const years = range([start.getFullYear(), end.getFullYear()], { exclusiveEnd: false });
|
|
593
|
+
return /* @__PURE__ */ jsx4("div", { className: clsx3("flex-col-0 select-none", className), children: /* @__PURE__ */ jsx4(Scrollbars, { autoHeight: true, autoHeightMax: maxHeight, style: { height: "100%" }, children: /* @__PURE__ */ jsx4("div", { className: "flex-col-1 mr-3", children: years.map((year) => {
|
|
594
|
+
const selectedYear = displayedYearMonth.getFullYear() === year;
|
|
595
|
+
return /* @__PURE__ */ jsx4(
|
|
596
|
+
ExpandableUncontrolled,
|
|
597
|
+
{
|
|
598
|
+
ref: (displayedYearMonth.getFullYear() ?? (/* @__PURE__ */ new Date()).getFullYear()) === year ? ref : void 0,
|
|
599
|
+
label: /* @__PURE__ */ jsx4("span", { className: clsx3({ "text-primary font-bold": selectedYear }), children: year }),
|
|
600
|
+
isExpanded: showValueOpen && selectedYear,
|
|
601
|
+
contentClassName: "gap-y-1",
|
|
602
|
+
children: equalSizeGroups([...monthsList], 3).map((monthList, index) => /* @__PURE__ */ jsx4("div", { className: "flex-row-1", children: monthList.map((month) => {
|
|
603
|
+
const monthIndex = monthsList.indexOf(month);
|
|
604
|
+
const newDate = new Date(year, monthIndex);
|
|
605
|
+
const selectedMonth = selectedYear && monthIndex === displayedYearMonth.getMonth();
|
|
606
|
+
const firstOfMonth = new Date(year, monthIndex, 1);
|
|
607
|
+
const lastOfMonth = new Date(year, monthIndex, 1);
|
|
608
|
+
const isAfterStart = start === void 0 || start <= addDuration(subtractDuration(lastOfMonth, { days: 1 }), { months: 1 });
|
|
609
|
+
const isBeforeEnd = end === void 0 || firstOfMonth <= end;
|
|
610
|
+
const isValid = isAfterStart && isBeforeEnd;
|
|
611
|
+
return /* @__PURE__ */ jsx4(
|
|
612
|
+
SolidButton,
|
|
613
|
+
{
|
|
614
|
+
disabled: !isValid,
|
|
615
|
+
color: selectedMonth && isValid ? "primary" : "neutral",
|
|
616
|
+
className: "flex-1",
|
|
617
|
+
size: "small",
|
|
618
|
+
onClick: () => {
|
|
619
|
+
onChange(newDate);
|
|
620
|
+
},
|
|
621
|
+
children: new Intl.DateTimeFormat(locale, { month: "short" }).format(newDate)
|
|
622
|
+
},
|
|
623
|
+
month
|
|
624
|
+
);
|
|
625
|
+
}) }, index))
|
|
626
|
+
},
|
|
627
|
+
year
|
|
628
|
+
);
|
|
629
|
+
}) }) }) });
|
|
630
|
+
};
|
|
631
|
+
var YearMonthPickerUncontrolled = ({
|
|
632
|
+
displayedYearMonth,
|
|
633
|
+
onChange = noop,
|
|
634
|
+
...props
|
|
635
|
+
}) => {
|
|
636
|
+
const [yearMonth, setYearMonth] = useState4(displayedYearMonth ?? /* @__PURE__ */ new Date());
|
|
637
|
+
useEffect3(() => setYearMonth(displayedYearMonth), [displayedYearMonth]);
|
|
638
|
+
return /* @__PURE__ */ jsx4(
|
|
639
|
+
YearMonthPicker,
|
|
640
|
+
{
|
|
641
|
+
displayedYearMonth: yearMonth,
|
|
642
|
+
onChange: (date) => {
|
|
643
|
+
setYearMonth(date);
|
|
644
|
+
onChange(date);
|
|
645
|
+
},
|
|
646
|
+
...props
|
|
647
|
+
}
|
|
648
|
+
);
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
// src/components/date/DayPicker.tsx
|
|
652
|
+
import clsx4 from "clsx";
|
|
653
|
+
import { useEffect as useEffect4, useState as useState5 } from "react";
|
|
654
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
655
|
+
var DayPicker = ({
|
|
656
|
+
displayedMonth,
|
|
657
|
+
selected,
|
|
658
|
+
start,
|
|
659
|
+
end,
|
|
660
|
+
onChange = noop,
|
|
661
|
+
weekStart = "monday",
|
|
662
|
+
markToday = true,
|
|
663
|
+
className = ""
|
|
664
|
+
}) => {
|
|
665
|
+
const locale = useLocale();
|
|
666
|
+
const month = displayedMonth.getMonth();
|
|
667
|
+
const weeks = getWeeksForCalenderMonth(displayedMonth, weekStart);
|
|
668
|
+
return /* @__PURE__ */ jsxs3("div", { className: clsx4("flex-col-1 min-w-[220px] select-none", className), children: [
|
|
669
|
+
/* @__PURE__ */ jsx5("div", { className: "flex-row-2 text-center", children: weeks[0].map((weekDay, index) => /* @__PURE__ */ jsx5("div", { className: "flex-1 font-semibold", children: new Intl.DateTimeFormat(locale, { weekday: "long" }).format(weekDay).substring(0, 2) }, index)) }),
|
|
670
|
+
weeks.map((week, index) => /* @__PURE__ */ jsx5("div", { className: "flex-row-2 text-center", children: week.map((date) => {
|
|
671
|
+
const isSelected = !!selected && equalDate(selected, date);
|
|
672
|
+
const isToday = equalDate(/* @__PURE__ */ new Date(), date);
|
|
673
|
+
const isSameMonth = date.getMonth() === month;
|
|
674
|
+
const isDayValid = isInTimeSpan(date, start, end);
|
|
675
|
+
return /* @__PURE__ */ jsx5(
|
|
676
|
+
"button",
|
|
677
|
+
{
|
|
678
|
+
disabled: !isDayValid,
|
|
679
|
+
className: clsx4(
|
|
680
|
+
"flex-1 rounded-full border-2",
|
|
681
|
+
{
|
|
682
|
+
"text-description": !isSameMonth && !isSelected && isDayValid,
|
|
683
|
+
"text-button-solid-neutral-text bg-button-solid-neutral-background": !isSelected && isSameMonth && isDayValid,
|
|
684
|
+
"text-button-solid-primary-text bg-button-solid-primary-background": isSelected && isDayValid,
|
|
685
|
+
"hover:brightness-90 hover:bg-button-solid-primary-background hover:text-button-solid-primary-text": isDayValid,
|
|
686
|
+
"text-disabled-text bg-disabled-background cursor-not-allowed": !isDayValid,
|
|
687
|
+
"border-secondary": isToday && markToday,
|
|
688
|
+
"border-transparent": !isToday || !markToday
|
|
689
|
+
}
|
|
690
|
+
),
|
|
691
|
+
onClick: () => onChange(date),
|
|
692
|
+
children: date.getDate()
|
|
693
|
+
},
|
|
694
|
+
date.getDate()
|
|
695
|
+
);
|
|
696
|
+
}) }, index))
|
|
697
|
+
] });
|
|
698
|
+
};
|
|
699
|
+
var DayPickerUncontrolled = ({
|
|
700
|
+
displayedMonth,
|
|
701
|
+
selected,
|
|
702
|
+
onChange = noop,
|
|
703
|
+
...restProps
|
|
704
|
+
}) => {
|
|
705
|
+
const [date, setDate] = useState5(selected);
|
|
706
|
+
const [usedDisplayedMonth, setUsedDDisplayedMonth] = useState5(displayedMonth);
|
|
707
|
+
useEffect4(() => {
|
|
708
|
+
setDate(selected);
|
|
709
|
+
setUsedDDisplayedMonth(selected);
|
|
710
|
+
}, [selected]);
|
|
711
|
+
return /* @__PURE__ */ jsx5(
|
|
712
|
+
DayPicker,
|
|
713
|
+
{
|
|
714
|
+
displayedMonth: usedDisplayedMonth,
|
|
715
|
+
selected: date,
|
|
716
|
+
onChange: (newDate) => {
|
|
717
|
+
setDate(newDate);
|
|
718
|
+
setUsedDDisplayedMonth(newDate);
|
|
719
|
+
onChange(newDate);
|
|
720
|
+
},
|
|
721
|
+
...restProps
|
|
722
|
+
}
|
|
723
|
+
);
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
// src/localization/defaults/time.ts
|
|
727
|
+
var monthTranslation = {
|
|
728
|
+
en: {
|
|
729
|
+
january: "January",
|
|
730
|
+
february: "Febuary",
|
|
731
|
+
march: "March",
|
|
732
|
+
april: "April",
|
|
733
|
+
may: "May",
|
|
734
|
+
june: "June",
|
|
735
|
+
july: "July",
|
|
736
|
+
august: "August",
|
|
737
|
+
september: "September",
|
|
738
|
+
october: "October",
|
|
739
|
+
november: "November",
|
|
740
|
+
december: "December"
|
|
741
|
+
},
|
|
742
|
+
de: {
|
|
743
|
+
january: "Januar",
|
|
744
|
+
february: "Febuar",
|
|
745
|
+
march: "M\xE4rz",
|
|
746
|
+
april: "April",
|
|
747
|
+
may: "Mai",
|
|
748
|
+
june: "Juni",
|
|
749
|
+
july: "Juli",
|
|
750
|
+
august: "August",
|
|
751
|
+
september: "September",
|
|
752
|
+
october: "October",
|
|
753
|
+
november: "November",
|
|
754
|
+
december: "December"
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
var timeTranslation = {
|
|
758
|
+
en: {
|
|
759
|
+
...monthTranslation.en,
|
|
760
|
+
century: { one: "Century", other: "Centuries" },
|
|
761
|
+
decade: { one: "Decade", other: "Decades" },
|
|
762
|
+
year: { one: "Year", other: "Years" },
|
|
763
|
+
month: { one: "Month", other: "Months" },
|
|
764
|
+
day: { one: "Day", other: "Days" },
|
|
765
|
+
hour: { one: "Hour", other: "Hours" },
|
|
766
|
+
minute: { one: "Minute", other: "Minutes" },
|
|
767
|
+
second: { one: "Second", other: "Seconds" },
|
|
768
|
+
millisecond: { one: "Millisecond", other: "Milliseconds" },
|
|
769
|
+
microsecond: { one: "Microsecond", other: "Microseconds" },
|
|
770
|
+
nanosecond: { one: "Nanosecond", other: "Nanoseconds" },
|
|
771
|
+
yesterday: "Yesterday",
|
|
772
|
+
today: "Today",
|
|
773
|
+
tomorrow: "Tomorrow",
|
|
774
|
+
in: "in",
|
|
775
|
+
ago: "ago"
|
|
776
|
+
},
|
|
777
|
+
de: {
|
|
778
|
+
...monthTranslation.de,
|
|
779
|
+
century: { one: "Jahrhundert", other: "Jahrhunderte" },
|
|
780
|
+
decade: { one: "Jahrzehnt", other: "Jahrzehnte" },
|
|
781
|
+
year: { one: "Jahr", other: "Jahre" },
|
|
782
|
+
month: { one: "Monat", other: "Monate" },
|
|
783
|
+
day: { one: "Tag", other: "Tage" },
|
|
784
|
+
hour: { one: "Stunde", other: "Stunden" },
|
|
785
|
+
minute: { one: "Minute", other: "Minuten" },
|
|
786
|
+
second: { one: "Sekunde", other: "Sekunden" },
|
|
787
|
+
millisecond: { one: "Millisekunde", other: "Millisekunden" },
|
|
788
|
+
microsecond: { one: "Mikrosekunde", other: "Mikrosekunden" },
|
|
789
|
+
nanosecond: { one: "Nanosekunde", other: "Nanosekunden" },
|
|
790
|
+
yesterday: "Gestern",
|
|
791
|
+
today: "Heute",
|
|
792
|
+
tomorrow: "Morgen",
|
|
793
|
+
in: "in",
|
|
794
|
+
ago: "vor"
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
// src/components/date/DatePicker.tsx
|
|
799
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
800
|
+
var DatePicker = ({
|
|
801
|
+
overwriteTranslation,
|
|
802
|
+
value = /* @__PURE__ */ new Date(),
|
|
803
|
+
start = subtractDuration(/* @__PURE__ */ new Date(), { years: 50 }),
|
|
804
|
+
end = addDuration(/* @__PURE__ */ new Date(), { years: 50 }),
|
|
805
|
+
initialDisplay = "day",
|
|
806
|
+
onChange = noop,
|
|
807
|
+
yearMonthPickerProps,
|
|
808
|
+
dayPickerProps,
|
|
809
|
+
className = ""
|
|
810
|
+
}) => {
|
|
811
|
+
const locale = useLocale();
|
|
812
|
+
const translation = useTranslation([timeTranslation], overwriteTranslation);
|
|
813
|
+
const [displayedMonth, setDisplayedMonth] = useState6(value);
|
|
814
|
+
const [displayMode, setDisplayMode] = useState6(initialDisplay);
|
|
815
|
+
useEffect5(() => {
|
|
816
|
+
setDisplayedMonth(value);
|
|
817
|
+
}, [value]);
|
|
818
|
+
return /* @__PURE__ */ jsxs4("div", { className: clsx5("flex-col-4", className), children: [
|
|
819
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex-row-2 items-center justify-between h-7", children: [
|
|
820
|
+
/* @__PURE__ */ jsxs4(
|
|
821
|
+
TextButton,
|
|
822
|
+
{
|
|
823
|
+
className: clsx5("flex-row-1 items-center cursor-pointer select-none", {
|
|
824
|
+
"text-disabled-text": displayMode !== "day"
|
|
825
|
+
}),
|
|
826
|
+
onClick: () => setDisplayMode(displayMode === "day" ? "yearMonth" : "day"),
|
|
827
|
+
children: [
|
|
828
|
+
`${new Intl.DateTimeFormat(locale, { month: "long" }).format(displayedMonth)} ${displayedMonth.getFullYear()}`,
|
|
829
|
+
/* @__PURE__ */ jsx6(ChevronDown2, { size: 16 })
|
|
830
|
+
]
|
|
831
|
+
}
|
|
832
|
+
),
|
|
833
|
+
displayMode === "day" && /* @__PURE__ */ jsxs4("div", { className: "flex-row-2 justify-end", children: [
|
|
834
|
+
/* @__PURE__ */ jsx6(
|
|
835
|
+
SolidButton,
|
|
836
|
+
{
|
|
837
|
+
size: "small",
|
|
838
|
+
color: "primary",
|
|
839
|
+
disabled: !isInTimeSpan(subtractDuration(displayedMonth, { months: 1 }), start, end),
|
|
840
|
+
onClick: () => {
|
|
841
|
+
setDisplayedMonth(subtractDuration(displayedMonth, { months: 1 }));
|
|
842
|
+
},
|
|
843
|
+
children: /* @__PURE__ */ jsx6(ArrowUp, { size: 20 })
|
|
844
|
+
}
|
|
845
|
+
),
|
|
846
|
+
/* @__PURE__ */ jsx6(
|
|
847
|
+
SolidButton,
|
|
848
|
+
{
|
|
849
|
+
size: "small",
|
|
850
|
+
color: "primary",
|
|
851
|
+
disabled: !isInTimeSpan(addDuration(displayedMonth, { months: 1 }), start, end),
|
|
852
|
+
onClick: () => {
|
|
853
|
+
setDisplayedMonth(addDuration(displayedMonth, { months: 1 }));
|
|
854
|
+
},
|
|
855
|
+
children: /* @__PURE__ */ jsx6(ArrowDown, { size: 20 })
|
|
856
|
+
}
|
|
857
|
+
)
|
|
858
|
+
] })
|
|
859
|
+
] }),
|
|
860
|
+
displayMode === "yearMonth" ? /* @__PURE__ */ jsx6(
|
|
861
|
+
YearMonthPicker,
|
|
862
|
+
{
|
|
863
|
+
...yearMonthPickerProps,
|
|
864
|
+
displayedYearMonth: value,
|
|
865
|
+
start,
|
|
866
|
+
end,
|
|
867
|
+
onChange: (newDate) => {
|
|
868
|
+
setDisplayedMonth(newDate);
|
|
869
|
+
setDisplayMode("day");
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
) : /* @__PURE__ */ jsxs4("div", { children: [
|
|
873
|
+
/* @__PURE__ */ jsx6(
|
|
874
|
+
DayPicker,
|
|
875
|
+
{
|
|
876
|
+
...dayPickerProps,
|
|
877
|
+
displayedMonth,
|
|
878
|
+
start,
|
|
879
|
+
end,
|
|
880
|
+
selected: value,
|
|
881
|
+
onChange: (date) => {
|
|
882
|
+
onChange(date);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
),
|
|
886
|
+
/* @__PURE__ */ jsx6("div", { className: "mt-2", children: /* @__PURE__ */ jsx6(
|
|
887
|
+
TextButton,
|
|
888
|
+
{
|
|
889
|
+
color: "primary",
|
|
890
|
+
onClick: () => {
|
|
891
|
+
const newDate = /* @__PURE__ */ new Date();
|
|
892
|
+
newDate.setHours(value.getHours(), value.getMinutes());
|
|
893
|
+
onChange(newDate);
|
|
894
|
+
},
|
|
895
|
+
children: translation("today")
|
|
896
|
+
}
|
|
897
|
+
) })
|
|
898
|
+
] })
|
|
899
|
+
] });
|
|
900
|
+
};
|
|
901
|
+
var DatePickerUncontrolled = ({
|
|
902
|
+
value = /* @__PURE__ */ new Date(),
|
|
903
|
+
onChange = noop,
|
|
904
|
+
...props
|
|
905
|
+
}) => {
|
|
906
|
+
const [date, setDate] = useState6(value);
|
|
907
|
+
useEffect5(() => setDate(value), [value]);
|
|
908
|
+
return /* @__PURE__ */ jsx6(
|
|
909
|
+
DatePicker,
|
|
910
|
+
{
|
|
911
|
+
...props,
|
|
912
|
+
value: date,
|
|
913
|
+
onChange: (date1) => {
|
|
914
|
+
setDate(date1);
|
|
915
|
+
onChange(date1);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
);
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
// src/components/date/TimeDisplay.tsx
|
|
922
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
923
|
+
var defaultTimeDisplayTranslations = {
|
|
924
|
+
en: {
|
|
925
|
+
...timeTranslation.en,
|
|
926
|
+
inDays: `in {{days}} days`,
|
|
927
|
+
agoDays: `{{days}} days ago`
|
|
928
|
+
},
|
|
929
|
+
de: {
|
|
930
|
+
...timeTranslation.de,
|
|
931
|
+
inDays: `in {{days}} Tagen`,
|
|
932
|
+
agoDays: `vor {{days}} Tagen`
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
var TimeDisplay = ({
|
|
936
|
+
overwriteTranslation,
|
|
937
|
+
date,
|
|
938
|
+
mode = "daysFromToday"
|
|
939
|
+
}) => {
|
|
940
|
+
const translation = useTranslation([defaultTimeDisplayTranslations], overwriteTranslation);
|
|
941
|
+
const difference = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0).valueOf() - new Date(date).setHours(0, 0, 0, 0).valueOf();
|
|
942
|
+
const isBefore = difference > 0;
|
|
943
|
+
const differenceInDays = Math.floor(Math.abs(difference) / (1e3 * 3600 * 24));
|
|
944
|
+
let displayString;
|
|
945
|
+
if (differenceInDays === 0) {
|
|
946
|
+
displayString = translation("today");
|
|
947
|
+
} else if (differenceInDays === 1) {
|
|
948
|
+
displayString = isBefore ? translation("yesterday") : translation("tomorrow");
|
|
949
|
+
} else {
|
|
950
|
+
displayString = isBefore ? translation("agoDays", { replacements: { days: differenceInDays.toString() } }) : translation("inDays", { replacements: { days: differenceInDays.toString() } });
|
|
951
|
+
}
|
|
952
|
+
const monthToTranslation = {
|
|
953
|
+
0: translation("january"),
|
|
954
|
+
1: translation("february"),
|
|
955
|
+
2: translation("march"),
|
|
956
|
+
3: translation("april"),
|
|
957
|
+
4: translation("may"),
|
|
958
|
+
5: translation("june"),
|
|
959
|
+
6: translation("july"),
|
|
960
|
+
7: translation("august"),
|
|
961
|
+
8: translation("september"),
|
|
962
|
+
9: translation("october"),
|
|
963
|
+
10: translation("november"),
|
|
964
|
+
11: translation("december")
|
|
965
|
+
};
|
|
966
|
+
let fullString;
|
|
967
|
+
if (mode === "daysFromToday") {
|
|
968
|
+
fullString = `${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")} - ${displayString}`;
|
|
969
|
+
} else {
|
|
970
|
+
fullString = `${date.getDate()}. ${monthToTranslation[date.getMonth()]} ${date.getFullYear()}`;
|
|
971
|
+
}
|
|
972
|
+
return /* @__PURE__ */ jsx7("span", { children: fullString });
|
|
973
|
+
};
|
|
974
|
+
|
|
975
|
+
// src/components/date/TimePicker.tsx
|
|
976
|
+
import { useEffect as useEffect6, useRef as useRef2, useState as useState7 } from "react";
|
|
977
|
+
import { Scrollbars as Scrollbars2 } from "react-custom-scrollbars-2";
|
|
978
|
+
import clsx6 from "clsx";
|
|
979
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
980
|
+
var TimePicker = ({
|
|
981
|
+
time = /* @__PURE__ */ new Date(),
|
|
982
|
+
onChange = noop,
|
|
983
|
+
is24HourFormat = true,
|
|
984
|
+
minuteIncrement = "5min",
|
|
985
|
+
maxHeight = 300,
|
|
986
|
+
className = ""
|
|
987
|
+
}) => {
|
|
988
|
+
const minuteRef = useRef2(null);
|
|
989
|
+
const hourRef = useRef2(null);
|
|
990
|
+
const isPM = time.getHours() >= 11;
|
|
991
|
+
const hours = is24HourFormat ? range(24) : range([1, 12], { exclusiveEnd: false });
|
|
992
|
+
let minutes = range(60);
|
|
993
|
+
useEffect6(() => {
|
|
994
|
+
const scrollToItem = () => {
|
|
995
|
+
if (minuteRef.current) {
|
|
996
|
+
const container = minuteRef.current.parentElement;
|
|
997
|
+
const hasOverflow = container.scrollHeight > maxHeight;
|
|
998
|
+
if (hasOverflow) {
|
|
999
|
+
minuteRef.current.scrollIntoView({
|
|
1000
|
+
behavior: "instant",
|
|
1001
|
+
block: "nearest"
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
scrollToItem();
|
|
1007
|
+
}, [minuteRef, minuteRef.current]);
|
|
1008
|
+
useEffect6(() => {
|
|
1009
|
+
const scrollToItem = () => {
|
|
1010
|
+
if (hourRef.current) {
|
|
1011
|
+
const container = hourRef.current.parentElement;
|
|
1012
|
+
const hasOverflow = container.scrollHeight > maxHeight;
|
|
1013
|
+
if (hasOverflow) {
|
|
1014
|
+
hourRef.current.scrollIntoView({
|
|
1015
|
+
behavior: "instant",
|
|
1016
|
+
block: "nearest"
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
scrollToItem();
|
|
1022
|
+
}, [hourRef, hourRef.current]);
|
|
1023
|
+
switch (minuteIncrement) {
|
|
1024
|
+
case "5min":
|
|
1025
|
+
minutes = minutes.filter((value) => value % 5 === 0);
|
|
1026
|
+
break;
|
|
1027
|
+
case "10min":
|
|
1028
|
+
minutes = minutes.filter((value) => value % 10 === 0);
|
|
1029
|
+
break;
|
|
1030
|
+
case "15min":
|
|
1031
|
+
minutes = minutes.filter((value) => value % 15 === 0);
|
|
1032
|
+
break;
|
|
1033
|
+
case "30min":
|
|
1034
|
+
minutes = minutes.filter((value) => value % 30 === 0);
|
|
1035
|
+
break;
|
|
1036
|
+
}
|
|
1037
|
+
const closestMinute = closestMatch(minutes, (item1, item2) => Math.abs(item1 - time.getMinutes()) < Math.abs(item2 - time.getMinutes()));
|
|
1038
|
+
const style = (selected) => clsx6(
|
|
1039
|
+
"chip-full hover:brightness-90 hover:bg-primary hover:text-on-primary rounded-md mr-3",
|
|
1040
|
+
{ "bg-primary text-on-primary": selected, "bg-white text-black": !selected }
|
|
1041
|
+
);
|
|
1042
|
+
const onChangeWrapper = (transformer) => {
|
|
1043
|
+
const newDate = new Date(time);
|
|
1044
|
+
transformer(newDate);
|
|
1045
|
+
onChange(newDate);
|
|
1046
|
+
};
|
|
1047
|
+
return /* @__PURE__ */ jsxs5("div", { className: clsx6("flex-row-2 w-fit min-w-[150px] select-none", className), children: [
|
|
1048
|
+
/* @__PURE__ */ jsx8(Scrollbars2, { autoHeight: true, autoHeightMax: maxHeight, style: { height: "100%" }, children: /* @__PURE__ */ jsx8("div", { className: "flex-col-1 h-full", children: hours.map((hour) => {
|
|
1049
|
+
const currentHour = hour === time.getHours() - (!is24HourFormat && isPM ? 12 : 0);
|
|
1050
|
+
return /* @__PURE__ */ jsx8(
|
|
1051
|
+
"button",
|
|
1052
|
+
{
|
|
1053
|
+
ref: currentHour ? hourRef : void 0,
|
|
1054
|
+
className: style(currentHour),
|
|
1055
|
+
onClick: () => onChangeWrapper((newDate) => newDate.setHours(hour + (!is24HourFormat && isPM ? 12 : 0))),
|
|
1056
|
+
children: hour.toString().padStart(2, "0")
|
|
1057
|
+
},
|
|
1058
|
+
hour
|
|
1059
|
+
);
|
|
1060
|
+
}) }) }),
|
|
1061
|
+
/* @__PURE__ */ jsx8(Scrollbars2, { autoHeight: true, autoHeightMax: maxHeight, style: { height: "100%" }, children: /* @__PURE__ */ jsx8("div", { className: "flex-col-1 h-full", children: minutes.map((minute) => {
|
|
1062
|
+
const currentMinute = minute === closestMinute;
|
|
1063
|
+
return /* @__PURE__ */ jsx8(
|
|
1064
|
+
"button",
|
|
1065
|
+
{
|
|
1066
|
+
ref: currentMinute ? minuteRef : void 0,
|
|
1067
|
+
className: style(currentMinute),
|
|
1068
|
+
onClick: () => onChangeWrapper((newDate) => newDate.setMinutes(minute)),
|
|
1069
|
+
children: minute.toString().padStart(2, "0")
|
|
1070
|
+
},
|
|
1071
|
+
minute + minuteIncrement
|
|
1072
|
+
);
|
|
1073
|
+
}) }) }),
|
|
1074
|
+
!is24HourFormat && /* @__PURE__ */ jsxs5("div", { className: "flex-col-1", children: [
|
|
1075
|
+
/* @__PURE__ */ jsx8(
|
|
1076
|
+
"button",
|
|
1077
|
+
{
|
|
1078
|
+
className: style(!isPM),
|
|
1079
|
+
onClick: () => onChangeWrapper((newDate) => isPM && newDate.setHours(newDate.getHours() - 12)),
|
|
1080
|
+
children: "AM"
|
|
1081
|
+
}
|
|
1082
|
+
),
|
|
1083
|
+
/* @__PURE__ */ jsx8(
|
|
1084
|
+
"button",
|
|
1085
|
+
{
|
|
1086
|
+
className: style(isPM),
|
|
1087
|
+
onClick: () => onChangeWrapper((newDate) => !isPM && newDate.setHours(newDate.getHours() + 12)),
|
|
1088
|
+
children: "PM"
|
|
1089
|
+
}
|
|
1090
|
+
)
|
|
1091
|
+
] })
|
|
1092
|
+
] });
|
|
1093
|
+
};
|
|
1094
|
+
var TimePickerUncontrolled = ({
|
|
1095
|
+
time,
|
|
1096
|
+
onChange = noop,
|
|
1097
|
+
...props
|
|
1098
|
+
}) => {
|
|
1099
|
+
const [value, setValue] = useState7(time);
|
|
1100
|
+
useEffect6(() => setValue(time), [time]);
|
|
1101
|
+
return /* @__PURE__ */ jsx8(
|
|
1102
|
+
TimePicker,
|
|
1103
|
+
{
|
|
1104
|
+
...props,
|
|
1105
|
+
time: value,
|
|
1106
|
+
onChange: (time1) => {
|
|
1107
|
+
setValue(time1);
|
|
1108
|
+
onChange(time1);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
);
|
|
1112
|
+
};
|
|
1113
|
+
export {
|
|
1114
|
+
DatePicker,
|
|
1115
|
+
DatePickerUncontrolled,
|
|
1116
|
+
DayPicker,
|
|
1117
|
+
DayPickerUncontrolled,
|
|
1118
|
+
TimeDisplay,
|
|
1119
|
+
TimePicker,
|
|
1120
|
+
TimePickerUncontrolled,
|
|
1121
|
+
YearMonthPicker,
|
|
1122
|
+
YearMonthPickerUncontrolled
|
|
1123
|
+
};
|
|
1124
|
+
//# sourceMappingURL=index.mjs.map
|