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