@povio/ui 3.3.0-rc.4 → 3.4.0-rc.1
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/README.md +15 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +55 -206
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +9 -34
- package/dist/components/buttons/shared/ButtonContent.js +22 -80
- package/dist/components/inputs/Checkbox/Checkbox.d.ts +1 -2
- package/dist/components/inputs/Checkbox/Checkbox.js +93 -100
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +10 -24
- package/dist/components/inputs/Checkbox/CheckboxGroup.d.ts +1 -2
- package/dist/components/inputs/Checkbox/CheckboxGroup.js +109 -113
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +97 -238
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +88 -214
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +64 -143
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +275 -294
- package/dist/components/inputs/DateTime/shared/Calendar.js +139 -339
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +114 -308
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +35 -150
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +95 -229
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +115 -296
- package/dist/components/inputs/DateTime/shared/DateField.js +135 -306
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +1 -2
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +136 -343
- package/dist/components/inputs/DateTime/shared/DateTimeDialogFooter.js +10 -59
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +1 -2
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +43 -46
- package/dist/components/inputs/File/FileUpload.d.ts +1 -1
- package/dist/components/inputs/File/FileUpload.js +18 -18
- package/dist/components/inputs/File/InputUpload.d.ts +1 -1
- package/dist/components/inputs/File/InputUpload.js +82 -278
- package/dist/components/inputs/File/fileUpload.types.d.ts +1 -1
- package/dist/components/inputs/File/inputUpload.types.d.ts +1 -1
- package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +48 -180
- package/dist/components/inputs/File/shared/FileUploadContentError.js +95 -265
- package/dist/components/inputs/File/shared/FileUploadContentFilled.js +99 -261
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +56 -234
- package/dist/components/inputs/File/shared/ProgressBar.js +15 -102
- package/dist/components/inputs/FormField/FormField.js +34 -47
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +1 -1
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +19 -19
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +1 -1
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +93 -331
- package/dist/components/inputs/Input/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/components/inputs/Input/TextArea/TextArea.d.ts +1 -1
- package/dist/components/inputs/Input/TextArea/TextArea.js +18 -18
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +2 -2
- package/dist/components/inputs/Input/TextInput/TextInput.js +36 -38
- package/dist/components/inputs/Inputs/Form.d.ts +4 -4
- package/dist/components/inputs/Inputs/InputItem.d.ts +22 -22
- package/dist/components/inputs/Inputs/InputItem.js +35 -36
- package/dist/components/inputs/Inputs/Inputs.d.ts +2 -2
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +1 -2
- package/dist/components/inputs/RadioGroup/RadioGroup.js +107 -111
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +1 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +26 -86
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +19 -19
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +1 -1
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +1 -1
- package/dist/components/inputs/Selection/Select/QuerySelect.js +49 -115
- package/dist/components/inputs/Selection/Select/Select.d.ts +1 -1
- package/dist/components/inputs/Selection/Select/Select.js +22 -22
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +0 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +34 -37
- package/dist/components/inputs/Selection/shared/SelectInput.js +1 -0
- package/dist/components/inputs/Selection/shared/SelectListBox.js +51 -163
- package/dist/components/inputs/Selection/shared/select.context.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/select.context.js +4 -8
- package/dist/components/inputs/Selection/shared/select.types.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/useSelectItems.js +48 -108
- package/dist/components/inputs/Skeleton/InputFrame.js +177 -552
- package/dist/components/inputs/Slider/Slider.d.ts +1 -1
- package/dist/components/inputs/Slider/Slider.js +18 -18
- package/dist/components/inputs/TextEditor/TextEditor.d.ts +1 -1
- package/dist/components/inputs/TextEditor/TextEditor.js +105 -407
- package/dist/components/inputs/Toggle/Toggle.d.ts +1 -2
- package/dist/components/inputs/Toggle/Toggle.js +59 -63
- package/dist/components/inputs/shared/InputClear.js +24 -40
- package/dist/components/inputs/shared/form.binding.d.ts +27 -0
- package/dist/components/inputs/shared/form.binding.js +57 -0
- package/dist/components/inputs/shared/form.types.d.ts +9 -8
- package/dist/components/inputs/shared/form.types.js +8 -0
- package/dist/components/navigation/Accordion/Accordion.js +22 -69
- package/dist/components/navigation/Accordion/AccordionItem.js +41 -86
- package/dist/components/navigation/Stepper/Stepper.js +22 -67
- package/dist/components/overlays/ActionModal/ActionModal.js +35 -169
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +29 -110
- package/dist/components/segment/Segment.d.ts +1 -1
- package/dist/components/segment/Segment.js +17 -17
- package/dist/components/segment/segment.types.d.ts +1 -1
- package/dist/components/shared/pagination/Pagination.js +22 -108
- package/dist/components/status/Alert/Alert.js +30 -97
- package/dist/components/table/InfiniteTable.js +16 -67
- package/dist/components/table/Table.d.ts +2 -8
- package/dist/components/table/Table.js +33 -55
- package/dist/components/text/Typography/Typography.js +8 -23
- package/dist/config/confirmation.context.js +1 -1
- package/dist/config/theme.context.js +45 -98
- package/dist/config/uiConfig.context.d.ts +5 -5
- package/dist/config/uiConfig.context.js +11 -51
- package/dist/config/uiOverrides.context.d.ts +0 -1
- package/dist/helpers/dynamicColumns.d.ts +1 -1
- package/dist/helpers/dynamicInputs.d.ts +7 -7
- package/dist/hooks/useAutosave.d.ts +4 -4
- package/dist/hooks/useAutosave.js +64 -49
- package/dist/hooks/useDebounceCallback.js +17 -51
- package/dist/hooks/useForm.d.ts +39 -15
- package/dist/hooks/useForm.js +96 -43
- package/dist/hooks/useFormAutosave.d.ts +8 -9
- package/dist/hooks/useFormAutosave.js +49 -122
- package/dist/hooks/useLongPressRepeat.js +20 -55
- package/dist/index.d.ts +2 -3
- package/dist/index.js +3 -4
- package/package.json +3 -4
- package/dist/components/inputs/FormField/formField.cva.d.ts +0 -11
- package/dist/components/inputs/FormField/formField.cva.js +0 -16
- package/dist/components/table/TableColumnFilterInput.d.ts +0 -9
- package/dist/components/table/TableColumnFilterInput.js +0 -108
- package/dist/components/table/TableColumnFilterPlaceholder.d.ts +0 -5
- package/dist/components/table/TableColumnFilterPlaceholder.js +0 -41
- package/dist/components/table/TableColumnFilterRow.d.ts +0 -16
- package/dist/components/table/TableColumnFilterRow.js +0 -68
- package/dist/hooks/useAutosave.spec.d.ts +0 -1
|
@@ -3,185 +3,73 @@ import { SelectContext } from "./select.context.js";
|
|
|
3
3
|
import { SelectListBoxItem } from "./SelectListBoxItem.js";
|
|
4
4
|
import { SelectListBoxItemSelectAll } from "./SelectListBoxItemSelectAll.js";
|
|
5
5
|
import { SelectListBoxLoadingItem } from "./SelectListBoxLoadingItem.js";
|
|
6
|
-
import { c } from "react/compiler-runtime";
|
|
7
6
|
import { jsx } from "react/jsx-runtime";
|
|
8
7
|
import { clsx } from "clsx";
|
|
9
8
|
import { ListBox, ListLayout, Virtualizer } from "react-aria-components";
|
|
10
9
|
//#region src/components/inputs/Selection/shared/SelectListBox.tsx
|
|
11
|
-
var SelectListBox = (
|
|
12
|
-
const $ = c(51);
|
|
13
|
-
let className;
|
|
14
|
-
let isSearchable;
|
|
15
|
-
let label;
|
|
16
|
-
let newItemRender;
|
|
17
|
-
let onClose;
|
|
18
|
-
let onLoadMore;
|
|
19
|
-
let props;
|
|
20
|
-
let selectionMode;
|
|
21
|
-
let t1;
|
|
22
|
-
let totalItems;
|
|
23
|
-
let virtualizerOptions;
|
|
24
|
-
if ($[0] !== t0) {
|
|
25
|
-
({label, selectionMode, isSearchable, isScrollable: t1, virtualizerOptions, totalItems, newItemRender, onLoadMore, className, onClose, ...props} = t0);
|
|
26
|
-
$[0] = t0;
|
|
27
|
-
$[1] = className;
|
|
28
|
-
$[2] = isSearchable;
|
|
29
|
-
$[3] = label;
|
|
30
|
-
$[4] = newItemRender;
|
|
31
|
-
$[5] = onClose;
|
|
32
|
-
$[6] = onLoadMore;
|
|
33
|
-
$[7] = props;
|
|
34
|
-
$[8] = selectionMode;
|
|
35
|
-
$[9] = t1;
|
|
36
|
-
$[10] = totalItems;
|
|
37
|
-
$[11] = virtualizerOptions;
|
|
38
|
-
} else {
|
|
39
|
-
className = $[1];
|
|
40
|
-
isSearchable = $[2];
|
|
41
|
-
label = $[3];
|
|
42
|
-
newItemRender = $[4];
|
|
43
|
-
onClose = $[5];
|
|
44
|
-
onLoadMore = $[6];
|
|
45
|
-
props = $[7];
|
|
46
|
-
selectionMode = $[8];
|
|
47
|
-
t1 = $[9];
|
|
48
|
-
totalItems = $[10];
|
|
49
|
-
virtualizerOptions = $[11];
|
|
50
|
-
}
|
|
51
|
-
const isScrollable = t1 === void 0 ? true : t1;
|
|
10
|
+
var SelectListBox = ({ label, selectionMode, isSearchable, isScrollable = true, virtualizerOptions, totalItems, newItemRender, onLoadMore, className, onClose, ...props }) => {
|
|
52
11
|
const { fieldState, onChange, listItems, selectableListItems, selectedIds, isMultiple, onClear, onSelectAll, hasLoadMore } = SelectContext.useSelect();
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!isMultiple && ids.length === 0) {
|
|
58
|
-
if (fieldState.value) {
|
|
59
|
-
onClose?.();
|
|
60
|
-
onChange(fieldState.value);
|
|
61
|
-
}
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (isMultiple && ids.includes("all-item-id")) {
|
|
65
|
-
if (ids.length > selectableListItems.length) onClear();
|
|
66
|
-
else onSelectAll();
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (isMultiple) onChange(ids);
|
|
70
|
-
else {
|
|
12
|
+
const onSelectionChange = (value) => {
|
|
13
|
+
const ids = Array.from(value);
|
|
14
|
+
if (!isMultiple && ids.length === 0) {
|
|
15
|
+
if (fieldState.value) {
|
|
71
16
|
onClose?.();
|
|
72
|
-
onChange(
|
|
17
|
+
onChange(fieldState.value);
|
|
73
18
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
} else t3 = $[23];
|
|
105
|
-
const renderItem = t3;
|
|
106
|
-
if (virtualizerOptions || (totalItems ?? listItems.length) > 100 || hasLoadMore) {
|
|
107
|
-
const t4 = isScrollable ? "max-h-full overflow-y-auto overflow-x-hidden" : "overflow-hidden";
|
|
108
|
-
let t5;
|
|
109
|
-
if ($[24] !== className || $[25] !== t4) {
|
|
110
|
-
t5 = clsx("flex-1 outline-none [&>div:last-child>*]:border-b-0", t4, className);
|
|
111
|
-
$[24] = className;
|
|
112
|
-
$[25] = t4;
|
|
113
|
-
$[26] = t5;
|
|
114
|
-
} else t5 = $[26];
|
|
115
|
-
let t6;
|
|
116
|
-
if ($[27] !== label || $[28] !== listItems || $[29] !== onSelectionChange || $[30] !== props || $[31] !== renderItem || $[32] !== selectedIds || $[33] !== selectionMode || $[34] !== t5) {
|
|
117
|
-
t6 = /* @__PURE__ */ jsx(ListBox, {
|
|
118
|
-
...props,
|
|
119
|
-
"aria-label": label,
|
|
120
|
-
selectionMode,
|
|
121
|
-
className: t5,
|
|
122
|
-
items: listItems,
|
|
123
|
-
selectedKeys: selectedIds,
|
|
124
|
-
onSelectionChange,
|
|
125
|
-
escapeKeyBehavior: "none",
|
|
126
|
-
shouldSelectOnPressUp: true,
|
|
127
|
-
children: renderItem
|
|
128
|
-
});
|
|
129
|
-
$[27] = label;
|
|
130
|
-
$[28] = listItems;
|
|
131
|
-
$[29] = onSelectionChange;
|
|
132
|
-
$[30] = props;
|
|
133
|
-
$[31] = renderItem;
|
|
134
|
-
$[32] = selectedIds;
|
|
135
|
-
$[33] = selectionMode;
|
|
136
|
-
$[34] = t5;
|
|
137
|
-
$[35] = t6;
|
|
138
|
-
} else t6 = $[35];
|
|
139
|
-
let t7;
|
|
140
|
-
if ($[36] !== t6 || $[37] !== virtualizerOptions) {
|
|
141
|
-
t7 = /* @__PURE__ */ jsx(Virtualizer, {
|
|
142
|
-
layout: ListLayout,
|
|
143
|
-
layoutOptions: virtualizerOptions,
|
|
144
|
-
children: t6
|
|
145
|
-
});
|
|
146
|
-
$[36] = t6;
|
|
147
|
-
$[37] = virtualizerOptions;
|
|
148
|
-
$[38] = t7;
|
|
149
|
-
} else t7 = $[38];
|
|
150
|
-
return t7;
|
|
151
|
-
}
|
|
152
|
-
const t4 = isScrollable ? "max-h-full overflow-y-auto overflow-x-hidden" : "overflow-hidden";
|
|
153
|
-
let t5;
|
|
154
|
-
if ($[39] !== className || $[40] !== t4) {
|
|
155
|
-
t5 = clsx("flex-1 outline-none [&>div:last-child]:border-b-0", t4, className);
|
|
156
|
-
$[39] = className;
|
|
157
|
-
$[40] = t4;
|
|
158
|
-
$[41] = t5;
|
|
159
|
-
} else t5 = $[41];
|
|
160
|
-
let t6;
|
|
161
|
-
if ($[42] !== label || $[43] !== listItems || $[44] !== onSelectionChange || $[45] !== props || $[46] !== renderItem || $[47] !== selectedIds || $[48] !== selectionMode || $[49] !== t5) {
|
|
162
|
-
t6 = /* @__PURE__ */ jsx(ListBox, {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (isMultiple && ids.includes("all-item-id")) {
|
|
22
|
+
if (ids.length > selectableListItems.length) onClear();
|
|
23
|
+
else onSelectAll();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (isMultiple) onChange(ids);
|
|
27
|
+
else {
|
|
28
|
+
onClose?.();
|
|
29
|
+
onChange(ids[0]);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const renderItem = (item) => {
|
|
33
|
+
if (item.isSelectAllItem) return /* @__PURE__ */ jsx(SelectListBoxItemSelectAll, { ...item }, item.id);
|
|
34
|
+
if (item.isLoadingItem) return /* @__PURE__ */ jsx(SelectListBoxLoadingItem, {
|
|
35
|
+
...item,
|
|
36
|
+
onLoadMore
|
|
37
|
+
}, item.id);
|
|
38
|
+
return /* @__PURE__ */ jsx(SelectListBoxItem, {
|
|
39
|
+
...item,
|
|
40
|
+
isSearchable,
|
|
41
|
+
isNewItem: item.isNewItem,
|
|
42
|
+
newItemRender
|
|
43
|
+
}, item.id);
|
|
44
|
+
};
|
|
45
|
+
if (virtualizerOptions || (totalItems ?? listItems.length) > 100 || hasLoadMore) return /* @__PURE__ */ jsx(Virtualizer, {
|
|
46
|
+
layout: ListLayout,
|
|
47
|
+
layoutOptions: virtualizerOptions,
|
|
48
|
+
children: /* @__PURE__ */ jsx(ListBox, {
|
|
163
49
|
...props,
|
|
164
50
|
"aria-label": label,
|
|
165
51
|
selectionMode,
|
|
166
|
-
className:
|
|
52
|
+
className: clsx("flex-1 outline-none [&>div:last-child>*]:border-b-0", isScrollable ? "max-h-full overflow-y-auto overflow-x-hidden" : "overflow-hidden", className),
|
|
167
53
|
items: listItems,
|
|
168
54
|
selectedKeys: selectedIds,
|
|
169
55
|
onSelectionChange,
|
|
170
56
|
escapeKeyBehavior: "none",
|
|
171
57
|
shouldSelectOnPressUp: true,
|
|
172
58
|
children: renderItem
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
return /* @__PURE__ */ jsx(ListBox, {
|
|
62
|
+
...props,
|
|
63
|
+
"aria-label": label,
|
|
64
|
+
selectionMode,
|
|
65
|
+
className: clsx("flex-1 outline-none [&>div:last-child]:border-b-0", isScrollable ? "max-h-full overflow-y-auto overflow-x-hidden" : "overflow-hidden", className),
|
|
66
|
+
items: listItems,
|
|
67
|
+
selectedKeys: selectedIds,
|
|
68
|
+
onSelectionChange,
|
|
69
|
+
escapeKeyBehavior: "none",
|
|
70
|
+
shouldSelectOnPressUp: true,
|
|
71
|
+
children: renderItem
|
|
72
|
+
});
|
|
185
73
|
};
|
|
186
74
|
//#endregion
|
|
187
75
|
export { SelectListBox };
|
|
@@ -25,8 +25,8 @@ export declare namespace SelectContext {
|
|
|
25
25
|
isMultiple: boolean;
|
|
26
26
|
multiSelectAutoConfirm: boolean;
|
|
27
27
|
} & Pick<SelectBaseProps, "onInputChange" | "isLoading" | "hasLoadMore">;
|
|
28
|
-
export type ProviderProps = GroupedSelectProps & Pick<SelectBaseProps, "items" | "onInputChange" | "onSearchChange" | "showSelectAllOption" | "showNewItemOption" | "newItemMinLength" | "onNewItemOption" | "isLoading" | "hasLoadMore" | "mapInitialToSelectItem" | "isSearchable" | "isClientSearchDisabled" | "ignoreInputValueFiltering" | "
|
|
29
|
-
export const Provider: ({ items, onInputChange, onSearchChange, showSelectAllOption, showNewItemOption, newItemMinLength, onNewItemOption, isLoading, hasLoadMore, isClientSearchDisabled, ignoreInputValueFiltering,
|
|
28
|
+
export type ProviderProps = GroupedSelectProps & Pick<SelectBaseProps, "items" | "onInputChange" | "onSearchChange" | "showSelectAllOption" | "showNewItemOption" | "newItemMinLength" | "onNewItemOption" | "isLoading" | "hasLoadMore" | "mapInitialToSelectItem" | "isSearchable" | "isClientSearchDisabled" | "ignoreInputValueFiltering" | "searchDebounceDelay" | "multiSelectAutoConfirm" | "onBlur">;
|
|
29
|
+
export const Provider: ({ items, onInputChange, onSearchChange, showSelectAllOption, showNewItemOption, newItemMinLength, onNewItemOption, isLoading, hasLoadMore, isClientSearchDisabled, ignoreInputValueFiltering, searchDebounceDelay, multiSelectAutoConfirm, onBlur: fieldOnBlur, children, mapInitialToSelectItem, ...props }: PropsWithChildren<ProviderProps>) => import("react/jsx-runtime").JSX.Element;
|
|
30
30
|
export const useSelect: () => Type;
|
|
31
31
|
export {};
|
|
32
32
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
2
1
|
import { useSelectItems } from "./useSelectItems.js";
|
|
2
|
+
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
//#region src/components/inputs/Selection/shared/select.context.tsx
|
|
@@ -10,7 +10,7 @@ var SelectContext;
|
|
|
10
10
|
id: item.id,
|
|
11
11
|
label: item.label ?? item.name ?? ""
|
|
12
12
|
});
|
|
13
|
-
_SelectContext.Provider = ({ items, onInputChange, onSearchChange, showSelectAllOption, showNewItemOption, newItemMinLength, onNewItemOption, isLoading, hasLoadMore, isClientSearchDisabled, ignoreInputValueFiltering,
|
|
13
|
+
_SelectContext.Provider = ({ items, onInputChange, onSearchChange, showSelectAllOption, showNewItemOption, newItemMinLength, onNewItemOption, isLoading, hasLoadMore, isClientSearchDisabled, ignoreInputValueFiltering, searchDebounceDelay, multiSelectAutoConfirm = false, onBlur: fieldOnBlur, children, mapInitialToSelectItem = defaultMapInitialToSelectItem, ...props }) => {
|
|
14
14
|
const isMultiple = props.selectionMode === "multiple";
|
|
15
15
|
const initialSelectedItems = useMemo(() => {
|
|
16
16
|
if (!props.initialSelection) return null;
|
|
@@ -75,9 +75,6 @@ var SelectContext;
|
|
|
75
75
|
onSearchChangeDebounced,
|
|
76
76
|
updateValue
|
|
77
77
|
]);
|
|
78
|
-
const triggerBlurOnChange = useCallback(() => {
|
|
79
|
-
if (fireBlurOnChange) fieldOnBlur?.({});
|
|
80
|
-
}, [fireBlurOnChange, fieldOnBlur]);
|
|
81
78
|
const syncFieldState = (value_1) => {
|
|
82
79
|
const newFieldState = {
|
|
83
80
|
value: value_1,
|
|
@@ -120,7 +117,7 @@ var SelectContext;
|
|
|
120
117
|
searchValue: ""
|
|
121
118
|
};
|
|
122
119
|
setFieldState(newFieldState_1);
|
|
123
|
-
|
|
120
|
+
emitStateChanges(newFieldState_1);
|
|
124
121
|
}
|
|
125
122
|
if (!isMultiple) {
|
|
126
123
|
setIsOpen(false);
|
|
@@ -131,8 +128,7 @@ var SelectContext;
|
|
|
131
128
|
onNewItemOption,
|
|
132
129
|
fieldState.inputValue,
|
|
133
130
|
getItem_0,
|
|
134
|
-
isMultiple
|
|
135
|
-
triggerBlurOnChange
|
|
131
|
+
isMultiple
|
|
136
132
|
]);
|
|
137
133
|
const onClear = useCallback(() => {
|
|
138
134
|
if (selectedIds.length === 0) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { Key } from 'react-aria-components';
|
|
3
|
-
import { FieldValues } from '
|
|
3
|
+
import { FieldValues } from '../../shared/form.binding';
|
|
4
4
|
import { ControlProps } from '../../shared/form.types';
|
|
5
5
|
export interface SelectItem<TKey extends Key = Key> {
|
|
6
6
|
id: TKey;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from "react";
|
|
2
2
|
import { useFilter } from "react-aria-components";
|
|
3
3
|
//#region src/components/inputs/Selection/shared/useSelectItems.tsx
|
|
4
4
|
var SelectAllItemId = "all-item-id";
|
|
@@ -24,121 +24,61 @@ var ReservedItemIds = [
|
|
|
24
24
|
NewItemId,
|
|
25
25
|
LoadingItemId
|
|
26
26
|
];
|
|
27
|
-
function useSelectItems(
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} else t2 = $[0];
|
|
36
|
-
const { contains } = useFilter(t2);
|
|
37
|
-
const showSelectAllItem = isMultiple && showSelectAllOption && inputValue.length === 0 && !hasLoadMore;
|
|
38
|
-
let t3;
|
|
39
|
-
if ($[1] !== cachedItems || $[2] !== contains || $[3] !== inputValue || $[4] !== newItemMinLength || $[5] !== showNewItemOption) {
|
|
40
|
-
t3 = showNewItemOption && inputValue.length >= newItemMinLength && !cachedItems.find((item) => contains(item.label, inputValue));
|
|
41
|
-
$[1] = cachedItems;
|
|
42
|
-
$[2] = contains;
|
|
43
|
-
$[3] = inputValue;
|
|
44
|
-
$[4] = newItemMinLength;
|
|
45
|
-
$[5] = showNewItemOption;
|
|
46
|
-
$[6] = t3;
|
|
47
|
-
} else t3 = $[6];
|
|
48
|
-
const showNewItem = t3;
|
|
49
|
-
const showLoadingItem = isLoading || hasLoadMore;
|
|
50
|
-
let t4;
|
|
51
|
-
if ($[7] !== inputValue || $[8] !== showSelectAllItem) {
|
|
52
|
-
t4 = showSelectAllItem ? [SelectAllItem(inputValue)] : [];
|
|
53
|
-
$[7] = inputValue;
|
|
54
|
-
$[8] = showSelectAllItem;
|
|
55
|
-
$[9] = t4;
|
|
56
|
-
} else t4 = $[9];
|
|
57
|
-
let t5;
|
|
58
|
-
if ($[10] !== inputValue || $[11] !== showNewItem) {
|
|
59
|
-
t5 = showNewItem ? [NewItem(inputValue)] : [];
|
|
60
|
-
$[10] = inputValue;
|
|
61
|
-
$[11] = showNewItem;
|
|
62
|
-
$[12] = t5;
|
|
63
|
-
} else t5 = $[12];
|
|
64
|
-
let t6;
|
|
65
|
-
if ($[13] !== inputValue || $[14] !== showLoadingItem) {
|
|
66
|
-
t6 = showLoadingItem ? [LoadingItem(inputValue)] : [];
|
|
67
|
-
$[13] = inputValue;
|
|
68
|
-
$[14] = showLoadingItem;
|
|
69
|
-
$[15] = t6;
|
|
70
|
-
} else t6 = $[15];
|
|
71
|
-
let t7;
|
|
72
|
-
if ($[16] !== cachedItems || $[17] !== t4 || $[18] !== t5 || $[19] !== t6) {
|
|
73
|
-
t7 = [
|
|
74
|
-
...t4,
|
|
27
|
+
function useSelectItems({ initialSelectedItems, selectedItems, cachedItems, inputValue, showAll, isMultiple, showSelectAllOption, showNewItemOption, newItemMinLength = 3, isLoading, hasLoadMore, isClientSearchDisabled }) {
|
|
28
|
+
const { contains } = useFilter({ sensitivity: "base" });
|
|
29
|
+
const allListItems = useMemo(() => {
|
|
30
|
+
const showSelectAllItem = isMultiple && showSelectAllOption && inputValue.length === 0 && !hasLoadMore;
|
|
31
|
+
const showNewItem = showNewItemOption && inputValue.length >= newItemMinLength && !cachedItems.find((item) => contains(item.label, inputValue));
|
|
32
|
+
const showLoadingItem = isLoading || hasLoadMore;
|
|
33
|
+
return [
|
|
34
|
+
...showSelectAllItem ? [SelectAllItem(inputValue)] : [],
|
|
75
35
|
...cachedItems,
|
|
76
|
-
...
|
|
77
|
-
...
|
|
36
|
+
...showNewItem ? [NewItem(inputValue)] : [],
|
|
37
|
+
...showLoadingItem ? [LoadingItem(inputValue)] : []
|
|
78
38
|
];
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
39
|
+
}, [
|
|
40
|
+
isMultiple,
|
|
41
|
+
showNewItemOption,
|
|
42
|
+
inputValue,
|
|
43
|
+
newItemMinLength,
|
|
44
|
+
cachedItems,
|
|
45
|
+
contains,
|
|
46
|
+
isLoading,
|
|
47
|
+
hasLoadMore,
|
|
48
|
+
showSelectAllOption
|
|
49
|
+
]);
|
|
50
|
+
const allItems = useMemo(() => {
|
|
88
51
|
const items = [
|
|
89
52
|
...Array.isArray(initialSelectedItems) ? initialSelectedItems : [initialSelectedItems],
|
|
90
53
|
...Array.isArray(selectedItems) ? selectedItems : [selectedItems],
|
|
91
54
|
...allListItems
|
|
92
|
-
].filter(
|
|
55
|
+
].filter((item_0) => !!item_0);
|
|
93
56
|
const allItemsMap = /* @__PURE__ */ new Map();
|
|
94
57
|
items.forEach((item_1) => allItemsMap.set(item_1.id, item_1));
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
let t11;
|
|
120
|
-
if ($[31] !== allItems || $[32] !== allListItems || $[33] !== filteredListItems || $[34] !== listItems || $[35] !== selectableListItems) {
|
|
121
|
-
t11 = {
|
|
122
|
-
allItems,
|
|
123
|
-
allListItems,
|
|
124
|
-
filteredListItems,
|
|
125
|
-
listItems,
|
|
126
|
-
selectableListItems
|
|
127
|
-
};
|
|
128
|
-
$[31] = allItems;
|
|
129
|
-
$[32] = allListItems;
|
|
130
|
-
$[33] = filteredListItems;
|
|
131
|
-
$[34] = listItems;
|
|
132
|
-
$[35] = selectableListItems;
|
|
133
|
-
$[36] = t11;
|
|
134
|
-
} else t11 = $[36];
|
|
135
|
-
return t11;
|
|
136
|
-
}
|
|
137
|
-
function _temp2(item_3) {
|
|
138
|
-
return !item_3.isDisabled && !ReservedItemIds.includes(String(item_3.id));
|
|
139
|
-
}
|
|
140
|
-
function _temp(item_0) {
|
|
141
|
-
return !!item_0;
|
|
58
|
+
return Array.from(allItemsMap.values());
|
|
59
|
+
}, [
|
|
60
|
+
allListItems,
|
|
61
|
+
initialSelectedItems,
|
|
62
|
+
selectedItems
|
|
63
|
+
]);
|
|
64
|
+
const filteredListItems = useMemo(() => allListItems.filter((item_2) => contains(item_2.label, inputValue)), [
|
|
65
|
+
allListItems,
|
|
66
|
+
contains,
|
|
67
|
+
inputValue
|
|
68
|
+
]);
|
|
69
|
+
const listItems = useMemo(() => showAll || isClientSearchDisabled ? allListItems : filteredListItems, [
|
|
70
|
+
showAll,
|
|
71
|
+
isClientSearchDisabled,
|
|
72
|
+
allListItems,
|
|
73
|
+
filteredListItems
|
|
74
|
+
]);
|
|
75
|
+
return {
|
|
76
|
+
allItems,
|
|
77
|
+
allListItems,
|
|
78
|
+
filteredListItems,
|
|
79
|
+
listItems,
|
|
80
|
+
selectableListItems: useMemo(() => listItems.filter((item_3) => !item_3.isDisabled && !ReservedItemIds.includes(String(item_3.id))), [listItems])
|
|
81
|
+
};
|
|
142
82
|
}
|
|
143
83
|
//#endregion
|
|
144
84
|
export { NewItemId, SelectAllItemId, useSelectItems };
|