@carto/meridian-ds 1.5.0 → 1.5.1-alpha-virtual-autocomplete.10
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 +6 -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-C1DvWMry.js} +10 -6
- package/dist/{MenuItem-Br2jY2lt.cjs → MenuItem-C4bG5WHw.cjs} +10 -6
- 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 +442 -55
- package/dist/components/index.js +444 -57
- package/dist/theme/index.cjs +13 -9
- package/dist/theme/index.js +14 -10
- package/dist/types/components/atoms/SplitButton.d.ts +9 -5
- package/dist/types/components/atoms/SplitButton.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/AutocompleteList.d.ts +13 -0
- package/dist/types/components/molecules/Autocomplete/AutocompleteList.d.ts.map +1 -0
- 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/MultipleAutocomplete.d.ts +1 -1
- package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/index.d.ts +3 -0
- package/dist/types/components/molecules/Autocomplete/index.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/types.d.ts +107 -7
- package/dist/types/components/molecules/Autocomplete/types.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/useAutocomplete.d.ts +11 -0
- package/dist/types/components/molecules/Autocomplete/useAutocomplete.d.ts.map +1 -0
- package/dist/types/components/molecules/Autocomplete/useAutocompleteRenderOption.d.ts +2 -1
- package/dist/types/components/molecules/Autocomplete/useAutocompleteRenderOption.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts +26 -1
- package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/utils.d.ts +135 -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/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
- package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts +0 -17
- package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts.map +0 -1
|
@@ -3,14 +3,15 @@ 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
7
|
const ArrowDown = require("../ArrowDown-8fLj23Ge.cjs");
|
|
8
8
|
const OpenDiagonallyRight = require("../OpenDiagonallyRight-CM1tojUq.cjs");
|
|
9
9
|
const reactIntl = require("react-intl");
|
|
10
10
|
const iconsMaterial = require("@mui/icons-material");
|
|
11
|
-
const Alert$1 = require("../Alert-
|
|
11
|
+
const Alert$1 = require("../Alert-BzEgeyQJ.cjs");
|
|
12
12
|
require("cartocolor");
|
|
13
|
-
const MenuItem = require("../MenuItem-
|
|
13
|
+
const MenuItem = require("../MenuItem-C4bG5WHw.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");
|
|
@@ -108,6 +109,9 @@ const ButtonGroup = material.styled(material.ButtonGroup)(({ theme, size }) => (
|
|
|
108
109
|
}));
|
|
109
110
|
function SplitButton({
|
|
110
111
|
options,
|
|
112
|
+
disabled,
|
|
113
|
+
loading,
|
|
114
|
+
loadingPosition,
|
|
111
115
|
onClick,
|
|
112
116
|
variant,
|
|
113
117
|
size,
|
|
@@ -146,8 +150,17 @@ function SplitButton({
|
|
|
146
150
|
color,
|
|
147
151
|
...otherProps,
|
|
148
152
|
children: [
|
|
149
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
150
|
-
|
|
153
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
154
|
+
Button,
|
|
155
|
+
{
|
|
156
|
+
disabled,
|
|
157
|
+
loading,
|
|
158
|
+
loadingPosition,
|
|
159
|
+
onClick: handleClick,
|
|
160
|
+
children: (_a = options[selectedIndex]) == null ? void 0 : _a.label
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { disabled: loading || disabled, onClick: handleToggle, children: open ? /* @__PURE__ */ jsxRuntime.jsx(OpenDiagonallyRight.ArrowUp, {}) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}) })
|
|
151
164
|
]
|
|
152
165
|
}
|
|
153
166
|
),
|
|
@@ -467,10 +480,10 @@ function ToggleButtonGroup({
|
|
|
467
480
|
}
|
|
468
481
|
const StyledMenu = material.styled(material.Menu, {
|
|
469
482
|
shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
|
|
470
|
-
})(({
|
|
483
|
+
})(({ extended, width, height }) => ({
|
|
471
484
|
...extended && {
|
|
472
485
|
".MuiMenuItem-root": {
|
|
473
|
-
minHeight:
|
|
486
|
+
minHeight: TablePaginationActions.MENU_ITEM_SIZE_EXTENDED
|
|
474
487
|
}
|
|
475
488
|
},
|
|
476
489
|
...width && {
|
|
@@ -510,10 +523,10 @@ function _Menu({ extended, width, height, MenuListProps, ...otherProps }, ref) {
|
|
|
510
523
|
const Menu$1 = React.forwardRef(_Menu);
|
|
511
524
|
const StyledMenuList = material.styled(material.MenuList, {
|
|
512
525
|
shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
|
|
513
|
-
})(({
|
|
526
|
+
})(({ extended, width, height }) => ({
|
|
514
527
|
...extended && {
|
|
515
528
|
".MuiMenuItem-root": {
|
|
516
|
-
minHeight:
|
|
529
|
+
minHeight: TablePaginationActions.MENU_ITEM_SIZE_EXTENDED
|
|
517
530
|
}
|
|
518
531
|
},
|
|
519
532
|
"&.MuiList-root": {
|
|
@@ -544,7 +557,8 @@ function _MenuList({ extended, width, height, ...otherProps }, ref) {
|
|
|
544
557
|
}
|
|
545
558
|
const MenuList = React.forwardRef(_MenuList);
|
|
546
559
|
const StyledMenuItem$1 = material.styled(MenuItem.MenuItem)(() => ({
|
|
547
|
-
marginTop: "0 !important"
|
|
560
|
+
marginTop: "0 !important",
|
|
561
|
+
marginBottom: "0 !important"
|
|
548
562
|
}));
|
|
549
563
|
const LinkFilter = material.styled(material.Link)(
|
|
550
564
|
({ disabled, theme }) => ({
|
|
@@ -784,12 +798,20 @@ function _MultipleSelectField({
|
|
|
784
798
|
},
|
|
785
799
|
children: [
|
|
786
800
|
showFilters && /* @__PURE__ */ jsxRuntime.jsx(
|
|
787
|
-
|
|
801
|
+
material.Box,
|
|
788
802
|
{
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
803
|
+
sx: {
|
|
804
|
+
mb: 1
|
|
805
|
+
},
|
|
806
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
807
|
+
MenuItemFilter,
|
|
808
|
+
{
|
|
809
|
+
areAllSelected,
|
|
810
|
+
areAnySelected,
|
|
811
|
+
selectAll,
|
|
812
|
+
selectAllDisabled
|
|
813
|
+
}
|
|
814
|
+
)
|
|
793
815
|
}
|
|
794
816
|
),
|
|
795
817
|
options == null ? void 0 : options.map((option) => {
|
|
@@ -1096,11 +1118,130 @@ function UploadField({
|
|
|
1096
1118
|
)
|
|
1097
1119
|
] });
|
|
1098
1120
|
}
|
|
1121
|
+
const AUTOCOMPLETE_GROUP_HEADER_PROPERTY = "__isGroupHeader";
|
|
1122
|
+
function isAutocompleteListGroupHeader(option) {
|
|
1123
|
+
return typeof option === "object" && option !== null && AUTOCOMPLETE_GROUP_HEADER_PROPERTY in option;
|
|
1124
|
+
}
|
|
1125
|
+
const getDefaultOptionLabel = (option) => {
|
|
1126
|
+
return option && typeof option === "object" ? option.title ?? String(option) : String(option);
|
|
1127
|
+
};
|
|
1128
|
+
const createOptionWithMultiple = (option, multiple) => {
|
|
1129
|
+
return typeof option !== "object" || option === null ? { value: option, multiple } : { ...option, multiple };
|
|
1130
|
+
};
|
|
1131
|
+
const getDefaultLimitTagsText = (more) => /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-testid": "more-options-tag", children: [
|
|
1132
|
+
"+",
|
|
1133
|
+
more
|
|
1134
|
+
] });
|
|
1135
|
+
function createCounterRenderTags({
|
|
1136
|
+
formatCounter,
|
|
1137
|
+
options = [],
|
|
1138
|
+
size = "small",
|
|
1139
|
+
getOptionLabel = getDefaultOptionLabel
|
|
1140
|
+
}) {
|
|
1141
|
+
const CounterRenderTags = (value) => {
|
|
1142
|
+
if (value.length === 0) {
|
|
1143
|
+
return null;
|
|
1144
|
+
}
|
|
1145
|
+
const selectedCount = value.length;
|
|
1146
|
+
const selectableOptions = options.filter(
|
|
1147
|
+
(option) => !isAutocompleteListGroupHeader(option)
|
|
1148
|
+
);
|
|
1149
|
+
const totalCount = selectableOptions.length;
|
|
1150
|
+
const text = formatCounter({
|
|
1151
|
+
selectedCount,
|
|
1152
|
+
totalCount,
|
|
1153
|
+
selectedItems: value,
|
|
1154
|
+
allItems: selectableOptions,
|
|
1155
|
+
getOptionLabel
|
|
1156
|
+
});
|
|
1157
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1158
|
+
TablePaginationActions.Typography,
|
|
1159
|
+
{
|
|
1160
|
+
variant: size === "small" ? "body2" : "body1",
|
|
1161
|
+
component: "span",
|
|
1162
|
+
"data-testid": "counter-tag",
|
|
1163
|
+
sx: {
|
|
1164
|
+
ml: 1
|
|
1165
|
+
},
|
|
1166
|
+
children: text
|
|
1167
|
+
}
|
|
1168
|
+
);
|
|
1169
|
+
};
|
|
1170
|
+
return CounterRenderTags;
|
|
1171
|
+
}
|
|
1172
|
+
function createCounterFormatter({
|
|
1173
|
+
counterText,
|
|
1174
|
+
allText,
|
|
1175
|
+
showSingleItemText = true
|
|
1176
|
+
}) {
|
|
1177
|
+
return ({
|
|
1178
|
+
selectedCount,
|
|
1179
|
+
totalCount,
|
|
1180
|
+
selectedItems,
|
|
1181
|
+
getOptionLabel
|
|
1182
|
+
}) => {
|
|
1183
|
+
if (selectedCount === totalCount && totalCount > 0) {
|
|
1184
|
+
return allText;
|
|
1185
|
+
} else if (selectedCount === 1 && showSingleItemText) {
|
|
1186
|
+
return getOptionLabel(selectedItems[0]);
|
|
1187
|
+
} else {
|
|
1188
|
+
return `${selectedCount} ${counterText}`;
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
function createAutocompleteGroupByList({
|
|
1193
|
+
options,
|
|
1194
|
+
groupBy,
|
|
1195
|
+
extended
|
|
1196
|
+
}) {
|
|
1197
|
+
const grouped = options.reduce(
|
|
1198
|
+
(acc, option) => {
|
|
1199
|
+
const group = groupBy(option);
|
|
1200
|
+
if (!acc[group]) {
|
|
1201
|
+
acc[group] = [];
|
|
1202
|
+
}
|
|
1203
|
+
acc[group].push(option);
|
|
1204
|
+
return acc;
|
|
1205
|
+
},
|
|
1206
|
+
{}
|
|
1207
|
+
);
|
|
1208
|
+
const result = [];
|
|
1209
|
+
Object.keys(grouped).forEach((title) => {
|
|
1210
|
+
result.push({ [AUTOCOMPLETE_GROUP_HEADER_PROPERTY]: true, title, extended });
|
|
1211
|
+
const groupOptions = grouped[title];
|
|
1212
|
+
if (groupOptions) {
|
|
1213
|
+
result.push(...groupOptions);
|
|
1214
|
+
}
|
|
1215
|
+
});
|
|
1216
|
+
return result;
|
|
1217
|
+
}
|
|
1218
|
+
function warnDeprecatedGroupBy(componentName) {
|
|
1219
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1220
|
+
console.error(
|
|
1221
|
+
`${componentName}: The \`groupBy\` prop is deprecated and breaks virtualization. Use \`createAutocompleteGroupByList\` instead:
|
|
1222
|
+
|
|
1223
|
+
\`\`\`
|
|
1224
|
+
import { createAutocompleteGroupByList, ${componentName} } from "@carto/meridian-ds/components"
|
|
1225
|
+
|
|
1226
|
+
const groupedOptions = createAutocompleteGroupByList({
|
|
1227
|
+
options,
|
|
1228
|
+
groupBy: (option) => option.category
|
|
1229
|
+
})
|
|
1230
|
+
|
|
1231
|
+
<${componentName} options={groupedOptions} />
|
|
1232
|
+
\`\`\`
|
|
1233
|
+
`
|
|
1234
|
+
);
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1099
1237
|
function _Autocomplete({
|
|
1100
1238
|
disabled,
|
|
1101
1239
|
loading,
|
|
1102
1240
|
...props
|
|
1103
1241
|
}, ref) {
|
|
1242
|
+
if (props.groupBy) {
|
|
1243
|
+
warnDeprecatedGroupBy("Autocomplete");
|
|
1244
|
+
}
|
|
1104
1245
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1105
1246
|
material.Autocomplete,
|
|
1106
1247
|
{
|
|
@@ -1117,15 +1258,24 @@ function _Autocomplete({
|
|
|
1117
1258
|
);
|
|
1118
1259
|
}
|
|
1119
1260
|
const Autocomplete = React.forwardRef(_Autocomplete);
|
|
1120
|
-
const getDefaultOptionLabel = (option) => {
|
|
1121
|
-
return option && typeof option === "object" ? option.title ?? String(option) : String(option);
|
|
1122
|
-
};
|
|
1123
|
-
const createOptionWithMultiple = (option, multiple) => {
|
|
1124
|
-
return typeof option !== "object" || option === null ? { value: option, multiple } : { ...option, multiple };
|
|
1125
|
-
};
|
|
1126
|
-
const getDefaultLimitTagsText = (more) => /* @__PURE__ */ jsxRuntime.jsx("span", { "data-testid": "more-options-tag", children: `+${more}` });
|
|
1127
1261
|
function useAutocompleteRenderOption() {
|
|
1128
1262
|
const renderOption = (props, option, state, getOptionLabel, customIcon) => {
|
|
1263
|
+
const { key, ...otherProps } = props;
|
|
1264
|
+
if (isAutocompleteListGroupHeader(option)) {
|
|
1265
|
+
return /* @__PURE__ */ React.createElement(
|
|
1266
|
+
MenuItem.MenuItem,
|
|
1267
|
+
{
|
|
1268
|
+
...otherProps,
|
|
1269
|
+
subtitle: true,
|
|
1270
|
+
extended: option.extended,
|
|
1271
|
+
key,
|
|
1272
|
+
"aria-disabled": true,
|
|
1273
|
+
"aria-selected": false
|
|
1274
|
+
},
|
|
1275
|
+
option.title
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1278
|
+
const regularOption = option;
|
|
1129
1279
|
const {
|
|
1130
1280
|
title,
|
|
1131
1281
|
inputValue,
|
|
@@ -1142,9 +1292,8 @@ function useAutocompleteRenderOption() {
|
|
|
1142
1292
|
alternativeTitle,
|
|
1143
1293
|
secondaryText,
|
|
1144
1294
|
multiple
|
|
1145
|
-
} =
|
|
1146
|
-
const
|
|
1147
|
-
const isPrimitiveOptionType = typeof option === "string" || typeof option === "number";
|
|
1295
|
+
} = regularOption;
|
|
1296
|
+
const isPrimitiveOptionType = typeof regularOption === "string" || typeof regularOption === "number";
|
|
1148
1297
|
const getOptionLabelText = (getOptionLabel2, option2, alternativeTitle2, title2) => {
|
|
1149
1298
|
if (alternativeTitle2) return alternativeTitle2;
|
|
1150
1299
|
if (title2) return title2;
|
|
@@ -1178,7 +1327,7 @@ function useAutocompleteRenderOption() {
|
|
|
1178
1327
|
/* @__PURE__ */ jsxRuntime.jsxs(material.ListItemText, { children: [
|
|
1179
1328
|
getOptionLabelText(
|
|
1180
1329
|
getOptionLabel ?? getDefaultOptionLabel,
|
|
1181
|
-
|
|
1330
|
+
regularOption,
|
|
1182
1331
|
alternativeTitle,
|
|
1183
1332
|
title
|
|
1184
1333
|
),
|
|
@@ -1265,8 +1414,16 @@ function useMultipleAutocomplete({
|
|
|
1265
1414
|
options,
|
|
1266
1415
|
value,
|
|
1267
1416
|
onChange,
|
|
1268
|
-
getOptionLabel
|
|
1417
|
+
getOptionLabel,
|
|
1418
|
+
size,
|
|
1419
|
+
counterFormatter,
|
|
1420
|
+
counterText,
|
|
1421
|
+
allSelectedText
|
|
1269
1422
|
}) {
|
|
1423
|
+
const intl = reactIntl.useIntl();
|
|
1424
|
+
const intlConfig = TablePaginationActions.useImperativeIntl(intl);
|
|
1425
|
+
const defaultCounterText = counterText || intlConfig.formatMessage({ id: "c4r.form.selected" });
|
|
1426
|
+
const defaultAllSelectedText = allSelectedText || intlConfig.formatMessage({ id: "c4r.form.allSelected" });
|
|
1270
1427
|
const [multipleValue, setMultipleValue] = React.useState(
|
|
1271
1428
|
Array.isArray(value) ? value : value ? [value] : []
|
|
1272
1429
|
);
|
|
@@ -1275,10 +1432,13 @@ function useMultipleAutocomplete({
|
|
|
1275
1432
|
const newValue = Array.isArray(value) ? value : value ? [value] : [];
|
|
1276
1433
|
setMultipleValue(newValue);
|
|
1277
1434
|
}, [value]);
|
|
1278
|
-
const
|
|
1279
|
-
|
|
1435
|
+
const selectableOptions = options.filter(
|
|
1436
|
+
(option) => !isAutocompleteListGroupHeader(option)
|
|
1437
|
+
);
|
|
1438
|
+
const allSelected = multipleValue.length === selectableOptions.length;
|
|
1439
|
+
const someSelected = multipleValue.length > 0 && multipleValue.length < selectableOptions.length;
|
|
1280
1440
|
const handleSelectAll = (event) => {
|
|
1281
|
-
const newValue = allSelected ? [] : [...
|
|
1441
|
+
const newValue = allSelected ? [] : [...selectableOptions];
|
|
1282
1442
|
setMultipleValue(newValue);
|
|
1283
1443
|
onChange == null ? void 0 : onChange(
|
|
1284
1444
|
event,
|
|
@@ -1300,31 +1460,173 @@ function useMultipleAutocomplete({
|
|
|
1300
1460
|
getOptionLabel
|
|
1301
1461
|
);
|
|
1302
1462
|
};
|
|
1463
|
+
const getCounterRenderTags = React.useCallback(() => {
|
|
1464
|
+
const formatter = counterFormatter || createCounterFormatter({
|
|
1465
|
+
counterText: defaultCounterText,
|
|
1466
|
+
allText: defaultAllSelectedText
|
|
1467
|
+
});
|
|
1468
|
+
return createCounterRenderTags({
|
|
1469
|
+
formatCounter: formatter,
|
|
1470
|
+
options,
|
|
1471
|
+
size,
|
|
1472
|
+
getOptionLabel: getOptionLabel ? (option) => getOptionLabel(option) : void 0
|
|
1473
|
+
});
|
|
1474
|
+
}, [
|
|
1475
|
+
options,
|
|
1476
|
+
counterFormatter,
|
|
1477
|
+
defaultCounterText,
|
|
1478
|
+
defaultAllSelectedText,
|
|
1479
|
+
size,
|
|
1480
|
+
getOptionLabel
|
|
1481
|
+
]);
|
|
1303
1482
|
return {
|
|
1304
1483
|
multipleValue,
|
|
1305
1484
|
allSelected,
|
|
1306
1485
|
someSelected,
|
|
1307
1486
|
handleSelectAll,
|
|
1308
1487
|
handleChange,
|
|
1309
|
-
multipleRenderOption
|
|
1488
|
+
multipleRenderOption,
|
|
1489
|
+
getCounterRenderTags
|
|
1310
1490
|
};
|
|
1311
1491
|
}
|
|
1312
|
-
|
|
1492
|
+
const List = material.styled("ul")(
|
|
1493
|
+
({ theme, hasFilters }) => ({
|
|
1494
|
+
...!hasFilters && {
|
|
1495
|
+
paddingTop: `${theme.spacing(1)} !important`
|
|
1496
|
+
}
|
|
1497
|
+
})
|
|
1498
|
+
);
|
|
1499
|
+
const ItemWrapper = material.styled("div")(({ style, theme, isSubtitle, isExtended, isMultiple }) => {
|
|
1500
|
+
const getSubtitleStyles = () => {
|
|
1501
|
+
const baseStyles = {
|
|
1502
|
+
height: TablePaginationActions.MENU_ITEM_SIZE_DENSE,
|
|
1503
|
+
minHeight: TablePaginationActions.MENU_ITEM_SIZE_DENSE,
|
|
1504
|
+
marginTop: `${theme.spacing(1)} !important`,
|
|
1505
|
+
alignItems: "flex-end",
|
|
1506
|
+
...theme.typography.caption,
|
|
1507
|
+
fontWeight: 500
|
|
1508
|
+
};
|
|
1509
|
+
if (isExtended) {
|
|
1510
|
+
baseStyles.alignItems = "center";
|
|
1511
|
+
if (isMultiple) {
|
|
1512
|
+
baseStyles.marginLeft = theme.spacing(0.5);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
return baseStyles;
|
|
1516
|
+
};
|
|
1517
|
+
return {
|
|
1518
|
+
pointerEvents: "none",
|
|
1519
|
+
// To avoid the extra div to receive the click event
|
|
1520
|
+
"& .MuiMenuItem-root": {
|
|
1521
|
+
pointerEvents: "auto",
|
|
1522
|
+
// Allow pointer events for the menu item
|
|
1523
|
+
marginTop: 0,
|
|
1524
|
+
"&:first-of-type": {
|
|
1525
|
+
marginTop: "0 !important"
|
|
1526
|
+
}
|
|
1527
|
+
},
|
|
1528
|
+
...isSubtitle && {
|
|
1529
|
+
"& .MuiAutocomplete-option.MuiMenuItem-root": getSubtitleStyles(),
|
|
1530
|
+
// First item has no divider
|
|
1531
|
+
"&:not(:first-of-type)": {
|
|
1532
|
+
"&::before": {
|
|
1533
|
+
content: '""',
|
|
1534
|
+
position: "absolute",
|
|
1535
|
+
zIndex: 1,
|
|
1536
|
+
top: theme.spacing(0.5),
|
|
1537
|
+
left: 0,
|
|
1538
|
+
right: 0,
|
|
1539
|
+
height: "1px",
|
|
1540
|
+
backgroundColor: theme.palette.divider
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
},
|
|
1544
|
+
...!isSubtitle && {
|
|
1545
|
+
"& .MuiAutocomplete-option": {
|
|
1546
|
+
minHeight: `${style == null ? void 0 : style.height}px !important`
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
};
|
|
1550
|
+
});
|
|
1551
|
+
function _AutocompleteList({
|
|
1313
1552
|
children,
|
|
1314
1553
|
showFilters,
|
|
1315
1554
|
allSelected,
|
|
1316
1555
|
someSelected,
|
|
1317
1556
|
handleSelectAll = () => void 0,
|
|
1318
1557
|
multiple,
|
|
1558
|
+
extended,
|
|
1559
|
+
itemHeight,
|
|
1560
|
+
maxListHeight = TablePaginationActions.MENU_LIST_MAX_SIZE,
|
|
1319
1561
|
...otherProps
|
|
1320
1562
|
}, ref) {
|
|
1563
|
+
const childrenArray = React.useMemo(() => {
|
|
1564
|
+
return React.Children.toArray(children).map((child) => {
|
|
1565
|
+
if (!React.isValidElement(child)) {
|
|
1566
|
+
return {
|
|
1567
|
+
child,
|
|
1568
|
+
isSubtitle: false,
|
|
1569
|
+
isExtended: false,
|
|
1570
|
+
isMultiple: !!multiple
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
const props = child.props;
|
|
1574
|
+
return {
|
|
1575
|
+
child,
|
|
1576
|
+
isSubtitle: props.subtitle === true,
|
|
1577
|
+
isExtended: props.extended === true,
|
|
1578
|
+
isMultiple: !!multiple
|
|
1579
|
+
};
|
|
1580
|
+
});
|
|
1581
|
+
}, [children, multiple]);
|
|
1582
|
+
const defaultItemHeight = itemHeight ?? (extended ? TablePaginationActions.MENU_ITEM_SIZE_EXTENDED : TablePaginationActions.MENU_ITEM_SIZE_DEFAULT);
|
|
1583
|
+
const listboxHeight = React.useMemo(() => {
|
|
1584
|
+
const filterHeight = showFilters && multiple ? TablePaginationActions.MENU_ITEM_SIZE_EXTENDED : 0;
|
|
1585
|
+
const availableHeight = maxListHeight - filterHeight;
|
|
1586
|
+
const calculatedHeight = Math.min(
|
|
1587
|
+
childrenArray.length * defaultItemHeight,
|
|
1588
|
+
availableHeight
|
|
1589
|
+
);
|
|
1590
|
+
return Math.max(calculatedHeight, defaultItemHeight);
|
|
1591
|
+
}, [
|
|
1592
|
+
showFilters,
|
|
1593
|
+
multiple,
|
|
1594
|
+
maxListHeight,
|
|
1595
|
+
childrenArray.length,
|
|
1596
|
+
defaultItemHeight
|
|
1597
|
+
]);
|
|
1598
|
+
const renderItem = ({
|
|
1599
|
+
index,
|
|
1600
|
+
style
|
|
1601
|
+
}) => {
|
|
1602
|
+
const item = childrenArray[index];
|
|
1603
|
+
if (!item) return null;
|
|
1604
|
+
const { child, isSubtitle, isExtended, isMultiple } = item;
|
|
1605
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1606
|
+
ItemWrapper,
|
|
1607
|
+
{
|
|
1608
|
+
style,
|
|
1609
|
+
isSubtitle,
|
|
1610
|
+
isExtended,
|
|
1611
|
+
isMultiple,
|
|
1612
|
+
"data-name": "virtual-menu-item",
|
|
1613
|
+
children: child
|
|
1614
|
+
}
|
|
1615
|
+
);
|
|
1616
|
+
};
|
|
1321
1617
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1322
|
-
|
|
1618
|
+
List,
|
|
1323
1619
|
{
|
|
1324
1620
|
ref,
|
|
1325
1621
|
...otherProps,
|
|
1326
1622
|
role: "listbox",
|
|
1623
|
+
"data-list-height": listboxHeight,
|
|
1624
|
+
"data-item-height": defaultItemHeight,
|
|
1327
1625
|
"aria-multiselectable": multiple,
|
|
1626
|
+
hasFilters: showFilters,
|
|
1627
|
+
style: {
|
|
1628
|
+
maxHeight: maxListHeight + defaultItemHeight
|
|
1629
|
+
},
|
|
1328
1630
|
children: [
|
|
1329
1631
|
showFilters && multiple && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1330
1632
|
MenuItemFilter,
|
|
@@ -1334,12 +1636,21 @@ function _ListboxWithFilter({
|
|
|
1334
1636
|
selectAll: handleSelectAll
|
|
1335
1637
|
}
|
|
1336
1638
|
),
|
|
1337
|
-
|
|
1639
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1640
|
+
reactWindow.FixedSizeList,
|
|
1641
|
+
{
|
|
1642
|
+
height: listboxHeight,
|
|
1643
|
+
width: "100%",
|
|
1644
|
+
itemCount: childrenArray.length,
|
|
1645
|
+
itemSize: defaultItemHeight,
|
|
1646
|
+
children: renderItem
|
|
1647
|
+
}
|
|
1648
|
+
)
|
|
1338
1649
|
]
|
|
1339
1650
|
}
|
|
1340
1651
|
);
|
|
1341
1652
|
}
|
|
1342
|
-
const
|
|
1653
|
+
const AutocompleteList = React.forwardRef(_AutocompleteList);
|
|
1343
1654
|
function _CreatableAutocomplete({
|
|
1344
1655
|
newItemLabel,
|
|
1345
1656
|
newItemIcon,
|
|
@@ -1349,23 +1660,41 @@ function _CreatableAutocomplete({
|
|
|
1349
1660
|
disabled,
|
|
1350
1661
|
loading,
|
|
1351
1662
|
showFilters,
|
|
1663
|
+
showCounter = false,
|
|
1664
|
+
counterFormatter,
|
|
1665
|
+
counterText,
|
|
1666
|
+
allSelectedText,
|
|
1352
1667
|
options = [],
|
|
1353
1668
|
value,
|
|
1354
1669
|
onChange,
|
|
1355
1670
|
getLimitTagsText,
|
|
1671
|
+
renderTags,
|
|
1672
|
+
itemHeight,
|
|
1673
|
+
maxListHeight,
|
|
1674
|
+
extended,
|
|
1675
|
+
groupBy,
|
|
1356
1676
|
...props
|
|
1357
1677
|
}, ref) {
|
|
1678
|
+
if (groupBy) {
|
|
1679
|
+
warnDeprecatedGroupBy("CreatableAutocomplete");
|
|
1680
|
+
}
|
|
1358
1681
|
const { freeSolo = true, ...otherProps } = props;
|
|
1359
1682
|
const {
|
|
1360
1683
|
multipleValue,
|
|
1361
1684
|
allSelected,
|
|
1362
1685
|
someSelected,
|
|
1363
1686
|
handleSelectAll,
|
|
1364
|
-
handleChange
|
|
1687
|
+
handleChange,
|
|
1688
|
+
getCounterRenderTags
|
|
1365
1689
|
} = useMultipleAutocomplete({
|
|
1366
1690
|
options,
|
|
1367
1691
|
value,
|
|
1368
|
-
onChange
|
|
1692
|
+
onChange,
|
|
1693
|
+
getOptionLabel,
|
|
1694
|
+
size: props.size,
|
|
1695
|
+
counterFormatter,
|
|
1696
|
+
counterText,
|
|
1697
|
+
allSelectedText
|
|
1369
1698
|
});
|
|
1370
1699
|
const {
|
|
1371
1700
|
creatableFilterOptions,
|
|
@@ -1377,6 +1706,17 @@ function _CreatableAutocomplete({
|
|
|
1377
1706
|
newItemIcon,
|
|
1378
1707
|
multiple
|
|
1379
1708
|
});
|
|
1709
|
+
const listboxProps = {
|
|
1710
|
+
showFilters,
|
|
1711
|
+
allSelected,
|
|
1712
|
+
someSelected,
|
|
1713
|
+
handleSelectAll,
|
|
1714
|
+
multiple,
|
|
1715
|
+
itemHeight,
|
|
1716
|
+
maxListHeight,
|
|
1717
|
+
extended
|
|
1718
|
+
};
|
|
1719
|
+
const finalRenderTags = showCounter && multiple && !renderTags ? getCounterRenderTags() : renderTags;
|
|
1380
1720
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1381
1721
|
material.Autocomplete,
|
|
1382
1722
|
{
|
|
@@ -1388,18 +1728,13 @@ function _CreatableAutocomplete({
|
|
|
1388
1728
|
filterOptions: creatableFilterOptions,
|
|
1389
1729
|
getOptionLabel: creatableOptionLabel,
|
|
1390
1730
|
renderOption: creatableRenderOption,
|
|
1731
|
+
renderTags: finalRenderTags,
|
|
1391
1732
|
freeSolo,
|
|
1392
1733
|
forcePopupIcon: true,
|
|
1393
1734
|
multiple,
|
|
1394
1735
|
disableCloseOnSelect: disableCloseOnSelect ?? multiple,
|
|
1395
|
-
ListboxComponent:
|
|
1396
|
-
ListboxProps:
|
|
1397
|
-
showFilters,
|
|
1398
|
-
allSelected,
|
|
1399
|
-
someSelected,
|
|
1400
|
-
handleSelectAll,
|
|
1401
|
-
multiple
|
|
1402
|
-
},
|
|
1736
|
+
ListboxComponent: AutocompleteList,
|
|
1737
|
+
ListboxProps: listboxProps,
|
|
1403
1738
|
getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
|
|
1404
1739
|
disabled: disabled || loading,
|
|
1405
1740
|
popupIcon: loading ? /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" }) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}),
|
|
@@ -1414,26 +1749,54 @@ function _MultipleAutocomplete({
|
|
|
1414
1749
|
disabled,
|
|
1415
1750
|
loading,
|
|
1416
1751
|
showFilters,
|
|
1752
|
+
showCounter = false,
|
|
1753
|
+
counterFormatter,
|
|
1754
|
+
counterText,
|
|
1755
|
+
allSelectedText,
|
|
1417
1756
|
options,
|
|
1418
1757
|
value,
|
|
1419
1758
|
onChange,
|
|
1420
1759
|
getOptionLabel,
|
|
1421
1760
|
getLimitTagsText,
|
|
1761
|
+
renderTags,
|
|
1762
|
+
itemHeight,
|
|
1763
|
+
maxListHeight,
|
|
1764
|
+
extended,
|
|
1765
|
+
groupBy,
|
|
1422
1766
|
...props
|
|
1423
1767
|
}, ref) {
|
|
1768
|
+
if (groupBy) {
|
|
1769
|
+
warnDeprecatedGroupBy("MultipleAutocomplete");
|
|
1770
|
+
}
|
|
1424
1771
|
const {
|
|
1425
1772
|
multipleValue,
|
|
1426
1773
|
allSelected,
|
|
1427
1774
|
someSelected,
|
|
1428
1775
|
handleSelectAll,
|
|
1429
1776
|
handleChange,
|
|
1430
|
-
multipleRenderOption
|
|
1777
|
+
multipleRenderOption,
|
|
1778
|
+
getCounterRenderTags
|
|
1431
1779
|
} = useMultipleAutocomplete({
|
|
1432
1780
|
options,
|
|
1433
1781
|
value,
|
|
1434
1782
|
onChange,
|
|
1435
|
-
getOptionLabel
|
|
1783
|
+
getOptionLabel,
|
|
1784
|
+
size: props.size,
|
|
1785
|
+
counterFormatter,
|
|
1786
|
+
counterText,
|
|
1787
|
+
allSelectedText
|
|
1436
1788
|
});
|
|
1789
|
+
const listboxProps = {
|
|
1790
|
+
showFilters,
|
|
1791
|
+
allSelected,
|
|
1792
|
+
someSelected,
|
|
1793
|
+
handleSelectAll,
|
|
1794
|
+
multiple: true,
|
|
1795
|
+
itemHeight,
|
|
1796
|
+
maxListHeight,
|
|
1797
|
+
extended
|
|
1798
|
+
};
|
|
1799
|
+
const finalRenderTags = showCounter && !renderTags ? getCounterRenderTags() : renderTags;
|
|
1437
1800
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1438
1801
|
material.Autocomplete,
|
|
1439
1802
|
{
|
|
@@ -1444,14 +1807,9 @@ function _MultipleAutocomplete({
|
|
|
1444
1807
|
onChange: handleChange,
|
|
1445
1808
|
getOptionLabel,
|
|
1446
1809
|
renderOption: renderOption ?? multipleRenderOption,
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
allSelected,
|
|
1451
|
-
someSelected,
|
|
1452
|
-
handleSelectAll,
|
|
1453
|
-
multiple: true
|
|
1454
|
-
},
|
|
1810
|
+
renderTags: finalRenderTags,
|
|
1811
|
+
ListboxComponent: AutocompleteList,
|
|
1812
|
+
ListboxProps: listboxProps,
|
|
1455
1813
|
multiple: true,
|
|
1456
1814
|
getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
|
|
1457
1815
|
disableCloseOnSelect,
|
|
@@ -1462,6 +1820,30 @@ function _MultipleAutocomplete({
|
|
|
1462
1820
|
);
|
|
1463
1821
|
}
|
|
1464
1822
|
const MultipleAutocomplete = React.forwardRef(_MultipleAutocomplete);
|
|
1823
|
+
function useAutocomplete({
|
|
1824
|
+
getOptionLabel = getDefaultOptionLabel
|
|
1825
|
+
}) {
|
|
1826
|
+
const { renderOption: autocompleteRenderOption } = useAutocompleteRenderOption();
|
|
1827
|
+
const internalGetOptionLabel = (option) => {
|
|
1828
|
+
if (isAutocompleteListGroupHeader(option)) {
|
|
1829
|
+
return option.title;
|
|
1830
|
+
}
|
|
1831
|
+
return getOptionLabel(option);
|
|
1832
|
+
};
|
|
1833
|
+
const singleRenderOption = (props, option, state) => {
|
|
1834
|
+
const optionWithMultiple = createOptionWithMultiple(option, false);
|
|
1835
|
+
return autocompleteRenderOption(
|
|
1836
|
+
props,
|
|
1837
|
+
optionWithMultiple,
|
|
1838
|
+
state,
|
|
1839
|
+
internalGetOptionLabel
|
|
1840
|
+
);
|
|
1841
|
+
};
|
|
1842
|
+
return {
|
|
1843
|
+
singleRenderOption,
|
|
1844
|
+
getOptionLabel: internalGetOptionLabel
|
|
1845
|
+
};
|
|
1846
|
+
}
|
|
1465
1847
|
const _CopiableComponent = ({
|
|
1466
1848
|
children,
|
|
1467
1849
|
disabled,
|
|
@@ -4686,9 +5068,11 @@ exports.Typography = TablePaginationActions.Typography;
|
|
|
4686
5068
|
exports.Alert = Alert$1.Alert;
|
|
4687
5069
|
exports.IconButton = Alert$1.IconButton;
|
|
4688
5070
|
exports.MenuItem = MenuItem.MenuItem;
|
|
5071
|
+
exports.AUTOCOMPLETE_GROUP_HEADER_PROPERTY = AUTOCOMPLETE_GROUP_HEADER_PROPERTY;
|
|
4689
5072
|
exports.AccordionGroup = AccordionGroup;
|
|
4690
5073
|
exports.AppBar = AppBar;
|
|
4691
5074
|
exports.Autocomplete = Autocomplete;
|
|
5075
|
+
exports.AutocompleteList = AutocompleteList;
|
|
4692
5076
|
exports.Avatar = Avatar;
|
|
4693
5077
|
exports.Button = Button;
|
|
4694
5078
|
exports.CodeAreaDialog = CodeAreaDialog;
|
|
@@ -4732,5 +5116,8 @@ exports.TooltipData = TooltipData;
|
|
|
4732
5116
|
exports.UploadField = UploadField;
|
|
4733
5117
|
exports.UploadFieldBase = UploadFieldBase;
|
|
4734
5118
|
exports.copyString = copyString;
|
|
5119
|
+
exports.createAutocompleteGroupByList = createAutocompleteGroupByList;
|
|
4735
5120
|
exports.dialogDimensionsBySize = dialogDimensionsBySize;
|
|
5121
|
+
exports.isAutocompleteListGroupHeader = isAutocompleteListGroupHeader;
|
|
5122
|
+
exports.useAutocomplete = useAutocomplete;
|
|
4736
5123
|
exports.useCopyValue = useCopyValue;
|