@povio/ui 3.2.4-rc.2 → 3.2.4-rc.4
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.cva.d.ts +1 -1
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +2 -1
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +2 -1
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +54 -2
- package/dist/components/inputs/Selection/Select/QuerySelect.js +99 -46
- package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +1 -0
- package/dist/components/inputs/Selection/shared/querySelect.utils.js +1 -0
- package/dist/components/inputs/Selection/shared/select.context.js +19 -9
- package/dist/components/inputs/shared/input.cva.js +1 -1
- package/dist/components/shared/pagination/minWidth.cva.d.ts +1 -1
- package/dist/helpers/dynamicColumns.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/utils/date-time.utils.js +21 -11
- package/dist/utils/intl.utils.d.ts +7 -0
- package/dist/utils/intl.utils.js +38 -0
- package/dist/utils/intl.utils.spec.d.ts +1 -0
- package/package.json +1 -1
|
@@ -92,7 +92,7 @@ export declare const buttonIconSizeDefinition: {
|
|
|
92
92
|
export type ButtonIconSizeConfig = NonNullable<typeof buttonIconSizeDefinition.config>;
|
|
93
93
|
export declare const buttonTypography: (props: {
|
|
94
94
|
readonly width?: "fill" | "hug" | null | undefined;
|
|
95
|
-
readonly size?: "none" | "
|
|
95
|
+
readonly size?: "none" | "xs" | "s" | "m" | "l" | null | undefined;
|
|
96
96
|
readonly color?: "error" | "primary" | "dual" | "secondary" | "success" | "warning" | null | undefined;
|
|
97
97
|
readonly variant?: "text" | "contained" | "outlined" | "subtle" | "ghost" | null | undefined;
|
|
98
98
|
readonly inverted?: boolean | null | undefined;
|
|
@@ -2,6 +2,7 @@ import { UIOverrides } from "../../../../config/uiOverrides.context.js";
|
|
|
2
2
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
3
|
import { FormField } from "../../FormField/FormField.js";
|
|
4
4
|
import { inputBaseDefinition } from "../../shared/input.cva.js";
|
|
5
|
+
import { IntlUtils } from "../../../../utils/intl.utils.js";
|
|
5
6
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
6
7
|
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
7
8
|
import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
|
|
@@ -338,7 +339,7 @@ var NumberInputInner = (t0) => {
|
|
|
338
339
|
if (!renderInput) {
|
|
339
340
|
const staticValue = props.value ?? props.defaultValue;
|
|
340
341
|
const formatOptions = props.formatOptions ?? ui.numberInput.formatOptions;
|
|
341
|
-
const displayValue = getStaticNumberDisplayValue(staticValue,
|
|
342
|
+
const displayValue = getStaticNumberDisplayValue(staticValue, IntlUtils.getNumberFormatter(locale, formatOptions)) ?? "";
|
|
342
343
|
const hasValue = displayValue !== "";
|
|
343
344
|
const as = props.as ?? ui.input.as;
|
|
344
345
|
let isDisabled = !!props.isDisabled;
|
|
@@ -2,6 +2,7 @@ import { UIOverrides } from "../../../../config/uiOverrides.context.js";
|
|
|
2
2
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
3
|
import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
|
|
4
4
|
import { inputBaseDefinition, inputSizeDefinition } from "../../shared/input.cva.js";
|
|
5
|
+
import { IntlUtils } from "../../../../utils/intl.utils.js";
|
|
5
6
|
import { InputClear } from "../../shared/InputClear.js";
|
|
6
7
|
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
7
8
|
import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
|
|
@@ -381,7 +382,7 @@ var NumberRangeInputInner = (t0) => {
|
|
|
381
382
|
if (!renderInput) {
|
|
382
383
|
const staticValue = normalizeRangeValue(props.value, props.minValue, props.maxValue);
|
|
383
384
|
const formatOptions = props.formatOptions ?? ui.numberInput.formatOptions;
|
|
384
|
-
const formatter =
|
|
385
|
+
const formatter = IntlUtils.getNumberFormatter(locale, formatOptions);
|
|
385
386
|
const minDisplay = getStaticNumberDisplayValue(staticValue.min, formatter);
|
|
386
387
|
const maxDisplay = getStaticNumberDisplayValue(staticValue.max, formatter);
|
|
387
388
|
const hasValue = minDisplay !== null || maxDisplay !== null;
|
|
@@ -8,7 +8,7 @@ import { useState } from "react";
|
|
|
8
8
|
import { mergeRefs } from "@react-aria/utils";
|
|
9
9
|
import { Controller } from "react-hook-form";
|
|
10
10
|
//#region src/components/inputs/Selection/Autocomplete/QueryAutocomplete.tsx
|
|
11
|
-
var
|
|
11
|
+
var LoadedQueryAutocompleteContent = ({ query, queryParams, queryOptions, queryMap, resolveSelectedItemsWithIds, isQueryEnabledInitially = false, leadingContent, ...props }) => {
|
|
12
12
|
"use no memo";
|
|
13
13
|
const ui = UIConfig.useConfig();
|
|
14
14
|
const [search, setSearch] = useState("");
|
|
@@ -27,7 +27,7 @@ var QueryAutocompleteContent = ({ query, queryParams, queryOptions, queryMap, re
|
|
|
27
27
|
mapItems: (data) => getQueryItems(data, queryMap),
|
|
28
28
|
resolveSelectedItemsWithIds: resolveSelectedItemsWithIds ?? ui.queryAutocomplete?.resolveSelectedItemsWithIds,
|
|
29
29
|
search,
|
|
30
|
-
initialQueryState: shouldEnableInitialQuery ? false : props.isInitialQueryDisabled ?? ui.queryAutocomplete?.isInitialQueryDisabled,
|
|
30
|
+
initialQueryState: isQueryEnabledInitially || shouldEnableInitialQuery ? false : selectedIdsToResolve.isResolvedByInitialSelection || (props.isInitialQueryDisabled ?? ui.queryAutocomplete?.isInitialQueryDisabled),
|
|
31
31
|
selectedIdsToResolve: selectedIdsToResolve.items
|
|
32
32
|
});
|
|
33
33
|
const handleChange = (value_0) => {
|
|
@@ -55,6 +55,58 @@ var QueryAutocompleteContent = ({ query, queryParams, queryOptions, queryMap, re
|
|
|
55
55
|
onLoadMore: fetchNextPage
|
|
56
56
|
});
|
|
57
57
|
};
|
|
58
|
+
var QueryAutocompleteContent = (props) => {
|
|
59
|
+
const $ = c(9);
|
|
60
|
+
const [isQueryMounted, setIsQueryMounted] = useState(false);
|
|
61
|
+
const value = "value" in props ? props.value : void 0;
|
|
62
|
+
if (!getSelectionIdsToResolve({
|
|
63
|
+
initialSelection: props.initialSelection,
|
|
64
|
+
value,
|
|
65
|
+
mapInitialToSelectItem: props.mapInitialToSelectItem
|
|
66
|
+
}).isResolvedByInitialSelection || isQueryMounted) {
|
|
67
|
+
let t0;
|
|
68
|
+
if ($[0] !== isQueryMounted || $[1] !== props) {
|
|
69
|
+
t0 = /* @__PURE__ */ jsx(LoadedQueryAutocompleteContent, {
|
|
70
|
+
...props,
|
|
71
|
+
isQueryEnabledInitially: isQueryMounted
|
|
72
|
+
});
|
|
73
|
+
$[0] = isQueryMounted;
|
|
74
|
+
$[1] = props;
|
|
75
|
+
$[2] = t0;
|
|
76
|
+
} else t0 = $[2];
|
|
77
|
+
return t0;
|
|
78
|
+
}
|
|
79
|
+
let autocompleteProps;
|
|
80
|
+
if ($[3] !== props) {
|
|
81
|
+
const { query: _, queryParams: _queryParams, queryOptions: _queryOptions, queryMap: _queryMap, resolveSelectedItemsWithIds: _resolveSelectedItemsWithIds, isInitialQueryDisabled: _isInitialQueryDisabled, ...t0 } = props;
|
|
82
|
+
autocompleteProps = t0;
|
|
83
|
+
$[3] = props;
|
|
84
|
+
$[4] = autocompleteProps;
|
|
85
|
+
} else autocompleteProps = $[4];
|
|
86
|
+
let t0;
|
|
87
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
88
|
+
t0 = () => setIsQueryMounted(true);
|
|
89
|
+
$[5] = t0;
|
|
90
|
+
} else t0 = $[5];
|
|
91
|
+
const mountQuery = t0;
|
|
92
|
+
let t1;
|
|
93
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
94
|
+
t1 = [];
|
|
95
|
+
$[6] = t1;
|
|
96
|
+
} else t1 = $[6];
|
|
97
|
+
let t2;
|
|
98
|
+
if ($[7] !== autocompleteProps) {
|
|
99
|
+
t2 = /* @__PURE__ */ jsx(Autocomplete, {
|
|
100
|
+
...autocompleteProps,
|
|
101
|
+
items: t1,
|
|
102
|
+
onMouseEnter: mountQuery,
|
|
103
|
+
onFocusCapture: mountQuery
|
|
104
|
+
});
|
|
105
|
+
$[7] = autocompleteProps;
|
|
106
|
+
$[8] = t2;
|
|
107
|
+
} else t2 = $[8];
|
|
108
|
+
return t2;
|
|
109
|
+
};
|
|
58
110
|
var QueryAutocomplete = (props) => {
|
|
59
111
|
const $ = c(16);
|
|
60
112
|
if ("formControl" in props && props.formControl) {
|
|
@@ -8,9 +8,10 @@ import { useState } from "react";
|
|
|
8
8
|
import { mergeRefs } from "@react-aria/utils";
|
|
9
9
|
import { Controller } from "react-hook-form";
|
|
10
10
|
//#region src/components/inputs/Selection/Select/QuerySelect.tsx
|
|
11
|
-
var
|
|
11
|
+
var LoadedQuerySelectContent = (t0) => {
|
|
12
12
|
const $ = c(31);
|
|
13
|
-
const { query, queryParams, queryOptions, queryMap, resolveSelectedItemsWithIds, ...props } = t0;
|
|
13
|
+
const { query, queryParams, queryOptions, queryMap, resolveSelectedItemsWithIds, isQueryEnabledInitially: t1, ...props } = t0;
|
|
14
|
+
const isQueryEnabledInitially = t1 === void 0 ? false : t1;
|
|
14
15
|
const ui = UIConfig.useConfig();
|
|
15
16
|
const [search, setSearch] = useState("");
|
|
16
17
|
const isSearchable = props.isSearchable ?? ui.select.isSearchable;
|
|
@@ -21,44 +22,44 @@ var QuerySelectContent = (t0) => {
|
|
|
21
22
|
mapInitialToSelectItem: props.mapInitialToSelectItem
|
|
22
23
|
});
|
|
23
24
|
const shouldEnableInitialQuery = selectedIdsToResolve.count > 0;
|
|
24
|
-
let
|
|
25
|
+
let t2;
|
|
25
26
|
if ($[0] !== queryMap) {
|
|
26
|
-
|
|
27
|
+
t2 = (data) => getQueryItems(data, queryMap);
|
|
27
28
|
$[0] = queryMap;
|
|
28
|
-
$[1] =
|
|
29
|
-
} else
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
let
|
|
34
|
-
if ($[2] !== query || $[3] !== queryOptions || $[4] !== queryParams || $[5] !== selectedIdsToResolve.items || $[6] !==
|
|
35
|
-
|
|
29
|
+
$[1] = t2;
|
|
30
|
+
} else t2 = $[1];
|
|
31
|
+
const t3 = resolveSelectedItemsWithIds ?? ui.querySelect?.resolveSelectedItemsWithIds;
|
|
32
|
+
const t4 = isSearchable ? search : void 0;
|
|
33
|
+
const t5 = isQueryEnabledInitially || shouldEnableInitialQuery ? false : selectedIdsToResolve.isResolvedByInitialSelection || (props.isInitialQueryDisabled ?? ui.querySelect?.isInitialQueryDisabled);
|
|
34
|
+
let t6;
|
|
35
|
+
if ($[2] !== query || $[3] !== queryOptions || $[4] !== queryParams || $[5] !== selectedIdsToResolve.items || $[6] !== t2 || $[7] !== t3 || $[8] !== t4 || $[9] !== t5) {
|
|
36
|
+
t6 = {
|
|
36
37
|
query,
|
|
37
38
|
queryParams,
|
|
38
39
|
queryOptions,
|
|
39
|
-
mapItems:
|
|
40
|
-
resolveSelectedItemsWithIds:
|
|
41
|
-
search:
|
|
42
|
-
initialQueryState:
|
|
40
|
+
mapItems: t2,
|
|
41
|
+
resolveSelectedItemsWithIds: t3,
|
|
42
|
+
search: t4,
|
|
43
|
+
initialQueryState: t5,
|
|
43
44
|
selectedIdsToResolve: selectedIdsToResolve.items
|
|
44
45
|
};
|
|
45
46
|
$[2] = query;
|
|
46
47
|
$[3] = queryOptions;
|
|
47
48
|
$[4] = queryParams;
|
|
48
49
|
$[5] = selectedIdsToResolve.items;
|
|
49
|
-
$[6] =
|
|
50
|
-
$[7] =
|
|
51
|
-
$[8] =
|
|
52
|
-
$[9] =
|
|
53
|
-
$[10] =
|
|
54
|
-
} else
|
|
55
|
-
const { items, totalItems, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete(
|
|
50
|
+
$[6] = t2;
|
|
51
|
+
$[7] = t3;
|
|
52
|
+
$[8] = t4;
|
|
53
|
+
$[9] = t5;
|
|
54
|
+
$[10] = t6;
|
|
55
|
+
} else t6 = $[10];
|
|
56
|
+
const { items, totalItems, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete(t6);
|
|
56
57
|
let onSearchChange;
|
|
57
58
|
let selectProps;
|
|
58
59
|
if ($[11] !== props) {
|
|
59
|
-
const { isInitialQueryDisabled: _, onSearchChange:
|
|
60
|
-
onSearchChange =
|
|
61
|
-
selectProps =
|
|
60
|
+
const { isInitialQueryDisabled: _, onSearchChange: t7, ...t8 } = props;
|
|
61
|
+
onSearchChange = t7;
|
|
62
|
+
selectProps = t8;
|
|
62
63
|
$[11] = props;
|
|
63
64
|
$[12] = onSearchChange;
|
|
64
65
|
$[13] = selectProps;
|
|
@@ -66,9 +67,9 @@ var QuerySelectContent = (t0) => {
|
|
|
66
67
|
onSearchChange = $[12];
|
|
67
68
|
selectProps = $[13];
|
|
68
69
|
}
|
|
69
|
-
let
|
|
70
|
+
let t7;
|
|
70
71
|
if ($[14] !== handleEnableQuery || $[15] !== onSearchChange || $[16] !== setSearch) {
|
|
71
|
-
|
|
72
|
+
t7 = (value_0) => {
|
|
72
73
|
setSearch(value_0);
|
|
73
74
|
handleEnableQuery();
|
|
74
75
|
onSearchChange?.(value_0);
|
|
@@ -76,33 +77,33 @@ var QuerySelectContent = (t0) => {
|
|
|
76
77
|
$[14] = handleEnableQuery;
|
|
77
78
|
$[15] = onSearchChange;
|
|
78
79
|
$[16] = setSearch;
|
|
79
|
-
$[17] =
|
|
80
|
-
} else
|
|
81
|
-
const handleSearchChange =
|
|
82
|
-
const
|
|
83
|
-
let
|
|
80
|
+
$[17] = t7;
|
|
81
|
+
} else t7 = $[17];
|
|
82
|
+
const handleSearchChange = t7;
|
|
83
|
+
const t8 = props.searchDebounceDelay ?? ui.querySelect?.searchDebounceDelay;
|
|
84
|
+
let t9;
|
|
84
85
|
if ($[18] !== handleSearchChange || $[19] !== isSearchable) {
|
|
85
|
-
|
|
86
|
+
t9 = isSearchable && {
|
|
86
87
|
isClientSearchDisabled: true,
|
|
87
88
|
onSearchChange: handleSearchChange
|
|
88
89
|
};
|
|
89
90
|
$[18] = handleSearchChange;
|
|
90
91
|
$[19] = isSearchable;
|
|
91
|
-
$[20] =
|
|
92
|
-
} else
|
|
93
|
-
let
|
|
94
|
-
if ($[21] !== fetchNextPage || $[22] !== handleEnableQuery || $[23] !== hasNextPage || $[24] !== isLoading || $[25] !== items || $[26] !== selectProps || $[27] !==
|
|
95
|
-
|
|
92
|
+
$[20] = t9;
|
|
93
|
+
} else t9 = $[20];
|
|
94
|
+
let t10;
|
|
95
|
+
if ($[21] !== fetchNextPage || $[22] !== handleEnableQuery || $[23] !== hasNextPage || $[24] !== isLoading || $[25] !== items || $[26] !== selectProps || $[27] !== t8 || $[28] !== t9 || $[29] !== totalItems) {
|
|
96
|
+
t10 = /* @__PURE__ */ jsx(Select, {
|
|
96
97
|
...selectProps,
|
|
97
98
|
items,
|
|
98
99
|
isLoading,
|
|
99
100
|
totalItems,
|
|
100
101
|
hasLoadMore: hasNextPage,
|
|
101
102
|
onLoadMore: fetchNextPage,
|
|
102
|
-
searchDebounceDelay:
|
|
103
|
+
searchDebounceDelay: t8,
|
|
103
104
|
onMouseEnter: handleEnableQuery,
|
|
104
105
|
onFocusCapture: handleEnableQuery,
|
|
105
|
-
...
|
|
106
|
+
...t9
|
|
106
107
|
});
|
|
107
108
|
$[21] = fetchNextPage;
|
|
108
109
|
$[22] = handleEnableQuery;
|
|
@@ -110,12 +111,64 @@ var QuerySelectContent = (t0) => {
|
|
|
110
111
|
$[24] = isLoading;
|
|
111
112
|
$[25] = items;
|
|
112
113
|
$[26] = selectProps;
|
|
113
|
-
$[27] =
|
|
114
|
-
$[28] =
|
|
114
|
+
$[27] = t8;
|
|
115
|
+
$[28] = t9;
|
|
115
116
|
$[29] = totalItems;
|
|
116
|
-
$[30] =
|
|
117
|
-
} else
|
|
118
|
-
return
|
|
117
|
+
$[30] = t10;
|
|
118
|
+
} else t10 = $[30];
|
|
119
|
+
return t10;
|
|
120
|
+
};
|
|
121
|
+
var QuerySelectContent = (props) => {
|
|
122
|
+
const $ = c(9);
|
|
123
|
+
const [isQueryMounted, setIsQueryMounted] = useState(false);
|
|
124
|
+
const value = "value" in props ? props.value : void 0;
|
|
125
|
+
if (!getSelectionIdsToResolve({
|
|
126
|
+
initialSelection: props.initialSelection,
|
|
127
|
+
value,
|
|
128
|
+
mapInitialToSelectItem: props.mapInitialToSelectItem
|
|
129
|
+
}).isResolvedByInitialSelection || isQueryMounted) {
|
|
130
|
+
let t0;
|
|
131
|
+
if ($[0] !== isQueryMounted || $[1] !== props) {
|
|
132
|
+
t0 = /* @__PURE__ */ jsx(LoadedQuerySelectContent, {
|
|
133
|
+
...props,
|
|
134
|
+
isQueryEnabledInitially: isQueryMounted
|
|
135
|
+
});
|
|
136
|
+
$[0] = isQueryMounted;
|
|
137
|
+
$[1] = props;
|
|
138
|
+
$[2] = t0;
|
|
139
|
+
} else t0 = $[2];
|
|
140
|
+
return t0;
|
|
141
|
+
}
|
|
142
|
+
let selectProps;
|
|
143
|
+
if ($[3] !== props) {
|
|
144
|
+
const { query: _, queryParams: _queryParams, queryOptions: _queryOptions, queryMap: _queryMap, resolveSelectedItemsWithIds: _resolveSelectedItemsWithIds, isInitialQueryDisabled: _isInitialQueryDisabled, ...t0 } = props;
|
|
145
|
+
selectProps = t0;
|
|
146
|
+
$[3] = props;
|
|
147
|
+
$[4] = selectProps;
|
|
148
|
+
} else selectProps = $[4];
|
|
149
|
+
let t0;
|
|
150
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
151
|
+
t0 = () => setIsQueryMounted(true);
|
|
152
|
+
$[5] = t0;
|
|
153
|
+
} else t0 = $[5];
|
|
154
|
+
const mountQuery = t0;
|
|
155
|
+
let t1;
|
|
156
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
157
|
+
t1 = [];
|
|
158
|
+
$[6] = t1;
|
|
159
|
+
} else t1 = $[6];
|
|
160
|
+
let t2;
|
|
161
|
+
if ($[7] !== selectProps) {
|
|
162
|
+
t2 = /* @__PURE__ */ jsx(Select, {
|
|
163
|
+
...selectProps,
|
|
164
|
+
items: t1,
|
|
165
|
+
onMouseEnter: mountQuery,
|
|
166
|
+
onFocusCapture: mountQuery
|
|
167
|
+
});
|
|
168
|
+
$[7] = selectProps;
|
|
169
|
+
$[8] = t2;
|
|
170
|
+
} else t2 = $[8];
|
|
171
|
+
return t2;
|
|
119
172
|
};
|
|
120
173
|
var QuerySelect = (props) => {
|
|
121
174
|
const $ = c(16);
|
|
@@ -9,6 +9,7 @@ export declare const getSelectionIdsToResolve: <TInitialSelectItem, TKey extends
|
|
|
9
9
|
mapInitialToSelectItem?: (item: TInitialSelectItem) => SelectItem<TKey>;
|
|
10
10
|
}) => {
|
|
11
11
|
count: number;
|
|
12
|
+
isResolvedByInitialSelection: boolean;
|
|
12
13
|
items: TKey[];
|
|
13
14
|
};
|
|
14
15
|
export declare const getQueryItems: <TQueryFn extends QueryFn, TKey extends Key = Key>(data: QueryDataType<TQueryFn> | undefined, queryMap?: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[]) => SelectItem<TKey>[];
|
|
@@ -26,6 +26,7 @@ var getSelectionIdsToResolve = ({ initialSelection, value, mapInitialToSelectIte
|
|
|
26
26
|
const items = Array.from(new Set([...missingLabelInitialSelectionIds, ...values.filter((id) => !labeledInitialSelectionIds.has(id))]));
|
|
27
27
|
return {
|
|
28
28
|
count: items.length,
|
|
29
|
+
isResolvedByInitialSelection: values.length > 0 && values.every((id) => labeledInitialSelectionIds.has(id)),
|
|
29
30
|
items
|
|
30
31
|
};
|
|
31
32
|
};
|
|
@@ -135,16 +135,26 @@ var SelectContext;
|
|
|
135
135
|
triggerBlurOnChange
|
|
136
136
|
]);
|
|
137
137
|
const onClear = useCallback(() => {
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
-
...
|
|
141
|
-
inputValue: ""
|
|
142
|
-
|
|
138
|
+
if (selectedIds.length === 0) {
|
|
139
|
+
const newFieldState_2 = {
|
|
140
|
+
...fieldState,
|
|
141
|
+
inputValue: "",
|
|
142
|
+
searchValue: ""
|
|
143
|
+
};
|
|
144
|
+
setFieldState(newFieldState_2);
|
|
145
|
+
emitStateChanges(newFieldState_2, true);
|
|
146
|
+
setShowAll(true);
|
|
143
147
|
return;
|
|
144
148
|
}
|
|
145
149
|
if (isMultiple) onChange([]);
|
|
146
150
|
else onChange(null);
|
|
147
|
-
}, [
|
|
151
|
+
}, [
|
|
152
|
+
emitStateChanges,
|
|
153
|
+
fieldState,
|
|
154
|
+
isMultiple,
|
|
155
|
+
onChange,
|
|
156
|
+
selectedIds.length
|
|
157
|
+
]);
|
|
148
158
|
const onSelectAll = useCallback(() => {
|
|
149
159
|
onChange(selectableListItems.map(({ id: id_4 }) => id_4));
|
|
150
160
|
}, [selectableListItems, onChange]);
|
|
@@ -157,13 +167,13 @@ var SelectContext;
|
|
|
157
167
|
]);
|
|
158
168
|
const onBlur = useCallback(() => {
|
|
159
169
|
if (props.isSearchable && isMultiple && fieldState.searchValue !== "") {
|
|
160
|
-
const
|
|
170
|
+
const newFieldState_3 = {
|
|
161
171
|
...fieldState,
|
|
162
172
|
inputValue: "",
|
|
163
173
|
searchValue: ""
|
|
164
174
|
};
|
|
165
|
-
setFieldState(
|
|
166
|
-
emitStateChanges(
|
|
175
|
+
setFieldState(newFieldState_3);
|
|
176
|
+
emitStateChanges(newFieldState_3);
|
|
167
177
|
setShowAll(true);
|
|
168
178
|
}
|
|
169
179
|
fieldOnBlur?.({});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IntlUtils } from "../utils/intl.utils.js";
|
|
1
2
|
import { StringUtils } from "../utils/string.utils.js";
|
|
2
3
|
import { ZodUtils } from "../utils/zod.utils.js";
|
|
3
4
|
import { DateUtils } from "../utils/date.utils.js";
|
|
@@ -11,7 +12,7 @@ var FORMAT_MAP = {
|
|
|
11
12
|
return `${DateUtils.formatDate(new Date(value.start))} - ${DateUtils.formatDate(new Date(value.end))}`;
|
|
12
13
|
},
|
|
13
14
|
enum: (value) => StringUtils.capitalize(value),
|
|
14
|
-
number: (value) =>
|
|
15
|
+
number: (value) => IntlUtils.getNumberFormatter(i18next.language).format(value),
|
|
15
16
|
string: (value) => String(value),
|
|
16
17
|
boolean: (value) => {
|
|
17
18
|
const key = `${DEFAULT_NAMESPACE}.${value ? "yes" : "no"}`;
|
package/dist/index.d.ts
CHANGED
|
@@ -253,6 +253,7 @@ export { DateTimeUtils } from './utils/date-time.utils';
|
|
|
253
253
|
export { DomUtils } from './utils/dom.utils';
|
|
254
254
|
export { FileUtils } from './utils/file.utils';
|
|
255
255
|
export { isEqual } from './utils/isEqual';
|
|
256
|
+
export { IntlUtils } from './utils/intl.utils';
|
|
256
257
|
export { logger } from './utils/logger';
|
|
257
258
|
export { ObjectUtils } from './utils/object.utils';
|
|
258
259
|
export { QueriesUtils } from './utils/queries.utils';
|
package/dist/index.js
CHANGED
|
@@ -82,6 +82,7 @@ import { inputBaseDefinition, inputClearClassDefinition, inputContentWrapperDefi
|
|
|
82
82
|
import { CheckboxGroup } from "./components/inputs/Checkbox/CheckboxGroup.js";
|
|
83
83
|
import { useLongPressRepeat } from "./hooks/useLongPressRepeat.js";
|
|
84
84
|
import { useScrollableListBox } from "./hooks/useScrollableListBox.js";
|
|
85
|
+
import { IntlUtils } from "./utils/intl.utils.js";
|
|
85
86
|
import { DateTimeUtils } from "./utils/date-time.utils.js";
|
|
86
87
|
import { datePickerInputContentRowDefinition } from "./components/inputs/DateTime/shared/datePickerInput.cva.js";
|
|
87
88
|
import { popoverDefinition } from "./components/shared/popover.cva.js";
|
|
@@ -176,4 +177,4 @@ import { useSorting } from "./hooks/useSorting.js";
|
|
|
176
177
|
import { useTableColumnConfig } from "./hooks/useTableColumnConfig.js";
|
|
177
178
|
import { ArrayUtils } from "./utils/array.utils.js";
|
|
178
179
|
import { QueriesUtils } from "./utils/queries.utils.js";
|
|
179
|
-
export { Accordion, ActionModal, Alert, AlignCenterIcon, AlignLeftIcon, AlignLeftRightIcon, AlignRightIcon, ArrayUtils, ArrowDropDownIcon, ArrowDropUpIcon, ArrowLeftIcon, ArrowRightIcon, Autocomplete, BoldIcon, BottomSheet, Breadcrumbs, BulletedListIcon, Button, CalendarIcon, CellText, CheckIcon, Checkbox, CheckboxCheckmarkIcon, CheckboxGroup, 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, Pill, 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, UIOverrides, UIRouter, UnderlinedIcon, VisibilityIcon, VisibilityOffIcon, ZodUtils, accordionChevronDefinition, accordionDefinition, accordionHeadingDefinition, accordionHeadingSubtitleDefinition, accordionHeadingTitleDefinition, accordionIconDefinition, accordionItemDefinition, accordionPanelContentDefinition, accordionPanelDefinition, accordionTriggerDefinition, alertDefinition, breadcrumbChevronDefinition, breadcrumbIconDefinition, breadcrumbItemDefinition, breadcrumbSegmentDefinition, breadcrumbsDefinition, buttonContentDefinition, buttonDefinition, buttonIconSizeDefinition, buttonSizeDefinition, checkboxContentRowDefinition, checkboxContentWrapperDefinition, checkboxDefinition, checkboxGroupLabelDefinition, checkboxIconDefinition, compoundMapper, createKeyInteractionsHandler, datePickerInputContentRowDefinition, dynamicColumns, dynamicInputs, fileUploadDropZoneDefinition, formFieldErrorDefinition, formFieldHeaderDefinition, formFieldHelperDefinition, getKeyInteractionAction, inputBaseDefinition, inputClearClassDefinition, inputContentWrapperDefinition, inputSideDefinition, inputSizeDefinition, inputUploadButtonDefinition, inputUploadDropZoneDefinition, isEqual, labelDefinition, linkDefinition, loaderDefinition, loaderWrapperDefinition, logger, menuDefinition, menuItemDefinition, menuPopoverDefinition, menuPopoverWrapperDefinition, modalContentDefinition, modalMainDefinition, modalOverlayDefinition, ns, pillButtonContentDefinition, pillButtonDefinition, popoverDefinition, progressBarDefinition, progressBarFillDefinition, progressBarTrackDefinition, progressBarTrackWrapperDefinition, progressBarValueDefinition, radioContentRowDefinition, radioContentWrapperDefinition, radioDefinition, resources, segmentDefinition, segmentItemDefinition, selectInputTagsContentWrapperDefinition, selectListBoxItemDefinition, selectPopoverDefinition, statusIconDefinition, statusSeparatorDefinition, stepperDefinition, stepperIconDefinition, stepperItemDefinition, stepperNumberDefinition, stepperSeparatorDefinition, stepperSubtextDefinition, stepperTitleDefinition, tableCellTextDefinition, tableDataDefinition, tableHeadDataDefinition, tableHeadRowDefinition, tableHeaderTextDefinition, tableRowDefinition, tagDefinition, textAreaWrapperDefinition, toastDefinition, statusIconDefinition$1 as toastStatusIconDefinition, statusSeparatorDefinition$1 as toastStatusSeparatorDefinition, toggleDefinition, tooltipDefinition, tooltipPointerHorizontalDefinition, tooltipPointerVerticalDefinition, tooltipTextDefinition, tooltipWrapperTriggerDefinition, typographyDefinition, uiOutlineClass, useAutosave, useBreakpoint, useDebounceCallback, useDeepCompareEffect, useDeepCompareLayoutEffect, useDeepCompareMemo, useFilters, useForm, useFormAutosave, useIntersectionObserver, useKeyInteractions, useLocalStorage, useLongPressRepeat, usePagination, useScrollableListBox, useSorting, useStateAndRef, useTableColumnConfig, useTableNav, useToast, useTranslationMemo };
|
|
180
|
+
export { Accordion, ActionModal, Alert, AlignCenterIcon, AlignLeftIcon, AlignLeftRightIcon, AlignRightIcon, ArrayUtils, ArrowDropDownIcon, ArrowDropUpIcon, ArrowLeftIcon, ArrowRightIcon, Autocomplete, BoldIcon, BottomSheet, Breadcrumbs, BulletedListIcon, Button, CalendarIcon, CellText, CheckIcon, Checkbox, CheckboxCheckmarkIcon, CheckboxGroup, 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, IntlUtils, ItalicIcon, Link, LinkContext, LinkIcon, Loader, Menu, MenuIcon, MenuItem, MenuPopover, Modal, NumberInput, NumberRangeInput, NumberedListIcon, ObjectUtils, PaginatedTable, Pagination, PaginationList, PasswordInput, Pill, 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, UIOverrides, UIRouter, UnderlinedIcon, VisibilityIcon, VisibilityOffIcon, ZodUtils, accordionChevronDefinition, accordionDefinition, accordionHeadingDefinition, accordionHeadingSubtitleDefinition, accordionHeadingTitleDefinition, accordionIconDefinition, accordionItemDefinition, accordionPanelContentDefinition, accordionPanelDefinition, accordionTriggerDefinition, alertDefinition, breadcrumbChevronDefinition, breadcrumbIconDefinition, breadcrumbItemDefinition, breadcrumbSegmentDefinition, breadcrumbsDefinition, buttonContentDefinition, buttonDefinition, buttonIconSizeDefinition, buttonSizeDefinition, checkboxContentRowDefinition, checkboxContentWrapperDefinition, checkboxDefinition, checkboxGroupLabelDefinition, checkboxIconDefinition, compoundMapper, createKeyInteractionsHandler, datePickerInputContentRowDefinition, dynamicColumns, dynamicInputs, fileUploadDropZoneDefinition, formFieldErrorDefinition, formFieldHeaderDefinition, formFieldHelperDefinition, getKeyInteractionAction, inputBaseDefinition, inputClearClassDefinition, inputContentWrapperDefinition, inputSideDefinition, inputSizeDefinition, inputUploadButtonDefinition, inputUploadDropZoneDefinition, isEqual, labelDefinition, linkDefinition, loaderDefinition, loaderWrapperDefinition, logger, menuDefinition, menuItemDefinition, menuPopoverDefinition, menuPopoverWrapperDefinition, modalContentDefinition, modalMainDefinition, modalOverlayDefinition, ns, pillButtonContentDefinition, pillButtonDefinition, popoverDefinition, progressBarDefinition, progressBarFillDefinition, progressBarTrackDefinition, progressBarTrackWrapperDefinition, progressBarValueDefinition, radioContentRowDefinition, radioContentWrapperDefinition, radioDefinition, resources, segmentDefinition, segmentItemDefinition, selectInputTagsContentWrapperDefinition, selectListBoxItemDefinition, selectPopoverDefinition, statusIconDefinition, statusSeparatorDefinition, stepperDefinition, stepperIconDefinition, stepperItemDefinition, stepperNumberDefinition, stepperSeparatorDefinition, stepperSubtextDefinition, stepperTitleDefinition, tableCellTextDefinition, tableDataDefinition, tableHeadDataDefinition, tableHeadRowDefinition, tableHeaderTextDefinition, tableRowDefinition, tagDefinition, textAreaWrapperDefinition, toastDefinition, statusIconDefinition$1 as toastStatusIconDefinition, statusSeparatorDefinition$1 as toastStatusSeparatorDefinition, toggleDefinition, tooltipDefinition, tooltipPointerHorizontalDefinition, tooltipPointerVerticalDefinition, tooltipTextDefinition, tooltipWrapperTriggerDefinition, typographyDefinition, uiOutlineClass, useAutosave, useBreakpoint, useDebounceCallback, useDeepCompareEffect, useDeepCompareLayoutEffect, useDeepCompareMemo, useFilters, useForm, useFormAutosave, useIntersectionObserver, useKeyInteractions, useLocalStorage, useLongPressRepeat, usePagination, useScrollableListBox, useSorting, useStateAndRef, useTableColumnConfig, useTableNav, useToast, useTranslationMemo };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IntlUtils } from "./intl.utils.js";
|
|
1
2
|
import { CalendarDate, CalendarDateTime, DateFormatter, fromDate, getLocalTimeZone, parseAbsolute } from "@internationalized/date";
|
|
2
3
|
import { DateTime } from "luxon";
|
|
3
4
|
//#region src/utils/date-time.utils.ts
|
|
@@ -5,33 +6,42 @@ var DateTimeUtils;
|
|
|
5
6
|
(function(_DateTimeUtils) {
|
|
6
7
|
const DATE_SAMPLE_DATE_UTC = new Date(Date.UTC(2e3, 10, 22));
|
|
7
8
|
const TIME_SAMPLE_DATE_UTC = new Date(Date.UTC(2e3, 10, 22, 6, 45));
|
|
9
|
+
const timeFormatters = /* @__PURE__ */ new Map();
|
|
8
10
|
const getDayMonthFormat = (shouldForceLeadingZeros = false) => shouldForceLeadingZeros ? "2-digit" : "numeric";
|
|
9
11
|
const getTimeHourFormat = (shouldForceLeadingZeros = false) => shouldForceLeadingZeros ? "2-digit" : "numeric";
|
|
10
|
-
const getDatePlaceholderFormatter = (locale, options) =>
|
|
12
|
+
const getDatePlaceholderFormatter = (locale, options) => IntlUtils.getDateTimeFormatter(locale, {
|
|
11
13
|
day: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
12
14
|
month: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
13
15
|
year: "numeric"
|
|
14
16
|
});
|
|
15
|
-
const getTimePlaceholderFormatter = (locale) =>
|
|
17
|
+
const getTimePlaceholderFormatter = (locale) => IntlUtils.getDateTimeFormatter(locale, {
|
|
16
18
|
hour: "2-digit",
|
|
17
19
|
minute: "2-digit"
|
|
18
20
|
});
|
|
19
21
|
const getResolvedLocale = (locale) => {
|
|
20
22
|
if (locale) return locale;
|
|
21
|
-
return
|
|
23
|
+
return IntlUtils.getDateTimeFormatter().resolvedOptions().locale;
|
|
22
24
|
};
|
|
23
|
-
const getDateFormatter = (locale, options) =>
|
|
25
|
+
const getDateFormatter = (locale, options) => IntlUtils.getDateTimeFormatter(getResolvedLocale(locale), {
|
|
24
26
|
day: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
25
27
|
month: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
26
28
|
year: "numeric",
|
|
27
29
|
timeZone: "UTC"
|
|
28
30
|
});
|
|
29
|
-
const getTimeFormatter = (locale, options) =>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const getTimeFormatter = (locale, options) => {
|
|
32
|
+
const resolvedLocale = getResolvedLocale(locale);
|
|
33
|
+
const key = `${resolvedLocale}|${options?.shouldForceLeadingZeros ?? false}`;
|
|
34
|
+
const cachedFormatter = timeFormatters.get(key);
|
|
35
|
+
if (cachedFormatter) return cachedFormatter;
|
|
36
|
+
const formatter = new DateFormatter(resolvedLocale, {
|
|
37
|
+
hour: getTimeHourFormat(options?.shouldForceLeadingZeros),
|
|
38
|
+
minute: "2-digit",
|
|
39
|
+
timeZone: "UTC"
|
|
40
|
+
});
|
|
41
|
+
timeFormatters.set(key, formatter);
|
|
42
|
+
return formatter;
|
|
43
|
+
};
|
|
44
|
+
const getDateTimeFormatter = (locale, options) => IntlUtils.getDateTimeFormatter(getResolvedLocale(locale), {
|
|
35
45
|
day: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
36
46
|
month: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
37
47
|
year: "numeric",
|
|
@@ -40,7 +50,7 @@ var DateTimeUtils;
|
|
|
40
50
|
timeZone: "UTC"
|
|
41
51
|
});
|
|
42
52
|
const repeatLocalizedFieldLabel = (type, length, locale) => {
|
|
43
|
-
const placeholderChar =
|
|
53
|
+
const placeholderChar = IntlUtils.getDisplayNamesFormatter(getResolvedLocale(locale), { type: "dateTimeField" }).of(type)?.trim().charAt(0).toLocaleLowerCase(getResolvedLocale(locale));
|
|
44
54
|
if (!placeholderChar) return null;
|
|
45
55
|
return placeholderChar.repeat(length);
|
|
46
56
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type IntlLocale = Intl.LocalesArgument;
|
|
2
|
+
export declare namespace IntlUtils {
|
|
3
|
+
const getDateTimeFormatter: (locale?: IntlLocale, options?: Intl.DateTimeFormatOptions) => Intl.DateTimeFormat;
|
|
4
|
+
const getDisplayNamesFormatter: (locale: IntlLocale, options: Intl.DisplayNamesOptions) => Intl.DisplayNames;
|
|
5
|
+
const getNumberFormatter: (locale?: IntlLocale, options?: Intl.NumberFormatOptions) => Intl.NumberFormat;
|
|
6
|
+
}
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/utils/intl.utils.ts
|
|
2
|
+
var formatterCacheKey = (locale, options) => {
|
|
3
|
+
const locales = Array.isArray(locale) ? locale.map(String) : locale ? [String(locale)] : [];
|
|
4
|
+
const normalizedOptions = Object.entries(options ?? {}).sort(([left], [right]) => left.localeCompare(right));
|
|
5
|
+
return JSON.stringify([locales, normalizedOptions]);
|
|
6
|
+
};
|
|
7
|
+
var IntlUtils;
|
|
8
|
+
(function(_IntlUtils) {
|
|
9
|
+
const dateTimeFormatters = /* @__PURE__ */ new Map();
|
|
10
|
+
const displayNamesFormatters = /* @__PURE__ */ new Map();
|
|
11
|
+
const numberFormatters = /* @__PURE__ */ new Map();
|
|
12
|
+
_IntlUtils.getDateTimeFormatter = (locale, options) => {
|
|
13
|
+
const key = formatterCacheKey(locale, options);
|
|
14
|
+
const cachedFormatter = dateTimeFormatters.get(key);
|
|
15
|
+
if (cachedFormatter) return cachedFormatter;
|
|
16
|
+
const formatter = new Intl.DateTimeFormat(locale, options);
|
|
17
|
+
dateTimeFormatters.set(key, formatter);
|
|
18
|
+
return formatter;
|
|
19
|
+
};
|
|
20
|
+
_IntlUtils.getDisplayNamesFormatter = (locale, options) => {
|
|
21
|
+
const key = formatterCacheKey(locale, options);
|
|
22
|
+
const cachedFormatter = displayNamesFormatters.get(key);
|
|
23
|
+
if (cachedFormatter) return cachedFormatter;
|
|
24
|
+
const formatter = new Intl.DisplayNames(locale, options);
|
|
25
|
+
displayNamesFormatters.set(key, formatter);
|
|
26
|
+
return formatter;
|
|
27
|
+
};
|
|
28
|
+
_IntlUtils.getNumberFormatter = (locale, options) => {
|
|
29
|
+
const key = formatterCacheKey(locale, options);
|
|
30
|
+
const cachedFormatter = numberFormatters.get(key);
|
|
31
|
+
if (cachedFormatter) return cachedFormatter;
|
|
32
|
+
const formatter = new Intl.NumberFormat(locale, options);
|
|
33
|
+
numberFormatters.set(key, formatter);
|
|
34
|
+
return formatter;
|
|
35
|
+
};
|
|
36
|
+
})(IntlUtils || (IntlUtils = {}));
|
|
37
|
+
//#endregion
|
|
38
|
+
export { IntlUtils };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|