@sproutsocial/seeds-react-menu 1.12.0 → 1.12.2
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/.turbo/turbo-build.log +16 -16
- package/CHANGELOG.md +19 -0
- package/dist/esm/v3/index.js +212 -63
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/v3/index.d.mts +13 -1
- package/dist/v3/index.d.ts +13 -1
- package/dist/v3/index.js +212 -63
- package/dist/v3/index.js.map +1 -1
- package/package.json +9 -9
- package/src/v3/Common/VirtualizedComboboxList.tsx +29 -2
- package/src/v3/Common/sentinels.ts +13 -0
- package/src/v3/MultiCombobox.stories.tsx +85 -1
- package/src/v3/MultiCombobox.tsx +238 -62
- package/src/v3/MultiSearchableSelect.tsx +6 -1
- package/src/v3/MultiSelect.tsx +3 -1
- package/src/v3/SingleCombobox.tsx +7 -1
- package/src/v3/SingleSearchableSelect.tsx +3 -1
- package/src/v3/SingleSelect.stories.tsx +19 -0
- package/src/v3/SingleSelect.tsx +3 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -8,28 +8,28 @@ $ tsup --dts
|
|
|
8
8
|
[34mCLI[39m Cleaning output folder
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[32mESM[39m [1mdist/esm/index.js [22m[32m73.60 KB[39m
|
|
12
|
-
[32mESM[39m [1mdist/esm/v2/index.js [22m[32m62.63 KB[39m
|
|
13
|
-
[32mESM[39m [1mdist/esm/v3/index.js [22m[32m82.62 KB[39m
|
|
14
|
-
[32mESM[39m [1mdist/esm/chunk-ROQATIB7.js [22m[32m9.15 KB[39m
|
|
15
|
-
[32mESM[39m [1mdist/esm/index.js.map [22m[32m156.29 KB[39m
|
|
16
|
-
[32mESM[39m [1mdist/esm/v2/index.js.map [22m[32m132.57 KB[39m
|
|
17
|
-
[32mESM[39m [1mdist/esm/v3/index.js.map [22m[32m162.12 KB[39m
|
|
18
|
-
[32mESM[39m [1mdist/esm/chunk-ROQATIB7.js.map [22m[32m22.93 KB[39m
|
|
19
|
-
[32mESM[39m ⚡️ Build success in 414ms
|
|
20
11
|
[32mCJS[39m [1mdist/index.js [22m[32m92.65 KB[39m
|
|
21
12
|
[32mCJS[39m [1mdist/v2/index.js [22m[32m73.18 KB[39m
|
|
22
|
-
[32mCJS[39m [1mdist/v3/index.js [22m[
|
|
13
|
+
[32mCJS[39m [1mdist/v3/index.js [22m[32m99.79 KB[39m
|
|
23
14
|
[32mCJS[39m [1mdist/index.js.map [22m[32m180.28 KB[39m
|
|
24
15
|
[32mCJS[39m [1mdist/v2/index.js.map [22m[32m152.19 KB[39m
|
|
25
|
-
[32mCJS[39m [1mdist/v3/index.js.map [22m[
|
|
26
|
-
[32mCJS[39m ⚡️ Build success in
|
|
16
|
+
[32mCJS[39m [1mdist/v3/index.js.map [22m[32m173.17 KB[39m
|
|
17
|
+
[32mCJS[39m ⚡️ Build success in 91ms
|
|
18
|
+
[32mESM[39m [1mdist/esm/index.js [22m[32m73.60 KB[39m
|
|
19
|
+
[32mESM[39m [1mdist/esm/v3/index.js [22m[32m88.52 KB[39m
|
|
20
|
+
[32mESM[39m [1mdist/esm/chunk-ROQATIB7.js [22m[32m9.15 KB[39m
|
|
21
|
+
[32mESM[39m [1mdist/esm/v2/index.js [22m[32m62.63 KB[39m
|
|
22
|
+
[32mESM[39m [1mdist/esm/index.js.map [22m[32m156.29 KB[39m
|
|
23
|
+
[32mESM[39m [1mdist/esm/v3/index.js.map [22m[32m173.24 KB[39m
|
|
24
|
+
[32mESM[39m [1mdist/esm/chunk-ROQATIB7.js.map [22m[32m22.93 KB[39m
|
|
25
|
+
[32mESM[39m [1mdist/esm/v2/index.js.map [22m[32m132.57 KB[39m
|
|
26
|
+
[32mESM[39m ⚡️ Build success in 91ms
|
|
27
27
|
[34mDTS[39m Build start
|
|
28
|
-
[32mDTS[39m ⚡️ Build success in
|
|
28
|
+
[32mDTS[39m ⚡️ Build success in 6715ms
|
|
29
29
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m39.11 KB[39m
|
|
30
30
|
[32mDTS[39m [1mdist/v2/index.d.ts [22m[32m5.55 KB[39m
|
|
31
|
-
[32mDTS[39m [1mdist/v3/index.d.ts [22m[
|
|
31
|
+
[32mDTS[39m [1mdist/v3/index.d.ts [22m[32m18.28 KB[39m
|
|
32
32
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m39.11 KB[39m
|
|
33
33
|
[32mDTS[39m [1mdist/v2/index.d.mts [22m[32m5.55 KB[39m
|
|
34
|
-
[32mDTS[39m [1mdist/v3/index.d.mts [22m[
|
|
35
|
-
Done in
|
|
34
|
+
[32mDTS[39m [1mdist/v3/index.d.mts [22m[32m18.28 KB[39m
|
|
35
|
+
Done in 7.46s.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @sproutsocial/seeds-react-menu
|
|
2
2
|
|
|
3
|
+
## 1.12.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c5a6ad9: Add aria-describedby to all base-ui components, and creatable functionality to Multicombobox
|
|
8
|
+
- @sproutsocial/seeds-react-icon@2.3.7
|
|
9
|
+
- @sproutsocial/seeds-react-button@2.0.5
|
|
10
|
+
- @sproutsocial/seeds-react-checkbox@1.3.33
|
|
11
|
+
- @sproutsocial/seeds-react-input@1.5.16
|
|
12
|
+
- @sproutsocial/seeds-react-switch@1.2.32
|
|
13
|
+
- @sproutsocial/seeds-react-token-input@1.4.38
|
|
14
|
+
- @sproutsocial/seeds-react-popout@2.4.38
|
|
15
|
+
|
|
16
|
+
## 1.12.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- bea3d69: 3 bugfixes for base-ui combobox items
|
|
21
|
+
|
|
3
22
|
## 1.12.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
package/dist/esm/v3/index.js
CHANGED
|
@@ -291,6 +291,7 @@ var StyledValue = styled4(Select3.Value)`
|
|
|
291
291
|
`;
|
|
292
292
|
function SingleSelect(props) {
|
|
293
293
|
const { id, placeholder, includePlaceholderItem } = props;
|
|
294
|
+
const ariaDescribedBy = props["aria-describedby"];
|
|
294
295
|
const isChildrenMode = "children" in props && props.children != null;
|
|
295
296
|
const selectedItemId = props.selectedItemId;
|
|
296
297
|
const defaultSelectedItemId = props.defaultSelectedItemId;
|
|
@@ -348,7 +349,7 @@ function SingleSelect(props) {
|
|
|
348
349
|
onValueChange: handleValueChange,
|
|
349
350
|
id,
|
|
350
351
|
children: [
|
|
351
|
-
/* @__PURE__ */ jsxs2(SelectTrigger, { children: [
|
|
352
|
+
/* @__PURE__ */ jsxs2(SelectTrigger, { "aria-describedby": ariaDescribedBy, children: [
|
|
352
353
|
/* @__PURE__ */ jsx3(StyledValue, { placeholder, children: renderSelection && selectedItem ? renderSelection(selectedItem) : void 0 }),
|
|
353
354
|
/* @__PURE__ */ jsx3(SelectIcon, { children: /* @__PURE__ */ jsx3(StyledChevron, { "data-chevron": true, children: /* @__PURE__ */ jsx3(ChevronIcon, {}) }) })
|
|
354
355
|
] }),
|
|
@@ -420,6 +421,7 @@ var Placeholder = styled5.div`
|
|
|
420
421
|
`;
|
|
421
422
|
function MultiSelect(props) {
|
|
422
423
|
const { id, placeholder = "Select..." } = props;
|
|
424
|
+
const ariaDescribedBy = props["aria-describedby"];
|
|
423
425
|
const isChildrenMode = "children" in props && props.children != null;
|
|
424
426
|
const data = isChildrenMode ? [] : props.data;
|
|
425
427
|
const itemToString = isChildrenMode ? () => "" : props.itemToString;
|
|
@@ -476,7 +478,7 @@ function MultiSelect(props) {
|
|
|
476
478
|
disabled: props.disabled,
|
|
477
479
|
id,
|
|
478
480
|
children: [
|
|
479
|
-
/* @__PURE__ */ jsxs3(SelectTrigger, { children: [
|
|
481
|
+
/* @__PURE__ */ jsxs3(SelectTrigger, { "aria-describedby": ariaDescribedBy, children: [
|
|
480
482
|
/* @__PURE__ */ jsx4(SelectValue, { children: () => {
|
|
481
483
|
if (renderSelection) return renderSelection(selectedItems);
|
|
482
484
|
if (selectedItems.length === 0)
|
|
@@ -1087,6 +1089,12 @@ function makePlaceholderSentinel(label) {
|
|
|
1087
1089
|
function isPlaceholderSentinel(v) {
|
|
1088
1090
|
return typeof v === "object" && v !== null && "__placeholder" in v;
|
|
1089
1091
|
}
|
|
1092
|
+
function makeCreatableSentinel(label) {
|
|
1093
|
+
return { __creatable: true, label };
|
|
1094
|
+
}
|
|
1095
|
+
function isCreatableSentinel(v) {
|
|
1096
|
+
return typeof v === "object" && v !== null && "__creatable" in v;
|
|
1097
|
+
}
|
|
1090
1098
|
|
|
1091
1099
|
// src/v3/Common/VirtualizedComboboxList.tsx
|
|
1092
1100
|
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
@@ -1106,7 +1114,8 @@ function VirtualizedComboboxList({
|
|
|
1106
1114
|
itemToString,
|
|
1107
1115
|
inputType,
|
|
1108
1116
|
renderItem,
|
|
1109
|
-
renderGroupHeading
|
|
1117
|
+
renderGroupHeading,
|
|
1118
|
+
renderCreatableItem
|
|
1110
1119
|
}) {
|
|
1111
1120
|
const filteredItems = Combobox2.useFilteredItems();
|
|
1112
1121
|
const scrollElementRef = React7.useRef(null);
|
|
@@ -1224,6 +1233,17 @@ function VirtualizedComboboxList({
|
|
|
1224
1233
|
virtualItem.key
|
|
1225
1234
|
);
|
|
1226
1235
|
}
|
|
1236
|
+
if (isCreatableSentinel(row)) {
|
|
1237
|
+
if (renderCreatableItem) {
|
|
1238
|
+
return renderCreatableItem(
|
|
1239
|
+
row,
|
|
1240
|
+
baseStyle,
|
|
1241
|
+
virtualItem.index,
|
|
1242
|
+
virtualizer.measureElement
|
|
1243
|
+
);
|
|
1244
|
+
}
|
|
1245
|
+
return null;
|
|
1246
|
+
}
|
|
1227
1247
|
const item = row;
|
|
1228
1248
|
return /* @__PURE__ */ jsx7(
|
|
1229
1249
|
ComboboxItem_default,
|
|
@@ -1257,6 +1277,7 @@ function SingleCombobox(props) {
|
|
|
1257
1277
|
emptyText = "No results found.",
|
|
1258
1278
|
filter
|
|
1259
1279
|
} = props;
|
|
1280
|
+
const ariaDescribedBy = props["aria-describedby"];
|
|
1260
1281
|
const isChildrenMode = "children" in props && props.children != null;
|
|
1261
1282
|
const data = isChildrenMode ? [] : props.data;
|
|
1262
1283
|
const itemToString = isChildrenMode ? (_item) => "" : props.itemToString;
|
|
@@ -1327,7 +1348,14 @@ function SingleCombobox(props) {
|
|
|
1327
1348
|
} : void 0,
|
|
1328
1349
|
children: [
|
|
1329
1350
|
/* @__PURE__ */ jsxs6(ComboboxInputGroup, { children: [
|
|
1330
|
-
/* @__PURE__ */ jsx8(
|
|
1351
|
+
/* @__PURE__ */ jsx8(
|
|
1352
|
+
ComboboxInput,
|
|
1353
|
+
{
|
|
1354
|
+
placeholder,
|
|
1355
|
+
id,
|
|
1356
|
+
"aria-describedby": ariaDescribedBy
|
|
1357
|
+
}
|
|
1358
|
+
),
|
|
1331
1359
|
/* @__PURE__ */ jsxs6(ComboboxActionButtons, { children: [
|
|
1332
1360
|
/* @__PURE__ */ jsx8(ComboboxClear, { "aria-label": "Clear selection", children: /* @__PURE__ */ jsx8(ClearIcon, {}) }),
|
|
1333
1361
|
/* @__PURE__ */ jsx8(ComboboxTrigger, { "aria-label": "Open popup", children: /* @__PURE__ */ jsx8(StyledChevron, { $isOpen: open, children: /* @__PURE__ */ jsx8(ChevronIcon, {}) }) })
|
|
@@ -1425,8 +1453,11 @@ function MultiCombobox(props) {
|
|
|
1425
1453
|
emptyText = "No results found.",
|
|
1426
1454
|
isLoading = false,
|
|
1427
1455
|
loadingText = "Loading...",
|
|
1428
|
-
filter
|
|
1456
|
+
filter,
|
|
1457
|
+
inputValue,
|
|
1458
|
+
onInputValueChange
|
|
1429
1459
|
} = props;
|
|
1460
|
+
const ariaDescribedBy = props["aria-describedby"];
|
|
1430
1461
|
const isChildrenMode = "children" in props && props.children != null;
|
|
1431
1462
|
const data = isChildrenMode ? [] : props.data;
|
|
1432
1463
|
const itemToString = isChildrenMode ? (_item) => "" : props.itemToString;
|
|
@@ -1439,14 +1470,20 @@ function MultiCombobox(props) {
|
|
|
1439
1470
|
const groupBy = isChildrenMode ? void 0 : props.groupBy;
|
|
1440
1471
|
const renderGroupHeading = isChildrenMode ? void 0 : props.renderGroupHeading;
|
|
1441
1472
|
const selectHeadings = isChildrenMode ? false : props.selectHeadings ?? false;
|
|
1442
|
-
const
|
|
1473
|
+
const selectAllProp = isChildrenMode ? false : props.selectAll ?? false;
|
|
1474
|
+
const selectAll = Boolean(selectAllProp);
|
|
1475
|
+
const selectAllLabel = typeof selectAllProp === "string" ? selectAllProp : "Select all";
|
|
1443
1476
|
const isVirtualized = isChildrenMode ? false : props.isVirtualized ?? false;
|
|
1477
|
+
const creatableProp = isChildrenMode ? false : props.creatable ?? false;
|
|
1478
|
+
const onCreateProp = isChildrenMode ? void 0 : props.onCreate;
|
|
1444
1479
|
const children = isChildrenMode ? props.children : void 0;
|
|
1445
1480
|
const selectedItemIds = props.selectedItemIds;
|
|
1446
1481
|
const defaultSelectedItemIds = props.defaultSelectedItemIds;
|
|
1447
1482
|
const onSelectedItemIdsChange = props.onSelectedItemIdsChange;
|
|
1448
1483
|
const { containerRef, portalContainer } = useSeedsPortalContainer();
|
|
1449
1484
|
const [open, setOpen] = React9.useState(false);
|
|
1485
|
+
const [internalInputValue, setInternalInputValue] = React9.useState("");
|
|
1486
|
+
const skipNextInputChangeRef = React9.useRef(false);
|
|
1450
1487
|
const virtualizerRef = React9.useRef(null);
|
|
1451
1488
|
const isControlled = selectedItemIds !== void 0;
|
|
1452
1489
|
const idsToItems = React9.useCallback(
|
|
@@ -1465,22 +1502,51 @@ function MultiCombobox(props) {
|
|
|
1465
1502
|
() => groupBy ? groupItems(visibleData, groupBy) : null,
|
|
1466
1503
|
[visibleData, groupBy]
|
|
1467
1504
|
);
|
|
1505
|
+
const currentInputValue = inputValue ?? internalInputValue;
|
|
1506
|
+
const creatableSentinel = React9.useMemo(() => {
|
|
1507
|
+
if (!creatableProp) return null;
|
|
1508
|
+
const trimmed = currentInputValue.trim();
|
|
1509
|
+
if (!trimmed) return null;
|
|
1510
|
+
const lowered = trimmed.toLocaleLowerCase();
|
|
1511
|
+
const exactExists = data.some(
|
|
1512
|
+
(d) => itemToString(d).trim().toLocaleLowerCase() === lowered
|
|
1513
|
+
);
|
|
1514
|
+
if (exactExists) return null;
|
|
1515
|
+
return makeCreatableSentinel(trimmed);
|
|
1516
|
+
}, [creatableProp, currentInputValue, data, itemToString]);
|
|
1468
1517
|
const flatItems = React9.useMemo(() => {
|
|
1469
|
-
if (!
|
|
1518
|
+
if (!selectHeadings && !selectAll) return null;
|
|
1519
|
+
if (!groups && !selectAll) return null;
|
|
1470
1520
|
const rows = [];
|
|
1471
1521
|
if (selectAll) rows.push(SELECT_ALL_SENTINEL);
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1522
|
+
if (groups) {
|
|
1523
|
+
for (const group of groups) {
|
|
1524
|
+
rows.push(makeGroupHeaderSentinel(group.value));
|
|
1525
|
+
rows.push(...group.items);
|
|
1526
|
+
}
|
|
1527
|
+
} else {
|
|
1528
|
+
rows.push(...visibleData);
|
|
1475
1529
|
}
|
|
1476
1530
|
return rows;
|
|
1477
|
-
}, [groups, selectHeadings, selectAll]);
|
|
1531
|
+
}, [groups, visibleData, selectHeadings, selectAll]);
|
|
1478
1532
|
function setSelectedItems(items) {
|
|
1479
1533
|
if (!isControlled) setInternalValue(items);
|
|
1480
1534
|
if (onSelectedItemIdsChange)
|
|
1481
1535
|
onSelectedItemIdsChange(items.map((item) => item.id));
|
|
1482
1536
|
}
|
|
1483
1537
|
function handleValueChange(next) {
|
|
1538
|
+
const creatableClicked = next.find(isCreatableSentinel);
|
|
1539
|
+
if (creatableClicked) {
|
|
1540
|
+
const newItem = onCreateProp?.(creatableClicked.label);
|
|
1541
|
+
const realItems2 = next.filter(
|
|
1542
|
+
(v) => !isGroupHeaderSentinel2(v) && !isSelectAllSentinel2(v) && !isCreatableSentinel(v)
|
|
1543
|
+
);
|
|
1544
|
+
setSelectedItems(newItem ? [...realItems2, newItem] : realItems2);
|
|
1545
|
+
skipNextInputChangeRef.current = true;
|
|
1546
|
+
setInternalInputValue("");
|
|
1547
|
+
onInputValueChange?.("");
|
|
1548
|
+
return;
|
|
1549
|
+
}
|
|
1484
1550
|
const selectAllClicked = next.filter(isSelectAllSentinel2);
|
|
1485
1551
|
const groupSentinels = next.filter(isGroupHeaderSentinel2);
|
|
1486
1552
|
const realItems = next.filter(
|
|
@@ -1518,6 +1584,16 @@ function MultiCombobox(props) {
|
|
|
1518
1584
|
setSelectedItems(updated);
|
|
1519
1585
|
}
|
|
1520
1586
|
function handleSimpleValueChange(newItems) {
|
|
1587
|
+
const creatableClicked = newItems.find(isCreatableSentinel);
|
|
1588
|
+
if (creatableClicked) {
|
|
1589
|
+
const newItem = onCreateProp?.(creatableClicked.label);
|
|
1590
|
+
const realItems = newItems.filter((v) => !isCreatableSentinel(v));
|
|
1591
|
+
setSelectedItems(newItem ? [...realItems, newItem] : realItems);
|
|
1592
|
+
skipNextInputChangeRef.current = true;
|
|
1593
|
+
setInternalInputValue("");
|
|
1594
|
+
onInputValueChange?.("");
|
|
1595
|
+
return;
|
|
1596
|
+
}
|
|
1521
1597
|
setSelectedItems(newItems);
|
|
1522
1598
|
}
|
|
1523
1599
|
function removeItem(item, e) {
|
|
@@ -1532,7 +1608,7 @@ function MultiCombobox(props) {
|
|
|
1532
1608
|
const state = selectedCount === 0 ? "none" : selectedCount === totalCount ? "all" : "partial";
|
|
1533
1609
|
return /* @__PURE__ */ jsxs7(ComboboxSelectAllItem, { value: row, children: [
|
|
1534
1610
|
/* @__PURE__ */ jsx9(ComboboxGroupHeaderCheckbox, { $state: state, id: "__selectAll" }),
|
|
1535
|
-
|
|
1611
|
+
selectAllLabel
|
|
1536
1612
|
] }, "__selectAll");
|
|
1537
1613
|
}
|
|
1538
1614
|
if (isGroupHeaderSentinel2(row)) {
|
|
@@ -1553,6 +1629,9 @@ function MultiCombobox(props) {
|
|
|
1553
1629
|
renderGroupHeading ? renderGroupHeading(row.groupName) : row.groupName
|
|
1554
1630
|
] }, `__header-${row.groupName}`);
|
|
1555
1631
|
}
|
|
1632
|
+
if (isCreatableSentinel(row)) {
|
|
1633
|
+
return renderCreatableItem(row);
|
|
1634
|
+
}
|
|
1556
1635
|
const item = row;
|
|
1557
1636
|
return /* @__PURE__ */ jsx9(
|
|
1558
1637
|
ComboboxItem_default,
|
|
@@ -1567,7 +1646,28 @@ function MultiCombobox(props) {
|
|
|
1567
1646
|
item.id
|
|
1568
1647
|
);
|
|
1569
1648
|
}
|
|
1570
|
-
|
|
1649
|
+
function renderCreatableItem(sentinel, style, index, measureRef) {
|
|
1650
|
+
return /* @__PURE__ */ jsx9(
|
|
1651
|
+
ComboboxItem_default,
|
|
1652
|
+
{
|
|
1653
|
+
value: sentinel,
|
|
1654
|
+
itemId: "__creatable",
|
|
1655
|
+
label: `Create "${sentinel.label}"`,
|
|
1656
|
+
inputType: "none",
|
|
1657
|
+
renderItem: () => /* @__PURE__ */ jsxs7(Fragment6, { children: [
|
|
1658
|
+
/* @__PURE__ */ jsx9(Icon3, { name: "plus-outline", size: "mini" }),
|
|
1659
|
+
`Create "${sentinel.label}"`
|
|
1660
|
+
] }),
|
|
1661
|
+
style,
|
|
1662
|
+
index,
|
|
1663
|
+
"data-index": index,
|
|
1664
|
+
ref: measureRef
|
|
1665
|
+
},
|
|
1666
|
+
"__creatable"
|
|
1667
|
+
);
|
|
1668
|
+
}
|
|
1669
|
+
const baseItems = flatItems ?? groups ?? (isChildrenMode ? void 0 : visibleData);
|
|
1670
|
+
const rootItems = creatableSentinel && Array.isArray(baseItems) ? [...baseItems, creatableSentinel] : baseItems;
|
|
1571
1671
|
const hasSentinels = selectAll || selectHeadings;
|
|
1572
1672
|
const rootValue = hasSentinels ? [...value] : value;
|
|
1573
1673
|
return /* @__PURE__ */ jsxs7(Field, { children: [
|
|
@@ -1580,8 +1680,27 @@ function MultiCombobox(props) {
|
|
|
1580
1680
|
virtualized: isVirtualized,
|
|
1581
1681
|
open,
|
|
1582
1682
|
disabled: props.disabled,
|
|
1583
|
-
onOpenChange:
|
|
1584
|
-
|
|
1683
|
+
onOpenChange: (nextOpen, eventDetails) => {
|
|
1684
|
+
if (!nextOpen && eventDetails.reason === "item-press") return;
|
|
1685
|
+
setOpen(nextOpen);
|
|
1686
|
+
},
|
|
1687
|
+
filter: creatableProp ? (item, query) => {
|
|
1688
|
+
if (isCreatableSentinel(item)) return true;
|
|
1689
|
+
if (filter) return filter(item, query);
|
|
1690
|
+
if (isGroupHeaderSentinel2(item) || isSelectAllSentinel2(item))
|
|
1691
|
+
return true;
|
|
1692
|
+
const label = itemToString(item);
|
|
1693
|
+
return label.toLowerCase().includes(query.toLowerCase());
|
|
1694
|
+
} : filter,
|
|
1695
|
+
inputValue: creatableProp ? currentInputValue : inputValue,
|
|
1696
|
+
onInputValueChange: creatableProp ? (v) => {
|
|
1697
|
+
if (skipNextInputChangeRef.current) {
|
|
1698
|
+
skipNextInputChangeRef.current = false;
|
|
1699
|
+
return;
|
|
1700
|
+
}
|
|
1701
|
+
setInternalInputValue(v);
|
|
1702
|
+
onInputValueChange?.(v);
|
|
1703
|
+
} : onInputValueChange,
|
|
1585
1704
|
onItemHighlighted: isVirtualized ? (item, { reason, index }) => {
|
|
1586
1705
|
const virt = virtualizerRef.current;
|
|
1587
1706
|
if (!item || !virt) return;
|
|
@@ -1601,15 +1720,17 @@ function MultiCombobox(props) {
|
|
|
1601
1720
|
hasSentinels ? handleValueChange : handleSimpleValueChange
|
|
1602
1721
|
),
|
|
1603
1722
|
itemToStringLabel: (item) => {
|
|
1604
|
-
if (!item || isGroupHeaderSentinel2(item) || isSelectAllSentinel2(item))
|
|
1723
|
+
if (!item || isGroupHeaderSentinel2(item) || isSelectAllSentinel2(item) || isCreatableSentinel(item))
|
|
1605
1724
|
return "";
|
|
1606
1725
|
return itemToString(item);
|
|
1607
1726
|
},
|
|
1608
1727
|
isItemEqualToValue: (a, b) => {
|
|
1728
|
+
if (isCreatableSentinel(a) && isCreatableSentinel(b))
|
|
1729
|
+
return a.label === b.label;
|
|
1609
1730
|
if (isGroupHeaderSentinel2(a) && isGroupHeaderSentinel2(b))
|
|
1610
1731
|
return a.groupName === b.groupName;
|
|
1611
1732
|
if (isSelectAllSentinel2(a) && isSelectAllSentinel2(b)) return true;
|
|
1612
|
-
if (!isGroupHeaderSentinel2(a) && !isSelectAllSentinel2(a) && !isGroupHeaderSentinel2(b) && !isSelectAllSentinel2(b))
|
|
1733
|
+
if (!isGroupHeaderSentinel2(a) && !isSelectAllSentinel2(a) && !isCreatableSentinel(a) && !isGroupHeaderSentinel2(b) && !isSelectAllSentinel2(b) && !isCreatableSentinel(b))
|
|
1613
1734
|
return a.id === b.id;
|
|
1614
1735
|
return false;
|
|
1615
1736
|
},
|
|
@@ -1642,7 +1763,8 @@ function MultiCombobox(props) {
|
|
|
1642
1763
|
ComboboxTokenInput,
|
|
1643
1764
|
{
|
|
1644
1765
|
id,
|
|
1645
|
-
placeholder: value.length > 0 ? "" : placeholder
|
|
1766
|
+
placeholder: value.length > 0 ? "" : placeholder,
|
|
1767
|
+
"aria-describedby": ariaDescribedBy
|
|
1646
1768
|
}
|
|
1647
1769
|
),
|
|
1648
1770
|
/* @__PURE__ */ jsxs7(ComboboxActionButtons, { children: [
|
|
@@ -1679,37 +1801,55 @@ function MultiCombobox(props) {
|
|
|
1679
1801
|
itemToString,
|
|
1680
1802
|
inputType,
|
|
1681
1803
|
renderItem,
|
|
1682
|
-
renderGroupHeading
|
|
1804
|
+
renderGroupHeading,
|
|
1805
|
+
renderCreatableItem: creatableProp ? (sentinel, style, index, measureRef) => renderCreatableItem(
|
|
1806
|
+
sentinel,
|
|
1807
|
+
style,
|
|
1808
|
+
index,
|
|
1809
|
+
measureRef
|
|
1810
|
+
) : void 0
|
|
1683
1811
|
}
|
|
1684
|
-
) : children ? children : flatItems ? (row) => renderSentinelRow(row) : groups ? (group, index) =>
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
}
|
|
1711
|
-
item
|
|
1712
|
-
|
|
1812
|
+
) : children ? children : flatItems ? (row) => renderSentinelRow(row) : groups ? (group, index) => {
|
|
1813
|
+
if (isCreatableSentinel(group)) {
|
|
1814
|
+
return renderCreatableItem(group);
|
|
1815
|
+
}
|
|
1816
|
+
const g = group;
|
|
1817
|
+
return /* @__PURE__ */ jsxs7(React9.Fragment, { children: [
|
|
1818
|
+
/* @__PURE__ */ jsxs7(ComboboxGroup, { items: g.items, children: [
|
|
1819
|
+
/* @__PURE__ */ jsx9(ComboboxGroupLabel, { children: renderGroupHeading ? renderGroupHeading(g.value) : g.value }),
|
|
1820
|
+
/* @__PURE__ */ jsx9(Combobox4.Collection, { children: (item) => /* @__PURE__ */ jsx9(
|
|
1821
|
+
ComboboxItem_default,
|
|
1822
|
+
{
|
|
1823
|
+
value: item,
|
|
1824
|
+
itemId: String(item.id),
|
|
1825
|
+
label: itemToString(item),
|
|
1826
|
+
disabled: item.disabled,
|
|
1827
|
+
inputType,
|
|
1828
|
+
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
|
|
1829
|
+
},
|
|
1830
|
+
item.id
|
|
1831
|
+
) })
|
|
1832
|
+
] }),
|
|
1833
|
+
index < groups.length - 1 && /* @__PURE__ */ jsx9(ComboboxSeparator, {})
|
|
1834
|
+
] }, g.value);
|
|
1835
|
+
} : (item) => {
|
|
1836
|
+
if (isCreatableSentinel(item)) {
|
|
1837
|
+
return renderCreatableItem(item);
|
|
1838
|
+
}
|
|
1839
|
+
const dataItem = item;
|
|
1840
|
+
return /* @__PURE__ */ jsx9(
|
|
1841
|
+
ComboboxItem_default,
|
|
1842
|
+
{
|
|
1843
|
+
value: dataItem,
|
|
1844
|
+
itemId: String(dataItem.id),
|
|
1845
|
+
label: itemToString(dataItem),
|
|
1846
|
+
disabled: dataItem.disabled,
|
|
1847
|
+
inputType,
|
|
1848
|
+
renderItem: renderItem ? () => renderItem(dataItem) : () => itemToString(dataItem)
|
|
1849
|
+
},
|
|
1850
|
+
dataItem.id
|
|
1851
|
+
);
|
|
1852
|
+
}
|
|
1713
1853
|
}
|
|
1714
1854
|
)
|
|
1715
1855
|
]
|
|
@@ -1737,6 +1877,7 @@ function SingleSearchableSelect(props) {
|
|
|
1737
1877
|
loadingText = "Loading...",
|
|
1738
1878
|
filter
|
|
1739
1879
|
} = props;
|
|
1880
|
+
const ariaDescribedBy = props["aria-describedby"];
|
|
1740
1881
|
const isChildrenMode = "children" in props && props.children != null;
|
|
1741
1882
|
const data = isChildrenMode ? [] : props.data;
|
|
1742
1883
|
const itemToString = isChildrenMode ? (_item) => "" : props.itemToString;
|
|
@@ -1811,7 +1952,7 @@ function SingleSearchableSelect(props) {
|
|
|
1811
1952
|
}
|
|
1812
1953
|
} : void 0,
|
|
1813
1954
|
children: [
|
|
1814
|
-
/* @__PURE__ */ jsxs8(SearchableSelectTrigger, { id, children: [
|
|
1955
|
+
/* @__PURE__ */ jsxs8(SearchableSelectTrigger, { id, "aria-describedby": ariaDescribedBy, children: [
|
|
1815
1956
|
/* @__PURE__ */ jsx10(SearchableSelectPlaceholder, { children: /* @__PURE__ */ jsx10(Combobox5.Value, { placeholder, children: value ? renderSelection ? renderSelection(value) : itemToString(value) : placeholder }) }),
|
|
1816
1957
|
/* @__PURE__ */ jsx10(SearchableSelectTriggerIcon, { children: /* @__PURE__ */ jsx10(StyledChevron, { "data-chevron": true, children: /* @__PURE__ */ jsx10(ChevronIcon, {}) }) })
|
|
1817
1958
|
] }),
|
|
@@ -1936,6 +2077,7 @@ function MultiSearchableSelect(props) {
|
|
|
1936
2077
|
loadingText = "Loading...",
|
|
1937
2078
|
filter
|
|
1938
2079
|
} = props;
|
|
2080
|
+
const ariaDescribedBy = props["aria-describedby"];
|
|
1939
2081
|
const isChildrenMode = "children" in props && props.children != null;
|
|
1940
2082
|
const data = isChildrenMode ? [] : props.data;
|
|
1941
2083
|
const itemToString = isChildrenMode ? (_item) => "" : props.itemToString;
|
|
@@ -2119,20 +2261,27 @@ function MultiSearchableSelect(props) {
|
|
|
2119
2261
|
},
|
|
2120
2262
|
items: rootItems,
|
|
2121
2263
|
children: [
|
|
2122
|
-
/* @__PURE__ */ jsxs9(
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2264
|
+
/* @__PURE__ */ jsxs9(
|
|
2265
|
+
SearchableSelectTokenTrigger,
|
|
2266
|
+
{
|
|
2267
|
+
id,
|
|
2268
|
+
"aria-describedby": ariaDescribedBy,
|
|
2269
|
+
children: [
|
|
2270
|
+
renderSelection ? renderSelection(value) : value.length > 0 ? (() => {
|
|
2271
|
+
const visibleItems = maxSelections != null ? value.slice(0, maxSelections) : value;
|
|
2272
|
+
const overflowCount = maxSelections != null && value.length > maxSelections ? value.length - maxSelections : 0;
|
|
2273
|
+
const text = visibleItems.map(
|
|
2274
|
+
(item) => customRenderSelections ? customRenderSelections(item) : itemToString(item)
|
|
2275
|
+
).join(", ");
|
|
2276
|
+
return /* @__PURE__ */ jsxs9(SelectionText2, { children: [
|
|
2277
|
+
text,
|
|
2278
|
+
overflowCount > 0 ? `, +${overflowCount}` : ""
|
|
2279
|
+
] });
|
|
2280
|
+
})() : /* @__PURE__ */ jsx11(SearchableSelectPlaceholder, { children: placeholder }),
|
|
2281
|
+
/* @__PURE__ */ jsx11(SearchableSelectTriggerIcon, { style: { marginLeft: "auto" }, children: /* @__PURE__ */ jsx11(StyledChevron, { "data-chevron": true, children: /* @__PURE__ */ jsx11(ChevronIcon, {}) }) })
|
|
2282
|
+
]
|
|
2283
|
+
}
|
|
2284
|
+
),
|
|
2136
2285
|
/* @__PURE__ */ jsx11(Combobox6.Portal, { container: portalContainer, children: /* @__PURE__ */ jsx11(ComboboxPositioner, { sideOffset: 4, children: /* @__PURE__ */ jsxs9(
|
|
2137
2286
|
SearchableSelectPopup,
|
|
2138
2287
|
{
|