@povio/ui 2.2.9-rc.4 → 2.2.9-rc.40
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/components/buttons/Button/Button.d.ts +2 -1
- package/dist/components/buttons/Button/Button.js +41 -32
- package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +2 -1
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +2 -2
- package/dist/components/inputs/Checkbox/Checkbox.js +6 -1
- package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +3 -0
- package/dist/components/inputs/Checkbox/checkbox.cva.js +2 -1
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +8 -3
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +81 -6
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +7 -2
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +83 -5
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +8 -2
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +84 -7
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +60 -4
- package/dist/components/inputs/DateTime/shared/Calendar.d.ts +5 -2
- package/dist/components/inputs/DateTime/shared/Calendar.js +23 -6
- package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +3 -3
- package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/DateField.js +3 -10
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +6 -2
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +65 -55
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +14 -0
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +19 -6
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +4 -2
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +4 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.d.ts +7 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +13 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +6 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +21 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.d.ts +2 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.js +9 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.spec.d.ts +1 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.d.ts +35 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +80 -0
- package/dist/components/inputs/File/FileUpload.js +1 -0
- package/dist/components/inputs/File/shared/InputUploadContent.js +1 -0
- package/dist/components/inputs/FormField/FormField.d.ts +3 -3
- package/dist/components/inputs/FormField/FormFieldHeader.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
- package/dist/components/inputs/FormField/FormFieldLabel.d.ts +2 -2
- package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +6 -0
- package/dist/components/inputs/FormField/formFieldHeader.cva.js +11 -0
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +78 -7
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.d.ts +45 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.js +146 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +35 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +233 -0
- package/dist/components/inputs/Input/TextArea/TextArea.cva.d.ts +4 -0
- package/dist/components/inputs/Input/TextArea/TextArea.cva.js +5 -0
- package/dist/components/inputs/Input/TextArea/TextArea.js +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +77 -7
- package/dist/components/inputs/Input/shared/InputContent.js +7 -6
- package/dist/components/inputs/Input/shared/numberStatic.utils.d.ts +1 -0
- package/dist/components/inputs/Input/shared/numberStatic.utils.js +7 -0
- package/dist/components/inputs/Inputs/InputItem.d.ts +12 -9
- package/dist/components/inputs/Inputs/InputItem.js +2 -0
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +2 -1
- package/dist/components/inputs/RadioGroup/RadioGroup.js +106 -25
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +17 -0
- package/dist/components/inputs/RadioGroup/radio.cva.js +42 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +98 -6
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +15 -10
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +25 -19
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +3 -3
- package/dist/components/inputs/Selection/Select/QuerySelect.js +8 -35
- package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
- package/dist/components/inputs/Selection/Select/Select.js +111 -4
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +4 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +3 -2
- package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +8 -4
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +13 -2
- package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectListBox.js +3 -3
- package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectMobile.js +5 -3
- package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/select.context.js +27 -4
- package/dist/components/inputs/Selection/shared/select.types.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +3 -0
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +5 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +23 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.js +37 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.spec.d.ts +1 -0
- package/dist/components/inputs/Skeleton/InputFrame.d.ts +77 -0
- package/dist/components/inputs/Skeleton/InputFrame.js +200 -0
- package/dist/components/inputs/TextEditor/TextEditor.js +1 -0
- package/dist/components/inputs/Toggle/Toggle.js +6 -1
- package/dist/components/inputs/Toggle/toggle.cva.d.ts +3 -0
- package/dist/components/inputs/Toggle/toggle.cva.js +2 -1
- package/dist/components/inputs/shared/CheckContent.d.ts +2 -1
- package/dist/components/inputs/shared/CheckContent.js +3 -4
- package/dist/components/inputs/shared/InputClear.d.ts +2 -1
- package/dist/components/inputs/shared/InputClear.js +13 -1
- package/dist/components/inputs/shared/StaticInput.d.ts +38 -0
- package/dist/components/inputs/shared/TooltipWrapper.js +5 -1
- package/dist/components/inputs/shared/input.cva.d.ts +10 -0
- package/dist/components/inputs/shared/input.cva.js +19 -1
- package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +4 -0
- package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.d.ts +13 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.js +47 -0
- package/dist/config/uiConfig.context.d.ts +8 -2
- package/dist/config/uiConfig.context.js +12 -1
- package/dist/config/uiStyle.context.d.ts +27 -4
- package/dist/hooks/useIntersectionObserver.d.ts +1 -1
- package/dist/hooks/useIntersectionObserver.js +29 -10
- package/dist/hooks/useQueryAutocomplete.d.ts +5 -16
- package/dist/hooks/useQueryAutocomplete.js +20 -5
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -2
- package/dist/tw-ui-plugin.js +2 -0
- package/dist/utils/date-time.utils.d.ts +30 -9
- package/dist/utils/date-time.utils.js +113 -1
- package/dist/utils/query.utils.d.ts +4 -0
- package/dist/utils/query.utils.js +8 -0
- package/package.json +1 -1
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { CalendarIcon } from "../assets/icons/Calendar.js";
|
|
2
|
+
import { ClockIcon } from "../assets/icons/Clock.js";
|
|
3
|
+
import { DateTimeIcon } from "../assets/icons/DateTime.js";
|
|
1
4
|
import { ObjectUtils } from "../utils/object.utils.js";
|
|
2
5
|
import { useDeepCompareMemo } from "../hooks/useDeepCompare.js";
|
|
3
6
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -6,6 +9,7 @@ import { createContext, use } from "react";
|
|
|
6
9
|
var UIConfig;
|
|
7
10
|
(function(_UIConfig) {
|
|
8
11
|
const DEFAULT_CONFIG = {
|
|
12
|
+
renderStaticInput: true,
|
|
9
13
|
input: {
|
|
10
14
|
variant: "outlined",
|
|
11
15
|
as: "default",
|
|
@@ -43,8 +47,15 @@ var UIConfig;
|
|
|
43
47
|
},
|
|
44
48
|
dateInput: {
|
|
45
49
|
todayIcon: false,
|
|
50
|
+
todayIconButtonSize: "none",
|
|
51
|
+
todayIconPlacement: "content",
|
|
46
52
|
shouldForceLeadingZeros: false,
|
|
47
|
-
disableManualEntry: false
|
|
53
|
+
disableManualEntry: false,
|
|
54
|
+
autoFixYear: false,
|
|
55
|
+
calendarIcon: /* @__PURE__ */ jsx(CalendarIcon, { className: "size-5" }),
|
|
56
|
+
dateTimeIcon: /* @__PURE__ */ jsx(DateTimeIcon, { className: "size-5" }),
|
|
57
|
+
timeIcon: /* @__PURE__ */ jsx(ClockIcon, { className: "size-6 text-interactive-text-secondary-idle" }),
|
|
58
|
+
setDateValueOnDateSelection: false
|
|
48
59
|
},
|
|
49
60
|
actionModal: {
|
|
50
61
|
titleTypography: {
|
|
@@ -4,11 +4,17 @@ import { BreadcrumbChevronVariantProps, BreadcrumbIconVariantProps, BreadcrumbIt
|
|
|
4
4
|
import { ButtonVariantProps } from '../components/buttons/Button/button.cva';
|
|
5
5
|
import { PillButtonVariants } from '../components/buttons/PillButton/pillButton.cva';
|
|
6
6
|
import { CheckboxIconVariantProps, CheckboxVariantProps } from '../components/inputs/Checkbox/checkbox.cva';
|
|
7
|
+
import { DatePickerInputContentRowProps } from '../components/inputs/DateTime/shared/datePickerInput.cva';
|
|
7
8
|
import { FormFieldErrorVariantProps } from '../components/inputs/FormField/formFieldError.cva';
|
|
9
|
+
import { FormFieldHeaderVariantProps } from '../components/inputs/FormField/formFieldHeader.cva';
|
|
8
10
|
import { FormFieldHelperVariantProps } from '../components/inputs/FormField/formFieldHelper.cva';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
+
import { TextAreaWrapperVariantProps } from '../components/inputs/Input/TextArea/TextArea.cva';
|
|
12
|
+
import { RadioContentRowVariantProps, RadioContentWrapperVariantProps, RadioVariantProps } from '../components/inputs/RadioGroup/radio.cva';
|
|
13
|
+
import { SelectPopoverCva } from '../components/inputs/Selection/shared/selectDesktop.cva';
|
|
14
|
+
import { SelectListBoxItemCva } from '../components/inputs/Selection/shared/selectItem.cva';
|
|
15
|
+
import { InputBaseProps, InputClearClassProps, InputContentWrapperProps, InputSideProps, InputSizeProps } from '../components/inputs/shared/input.cva';
|
|
11
16
|
import { LabelBaseProps } from '../components/inputs/shared/label.cva';
|
|
17
|
+
import { TooltipWrapperTriggerVariantProps } from '../components/inputs/shared/tooltipWrapper.cva';
|
|
12
18
|
import { ToggleVariantProps } from '../components/inputs/Toggle/toggle.cva';
|
|
13
19
|
import { MenuCvaVariantProps, MenuItemVariantProps, MenuPopoverVariantProps, MenuPopoverWrapperVariantProps } from '../components/Menu/menu.cva';
|
|
14
20
|
import { AccordionChevronVariantProps, AccordionHeadingSubtitleVariantProps, AccordionHeadingTitleVariantProps, AccordionHeadingVariantProps, AccordionIconVariantProps, AccordionItemVariantProps, AccordionPanelContentVariantProps, AccordionPanelVariantProps, AccordionTriggerVariantProps, AccordionVariantProps } from '../components/navigation/Accordion/accordion.cva';
|
|
@@ -24,13 +30,12 @@ import { LinkVariantProps } from '../components/text/Link/link.cva';
|
|
|
24
30
|
import { TagVariantProps } from '../components/text/Tag/tag.cva';
|
|
25
31
|
import { TypographyVariantProps } from '../components/text/Typography/typography.cva';
|
|
26
32
|
import { CompoundMapper, ConfigSchema } from '../utils/compoundMapper';
|
|
27
|
-
import { SelectListBoxItemCva } from '../components/inputs/Selection/shared/selectItem.cva';
|
|
28
33
|
export declare namespace UIStyle {
|
|
29
34
|
export type Cva<T> = (props: (T & ClassProp) | ClassProp) => string;
|
|
30
35
|
type OptionKey = {
|
|
31
36
|
[K in keyof Options]: Options[K] extends object ? `${K & string}.${keyof Options[K] & string}` : never;
|
|
32
37
|
}[keyof Options];
|
|
33
|
-
interface Options {
|
|
38
|
+
export interface Options {
|
|
34
39
|
button: {
|
|
35
40
|
cva?: Cva<ButtonVariantProps>;
|
|
36
41
|
sizeCva?: Cva<ButtonVariantProps>;
|
|
@@ -46,10 +51,14 @@ export declare namespace UIStyle {
|
|
|
46
51
|
cva?: Cva<CheckboxVariantProps>;
|
|
47
52
|
iconCva?: Cva<CheckboxIconVariantProps>;
|
|
48
53
|
typography?: CompoundMapper<TypographyVariantProps, CheckboxVariantProps>;
|
|
54
|
+
contentClassName?: CompoundMapper<string, CheckboxVariantProps>;
|
|
49
55
|
};
|
|
50
56
|
radio: {
|
|
51
57
|
cva?: Cva<RadioVariantProps>;
|
|
58
|
+
contentWrapperCva?: Cva<RadioContentWrapperVariantProps>;
|
|
59
|
+
contentRowCva?: Cva<RadioContentRowVariantProps>;
|
|
52
60
|
typography?: CompoundMapper<TypographyVariantProps, RadioVariantProps>;
|
|
61
|
+
contentClassName?: CompoundMapper<string, RadioVariantProps>;
|
|
53
62
|
};
|
|
54
63
|
status: {
|
|
55
64
|
iconCva?: Cva<ToastVariantProps>;
|
|
@@ -64,9 +73,20 @@ export declare namespace UIStyle {
|
|
|
64
73
|
};
|
|
65
74
|
input: {
|
|
66
75
|
baseCva?: Cva<InputBaseProps>;
|
|
76
|
+
clearClassCva?: Cva<InputClearClassProps>;
|
|
77
|
+
contentWrapperCva?: Cva<InputContentWrapperProps>;
|
|
67
78
|
sizeCva?: Cva<InputSizeProps>;
|
|
68
79
|
sideCva?: Cva<InputSideProps>;
|
|
69
80
|
};
|
|
81
|
+
textArea: {
|
|
82
|
+
wrapperCva?: Cva<TextAreaWrapperVariantProps>;
|
|
83
|
+
};
|
|
84
|
+
tooltipWrapper: {
|
|
85
|
+
triggerCva?: Cva<TooltipWrapperTriggerVariantProps>;
|
|
86
|
+
};
|
|
87
|
+
datePickerInput: {
|
|
88
|
+
contentRowCva?: Cva<DatePickerInputContentRowProps>;
|
|
89
|
+
};
|
|
70
90
|
label: {
|
|
71
91
|
cva?: Cva<LabelBaseProps>;
|
|
72
92
|
typography?: CompoundMapper<TypographyVariantProps, LabelBaseProps>;
|
|
@@ -74,6 +94,7 @@ export declare namespace UIStyle {
|
|
|
74
94
|
toggle: {
|
|
75
95
|
cva?: Cva<ToggleVariantProps>;
|
|
76
96
|
typography?: CompoundMapper<TypographyVariantProps, ToggleVariantProps>;
|
|
97
|
+
contentClassName?: CompoundMapper<string, ToggleVariantProps>;
|
|
77
98
|
};
|
|
78
99
|
typography: {
|
|
79
100
|
cva?: Cva<TypographyVariantProps>;
|
|
@@ -145,11 +166,13 @@ export declare namespace UIStyle {
|
|
|
145
166
|
cva?: Cva<PopoverVariantProps>;
|
|
146
167
|
};
|
|
147
168
|
formField: {
|
|
169
|
+
headerCva?: Cva<FormFieldHeaderVariantProps>;
|
|
148
170
|
errorLabelCva?: Cva<FormFieldErrorVariantProps>;
|
|
149
171
|
helperLabelCva?: Cva<FormFieldHelperVariantProps>;
|
|
150
172
|
};
|
|
151
173
|
select: {
|
|
152
174
|
listBoxItemCva?: Cva<SelectListBoxItemCva>;
|
|
175
|
+
popoverCva?: Cva<SelectPopoverCva>;
|
|
153
176
|
};
|
|
154
177
|
}
|
|
155
178
|
interface ProviderProps {
|
|
@@ -3,6 +3,6 @@ type UseIntersectionObserverProps = {
|
|
|
3
3
|
onIntersectionChange?: (entry: IntersectionObserverEntry) => void;
|
|
4
4
|
} & IntersectionObserverInit;
|
|
5
5
|
export declare const useIntersectionObserver: <T extends HTMLElement>({ onIntersection, onIntersectionChange, root, rootMargin, threshold, }: UseIntersectionObserverProps) => {
|
|
6
|
-
ref:
|
|
6
|
+
ref: (element: T | null) => void;
|
|
7
7
|
};
|
|
8
8
|
export {};
|
|
@@ -1,25 +1,44 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
2
|
//#region src/hooks/useIntersectionObserver.ts
|
|
3
3
|
var useIntersectionObserver = ({ onIntersection, onIntersectionChange, root, rootMargin, threshold }) => {
|
|
4
|
-
const
|
|
4
|
+
const elementRef = useRef(null);
|
|
5
|
+
const observerRef = useRef(null);
|
|
6
|
+
const onIntersectionRef = useRef(onIntersection);
|
|
7
|
+
const onIntersectionChangeRef = useRef(onIntersectionChange);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
onIntersectionRef.current = onIntersection;
|
|
10
|
+
}, [onIntersection]);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
onIntersectionChangeRef.current = onIntersectionChange;
|
|
13
|
+
}, [onIntersectionChange]);
|
|
5
14
|
useEffect(() => {
|
|
6
15
|
const observer = new IntersectionObserver((entries) => {
|
|
7
|
-
if (entries.some((entry) => entry.isIntersecting))
|
|
8
|
-
|
|
16
|
+
if (entries.some((entry) => entry.isIntersecting)) onIntersectionRef.current?.();
|
|
17
|
+
onIntersectionChangeRef.current?.(entries[0]);
|
|
9
18
|
}, {
|
|
10
19
|
root,
|
|
11
20
|
rootMargin,
|
|
12
21
|
threshold
|
|
13
22
|
});
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
observerRef.current = observer;
|
|
24
|
+
if (elementRef.current) observer.observe(elementRef.current);
|
|
25
|
+
return () => {
|
|
26
|
+
if (elementRef.current) observer.unobserve(elementRef.current);
|
|
27
|
+
observer.disconnect();
|
|
28
|
+
observerRef.current = null;
|
|
29
|
+
};
|
|
16
30
|
}, [
|
|
17
|
-
ref,
|
|
18
31
|
root,
|
|
19
|
-
|
|
20
|
-
|
|
32
|
+
rootMargin,
|
|
33
|
+
threshold
|
|
21
34
|
]);
|
|
22
|
-
|
|
35
|
+
const ref = useCallback((element) => {
|
|
36
|
+
if (elementRef.current === element) return;
|
|
37
|
+
if (observerRef.current && elementRef.current) observerRef.current.unobserve(elementRef.current);
|
|
38
|
+
elementRef.current = element;
|
|
39
|
+
if (observerRef.current && elementRef.current) observerRef.current.observe(elementRef.current);
|
|
40
|
+
}, []);
|
|
41
|
+
return useMemo(() => ({ ref }), [ref]);
|
|
23
42
|
};
|
|
24
43
|
//#endregion
|
|
25
44
|
export { useIntersectionObserver };
|
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InfiniteData } from '@tanstack/react-query';
|
|
2
2
|
import { Key } from 'react-aria-components';
|
|
3
|
-
import {
|
|
4
|
-
type QueryResult<TData = any> = UseQueryResult<TData> | UseInfiniteQueryResult<TData>;
|
|
5
|
-
type QueryFn<TData = any> = (...args: any[]) => QueryResult<TData>;
|
|
6
|
-
type QueryDataType<TQueryFn extends QueryFn> = Exclude<ReturnType<TQueryFn>["data"], undefined>;
|
|
7
|
-
interface UseQueryAutocompleteOptions<TQueryFn extends QueryFn, TKey extends Key = Key> {
|
|
8
|
-
query: TQueryFn;
|
|
9
|
-
queryParams?: Parameters<TQueryFn>[0];
|
|
10
|
-
queryOptions?: Parameters<TQueryFn>[1];
|
|
11
|
-
mapItems: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[];
|
|
12
|
-
initialQueryState?: boolean;
|
|
13
|
-
search?: string;
|
|
14
|
-
}
|
|
3
|
+
import { InfiniteQueryPage, QueryFn, UseQueryAutocompleteOptions } from '../components/inputs/Selection/Autocomplete/queryAutocomplete.types';
|
|
15
4
|
export declare const useQueryAutocomplete: <TQueryFn extends QueryFn, TKey extends Key = Key>({ query, queryParams, queryOptions, mapItems, initialQueryState, search, }: UseQueryAutocompleteOptions<TQueryFn, TKey>) => {
|
|
16
5
|
data: any;
|
|
17
6
|
isLoading: boolean;
|
|
18
7
|
isQueryEnabled: boolean;
|
|
19
8
|
handleEnableQuery: () => void;
|
|
20
|
-
items: SelectItem<TKey>[];
|
|
9
|
+
items: import('..').SelectItem<TKey>[];
|
|
10
|
+
totalItems: number | undefined;
|
|
21
11
|
hasNextPage: boolean;
|
|
22
|
-
fetchNextPage: ((
|
|
12
|
+
fetchNextPage: ((options?: import('@tanstack/react-query').FetchNextPageOptions) => Promise<import('@tanstack/react-query').InfiniteQueryObserverResult<InfiniteData<InfiniteQueryPage<TKey>, unknown>, Error>>) | undefined;
|
|
23
13
|
isFetchingNextPage: boolean;
|
|
24
14
|
};
|
|
25
|
-
export {};
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
import { ApiQueryUtils } from "../utils/query.utils.js";
|
|
1
2
|
import { useMemo, useState } from "react";
|
|
2
3
|
//#region src/hooks/useQueryAutocomplete.ts
|
|
4
|
+
var isFilterSearchParams = (params) => {
|
|
5
|
+
return typeof params === "object" && params !== null && "filter" in params;
|
|
6
|
+
};
|
|
3
7
|
var useQueryAutocomplete = ({ query, queryParams, queryOptions, mapItems, initialQueryState, search }) => {
|
|
4
8
|
const [isQueryEnabled, setIsQueryEnabled] = useState(!initialQueryState);
|
|
5
9
|
const queryResult = query(search === void 0 ? queryParams : {
|
|
10
|
+
...queryParams,
|
|
11
|
+
limit: queryParams?.limit ?? ApiQueryUtils.DEFAULT_LIMIT,
|
|
6
12
|
search,
|
|
7
|
-
|
|
13
|
+
filter: {
|
|
14
|
+
...isFilterSearchParams(queryParams) ? queryParams.filter : {},
|
|
15
|
+
search
|
|
16
|
+
}
|
|
8
17
|
}, {
|
|
9
18
|
...queryOptions,
|
|
10
19
|
enabled: isQueryEnabled && (queryOptions?.enabled ?? true)
|
|
@@ -14,24 +23,30 @@ var useQueryAutocomplete = ({ query, queryParams, queryOptions, mapItems, initia
|
|
|
14
23
|
const isInfiniteQueryResult = (result) => {
|
|
15
24
|
return "hasNextPage" in result && "fetchNextPage" in result;
|
|
16
25
|
};
|
|
17
|
-
const isInfiniteQuery = isInfiniteQueryResult(queryResult);
|
|
18
26
|
const handleEnableQuery = () => {
|
|
19
27
|
setIsQueryEnabled(true);
|
|
20
28
|
};
|
|
21
|
-
const infiniteQueryResult =
|
|
29
|
+
const infiniteQueryResult = isInfiniteQueryResult(queryResult) ? queryResult : void 0;
|
|
30
|
+
const isInfiniteQuery = infiniteQueryResult !== void 0;
|
|
22
31
|
const hasNextPage = infiniteQueryResult?.hasNextPage ?? false;
|
|
23
32
|
const fetchNextPage = infiniteQueryResult?.fetchNextPage;
|
|
24
33
|
const isFetchingNextPage = infiniteQueryResult?.isFetchingNextPage ?? false;
|
|
34
|
+
const totalItems = infiniteQueryResult?.data?.pages?.[0]?.totalItems;
|
|
25
35
|
const items = useMemo(() => {
|
|
26
36
|
if (!data) return [];
|
|
27
|
-
return mapItems(data);
|
|
28
|
-
}, [
|
|
37
|
+
return mapItems(isInfiniteQuery ? data.pages?.flatMap((page) => page?.items ?? []) : data);
|
|
38
|
+
}, [
|
|
39
|
+
data,
|
|
40
|
+
isInfiniteQuery,
|
|
41
|
+
mapItems
|
|
42
|
+
]);
|
|
29
43
|
return {
|
|
30
44
|
data,
|
|
31
45
|
isLoading: isLoading || isFetchingNextPage,
|
|
32
46
|
isQueryEnabled,
|
|
33
47
|
handleEnableQuery,
|
|
34
48
|
items,
|
|
49
|
+
totalItems,
|
|
35
50
|
hasNextPage,
|
|
36
51
|
fetchNextPage,
|
|
37
52
|
isFetchingNextPage
|
package/dist/index.d.ts
CHANGED
|
@@ -78,6 +78,8 @@ export type { FormFieldProps } from './components/inputs/FormField/FormField';
|
|
|
78
78
|
export { FormField } from './components/inputs/FormField/FormField';
|
|
79
79
|
export type { ControlledNumberInputProps, NumberInputProps } from './components/inputs/Input/NumberInput/NumberInput';
|
|
80
80
|
export { NumberInput } from './components/inputs/Input/NumberInput/NumberInput';
|
|
81
|
+
export type { ControlledNumberRangeInputProps, NumberRangeInputProps, NumberRangeValue, } from './components/inputs/Input/NumberRangeInput/NumberRangeInput';
|
|
82
|
+
export { NumberRangeInput } from './components/inputs/Input/NumberRangeInput/NumberRangeInput';
|
|
81
83
|
export type { ControlledPasswordInputProps, PasswordInputProps, } from './components/inputs/Input/PasswordInput/PasswordInput';
|
|
82
84
|
export { PasswordInput } from './components/inputs/Input/PasswordInput/PasswordInput';
|
|
83
85
|
export type { ControlledTextAreaProps, TextAreaProps } from './components/inputs/Input/TextArea/TextArea';
|
|
@@ -94,6 +96,8 @@ export type { RadioVariantProps } from './components/inputs/RadioGroup/radio.cva
|
|
|
94
96
|
export type { AutocompleteProps, ControlledAutocompleteProps, } from './components/inputs/Selection/Autocomplete/Autocomplete';
|
|
95
97
|
export { Autocomplete } from './components/inputs/Selection/Autocomplete/Autocomplete';
|
|
96
98
|
export { QueryAutocomplete } from './components/inputs/Selection/Autocomplete/QueryAutocomplete';
|
|
99
|
+
export type { SelectBaseProps } from './components/inputs/Selection/shared/SelectBase';
|
|
100
|
+
export type { DefaultInitialSelectItem, SelectAsyncProps, SelectItem, } from './components/inputs/Selection/shared/select.types';
|
|
97
101
|
export type { QuerySelectProps } from './components/inputs/Selection/Select/QuerySelect';
|
|
98
102
|
export { QuerySelect } from './components/inputs/Selection/Select/QuerySelect';
|
|
99
103
|
export type { ControlledSelectProps, SelectProps } from './components/inputs/Selection/Select/Select';
|
|
@@ -101,6 +105,7 @@ export { Select } from './components/inputs/Selection/Select/Select';
|
|
|
101
105
|
export type { ControlledSliderProps, SliderProps } from './components/inputs/Slider/Slider';
|
|
102
106
|
export { Slider } from './components/inputs/Slider/Slider';
|
|
103
107
|
export type { InputVariantProps } from './components/inputs/shared/input.cva';
|
|
108
|
+
export type { TooltipWrapperTriggerVariantProps } from './components/inputs/shared/tooltipWrapper.cva';
|
|
104
109
|
export type { ControlledToggleProps, ToggleProps } from './components/inputs/Toggle/Toggle';
|
|
105
110
|
export { Toggle } from './components/inputs/Toggle/Toggle';
|
|
106
111
|
export type { MenuProps } from './components/Menu/Menu';
|
package/dist/index.js
CHANGED
|
@@ -67,9 +67,9 @@ import { ToggleButton } from "./components/buttons/ToggleButton/ToggleButton.js"
|
|
|
67
67
|
import { Checkbox } from "./components/inputs/Checkbox/Checkbox.js";
|
|
68
68
|
import { useLongPressRepeat } from "./hooks/useLongPressRepeat.js";
|
|
69
69
|
import { useScrollableListBox } from "./hooks/useScrollableListBox.js";
|
|
70
|
+
import { DateTimeUtils } from "./utils/date-time.utils.js";
|
|
70
71
|
import { FormField } from "./components/inputs/FormField/FormField.js";
|
|
71
72
|
import { useDebounceCallback } from "./hooks/useDebounceCallback.js";
|
|
72
|
-
import { DateTimeUtils } from "./utils/date-time.utils.js";
|
|
73
73
|
import { DatePicker } from "./components/inputs/DateTime/DatePicker/DatePicker.js";
|
|
74
74
|
import { Tag } from "./components/text/Tag/Tag.js";
|
|
75
75
|
import { useIntersectionObserver } from "./hooks/useIntersectionObserver.js";
|
|
@@ -85,6 +85,7 @@ import { FileUpload } from "./components/inputs/File/FileUpload.js";
|
|
|
85
85
|
import { FileUploadContainer } from "./components/inputs/File/FileUploadContainer.js";
|
|
86
86
|
import { InputUpload } from "./components/inputs/File/InputUpload.js";
|
|
87
87
|
import { NumberInput } from "./components/inputs/Input/NumberInput/NumberInput.js";
|
|
88
|
+
import { NumberRangeInput } from "./components/inputs/Input/NumberRangeInput/NumberRangeInput.js";
|
|
88
89
|
import { PasswordInput } from "./components/inputs/Input/PasswordInput/PasswordInput.js";
|
|
89
90
|
import { TextArea } from "./components/inputs/Input/TextArea/TextArea.js";
|
|
90
91
|
import { Autocomplete } from "./components/inputs/Selection/Autocomplete/Autocomplete.js";
|
|
@@ -136,4 +137,4 @@ import { useTableColumnConfig } from "./hooks/useTableColumnConfig.js";
|
|
|
136
137
|
import { ArrayUtils } from "./utils/array.utils.js";
|
|
137
138
|
import { QueriesUtils } from "./utils/queries.utils.js";
|
|
138
139
|
import { RoutingUtils } from "./utils/routing.utils.js";
|
|
139
|
-
export { Accordion, ActionModal, Alert, AlignCenterIcon, AlignLeftIcon, AlignLeftRightIcon, AlignRightIcon, ArrayUtils, ArrowDropDownIcon, ArrowDropUpIcon, ArrowLeftIcon, ArrowRightIcon, Autocomplete, BoldIcon, BottomSheet, Breadcrumbs, BulletedListIcon, Button, CalendarIcon, CellText, CheckIcon, Checkbox, CheckboxCheckmarkIcon, CheckboxIndeterminateIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronsLeftIcon, ChevronsRightIcon, ClockIcon, CloseIcon, ColumnConfigModal, Confirmation, DatePicker, DateRangePicker, DateTimeIcon, DateTimePicker, DateTimeUtils, DateUtils, DomUtils, Drawer, FileUpload, FileUploadContainer, FileUtils, Form, FormField, HeaderText, HighlightIcon, HighlightOnIcon, HomeIcon, IconButton, InfiniteTable, InfoIcon, InlineIconButton, InputUpload, Inputs, ItalicIcon, Link, LinkContext, LinkIcon, Loader, Menu, MenuIcon, MenuItem, MenuPopover, Modal, NumberInput, NumberedListIcon, ObjectUtils, PaginatedTable, Pagination, PaginationList, PasswordInput, PillButton, PointerHorizontalIcon, PointerVerticalIcon, ProgressBar, QueriesUtils, QueryAutocomplete, QuerySelect, RadioGroup, ResponsivePopover, RestUtils, RoutingUtils, Segment, Select, SendIcon, Slider, SplitButton, Stepper, StrikethroughIcon, StringUtils, Table, Tag, TextArea, TextButton, TextColorIcon, TextInput, ThemeContext, TimePicker, Toast, ToastContainer, Toggle, ToggleButton, Tooltip, TooltipEllipsis, Typography, UIConfig, UIRouter, UIStyle, UnderlinedIcon, VisibilityIcon, VisibilityOffIcon, compoundMapper, dynamicColumns, dynamicInputs, isEqual, logger, ns, resources, uiOutlineClass, useAutosave, useBreakpoint, useDebounceCallback, useDeepCompareEffect, useDeepCompareLayoutEffect, useDeepCompareMemo, useFilters, useForm, useFormAutosave, useIntersectionObserver, useLocalStorage, useLongPressRepeat, usePagination, useScrollableListBox, useSorting, useStateAndRef, useTableColumnConfig, useTableNav, useToast, useTranslationMemo };
|
|
140
|
+
export { Accordion, ActionModal, Alert, AlignCenterIcon, AlignLeftIcon, AlignLeftRightIcon, AlignRightIcon, ArrayUtils, ArrowDropDownIcon, ArrowDropUpIcon, ArrowLeftIcon, ArrowRightIcon, Autocomplete, BoldIcon, BottomSheet, Breadcrumbs, BulletedListIcon, Button, CalendarIcon, CellText, CheckIcon, Checkbox, CheckboxCheckmarkIcon, CheckboxIndeterminateIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronsLeftIcon, ChevronsRightIcon, ClockIcon, CloseIcon, ColumnConfigModal, Confirmation, DatePicker, DateRangePicker, DateTimeIcon, DateTimePicker, DateTimeUtils, DateUtils, DomUtils, Drawer, FileUpload, FileUploadContainer, FileUtils, Form, FormField, HeaderText, HighlightIcon, HighlightOnIcon, HomeIcon, IconButton, InfiniteTable, InfoIcon, InlineIconButton, InputUpload, Inputs, ItalicIcon, Link, LinkContext, LinkIcon, Loader, Menu, MenuIcon, MenuItem, MenuPopover, Modal, NumberInput, NumberRangeInput, NumberedListIcon, ObjectUtils, PaginatedTable, Pagination, PaginationList, PasswordInput, PillButton, PointerHorizontalIcon, PointerVerticalIcon, ProgressBar, QueriesUtils, QueryAutocomplete, QuerySelect, RadioGroup, ResponsivePopover, RestUtils, RoutingUtils, Segment, Select, SendIcon, Slider, SplitButton, Stepper, StrikethroughIcon, StringUtils, Table, Tag, TextArea, TextButton, TextColorIcon, TextInput, ThemeContext, TimePicker, Toast, ToastContainer, Toggle, ToggleButton, Tooltip, TooltipEllipsis, Typography, UIConfig, UIRouter, UIStyle, UnderlinedIcon, VisibilityIcon, VisibilityOffIcon, compoundMapper, dynamicColumns, dynamicInputs, isEqual, logger, ns, resources, uiOutlineClass, useAutosave, useBreakpoint, useDebounceCallback, useDeepCompareEffect, useDeepCompareLayoutEffect, useDeepCompareMemo, useFilters, useForm, useFormAutosave, useIntersectionObserver, useLocalStorage, useLongPressRepeat, usePagination, useScrollableListBox, useSorting, useStateAndRef, useTableColumnConfig, useTableNav, useToast, useTranslationMemo };
|
package/dist/tw-ui-plugin.js
CHANGED
|
@@ -7,6 +7,7 @@ var uiPlugin = plugin(({ addVariant }) => {
|
|
|
7
7
|
"&:is(:where(.group\\/select-content)[data-has-selection] *)",
|
|
8
8
|
"&:is(:where(.group\\/select-content)[data-has-search] *)",
|
|
9
9
|
"&:is(:where(.group\\/select-content)[data-searchable-focus-within] *)",
|
|
10
|
+
"&:is(:where(.group\\/radio-group-content)[data-radio-group-content] *)",
|
|
10
11
|
"&:is(:where(.group\\/date-picker-content)[data-has-selection] *)",
|
|
11
12
|
"&:is(:where(.group\\/date-picker-content)[data-focus-within] *)"
|
|
12
13
|
].join(", "));
|
|
@@ -14,6 +15,7 @@ var uiPlugin = plugin(({ addVariant }) => {
|
|
|
14
15
|
"&:is(:where(.group\\/input-content):has(*:is(input:disabled)) *)",
|
|
15
16
|
"&:is(:where(.group\\/select-content)[data-disabled] *)",
|
|
16
17
|
"&:is(:where(.group\\/select-content):has(*:is(input:disabled)) *)",
|
|
18
|
+
"&:is(:where(.group\\/radio-group-content)[data-disabled] *)",
|
|
17
19
|
"&:is(:where(.group\\/text-area):has(*:is(textarea:disabled)) *)",
|
|
18
20
|
"&:is(:where(.group\\/text-editor):where([data-rac])[data-disabled] *)",
|
|
19
21
|
"&:is(:where(.group\\/date-picker-content):where([data-rac])[data-disabled] *)"
|
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
import { CalendarDate, CalendarDateTime, DateValue, ZonedDateTime } from '@internationalized/date';
|
|
2
2
|
export declare namespace DateTimeUtils {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
interface LocalizedDateFormatOptions {
|
|
4
|
+
shouldForceLeadingZeros?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface LocalizedDatePart {
|
|
7
|
+
type: Intl.DateTimeFormatPartTypes;
|
|
8
|
+
value: string;
|
|
9
|
+
placeholder: string;
|
|
10
|
+
isPlaceholder: boolean;
|
|
11
|
+
}
|
|
12
|
+
export function getDatePlaceholder(locale?: string, options?: LocalizedDateFormatOptions): string;
|
|
13
|
+
export function getTimePlaceholder(locale?: string): string;
|
|
14
|
+
export function getDateTimePlaceholder(locale?: string, options?: LocalizedDateFormatOptions): string;
|
|
15
|
+
export function getDateRangePlaceholder(locale?: string, options?: LocalizedDateFormatOptions): string;
|
|
16
|
+
export function formatCalendarDateLocalized(calendarDate: CalendarDate, locale?: string, options?: LocalizedDateFormatOptions): string;
|
|
17
|
+
export function formatCalendarDatePartsLocalized(calendarDate?: CalendarDate | null, locale?: string, options?: LocalizedDateFormatOptions): LocalizedDatePart[];
|
|
18
|
+
export function formatTimeLocalized(timeValue: {
|
|
19
|
+
hour: number;
|
|
20
|
+
minute: number;
|
|
21
|
+
}, locale?: string): string;
|
|
22
|
+
export function formatCalendarDateTimeLocalized(calendarDateTime: Pick<CalendarDateTime, "day" | "month" | "year" | "hour" | "minute">, locale?: string, options?: LocalizedDateFormatOptions): string;
|
|
23
|
+
export function fromISOtoZonedDateTime(isoString: string): ZonedDateTime;
|
|
24
|
+
export function fromDateValueToISO(dateValue: DateValue): string;
|
|
25
|
+
export function fromLocalToZonedDateTime(date: Date): ZonedDateTime;
|
|
26
|
+
export function fromDateValueToLocal(dateValue: DateValue): Date;
|
|
27
|
+
export function fromCalendarDateToUTCISO(calendarDate: CalendarDate, options?: {
|
|
8
28
|
endOfDay?: boolean;
|
|
9
29
|
}): string;
|
|
10
|
-
function fromUTCISOToCalendarDate(isoString: string): CalendarDate;
|
|
11
|
-
function fromCalendarDateTimeToUTCISO(calendarDateTime: CalendarDateTime): string;
|
|
12
|
-
function fromUTCISOToCalendarDateTime(isoString: string): CalendarDateTime;
|
|
13
|
-
function formatTextDateToCalendarDateTime(textDate: string | null): CalendarDateTime | null;
|
|
30
|
+
export function fromUTCISOToCalendarDate(isoString: string): CalendarDate;
|
|
31
|
+
export function fromCalendarDateTimeToUTCISO(calendarDateTime: CalendarDateTime): string;
|
|
32
|
+
export function fromUTCISOToCalendarDateTime(isoString: string): CalendarDateTime;
|
|
33
|
+
export function formatTextDateToCalendarDateTime(textDate: string | null): CalendarDateTime | null;
|
|
34
|
+
export {};
|
|
14
35
|
}
|
|
@@ -1,7 +1,119 @@
|
|
|
1
|
-
import { CalendarDate, CalendarDateTime, fromDate, getLocalTimeZone, parseAbsolute, parseAbsoluteToLocal } from "@internationalized/date";
|
|
1
|
+
import { CalendarDate, CalendarDateTime, DateFormatter, fromDate, getLocalTimeZone, parseAbsolute, parseAbsoluteToLocal } from "@internationalized/date";
|
|
2
2
|
//#region src/utils/date-time.utils.ts
|
|
3
3
|
var DateTimeUtils;
|
|
4
4
|
(function(_DateTimeUtils) {
|
|
5
|
+
const DATE_SAMPLE_DATE_UTC = new Date(Date.UTC(2e3, 10, 22));
|
|
6
|
+
const TIME_SAMPLE_DATE_UTC = new Date(Date.UTC(2e3, 10, 22, 13, 45));
|
|
7
|
+
const getDayMonthFormat = (shouldForceLeadingZeros = false) => shouldForceLeadingZeros ? "2-digit" : "numeric";
|
|
8
|
+
const getDatePlaceholderFormatter = (locale, options) => new Intl.DateTimeFormat(locale, {
|
|
9
|
+
day: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
10
|
+
month: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
11
|
+
year: "numeric"
|
|
12
|
+
});
|
|
13
|
+
const getTimePlaceholderFormatter = (locale) => new Intl.DateTimeFormat(locale, {
|
|
14
|
+
hour: "2-digit",
|
|
15
|
+
minute: "2-digit",
|
|
16
|
+
hourCycle: "h23"
|
|
17
|
+
});
|
|
18
|
+
const getResolvedLocale = (locale) => {
|
|
19
|
+
if (locale) return locale;
|
|
20
|
+
return new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
21
|
+
};
|
|
22
|
+
const getDateFormatter = (locale, options) => new Intl.DateTimeFormat(getResolvedLocale(locale), {
|
|
23
|
+
day: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
24
|
+
month: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
25
|
+
year: "numeric",
|
|
26
|
+
timeZone: "UTC"
|
|
27
|
+
});
|
|
28
|
+
const getTimeFormatter = (locale) => new DateFormatter(getResolvedLocale(locale), {
|
|
29
|
+
hour: "2-digit",
|
|
30
|
+
minute: "2-digit",
|
|
31
|
+
hourCycle: "h23",
|
|
32
|
+
timeZone: "UTC"
|
|
33
|
+
});
|
|
34
|
+
const getDateTimeFormatter = (locale, options) => new Intl.DateTimeFormat(getResolvedLocale(locale), {
|
|
35
|
+
day: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
36
|
+
month: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
37
|
+
year: "numeric",
|
|
38
|
+
hour: "2-digit",
|
|
39
|
+
minute: "2-digit",
|
|
40
|
+
hourCycle: "h23",
|
|
41
|
+
timeZone: "UTC"
|
|
42
|
+
});
|
|
43
|
+
const repeatLocalizedFieldLabel = (type, length, locale) => {
|
|
44
|
+
const placeholderChar = new Intl.DisplayNames(getResolvedLocale(locale), { type: "dateTimeField" }).of(type)?.trim().charAt(0).toLocaleLowerCase(getResolvedLocale(locale));
|
|
45
|
+
if (!placeholderChar) return null;
|
|
46
|
+
return placeholderChar.repeat(length);
|
|
47
|
+
};
|
|
48
|
+
const mapTypeToPlaceholder = (type, locale) => {
|
|
49
|
+
switch (type) {
|
|
50
|
+
case "day": return repeatLocalizedFieldLabel(type, 2, locale);
|
|
51
|
+
case "month": return repeatLocalizedFieldLabel(type, 2, locale);
|
|
52
|
+
case "year": return repeatLocalizedFieldLabel(type, 4, locale);
|
|
53
|
+
case "hour": return "hh";
|
|
54
|
+
case "minute": return "mm";
|
|
55
|
+
default: return null;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const formatPlaceholder = (formatter, sampleDate) => {
|
|
59
|
+
return formatter.formatToParts(sampleDate).map((part) => mapTypeToPlaceholder(part.type, formatter.resolvedOptions().locale) ?? part.value.replace(/\s+/gu, "")).join("");
|
|
60
|
+
};
|
|
61
|
+
const removeLeadingZero = (value) => value.replace(/^0+(?=\d)/u, "");
|
|
62
|
+
const removeDateSeparatorSpacing = (value) => value.replace(/([./-])\s+(?=\d)/gu, "$1");
|
|
63
|
+
const formatLocalizedDateParts = (formatter, date, options) => {
|
|
64
|
+
if (options?.shouldForceLeadingZeros !== false) return removeDateSeparatorSpacing(formatter.format(date));
|
|
65
|
+
return removeDateSeparatorSpacing(formatter.formatToParts(date).map((part) => {
|
|
66
|
+
if (part.type === "day" || part.type === "month") return removeLeadingZero(part.value);
|
|
67
|
+
return part.value;
|
|
68
|
+
}).join(""));
|
|
69
|
+
};
|
|
70
|
+
const formatLocalizedDatePartList = (formatter, date, isPlaceholder, options) => {
|
|
71
|
+
const locale = formatter.resolvedOptions().locale;
|
|
72
|
+
return formatter.formatToParts(date).map((part) => {
|
|
73
|
+
const value = options?.shouldForceLeadingZeros === false && (part.type === "day" || part.type === "month") ? removeLeadingZero(part.value) : part.value.replace(/\s+/gu, "");
|
|
74
|
+
return {
|
|
75
|
+
type: part.type,
|
|
76
|
+
value,
|
|
77
|
+
placeholder: mapTypeToPlaceholder(part.type, locale) ?? part.value.replace(/\s+/gu, ""),
|
|
78
|
+
isPlaceholder
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
function getDatePlaceholder(locale, options) {
|
|
83
|
+
return formatPlaceholder(getDatePlaceholderFormatter(locale, options), DATE_SAMPLE_DATE_UTC);
|
|
84
|
+
}
|
|
85
|
+
_DateTimeUtils.getDatePlaceholder = getDatePlaceholder;
|
|
86
|
+
function getTimePlaceholder(locale) {
|
|
87
|
+
return formatPlaceholder(getTimePlaceholderFormatter(locale), TIME_SAMPLE_DATE_UTC);
|
|
88
|
+
}
|
|
89
|
+
_DateTimeUtils.getTimePlaceholder = getTimePlaceholder;
|
|
90
|
+
function getDateTimePlaceholder(locale, options) {
|
|
91
|
+
return `${getDatePlaceholder(locale, options)}, ${getTimePlaceholder(locale)}`;
|
|
92
|
+
}
|
|
93
|
+
_DateTimeUtils.getDateTimePlaceholder = getDateTimePlaceholder;
|
|
94
|
+
function getDateRangePlaceholder(locale, options) {
|
|
95
|
+
const datePlaceholder = getDatePlaceholder(locale, options);
|
|
96
|
+
return `${datePlaceholder} – ${datePlaceholder}`;
|
|
97
|
+
}
|
|
98
|
+
_DateTimeUtils.getDateRangePlaceholder = getDateRangePlaceholder;
|
|
99
|
+
function formatCalendarDateLocalized(calendarDate, locale, options) {
|
|
100
|
+
return formatLocalizedDateParts(getDateFormatter(locale, options), calendarDate.toDate("UTC"), options);
|
|
101
|
+
}
|
|
102
|
+
_DateTimeUtils.formatCalendarDateLocalized = formatCalendarDateLocalized;
|
|
103
|
+
function formatCalendarDatePartsLocalized(calendarDate, locale, options) {
|
|
104
|
+
return formatLocalizedDatePartList(getDateFormatter(locale, options), calendarDate?.toDate("UTC") ?? DATE_SAMPLE_DATE_UTC, !calendarDate, options);
|
|
105
|
+
}
|
|
106
|
+
_DateTimeUtils.formatCalendarDatePartsLocalized = formatCalendarDatePartsLocalized;
|
|
107
|
+
function formatTimeLocalized(timeValue, locale) {
|
|
108
|
+
const dateTime = new CalendarDateTime(2e3, 11, 22, timeValue.hour, timeValue.minute);
|
|
109
|
+
return getTimeFormatter(locale).format(dateTime.toDate("UTC"));
|
|
110
|
+
}
|
|
111
|
+
_DateTimeUtils.formatTimeLocalized = formatTimeLocalized;
|
|
112
|
+
function formatCalendarDateTimeLocalized(calendarDateTime, locale, options) {
|
|
113
|
+
const normalizedValue = new CalendarDateTime(calendarDateTime.year, calendarDateTime.month, calendarDateTime.day, calendarDateTime.hour, calendarDateTime.minute);
|
|
114
|
+
return formatLocalizedDateParts(getDateTimeFormatter(locale, options), normalizedValue.toDate("UTC"), options);
|
|
115
|
+
}
|
|
116
|
+
_DateTimeUtils.formatCalendarDateTimeLocalized = formatCalendarDateTimeLocalized;
|
|
5
117
|
function fromISOtoZonedDateTime(isoString) {
|
|
6
118
|
return parseAbsoluteToLocal(isoString);
|
|
7
119
|
}
|