@carto/meridian-ds 1.5.0-alpha-virtual-autocomplete.1 → 1.5.0-alpha-virtual-autocomplete.3
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 +1 -0
- package/dist/{MenuItem-D6wJym7Z.js → MenuItem-C1DvWMry.js} +1 -1
- package/dist/{MenuItem-lAxlHrDp.cjs → MenuItem-C4bG5WHw.cjs} +1 -1
- package/dist/components/index.cjs +235 -56
- package/dist/components/index.js +237 -58
- package/dist/theme/index.cjs +1 -1
- package/dist/theme/index.js +1 -1
- 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 +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 +73 -40
- 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 +6 -1
- package/dist/types/components/molecules/Autocomplete/useAutocompleteRenderOption.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts +24 -1
- package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/utils.d.ts +58 -3
- package/dist/types/components/molecules/Autocomplete/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts +0 -35
- package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -21,7 +21,7 @@ const StyledMenuItem = styled(MenuItem$1, {
|
|
|
21
21
|
columnGap: 0,
|
|
22
22
|
...theme.typography.caption,
|
|
23
23
|
fontWeight: 500,
|
|
24
|
-
color: theme.palette.text.secondary
|
|
24
|
+
color: `${theme.palette.text.secondary} !important`,
|
|
25
25
|
".MuiListItemText-root .MuiTypography-root": {
|
|
26
26
|
...theme.typography.caption,
|
|
27
27
|
fontWeight: 500,
|
|
@@ -22,7 +22,7 @@ const StyledMenuItem = material.styled(material.MenuItem, {
|
|
|
22
22
|
columnGap: 0,
|
|
23
23
|
...theme.typography.caption,
|
|
24
24
|
fontWeight: 500,
|
|
25
|
-
color: theme.palette.text.secondary
|
|
25
|
+
color: `${theme.palette.text.secondary} !important`,
|
|
26
26
|
".MuiListItemText-root .MuiTypography-root": {
|
|
27
27
|
...theme.typography.caption,
|
|
28
28
|
fontWeight: 500,
|
|
@@ -10,7 +10,7 @@ const reactIntl = require("react-intl");
|
|
|
10
10
|
const iconsMaterial = require("@mui/icons-material");
|
|
11
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
14
|
const reactWindow = require("react-window");
|
|
15
15
|
const DatePicker$1 = require("@mui/x-date-pickers/DatePicker");
|
|
16
16
|
const xDatePickers = require("@mui/x-date-pickers");
|
|
@@ -109,6 +109,9 @@ const ButtonGroup = material.styled(material.ButtonGroup)(({ theme, size }) => (
|
|
|
109
109
|
}));
|
|
110
110
|
function SplitButton({
|
|
111
111
|
options,
|
|
112
|
+
disabled,
|
|
113
|
+
loading,
|
|
114
|
+
loadingPosition,
|
|
112
115
|
onClick,
|
|
113
116
|
variant,
|
|
114
117
|
size,
|
|
@@ -147,8 +150,17 @@ function SplitButton({
|
|
|
147
150
|
color,
|
|
148
151
|
...otherProps,
|
|
149
152
|
children: [
|
|
150
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
151
|
-
|
|
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, {}) })
|
|
152
164
|
]
|
|
153
165
|
}
|
|
154
166
|
),
|
|
@@ -1106,27 +1118,6 @@ function UploadField({
|
|
|
1106
1118
|
)
|
|
1107
1119
|
] });
|
|
1108
1120
|
}
|
|
1109
|
-
function _Autocomplete({
|
|
1110
|
-
disabled,
|
|
1111
|
-
loading,
|
|
1112
|
-
...props
|
|
1113
|
-
}, ref) {
|
|
1114
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1115
|
-
material.Autocomplete,
|
|
1116
|
-
{
|
|
1117
|
-
...props,
|
|
1118
|
-
ref,
|
|
1119
|
-
disabled: disabled || loading,
|
|
1120
|
-
popupIcon: loading ? /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" }) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}),
|
|
1121
|
-
"data-name": "autocomplete",
|
|
1122
|
-
ListboxProps: {
|
|
1123
|
-
"aria-multiselectable": false,
|
|
1124
|
-
...props.ListboxProps
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
);
|
|
1128
|
-
}
|
|
1129
|
-
const Autocomplete = React.forwardRef(_Autocomplete);
|
|
1130
1121
|
const getDefaultOptionLabel = (option) => {
|
|
1131
1122
|
return option && typeof option === "object" ? option.title ?? String(option) : String(option);
|
|
1132
1123
|
};
|
|
@@ -1137,21 +1128,20 @@ const getDefaultLimitTagsText = (more) => /* @__PURE__ */ jsxRuntime.jsxs("span"
|
|
|
1137
1128
|
"+",
|
|
1138
1129
|
more
|
|
1139
1130
|
] });
|
|
1140
|
-
function createCounterRenderTags(
|
|
1131
|
+
function createCounterRenderTags(formatCounter, options = [], size = "small", getOptionLabel = getDefaultOptionLabel) {
|
|
1141
1132
|
const CounterRenderTags = (value) => {
|
|
1142
1133
|
if (value.length === 0) {
|
|
1143
1134
|
return null;
|
|
1144
1135
|
}
|
|
1145
|
-
const totalCount = options.length;
|
|
1146
1136
|
const selectedCount = value.length;
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
}
|
|
1137
|
+
const totalCount = options.length;
|
|
1138
|
+
const text = formatCounter({
|
|
1139
|
+
selectedCount,
|
|
1140
|
+
totalCount,
|
|
1141
|
+
selectedItems: value,
|
|
1142
|
+
allItems: options,
|
|
1143
|
+
getOptionLabel
|
|
1144
|
+
});
|
|
1155
1145
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1156
1146
|
TablePaginationActions.Typography,
|
|
1157
1147
|
{
|
|
@@ -1167,8 +1157,102 @@ function createCounterRenderTags(counterText = "selected", options = [], size =
|
|
|
1167
1157
|
};
|
|
1168
1158
|
return CounterRenderTags;
|
|
1169
1159
|
}
|
|
1160
|
+
function createCounterFormatter(counterText, allText, showSingleItemText = true) {
|
|
1161
|
+
return ({
|
|
1162
|
+
selectedCount,
|
|
1163
|
+
totalCount,
|
|
1164
|
+
selectedItems,
|
|
1165
|
+
getOptionLabel
|
|
1166
|
+
}) => {
|
|
1167
|
+
if (selectedCount === totalCount && totalCount > 0) {
|
|
1168
|
+
return allText;
|
|
1169
|
+
} else if (selectedCount === 1 && showSingleItemText) {
|
|
1170
|
+
return getOptionLabel(selectedItems[0]);
|
|
1171
|
+
} else {
|
|
1172
|
+
return `${selectedCount} ${counterText}`;
|
|
1173
|
+
}
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
function createAutocompleteGroupByList(options, groupBy) {
|
|
1177
|
+
const grouped = options.reduce(
|
|
1178
|
+
(acc, option) => {
|
|
1179
|
+
const group = groupBy(option);
|
|
1180
|
+
if (!acc[group]) {
|
|
1181
|
+
acc[group] = [];
|
|
1182
|
+
}
|
|
1183
|
+
acc[group].push(option);
|
|
1184
|
+
return acc;
|
|
1185
|
+
},
|
|
1186
|
+
{}
|
|
1187
|
+
);
|
|
1188
|
+
const result = [];
|
|
1189
|
+
Object.keys(grouped).forEach((title) => {
|
|
1190
|
+
result.push({ __isGroupHeader: true, title });
|
|
1191
|
+
const groupOptions = grouped[title];
|
|
1192
|
+
if (groupOptions) {
|
|
1193
|
+
result.push(...groupOptions);
|
|
1194
|
+
}
|
|
1195
|
+
});
|
|
1196
|
+
return result;
|
|
1197
|
+
}
|
|
1198
|
+
function warnDeprecatedGroupBy(componentName) {
|
|
1199
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1200
|
+
console.warn(
|
|
1201
|
+
`${componentName}: The \`groupBy\` prop is deprecated and breaks virtualization. Use \`createAutocompleteGroupByList\` instead:
|
|
1202
|
+
|
|
1203
|
+
\`\`\`
|
|
1204
|
+
import { createAutocompleteGroupByList, ${componentName} } from "@carto/meridian-ds/components"
|
|
1205
|
+
|
|
1206
|
+
const groupedOptions = createAutocompleteGroupByList(options, (option) => option.category)
|
|
1207
|
+
|
|
1208
|
+
<${componentName} options={groupedOptions} />
|
|
1209
|
+
\`\`\`
|
|
1210
|
+
`
|
|
1211
|
+
);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
function _Autocomplete({
|
|
1215
|
+
disabled,
|
|
1216
|
+
loading,
|
|
1217
|
+
groupBy,
|
|
1218
|
+
...props
|
|
1219
|
+
}, ref) {
|
|
1220
|
+
if (groupBy) {
|
|
1221
|
+
warnDeprecatedGroupBy("Autocomplete");
|
|
1222
|
+
}
|
|
1223
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1224
|
+
material.Autocomplete,
|
|
1225
|
+
{
|
|
1226
|
+
...props,
|
|
1227
|
+
ref,
|
|
1228
|
+
disabled: disabled || loading,
|
|
1229
|
+
popupIcon: loading ? /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" }) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}),
|
|
1230
|
+
"data-name": "autocomplete",
|
|
1231
|
+
ListboxProps: {
|
|
1232
|
+
"aria-multiselectable": false,
|
|
1233
|
+
...props.ListboxProps
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
);
|
|
1237
|
+
}
|
|
1238
|
+
const Autocomplete = React.forwardRef(_Autocomplete);
|
|
1170
1239
|
function useAutocompleteRenderOption() {
|
|
1171
1240
|
const renderOption = (props, option, state, getOptionLabel, customIcon) => {
|
|
1241
|
+
const { key, ...otherProps } = props;
|
|
1242
|
+
if (typeof option === "object" && option !== null && "__isGroupHeader" in option) {
|
|
1243
|
+
return /* @__PURE__ */ React.createElement(
|
|
1244
|
+
MenuItem.MenuItem,
|
|
1245
|
+
{
|
|
1246
|
+
...otherProps,
|
|
1247
|
+
subtitle: true,
|
|
1248
|
+
key,
|
|
1249
|
+
"aria-disabled": true,
|
|
1250
|
+
"aria-selected": false
|
|
1251
|
+
},
|
|
1252
|
+
option.title
|
|
1253
|
+
);
|
|
1254
|
+
}
|
|
1255
|
+
const regularOption = option;
|
|
1172
1256
|
const {
|
|
1173
1257
|
title,
|
|
1174
1258
|
inputValue,
|
|
@@ -1185,9 +1269,8 @@ function useAutocompleteRenderOption() {
|
|
|
1185
1269
|
alternativeTitle,
|
|
1186
1270
|
secondaryText,
|
|
1187
1271
|
multiple
|
|
1188
|
-
} =
|
|
1189
|
-
const
|
|
1190
|
-
const isPrimitiveOptionType = typeof option === "string" || typeof option === "number";
|
|
1272
|
+
} = regularOption;
|
|
1273
|
+
const isPrimitiveOptionType = typeof regularOption === "string" || typeof regularOption === "number";
|
|
1191
1274
|
const getOptionLabelText = (getOptionLabel2, option2, alternativeTitle2, title2) => {
|
|
1192
1275
|
if (alternativeTitle2) return alternativeTitle2;
|
|
1193
1276
|
if (title2) return title2;
|
|
@@ -1221,7 +1304,7 @@ function useAutocompleteRenderOption() {
|
|
|
1221
1304
|
/* @__PURE__ */ jsxRuntime.jsxs(material.ListItemText, { children: [
|
|
1222
1305
|
getOptionLabelText(
|
|
1223
1306
|
getOptionLabel ?? getDefaultOptionLabel,
|
|
1224
|
-
|
|
1307
|
+
regularOption,
|
|
1225
1308
|
alternativeTitle,
|
|
1226
1309
|
title
|
|
1227
1310
|
),
|
|
@@ -1309,8 +1392,15 @@ function useMultipleAutocomplete({
|
|
|
1309
1392
|
value,
|
|
1310
1393
|
onChange,
|
|
1311
1394
|
getOptionLabel,
|
|
1312
|
-
size
|
|
1395
|
+
size,
|
|
1396
|
+
counterFormatter,
|
|
1397
|
+
counterText,
|
|
1398
|
+
allSelectedText
|
|
1313
1399
|
}) {
|
|
1400
|
+
const intl = reactIntl.useIntl();
|
|
1401
|
+
const intlConfig = TablePaginationActions.useImperativeIntl(intl);
|
|
1402
|
+
const defaultCounterText = counterText || intlConfig.formatMessage({ id: "c4r.form.selected" });
|
|
1403
|
+
const defaultAllSelectedText = allSelectedText || intlConfig.formatMessage({ id: "c4r.form.allSelected" });
|
|
1314
1404
|
const [multipleValue, setMultipleValue] = React.useState(
|
|
1315
1405
|
Array.isArray(value) ? value : value ? [value] : []
|
|
1316
1406
|
);
|
|
@@ -1344,12 +1434,15 @@ function useMultipleAutocomplete({
|
|
|
1344
1434
|
getOptionLabel
|
|
1345
1435
|
);
|
|
1346
1436
|
};
|
|
1347
|
-
const getCounterRenderTags = () =>
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1437
|
+
const getCounterRenderTags = () => {
|
|
1438
|
+
const formatter = counterFormatter || createCounterFormatter(defaultCounterText, defaultAllSelectedText);
|
|
1439
|
+
return createCounterRenderTags(
|
|
1440
|
+
formatter,
|
|
1441
|
+
options,
|
|
1442
|
+
size,
|
|
1443
|
+
getOptionLabel ? (option) => getOptionLabel(option) : void 0
|
|
1444
|
+
);
|
|
1445
|
+
};
|
|
1353
1446
|
return {
|
|
1354
1447
|
multipleValue,
|
|
1355
1448
|
allSelected,
|
|
@@ -1360,7 +1453,40 @@ function useMultipleAutocomplete({
|
|
|
1360
1453
|
getCounterRenderTags
|
|
1361
1454
|
};
|
|
1362
1455
|
}
|
|
1363
|
-
|
|
1456
|
+
const ItemWrapper = material.styled("div")(
|
|
1457
|
+
({ theme, isSubtitle }) => ({
|
|
1458
|
+
"& .MuiMenuItem-root": {
|
|
1459
|
+
marginTop: 0,
|
|
1460
|
+
"&:first-of-type": {
|
|
1461
|
+
marginTop: "0 !important"
|
|
1462
|
+
}
|
|
1463
|
+
},
|
|
1464
|
+
...isSubtitle && {
|
|
1465
|
+
"& .MuiAutocomplete-option.MuiMenuItem-root": {
|
|
1466
|
+
height: TablePaginationActions.MENU_ITEM_SIZE_DENSE,
|
|
1467
|
+
minHeight: TablePaginationActions.MENU_ITEM_SIZE_DENSE,
|
|
1468
|
+
marginTop: `${theme.spacing(1)} !important`,
|
|
1469
|
+
alignItems: "flex-end",
|
|
1470
|
+
...theme.typography.caption,
|
|
1471
|
+
fontWeight: 500
|
|
1472
|
+
},
|
|
1473
|
+
// First item has no divider
|
|
1474
|
+
"&:not(:first-of-type)": {
|
|
1475
|
+
"&::before": {
|
|
1476
|
+
content: '""',
|
|
1477
|
+
position: "absolute",
|
|
1478
|
+
zIndex: 1,
|
|
1479
|
+
top: theme.spacing(0.5),
|
|
1480
|
+
left: 0,
|
|
1481
|
+
right: 0,
|
|
1482
|
+
height: "1px",
|
|
1483
|
+
backgroundColor: theme.palette.divider
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
})
|
|
1488
|
+
);
|
|
1489
|
+
function _AutocompleteList({
|
|
1364
1490
|
children,
|
|
1365
1491
|
showFilters,
|
|
1366
1492
|
allSelected,
|
|
@@ -1373,10 +1499,7 @@ function _ListboxWithFilter({
|
|
|
1373
1499
|
...otherProps
|
|
1374
1500
|
}, ref) {
|
|
1375
1501
|
const childrenArray = React.useMemo(() => {
|
|
1376
|
-
|
|
1377
|
-
return children;
|
|
1378
|
-
}
|
|
1379
|
-
return children ? [children] : [];
|
|
1502
|
+
return React.Children.toArray(children);
|
|
1380
1503
|
}, [children]);
|
|
1381
1504
|
const defaultItemHeight = itemHeight ?? (extended ? TablePaginationActions.MENU_ITEM_SIZE_EXTENDED : TablePaginationActions.MENU_ITEM_SIZE_DEFAULT);
|
|
1382
1505
|
const listboxHeight = React.useMemo(() => {
|
|
@@ -1400,7 +1523,16 @@ function _ListboxWithFilter({
|
|
|
1400
1523
|
}) => {
|
|
1401
1524
|
const child = childrenArray[index];
|
|
1402
1525
|
if (!child) return null;
|
|
1403
|
-
|
|
1526
|
+
const isSubtitle = React.isValidElement(child) && child.props.subtitle === true;
|
|
1527
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1528
|
+
ItemWrapper,
|
|
1529
|
+
{
|
|
1530
|
+
style,
|
|
1531
|
+
isSubtitle,
|
|
1532
|
+
"data-name": "virtual-menu-item",
|
|
1533
|
+
children: child
|
|
1534
|
+
}
|
|
1535
|
+
);
|
|
1404
1536
|
};
|
|
1405
1537
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1406
1538
|
"ul",
|
|
@@ -1437,7 +1569,7 @@ function _ListboxWithFilter({
|
|
|
1437
1569
|
}
|
|
1438
1570
|
);
|
|
1439
1571
|
}
|
|
1440
|
-
const
|
|
1572
|
+
const AutocompleteList = React.forwardRef(_AutocompleteList);
|
|
1441
1573
|
function _CreatableAutocomplete({
|
|
1442
1574
|
newItemLabel,
|
|
1443
1575
|
newItemIcon,
|
|
@@ -1448,6 +1580,9 @@ function _CreatableAutocomplete({
|
|
|
1448
1580
|
loading,
|
|
1449
1581
|
showFilters,
|
|
1450
1582
|
showCounter = false,
|
|
1583
|
+
counterFormatter,
|
|
1584
|
+
counterText,
|
|
1585
|
+
allSelectedText,
|
|
1451
1586
|
options = [],
|
|
1452
1587
|
value,
|
|
1453
1588
|
onChange,
|
|
@@ -1456,8 +1591,12 @@ function _CreatableAutocomplete({
|
|
|
1456
1591
|
itemHeight,
|
|
1457
1592
|
maxListHeight,
|
|
1458
1593
|
extended,
|
|
1594
|
+
groupBy,
|
|
1459
1595
|
...props
|
|
1460
1596
|
}, ref) {
|
|
1597
|
+
if (groupBy) {
|
|
1598
|
+
warnDeprecatedGroupBy("CreatableAutocomplete");
|
|
1599
|
+
}
|
|
1461
1600
|
const { freeSolo = true, ...otherProps } = props;
|
|
1462
1601
|
const {
|
|
1463
1602
|
multipleValue,
|
|
@@ -1471,7 +1610,10 @@ function _CreatableAutocomplete({
|
|
|
1471
1610
|
value,
|
|
1472
1611
|
onChange,
|
|
1473
1612
|
getOptionLabel,
|
|
1474
|
-
size: props.size
|
|
1613
|
+
size: props.size,
|
|
1614
|
+
counterFormatter,
|
|
1615
|
+
counterText,
|
|
1616
|
+
allSelectedText
|
|
1475
1617
|
});
|
|
1476
1618
|
const {
|
|
1477
1619
|
creatableFilterOptions,
|
|
@@ -1510,7 +1652,7 @@ function _CreatableAutocomplete({
|
|
|
1510
1652
|
forcePopupIcon: true,
|
|
1511
1653
|
multiple,
|
|
1512
1654
|
disableCloseOnSelect: disableCloseOnSelect ?? multiple,
|
|
1513
|
-
ListboxComponent:
|
|
1655
|
+
ListboxComponent: AutocompleteList,
|
|
1514
1656
|
ListboxProps: listboxProps,
|
|
1515
1657
|
getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
|
|
1516
1658
|
disabled: disabled || loading,
|
|
@@ -1527,6 +1669,9 @@ function _MultipleAutocomplete({
|
|
|
1527
1669
|
loading,
|
|
1528
1670
|
showFilters,
|
|
1529
1671
|
showCounter = false,
|
|
1672
|
+
counterFormatter,
|
|
1673
|
+
counterText,
|
|
1674
|
+
allSelectedText,
|
|
1530
1675
|
options,
|
|
1531
1676
|
value,
|
|
1532
1677
|
onChange,
|
|
@@ -1536,8 +1681,12 @@ function _MultipleAutocomplete({
|
|
|
1536
1681
|
itemHeight,
|
|
1537
1682
|
maxListHeight,
|
|
1538
1683
|
extended,
|
|
1684
|
+
groupBy,
|
|
1539
1685
|
...props
|
|
1540
1686
|
}, ref) {
|
|
1687
|
+
if (groupBy) {
|
|
1688
|
+
warnDeprecatedGroupBy("MultipleAutocomplete");
|
|
1689
|
+
}
|
|
1541
1690
|
const {
|
|
1542
1691
|
multipleValue,
|
|
1543
1692
|
allSelected,
|
|
@@ -1551,7 +1700,10 @@ function _MultipleAutocomplete({
|
|
|
1551
1700
|
value,
|
|
1552
1701
|
onChange,
|
|
1553
1702
|
getOptionLabel,
|
|
1554
|
-
size: props.size
|
|
1703
|
+
size: props.size,
|
|
1704
|
+
counterFormatter,
|
|
1705
|
+
counterText,
|
|
1706
|
+
allSelectedText
|
|
1555
1707
|
});
|
|
1556
1708
|
const listboxProps = {
|
|
1557
1709
|
showFilters,
|
|
@@ -1575,7 +1727,7 @@ function _MultipleAutocomplete({
|
|
|
1575
1727
|
getOptionLabel,
|
|
1576
1728
|
renderOption: renderOption ?? multipleRenderOption,
|
|
1577
1729
|
renderTags: finalRenderTags,
|
|
1578
|
-
ListboxComponent:
|
|
1730
|
+
ListboxComponent: AutocompleteList,
|
|
1579
1731
|
ListboxProps: listboxProps,
|
|
1580
1732
|
multiple: true,
|
|
1581
1733
|
getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
|
|
@@ -1587,6 +1739,30 @@ function _MultipleAutocomplete({
|
|
|
1587
1739
|
);
|
|
1588
1740
|
}
|
|
1589
1741
|
const MultipleAutocomplete = React.forwardRef(_MultipleAutocomplete);
|
|
1742
|
+
function useAutocomplete({
|
|
1743
|
+
getOptionLabel = getDefaultOptionLabel
|
|
1744
|
+
}) {
|
|
1745
|
+
const { renderOption: autocompleteRenderOption } = useAutocompleteRenderOption();
|
|
1746
|
+
const internalGetOptionLabel = (option) => {
|
|
1747
|
+
if (typeof option === "object" && option !== null && "__isGroupHeader" in option) {
|
|
1748
|
+
return option.title;
|
|
1749
|
+
}
|
|
1750
|
+
return getOptionLabel(option);
|
|
1751
|
+
};
|
|
1752
|
+
const singleRenderOption = (props, option, state) => {
|
|
1753
|
+
const optionWithMultiple = createOptionWithMultiple(option, false);
|
|
1754
|
+
return autocompleteRenderOption(
|
|
1755
|
+
props,
|
|
1756
|
+
optionWithMultiple,
|
|
1757
|
+
state,
|
|
1758
|
+
internalGetOptionLabel
|
|
1759
|
+
);
|
|
1760
|
+
};
|
|
1761
|
+
return {
|
|
1762
|
+
singleRenderOption,
|
|
1763
|
+
getOptionLabel: internalGetOptionLabel
|
|
1764
|
+
};
|
|
1765
|
+
}
|
|
1590
1766
|
const _CopiableComponent = ({
|
|
1591
1767
|
children,
|
|
1592
1768
|
disabled,
|
|
@@ -4814,6 +4990,7 @@ exports.MenuItem = MenuItem.MenuItem;
|
|
|
4814
4990
|
exports.AccordionGroup = AccordionGroup;
|
|
4815
4991
|
exports.AppBar = AppBar;
|
|
4816
4992
|
exports.Autocomplete = Autocomplete;
|
|
4993
|
+
exports.AutocompleteList = AutocompleteList;
|
|
4817
4994
|
exports.Avatar = Avatar;
|
|
4818
4995
|
exports.Button = Button;
|
|
4819
4996
|
exports.CodeAreaDialog = CodeAreaDialog;
|
|
@@ -4857,5 +5034,7 @@ exports.TooltipData = TooltipData;
|
|
|
4857
5034
|
exports.UploadField = UploadField;
|
|
4858
5035
|
exports.UploadFieldBase = UploadFieldBase;
|
|
4859
5036
|
exports.copyString = copyString;
|
|
5037
|
+
exports.createAutocompleteGroupByList = createAutocompleteGroupByList;
|
|
4860
5038
|
exports.dialogDimensionsBySize = dialogDimensionsBySize;
|
|
5039
|
+
exports.useAutocomplete = useAutocomplete;
|
|
4861
5040
|
exports.useCopyValue = useCopyValue;
|