@mirohq/design-system-combobox 0.1.0-combobox.2 → 0.1.0-combobox.4
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/main.js +350 -70
- package/dist/main.js.map +1 -1
- package/dist/module.js +352 -73
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +1100 -546
- package/package.json +11 -13
package/dist/main.js
CHANGED
|
@@ -4,16 +4,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var
|
|
7
|
+
var react = require('@ariakit/react');
|
|
8
8
|
var designSystemBaseForm = require('@mirohq/design-system-base-form');
|
|
9
9
|
var RadixPopover = require('@radix-ui/react-popover');
|
|
10
10
|
var designSystemUtils = require('@mirohq/design-system-utils');
|
|
11
|
-
var designSystemIcons = require('@mirohq/design-system-icons');
|
|
12
|
-
var designSystemInput = require('@mirohq/design-system-input');
|
|
13
11
|
var designSystemStitches = require('@mirohq/design-system-stitches');
|
|
12
|
+
var designSystemInput = require('@mirohq/design-system-input');
|
|
13
|
+
var designSystemIcons = require('@mirohq/design-system-icons');
|
|
14
14
|
var designSystemUseAriaDisabled = require('@mirohq/design-system-use-aria-disabled');
|
|
15
15
|
var designSystemStyles = require('@mirohq/design-system-styles');
|
|
16
16
|
var designSystemPrimitive = require('@mirohq/design-system-primitive');
|
|
17
|
+
var designSystemBaseButton = require('@mirohq/design-system-base-button');
|
|
17
18
|
|
|
18
19
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
20
|
|
|
@@ -36,13 +37,36 @@ function _interopNamespace(e) {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
39
|
-
var Ariakit__namespace = /*#__PURE__*/_interopNamespace(Ariakit);
|
|
40
40
|
var RadixPopover__namespace = /*#__PURE__*/_interopNamespace(RadixPopover);
|
|
41
41
|
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
const StyledInput = designSystemStitches.styled(designSystemInput.Input, {
|
|
43
|
+
flexWrap: "wrap",
|
|
44
|
+
flexGrow: 1,
|
|
45
|
+
gap: "0 $50",
|
|
46
|
+
"&&&": {
|
|
47
|
+
height: "max-content"
|
|
48
|
+
},
|
|
49
|
+
"& input": {
|
|
50
|
+
minWidth: "30px",
|
|
51
|
+
flexBasis: 0,
|
|
52
|
+
flexGrow: 1,
|
|
53
|
+
marginRight: "$300"
|
|
54
|
+
},
|
|
55
|
+
variants: {
|
|
56
|
+
size: {
|
|
57
|
+
large: {
|
|
58
|
+
minHeight: "$10",
|
|
59
|
+
padding: "5px $100"
|
|
60
|
+
},
|
|
61
|
+
"x-large": {
|
|
62
|
+
minHeight: "$12",
|
|
63
|
+
padding: "9px $150"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
defaultVariants: {
|
|
68
|
+
size: "large"
|
|
69
|
+
}
|
|
46
70
|
});
|
|
47
71
|
|
|
48
72
|
const ComboboxContext = React.createContext({});
|
|
@@ -52,14 +76,17 @@ const ComboboxProvider = ({
|
|
|
52
76
|
valid,
|
|
53
77
|
value: valueProp,
|
|
54
78
|
defaultValue: defaultValueProp,
|
|
79
|
+
onSearchValueChange,
|
|
80
|
+
autoFilter = true,
|
|
55
81
|
...restProps
|
|
56
82
|
}) => {
|
|
57
83
|
const triggerRef = React.useRef(null);
|
|
58
84
|
const contentRef = React.useRef(null);
|
|
59
|
-
const [openState, setOpenState] = React.useState(defaultOpen);
|
|
85
|
+
const [openState, setOpenState] = React.useState(defaultOpen != null ? defaultOpen : false);
|
|
60
86
|
const [value, setValue] = React.useState(valueProp != null ? valueProp : []);
|
|
61
87
|
const [defaultValue, setDefaultValue] = React.useState(defaultValueProp);
|
|
62
|
-
const [
|
|
88
|
+
const [filteredItems, setFilteredItems] = React.useState(/* @__PURE__ */ new Set());
|
|
89
|
+
const [searchValue, setSearchValue] = React.useState("");
|
|
63
90
|
const { valid: formFieldValid } = designSystemBaseForm.useFormFieldContext();
|
|
64
91
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
65
92
|
ComboboxContext.Provider,
|
|
@@ -73,10 +100,14 @@ const ComboboxProvider = ({
|
|
|
73
100
|
setValue,
|
|
74
101
|
setDefaultValue,
|
|
75
102
|
defaultValue,
|
|
103
|
+
onSearchValueChange,
|
|
104
|
+
triggerRef,
|
|
105
|
+
contentRef,
|
|
106
|
+
autoFilter,
|
|
76
107
|
searchValue,
|
|
77
108
|
setSearchValue,
|
|
78
|
-
|
|
79
|
-
|
|
109
|
+
filteredItems,
|
|
110
|
+
setFilteredItems
|
|
80
111
|
},
|
|
81
112
|
children
|
|
82
113
|
}
|
|
@@ -84,6 +115,47 @@ const ComboboxProvider = ({
|
|
|
84
115
|
};
|
|
85
116
|
const useComboboxContext = () => React.useContext(ComboboxContext);
|
|
86
117
|
|
|
118
|
+
const StyledActionButton = designSystemStitches.styled(designSystemInput.Input.ActionButton, {
|
|
119
|
+
position: "absolute",
|
|
120
|
+
right: "$100",
|
|
121
|
+
variants: {
|
|
122
|
+
size: {
|
|
123
|
+
large: {
|
|
124
|
+
top: "5px"
|
|
125
|
+
},
|
|
126
|
+
"x-large": {
|
|
127
|
+
top: "9px"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
defaultVariants: {
|
|
132
|
+
size: "large"
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const TriggerActionButton = ({
|
|
137
|
+
openActionLabel,
|
|
138
|
+
clearActionLabel,
|
|
139
|
+
size
|
|
140
|
+
}) => {
|
|
141
|
+
const { setOpenState, value, setValue } = useComboboxContext();
|
|
142
|
+
const isEmpty = value === void 0 || value.length === 0;
|
|
143
|
+
const ActionButtonIcon = isEmpty ? designSystemIcons.IconChevronDown : designSystemIcons.IconCross;
|
|
144
|
+
const label = isEmpty ? openActionLabel : clearActionLabel;
|
|
145
|
+
const onActionButtonClick = React.useCallback(
|
|
146
|
+
(event) => {
|
|
147
|
+
if (!isEmpty) {
|
|
148
|
+
setValue([]);
|
|
149
|
+
} else {
|
|
150
|
+
setOpenState((prevOpen) => !prevOpen);
|
|
151
|
+
}
|
|
152
|
+
event.stopPropagation();
|
|
153
|
+
},
|
|
154
|
+
[isEmpty, setValue, setOpenState]
|
|
155
|
+
);
|
|
156
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StyledActionButton, { label, size, onClick: onActionButtonClick, children: /* @__PURE__ */ jsxRuntime.jsx(ActionButtonIcon, { size: "small", weight: "thin" }) });
|
|
157
|
+
};
|
|
158
|
+
|
|
87
159
|
const Trigger = React__default["default"].forwardRef(
|
|
88
160
|
({
|
|
89
161
|
id,
|
|
@@ -92,6 +164,9 @@ const Trigger = React__default["default"].forwardRef(
|
|
|
92
164
|
"aria-describedby": ariaDescribedBy,
|
|
93
165
|
"aria-invalid": ariaInvalid,
|
|
94
166
|
placeholder,
|
|
167
|
+
openActionLabel,
|
|
168
|
+
clearActionLabel,
|
|
169
|
+
onChange,
|
|
95
170
|
...restProps
|
|
96
171
|
}, forwardRef) => {
|
|
97
172
|
const {
|
|
@@ -99,13 +174,19 @@ const Trigger = React__default["default"].forwardRef(
|
|
|
99
174
|
valid: comboboxValid,
|
|
100
175
|
disabled,
|
|
101
176
|
value,
|
|
102
|
-
triggerRef
|
|
177
|
+
triggerRef,
|
|
178
|
+
onSearchValueChange,
|
|
179
|
+
searchValue,
|
|
180
|
+
setSearchValue
|
|
103
181
|
} = useComboboxContext();
|
|
104
182
|
const {
|
|
105
183
|
formElementId,
|
|
106
184
|
ariaDescribedBy: formFieldContextDescribedBy,
|
|
107
185
|
ariaInvalid: formFieldAriaInvalid,
|
|
108
|
-
valid: formFieldValid
|
|
186
|
+
valid: formFieldValid,
|
|
187
|
+
label,
|
|
188
|
+
isFloatingLabel,
|
|
189
|
+
focused
|
|
109
190
|
} = designSystemBaseForm.useFormFieldContext();
|
|
110
191
|
const valid = formFieldValid != null ? formFieldValid : comboboxValid;
|
|
111
192
|
const inputProps = {
|
|
@@ -122,16 +203,37 @@ const Trigger = React__default["default"].forwardRef(
|
|
|
122
203
|
id: id != null ? id : formElementId,
|
|
123
204
|
placeholder: (value == null ? void 0 : value.length) === 0 ? placeholder : void 0
|
|
124
205
|
};
|
|
125
|
-
const
|
|
126
|
-
|
|
206
|
+
const shouldUseFloatingLabel = label !== null && isFloatingLabel;
|
|
207
|
+
const isFloating = placeholder !== void 0 || (value == null ? void 0 : value.length) !== 0 || focused;
|
|
208
|
+
const onInputChange = (e) => {
|
|
209
|
+
setSearchValue(e.target.value);
|
|
210
|
+
onSearchValueChange == null ? void 0 : onSearchValueChange(e.target.value);
|
|
211
|
+
onChange == null ? void 0 : onChange(e);
|
|
127
212
|
};
|
|
128
213
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixPopover__namespace.Anchor, { ref: designSystemUtils.mergeRefs([triggerRef, forwardRef]), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
129
|
-
|
|
214
|
+
react.Combobox,
|
|
130
215
|
{
|
|
131
|
-
render: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
216
|
+
render: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
217
|
+
StyledInput,
|
|
218
|
+
{
|
|
219
|
+
value: searchValue,
|
|
220
|
+
onChange: onInputChange,
|
|
221
|
+
...inputProps,
|
|
222
|
+
size,
|
|
223
|
+
children: [
|
|
224
|
+
shouldUseFloatingLabel && /* @__PURE__ */ jsxRuntime.jsx(designSystemBaseForm.FloatingLabel, { floating: isFloating, size, children: label }),
|
|
225
|
+
children,
|
|
226
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
227
|
+
TriggerActionButton,
|
|
228
|
+
{
|
|
229
|
+
openActionLabel,
|
|
230
|
+
clearActionLabel,
|
|
231
|
+
size
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
)
|
|
135
237
|
}
|
|
136
238
|
) });
|
|
137
239
|
}
|
|
@@ -144,37 +246,24 @@ const StyledContent = designSystemStitches.styled(RadixPopover__namespace.Conten
|
|
|
144
246
|
fontSize: "$175",
|
|
145
247
|
fontWeight: "normal",
|
|
146
248
|
lineHeight: "1.5",
|
|
147
|
-
|
|
249
|
+
width: "var(--radix-popover-trigger-width)",
|
|
148
250
|
zIndex: "$select",
|
|
149
251
|
overflowY: "auto",
|
|
150
|
-
marginTop: "$200"
|
|
252
|
+
marginTop: "$200",
|
|
253
|
+
padding: "$150",
|
|
254
|
+
boxSizing: "border-box",
|
|
255
|
+
outline: "1px solid transparent"
|
|
151
256
|
});
|
|
152
257
|
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
StyledContent,
|
|
157
|
-
{
|
|
158
|
-
...restProps,
|
|
159
|
-
ref: designSystemUtils.mergeRefs([forwardRef, contentRef]),
|
|
160
|
-
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
161
|
-
onInteractOutside: (event) => {
|
|
162
|
-
var _a, _b;
|
|
163
|
-
const target = event.target;
|
|
164
|
-
const isTrigger = target === triggerRef.current;
|
|
165
|
-
const isContent = (_b = target != null && ((_a = contentRef.current) == null ? void 0 : _a.contains(target))) != null ? _b : false;
|
|
166
|
-
if (isTrigger || isContent) {
|
|
167
|
-
event.preventDefault();
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
children
|
|
171
|
-
}
|
|
172
|
-
);
|
|
258
|
+
const StyledItemCheck = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
|
|
259
|
+
color: "$icon-primary",
|
|
260
|
+
paddingX: "$100"
|
|
173
261
|
});
|
|
174
|
-
|
|
175
|
-
const StyledItem = designSystemStitches.styled(Ariakit.ComboboxItem, {
|
|
262
|
+
const StyledItem = designSystemStitches.styled(react.ComboboxItem, {
|
|
176
263
|
display: "flex",
|
|
177
264
|
alignItems: "center",
|
|
265
|
+
justifyContent: "space-between",
|
|
266
|
+
gap: "$200",
|
|
178
267
|
borderRadius: "$50",
|
|
179
268
|
boxSizing: "border-box",
|
|
180
269
|
color: "$text-neutrals",
|
|
@@ -183,15 +272,19 @@ const StyledItem = designSystemStitches.styled(Ariakit.ComboboxItem, {
|
|
|
183
272
|
lineHeight: 1.5,
|
|
184
273
|
position: "relative",
|
|
185
274
|
userSelect: "none",
|
|
186
|
-
|
|
187
|
-
|
|
275
|
+
paddingX: "$100",
|
|
276
|
+
paddingY: "10px",
|
|
188
277
|
...designSystemStyles.focus.css({
|
|
189
|
-
boxShadow: "$focus-small"
|
|
190
|
-
outline: "1px solid transparent"
|
|
278
|
+
boxShadow: "$focus-small"
|
|
191
279
|
}),
|
|
192
|
-
'&:
|
|
193
|
-
|
|
194
|
-
|
|
280
|
+
'&:not([aria-disabled="true"])': {
|
|
281
|
+
_hover: {
|
|
282
|
+
background: "$background-primary-subtle-hover",
|
|
283
|
+
color: "$text-primary-hover",
|
|
284
|
+
["".concat(StyledItemCheck)]: {
|
|
285
|
+
color: "$icon-primary-hover"
|
|
286
|
+
}
|
|
287
|
+
}
|
|
195
288
|
},
|
|
196
289
|
"&:disabled, &[aria-disabled=true], &[data-disabled]": {
|
|
197
290
|
cursor: "default",
|
|
@@ -202,6 +295,10 @@ const StyledItem = designSystemStitches.styled(Ariakit.ComboboxItem, {
|
|
|
202
295
|
const Item = React__default["default"].forwardRef(
|
|
203
296
|
({ disabled = false, value, textValue, children, ...restProps }, forwardRef) => {
|
|
204
297
|
const { "aria-disabled": ariaDisabled, ...restAriaDisabledProps } = designSystemUseAriaDisabled.useAriaDisabled(restProps, { allowArrows: true });
|
|
298
|
+
const { autoFilter, filteredItems } = useComboboxContext();
|
|
299
|
+
if (autoFilter !== false && !filteredItems.has(value)) {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
205
302
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
206
303
|
StyledItem,
|
|
207
304
|
{
|
|
@@ -213,36 +310,199 @@ const Item = React__default["default"].forwardRef(
|
|
|
213
310
|
ref: forwardRef,
|
|
214
311
|
value,
|
|
215
312
|
children: [
|
|
216
|
-
|
|
217
|
-
|
|
313
|
+
children,
|
|
314
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
315
|
+
react.ComboboxItemCheck,
|
|
316
|
+
{
|
|
317
|
+
render: ({ style, ...props }) => (
|
|
318
|
+
// AriakitComboboxItemCheck adds its owm inline styles which we want to omit here
|
|
319
|
+
/* @__PURE__ */ jsxRuntime.jsx(StyledItemCheck, { ...props })
|
|
320
|
+
),
|
|
321
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystemIcons.IconCheckMark, { size: "small" })
|
|
322
|
+
}
|
|
323
|
+
)
|
|
218
324
|
]
|
|
219
325
|
}
|
|
220
326
|
);
|
|
221
327
|
}
|
|
222
328
|
);
|
|
223
329
|
|
|
224
|
-
const
|
|
330
|
+
const itemType = React__default["default"].createElement(Item).type;
|
|
331
|
+
const getChildrenItemValues = (componentChildren) => {
|
|
332
|
+
const values = [];
|
|
333
|
+
const recurse = (children) => {
|
|
334
|
+
React__default["default"].Children.forEach(children, (child) => {
|
|
335
|
+
if (!React__default["default"].isValidElement(child)) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
if (child.type === itemType) {
|
|
339
|
+
const props = child.props;
|
|
340
|
+
values.push(props.value);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (child.props.children) {
|
|
344
|
+
recurse(child.props.children);
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
};
|
|
348
|
+
recurse(componentChildren);
|
|
349
|
+
return values;
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
const isInsideRef = (element, ref) => {
|
|
353
|
+
var _a, _b;
|
|
354
|
+
return (_b = element != null && ((_a = ref.current) == null ? void 0 : _a.contains(element))) != null ? _b : false;
|
|
355
|
+
};
|
|
356
|
+
const Content = React__default["default"].forwardRef(({ children, ...restProps }, forwardRef) => {
|
|
357
|
+
const {
|
|
358
|
+
triggerRef,
|
|
359
|
+
contentRef,
|
|
360
|
+
autoFilter,
|
|
361
|
+
filteredItems,
|
|
362
|
+
setFilteredItems,
|
|
363
|
+
searchValue,
|
|
364
|
+
noResultsText
|
|
365
|
+
} = useComboboxContext();
|
|
366
|
+
React.useEffect(() => {
|
|
367
|
+
const childrenItemValues = getChildrenItemValues(children);
|
|
368
|
+
setFilteredItems(
|
|
369
|
+
new Set(
|
|
370
|
+
autoFilter === false ? childrenItemValues : childrenItemValues.filter(
|
|
371
|
+
(child) => child.toLowerCase().includes(searchValue.toLowerCase())
|
|
372
|
+
)
|
|
373
|
+
)
|
|
374
|
+
);
|
|
375
|
+
}, [children, autoFilter, setFilteredItems, searchValue]);
|
|
376
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
377
|
+
StyledContent,
|
|
378
|
+
{
|
|
379
|
+
...restProps,
|
|
380
|
+
ref: designSystemUtils.mergeRefs([forwardRef, contentRef]),
|
|
381
|
+
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
382
|
+
onInteractOutside: (event) => {
|
|
383
|
+
const target = event.target;
|
|
384
|
+
const isTrigger = isInsideRef(target, triggerRef);
|
|
385
|
+
const isContent = isInsideRef(target, contentRef);
|
|
386
|
+
if (isTrigger || isContent) {
|
|
387
|
+
event.preventDefault();
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
children: filteredItems.size === 0 ? noResultsText : children
|
|
391
|
+
}
|
|
392
|
+
);
|
|
393
|
+
});
|
|
225
394
|
|
|
226
|
-
const
|
|
395
|
+
const Portal = (props) => /* @__PURE__ */ jsxRuntime.jsx(RadixPopover.Portal, { ...props });
|
|
227
396
|
|
|
228
|
-
const Group = React__default["default"].forwardRef((
|
|
397
|
+
const Group = React__default["default"].forwardRef(({ children, ...rest }, forwardRef) => {
|
|
398
|
+
const { autoFilter, filteredItems } = useComboboxContext();
|
|
399
|
+
const childValues = React.useMemo(
|
|
400
|
+
// don't perform calculation if auto filter is disabled
|
|
401
|
+
() => autoFilter !== false ? getChildrenItemValues(children) : [],
|
|
402
|
+
[children, autoFilter]
|
|
403
|
+
);
|
|
404
|
+
const hasVisibleChildren = React.useMemo(
|
|
405
|
+
() => (
|
|
406
|
+
// don't perform calculation if auto filter is disabled
|
|
407
|
+
autoFilter !== false ? childValues.some((value) => filteredItems.has(value)) : true
|
|
408
|
+
),
|
|
409
|
+
[childValues, filteredItems, autoFilter]
|
|
410
|
+
);
|
|
411
|
+
if (!hasVisibleChildren) {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Group, { ...rest, ref: forwardRef, children });
|
|
415
|
+
});
|
|
229
416
|
|
|
230
|
-
const StyledGroupLabel = designSystemStitches.styled(
|
|
417
|
+
const StyledGroupLabel = designSystemStitches.styled(react.GroupLabel, {
|
|
418
|
+
padding: "$100",
|
|
419
|
+
color: "$text-neutrals-subtle",
|
|
420
|
+
fontSize: "$150",
|
|
421
|
+
textTransform: "uppercase",
|
|
422
|
+
fontWeight: 650
|
|
423
|
+
});
|
|
231
424
|
|
|
232
425
|
const GroupLabel = React__default["default"].forwardRef((props, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(StyledGroupLabel, { ...props, ref: forwardRef }));
|
|
233
426
|
|
|
234
|
-
const
|
|
427
|
+
const StyledChip = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
|
|
428
|
+
fontSize: "$150",
|
|
429
|
+
padding: "$50 $100",
|
|
430
|
+
borderRadius: "$round",
|
|
431
|
+
display: "flex",
|
|
432
|
+
alignItems: "center",
|
|
433
|
+
gap: "$50",
|
|
434
|
+
whiteSpace: "nowrap",
|
|
435
|
+
maxWidth: "$35",
|
|
436
|
+
background: "$gray-100",
|
|
437
|
+
color: "$gray-900"
|
|
438
|
+
});
|
|
439
|
+
const StyledChipButton = designSystemStitches.styled(designSystemBaseButton.BaseButton, {
|
|
440
|
+
...designSystemStyles.focus.css({
|
|
441
|
+
boxShadow: "$focus-small-outline",
|
|
442
|
+
borderColor: "$blue-400 !important"
|
|
443
|
+
})
|
|
444
|
+
});
|
|
445
|
+
const StyledChipContent = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
|
|
446
|
+
textOverflow: "ellipsis",
|
|
447
|
+
whiteSpace: "nowrap",
|
|
448
|
+
overflow: "hidden",
|
|
449
|
+
lineHeight: 1.3
|
|
450
|
+
});
|
|
235
451
|
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
452
|
+
const StyledLeftSlot = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
|
|
453
|
+
order: -1,
|
|
454
|
+
marginRight: "$50"
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
const LeftSlot = StyledLeftSlot;
|
|
458
|
+
|
|
459
|
+
const Chip = React__default["default"].forwardRef(
|
|
460
|
+
({ children, disabled = false, onRemove, removeChipAriaLabel, ...restProps }, forwardRef) => /* @__PURE__ */ jsxRuntime.jsxs(StyledChip, { ...restProps, ref: forwardRef, children: [
|
|
461
|
+
/* @__PURE__ */ jsxRuntime.jsx(StyledChipContent, { children }),
|
|
462
|
+
!designSystemUtils.booleanify(disabled) && /* @__PURE__ */ jsxRuntime.jsx(StyledChipButton, { onClick: onRemove, "aria-label": removeChipAriaLabel, children: /* @__PURE__ */ jsxRuntime.jsx(designSystemIcons.IconCross, { size: "small", weight: "thin", color: "gray-500" }) })
|
|
463
|
+
] })
|
|
245
464
|
);
|
|
465
|
+
Chip.LeftSlot = LeftSlot;
|
|
466
|
+
|
|
467
|
+
const StyledValue = designSystemStitches.styled(Chip, {
|
|
468
|
+
marginTop: "$50"
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
const Value = ({ removeChipAriaLabel }) => {
|
|
472
|
+
const {
|
|
473
|
+
value,
|
|
474
|
+
setValue,
|
|
475
|
+
disabled,
|
|
476
|
+
"aria-disabled": ariaDisabled
|
|
477
|
+
} = useComboboxContext();
|
|
478
|
+
const isEmpty = value === void 0 || value.length === 0;
|
|
479
|
+
const isDisabled = ariaDisabled === true || disabled;
|
|
480
|
+
const onItemRemove = (item) => {
|
|
481
|
+
setValue((prevValue) => prevValue.filter((value2) => value2 !== item));
|
|
482
|
+
};
|
|
483
|
+
if (isEmpty) {
|
|
484
|
+
return null;
|
|
485
|
+
}
|
|
486
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: value.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
487
|
+
StyledValue,
|
|
488
|
+
{
|
|
489
|
+
onRemove: () => onItemRemove(item),
|
|
490
|
+
disabled: isDisabled,
|
|
491
|
+
removeChipAriaLabel,
|
|
492
|
+
children: item
|
|
493
|
+
},
|
|
494
|
+
item
|
|
495
|
+
)) });
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
const StyledSeparator = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
|
|
499
|
+
backgroundColor: "$border-neutrals-subtle",
|
|
500
|
+
height: "1px",
|
|
501
|
+
width: "100%",
|
|
502
|
+
margin: "$100 0"
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
const Separator = React__default["default"].forwardRef((props, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(StyledSeparator, { ...props, ref: forwardRef, "aria-hidden": true }));
|
|
246
506
|
|
|
247
507
|
const StyledComboboxContent = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {});
|
|
248
508
|
|
|
@@ -280,7 +540,7 @@ const Root = React__default["default"].forwardRef(({ value: valueProp, onValueCh
|
|
|
280
540
|
setValue(newValue);
|
|
281
541
|
};
|
|
282
542
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixPopover__namespace.Root, { open: openState, onOpenChange: setOpenState, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
283
|
-
|
|
543
|
+
react.ComboboxProvider,
|
|
284
544
|
{
|
|
285
545
|
open: openState,
|
|
286
546
|
setOpen: setOpenState,
|
|
@@ -302,15 +562,19 @@ const Combobox = React__default["default"].forwardRef(
|
|
|
302
562
|
required,
|
|
303
563
|
value,
|
|
304
564
|
defaultValue,
|
|
565
|
+
onSearchValueChange,
|
|
305
566
|
onOpen,
|
|
306
567
|
onValueChange,
|
|
307
568
|
direction = "ltr",
|
|
569
|
+
autoFilter = true,
|
|
570
|
+
noResultsText,
|
|
308
571
|
...restProps
|
|
309
572
|
}, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
310
573
|
ComboboxProvider,
|
|
311
574
|
{
|
|
312
575
|
defaultValue,
|
|
313
576
|
value,
|
|
577
|
+
onSearchValueChange,
|
|
314
578
|
defaultOpen,
|
|
315
579
|
open,
|
|
316
580
|
valid,
|
|
@@ -319,7 +583,17 @@ const Combobox = React__default["default"].forwardRef(
|
|
|
319
583
|
readOnly,
|
|
320
584
|
"aria-disabled": ariaDisabled,
|
|
321
585
|
direction,
|
|
322
|
-
|
|
586
|
+
autoFilter,
|
|
587
|
+
noResultsText,
|
|
588
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
589
|
+
Root,
|
|
590
|
+
{
|
|
591
|
+
...restProps,
|
|
592
|
+
noResultsText,
|
|
593
|
+
value,
|
|
594
|
+
ref: forwardRef
|
|
595
|
+
}
|
|
596
|
+
)
|
|
323
597
|
}
|
|
324
598
|
)
|
|
325
599
|
);
|
|
@@ -330,6 +604,12 @@ Combobox.Item = Item;
|
|
|
330
604
|
Combobox.Group = Group;
|
|
331
605
|
Combobox.GroupLabel = GroupLabel;
|
|
332
606
|
Combobox.Value = Value;
|
|
607
|
+
Combobox.Separator = Separator;
|
|
608
|
+
|
|
609
|
+
var types = /*#__PURE__*/Object.freeze({
|
|
610
|
+
__proto__: null
|
|
611
|
+
});
|
|
333
612
|
|
|
334
613
|
exports.Combobox = Combobox;
|
|
614
|
+
exports.ComboboxTypes = types;
|
|
335
615
|
//# sourceMappingURL=main.js.map
|