@mmb-digital/ds-lilly 0.3.13 → 0.3.14
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/dist/ds-lilly.js +42 -44
- package/package.json +1 -1
package/dist/ds-lilly.js
CHANGED
|
@@ -98271,27 +98271,28 @@ var Autocomplete2_spreadArray = (undefined && undefined.__spreadArray) || functi
|
|
|
98271
98271
|
|
|
98272
98272
|
|
|
98273
98273
|
var Autocomplete2 = function (_a) {
|
|
98274
|
-
var _b;
|
|
98275
|
-
var
|
|
98276
|
-
var _k = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(
|
|
98277
|
-
var _l = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(
|
|
98278
|
-
var _m = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(
|
|
98279
|
-
var _o = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(
|
|
98280
|
-
var _p = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(
|
|
98281
|
-
var _q = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(
|
|
98282
|
-
var _r = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])({
|
|
98274
|
+
var _b = _a.asyncDelayMilliseconds, asyncDelayMilliseconds = _b === void 0 ? 200 : _b, _c = _a.canAlwaysCreateNewItem, canAlwaysCreateNewItem = _c === void 0 ? false : _c, disabledTooltip = _a.disabledTooltip, _d = _a.displayDetails, displayDetails = _d === void 0 ? false : _d, dropdownTheme = _a.dropdownTheme, emptyValueLabel = _a.emptyValueLabel, error = _a.error, _e = _a.filterMinimumLength, filterMinimumLength = _e === void 0 ? 2 : _e, _f = _a.hasFullWidthOptions, hasFullWidthOptions = _f === void 0 ? true : _f, help = _a.help, isDisabled = _a.isDisabled, isLazyLoaded = _a.isLazyLoaded, isLoading = _a.isLoading, _g = _a.items, inputItems = _g === void 0 ? [] : _g, label = _a.label, labelTooltip = _a.labelTooltip, loadItems = _a.loadItems, loadMoreItems = _a.loadMoreItems, name = _a.name, messages = _a.messages, _h = _a.newItemMinimumLength, newItemMinimumLength = _h === void 0 ? 2 : _h, onBlur = _a.onBlur, onChange = _a.onChange, onCreateNewItem = _a.onCreateNewItem, onFocus = _a.onFocus, placeholder = _a.placeholder, testId = _a.testId, theme = _a.theme, value = _a.value;
|
|
98275
|
+
var _j = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(false), isDropdownVisible = _j[0], setIsDropdownVisible = _j[1];
|
|
98276
|
+
var _k = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(null), buttonValue = _k[0], setButtonValue = _k[1];
|
|
98277
|
+
var _l = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(false), typingMode = _l[0], setTypingMode = _l[1];
|
|
98278
|
+
var _m = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(''), fulltextValue = _m[0], setFulltextValue = _m[1];
|
|
98279
|
+
var _o = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(-1), currentItemPosition = _o[0], setCurrentItemPosition = _o[1];
|
|
98280
|
+
var _p = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])([]), items = _p[0], setItems = _p[1];
|
|
98281
|
+
var _q = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])({
|
|
98283
98282
|
loading: false,
|
|
98284
98283
|
found: -1
|
|
98285
|
-
}), searchState =
|
|
98286
|
-
var
|
|
98284
|
+
}), searchState = _q[0], setSearchState = _q[1];
|
|
98285
|
+
var _r = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])({
|
|
98287
98286
|
loading: false,
|
|
98288
98287
|
found: -1
|
|
98289
|
-
}), pagingState =
|
|
98288
|
+
}), pagingState = _r[0], setPagingState = _r[1];
|
|
98289
|
+
var getSearchString = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function (str) { return stripDiacritics(str).toLowerCase(); }, []);
|
|
98290
|
+
var emptyValueLabelPattern = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useMemo"])(function () { return getSearchString(emptyValueLabel || ''); }, [emptyValueLabel]);
|
|
98291
|
+
var isCategorised = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function (itemList) { var _a; return !!(itemList && ((_a = itemList[0]) === null || _a === void 0 ? void 0 : _a.items)); }, []);
|
|
98290
98292
|
var loadAsyncItems = function (query) { return Autocomplete2_awaiter(void 0, void 0, void 0, function () {
|
|
98291
|
-
var newItems,
|
|
98292
|
-
|
|
98293
|
-
|
|
98294
|
-
switch (_b.label) {
|
|
98293
|
+
var newItems, categorised, found;
|
|
98294
|
+
return Autocomplete2_generator(this, function (_a) {
|
|
98295
|
+
switch (_a.label) {
|
|
98295
98296
|
case 0:
|
|
98296
98297
|
if (!loadItems)
|
|
98297
98298
|
return [2 /*return*/];
|
|
@@ -98299,9 +98300,9 @@ var Autocomplete2 = function (_a) {
|
|
|
98299
98300
|
setItems([]);
|
|
98300
98301
|
return [4 /*yield*/, loadItems(query)];
|
|
98301
98302
|
case 1:
|
|
98302
|
-
newItems =
|
|
98303
|
-
|
|
98304
|
-
found =
|
|
98303
|
+
newItems = _a.sent();
|
|
98304
|
+
categorised = isCategorised(newItems);
|
|
98305
|
+
found = categorised
|
|
98305
98306
|
? newItems.reduce(function (acc, curr) { return acc + curr.items.length; }, 0)
|
|
98306
98307
|
: newItems.length;
|
|
98307
98308
|
setSearchState({ loading: false, found: found });
|
|
@@ -98310,11 +98311,11 @@ var Autocomplete2 = function (_a) {
|
|
|
98310
98311
|
}
|
|
98311
98312
|
});
|
|
98312
98313
|
}); };
|
|
98314
|
+
var fulltextMatchesEmptyValue = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useMemo"])(function () { return emptyValueLabelPattern.includes(fulltextValue); }, [fulltextValue]);
|
|
98313
98315
|
var debouncedCallApi = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(function () { return (loadItems ? lodash_debounce_default()(loadAsyncItems, asyncDelayMilliseconds) : noop); })[0];
|
|
98314
|
-
var isCategorised = !!(items && ((_b = items[0]) === null || _b === void 0 ? void 0 : _b.items));
|
|
98315
98316
|
var itemsIndex = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useMemo"])(function () {
|
|
98316
98317
|
var map;
|
|
98317
|
-
if (isCategorised) {
|
|
98318
|
+
if (isCategorised(items)) {
|
|
98318
98319
|
map = items.reduce(function (acc, category, categoryIndex) {
|
|
98319
98320
|
return acc.concat(category.items
|
|
98320
98321
|
.map(function (item, index) { return (!item.isDisabled ? { category: categoryIndex, item: index } : undefined); })
|
|
@@ -98326,11 +98327,11 @@ var Autocomplete2 = function (_a) {
|
|
|
98326
98327
|
.map(function (item, index) { return (!item.isDisabled ? { category: -1, item: index } : undefined); })
|
|
98327
98328
|
.filter(Boolean);
|
|
98328
98329
|
}
|
|
98329
|
-
if (emptyValueLabel &&
|
|
98330
|
+
if (emptyValueLabel && (!fulltextValue || fulltextValue === (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) || fulltextMatchesEmptyValue)) {
|
|
98330
98331
|
return Autocomplete2_spreadArray([{ item: -1, category: -1 }], map);
|
|
98331
98332
|
}
|
|
98332
98333
|
return map;
|
|
98333
|
-
}, [items,
|
|
98334
|
+
}, [items, fulltextValue, value, buttonValue]);
|
|
98334
98335
|
var showCreatable = !!onCreateNewItem &&
|
|
98335
98336
|
(itemsIndex.length === 0 || canAlwaysCreateNewItem) &&
|
|
98336
98337
|
typingMode &&
|
|
@@ -98341,7 +98342,7 @@ var Autocomplete2 = function (_a) {
|
|
|
98341
98342
|
if (val === '' || val === undefined) {
|
|
98342
98343
|
return { item: -1, category: -1 };
|
|
98343
98344
|
}
|
|
98344
|
-
if (isCategorised) {
|
|
98345
|
+
if (isCategorised(sourceItems)) {
|
|
98345
98346
|
var index = sourceItems
|
|
98346
98347
|
.map(function (category, categoryIndex) {
|
|
98347
98348
|
var item = category.items.findIndex(function (item) { return item.value === val && !item.isDisabled; });
|
|
@@ -98363,16 +98364,14 @@ var Autocomplete2 = function (_a) {
|
|
|
98363
98364
|
});
|
|
98364
98365
|
};
|
|
98365
98366
|
var getFilteredItems = function (filter) {
|
|
98366
|
-
var newFilter =
|
|
98367
|
-
|
|
98368
|
-
.trim();
|
|
98369
|
-
if (isCategorised) {
|
|
98367
|
+
var newFilter = getSearchString(typeof filter === 'string' ? filter : filter.toString()).trim();
|
|
98368
|
+
if (isCategorised(inputItems)) {
|
|
98370
98369
|
var filteredCategories_1 = [];
|
|
98371
98370
|
var unfilteredItems = inputItems;
|
|
98372
98371
|
unfilteredItems.map(function (category) {
|
|
98373
98372
|
var filteredCategory = category.items.filter(function (_a) {
|
|
98374
98373
|
var amount = _a.amount, label = _a.label, perex = _a.perex;
|
|
98375
|
-
var text =
|
|
98374
|
+
var text = getSearchString(label + " " + (perex || '') + " " + (amount || ''));
|
|
98376
98375
|
return text.includes(newFilter);
|
|
98377
98376
|
});
|
|
98378
98377
|
if (filteredCategory.length > 0) {
|
|
@@ -98384,7 +98383,7 @@ var Autocomplete2 = function (_a) {
|
|
|
98384
98383
|
else {
|
|
98385
98384
|
var filteredOptions = inputItems.filter(function (_a) {
|
|
98386
98385
|
var amount = _a.amount, label = _a.label, perex = _a.perex;
|
|
98387
|
-
var text =
|
|
98386
|
+
var text = getSearchString(label + " " + (perex || '') + " " + (amount || ''));
|
|
98388
98387
|
return text.includes(newFilter);
|
|
98389
98388
|
});
|
|
98390
98389
|
return filteredOptions;
|
|
@@ -98395,7 +98394,7 @@ var Autocomplete2 = function (_a) {
|
|
|
98395
98394
|
setItems(inputItems);
|
|
98396
98395
|
var _a = getItemIndexByValue(value, inputItems), category = _a.category, item = _a.item;
|
|
98397
98396
|
if (item > -1) {
|
|
98398
|
-
var selectedItem = isCategorised
|
|
98397
|
+
var selectedItem = isCategorised(inputItems)
|
|
98399
98398
|
? inputItems[category].items[item]
|
|
98400
98399
|
: inputItems[item];
|
|
98401
98400
|
if (selectedItem) {
|
|
@@ -98410,7 +98409,7 @@ var Autocomplete2 = function (_a) {
|
|
|
98410
98409
|
setCurrentItemPosition(itemIndexPosition);
|
|
98411
98410
|
var category = itemIndex.category, item = itemIndex.item;
|
|
98412
98411
|
if (item > -1) {
|
|
98413
|
-
var selectedItem = isCategorised
|
|
98412
|
+
var selectedItem = isCategorised(items)
|
|
98414
98413
|
? items[category].items[item]
|
|
98415
98414
|
: items[item];
|
|
98416
98415
|
if (selectedItem) {
|
|
@@ -98434,7 +98433,7 @@ var Autocomplete2 = function (_a) {
|
|
|
98434
98433
|
var _a, _b, _c, _d, _e, _f;
|
|
98435
98434
|
if (category === void 0) { category = -1; }
|
|
98436
98435
|
if (center === void 0) { center = false; }
|
|
98437
|
-
var itemElementId = isCategorised ? name + "_option-" + category + "-" + item : name + "_option-" + item;
|
|
98436
|
+
var itemElementId = isCategorised(items) ? name + "_option-" + category + "-" + item : name + "_option-" + item;
|
|
98438
98437
|
if (center) {
|
|
98439
98438
|
var dropdownHalfHeight = (((_a = document.getElementById('autocomplete_dropdown')) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0) / 2;
|
|
98440
98439
|
var itemHalfHeight = (((_b = document.getElementById(itemElementId)) === null || _b === void 0 ? void 0 : _b.clientHeight) || 0) / 2;
|
|
@@ -98550,7 +98549,7 @@ var Autocomplete2 = function (_a) {
|
|
|
98550
98549
|
propagateChange();
|
|
98551
98550
|
return undefined;
|
|
98552
98551
|
}
|
|
98553
|
-
var selectedItem = isCategorised
|
|
98552
|
+
var selectedItem = isCategorised(items)
|
|
98554
98553
|
? items[category].items[item]
|
|
98555
98554
|
: items[item];
|
|
98556
98555
|
if (selectedItem) {
|
|
@@ -98675,7 +98674,7 @@ var Autocomplete2 = function (_a) {
|
|
|
98675
98674
|
setTimeout(function () {
|
|
98676
98675
|
var _a;
|
|
98677
98676
|
scrollToItem(item_1, category_1);
|
|
98678
|
-
var listElementId = isCategorised ? name + "_list-" + category_1 : name + "_list";
|
|
98677
|
+
var listElementId = isCategorised(items) ? name + "_list-" + category_1 : name + "_list";
|
|
98679
98678
|
(_a = document.getElementById(listElementId)) === null || _a === void 0 ? void 0 : _a.focus();
|
|
98680
98679
|
});
|
|
98681
98680
|
}
|
|
@@ -98690,16 +98689,15 @@ var Autocomplete2 = function (_a) {
|
|
|
98690
98689
|
if (key === KEYS.Enter) {
|
|
98691
98690
|
event.preventDefault();
|
|
98692
98691
|
if (isDropdownVisible) {
|
|
98693
|
-
var minItemsToAutoselect = emptyValueLabel && !value ? 2 : 1;
|
|
98694
98692
|
if (showCreatable && itemsIndex.length === 0) {
|
|
98695
98693
|
handleCreateNewOption();
|
|
98696
98694
|
}
|
|
98697
|
-
else if (fulltextValue && fulltextValue !== (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) && itemsIndex.length
|
|
98698
|
-
var _a = itemsIndex[
|
|
98699
|
-
var selectedItem = isCategorised
|
|
98695
|
+
else if (fulltextValue && fulltextValue !== (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) && itemsIndex.length > 0) {
|
|
98696
|
+
var _a = itemsIndex[0], category = _a.category, item = _a.item;
|
|
98697
|
+
var selectedItem = isCategorised(items)
|
|
98700
98698
|
? items[category].items[item]
|
|
98701
98699
|
: items[item];
|
|
98702
|
-
setFulltextValue(selectedItem.label);
|
|
98700
|
+
setFulltextValue((selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.label) || '');
|
|
98703
98701
|
propagateChange(selectedItem);
|
|
98704
98702
|
setTypingMode(false);
|
|
98705
98703
|
}
|
|
@@ -98725,7 +98723,7 @@ var Autocomplete2 = function (_a) {
|
|
|
98725
98723
|
setTimeout(function () {
|
|
98726
98724
|
var _a;
|
|
98727
98725
|
scrollToItem(item_2, category_2);
|
|
98728
|
-
var listElementId = isCategorised ? name + "_list-" + category_2 : name + "_list";
|
|
98726
|
+
var listElementId = isCategorised(items) ? name + "_list-" + category_2 : name + "_list";
|
|
98729
98727
|
(_a = document.getElementById(listElementId)) === null || _a === void 0 ? void 0 : _a.focus();
|
|
98730
98728
|
});
|
|
98731
98729
|
}
|
|
@@ -98756,7 +98754,7 @@ var Autocomplete2 = function (_a) {
|
|
|
98756
98754
|
}
|
|
98757
98755
|
else if (fulltextValue && fulltextValue !== (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) && itemsIndex.length > 0) {
|
|
98758
98756
|
var _c = itemsIndex[0], category = _c.category, item = _c.item;
|
|
98759
|
-
var selectedItem = isCategorised
|
|
98757
|
+
var selectedItem = isCategorised(items)
|
|
98760
98758
|
? items[category].items[item]
|
|
98761
98759
|
: items[item];
|
|
98762
98760
|
setButtonValue(selectedItem);
|
|
@@ -98825,7 +98823,7 @@ var Autocomplete2 = function (_a) {
|
|
|
98825
98823
|
messages.loadingItems));
|
|
98826
98824
|
}
|
|
98827
98825
|
return (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["Fragment"], null,
|
|
98828
|
-
isCategorised ? external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Select2CategorisedOptions, null) : external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Select2Options, null),
|
|
98826
|
+
isCategorised(items) ? external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Select2CategorisedOptions, null) : external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Select2Options, null),
|
|
98829
98827
|
pagingState.loading && messages.loadingItems && (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: "f-autocomplete__message", id: "autocomplete_loading-more-items" },
|
|
98830
98828
|
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: "loading", size: "large" }),
|
|
98831
98829
|
messages.loadingMoreItems)),
|
|
@@ -98840,7 +98838,7 @@ var Autocomplete2 = function (_a) {
|
|
|
98840
98838
|
};
|
|
98841
98839
|
var focusedItem = itemsIndex[currentItemPosition];
|
|
98842
98840
|
var select2context = {
|
|
98843
|
-
emptyValueLabel:
|
|
98841
|
+
emptyValueLabel: !fulltextValue || fulltextValue === (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) || fulltextMatchesEmptyValue ? emptyValueLabel : undefined,
|
|
98844
98842
|
focusedCategoryIndex: focusedItem ? focusedItem.category : -1,
|
|
98845
98843
|
focusedItemIndex: focusedItem ? focusedItem.item : -1,
|
|
98846
98844
|
items: items,
|