@carto/meridian-ds 1.4.8 → 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.
- package/CHANGELOG.md +7 -0
- package/dist/{Alert-BiOR9aar.cjs → Alert-BzEgeyQJ.cjs} +1 -1
- package/dist/{Alert-CywtIMOj.js → Alert-CnaTtNJd.js} +1 -1
- package/dist/{MenuItem-CXnnE5lK.js → MenuItem-D6wJym7Z.js} +9 -5
- package/dist/{MenuItem-Br2jY2lt.cjs → MenuItem-lAxlHrDp.cjs} +9 -5
- package/dist/{OpenDiagonallyRight-BrRyCV4Q.cjs → OpenDiagonallyRight-CM1tojUq.cjs} +27 -0
- package/dist/{OpenDiagonallyRight-5HZXh46V.js → OpenDiagonallyRight-CSm5GYYJ.js} +27 -0
- package/dist/{TablePaginationActions-KpTvhN4Y.js → TablePaginationActions-Cz5Hbi6N.js} +9 -1
- package/dist/{TablePaginationActions-CFGXm44W.cjs → TablePaginationActions-mbbjzV6Y.cjs} +8 -0
- package/dist/components/index.cjs +378 -52
- package/dist/components/index.js +384 -58
- package/dist/custom-icons/index.cjs +29 -55
- package/dist/custom-icons/index.js +29 -55
- package/dist/theme/index.cjs +13 -9
- package/dist/theme/index.js +14 -10
- package/dist/types/components/atoms/SplitButton.d.ts +17 -0
- package/dist/types/components/atoms/SplitButton.d.ts.map +1 -0
- package/dist/types/components/atoms/index.d.ts +2 -0
- package/dist/types/components/atoms/index.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts +1 -1
- package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts +18 -0
- package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts +1 -1
- package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/types.d.ts +61 -3
- package/dist/types/components/molecules/Autocomplete/types.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts +3 -1
- package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/utils.d.ts +9 -0
- package/dist/types/components/molecules/Autocomplete/utils.d.ts.map +1 -1
- package/dist/types/components/molecules/Menu/Menu.d.ts.map +1 -1
- package/dist/types/components/molecules/Menu/MenuItem.d.ts.map +1 -1
- package/dist/types/components/molecules/Menu/MenuItemFilter.d.ts.map +1 -1
- package/dist/types/components/molecules/Menu/MenuList.d.ts.map +1 -1
- package/dist/types/components/molecules/MultipleSelectField/MultipleSelectField.d.ts.map +1 -1
- package/dist/types/components/organisms/CodeArea/CodeAreaInput.d.ts.map +1 -1
- package/dist/types/components/organisms/CodeArea/CodeAreaTheme.d.ts.map +1 -1
- package/dist/types/components/organisms/CodeArea/index.d.ts +1 -0
- package/dist/types/components/organisms/CodeArea/index.d.ts.map +1 -1
- package/dist/types/components/organisms/CodeArea/types.d.ts +4 -0
- package/dist/types/components/organisms/CodeArea/types.d.ts.map +1 -1
- package/dist/types/components/organisms/CodeArea/utils.d.ts +34 -0
- package/dist/types/components/organisms/CodeArea/utils.d.ts.map +1 -1
- package/dist/types/theme/sections/components/forms.d.ts.map +1 -1
- package/dist/types/theme/sections/components/navigation.d.ts.map +1 -1
- package/dist/types/theme/theme-constants.d.ts +4 -0
- package/dist/types/theme/theme-constants.d.ts.map +1 -1
- package/dist/widgets/index.cjs +2 -2
- package/dist/widgets/index.js +2 -2
- package/package.json +1 -1
|
@@ -3,18 +3,19 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const material = require("@mui/material");
|
|
6
|
-
const TablePaginationActions = require("../TablePaginationActions-
|
|
6
|
+
const TablePaginationActions = require("../TablePaginationActions-mbbjzV6Y.cjs");
|
|
7
|
+
const ArrowDown = require("../ArrowDown-8fLj23Ge.cjs");
|
|
8
|
+
const OpenDiagonallyRight = require("../OpenDiagonallyRight-CM1tojUq.cjs");
|
|
7
9
|
const reactIntl = require("react-intl");
|
|
8
10
|
const iconsMaterial = require("@mui/icons-material");
|
|
9
|
-
const Alert$1 = require("../Alert-
|
|
11
|
+
const Alert$1 = require("../Alert-BzEgeyQJ.cjs");
|
|
10
12
|
require("cartocolor");
|
|
11
|
-
const MenuItem = require("../MenuItem-
|
|
12
|
-
const
|
|
13
|
+
const MenuItem = require("../MenuItem-lAxlHrDp.cjs");
|
|
14
|
+
const reactWindow = require("react-window");
|
|
13
15
|
const DatePicker$1 = require("@mui/x-date-pickers/DatePicker");
|
|
14
16
|
const xDatePickers = require("@mui/x-date-pickers");
|
|
15
17
|
const TimePicker$1 = require("@mui/x-date-pickers/TimePicker");
|
|
16
18
|
const DateTimePicker$1 = require("@mui/x-date-pickers/DateTimePicker");
|
|
17
|
-
const OpenDiagonallyRight = require("../OpenDiagonallyRight-BrRyCV4Q.cjs");
|
|
18
19
|
const reactCodemirror2 = require("react-codemirror2");
|
|
19
20
|
const colors = require("@mui/material/colors");
|
|
20
21
|
require("codemirror/lib/codemirror.css");
|
|
@@ -100,6 +101,90 @@ function _Button({
|
|
|
100
101
|
);
|
|
101
102
|
}
|
|
102
103
|
const Button = React.forwardRef(_Button);
|
|
104
|
+
const ButtonGroup = material.styled(material.ButtonGroup)(({ theme, size }) => ({
|
|
105
|
+
"& .MuiButton-root:last-child": {
|
|
106
|
+
padding: 0,
|
|
107
|
+
minWidth: size === "small" ? theme.spacing(3) : size === "large" ? theme.spacing(6) : theme.spacing(4)
|
|
108
|
+
}
|
|
109
|
+
}));
|
|
110
|
+
function SplitButton({
|
|
111
|
+
options,
|
|
112
|
+
onClick,
|
|
113
|
+
variant,
|
|
114
|
+
size,
|
|
115
|
+
color,
|
|
116
|
+
...otherProps
|
|
117
|
+
}) {
|
|
118
|
+
var _a;
|
|
119
|
+
const [open, setOpen] = React.useState(false);
|
|
120
|
+
const anchorRef = React.useRef(null);
|
|
121
|
+
const [selectedIndex, setSelectedIndex] = React.useState(0);
|
|
122
|
+
const handleClick = () => {
|
|
123
|
+
onClick(options[selectedIndex]);
|
|
124
|
+
};
|
|
125
|
+
const handleMenuItemClick = (_, index) => {
|
|
126
|
+
setSelectedIndex(index);
|
|
127
|
+
setOpen(false);
|
|
128
|
+
};
|
|
129
|
+
const handleToggle = () => {
|
|
130
|
+
setOpen((prevOpen) => !prevOpen);
|
|
131
|
+
};
|
|
132
|
+
const handleClose = (event) => {
|
|
133
|
+
var _a2;
|
|
134
|
+
if ((_a2 = anchorRef.current) == null ? void 0 : _a2.contains(event.target)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
setOpen(false);
|
|
138
|
+
};
|
|
139
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
140
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
141
|
+
ButtonGroup,
|
|
142
|
+
{
|
|
143
|
+
"data-name": "split-button",
|
|
144
|
+
ref: anchorRef,
|
|
145
|
+
variant,
|
|
146
|
+
size,
|
|
147
|
+
color,
|
|
148
|
+
...otherProps,
|
|
149
|
+
children: [
|
|
150
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Button, { onClick: handleClick, children: (_a = options[selectedIndex]) == null ? void 0 : _a.label }),
|
|
151
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Button, { onClick: handleToggle, children: open ? /* @__PURE__ */ jsxRuntime.jsx(OpenDiagonallyRight.ArrowUp, {}) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}) })
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
),
|
|
155
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
156
|
+
material.Popper,
|
|
157
|
+
{
|
|
158
|
+
sx: { zIndex: 1 },
|
|
159
|
+
open,
|
|
160
|
+
anchorEl: anchorRef.current,
|
|
161
|
+
role: void 0,
|
|
162
|
+
transition: true,
|
|
163
|
+
disablePortal: true,
|
|
164
|
+
placement: "bottom-end",
|
|
165
|
+
children: ({ TransitionProps, placement }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
166
|
+
material.Grow,
|
|
167
|
+
{
|
|
168
|
+
...TransitionProps,
|
|
169
|
+
style: {
|
|
170
|
+
transformOrigin: placement === "bottom" ? "center top" : "center bottom"
|
|
171
|
+
},
|
|
172
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(material.Paper, { elevation: 8, children: /* @__PURE__ */ jsxRuntime.jsx(material.ClickAwayListener, { onClickAway: handleClose, children: /* @__PURE__ */ jsxRuntime.jsx(material.MenuList, { autoFocusItem: true, sx: { paddingY: 1 }, children: options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
173
|
+
material.MenuItem,
|
|
174
|
+
{
|
|
175
|
+
disabled: option.disabled,
|
|
176
|
+
selected: index === selectedIndex,
|
|
177
|
+
onClick: (event) => handleMenuItemClick(event, index),
|
|
178
|
+
children: option.label
|
|
179
|
+
},
|
|
180
|
+
option.label
|
|
181
|
+
)) }) }) })
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
] });
|
|
187
|
+
}
|
|
103
188
|
const Root$5 = material.styled(material.Box)(({ theme }) => ({
|
|
104
189
|
display: "flex",
|
|
105
190
|
alignItems: "center",
|
|
@@ -383,10 +468,10 @@ function ToggleButtonGroup({
|
|
|
383
468
|
}
|
|
384
469
|
const StyledMenu = material.styled(material.Menu, {
|
|
385
470
|
shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
|
|
386
|
-
})(({
|
|
471
|
+
})(({ extended, width, height }) => ({
|
|
387
472
|
...extended && {
|
|
388
473
|
".MuiMenuItem-root": {
|
|
389
|
-
minHeight:
|
|
474
|
+
minHeight: TablePaginationActions.MENU_ITEM_SIZE_EXTENDED
|
|
390
475
|
}
|
|
391
476
|
},
|
|
392
477
|
...width && {
|
|
@@ -426,10 +511,10 @@ function _Menu({ extended, width, height, MenuListProps, ...otherProps }, ref) {
|
|
|
426
511
|
const Menu$1 = React.forwardRef(_Menu);
|
|
427
512
|
const StyledMenuList = material.styled(material.MenuList, {
|
|
428
513
|
shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
|
|
429
|
-
})(({
|
|
514
|
+
})(({ extended, width, height }) => ({
|
|
430
515
|
...extended && {
|
|
431
516
|
".MuiMenuItem-root": {
|
|
432
|
-
minHeight:
|
|
517
|
+
minHeight: TablePaginationActions.MENU_ITEM_SIZE_EXTENDED
|
|
433
518
|
}
|
|
434
519
|
},
|
|
435
520
|
"&.MuiList-root": {
|
|
@@ -460,7 +545,8 @@ function _MenuList({ extended, width, height, ...otherProps }, ref) {
|
|
|
460
545
|
}
|
|
461
546
|
const MenuList = React.forwardRef(_MenuList);
|
|
462
547
|
const StyledMenuItem$1 = material.styled(MenuItem.MenuItem)(() => ({
|
|
463
|
-
marginTop: "0 !important"
|
|
548
|
+
marginTop: "0 !important",
|
|
549
|
+
marginBottom: "0 !important"
|
|
464
550
|
}));
|
|
465
551
|
const LinkFilter = material.styled(material.Link)(
|
|
466
552
|
({ disabled, theme }) => ({
|
|
@@ -700,12 +786,20 @@ function _MultipleSelectField({
|
|
|
700
786
|
},
|
|
701
787
|
children: [
|
|
702
788
|
showFilters && /* @__PURE__ */ jsxRuntime.jsx(
|
|
703
|
-
|
|
789
|
+
material.Box,
|
|
704
790
|
{
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
791
|
+
sx: {
|
|
792
|
+
mb: 1
|
|
793
|
+
},
|
|
794
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
795
|
+
MenuItemFilter,
|
|
796
|
+
{
|
|
797
|
+
areAllSelected,
|
|
798
|
+
areAnySelected,
|
|
799
|
+
selectAll,
|
|
800
|
+
selectAllDisabled
|
|
801
|
+
}
|
|
802
|
+
)
|
|
709
803
|
}
|
|
710
804
|
),
|
|
711
805
|
options == null ? void 0 : options.map((option) => {
|
|
@@ -1039,7 +1133,40 @@ const getDefaultOptionLabel = (option) => {
|
|
|
1039
1133
|
const createOptionWithMultiple = (option, multiple) => {
|
|
1040
1134
|
return typeof option !== "object" || option === null ? { value: option, multiple } : { ...option, multiple };
|
|
1041
1135
|
};
|
|
1042
|
-
const getDefaultLimitTagsText = (more) => /* @__PURE__ */ jsxRuntime.
|
|
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
|
+
}
|
|
1043
1170
|
function useAutocompleteRenderOption() {
|
|
1044
1171
|
const renderOption = (props, option, state, getOptionLabel, customIcon) => {
|
|
1045
1172
|
const {
|
|
@@ -1181,7 +1308,8 @@ function useMultipleAutocomplete({
|
|
|
1181
1308
|
options,
|
|
1182
1309
|
value,
|
|
1183
1310
|
onChange,
|
|
1184
|
-
getOptionLabel
|
|
1311
|
+
getOptionLabel,
|
|
1312
|
+
size
|
|
1185
1313
|
}) {
|
|
1186
1314
|
const [multipleValue, setMultipleValue] = React.useState(
|
|
1187
1315
|
Array.isArray(value) ? value : value ? [value] : []
|
|
@@ -1216,13 +1344,20 @@ function useMultipleAutocomplete({
|
|
|
1216
1344
|
getOptionLabel
|
|
1217
1345
|
);
|
|
1218
1346
|
};
|
|
1347
|
+
const getCounterRenderTags = () => createCounterRenderTags(
|
|
1348
|
+
"selected",
|
|
1349
|
+
options,
|
|
1350
|
+
size,
|
|
1351
|
+
getOptionLabel ? (option) => getOptionLabel(option) : void 0
|
|
1352
|
+
);
|
|
1219
1353
|
return {
|
|
1220
1354
|
multipleValue,
|
|
1221
1355
|
allSelected,
|
|
1222
1356
|
someSelected,
|
|
1223
1357
|
handleSelectAll,
|
|
1224
1358
|
handleChange,
|
|
1225
|
-
multipleRenderOption
|
|
1359
|
+
multipleRenderOption,
|
|
1360
|
+
getCounterRenderTags
|
|
1226
1361
|
};
|
|
1227
1362
|
}
|
|
1228
1363
|
function _ListboxWithFilter({
|
|
@@ -1232,15 +1367,53 @@ function _ListboxWithFilter({
|
|
|
1232
1367
|
someSelected,
|
|
1233
1368
|
handleSelectAll = () => void 0,
|
|
1234
1369
|
multiple,
|
|
1370
|
+
extended,
|
|
1371
|
+
itemHeight,
|
|
1372
|
+
maxListHeight = TablePaginationActions.MENU_LIST_MAX_SIZE,
|
|
1235
1373
|
...otherProps
|
|
1236
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
|
+
};
|
|
1237
1405
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1238
1406
|
"ul",
|
|
1239
1407
|
{
|
|
1240
1408
|
ref,
|
|
1241
1409
|
...otherProps,
|
|
1242
1410
|
role: "listbox",
|
|
1411
|
+
"data-list-height": listboxHeight,
|
|
1412
|
+
"data-item-height": defaultItemHeight,
|
|
1243
1413
|
"aria-multiselectable": multiple,
|
|
1414
|
+
style: {
|
|
1415
|
+
maxHeight: maxListHeight + defaultItemHeight
|
|
1416
|
+
},
|
|
1244
1417
|
children: [
|
|
1245
1418
|
showFilters && multiple && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1246
1419
|
MenuItemFilter,
|
|
@@ -1250,7 +1423,16 @@ function _ListboxWithFilter({
|
|
|
1250
1423
|
selectAll: handleSelectAll
|
|
1251
1424
|
}
|
|
1252
1425
|
),
|
|
1253
|
-
|
|
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
|
+
)
|
|
1254
1436
|
]
|
|
1255
1437
|
}
|
|
1256
1438
|
);
|
|
@@ -1265,10 +1447,15 @@ function _CreatableAutocomplete({
|
|
|
1265
1447
|
disabled,
|
|
1266
1448
|
loading,
|
|
1267
1449
|
showFilters,
|
|
1450
|
+
showCounter = false,
|
|
1268
1451
|
options = [],
|
|
1269
1452
|
value,
|
|
1270
1453
|
onChange,
|
|
1271
1454
|
getLimitTagsText,
|
|
1455
|
+
renderTags,
|
|
1456
|
+
itemHeight,
|
|
1457
|
+
maxListHeight,
|
|
1458
|
+
extended,
|
|
1272
1459
|
...props
|
|
1273
1460
|
}, ref) {
|
|
1274
1461
|
const { freeSolo = true, ...otherProps } = props;
|
|
@@ -1277,11 +1464,14 @@ function _CreatableAutocomplete({
|
|
|
1277
1464
|
allSelected,
|
|
1278
1465
|
someSelected,
|
|
1279
1466
|
handleSelectAll,
|
|
1280
|
-
handleChange
|
|
1467
|
+
handleChange,
|
|
1468
|
+
getCounterRenderTags
|
|
1281
1469
|
} = useMultipleAutocomplete({
|
|
1282
1470
|
options,
|
|
1283
1471
|
value,
|
|
1284
|
-
onChange
|
|
1472
|
+
onChange,
|
|
1473
|
+
getOptionLabel,
|
|
1474
|
+
size: props.size
|
|
1285
1475
|
});
|
|
1286
1476
|
const {
|
|
1287
1477
|
creatableFilterOptions,
|
|
@@ -1293,6 +1483,17 @@ function _CreatableAutocomplete({
|
|
|
1293
1483
|
newItemIcon,
|
|
1294
1484
|
multiple
|
|
1295
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;
|
|
1296
1497
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1297
1498
|
material.Autocomplete,
|
|
1298
1499
|
{
|
|
@@ -1304,18 +1505,13 @@ function _CreatableAutocomplete({
|
|
|
1304
1505
|
filterOptions: creatableFilterOptions,
|
|
1305
1506
|
getOptionLabel: creatableOptionLabel,
|
|
1306
1507
|
renderOption: creatableRenderOption,
|
|
1508
|
+
renderTags: finalRenderTags,
|
|
1307
1509
|
freeSolo,
|
|
1308
1510
|
forcePopupIcon: true,
|
|
1309
1511
|
multiple,
|
|
1310
1512
|
disableCloseOnSelect: disableCloseOnSelect ?? multiple,
|
|
1311
1513
|
ListboxComponent: ListboxWithFilter,
|
|
1312
|
-
ListboxProps:
|
|
1313
|
-
showFilters,
|
|
1314
|
-
allSelected,
|
|
1315
|
-
someSelected,
|
|
1316
|
-
handleSelectAll,
|
|
1317
|
-
multiple
|
|
1318
|
-
},
|
|
1514
|
+
ListboxProps: listboxProps,
|
|
1319
1515
|
getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
|
|
1320
1516
|
disabled: disabled || loading,
|
|
1321
1517
|
popupIcon: loading ? /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" }) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}),
|
|
@@ -1330,11 +1526,16 @@ function _MultipleAutocomplete({
|
|
|
1330
1526
|
disabled,
|
|
1331
1527
|
loading,
|
|
1332
1528
|
showFilters,
|
|
1529
|
+
showCounter = false,
|
|
1333
1530
|
options,
|
|
1334
1531
|
value,
|
|
1335
1532
|
onChange,
|
|
1336
1533
|
getOptionLabel,
|
|
1337
1534
|
getLimitTagsText,
|
|
1535
|
+
renderTags,
|
|
1536
|
+
itemHeight,
|
|
1537
|
+
maxListHeight,
|
|
1538
|
+
extended,
|
|
1338
1539
|
...props
|
|
1339
1540
|
}, ref) {
|
|
1340
1541
|
const {
|
|
@@ -1343,13 +1544,26 @@ function _MultipleAutocomplete({
|
|
|
1343
1544
|
someSelected,
|
|
1344
1545
|
handleSelectAll,
|
|
1345
1546
|
handleChange,
|
|
1346
|
-
multipleRenderOption
|
|
1547
|
+
multipleRenderOption,
|
|
1548
|
+
getCounterRenderTags
|
|
1347
1549
|
} = useMultipleAutocomplete({
|
|
1348
1550
|
options,
|
|
1349
1551
|
value,
|
|
1350
1552
|
onChange,
|
|
1351
|
-
getOptionLabel
|
|
1553
|
+
getOptionLabel,
|
|
1554
|
+
size: props.size
|
|
1352
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;
|
|
1353
1567
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1354
1568
|
material.Autocomplete,
|
|
1355
1569
|
{
|
|
@@ -1360,14 +1574,9 @@ function _MultipleAutocomplete({
|
|
|
1360
1574
|
onChange: handleChange,
|
|
1361
1575
|
getOptionLabel,
|
|
1362
1576
|
renderOption: renderOption ?? multipleRenderOption,
|
|
1577
|
+
renderTags: finalRenderTags,
|
|
1363
1578
|
ListboxComponent: ListboxWithFilter,
|
|
1364
|
-
ListboxProps:
|
|
1365
|
-
showFilters,
|
|
1366
|
-
allSelected,
|
|
1367
|
-
someSelected,
|
|
1368
|
-
handleSelectAll,
|
|
1369
|
-
multiple: true
|
|
1370
|
-
},
|
|
1579
|
+
ListboxProps: listboxProps,
|
|
1371
1580
|
multiple: true,
|
|
1372
1581
|
getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
|
|
1373
1582
|
disableCloseOnSelect,
|
|
@@ -3114,8 +3323,9 @@ const CodeAreaTheme = material.styled(material.Box, {
|
|
|
3114
3323
|
right: 0,
|
|
3115
3324
|
zIndex: 1
|
|
3116
3325
|
},
|
|
3117
|
-
"
|
|
3118
|
-
color: theme.palette.text.primary
|
|
3326
|
+
".CodeMirror pre.CodeMirror-line, .CodeMirror pre.CodeMirror-line-like, & .cm-bracket": {
|
|
3327
|
+
color: theme.palette.text.primary,
|
|
3328
|
+
fontVariantLigatures: "no-common-ligatures"
|
|
3119
3329
|
},
|
|
3120
3330
|
"& .CodeMirror pre.CodeMirror-placeholder": {
|
|
3121
3331
|
color: theme.palette.text.hint
|
|
@@ -3133,7 +3343,7 @@ const CodeAreaTheme = material.styled(material.Box, {
|
|
|
3133
3343
|
"& .cm-number, & .cm-property, & .cm-builtin": {
|
|
3134
3344
|
color: colors.red[700]
|
|
3135
3345
|
},
|
|
3136
|
-
"& .cm-comment": {
|
|
3346
|
+
"& .cm-comment, & .cm-quote": {
|
|
3137
3347
|
color: theme.palette.text.secondary
|
|
3138
3348
|
},
|
|
3139
3349
|
"& .cm-variable": {
|
|
@@ -3142,9 +3352,18 @@ const CodeAreaTheme = material.styled(material.Box, {
|
|
|
3142
3352
|
"& .cm-variable-2": {
|
|
3143
3353
|
color: theme.palette.text.primary
|
|
3144
3354
|
},
|
|
3145
|
-
"& .cm-punctuation, & .cm-def
|
|
3355
|
+
"& .cm-punctuation, & .cm-def": {
|
|
3146
3356
|
color: colors.blue[800]
|
|
3147
3357
|
},
|
|
3358
|
+
"& .cm-image-alt-text, & .cm-link": {
|
|
3359
|
+
color: colors.green[800],
|
|
3360
|
+
textDecoration: "none"
|
|
3361
|
+
},
|
|
3362
|
+
// Custom inline link styling .cm-inline-url
|
|
3363
|
+
"& .cm-url, & .cm-inline-url": {
|
|
3364
|
+
color: colors.blue[800],
|
|
3365
|
+
textDecoration: "none"
|
|
3366
|
+
},
|
|
3148
3367
|
"& .cm-variable-3, & .cm-type": {
|
|
3149
3368
|
color: colors.indigo[800]
|
|
3150
3369
|
},
|
|
@@ -3158,20 +3377,23 @@ const CodeAreaTheme = material.styled(material.Box, {
|
|
|
3158
3377
|
"& .CodeMirror-selected": {
|
|
3159
3378
|
background: colors.blue[800]
|
|
3160
3379
|
},
|
|
3161
|
-
"& .cm-header
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
fontSize: theme.typography.h3.fontSize
|
|
3380
|
+
"& .cm-header": {
|
|
3381
|
+
color: colors.red[700],
|
|
3382
|
+
...theme.typography.code3,
|
|
3383
|
+
fontWeight: theme.typography.fontWeightBold
|
|
3166
3384
|
},
|
|
3167
|
-
"& .cm-header-
|
|
3168
|
-
|
|
3385
|
+
"& .cm-header-4, & .cm-header-5, & .cm-header-6": {
|
|
3386
|
+
fontWeight: theme.typography.fontWeightRegular
|
|
3169
3387
|
},
|
|
3170
|
-
|
|
3171
|
-
|
|
3388
|
+
// Custom inline code styling
|
|
3389
|
+
"& .cm-inline-code": {
|
|
3390
|
+
backgroundColor: theme.palette.black[4],
|
|
3391
|
+
color: colors.purple[500]
|
|
3172
3392
|
},
|
|
3173
|
-
|
|
3174
|
-
|
|
3393
|
+
// Custom code block styling
|
|
3394
|
+
"& .cm-code-block": {
|
|
3395
|
+
backgroundColor: theme.palette.black[4],
|
|
3396
|
+
marginRight: theme.spacing(2)
|
|
3175
3397
|
},
|
|
3176
3398
|
...size === "small" && {
|
|
3177
3399
|
"& .CodeMirror": {
|
|
@@ -3207,6 +3429,100 @@ function findCodeAreaControlCodeOccurrences(content) {
|
|
|
3207
3429
|
}
|
|
3208
3430
|
return matches;
|
|
3209
3431
|
}
|
|
3432
|
+
const editorMarkers = /* @__PURE__ */ new WeakMap();
|
|
3433
|
+
function clearMarkersForClass(editor, className) {
|
|
3434
|
+
var _a, _b;
|
|
3435
|
+
const markers = (_a = editorMarkers.get(editor)) == null ? void 0 : _a.get(className);
|
|
3436
|
+
if (!markers) return;
|
|
3437
|
+
markers.forEach((marker) => {
|
|
3438
|
+
if (marker.find()) {
|
|
3439
|
+
marker.clear();
|
|
3440
|
+
}
|
|
3441
|
+
});
|
|
3442
|
+
(_b = editorMarkers.get(editor)) == null ? void 0 : _b.delete(className);
|
|
3443
|
+
}
|
|
3444
|
+
function storeMarkersForClass(editor, className, markers) {
|
|
3445
|
+
if (!editorMarkers.has(editor)) {
|
|
3446
|
+
editorMarkers.set(editor, /* @__PURE__ */ new Map());
|
|
3447
|
+
}
|
|
3448
|
+
const editorMap = editorMarkers.get(editor);
|
|
3449
|
+
if (editorMap) {
|
|
3450
|
+
editorMap.set(className, markers);
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3453
|
+
function CodeAreaMarkTextPattern(editor, pattern, options, excludePatterns) {
|
|
3454
|
+
const { className } = options;
|
|
3455
|
+
clearMarkersForClass(editor, className);
|
|
3456
|
+
const doc = editor.getDoc();
|
|
3457
|
+
const content = doc.getValue();
|
|
3458
|
+
const excludeRanges = (excludePatterns == null ? void 0 : excludePatterns.flatMap(
|
|
3459
|
+
(excludePattern) => Array.from(content.matchAll(excludePattern), (match) => ({
|
|
3460
|
+
start: match.index,
|
|
3461
|
+
end: match.index + match[0].length
|
|
3462
|
+
}))
|
|
3463
|
+
)) ?? [];
|
|
3464
|
+
const markers = Array.from(content.matchAll(pattern)).filter((match) => {
|
|
3465
|
+
if (excludeRanges.some(
|
|
3466
|
+
(range) => match.index >= range.start && match.index < range.end
|
|
3467
|
+
)) {
|
|
3468
|
+
return false;
|
|
3469
|
+
}
|
|
3470
|
+
return !match[1] || match[1].trim().length > 0;
|
|
3471
|
+
}).map((match) => {
|
|
3472
|
+
const startPos = doc.posFromIndex(match.index);
|
|
3473
|
+
const endPos = doc.posFromIndex(match.index + match[0].length);
|
|
3474
|
+
return editor.markText(startPos, endPos, {
|
|
3475
|
+
atomic: false,
|
|
3476
|
+
clearOnEnter: false,
|
|
3477
|
+
...options
|
|
3478
|
+
});
|
|
3479
|
+
});
|
|
3480
|
+
if (markers.length > 0) {
|
|
3481
|
+
storeMarkersForClass(editor, className, markers);
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
function markInlineCode(editor, className = "cm-inline-code") {
|
|
3485
|
+
const inlineCodePattern = /`([^`\n\r]+)`/g;
|
|
3486
|
+
const codeBlockPattern = /```[\s\S]*?```/g;
|
|
3487
|
+
CodeAreaMarkTextPattern(
|
|
3488
|
+
editor,
|
|
3489
|
+
inlineCodePattern,
|
|
3490
|
+
{
|
|
3491
|
+
className
|
|
3492
|
+
},
|
|
3493
|
+
[codeBlockPattern]
|
|
3494
|
+
);
|
|
3495
|
+
}
|
|
3496
|
+
function markInlineLinks(editor, className = "cm-inline-url") {
|
|
3497
|
+
const inlineLinkPattern = /<((?:https?:\/\/[^\s<>]+)|(?:[^\s<>@]+@[^\s<>@]+\.[^\s<>@]+))>/g;
|
|
3498
|
+
const codeBlockPattern = /```[\s\S]*?```/g;
|
|
3499
|
+
CodeAreaMarkTextPattern(
|
|
3500
|
+
editor,
|
|
3501
|
+
inlineLinkPattern,
|
|
3502
|
+
{
|
|
3503
|
+
className
|
|
3504
|
+
},
|
|
3505
|
+
[codeBlockPattern]
|
|
3506
|
+
);
|
|
3507
|
+
}
|
|
3508
|
+
function markCodeBlocks(editor, className = "cm-code-block") {
|
|
3509
|
+
const doc = editor.getDoc();
|
|
3510
|
+
const content = doc.getValue();
|
|
3511
|
+
const lineCount = content.split("\n").length;
|
|
3512
|
+
for (let i = 0; i < lineCount; i++) {
|
|
3513
|
+
["background", "wrap", "text"].forEach(
|
|
3514
|
+
(where) => editor.removeLineClass(i, where, className)
|
|
3515
|
+
);
|
|
3516
|
+
}
|
|
3517
|
+
const codeBlockPattern = /```[\s\S]*?(?:```|$)/g;
|
|
3518
|
+
Array.from(content.matchAll(codeBlockPattern)).forEach((match) => {
|
|
3519
|
+
const startPos = doc.posFromIndex(match.index);
|
|
3520
|
+
const endPos = doc.posFromIndex(match.index + match[0].length);
|
|
3521
|
+
for (let lineNum = startPos.line; lineNum <= endPos.line; lineNum++) {
|
|
3522
|
+
editor.addLineClass(lineNum, "wrap", className);
|
|
3523
|
+
}
|
|
3524
|
+
});
|
|
3525
|
+
}
|
|
3210
3526
|
function foldCode(editor, { from, to }) {
|
|
3211
3527
|
editor.foldCode(
|
|
3212
3528
|
0,
|
|
@@ -3247,6 +3563,7 @@ function CodeAreaInput({
|
|
|
3247
3563
|
const codeMirrorOptions = {
|
|
3248
3564
|
mode: "sql",
|
|
3249
3565
|
theme: "light",
|
|
3566
|
+
addModeClass: true,
|
|
3250
3567
|
lineNumbers: true,
|
|
3251
3568
|
lineWrapping: true,
|
|
3252
3569
|
extraKeys: { "Ctrl-Space": "autocomplete" },
|
|
@@ -3277,6 +3594,13 @@ function CodeAreaInput({
|
|
|
3277
3594
|
}
|
|
3278
3595
|
initialFoldingDoneRef.current = true;
|
|
3279
3596
|
}, [value, editor, autoFoldControlBlocks]);
|
|
3597
|
+
React.useEffect(() => {
|
|
3598
|
+
const mode = typeof (options == null ? void 0 : options.mode) === "object" && options.mode !== null ? options.mode.name : options == null ? void 0 : options.mode;
|
|
3599
|
+
if (mode !== "markdown" || !editor || !value) return;
|
|
3600
|
+
markInlineCode(editor);
|
|
3601
|
+
markInlineLinks(editor);
|
|
3602
|
+
markCodeBlocks(editor);
|
|
3603
|
+
}, [editor, value, options == null ? void 0 : options.mode]);
|
|
3280
3604
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3281
3605
|
CodeAreaTheme,
|
|
3282
3606
|
{
|
|
@@ -4500,6 +4824,7 @@ exports.CodeAreaField = CodeAreaField;
|
|
|
4500
4824
|
exports.CodeAreaFooter = CodeAreaFooter;
|
|
4501
4825
|
exports.CodeAreaHeader = CodeAreaHeader;
|
|
4502
4826
|
exports.CodeAreaInput = CodeAreaInput;
|
|
4827
|
+
exports.CodeAreaMarkTextPattern = CodeAreaMarkTextPattern;
|
|
4503
4828
|
exports.CopiableComponent = CopiableComponent;
|
|
4504
4829
|
exports.CreatableAutocomplete = CreatableAutocomplete;
|
|
4505
4830
|
exports.DatePicker = DatePicker;
|
|
@@ -4524,6 +4849,7 @@ exports.MultipleSelectField = MultipleSelectField;
|
|
|
4524
4849
|
exports.PasswordField = PasswordField;
|
|
4525
4850
|
exports.SelectField = SelectField;
|
|
4526
4851
|
exports.Snackbar = Snackbar;
|
|
4852
|
+
exports.SplitButton = SplitButton;
|
|
4527
4853
|
exports.Tag = Tag;
|
|
4528
4854
|
exports.TimePicker = TimePicker;
|
|
4529
4855
|
exports.ToggleButtonGroup = ToggleButtonGroup;
|