@carto/meridian-ds 1.4.8-alpha-external-link.5 → 1.5.0-alpha-virtual-autocomplete.1

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 (54) hide show
  1. package/CHANGELOG.md +6 -4
  2. package/dist/{Alert-CmDToT57.cjs → Alert-BzEgeyQJ.cjs} +1 -72
  3. package/dist/{Alert-2L0Hy8lT.js → Alert-CnaTtNJd.js} +3 -74
  4. package/dist/{MenuItem-CXnnE5lK.js → MenuItem-D6wJym7Z.js} +9 -5
  5. package/dist/{MenuItem-Br2jY2lt.cjs → MenuItem-lAxlHrDp.cjs} +9 -5
  6. package/dist/{TablePaginationActions-b5wP_uRE.js → TablePaginationActions-Cz5Hbi6N.js} +12 -7
  7. package/dist/{TablePaginationActions-CAmwcyTy.cjs → TablePaginationActions-mbbjzV6Y.cjs} +11 -6
  8. package/dist/components/index.cjs +163 -55
  9. package/dist/components/index.js +164 -57
  10. package/dist/theme/index.cjs +13 -9
  11. package/dist/theme/index.js +14 -10
  12. package/dist/types/components/atoms/Button.d.ts +0 -11
  13. package/dist/types/components/atoms/Button.d.ts.map +1 -1
  14. package/dist/types/components/atoms/index.d.ts +0 -2
  15. package/dist/types/components/atoms/index.d.ts.map +1 -1
  16. package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts +1 -1
  17. package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts.map +1 -1
  18. package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts +18 -0
  19. package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts.map +1 -1
  20. package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts +1 -1
  21. package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts.map +1 -1
  22. package/dist/types/components/molecules/Autocomplete/types.d.ts +61 -3
  23. package/dist/types/components/molecules/Autocomplete/types.d.ts.map +1 -1
  24. package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts +3 -1
  25. package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts.map +1 -1
  26. package/dist/types/components/molecules/Autocomplete/utils.d.ts +9 -0
  27. package/dist/types/components/molecules/Autocomplete/utils.d.ts.map +1 -1
  28. package/dist/types/components/molecules/Menu/Menu.d.ts.map +1 -1
  29. package/dist/types/components/molecules/Menu/MenuItem.d.ts.map +1 -1
  30. package/dist/types/components/molecules/Menu/MenuItemFilter.d.ts.map +1 -1
  31. package/dist/types/components/molecules/Menu/MenuList.d.ts.map +1 -1
  32. package/dist/types/components/molecules/MultipleSelectField/MultipleSelectField.d.ts.map +1 -1
  33. package/dist/types/localization/en.d.ts +0 -1
  34. package/dist/types/localization/en.d.ts.map +1 -1
  35. package/dist/types/localization/es.d.ts +0 -1
  36. package/dist/types/localization/es.d.ts.map +1 -1
  37. package/dist/types/localization/id.d.ts +0 -1
  38. package/dist/types/localization/id.d.ts.map +1 -1
  39. package/dist/types/localization/index.d.ts +0 -3
  40. package/dist/types/localization/index.d.ts.map +1 -1
  41. package/dist/types/theme/sections/components/forms.d.ts.map +1 -1
  42. package/dist/types/theme/sections/components/navigation.d.ts.map +1 -1
  43. package/dist/types/theme/theme-constants.d.ts +4 -0
  44. package/dist/types/theme/theme-constants.d.ts.map +1 -1
  45. package/dist/types/theme/types.d.ts +0 -6
  46. package/dist/types/theme/types.d.ts.map +1 -1
  47. package/dist/types/widgets/CategoryWidgetUI/CategoryWidgetUI.styled.d.ts +1 -1
  48. package/dist/types/widgets/CategoryWidgetUI/CategoryWidgetUI.styled.d.ts.map +1 -1
  49. package/dist/types/widgets/comparative/ComparativeCategoryWidgetUI/ComparativeCategoryWidgetUI.d.ts.map +1 -1
  50. package/dist/widgets/index.cjs +5 -5
  51. package/dist/widgets/index.js +5 -5
  52. package/package.json +1 -1
  53. package/dist/types/components/atoms/Link.d.ts +0 -14
  54. package/dist/types/components/atoms/Link.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 reactIntl = require("react-intl");
6
5
  const material = require("@mui/material");
7
- const iconsMaterial = require("@mui/icons-material");
8
- const TablePaginationActions = require("../TablePaginationActions-CAmwcyTy.cjs");
6
+ const TablePaginationActions = require("../TablePaginationActions-mbbjzV6Y.cjs");
9
7
  const ArrowDown = require("../ArrowDown-8fLj23Ge.cjs");
10
8
  const OpenDiagonallyRight = require("../OpenDiagonallyRight-CM1tojUq.cjs");
11
- const Alert$1 = require("../Alert-CmDToT57.cjs");
9
+ const reactIntl = require("react-intl");
10
+ const iconsMaterial = require("@mui/icons-material");
11
+ const Alert$1 = require("../Alert-BzEgeyQJ.cjs");
12
12
  require("cartocolor");
13
- const MenuItem = require("../MenuItem-Br2jY2lt.cjs");
13
+ const MenuItem = require("../MenuItem-lAxlHrDp.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,13 +62,8 @@ function _Button({
61
62
  startIcon,
62
63
  endIcon,
63
64
  loadingPosition,
64
- external,
65
- showExternalIcon = true,
66
- "aria-label": ariaLabel,
67
65
  ...otherProps
68
66
  }, ref) {
69
- const intl = reactIntl.useIntl();
70
- const intlConfig = TablePaginationActions.useImperativeIntl(intl);
71
67
  const defaultIconLoader = /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" });
72
68
  const isDefaultLoading = loading && loadingPosition === void 0;
73
69
  const renderContent = () => {
@@ -89,11 +85,7 @@ function _Button({
89
85
  }
90
86
  return void 0;
91
87
  }
92
- if (position === "start") {
93
- return startIcon;
94
- } else {
95
- return endIcon || (external && showExternalIcon && otherProps.href ? /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.OpenInNewOutlined, {}) : void 0);
96
- }
88
+ return position === "start" ? startIcon : endIcon;
97
89
  };
98
90
  return /* @__PURE__ */ jsxRuntime.jsx(
99
91
  material.Button,
@@ -103,13 +95,6 @@ function _Button({
103
95
  endIcon: getIconForPosition("end"),
104
96
  ...otherProps,
105
97
  role: otherProps.href ? "link" : "button",
106
- ...otherProps.href && external && {
107
- target: "_blank",
108
- rel: "noopener noreferrer"
109
- },
110
- "aria-label": ariaLabel || (external && otherProps.href ? `${children == null ? void 0 : children.toString()} (${intlConfig.formatMessage({
111
- id: "c4r.button.opensInNewTab"
112
- })})` : void 0),
113
98
  ref,
114
99
  children: /* @__PURE__ */ jsxRuntime.jsx(TablePaginationActions.Typography, { variant: "inherit", color: "inherit", noWrap: true, component: "span", children: renderContent() })
115
100
  }
@@ -483,10 +468,10 @@ function ToggleButtonGroup({
483
468
  }
484
469
  const StyledMenu = material.styled(material.Menu, {
485
470
  shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
486
- })(({ theme, extended, width, height }) => ({
471
+ })(({ extended, width, height }) => ({
487
472
  ...extended && {
488
473
  ".MuiMenuItem-root": {
489
- minHeight: theme.spacing(6)
474
+ minHeight: TablePaginationActions.MENU_ITEM_SIZE_EXTENDED
490
475
  }
491
476
  },
492
477
  ...width && {
@@ -526,10 +511,10 @@ function _Menu({ extended, width, height, MenuListProps, ...otherProps }, ref) {
526
511
  const Menu$1 = React.forwardRef(_Menu);
527
512
  const StyledMenuList = material.styled(material.MenuList, {
528
513
  shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
529
- })(({ theme, extended, width, height }) => ({
514
+ })(({ extended, width, height }) => ({
530
515
  ...extended && {
531
516
  ".MuiMenuItem-root": {
532
- minHeight: theme.spacing(6)
517
+ minHeight: TablePaginationActions.MENU_ITEM_SIZE_EXTENDED
533
518
  }
534
519
  },
535
520
  "&.MuiList-root": {
@@ -560,7 +545,8 @@ function _MenuList({ extended, width, height, ...otherProps }, ref) {
560
545
  }
561
546
  const MenuList = React.forwardRef(_MenuList);
562
547
  const StyledMenuItem$1 = material.styled(MenuItem.MenuItem)(() => ({
563
- marginTop: "0 !important"
548
+ marginTop: "0 !important",
549
+ marginBottom: "0 !important"
564
550
  }));
565
551
  const LinkFilter = material.styled(material.Link)(
566
552
  ({ disabled, theme }) => ({
@@ -800,12 +786,20 @@ function _MultipleSelectField({
800
786
  },
801
787
  children: [
802
788
  showFilters && /* @__PURE__ */ jsxRuntime.jsx(
803
- MenuItemFilter,
789
+ material.Box,
804
790
  {
805
- areAllSelected,
806
- areAnySelected,
807
- selectAll,
808
- selectAllDisabled
791
+ sx: {
792
+ mb: 1
793
+ },
794
+ children: /* @__PURE__ */ jsxRuntime.jsx(
795
+ MenuItemFilter,
796
+ {
797
+ areAllSelected,
798
+ areAnySelected,
799
+ selectAll,
800
+ selectAllDisabled
801
+ }
802
+ )
809
803
  }
810
804
  ),
811
805
  options == null ? void 0 : options.map((option) => {
@@ -1139,7 +1133,40 @@ const getDefaultOptionLabel = (option) => {
1139
1133
  const createOptionWithMultiple = (option, multiple) => {
1140
1134
  return typeof option !== "object" || option === null ? { value: option, multiple } : { ...option, multiple };
1141
1135
  };
1142
- const getDefaultLimitTagsText = (more) => /* @__PURE__ */ jsxRuntime.jsx("span", { "data-testid": "more-options-tag", children: `+${more}` });
1136
+ const getDefaultLimitTagsText = (more) => /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-testid": "more-options-tag", children: [
1137
+ "+",
1138
+ more
1139
+ ] });
1140
+ function createCounterRenderTags(counterText = "selected", options = [], size = "small", getOptionLabel = getDefaultOptionLabel) {
1141
+ const CounterRenderTags = (value) => {
1142
+ if (value.length === 0) {
1143
+ return null;
1144
+ }
1145
+ const totalCount = options.length;
1146
+ const selectedCount = value.length;
1147
+ let text;
1148
+ if (selectedCount === totalCount && totalCount > 0) {
1149
+ text = `All ${counterText}`;
1150
+ } else if (selectedCount === 1) {
1151
+ text = getOptionLabel(value[0]);
1152
+ } else {
1153
+ text = `${selectedCount} ${counterText}`;
1154
+ }
1155
+ return /* @__PURE__ */ jsxRuntime.jsx(
1156
+ TablePaginationActions.Typography,
1157
+ {
1158
+ variant: size === "small" ? "body2" : "body1",
1159
+ component: "span",
1160
+ "data-testid": "counter-tag",
1161
+ sx: {
1162
+ ml: 1
1163
+ },
1164
+ children: text
1165
+ }
1166
+ );
1167
+ };
1168
+ return CounterRenderTags;
1169
+ }
1143
1170
  function useAutocompleteRenderOption() {
1144
1171
  const renderOption = (props, option, state, getOptionLabel, customIcon) => {
1145
1172
  const {
@@ -1281,7 +1308,8 @@ function useMultipleAutocomplete({
1281
1308
  options,
1282
1309
  value,
1283
1310
  onChange,
1284
- getOptionLabel
1311
+ getOptionLabel,
1312
+ size
1285
1313
  }) {
1286
1314
  const [multipleValue, setMultipleValue] = React.useState(
1287
1315
  Array.isArray(value) ? value : value ? [value] : []
@@ -1316,13 +1344,20 @@ function useMultipleAutocomplete({
1316
1344
  getOptionLabel
1317
1345
  );
1318
1346
  };
1347
+ const getCounterRenderTags = () => createCounterRenderTags(
1348
+ "selected",
1349
+ options,
1350
+ size,
1351
+ getOptionLabel ? (option) => getOptionLabel(option) : void 0
1352
+ );
1319
1353
  return {
1320
1354
  multipleValue,
1321
1355
  allSelected,
1322
1356
  someSelected,
1323
1357
  handleSelectAll,
1324
1358
  handleChange,
1325
- multipleRenderOption
1359
+ multipleRenderOption,
1360
+ getCounterRenderTags
1326
1361
  };
1327
1362
  }
1328
1363
  function _ListboxWithFilter({
@@ -1332,15 +1367,53 @@ function _ListboxWithFilter({
1332
1367
  someSelected,
1333
1368
  handleSelectAll = () => void 0,
1334
1369
  multiple,
1370
+ extended,
1371
+ itemHeight,
1372
+ maxListHeight = TablePaginationActions.MENU_LIST_MAX_SIZE,
1335
1373
  ...otherProps
1336
1374
  }, ref) {
1375
+ const childrenArray = React.useMemo(() => {
1376
+ if (Array.isArray(children)) {
1377
+ return children;
1378
+ }
1379
+ return children ? [children] : [];
1380
+ }, [children]);
1381
+ const defaultItemHeight = itemHeight ?? (extended ? TablePaginationActions.MENU_ITEM_SIZE_EXTENDED : TablePaginationActions.MENU_ITEM_SIZE_DEFAULT);
1382
+ const listboxHeight = React.useMemo(() => {
1383
+ const filterHeight = showFilters && multiple ? TablePaginationActions.MENU_ITEM_SIZE_EXTENDED : 0;
1384
+ const availableHeight = maxListHeight - filterHeight;
1385
+ const calculatedHeight = Math.min(
1386
+ childrenArray.length * defaultItemHeight,
1387
+ availableHeight
1388
+ );
1389
+ return Math.max(calculatedHeight, defaultItemHeight + 8);
1390
+ }, [
1391
+ showFilters,
1392
+ multiple,
1393
+ maxListHeight,
1394
+ childrenArray.length,
1395
+ defaultItemHeight
1396
+ ]);
1397
+ const renderItem = ({
1398
+ index,
1399
+ style
1400
+ }) => {
1401
+ const child = childrenArray[index];
1402
+ if (!child) return null;
1403
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style, children: child });
1404
+ };
1337
1405
  return /* @__PURE__ */ jsxRuntime.jsxs(
1338
1406
  "ul",
1339
1407
  {
1340
1408
  ref,
1341
1409
  ...otherProps,
1342
1410
  role: "listbox",
1411
+ "data-list-height": listboxHeight,
1412
+ "data-item-height": defaultItemHeight,
1343
1413
  "aria-multiselectable": multiple,
1414
+ style: {
1415
+ maxHeight: maxListHeight + defaultItemHeight
1416
+ },
1344
1417
  children: [
1345
1418
  showFilters && multiple && /* @__PURE__ */ jsxRuntime.jsx(
1346
1419
  MenuItemFilter,
@@ -1350,7 +1423,16 @@ function _ListboxWithFilter({
1350
1423
  selectAll: handleSelectAll
1351
1424
  }
1352
1425
  ),
1353
- children
1426
+ /* @__PURE__ */ jsxRuntime.jsx(
1427
+ reactWindow.FixedSizeList,
1428
+ {
1429
+ height: listboxHeight,
1430
+ width: "100%",
1431
+ itemCount: childrenArray.length,
1432
+ itemSize: defaultItemHeight,
1433
+ children: renderItem
1434
+ }
1435
+ )
1354
1436
  ]
1355
1437
  }
1356
1438
  );
@@ -1365,10 +1447,15 @@ function _CreatableAutocomplete({
1365
1447
  disabled,
1366
1448
  loading,
1367
1449
  showFilters,
1450
+ showCounter = false,
1368
1451
  options = [],
1369
1452
  value,
1370
1453
  onChange,
1371
1454
  getLimitTagsText,
1455
+ renderTags,
1456
+ itemHeight,
1457
+ maxListHeight,
1458
+ extended,
1372
1459
  ...props
1373
1460
  }, ref) {
1374
1461
  const { freeSolo = true, ...otherProps } = props;
@@ -1377,11 +1464,14 @@ function _CreatableAutocomplete({
1377
1464
  allSelected,
1378
1465
  someSelected,
1379
1466
  handleSelectAll,
1380
- handleChange
1467
+ handleChange,
1468
+ getCounterRenderTags
1381
1469
  } = useMultipleAutocomplete({
1382
1470
  options,
1383
1471
  value,
1384
- onChange
1472
+ onChange,
1473
+ getOptionLabel,
1474
+ size: props.size
1385
1475
  });
1386
1476
  const {
1387
1477
  creatableFilterOptions,
@@ -1393,6 +1483,17 @@ function _CreatableAutocomplete({
1393
1483
  newItemIcon,
1394
1484
  multiple
1395
1485
  });
1486
+ const listboxProps = {
1487
+ showFilters,
1488
+ allSelected,
1489
+ someSelected,
1490
+ handleSelectAll,
1491
+ multiple,
1492
+ itemHeight,
1493
+ maxListHeight,
1494
+ extended
1495
+ };
1496
+ const finalRenderTags = showCounter && multiple && !renderTags ? getCounterRenderTags() : renderTags;
1396
1497
  return /* @__PURE__ */ jsxRuntime.jsx(
1397
1498
  material.Autocomplete,
1398
1499
  {
@@ -1404,18 +1505,13 @@ function _CreatableAutocomplete({
1404
1505
  filterOptions: creatableFilterOptions,
1405
1506
  getOptionLabel: creatableOptionLabel,
1406
1507
  renderOption: creatableRenderOption,
1508
+ renderTags: finalRenderTags,
1407
1509
  freeSolo,
1408
1510
  forcePopupIcon: true,
1409
1511
  multiple,
1410
1512
  disableCloseOnSelect: disableCloseOnSelect ?? multiple,
1411
1513
  ListboxComponent: ListboxWithFilter,
1412
- ListboxProps: {
1413
- showFilters,
1414
- allSelected,
1415
- someSelected,
1416
- handleSelectAll,
1417
- multiple
1418
- },
1514
+ ListboxProps: listboxProps,
1419
1515
  getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
1420
1516
  disabled: disabled || loading,
1421
1517
  popupIcon: loading ? /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" }) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}),
@@ -1430,11 +1526,16 @@ function _MultipleAutocomplete({
1430
1526
  disabled,
1431
1527
  loading,
1432
1528
  showFilters,
1529
+ showCounter = false,
1433
1530
  options,
1434
1531
  value,
1435
1532
  onChange,
1436
1533
  getOptionLabel,
1437
1534
  getLimitTagsText,
1535
+ renderTags,
1536
+ itemHeight,
1537
+ maxListHeight,
1538
+ extended,
1438
1539
  ...props
1439
1540
  }, ref) {
1440
1541
  const {
@@ -1443,13 +1544,26 @@ function _MultipleAutocomplete({
1443
1544
  someSelected,
1444
1545
  handleSelectAll,
1445
1546
  handleChange,
1446
- multipleRenderOption
1547
+ multipleRenderOption,
1548
+ getCounterRenderTags
1447
1549
  } = useMultipleAutocomplete({
1448
1550
  options,
1449
1551
  value,
1450
1552
  onChange,
1451
- getOptionLabel
1553
+ getOptionLabel,
1554
+ size: props.size
1452
1555
  });
1556
+ const listboxProps = {
1557
+ showFilters,
1558
+ allSelected,
1559
+ someSelected,
1560
+ handleSelectAll,
1561
+ multiple: true,
1562
+ itemHeight,
1563
+ maxListHeight,
1564
+ extended
1565
+ };
1566
+ const finalRenderTags = showCounter && !renderTags ? getCounterRenderTags() : renderTags;
1453
1567
  return /* @__PURE__ */ jsxRuntime.jsx(
1454
1568
  material.Autocomplete,
1455
1569
  {
@@ -1460,14 +1574,9 @@ function _MultipleAutocomplete({
1460
1574
  onChange: handleChange,
1461
1575
  getOptionLabel,
1462
1576
  renderOption: renderOption ?? multipleRenderOption,
1577
+ renderTags: finalRenderTags,
1463
1578
  ListboxComponent: ListboxWithFilter,
1464
- ListboxProps: {
1465
- showFilters,
1466
- allSelected,
1467
- someSelected,
1468
- handleSelectAll,
1469
- multiple: true
1470
- },
1579
+ ListboxProps: listboxProps,
1471
1580
  multiple: true,
1472
1581
  getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
1473
1582
  disableCloseOnSelect,
@@ -4701,7 +4810,6 @@ exports.TablePaginationActions = TablePaginationActions.TablePaginationActions;
4701
4810
  exports.Typography = TablePaginationActions.Typography;
4702
4811
  exports.Alert = Alert$1.Alert;
4703
4812
  exports.IconButton = Alert$1.IconButton;
4704
- exports.Link = Alert$1.Link;
4705
4813
  exports.MenuItem = MenuItem.MenuItem;
4706
4814
  exports.AccordionGroup = AccordionGroup;
4707
4815
  exports.AppBar = AppBar;