@jobber/components 9.4.0 → 9.5.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/dist/Autocomplete/index.cjs +0 -1
- package/dist/Autocomplete/index.mjs +0 -1
- package/dist/Card/index.cjs +7 -7
- package/dist/Card/index.mjs +7 -7
- package/dist/Chip/index.cjs +0 -1
- package/dist/Chip/index.mjs +0 -1
- package/dist/Chips/InternalChipDismissible/hooks/index.cjs +0 -1
- package/dist/Chips/InternalChipDismissible/hooks/index.mjs +0 -1
- package/dist/Chips/InternalChipDismissible/index.cjs +0 -1
- package/dist/Chips/InternalChipDismissible/index.mjs +0 -1
- package/dist/Chips/index.cjs +0 -1
- package/dist/Chips/index.mjs +0 -1
- package/dist/ComboboxChipRemove-cjs.js +181 -184
- package/dist/ComboboxChipRemove-es.js +4 -7
- package/dist/ConfirmationModal/index.cjs +0 -1
- package/dist/ConfirmationModal/index.mjs +0 -1
- package/dist/DataDump/index.cjs +7 -7
- package/dist/DataDump/index.mjs +7 -7
- package/dist/DataList/components/DataListActions/index.cjs +0 -1
- package/dist/DataList/components/DataListActions/index.mjs +0 -1
- package/dist/DataList/components/DataListBulkActions/index.cjs +0 -1
- package/dist/DataList/components/DataListBulkActions/index.mjs +0 -1
- package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +0 -1
- package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +0 -1
- package/dist/DataList/components/DataListFilters/index.cjs +0 -1
- package/dist/DataList/components/DataListFilters/index.mjs +0 -1
- package/dist/DataList/components/DataListHeader/index.cjs +0 -1
- package/dist/DataList/components/DataListHeader/index.mjs +0 -1
- package/dist/DataList/components/DataListItem/index.cjs +0 -1
- package/dist/DataList/components/DataListItem/index.mjs +0 -1
- package/dist/DataList/components/DataListItemActions/index.cjs +0 -1
- package/dist/DataList/components/DataListItemActions/index.mjs +0 -1
- package/dist/DataList/components/DataListItemActionsOverflow/index.cjs +0 -1
- package/dist/DataList/components/DataListItemActionsOverflow/index.mjs +0 -1
- package/dist/DataList/components/DataListItems/index.cjs +0 -1
- package/dist/DataList/components/DataListItems/index.mjs +0 -1
- package/dist/DataList/components/DataListLayout/index.cjs +0 -1
- package/dist/DataList/components/DataListLayout/index.mjs +0 -1
- package/dist/DataList/components/DataListLayoutActions/index.cjs +0 -1
- package/dist/DataList/components/DataListLayoutActions/index.mjs +0 -1
- package/dist/DataList/index.cjs +0 -1
- package/dist/DataList/index.mjs +0 -1
- package/dist/DatePicker/index.cjs +0 -2
- package/dist/DatePicker/index.mjs +0 -2
- package/dist/DatePicker-cjs.js +19 -18
- package/dist/DatePicker-es.js +2 -1
- package/dist/Dialog/index.cjs +11 -6
- package/dist/Dialog/index.mjs +11 -6
- package/dist/DrawerDescription-cjs.js +7 -8
- package/dist/DrawerDescription-es.js +1 -2
- package/dist/DrawerTitle-cjs.js +4 -4
- package/dist/DrawerTitle-es.js +1 -1
- package/dist/FieldDescription-cjs.js +49 -49
- package/dist/FieldDescription-es.js +2 -2
- package/dist/FilterPicker/components/FilterPickerActivator/index.cjs +0 -1
- package/dist/FilterPicker/components/FilterPickerActivator/index.mjs +0 -1
- package/dist/FilterPicker/components/FilterPickerContent/index.cjs +0 -1
- package/dist/FilterPicker/components/FilterPickerContent/index.mjs +0 -1
- package/dist/FilterPicker/components/FilterPickerTrigger/index.cjs +0 -1
- package/dist/FilterPicker/components/FilterPickerTrigger/index.mjs +0 -1
- package/dist/FilterPicker/index.cjs +0 -1
- package/dist/FilterPicker/index.mjs +0 -1
- package/dist/FormatFile/index.cjs +0 -1
- package/dist/FormatFile/index.mjs +0 -1
- package/dist/Gallery/index.cjs +0 -1
- package/dist/Gallery/index.mjs +0 -1
- package/dist/HelperText-cjs.js +3 -2
- package/dist/HelperText-es.js +3 -2
- package/dist/InputDate/index.cjs +0 -2
- package/dist/InputDate/index.mjs +0 -2
- package/dist/InputNumber/InputNumber.d.ts +75 -5
- package/dist/InputNumber/index.cjs +27 -3
- package/dist/InputNumber/index.d.ts +2 -2
- package/dist/InputNumber/index.mjs +27 -3
- package/dist/{primitives/InputNumberExperimental → InputNumber}/types.d.ts +48 -35
- package/dist/InputNumber-cjs.js +267 -4986
- package/dist/InputNumber-es.js +268 -4987
- package/dist/LightBox/index.cjs +0 -1
- package/dist/LightBox/index.mjs +0 -1
- package/dist/Menu/index.cjs +7 -7
- package/dist/Menu/index.mjs +7 -7
- package/dist/Menu-cjs.js +8 -5
- package/dist/Menu-es.js +8 -5
- package/dist/MenuSubmenuTrigger-cjs.js +142 -143
- package/dist/MenuSubmenuTrigger-es.js +5 -6
- package/dist/Modal/index.cjs +0 -1
- package/dist/Modal/index.mjs +0 -1
- package/dist/NumberFieldInput-cjs.js +63 -63
- package/dist/NumberFieldInput-es.js +5 -5
- package/dist/Page/index.cjs +7 -8
- package/dist/Page/index.mjs +7 -8
- package/dist/Popover/index.cjs +0 -1
- package/dist/Popover/index.mjs +0 -1
- package/dist/ScrollAreaViewport-cjs.js +119 -121
- package/dist/ScrollAreaViewport-es.js +3 -5
- package/dist/Select/index.cjs +3 -9
- package/dist/Select/index.mjs +3 -9
- package/dist/SelectGroupLabel-cjs.js +117 -107
- package/dist/SelectGroupLabel-es.js +20 -12
- package/dist/Tooltip/index.cjs +0 -1
- package/dist/Tooltip/index.mjs +0 -1
- package/dist/dialogReturnFocus-cjs.js +4 -1
- package/dist/dialogReturnFocus-es.js +4 -1
- package/dist/docs/InputNumber/InputNumber.md +564 -56
- package/dist/docs/index.md +0 -1
- package/dist/floating-ui.react-cjs.js +34 -35
- package/dist/floating-ui.react-dom-cjs.js +64 -65
- package/dist/floating-ui.react-dom-es.js +1 -2
- package/dist/floating-ui.react-es.js +1 -2
- package/dist/floating-ui.utils-cjs.js +183 -0
- package/dist/floating-ui.utils-es.js +165 -1
- package/dist/index.cjs +10 -15
- package/dist/index.mjs +10 -15
- package/dist/primitives/BottomSheet/index.cjs +2 -5
- package/dist/primitives/BottomSheet/index.mjs +2 -5
- package/dist/primitives/ComboboxPrimitive/index.cjs +3 -7
- package/dist/primitives/ComboboxPrimitive/index.mjs +3 -7
- package/dist/primitives/HelperText/HelperText.d.ts +4 -1
- package/dist/primitives/HelperText/index.cjs +1 -1
- package/dist/primitives/HelperText/index.mjs +1 -1
- package/dist/primitives/SelectPrimitive/index.cjs +3 -9
- package/dist/primitives/SelectPrimitive/index.mjs +3 -9
- package/dist/primitives/index.cjs +2 -16
- package/dist/primitives/index.d.ts +0 -2
- package/dist/primitives/index.mjs +2 -15
- package/dist/scrollEdges-cjs.js +6 -2
- package/dist/scrollEdges-es.js +5 -2
- package/dist/styles.css +573 -902
- package/dist/unstyledPrimitives/index.cjs +105 -111
- package/dist/unstyledPrimitives/index.mjs +5 -11
- package/dist/useCompositeListItem-cjs.js +516 -90
- package/dist/useCompositeListItem-es.js +407 -6
- package/dist/useLabel-cjs.js +10 -10
- package/dist/useLabel-es.js +3 -3
- package/dist/useRenderElement-es.js +1 -1
- package/dist/useScrollLock-cjs.js +1332 -203
- package/dist/useScrollLock-es.js +1068 -5
- package/dist/utils/meta/meta.json +12 -0
- package/package.json +2 -3
- package/dist/InputNumber/InputNumber.types.d.ts +0 -20
- package/dist/InputNumberExperimental-cjs.js +0 -277
- package/dist/InputNumberExperimental-es.js +0 -275
- package/dist/clamp-cjs.js +0 -7
- package/dist/clamp-es.js +0 -5
- package/dist/clsx-cjs.js +0 -5
- package/dist/clsx-es.js +0 -3
- package/dist/docs/InputNumberExperimental/InputNumberExperimental.md +0 -578
- package/dist/floating-ui.utils.dom-cjs.js +0 -185
- package/dist/floating-ui.utils.dom-es.js +0 -165
- package/dist/isElementDisabled-cjs.js +0 -40
- package/dist/isElementDisabled-es.js +0 -18
- package/dist/primitives/InputNumberExperimental/InputNumberExperimental.d.ts +0 -77
- package/dist/primitives/InputNumberExperimental/index.cjs +0 -30
- package/dist/primitives/InputNumberExperimental/index.d.ts +0 -2
- package/dist/primitives/InputNumberExperimental/index.mjs +0 -24
- package/dist/resolveAriaLabelledBy-cjs.js +0 -200
- package/dist/resolveAriaLabelledBy-es.js +0 -166
- package/dist/useButton-cjs.js +0 -1164
- package/dist/useButton-es.js +0 -1071
- package/dist/useLabelableId-cjs.js +0 -278
- package/dist/useLabelableId-es.js +0 -247
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
|
|
6
|
-
function _interopNamespaceDefault(e) {
|
|
7
|
-
var n = Object.create(null);
|
|
8
|
-
if (e) {
|
|
9
|
-
Object.keys(e).forEach(function (k) {
|
|
10
|
-
if (k !== 'default') {
|
|
11
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () { return e[k]; }
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
n.default = e;
|
|
20
|
-
return Object.freeze(n);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
24
|
-
|
|
25
|
-
const defaultItemEquality = (itemValue, selectedValue) => Object.is(itemValue, selectedValue);
|
|
26
|
-
function compareItemEquality(itemValue, selectedValue, comparer) {
|
|
27
|
-
if (itemValue == null || selectedValue == null) {
|
|
28
|
-
return Object.is(itemValue, selectedValue);
|
|
29
|
-
}
|
|
30
|
-
return comparer(itemValue, selectedValue);
|
|
31
|
-
}
|
|
32
|
-
function selectedValueIncludes(selectedValues, itemValue, comparer) {
|
|
33
|
-
if (!selectedValues || selectedValues.length === 0) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
return selectedValues.some(selectedValue => {
|
|
37
|
-
if (selectedValue === undefined) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
return compareItemEquality(itemValue, selectedValue, comparer);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
function findItemIndex(itemValues, selectedValue, comparer) {
|
|
44
|
-
if (!itemValues || itemValues.length === 0) {
|
|
45
|
-
return -1;
|
|
46
|
-
}
|
|
47
|
-
return itemValues.findIndex(itemValue => {
|
|
48
|
-
if (itemValue === undefined) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
return compareItemEquality(itemValue, selectedValue, comparer);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function removeItem(selectedValues, itemValue, comparer) {
|
|
55
|
-
return selectedValues.filter(selectedValue => !compareItemEquality(itemValue, selectedValue, comparer));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function serializeValue(value) {
|
|
59
|
-
if (value == null) {
|
|
60
|
-
return '';
|
|
61
|
-
}
|
|
62
|
-
if (typeof value === 'string') {
|
|
63
|
-
return value;
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
return JSON.stringify(value);
|
|
67
|
-
} catch {
|
|
68
|
-
return String(value);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function isGroupedItems(items) {
|
|
73
|
-
return items != null && items.length > 0 && typeof items[0] === 'object' && items[0] != null && 'items' in items[0];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Checks if the items array contains an item with a null value that has a non-null label.
|
|
78
|
-
*/
|
|
79
|
-
function hasNullItemLabel(items) {
|
|
80
|
-
if (!Array.isArray(items)) {
|
|
81
|
-
return items != null && 'null' in items;
|
|
82
|
-
}
|
|
83
|
-
const arrayItems = items;
|
|
84
|
-
if (isGroupedItems(arrayItems)) {
|
|
85
|
-
for (const group of arrayItems) {
|
|
86
|
-
for (const item of group.items) {
|
|
87
|
-
if (item && item.value == null && item.label != null) {
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
for (const item of arrayItems) {
|
|
95
|
-
if (item && item.value == null && item.label != null) {
|
|
96
|
-
return true;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
function stringifyAsLabel(item, itemToStringLabel) {
|
|
102
|
-
if (itemToStringLabel && item != null) {
|
|
103
|
-
return itemToStringLabel(item) ?? '';
|
|
104
|
-
}
|
|
105
|
-
if (item && typeof item === 'object') {
|
|
106
|
-
if ('label' in item && item.label != null) {
|
|
107
|
-
return String(item.label);
|
|
108
|
-
}
|
|
109
|
-
if ('value' in item) {
|
|
110
|
-
return String(item.value);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return serializeValue(item);
|
|
114
|
-
}
|
|
115
|
-
function stringifyAsValue(item, itemToStringValue) {
|
|
116
|
-
if (itemToStringValue && item != null) {
|
|
117
|
-
return itemToStringValue(item) ?? '';
|
|
118
|
-
}
|
|
119
|
-
if (item && typeof item === 'object' && 'value' in item && 'label' in item) {
|
|
120
|
-
return serializeValue(item.value);
|
|
121
|
-
}
|
|
122
|
-
return serializeValue(item);
|
|
123
|
-
}
|
|
124
|
-
function resolveSelectedLabel(value, items, itemToStringLabel) {
|
|
125
|
-
function fallback() {
|
|
126
|
-
return stringifyAsLabel(value, itemToStringLabel);
|
|
127
|
-
}
|
|
128
|
-
if (itemToStringLabel && value != null) {
|
|
129
|
-
return itemToStringLabel(value);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Custom object with explicit label takes precedence
|
|
133
|
-
if (value && typeof value === 'object' && 'label' in value && value.label != null) {
|
|
134
|
-
return value.label;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Items provided as plain record map
|
|
138
|
-
if (items && !Array.isArray(items)) {
|
|
139
|
-
return items[value] ?? fallback();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Items provided as array (flat or grouped)
|
|
143
|
-
if (Array.isArray(items)) {
|
|
144
|
-
const arrayItems = items;
|
|
145
|
-
const flatItems = isGroupedItems(arrayItems) ? arrayItems.flatMap(group => group.items) : arrayItems;
|
|
146
|
-
if (value == null || typeof value !== 'object') {
|
|
147
|
-
const match = flatItems.find(item => item.value === value);
|
|
148
|
-
if (match && match.label != null) {
|
|
149
|
-
return match.label;
|
|
150
|
-
}
|
|
151
|
-
return fallback();
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Object without explicit label: try matching by its `value` property
|
|
155
|
-
if ('value' in value) {
|
|
156
|
-
const match = flatItems.find(item => item && item.value === value.value);
|
|
157
|
-
if (match && match.label != null) {
|
|
158
|
-
return match.label;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return fallback();
|
|
163
|
-
}
|
|
164
|
-
function resolveMultipleLabels(values, items, itemToStringLabel) {
|
|
165
|
-
return values.reduce((acc, value, index) => {
|
|
166
|
-
if (index > 0) {
|
|
167
|
-
acc.push(', ');
|
|
168
|
-
}
|
|
169
|
-
acc.push(/*#__PURE__*/jsxRuntime.jsx(React__namespace.Fragment, {
|
|
170
|
-
children: resolveSelectedLabel(value, items, itemToStringLabel)
|
|
171
|
-
}, index));
|
|
172
|
-
return acc;
|
|
173
|
-
}, []);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function areArraysEqual(array1, array2, itemComparer = (a, b) => a === b) {
|
|
177
|
-
return array1.length === array2.length && array1.every((value, index) => itemComparer(value, array2[index]));
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function getDefaultLabelId(id) {
|
|
181
|
-
return id == null ? undefined : `${id}-label`;
|
|
182
|
-
}
|
|
183
|
-
function resolveAriaLabelledBy(fieldLabelId, localLabelId) {
|
|
184
|
-
return fieldLabelId ?? localLabelId;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
exports.areArraysEqual = areArraysEqual;
|
|
188
|
-
exports.compareItemEquality = compareItemEquality;
|
|
189
|
-
exports.defaultItemEquality = defaultItemEquality;
|
|
190
|
-
exports.findItemIndex = findItemIndex;
|
|
191
|
-
exports.getDefaultLabelId = getDefaultLabelId;
|
|
192
|
-
exports.hasNullItemLabel = hasNullItemLabel;
|
|
193
|
-
exports.isGroupedItems = isGroupedItems;
|
|
194
|
-
exports.removeItem = removeItem;
|
|
195
|
-
exports.resolveAriaLabelledBy = resolveAriaLabelledBy;
|
|
196
|
-
exports.resolveMultipleLabels = resolveMultipleLabels;
|
|
197
|
-
exports.resolveSelectedLabel = resolveSelectedLabel;
|
|
198
|
-
exports.selectedValueIncludes = selectedValueIncludes;
|
|
199
|
-
exports.stringifyAsLabel = stringifyAsLabel;
|
|
200
|
-
exports.stringifyAsValue = stringifyAsValue;
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
|
|
4
|
-
const defaultItemEquality = (itemValue, selectedValue) => Object.is(itemValue, selectedValue);
|
|
5
|
-
function compareItemEquality(itemValue, selectedValue, comparer) {
|
|
6
|
-
if (itemValue == null || selectedValue == null) {
|
|
7
|
-
return Object.is(itemValue, selectedValue);
|
|
8
|
-
}
|
|
9
|
-
return comparer(itemValue, selectedValue);
|
|
10
|
-
}
|
|
11
|
-
function selectedValueIncludes(selectedValues, itemValue, comparer) {
|
|
12
|
-
if (!selectedValues || selectedValues.length === 0) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
return selectedValues.some(selectedValue => {
|
|
16
|
-
if (selectedValue === undefined) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
return compareItemEquality(itemValue, selectedValue, comparer);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
function findItemIndex(itemValues, selectedValue, comparer) {
|
|
23
|
-
if (!itemValues || itemValues.length === 0) {
|
|
24
|
-
return -1;
|
|
25
|
-
}
|
|
26
|
-
return itemValues.findIndex(itemValue => {
|
|
27
|
-
if (itemValue === undefined) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
return compareItemEquality(itemValue, selectedValue, comparer);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
function removeItem(selectedValues, itemValue, comparer) {
|
|
34
|
-
return selectedValues.filter(selectedValue => !compareItemEquality(itemValue, selectedValue, comparer));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function serializeValue(value) {
|
|
38
|
-
if (value == null) {
|
|
39
|
-
return '';
|
|
40
|
-
}
|
|
41
|
-
if (typeof value === 'string') {
|
|
42
|
-
return value;
|
|
43
|
-
}
|
|
44
|
-
try {
|
|
45
|
-
return JSON.stringify(value);
|
|
46
|
-
} catch {
|
|
47
|
-
return String(value);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function isGroupedItems(items) {
|
|
52
|
-
return items != null && items.length > 0 && typeof items[0] === 'object' && items[0] != null && 'items' in items[0];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Checks if the items array contains an item with a null value that has a non-null label.
|
|
57
|
-
*/
|
|
58
|
-
function hasNullItemLabel(items) {
|
|
59
|
-
if (!Array.isArray(items)) {
|
|
60
|
-
return items != null && 'null' in items;
|
|
61
|
-
}
|
|
62
|
-
const arrayItems = items;
|
|
63
|
-
if (isGroupedItems(arrayItems)) {
|
|
64
|
-
for (const group of arrayItems) {
|
|
65
|
-
for (const item of group.items) {
|
|
66
|
-
if (item && item.value == null && item.label != null) {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
for (const item of arrayItems) {
|
|
74
|
-
if (item && item.value == null && item.label != null) {
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
function stringifyAsLabel(item, itemToStringLabel) {
|
|
81
|
-
if (itemToStringLabel && item != null) {
|
|
82
|
-
return itemToStringLabel(item) ?? '';
|
|
83
|
-
}
|
|
84
|
-
if (item && typeof item === 'object') {
|
|
85
|
-
if ('label' in item && item.label != null) {
|
|
86
|
-
return String(item.label);
|
|
87
|
-
}
|
|
88
|
-
if ('value' in item) {
|
|
89
|
-
return String(item.value);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return serializeValue(item);
|
|
93
|
-
}
|
|
94
|
-
function stringifyAsValue(item, itemToStringValue) {
|
|
95
|
-
if (itemToStringValue && item != null) {
|
|
96
|
-
return itemToStringValue(item) ?? '';
|
|
97
|
-
}
|
|
98
|
-
if (item && typeof item === 'object' && 'value' in item && 'label' in item) {
|
|
99
|
-
return serializeValue(item.value);
|
|
100
|
-
}
|
|
101
|
-
return serializeValue(item);
|
|
102
|
-
}
|
|
103
|
-
function resolveSelectedLabel(value, items, itemToStringLabel) {
|
|
104
|
-
function fallback() {
|
|
105
|
-
return stringifyAsLabel(value, itemToStringLabel);
|
|
106
|
-
}
|
|
107
|
-
if (itemToStringLabel && value != null) {
|
|
108
|
-
return itemToStringLabel(value);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Custom object with explicit label takes precedence
|
|
112
|
-
if (value && typeof value === 'object' && 'label' in value && value.label != null) {
|
|
113
|
-
return value.label;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Items provided as plain record map
|
|
117
|
-
if (items && !Array.isArray(items)) {
|
|
118
|
-
return items[value] ?? fallback();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Items provided as array (flat or grouped)
|
|
122
|
-
if (Array.isArray(items)) {
|
|
123
|
-
const arrayItems = items;
|
|
124
|
-
const flatItems = isGroupedItems(arrayItems) ? arrayItems.flatMap(group => group.items) : arrayItems;
|
|
125
|
-
if (value == null || typeof value !== 'object') {
|
|
126
|
-
const match = flatItems.find(item => item.value === value);
|
|
127
|
-
if (match && match.label != null) {
|
|
128
|
-
return match.label;
|
|
129
|
-
}
|
|
130
|
-
return fallback();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Object without explicit label: try matching by its `value` property
|
|
134
|
-
if ('value' in value) {
|
|
135
|
-
const match = flatItems.find(item => item && item.value === value.value);
|
|
136
|
-
if (match && match.label != null) {
|
|
137
|
-
return match.label;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return fallback();
|
|
142
|
-
}
|
|
143
|
-
function resolveMultipleLabels(values, items, itemToStringLabel) {
|
|
144
|
-
return values.reduce((acc, value, index) => {
|
|
145
|
-
if (index > 0) {
|
|
146
|
-
acc.push(', ');
|
|
147
|
-
}
|
|
148
|
-
acc.push(/*#__PURE__*/jsx(React.Fragment, {
|
|
149
|
-
children: resolveSelectedLabel(value, items, itemToStringLabel)
|
|
150
|
-
}, index));
|
|
151
|
-
return acc;
|
|
152
|
-
}, []);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function areArraysEqual(array1, array2, itemComparer = (a, b) => a === b) {
|
|
156
|
-
return array1.length === array2.length && array1.every((value, index) => itemComparer(value, array2[index]));
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function getDefaultLabelId(id) {
|
|
160
|
-
return id == null ? undefined : `${id}-label`;
|
|
161
|
-
}
|
|
162
|
-
function resolveAriaLabelledBy(fieldLabelId, localLabelId) {
|
|
163
|
-
return fieldLabelId ?? localLabelId;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export { stringifyAsLabel as a, areArraysEqual as b, compareItemEquality as c, defaultItemEquality as d, resolveMultipleLabels as e, findItemIndex as f, resolveSelectedLabel as g, hasNullItemLabel as h, selectedValueIncludes as i, removeItem as j, isGroupedItems as k, getDefaultLabelId as l, resolveAriaLabelledBy as r, stringifyAsValue as s };
|