@stenajs-webui/select 17.13.2 → 17.13.3

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/index.es.js CHANGED
@@ -1,12 +1,13 @@
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);} })();import * as React from "react";
2
- import { useMemo } from "react";
3
- import SelectComponent, { mergeStyles, components } from "react-select";
4
- import AsyncComponent from "react-select/async";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
- import { Row, Space, Text, Column, Spacing } from "@stenajs-webui/core";
7
- import { Icon, stenaCheck, Chip, FlatButton } from "@stenajs-webui/elements";
8
- import { differenceWith, isEqual, uniqWith, intersectionWith } from "lodash";
9
- const defaultSelectTheme = {
1
+ (function(){"use strict";try{var e=document.createElement("style");e.appendChild(document.createTextNode("")),document.head.appendChild(e)}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
+ import * as T from "react";
3
+ import { useMemo as p } from "react";
4
+ import F, { mergeStyles as g, components as B } from "react-select";
5
+ import M from "react-select/async";
6
+ import { jsx as a, jsxs as m } from "react/jsx-runtime";
7
+ import { Row as C, Space as S, Text as j, Column as E, Spacing as k } from "@stenajs-webui/core";
8
+ import { Icon as N, stenaCheck as P, Chip as I, FlatButton as q } from "@stenajs-webui/elements";
9
+ import { uniqWith as V, isEqual as w, intersectionWith as R, differenceWith as _ } from "lodash";
10
+ const H = {
10
11
  arrowColor: {
11
12
  focused: {
12
13
  hover: "var(--lhds-color-ui-500)",
@@ -23,7 +24,7 @@ const defaultSelectTheme = {
23
24
  },
24
25
  input: {
25
26
  backgroundColor: "var(--swui-field-bg-enabled)",
26
- border: `1px solid var(--swui-select-border-color)`,
27
+ border: "1px solid var(--swui-select-border-color)",
27
28
  borderColor: "var(--swui-field-border-color)",
28
29
  borderColorFocused: "var(--swui-field-border-color-hover)",
29
30
  disabledBackgroundColor: "var(--swui-field-bg-disabled)",
@@ -85,195 +86,158 @@ const defaultSelectTheme = {
85
86
  removeButtonHoverBackgroundColor: "var(--swui-primary-action-color-hover)",
86
87
  removeButtonHoverTextColor: "var(--swui-white)"
87
88
  }
88
- };
89
- const resolveOptionBackgroundColor = (colors, isDisabled, isSelected, isFocused) => {
90
- if (isDisabled) {
91
- return colors.disabledBackgroundColor;
92
- } else if (isSelected && isFocused) {
93
- return colors.selectedItemHoverBackgroundColor;
94
- } else if (isSelected) {
95
- return colors.selectedItemBackgroundColor;
96
- } else if (isFocused) {
97
- return colors.hoverBackgroundColor;
98
- } else {
99
- return void 0;
100
- }
101
- };
102
- const resolveOptionColor = (colors, isDisabled, isSelected, isFocused) => {
103
- if (isDisabled) {
104
- return colors.disabledTextColor;
105
- } else if (isSelected && isFocused) {
106
- return colors.selectedItemHoverTextColor;
107
- } else if (isSelected) {
108
- return colors.selectedItemTextColor;
109
- } else if (isFocused) {
110
- return colors.hoverTextColor;
111
- } else {
112
- return void 0;
113
- }
114
- };
115
- const resolveInputBackgroundColor = (colors, isDisabled, isFocused, variant) => {
116
- if (isDisabled) {
117
- return colors.disabledBackgroundColor;
118
- } else if (isFocused) {
119
- return colors.backgroundColor;
120
- } else if (variant === "warning") {
121
- return colors.warningBackgroundColor;
122
- } else if (variant === "success") {
123
- return colors.successBackgroundColor;
124
- } else if (variant === "error") {
125
- return colors.errorBackgroundColor;
126
- } else {
127
- return colors.backgroundColor;
128
- }
129
- };
130
- const resolveInputBorderColor = (colors, isDisabled, isFocused, isHovered, variant) => {
131
- if (isDisabled) {
132
- return colors.borderColor;
133
- } else if (isFocused) {
134
- return colors.borderColorFocused;
135
- } else if (variant === "warning") {
136
- return colors.warningBorderColor;
137
- } else if (variant === "success") {
138
- return colors.successBorderColor;
139
- } else if (variant === "error") {
140
- return colors.errorBorderColor;
141
- } else if (isHovered) {
142
- return colors.borderColorFocused;
143
- } else {
144
- return colors.borderColor;
145
- }
146
- };
147
- const createStylesFromTheme = ({
148
- menu,
149
- menuPortal,
150
- input,
151
- multiSelect,
152
- clearButtonColor,
153
- arrowColor,
154
- groupHeading,
155
- loadingIndicator
156
- }, variant) => ({
157
- option: (base, { isDisabled, isFocused, isSelected }) => ({
158
- ...base,
159
- fontFamily: input.fontFamily,
160
- fontSize: input.fontSize,
161
- backgroundColor: resolveOptionBackgroundColor(menu, isDisabled, isSelected, isFocused),
162
- color: resolveOptionColor(menu, isDisabled, isSelected, isFocused),
163
- cursor: isDisabled ? "not-allowed" : "default",
164
- whiteSpace: menu.whiteSpace || base.whiteSpace,
89
+ }, J = (o, r, e, t) => r ? o.disabledBackgroundColor : e && t ? o.selectedItemHoverBackgroundColor : e ? o.selectedItemBackgroundColor : t ? o.hoverBackgroundColor : void 0, K = (o, r, e, t) => r ? o.disabledTextColor : e && t ? o.selectedItemHoverTextColor : e ? o.selectedItemTextColor : t ? o.hoverTextColor : void 0, Q = (o, r, e, t) => r ? o.disabledBackgroundColor : e ? o.backgroundColor : t === "warning" ? o.warningBackgroundColor : t === "success" ? o.successBackgroundColor : t === "error" ? o.errorBackgroundColor : o.backgroundColor, O = (o, r, e, t, n) => r ? o.borderColor : e ? o.borderColorFocused : n === "warning" ? o.warningBorderColor : n === "success" ? o.successBorderColor : n === "error" ? o.errorBorderColor : t ? o.borderColorFocused : o.borderColor, U = ({
90
+ menu: o,
91
+ menuPortal: r,
92
+ input: e,
93
+ multiSelect: t,
94
+ clearButtonColor: n,
95
+ arrowColor: i,
96
+ groupHeading: c,
97
+ loadingIndicator: v
98
+ }, u) => ({
99
+ option: (l, { isDisabled: d, isFocused: s, isSelected: f }) => ({
100
+ ...l,
101
+ fontFamily: e.fontFamily,
102
+ fontSize: e.fontSize,
103
+ backgroundColor: J(
104
+ o,
105
+ d,
106
+ f,
107
+ s
108
+ ),
109
+ color: K(o, d, f, s),
110
+ cursor: d ? "not-allowed" : "default",
111
+ whiteSpace: o.whiteSpace || l.whiteSpace,
165
112
  ":active": {
166
- backgroundColor: isDisabled ? void 0 : isSelected ? menu.selectedItemActiveBackgroundColor : menu.activeBackgroundColor,
167
- color: isDisabled ? void 0 : isSelected ? menu.selectedItemActiveTextColor : menu.activeTextColor
113
+ backgroundColor: d ? void 0 : f ? o.selectedItemActiveBackgroundColor : o.activeBackgroundColor,
114
+ color: d ? void 0 : f ? o.selectedItemActiveTextColor : o.activeTextColor
168
115
  }
169
116
  }),
170
- control: (base, { isFocused, isDisabled, menuIsOpen }) => ({
171
- ...base,
172
- fontFamily: input.fontFamily,
173
- fontSize: input.fontSize,
174
- minHeight: input.minHeight,
175
- backgroundColor: resolveInputBackgroundColor(input, isDisabled, isFocused, variant),
176
- borderRadius: input.borderRadius,
177
- border: input.border,
178
- "--swui-select-border-color": resolveInputBorderColor(input, isDisabled, isFocused || menuIsOpen, false, variant),
179
- boxShadow: isFocused ? input.boxShadowFocused : void 0,
117
+ control: (l, { isFocused: d, isDisabled: s, menuIsOpen: f }) => ({
118
+ ...l,
119
+ fontFamily: e.fontFamily,
120
+ fontSize: e.fontSize,
121
+ minHeight: e.minHeight,
122
+ backgroundColor: Q(
123
+ e,
124
+ s,
125
+ d,
126
+ u
127
+ ),
128
+ borderRadius: e.borderRadius,
129
+ border: e.border,
130
+ "--swui-select-border-color": O(
131
+ e,
132
+ s,
133
+ d || f,
134
+ !1,
135
+ u
136
+ ),
137
+ boxShadow: d ? e.boxShadowFocused : void 0,
180
138
  "&:hover": {
181
- "--swui-select-border-color": resolveInputBorderColor(input, false, isFocused || menuIsOpen, true, variant)
139
+ "--swui-select-border-color": O(
140
+ e,
141
+ !1,
142
+ d || f,
143
+ !0,
144
+ u
145
+ )
182
146
  }
183
147
  }),
184
- singleValue: (base) => ({
185
- ...base,
186
- fontFamily: input.fontFamily,
187
- fontSize: input.fontSize,
188
- color: input.textColor
148
+ singleValue: (l) => ({
149
+ ...l,
150
+ fontFamily: e.fontFamily,
151
+ fontSize: e.fontSize,
152
+ color: e.textColor
189
153
  }),
190
- noOptionsMessage: (base) => ({
191
- ...base,
192
- fontFamily: input.fontFamily,
193
- fontSize: input.fontSize
154
+ noOptionsMessage: (l) => ({
155
+ ...l,
156
+ fontFamily: e.fontFamily,
157
+ fontSize: e.fontSize
194
158
  }),
195
- input: (base) => ({
196
- ...base,
197
- fontFamily: input.fontFamily,
198
- fontSize: input.fontSize,
199
- color: input.textColor
159
+ input: (l) => ({
160
+ ...l,
161
+ fontFamily: e.fontFamily,
162
+ fontSize: e.fontSize,
163
+ color: e.textColor
200
164
  }),
201
- groupHeading: (base) => ({
202
- ...base,
203
- fontFamily: input.fontFamily,
204
- fontSize: groupHeading.fontSize,
205
- lineHeight: groupHeading.lineHeight,
206
- fontWeight: groupHeading.fontWeight,
207
- color: groupHeading.color,
208
- letterSpacing: groupHeading.letterSpacing
165
+ groupHeading: (l) => ({
166
+ ...l,
167
+ fontFamily: e.fontFamily,
168
+ fontSize: c.fontSize,
169
+ lineHeight: c.lineHeight,
170
+ fontWeight: c.fontWeight,
171
+ color: c.color,
172
+ letterSpacing: c.letterSpacing
209
173
  }),
210
- multiValueLabel: (base) => ({
211
- ...base,
212
- backgroundColor: multiSelect.backgroundColor,
213
- color: multiSelect.textColor,
214
- fontFamily: input.fontFamily,
215
- fontSize: groupHeading.fontSize
174
+ multiValueLabel: (l) => ({
175
+ ...l,
176
+ backgroundColor: t.backgroundColor,
177
+ color: t.textColor,
178
+ fontFamily: e.fontFamily,
179
+ fontSize: c.fontSize
216
180
  }),
217
- indicatorSeparator: (base) => ({
218
- ...base,
181
+ indicatorSeparator: (l) => ({
182
+ ...l,
219
183
  display: "none"
220
184
  }),
221
- clearIndicator: (base) => ({
222
- ...base,
185
+ clearIndicator: (l) => ({
186
+ ...l,
223
187
  padding: "5px",
224
- color: clearButtonColor.standard,
188
+ color: n.standard,
225
189
  "&:hover": {
226
- color: clearButtonColor.hover
190
+ color: n.hover
227
191
  },
228
192
  cursor: "pointer"
229
193
  }),
230
- placeholder: (base) => ({
231
- ...base,
232
- fontFamily: input.fontFamily,
233
- fontSize: input.fontSize,
234
- color: input.placeholderColor
194
+ placeholder: (l) => ({
195
+ ...l,
196
+ fontFamily: e.fontFamily,
197
+ fontSize: e.fontSize,
198
+ color: e.placeholderColor
235
199
  }),
236
- container: (base) => ({
237
- ...base
200
+ container: (l) => ({
201
+ ...l
238
202
  }),
239
- valueContainer: (base) => ({
240
- ...base,
203
+ valueContainer: (l) => ({
204
+ ...l,
241
205
  padding: "0 8px"
242
206
  }),
243
- dropdownIndicator: (base, { isFocused }) => ({
244
- ...base,
207
+ dropdownIndicator: (l, { isFocused: d }) => ({
208
+ ...l,
245
209
  padding: "5px",
246
- color: isFocused ? arrowColor.focused.standard : arrowColor.closed.standard,
210
+ color: d ? i.focused.standard : i.closed.standard,
247
211
  "&:hover": {
248
- color: isFocused ? arrowColor.focused.hover : arrowColor.closed.hover
212
+ color: d ? i.focused.hover : i.closed.hover
249
213
  },
250
214
  svg: {
251
215
  width: 14,
252
216
  height: 14
253
217
  }
254
218
  }),
255
- menu: (base) => ({
256
- ...base,
257
- backgroundColor: menu.backgroundColor,
258
- color: menu.textColor,
259
- minWidth: menu.minWidth || base.minWidth,
260
- zIndex: menu.zIndex,
261
- width: menu.width || base.width,
262
- border: input.border,
263
- borderColor: input.borderColorFocused
219
+ menu: (l) => ({
220
+ ...l,
221
+ backgroundColor: o.backgroundColor,
222
+ color: o.textColor,
223
+ minWidth: o.minWidth || l.minWidth,
224
+ zIndex: o.zIndex,
225
+ width: o.width || l.width,
226
+ border: e.border,
227
+ borderColor: e.borderColorFocused
264
228
  }),
265
- menuPortal: (base) => ({
266
- ...base,
267
- zIndex: menuPortal.zIndex
229
+ menuPortal: (l) => ({
230
+ ...l,
231
+ zIndex: r.zIndex
268
232
  }),
269
- multiValueRemove: (styles) => ({
270
- ...styles,
271
- backgroundColor: multiSelect.removeButtonBackgroundColor,
233
+ multiValueRemove: (l) => ({
234
+ ...l,
235
+ backgroundColor: t.removeButtonBackgroundColor,
272
236
  ":hover": {
273
- color: multiSelect.removeButtonHoverTextColor,
274
- backgroundColor: multiSelect.removeButtonHoverBackgroundColor
237
+ color: t.removeButtonHoverTextColor,
238
+ backgroundColor: t.removeButtonHoverBackgroundColor
275
239
  },
276
- color: multiSelect.removeButtonTextColor,
240
+ color: t.removeButtonTextColor,
277
241
  borderRadius: "50%",
278
242
  width: 16,
279
243
  height: 16,
@@ -285,364 +249,363 @@ const createStylesFromTheme = ({
285
249
  alignItems: "center",
286
250
  cursor: "pointer"
287
251
  }),
288
- multiValue: (base) => ({
289
- ...base,
290
- backgroundColor: multiSelect.backgroundColor,
291
- color: multiSelect.textColor,
292
- fontFamily: input.fontFamily,
293
- fontSize: groupHeading.fontSize,
252
+ multiValue: (l) => ({
253
+ ...l,
254
+ backgroundColor: t.backgroundColor,
255
+ color: t.textColor,
256
+ fontFamily: e.fontFamily,
257
+ fontSize: c.fontSize,
294
258
  alignItems: "center",
295
259
  margin: 0,
296
260
  marginRight: 2
297
261
  }),
298
- loadingMessage: (base) => ({
299
- ...base,
300
- color: loadingIndicator.textColor,
301
- fontFamily: input.fontFamily,
302
- fontSize: input.fontSize
262
+ loadingMessage: (l) => ({
263
+ ...l,
264
+ color: v.textColor,
265
+ fontFamily: e.fontFamily,
266
+ fontSize: e.fontSize
303
267
  })
304
- });
305
- const createStylesFromVariant = (variant) => createStylesFromTheme(defaultSelectTheme, variant);
306
- const AsyncMultiSelect = ({
307
- variant = "standard",
308
- styles,
309
- isMulti,
310
- ...selectProps
311
- }) => {
312
- const selectStyles = useMemo(() => {
313
- const sourceStyles = createStylesFromVariant(variant);
314
- return styles ? mergeStyles(sourceStyles, styles) : sourceStyles;
315
- }, [variant, styles]);
316
- return /* @__PURE__ */ jsx(AsyncComponent, {
317
- styles: selectStyles,
318
- ...selectProps,
319
- isMulti: true
268
+ }), x = (o) => U(H, o);
269
+ function ho({
270
+ variant: o = "standard",
271
+ styles: r,
272
+ isMulti: e,
273
+ ...t
274
+ }) {
275
+ const n = p(() => {
276
+ const i = x(o);
277
+ return r ? g(i, r) : i;
278
+ }, [o, r]);
279
+ return /* @__PURE__ */ a(M, {
280
+ styles: n,
281
+ ...t,
282
+ isMulti: !0
320
283
  });
321
- };
322
- const AsyncSelect = ({
323
- variant = "standard",
324
- styles,
325
- isMulti,
326
- ...selectProps
327
- }) => {
328
- const selectStyles = useMemo(() => {
329
- const sourceStyles = createStylesFromVariant(variant);
330
- return styles ? mergeStyles(sourceStyles, styles) : sourceStyles;
331
- }, [variant, styles]);
332
- return /* @__PURE__ */ jsx(AsyncComponent, {
333
- styles: selectStyles,
334
- ...selectProps,
335
- isMulti: false
284
+ }
285
+ function mo({
286
+ variant: o = "standard",
287
+ styles: r,
288
+ isMulti: e,
289
+ ...t
290
+ }) {
291
+ const n = p(() => {
292
+ const i = x(o);
293
+ return r ? g(i, r) : i;
294
+ }, [o, r]);
295
+ return /* @__PURE__ */ a(M, {
296
+ styles: n,
297
+ ...t,
298
+ isMulti: !1
336
299
  });
337
- };
338
- const MultiSelect = ({
339
- variant = "standard",
340
- styles,
341
- isMulti,
342
- ...selectProps
343
- }) => {
344
- const selectStyles = useMemo(() => {
345
- const sourceStyles = createStylesFromVariant(variant);
346
- return styles ? mergeStyles(sourceStyles, styles) : sourceStyles;
347
- }, [variant, styles]);
348
- return /* @__PURE__ */ jsx(SelectComponent, {
349
- styles: selectStyles,
350
- ...selectProps,
351
- isMulti: true
300
+ }
301
+ function W({
302
+ variant: o = "standard",
303
+ styles: r,
304
+ isMulti: e,
305
+ ...t
306
+ }) {
307
+ const n = p(() => {
308
+ const i = x(o);
309
+ return r ? g(i, r) : i;
310
+ }, [o, r]);
311
+ return /* @__PURE__ */ a(F, {
312
+ styles: n,
313
+ ...t,
314
+ isMulti: !0
352
315
  });
353
- };
354
- const Select = ({
355
- variant = "standard",
356
- styles,
357
- isMulti,
358
- ...selectProps
359
- }) => {
360
- const selectStyles = useMemo(() => {
361
- const sourceStyles = createStylesFromVariant(variant);
362
- return styles ? mergeStyles(sourceStyles, styles) : sourceStyles;
363
- }, [variant, styles]);
364
- return /* @__PURE__ */ jsx(SelectComponent, {
365
- styles: selectStyles,
366
- ...selectProps,
367
- isMulti: false
316
+ }
317
+ function bo({
318
+ variant: o = "standard",
319
+ styles: r,
320
+ isMulti: e,
321
+ ...t
322
+ }) {
323
+ const n = p(() => {
324
+ const i = x(o);
325
+ return r ? g(i, r) : i;
326
+ }, [o, r]);
327
+ return /* @__PURE__ */ a(F, {
328
+ styles: n,
329
+ ...t,
330
+ isMulti: !1
368
331
  });
369
- };
370
- const removeGroupedOptionsType = (removedValue, selectedInternalOptions) => differenceWith(selectedInternalOptions, [...removedValue.internalOptions, removedValue], isEqual).map(convertInternalOptionToDropdownOption);
371
- const removeInternalOptions = (selectedInternalOption) => !("internalOptions" in selectedInternalOption);
372
- const removeOptionHeaders = (selectedInternalOptions) => selectedInternalOptions.filter(removeInternalOptions).map(convertInternalOptionToDropdownOption);
373
- const createOnChange = (onChange) => (incomingSelectedInternalOptions, meta) => {
374
- const selectedInternalOptions = incomingSelectedInternalOptions != null ? incomingSelectedInternalOptions : [];
375
- switch (meta.action) {
332
+ }
333
+ const z = (o, r) => _(
334
+ r,
335
+ [...o.internalOptions, o],
336
+ w
337
+ ).map(b), X = (o) => !("internalOptions" in o), h = (o) => o.filter(X).map(b), Y = (o) => (r, e) => {
338
+ const t = r != null ? r : [];
339
+ switch (e.action) {
376
340
  case "select-option":
377
- if (meta.option && "internalOptions" in meta.option) {
378
- const selectedOptions = uniqWith(selectedInternalOptions.reduce((previousValue, currentValue) => {
379
- if ("internalOptions" in currentValue) {
380
- return [...previousValue, ...currentValue.internalOptions];
381
- } else {
382
- return [
383
- ...previousValue,
384
- convertInternalOptionToDropdownOption(currentValue)
385
- ];
386
- }
387
- }, []), isEqual);
388
- onChange(selectedOptions, meta);
389
- } else {
390
- onChange(removeOptionHeaders(selectedInternalOptions), meta);
391
- }
341
+ if (e.option && "internalOptions" in e.option) {
342
+ const n = V(
343
+ t.reduce(
344
+ (i, c) => "internalOptions" in c ? [...i, ...c.internalOptions] : [
345
+ ...i,
346
+ b(c)
347
+ ],
348
+ []
349
+ ),
350
+ w
351
+ );
352
+ o(n, e);
353
+ } else
354
+ o(h(t), e);
392
355
  break;
393
356
  case "deselect-option":
394
- if (meta.option && "internalOptions" in meta.option) {
395
- onChange(removeGroupedOptionsType(meta.option, removeOptionHeaders(selectedInternalOptions)), meta);
396
- } else {
397
- onChange(removeOptionHeaders(selectedInternalOptions), meta);
398
- }
357
+ e.option && "internalOptions" in e.option ? o(
358
+ z(
359
+ e.option,
360
+ h(t)
361
+ ),
362
+ e
363
+ ) : o(h(t), e);
399
364
  break;
400
365
  case "remove-value":
401
366
  case "pop-value":
402
- if (meta.removedValue && "internalOptions" in meta.removedValue) {
403
- onChange(removeGroupedOptionsType(meta.removedValue, removeOptionHeaders(selectedInternalOptions)), meta);
404
- } else {
405
- onChange(removeOptionHeaders(selectedInternalOptions), meta);
406
- }
367
+ e.removedValue && "internalOptions" in e.removedValue ? o(
368
+ z(
369
+ e.removedValue,
370
+ h(t)
371
+ ),
372
+ e
373
+ ) : o(h(t), e);
407
374
  break;
408
375
  case "clear":
409
- onChange(selectedInternalOptions.map(convertInternalOptionToDropdownOption), meta);
376
+ o(
377
+ t.map(b),
378
+ e
379
+ );
410
380
  break;
411
381
  case "create-option":
412
- onChange(selectedInternalOptions.map(convertInternalOptionToDropdownOption), meta);
382
+ o(
383
+ t.map(b),
384
+ e
385
+ );
413
386
  break;
414
387
  }
415
- };
416
- const convertGroupedDropdownOptionsToInternalOptions = (options) => {
417
- return options.reduce((previousValue, currentValue) => {
418
- return [
419
- ...previousValue,
420
- convertGroupedDropdownOptionToInternalOption(currentValue),
421
- ...currentValue.options.map(convertDropdownOptionToInternalOption)
422
- ];
423
- }, []);
424
- };
425
- const convertValueToInternalValue = (options, values) => {
426
- if (!values) {
388
+ }, Z = (o) => o.reduce(
389
+ (r, e) => [
390
+ ...r,
391
+ L(e),
392
+ ...e.options.map(G)
393
+ ],
394
+ []
395
+ ), $ = (o, r) => {
396
+ if (!r)
427
397
  return [];
428
- }
429
- const selectedOptions = [];
430
- options.forEach((option) => {
431
- if (allOptionsExists(option.options, values)) {
432
- selectedOptions.push(convertGroupedDropdownOptionToInternalOption(option));
433
- }
434
- selectedOptions.push(...intersectionWith(option.options, values, isEqual).map((option2) => convertDropdownOptionToInternalOption(option2)));
435
- });
436
- return selectedOptions;
437
- };
438
- const allOptionsExists = (options, selectedValues) => {
439
- if (!selectedValues) {
440
- return false;
441
- }
442
- return intersectionWith(options, selectedValues, isEqual).length === options.length;
443
- };
444
- const convertDropdownOptionToInternalOption = (option) => ({
445
- data: option.data,
446
- label: option.label,
447
- value: option.value
448
- });
449
- const convertGroupedDropdownOptionToInternalOption = (option) => ({
450
- data: option.label,
451
- label: option.label,
452
- value: option.label,
453
- internalOptions: option.options
454
- });
455
- const convertInternalOptionToDropdownOption = (option) => ({
456
- data: option.data,
457
- label: option.label,
458
- value: option.value
459
- });
460
- const resolveIconColor = (theme, isFocused) => isFocused ? theme.menu.selectedItemHoverIconColor : theme.menu.selectedItemIconColor;
461
- function formatInnerOptionLabel(props) {
462
- var _a;
398
+ const e = [];
399
+ return o.forEach((t) => {
400
+ D(t.options, r) && e.push(
401
+ L(t)
402
+ ), e.push(
403
+ ...R(t.options, r, w).map(
404
+ (n) => G(n)
405
+ )
406
+ );
407
+ }), e;
408
+ }, D = (o, r) => r ? R(o, r, w).length === o.length : !1, G = (o) => ({
409
+ data: o.data,
410
+ label: o.label,
411
+ value: o.value
412
+ }), L = (o) => ({
413
+ data: o.label,
414
+ label: o.label,
415
+ value: o.label,
416
+ internalOptions: o.options
417
+ }), b = (o) => ({
418
+ data: o.data,
419
+ label: o.label,
420
+ value: o.value
421
+ }), oo = (o, r) => r ? o.menu.selectedItemHoverIconColor : o.menu.selectedItemIconColor;
422
+ function eo(o) {
423
+ var t;
463
424
  const {
464
- formatGroupLabel,
465
- formatOptionLabel
466
- } = props.selectProps;
467
- if ("internalOptions" in props.data) {
468
- return formatGroupLabel ? formatGroupLabel({
469
- label: props.data.label,
470
- options: props.data.internalOptions
471
- }) : props.label;
472
- }
473
- return formatOptionLabel ? formatOptionLabel(props.data, {
425
+ formatGroupLabel: r,
426
+ formatOptionLabel: e
427
+ } = o.selectProps;
428
+ return "internalOptions" in o.data ? r ? r({
429
+ label: o.data.label,
430
+ options: o.data.internalOptions
431
+ }) : o.label : e ? e(o.data, {
474
432
  context: "menu",
475
- inputValue: (_a = props.selectProps.inputValue) != null ? _a : "",
476
- selectValue: props.getValue()
477
- }) : props.label;
433
+ inputValue: (t = o.selectProps.inputValue) != null ? t : "",
434
+ selectValue: o.getValue()
435
+ }) : o.label;
478
436
  }
479
- const GroupedMultiSelect = ({
480
- onChange,
481
- options,
482
- value,
483
- variant = "standard",
484
- formatGroupLabel,
485
- formatOptionLabel,
486
- ...selectProps
487
- }) => {
488
- const Option = (props) => {
489
- const label = formatInnerOptionLabel(props);
490
- const isGroupOption = "internalOptions" in props.data;
491
- return /* @__PURE__ */ jsx(components.Option, {
492
- ...props,
493
- children: /* @__PURE__ */ jsxs(Row, {
494
- children: [!isGroupOption && /* @__PURE__ */ jsx(Space, {}), /* @__PURE__ */ jsx(InnerOption, {
495
- theme: defaultSelectTheme,
496
- size: !isGroupOption ? "small" : void 0,
497
- label,
498
- selected: props.isSelected,
499
- focused: props.isFocused
437
+ function ro({
438
+ onChange: o,
439
+ options: r,
440
+ value: e,
441
+ variant: t = "standard",
442
+ formatGroupLabel: n,
443
+ formatOptionLabel: i,
444
+ ...c
445
+ }) {
446
+ const v = (s) => {
447
+ const f = eo(s), y = "internalOptions" in s.data;
448
+ return /* @__PURE__ */ a(B.Option, {
449
+ ...s,
450
+ children: /* @__PURE__ */ m(C, {
451
+ children: [!y && /* @__PURE__ */ a(S, {}), /* @__PURE__ */ a(to, {
452
+ theme: H,
453
+ size: y ? void 0 : "small",
454
+ label: f,
455
+ selected: s.isSelected,
456
+ focused: s.isFocused
500
457
  })]
501
458
  })
502
459
  });
503
- };
504
- const MultiValue = (props) => {
505
- return !("internalOptions" in props.data) ? /* @__PURE__ */ jsx(components.MultiValue, {
506
- ...props
507
- }) : null;
508
- };
509
- const internalValue = options ? convertValueToInternalValue(options, value) : void 0;
510
- const internalOptions = options ? convertGroupedDropdownOptionsToInternalOptions(options) : void 0;
511
- return /* @__PURE__ */ jsx(MultiSelect, {
512
- ...selectProps,
513
- onChange: onChange ? createOnChange(onChange) : void 0,
514
- hideSelectedOptions: false,
460
+ }, u = (s) => "internalOptions" in s.data ? null : /* @__PURE__ */ a(B.MultiValue, {
461
+ ...s
462
+ }), l = r ? $(r, e) : void 0, d = r ? Z(r) : void 0;
463
+ return /* @__PURE__ */ a(W, {
464
+ ...c,
465
+ onChange: o ? Y(o) : void 0,
466
+ hideSelectedOptions: !1,
515
467
  components: {
516
- ...selectProps.components,
517
- MultiValue,
518
- Option
468
+ ...c.components,
469
+ MultiValue: u,
470
+ Option: v
519
471
  },
520
- isMulti: true,
521
- options: internalOptions,
522
- value: internalValue,
523
- variant
472
+ isMulti: !0,
473
+ options: d,
474
+ value: l,
475
+ variant: t
524
476
  });
525
- };
526
- const InnerOption = ({
527
- focused,
528
- label,
529
- selected,
530
- size,
531
- theme
532
- }) => /* @__PURE__ */ jsxs(Row, {
477
+ }
478
+ const to = ({
479
+ focused: o,
480
+ label: r,
481
+ selected: e,
482
+ size: t,
483
+ theme: n
484
+ }) => /* @__PURE__ */ m(C, {
533
485
  alignItems: "center",
534
486
  justifyContent: "space-between",
535
487
  flexGrow: 1,
536
- children: [/* @__PURE__ */ jsx(Text, {
488
+ children: [/* @__PURE__ */ a(j, {
537
489
  tabIndex: -1,
538
- size,
490
+ size: t,
539
491
  color: "currentColor",
540
- children: label
541
- }), selected && /* @__PURE__ */ jsx(Icon, {
542
- color: resolveIconColor(theme, focused),
543
- icon: stenaCheck,
492
+ children: r
493
+ }), e && /* @__PURE__ */ a(N, {
494
+ color: oo(n, o),
495
+ icon: P,
544
496
  size: 12
545
497
  })]
546
498
  });
547
- function ChipRow({
548
- value,
549
- onValueChange,
550
- noneSelectedLabel = "None",
551
- children
499
+ function A({
500
+ value: o,
501
+ onValueChange: r,
502
+ noneSelectedLabel: e = "None",
503
+ children: t
552
504
  }) {
553
- return /* @__PURE__ */ jsxs(Column, {
505
+ return /* @__PURE__ */ m(E, {
554
506
  flex: 1,
555
- children: [/* @__PURE__ */ jsxs(Row, {
507
+ children: [/* @__PURE__ */ m(C, {
556
508
  flexWrap: "wrap",
557
- children: [value == null ? void 0 : value.map((v) => /* @__PURE__ */ jsxs(Row, {
558
- children: [/* @__PURE__ */ jsx(Spacing, {
509
+ children: [o == null ? void 0 : o.map((n) => /* @__PURE__ */ m(C, {
510
+ children: [/* @__PURE__ */ a(k, {
559
511
  num: 0.5,
560
- children: /* @__PURE__ */ jsx(Chip, {
561
- label: v.label,
512
+ children: /* @__PURE__ */ a(I, {
513
+ label: n.label,
562
514
  onClickRemove: () => {
563
- var _a;
564
- return onValueChange == null ? void 0 : onValueChange((_a = value == null ? void 0 : value.filter((f) => f.value !== v.value)) != null ? _a : []);
515
+ var i;
516
+ return r == null ? void 0 : r((i = o == null ? void 0 : o.filter((c) => c.value !== n.value)) != null ? i : []);
565
517
  }
566
518
  })
567
- }), /* @__PURE__ */ jsx(Space, {})]
568
- }, v.value)), (value == null ? void 0 : value.length) ? /* @__PURE__ */ jsx(Spacing, {
519
+ }), /* @__PURE__ */ a(S, {})]
520
+ }, n.value)), o != null && o.length ? /* @__PURE__ */ a(k, {
569
521
  num: 0.5,
570
- children: /* @__PURE__ */ jsx(FlatButton, {
522
+ children: /* @__PURE__ */ a(q, {
571
523
  size: "small",
572
524
  label: "Clear",
573
- onClick: () => onValueChange == null ? void 0 : onValueChange([])
525
+ onClick: () => r == null ? void 0 : r([])
574
526
  })
575
- }) : /* @__PURE__ */ jsx(Spacing, {
527
+ }) : /* @__PURE__ */ a(k, {
576
528
  num: 0.5,
577
- children: /* @__PURE__ */ jsx(Chip, {
529
+ children: /* @__PURE__ */ a(I, {
578
530
  variant: "secondary",
579
- label: noneSelectedLabel
531
+ label: e
580
532
  })
581
533
  })]
582
- }), /* @__PURE__ */ jsx(Space, {
534
+ }), /* @__PURE__ */ a(S, {
583
535
  num: 0.5
584
- }), children]
536
+ }), t]
585
537
  });
586
538
  }
587
- function _ChipMultiSelect({
588
- value,
589
- onValueChange,
590
- placeholder = "Type to search",
591
- loading,
592
- inputValue,
593
- onInputChange,
594
- noneSelectedLabel = "None",
595
- ...selectProps
539
+ function lo({
540
+ value: o,
541
+ onValueChange: r,
542
+ placeholder: e = "Type to search",
543
+ loading: t,
544
+ inputValue: n,
545
+ onInputChange: i,
546
+ noneSelectedLabel: c = "None",
547
+ ...v
596
548
  }) {
597
- return /* @__PURE__ */ jsx(ChipRow, {
598
- noneSelectedLabel,
599
- onValueChange,
600
- value,
601
- children: /* @__PURE__ */ jsx(MultiSelect, {
602
- ...selectProps,
603
- isClearable: false,
604
- value,
605
- onChange: onValueChange ? (value2) => onValueChange([...value2]) : void 0,
606
- backspaceRemovesValue: false,
607
- hideSelectedOptions: true,
608
- controlShouldRenderValue: false,
609
- placeholder,
610
- isLoading: loading,
611
- inputValue,
612
- onInputChange
549
+ return /* @__PURE__ */ a(A, {
550
+ noneSelectedLabel: c,
551
+ onValueChange: r,
552
+ value: o,
553
+ children: /* @__PURE__ */ a(W, {
554
+ ...v,
555
+ isClearable: !1,
556
+ value: o,
557
+ onChange: r ? (u) => r([...u]) : void 0,
558
+ backspaceRemovesValue: !1,
559
+ hideSelectedOptions: !0,
560
+ controlShouldRenderValue: !1,
561
+ placeholder: e,
562
+ isLoading: t,
563
+ inputValue: n,
564
+ onInputChange: i
613
565
  })
614
566
  });
615
567
  }
616
- const ChipMultiSelect = React.memo(_ChipMultiSelect);
617
- function _GroupedChipMultiSelect({
618
- value,
619
- onValueChange,
620
- placeholder = "Type to search",
621
- loading,
622
- inputValue,
623
- onInputChange,
624
- noneSelectedLabel = "None",
625
- ...selectProps
568
+ const Co = T.memo(lo);
569
+ function no({
570
+ value: o,
571
+ onValueChange: r,
572
+ placeholder: e = "Type to search",
573
+ loading: t,
574
+ inputValue: n,
575
+ onInputChange: i,
576
+ noneSelectedLabel: c = "None",
577
+ ...v
626
578
  }) {
627
- return /* @__PURE__ */ jsx(ChipRow, {
628
- noneSelectedLabel,
629
- onValueChange,
630
- value,
631
- children: /* @__PURE__ */ jsx(GroupedMultiSelect, {
632
- ...selectProps,
633
- isClearable: false,
634
- value,
635
- onChange: onValueChange ? (value2) => onValueChange([...value2]) : void 0,
636
- backspaceRemovesValue: false,
637
- hideSelectedOptions: true,
638
- controlShouldRenderValue: false,
639
- placeholder,
640
- isLoading: loading,
641
- inputValue,
642
- onInputChange
579
+ return /* @__PURE__ */ a(A, {
580
+ noneSelectedLabel: c,
581
+ onValueChange: r,
582
+ value: o,
583
+ children: /* @__PURE__ */ a(ro, {
584
+ ...v,
585
+ isClearable: !1,
586
+ value: o,
587
+ onChange: r ? (u) => r([...u]) : void 0,
588
+ backspaceRemovesValue: !1,
589
+ hideSelectedOptions: !0,
590
+ controlShouldRenderValue: !1,
591
+ placeholder: e,
592
+ isLoading: t,
593
+ inputValue: n,
594
+ onInputChange: i
643
595
  })
644
596
  });
645
597
  }
646
- const GroupedChipMultiSelect = React.memo(_GroupedChipMultiSelect);
647
- export { AsyncMultiSelect, AsyncSelect, ChipMultiSelect, GroupedChipMultiSelect, GroupedMultiSelect, MultiSelect, Select, createStylesFromTheme, createStylesFromVariant, defaultSelectTheme };
598
+ const po = T.memo(no);
599
+ export {
600
+ ho as AsyncMultiSelect,
601
+ mo as AsyncSelect,
602
+ Co as ChipMultiSelect,
603
+ po as GroupedChipMultiSelect,
604
+ ro as GroupedMultiSelect,
605
+ W as MultiSelect,
606
+ bo as Select,
607
+ U as createStylesFromTheme,
608
+ x as createStylesFromVariant,
609
+ H as defaultSelectTheme
610
+ };
648
611
  //# sourceMappingURL=index.es.js.map