@sproutsocial/seeds-react-menu 1.11.1 → 1.11.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/v3/index.js CHANGED
@@ -52,6 +52,9 @@ __export(v3_exports, {
52
52
  ComboboxTokenInput: () => ComboboxTokenInput,
53
53
  ComboboxTokenInputGroup: () => ComboboxTokenInputGroup,
54
54
  ComboboxTrigger: () => ComboboxTrigger,
55
+ MultiCombobox: () => MultiCombobox,
56
+ MultiSearchableSelect: () => MultiSearchableSelect,
57
+ MultiSelect: () => MultiSelect,
55
58
  SearchableSelectInput: () => SearchableSelectInput,
56
59
  SearchableSelectList: () => SearchableSelectList,
57
60
  SearchableSelectPlaceholder: () => SearchableSelectPlaceholder,
@@ -60,6 +63,9 @@ __export(v3_exports, {
60
63
  SearchableSelectTokenTrigger: () => SearchableSelectTokenTrigger,
61
64
  SearchableSelectTrigger: () => SearchableSelectTrigger,
62
65
  SearchableSelectTriggerIcon: () => SearchableSelectTriggerIcon,
66
+ SingleCombobox: () => SingleCombobox,
67
+ SingleSearchableSelect: () => SingleSearchableSelect,
68
+ SingleSelect: () => SingleSelect,
63
69
  Token: () => Token,
64
70
  TokenRemove: () => TokenRemove
65
71
  });
@@ -73,6 +79,18 @@ var import_styled_components4 = __toESM(require("styled-components"));
73
79
  // src/v3/SeedsPortal.tsx
74
80
  var React = __toESM(require("react"));
75
81
  var import_seeds_react_portal = require("@sproutsocial/seeds-react-portal");
82
+ function useSeedsPortalContainer() {
83
+ const disablePortalToBody = React.useContext(import_seeds_react_portal.DisablePortalToBodyContext);
84
+ const containerRef = React.useRef(null);
85
+ const [portalContainer, setPortalContainer] = React.useState(void 0);
86
+ React.useEffect(() => {
87
+ if (disablePortalToBody && containerRef.current) {
88
+ const dialogContent = containerRef.current.closest("[role='dialog']");
89
+ setPortalContainer(dialogContent ?? containerRef.current);
90
+ }
91
+ }, [disablePortalToBody]);
92
+ return { containerRef, portalContainer, disablePortalToBody };
93
+ }
76
94
 
77
95
  // src/v3/Common/SelectItem.tsx
78
96
  var React2 = require("react");
@@ -118,6 +136,74 @@ var StyledItemIndicator = (0, import_styled_components.default)(import_select.Se
118
136
  }
119
137
  `;
120
138
  var StyledItemText = (0, import_styled_components.default)(import_select.Select.ItemText)``;
139
+ function CheckIcon() {
140
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_icon.Icon, { name: "check-outline", fixedWidth: true, "aria-hidden": true });
141
+ }
142
+ function SelectItem({
143
+ value,
144
+ label,
145
+ disabled,
146
+ inputType = "icon",
147
+ renderItem,
148
+ hidden
149
+ }) {
150
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
151
+ StyledItem,
152
+ {
153
+ value,
154
+ disabled,
155
+ style: hidden ? { display: "none" } : void 0,
156
+ "data-qa-menu-item": label,
157
+ children: [
158
+ inputType === "radio" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
159
+ StyledItemIndicator,
160
+ {
161
+ keepMounted: true,
162
+ render: (_props, state) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
163
+ import_seeds_react_radio.default,
164
+ {
165
+ checked: state.selected,
166
+ onChange: () => {
167
+ },
168
+ tabIndex: -1,
169
+ id: `radio-${value}`,
170
+ name: "select-item"
171
+ }
172
+ )
173
+ }
174
+ ) : inputType === "checkbox" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
175
+ StyledItemIndicator,
176
+ {
177
+ keepMounted: true,
178
+ render: (_props, state) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
179
+ import_seeds_react_checkbox.default,
180
+ {
181
+ checked: state.selected,
182
+ onChange: () => {
183
+ },
184
+ tabIndex: -1,
185
+ id: `checkbox-${value}`,
186
+ name: "select-item"
187
+ }
188
+ )
189
+ }
190
+ ) : inputType === "icon" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StyledItemIndicator, { keepMounted: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckIcon, {}) }) : null,
191
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StyledItemText, { children: renderItem ? renderItem() : label })
192
+ ]
193
+ }
194
+ );
195
+ }
196
+
197
+ // src/v3/Common/groupItems.ts
198
+ function groupItems(data, groupBy) {
199
+ const map = /* @__PURE__ */ new Map();
200
+ for (const item of data) {
201
+ const key = groupBy(item);
202
+ if (!map.has(key)) map.set(key, []);
203
+ map.get(key).push(item);
204
+ }
205
+ return Array.from(map.entries()).map(([value, items]) => ({ value, items }));
206
+ }
121
207
 
122
208
  // src/v3/Common/SelectStyles.tsx
123
209
  var import_select2 = require("@base-ui/react/select");
@@ -163,6 +249,11 @@ var SelectTrigger = (0, import_styled_components2.default)(import_select2.Select
163
249
  &[data-popup-open] [data-chevron] {
164
250
  transform: rotate(-180deg);
165
251
  }
252
+
253
+ &[data-disabled] {
254
+ opacity: 0.4;
255
+ cursor: not-allowed;
256
+ }
166
257
  `;
167
258
  var SelectValue = (0, import_styled_components2.default)(import_select2.Select.Value)`
168
259
  min-width: 0;
@@ -247,7 +338,13 @@ var StyledChevron = import_styled_components3.default.div`
247
338
  transition: transform 0.15s;
248
339
  ${({ $isOpen }) => $isOpen && "transform: rotate(-180deg);"}
249
340
  `;
250
- function CheckIcon() {
341
+ function ChevronIcon() {
342
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_seeds_react_icon2.Icon, { name: "chevron-down-outline", fixedWidth: true, "aria-hidden": true });
343
+ }
344
+ function ClearIcon() {
345
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_seeds_react_icon2.Icon, { name: "circle-x-outline", fixedWidth: true, "aria-hidden": true, size: "mini" });
346
+ }
347
+ function CheckIcon2() {
251
348
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_seeds_react_icon2.Icon, { name: "check-outline", fixedWidth: true, "aria-hidden": true });
252
349
  }
253
350
 
@@ -264,6 +361,115 @@ var StyledValue = (0, import_styled_components4.default)(import_select3.Select.V
264
361
  color: ${({ theme }) => theme.colors.text.subtext};
265
362
  }
266
363
  `;
364
+ function SingleSelect(props) {
365
+ const { id, placeholder, includePlaceholderItem } = props;
366
+ const isChildrenMode = "children" in props && props.children != null;
367
+ const selectedItemId = props.selectedItemId;
368
+ const defaultSelectedItemId = props.defaultSelectedItemId;
369
+ const onSelectedItemIdChange = props.onSelectedItemIdChange;
370
+ const data = isChildrenMode ? [] : props.data;
371
+ const itemToString = isChildrenMode ? () => "" : props.itemToString;
372
+ const renderItem = isChildrenMode ? void 0 : props.renderItem;
373
+ const inputType = isChildrenMode ? "icon" : props.inputType ?? "icon";
374
+ const renderSelection = isChildrenMode ? void 0 : props.renderSelection;
375
+ const groupBy = isChildrenMode ? void 0 : props.groupBy;
376
+ const renderGroupHeading = isChildrenMode ? void 0 : props.renderGroupHeading;
377
+ const children = isChildrenMode ? props.children : void 0;
378
+ const { containerRef, portalContainer } = useSeedsPortalContainer();
379
+ const items = React4.useMemo(() => {
380
+ const dataItems = data.map((item) => ({
381
+ value: String(item.id),
382
+ label: itemToString(item)
383
+ }));
384
+ if (includePlaceholderItem) {
385
+ return [{ value: null, label: placeholder ?? "" }, ...dataItems];
386
+ }
387
+ return dataItems;
388
+ }, [data, itemToString, includePlaceholderItem, placeholder]);
389
+ const dataWithPlaceholder = includePlaceholderItem ? [{ id: null, value: null, label: placeholder ?? "" }, ...data] : data;
390
+ const isControlled = selectedItemId !== void 0;
391
+ const [internalValue, setInternalValue] = React4.useState(
392
+ defaultSelectedItemId != null ? String(defaultSelectedItemId) : null
393
+ );
394
+ const value = isControlled ? selectedItemId != null ? String(selectedItemId) : null : internalValue;
395
+ const selectedItem = React4.useMemo(
396
+ () => value != null ? data.find((d) => String(d.id) === value) ?? null : null,
397
+ [data, value]
398
+ );
399
+ function handleValueChange(newValue) {
400
+ if (!isControlled) {
401
+ setInternalValue(newValue);
402
+ }
403
+ if (onSelectedItemIdChange) {
404
+ if (newValue == null) {
405
+ onSelectedItemIdChange(null);
406
+ } else {
407
+ const item = data.find((d) => String(d.id) === newValue);
408
+ onSelectedItemIdChange(item ? item.id : null);
409
+ }
410
+ }
411
+ }
412
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Field, { children: [
413
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: containerRef, style: { position: "relative" } }),
414
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
415
+ import_select3.Select.Root,
416
+ {
417
+ items,
418
+ value,
419
+ disabled: props.disabled,
420
+ onValueChange: handleValueChange,
421
+ id,
422
+ children: [
423
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(SelectTrigger, { children: [
424
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StyledValue, { placeholder, children: renderSelection && selectedItem ? renderSelection(selectedItem) : void 0 }),
425
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SelectIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StyledChevron, { "data-chevron": true, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChevronIcon, {}) }) })
426
+ ] }),
427
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_select3.Select.Portal, { container: portalContainer, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SelectPositioner, { sideOffset: 8, alignItemWithTrigger: false, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(SelectPopup, { children: [
428
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_select3.Select.ScrollUpArrow, {}),
429
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_select3.Select.List, { children: children ? children : groupBy ? groupItems(data, groupBy).map((group, index, arr) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React4.Fragment, { children: [
430
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(SelectGroup, { children: [
431
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SelectGroupLabel, { children: renderGroupHeading ? renderGroupHeading(group.value) : group.value }),
432
+ group.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
433
+ SelectItem,
434
+ {
435
+ value: String(item.id),
436
+ label: itemToString(item),
437
+ disabled: item.disabled,
438
+ inputType,
439
+ renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
440
+ },
441
+ item.id
442
+ ))
443
+ ] }),
444
+ index < arr.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SelectSeparator, {})
445
+ ] }, group.value)) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
446
+ includePlaceholderItem && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
447
+ SelectItem,
448
+ {
449
+ value: null,
450
+ label: placeholder ?? ""
451
+ },
452
+ "placeholder"
453
+ ),
454
+ data.map((item) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
455
+ SelectItem,
456
+ {
457
+ value: String(item.id),
458
+ label: itemToString(item),
459
+ disabled: item.disabled,
460
+ inputType,
461
+ renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
462
+ },
463
+ item.id
464
+ ))
465
+ ] }) }),
466
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_select3.Select.ScrollDownArrow, {})
467
+ ] }) }) })
468
+ ]
469
+ }
470
+ )
471
+ ] });
472
+ }
267
473
 
268
474
  // src/v3/MultiSelect.tsx
269
475
  var React5 = __toESM(require("react"));
@@ -284,6 +490,119 @@ var Placeholder = import_styled_components5.default.div`
284
490
  padding-bottom: 2px;
285
491
  margin: 2px 8px 0px 0px;
286
492
  `;
493
+ function MultiSelect(props) {
494
+ const { id, placeholder = "Select..." } = props;
495
+ const isChildrenMode = "children" in props && props.children != null;
496
+ const data = isChildrenMode ? [] : props.data;
497
+ const itemToString = isChildrenMode ? () => "" : props.itemToString;
498
+ const renderItem = isChildrenMode ? void 0 : props.renderItem;
499
+ const customRenderSelections = isChildrenMode ? void 0 : props.customRenderSelections;
500
+ const maxSelections = isChildrenMode ? void 0 : props.maxSelections;
501
+ const renderSelection = isChildrenMode ? void 0 : props.renderSelection;
502
+ const removeSelectedItems = isChildrenMode ? false : props.removeSelectedItems ?? false;
503
+ const inputType = isChildrenMode ? "checkbox" : removeSelectedItems ? "none" : props.inputType ?? "checkbox";
504
+ const selectedItemIds = props.selectedItemIds;
505
+ const defaultSelectedItemIds = props.defaultSelectedItemIds;
506
+ const onSelectedItemIdsChange = props.onSelectedItemIdsChange;
507
+ const groupBy = isChildrenMode ? void 0 : props.groupBy;
508
+ const renderGroupHeading = isChildrenMode ? void 0 : props.renderGroupHeading;
509
+ const children = isChildrenMode ? props.children : void 0;
510
+ const { containerRef, portalContainer } = useSeedsPortalContainer();
511
+ const isControlled = selectedItemIds !== void 0;
512
+ const [internalValue, setInternalValue] = React5.useState(
513
+ () => defaultSelectedItemIds?.map(String) ?? []
514
+ );
515
+ const value = isControlled ? selectedItemIds.map(String) : internalValue;
516
+ const items = React5.useMemo(
517
+ () => data.map((item) => ({
518
+ value: String(item.id),
519
+ label: itemToString(item)
520
+ })),
521
+ [data, itemToString]
522
+ );
523
+ const selectedItems = React5.useMemo(
524
+ () => value.map((v) => data.find((d) => String(d.id) === v)).filter((d) => d != null),
525
+ [data, value]
526
+ );
527
+ function handleValueChange(newValues) {
528
+ if (!isControlled) {
529
+ setInternalValue(newValues);
530
+ }
531
+ if (onSelectedItemIdsChange) {
532
+ const ids = newValues.map((v) => {
533
+ const item = data.find((d) => String(d.id) === v);
534
+ return item ? item.id : v;
535
+ });
536
+ onSelectedItemIdsChange(ids);
537
+ }
538
+ }
539
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Field, { children: [
540
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { ref: containerRef, style: { position: "relative" } }),
541
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
542
+ import_select4.Select.Root,
543
+ {
544
+ multiple: true,
545
+ items,
546
+ value,
547
+ onValueChange: handleValueChange,
548
+ disabled: props.disabled,
549
+ id,
550
+ children: [
551
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(SelectTrigger, { children: [
552
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SelectValue, { children: () => {
553
+ if (renderSelection) return renderSelection(selectedItems);
554
+ if (selectedItems.length === 0)
555
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Placeholder, { children: placeholder });
556
+ const visibleItems = maxSelections != null ? selectedItems.slice(0, maxSelections) : selectedItems;
557
+ const overflowCount = maxSelections != null && selectedItems.length > maxSelections ? selectedItems.length - maxSelections : 0;
558
+ const text = visibleItems.map(
559
+ (item) => customRenderSelections ? customRenderSelections(item) : itemToString(item)
560
+ ).join(", ");
561
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(SelectionText, { children: [
562
+ text,
563
+ overflowCount > 0 ? `, +${overflowCount}` : ""
564
+ ] });
565
+ } }),
566
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SelectIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StyledChevron, { "data-chevron": true, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ChevronIcon, {}) }) })
567
+ ] }),
568
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_select4.Select.Portal, { container: portalContainer, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SelectPositioner, { sideOffset: 8, alignItemWithTrigger: false, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(SelectPopup, { children: [
569
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_select4.Select.ScrollUpArrow, {}),
570
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_select4.Select.List, { children: children ? children : groupBy ? groupItems(data, groupBy).map((group, index, arr) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(React5.Fragment, { children: [
571
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(SelectGroup, { children: [
572
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SelectGroupLabel, { children: renderGroupHeading ? renderGroupHeading(group.value) : group.value }),
573
+ group.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
574
+ SelectItem,
575
+ {
576
+ value: String(item.id),
577
+ label: itemToString(item),
578
+ disabled: item.disabled,
579
+ inputType,
580
+ hidden: removeSelectedItems && value.includes(String(item.id)),
581
+ renderItem: renderItem ? () => renderItem(item) : void 0
582
+ },
583
+ item.id
584
+ ))
585
+ ] }),
586
+ index < arr.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SelectSeparator, {})
587
+ ] }, group.value)) : data.map((item) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
588
+ SelectItem,
589
+ {
590
+ value: String(item.id),
591
+ label: itemToString(item),
592
+ disabled: item.disabled,
593
+ inputType,
594
+ hidden: removeSelectedItems && value.includes(String(item.id)),
595
+ renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
596
+ },
597
+ item.id
598
+ )) }),
599
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_select4.Select.ScrollDownArrow, {})
600
+ ] }) }) })
601
+ ]
602
+ }
603
+ )
604
+ ] });
605
+ }
287
606
 
288
607
  // src/v3/SingleCombobox.tsx
289
608
  var React8 = __toESM(require("react"));
@@ -322,6 +641,11 @@ var ComboboxInputGroup = (0, import_styled_components6.default)(import_combobox.
322
641
  &:focus-within {
323
642
  ${import_seeds_react_mixins2.focusRing}
324
643
  }
644
+
645
+ &[data-disabled] {
646
+ opacity: 0.4;
647
+ cursor: not-allowed;
648
+ }
325
649
  `;
326
650
  var ComboboxInput = (0, import_styled_components6.default)(import_combobox.Combobox.Input)`
327
651
  flex: 1;
@@ -337,6 +661,10 @@ var ComboboxInput = (0, import_styled_components6.default)(import_combobox.Combo
337
661
  &::placeholder {
338
662
  color: ${({ theme }) => theme.colors.text.subtext};
339
663
  }
664
+
665
+ &:disabled {
666
+ cursor: not-allowed;
667
+ }
340
668
  `;
341
669
  var ComboboxTokenInput = (0, import_styled_components6.default)(import_combobox.Combobox.Input)`
342
670
  flex: 1;
@@ -353,6 +681,10 @@ var ComboboxTokenInput = (0, import_styled_components6.default)(import_combobox.
353
681
  &::placeholder {
354
682
  color: ${({ theme }) => theme.colors.text.subtext};
355
683
  }
684
+
685
+ &:disabled {
686
+ cursor: not-allowed;
687
+ }
356
688
  `;
357
689
  var ComboboxActionButtons = import_styled_components6.default.div`
358
690
  display: flex;
@@ -596,6 +928,11 @@ var ComboboxTokenInputGroup = (0, import_styled_components6.default)(import_comb
596
928
  &:focus-within {
597
929
  ${import_seeds_react_mixins2.focusRing}
598
930
  }
931
+
932
+ &[data-disabled] {
933
+ opacity: 0.4;
934
+ cursor: not-allowed;
935
+ }
599
936
  `;
600
937
  var Token = import_styled_components6.default.span`
601
938
  display: inline-flex;
@@ -656,6 +993,11 @@ var SearchableSelectTrigger = (0, import_styled_components6.default)(import_comb
656
993
  &[data-popup-open] [data-chevron] {
657
994
  transform: rotate(-180deg);
658
995
  }
996
+
997
+ &[data-disabled] {
998
+ opacity: 0.4;
999
+ cursor: not-allowed;
1000
+ }
659
1001
  `;
660
1002
  var SearchableSelectTriggerIcon = (0, import_styled_components6.default)(import_combobox.Combobox.Icon)`
661
1003
  display: flex;
@@ -733,6 +1075,11 @@ var SearchableSelectTokenTrigger = (0, import_styled_components6.default)(import
733
1075
  &[data-popup-open] [data-chevron] {
734
1076
  transform: rotate(-180deg);
735
1077
  }
1078
+
1079
+ &[data-disabled] {
1080
+ opacity: 0.4;
1081
+ cursor: not-allowed;
1082
+ }
736
1083
  `;
737
1084
 
738
1085
  // src/v3/Common/ComboboxItem.tsx
@@ -741,6 +1088,7 @@ function ComboboxItemInner({
741
1088
  value,
742
1089
  itemId,
743
1090
  label,
1091
+ disabled,
744
1092
  inputType = "icon",
745
1093
  renderItem,
746
1094
  index,
@@ -755,6 +1103,8 @@ function ComboboxItemInner({
755
1103
  "data-index": dataIndex,
756
1104
  style,
757
1105
  ref,
1106
+ disabled,
1107
+ "data-qa-menu-item": label,
758
1108
  children: [
759
1109
  inputType === "radio" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
760
1110
  ComboboxItemIndicator,
@@ -788,22 +1138,312 @@ function ComboboxItemInner({
788
1138
  }
789
1139
  )
790
1140
  }
791
- ) : inputType === "icon" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ComboboxItemIndicator, { keepMounted: true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckIcon, {}) }) : null,
1141
+ ) : inputType === "icon" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ComboboxItemIndicator, { keepMounted: true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckIcon2, {}) }) : null,
792
1142
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: renderItem ? renderItem() : label })
793
1143
  ]
794
1144
  }
795
1145
  );
796
1146
  }
797
1147
  var ComboboxItem2 = React6.forwardRef(ComboboxItemInner);
1148
+ var ComboboxItem_default = ComboboxItem2;
798
1149
 
799
1150
  // src/v3/Common/VirtualizedComboboxList.tsx
800
1151
  var React7 = __toESM(require("react"));
801
1152
  var import_combobox2 = require("@base-ui/react/combobox");
802
1153
  var import_react_virtual = require("@tanstack/react-virtual");
803
1154
  var import_jsx_runtime7 = require("react/jsx-runtime");
1155
+ var ITEM_HEIGHT = 32;
1156
+ function isGroupHeaderSentinel(v) {
1157
+ return typeof v === "object" && v !== null && "__groupHeader" in v;
1158
+ }
1159
+ function isSelectAllSentinel(v) {
1160
+ return typeof v === "object" && v !== null && "__selectAll" in v;
1161
+ }
1162
+ function VirtualizedComboboxList({
1163
+ open,
1164
+ virtualizerRef,
1165
+ value,
1166
+ groups,
1167
+ data,
1168
+ itemToString,
1169
+ inputType,
1170
+ renderItem,
1171
+ renderGroupHeading
1172
+ }) {
1173
+ const filteredItems = import_combobox2.Combobox.useFilteredItems();
1174
+ const scrollElementRef = React7.useRef(null);
1175
+ const virtualizer = (0, import_react_virtual.useVirtualizer)({
1176
+ enabled: open,
1177
+ count: filteredItems.length,
1178
+ getScrollElement: () => scrollElementRef.current,
1179
+ estimateSize: () => ITEM_HEIGHT,
1180
+ overscan: 20,
1181
+ paddingStart: 4,
1182
+ paddingEnd: 4,
1183
+ scrollPaddingStart: 4,
1184
+ scrollPaddingEnd: 4
1185
+ });
1186
+ React7.useImperativeHandle(virtualizerRef, () => virtualizer);
1187
+ const handleScrollRef = React7.useCallback(
1188
+ (el) => {
1189
+ scrollElementRef.current = el;
1190
+ if (el) virtualizer.measure();
1191
+ },
1192
+ [virtualizer]
1193
+ );
1194
+ if (!filteredItems.length) return null;
1195
+ const selectedArray = Array.isArray(value) ? value : value != null ? [value] : [];
1196
+ const totalSize = virtualizer.getTotalSize();
1197
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1198
+ "div",
1199
+ {
1200
+ role: "presentation",
1201
+ ref: handleScrollRef,
1202
+ style: {
1203
+ flex: 1,
1204
+ minHeight: 0,
1205
+ overflowY: "auto",
1206
+ overscrollBehavior: "contain"
1207
+ },
1208
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1209
+ "div",
1210
+ {
1211
+ role: "presentation",
1212
+ style: { position: "relative", width: "100%", height: totalSize },
1213
+ children: virtualizer.getVirtualItems().map((virtualItem) => {
1214
+ const row = filteredItems[virtualItem.index];
1215
+ if (!row) return null;
1216
+ const baseStyle = {
1217
+ position: "absolute",
1218
+ top: 0,
1219
+ left: 0,
1220
+ width: "100%",
1221
+ transform: `translateY(${virtualItem.start}px)`,
1222
+ boxSizing: "border-box"
1223
+ };
1224
+ if (isSelectAllSentinel(row)) {
1225
+ const selectedCount = selectedArray.length;
1226
+ const totalCount = data.length;
1227
+ const state = selectedCount === 0 ? "none" : selectedCount === totalCount ? "all" : "partial";
1228
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1229
+ ComboboxSelectAllItem,
1230
+ {
1231
+ index: virtualItem.index,
1232
+ "data-index": virtualItem.index,
1233
+ value: row,
1234
+ style: baseStyle,
1235
+ ref: virtualizer.measureElement,
1236
+ children: [
1237
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ComboboxGroupHeaderCheckbox, { $state: state, id: "__selectAll" }),
1238
+ "Select all"
1239
+ ]
1240
+ },
1241
+ virtualItem.key
1242
+ );
1243
+ }
1244
+ if (isGroupHeaderSentinel(row)) {
1245
+ const group = groups?.find((g) => g.value === row.groupName);
1246
+ const groupItems2 = group?.items ?? [];
1247
+ const selectedCount = groupItems2.filter(
1248
+ (item2) => selectedArray.some((s) => s.id === item2.id)
1249
+ ).length;
1250
+ const state = selectedCount === 0 ? "none" : selectedCount === groupItems2.length ? "all" : "partial";
1251
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1252
+ ComboboxGroupHeaderItem,
1253
+ {
1254
+ index: virtualItem.index,
1255
+ "data-index": virtualItem.index,
1256
+ value: row,
1257
+ style: baseStyle,
1258
+ ref: virtualizer.measureElement,
1259
+ children: [
1260
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1261
+ ComboboxGroupHeaderCheckbox,
1262
+ {
1263
+ $state: state,
1264
+ id: `__header-${row.groupName}`
1265
+ }
1266
+ ),
1267
+ renderGroupHeading ? renderGroupHeading(row.groupName) : row.groupName
1268
+ ]
1269
+ },
1270
+ virtualItem.key
1271
+ );
1272
+ }
1273
+ const item = row;
1274
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1275
+ ComboboxItem_default,
1276
+ {
1277
+ index: virtualItem.index,
1278
+ "data-index": virtualItem.index,
1279
+ value: item,
1280
+ itemId: String(item.id),
1281
+ label: itemToString(item),
1282
+ inputType,
1283
+ renderItem: renderItem ? () => renderItem(item) : () => itemToString(item),
1284
+ style: baseStyle,
1285
+ ref: virtualizer.measureElement
1286
+ },
1287
+ virtualItem.key
1288
+ );
1289
+ })
1290
+ }
1291
+ )
1292
+ }
1293
+ );
1294
+ }
804
1295
 
805
1296
  // src/v3/SingleCombobox.tsx
806
1297
  var import_jsx_runtime8 = require("react/jsx-runtime");
1298
+ function SingleCombobox(props) {
1299
+ const {
1300
+ id,
1301
+ placeholder = "Search...",
1302
+ emptyText = "No results found."
1303
+ } = props;
1304
+ const isChildrenMode = "children" in props && props.children != null;
1305
+ const data = isChildrenMode ? [] : props.data;
1306
+ const itemToString = isChildrenMode ? (_item) => "" : props.itemToString;
1307
+ const renderItem = isChildrenMode ? void 0 : props.renderItem;
1308
+ const inputType = isChildrenMode ? "icon" : props.inputType ?? "icon";
1309
+ const isVirtualized = isChildrenMode ? false : props.isVirtualized ?? false;
1310
+ const groupBy = isChildrenMode ? void 0 : isVirtualized ? void 0 : props.groupBy;
1311
+ const renderGroupHeading = isChildrenMode ? void 0 : isVirtualized ? void 0 : props.renderGroupHeading;
1312
+ const children = isChildrenMode ? props.children : void 0;
1313
+ const selectedItemId = props.selectedItemId;
1314
+ const defaultSelectedItemId = props.defaultSelectedItemId;
1315
+ const onSelectedItemIdChange = props.onSelectedItemIdChange;
1316
+ const { containerRef, portalContainer } = useSeedsPortalContainer();
1317
+ const [open, setOpen] = React8.useState(false);
1318
+ const virtualizerRef = React8.useRef(null);
1319
+ const isControlled = selectedItemId !== void 0;
1320
+ const idToItem = React8.useCallback(
1321
+ (id2) => {
1322
+ if (id2 == null) return null;
1323
+ return data.find((d) => String(d.id) === String(id2)) ?? null;
1324
+ },
1325
+ [data]
1326
+ );
1327
+ const [internalValue, setInternalValue] = React8.useState(
1328
+ () => idToItem(defaultSelectedItemId)
1329
+ );
1330
+ const value = isControlled ? idToItem(selectedItemId) : internalValue;
1331
+ function handleValueChange(newItem) {
1332
+ if (!isControlled) {
1333
+ setInternalValue(newItem);
1334
+ }
1335
+ if (onSelectedItemIdChange) {
1336
+ onSelectedItemIdChange(newItem ? newItem.id : null);
1337
+ }
1338
+ }
1339
+ const groups = React8.useMemo(
1340
+ () => groupBy ? groupItems(data, groupBy) : null,
1341
+ [data, groupBy]
1342
+ );
1343
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Field, { children: [
1344
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: containerRef, style: { position: "relative" } }),
1345
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1346
+ import_combobox3.Combobox.Root,
1347
+ {
1348
+ id,
1349
+ value,
1350
+ onValueChange: handleValueChange,
1351
+ itemToStringLabel: itemToString,
1352
+ isItemEqualToValue: (a, b) => a != null && b != null && a.id === b.id,
1353
+ items: isVirtualized ? data : groups ?? (isChildrenMode ? void 0 : data),
1354
+ virtualized: isVirtualized,
1355
+ disabled: props.disabled,
1356
+ open,
1357
+ onOpenChange: setOpen,
1358
+ onItemHighlighted: isVirtualized ? (item, { reason, index }) => {
1359
+ const virt = virtualizerRef.current;
1360
+ if (!item || !virt) return;
1361
+ const isStart = index === 0;
1362
+ const isEnd = index === virt.options.count - 1;
1363
+ if (reason === "none" || reason === "keyboard" && (isStart || isEnd)) {
1364
+ queueMicrotask(() => {
1365
+ virt.scrollToIndex(index, {
1366
+ align: isEnd ? "start" : "end"
1367
+ });
1368
+ });
1369
+ }
1370
+ } : void 0,
1371
+ children: [
1372
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(ComboboxInputGroup, { children: [
1373
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ComboboxInput, { placeholder, id }),
1374
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(ComboboxActionButtons, { children: [
1375
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ComboboxClear, { "aria-label": "Clear selection", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ClearIcon, {}) }),
1376
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ComboboxTrigger, { "aria-label": "Open popup", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StyledChevron, { $isOpen: open, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ChevronIcon, {}) }) })
1377
+ ] })
1378
+ ] }),
1379
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_combobox3.Combobox.Portal, { container: portalContainer, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ComboboxPositioner, { sideOffset: 4, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1380
+ ComboboxPopup,
1381
+ {
1382
+ style: isVirtualized ? { display: "flex", flexDirection: "column" } : void 0,
1383
+ children: [
1384
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ComboboxEmpty, { children: emptyText }),
1385
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1386
+ ComboboxList,
1387
+ {
1388
+ style: isVirtualized ? {
1389
+ padding: 0,
1390
+ flex: 1,
1391
+ minHeight: 0,
1392
+ display: "flex",
1393
+ flexDirection: "column"
1394
+ } : void 0,
1395
+ children: isVirtualized ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1396
+ VirtualizedComboboxList,
1397
+ {
1398
+ open,
1399
+ virtualizerRef,
1400
+ value,
1401
+ groups,
1402
+ data,
1403
+ itemToString,
1404
+ inputType,
1405
+ renderItem,
1406
+ renderGroupHeading
1407
+ }
1408
+ ) : children ? children : groups ? (group, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(React8.Fragment, { children: [
1409
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(ComboboxGroup, { items: group.items, children: [
1410
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ComboboxGroupLabel, { children: renderGroupHeading ? renderGroupHeading(group.value) : group.value }),
1411
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_combobox3.Combobox.Collection, { children: (item) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1412
+ ComboboxItem_default,
1413
+ {
1414
+ value: item,
1415
+ itemId: String(item.id),
1416
+ label: itemToString(item),
1417
+ disabled: item.disabled,
1418
+ inputType,
1419
+ renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
1420
+ },
1421
+ item.id
1422
+ ) })
1423
+ ] }),
1424
+ index < groups.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ComboboxSeparator, {})
1425
+ ] }, group.value) : (item) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1426
+ ComboboxItem_default,
1427
+ {
1428
+ value: item,
1429
+ itemId: String(item.id),
1430
+ label: itemToString(item),
1431
+ disabled: item.disabled,
1432
+ inputType,
1433
+ renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
1434
+ },
1435
+ item.id
1436
+ )
1437
+ }
1438
+ )
1439
+ ]
1440
+ }
1441
+ ) }) })
1442
+ ]
1443
+ }
1444
+ )
1445
+ ] });
1446
+ }
807
1447
 
808
1448
  // src/v3/MultiCombobox.tsx
809
1449
  var React9 = __toESM(require("react"));
@@ -811,12 +1451,490 @@ var import_combobox4 = require("@base-ui/react/combobox");
811
1451
  var import_react_virtual3 = require("@tanstack/react-virtual");
812
1452
  var import_seeds_react_icon3 = __toESM(require("@sproutsocial/seeds-react-icon"));
813
1453
  var import_jsx_runtime9 = require("react/jsx-runtime");
1454
+ function makeGroupHeaderSentinel(groupName) {
1455
+ return { __groupHeader: true, groupName };
1456
+ }
1457
+ function isGroupHeaderSentinel2(v) {
1458
+ return typeof v === "object" && v !== null && "__groupHeader" in v;
1459
+ }
1460
+ var SELECT_ALL_SENTINEL = { __selectAll: true };
1461
+ function isSelectAllSentinel2(v) {
1462
+ return typeof v === "object" && v !== null && "__selectAll" in v;
1463
+ }
1464
+ function MultiCombobox(props) {
1465
+ const {
1466
+ id,
1467
+ placeholder = "Search...",
1468
+ emptyText = "No results found.",
1469
+ isLoading = false,
1470
+ loadingText = "Loading..."
1471
+ } = props;
1472
+ const isChildrenMode = "children" in props && props.children != null;
1473
+ const data = isChildrenMode ? [] : props.data;
1474
+ const itemToString = isChildrenMode ? (_item) => "" : props.itemToString;
1475
+ const renderItem = isChildrenMode ? void 0 : props.renderItem;
1476
+ const renderToken = isChildrenMode ? void 0 : props.renderToken;
1477
+ const renderSelection = isChildrenMode ? void 0 : props.renderSelection;
1478
+ const maxTokens = isChildrenMode ? void 0 : props.maxTokens;
1479
+ const removeSelectedItems = isChildrenMode ? false : props.removeSelectedItems ?? false;
1480
+ const inputType = isChildrenMode ? "checkbox" : removeSelectedItems ? "none" : props.inputType ?? "checkbox";
1481
+ const groupBy = isChildrenMode ? void 0 : props.groupBy;
1482
+ const renderGroupHeading = isChildrenMode ? void 0 : props.renderGroupHeading;
1483
+ const selectHeadings = isChildrenMode ? false : props.selectHeadings ?? false;
1484
+ const selectAll = isChildrenMode ? false : props.selectAll ?? false;
1485
+ const isVirtualized = isChildrenMode ? false : props.isVirtualized ?? false;
1486
+ const children = isChildrenMode ? props.children : void 0;
1487
+ const selectedItemIds = props.selectedItemIds;
1488
+ const defaultSelectedItemIds = props.defaultSelectedItemIds;
1489
+ const onSelectedItemIdsChange = props.onSelectedItemIdsChange;
1490
+ const { containerRef, portalContainer } = useSeedsPortalContainer();
1491
+ const [open, setOpen] = React9.useState(false);
1492
+ const virtualizerRef = React9.useRef(null);
1493
+ const isControlled = selectedItemIds !== void 0;
1494
+ const idsToItems = React9.useCallback(
1495
+ (ids) => ids.map((id2) => data.find((d) => d.id === id2)).filter((d) => d != null),
1496
+ [data]
1497
+ );
1498
+ const [internalValue, setInternalValue] = React9.useState(
1499
+ () => defaultSelectedItemIds ? idsToItems(defaultSelectedItemIds) : []
1500
+ );
1501
+ const value = isControlled ? idsToItems(selectedItemIds) : internalValue;
1502
+ const visibleData = React9.useMemo(
1503
+ () => removeSelectedItems ? data.filter((item) => !value.some((v) => v.id === item.id)) : data,
1504
+ [data, value, removeSelectedItems]
1505
+ );
1506
+ const groups = React9.useMemo(
1507
+ () => groupBy ? groupItems(visibleData, groupBy) : null,
1508
+ [visibleData, groupBy]
1509
+ );
1510
+ const flatItems = React9.useMemo(() => {
1511
+ if (!groups || !selectHeadings && !selectAll) return null;
1512
+ const rows = [];
1513
+ if (selectAll) rows.push(SELECT_ALL_SENTINEL);
1514
+ for (const group of groups) {
1515
+ rows.push(makeGroupHeaderSentinel(group.value));
1516
+ rows.push(...group.items);
1517
+ }
1518
+ return rows;
1519
+ }, [groups, selectHeadings, selectAll]);
1520
+ function setSelectedItems(items) {
1521
+ if (!isControlled) setInternalValue(items);
1522
+ if (onSelectedItemIdsChange)
1523
+ onSelectedItemIdsChange(items.map((item) => item.id));
1524
+ }
1525
+ function handleValueChange(next) {
1526
+ const selectAllClicked = next.filter(isSelectAllSentinel2);
1527
+ const groupSentinels = next.filter(isGroupHeaderSentinel2);
1528
+ const realItems = next.filter(
1529
+ (v) => !isGroupHeaderSentinel2(v) && !isSelectAllSentinel2(v)
1530
+ );
1531
+ if (selectAllClicked.length > 0) {
1532
+ const allSelected = data.every(
1533
+ (d) => realItems.some((s) => s.id === d.id)
1534
+ );
1535
+ setSelectedItems(allSelected ? [] : [...data]);
1536
+ return;
1537
+ }
1538
+ if (groupSentinels.length === 0) {
1539
+ setSelectedItems(realItems);
1540
+ return;
1541
+ }
1542
+ let updated = [...realItems];
1543
+ for (const sentinel of groupSentinels) {
1544
+ const group = groups?.find((g) => g.value === sentinel.groupName);
1545
+ if (!group) continue;
1546
+ const allSelected = group.items.every(
1547
+ (item) => updated.some((s) => s.id === item.id)
1548
+ );
1549
+ if (allSelected) {
1550
+ updated = updated.filter(
1551
+ (s) => !group.items.some((item) => item.id === s.id)
1552
+ );
1553
+ } else {
1554
+ const missing = group.items.filter(
1555
+ (item) => !updated.some((s) => s.id === item.id)
1556
+ );
1557
+ updated = [...updated, ...missing];
1558
+ }
1559
+ }
1560
+ setSelectedItems(updated);
1561
+ }
1562
+ function handleSimpleValueChange(newItems) {
1563
+ setSelectedItems(newItems);
1564
+ }
1565
+ function removeItem(item, e) {
1566
+ e.preventDefault();
1567
+ e.stopPropagation();
1568
+ setSelectedItems(value.filter((v) => v.id !== item.id));
1569
+ }
1570
+ function renderSentinelRow(row) {
1571
+ if (isSelectAllSentinel2(row)) {
1572
+ const totalCount = data.length;
1573
+ const selectedCount = value.length;
1574
+ const state = selectedCount === 0 ? "none" : selectedCount === totalCount ? "all" : "partial";
1575
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(ComboboxSelectAllItem, { value: row, children: [
1576
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ComboboxGroupHeaderCheckbox, { $state: state, id: "__selectAll" }),
1577
+ "Select all"
1578
+ ] }, "__selectAll");
1579
+ }
1580
+ if (isGroupHeaderSentinel2(row)) {
1581
+ const group = groups?.find((g) => g.value === row.groupName);
1582
+ const groupItemsList = group?.items ?? [];
1583
+ const selectedCount = groupItemsList.filter(
1584
+ (item2) => value.some((s) => s.id === item2.id)
1585
+ ).length;
1586
+ const state = selectedCount === 0 ? "none" : selectedCount === groupItemsList.length ? "all" : "partial";
1587
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(ComboboxGroupHeaderItem, { value: row, children: [
1588
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1589
+ ComboboxGroupHeaderCheckbox,
1590
+ {
1591
+ $state: state,
1592
+ id: `__header-${row.groupName}`
1593
+ }
1594
+ ),
1595
+ renderGroupHeading ? renderGroupHeading(row.groupName) : row.groupName
1596
+ ] }, `__header-${row.groupName}`);
1597
+ }
1598
+ const item = row;
1599
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1600
+ ComboboxItem_default,
1601
+ {
1602
+ value: item,
1603
+ itemId: String(item.id),
1604
+ label: itemToString(item),
1605
+ disabled: item.disabled,
1606
+ inputType,
1607
+ renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
1608
+ },
1609
+ item.id
1610
+ );
1611
+ }
1612
+ const rootItems = flatItems ?? groups ?? (isChildrenMode ? void 0 : visibleData);
1613
+ const hasSentinels = selectAll || selectHeadings;
1614
+ const rootValue = hasSentinels ? [...value] : value;
1615
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Field, { children: [
1616
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ref: containerRef, style: { position: "relative" } }),
1617
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1618
+ import_combobox4.Combobox.Root,
1619
+ {
1620
+ multiple: true,
1621
+ id,
1622
+ virtualized: isVirtualized,
1623
+ open,
1624
+ disabled: props.disabled,
1625
+ onOpenChange: setOpen,
1626
+ onItemHighlighted: isVirtualized ? (item, { reason, index }) => {
1627
+ const virt = virtualizerRef.current;
1628
+ if (!item || !virt) return;
1629
+ const isStart = index === 0;
1630
+ const isEnd = index === virt.options.count - 1;
1631
+ if (reason === "none" || reason === "keyboard" && (isStart || isEnd)) {
1632
+ queueMicrotask(() => {
1633
+ virt.scrollToIndex(index, {
1634
+ align: isEnd ? "start" : "end"
1635
+ });
1636
+ });
1637
+ }
1638
+ } : void 0,
1639
+ value: rootValue,
1640
+ onValueChange: (
1641
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1642
+ hasSentinels ? handleValueChange : handleSimpleValueChange
1643
+ ),
1644
+ itemToStringLabel: (item) => {
1645
+ if (!item || isGroupHeaderSentinel2(item) || isSelectAllSentinel2(item))
1646
+ return "";
1647
+ return itemToString(item);
1648
+ },
1649
+ isItemEqualToValue: (a, b) => {
1650
+ if (isGroupHeaderSentinel2(a) && isGroupHeaderSentinel2(b))
1651
+ return a.groupName === b.groupName;
1652
+ if (isSelectAllSentinel2(a) && isSelectAllSentinel2(b)) return true;
1653
+ if (!isGroupHeaderSentinel2(a) && !isSelectAllSentinel2(a) && !isGroupHeaderSentinel2(b) && !isSelectAllSentinel2(b))
1654
+ return a.id === b.id;
1655
+ return false;
1656
+ },
1657
+ items: rootItems,
1658
+ children: [
1659
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ComboboxTokenInputGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(ComboboxToken, { children: [
1660
+ renderSelection ? renderSelection(value) : (() => {
1661
+ const visibleTokens = maxTokens != null ? value.slice(0, maxTokens) : value;
1662
+ const overflow = maxTokens != null ? value.length - maxTokens : 0;
1663
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1664
+ visibleTokens.map((item) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Token, { children: [
1665
+ renderToken ? renderToken(item) : itemToString(item),
1666
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1667
+ TokenRemove,
1668
+ {
1669
+ "aria-label": `Remove ${itemToString(item)}`,
1670
+ onPointerDown: (e) => e.preventDefault(),
1671
+ onClick: (e) => removeItem(item, e),
1672
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_seeds_react_icon3.default, { name: "x-outline", size: "mini" })
1673
+ }
1674
+ )
1675
+ ] }, item.id)),
1676
+ overflow > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Token, { children: [
1677
+ "+",
1678
+ overflow
1679
+ ] }, "__overflow")
1680
+ ] });
1681
+ })(),
1682
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1683
+ ComboboxTokenInput,
1684
+ {
1685
+ id,
1686
+ placeholder: value.length > 0 ? "" : placeholder
1687
+ }
1688
+ ),
1689
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(ComboboxActionButtons, { children: [
1690
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ComboboxClear, { "aria-label": "Clear all", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ClearIcon, {}) }),
1691
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ComboboxTrigger, { "aria-label": "Open popup", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StyledChevron, { $isOpen: open, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChevronIcon, {}) }) })
1692
+ ] })
1693
+ ] }) }),
1694
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_combobox4.Combobox.Portal, { container: portalContainer, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ComboboxPositioner, { sideOffset: 4, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1695
+ ComboboxPopup,
1696
+ {
1697
+ "aria-busy": isLoading || void 0,
1698
+ style: isVirtualized ? { display: "flex", flexDirection: "column" } : void 0,
1699
+ children: [
1700
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ComboboxStatus, { children: isLoading ? loadingText : null }),
1701
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ComboboxEmpty, { children: isLoading ? null : emptyText }),
1702
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1703
+ ComboboxList,
1704
+ {
1705
+ style: isVirtualized ? {
1706
+ padding: 0,
1707
+ flex: 1,
1708
+ minHeight: 0,
1709
+ display: "flex",
1710
+ flexDirection: "column"
1711
+ } : void 0,
1712
+ children: isVirtualized ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1713
+ VirtualizedComboboxList,
1714
+ {
1715
+ open,
1716
+ virtualizerRef,
1717
+ value,
1718
+ groups,
1719
+ data: visibleData,
1720
+ itemToString,
1721
+ inputType,
1722
+ renderItem,
1723
+ renderGroupHeading
1724
+ }
1725
+ ) : children ? children : flatItems ? (row) => renderSentinelRow(row) : groups ? (group, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(React9.Fragment, { children: [
1726
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(ComboboxGroup, { items: group.items, children: [
1727
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ComboboxGroupLabel, { children: renderGroupHeading ? renderGroupHeading(group.value) : group.value }),
1728
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_combobox4.Combobox.Collection, { children: (item) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1729
+ ComboboxItem_default,
1730
+ {
1731
+ value: item,
1732
+ itemId: String(item.id),
1733
+ label: itemToString(item),
1734
+ disabled: item.disabled,
1735
+ inputType,
1736
+ renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
1737
+ },
1738
+ item.id
1739
+ ) })
1740
+ ] }),
1741
+ index < groups.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ComboboxSeparator, {})
1742
+ ] }, group.value) : (item) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1743
+ ComboboxItem_default,
1744
+ {
1745
+ value: item,
1746
+ itemId: String(item.id),
1747
+ label: itemToString(item),
1748
+ disabled: item.disabled,
1749
+ inputType,
1750
+ renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
1751
+ },
1752
+ item.id
1753
+ )
1754
+ }
1755
+ )
1756
+ ]
1757
+ }
1758
+ ) }) })
1759
+ ]
1760
+ }
1761
+ )
1762
+ ] });
1763
+ }
814
1764
 
815
1765
  // src/v3/SingleSearchableSelect.tsx
816
1766
  var React10 = __toESM(require("react"));
817
1767
  var import_combobox5 = require("@base-ui/react/combobox");
818
1768
  var import_react_virtual4 = require("@tanstack/react-virtual");
819
1769
  var import_jsx_runtime10 = require("react/jsx-runtime");
1770
+ function SingleSearchableSelect(props) {
1771
+ const {
1772
+ id,
1773
+ placeholder = "Select...",
1774
+ includePlaceholderItem,
1775
+ searchPlaceholder = "Search...",
1776
+ emptyText = "No results found.",
1777
+ isLoading = false,
1778
+ loadingText = "Loading..."
1779
+ } = props;
1780
+ const isChildrenMode = "children" in props && props.children != null;
1781
+ const data = isChildrenMode ? [] : props.data;
1782
+ const itemToString = isChildrenMode ? (_item) => "" : props.itemToString;
1783
+ const renderItem = isChildrenMode ? void 0 : props.renderItem;
1784
+ const renderSelection = isChildrenMode ? void 0 : props.renderSelection;
1785
+ const inputType = isChildrenMode ? "icon" : props.inputType ?? "icon";
1786
+ const isVirtualized = isChildrenMode ? false : props.isVirtualized ?? false;
1787
+ const groupBy = isChildrenMode ? void 0 : isVirtualized ? void 0 : props.groupBy;
1788
+ const renderGroupHeading = isChildrenMode ? void 0 : isVirtualized ? void 0 : props.renderGroupHeading;
1789
+ const children = isChildrenMode ? props.children : void 0;
1790
+ const selectedItemId = props.selectedItemId;
1791
+ const defaultSelectedItemId = props.defaultSelectedItemId;
1792
+ const onSelectedItemIdChange = props.onSelectedItemIdChange;
1793
+ const { containerRef, portalContainer } = useSeedsPortalContainer();
1794
+ const [open, setOpen] = React10.useState(false);
1795
+ const virtualizerRef = React10.useRef(null);
1796
+ const isControlled = selectedItemId !== void 0;
1797
+ const idToItem = React10.useCallback(
1798
+ (id2) => {
1799
+ if (id2 == null) return null;
1800
+ return data.find((d) => String(d.id) === String(id2)) ?? null;
1801
+ },
1802
+ [data]
1803
+ );
1804
+ const [internalValue, setInternalValue] = React10.useState(
1805
+ () => idToItem(defaultSelectedItemId)
1806
+ );
1807
+ const value = isControlled ? idToItem(selectedItemId) : internalValue;
1808
+ function handleValueChange(newItem) {
1809
+ if (!isControlled) setInternalValue(newItem);
1810
+ if (onSelectedItemIdChange) {
1811
+ onSelectedItemIdChange(newItem ? newItem.id : null);
1812
+ }
1813
+ }
1814
+ const groups = React10.useMemo(
1815
+ () => groupBy ? groupItems(data, groupBy) : null,
1816
+ [data, groupBy]
1817
+ );
1818
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Field, { children: [
1819
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { ref: containerRef, style: { position: "relative" } }),
1820
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1821
+ import_combobox5.Combobox.Root,
1822
+ {
1823
+ id,
1824
+ value,
1825
+ disabled: props.disabled,
1826
+ onValueChange: handleValueChange,
1827
+ itemToStringLabel: itemToString,
1828
+ isItemEqualToValue: (a, b) => a != null && b != null && a.id === b.id,
1829
+ items: isVirtualized ? data : groups ?? (isChildrenMode ? void 0 : data),
1830
+ virtualized: isVirtualized,
1831
+ open,
1832
+ onOpenChange: setOpen,
1833
+ onItemHighlighted: isVirtualized ? (item, { reason, index }) => {
1834
+ const virt = virtualizerRef.current;
1835
+ if (!item || !virt) return;
1836
+ const isStart = index === 0;
1837
+ const isEnd = index === virt.options.count - 1;
1838
+ if (reason === "none" || reason === "keyboard" && (isStart || isEnd)) {
1839
+ queueMicrotask(() => {
1840
+ virt.scrollToIndex(index, {
1841
+ align: isEnd ? "start" : "end"
1842
+ });
1843
+ });
1844
+ }
1845
+ } : void 0,
1846
+ children: [
1847
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(SearchableSelectTrigger, { id, children: [
1848
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SearchableSelectPlaceholder, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_combobox5.Combobox.Value, { placeholder, children: value ? renderSelection ? renderSelection(value) : itemToString(value) : null }) }),
1849
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SearchableSelectTriggerIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(StyledChevron, { "data-chevron": true, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ChevronIcon, {}) }) })
1850
+ ] }),
1851
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_combobox5.Combobox.Portal, { container: portalContainer, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ComboboxPositioner, { sideOffset: 4, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1852
+ SearchableSelectPopup,
1853
+ {
1854
+ "aria-busy": isLoading || void 0,
1855
+ style: { display: "flex", flexDirection: "column" },
1856
+ children: [
1857
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SearchableSelectSearchContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1858
+ SearchableSelectInput,
1859
+ {
1860
+ placeholder: searchPlaceholder,
1861
+ autoFocus: true
1862
+ }
1863
+ ) }),
1864
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ComboboxStatus, { children: isLoading ? loadingText : null }),
1865
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ComboboxEmpty, { children: isLoading ? null : emptyText }),
1866
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1867
+ SearchableSelectList,
1868
+ {
1869
+ style: isVirtualized ? {
1870
+ padding: 0,
1871
+ flex: 1,
1872
+ minHeight: 0,
1873
+ display: "flex",
1874
+ flexDirection: "column"
1875
+ } : void 0,
1876
+ children: isVirtualized ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1877
+ VirtualizedComboboxList,
1878
+ {
1879
+ open,
1880
+ virtualizerRef,
1881
+ value,
1882
+ groups: null,
1883
+ data,
1884
+ itemToString,
1885
+ inputType,
1886
+ renderItem
1887
+ }
1888
+ ) : children ? children : groups ? (group, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(React10.Fragment, { children: [
1889
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(ComboboxGroup, { items: group.items, children: [
1890
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ComboboxGroupLabel, { children: renderGroupHeading ? renderGroupHeading(group.value) : group.value }),
1891
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_combobox5.Combobox.Collection, { children: (item) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1892
+ ComboboxItem_default,
1893
+ {
1894
+ value: item,
1895
+ itemId: String(item.id),
1896
+ label: itemToString(item),
1897
+ disabled: item.disabled,
1898
+ inputType,
1899
+ renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
1900
+ },
1901
+ item.id
1902
+ ) })
1903
+ ] }),
1904
+ index < groups.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ComboboxSeparator, {})
1905
+ ] }, group.value) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1906
+ includePlaceholderItem && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1907
+ ComboboxItem_default,
1908
+ {
1909
+ value: null,
1910
+ itemId: "placeholder",
1911
+ label: placeholder
1912
+ },
1913
+ "placeholder"
1914
+ ),
1915
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_combobox5.Combobox.Collection, { children: (item) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1916
+ ComboboxItem_default,
1917
+ {
1918
+ value: item,
1919
+ itemId: String(item.id),
1920
+ label: itemToString(item),
1921
+ disabled: item.disabled,
1922
+ inputType,
1923
+ renderItem: renderItem ? () => renderItem(item) : void 0
1924
+ },
1925
+ item.id
1926
+ ) })
1927
+ ] })
1928
+ }
1929
+ )
1930
+ ]
1931
+ }
1932
+ ) }) })
1933
+ ]
1934
+ }
1935
+ )
1936
+ ] });
1937
+ }
820
1938
 
821
1939
  // src/v3/MultiSearchableSelect.tsx
822
1940
  var React11 = __toESM(require("react"));
@@ -830,6 +1948,298 @@ var SelectionText2 = import_styled_components7.default.span`
830
1948
  text-overflow: ellipsis;
831
1949
  white-space: nowrap;
832
1950
  `;
1951
+ function makeGroupHeaderSentinel2(groupName) {
1952
+ return { __groupHeader: true, groupName };
1953
+ }
1954
+ function isGroupHeaderSentinel3(v) {
1955
+ return typeof v === "object" && v !== null && "__groupHeader" in v;
1956
+ }
1957
+ var SELECT_ALL_SENTINEL2 = { __selectAll: true };
1958
+ function isSelectAllSentinel3(v) {
1959
+ return typeof v === "object" && v !== null && "__selectAll" in v;
1960
+ }
1961
+ function MultiSearchableSelect(props) {
1962
+ const {
1963
+ id,
1964
+ placeholder = "Select...",
1965
+ searchPlaceholder = "Search...",
1966
+ emptyText = "No results found.",
1967
+ isLoading = false,
1968
+ loadingText = "Loading..."
1969
+ } = props;
1970
+ const isChildrenMode = "children" in props && props.children != null;
1971
+ const data = isChildrenMode ? [] : props.data;
1972
+ const itemToString = isChildrenMode ? (_item) => "" : props.itemToString;
1973
+ const renderItem = isChildrenMode ? void 0 : props.renderItem;
1974
+ const customRenderSelections = isChildrenMode ? void 0 : props.customRenderSelections;
1975
+ const maxSelections = isChildrenMode ? void 0 : props.maxSelections;
1976
+ const renderSelection = isChildrenMode ? void 0 : props.renderSelection;
1977
+ const removeSelectedItems = isChildrenMode ? false : props.removeSelectedItems ?? false;
1978
+ const inputType = isChildrenMode ? "checkbox" : removeSelectedItems ? "none" : props.inputType ?? "checkbox";
1979
+ const groupBy = isChildrenMode ? void 0 : props.groupBy;
1980
+ const renderGroupHeading = isChildrenMode ? void 0 : props.renderGroupHeading;
1981
+ const selectHeadings = isChildrenMode ? false : props.selectHeadings ?? false;
1982
+ const selectAll = isChildrenMode ? false : props.selectAll ?? false;
1983
+ const isVirtualized = isChildrenMode ? false : props.isVirtualized ?? false;
1984
+ const children = isChildrenMode ? props.children : void 0;
1985
+ const selectedItemIds = props.selectedItemIds;
1986
+ const defaultSelectedItemIds = props.defaultSelectedItemIds;
1987
+ const onSelectedItemIdsChange = props.onSelectedItemIdsChange;
1988
+ const { containerRef, portalContainer } = useSeedsPortalContainer();
1989
+ const [open, setOpen] = React11.useState(false);
1990
+ const virtualizerRef = React11.useRef(null);
1991
+ const isControlled = selectedItemIds !== void 0;
1992
+ const idsToItems = React11.useCallback(
1993
+ (ids) => ids.map((id2) => data.find((d) => d.id === id2)).filter((d) => d != null),
1994
+ [data]
1995
+ );
1996
+ const [internalValue, setInternalValue] = React11.useState(
1997
+ () => defaultSelectedItemIds ? idsToItems(defaultSelectedItemIds) : []
1998
+ );
1999
+ const value = isControlled ? idsToItems(selectedItemIds) : internalValue;
2000
+ const visibleData = React11.useMemo(
2001
+ () => removeSelectedItems ? data.filter((item) => !value.some((v) => v.id === item.id)) : data,
2002
+ [data, value, removeSelectedItems]
2003
+ );
2004
+ const groups = React11.useMemo(
2005
+ () => groupBy ? groupItems(visibleData, groupBy) : null,
2006
+ [visibleData, groupBy]
2007
+ );
2008
+ const flatItems = React11.useMemo(() => {
2009
+ if (!groups || !selectHeadings && !selectAll) return null;
2010
+ const rows = [];
2011
+ if (selectAll) rows.push(SELECT_ALL_SENTINEL2);
2012
+ for (const group of groups) {
2013
+ rows.push(makeGroupHeaderSentinel2(group.value));
2014
+ rows.push(...group.items);
2015
+ }
2016
+ return rows;
2017
+ }, [groups, selectHeadings, selectAll]);
2018
+ function setSelectedItems(items) {
2019
+ if (!isControlled) setInternalValue(items);
2020
+ if (onSelectedItemIdsChange)
2021
+ onSelectedItemIdsChange(items.map((item) => item.id));
2022
+ }
2023
+ function handleValueChange(next) {
2024
+ const selectAllClicked = next.filter(isSelectAllSentinel3);
2025
+ const groupSentinels = next.filter(isGroupHeaderSentinel3);
2026
+ const realItems = next.filter(
2027
+ (v) => !isGroupHeaderSentinel3(v) && !isSelectAllSentinel3(v)
2028
+ );
2029
+ if (selectAllClicked.length > 0) {
2030
+ const allSelected = data.every(
2031
+ (d) => realItems.some((s) => s.id === d.id)
2032
+ );
2033
+ setSelectedItems(allSelected ? [] : [...data]);
2034
+ return;
2035
+ }
2036
+ if (groupSentinels.length === 0) {
2037
+ setSelectedItems(realItems);
2038
+ return;
2039
+ }
2040
+ let updated = [...realItems];
2041
+ for (const sentinel of groupSentinels) {
2042
+ const group = groups?.find((g) => g.value === sentinel.groupName);
2043
+ if (!group) continue;
2044
+ const allSelected = group.items.every(
2045
+ (item) => updated.some((s) => s.id === item.id)
2046
+ );
2047
+ if (allSelected) {
2048
+ updated = updated.filter(
2049
+ (s) => !group.items.some((item) => item.id === s.id)
2050
+ );
2051
+ } else {
2052
+ const missing = group.items.filter(
2053
+ (item) => !updated.some((s) => s.id === item.id)
2054
+ );
2055
+ updated = [...updated, ...missing];
2056
+ }
2057
+ }
2058
+ setSelectedItems(updated);
2059
+ }
2060
+ function handleSimpleValueChange(newItems) {
2061
+ setSelectedItems(newItems);
2062
+ }
2063
+ function renderSentinelRow(row) {
2064
+ if (isSelectAllSentinel3(row)) {
2065
+ const totalCount = data.length;
2066
+ const selectedCount = value.length;
2067
+ const state = selectedCount === 0 ? "none" : selectedCount === totalCount ? "all" : "partial";
2068
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(ComboboxSelectAllItem, { value: row, children: [
2069
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ComboboxGroupHeaderCheckbox, { $state: state, id: "__selectAll" }),
2070
+ "Select all"
2071
+ ] }, "__selectAll");
2072
+ }
2073
+ if (isGroupHeaderSentinel3(row)) {
2074
+ const group = groups?.find((g) => g.value === row.groupName);
2075
+ const groupItemsList = group?.items ?? [];
2076
+ const selectedCount = groupItemsList.filter(
2077
+ (item2) => value.some((s) => s.id === item2.id)
2078
+ ).length;
2079
+ const state = selectedCount === 0 ? "none" : selectedCount === groupItemsList.length ? "all" : "partial";
2080
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(ComboboxGroupHeaderItem, { value: row, children: [
2081
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2082
+ ComboboxGroupHeaderCheckbox,
2083
+ {
2084
+ $state: state,
2085
+ id: `__header-${row.groupName}`
2086
+ }
2087
+ ),
2088
+ renderGroupHeading ? renderGroupHeading(row.groupName) : row.groupName
2089
+ ] }, `__header-${row.groupName}`);
2090
+ }
2091
+ const item = row;
2092
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2093
+ ComboboxItem_default,
2094
+ {
2095
+ value: item,
2096
+ itemId: String(item.id),
2097
+ label: itemToString(item),
2098
+ disabled: item.disabled,
2099
+ inputType,
2100
+ renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
2101
+ },
2102
+ item.id
2103
+ );
2104
+ }
2105
+ const rootItems = flatItems ?? groups ?? (isChildrenMode ? void 0 : visibleData);
2106
+ const hasSentinels = selectAll || selectHeadings;
2107
+ const rootValue = hasSentinels ? [...value] : value;
2108
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Field, { children: [
2109
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { ref: containerRef, style: { position: "relative" } }),
2110
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2111
+ import_combobox6.Combobox.Root,
2112
+ {
2113
+ multiple: true,
2114
+ id,
2115
+ virtualized: isVirtualized,
2116
+ open,
2117
+ disabled: props.disabled,
2118
+ onOpenChange: setOpen,
2119
+ onItemHighlighted: isVirtualized ? (item, { reason, index }) => {
2120
+ const virt = virtualizerRef.current;
2121
+ if (!item || !virt) return;
2122
+ const isStart = index === 0;
2123
+ const isEnd = index === virt.options.count - 1;
2124
+ if (reason === "none" || reason === "keyboard" && (isStart || isEnd)) {
2125
+ queueMicrotask(() => {
2126
+ virt.scrollToIndex(index, {
2127
+ align: isEnd ? "start" : "end"
2128
+ });
2129
+ });
2130
+ }
2131
+ } : void 0,
2132
+ value: rootValue,
2133
+ onValueChange: (
2134
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2135
+ hasSentinels ? handleValueChange : handleSimpleValueChange
2136
+ ),
2137
+ itemToStringLabel: (item) => {
2138
+ if (!item || isGroupHeaderSentinel3(item) || isSelectAllSentinel3(item))
2139
+ return "";
2140
+ return itemToString(item);
2141
+ },
2142
+ isItemEqualToValue: (a, b) => {
2143
+ if (isGroupHeaderSentinel3(a) && isGroupHeaderSentinel3(b))
2144
+ return a.groupName === b.groupName;
2145
+ if (isSelectAllSentinel3(a) && isSelectAllSentinel3(b)) return true;
2146
+ if (!isGroupHeaderSentinel3(a) && !isSelectAllSentinel3(a) && !isGroupHeaderSentinel3(b) && !isSelectAllSentinel3(b))
2147
+ return a.id === b.id;
2148
+ return false;
2149
+ },
2150
+ items: rootItems,
2151
+ children: [
2152
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(SearchableSelectTokenTrigger, { id, children: [
2153
+ renderSelection ? renderSelection(value) : value.length > 0 ? (() => {
2154
+ const visibleItems = maxSelections != null ? value.slice(0, maxSelections) : value;
2155
+ const overflowCount = maxSelections != null && value.length > maxSelections ? value.length - maxSelections : 0;
2156
+ const text = visibleItems.map(
2157
+ (item) => customRenderSelections ? customRenderSelections(item) : itemToString(item)
2158
+ ).join(", ");
2159
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(SelectionText2, { children: [
2160
+ text,
2161
+ overflowCount > 0 ? `, +${overflowCount}` : ""
2162
+ ] });
2163
+ })() : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SearchableSelectPlaceholder, { children: placeholder }),
2164
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SearchableSelectTriggerIcon, { style: { marginLeft: "auto" }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(StyledChevron, { "data-chevron": true, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ChevronIcon, {}) }) })
2165
+ ] }),
2166
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_combobox6.Combobox.Portal, { container: portalContainer, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ComboboxPositioner, { sideOffset: 4, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2167
+ SearchableSelectPopup,
2168
+ {
2169
+ "aria-busy": isLoading || void 0,
2170
+ style: { display: "flex", flexDirection: "column" },
2171
+ children: [
2172
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SearchableSelectSearchContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2173
+ SearchableSelectInput,
2174
+ {
2175
+ placeholder: searchPlaceholder,
2176
+ autoFocus: true
2177
+ }
2178
+ ) }),
2179
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ComboboxStatus, { children: isLoading ? loadingText : null }),
2180
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ComboboxEmpty, { children: isLoading ? null : emptyText }),
2181
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2182
+ SearchableSelectList,
2183
+ {
2184
+ style: isVirtualized ? {
2185
+ padding: 0,
2186
+ flex: 1,
2187
+ minHeight: 0,
2188
+ display: "flex",
2189
+ flexDirection: "column"
2190
+ } : void 0,
2191
+ children: isVirtualized ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2192
+ VirtualizedComboboxList,
2193
+ {
2194
+ open,
2195
+ virtualizerRef,
2196
+ value,
2197
+ groups,
2198
+ data: visibleData,
2199
+ itemToString,
2200
+ inputType,
2201
+ renderItem,
2202
+ renderGroupHeading
2203
+ }
2204
+ ) : children ? children : flatItems ? (row) => renderSentinelRow(row) : groups ? (group, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(React11.Fragment, { children: [
2205
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(ComboboxGroup, { items: group.items, children: [
2206
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ComboboxGroupLabel, { children: renderGroupHeading ? renderGroupHeading(group.value) : group.value }),
2207
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_combobox6.Combobox.Collection, { children: (item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2208
+ ComboboxItem_default,
2209
+ {
2210
+ value: item,
2211
+ itemId: String(item.id),
2212
+ label: itemToString(item),
2213
+ disabled: item.disabled,
2214
+ inputType,
2215
+ renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
2216
+ },
2217
+ item.id
2218
+ ) })
2219
+ ] }),
2220
+ index < groups.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ComboboxSeparator, {})
2221
+ ] }, group.value) : (item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2222
+ ComboboxItem_default,
2223
+ {
2224
+ value: item,
2225
+ itemId: String(item.id),
2226
+ label: itemToString(item),
2227
+ disabled: item.disabled,
2228
+ inputType,
2229
+ renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
2230
+ },
2231
+ item.id
2232
+ )
2233
+ }
2234
+ )
2235
+ ]
2236
+ }
2237
+ ) }) })
2238
+ ]
2239
+ }
2240
+ )
2241
+ ] });
2242
+ }
833
2243
  // Annotate the CommonJS export names for ESM import in node:
834
2244
  0 && (module.exports = {
835
2245
  ComboboxActionButtons,
@@ -854,6 +2264,9 @@ var SelectionText2 = import_styled_components7.default.span`
854
2264
  ComboboxTokenInput,
855
2265
  ComboboxTokenInputGroup,
856
2266
  ComboboxTrigger,
2267
+ MultiCombobox,
2268
+ MultiSearchableSelect,
2269
+ MultiSelect,
857
2270
  SearchableSelectInput,
858
2271
  SearchableSelectList,
859
2272
  SearchableSelectPlaceholder,
@@ -862,6 +2275,9 @@ var SelectionText2 = import_styled_components7.default.span`
862
2275
  SearchableSelectTokenTrigger,
863
2276
  SearchableSelectTrigger,
864
2277
  SearchableSelectTriggerIcon,
2278
+ SingleCombobox,
2279
+ SingleSearchableSelect,
2280
+ SingleSelect,
865
2281
  Token,
866
2282
  TokenRemove
867
2283
  });