@vuu-ui/vuu-ui-controls 4.0.0-alpha.2 → 4.0.0-alpha.20
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/package.json +11 -10
- package/src/index.js +0 -1
- package/src/item-picker/ItemPicker.css.js +0 -4
- package/src/item-picker/ItemPicker.js +69 -60
- package/src/item-picker/useItemPicker.js +2 -5
- package/src/time-input/MaskedInput.js +176 -156
- package/src/time-input/TimeInput.css.js +41 -18
- package/src/time-input/TimeInput.js +25 -14
- package/src/time-input/useTimeInput.js +57 -47
- package/src/vuu-date-picker/VuuDatePicker.js +46 -52
- package/src/vuu-time-picker/VuuTimePicker.js +6 -5
- package/types/index.d.ts +3 -4
- package/types/item-picker/ItemPicker.d.ts +25 -7
- package/types/item-picker/useItemPicker.d.ts +4 -7
- package/types/modal-provider/ModalProvider.d.ts +1 -1
- package/types/time-input/MaskedInput.d.ts +60 -10
- package/types/time-input/TimeInput.d.ts +4 -3
- package/types/time-input/useTimeInput.d.ts +24 -5
- package/types/vuu-date-picker/VuuDatePicker.d.ts +19 -3
- package/types/vuu-time-picker/VuuTimePicker.d.ts +8 -6
- package/src/modal-provider/ModalProvider.js +0 -147
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.0.0-alpha.
|
|
2
|
+
"version": "4.0.0-alpha.20",
|
|
3
3
|
"description": "VUU UI Controls",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"author": "heswell",
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
"type-defs": "node ../../scripts/build-type-defs.mjs"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@vuu-ui/vuu-data-types": "4.0.0-alpha.
|
|
15
|
-
"@vuu-ui/vuu-protocol-types": "4.0.0-alpha.
|
|
16
|
-
"@vuu-ui/vuu-table-types": "4.0.0-alpha.
|
|
14
|
+
"@vuu-ui/vuu-data-types": "4.0.0-alpha.20",
|
|
15
|
+
"@vuu-ui/vuu-protocol-types": "4.0.0-alpha.20",
|
|
16
|
+
"@vuu-ui/vuu-table-types": "4.0.0-alpha.20"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@vuu-ui/vuu-context-menu": "4.0.0-alpha.
|
|
20
|
-
"@vuu-ui/vuu-data-react": "4.0.0-alpha.
|
|
21
|
-
"@vuu-ui/vuu-popups": "4.0.0-alpha.
|
|
22
|
-
"@vuu-ui/vuu-table": "4.0.0-alpha.
|
|
23
|
-
"@vuu-ui/vuu-utils": "4.0.0-alpha.
|
|
19
|
+
"@vuu-ui/vuu-context-menu": "4.0.0-alpha.20",
|
|
20
|
+
"@vuu-ui/vuu-data-react": "4.0.0-alpha.20",
|
|
21
|
+
"@vuu-ui/vuu-popups": "4.0.0-alpha.20",
|
|
22
|
+
"@vuu-ui/vuu-table": "4.0.0-alpha.20",
|
|
23
|
+
"@vuu-ui/vuu-utils": "4.0.0-alpha.20",
|
|
24
24
|
"@salt-ds/core": "1.67.0",
|
|
25
25
|
"@salt-ds/icons": "1.16.0",
|
|
26
26
|
"@salt-ds/styles": "0.2.1",
|
|
@@ -42,8 +42,9 @@
|
|
|
42
42
|
],
|
|
43
43
|
"exports": {
|
|
44
44
|
".": {
|
|
45
|
+
"types": "./types/index.d.ts",
|
|
45
46
|
"import": "./src/index.js",
|
|
46
|
-
"
|
|
47
|
+
"default": "./src/index.js"
|
|
47
48
|
}
|
|
48
49
|
},
|
|
49
50
|
"module": "./src/index.js",
|
package/src/index.js
CHANGED
|
@@ -25,7 +25,6 @@ export * from "./vuu-typeahead-input/index.js";
|
|
|
25
25
|
export { ContextPanelProvider, useContextPanel, useHideContextPanel } from "./context-panel-provider/ContextPanelProvider.js";
|
|
26
26
|
export { HoverOverlay } from "./hover-overlay/HoverOverlay.js";
|
|
27
27
|
export { ItemPicker } from "./item-picker/ItemPicker.js";
|
|
28
|
-
export { ModalProvider, useModal } from "./modal-provider/ModalProvider.js";
|
|
29
28
|
export { Prompt } from "./prompt/Prompt.js";
|
|
30
29
|
export { SortableList, SortableOption } from "./sortable-list/SortableList.js";
|
|
31
30
|
export { TimeInput } from "./time-input/TimeInput.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Input, ListBox, Option } from "@salt-ds/core";
|
|
3
3
|
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
4
4
|
import { useWindow } from "@salt-ds/window";
|
|
5
5
|
import { applyHighlighting } from "@vuu-ui/vuu-table";
|
|
@@ -32,7 +32,7 @@ const useSorting = (id, index)=>{
|
|
|
32
32
|
ref
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
-
const
|
|
35
|
+
const DefaultSelectedListItem = ({ className: classNameProp, index, item, onRemove, searchPattern = "", ...optionProps })=>{
|
|
36
36
|
const { handleRef, ref } = useSorting(item.name, index);
|
|
37
37
|
const value = getItemLabel(item);
|
|
38
38
|
const valueWithHighlighting = applyHighlighting(value, searchPattern);
|
|
@@ -73,7 +73,7 @@ const SelectedListItem = ({ className: classNameProp, index, item, onRemove, sea
|
|
|
73
73
|
]
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
|
-
const
|
|
76
|
+
const DefaultAvailableListItem = ({ className: classNameProp, index, item, onAdd, searchPattern = "", disabled, ...optionProps })=>{
|
|
77
77
|
const value = getItemLabel(item);
|
|
78
78
|
const valueWithHighlighting = applyHighlighting(value, searchPattern);
|
|
79
79
|
return /*#__PURE__*/ jsxs(Option, {
|
|
@@ -98,7 +98,14 @@ const AvailableListItem = ({ className: classNameProp, index, item, onAdd, searc
|
|
|
98
98
|
]
|
|
99
99
|
});
|
|
100
100
|
};
|
|
101
|
-
const
|
|
101
|
+
const getOptionName = (option)=>{
|
|
102
|
+
if (option) {
|
|
103
|
+
const { name } = option.dataset;
|
|
104
|
+
if (name) return name;
|
|
105
|
+
}
|
|
106
|
+
throw Error("[ItemPicker] list option has no data-name");
|
|
107
|
+
};
|
|
108
|
+
const ItemPicker_ItemPicker = /*#__PURE__*/ forwardRef(function({ AvailableListItem = DefaultAvailableListItem, SelectedListItem = DefaultSelectedListItem, className, itemTypeName = 'Item', searchForm = true, allItems, layout = 'v-selected-available', selectedItems, maxSelections, onSelectedItemsChange, onSelectionChange, selected = NO_SELECTION, ...htmlAttributes }, forwardedRef) {
|
|
102
109
|
const targetWindow = useWindow();
|
|
103
110
|
useComponentCssInjection({
|
|
104
111
|
testId: "vuu-item-picker",
|
|
@@ -117,13 +124,6 @@ const ItemPicker_ItemPicker = /*#__PURE__*/ forwardRef(function({ className, ite
|
|
|
117
124
|
maxSelections
|
|
118
125
|
});
|
|
119
126
|
const listRef = useRef(null);
|
|
120
|
-
const getOptionName = (option)=>{
|
|
121
|
-
if (option) {
|
|
122
|
-
const { name } = option.dataset;
|
|
123
|
-
if (name) return name;
|
|
124
|
-
}
|
|
125
|
-
throw Error("[ItemPicker] list option has no data-name");
|
|
126
|
-
};
|
|
127
127
|
const handleDragEnd = useCallback(()=>{
|
|
128
128
|
setTimeout(()=>{
|
|
129
129
|
const listItems = listRef.current?.querySelectorAll(".saltOption");
|
|
@@ -133,13 +133,56 @@ const ItemPicker_ItemPicker = /*#__PURE__*/ forwardRef(function({ className, ite
|
|
|
133
133
|
}
|
|
134
134
|
}, 300);
|
|
135
135
|
}, [
|
|
136
|
-
|
|
137
|
-
selectedItemsFiltered
|
|
136
|
+
onReorderSelectedItems
|
|
138
137
|
]);
|
|
139
138
|
const searchPlaceholderText = `Find ${singularForm(itemTypeName)}`;
|
|
140
139
|
const maxSelectionsSubHeading = maxSelections ? `(${maxSelections} max)` : "";
|
|
141
140
|
const selectedItemsHeading = `${selectedItemsCount} ${1 === selectedItemsCount ? singularForm(itemTypeName) : pluralForm(itemTypeName)} in view ${maxSelectionsSubHeading}`;
|
|
142
141
|
const availableItemsHeading = `${availableItemsCount} available ${1 === availableItemsCount ? singularForm(itemTypeName) : pluralForm(itemTypeName)}`;
|
|
142
|
+
const selectedList = /*#__PURE__*/ jsxs(Fragment, {
|
|
143
|
+
children: [
|
|
144
|
+
/*#__PURE__*/ jsx("div", {
|
|
145
|
+
className: `${classBase}-sectionHeader`,
|
|
146
|
+
children: selectedItemsHeading
|
|
147
|
+
}),
|
|
148
|
+
/*#__PURE__*/ jsx(DragDropProvider, {
|
|
149
|
+
onDragEnd: handleDragEnd,
|
|
150
|
+
children: /*#__PURE__*/ jsx(ListBox, {
|
|
151
|
+
className: `${classBase}-selectedList`,
|
|
152
|
+
onSelectionChange: onSelectionChange,
|
|
153
|
+
ref: listRef,
|
|
154
|
+
selected: selected,
|
|
155
|
+
children: selectedItemsFiltered.map((item, index)=>/*#__PURE__*/ jsx(SelectedListItem, {
|
|
156
|
+
item: item,
|
|
157
|
+
index: index,
|
|
158
|
+
onRemove: onRemoveItemFromSelectedList,
|
|
159
|
+
searchPattern: searchText.toLowerCase(),
|
|
160
|
+
value: item
|
|
161
|
+
}, item.name))
|
|
162
|
+
})
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
});
|
|
166
|
+
const availableList = /*#__PURE__*/ jsxs(Fragment, {
|
|
167
|
+
children: [
|
|
168
|
+
/*#__PURE__*/ jsx("div", {
|
|
169
|
+
className: clsx(`${classBase}-sectionHeader`, `${classBase}-availableHeader`),
|
|
170
|
+
children: availableItemsHeading
|
|
171
|
+
}),
|
|
172
|
+
/*#__PURE__*/ jsx(ListBox, {
|
|
173
|
+
className: `${classBase}-availableList`,
|
|
174
|
+
selected: NO_SELECTION,
|
|
175
|
+
children: availableItemsFiltered.map((item, index)=>/*#__PURE__*/ jsx(AvailableListItem, {
|
|
176
|
+
item: item,
|
|
177
|
+
index: index,
|
|
178
|
+
onAdd: onAddItemToSelectedList,
|
|
179
|
+
searchPattern: searchText.toLowerCase(),
|
|
180
|
+
value: item,
|
|
181
|
+
disabled: selectedItemsCount === maxSelections
|
|
182
|
+
}, item.name))
|
|
183
|
+
})
|
|
184
|
+
]
|
|
185
|
+
});
|
|
143
186
|
return /*#__PURE__*/ jsxs("div", {
|
|
144
187
|
...htmlAttributes,
|
|
145
188
|
className: clsx(classBase, className),
|
|
@@ -166,54 +209,20 @@ const ItemPicker_ItemPicker = /*#__PURE__*/ forwardRef(function({ className, ite
|
|
|
166
209
|
onChange: onChangeSearchInput
|
|
167
210
|
})
|
|
168
211
|
}),
|
|
169
|
-
/*#__PURE__*/
|
|
212
|
+
/*#__PURE__*/ jsx("div", {
|
|
170
213
|
className: `${classBase}-scrollContainer vuuScrollable`,
|
|
171
|
-
children:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
ref: listRef,
|
|
182
|
-
selected: selected,
|
|
183
|
-
children: selectedItemsFiltered.map((item, index)=>/*#__PURE__*/ jsx(SelectedListItem, {
|
|
184
|
-
item: item,
|
|
185
|
-
index: index,
|
|
186
|
-
onRemove: onRemoveItemFromSelectedList,
|
|
187
|
-
searchPattern: searchText.toLowerCase(),
|
|
188
|
-
value: item
|
|
189
|
-
}, item.name))
|
|
190
|
-
})
|
|
191
|
-
}),
|
|
192
|
-
/*#__PURE__*/ jsx("div", {
|
|
193
|
-
className: clsx(`${classBase}-sectionHeader`, `${classBase}-availableHeader`),
|
|
194
|
-
children: availableItemsHeading
|
|
195
|
-
}),
|
|
196
|
-
/*#__PURE__*/ jsx(ListBox, {
|
|
197
|
-
className: `${classBase}-availableList`,
|
|
198
|
-
selected: NO_SELECTION,
|
|
199
|
-
children: availableItemsFiltered.map((item, index)=>/*#__PURE__*/ jsx(AvailableListItem, {
|
|
200
|
-
item: item,
|
|
201
|
-
index: index,
|
|
202
|
-
onAdd: onAddItemToSelectedList,
|
|
203
|
-
searchPattern: searchText.toLowerCase(),
|
|
204
|
-
value: item,
|
|
205
|
-
disabled: selectedItemsCount === maxSelections
|
|
206
|
-
}, item.name))
|
|
207
|
-
})
|
|
208
|
-
]
|
|
209
|
-
}),
|
|
210
|
-
createCustomItemProps ? /*#__PURE__*/ jsx("div", {
|
|
211
|
-
className: `${classBase}-item-buttons`,
|
|
212
|
-
children: /*#__PURE__*/ jsx(Button, {
|
|
213
|
-
onClick: createCustomItemProps.onClickCreateCustomItem,
|
|
214
|
-
children: createCustomItemProps.buttonLabel
|
|
214
|
+
children: 'v-selected-available' === layout ? /*#__PURE__*/ jsxs(Fragment, {
|
|
215
|
+
children: [
|
|
216
|
+
selectedList,
|
|
217
|
+
availableList
|
|
218
|
+
]
|
|
219
|
+
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
220
|
+
children: [
|
|
221
|
+
availableList,
|
|
222
|
+
selectedList
|
|
223
|
+
]
|
|
215
224
|
})
|
|
216
|
-
})
|
|
225
|
+
})
|
|
217
226
|
]
|
|
218
227
|
});
|
|
219
228
|
});
|
|
@@ -55,10 +55,7 @@ const useItemPicker = ({ allItems, selectedItems, maxSelections, onSelectedItems
|
|
|
55
55
|
selectedItems,
|
|
56
56
|
onSelectedItemsChange
|
|
57
57
|
]);
|
|
58
|
-
const getSelectedItemsFiltered =
|
|
59
|
-
selectedItems,
|
|
60
|
-
searchPattern
|
|
61
|
-
]);
|
|
58
|
+
const getSelectedItemsFiltered = (latestSelectedItems, latestSearchPattern)=>filterItems(latestSelectedItems, latestSearchPattern);
|
|
62
59
|
const getAvailableItemsFiltered = useMemo(()=>filterItems(allItems, searchPattern).filter(({ name })=>-1 === selectedItems.findIndex((item)=>item.name === name)).toSorted(byItemName), [
|
|
63
60
|
allItems,
|
|
64
61
|
selectedItems,
|
|
@@ -71,7 +68,7 @@ const useItemPicker = ({ allItems, selectedItems, maxSelections, onSelectedItems
|
|
|
71
68
|
return {
|
|
72
69
|
selectedItemsCount: selectedItems.length,
|
|
73
70
|
availableItemsCount: getAvailableItemsCount,
|
|
74
|
-
selectedItemsFiltered: getSelectedItemsFiltered,
|
|
71
|
+
selectedItemsFiltered: getSelectedItemsFiltered(selectedItems, searchPattern),
|
|
75
72
|
availableItemsFiltered: getAvailableItemsFiltered,
|
|
76
73
|
searchText: searchPattern,
|
|
77
74
|
onChangeSearchInput: handleChangeSearchInput,
|