@carto/meridian-ds 1.5.1 → 2.0.0-alpha-external-link.6

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 (77) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/{Alert-BiOR9aar.cjs → Alert-CmglMdw_.cjs} +96 -1
  3. package/dist/{Alert-CywtIMOj.js → Alert-DWK8eGnD.js} +98 -3
  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-C8x-GasJ.js} +10 -6
  7. package/dist/{MenuItem-Br2jY2lt.cjs → MenuItem-CyIdh2wX.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-BWer8cmX.js} +15 -4
  13. package/dist/{TablePaginationActions-CFGXm44W.cjs → TablePaginationActions-MwqZJoRm.cjs} +14 -3
  14. package/dist/components/index.cjs +456 -57
  15. package/dist/components/index.js +460 -60
  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/atoms/Button.d.ts +10 -0
  21. package/dist/types/components/atoms/Button.d.ts.map +1 -1
  22. package/dist/types/components/atoms/Link.d.ts +16 -0
  23. package/dist/types/components/atoms/Link.d.ts.map +1 -0
  24. package/dist/types/components/atoms/ScreenReaderOnly.d.ts +3 -0
  25. package/dist/types/components/atoms/ScreenReaderOnly.d.ts.map +1 -0
  26. package/dist/types/components/atoms/index.d.ts +3 -0
  27. package/dist/types/components/atoms/index.d.ts.map +1 -1
  28. package/dist/types/components/molecules/Autocomplete/Autocomplete.d.ts.map +1 -1
  29. package/dist/types/components/molecules/Autocomplete/AutocompleteList.d.ts +13 -0
  30. package/dist/types/components/molecules/Autocomplete/AutocompleteList.d.ts.map +1 -0
  31. package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts +1 -1
  32. package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts.map +1 -1
  33. package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts +1 -1
  34. package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts.map +1 -1
  35. package/dist/types/components/molecules/Autocomplete/index.d.ts +3 -0
  36. package/dist/types/components/molecules/Autocomplete/index.d.ts.map +1 -1
  37. package/dist/types/components/molecules/Autocomplete/types.d.ts +107 -7
  38. package/dist/types/components/molecules/Autocomplete/types.d.ts.map +1 -1
  39. package/dist/types/components/molecules/Autocomplete/useAutocomplete.d.ts +11 -0
  40. package/dist/types/components/molecules/Autocomplete/useAutocomplete.d.ts.map +1 -0
  41. package/dist/types/components/molecules/Autocomplete/useAutocompleteRenderOption.d.ts +2 -1
  42. package/dist/types/components/molecules/Autocomplete/useAutocompleteRenderOption.d.ts.map +1 -1
  43. package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts +26 -1
  44. package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts.map +1 -1
  45. package/dist/types/components/molecules/Autocomplete/utils.d.ts +135 -0
  46. package/dist/types/components/molecules/Autocomplete/utils.d.ts.map +1 -1
  47. package/dist/types/components/molecules/Menu/Menu.d.ts.map +1 -1
  48. package/dist/types/components/molecules/Menu/MenuItem.d.ts.map +1 -1
  49. package/dist/types/components/molecules/Menu/MenuItemFilter.d.ts.map +1 -1
  50. package/dist/types/components/molecules/Menu/MenuList.d.ts.map +1 -1
  51. package/dist/types/components/molecules/MultipleSelectField/MultipleSelectField.d.ts.map +1 -1
  52. package/dist/types/custom-icons/AiAgent.d.ts +4 -0
  53. package/dist/types/custom-icons/AiAgent.d.ts.map +1 -0
  54. package/dist/types/custom-icons/HideRightsidebar.d.ts +4 -0
  55. package/dist/types/custom-icons/HideRightsidebar.d.ts.map +1 -0
  56. package/dist/types/custom-icons/ShowRightsidebar.d.ts +4 -0
  57. package/dist/types/custom-icons/ShowRightsidebar.d.ts.map +1 -0
  58. package/dist/types/custom-icons/index.d.ts +3 -0
  59. package/dist/types/custom-icons/index.d.ts.map +1 -1
  60. package/dist/types/localization/en.d.ts +1 -0
  61. package/dist/types/localization/en.d.ts.map +1 -1
  62. package/dist/types/localization/es.d.ts +1 -0
  63. package/dist/types/localization/es.d.ts.map +1 -1
  64. package/dist/types/localization/id.d.ts +1 -0
  65. package/dist/types/localization/id.d.ts.map +1 -1
  66. package/dist/types/localization/index.d.ts +3 -0
  67. package/dist/types/localization/index.d.ts.map +1 -1
  68. package/dist/types/theme/sections/components/forms.d.ts.map +1 -1
  69. package/dist/types/theme/sections/components/navigation.d.ts.map +1 -1
  70. package/dist/types/theme/theme-constants.d.ts +4 -0
  71. package/dist/types/theme/theme-constants.d.ts.map +1 -1
  72. package/dist/types/widgets/comparative/ComparativeCategoryWidgetUI/ComparativeCategoryWidgetUI.d.ts.map +1 -1
  73. package/dist/widgets/index.cjs +6 -6
  74. package/dist/widgets/index.js +6 -6
  75. package/package.json +1 -1
  76. package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts +0 -17
  77. package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts.map +0 -1
@@ -2,15 +2,16 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
- const material = require("@mui/material");
6
- const TablePaginationActions = require("../TablePaginationActions-CFGXm44W.cjs");
7
- const ArrowDown = require("../ArrowDown-8fLj23Ge.cjs");
8
- const OpenDiagonallyRight = require("../OpenDiagonallyRight-CM1tojUq.cjs");
9
5
  const reactIntl = require("react-intl");
6
+ const material = require("@mui/material");
10
7
  const iconsMaterial = require("@mui/icons-material");
11
- const Alert$1 = require("../Alert-BiOR9aar.cjs");
8
+ const TablePaginationActions = require("../TablePaginationActions-MwqZJoRm.cjs");
9
+ const Alert$1 = require("../Alert-CmglMdw_.cjs");
10
+ const ArrowDown = require("../ArrowDown-DJ0vhbsw.cjs");
11
+ const OpenDiagonallyRight = require("../OpenDiagonallyRight-CpL4ROwg.cjs");
12
12
  require("cartocolor");
13
- const MenuItem = require("../MenuItem-Br2jY2lt.cjs");
13
+ const MenuItem = require("../MenuItem-CyIdh2wX.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");
@@ -61,10 +62,15 @@ function _Button({
61
62
  startIcon,
62
63
  endIcon,
63
64
  loadingPosition,
65
+ external,
66
+ showExternalIcon = true,
64
67
  ...otherProps
65
68
  }, ref) {
69
+ const intl = reactIntl.useIntl();
70
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
66
71
  const defaultIconLoader = /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" });
67
72
  const isDefaultLoading = loading && loadingPosition === void 0;
73
+ const isExternalLink = otherProps.href && external;
68
74
  const renderContent = () => {
69
75
  if (isDefaultLoading) {
70
76
  return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { position: "relative" }, children: [
@@ -72,6 +78,14 @@ function _Button({
72
78
  /* @__PURE__ */ jsxRuntime.jsx(HiddenText, { children })
73
79
  ] });
74
80
  }
81
+ if (isExternalLink) {
82
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
83
+ children,
84
+ /* @__PURE__ */ jsxRuntime.jsx(Alert$1.ScreenReaderOnly, { id: "external-hint", children: `(${intlConfig.formatMessage({
85
+ id: "c4r.button.opensInNewTab"
86
+ })})` })
87
+ ] });
88
+ }
75
89
  return children;
76
90
  };
77
91
  const getIconForPosition = (position) => {
@@ -84,7 +98,11 @@ function _Button({
84
98
  }
85
99
  return void 0;
86
100
  }
87
- return position === "start" ? startIcon : endIcon;
101
+ if (position === "start") {
102
+ return startIcon;
103
+ } else {
104
+ return endIcon || (isExternalLink && showExternalIcon ? /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.OpenInNewOutlined, {}) : void 0);
105
+ }
88
106
  };
89
107
  return /* @__PURE__ */ jsxRuntime.jsx(
90
108
  material.Button,
@@ -94,7 +112,12 @@ function _Button({
94
112
  endIcon: getIconForPosition("end"),
95
113
  ...otherProps,
96
114
  role: otherProps.href ? "link" : "button",
115
+ ...isExternalLink && {
116
+ target: "_blank",
117
+ rel: "noopener noreferrer"
118
+ },
97
119
  ref,
120
+ "aria-describedby": isExternalLink ? "external-hint" : void 0,
98
121
  children: /* @__PURE__ */ jsxRuntime.jsx(TablePaginationActions.Typography, { variant: "inherit", color: "inherit", noWrap: true, component: "span", children: renderContent() })
99
122
  }
100
123
  );
@@ -479,10 +502,10 @@ function ToggleButtonGroup({
479
502
  }
480
503
  const StyledMenu = material.styled(material.Menu, {
481
504
  shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
482
- })(({ theme, extended, width, height }) => ({
505
+ })(({ extended, width, height }) => ({
483
506
  ...extended && {
484
507
  ".MuiMenuItem-root": {
485
- minHeight: theme.spacing(6)
508
+ minHeight: TablePaginationActions.MENU_ITEM_SIZE_EXTENDED
486
509
  }
487
510
  },
488
511
  ...width && {
@@ -522,10 +545,10 @@ function _Menu({ extended, width, height, MenuListProps, ...otherProps }, ref) {
522
545
  const Menu$1 = React.forwardRef(_Menu);
523
546
  const StyledMenuList = material.styled(material.MenuList, {
524
547
  shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
525
- })(({ theme, extended, width, height }) => ({
548
+ })(({ extended, width, height }) => ({
526
549
  ...extended && {
527
550
  ".MuiMenuItem-root": {
528
- minHeight: theme.spacing(6)
551
+ minHeight: TablePaginationActions.MENU_ITEM_SIZE_EXTENDED
529
552
  }
530
553
  },
531
554
  "&.MuiList-root": {
@@ -556,7 +579,8 @@ function _MenuList({ extended, width, height, ...otherProps }, ref) {
556
579
  }
557
580
  const MenuList = React.forwardRef(_MenuList);
558
581
  const StyledMenuItem$1 = material.styled(MenuItem.MenuItem)(() => ({
559
- marginTop: "0 !important"
582
+ marginTop: "0 !important",
583
+ marginBottom: "0 !important"
560
584
  }));
561
585
  const LinkFilter = material.styled(material.Link)(
562
586
  ({ disabled, theme }) => ({
@@ -796,12 +820,20 @@ function _MultipleSelectField({
796
820
  },
797
821
  children: [
798
822
  showFilters && /* @__PURE__ */ jsxRuntime.jsx(
799
- MenuItemFilter,
823
+ material.Box,
800
824
  {
801
- areAllSelected,
802
- areAnySelected,
803
- selectAll,
804
- selectAllDisabled
825
+ sx: {
826
+ mb: 1
827
+ },
828
+ children: /* @__PURE__ */ jsxRuntime.jsx(
829
+ MenuItemFilter,
830
+ {
831
+ areAllSelected,
832
+ areAnySelected,
833
+ selectAll,
834
+ selectAllDisabled
835
+ }
836
+ )
805
837
  }
806
838
  ),
807
839
  options == null ? void 0 : options.map((option) => {
@@ -1108,11 +1140,130 @@ function UploadField({
1108
1140
  )
1109
1141
  ] });
1110
1142
  }
1143
+ const AUTOCOMPLETE_GROUP_HEADER_PROPERTY = "__isGroupHeader";
1144
+ function isAutocompleteListGroupHeader(option) {
1145
+ return typeof option === "object" && option !== null && AUTOCOMPLETE_GROUP_HEADER_PROPERTY in option;
1146
+ }
1147
+ const getDefaultOptionLabel = (option) => {
1148
+ return option && typeof option === "object" ? option.title ?? String(option) : String(option);
1149
+ };
1150
+ const createOptionWithMultiple = (option, multiple) => {
1151
+ return typeof option !== "object" || option === null ? { value: option, multiple } : { ...option, multiple };
1152
+ };
1153
+ const getDefaultLimitTagsText = (more) => /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-testid": "more-options-tag", children: [
1154
+ "+",
1155
+ more
1156
+ ] });
1157
+ function createCounterRenderTags({
1158
+ formatCounter,
1159
+ options = [],
1160
+ size = "small",
1161
+ getOptionLabel = getDefaultOptionLabel
1162
+ }) {
1163
+ const CounterRenderTags = (value) => {
1164
+ if (value.length === 0) {
1165
+ return null;
1166
+ }
1167
+ const selectedCount = value.length;
1168
+ const selectableOptions = options.filter(
1169
+ (option) => !isAutocompleteListGroupHeader(option)
1170
+ );
1171
+ const totalCount = selectableOptions.length;
1172
+ const text = formatCounter({
1173
+ selectedCount,
1174
+ totalCount,
1175
+ selectedItems: value,
1176
+ allItems: selectableOptions,
1177
+ getOptionLabel
1178
+ });
1179
+ return /* @__PURE__ */ jsxRuntime.jsx(
1180
+ TablePaginationActions.Typography,
1181
+ {
1182
+ variant: size === "small" ? "body2" : "body1",
1183
+ component: "span",
1184
+ "data-testid": "counter-tag",
1185
+ sx: {
1186
+ ml: 1
1187
+ },
1188
+ children: text
1189
+ }
1190
+ );
1191
+ };
1192
+ return CounterRenderTags;
1193
+ }
1194
+ function createCounterFormatter({
1195
+ counterText,
1196
+ allText,
1197
+ showSingleItemText = true
1198
+ }) {
1199
+ return ({
1200
+ selectedCount,
1201
+ totalCount,
1202
+ selectedItems,
1203
+ getOptionLabel
1204
+ }) => {
1205
+ if (selectedCount === totalCount && totalCount > 0) {
1206
+ return allText;
1207
+ } else if (selectedCount === 1 && showSingleItemText) {
1208
+ return getOptionLabel(selectedItems[0]);
1209
+ } else {
1210
+ return `${selectedCount} ${counterText}`;
1211
+ }
1212
+ };
1213
+ }
1214
+ function createAutocompleteGroupByList({
1215
+ options,
1216
+ groupBy,
1217
+ extended
1218
+ }) {
1219
+ const grouped = options.reduce(
1220
+ (acc, option) => {
1221
+ const group = groupBy(option);
1222
+ if (!acc[group]) {
1223
+ acc[group] = [];
1224
+ }
1225
+ acc[group].push(option);
1226
+ return acc;
1227
+ },
1228
+ {}
1229
+ );
1230
+ const result = [];
1231
+ Object.keys(grouped).forEach((title) => {
1232
+ result.push({ [AUTOCOMPLETE_GROUP_HEADER_PROPERTY]: true, title, extended });
1233
+ const groupOptions = grouped[title];
1234
+ if (groupOptions) {
1235
+ result.push(...groupOptions);
1236
+ }
1237
+ });
1238
+ return result;
1239
+ }
1240
+ function warnDeprecatedGroupBy(componentName) {
1241
+ if (process.env.NODE_ENV !== "production") {
1242
+ console.error(
1243
+ `${componentName}: The \`groupBy\` prop is deprecated and breaks virtualization. Use \`createAutocompleteGroupByList\` instead:
1244
+
1245
+ \`\`\`
1246
+ import { createAutocompleteGroupByList, ${componentName} } from "@carto/meridian-ds/components"
1247
+
1248
+ const groupedOptions = createAutocompleteGroupByList({
1249
+ options,
1250
+ groupBy: (option) => option.category
1251
+ })
1252
+
1253
+ <${componentName} options={groupedOptions} />
1254
+ \`\`\`
1255
+ `
1256
+ );
1257
+ }
1258
+ }
1111
1259
  function _Autocomplete({
1112
1260
  disabled,
1113
1261
  loading,
1114
1262
  ...props
1115
1263
  }, ref) {
1264
+ if (props.groupBy) {
1265
+ warnDeprecatedGroupBy("Autocomplete");
1266
+ }
1116
1267
  return /* @__PURE__ */ jsxRuntime.jsx(
1117
1268
  material.Autocomplete,
1118
1269
  {
@@ -1129,15 +1280,24 @@ function _Autocomplete({
1129
1280
  );
1130
1281
  }
1131
1282
  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
1283
  function useAutocompleteRenderOption() {
1140
1284
  const renderOption = (props, option, state, getOptionLabel, customIcon) => {
1285
+ const { key, ...otherProps } = props;
1286
+ if (isAutocompleteListGroupHeader(option)) {
1287
+ return /* @__PURE__ */ React.createElement(
1288
+ MenuItem.MenuItem,
1289
+ {
1290
+ ...otherProps,
1291
+ subtitle: true,
1292
+ extended: option.extended,
1293
+ key,
1294
+ "aria-disabled": true,
1295
+ "aria-selected": false
1296
+ },
1297
+ option.title
1298
+ );
1299
+ }
1300
+ const regularOption = option;
1141
1301
  const {
1142
1302
  title,
1143
1303
  inputValue,
@@ -1154,9 +1314,8 @@ function useAutocompleteRenderOption() {
1154
1314
  alternativeTitle,
1155
1315
  secondaryText,
1156
1316
  multiple
1157
- } = option;
1158
- const { key, ...otherProps } = props;
1159
- const isPrimitiveOptionType = typeof option === "string" || typeof option === "number";
1317
+ } = regularOption;
1318
+ const isPrimitiveOptionType = typeof regularOption === "string" || typeof regularOption === "number";
1160
1319
  const getOptionLabelText = (getOptionLabel2, option2, alternativeTitle2, title2) => {
1161
1320
  if (alternativeTitle2) return alternativeTitle2;
1162
1321
  if (title2) return title2;
@@ -1190,7 +1349,7 @@ function useAutocompleteRenderOption() {
1190
1349
  /* @__PURE__ */ jsxRuntime.jsxs(material.ListItemText, { children: [
1191
1350
  getOptionLabelText(
1192
1351
  getOptionLabel ?? getDefaultOptionLabel,
1193
- option,
1352
+ regularOption,
1194
1353
  alternativeTitle,
1195
1354
  title
1196
1355
  ),
@@ -1277,8 +1436,16 @@ function useMultipleAutocomplete({
1277
1436
  options,
1278
1437
  value,
1279
1438
  onChange,
1280
- getOptionLabel
1439
+ getOptionLabel,
1440
+ size,
1441
+ counterFormatter,
1442
+ counterText,
1443
+ allSelectedText
1281
1444
  }) {
1445
+ const intl = reactIntl.useIntl();
1446
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
1447
+ const defaultCounterText = counterText || intlConfig.formatMessage({ id: "c4r.form.selected" });
1448
+ const defaultAllSelectedText = allSelectedText || intlConfig.formatMessage({ id: "c4r.form.allSelected" });
1282
1449
  const [multipleValue, setMultipleValue] = React.useState(
1283
1450
  Array.isArray(value) ? value : value ? [value] : []
1284
1451
  );
@@ -1287,10 +1454,13 @@ function useMultipleAutocomplete({
1287
1454
  const newValue = Array.isArray(value) ? value : value ? [value] : [];
1288
1455
  setMultipleValue(newValue);
1289
1456
  }, [value]);
1290
- const allSelected = multipleValue.length === options.length;
1291
- const someSelected = multipleValue.length > 0 && multipleValue.length < options.length;
1457
+ const selectableOptions = options.filter(
1458
+ (option) => !isAutocompleteListGroupHeader(option)
1459
+ );
1460
+ const allSelected = multipleValue.length === selectableOptions.length;
1461
+ const someSelected = multipleValue.length > 0 && multipleValue.length < selectableOptions.length;
1292
1462
  const handleSelectAll = (event) => {
1293
- const newValue = allSelected ? [] : [...options];
1463
+ const newValue = allSelected ? [] : [...selectableOptions];
1294
1464
  setMultipleValue(newValue);
1295
1465
  onChange == null ? void 0 : onChange(
1296
1466
  event,
@@ -1312,31 +1482,173 @@ function useMultipleAutocomplete({
1312
1482
  getOptionLabel
1313
1483
  );
1314
1484
  };
1485
+ const getCounterRenderTags = React.useCallback(() => {
1486
+ const formatter = counterFormatter || createCounterFormatter({
1487
+ counterText: defaultCounterText,
1488
+ allText: defaultAllSelectedText
1489
+ });
1490
+ return createCounterRenderTags({
1491
+ formatCounter: formatter,
1492
+ options,
1493
+ size,
1494
+ getOptionLabel: getOptionLabel ? (option) => getOptionLabel(option) : void 0
1495
+ });
1496
+ }, [
1497
+ options,
1498
+ counterFormatter,
1499
+ defaultCounterText,
1500
+ defaultAllSelectedText,
1501
+ size,
1502
+ getOptionLabel
1503
+ ]);
1315
1504
  return {
1316
1505
  multipleValue,
1317
1506
  allSelected,
1318
1507
  someSelected,
1319
1508
  handleSelectAll,
1320
1509
  handleChange,
1321
- multipleRenderOption
1510
+ multipleRenderOption,
1511
+ getCounterRenderTags
1322
1512
  };
1323
1513
  }
1324
- function _ListboxWithFilter({
1514
+ const List = material.styled("ul")(
1515
+ ({ theme, hasFilters }) => ({
1516
+ ...!hasFilters && {
1517
+ paddingTop: `${theme.spacing(1)} !important`
1518
+ }
1519
+ })
1520
+ );
1521
+ const ItemWrapper = material.styled("div")(({ style, theme, isSubtitle, isExtended, isMultiple }) => {
1522
+ const getSubtitleStyles = () => {
1523
+ const baseStyles = {
1524
+ height: TablePaginationActions.MENU_ITEM_SIZE_DENSE,
1525
+ minHeight: TablePaginationActions.MENU_ITEM_SIZE_DENSE,
1526
+ marginTop: `${theme.spacing(1)} !important`,
1527
+ alignItems: "flex-end",
1528
+ ...theme.typography.caption,
1529
+ fontWeight: 500
1530
+ };
1531
+ if (isExtended) {
1532
+ baseStyles.alignItems = "center";
1533
+ if (isMultiple) {
1534
+ baseStyles.marginLeft = theme.spacing(0.5);
1535
+ }
1536
+ }
1537
+ return baseStyles;
1538
+ };
1539
+ return {
1540
+ pointerEvents: "none",
1541
+ // To avoid the extra div to receive the click event
1542
+ "& .MuiMenuItem-root": {
1543
+ pointerEvents: "auto",
1544
+ // Allow pointer events for the menu item
1545
+ marginTop: 0,
1546
+ "&:first-of-type": {
1547
+ marginTop: "0 !important"
1548
+ }
1549
+ },
1550
+ ...isSubtitle && {
1551
+ "& .MuiAutocomplete-option.MuiMenuItem-root": getSubtitleStyles(),
1552
+ // First item has no divider
1553
+ "&:not(:first-of-type)": {
1554
+ "&::before": {
1555
+ content: '""',
1556
+ position: "absolute",
1557
+ zIndex: 1,
1558
+ top: theme.spacing(0.5),
1559
+ left: 0,
1560
+ right: 0,
1561
+ height: "1px",
1562
+ backgroundColor: theme.palette.divider
1563
+ }
1564
+ }
1565
+ },
1566
+ ...!isSubtitle && {
1567
+ "& .MuiAutocomplete-option": {
1568
+ minHeight: `${style == null ? void 0 : style.height}px !important`
1569
+ }
1570
+ }
1571
+ };
1572
+ });
1573
+ function _AutocompleteList({
1325
1574
  children,
1326
1575
  showFilters,
1327
1576
  allSelected,
1328
1577
  someSelected,
1329
1578
  handleSelectAll = () => void 0,
1330
1579
  multiple,
1580
+ extended,
1581
+ itemHeight,
1582
+ maxListHeight = TablePaginationActions.MENU_LIST_MAX_SIZE,
1331
1583
  ...otherProps
1332
1584
  }, ref) {
1585
+ const childrenArray = React.useMemo(() => {
1586
+ return React.Children.toArray(children).map((child) => {
1587
+ if (!React.isValidElement(child)) {
1588
+ return {
1589
+ child,
1590
+ isSubtitle: false,
1591
+ isExtended: false,
1592
+ isMultiple: !!multiple
1593
+ };
1594
+ }
1595
+ const props = child.props;
1596
+ return {
1597
+ child,
1598
+ isSubtitle: props.subtitle === true,
1599
+ isExtended: props.extended === true,
1600
+ isMultiple: !!multiple
1601
+ };
1602
+ });
1603
+ }, [children, multiple]);
1604
+ const defaultItemHeight = itemHeight ?? (extended ? TablePaginationActions.MENU_ITEM_SIZE_EXTENDED : TablePaginationActions.MENU_ITEM_SIZE_DEFAULT);
1605
+ const listboxHeight = React.useMemo(() => {
1606
+ const filterHeight = showFilters && multiple ? TablePaginationActions.MENU_ITEM_SIZE_EXTENDED : 0;
1607
+ const availableHeight = maxListHeight - filterHeight;
1608
+ const calculatedHeight = Math.min(
1609
+ childrenArray.length * defaultItemHeight,
1610
+ availableHeight
1611
+ );
1612
+ return Math.max(calculatedHeight, defaultItemHeight);
1613
+ }, [
1614
+ showFilters,
1615
+ multiple,
1616
+ maxListHeight,
1617
+ childrenArray.length,
1618
+ defaultItemHeight
1619
+ ]);
1620
+ const renderItem = ({
1621
+ index,
1622
+ style
1623
+ }) => {
1624
+ const item = childrenArray[index];
1625
+ if (!item) return null;
1626
+ const { child, isSubtitle, isExtended, isMultiple } = item;
1627
+ return /* @__PURE__ */ jsxRuntime.jsx(
1628
+ ItemWrapper,
1629
+ {
1630
+ style,
1631
+ isSubtitle,
1632
+ isExtended,
1633
+ isMultiple,
1634
+ "data-name": "virtual-menu-item",
1635
+ children: child
1636
+ }
1637
+ );
1638
+ };
1333
1639
  return /* @__PURE__ */ jsxRuntime.jsxs(
1334
- "ul",
1640
+ List,
1335
1641
  {
1336
1642
  ref,
1337
1643
  ...otherProps,
1338
1644
  role: "listbox",
1645
+ "data-list-height": listboxHeight,
1646
+ "data-item-height": defaultItemHeight,
1339
1647
  "aria-multiselectable": multiple,
1648
+ hasFilters: showFilters,
1649
+ style: {
1650
+ maxHeight: maxListHeight + defaultItemHeight
1651
+ },
1340
1652
  children: [
1341
1653
  showFilters && multiple && /* @__PURE__ */ jsxRuntime.jsx(
1342
1654
  MenuItemFilter,
@@ -1346,12 +1658,21 @@ function _ListboxWithFilter({
1346
1658
  selectAll: handleSelectAll
1347
1659
  }
1348
1660
  ),
1349
- children
1661
+ /* @__PURE__ */ jsxRuntime.jsx(
1662
+ reactWindow.FixedSizeList,
1663
+ {
1664
+ height: listboxHeight,
1665
+ width: "100%",
1666
+ itemCount: childrenArray.length,
1667
+ itemSize: defaultItemHeight,
1668
+ children: renderItem
1669
+ }
1670
+ )
1350
1671
  ]
1351
1672
  }
1352
1673
  );
1353
1674
  }
1354
- const ListboxWithFilter = React.forwardRef(_ListboxWithFilter);
1675
+ const AutocompleteList = React.forwardRef(_AutocompleteList);
1355
1676
  function _CreatableAutocomplete({
1356
1677
  newItemLabel,
1357
1678
  newItemIcon,
@@ -1361,23 +1682,41 @@ function _CreatableAutocomplete({
1361
1682
  disabled,
1362
1683
  loading,
1363
1684
  showFilters,
1685
+ showCounter = false,
1686
+ counterFormatter,
1687
+ counterText,
1688
+ allSelectedText,
1364
1689
  options = [],
1365
1690
  value,
1366
1691
  onChange,
1367
1692
  getLimitTagsText,
1693
+ renderTags,
1694
+ itemHeight,
1695
+ maxListHeight,
1696
+ extended,
1697
+ groupBy,
1368
1698
  ...props
1369
1699
  }, ref) {
1700
+ if (groupBy) {
1701
+ warnDeprecatedGroupBy("CreatableAutocomplete");
1702
+ }
1370
1703
  const { freeSolo = true, ...otherProps } = props;
1371
1704
  const {
1372
1705
  multipleValue,
1373
1706
  allSelected,
1374
1707
  someSelected,
1375
1708
  handleSelectAll,
1376
- handleChange
1709
+ handleChange,
1710
+ getCounterRenderTags
1377
1711
  } = useMultipleAutocomplete({
1378
1712
  options,
1379
1713
  value,
1380
- onChange
1714
+ onChange,
1715
+ getOptionLabel,
1716
+ size: props.size,
1717
+ counterFormatter,
1718
+ counterText,
1719
+ allSelectedText
1381
1720
  });
1382
1721
  const {
1383
1722
  creatableFilterOptions,
@@ -1389,6 +1728,17 @@ function _CreatableAutocomplete({
1389
1728
  newItemIcon,
1390
1729
  multiple
1391
1730
  });
1731
+ const listboxProps = {
1732
+ showFilters,
1733
+ allSelected,
1734
+ someSelected,
1735
+ handleSelectAll,
1736
+ multiple,
1737
+ itemHeight,
1738
+ maxListHeight,
1739
+ extended
1740
+ };
1741
+ const finalRenderTags = showCounter && multiple && !renderTags ? getCounterRenderTags() : renderTags;
1392
1742
  return /* @__PURE__ */ jsxRuntime.jsx(
1393
1743
  material.Autocomplete,
1394
1744
  {
@@ -1400,18 +1750,13 @@ function _CreatableAutocomplete({
1400
1750
  filterOptions: creatableFilterOptions,
1401
1751
  getOptionLabel: creatableOptionLabel,
1402
1752
  renderOption: creatableRenderOption,
1753
+ renderTags: finalRenderTags,
1403
1754
  freeSolo,
1404
1755
  forcePopupIcon: true,
1405
1756
  multiple,
1406
1757
  disableCloseOnSelect: disableCloseOnSelect ?? multiple,
1407
- ListboxComponent: ListboxWithFilter,
1408
- ListboxProps: {
1409
- showFilters,
1410
- allSelected,
1411
- someSelected,
1412
- handleSelectAll,
1413
- multiple
1414
- },
1758
+ ListboxComponent: AutocompleteList,
1759
+ ListboxProps: listboxProps,
1415
1760
  getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
1416
1761
  disabled: disabled || loading,
1417
1762
  popupIcon: loading ? /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" }) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}),
@@ -1426,26 +1771,54 @@ function _MultipleAutocomplete({
1426
1771
  disabled,
1427
1772
  loading,
1428
1773
  showFilters,
1774
+ showCounter = false,
1775
+ counterFormatter,
1776
+ counterText,
1777
+ allSelectedText,
1429
1778
  options,
1430
1779
  value,
1431
1780
  onChange,
1432
1781
  getOptionLabel,
1433
1782
  getLimitTagsText,
1783
+ renderTags,
1784
+ itemHeight,
1785
+ maxListHeight,
1786
+ extended,
1787
+ groupBy,
1434
1788
  ...props
1435
1789
  }, ref) {
1790
+ if (groupBy) {
1791
+ warnDeprecatedGroupBy("MultipleAutocomplete");
1792
+ }
1436
1793
  const {
1437
1794
  multipleValue,
1438
1795
  allSelected,
1439
1796
  someSelected,
1440
1797
  handleSelectAll,
1441
1798
  handleChange,
1442
- multipleRenderOption
1799
+ multipleRenderOption,
1800
+ getCounterRenderTags
1443
1801
  } = useMultipleAutocomplete({
1444
1802
  options,
1445
1803
  value,
1446
1804
  onChange,
1447
- getOptionLabel
1805
+ getOptionLabel,
1806
+ size: props.size,
1807
+ counterFormatter,
1808
+ counterText,
1809
+ allSelectedText
1448
1810
  });
1811
+ const listboxProps = {
1812
+ showFilters,
1813
+ allSelected,
1814
+ someSelected,
1815
+ handleSelectAll,
1816
+ multiple: true,
1817
+ itemHeight,
1818
+ maxListHeight,
1819
+ extended
1820
+ };
1821
+ const finalRenderTags = showCounter && !renderTags ? getCounterRenderTags() : renderTags;
1449
1822
  return /* @__PURE__ */ jsxRuntime.jsx(
1450
1823
  material.Autocomplete,
1451
1824
  {
@@ -1456,14 +1829,9 @@ function _MultipleAutocomplete({
1456
1829
  onChange: handleChange,
1457
1830
  getOptionLabel,
1458
1831
  renderOption: renderOption ?? multipleRenderOption,
1459
- ListboxComponent: ListboxWithFilter,
1460
- ListboxProps: {
1461
- showFilters,
1462
- allSelected,
1463
- someSelected,
1464
- handleSelectAll,
1465
- multiple: true
1466
- },
1832
+ renderTags: finalRenderTags,
1833
+ ListboxComponent: AutocompleteList,
1834
+ ListboxProps: listboxProps,
1467
1835
  multiple: true,
1468
1836
  getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
1469
1837
  disableCloseOnSelect,
@@ -1474,6 +1842,30 @@ function _MultipleAutocomplete({
1474
1842
  );
1475
1843
  }
1476
1844
  const MultipleAutocomplete = React.forwardRef(_MultipleAutocomplete);
1845
+ function useAutocomplete({
1846
+ getOptionLabel = getDefaultOptionLabel
1847
+ }) {
1848
+ const { renderOption: autocompleteRenderOption } = useAutocompleteRenderOption();
1849
+ const internalGetOptionLabel = (option) => {
1850
+ if (isAutocompleteListGroupHeader(option)) {
1851
+ return option.title;
1852
+ }
1853
+ return getOptionLabel(option);
1854
+ };
1855
+ const singleRenderOption = (props, option, state) => {
1856
+ const optionWithMultiple = createOptionWithMultiple(option, false);
1857
+ return autocompleteRenderOption(
1858
+ props,
1859
+ optionWithMultiple,
1860
+ state,
1861
+ internalGetOptionLabel
1862
+ );
1863
+ };
1864
+ return {
1865
+ singleRenderOption,
1866
+ getOptionLabel: internalGetOptionLabel
1867
+ };
1868
+ }
1477
1869
  const _CopiableComponent = ({
1478
1870
  children,
1479
1871
  disabled,
@@ -4697,10 +5089,14 @@ exports.TablePaginationActions = TablePaginationActions.TablePaginationActions;
4697
5089
  exports.Typography = TablePaginationActions.Typography;
4698
5090
  exports.Alert = Alert$1.Alert;
4699
5091
  exports.IconButton = Alert$1.IconButton;
5092
+ exports.Link = Alert$1.Link;
5093
+ exports.ScreenReaderOnly = Alert$1.ScreenReaderOnly;
4700
5094
  exports.MenuItem = MenuItem.MenuItem;
5095
+ exports.AUTOCOMPLETE_GROUP_HEADER_PROPERTY = AUTOCOMPLETE_GROUP_HEADER_PROPERTY;
4701
5096
  exports.AccordionGroup = AccordionGroup;
4702
5097
  exports.AppBar = AppBar;
4703
5098
  exports.Autocomplete = Autocomplete;
5099
+ exports.AutocompleteList = AutocompleteList;
4704
5100
  exports.Avatar = Avatar;
4705
5101
  exports.Button = Button;
4706
5102
  exports.CodeAreaDialog = CodeAreaDialog;
@@ -4744,5 +5140,8 @@ exports.TooltipData = TooltipData;
4744
5140
  exports.UploadField = UploadField;
4745
5141
  exports.UploadFieldBase = UploadFieldBase;
4746
5142
  exports.copyString = copyString;
5143
+ exports.createAutocompleteGroupByList = createAutocompleteGroupByList;
4747
5144
  exports.dialogDimensionsBySize = dialogDimensionsBySize;
5145
+ exports.isAutocompleteListGroupHeader = isAutocompleteListGroupHeader;
5146
+ exports.useAutocomplete = useAutocomplete;
4748
5147
  exports.useCopyValue = useCopyValue;