@eightshift/ui-components 5.0.10 → 5.1.0
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/{Collection-uTAXq9Br.js → Collection-BRJOMbOa.js} +12 -7
- package/dist/{Dialog-CmAxaSUv.js → Dialog-D6EdDPeu.js} +8 -8
- package/dist/{useFormValidation-Dy0PXJg5.js → Form-Bnyyv3Im.js} +6 -4
- package/dist/{Group-DDPhPPTQ.js → Group-LBogWgyp.js} +2 -2
- package/dist/{Input-BmDS8Juy.js → Input-DfSBLhDx.js} +1 -1
- package/dist/List-BLeHBkfx.js +590 -0
- package/dist/{ListBox-_nDFq8-H.js → ListBox-BY3gwI8c.js} +3 -3
- package/dist/Select-BebwUgKB.js +764 -0
- package/dist/Separator-CTQWg_HO.js +1111 -0
- package/dist/TextField-o2U-uBWv.js +133 -0
- package/dist/assets/style-admin.css +268 -150
- package/dist/assets/style-editor.css +268 -150
- package/dist/assets/style.css +268 -150
- package/dist/assets/wp-font-enhancements.css +1 -1
- package/dist/assets/wp-ui-enhancements.css +1 -1
- package/dist/components/breakpoint-preview/breakpoint-preview.js +3 -4
- package/dist/components/button/button.js +3 -3
- package/dist/components/checkbox/checkbox.js +1 -2
- package/dist/components/color-pickers/color-picker.js +7 -9
- package/dist/components/color-pickers/color-swatch.js +1 -1
- package/dist/components/color-pickers/gradient-editor.js +19 -25
- package/dist/components/color-pickers/solid-color-picker.js +27 -27
- package/dist/components/component-toggle/component-toggle.js +1 -1
- package/dist/components/draggable/draggable-handle.js +2 -2
- package/dist/components/draggable/draggable.js +5 -5
- package/dist/components/draggable-list/draggable-list-item.js +2 -2
- package/dist/components/draggable-list/draggable-list.js +5 -5
- package/dist/components/expandable/expandable.js +1 -1
- package/dist/components/index.js +5 -5
- package/dist/components/input-field/input-field.js +13 -129
- package/dist/components/item-collection/item-collection.js +1 -1
- package/dist/components/link-input/link-input.js +1463 -17
- package/dist/components/matrix-align/matrix-align.js +11 -14
- package/dist/components/menu/menu.js +4 -8
- package/dist/components/modal/modal.js +3 -3
- package/dist/components/number-picker/number-picker.js +9 -10
- package/dist/components/option-select/option-select.js +140 -156
- package/dist/components/placeholders/file-placeholder.js +1 -1
- package/dist/components/placeholders/image-placeholder.js +3 -3
- package/dist/components/placeholders/media-placeholder.js +2 -2
- package/dist/components/popover/popover.js +10 -5
- package/dist/components/radio/radio.js +4 -5
- package/dist/components/repeater/repeater-item.js +1 -1
- package/dist/components/repeater/repeater.js +6 -6
- package/dist/components/responsive/mini-responsive.js +45 -47
- package/dist/components/responsive/responsive-legacy.js +51 -55
- package/dist/components/responsive/responsive.js +47 -49
- package/dist/components/responsive-preview/responsive-preview.js +12 -15
- package/dist/components/select/async-multi-select.js +4 -4
- package/dist/components/select/async-single-select.js +1 -1
- package/dist/components/select/multi-select-components.js +1 -1
- package/dist/components/select/multi-select.js +4 -4
- package/dist/components/select/shared.js +2 -2
- package/dist/components/select/single-select.js +1 -1
- package/dist/components/select/styles.js +3 -3
- package/dist/components/select/v2/async-select.js +215 -158
- package/dist/components/select/v2/shared.js +29 -20
- package/dist/components/select/v2/single-select.js +202 -851
- package/dist/components/slider/column-config-slider.js +2 -2
- package/dist/components/slider/slider.js +2 -2
- package/dist/components/slider/utils.js +1 -1
- package/dist/components/tabs/tabs.js +7 -8
- package/dist/components/toggle/switch.js +4 -3
- package/dist/components/toggle-button/toggle-button.js +1 -1
- package/dist/{default-i18n-CT_oS1Fy.js → default-i18n-OFa3zAyB.js} +5 -9
- package/dist/icons/jsx-svg.js +3 -4
- package/dist/index.js +4 -4
- package/dist/{multi-select-components-Sp-JEFEX.js → multi-select-components-BcKzA24f.js} +3 -3
- package/dist/{react-jsx-parser.min-DZCiis5V.js → react-jsx-parser.min-LF707GK8.js} +312 -332
- package/dist/useAsyncList-fLtZMvJO.js +420 -0
- package/dist/useFilter-BR5z1A4Q.js +50 -0
- package/dist/{useListState-9Hq_FiRF.js → useListState-BrZ2XvDS.js} +1 -1
- package/dist/{useNumberField-D0u2bh8g.js → useNumberField-y0dLc_6m.js} +2 -2
- package/dist/{useSingleSelectListState-DqhemUIh.js → useSingleSelectListState-Bh46cRXs.js} +1 -1
- package/dist/utilities/array-helpers.js +4 -7
- package/dist/utilities/es-dash.js +21 -3
- package/dist/utilities/index.js +2 -1
- package/dist/utilities/text-helpers.js +3 -3
- package/package.json +9 -9
- package/dist/ComboBox-BANSEKnb.js +0 -1915
- package/dist/Form-Cq3fu75_.js +0 -5
- package/dist/List-CZMUbkFU.js +0 -593
- package/dist/Separator-BN3mjL6q.js +0 -332
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import { useReducer, useRef, useEffect } from "react";
|
|
2
|
+
function $0d86e9c8f07f9a7b$export$79c0c687a5963b0a(opts, dispatch) {
|
|
3
|
+
let { cursor, getKey } = opts;
|
|
4
|
+
return {
|
|
5
|
+
setSelectedKeys(selectedKeys) {
|
|
6
|
+
dispatch((state) => ({
|
|
7
|
+
...state,
|
|
8
|
+
selectedKeys
|
|
9
|
+
}));
|
|
10
|
+
},
|
|
11
|
+
setFilterText(filterText) {
|
|
12
|
+
dispatch((state) => ({
|
|
13
|
+
...state,
|
|
14
|
+
filterText
|
|
15
|
+
}));
|
|
16
|
+
},
|
|
17
|
+
insert(index, ...values) {
|
|
18
|
+
dispatch((state) => $0d86e9c8f07f9a7b$var$insert(state, index, ...values));
|
|
19
|
+
},
|
|
20
|
+
insertBefore(key, ...values) {
|
|
21
|
+
dispatch((state) => {
|
|
22
|
+
let index = state.items.findIndex((item) => (getKey === null || getKey === void 0 ? void 0 : getKey(item)) === key);
|
|
23
|
+
if (index === -1) {
|
|
24
|
+
if (state.items.length === 0) index = 0;
|
|
25
|
+
else return state;
|
|
26
|
+
}
|
|
27
|
+
return $0d86e9c8f07f9a7b$var$insert(state, index, ...values);
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
insertAfter(key, ...values) {
|
|
31
|
+
dispatch((state) => {
|
|
32
|
+
let index = state.items.findIndex((item) => (getKey === null || getKey === void 0 ? void 0 : getKey(item)) === key);
|
|
33
|
+
if (index === -1) {
|
|
34
|
+
if (state.items.length === 0) index = 0;
|
|
35
|
+
else return state;
|
|
36
|
+
}
|
|
37
|
+
return $0d86e9c8f07f9a7b$var$insert(state, index + 1, ...values);
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
prepend(...values) {
|
|
41
|
+
dispatch((state) => $0d86e9c8f07f9a7b$var$insert(state, 0, ...values));
|
|
42
|
+
},
|
|
43
|
+
append(...values) {
|
|
44
|
+
dispatch((state) => $0d86e9c8f07f9a7b$var$insert(state, state.items.length, ...values));
|
|
45
|
+
},
|
|
46
|
+
remove(...keys) {
|
|
47
|
+
dispatch((state) => {
|
|
48
|
+
let keySet = new Set(keys);
|
|
49
|
+
let items = state.items.filter((item) => !keySet.has(getKey(item)));
|
|
50
|
+
let selection = "all";
|
|
51
|
+
if (state.selectedKeys !== "all") {
|
|
52
|
+
selection = new Set(state.selectedKeys);
|
|
53
|
+
for (let key of keys) selection.delete(key);
|
|
54
|
+
}
|
|
55
|
+
if (cursor == null && items.length === 0) selection = /* @__PURE__ */ new Set();
|
|
56
|
+
return {
|
|
57
|
+
...state,
|
|
58
|
+
items,
|
|
59
|
+
selectedKeys: selection
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
removeSelectedItems() {
|
|
64
|
+
dispatch((state) => {
|
|
65
|
+
if (state.selectedKeys === "all") return {
|
|
66
|
+
...state,
|
|
67
|
+
items: [],
|
|
68
|
+
selectedKeys: /* @__PURE__ */ new Set()
|
|
69
|
+
};
|
|
70
|
+
let selectedKeys = state.selectedKeys;
|
|
71
|
+
let items = state.items.filter((item) => !selectedKeys.has(getKey(item)));
|
|
72
|
+
return {
|
|
73
|
+
...state,
|
|
74
|
+
items,
|
|
75
|
+
selectedKeys: /* @__PURE__ */ new Set()
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
move(key, toIndex) {
|
|
80
|
+
dispatch((state) => {
|
|
81
|
+
let index = state.items.findIndex((item2) => getKey(item2) === key);
|
|
82
|
+
if (index === -1) return state;
|
|
83
|
+
let copy = state.items.slice();
|
|
84
|
+
let [item] = copy.splice(index, 1);
|
|
85
|
+
copy.splice(toIndex, 0, item);
|
|
86
|
+
return {
|
|
87
|
+
...state,
|
|
88
|
+
items: copy
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
moveBefore(key, keys) {
|
|
93
|
+
dispatch((state) => {
|
|
94
|
+
let toIndex = state.items.findIndex((item) => getKey(item) === key);
|
|
95
|
+
if (toIndex === -1) return state;
|
|
96
|
+
let keyArray = Array.isArray(keys) ? keys : [
|
|
97
|
+
...keys
|
|
98
|
+
];
|
|
99
|
+
let indices = keyArray.map((key2) => state.items.findIndex((item) => getKey(item) === key2)).sort((a, b) => a - b);
|
|
100
|
+
return $0d86e9c8f07f9a7b$var$move(state, indices, toIndex);
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
moveAfter(key, keys) {
|
|
104
|
+
dispatch((state) => {
|
|
105
|
+
let toIndex = state.items.findIndex((item) => getKey(item) === key);
|
|
106
|
+
if (toIndex === -1) return state;
|
|
107
|
+
let keyArray = Array.isArray(keys) ? keys : [
|
|
108
|
+
...keys
|
|
109
|
+
];
|
|
110
|
+
let indices = keyArray.map((key2) => state.items.findIndex((item) => getKey(item) === key2)).sort((a, b) => a - b);
|
|
111
|
+
return $0d86e9c8f07f9a7b$var$move(state, indices, toIndex + 1);
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
update(key, newValue) {
|
|
115
|
+
dispatch((state) => {
|
|
116
|
+
let index = state.items.findIndex((item) => getKey(item) === key);
|
|
117
|
+
if (index === -1) return state;
|
|
118
|
+
return {
|
|
119
|
+
...state,
|
|
120
|
+
items: [
|
|
121
|
+
...state.items.slice(0, index),
|
|
122
|
+
newValue,
|
|
123
|
+
...state.items.slice(index + 1)
|
|
124
|
+
]
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function $0d86e9c8f07f9a7b$var$insert(state, index, ...values) {
|
|
131
|
+
return {
|
|
132
|
+
...state,
|
|
133
|
+
items: [
|
|
134
|
+
...state.items.slice(0, index),
|
|
135
|
+
...values,
|
|
136
|
+
...state.items.slice(index)
|
|
137
|
+
]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function $0d86e9c8f07f9a7b$var$move(state, indices, toIndex) {
|
|
141
|
+
toIndex -= indices.filter((index) => index < toIndex).length;
|
|
142
|
+
let moves = indices.map((from) => ({
|
|
143
|
+
from,
|
|
144
|
+
to: toIndex++
|
|
145
|
+
}));
|
|
146
|
+
for (let i = 0; i < moves.length; i++) {
|
|
147
|
+
let a = moves[i].from;
|
|
148
|
+
for (let j = i; j < moves.length; j++) {
|
|
149
|
+
let b = moves[j].from;
|
|
150
|
+
if (b > a) moves[j].from--;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
for (let i = 0; i < moves.length; i++) {
|
|
154
|
+
let a = moves[i];
|
|
155
|
+
for (let j = moves.length - 1; j > i; j--) {
|
|
156
|
+
let b = moves[j];
|
|
157
|
+
if (b.from < a.to) a.to++;
|
|
158
|
+
else b.from++;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
let copy = state.items.slice();
|
|
162
|
+
for (let move of moves) {
|
|
163
|
+
let [item] = copy.splice(move.from, 1);
|
|
164
|
+
copy.splice(move.to, 0, item);
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
...state,
|
|
168
|
+
items: copy
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function $f86e6c1ec7da6ebb$var$reducer(data, action) {
|
|
172
|
+
let selectedKeys;
|
|
173
|
+
switch (data.state) {
|
|
174
|
+
case "idle":
|
|
175
|
+
case "error":
|
|
176
|
+
switch (action.type) {
|
|
177
|
+
case "loading":
|
|
178
|
+
case "loadingMore":
|
|
179
|
+
case "sorting":
|
|
180
|
+
case "filtering":
|
|
181
|
+
var _action_filterText, _action_sortDescriptor;
|
|
182
|
+
return {
|
|
183
|
+
...data,
|
|
184
|
+
filterText: (_action_filterText = action.filterText) !== null && _action_filterText !== void 0 ? _action_filterText : data.filterText,
|
|
185
|
+
state: action.type,
|
|
186
|
+
// Reset items to an empty list if loading, but not when sorting.
|
|
187
|
+
items: action.type === "loading" ? [] : data.items,
|
|
188
|
+
sortDescriptor: (_action_sortDescriptor = action.sortDescriptor) !== null && _action_sortDescriptor !== void 0 ? _action_sortDescriptor : data.sortDescriptor,
|
|
189
|
+
abortController: action.abortController
|
|
190
|
+
};
|
|
191
|
+
case "update":
|
|
192
|
+
var _action_updater;
|
|
193
|
+
return {
|
|
194
|
+
...data,
|
|
195
|
+
...(_action_updater = action.updater) === null || _action_updater === void 0 ? void 0 : _action_updater.call(action, data)
|
|
196
|
+
};
|
|
197
|
+
case "success":
|
|
198
|
+
case "error":
|
|
199
|
+
return data;
|
|
200
|
+
default:
|
|
201
|
+
throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
|
|
202
|
+
}
|
|
203
|
+
case "loading":
|
|
204
|
+
case "sorting":
|
|
205
|
+
case "filtering":
|
|
206
|
+
switch (action.type) {
|
|
207
|
+
case "success":
|
|
208
|
+
if (action.abortController !== data.abortController) return data;
|
|
209
|
+
var _action_selectedKeys;
|
|
210
|
+
selectedKeys = (_action_selectedKeys = action.selectedKeys) !== null && _action_selectedKeys !== void 0 ? _action_selectedKeys : data.selectedKeys;
|
|
211
|
+
var _action_filterText1, _action_items, _action_sortDescriptor1;
|
|
212
|
+
return {
|
|
213
|
+
...data,
|
|
214
|
+
filterText: (_action_filterText1 = action.filterText) !== null && _action_filterText1 !== void 0 ? _action_filterText1 : data.filterText,
|
|
215
|
+
state: "idle",
|
|
216
|
+
items: [
|
|
217
|
+
...(_action_items = action.items) !== null && _action_items !== void 0 ? _action_items : []
|
|
218
|
+
],
|
|
219
|
+
selectedKeys: selectedKeys === "all" ? "all" : new Set(selectedKeys),
|
|
220
|
+
sortDescriptor: (_action_sortDescriptor1 = action.sortDescriptor) !== null && _action_sortDescriptor1 !== void 0 ? _action_sortDescriptor1 : data.sortDescriptor,
|
|
221
|
+
abortController: void 0,
|
|
222
|
+
cursor: action.cursor
|
|
223
|
+
};
|
|
224
|
+
case "error":
|
|
225
|
+
if (action.abortController !== data.abortController) return data;
|
|
226
|
+
return {
|
|
227
|
+
...data,
|
|
228
|
+
state: "error",
|
|
229
|
+
error: action.error,
|
|
230
|
+
abortController: void 0
|
|
231
|
+
};
|
|
232
|
+
case "loading":
|
|
233
|
+
case "loadingMore":
|
|
234
|
+
case "sorting":
|
|
235
|
+
case "filtering":
|
|
236
|
+
var _data_abortController;
|
|
237
|
+
(_data_abortController = data.abortController) === null || _data_abortController === void 0 ? void 0 : _data_abortController.abort();
|
|
238
|
+
var _action_filterText2;
|
|
239
|
+
return {
|
|
240
|
+
...data,
|
|
241
|
+
filterText: (_action_filterText2 = action.filterText) !== null && _action_filterText2 !== void 0 ? _action_filterText2 : data.filterText,
|
|
242
|
+
state: action.type,
|
|
243
|
+
// Reset items to an empty list if loading, but not when sorting.
|
|
244
|
+
items: action.type === "loading" ? [] : data.items,
|
|
245
|
+
abortController: action.abortController
|
|
246
|
+
};
|
|
247
|
+
case "update":
|
|
248
|
+
var _action_updater1;
|
|
249
|
+
return {
|
|
250
|
+
...data,
|
|
251
|
+
...(_action_updater1 = action.updater) === null || _action_updater1 === void 0 ? void 0 : _action_updater1.call(action, data)
|
|
252
|
+
};
|
|
253
|
+
default:
|
|
254
|
+
throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
|
|
255
|
+
}
|
|
256
|
+
case "loadingMore":
|
|
257
|
+
switch (action.type) {
|
|
258
|
+
case "success":
|
|
259
|
+
var _action_selectedKeys1;
|
|
260
|
+
selectedKeys = data.selectedKeys === "all" || action.selectedKeys === "all" ? "all" : /* @__PURE__ */ new Set([
|
|
261
|
+
...data.selectedKeys,
|
|
262
|
+
...(_action_selectedKeys1 = action.selectedKeys) !== null && _action_selectedKeys1 !== void 0 ? _action_selectedKeys1 : []
|
|
263
|
+
]);
|
|
264
|
+
var _action_items1, _action_sortDescriptor2;
|
|
265
|
+
return {
|
|
266
|
+
...data,
|
|
267
|
+
state: "idle",
|
|
268
|
+
items: [
|
|
269
|
+
...data.items,
|
|
270
|
+
...(_action_items1 = action.items) !== null && _action_items1 !== void 0 ? _action_items1 : []
|
|
271
|
+
],
|
|
272
|
+
selectedKeys,
|
|
273
|
+
sortDescriptor: (_action_sortDescriptor2 = action.sortDescriptor) !== null && _action_sortDescriptor2 !== void 0 ? _action_sortDescriptor2 : data.sortDescriptor,
|
|
274
|
+
abortController: void 0,
|
|
275
|
+
cursor: action.cursor
|
|
276
|
+
};
|
|
277
|
+
case "error":
|
|
278
|
+
if (action.abortController !== data.abortController) return data;
|
|
279
|
+
return {
|
|
280
|
+
...data,
|
|
281
|
+
state: "error",
|
|
282
|
+
error: action.error
|
|
283
|
+
};
|
|
284
|
+
case "loading":
|
|
285
|
+
case "sorting":
|
|
286
|
+
case "filtering":
|
|
287
|
+
var _data_abortController1;
|
|
288
|
+
(_data_abortController1 = data.abortController) === null || _data_abortController1 === void 0 ? void 0 : _data_abortController1.abort();
|
|
289
|
+
var _action_filterText3;
|
|
290
|
+
return {
|
|
291
|
+
...data,
|
|
292
|
+
filterText: (_action_filterText3 = action.filterText) !== null && _action_filterText3 !== void 0 ? _action_filterText3 : data.filterText,
|
|
293
|
+
state: action.type,
|
|
294
|
+
// Reset items to an empty list if loading, but not when sorting.
|
|
295
|
+
items: action.type === "loading" ? [] : data.items,
|
|
296
|
+
abortController: action.abortController
|
|
297
|
+
};
|
|
298
|
+
case "loadingMore":
|
|
299
|
+
var _action_abortController;
|
|
300
|
+
(_action_abortController = action.abortController) === null || _action_abortController === void 0 ? void 0 : _action_abortController.abort();
|
|
301
|
+
return data;
|
|
302
|
+
case "update":
|
|
303
|
+
var _action_updater2;
|
|
304
|
+
return {
|
|
305
|
+
...data,
|
|
306
|
+
...(_action_updater2 = action.updater) === null || _action_updater2 === void 0 ? void 0 : _action_updater2.call(action, data)
|
|
307
|
+
};
|
|
308
|
+
default:
|
|
309
|
+
throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
|
|
310
|
+
}
|
|
311
|
+
default:
|
|
312
|
+
throw new Error(`Invalid state "${data.state}"`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
|
|
316
|
+
const { load, sort, initialSelectedKeys, initialSortDescriptor, getKey = (item) => item.id || item.key, initialFilterText = "" } = options;
|
|
317
|
+
let [data, dispatch] = useReducer($f86e6c1ec7da6ebb$var$reducer, {
|
|
318
|
+
state: "idle",
|
|
319
|
+
error: void 0,
|
|
320
|
+
items: [],
|
|
321
|
+
selectedKeys: initialSelectedKeys === "all" ? "all" : new Set(initialSelectedKeys),
|
|
322
|
+
sortDescriptor: initialSortDescriptor,
|
|
323
|
+
filterText: initialFilterText
|
|
324
|
+
});
|
|
325
|
+
const dispatchFetch = async (action, fn) => {
|
|
326
|
+
let abortController = new AbortController();
|
|
327
|
+
try {
|
|
328
|
+
dispatch({
|
|
329
|
+
...action,
|
|
330
|
+
abortController
|
|
331
|
+
});
|
|
332
|
+
var _action_filterText;
|
|
333
|
+
let previousFilterText = (_action_filterText = action.filterText) !== null && _action_filterText !== void 0 ? _action_filterText : data.filterText;
|
|
334
|
+
var _action_sortDescriptor;
|
|
335
|
+
let response = await fn({
|
|
336
|
+
items: data.items.slice(),
|
|
337
|
+
selectedKeys: data.selectedKeys,
|
|
338
|
+
sortDescriptor: (_action_sortDescriptor = action.sortDescriptor) !== null && _action_sortDescriptor !== void 0 ? _action_sortDescriptor : data.sortDescriptor,
|
|
339
|
+
signal: abortController.signal,
|
|
340
|
+
cursor: action.type === "loadingMore" ? data.cursor : void 0,
|
|
341
|
+
filterText: previousFilterText,
|
|
342
|
+
loadingState: data.state
|
|
343
|
+
});
|
|
344
|
+
var _response_filterText;
|
|
345
|
+
let filterText = (_response_filterText = response.filterText) !== null && _response_filterText !== void 0 ? _response_filterText : previousFilterText;
|
|
346
|
+
dispatch({
|
|
347
|
+
type: "success",
|
|
348
|
+
...response,
|
|
349
|
+
abortController
|
|
350
|
+
});
|
|
351
|
+
if (filterText && filterText !== previousFilterText && !abortController.signal.aborted) dispatchFetch({
|
|
352
|
+
type: "filtering",
|
|
353
|
+
filterText
|
|
354
|
+
}, load);
|
|
355
|
+
} catch (e) {
|
|
356
|
+
dispatch({
|
|
357
|
+
type: "error",
|
|
358
|
+
error: e,
|
|
359
|
+
abortController
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
let didDispatchInitialFetch = useRef(false);
|
|
364
|
+
useEffect(() => {
|
|
365
|
+
if (!didDispatchInitialFetch.current) {
|
|
366
|
+
dispatchFetch({
|
|
367
|
+
type: "loading"
|
|
368
|
+
}, load);
|
|
369
|
+
didDispatchInitialFetch.current = true;
|
|
370
|
+
}
|
|
371
|
+
}, []);
|
|
372
|
+
return {
|
|
373
|
+
items: data.items,
|
|
374
|
+
selectedKeys: data.selectedKeys,
|
|
375
|
+
sortDescriptor: data.sortDescriptor,
|
|
376
|
+
isLoading: data.state === "loading" || data.state === "loadingMore" || data.state === "sorting" || data.state === "filtering",
|
|
377
|
+
loadingState: data.state,
|
|
378
|
+
error: data.error,
|
|
379
|
+
filterText: data.filterText,
|
|
380
|
+
getItem(key) {
|
|
381
|
+
return data.items.find((item) => getKey(item) === key);
|
|
382
|
+
},
|
|
383
|
+
reload() {
|
|
384
|
+
dispatchFetch({
|
|
385
|
+
type: "loading"
|
|
386
|
+
}, load);
|
|
387
|
+
},
|
|
388
|
+
loadMore() {
|
|
389
|
+
if (data.state === "loadingMore" || data.state === "filtering" || data.cursor == null) return;
|
|
390
|
+
dispatchFetch({
|
|
391
|
+
type: "loadingMore"
|
|
392
|
+
}, load);
|
|
393
|
+
},
|
|
394
|
+
sort(sortDescriptor) {
|
|
395
|
+
dispatchFetch({
|
|
396
|
+
type: "sorting",
|
|
397
|
+
sortDescriptor
|
|
398
|
+
}, sort || load);
|
|
399
|
+
},
|
|
400
|
+
...$0d86e9c8f07f9a7b$export$79c0c687a5963b0a({
|
|
401
|
+
...options,
|
|
402
|
+
getKey,
|
|
403
|
+
cursor: data.cursor
|
|
404
|
+
}, (fn) => {
|
|
405
|
+
dispatch({
|
|
406
|
+
type: "update",
|
|
407
|
+
updater: fn
|
|
408
|
+
});
|
|
409
|
+
}),
|
|
410
|
+
setFilterText(filterText) {
|
|
411
|
+
dispatchFetch({
|
|
412
|
+
type: "filtering",
|
|
413
|
+
filterText
|
|
414
|
+
}, load);
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
export {
|
|
419
|
+
$f86e6c1ec7da6ebb$export$bc3384a35de93d66 as $
|
|
420
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { d as $325a3faab7a68acd$export$a16aca283550c30d } from "./Separator-CTQWg_HO.js";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
|
+
function $bb77f239b46e8c72$export$3274cf84b703fff(options) {
|
|
4
|
+
let collator = $325a3faab7a68acd$export$a16aca283550c30d({
|
|
5
|
+
usage: "search",
|
|
6
|
+
...options
|
|
7
|
+
});
|
|
8
|
+
let startsWith = useCallback((string, substring) => {
|
|
9
|
+
if (substring.length === 0) return true;
|
|
10
|
+
string = string.normalize("NFC");
|
|
11
|
+
substring = substring.normalize("NFC");
|
|
12
|
+
return collator.compare(string.slice(0, substring.length), substring) === 0;
|
|
13
|
+
}, [
|
|
14
|
+
collator
|
|
15
|
+
]);
|
|
16
|
+
let endsWith = useCallback((string, substring) => {
|
|
17
|
+
if (substring.length === 0) return true;
|
|
18
|
+
string = string.normalize("NFC");
|
|
19
|
+
substring = substring.normalize("NFC");
|
|
20
|
+
return collator.compare(string.slice(-substring.length), substring) === 0;
|
|
21
|
+
}, [
|
|
22
|
+
collator
|
|
23
|
+
]);
|
|
24
|
+
let contains = useCallback((string, substring) => {
|
|
25
|
+
if (substring.length === 0) return true;
|
|
26
|
+
string = string.normalize("NFC");
|
|
27
|
+
substring = substring.normalize("NFC");
|
|
28
|
+
let scan = 0;
|
|
29
|
+
let sliceLen = substring.length;
|
|
30
|
+
for (; scan + sliceLen <= string.length; scan++) {
|
|
31
|
+
let slice = string.slice(scan, scan + sliceLen);
|
|
32
|
+
if (collator.compare(substring, slice) === 0) return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}, [
|
|
36
|
+
collator
|
|
37
|
+
]);
|
|
38
|
+
return useMemo(() => ({
|
|
39
|
+
startsWith,
|
|
40
|
+
endsWith,
|
|
41
|
+
contains
|
|
42
|
+
}), [
|
|
43
|
+
startsWith,
|
|
44
|
+
endsWith,
|
|
45
|
+
contains
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
$bb77f239b46e8c72$export$3274cf84b703fff as $
|
|
50
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { version, useMemo, useCallback, useRef, useEffect } from "react";
|
|
2
|
-
import { $ as $7af3f5b51489e0b5$export$253fe78d46329472, a as $7613b1592d41b092$export$6cd28814d92fa9c9, b as $d496c0a20b6e58ec$export$6c8a5aaad13c9852 } from "./Collection-
|
|
2
|
+
import { $ as $7af3f5b51489e0b5$export$253fe78d46329472, a as $7613b1592d41b092$export$6cd28814d92fa9c9, b as $d496c0a20b6e58ec$export$6c8a5aaad13c9852 } from "./Collection-BRJOMbOa.js";
|
|
3
3
|
function $cdc5a6778b766db2$export$a9d04c5684123369(value) {
|
|
4
4
|
const pieces = version.split(".");
|
|
5
5
|
const major = parseInt(pieces[0], 10);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { b as $458b0a5536c1a7cf$export$40bfa8c7b0832715, g as $03deb23ff14920c4$export$4eaf04e54aa8eed6, p as $a1ea59d68270f0dd$export$f8168d8dd8fd66e6, L as $c87311424ea30a05$export$186c6964ca17d99, v as $c87311424ea30a05$export$a11b0059900ceec8, c as $c87311424ea30a05$export$fedb369cb70207f1 } from "./useHover-C2SkI1Fn.js";
|
|
2
2
|
import { a as $9446cca9a3875146$export$cb6e0bb50bc19463, $ as $9446cca9a3875146$export$7d15b64cf5a3a4c4 } from "./number-CHmNj-oR.js";
|
|
3
|
-
import {
|
|
3
|
+
import { a as $e5be200c675c3b3a$export$fc1a364ae1f3ff10, c as $e5be200c675c3b3a$export$a763b9476acd3eb } from "./Form-Bnyyv3Im.js";
|
|
4
4
|
import { $ as $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 } from "./NumberFormatter-DA8u1Ot7.js";
|
|
5
5
|
import { useCallback, useState, useMemo, useEffect, useRef } from "react";
|
|
6
6
|
import { f as $8ae05eaa5c114e9c$export$7f54fc3180508a52, d as $3ef42575df84b30b$export$9d1611c77c2fe928, e as $bdb11010cef70236$export$f680877a34711e37, p as $ff5963eb1fccf552$export$e08e3b67e392101e } from "./utils-CZt7LCbO.js";
|
|
@@ -8,7 +8,7 @@ import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "./filterDOMProps
|
|
|
8
8
|
import { $ as $99facab73266f662$export$5add1d006293d136 } from "./useFormReset-D2YaWRIA.js";
|
|
9
9
|
import { a as $9ab94262bd0047c7$export$420e68273165f4ec } from "./useFocusRing-Bv0UJQl8.js";
|
|
10
10
|
import { $ as $e9faafb641e167db$export$90fc3a17d93f704c } from "./useEvent-ICdlokG-.js";
|
|
11
|
-
import { b as $2d73ec29415bd339$export$712718f7aec83d5 } from "./Input-
|
|
11
|
+
import { b as $2d73ec29415bd339$export$712718f7aec83d5 } from "./Input-DfSBLhDx.js";
|
|
12
12
|
import { $ as $fca6afa0e843324b$export$f12b703ca79dfbb1 } from "./useLocalizedStringFormatter-C9GO0IDB.js";
|
|
13
13
|
import { $ as $a916eb452884faea$export$b7a616150fdb9f44 } from "./useNumberFormatter-CZ9QUnRt.js";
|
|
14
14
|
import { d as $319e236875307eab$export$d10ae4f68404609a, c as $319e236875307eab$export$a9b970dcc4ae71a9 } from "./Button-DH22t_SM.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as $e72dd72e1c76a225$export$2f645645f7bca764 } from "./useListState-
|
|
1
|
+
import { $ as $e72dd72e1c76a225$export$2f645645f7bca764 } from "./useListState-BrZ2XvDS.js";
|
|
2
2
|
import { b as $458b0a5536c1a7cf$export$40bfa8c7b0832715 } from "./useHover-C2SkI1Fn.js";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
4
|
function $a0d645289fe9b86b$export$e7f05e985daf4b5f(props) {
|
|
@@ -36,13 +36,10 @@ const arrayMoveMultiple = (array, fromIndices, to, direction = "before") => {
|
|
|
36
36
|
* @preserve
|
|
37
37
|
*/
|
|
38
38
|
const fixIds = (items, onChange, idKey = "id") => {
|
|
39
|
-
const allIds =
|
|
40
|
-
const hasDuplicates = (input) =>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
const hasMissingIds = items == null ? void 0 : items.some((item) => typeof (item == null ? void 0 : item[idKey]) === "undefined" || (item == null ? void 0 : item[idKey]) === null || (item == null ? void 0 : item[idKey]) === "");
|
|
45
|
-
if (hasDuplicates(allIds) && (items == null ? void 0 : items.length) > 0 || hasMissingIds) {
|
|
39
|
+
const allIds = items?.map((item) => item?.[idKey]) ?? [];
|
|
40
|
+
const hasDuplicates = (input) => new Set(input)?.size !== input?.length;
|
|
41
|
+
const hasMissingIds = items?.some((item) => typeof item?.[idKey] === "undefined" || item?.[idKey] === null || item?.[idKey] === "");
|
|
42
|
+
if (hasDuplicates(allIds) && items?.length > 0 || hasMissingIds) {
|
|
46
43
|
const newItems = [...items].map((item, index) => ({
|
|
47
44
|
...item,
|
|
48
45
|
[idKey]: index + 1
|
|
@@ -221,7 +221,7 @@ const lowerFirst = (input) => {
|
|
|
221
221
|
if (typeof input !== "string") {
|
|
222
222
|
input = String(input);
|
|
223
223
|
}
|
|
224
|
-
if (
|
|
224
|
+
if (input?.length < 2) {
|
|
225
225
|
return input.toLowerCase();
|
|
226
226
|
}
|
|
227
227
|
return input.charAt(0).toLowerCase() + input.slice(1);
|
|
@@ -319,8 +319,8 @@ const isEqual = (first, second) => {
|
|
|
319
319
|
if ((first === void 0 || second === void 0 || first === null || second === null) && (first || second)) {
|
|
320
320
|
return false;
|
|
321
321
|
}
|
|
322
|
-
const firstType = first
|
|
323
|
-
const secondType = second
|
|
322
|
+
const firstType = first?.constructor.name;
|
|
323
|
+
const secondType = second?.constructor.name;
|
|
324
324
|
if (firstType !== secondType) {
|
|
325
325
|
return false;
|
|
326
326
|
}
|
|
@@ -367,6 +367,23 @@ const isEqual = (first, second) => {
|
|
|
367
367
|
}
|
|
368
368
|
return first === second;
|
|
369
369
|
};
|
|
370
|
+
/**
|
|
371
|
+
* Checks if value is the language type of `String`.
|
|
372
|
+
*
|
|
373
|
+
* @param {*} value - Value to check.
|
|
374
|
+
* @returns {boolean} true if value is a string, false otherwise.
|
|
375
|
+
*
|
|
376
|
+
* Usage:
|
|
377
|
+
* ```js
|
|
378
|
+
* isString('Lorem') // => true
|
|
379
|
+
* isString(2) // => false
|
|
380
|
+
* isString([]) // => false
|
|
381
|
+
* isString(new String('Lorem')) // => false
|
|
382
|
+
* ```
|
|
383
|
+
*
|
|
384
|
+
* @preserve
|
|
385
|
+
*/
|
|
386
|
+
const isString = (value) => typeof value === "string" || value instanceof String;
|
|
370
387
|
export {
|
|
371
388
|
camelCase,
|
|
372
389
|
has,
|
|
@@ -374,6 +391,7 @@ export {
|
|
|
374
391
|
isEqual,
|
|
375
392
|
isObject,
|
|
376
393
|
isPlainObject,
|
|
394
|
+
isString,
|
|
377
395
|
kebabCase,
|
|
378
396
|
lowerFirst,
|
|
379
397
|
pascalCase,
|
package/dist/utilities/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { arrayMoveMultiple, fixIds } from "./array-helpers.js";
|
|
2
|
-
import { camelCase, has, isEmpty, isEqual, isObject, isPlainObject, kebabCase, lowerFirst, pascalCase, snakeCase, upperFirst } from "./es-dash.js";
|
|
2
|
+
import { camelCase, has, isEmpty, isEqual, isObject, isPlainObject, isString, kebabCase, lowerFirst, pascalCase, snakeCase, upperFirst } from "./es-dash.js";
|
|
3
3
|
import { truncate, truncateEnd, truncateMiddle, unescapeHTML } from "./text-helpers.js";
|
|
4
4
|
import { debounce, throttle } from "./debounce-throttle.js";
|
|
5
5
|
import { c } from "../lite-DVmmD_-j.js";
|
|
@@ -14,6 +14,7 @@ export {
|
|
|
14
14
|
isEqual,
|
|
15
15
|
isObject,
|
|
16
16
|
isPlainObject,
|
|
17
|
+
isString,
|
|
17
18
|
kebabCase,
|
|
18
19
|
lowerFirst,
|
|
19
20
|
pascalCase,
|
|
@@ -24,7 +24,7 @@ const truncateMiddle = (input, maxLength, separator = "...") => {
|
|
|
24
24
|
if (!input) {
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
|
-
if (
|
|
27
|
+
if (input?.length <= maxLength) {
|
|
28
28
|
return input;
|
|
29
29
|
}
|
|
30
30
|
if (separator.length + 1 > maxLength) {
|
|
@@ -81,7 +81,7 @@ const truncate = (input, maxLength, separator = "...") => {
|
|
|
81
81
|
if (!input) {
|
|
82
82
|
return null;
|
|
83
83
|
}
|
|
84
|
-
if (
|
|
84
|
+
if (input?.length <= maxLength) {
|
|
85
85
|
return input;
|
|
86
86
|
}
|
|
87
87
|
if (separator.length + 1 > maxLength) {
|
|
@@ -117,7 +117,7 @@ const truncateEnd = (input, maxLength, separator = "...") => {
|
|
|
117
117
|
if (!input) {
|
|
118
118
|
return null;
|
|
119
119
|
}
|
|
120
|
-
if (
|
|
120
|
+
if (input?.length <= maxLength) {
|
|
121
121
|
return input;
|
|
122
122
|
}
|
|
123
123
|
if (separator.length + 1 > maxLength) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eightshift/ui-components",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -52,22 +52,22 @@
|
|
|
52
52
|
"@dnd-kit/react": "^0.1.19",
|
|
53
53
|
"@dnd-kit/sortable": "^10.0.0",
|
|
54
54
|
"@dnd-kit/utilities": "^3.2.2",
|
|
55
|
-
"@eslint/compat": "^1.3.
|
|
55
|
+
"@eslint/compat": "^1.3.1",
|
|
56
56
|
"@react-stately/collections": "^3.12.5",
|
|
57
57
|
"@stylistic/eslint-plugin-js": "^4.4.1",
|
|
58
|
-
"@tailwindcss/vite": "^4.1.
|
|
58
|
+
"@tailwindcss/vite": "^4.1.11",
|
|
59
59
|
"@types/react": "^18.3.23",
|
|
60
60
|
"@types/react-dom": "^18.3.7",
|
|
61
61
|
"@vitejs/plugin-react-swc": "^3.10.2",
|
|
62
|
-
"@wordpress/i18n": "^5.
|
|
62
|
+
"@wordpress/i18n": "^5.26.0",
|
|
63
63
|
"autoprefixer": "^10.4.21",
|
|
64
64
|
"class-variance-authority": "^0.7.1",
|
|
65
65
|
"clsx": "^2.1.1",
|
|
66
66
|
"css-gradient-parser": "^0.0.16",
|
|
67
67
|
"eslint": "^9.29.0",
|
|
68
68
|
"eslint-config-prettier": "^10.1.5",
|
|
69
|
-
"eslint-plugin-jsdoc": "^51.2.
|
|
70
|
-
"eslint-plugin-prettier": "^5.5.
|
|
69
|
+
"eslint-plugin-jsdoc": "^51.2.3",
|
|
70
|
+
"eslint-plugin-prettier": "^5.5.1",
|
|
71
71
|
"glob": "^11.0.3",
|
|
72
72
|
"globals": "^16.2.0",
|
|
73
73
|
"just-camel-case": "^6.2.0",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"just-throttle": "^4.2.0",
|
|
79
79
|
"lightningcss": "^1.30.1",
|
|
80
80
|
"postcss": "^8.5.6",
|
|
81
|
-
"prettier": "^3.6.
|
|
81
|
+
"prettier": "^3.6.2",
|
|
82
82
|
"prettier-plugin-tailwindcss": "^0.6.13",
|
|
83
83
|
"react": "^18.3.1",
|
|
84
84
|
"react-aria": "^3.41.1",
|
|
@@ -89,10 +89,10 @@
|
|
|
89
89
|
"react-select": "^5.10.1",
|
|
90
90
|
"react-stately": "^3.39.0",
|
|
91
91
|
"svg-to-jsx-string": "^0.1.1",
|
|
92
|
-
"tailwindcss": "^4.1.
|
|
92
|
+
"tailwindcss": "^4.1.11",
|
|
93
93
|
"tailwindcss-motion": "^1.1.1",
|
|
94
94
|
"tailwindcss-react-aria-components": "^2.0.0",
|
|
95
|
-
"vite": "^
|
|
95
|
+
"vite": "^7.0.0",
|
|
96
96
|
"vite-plugin-lib-inject-css": "^2.2.2"
|
|
97
97
|
},
|
|
98
98
|
"dependencies": {
|