@povio/ui 2.2.9-rc.3 → 2.2.9-rc.31
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 +80 -6
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +7 -2
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +83 -6
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +8 -2
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +83 -7
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +64 -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.js +3 -1
- 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 +76 -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 +232 -0
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +79 -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 +15 -18
- package/dist/components/inputs/Inputs/InputItem.js +2 -0
- package/dist/components/inputs/RadioGroup/RadioGroup.js +17 -9
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +3 -0
- package/dist/components/inputs/RadioGroup/radio.cva.js +2 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +99 -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 -4
- 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 +112 -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 +68 -0
- package/dist/components/inputs/Skeleton/InputFrame.js +178 -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/config/uiConfig.context.d.ts +8 -2
- package/dist/config/uiConfig.context.js +12 -1
- package/dist/config/uiStyle.context.d.ts +20 -3
- package/dist/helpers/dynamicInputs.d.ts +1 -1
- package/dist/helpers/dynamicInputs.js +3 -0
- 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 +13 -3
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -2
- 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,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
|
-
...queryParams
|
|
13
|
+
...isFilterSearchParams(queryParams) ? { filter: {
|
|
14
|
+
...queryParams.filter,
|
|
15
|
+
search
|
|
16
|
+
} } : {}
|
|
8
17
|
}, {
|
|
9
18
|
...queryOptions,
|
|
10
19
|
enabled: isQueryEnabled && (queryOptions?.enabled ?? true)
|
|
@@ -14,14 +23,14 @@ 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;
|
|
22
30
|
const hasNextPage = infiniteQueryResult?.hasNextPage ?? false;
|
|
23
31
|
const fetchNextPage = infiniteQueryResult?.fetchNextPage;
|
|
24
32
|
const isFetchingNextPage = infiniteQueryResult?.isFetchingNextPage ?? false;
|
|
33
|
+
const totalItems = infiniteQueryResult?.data?.pages?.[0]?.totalItems;
|
|
25
34
|
const items = useMemo(() => {
|
|
26
35
|
if (!data) return [];
|
|
27
36
|
return mapItems(data);
|
|
@@ -32,6 +41,7 @@ var useQueryAutocomplete = ({ query, queryParams, queryOptions, mapItems, initia
|
|
|
32
41
|
isQueryEnabled,
|
|
33
42
|
handleEnableQuery,
|
|
34
43
|
items,
|
|
44
|
+
totalItems,
|
|
35
45
|
hasNextPage,
|
|
36
46
|
fetchNextPage,
|
|
37
47
|
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,11 +96,16 @@ 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';
|
|
101
|
+
export type { QuerySelectProps } from './components/inputs/Selection/Select/QuerySelect';
|
|
102
|
+
export { QuerySelect } from './components/inputs/Selection/Select/QuerySelect';
|
|
97
103
|
export type { ControlledSelectProps, SelectProps } from './components/inputs/Selection/Select/Select';
|
|
98
104
|
export { Select } from './components/inputs/Selection/Select/Select';
|
|
99
105
|
export type { ControlledSliderProps, SliderProps } from './components/inputs/Slider/Slider';
|
|
100
106
|
export { Slider } from './components/inputs/Slider/Slider';
|
|
101
107
|
export type { InputVariantProps } from './components/inputs/shared/input.cva';
|
|
108
|
+
export type { TooltipWrapperTriggerVariantProps } from './components/inputs/shared/tooltipWrapper.cva';
|
|
102
109
|
export type { ControlledToggleProps, ToggleProps } from './components/inputs/Toggle/Toggle';
|
|
103
110
|
export { Toggle } from './components/inputs/Toggle/Toggle';
|
|
104
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";
|
|
@@ -92,6 +93,7 @@ import { QueryAutocomplete } from "./components/inputs/Selection/Autocomplete/Qu
|
|
|
92
93
|
import { Slider } from "./components/inputs/Slider/Slider.js";
|
|
93
94
|
import { Toggle } from "./components/inputs/Toggle/Toggle.js";
|
|
94
95
|
import { Segment } from "./components/segment/Segment.js";
|
|
96
|
+
import { QuerySelect } from "./components/inputs/Selection/Select/QuerySelect.js";
|
|
95
97
|
import { ResponsivePopover } from "./components/overlays/ResponsivePopover/ResponsivePopover.js";
|
|
96
98
|
import { StringUtils } from "./utils/string.utils.js";
|
|
97
99
|
import { dynamicInputs } from "./helpers/dynamicInputs.js";
|
|
@@ -135,4 +137,4 @@ import { useTableColumnConfig } from "./hooks/useTableColumnConfig.js";
|
|
|
135
137
|
import { ArrayUtils } from "./utils/array.utils.js";
|
|
136
138
|
import { QueriesUtils } from "./utils/queries.utils.js";
|
|
137
139
|
import { RoutingUtils } from "./utils/routing.utils.js";
|
|
138
|
-
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, 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 };
|
|
@@ -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
|
}
|