@carto/meridian-ds 1.5.1 → 2.0.0

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 (60) hide show
  1. package/CHANGELOG.md +9 -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/{ArrowDown-8fLj23Ge.cjs → ArrowDown-DJ0vhbsw.cjs} +2 -2
  5. package/dist/{ArrowDown-CY_wMVJT.js → ArrowDown-d6bxUL0F.js} +1 -1
  6. package/dist/{MenuItem-CXnnE5lK.js → MenuItem-C1DvWMry.js} +10 -6
  7. package/dist/{MenuItem-Br2jY2lt.cjs → MenuItem-C4bG5WHw.cjs} +10 -6
  8. package/dist/{OpenDiagonallyRight-CSm5GYYJ.js → OpenDiagonallyRight-CGdCEXlF.js} +1 -1
  9. package/dist/{OpenDiagonallyRight-CM1tojUq.cjs → OpenDiagonallyRight-CpL4ROwg.cjs} +4 -4
  10. package/dist/{SwatchSquare-benaO55C.cjs → SwatchSquare-B8PIY3Rd.cjs} +3 -3
  11. package/dist/{SwatchSquare-DhaaXt53.js → SwatchSquare-CaaLsjAC.js} +1 -1
  12. package/dist/{TablePaginationActions-KpTvhN4Y.js → TablePaginationActions-Cz5Hbi6N.js} +9 -1
  13. package/dist/{TablePaginationActions-CFGXm44W.cjs → TablePaginationActions-mbbjzV6Y.cjs} +8 -0
  14. package/dist/components/index.cjs +430 -55
  15. package/dist/components/index.js +432 -57
  16. package/dist/custom-icons/index.cjs +608 -486
  17. package/dist/custom-icons/index.js +561 -439
  18. package/dist/theme/index.cjs +14 -10
  19. package/dist/theme/index.js +15 -11
  20. package/dist/types/components/molecules/Autocomplete/Autocomplete.d.ts.map +1 -1
  21. package/dist/types/components/molecules/Autocomplete/AutocompleteList.d.ts +13 -0
  22. package/dist/types/components/molecules/Autocomplete/AutocompleteList.d.ts.map +1 -0
  23. package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts +1 -1
  24. package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts.map +1 -1
  25. package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts +1 -1
  26. package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts.map +1 -1
  27. package/dist/types/components/molecules/Autocomplete/index.d.ts +3 -0
  28. package/dist/types/components/molecules/Autocomplete/index.d.ts.map +1 -1
  29. package/dist/types/components/molecules/Autocomplete/types.d.ts +107 -7
  30. package/dist/types/components/molecules/Autocomplete/types.d.ts.map +1 -1
  31. package/dist/types/components/molecules/Autocomplete/useAutocomplete.d.ts +11 -0
  32. package/dist/types/components/molecules/Autocomplete/useAutocomplete.d.ts.map +1 -0
  33. package/dist/types/components/molecules/Autocomplete/useAutocompleteRenderOption.d.ts +2 -1
  34. package/dist/types/components/molecules/Autocomplete/useAutocompleteRenderOption.d.ts.map +1 -1
  35. package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts +26 -1
  36. package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts.map +1 -1
  37. package/dist/types/components/molecules/Autocomplete/utils.d.ts +135 -0
  38. package/dist/types/components/molecules/Autocomplete/utils.d.ts.map +1 -1
  39. package/dist/types/components/molecules/Menu/Menu.d.ts.map +1 -1
  40. package/dist/types/components/molecules/Menu/MenuItem.d.ts.map +1 -1
  41. package/dist/types/components/molecules/Menu/MenuItemFilter.d.ts.map +1 -1
  42. package/dist/types/components/molecules/Menu/MenuList.d.ts.map +1 -1
  43. package/dist/types/components/molecules/MultipleSelectField/MultipleSelectField.d.ts.map +1 -1
  44. package/dist/types/custom-icons/AiAgent.d.ts +4 -0
  45. package/dist/types/custom-icons/AiAgent.d.ts.map +1 -0
  46. package/dist/types/custom-icons/HideRightsidebar.d.ts +4 -0
  47. package/dist/types/custom-icons/HideRightsidebar.d.ts.map +1 -0
  48. package/dist/types/custom-icons/ShowRightsidebar.d.ts +4 -0
  49. package/dist/types/custom-icons/ShowRightsidebar.d.ts.map +1 -0
  50. package/dist/types/custom-icons/index.d.ts +3 -0
  51. package/dist/types/custom-icons/index.d.ts.map +1 -1
  52. package/dist/types/theme/sections/components/forms.d.ts.map +1 -1
  53. package/dist/types/theme/sections/components/navigation.d.ts.map +1 -1
  54. package/dist/types/theme/theme-constants.d.ts +4 -0
  55. package/dist/types/theme/theme-constants.d.ts.map +1 -1
  56. package/dist/widgets/index.cjs +3 -3
  57. package/dist/widgets/index.js +3 -3
  58. package/package.json +1 -1
  59. package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts +0 -17
  60. 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";
6
- import { A as ArrowDown } from "../ArrowDown-CY_wMVJT.js";
7
- import { A as ArrowUp, O as OpenDiagonallyRight, C as CloseDiagonallyRight } from "../OpenDiagonallyRight-CSm5GYYJ.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
+ import { A as ArrowDown } from "../ArrowDown-d6bxUL0F.js";
7
+ import { A as ArrowUp, O as OpenDiagonallyRight, C as CloseDiagonallyRight } from "../OpenDiagonallyRight-CGdCEXlF.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,130 @@ 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({
1192
+ options,
1193
+ groupBy,
1194
+ extended
1195
+ }) {
1196
+ const grouped = options.reduce(
1197
+ (acc, option) => {
1198
+ const group = groupBy(option);
1199
+ if (!acc[group]) {
1200
+ acc[group] = [];
1201
+ }
1202
+ acc[group].push(option);
1203
+ return acc;
1204
+ },
1205
+ {}
1206
+ );
1207
+ const result = [];
1208
+ Object.keys(grouped).forEach((title) => {
1209
+ result.push({ [AUTOCOMPLETE_GROUP_HEADER_PROPERTY]: true, title, extended });
1210
+ const groupOptions = grouped[title];
1211
+ if (groupOptions) {
1212
+ result.push(...groupOptions);
1213
+ }
1214
+ });
1215
+ return result;
1216
+ }
1217
+ function warnDeprecatedGroupBy(componentName) {
1218
+ if (process.env.NODE_ENV !== "production") {
1219
+ console.error(
1220
+ `${componentName}: The \`groupBy\` prop is deprecated and breaks virtualization. Use \`createAutocompleteGroupByList\` instead:
1221
+
1222
+ \`\`\`
1223
+ import { createAutocompleteGroupByList, ${componentName} } from "@carto/meridian-ds/components"
1224
+
1225
+ const groupedOptions = createAutocompleteGroupByList({
1226
+ options,
1227
+ groupBy: (option) => option.category
1228
+ })
1229
+
1230
+ <${componentName} options={groupedOptions} />
1231
+ \`\`\`
1232
+ `
1233
+ );
1234
+ }
1235
+ }
1110
1236
  function _Autocomplete({
1111
1237
  disabled,
1112
1238
  loading,
1113
1239
  ...props
1114
1240
  }, ref) {
1241
+ if (props.groupBy) {
1242
+ warnDeprecatedGroupBy("Autocomplete");
1243
+ }
1115
1244
  return /* @__PURE__ */ jsx(
1116
1245
  Autocomplete$1,
1117
1246
  {
@@ -1128,15 +1257,24 @@ function _Autocomplete({
1128
1257
  );
1129
1258
  }
1130
1259
  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
1260
  function useAutocompleteRenderOption() {
1139
1261
  const renderOption = (props, option, state, getOptionLabel, customIcon) => {
1262
+ const { key, ...otherProps } = props;
1263
+ if (isAutocompleteListGroupHeader(option)) {
1264
+ return /* @__PURE__ */ createElement(
1265
+ MenuItem$1,
1266
+ {
1267
+ ...otherProps,
1268
+ subtitle: true,
1269
+ extended: option.extended,
1270
+ key,
1271
+ "aria-disabled": true,
1272
+ "aria-selected": false
1273
+ },
1274
+ option.title
1275
+ );
1276
+ }
1277
+ const regularOption = option;
1140
1278
  const {
1141
1279
  title,
1142
1280
  inputValue,
@@ -1153,9 +1291,8 @@ function useAutocompleteRenderOption() {
1153
1291
  alternativeTitle,
1154
1292
  secondaryText,
1155
1293
  multiple
1156
- } = option;
1157
- const { key, ...otherProps } = props;
1158
- const isPrimitiveOptionType = typeof option === "string" || typeof option === "number";
1294
+ } = regularOption;
1295
+ const isPrimitiveOptionType = typeof regularOption === "string" || typeof regularOption === "number";
1159
1296
  const getOptionLabelText = (getOptionLabel2, option2, alternativeTitle2, title2) => {
1160
1297
  if (alternativeTitle2) return alternativeTitle2;
1161
1298
  if (title2) return title2;
@@ -1189,7 +1326,7 @@ function useAutocompleteRenderOption() {
1189
1326
  /* @__PURE__ */ jsxs(ListItemText, { children: [
1190
1327
  getOptionLabelText(
1191
1328
  getOptionLabel ?? getDefaultOptionLabel,
1192
- option,
1329
+ regularOption,
1193
1330
  alternativeTitle,
1194
1331
  title
1195
1332
  ),
@@ -1276,8 +1413,16 @@ function useMultipleAutocomplete({
1276
1413
  options,
1277
1414
  value,
1278
1415
  onChange,
1279
- getOptionLabel
1416
+ getOptionLabel,
1417
+ size,
1418
+ counterFormatter,
1419
+ counterText,
1420
+ allSelectedText
1280
1421
  }) {
1422
+ const intl = useIntl();
1423
+ const intlConfig = useImperativeIntl(intl);
1424
+ const defaultCounterText = counterText || intlConfig.formatMessage({ id: "c4r.form.selected" });
1425
+ const defaultAllSelectedText = allSelectedText || intlConfig.formatMessage({ id: "c4r.form.allSelected" });
1281
1426
  const [multipleValue, setMultipleValue] = useState(
1282
1427
  Array.isArray(value) ? value : value ? [value] : []
1283
1428
  );
@@ -1286,10 +1431,13 @@ function useMultipleAutocomplete({
1286
1431
  const newValue = Array.isArray(value) ? value : value ? [value] : [];
1287
1432
  setMultipleValue(newValue);
1288
1433
  }, [value]);
1289
- const allSelected = multipleValue.length === options.length;
1290
- const someSelected = multipleValue.length > 0 && multipleValue.length < options.length;
1434
+ const selectableOptions = options.filter(
1435
+ (option) => !isAutocompleteListGroupHeader(option)
1436
+ );
1437
+ const allSelected = multipleValue.length === selectableOptions.length;
1438
+ const someSelected = multipleValue.length > 0 && multipleValue.length < selectableOptions.length;
1291
1439
  const handleSelectAll = (event) => {
1292
- const newValue = allSelected ? [] : [...options];
1440
+ const newValue = allSelected ? [] : [...selectableOptions];
1293
1441
  setMultipleValue(newValue);
1294
1442
  onChange == null ? void 0 : onChange(
1295
1443
  event,
@@ -1311,31 +1459,173 @@ function useMultipleAutocomplete({
1311
1459
  getOptionLabel
1312
1460
  );
1313
1461
  };
1462
+ const getCounterRenderTags = useCallback(() => {
1463
+ const formatter = counterFormatter || createCounterFormatter({
1464
+ counterText: defaultCounterText,
1465
+ allText: defaultAllSelectedText
1466
+ });
1467
+ return createCounterRenderTags({
1468
+ formatCounter: formatter,
1469
+ options,
1470
+ size,
1471
+ getOptionLabel: getOptionLabel ? (option) => getOptionLabel(option) : void 0
1472
+ });
1473
+ }, [
1474
+ options,
1475
+ counterFormatter,
1476
+ defaultCounterText,
1477
+ defaultAllSelectedText,
1478
+ size,
1479
+ getOptionLabel
1480
+ ]);
1314
1481
  return {
1315
1482
  multipleValue,
1316
1483
  allSelected,
1317
1484
  someSelected,
1318
1485
  handleSelectAll,
1319
1486
  handleChange,
1320
- multipleRenderOption
1487
+ multipleRenderOption,
1488
+ getCounterRenderTags
1321
1489
  };
1322
1490
  }
1323
- function _ListboxWithFilter({
1491
+ const List = styled("ul")(
1492
+ ({ theme, hasFilters }) => ({
1493
+ ...!hasFilters && {
1494
+ paddingTop: `${theme.spacing(1)} !important`
1495
+ }
1496
+ })
1497
+ );
1498
+ const ItemWrapper = styled("div")(({ style, theme, isSubtitle, isExtended, isMultiple }) => {
1499
+ const getSubtitleStyles = () => {
1500
+ const baseStyles = {
1501
+ height: MENU_ITEM_SIZE_DENSE,
1502
+ minHeight: MENU_ITEM_SIZE_DENSE,
1503
+ marginTop: `${theme.spacing(1)} !important`,
1504
+ alignItems: "flex-end",
1505
+ ...theme.typography.caption,
1506
+ fontWeight: 500
1507
+ };
1508
+ if (isExtended) {
1509
+ baseStyles.alignItems = "center";
1510
+ if (isMultiple) {
1511
+ baseStyles.marginLeft = theme.spacing(0.5);
1512
+ }
1513
+ }
1514
+ return baseStyles;
1515
+ };
1516
+ return {
1517
+ pointerEvents: "none",
1518
+ // To avoid the extra div to receive the click event
1519
+ "& .MuiMenuItem-root": {
1520
+ pointerEvents: "auto",
1521
+ // Allow pointer events for the menu item
1522
+ marginTop: 0,
1523
+ "&:first-of-type": {
1524
+ marginTop: "0 !important"
1525
+ }
1526
+ },
1527
+ ...isSubtitle && {
1528
+ "& .MuiAutocomplete-option.MuiMenuItem-root": getSubtitleStyles(),
1529
+ // First item has no divider
1530
+ "&:not(:first-of-type)": {
1531
+ "&::before": {
1532
+ content: '""',
1533
+ position: "absolute",
1534
+ zIndex: 1,
1535
+ top: theme.spacing(0.5),
1536
+ left: 0,
1537
+ right: 0,
1538
+ height: "1px",
1539
+ backgroundColor: theme.palette.divider
1540
+ }
1541
+ }
1542
+ },
1543
+ ...!isSubtitle && {
1544
+ "& .MuiAutocomplete-option": {
1545
+ minHeight: `${style == null ? void 0 : style.height}px !important`
1546
+ }
1547
+ }
1548
+ };
1549
+ });
1550
+ function _AutocompleteList({
1324
1551
  children,
1325
1552
  showFilters,
1326
1553
  allSelected,
1327
1554
  someSelected,
1328
1555
  handleSelectAll = () => void 0,
1329
1556
  multiple,
1557
+ extended,
1558
+ itemHeight,
1559
+ maxListHeight = MENU_LIST_MAX_SIZE,
1330
1560
  ...otherProps
1331
1561
  }, ref) {
1562
+ const childrenArray = useMemo(() => {
1563
+ return React.Children.toArray(children).map((child) => {
1564
+ if (!React.isValidElement(child)) {
1565
+ return {
1566
+ child,
1567
+ isSubtitle: false,
1568
+ isExtended: false,
1569
+ isMultiple: !!multiple
1570
+ };
1571
+ }
1572
+ const props = child.props;
1573
+ return {
1574
+ child,
1575
+ isSubtitle: props.subtitle === true,
1576
+ isExtended: props.extended === true,
1577
+ isMultiple: !!multiple
1578
+ };
1579
+ });
1580
+ }, [children, multiple]);
1581
+ const defaultItemHeight = itemHeight ?? (extended ? MENU_ITEM_SIZE_EXTENDED : MENU_ITEM_SIZE_DEFAULT);
1582
+ const listboxHeight = useMemo(() => {
1583
+ const filterHeight = showFilters && multiple ? MENU_ITEM_SIZE_EXTENDED : 0;
1584
+ const availableHeight = maxListHeight - filterHeight;
1585
+ const calculatedHeight = Math.min(
1586
+ childrenArray.length * defaultItemHeight,
1587
+ availableHeight
1588
+ );
1589
+ return Math.max(calculatedHeight, defaultItemHeight);
1590
+ }, [
1591
+ showFilters,
1592
+ multiple,
1593
+ maxListHeight,
1594
+ childrenArray.length,
1595
+ defaultItemHeight
1596
+ ]);
1597
+ const renderItem = ({
1598
+ index,
1599
+ style
1600
+ }) => {
1601
+ const item = childrenArray[index];
1602
+ if (!item) return null;
1603
+ const { child, isSubtitle, isExtended, isMultiple } = item;
1604
+ return /* @__PURE__ */ jsx(
1605
+ ItemWrapper,
1606
+ {
1607
+ style,
1608
+ isSubtitle,
1609
+ isExtended,
1610
+ isMultiple,
1611
+ "data-name": "virtual-menu-item",
1612
+ children: child
1613
+ }
1614
+ );
1615
+ };
1332
1616
  return /* @__PURE__ */ jsxs(
1333
- "ul",
1617
+ List,
1334
1618
  {
1335
1619
  ref,
1336
1620
  ...otherProps,
1337
1621
  role: "listbox",
1622
+ "data-list-height": listboxHeight,
1623
+ "data-item-height": defaultItemHeight,
1338
1624
  "aria-multiselectable": multiple,
1625
+ hasFilters: showFilters,
1626
+ style: {
1627
+ maxHeight: maxListHeight + defaultItemHeight
1628
+ },
1339
1629
  children: [
1340
1630
  showFilters && multiple && /* @__PURE__ */ jsx(
1341
1631
  MenuItemFilter,
@@ -1345,12 +1635,21 @@ function _ListboxWithFilter({
1345
1635
  selectAll: handleSelectAll
1346
1636
  }
1347
1637
  ),
1348
- children
1638
+ /* @__PURE__ */ jsx(
1639
+ FixedSizeList,
1640
+ {
1641
+ height: listboxHeight,
1642
+ width: "100%",
1643
+ itemCount: childrenArray.length,
1644
+ itemSize: defaultItemHeight,
1645
+ children: renderItem
1646
+ }
1647
+ )
1349
1648
  ]
1350
1649
  }
1351
1650
  );
1352
1651
  }
1353
- const ListboxWithFilter = forwardRef(_ListboxWithFilter);
1652
+ const AutocompleteList = forwardRef(_AutocompleteList);
1354
1653
  function _CreatableAutocomplete({
1355
1654
  newItemLabel,
1356
1655
  newItemIcon,
@@ -1360,23 +1659,41 @@ function _CreatableAutocomplete({
1360
1659
  disabled,
1361
1660
  loading,
1362
1661
  showFilters,
1662
+ showCounter = false,
1663
+ counterFormatter,
1664
+ counterText,
1665
+ allSelectedText,
1363
1666
  options = [],
1364
1667
  value,
1365
1668
  onChange,
1366
1669
  getLimitTagsText,
1670
+ renderTags,
1671
+ itemHeight,
1672
+ maxListHeight,
1673
+ extended,
1674
+ groupBy,
1367
1675
  ...props
1368
1676
  }, ref) {
1677
+ if (groupBy) {
1678
+ warnDeprecatedGroupBy("CreatableAutocomplete");
1679
+ }
1369
1680
  const { freeSolo = true, ...otherProps } = props;
1370
1681
  const {
1371
1682
  multipleValue,
1372
1683
  allSelected,
1373
1684
  someSelected,
1374
1685
  handleSelectAll,
1375
- handleChange
1686
+ handleChange,
1687
+ getCounterRenderTags
1376
1688
  } = useMultipleAutocomplete({
1377
1689
  options,
1378
1690
  value,
1379
- onChange
1691
+ onChange,
1692
+ getOptionLabel,
1693
+ size: props.size,
1694
+ counterFormatter,
1695
+ counterText,
1696
+ allSelectedText
1380
1697
  });
1381
1698
  const {
1382
1699
  creatableFilterOptions,
@@ -1388,6 +1705,17 @@ function _CreatableAutocomplete({
1388
1705
  newItemIcon,
1389
1706
  multiple
1390
1707
  });
1708
+ const listboxProps = {
1709
+ showFilters,
1710
+ allSelected,
1711
+ someSelected,
1712
+ handleSelectAll,
1713
+ multiple,
1714
+ itemHeight,
1715
+ maxListHeight,
1716
+ extended
1717
+ };
1718
+ const finalRenderTags = showCounter && multiple && !renderTags ? getCounterRenderTags() : renderTags;
1391
1719
  return /* @__PURE__ */ jsx(
1392
1720
  Autocomplete$1,
1393
1721
  {
@@ -1399,18 +1727,13 @@ function _CreatableAutocomplete({
1399
1727
  filterOptions: creatableFilterOptions,
1400
1728
  getOptionLabel: creatableOptionLabel,
1401
1729
  renderOption: creatableRenderOption,
1730
+ renderTags: finalRenderTags,
1402
1731
  freeSolo,
1403
1732
  forcePopupIcon: true,
1404
1733
  multiple,
1405
1734
  disableCloseOnSelect: disableCloseOnSelect ?? multiple,
1406
- ListboxComponent: ListboxWithFilter,
1407
- ListboxProps: {
1408
- showFilters,
1409
- allSelected,
1410
- someSelected,
1411
- handleSelectAll,
1412
- multiple
1413
- },
1735
+ ListboxComponent: AutocompleteList,
1736
+ ListboxProps: listboxProps,
1414
1737
  getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
1415
1738
  disabled: disabled || loading,
1416
1739
  popupIcon: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: 18, color: "inherit" }) : /* @__PURE__ */ jsx(ArrowDown, {}),
@@ -1425,26 +1748,54 @@ function _MultipleAutocomplete({
1425
1748
  disabled,
1426
1749
  loading,
1427
1750
  showFilters,
1751
+ showCounter = false,
1752
+ counterFormatter,
1753
+ counterText,
1754
+ allSelectedText,
1428
1755
  options,
1429
1756
  value,
1430
1757
  onChange,
1431
1758
  getOptionLabel,
1432
1759
  getLimitTagsText,
1760
+ renderTags,
1761
+ itemHeight,
1762
+ maxListHeight,
1763
+ extended,
1764
+ groupBy,
1433
1765
  ...props
1434
1766
  }, ref) {
1767
+ if (groupBy) {
1768
+ warnDeprecatedGroupBy("MultipleAutocomplete");
1769
+ }
1435
1770
  const {
1436
1771
  multipleValue,
1437
1772
  allSelected,
1438
1773
  someSelected,
1439
1774
  handleSelectAll,
1440
1775
  handleChange,
1441
- multipleRenderOption
1776
+ multipleRenderOption,
1777
+ getCounterRenderTags
1442
1778
  } = useMultipleAutocomplete({
1443
1779
  options,
1444
1780
  value,
1445
1781
  onChange,
1446
- getOptionLabel
1782
+ getOptionLabel,
1783
+ size: props.size,
1784
+ counterFormatter,
1785
+ counterText,
1786
+ allSelectedText
1447
1787
  });
1788
+ const listboxProps = {
1789
+ showFilters,
1790
+ allSelected,
1791
+ someSelected,
1792
+ handleSelectAll,
1793
+ multiple: true,
1794
+ itemHeight,
1795
+ maxListHeight,
1796
+ extended
1797
+ };
1798
+ const finalRenderTags = showCounter && !renderTags ? getCounterRenderTags() : renderTags;
1448
1799
  return /* @__PURE__ */ jsx(
1449
1800
  Autocomplete$1,
1450
1801
  {
@@ -1455,14 +1806,9 @@ function _MultipleAutocomplete({
1455
1806
  onChange: handleChange,
1456
1807
  getOptionLabel,
1457
1808
  renderOption: renderOption ?? multipleRenderOption,
1458
- ListboxComponent: ListboxWithFilter,
1459
- ListboxProps: {
1460
- showFilters,
1461
- allSelected,
1462
- someSelected,
1463
- handleSelectAll,
1464
- multiple: true
1465
- },
1809
+ renderTags: finalRenderTags,
1810
+ ListboxComponent: AutocompleteList,
1811
+ ListboxProps: listboxProps,
1466
1812
  multiple: true,
1467
1813
  getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
1468
1814
  disableCloseOnSelect,
@@ -1473,6 +1819,30 @@ function _MultipleAutocomplete({
1473
1819
  );
1474
1820
  }
1475
1821
  const MultipleAutocomplete = forwardRef(_MultipleAutocomplete);
1822
+ function useAutocomplete({
1823
+ getOptionLabel = getDefaultOptionLabel
1824
+ }) {
1825
+ const { renderOption: autocompleteRenderOption } = useAutocompleteRenderOption();
1826
+ const internalGetOptionLabel = (option) => {
1827
+ if (isAutocompleteListGroupHeader(option)) {
1828
+ return option.title;
1829
+ }
1830
+ return getOptionLabel(option);
1831
+ };
1832
+ const singleRenderOption = (props, option, state) => {
1833
+ const optionWithMultiple = createOptionWithMultiple(option, false);
1834
+ return autocompleteRenderOption(
1835
+ props,
1836
+ optionWithMultiple,
1837
+ state,
1838
+ internalGetOptionLabel
1839
+ );
1840
+ };
1841
+ return {
1842
+ singleRenderOption,
1843
+ getOptionLabel: internalGetOptionLabel
1844
+ };
1845
+ }
1476
1846
  const _CopiableComponent = ({
1477
1847
  children,
1478
1848
  disabled,
@@ -4693,10 +5063,12 @@ function CodeAreaDialog({
4693
5063
  );
4694
5064
  }
4695
5065
  export {
5066
+ AUTOCOMPLETE_GROUP_HEADER_PROPERTY,
4696
5067
  AccordionGroup,
4697
5068
  Alert$1 as Alert,
4698
5069
  AppBar,
4699
5070
  Autocomplete,
5071
+ AutocompleteList,
4700
5072
  Avatar,
4701
5073
  Button,
4702
5074
  CodeAreaDialog,
@@ -4744,6 +5116,9 @@ export {
4744
5116
  UploadField,
4745
5117
  UploadFieldBase,
4746
5118
  copyString,
5119
+ createAutocompleteGroupByList,
4747
5120
  dialogDimensionsBySize,
5121
+ isAutocompleteListGroupHeader,
5122
+ useAutocomplete,
4748
5123
  useCopyValue
4749
5124
  };