@carto/meridian-ds 1.4.8 → 1.5.0-alpha-virtual-autocomplete.2

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 (53) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/{Alert-BiOR9aar.cjs → Alert-BzEgeyQJ.cjs} +1 -1
  3. package/dist/{Alert-CywtIMOj.js → Alert-CnaTtNJd.js} +1 -1
  4. package/dist/{MenuItem-CXnnE5lK.js → MenuItem-D6wJym7Z.js} +9 -5
  5. package/dist/{MenuItem-Br2jY2lt.cjs → MenuItem-lAxlHrDp.cjs} +9 -5
  6. package/dist/{OpenDiagonallyRight-BrRyCV4Q.cjs → OpenDiagonallyRight-CM1tojUq.cjs} +27 -0
  7. package/dist/{OpenDiagonallyRight-5HZXh46V.js → OpenDiagonallyRight-CSm5GYYJ.js} +27 -0
  8. package/dist/{TablePaginationActions-KpTvhN4Y.js → TablePaginationActions-Cz5Hbi6N.js} +9 -1
  9. package/dist/{TablePaginationActions-CFGXm44W.cjs → TablePaginationActions-mbbjzV6Y.cjs} +8 -0
  10. package/dist/components/index.cjs +426 -52
  11. package/dist/components/index.js +432 -58
  12. package/dist/custom-icons/index.cjs +29 -55
  13. package/dist/custom-icons/index.js +29 -55
  14. package/dist/theme/index.cjs +13 -9
  15. package/dist/theme/index.js +14 -10
  16. package/dist/types/components/atoms/SplitButton.d.ts +21 -0
  17. package/dist/types/components/atoms/SplitButton.d.ts.map +1 -0
  18. package/dist/types/components/atoms/index.d.ts +2 -0
  19. package/dist/types/components/atoms/index.d.ts.map +1 -1
  20. package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts +1 -1
  21. package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts.map +1 -1
  22. package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts +21 -3
  23. package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts.map +1 -1
  24. package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts +1 -1
  25. package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts.map +1 -1
  26. package/dist/types/components/molecules/Autocomplete/index.d.ts +1 -0
  27. package/dist/types/components/molecules/Autocomplete/index.d.ts.map +1 -1
  28. package/dist/types/components/molecules/Autocomplete/types.d.ts +59 -7
  29. package/dist/types/components/molecules/Autocomplete/types.d.ts.map +1 -1
  30. package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts +26 -1
  31. package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts.map +1 -1
  32. package/dist/types/components/molecules/Autocomplete/utils.d.ts +49 -0
  33. package/dist/types/components/molecules/Autocomplete/utils.d.ts.map +1 -1
  34. package/dist/types/components/molecules/Menu/Menu.d.ts.map +1 -1
  35. package/dist/types/components/molecules/Menu/MenuItem.d.ts.map +1 -1
  36. package/dist/types/components/molecules/Menu/MenuItemFilter.d.ts.map +1 -1
  37. package/dist/types/components/molecules/Menu/MenuList.d.ts.map +1 -1
  38. package/dist/types/components/molecules/MultipleSelectField/MultipleSelectField.d.ts.map +1 -1
  39. package/dist/types/components/organisms/CodeArea/CodeAreaInput.d.ts.map +1 -1
  40. package/dist/types/components/organisms/CodeArea/CodeAreaTheme.d.ts.map +1 -1
  41. package/dist/types/components/organisms/CodeArea/index.d.ts +1 -0
  42. package/dist/types/components/organisms/CodeArea/index.d.ts.map +1 -1
  43. package/dist/types/components/organisms/CodeArea/types.d.ts +4 -0
  44. package/dist/types/components/organisms/CodeArea/types.d.ts.map +1 -1
  45. package/dist/types/components/organisms/CodeArea/utils.d.ts +34 -0
  46. package/dist/types/components/organisms/CodeArea/utils.d.ts.map +1 -1
  47. package/dist/types/theme/sections/components/forms.d.ts.map +1 -1
  48. package/dist/types/theme/sections/components/navigation.d.ts.map +1 -1
  49. package/dist/types/theme/theme-constants.d.ts +4 -0
  50. package/dist/types/theme/theme-constants.d.ts.map +1 -1
  51. package/dist/widgets/index.cjs +2 -2
  52. package/dist/widgets/index.js +2 -2
  53. package/package.json +1 -1
@@ -1,21 +1,22 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { forwardRef, useState, useEffect, useMemo, useRef, Fragment as Fragment$1, useImperativeHandle, useCallback } from "react";
3
- import { styled, Box, Button as Button$1, CircularProgress, TextField, InputAdornment, IconButton, Tooltip, Select, MenuItem, FormControl, InputLabel, FormHelperText, ToggleButtonGroup as ToggleButtonGroup$1, Menu as Menu$2, MenuList as MenuList$1, 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, Paper, 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";
2
+ import React, { forwardRef, useState, useRef, useEffect, useMemo, Fragment as Fragment$1, useImperativeHandle, useCallback } from "react";
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, f as MENU_ITEM_SIZE_EXTENDED, 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-CY_wMVJT.js";
7
+ import { A as ArrowUp, O as OpenDiagonallyRight, C as CloseDiagonallyRight } from "../OpenDiagonallyRight-CSm5GYYJ.js";
6
8
  import { useIntl } from "react-intl";
7
9
  import { VisibilityOffOutlined, VisibilityOutlined, Cancel, AddCircleOutlineOutlined, ContentCopyOutlined, CloseOutlined, MenuOutlined, HelpOutline, TodayOutlined, MoreVertOutlined, ErrorOutline, Check } from "@mui/icons-material";
8
- 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";
9
11
  import "cartocolor";
10
- import { M as MenuItem$1 } from "../MenuItem-CXnnE5lK.js";
11
- import { A as ArrowDown } from "../ArrowDown-CY_wMVJT.js";
12
+ import { M as MenuItem$1 } from "../MenuItem-D6wJym7Z.js";
13
+ import { FixedSizeList } from "react-window";
12
14
  import { DatePicker as DatePicker$1 } from "@mui/x-date-pickers/DatePicker";
13
15
  import { PickersDay as PickersDay$1 } from "@mui/x-date-pickers";
14
16
  import { TimePicker as TimePicker$1 } from "@mui/x-date-pickers/TimePicker";
15
17
  import { DateTimePicker as DateTimePicker$1 } from "@mui/x-date-pickers/DateTimePicker";
16
- import { O as OpenDiagonallyRight, C as CloseDiagonallyRight } from "../OpenDiagonallyRight-5HZXh46V.js";
17
18
  import { Controlled, UnControlled } from "react-codemirror2";
18
- import { lime, blue, purple, teal, red, indigo } from "@mui/material/colors";
19
+ import { lime, blue, purple, teal, red, green, indigo } from "@mui/material/colors";
19
20
  import "codemirror/lib/codemirror.css";
20
21
  import "codemirror/lib/codemirror.js";
21
22
  import "codemirror/mode/sql/sql.js";
@@ -38,7 +39,7 @@ import "codemirror/addon/fold/xml-fold.js";
38
39
  import "codemirror/addon/fold/indent-fold.js";
39
40
  import "codemirror/addon/fold/markdown-fold.js";
40
41
  import "codemirror/addon/fold/comment-fold.js";
41
- import ClickAwayListener from "@mui/material/ClickAwayListener";
42
+ import ClickAwayListener$1 from "@mui/material/ClickAwayListener";
42
43
  const IndicatorIcon = styled(Box)({
43
44
  position: "absolute",
44
45
  top: 0,
@@ -99,6 +100,102 @@ function _Button({
99
100
  );
100
101
  }
101
102
  const Button = forwardRef(_Button);
103
+ const ButtonGroup = styled(ButtonGroup$1)(({ theme, size }) => ({
104
+ "& .MuiButton-root:last-child": {
105
+ padding: 0,
106
+ minWidth: size === "small" ? theme.spacing(3) : size === "large" ? theme.spacing(6) : theme.spacing(4)
107
+ }
108
+ }));
109
+ function SplitButton({
110
+ options,
111
+ disabled,
112
+ loading,
113
+ loadingPosition,
114
+ onClick,
115
+ variant,
116
+ size,
117
+ color,
118
+ ...otherProps
119
+ }) {
120
+ var _a;
121
+ const [open, setOpen] = useState(false);
122
+ const anchorRef = useRef(null);
123
+ const [selectedIndex, setSelectedIndex] = useState(0);
124
+ const handleClick = () => {
125
+ onClick(options[selectedIndex]);
126
+ };
127
+ const handleMenuItemClick = (_, index) => {
128
+ setSelectedIndex(index);
129
+ setOpen(false);
130
+ };
131
+ const handleToggle = () => {
132
+ setOpen((prevOpen) => !prevOpen);
133
+ };
134
+ const handleClose = (event) => {
135
+ var _a2;
136
+ if ((_a2 = anchorRef.current) == null ? void 0 : _a2.contains(event.target)) {
137
+ return;
138
+ }
139
+ setOpen(false);
140
+ };
141
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
142
+ /* @__PURE__ */ jsxs(
143
+ ButtonGroup,
144
+ {
145
+ "data-name": "split-button",
146
+ ref: anchorRef,
147
+ variant,
148
+ size,
149
+ color,
150
+ ...otherProps,
151
+ children: [
152
+ /* @__PURE__ */ jsx(
153
+ Button,
154
+ {
155
+ disabled,
156
+ loading,
157
+ loadingPosition,
158
+ onClick: handleClick,
159
+ children: (_a = options[selectedIndex]) == null ? void 0 : _a.label
160
+ }
161
+ ),
162
+ /* @__PURE__ */ jsx(Button, { disabled: loading || disabled, onClick: handleToggle, children: open ? /* @__PURE__ */ jsx(ArrowUp, {}) : /* @__PURE__ */ jsx(ArrowDown, {}) })
163
+ ]
164
+ }
165
+ ),
166
+ /* @__PURE__ */ jsx(
167
+ Popper,
168
+ {
169
+ sx: { zIndex: 1 },
170
+ open,
171
+ anchorEl: anchorRef.current,
172
+ role: void 0,
173
+ transition: true,
174
+ disablePortal: true,
175
+ placement: "bottom-end",
176
+ children: ({ TransitionProps, placement }) => /* @__PURE__ */ jsx(
177
+ Grow,
178
+ {
179
+ ...TransitionProps,
180
+ style: {
181
+ transformOrigin: placement === "bottom" ? "center top" : "center bottom"
182
+ },
183
+ children: /* @__PURE__ */ jsx(Paper, { elevation: 8, children: /* @__PURE__ */ jsx(ClickAwayListener, { onClickAway: handleClose, children: /* @__PURE__ */ jsx(MenuList$1, { autoFocusItem: true, sx: { paddingY: 1 }, children: options.map((option, index) => /* @__PURE__ */ jsx(
184
+ MenuItem,
185
+ {
186
+ disabled: option.disabled,
187
+ selected: index === selectedIndex,
188
+ onClick: (event) => handleMenuItemClick(event, index),
189
+ children: option.label
190
+ },
191
+ option.label
192
+ )) }) }) })
193
+ }
194
+ )
195
+ }
196
+ )
197
+ ] });
198
+ }
102
199
  const Root$5 = styled(Box)(({ theme }) => ({
103
200
  display: "flex",
104
201
  alignItems: "center",
@@ -382,10 +479,10 @@ function ToggleButtonGroup({
382
479
  }
383
480
  const StyledMenu = styled(Menu$2, {
384
481
  shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
385
- })(({ theme, extended, width, height }) => ({
482
+ })(({ extended, width, height }) => ({
386
483
  ...extended && {
387
484
  ".MuiMenuItem-root": {
388
- minHeight: theme.spacing(6)
485
+ minHeight: MENU_ITEM_SIZE_EXTENDED
389
486
  }
390
487
  },
391
488
  ...width && {
@@ -425,10 +522,10 @@ function _Menu({ extended, width, height, MenuListProps, ...otherProps }, ref) {
425
522
  const Menu$1 = forwardRef(_Menu);
426
523
  const StyledMenuList = styled(MenuList$1, {
427
524
  shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
428
- })(({ theme, extended, width, height }) => ({
525
+ })(({ extended, width, height }) => ({
429
526
  ...extended && {
430
527
  ".MuiMenuItem-root": {
431
- minHeight: theme.spacing(6)
528
+ minHeight: MENU_ITEM_SIZE_EXTENDED
432
529
  }
433
530
  },
434
531
  "&.MuiList-root": {
@@ -459,7 +556,8 @@ function _MenuList({ extended, width, height, ...otherProps }, ref) {
459
556
  }
460
557
  const MenuList = forwardRef(_MenuList);
461
558
  const StyledMenuItem$1 = styled(MenuItem$1)(() => ({
462
- marginTop: "0 !important"
559
+ marginTop: "0 !important",
560
+ marginBottom: "0 !important"
463
561
  }));
464
562
  const LinkFilter = styled(Link)(
465
563
  ({ disabled, theme }) => ({
@@ -699,12 +797,20 @@ function _MultipleSelectField({
699
797
  },
700
798
  children: [
701
799
  showFilters && /* @__PURE__ */ jsx(
702
- MenuItemFilter,
800
+ Box,
703
801
  {
704
- areAllSelected,
705
- areAnySelected,
706
- selectAll,
707
- selectAllDisabled
802
+ sx: {
803
+ mb: 1
804
+ },
805
+ children: /* @__PURE__ */ jsx(
806
+ MenuItemFilter,
807
+ {
808
+ areAllSelected,
809
+ areAnySelected,
810
+ selectAll,
811
+ selectAllDisabled
812
+ }
813
+ )
708
814
  }
709
815
  ),
710
816
  options == null ? void 0 : options.map((option) => {
@@ -1038,7 +1144,55 @@ const getDefaultOptionLabel = (option) => {
1038
1144
  const createOptionWithMultiple = (option, multiple) => {
1039
1145
  return typeof option !== "object" || option === null ? { value: option, multiple } : { ...option, multiple };
1040
1146
  };
1041
- const getDefaultLimitTagsText = (more) => /* @__PURE__ */ jsx("span", { "data-testid": "more-options-tag", children: `+${more}` });
1147
+ const getDefaultLimitTagsText = (more) => /* @__PURE__ */ jsxs("span", { "data-testid": "more-options-tag", children: [
1148
+ "+",
1149
+ more
1150
+ ] });
1151
+ function createCounterRenderTags(formatCounter, options = [], size = "small", getOptionLabel = getDefaultOptionLabel) {
1152
+ const CounterRenderTags = (value) => {
1153
+ if (value.length === 0) {
1154
+ return null;
1155
+ }
1156
+ const selectedCount = value.length;
1157
+ const totalCount = options.length;
1158
+ const text = formatCounter({
1159
+ selectedCount,
1160
+ totalCount,
1161
+ selectedItems: value,
1162
+ allItems: options,
1163
+ getOptionLabel
1164
+ });
1165
+ return /* @__PURE__ */ jsx(
1166
+ Typography,
1167
+ {
1168
+ variant: size === "small" ? "body2" : "body1",
1169
+ component: "span",
1170
+ "data-testid": "counter-tag",
1171
+ sx: {
1172
+ ml: 1
1173
+ },
1174
+ children: text
1175
+ }
1176
+ );
1177
+ };
1178
+ return CounterRenderTags;
1179
+ }
1180
+ function createCounterFormatter(counterText, allText, showSingleItemText = true) {
1181
+ return ({
1182
+ selectedCount,
1183
+ totalCount,
1184
+ selectedItems,
1185
+ getOptionLabel
1186
+ }) => {
1187
+ if (selectedCount === totalCount && totalCount > 0) {
1188
+ return allText;
1189
+ } else if (selectedCount === 1 && showSingleItemText) {
1190
+ return getOptionLabel(selectedItems[0]);
1191
+ } else {
1192
+ return `${selectedCount} ${counterText}`;
1193
+ }
1194
+ };
1195
+ }
1042
1196
  function useAutocompleteRenderOption() {
1043
1197
  const renderOption = (props, option, state, getOptionLabel, customIcon) => {
1044
1198
  const {
@@ -1180,8 +1334,16 @@ function useMultipleAutocomplete({
1180
1334
  options,
1181
1335
  value,
1182
1336
  onChange,
1183
- getOptionLabel
1337
+ getOptionLabel,
1338
+ size,
1339
+ counterFormatter,
1340
+ counterText,
1341
+ allSelectedText
1184
1342
  }) {
1343
+ const intl = useIntl();
1344
+ const intlConfig = useImperativeIntl(intl);
1345
+ const defaultCounterText = counterText || intlConfig.formatMessage({ id: "c4r.form.selected" });
1346
+ const defaultAllSelectedText = allSelectedText || intlConfig.formatMessage({ id: "c4r.form.allSelected" });
1185
1347
  const [multipleValue, setMultipleValue] = useState(
1186
1348
  Array.isArray(value) ? value : value ? [value] : []
1187
1349
  );
@@ -1215,13 +1377,23 @@ function useMultipleAutocomplete({
1215
1377
  getOptionLabel
1216
1378
  );
1217
1379
  };
1380
+ const getCounterRenderTags = () => {
1381
+ const formatter = counterFormatter || createCounterFormatter(defaultCounterText, defaultAllSelectedText);
1382
+ return createCounterRenderTags(
1383
+ formatter,
1384
+ options,
1385
+ size,
1386
+ getOptionLabel ? (option) => getOptionLabel(option) : void 0
1387
+ );
1388
+ };
1218
1389
  return {
1219
1390
  multipleValue,
1220
1391
  allSelected,
1221
1392
  someSelected,
1222
1393
  handleSelectAll,
1223
1394
  handleChange,
1224
- multipleRenderOption
1395
+ multipleRenderOption,
1396
+ getCounterRenderTags
1225
1397
  };
1226
1398
  }
1227
1399
  function _ListboxWithFilter({
@@ -1231,15 +1403,50 @@ function _ListboxWithFilter({
1231
1403
  someSelected,
1232
1404
  handleSelectAll = () => void 0,
1233
1405
  multiple,
1406
+ extended,
1407
+ itemHeight,
1408
+ maxListHeight = MENU_LIST_MAX_SIZE,
1234
1409
  ...otherProps
1235
1410
  }, ref) {
1411
+ const childrenArray = useMemo(() => {
1412
+ return React.Children.toArray(children);
1413
+ }, [children]);
1414
+ const defaultItemHeight = itemHeight ?? (extended ? MENU_ITEM_SIZE_EXTENDED : MENU_ITEM_SIZE_DEFAULT);
1415
+ const listboxHeight = useMemo(() => {
1416
+ const filterHeight = showFilters && multiple ? MENU_ITEM_SIZE_EXTENDED : 0;
1417
+ const availableHeight = maxListHeight - filterHeight;
1418
+ const calculatedHeight = Math.min(
1419
+ childrenArray.length * defaultItemHeight,
1420
+ availableHeight
1421
+ );
1422
+ return Math.max(calculatedHeight, defaultItemHeight + 8);
1423
+ }, [
1424
+ showFilters,
1425
+ multiple,
1426
+ maxListHeight,
1427
+ childrenArray.length,
1428
+ defaultItemHeight
1429
+ ]);
1430
+ const renderItem = ({
1431
+ index,
1432
+ style
1433
+ }) => {
1434
+ const child = childrenArray[index];
1435
+ if (!child) return null;
1436
+ return /* @__PURE__ */ jsx("div", { style, children: child });
1437
+ };
1236
1438
  return /* @__PURE__ */ jsxs(
1237
1439
  "ul",
1238
1440
  {
1239
1441
  ref,
1240
1442
  ...otherProps,
1241
1443
  role: "listbox",
1444
+ "data-list-height": listboxHeight,
1445
+ "data-item-height": defaultItemHeight,
1242
1446
  "aria-multiselectable": multiple,
1447
+ style: {
1448
+ maxHeight: maxListHeight + defaultItemHeight
1449
+ },
1243
1450
  children: [
1244
1451
  showFilters && multiple && /* @__PURE__ */ jsx(
1245
1452
  MenuItemFilter,
@@ -1249,7 +1456,16 @@ function _ListboxWithFilter({
1249
1456
  selectAll: handleSelectAll
1250
1457
  }
1251
1458
  ),
1252
- children
1459
+ /* @__PURE__ */ jsx(
1460
+ FixedSizeList,
1461
+ {
1462
+ height: listboxHeight,
1463
+ width: "100%",
1464
+ itemCount: childrenArray.length,
1465
+ itemSize: defaultItemHeight,
1466
+ children: renderItem
1467
+ }
1468
+ )
1253
1469
  ]
1254
1470
  }
1255
1471
  );
@@ -1264,10 +1480,18 @@ function _CreatableAutocomplete({
1264
1480
  disabled,
1265
1481
  loading,
1266
1482
  showFilters,
1483
+ showCounter = false,
1484
+ counterFormatter,
1485
+ counterText,
1486
+ allSelectedText,
1267
1487
  options = [],
1268
1488
  value,
1269
1489
  onChange,
1270
1490
  getLimitTagsText,
1491
+ renderTags,
1492
+ itemHeight,
1493
+ maxListHeight,
1494
+ extended,
1271
1495
  ...props
1272
1496
  }, ref) {
1273
1497
  const { freeSolo = true, ...otherProps } = props;
@@ -1276,11 +1500,17 @@ function _CreatableAutocomplete({
1276
1500
  allSelected,
1277
1501
  someSelected,
1278
1502
  handleSelectAll,
1279
- handleChange
1503
+ handleChange,
1504
+ getCounterRenderTags
1280
1505
  } = useMultipleAutocomplete({
1281
1506
  options,
1282
1507
  value,
1283
- onChange
1508
+ onChange,
1509
+ getOptionLabel,
1510
+ size: props.size,
1511
+ counterFormatter,
1512
+ counterText,
1513
+ allSelectedText
1284
1514
  });
1285
1515
  const {
1286
1516
  creatableFilterOptions,
@@ -1292,6 +1522,17 @@ function _CreatableAutocomplete({
1292
1522
  newItemIcon,
1293
1523
  multiple
1294
1524
  });
1525
+ const listboxProps = {
1526
+ showFilters,
1527
+ allSelected,
1528
+ someSelected,
1529
+ handleSelectAll,
1530
+ multiple,
1531
+ itemHeight,
1532
+ maxListHeight,
1533
+ extended
1534
+ };
1535
+ const finalRenderTags = showCounter && multiple && !renderTags ? getCounterRenderTags() : renderTags;
1295
1536
  return /* @__PURE__ */ jsx(
1296
1537
  Autocomplete$1,
1297
1538
  {
@@ -1303,18 +1544,13 @@ function _CreatableAutocomplete({
1303
1544
  filterOptions: creatableFilterOptions,
1304
1545
  getOptionLabel: creatableOptionLabel,
1305
1546
  renderOption: creatableRenderOption,
1547
+ renderTags: finalRenderTags,
1306
1548
  freeSolo,
1307
1549
  forcePopupIcon: true,
1308
1550
  multiple,
1309
1551
  disableCloseOnSelect: disableCloseOnSelect ?? multiple,
1310
1552
  ListboxComponent: ListboxWithFilter,
1311
- ListboxProps: {
1312
- showFilters,
1313
- allSelected,
1314
- someSelected,
1315
- handleSelectAll,
1316
- multiple
1317
- },
1553
+ ListboxProps: listboxProps,
1318
1554
  getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
1319
1555
  disabled: disabled || loading,
1320
1556
  popupIcon: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: 18, color: "inherit" }) : /* @__PURE__ */ jsx(ArrowDown, {}),
@@ -1329,11 +1565,19 @@ function _MultipleAutocomplete({
1329
1565
  disabled,
1330
1566
  loading,
1331
1567
  showFilters,
1568
+ showCounter = false,
1569
+ counterFormatter,
1570
+ counterText,
1571
+ allSelectedText,
1332
1572
  options,
1333
1573
  value,
1334
1574
  onChange,
1335
1575
  getOptionLabel,
1336
1576
  getLimitTagsText,
1577
+ renderTags,
1578
+ itemHeight,
1579
+ maxListHeight,
1580
+ extended,
1337
1581
  ...props
1338
1582
  }, ref) {
1339
1583
  const {
@@ -1342,13 +1586,29 @@ function _MultipleAutocomplete({
1342
1586
  someSelected,
1343
1587
  handleSelectAll,
1344
1588
  handleChange,
1345
- multipleRenderOption
1589
+ multipleRenderOption,
1590
+ getCounterRenderTags
1346
1591
  } = useMultipleAutocomplete({
1347
1592
  options,
1348
1593
  value,
1349
1594
  onChange,
1350
- getOptionLabel
1595
+ getOptionLabel,
1596
+ size: props.size,
1597
+ counterFormatter,
1598
+ counterText,
1599
+ allSelectedText
1351
1600
  });
1601
+ const listboxProps = {
1602
+ showFilters,
1603
+ allSelected,
1604
+ someSelected,
1605
+ handleSelectAll,
1606
+ multiple: true,
1607
+ itemHeight,
1608
+ maxListHeight,
1609
+ extended
1610
+ };
1611
+ const finalRenderTags = showCounter && !renderTags ? getCounterRenderTags() : renderTags;
1352
1612
  return /* @__PURE__ */ jsx(
1353
1613
  Autocomplete$1,
1354
1614
  {
@@ -1359,14 +1619,9 @@ function _MultipleAutocomplete({
1359
1619
  onChange: handleChange,
1360
1620
  getOptionLabel,
1361
1621
  renderOption: renderOption ?? multipleRenderOption,
1622
+ renderTags: finalRenderTags,
1362
1623
  ListboxComponent: ListboxWithFilter,
1363
- ListboxProps: {
1364
- showFilters,
1365
- allSelected,
1366
- someSelected,
1367
- handleSelectAll,
1368
- multiple: true
1369
- },
1624
+ ListboxProps: listboxProps,
1370
1625
  multiple: true,
1371
1626
  getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
1372
1627
  disableCloseOnSelect,
@@ -3113,8 +3368,9 @@ const CodeAreaTheme = styled(Box, {
3113
3368
  right: 0,
3114
3369
  zIndex: 1
3115
3370
  },
3116
- "& .pre.CodeMirror-line, .CodeMirror pre.CodeMirror-line-like, & .cm-bracket": {
3117
- color: theme.palette.text.primary
3371
+ ".CodeMirror pre.CodeMirror-line, .CodeMirror pre.CodeMirror-line-like, & .cm-bracket": {
3372
+ color: theme.palette.text.primary,
3373
+ fontVariantLigatures: "no-common-ligatures"
3118
3374
  },
3119
3375
  "& .CodeMirror pre.CodeMirror-placeholder": {
3120
3376
  color: theme.palette.text.hint
@@ -3132,7 +3388,7 @@ const CodeAreaTheme = styled(Box, {
3132
3388
  "& .cm-number, & .cm-property, & .cm-builtin": {
3133
3389
  color: red[700]
3134
3390
  },
3135
- "& .cm-comment": {
3391
+ "& .cm-comment, & .cm-quote": {
3136
3392
  color: theme.palette.text.secondary
3137
3393
  },
3138
3394
  "& .cm-variable": {
@@ -3141,9 +3397,18 @@ const CodeAreaTheme = styled(Box, {
3141
3397
  "& .cm-variable-2": {
3142
3398
  color: theme.palette.text.primary
3143
3399
  },
3144
- "& .cm-punctuation, & .cm-def, ": {
3400
+ "& .cm-punctuation, & .cm-def": {
3145
3401
  color: blue[800]
3146
3402
  },
3403
+ "& .cm-image-alt-text, & .cm-link": {
3404
+ color: green[800],
3405
+ textDecoration: "none"
3406
+ },
3407
+ // Custom inline link styling .cm-inline-url
3408
+ "& .cm-url, & .cm-inline-url": {
3409
+ color: blue[800],
3410
+ textDecoration: "none"
3411
+ },
3147
3412
  "& .cm-variable-3, & .cm-type": {
3148
3413
  color: indigo[800]
3149
3414
  },
@@ -3157,20 +3422,23 @@ const CodeAreaTheme = styled(Box, {
3157
3422
  "& .CodeMirror-selected": {
3158
3423
  background: blue[800]
3159
3424
  },
3160
- "& .cm-header-1": {
3161
- fontSize: theme.typography.h2.fontSize
3425
+ "& .cm-header": {
3426
+ color: red[700],
3427
+ ...theme.typography.code3,
3428
+ fontWeight: theme.typography.fontWeightBold
3162
3429
  },
3163
- "& .cm-header-2": {
3164
- fontSize: theme.typography.h3.fontSize
3430
+ "& .cm-header-4, & .cm-header-5, & .cm-header-6": {
3431
+ fontWeight: theme.typography.fontWeightRegular
3165
3432
  },
3166
- "& .cm-header-3": {
3167
- fontSize: theme.typography.h4.fontSize
3168
- },
3169
- "& .cm-header-4": {
3170
- fontSize: theme.typography.h5.fontSize
3433
+ // Custom inline code styling
3434
+ "& .cm-inline-code": {
3435
+ backgroundColor: theme.palette.black[4],
3436
+ color: purple[500]
3171
3437
  },
3172
- "& .cm-header-5": {
3173
- fontSize: theme.typography.h6.fontSize
3438
+ // Custom code block styling
3439
+ "& .cm-code-block": {
3440
+ backgroundColor: theme.palette.black[4],
3441
+ marginRight: theme.spacing(2)
3174
3442
  },
3175
3443
  ...size === "small" && {
3176
3444
  "& .CodeMirror": {
@@ -3206,6 +3474,100 @@ function findCodeAreaControlCodeOccurrences(content) {
3206
3474
  }
3207
3475
  return matches;
3208
3476
  }
3477
+ const editorMarkers = /* @__PURE__ */ new WeakMap();
3478
+ function clearMarkersForClass(editor, className) {
3479
+ var _a, _b;
3480
+ const markers = (_a = editorMarkers.get(editor)) == null ? void 0 : _a.get(className);
3481
+ if (!markers) return;
3482
+ markers.forEach((marker) => {
3483
+ if (marker.find()) {
3484
+ marker.clear();
3485
+ }
3486
+ });
3487
+ (_b = editorMarkers.get(editor)) == null ? void 0 : _b.delete(className);
3488
+ }
3489
+ function storeMarkersForClass(editor, className, markers) {
3490
+ if (!editorMarkers.has(editor)) {
3491
+ editorMarkers.set(editor, /* @__PURE__ */ new Map());
3492
+ }
3493
+ const editorMap = editorMarkers.get(editor);
3494
+ if (editorMap) {
3495
+ editorMap.set(className, markers);
3496
+ }
3497
+ }
3498
+ function CodeAreaMarkTextPattern(editor, pattern, options, excludePatterns) {
3499
+ const { className } = options;
3500
+ clearMarkersForClass(editor, className);
3501
+ const doc = editor.getDoc();
3502
+ const content = doc.getValue();
3503
+ const excludeRanges = (excludePatterns == null ? void 0 : excludePatterns.flatMap(
3504
+ (excludePattern) => Array.from(content.matchAll(excludePattern), (match) => ({
3505
+ start: match.index,
3506
+ end: match.index + match[0].length
3507
+ }))
3508
+ )) ?? [];
3509
+ const markers = Array.from(content.matchAll(pattern)).filter((match) => {
3510
+ if (excludeRanges.some(
3511
+ (range) => match.index >= range.start && match.index < range.end
3512
+ )) {
3513
+ return false;
3514
+ }
3515
+ return !match[1] || match[1].trim().length > 0;
3516
+ }).map((match) => {
3517
+ const startPos = doc.posFromIndex(match.index);
3518
+ const endPos = doc.posFromIndex(match.index + match[0].length);
3519
+ return editor.markText(startPos, endPos, {
3520
+ atomic: false,
3521
+ clearOnEnter: false,
3522
+ ...options
3523
+ });
3524
+ });
3525
+ if (markers.length > 0) {
3526
+ storeMarkersForClass(editor, className, markers);
3527
+ }
3528
+ }
3529
+ function markInlineCode(editor, className = "cm-inline-code") {
3530
+ const inlineCodePattern = /`([^`\n\r]+)`/g;
3531
+ const codeBlockPattern = /```[\s\S]*?```/g;
3532
+ CodeAreaMarkTextPattern(
3533
+ editor,
3534
+ inlineCodePattern,
3535
+ {
3536
+ className
3537
+ },
3538
+ [codeBlockPattern]
3539
+ );
3540
+ }
3541
+ function markInlineLinks(editor, className = "cm-inline-url") {
3542
+ const inlineLinkPattern = /<((?:https?:\/\/[^\s<>]+)|(?:[^\s<>@]+@[^\s<>@]+\.[^\s<>@]+))>/g;
3543
+ const codeBlockPattern = /```[\s\S]*?```/g;
3544
+ CodeAreaMarkTextPattern(
3545
+ editor,
3546
+ inlineLinkPattern,
3547
+ {
3548
+ className
3549
+ },
3550
+ [codeBlockPattern]
3551
+ );
3552
+ }
3553
+ function markCodeBlocks(editor, className = "cm-code-block") {
3554
+ const doc = editor.getDoc();
3555
+ const content = doc.getValue();
3556
+ const lineCount = content.split("\n").length;
3557
+ for (let i = 0; i < lineCount; i++) {
3558
+ ["background", "wrap", "text"].forEach(
3559
+ (where) => editor.removeLineClass(i, where, className)
3560
+ );
3561
+ }
3562
+ const codeBlockPattern = /```[\s\S]*?(?:```|$)/g;
3563
+ Array.from(content.matchAll(codeBlockPattern)).forEach((match) => {
3564
+ const startPos = doc.posFromIndex(match.index);
3565
+ const endPos = doc.posFromIndex(match.index + match[0].length);
3566
+ for (let lineNum = startPos.line; lineNum <= endPos.line; lineNum++) {
3567
+ editor.addLineClass(lineNum, "wrap", className);
3568
+ }
3569
+ });
3570
+ }
3209
3571
  function foldCode(editor, { from, to }) {
3210
3572
  editor.foldCode(
3211
3573
  0,
@@ -3246,6 +3608,7 @@ function CodeAreaInput({
3246
3608
  const codeMirrorOptions = {
3247
3609
  mode: "sql",
3248
3610
  theme: "light",
3611
+ addModeClass: true,
3249
3612
  lineNumbers: true,
3250
3613
  lineWrapping: true,
3251
3614
  extraKeys: { "Ctrl-Space": "autocomplete" },
@@ -3276,6 +3639,13 @@ function CodeAreaInput({
3276
3639
  }
3277
3640
  initialFoldingDoneRef.current = true;
3278
3641
  }, [value, editor, autoFoldControlBlocks]);
3642
+ useEffect(() => {
3643
+ const mode = typeof (options == null ? void 0 : options.mode) === "object" && options.mode !== null ? options.mode.name : options == null ? void 0 : options.mode;
3644
+ if (mode !== "markdown" || !editor || !value) return;
3645
+ markInlineCode(editor);
3646
+ markInlineLinks(editor);
3647
+ markCodeBlocks(editor);
3648
+ }, [editor, value, options == null ? void 0 : options.mode]);
3279
3649
  return /* @__PURE__ */ jsxs(
3280
3650
  CodeAreaTheme,
3281
3651
  {
@@ -4210,7 +4580,7 @@ function DialogConfirmation({
4210
4580
  "aria-label": ariaLabel,
4211
4581
  role: "presentation",
4212
4582
  "data-name": "dialog-confirmation",
4213
- children: /* @__PURE__ */ jsx(ClickAwayListener, { onClickAway: handleClickAway, children: /* @__PURE__ */ jsx(
4583
+ children: /* @__PURE__ */ jsx(ClickAwayListener$1, { onClickAway: handleClickAway, children: /* @__PURE__ */ jsx(
4214
4584
  Slide,
4215
4585
  {
4216
4586
  direction: "up",
@@ -4496,6 +4866,7 @@ export {
4496
4866
  CodeAreaFooter,
4497
4867
  CodeAreaHeader,
4498
4868
  CodeAreaInput,
4869
+ CodeAreaMarkTextPattern,
4499
4870
  CopiableComponent,
4500
4871
  CreatableAutocomplete,
4501
4872
  DatePicker,
@@ -4522,6 +4893,7 @@ export {
4522
4893
  PasswordField,
4523
4894
  SelectField,
4524
4895
  Snackbar,
4896
+ SplitButton,
4525
4897
  a as TablePaginationActions,
4526
4898
  Tag,
4527
4899
  TimePicker,
@@ -4531,6 +4903,8 @@ export {
4531
4903
  UploadField,
4532
4904
  UploadFieldBase,
4533
4905
  copyString,
4906
+ createCounterFormatter,
4907
+ createCounterRenderTags,
4534
4908
  dialogDimensionsBySize,
4535
4909
  useCopyValue
4536
4910
  };