@carto/meridian-ds 1.5.1 → 2.0.0
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 +9 -0
- package/dist/{Alert-BiOR9aar.cjs → Alert-BzEgeyQJ.cjs} +1 -1
- package/dist/{Alert-CywtIMOj.js → Alert-CnaTtNJd.js} +1 -1
- package/dist/{ArrowDown-8fLj23Ge.cjs → ArrowDown-DJ0vhbsw.cjs} +2 -2
- package/dist/{ArrowDown-CY_wMVJT.js → ArrowDown-d6bxUL0F.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/{OpenDiagonallyRight-CSm5GYYJ.js → OpenDiagonallyRight-CGdCEXlF.js} +1 -1
- package/dist/{OpenDiagonallyRight-CM1tojUq.cjs → OpenDiagonallyRight-CpL4ROwg.cjs} +4 -4
- package/dist/{SwatchSquare-benaO55C.cjs → SwatchSquare-B8PIY3Rd.cjs} +3 -3
- package/dist/{SwatchSquare-DhaaXt53.js → SwatchSquare-CaaLsjAC.js} +1 -1
- 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 +430 -55
- package/dist/components/index.js +432 -57
- package/dist/custom-icons/index.cjs +608 -486
- package/dist/custom-icons/index.js +561 -439
- package/dist/theme/index.cjs +14 -10
- package/dist/theme/index.js +15 -11
- 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/custom-icons/AiAgent.d.ts +4 -0
- package/dist/types/custom-icons/AiAgent.d.ts.map +1 -0
- package/dist/types/custom-icons/HideRightsidebar.d.ts +4 -0
- package/dist/types/custom-icons/HideRightsidebar.d.ts.map +1 -0
- package/dist/types/custom-icons/ShowRightsidebar.d.ts +4 -0
- package/dist/types/custom-icons/ShowRightsidebar.d.ts.map +1 -0
- package/dist/types/custom-icons/index.d.ts +3 -0
- package/dist/types/custom-icons/index.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 +3 -3
- package/dist/widgets/index.js +3 -3
- 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-
|
|
7
|
-
const ArrowDown = require("../ArrowDown-
|
|
8
|
-
const OpenDiagonallyRight = require("../OpenDiagonallyRight-
|
|
6
|
+
const TablePaginationActions = require("../TablePaginationActions-mbbjzV6Y.cjs");
|
|
7
|
+
const ArrowDown = require("../ArrowDown-DJ0vhbsw.cjs");
|
|
8
|
+
const OpenDiagonallyRight = require("../OpenDiagonallyRight-CpL4ROwg.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");
|
|
@@ -479,10 +480,10 @@ function ToggleButtonGroup({
|
|
|
479
480
|
}
|
|
480
481
|
const StyledMenu = material.styled(material.Menu, {
|
|
481
482
|
shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
|
|
482
|
-
})(({
|
|
483
|
+
})(({ extended, width, height }) => ({
|
|
483
484
|
...extended && {
|
|
484
485
|
".MuiMenuItem-root": {
|
|
485
|
-
minHeight:
|
|
486
|
+
minHeight: TablePaginationActions.MENU_ITEM_SIZE_EXTENDED
|
|
486
487
|
}
|
|
487
488
|
},
|
|
488
489
|
...width && {
|
|
@@ -522,10 +523,10 @@ function _Menu({ extended, width, height, MenuListProps, ...otherProps }, ref) {
|
|
|
522
523
|
const Menu$1 = React.forwardRef(_Menu);
|
|
523
524
|
const StyledMenuList = material.styled(material.MenuList, {
|
|
524
525
|
shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
|
|
525
|
-
})(({
|
|
526
|
+
})(({ extended, width, height }) => ({
|
|
526
527
|
...extended && {
|
|
527
528
|
".MuiMenuItem-root": {
|
|
528
|
-
minHeight:
|
|
529
|
+
minHeight: TablePaginationActions.MENU_ITEM_SIZE_EXTENDED
|
|
529
530
|
}
|
|
530
531
|
},
|
|
531
532
|
"&.MuiList-root": {
|
|
@@ -556,7 +557,8 @@ function _MenuList({ extended, width, height, ...otherProps }, ref) {
|
|
|
556
557
|
}
|
|
557
558
|
const MenuList = React.forwardRef(_MenuList);
|
|
558
559
|
const StyledMenuItem$1 = material.styled(MenuItem.MenuItem)(() => ({
|
|
559
|
-
marginTop: "0 !important"
|
|
560
|
+
marginTop: "0 !important",
|
|
561
|
+
marginBottom: "0 !important"
|
|
560
562
|
}));
|
|
561
563
|
const LinkFilter = material.styled(material.Link)(
|
|
562
564
|
({ disabled, theme }) => ({
|
|
@@ -796,12 +798,20 @@ function _MultipleSelectField({
|
|
|
796
798
|
},
|
|
797
799
|
children: [
|
|
798
800
|
showFilters && /* @__PURE__ */ jsxRuntime.jsx(
|
|
799
|
-
|
|
801
|
+
material.Box,
|
|
800
802
|
{
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
803
|
+
sx: {
|
|
804
|
+
mb: 1
|
|
805
|
+
},
|
|
806
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
807
|
+
MenuItemFilter,
|
|
808
|
+
{
|
|
809
|
+
areAllSelected,
|
|
810
|
+
areAnySelected,
|
|
811
|
+
selectAll,
|
|
812
|
+
selectAllDisabled
|
|
813
|
+
}
|
|
814
|
+
)
|
|
805
815
|
}
|
|
806
816
|
),
|
|
807
817
|
options == null ? void 0 : options.map((option) => {
|
|
@@ -1108,11 +1118,130 @@ function UploadField({
|
|
|
1108
1118
|
)
|
|
1109
1119
|
] });
|
|
1110
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
|
+
}
|
|
1111
1237
|
function _Autocomplete({
|
|
1112
1238
|
disabled,
|
|
1113
1239
|
loading,
|
|
1114
1240
|
...props
|
|
1115
1241
|
}, ref) {
|
|
1242
|
+
if (props.groupBy) {
|
|
1243
|
+
warnDeprecatedGroupBy("Autocomplete");
|
|
1244
|
+
}
|
|
1116
1245
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1117
1246
|
material.Autocomplete,
|
|
1118
1247
|
{
|
|
@@ -1129,15 +1258,24 @@ function _Autocomplete({
|
|
|
1129
1258
|
);
|
|
1130
1259
|
}
|
|
1131
1260
|
const Autocomplete = React.forwardRef(_Autocomplete);
|
|
1132
|
-
const getDefaultOptionLabel = (option) => {
|
|
1133
|
-
return option && typeof option === "object" ? option.title ?? String(option) : String(option);
|
|
1134
|
-
};
|
|
1135
|
-
const createOptionWithMultiple = (option, multiple) => {
|
|
1136
|
-
return typeof option !== "object" || option === null ? { value: option, multiple } : { ...option, multiple };
|
|
1137
|
-
};
|
|
1138
|
-
const getDefaultLimitTagsText = (more) => /* @__PURE__ */ jsxRuntime.jsx("span", { "data-testid": "more-options-tag", children: `+${more}` });
|
|
1139
1261
|
function useAutocompleteRenderOption() {
|
|
1140
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;
|
|
1141
1279
|
const {
|
|
1142
1280
|
title,
|
|
1143
1281
|
inputValue,
|
|
@@ -1154,9 +1292,8 @@ function useAutocompleteRenderOption() {
|
|
|
1154
1292
|
alternativeTitle,
|
|
1155
1293
|
secondaryText,
|
|
1156
1294
|
multiple
|
|
1157
|
-
} =
|
|
1158
|
-
const
|
|
1159
|
-
const isPrimitiveOptionType = typeof option === "string" || typeof option === "number";
|
|
1295
|
+
} = regularOption;
|
|
1296
|
+
const isPrimitiveOptionType = typeof regularOption === "string" || typeof regularOption === "number";
|
|
1160
1297
|
const getOptionLabelText = (getOptionLabel2, option2, alternativeTitle2, title2) => {
|
|
1161
1298
|
if (alternativeTitle2) return alternativeTitle2;
|
|
1162
1299
|
if (title2) return title2;
|
|
@@ -1190,7 +1327,7 @@ function useAutocompleteRenderOption() {
|
|
|
1190
1327
|
/* @__PURE__ */ jsxRuntime.jsxs(material.ListItemText, { children: [
|
|
1191
1328
|
getOptionLabelText(
|
|
1192
1329
|
getOptionLabel ?? getDefaultOptionLabel,
|
|
1193
|
-
|
|
1330
|
+
regularOption,
|
|
1194
1331
|
alternativeTitle,
|
|
1195
1332
|
title
|
|
1196
1333
|
),
|
|
@@ -1277,8 +1414,16 @@ function useMultipleAutocomplete({
|
|
|
1277
1414
|
options,
|
|
1278
1415
|
value,
|
|
1279
1416
|
onChange,
|
|
1280
|
-
getOptionLabel
|
|
1417
|
+
getOptionLabel,
|
|
1418
|
+
size,
|
|
1419
|
+
counterFormatter,
|
|
1420
|
+
counterText,
|
|
1421
|
+
allSelectedText
|
|
1281
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" });
|
|
1282
1427
|
const [multipleValue, setMultipleValue] = React.useState(
|
|
1283
1428
|
Array.isArray(value) ? value : value ? [value] : []
|
|
1284
1429
|
);
|
|
@@ -1287,10 +1432,13 @@ function useMultipleAutocomplete({
|
|
|
1287
1432
|
const newValue = Array.isArray(value) ? value : value ? [value] : [];
|
|
1288
1433
|
setMultipleValue(newValue);
|
|
1289
1434
|
}, [value]);
|
|
1290
|
-
const
|
|
1291
|
-
|
|
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;
|
|
1292
1440
|
const handleSelectAll = (event) => {
|
|
1293
|
-
const newValue = allSelected ? [] : [...
|
|
1441
|
+
const newValue = allSelected ? [] : [...selectableOptions];
|
|
1294
1442
|
setMultipleValue(newValue);
|
|
1295
1443
|
onChange == null ? void 0 : onChange(
|
|
1296
1444
|
event,
|
|
@@ -1312,31 +1460,173 @@ function useMultipleAutocomplete({
|
|
|
1312
1460
|
getOptionLabel
|
|
1313
1461
|
);
|
|
1314
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
|
+
]);
|
|
1315
1482
|
return {
|
|
1316
1483
|
multipleValue,
|
|
1317
1484
|
allSelected,
|
|
1318
1485
|
someSelected,
|
|
1319
1486
|
handleSelectAll,
|
|
1320
1487
|
handleChange,
|
|
1321
|
-
multipleRenderOption
|
|
1488
|
+
multipleRenderOption,
|
|
1489
|
+
getCounterRenderTags
|
|
1322
1490
|
};
|
|
1323
1491
|
}
|
|
1324
|
-
|
|
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({
|
|
1325
1552
|
children,
|
|
1326
1553
|
showFilters,
|
|
1327
1554
|
allSelected,
|
|
1328
1555
|
someSelected,
|
|
1329
1556
|
handleSelectAll = () => void 0,
|
|
1330
1557
|
multiple,
|
|
1558
|
+
extended,
|
|
1559
|
+
itemHeight,
|
|
1560
|
+
maxListHeight = TablePaginationActions.MENU_LIST_MAX_SIZE,
|
|
1331
1561
|
...otherProps
|
|
1332
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
|
+
};
|
|
1333
1617
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1334
|
-
|
|
1618
|
+
List,
|
|
1335
1619
|
{
|
|
1336
1620
|
ref,
|
|
1337
1621
|
...otherProps,
|
|
1338
1622
|
role: "listbox",
|
|
1623
|
+
"data-list-height": listboxHeight,
|
|
1624
|
+
"data-item-height": defaultItemHeight,
|
|
1339
1625
|
"aria-multiselectable": multiple,
|
|
1626
|
+
hasFilters: showFilters,
|
|
1627
|
+
style: {
|
|
1628
|
+
maxHeight: maxListHeight + defaultItemHeight
|
|
1629
|
+
},
|
|
1340
1630
|
children: [
|
|
1341
1631
|
showFilters && multiple && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1342
1632
|
MenuItemFilter,
|
|
@@ -1346,12 +1636,21 @@ function _ListboxWithFilter({
|
|
|
1346
1636
|
selectAll: handleSelectAll
|
|
1347
1637
|
}
|
|
1348
1638
|
),
|
|
1349
|
-
|
|
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
|
+
)
|
|
1350
1649
|
]
|
|
1351
1650
|
}
|
|
1352
1651
|
);
|
|
1353
1652
|
}
|
|
1354
|
-
const
|
|
1653
|
+
const AutocompleteList = React.forwardRef(_AutocompleteList);
|
|
1355
1654
|
function _CreatableAutocomplete({
|
|
1356
1655
|
newItemLabel,
|
|
1357
1656
|
newItemIcon,
|
|
@@ -1361,23 +1660,41 @@ function _CreatableAutocomplete({
|
|
|
1361
1660
|
disabled,
|
|
1362
1661
|
loading,
|
|
1363
1662
|
showFilters,
|
|
1663
|
+
showCounter = false,
|
|
1664
|
+
counterFormatter,
|
|
1665
|
+
counterText,
|
|
1666
|
+
allSelectedText,
|
|
1364
1667
|
options = [],
|
|
1365
1668
|
value,
|
|
1366
1669
|
onChange,
|
|
1367
1670
|
getLimitTagsText,
|
|
1671
|
+
renderTags,
|
|
1672
|
+
itemHeight,
|
|
1673
|
+
maxListHeight,
|
|
1674
|
+
extended,
|
|
1675
|
+
groupBy,
|
|
1368
1676
|
...props
|
|
1369
1677
|
}, ref) {
|
|
1678
|
+
if (groupBy) {
|
|
1679
|
+
warnDeprecatedGroupBy("CreatableAutocomplete");
|
|
1680
|
+
}
|
|
1370
1681
|
const { freeSolo = true, ...otherProps } = props;
|
|
1371
1682
|
const {
|
|
1372
1683
|
multipleValue,
|
|
1373
1684
|
allSelected,
|
|
1374
1685
|
someSelected,
|
|
1375
1686
|
handleSelectAll,
|
|
1376
|
-
handleChange
|
|
1687
|
+
handleChange,
|
|
1688
|
+
getCounterRenderTags
|
|
1377
1689
|
} = useMultipleAutocomplete({
|
|
1378
1690
|
options,
|
|
1379
1691
|
value,
|
|
1380
|
-
onChange
|
|
1692
|
+
onChange,
|
|
1693
|
+
getOptionLabel,
|
|
1694
|
+
size: props.size,
|
|
1695
|
+
counterFormatter,
|
|
1696
|
+
counterText,
|
|
1697
|
+
allSelectedText
|
|
1381
1698
|
});
|
|
1382
1699
|
const {
|
|
1383
1700
|
creatableFilterOptions,
|
|
@@ -1389,6 +1706,17 @@ function _CreatableAutocomplete({
|
|
|
1389
1706
|
newItemIcon,
|
|
1390
1707
|
multiple
|
|
1391
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;
|
|
1392
1720
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1393
1721
|
material.Autocomplete,
|
|
1394
1722
|
{
|
|
@@ -1400,18 +1728,13 @@ function _CreatableAutocomplete({
|
|
|
1400
1728
|
filterOptions: creatableFilterOptions,
|
|
1401
1729
|
getOptionLabel: creatableOptionLabel,
|
|
1402
1730
|
renderOption: creatableRenderOption,
|
|
1731
|
+
renderTags: finalRenderTags,
|
|
1403
1732
|
freeSolo,
|
|
1404
1733
|
forcePopupIcon: true,
|
|
1405
1734
|
multiple,
|
|
1406
1735
|
disableCloseOnSelect: disableCloseOnSelect ?? multiple,
|
|
1407
|
-
ListboxComponent:
|
|
1408
|
-
ListboxProps:
|
|
1409
|
-
showFilters,
|
|
1410
|
-
allSelected,
|
|
1411
|
-
someSelected,
|
|
1412
|
-
handleSelectAll,
|
|
1413
|
-
multiple
|
|
1414
|
-
},
|
|
1736
|
+
ListboxComponent: AutocompleteList,
|
|
1737
|
+
ListboxProps: listboxProps,
|
|
1415
1738
|
getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
|
|
1416
1739
|
disabled: disabled || loading,
|
|
1417
1740
|
popupIcon: loading ? /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" }) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}),
|
|
@@ -1426,26 +1749,54 @@ function _MultipleAutocomplete({
|
|
|
1426
1749
|
disabled,
|
|
1427
1750
|
loading,
|
|
1428
1751
|
showFilters,
|
|
1752
|
+
showCounter = false,
|
|
1753
|
+
counterFormatter,
|
|
1754
|
+
counterText,
|
|
1755
|
+
allSelectedText,
|
|
1429
1756
|
options,
|
|
1430
1757
|
value,
|
|
1431
1758
|
onChange,
|
|
1432
1759
|
getOptionLabel,
|
|
1433
1760
|
getLimitTagsText,
|
|
1761
|
+
renderTags,
|
|
1762
|
+
itemHeight,
|
|
1763
|
+
maxListHeight,
|
|
1764
|
+
extended,
|
|
1765
|
+
groupBy,
|
|
1434
1766
|
...props
|
|
1435
1767
|
}, ref) {
|
|
1768
|
+
if (groupBy) {
|
|
1769
|
+
warnDeprecatedGroupBy("MultipleAutocomplete");
|
|
1770
|
+
}
|
|
1436
1771
|
const {
|
|
1437
1772
|
multipleValue,
|
|
1438
1773
|
allSelected,
|
|
1439
1774
|
someSelected,
|
|
1440
1775
|
handleSelectAll,
|
|
1441
1776
|
handleChange,
|
|
1442
|
-
multipleRenderOption
|
|
1777
|
+
multipleRenderOption,
|
|
1778
|
+
getCounterRenderTags
|
|
1443
1779
|
} = useMultipleAutocomplete({
|
|
1444
1780
|
options,
|
|
1445
1781
|
value,
|
|
1446
1782
|
onChange,
|
|
1447
|
-
getOptionLabel
|
|
1783
|
+
getOptionLabel,
|
|
1784
|
+
size: props.size,
|
|
1785
|
+
counterFormatter,
|
|
1786
|
+
counterText,
|
|
1787
|
+
allSelectedText
|
|
1448
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;
|
|
1449
1800
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1450
1801
|
material.Autocomplete,
|
|
1451
1802
|
{
|
|
@@ -1456,14 +1807,9 @@ function _MultipleAutocomplete({
|
|
|
1456
1807
|
onChange: handleChange,
|
|
1457
1808
|
getOptionLabel,
|
|
1458
1809
|
renderOption: renderOption ?? multipleRenderOption,
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
allSelected,
|
|
1463
|
-
someSelected,
|
|
1464
|
-
handleSelectAll,
|
|
1465
|
-
multiple: true
|
|
1466
|
-
},
|
|
1810
|
+
renderTags: finalRenderTags,
|
|
1811
|
+
ListboxComponent: AutocompleteList,
|
|
1812
|
+
ListboxProps: listboxProps,
|
|
1467
1813
|
multiple: true,
|
|
1468
1814
|
getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
|
|
1469
1815
|
disableCloseOnSelect,
|
|
@@ -1474,6 +1820,30 @@ function _MultipleAutocomplete({
|
|
|
1474
1820
|
);
|
|
1475
1821
|
}
|
|
1476
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
|
+
}
|
|
1477
1847
|
const _CopiableComponent = ({
|
|
1478
1848
|
children,
|
|
1479
1849
|
disabled,
|
|
@@ -4698,9 +5068,11 @@ exports.Typography = TablePaginationActions.Typography;
|
|
|
4698
5068
|
exports.Alert = Alert$1.Alert;
|
|
4699
5069
|
exports.IconButton = Alert$1.IconButton;
|
|
4700
5070
|
exports.MenuItem = MenuItem.MenuItem;
|
|
5071
|
+
exports.AUTOCOMPLETE_GROUP_HEADER_PROPERTY = AUTOCOMPLETE_GROUP_HEADER_PROPERTY;
|
|
4701
5072
|
exports.AccordionGroup = AccordionGroup;
|
|
4702
5073
|
exports.AppBar = AppBar;
|
|
4703
5074
|
exports.Autocomplete = Autocomplete;
|
|
5075
|
+
exports.AutocompleteList = AutocompleteList;
|
|
4704
5076
|
exports.Avatar = Avatar;
|
|
4705
5077
|
exports.Button = Button;
|
|
4706
5078
|
exports.CodeAreaDialog = CodeAreaDialog;
|
|
@@ -4744,5 +5116,8 @@ exports.TooltipData = TooltipData;
|
|
|
4744
5116
|
exports.UploadField = UploadField;
|
|
4745
5117
|
exports.UploadFieldBase = UploadFieldBase;
|
|
4746
5118
|
exports.copyString = copyString;
|
|
5119
|
+
exports.createAutocompleteGroupByList = createAutocompleteGroupByList;
|
|
4747
5120
|
exports.dialogDimensionsBySize = dialogDimensionsBySize;
|
|
5121
|
+
exports.isAutocompleteListGroupHeader = isAutocompleteListGroupHeader;
|
|
5122
|
+
exports.useAutocomplete = useAutocomplete;
|
|
4748
5123
|
exports.useCopyValue = useCopyValue;
|