@stenajs-webui/select 17.4.1 → 17.7.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/CHANGELOG.md +26 -0
- package/dist/SelectTheme.d.ts +75 -75
- package/dist/components/ui/AsyncMultiSelect.d.ts +12 -12
- package/dist/components/ui/AsyncSelect.d.ts +12 -12
- package/dist/components/ui/ChipMultiSelect/ChipMultiSelect.d.ts +19 -19
- package/dist/components/ui/ChipMultiSelect/ChipRow.d.ts +10 -10
- package/dist/components/ui/ChipMultiSelect/GroupedChipMultiSelect.d.ts +15 -15
- package/dist/components/ui/GroupedMultiSelect.d.ts +25 -25
- package/dist/components/ui/GroupedMultiSelectTypes.d.ts +5 -5
- package/dist/components/ui/MultiSelect.d.ts +13 -13
- package/dist/components/ui/Select.d.ts +11 -11
- package/dist/index.d.ts +10 -10
- package/dist/index.es.js +625 -487
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -532
- package/dist/index.js.map +1 -1
- package/dist/util/StylesBuilder.d.ts +9 -9
- package/dist/util/multiDropdownUtils.d.ts +24 -24
- package/package.json +8 -9
- package/dist/components/ui/AsyncSelect.stories.d.ts +0 -7
- package/dist/components/ui/ChipMultiSelect/ChipMultiSelect.stories.d.ts +0 -12
- package/dist/components/ui/ChipMultiSelect/GroupedChipMultiSelect.stories.d.ts +0 -10
- package/dist/components/ui/GroupedMultiSelect.stories.d.ts +0 -9
- package/dist/components/ui/MultiSelect.stories.d.ts +0 -10
- package/dist/components/ui/Select.stories.d.ts +0 -11
- package/dist/util/__tests__/multiDropdownUtils.test.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -1,533 +1,2 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var SelectComponent = require('react-select');
|
|
7
|
-
var AsyncComponent = require('react-select/async');
|
|
8
|
-
var faCheck = require('@fortawesome/free-solid-svg-icons/faCheck');
|
|
9
|
-
var core = require('@stenajs-webui/core');
|
|
10
|
-
var elements = require('@stenajs-webui/elements');
|
|
11
|
-
var lodash = require('lodash');
|
|
12
|
-
|
|
13
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
-
|
|
15
|
-
function _interopNamespace(e) {
|
|
16
|
-
if (e && e.__esModule) return e;
|
|
17
|
-
var n = Object.create(null);
|
|
18
|
-
if (e) {
|
|
19
|
-
Object.keys(e).forEach(function (k) {
|
|
20
|
-
if (k !== 'default') {
|
|
21
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () { return e[k]; }
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
n["default"] = e;
|
|
30
|
-
return Object.freeze(n);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
34
|
-
var SelectComponent__default = /*#__PURE__*/_interopDefaultLegacy(SelectComponent);
|
|
35
|
-
var AsyncComponent__default = /*#__PURE__*/_interopDefaultLegacy(AsyncComponent);
|
|
36
|
-
|
|
37
|
-
/*! *****************************************************************************
|
|
38
|
-
Copyright (c) Microsoft Corporation.
|
|
39
|
-
|
|
40
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
41
|
-
purpose with or without fee is hereby granted.
|
|
42
|
-
|
|
43
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
44
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
45
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
46
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
47
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
48
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
49
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
50
|
-
***************************************************************************** */
|
|
51
|
-
|
|
52
|
-
var __assign = function() {
|
|
53
|
-
__assign = Object.assign || function __assign(t) {
|
|
54
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
55
|
-
s = arguments[i];
|
|
56
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
57
|
-
}
|
|
58
|
-
return t;
|
|
59
|
-
};
|
|
60
|
-
return __assign.apply(this, arguments);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
function __rest(s, e) {
|
|
64
|
-
var t = {};
|
|
65
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
66
|
-
t[p] = s[p];
|
|
67
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
68
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
69
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
70
|
-
t[p[i]] = s[p[i]];
|
|
71
|
-
}
|
|
72
|
-
return t;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function __spreadArray(to, from, pack) {
|
|
76
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
77
|
-
if (ar || !(i in from)) {
|
|
78
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
79
|
-
ar[i] = from[i];
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
var defaultSelectTheme = {
|
|
86
|
-
arrowColor: {
|
|
87
|
-
focused: {
|
|
88
|
-
hover: "var(--lhds-color-ui-500)",
|
|
89
|
-
standard: "var(--lhds-color-ui-500)",
|
|
90
|
-
},
|
|
91
|
-
closed: {
|
|
92
|
-
hover: "var(--lhds-color-ui-500)",
|
|
93
|
-
standard: "var(--lhds-color-ui-500)",
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
clearButtonColor: {
|
|
97
|
-
hover: "var(--lhds-color-ui-600)",
|
|
98
|
-
standard: "var(--lhds-color-ui-500)",
|
|
99
|
-
},
|
|
100
|
-
input: {
|
|
101
|
-
backgroundColor: "var(--swui-field-bg-enabled)",
|
|
102
|
-
border: "1px solid var(--swui-select-border-color)",
|
|
103
|
-
borderColor: "var(--swui-field-border-color)",
|
|
104
|
-
borderColorFocused: "var(--swui-field-border-color-hover)",
|
|
105
|
-
disabledBackgroundColor: "var(--swui-field-bg-disabled)",
|
|
106
|
-
warningBackgroundColor: "var(--swui-state-alert-light-color)",
|
|
107
|
-
errorBackgroundColor: "var(--swui-state-error-light-color)",
|
|
108
|
-
successBackgroundColor: "var(--swui-state-success-light-color)",
|
|
109
|
-
warningBorderColor: "var(--swui-state-alert-color)",
|
|
110
|
-
errorBorderColor: "var(--swui-state-error-color)",
|
|
111
|
-
successBorderColor: "var(--swui-state-success-color)",
|
|
112
|
-
boxShadowFocused: "var(--swui-field-focus-shadow)",
|
|
113
|
-
fontFamily: "var(--swui-font-primary)",
|
|
114
|
-
fontSize: "var(--swui-font-size-inputs)",
|
|
115
|
-
height: "32px",
|
|
116
|
-
minHeight: "32px",
|
|
117
|
-
placeholderColor: "var(--swui-field-border-color-disabled)",
|
|
118
|
-
textColor: "var(--swui-field-text-color)",
|
|
119
|
-
borderRadius: "var(--swui-field-border-radius)",
|
|
120
|
-
},
|
|
121
|
-
loadingIndicator: {
|
|
122
|
-
textColor: "var(--swui-field-text-color)",
|
|
123
|
-
},
|
|
124
|
-
menu: {
|
|
125
|
-
activeBackgroundColor: "var(--lhds-color-blue-100)",
|
|
126
|
-
activeTextColor: "var(--swui-field-text-color)",
|
|
127
|
-
selectedItemActiveBackgroundColor: "var(--lhds-color-blue-500)",
|
|
128
|
-
selectedItemActiveTextColor: "var(--lhds-color-blue-50)",
|
|
129
|
-
disabledTextColor: "var(--swui-field-text-color-disabled)",
|
|
130
|
-
disabledBackgroundColor: "var(--swui-field-bg-disabled)",
|
|
131
|
-
textColor: "var(--swui-field-text-color)",
|
|
132
|
-
backgroundColor: "var(--swui-field-bg-enabled)",
|
|
133
|
-
hoverTextColor: "var(--swui-field-text-color)",
|
|
134
|
-
hoverBackgroundColor: "var(--lhds-color-blue-200)",
|
|
135
|
-
selectedItemTextColor: "var(--lhds-color-blue-500)",
|
|
136
|
-
selectedItemIconColor: "var(--lhds-color-blue-500)",
|
|
137
|
-
selectedItemHoverTextColor: "var(--swui-field-text-color)",
|
|
138
|
-
selectedItemHoverIconColor: "var(--swui-field-text-color)",
|
|
139
|
-
selectedItemBackgroundColor: "var(--lhds-color-blue-50)",
|
|
140
|
-
selectedItemHoverBackgroundColor: "var(--lhds-color-blue-50)",
|
|
141
|
-
zIndex: 1,
|
|
142
|
-
width: "auto",
|
|
143
|
-
minWidth: "100%",
|
|
144
|
-
whiteSpace: "nowrap",
|
|
145
|
-
},
|
|
146
|
-
menuPortal: {
|
|
147
|
-
zIndex: 1,
|
|
148
|
-
},
|
|
149
|
-
multiSelect: {
|
|
150
|
-
backgroundColor: "var(--swui-primary-action-color)",
|
|
151
|
-
textColor: "var(--lhds-color-blue-50)",
|
|
152
|
-
removeButtonBackgroundColor: "transparent",
|
|
153
|
-
removeButtonTextColor: "var(--swui-white)",
|
|
154
|
-
removeButtonHoverBackgroundColor: "var(--swui-primary-action-color-hover)",
|
|
155
|
-
removeButtonHoverTextColor: "var(--swui-white)",
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
var resolveOptionBackgroundColor = function (colors, isDisabled, isSelected, isFocused) {
|
|
160
|
-
if (isDisabled) {
|
|
161
|
-
return colors.disabledBackgroundColor;
|
|
162
|
-
}
|
|
163
|
-
else if (isSelected && isFocused) {
|
|
164
|
-
return colors.selectedItemHoverBackgroundColor;
|
|
165
|
-
}
|
|
166
|
-
else if (isSelected) {
|
|
167
|
-
return colors.selectedItemBackgroundColor;
|
|
168
|
-
}
|
|
169
|
-
else if (isFocused) {
|
|
170
|
-
return colors.hoverBackgroundColor;
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
return undefined;
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
var resolveOptionColor = function (colors, isDisabled, isSelected, isFocused) {
|
|
177
|
-
if (isDisabled) {
|
|
178
|
-
return colors.disabledTextColor;
|
|
179
|
-
}
|
|
180
|
-
else if (isSelected && isFocused) {
|
|
181
|
-
return colors.selectedItemHoverTextColor;
|
|
182
|
-
}
|
|
183
|
-
else if (isSelected) {
|
|
184
|
-
return colors.selectedItemTextColor;
|
|
185
|
-
}
|
|
186
|
-
else if (isFocused) {
|
|
187
|
-
return colors.hoverTextColor;
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
return undefined;
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
var resolveInputBackgroundColor = function (colors, isDisabled, isFocused, variant) {
|
|
194
|
-
if (isDisabled) {
|
|
195
|
-
return colors.disabledBackgroundColor;
|
|
196
|
-
}
|
|
197
|
-
else if (isFocused) {
|
|
198
|
-
return colors.backgroundColor;
|
|
199
|
-
}
|
|
200
|
-
else if (variant === "warning") {
|
|
201
|
-
return colors.warningBackgroundColor;
|
|
202
|
-
}
|
|
203
|
-
else if (variant === "success") {
|
|
204
|
-
return colors.successBackgroundColor;
|
|
205
|
-
}
|
|
206
|
-
else if (variant === "error") {
|
|
207
|
-
return colors.errorBackgroundColor;
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
return colors.backgroundColor;
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
var resolveInputBorderColor = function (colors, isDisabled, isFocused, isHovered, variant) {
|
|
214
|
-
if (isDisabled) {
|
|
215
|
-
return colors.borderColor;
|
|
216
|
-
}
|
|
217
|
-
else if (isFocused) {
|
|
218
|
-
return colors.borderColorFocused;
|
|
219
|
-
}
|
|
220
|
-
else if (variant === "warning") {
|
|
221
|
-
return colors.warningBorderColor;
|
|
222
|
-
}
|
|
223
|
-
else if (variant === "success") {
|
|
224
|
-
return colors.successBorderColor;
|
|
225
|
-
}
|
|
226
|
-
else if (variant === "error") {
|
|
227
|
-
return colors.errorBorderColor;
|
|
228
|
-
}
|
|
229
|
-
else if (isHovered) {
|
|
230
|
-
return colors.borderColorFocused;
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
return colors.borderColor;
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
/**
|
|
237
|
-
* @deprecated
|
|
238
|
-
*/
|
|
239
|
-
var createStylesFromTheme = function (_a, variant) {
|
|
240
|
-
var menu = _a.menu, menuPortal = _a.menuPortal, input = _a.input, multiSelect = _a.multiSelect, clearButtonColor = _a.clearButtonColor, arrowColor = _a.arrowColor, loadingIndicator = _a.loadingIndicator;
|
|
241
|
-
return ({
|
|
242
|
-
option: function (base, _a) {
|
|
243
|
-
var isDisabled = _a.isDisabled, isFocused = _a.isFocused, isSelected = _a.isSelected;
|
|
244
|
-
return (__assign(__assign({}, base), { fontFamily: input.fontFamily, fontSize: input.fontSize, backgroundColor: resolveOptionBackgroundColor(menu, isDisabled, isSelected, isFocused), color: resolveOptionColor(menu, isDisabled, isSelected, isFocused), cursor: isDisabled ? "not-allowed" : "default", whiteSpace: menu.whiteSpace || base.whiteSpace, ":active": {
|
|
245
|
-
backgroundColor: isDisabled
|
|
246
|
-
? undefined
|
|
247
|
-
: isSelected
|
|
248
|
-
? menu.selectedItemActiveBackgroundColor
|
|
249
|
-
: menu.activeBackgroundColor,
|
|
250
|
-
color: isDisabled
|
|
251
|
-
? undefined
|
|
252
|
-
: isSelected
|
|
253
|
-
? menu.selectedItemActiveTextColor
|
|
254
|
-
: menu.activeTextColor,
|
|
255
|
-
} }));
|
|
256
|
-
},
|
|
257
|
-
control: function (base, _a) {
|
|
258
|
-
var isFocused = _a.isFocused, isDisabled = _a.isDisabled, menuIsOpen = _a.menuIsOpen;
|
|
259
|
-
return (__assign(__assign({}, base), {
|
|
260
|
-
// none of react-selects styles are passed to <View />
|
|
261
|
-
fontFamily: input.fontFamily, fontSize: input.fontSize, minHeight: input.minHeight, backgroundColor: resolveInputBackgroundColor(input, isDisabled, isFocused, variant), borderRadius: input.borderRadius, border: input.border, "--swui-select-border-color": resolveInputBorderColor(input, isDisabled, isFocused || menuIsOpen, false, variant), boxShadow: isFocused ? input.boxShadowFocused : undefined, "&:hover": {
|
|
262
|
-
"--swui-select-border-color": resolveInputBorderColor(input, false, isFocused || menuIsOpen, true, variant),
|
|
263
|
-
} }));
|
|
264
|
-
},
|
|
265
|
-
singleValue: function (base) { return (__assign(__assign({}, base), { fontFamily: input.fontFamily, fontSize: input.fontSize, color: input.textColor })); },
|
|
266
|
-
noOptionsMessage: function (base) { return (__assign(__assign({}, base), { fontFamily: input.fontFamily, fontSize: input.fontSize })); },
|
|
267
|
-
input: function (base) { return (__assign(__assign({}, base), { fontFamily: input.fontFamily, fontSize: input.fontSize, color: input.textColor })); },
|
|
268
|
-
groupHeading: function (base) { return (__assign(__assign({}, base), { fontFamily: input.fontFamily })); },
|
|
269
|
-
multiValueLabel: function (base) { return (__assign(__assign({}, base), { backgroundColor: multiSelect.backgroundColor, color: multiSelect.textColor, fontFamily: input.fontFamily, fontSize: "12px" })); },
|
|
270
|
-
indicatorSeparator: function (base) { return (__assign(__assign({}, base), { display: "none" })); },
|
|
271
|
-
clearIndicator: function (base) { return (__assign(__assign({}, base), { padding: "5px", color: clearButtonColor.standard, "&:hover": {
|
|
272
|
-
color: clearButtonColor.hover,
|
|
273
|
-
}, cursor: "pointer" })); },
|
|
274
|
-
placeholder: function (base) { return (__assign(__assign({}, base), { fontFamily: input.fontFamily, fontSize: input.fontSize, color: input.placeholderColor })); },
|
|
275
|
-
container: function (base) { return (__assign({}, base)); },
|
|
276
|
-
valueContainer: function (base) { return (__assign(__assign({}, base), { padding: "0 8px" })); },
|
|
277
|
-
dropdownIndicator: function (base, _a) {
|
|
278
|
-
var isFocused = _a.isFocused;
|
|
279
|
-
return (__assign(__assign({}, base), { padding: "5px", color: isFocused ? arrowColor.focused.standard : arrowColor.closed.standard, "&:hover": {
|
|
280
|
-
color: isFocused ? arrowColor.focused.hover : arrowColor.closed.hover,
|
|
281
|
-
}, svg: {
|
|
282
|
-
width: 14,
|
|
283
|
-
height: 14,
|
|
284
|
-
} }));
|
|
285
|
-
},
|
|
286
|
-
menu: function (base) { return (__assign(__assign({}, base), { backgroundColor: menu.backgroundColor, color: menu.textColor, minWidth: menu.minWidth || base.minWidth, zIndex: menu.zIndex, width: menu.width || base.width, border: input.border, borderColor: input.borderColorFocused })); },
|
|
287
|
-
menuPortal: function (base) { return (__assign(__assign({}, base), { zIndex: menuPortal.zIndex })); },
|
|
288
|
-
multiValueRemove: function (styles) { return (__assign(__assign({}, styles), { backgroundColor: multiSelect.removeButtonBackgroundColor, ":hover": {
|
|
289
|
-
color: multiSelect.removeButtonHoverTextColor,
|
|
290
|
-
backgroundColor: multiSelect.removeButtonHoverBackgroundColor,
|
|
291
|
-
}, color: multiSelect.removeButtonTextColor, borderRadius: "50%", width: 16, height: 16, padding: 0, margin: 3, marginTop: 4, display: "flex", justifyContent: "center", alignItems: "center", cursor: "pointer" })); },
|
|
292
|
-
multiValue: function (base) { return (__assign(__assign({}, base), { backgroundColor: multiSelect.backgroundColor, color: multiSelect.textColor, fontFamily: input.fontFamily, fontSize: "12px", alignItems: "center", margin: 0, marginRight: 2 })); },
|
|
293
|
-
loadingMessage: function (base) { return (__assign(__assign({}, base), { color: loadingIndicator.textColor, fontFamily: input.fontFamily, fontSize: input.fontSize })); },
|
|
294
|
-
});
|
|
295
|
-
};
|
|
296
|
-
var createStylesFromVariant = function (variant) {
|
|
297
|
-
return createStylesFromTheme(defaultSelectTheme, variant);
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
var AsyncMultiSelect = function (_a) {
|
|
301
|
-
var _b = _a.variant, variant = _b === void 0 ? "standard" : _b, styles = _a.styles; _a.isMulti; var selectProps = __rest(_a, ["variant", "styles", "isMulti"]);
|
|
302
|
-
var selectStyles = React.useMemo(function () {
|
|
303
|
-
var sourceStyles = createStylesFromVariant(variant);
|
|
304
|
-
return styles ? SelectComponent.mergeStyles(sourceStyles, styles) : sourceStyles;
|
|
305
|
-
}, [variant, styles]);
|
|
306
|
-
return (React__namespace.createElement(AsyncComponent__default["default"], __assign({ styles: selectStyles }, selectProps, { isMulti: true })));
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
var AsyncSelect = function (_a) {
|
|
310
|
-
var _b = _a.variant, variant = _b === void 0 ? "standard" : _b, styles = _a.styles; _a.isMulti; var selectProps = __rest(_a, ["variant", "styles", "isMulti"]);
|
|
311
|
-
var selectStyles = React.useMemo(function () {
|
|
312
|
-
var sourceStyles = createStylesFromVariant(variant);
|
|
313
|
-
return styles ? SelectComponent.mergeStyles(sourceStyles, styles) : sourceStyles;
|
|
314
|
-
}, [variant, styles]);
|
|
315
|
-
return (React__namespace.createElement(AsyncComponent__default["default"], __assign({ styles: selectStyles }, selectProps, { isMulti: false })));
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
var MultiSelect = function (_a) {
|
|
319
|
-
var _b = _a.variant, variant = _b === void 0 ? "standard" : _b, styles = _a.styles; _a.isMulti; var selectProps = __rest(_a, ["variant", "styles", "isMulti"]);
|
|
320
|
-
var selectStyles = React.useMemo(function () {
|
|
321
|
-
var sourceStyles = createStylesFromVariant(variant);
|
|
322
|
-
return styles ? SelectComponent.mergeStyles(sourceStyles, styles) : sourceStyles;
|
|
323
|
-
}, [variant, styles]);
|
|
324
|
-
return (React__namespace.createElement(SelectComponent__default["default"], __assign({ styles: selectStyles }, selectProps, { isMulti: true })));
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
var Select = function (_a) {
|
|
328
|
-
var _b = _a.variant, variant = _b === void 0 ? "standard" : _b, styles = _a.styles; _a.isMulti; var selectProps = __rest(_a, ["variant", "styles", "isMulti"]);
|
|
329
|
-
var selectStyles = React.useMemo(function () {
|
|
330
|
-
var sourceStyles = createStylesFromVariant(variant);
|
|
331
|
-
return styles ? SelectComponent.mergeStyles(sourceStyles, styles) : sourceStyles;
|
|
332
|
-
}, [variant, styles]);
|
|
333
|
-
return (React__namespace.createElement(SelectComponent__default["default"], __assign({ styles: selectStyles }, selectProps, { isMulti: false })));
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
var removeGroupedOptionsType = function (removedValue, selectedInternalOptions) {
|
|
337
|
-
return lodash.differenceWith(selectedInternalOptions, __spreadArray(__spreadArray([], removedValue.internalOptions, true), [removedValue], false), lodash.isEqual).map(convertInternalOptionToDropdownOption);
|
|
338
|
-
};
|
|
339
|
-
var removeInternalOptions = function (selectedInternalOption) { return !("internalOptions" in selectedInternalOption); };
|
|
340
|
-
var removeOptionHeaders = function (selectedInternalOptions) {
|
|
341
|
-
return selectedInternalOptions
|
|
342
|
-
.filter(removeInternalOptions)
|
|
343
|
-
.map(convertInternalOptionToDropdownOption);
|
|
344
|
-
};
|
|
345
|
-
var createOnChange = function (onChange) {
|
|
346
|
-
return function (incomingSelectedInternalOptions, meta) {
|
|
347
|
-
var selectedInternalOptions = incomingSelectedInternalOptions !== null && incomingSelectedInternalOptions !== void 0 ? incomingSelectedInternalOptions : [];
|
|
348
|
-
switch (meta.action) {
|
|
349
|
-
case "select-option":
|
|
350
|
-
if (meta.option && "internalOptions" in meta.option) {
|
|
351
|
-
var selectedOptions = lodash.uniqWith(selectedInternalOptions.reduce(function (previousValue, currentValue) {
|
|
352
|
-
if ("internalOptions" in currentValue) {
|
|
353
|
-
return __spreadArray(__spreadArray([], previousValue, true), currentValue.internalOptions, true);
|
|
354
|
-
}
|
|
355
|
-
else {
|
|
356
|
-
return __spreadArray(__spreadArray([], previousValue, true), [
|
|
357
|
-
convertInternalOptionToDropdownOption(currentValue),
|
|
358
|
-
], false);
|
|
359
|
-
}
|
|
360
|
-
}, []), lodash.isEqual);
|
|
361
|
-
onChange(selectedOptions, meta);
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
onChange(removeOptionHeaders(selectedInternalOptions), meta);
|
|
365
|
-
}
|
|
366
|
-
break;
|
|
367
|
-
case "deselect-option":
|
|
368
|
-
if (meta.option && "internalOptions" in meta.option) {
|
|
369
|
-
onChange(removeGroupedOptionsType(meta.option, removeOptionHeaders(selectedInternalOptions)), meta);
|
|
370
|
-
}
|
|
371
|
-
else {
|
|
372
|
-
onChange(removeOptionHeaders(selectedInternalOptions), meta);
|
|
373
|
-
}
|
|
374
|
-
break;
|
|
375
|
-
case "remove-value":
|
|
376
|
-
case "pop-value":
|
|
377
|
-
if (meta.removedValue && "internalOptions" in meta.removedValue) {
|
|
378
|
-
onChange(removeGroupedOptionsType(meta.removedValue, removeOptionHeaders(selectedInternalOptions)), meta);
|
|
379
|
-
}
|
|
380
|
-
else {
|
|
381
|
-
onChange(removeOptionHeaders(selectedInternalOptions), meta);
|
|
382
|
-
}
|
|
383
|
-
break;
|
|
384
|
-
case "clear":
|
|
385
|
-
onChange(selectedInternalOptions.map(convertInternalOptionToDropdownOption), meta);
|
|
386
|
-
break;
|
|
387
|
-
case "create-option":
|
|
388
|
-
onChange(selectedInternalOptions.map(convertInternalOptionToDropdownOption), meta);
|
|
389
|
-
break;
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
};
|
|
393
|
-
var convertGroupedDropdownOptionsToInternalOptions = function (options) {
|
|
394
|
-
return options.reduce(function (previousValue, currentValue) {
|
|
395
|
-
return __spreadArray(__spreadArray(__spreadArray([], previousValue, true), [
|
|
396
|
-
convertGroupedDropdownOptionToInternalOption(currentValue)
|
|
397
|
-
], false), currentValue.options.map(convertDropdownOptionToInternalOption), true);
|
|
398
|
-
}, []);
|
|
399
|
-
};
|
|
400
|
-
var convertValueToInternalValue = function (options, values) {
|
|
401
|
-
if (!values) {
|
|
402
|
-
return [];
|
|
403
|
-
}
|
|
404
|
-
var selectedOptions = [];
|
|
405
|
-
options.forEach(function (option) {
|
|
406
|
-
if (allOptionsExists(option.options, values)) {
|
|
407
|
-
selectedOptions.push(convertGroupedDropdownOptionToInternalOption(option));
|
|
408
|
-
}
|
|
409
|
-
selectedOptions.push.apply(selectedOptions, lodash.intersectionWith(option.options, values, lodash.isEqual).map(function (option) {
|
|
410
|
-
return convertDropdownOptionToInternalOption(option);
|
|
411
|
-
}));
|
|
412
|
-
});
|
|
413
|
-
return selectedOptions;
|
|
414
|
-
};
|
|
415
|
-
var allOptionsExists = function (options, selectedValues) {
|
|
416
|
-
if (!selectedValues) {
|
|
417
|
-
return false;
|
|
418
|
-
}
|
|
419
|
-
return (lodash.intersectionWith(options, selectedValues, lodash.isEqual).length === options.length);
|
|
420
|
-
};
|
|
421
|
-
var convertDropdownOptionToInternalOption = function (option) { return ({
|
|
422
|
-
data: option.data,
|
|
423
|
-
label: option.label,
|
|
424
|
-
value: option.value,
|
|
425
|
-
}); };
|
|
426
|
-
// TODO: can this be done `any` other way
|
|
427
|
-
var convertGroupedDropdownOptionToInternalOption = function (option) { return ({
|
|
428
|
-
data: option.label,
|
|
429
|
-
label: option.label,
|
|
430
|
-
value: option.label,
|
|
431
|
-
internalOptions: option.options,
|
|
432
|
-
}); };
|
|
433
|
-
var convertInternalOptionToDropdownOption = function (option) { return ({
|
|
434
|
-
data: option.data,
|
|
435
|
-
label: option.label,
|
|
436
|
-
value: option.value,
|
|
437
|
-
}); };
|
|
438
|
-
|
|
439
|
-
var resolveIconColor = function (theme, isFocused) {
|
|
440
|
-
return isFocused
|
|
441
|
-
? theme.menu.selectedItemHoverIconColor
|
|
442
|
-
: theme.menu.selectedItemIconColor;
|
|
443
|
-
};
|
|
444
|
-
function formatInnerOptionLabel(props) {
|
|
445
|
-
var _a;
|
|
446
|
-
var _b = props.selectProps, formatGroupLabel = _b.formatGroupLabel, formatOptionLabel = _b.formatOptionLabel;
|
|
447
|
-
if ("internalOptions" in props.data) {
|
|
448
|
-
return formatGroupLabel
|
|
449
|
-
? formatGroupLabel({
|
|
450
|
-
label: props.data.label,
|
|
451
|
-
options: props.data.internalOptions,
|
|
452
|
-
})
|
|
453
|
-
: props.label;
|
|
454
|
-
}
|
|
455
|
-
return formatOptionLabel
|
|
456
|
-
? formatOptionLabel(props.data, {
|
|
457
|
-
context: "menu",
|
|
458
|
-
inputValue: (_a = props.selectProps.inputValue) !== null && _a !== void 0 ? _a : "",
|
|
459
|
-
selectValue: props.getValue(),
|
|
460
|
-
})
|
|
461
|
-
: props.label;
|
|
462
|
-
}
|
|
463
|
-
var GroupedMultiSelect = function (_a) {
|
|
464
|
-
var onChange = _a.onChange, options = _a.options, value = _a.value, _b = _a.variant, variant = _b === void 0 ? "standard" : _b; _a.formatGroupLabel; _a.formatOptionLabel; var selectProps = __rest(_a, ["onChange", "options", "value", "variant", "formatGroupLabel", "formatOptionLabel"]);
|
|
465
|
-
var Option = function (props) {
|
|
466
|
-
var label = formatInnerOptionLabel(props);
|
|
467
|
-
var isGroupOption = "internalOptions" in props.data;
|
|
468
|
-
return (React__namespace.createElement(SelectComponent.components.Option, __assign({}, props),
|
|
469
|
-
React__namespace.createElement(core.Row, null,
|
|
470
|
-
!isGroupOption && React__namespace.createElement(core.Space, null),
|
|
471
|
-
React__namespace.createElement(InnerOption, { theme: defaultSelectTheme, size: !isGroupOption ? "small" : undefined, label: label, selected: props.isSelected, focused: props.isFocused }))));
|
|
472
|
-
};
|
|
473
|
-
var MultiValue = function (props) {
|
|
474
|
-
return !("internalOptions" in props.data) ? (React__namespace.createElement(SelectComponent.components.MultiValue, __assign({}, props))) : null;
|
|
475
|
-
};
|
|
476
|
-
var internalValue = options
|
|
477
|
-
? convertValueToInternalValue(options, value)
|
|
478
|
-
: undefined;
|
|
479
|
-
var internalOptions = options
|
|
480
|
-
? convertGroupedDropdownOptionsToInternalOptions(options)
|
|
481
|
-
: undefined;
|
|
482
|
-
return (React__namespace.createElement(MultiSelect, __assign({}, selectProps, { onChange: onChange ? createOnChange(onChange) : undefined, hideSelectedOptions: false, components: __assign(__assign({}, selectProps.components), { MultiValue: MultiValue, Option: Option }), isMulti: true, options: internalOptions, value: internalValue, variant: variant })));
|
|
483
|
-
};
|
|
484
|
-
var InnerOption = function (_a) {
|
|
485
|
-
var focused = _a.focused, label = _a.label, selected = _a.selected, size = _a.size, theme = _a.theme;
|
|
486
|
-
return (React__namespace.createElement(core.Row, { alignItems: "center", justifyContent: "space-between", flexGrow: 1 },
|
|
487
|
-
React__namespace.createElement(core.Text, { tabIndex: -1, size: size, color: "currentColor" }, label),
|
|
488
|
-
selected && (React__namespace.createElement(elements.Icon, { color: resolveIconColor(theme, focused), icon: faCheck.faCheck, size: 12 }))));
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
function ChipRow(_a) {
|
|
492
|
-
var value = _a.value, onValueChange = _a.onValueChange, _b = _a.noneSelectedLabel, noneSelectedLabel = _b === void 0 ? "None" : _b, children = _a.children;
|
|
493
|
-
return (React__namespace.createElement(core.Column, { flex: 1 },
|
|
494
|
-
React__namespace.createElement(core.Row, { flexWrap: "wrap" }, value === null || value === void 0 ? void 0 :
|
|
495
|
-
value.map(function (v) { return (React__namespace.createElement(core.Row, { key: v.value },
|
|
496
|
-
React__namespace.createElement(core.Spacing, { num: 0.5 },
|
|
497
|
-
React__namespace.createElement(elements.Chip, { label: v.label, onClickRemove: function () {
|
|
498
|
-
var _a;
|
|
499
|
-
return onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange((_a = value === null || value === void 0 ? void 0 : value.filter(function (f) { return f.value !== v.value; })) !== null && _a !== void 0 ? _a : []);
|
|
500
|
-
} })),
|
|
501
|
-
React__namespace.createElement(core.Space, null))); }),
|
|
502
|
-
(value === null || value === void 0 ? void 0 : value.length) ? (React__namespace.createElement(core.Spacing, { num: 0.5 },
|
|
503
|
-
React__namespace.createElement(elements.FlatButton, { size: "small", label: "Clear", onClick: function () { return onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange([]); } }))) : (React__namespace.createElement(core.Spacing, { num: 0.5 },
|
|
504
|
-
React__namespace.createElement(elements.Chip, { variant: "secondary", label: noneSelectedLabel })))),
|
|
505
|
-
React__namespace.createElement(core.Space, { num: 0.5 }),
|
|
506
|
-
children));
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
function _ChipMultiSelect(_a) {
|
|
510
|
-
var value = _a.value, onValueChange = _a.onValueChange, _b = _a.placeholder, placeholder = _b === void 0 ? "Type to search" : _b, loading = _a.loading, inputValue = _a.inputValue, onInputChange = _a.onInputChange, _c = _a.noneSelectedLabel, noneSelectedLabel = _c === void 0 ? "None" : _c, selectProps = __rest(_a, ["value", "onValueChange", "placeholder", "loading", "inputValue", "onInputChange", "noneSelectedLabel"]);
|
|
511
|
-
return (React__namespace.createElement(ChipRow, { noneSelectedLabel: noneSelectedLabel, onValueChange: onValueChange, value: value },
|
|
512
|
-
React__namespace.createElement(MultiSelect, __assign({}, selectProps, { isClearable: false, value: value, onChange: onValueChange ? function (value) { return onValueChange(__spreadArray([], value, true)); } : undefined, backspaceRemovesValue: false, hideSelectedOptions: true, controlShouldRenderValue: false, placeholder: placeholder, isLoading: loading, inputValue: inputValue, onInputChange: onInputChange }))));
|
|
513
|
-
}
|
|
514
|
-
var ChipMultiSelect = React__namespace.memo(_ChipMultiSelect);
|
|
515
|
-
|
|
516
|
-
function _GroupedChipMultiSelect(_a) {
|
|
517
|
-
var value = _a.value, onValueChange = _a.onValueChange, _b = _a.placeholder, placeholder = _b === void 0 ? "Type to search" : _b, loading = _a.loading, inputValue = _a.inputValue, onInputChange = _a.onInputChange, _c = _a.noneSelectedLabel, noneSelectedLabel = _c === void 0 ? "None" : _c, selectProps = __rest(_a, ["value", "onValueChange", "placeholder", "loading", "inputValue", "onInputChange", "noneSelectedLabel"]);
|
|
518
|
-
return (React__namespace.createElement(ChipRow, { noneSelectedLabel: noneSelectedLabel, onValueChange: onValueChange, value: value },
|
|
519
|
-
React__namespace.createElement(GroupedMultiSelect, __assign({}, selectProps, { isClearable: false, value: value, onChange: onValueChange ? function (value) { return onValueChange(__spreadArray([], value, true)); } : undefined, backspaceRemovesValue: false, hideSelectedOptions: true, controlShouldRenderValue: false, placeholder: placeholder, isLoading: loading, inputValue: inputValue, onInputChange: onInputChange }))));
|
|
520
|
-
}
|
|
521
|
-
var GroupedChipMultiSelect = React__namespace.memo(_GroupedChipMultiSelect);
|
|
522
|
-
|
|
523
|
-
exports.AsyncMultiSelect = AsyncMultiSelect;
|
|
524
|
-
exports.AsyncSelect = AsyncSelect;
|
|
525
|
-
exports.ChipMultiSelect = ChipMultiSelect;
|
|
526
|
-
exports.GroupedChipMultiSelect = GroupedChipMultiSelect;
|
|
527
|
-
exports.GroupedMultiSelect = GroupedMultiSelect;
|
|
528
|
-
exports.MultiSelect = MultiSelect;
|
|
529
|
-
exports.Select = Select;
|
|
530
|
-
exports.createStylesFromTheme = createStylesFromTheme;
|
|
531
|
-
exports.createStylesFromVariant = createStylesFromVariant;
|
|
532
|
-
exports.defaultSelectTheme = defaultSelectTheme;
|
|
1
|
+
(function(){ try {var elementStyle = document.createElement('style'); elementStyle.appendChild(document.createTextNode("")); document.head.appendChild(elementStyle);} catch(e) {console.error('vite-plugin-css-injected-by-js', e);} })();"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var x=require("react"),m=require("react-select"),q=require("react-select/async"),i=require("react/jsx-runtime"),u=require("@stenajs-webui/core"),C=require("@stenajs-webui/elements"),v=require("lodash");function B(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function G(e){if(e&&e.__esModule)return e;var r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return e&&Object.keys(e).forEach(function(o){if(o!=="default"){var t=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,t.get?t:{enumerable:!0,get:function(){return e[o]}})}}),r.default=e,Object.freeze(r)}var j=G(x),I=B(m),M=B(q);const w={arrowColor:{focused:{hover:"var(--lhds-color-ui-500)",standard:"var(--lhds-color-ui-500)"},closed:{hover:"var(--lhds-color-ui-500)",standard:"var(--lhds-color-ui-500)"}},clearButtonColor:{hover:"var(--lhds-color-ui-600)",standard:"var(--lhds-color-ui-500)"},input:{backgroundColor:"var(--swui-field-bg-enabled)",border:"1px solid var(--swui-select-border-color)",borderColor:"var(--swui-field-border-color)",borderColorFocused:"var(--swui-field-border-color-hover)",disabledBackgroundColor:"var(--swui-field-bg-disabled)",warningBackgroundColor:"var(--swui-state-alert-light-color)",errorBackgroundColor:"var(--swui-state-error-light-color)",successBackgroundColor:"var(--swui-state-success-light-color)",warningBorderColor:"var(--swui-state-alert-color)",errorBorderColor:"var(--swui-state-error-color)",successBorderColor:"var(--swui-state-success-color)",boxShadowFocused:"var(--swui-field-focus-shadow)",fontFamily:"var(--swui-font-primary)",fontSize:"var(--swui-font-size-inputs)",height:"32px",minHeight:"32px",placeholderColor:"var(--swui-field-border-color-disabled)",textColor:"var(--swui-field-text-color)",borderRadius:"var(--swui-field-border-radius)"},loadingIndicator:{textColor:"var(--swui-field-text-color)"},menu:{activeBackgroundColor:"var(--lhds-color-blue-100)",activeTextColor:"var(--swui-field-text-color)",selectedItemActiveBackgroundColor:"var(--lhds-color-blue-500)",selectedItemActiveTextColor:"var(--lhds-color-blue-50)",disabledTextColor:"var(--swui-field-text-color-disabled)",disabledBackgroundColor:"var(--swui-field-bg-disabled)",textColor:"var(--swui-field-text-color)",backgroundColor:"var(--swui-field-bg-enabled)",hoverTextColor:"var(--swui-field-text-color)",hoverBackgroundColor:"var(--lhds-color-blue-200)",selectedItemTextColor:"var(--lhds-color-blue-500)",selectedItemIconColor:"var(--lhds-color-blue-500)",selectedItemHoverTextColor:"var(--swui-field-text-color)",selectedItemHoverIconColor:"var(--swui-field-text-color)",selectedItemBackgroundColor:"var(--lhds-color-blue-50)",selectedItemHoverBackgroundColor:"var(--lhds-color-blue-50)",zIndex:1,width:"auto",minWidth:"100%",whiteSpace:"nowrap"},menuPortal:{zIndex:1},multiSelect:{backgroundColor:"var(--swui-primary-action-color)",textColor:"var(--lhds-color-blue-50)",removeButtonBackgroundColor:"transparent",removeButtonTextColor:"var(--swui-white)",removeButtonHoverBackgroundColor:"var(--swui-primary-action-color-hover)",removeButtonHoverTextColor:"var(--swui-white)"}},A=(e,r,o,t)=>r?e.disabledBackgroundColor:o&&t?e.selectedItemHoverBackgroundColor:o?e.selectedItemBackgroundColor:t?e.hoverBackgroundColor:void 0,L=(e,r,o,t)=>r?e.disabledTextColor:o&&t?e.selectedItemHoverTextColor:o?e.selectedItemTextColor:t?e.hoverTextColor:void 0,W=(e,r,o,t)=>r?e.disabledBackgroundColor:o?e.backgroundColor:t==="warning"?e.warningBackgroundColor:t==="success"?e.successBackgroundColor:t==="error"?e.errorBackgroundColor:e.backgroundColor,k=(e,r,o,t,n)=>r?e.borderColor:o?e.borderColorFocused:n==="warning"?e.warningBorderColor:n==="success"?e.successBorderColor:n==="error"?e.errorBorderColor:t?e.borderColorFocused:e.borderColor,T=({menu:e,menuPortal:r,input:o,multiSelect:t,clearButtonColor:n,arrowColor:a,loadingIndicator:d},f)=>({option:(l,{isDisabled:c,isFocused:b,isSelected:s})=>({...l,fontFamily:o.fontFamily,fontSize:o.fontSize,backgroundColor:A(e,c,s,b),color:L(e,c,s,b),cursor:c?"not-allowed":"default",whiteSpace:e.whiteSpace||l.whiteSpace,":active":{backgroundColor:c?void 0:s?e.selectedItemActiveBackgroundColor:e.activeBackgroundColor,color:c?void 0:s?e.selectedItemActiveTextColor:e.activeTextColor}}),control:(l,{isFocused:c,isDisabled:b,menuIsOpen:s})=>({...l,fontFamily:o.fontFamily,fontSize:o.fontSize,minHeight:o.minHeight,backgroundColor:W(o,b,c,f),borderRadius:o.borderRadius,border:o.border,"--swui-select-border-color":k(o,b,c||s,!1,f),boxShadow:c?o.boxShadowFocused:void 0,"&:hover":{"--swui-select-border-color":k(o,!1,c||s,!0,f)}}),singleValue:l=>({...l,fontFamily:o.fontFamily,fontSize:o.fontSize,color:o.textColor}),noOptionsMessage:l=>({...l,fontFamily:o.fontFamily,fontSize:o.fontSize}),input:l=>({...l,fontFamily:o.fontFamily,fontSize:o.fontSize,color:o.textColor}),groupHeading:l=>({...l,fontFamily:o.fontFamily}),multiValueLabel:l=>({...l,backgroundColor:t.backgroundColor,color:t.textColor,fontFamily:o.fontFamily,fontSize:"12px"}),indicatorSeparator:l=>({...l,display:"none"}),clearIndicator:l=>({...l,padding:"5px",color:n.standard,"&:hover":{color:n.hover},cursor:"pointer"}),placeholder:l=>({...l,fontFamily:o.fontFamily,fontSize:o.fontSize,color:o.placeholderColor}),container:l=>({...l}),valueContainer:l=>({...l,padding:"0 8px"}),dropdownIndicator:(l,{isFocused:c})=>({...l,padding:"5px",color:c?a.focused.standard:a.closed.standard,"&:hover":{color:c?a.focused.hover:a.closed.hover},svg:{width:14,height:14}}),menu:l=>({...l,backgroundColor:e.backgroundColor,color:e.textColor,minWidth:e.minWidth||l.minWidth,zIndex:e.zIndex,width:e.width||l.width,border:o.border,borderColor:o.borderColorFocused}),menuPortal:l=>({...l,zIndex:r.zIndex}),multiValueRemove:l=>({...l,backgroundColor:t.removeButtonBackgroundColor,":hover":{color:t.removeButtonHoverTextColor,backgroundColor:t.removeButtonHoverBackgroundColor},color:t.removeButtonTextColor,borderRadius:"50%",width:16,height:16,padding:0,margin:3,marginTop:4,display:"flex",justifyContent:"center",alignItems:"center",cursor:"pointer"}),multiValue:l=>({...l,backgroundColor:t.backgroundColor,color:t.textColor,fontFamily:o.fontFamily,fontSize:"12px",alignItems:"center",margin:0,marginRight:2}),loadingMessage:l=>({...l,color:d.textColor,fontFamily:o.fontFamily,fontSize:o.fontSize})}),g=e=>T(w,e),E=({variant:e="standard",styles:r,isMulti:o,...t})=>{const n=x.useMemo(()=>{const a=g(e);return r?m.mergeStyles(a,r):a},[e,r]);return i.jsx(M.default,{styles:n,...t,isMulti:!0})},P=({variant:e="standard",styles:r,isMulti:o,...t})=>{const n=x.useMemo(()=>{const a=g(e);return r?m.mergeStyles(a,r):a},[e,r]);return i.jsx(M.default,{styles:n,...t,isMulti:!1})},S=({variant:e="standard",styles:r,isMulti:o,...t})=>{const n=x.useMemo(()=>{const a=g(e);return r?m.mergeStyles(a,r):a},[e,r]);return i.jsx(I.default,{styles:n,...t,isMulti:!0})},N=({variant:e="standard",styles:r,isMulti:o,...t})=>{const n=x.useMemo(()=>{const a=g(e);return r?m.mergeStyles(a,r):a},[e,r]);return i.jsx(I.default,{styles:n,...t,isMulti:!1})},O=(e,r)=>v.differenceWith(r,[...e.internalOptions,e],v.isEqual).map(p),V=e=>!("internalOptions"in e),h=e=>e.filter(V).map(p),D=e=>(r,o)=>{const t=r!=null?r:[];switch(o.action){case"select-option":if(o.option&&"internalOptions"in o.option){const n=v.uniqWith(t.reduce((a,d)=>"internalOptions"in d?[...a,...d.internalOptions]:[...a,p(d)],[]),v.isEqual);e(n,o)}else e(h(t),o);break;case"deselect-option":o.option&&"internalOptions"in o.option?e(O(o.option,h(t)),o):e(h(t),o);break;case"remove-value":case"pop-value":o.removedValue&&"internalOptions"in o.removedValue?e(O(o.removedValue,h(t)),o):e(h(t),o);break;case"clear":e(t.map(p),o);break;case"create-option":e(t.map(p),o);break}},J=e=>e.reduce((r,o)=>[...r,F(o),...o.options.map(z)],[]),K=(e,r)=>{if(!r)return[];const o=[];return e.forEach(t=>{Q(t.options,r)&&o.push(F(t)),o.push(...v.intersectionWith(t.options,r,v.isEqual).map(n=>z(n)))}),o},Q=(e,r)=>r?v.intersectionWith(e,r,v.isEqual).length===e.length:!1,z=e=>({data:e.data,label:e.label,value:e.value}),F=e=>({data:e.label,label:e.label,value:e.label,internalOptions:e.options}),p=e=>({data:e.data,label:e.label,value:e.value}),U=(e,r)=>r?e.menu.selectedItemHoverIconColor:e.menu.selectedItemIconColor;function X(e){var t;const{formatGroupLabel:r,formatOptionLabel:o}=e.selectProps;return"internalOptions"in e.data?r?r({label:e.data.label,options:e.data.internalOptions}):e.label:o?o(e.data,{context:"menu",inputValue:(t=e.selectProps.inputValue)!=null?t:"",selectValue:e.getValue()}):e.label}const R=({onChange:e,options:r,value:o,variant:t="standard",formatGroupLabel:n,formatOptionLabel:a,...d})=>{const f=s=>{const _=X(s),y="internalOptions"in s.data;return i.jsx(m.components.Option,{...s,children:i.jsxs(u.Row,{children:[!y&&i.jsx(u.Space,{}),i.jsx(Y,{theme:w,size:y?void 0:"small",label:_,selected:s.isSelected,focused:s.isFocused})]})})},l=s=>"internalOptions"in s.data?null:i.jsx(m.components.MultiValue,{...s}),c=r?K(r,o):void 0,b=r?J(r):void 0;return i.jsx(S,{...d,onChange:e?D(e):void 0,hideSelectedOptions:!1,components:{...d.components,MultiValue:l,Option:f},isMulti:!0,options:b,value:c,variant:t})},Y=({focused:e,label:r,selected:o,size:t,theme:n})=>i.jsxs(u.Row,{alignItems:"center",justifyContent:"space-between",flexGrow:1,children:[i.jsx(u.Text,{tabIndex:-1,size:t,color:"currentColor",children:r}),o&&i.jsx(C.Icon,{color:U(n,e),icon:C.stenaCheck,size:12})]});function H({value:e,onValueChange:r,noneSelectedLabel:o="None",children:t}){return i.jsxs(u.Column,{flex:1,children:[i.jsxs(u.Row,{flexWrap:"wrap",children:[e==null?void 0:e.map(n=>i.jsxs(u.Row,{children:[i.jsx(u.Spacing,{num:.5,children:i.jsx(C.Chip,{label:n.label,onClickRemove:()=>{var a;return r==null?void 0:r((a=e==null?void 0:e.filter(d=>d.value!==n.value))!=null?a:[])}})}),i.jsx(u.Space,{})]},n.value)),e!=null&&e.length?i.jsx(u.Spacing,{num:.5,children:i.jsx(C.FlatButton,{size:"small",label:"Clear",onClick:()=>r==null?void 0:r([])})}):i.jsx(u.Spacing,{num:.5,children:i.jsx(C.Chip,{variant:"secondary",label:o})})]}),i.jsx(u.Space,{num:.5}),t]})}function Z({value:e,onValueChange:r,placeholder:o="Type to search",loading:t,inputValue:n,onInputChange:a,noneSelectedLabel:d="None",...f}){return i.jsx(H,{noneSelectedLabel:d,onValueChange:r,value:e,children:i.jsx(S,{...f,isClearable:!1,value:e,onChange:r?l=>r([...l]):void 0,backspaceRemovesValue:!1,hideSelectedOptions:!0,controlShouldRenderValue:!1,placeholder:o,isLoading:t,inputValue:n,onInputChange:a})})}const $=j.memo(Z);function ee({value:e,onValueChange:r,placeholder:o="Type to search",loading:t,inputValue:n,onInputChange:a,noneSelectedLabel:d="None",...f}){return i.jsx(H,{noneSelectedLabel:d,onValueChange:r,value:e,children:i.jsx(R,{...f,isClearable:!1,value:e,onChange:r?l=>r([...l]):void 0,backspaceRemovesValue:!1,hideSelectedOptions:!0,controlShouldRenderValue:!1,placeholder:o,isLoading:t,inputValue:n,onInputChange:a})})}const oe=j.memo(ee);exports.AsyncMultiSelect=E;exports.AsyncSelect=P;exports.ChipMultiSelect=$;exports.GroupedChipMultiSelect=oe;exports.GroupedMultiSelect=R;exports.MultiSelect=S;exports.Select=N;exports.createStylesFromTheme=T;exports.createStylesFromVariant=g;exports.defaultSelectTheme=w;
|
|
533
2
|
//# sourceMappingURL=index.js.map
|