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