@carto/meridian-ds 1.5.0 → 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 (46) hide show
  1. package/CHANGELOG.md +6 -0
  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 +435 -55
  9. package/dist/components/index.js +437 -57
  10. package/dist/theme/index.cjs +13 -9
  11. package/dist/theme/index.js +14 -10
  12. package/dist/types/components/atoms/SplitButton.d.ts +9 -5
  13. package/dist/types/components/atoms/SplitButton.d.ts.map +1 -1
  14. package/dist/types/components/molecules/Autocomplete/Autocomplete.d.ts.map +1 -1
  15. package/dist/types/components/molecules/Autocomplete/AutocompleteList.d.ts +13 -0
  16. package/dist/types/components/molecules/Autocomplete/AutocompleteList.d.ts.map +1 -0
  17. package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts +1 -1
  18. package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts.map +1 -1
  19. package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts +1 -1
  20. package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts.map +1 -1
  21. package/dist/types/components/molecules/Autocomplete/index.d.ts +3 -0
  22. package/dist/types/components/molecules/Autocomplete/index.d.ts.map +1 -1
  23. package/dist/types/components/molecules/Autocomplete/types.d.ts +107 -7
  24. package/dist/types/components/molecules/Autocomplete/types.d.ts.map +1 -1
  25. package/dist/types/components/molecules/Autocomplete/useAutocomplete.d.ts +11 -0
  26. package/dist/types/components/molecules/Autocomplete/useAutocomplete.d.ts.map +1 -0
  27. package/dist/types/components/molecules/Autocomplete/useAutocompleteRenderOption.d.ts +2 -1
  28. package/dist/types/components/molecules/Autocomplete/useAutocompleteRenderOption.d.ts.map +1 -1
  29. package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts +26 -1
  30. package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts.map +1 -1
  31. package/dist/types/components/molecules/Autocomplete/utils.d.ts +107 -0
  32. package/dist/types/components/molecules/Autocomplete/utils.d.ts.map +1 -1
  33. package/dist/types/components/molecules/Menu/Menu.d.ts.map +1 -1
  34. package/dist/types/components/molecules/Menu/MenuItem.d.ts.map +1 -1
  35. package/dist/types/components/molecules/Menu/MenuItemFilter.d.ts.map +1 -1
  36. package/dist/types/components/molecules/Menu/MenuList.d.ts.map +1 -1
  37. package/dist/types/components/molecules/MultipleSelectField/MultipleSelectField.d.ts.map +1 -1
  38. package/dist/types/theme/sections/components/forms.d.ts.map +1 -1
  39. package/dist/types/theme/sections/components/navigation.d.ts.map +1 -1
  40. package/dist/types/theme/theme-constants.d.ts +4 -0
  41. package/dist/types/theme/theme-constants.d.ts.map +1 -1
  42. package/dist/widgets/index.cjs +2 -2
  43. package/dist/widgets/index.js +2 -2
  44. package/package.json +1 -1
  45. package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts +0 -17
  46. 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");
@@ -108,6 +109,9 @@ const ButtonGroup = material.styled(material.ButtonGroup)(({ theme, size }) => (
108
109
  }));
109
110
  function SplitButton({
110
111
  options,
112
+ disabled,
113
+ loading,
114
+ loadingPosition,
111
115
  onClick,
112
116
  variant,
113
117
  size,
@@ -146,8 +150,17 @@ function SplitButton({
146
150
  color,
147
151
  ...otherProps,
148
152
  children: [
149
- /* @__PURE__ */ jsxRuntime.jsx(material.Button, { onClick: handleClick, children: (_a = options[selectedIndex]) == null ? void 0 : _a.label }),
150
- /* @__PURE__ */ jsxRuntime.jsx(material.Button, { onClick: handleToggle, children: open ? /* @__PURE__ */ jsxRuntime.jsx(OpenDiagonallyRight.ArrowUp, {}) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}) })
153
+ /* @__PURE__ */ jsxRuntime.jsx(
154
+ Button,
155
+ {
156
+ disabled,
157
+ loading,
158
+ loadingPosition,
159
+ onClick: handleClick,
160
+ children: (_a = options[selectedIndex]) == null ? void 0 : _a.label
161
+ }
162
+ ),
163
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { disabled: loading || disabled, onClick: handleToggle, children: open ? /* @__PURE__ */ jsxRuntime.jsx(OpenDiagonallyRight.ArrowUp, {}) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}) })
151
164
  ]
152
165
  }
153
166
  ),
@@ -467,10 +480,10 @@ function ToggleButtonGroup({
467
480
  }
468
481
  const StyledMenu = material.styled(material.Menu, {
469
482
  shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
470
- })(({ theme, extended, width, height }) => ({
483
+ })(({ extended, width, height }) => ({
471
484
  ...extended && {
472
485
  ".MuiMenuItem-root": {
473
- minHeight: theme.spacing(6)
486
+ minHeight: TablePaginationActions.MENU_ITEM_SIZE_EXTENDED
474
487
  }
475
488
  },
476
489
  ...width && {
@@ -510,10 +523,10 @@ function _Menu({ extended, width, height, MenuListProps, ...otherProps }, ref) {
510
523
  const Menu$1 = React.forwardRef(_Menu);
511
524
  const StyledMenuList = material.styled(material.MenuList, {
512
525
  shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
513
- })(({ theme, extended, width, height }) => ({
526
+ })(({ extended, width, height }) => ({
514
527
  ...extended && {
515
528
  ".MuiMenuItem-root": {
516
- minHeight: theme.spacing(6)
529
+ minHeight: TablePaginationActions.MENU_ITEM_SIZE_EXTENDED
517
530
  }
518
531
  },
519
532
  "&.MuiList-root": {
@@ -544,7 +557,8 @@ function _MenuList({ extended, width, height, ...otherProps }, ref) {
544
557
  }
545
558
  const MenuList = React.forwardRef(_MenuList);
546
559
  const StyledMenuItem$1 = material.styled(MenuItem.MenuItem)(() => ({
547
- marginTop: "0 !important"
560
+ marginTop: "0 !important",
561
+ marginBottom: "0 !important"
548
562
  }));
549
563
  const LinkFilter = material.styled(material.Link)(
550
564
  ({ disabled, theme }) => ({
@@ -784,12 +798,20 @@ function _MultipleSelectField({
784
798
  },
785
799
  children: [
786
800
  showFilters && /* @__PURE__ */ jsxRuntime.jsx(
787
- MenuItemFilter,
801
+ material.Box,
788
802
  {
789
- areAllSelected,
790
- areAnySelected,
791
- selectAll,
792
- 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
+ )
793
815
  }
794
816
  ),
795
817
  options == null ? void 0 : options.map((option) => {
@@ -1096,11 +1118,123 @@ function UploadField({
1096
1118
  )
1097
1119
  ] });
1098
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
+ }
1099
1230
  function _Autocomplete({
1100
1231
  disabled,
1101
1232
  loading,
1102
1233
  ...props
1103
1234
  }, ref) {
1235
+ if (props.groupBy) {
1236
+ warnDeprecatedGroupBy("Autocomplete");
1237
+ }
1104
1238
  return /* @__PURE__ */ jsxRuntime.jsx(
1105
1239
  material.Autocomplete,
1106
1240
  {
@@ -1117,15 +1251,24 @@ function _Autocomplete({
1117
1251
  );
1118
1252
  }
1119
1253
  const Autocomplete = React.forwardRef(_Autocomplete);
1120
- const getDefaultOptionLabel = (option) => {
1121
- return option && typeof option === "object" ? option.title ?? String(option) : String(option);
1122
- };
1123
- const createOptionWithMultiple = (option, multiple) => {
1124
- return typeof option !== "object" || option === null ? { value: option, multiple } : { ...option, multiple };
1125
- };
1126
- const getDefaultLimitTagsText = (more) => /* @__PURE__ */ jsxRuntime.jsx("span", { "data-testid": "more-options-tag", children: `+${more}` });
1127
1254
  function useAutocompleteRenderOption() {
1128
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;
1129
1272
  const {
1130
1273
  title,
1131
1274
  inputValue,
@@ -1142,9 +1285,8 @@ function useAutocompleteRenderOption() {
1142
1285
  alternativeTitle,
1143
1286
  secondaryText,
1144
1287
  multiple
1145
- } = option;
1146
- const { key, ...otherProps } = props;
1147
- const isPrimitiveOptionType = typeof option === "string" || typeof option === "number";
1288
+ } = regularOption;
1289
+ const isPrimitiveOptionType = typeof regularOption === "string" || typeof regularOption === "number";
1148
1290
  const getOptionLabelText = (getOptionLabel2, option2, alternativeTitle2, title2) => {
1149
1291
  if (alternativeTitle2) return alternativeTitle2;
1150
1292
  if (title2) return title2;
@@ -1178,7 +1320,7 @@ function useAutocompleteRenderOption() {
1178
1320
  /* @__PURE__ */ jsxRuntime.jsxs(material.ListItemText, { children: [
1179
1321
  getOptionLabelText(
1180
1322
  getOptionLabel ?? getDefaultOptionLabel,
1181
- option,
1323
+ regularOption,
1182
1324
  alternativeTitle,
1183
1325
  title
1184
1326
  ),
@@ -1265,8 +1407,16 @@ function useMultipleAutocomplete({
1265
1407
  options,
1266
1408
  value,
1267
1409
  onChange,
1268
- getOptionLabel
1410
+ getOptionLabel,
1411
+ size,
1412
+ counterFormatter,
1413
+ counterText,
1414
+ allSelectedText
1269
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" });
1270
1420
  const [multipleValue, setMultipleValue] = React.useState(
1271
1421
  Array.isArray(value) ? value : value ? [value] : []
1272
1422
  );
@@ -1275,10 +1425,13 @@ function useMultipleAutocomplete({
1275
1425
  const newValue = Array.isArray(value) ? value : value ? [value] : [];
1276
1426
  setMultipleValue(newValue);
1277
1427
  }, [value]);
1278
- const allSelected = multipleValue.length === options.length;
1279
- 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;
1280
1433
  const handleSelectAll = (event) => {
1281
- const newValue = allSelected ? [] : [...options];
1434
+ const newValue = allSelected ? [] : [...selectableOptions];
1282
1435
  setMultipleValue(newValue);
1283
1436
  onChange == null ? void 0 : onChange(
1284
1437
  event,
@@ -1300,31 +1453,173 @@ function useMultipleAutocomplete({
1300
1453
  getOptionLabel
1301
1454
  );
1302
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
+ ]);
1303
1475
  return {
1304
1476
  multipleValue,
1305
1477
  allSelected,
1306
1478
  someSelected,
1307
1479
  handleSelectAll,
1308
1480
  handleChange,
1309
- multipleRenderOption
1481
+ multipleRenderOption,
1482
+ getCounterRenderTags
1310
1483
  };
1311
1484
  }
1312
- 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({
1313
1545
  children,
1314
1546
  showFilters,
1315
1547
  allSelected,
1316
1548
  someSelected,
1317
1549
  handleSelectAll = () => void 0,
1318
1550
  multiple,
1551
+ extended,
1552
+ itemHeight,
1553
+ maxListHeight = TablePaginationActions.MENU_LIST_MAX_SIZE,
1319
1554
  ...otherProps
1320
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
+ };
1321
1610
  return /* @__PURE__ */ jsxRuntime.jsxs(
1322
- "ul",
1611
+ List,
1323
1612
  {
1324
1613
  ref,
1325
1614
  ...otherProps,
1326
1615
  role: "listbox",
1616
+ "data-list-height": listboxHeight,
1617
+ "data-item-height": defaultItemHeight,
1327
1618
  "aria-multiselectable": multiple,
1619
+ hasFilters: showFilters,
1620
+ style: {
1621
+ maxHeight: maxListHeight + defaultItemHeight
1622
+ },
1328
1623
  children: [
1329
1624
  showFilters && multiple && /* @__PURE__ */ jsxRuntime.jsx(
1330
1625
  MenuItemFilter,
@@ -1334,12 +1629,21 @@ function _ListboxWithFilter({
1334
1629
  selectAll: handleSelectAll
1335
1630
  }
1336
1631
  ),
1337
- 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
+ )
1338
1642
  ]
1339
1643
  }
1340
1644
  );
1341
1645
  }
1342
- const ListboxWithFilter = React.forwardRef(_ListboxWithFilter);
1646
+ const AutocompleteList = React.forwardRef(_AutocompleteList);
1343
1647
  function _CreatableAutocomplete({
1344
1648
  newItemLabel,
1345
1649
  newItemIcon,
@@ -1349,23 +1653,41 @@ function _CreatableAutocomplete({
1349
1653
  disabled,
1350
1654
  loading,
1351
1655
  showFilters,
1656
+ showCounter = false,
1657
+ counterFormatter,
1658
+ counterText,
1659
+ allSelectedText,
1352
1660
  options = [],
1353
1661
  value,
1354
1662
  onChange,
1355
1663
  getLimitTagsText,
1664
+ renderTags,
1665
+ itemHeight,
1666
+ maxListHeight,
1667
+ extended,
1668
+ groupBy,
1356
1669
  ...props
1357
1670
  }, ref) {
1671
+ if (groupBy) {
1672
+ warnDeprecatedGroupBy("CreatableAutocomplete");
1673
+ }
1358
1674
  const { freeSolo = true, ...otherProps } = props;
1359
1675
  const {
1360
1676
  multipleValue,
1361
1677
  allSelected,
1362
1678
  someSelected,
1363
1679
  handleSelectAll,
1364
- handleChange
1680
+ handleChange,
1681
+ getCounterRenderTags
1365
1682
  } = useMultipleAutocomplete({
1366
1683
  options,
1367
1684
  value,
1368
- onChange
1685
+ onChange,
1686
+ getOptionLabel,
1687
+ size: props.size,
1688
+ counterFormatter,
1689
+ counterText,
1690
+ allSelectedText
1369
1691
  });
1370
1692
  const {
1371
1693
  creatableFilterOptions,
@@ -1377,6 +1699,17 @@ function _CreatableAutocomplete({
1377
1699
  newItemIcon,
1378
1700
  multiple
1379
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;
1380
1713
  return /* @__PURE__ */ jsxRuntime.jsx(
1381
1714
  material.Autocomplete,
1382
1715
  {
@@ -1388,18 +1721,13 @@ function _CreatableAutocomplete({
1388
1721
  filterOptions: creatableFilterOptions,
1389
1722
  getOptionLabel: creatableOptionLabel,
1390
1723
  renderOption: creatableRenderOption,
1724
+ renderTags: finalRenderTags,
1391
1725
  freeSolo,
1392
1726
  forcePopupIcon: true,
1393
1727
  multiple,
1394
1728
  disableCloseOnSelect: disableCloseOnSelect ?? multiple,
1395
- ListboxComponent: ListboxWithFilter,
1396
- ListboxProps: {
1397
- showFilters,
1398
- allSelected,
1399
- someSelected,
1400
- handleSelectAll,
1401
- multiple
1402
- },
1729
+ ListboxComponent: AutocompleteList,
1730
+ ListboxProps: listboxProps,
1403
1731
  getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
1404
1732
  disabled: disabled || loading,
1405
1733
  popupIcon: loading ? /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" }) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}),
@@ -1414,26 +1742,54 @@ function _MultipleAutocomplete({
1414
1742
  disabled,
1415
1743
  loading,
1416
1744
  showFilters,
1745
+ showCounter = false,
1746
+ counterFormatter,
1747
+ counterText,
1748
+ allSelectedText,
1417
1749
  options,
1418
1750
  value,
1419
1751
  onChange,
1420
1752
  getOptionLabel,
1421
1753
  getLimitTagsText,
1754
+ renderTags,
1755
+ itemHeight,
1756
+ maxListHeight,
1757
+ extended,
1758
+ groupBy,
1422
1759
  ...props
1423
1760
  }, ref) {
1761
+ if (groupBy) {
1762
+ warnDeprecatedGroupBy("MultipleAutocomplete");
1763
+ }
1424
1764
  const {
1425
1765
  multipleValue,
1426
1766
  allSelected,
1427
1767
  someSelected,
1428
1768
  handleSelectAll,
1429
1769
  handleChange,
1430
- multipleRenderOption
1770
+ multipleRenderOption,
1771
+ getCounterRenderTags
1431
1772
  } = useMultipleAutocomplete({
1432
1773
  options,
1433
1774
  value,
1434
1775
  onChange,
1435
- getOptionLabel
1776
+ getOptionLabel,
1777
+ size: props.size,
1778
+ counterFormatter,
1779
+ counterText,
1780
+ allSelectedText
1436
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;
1437
1793
  return /* @__PURE__ */ jsxRuntime.jsx(
1438
1794
  material.Autocomplete,
1439
1795
  {
@@ -1444,14 +1800,9 @@ function _MultipleAutocomplete({
1444
1800
  onChange: handleChange,
1445
1801
  getOptionLabel,
1446
1802
  renderOption: renderOption ?? multipleRenderOption,
1447
- ListboxComponent: ListboxWithFilter,
1448
- ListboxProps: {
1449
- showFilters,
1450
- allSelected,
1451
- someSelected,
1452
- handleSelectAll,
1453
- multiple: true
1454
- },
1803
+ renderTags: finalRenderTags,
1804
+ ListboxComponent: AutocompleteList,
1805
+ ListboxProps: listboxProps,
1455
1806
  multiple: true,
1456
1807
  getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
1457
1808
  disableCloseOnSelect,
@@ -1462,6 +1813,30 @@ function _MultipleAutocomplete({
1462
1813
  );
1463
1814
  }
1464
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
+ }
1465
1840
  const _CopiableComponent = ({
1466
1841
  children,
1467
1842
  disabled,
@@ -4686,9 +5061,11 @@ exports.Typography = TablePaginationActions.Typography;
4686
5061
  exports.Alert = Alert$1.Alert;
4687
5062
  exports.IconButton = Alert$1.IconButton;
4688
5063
  exports.MenuItem = MenuItem.MenuItem;
5064
+ exports.AUTOCOMPLETE_GROUP_HEADER_PROPERTY = AUTOCOMPLETE_GROUP_HEADER_PROPERTY;
4689
5065
  exports.AccordionGroup = AccordionGroup;
4690
5066
  exports.AppBar = AppBar;
4691
5067
  exports.Autocomplete = Autocomplete;
5068
+ exports.AutocompleteList = AutocompleteList;
4692
5069
  exports.Avatar = Avatar;
4693
5070
  exports.Button = Button;
4694
5071
  exports.CodeAreaDialog = CodeAreaDialog;
@@ -4732,5 +5109,8 @@ exports.TooltipData = TooltipData;
4732
5109
  exports.UploadField = UploadField;
4733
5110
  exports.UploadFieldBase = UploadFieldBase;
4734
5111
  exports.copyString = copyString;
5112
+ exports.createAutocompleteGroupByList = createAutocompleteGroupByList;
4735
5113
  exports.dialogDimensionsBySize = dialogDimensionsBySize;
5114
+ exports.isAutocompleteListGroupHeader = isAutocompleteListGroupHeader;
5115
+ exports.useAutocomplete = useAutocomplete;
4736
5116
  exports.useCopyValue = useCopyValue;