@carto/meridian-ds 1.5.0-alpha.split → 1.5.1-alpha-virtual-autocomplete.9

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/dist/{Alert-BiOR9aar.cjs → Alert-BzEgeyQJ.cjs} +1 -1
  3. package/dist/{Alert-CywtIMOj.js → Alert-CnaTtNJd.js} +1 -1
  4. package/dist/{MenuItem-CXnnE5lK.js → MenuItem-C1DvWMry.js} +10 -6
  5. package/dist/{MenuItem-Br2jY2lt.cjs → MenuItem-C4bG5WHw.cjs} +10 -6
  6. package/dist/{TablePaginationActions-KpTvhN4Y.js → TablePaginationActions-Cz5Hbi6N.js} +9 -1
  7. package/dist/{TablePaginationActions-CFGXm44W.cjs → TablePaginationActions-mbbjzV6Y.cjs} +8 -0
  8. package/dist/components/index.cjs +421 -53
  9. package/dist/components/index.js +423 -55
  10. package/dist/theme/index.cjs +13 -9
  11. package/dist/theme/index.js +14 -10
  12. package/dist/types/components/molecules/Autocomplete/Autocomplete.d.ts.map +1 -1
  13. package/dist/types/components/molecules/Autocomplete/AutocompleteList.d.ts +13 -0
  14. package/dist/types/components/molecules/Autocomplete/AutocompleteList.d.ts.map +1 -0
  15. package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts +1 -1
  16. package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts.map +1 -1
  17. package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts +1 -1
  18. package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts.map +1 -1
  19. package/dist/types/components/molecules/Autocomplete/index.d.ts +3 -0
  20. package/dist/types/components/molecules/Autocomplete/index.d.ts.map +1 -1
  21. package/dist/types/components/molecules/Autocomplete/types.d.ts +107 -7
  22. package/dist/types/components/molecules/Autocomplete/types.d.ts.map +1 -1
  23. package/dist/types/components/molecules/Autocomplete/useAutocomplete.d.ts +11 -0
  24. package/dist/types/components/molecules/Autocomplete/useAutocomplete.d.ts.map +1 -0
  25. package/dist/types/components/molecules/Autocomplete/useAutocompleteRenderOption.d.ts +2 -1
  26. package/dist/types/components/molecules/Autocomplete/useAutocompleteRenderOption.d.ts.map +1 -1
  27. package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts +26 -1
  28. package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts.map +1 -1
  29. package/dist/types/components/molecules/Autocomplete/utils.d.ts +107 -0
  30. package/dist/types/components/molecules/Autocomplete/utils.d.ts.map +1 -1
  31. package/dist/types/components/molecules/Menu/Menu.d.ts.map +1 -1
  32. package/dist/types/components/molecules/Menu/MenuItem.d.ts.map +1 -1
  33. package/dist/types/components/molecules/Menu/MenuItemFilter.d.ts.map +1 -1
  34. package/dist/types/components/molecules/Menu/MenuList.d.ts.map +1 -1
  35. package/dist/types/components/molecules/MultipleSelectField/MultipleSelectField.d.ts.map +1 -1
  36. package/dist/types/theme/sections/components/forms.d.ts.map +1 -1
  37. package/dist/types/theme/sections/components/navigation.d.ts.map +1 -1
  38. package/dist/types/theme/theme-constants.d.ts +4 -0
  39. package/dist/types/theme/theme-constants.d.ts.map +1 -1
  40. package/dist/widgets/index.cjs +2 -2
  41. package/dist/widgets/index.js +2 -2
  42. package/package.json +2 -3
  43. package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts +0 -17
  44. package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts.map +0 -1
@@ -3,14 +3,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const material = require("@mui/material");
6
- const TablePaginationActions = require("../TablePaginationActions-CFGXm44W.cjs");
6
+ const TablePaginationActions = require("../TablePaginationActions-mbbjzV6Y.cjs");
7
7
  const ArrowDown = require("../ArrowDown-8fLj23Ge.cjs");
8
8
  const OpenDiagonallyRight = require("../OpenDiagonallyRight-CM1tojUq.cjs");
9
9
  const reactIntl = require("react-intl");
10
10
  const iconsMaterial = require("@mui/icons-material");
11
- const Alert$1 = require("../Alert-BiOR9aar.cjs");
11
+ const Alert$1 = require("../Alert-BzEgeyQJ.cjs");
12
12
  require("cartocolor");
13
- const MenuItem = require("../MenuItem-Br2jY2lt.cjs");
13
+ const MenuItem = require("../MenuItem-C4bG5WHw.cjs");
14
+ const reactWindow = require("react-window");
14
15
  const DatePicker$1 = require("@mui/x-date-pickers/DatePicker");
15
16
  const xDatePickers = require("@mui/x-date-pickers");
16
17
  const TimePicker$1 = require("@mui/x-date-pickers/TimePicker");
@@ -479,10 +480,10 @@ function ToggleButtonGroup({
479
480
  }
480
481
  const StyledMenu = material.styled(material.Menu, {
481
482
  shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
482
- })(({ theme, extended, width, height }) => ({
483
+ })(({ extended, width, height }) => ({
483
484
  ...extended && {
484
485
  ".MuiMenuItem-root": {
485
- minHeight: theme.spacing(6)
486
+ minHeight: TablePaginationActions.MENU_ITEM_SIZE_EXTENDED
486
487
  }
487
488
  },
488
489
  ...width && {
@@ -522,10 +523,10 @@ function _Menu({ extended, width, height, MenuListProps, ...otherProps }, ref) {
522
523
  const Menu$1 = React.forwardRef(_Menu);
523
524
  const StyledMenuList = material.styled(material.MenuList, {
524
525
  shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
525
- })(({ theme, extended, width, height }) => ({
526
+ })(({ extended, width, height }) => ({
526
527
  ...extended && {
527
528
  ".MuiMenuItem-root": {
528
- minHeight: theme.spacing(6)
529
+ minHeight: TablePaginationActions.MENU_ITEM_SIZE_EXTENDED
529
530
  }
530
531
  },
531
532
  "&.MuiList-root": {
@@ -556,7 +557,8 @@ function _MenuList({ extended, width, height, ...otherProps }, ref) {
556
557
  }
557
558
  const MenuList = React.forwardRef(_MenuList);
558
559
  const StyledMenuItem$1 = material.styled(MenuItem.MenuItem)(() => ({
559
- marginTop: "0 !important"
560
+ marginTop: "0 !important",
561
+ marginBottom: "0 !important"
560
562
  }));
561
563
  const LinkFilter = material.styled(material.Link)(
562
564
  ({ disabled, theme }) => ({
@@ -796,12 +798,20 @@ function _MultipleSelectField({
796
798
  },
797
799
  children: [
798
800
  showFilters && /* @__PURE__ */ jsxRuntime.jsx(
799
- MenuItemFilter,
801
+ material.Box,
800
802
  {
801
- areAllSelected,
802
- areAnySelected,
803
- selectAll,
804
- selectAllDisabled
803
+ sx: {
804
+ mb: 1
805
+ },
806
+ children: /* @__PURE__ */ jsxRuntime.jsx(
807
+ MenuItemFilter,
808
+ {
809
+ areAllSelected,
810
+ areAnySelected,
811
+ selectAll,
812
+ selectAllDisabled
813
+ }
814
+ )
805
815
  }
806
816
  ),
807
817
  options == null ? void 0 : options.map((option) => {
@@ -1108,11 +1118,123 @@ function UploadField({
1108
1118
  )
1109
1119
  ] });
1110
1120
  }
1121
+ const AUTOCOMPLETE_GROUP_HEADER_PROPERTY = "__isGroupHeader";
1122
+ function isAutocompleteListGroupHeader(option) {
1123
+ return typeof option === "object" && option !== null && AUTOCOMPLETE_GROUP_HEADER_PROPERTY in option;
1124
+ }
1125
+ const getDefaultOptionLabel = (option) => {
1126
+ return option && typeof option === "object" ? option.title ?? String(option) : String(option);
1127
+ };
1128
+ const createOptionWithMultiple = (option, multiple) => {
1129
+ return typeof option !== "object" || option === null ? { value: option, multiple } : { ...option, multiple };
1130
+ };
1131
+ const getDefaultLimitTagsText = (more) => /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-testid": "more-options-tag", children: [
1132
+ "+",
1133
+ more
1134
+ ] });
1135
+ function createCounterRenderTags({
1136
+ formatCounter,
1137
+ options = [],
1138
+ size = "small",
1139
+ getOptionLabel = getDefaultOptionLabel
1140
+ }) {
1141
+ const CounterRenderTags = (value) => {
1142
+ if (value.length === 0) {
1143
+ return null;
1144
+ }
1145
+ const selectedCount = value.length;
1146
+ const selectableOptions = options.filter(
1147
+ (option) => !isAutocompleteListGroupHeader(option)
1148
+ );
1149
+ const totalCount = selectableOptions.length;
1150
+ const text = formatCounter({
1151
+ selectedCount,
1152
+ totalCount,
1153
+ selectedItems: value,
1154
+ allItems: selectableOptions,
1155
+ getOptionLabel
1156
+ });
1157
+ return /* @__PURE__ */ jsxRuntime.jsx(
1158
+ TablePaginationActions.Typography,
1159
+ {
1160
+ variant: size === "small" ? "body2" : "body1",
1161
+ component: "span",
1162
+ "data-testid": "counter-tag",
1163
+ sx: {
1164
+ ml: 1
1165
+ },
1166
+ children: text
1167
+ }
1168
+ );
1169
+ };
1170
+ return CounterRenderTags;
1171
+ }
1172
+ function createCounterFormatter({
1173
+ counterText,
1174
+ allText,
1175
+ showSingleItemText = true
1176
+ }) {
1177
+ return ({
1178
+ selectedCount,
1179
+ totalCount,
1180
+ selectedItems,
1181
+ getOptionLabel
1182
+ }) => {
1183
+ if (selectedCount === totalCount && totalCount > 0) {
1184
+ return allText;
1185
+ } else if (selectedCount === 1 && showSingleItemText) {
1186
+ return getOptionLabel(selectedItems[0]);
1187
+ } else {
1188
+ return `${selectedCount} ${counterText}`;
1189
+ }
1190
+ };
1191
+ }
1192
+ function createAutocompleteGroupByList(options, groupBy, extended) {
1193
+ const grouped = options.reduce(
1194
+ (acc, option) => {
1195
+ const group = groupBy(option);
1196
+ if (!acc[group]) {
1197
+ acc[group] = [];
1198
+ }
1199
+ acc[group].push(option);
1200
+ return acc;
1201
+ },
1202
+ {}
1203
+ );
1204
+ const result = [];
1205
+ Object.keys(grouped).forEach((title) => {
1206
+ result.push({ [AUTOCOMPLETE_GROUP_HEADER_PROPERTY]: true, title, extended });
1207
+ const groupOptions = grouped[title];
1208
+ if (groupOptions) {
1209
+ result.push(...groupOptions);
1210
+ }
1211
+ });
1212
+ return result;
1213
+ }
1214
+ function warnDeprecatedGroupBy(componentName) {
1215
+ if (process.env.NODE_ENV !== "production") {
1216
+ console.error(
1217
+ `${componentName}: The \`groupBy\` prop is deprecated and breaks virtualization. Use \`createAutocompleteGroupByList\` instead:
1218
+
1219
+ \`\`\`
1220
+ import { createAutocompleteGroupByList, ${componentName} } from "@carto/meridian-ds/components"
1221
+
1222
+ const groupedOptions = createAutocompleteGroupByList(options, (option) => option.category)
1223
+
1224
+ <${componentName} options={groupedOptions} />
1225
+ \`\`\`
1226
+ `
1227
+ );
1228
+ }
1229
+ }
1111
1230
  function _Autocomplete({
1112
1231
  disabled,
1113
1232
  loading,
1114
1233
  ...props
1115
1234
  }, ref) {
1235
+ if (props.groupBy) {
1236
+ warnDeprecatedGroupBy("Autocomplete");
1237
+ }
1116
1238
  return /* @__PURE__ */ jsxRuntime.jsx(
1117
1239
  material.Autocomplete,
1118
1240
  {
@@ -1129,15 +1251,24 @@ function _Autocomplete({
1129
1251
  );
1130
1252
  }
1131
1253
  const Autocomplete = React.forwardRef(_Autocomplete);
1132
- const getDefaultOptionLabel = (option) => {
1133
- return option && typeof option === "object" ? option.title ?? String(option) : String(option);
1134
- };
1135
- const createOptionWithMultiple = (option, multiple) => {
1136
- return typeof option !== "object" || option === null ? { value: option, multiple } : { ...option, multiple };
1137
- };
1138
- const getDefaultLimitTagsText = (more) => /* @__PURE__ */ jsxRuntime.jsx("span", { "data-testid": "more-options-tag", children: `+${more}` });
1139
1254
  function useAutocompleteRenderOption() {
1140
1255
  const renderOption = (props, option, state, getOptionLabel, customIcon) => {
1256
+ const { key, ...otherProps } = props;
1257
+ if (isAutocompleteListGroupHeader(option)) {
1258
+ return /* @__PURE__ */ React.createElement(
1259
+ MenuItem.MenuItem,
1260
+ {
1261
+ ...otherProps,
1262
+ subtitle: true,
1263
+ extended: option.extended,
1264
+ key,
1265
+ "aria-disabled": true,
1266
+ "aria-selected": false
1267
+ },
1268
+ option.title
1269
+ );
1270
+ }
1271
+ const regularOption = option;
1141
1272
  const {
1142
1273
  title,
1143
1274
  inputValue,
@@ -1154,9 +1285,8 @@ function useAutocompleteRenderOption() {
1154
1285
  alternativeTitle,
1155
1286
  secondaryText,
1156
1287
  multiple
1157
- } = option;
1158
- const { key, ...otherProps } = props;
1159
- const isPrimitiveOptionType = typeof option === "string" || typeof option === "number";
1288
+ } = regularOption;
1289
+ const isPrimitiveOptionType = typeof regularOption === "string" || typeof regularOption === "number";
1160
1290
  const getOptionLabelText = (getOptionLabel2, option2, alternativeTitle2, title2) => {
1161
1291
  if (alternativeTitle2) return alternativeTitle2;
1162
1292
  if (title2) return title2;
@@ -1190,7 +1320,7 @@ function useAutocompleteRenderOption() {
1190
1320
  /* @__PURE__ */ jsxRuntime.jsxs(material.ListItemText, { children: [
1191
1321
  getOptionLabelText(
1192
1322
  getOptionLabel ?? getDefaultOptionLabel,
1193
- option,
1323
+ regularOption,
1194
1324
  alternativeTitle,
1195
1325
  title
1196
1326
  ),
@@ -1277,8 +1407,16 @@ function useMultipleAutocomplete({
1277
1407
  options,
1278
1408
  value,
1279
1409
  onChange,
1280
- getOptionLabel
1410
+ getOptionLabel,
1411
+ size,
1412
+ counterFormatter,
1413
+ counterText,
1414
+ allSelectedText
1281
1415
  }) {
1416
+ const intl = reactIntl.useIntl();
1417
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
1418
+ const defaultCounterText = counterText || intlConfig.formatMessage({ id: "c4r.form.selected" });
1419
+ const defaultAllSelectedText = allSelectedText || intlConfig.formatMessage({ id: "c4r.form.allSelected" });
1282
1420
  const [multipleValue, setMultipleValue] = React.useState(
1283
1421
  Array.isArray(value) ? value : value ? [value] : []
1284
1422
  );
@@ -1287,10 +1425,13 @@ function useMultipleAutocomplete({
1287
1425
  const newValue = Array.isArray(value) ? value : value ? [value] : [];
1288
1426
  setMultipleValue(newValue);
1289
1427
  }, [value]);
1290
- const allSelected = multipleValue.length === options.length;
1291
- const someSelected = multipleValue.length > 0 && multipleValue.length < options.length;
1428
+ const selectableOptions = options.filter(
1429
+ (option) => !isAutocompleteListGroupHeader(option)
1430
+ );
1431
+ const allSelected = multipleValue.length === selectableOptions.length;
1432
+ const someSelected = multipleValue.length > 0 && multipleValue.length < selectableOptions.length;
1292
1433
  const handleSelectAll = (event) => {
1293
- const newValue = allSelected ? [] : [...options];
1434
+ const newValue = allSelected ? [] : [...selectableOptions];
1294
1435
  setMultipleValue(newValue);
1295
1436
  onChange == null ? void 0 : onChange(
1296
1437
  event,
@@ -1312,31 +1453,173 @@ function useMultipleAutocomplete({
1312
1453
  getOptionLabel
1313
1454
  );
1314
1455
  };
1456
+ const getCounterRenderTags = React.useCallback(() => {
1457
+ const formatter = counterFormatter || createCounterFormatter({
1458
+ counterText: defaultCounterText,
1459
+ allText: defaultAllSelectedText
1460
+ });
1461
+ return createCounterRenderTags({
1462
+ formatCounter: formatter,
1463
+ options,
1464
+ size,
1465
+ getOptionLabel: getOptionLabel ? (option) => getOptionLabel(option) : void 0
1466
+ });
1467
+ }, [
1468
+ options,
1469
+ counterFormatter,
1470
+ defaultCounterText,
1471
+ defaultAllSelectedText,
1472
+ size,
1473
+ getOptionLabel
1474
+ ]);
1315
1475
  return {
1316
1476
  multipleValue,
1317
1477
  allSelected,
1318
1478
  someSelected,
1319
1479
  handleSelectAll,
1320
1480
  handleChange,
1321
- multipleRenderOption
1481
+ multipleRenderOption,
1482
+ getCounterRenderTags
1322
1483
  };
1323
1484
  }
1324
- function _ListboxWithFilter({
1485
+ const List = material.styled("ul")(
1486
+ ({ theme, hasFilters }) => ({
1487
+ ...!hasFilters && {
1488
+ paddingTop: `${theme.spacing(1)} !important`
1489
+ }
1490
+ })
1491
+ );
1492
+ const ItemWrapper = material.styled("div")(({ style, theme, isSubtitle, isExtended, isMultiple }) => {
1493
+ const getSubtitleStyles = () => {
1494
+ const baseStyles = {
1495
+ height: TablePaginationActions.MENU_ITEM_SIZE_DENSE,
1496
+ minHeight: TablePaginationActions.MENU_ITEM_SIZE_DENSE,
1497
+ marginTop: `${theme.spacing(1)} !important`,
1498
+ alignItems: "flex-end",
1499
+ ...theme.typography.caption,
1500
+ fontWeight: 500
1501
+ };
1502
+ if (isExtended) {
1503
+ baseStyles.alignItems = "center";
1504
+ if (isMultiple) {
1505
+ baseStyles.marginLeft = theme.spacing(0.5);
1506
+ }
1507
+ }
1508
+ return baseStyles;
1509
+ };
1510
+ return {
1511
+ pointerEvents: "none",
1512
+ // To avoid the extra div to receive the click event
1513
+ "& .MuiMenuItem-root": {
1514
+ pointerEvents: "auto",
1515
+ // Allow pointer events for the menu item
1516
+ marginTop: 0,
1517
+ "&:first-of-type": {
1518
+ marginTop: "0 !important"
1519
+ }
1520
+ },
1521
+ ...isSubtitle && {
1522
+ "& .MuiAutocomplete-option.MuiMenuItem-root": getSubtitleStyles(),
1523
+ // First item has no divider
1524
+ "&:not(:first-of-type)": {
1525
+ "&::before": {
1526
+ content: '""',
1527
+ position: "absolute",
1528
+ zIndex: 1,
1529
+ top: theme.spacing(0.5),
1530
+ left: 0,
1531
+ right: 0,
1532
+ height: "1px",
1533
+ backgroundColor: theme.palette.divider
1534
+ }
1535
+ }
1536
+ },
1537
+ ...!isSubtitle && {
1538
+ "& .MuiAutocomplete-option": {
1539
+ minHeight: `${style == null ? void 0 : style.height}px !important`
1540
+ }
1541
+ }
1542
+ };
1543
+ });
1544
+ function _AutocompleteList({
1325
1545
  children,
1326
1546
  showFilters,
1327
1547
  allSelected,
1328
1548
  someSelected,
1329
1549
  handleSelectAll = () => void 0,
1330
1550
  multiple,
1551
+ extended,
1552
+ itemHeight,
1553
+ maxListHeight = TablePaginationActions.MENU_LIST_MAX_SIZE,
1331
1554
  ...otherProps
1332
1555
  }, ref) {
1556
+ const childrenArray = React.useMemo(() => {
1557
+ return React.Children.toArray(children).map((child) => {
1558
+ if (!React.isValidElement(child)) {
1559
+ return {
1560
+ child,
1561
+ isSubtitle: false,
1562
+ isExtended: false,
1563
+ isMultiple: !!multiple
1564
+ };
1565
+ }
1566
+ const props = child.props;
1567
+ return {
1568
+ child,
1569
+ isSubtitle: props.subtitle === true,
1570
+ isExtended: props.extended === true,
1571
+ isMultiple: !!multiple
1572
+ };
1573
+ });
1574
+ }, [children, multiple]);
1575
+ const defaultItemHeight = itemHeight ?? (extended ? TablePaginationActions.MENU_ITEM_SIZE_EXTENDED : TablePaginationActions.MENU_ITEM_SIZE_DEFAULT);
1576
+ const listboxHeight = React.useMemo(() => {
1577
+ const filterHeight = showFilters && multiple ? TablePaginationActions.MENU_ITEM_SIZE_EXTENDED : 0;
1578
+ const availableHeight = maxListHeight - filterHeight;
1579
+ const calculatedHeight = Math.min(
1580
+ childrenArray.length * defaultItemHeight,
1581
+ availableHeight
1582
+ );
1583
+ return Math.max(calculatedHeight, defaultItemHeight);
1584
+ }, [
1585
+ showFilters,
1586
+ multiple,
1587
+ maxListHeight,
1588
+ childrenArray.length,
1589
+ defaultItemHeight
1590
+ ]);
1591
+ const renderItem = ({
1592
+ index,
1593
+ style
1594
+ }) => {
1595
+ const item = childrenArray[index];
1596
+ if (!item) return null;
1597
+ const { child, isSubtitle, isExtended, isMultiple } = item;
1598
+ return /* @__PURE__ */ jsxRuntime.jsx(
1599
+ ItemWrapper,
1600
+ {
1601
+ style,
1602
+ isSubtitle,
1603
+ isExtended,
1604
+ isMultiple,
1605
+ "data-name": "virtual-menu-item",
1606
+ children: child
1607
+ }
1608
+ );
1609
+ };
1333
1610
  return /* @__PURE__ */ jsxRuntime.jsxs(
1334
- "ul",
1611
+ List,
1335
1612
  {
1336
1613
  ref,
1337
1614
  ...otherProps,
1338
1615
  role: "listbox",
1616
+ "data-list-height": listboxHeight,
1617
+ "data-item-height": defaultItemHeight,
1339
1618
  "aria-multiselectable": multiple,
1619
+ hasFilters: showFilters,
1620
+ style: {
1621
+ maxHeight: maxListHeight + defaultItemHeight
1622
+ },
1340
1623
  children: [
1341
1624
  showFilters && multiple && /* @__PURE__ */ jsxRuntime.jsx(
1342
1625
  MenuItemFilter,
@@ -1346,12 +1629,21 @@ function _ListboxWithFilter({
1346
1629
  selectAll: handleSelectAll
1347
1630
  }
1348
1631
  ),
1349
- children
1632
+ /* @__PURE__ */ jsxRuntime.jsx(
1633
+ reactWindow.FixedSizeList,
1634
+ {
1635
+ height: listboxHeight,
1636
+ width: "100%",
1637
+ itemCount: childrenArray.length,
1638
+ itemSize: defaultItemHeight,
1639
+ children: renderItem
1640
+ }
1641
+ )
1350
1642
  ]
1351
1643
  }
1352
1644
  );
1353
1645
  }
1354
- const ListboxWithFilter = React.forwardRef(_ListboxWithFilter);
1646
+ const AutocompleteList = React.forwardRef(_AutocompleteList);
1355
1647
  function _CreatableAutocomplete({
1356
1648
  newItemLabel,
1357
1649
  newItemIcon,
@@ -1361,23 +1653,41 @@ function _CreatableAutocomplete({
1361
1653
  disabled,
1362
1654
  loading,
1363
1655
  showFilters,
1656
+ showCounter = false,
1657
+ counterFormatter,
1658
+ counterText,
1659
+ allSelectedText,
1364
1660
  options = [],
1365
1661
  value,
1366
1662
  onChange,
1367
1663
  getLimitTagsText,
1664
+ renderTags,
1665
+ itemHeight,
1666
+ maxListHeight,
1667
+ extended,
1668
+ groupBy,
1368
1669
  ...props
1369
1670
  }, ref) {
1671
+ if (groupBy) {
1672
+ warnDeprecatedGroupBy("CreatableAutocomplete");
1673
+ }
1370
1674
  const { freeSolo = true, ...otherProps } = props;
1371
1675
  const {
1372
1676
  multipleValue,
1373
1677
  allSelected,
1374
1678
  someSelected,
1375
1679
  handleSelectAll,
1376
- handleChange
1680
+ handleChange,
1681
+ getCounterRenderTags
1377
1682
  } = useMultipleAutocomplete({
1378
1683
  options,
1379
1684
  value,
1380
- onChange
1685
+ onChange,
1686
+ getOptionLabel,
1687
+ size: props.size,
1688
+ counterFormatter,
1689
+ counterText,
1690
+ allSelectedText
1381
1691
  });
1382
1692
  const {
1383
1693
  creatableFilterOptions,
@@ -1389,6 +1699,17 @@ function _CreatableAutocomplete({
1389
1699
  newItemIcon,
1390
1700
  multiple
1391
1701
  });
1702
+ const listboxProps = {
1703
+ showFilters,
1704
+ allSelected,
1705
+ someSelected,
1706
+ handleSelectAll,
1707
+ multiple,
1708
+ itemHeight,
1709
+ maxListHeight,
1710
+ extended
1711
+ };
1712
+ const finalRenderTags = showCounter && multiple && !renderTags ? getCounterRenderTags() : renderTags;
1392
1713
  return /* @__PURE__ */ jsxRuntime.jsx(
1393
1714
  material.Autocomplete,
1394
1715
  {
@@ -1400,18 +1721,13 @@ function _CreatableAutocomplete({
1400
1721
  filterOptions: creatableFilterOptions,
1401
1722
  getOptionLabel: creatableOptionLabel,
1402
1723
  renderOption: creatableRenderOption,
1724
+ renderTags: finalRenderTags,
1403
1725
  freeSolo,
1404
1726
  forcePopupIcon: true,
1405
1727
  multiple,
1406
1728
  disableCloseOnSelect: disableCloseOnSelect ?? multiple,
1407
- ListboxComponent: ListboxWithFilter,
1408
- ListboxProps: {
1409
- showFilters,
1410
- allSelected,
1411
- someSelected,
1412
- handleSelectAll,
1413
- multiple
1414
- },
1729
+ ListboxComponent: AutocompleteList,
1730
+ ListboxProps: listboxProps,
1415
1731
  getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
1416
1732
  disabled: disabled || loading,
1417
1733
  popupIcon: loading ? /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" }) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}),
@@ -1426,26 +1742,54 @@ function _MultipleAutocomplete({
1426
1742
  disabled,
1427
1743
  loading,
1428
1744
  showFilters,
1745
+ showCounter = false,
1746
+ counterFormatter,
1747
+ counterText,
1748
+ allSelectedText,
1429
1749
  options,
1430
1750
  value,
1431
1751
  onChange,
1432
1752
  getOptionLabel,
1433
1753
  getLimitTagsText,
1754
+ renderTags,
1755
+ itemHeight,
1756
+ maxListHeight,
1757
+ extended,
1758
+ groupBy,
1434
1759
  ...props
1435
1760
  }, ref) {
1761
+ if (groupBy) {
1762
+ warnDeprecatedGroupBy("MultipleAutocomplete");
1763
+ }
1436
1764
  const {
1437
1765
  multipleValue,
1438
1766
  allSelected,
1439
1767
  someSelected,
1440
1768
  handleSelectAll,
1441
1769
  handleChange,
1442
- multipleRenderOption
1770
+ multipleRenderOption,
1771
+ getCounterRenderTags
1443
1772
  } = useMultipleAutocomplete({
1444
1773
  options,
1445
1774
  value,
1446
1775
  onChange,
1447
- getOptionLabel
1776
+ getOptionLabel,
1777
+ size: props.size,
1778
+ counterFormatter,
1779
+ counterText,
1780
+ allSelectedText
1448
1781
  });
1782
+ const listboxProps = {
1783
+ showFilters,
1784
+ allSelected,
1785
+ someSelected,
1786
+ handleSelectAll,
1787
+ multiple: true,
1788
+ itemHeight,
1789
+ maxListHeight,
1790
+ extended
1791
+ };
1792
+ const finalRenderTags = showCounter && !renderTags ? getCounterRenderTags() : renderTags;
1449
1793
  return /* @__PURE__ */ jsxRuntime.jsx(
1450
1794
  material.Autocomplete,
1451
1795
  {
@@ -1456,14 +1800,9 @@ function _MultipleAutocomplete({
1456
1800
  onChange: handleChange,
1457
1801
  getOptionLabel,
1458
1802
  renderOption: renderOption ?? multipleRenderOption,
1459
- ListboxComponent: ListboxWithFilter,
1460
- ListboxProps: {
1461
- showFilters,
1462
- allSelected,
1463
- someSelected,
1464
- handleSelectAll,
1465
- multiple: true
1466
- },
1803
+ renderTags: finalRenderTags,
1804
+ ListboxComponent: AutocompleteList,
1805
+ ListboxProps: listboxProps,
1467
1806
  multiple: true,
1468
1807
  getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
1469
1808
  disableCloseOnSelect,
@@ -1474,6 +1813,30 @@ function _MultipleAutocomplete({
1474
1813
  );
1475
1814
  }
1476
1815
  const MultipleAutocomplete = React.forwardRef(_MultipleAutocomplete);
1816
+ function useAutocomplete({
1817
+ getOptionLabel = getDefaultOptionLabel
1818
+ }) {
1819
+ const { renderOption: autocompleteRenderOption } = useAutocompleteRenderOption();
1820
+ const internalGetOptionLabel = (option) => {
1821
+ if (isAutocompleteListGroupHeader(option)) {
1822
+ return option.title;
1823
+ }
1824
+ return getOptionLabel(option);
1825
+ };
1826
+ const singleRenderOption = (props, option, state) => {
1827
+ const optionWithMultiple = createOptionWithMultiple(option, false);
1828
+ return autocompleteRenderOption(
1829
+ props,
1830
+ optionWithMultiple,
1831
+ state,
1832
+ internalGetOptionLabel
1833
+ );
1834
+ };
1835
+ return {
1836
+ singleRenderOption,
1837
+ getOptionLabel: internalGetOptionLabel
1838
+ };
1839
+ }
1477
1840
  const _CopiableComponent = ({
1478
1841
  children,
1479
1842
  disabled,
@@ -4698,9 +5061,11 @@ exports.Typography = TablePaginationActions.Typography;
4698
5061
  exports.Alert = Alert$1.Alert;
4699
5062
  exports.IconButton = Alert$1.IconButton;
4700
5063
  exports.MenuItem = MenuItem.MenuItem;
5064
+ exports.AUTOCOMPLETE_GROUP_HEADER_PROPERTY = AUTOCOMPLETE_GROUP_HEADER_PROPERTY;
4701
5065
  exports.AccordionGroup = AccordionGroup;
4702
5066
  exports.AppBar = AppBar;
4703
5067
  exports.Autocomplete = Autocomplete;
5068
+ exports.AutocompleteList = AutocompleteList;
4704
5069
  exports.Avatar = Avatar;
4705
5070
  exports.Button = Button;
4706
5071
  exports.CodeAreaDialog = CodeAreaDialog;
@@ -4744,5 +5109,8 @@ exports.TooltipData = TooltipData;
4744
5109
  exports.UploadField = UploadField;
4745
5110
  exports.UploadFieldBase = UploadFieldBase;
4746
5111
  exports.copyString = copyString;
5112
+ exports.createAutocompleteGroupByList = createAutocompleteGroupByList;
4747
5113
  exports.dialogDimensionsBySize = dialogDimensionsBySize;
5114
+ exports.isAutocompleteListGroupHeader = isAutocompleteListGroupHeader;
5115
+ exports.useAutocomplete = useAutocomplete;
4748
5116
  exports.useCopyValue = useCopyValue;