@mmb-digital/ds-lilly 0.3.12 → 0.3.15

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 CHANGED
@@ -96928,62 +96928,34 @@ var Tile = function (_a) {
96928
96928
 
96929
96929
 
96930
96930
  // CONCATENATED MODULE: ./src/components/Components/Toast/Toast.hook.ts
96931
- var Toast_hook_assign = (undefined && undefined.__assign) || function () {
96932
- Toast_hook_assign = Object.assign || function(t) {
96933
- for (var s, i = 1, n = arguments.length; i < n; i++) {
96934
- s = arguments[i];
96935
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
96936
- t[p] = s[p];
96937
- }
96938
- return t;
96939
- };
96940
- return Toast_hook_assign.apply(this, arguments);
96931
+ var ADD_TOAST_EVENT = 'toast/add';
96932
+ var REMOVE_TOAST_EVENT = 'toast/remove';
96933
+ var REMOVE_ALL_TOASTS_EVENT = 'toast/removeAll';
96934
+ var triggerEvent = function (eventType, data) {
96935
+ try {
96936
+ var event_1 = new CustomEvent(eventType, { detail: data });
96937
+ document.dispatchEvent(event_1);
96938
+ }
96939
+ catch (err) {
96940
+ var event_2 = document.createEvent('CustomEvent');
96941
+ event_2.initCustomEvent(eventType, true, false, data);
96942
+ document.dispatchEvent(event_2);
96943
+ }
96941
96944
  };
96942
- var Toast_hook_rest = (undefined && undefined.__rest) || function (s, e) {
96943
- var t = {};
96944
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
96945
- t[p] = s[p];
96946
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
96947
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
96948
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
96949
- t[p[i]] = s[p[i]];
96950
- }
96951
- return t;
96945
+ var addToast = function (toast) {
96946
+ triggerEvent(ADD_TOAST_EVENT, toast);
96952
96947
  };
96953
- var Toast_hook_spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
96954
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
96955
- to[j] = from[i];
96956
- return to;
96948
+ var removeToast = function (toastId) {
96949
+ triggerEvent(REMOVE_TOAST_EVENT, toastId);
96957
96950
  };
96958
-
96959
- var Toast_hook_toasts = [];
96960
- var useToast = function (_a) {
96961
- var _b = _a === void 0 ? {} : _a, autoCloseMilliseconds = _b.autoCloseMilliseconds;
96962
- var _c = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useReducer"])(function (x) { return x + 1; }, 0), forceUpdate = _c[1];
96963
- var removeAllToasts = function () {
96964
- Toast_hook_toasts = [];
96965
- forceUpdate();
96966
- };
96967
- var removeToast = function (toastId) {
96968
- Toast_hook_toasts = Toast_hook_toasts.filter(function (toast) { return toast.toastId !== toastId; });
96969
- forceUpdate();
96970
- };
96971
- var addToast = function (toast) {
96972
- var toastAutoCloseMilliseconds = toast.autoCloseMilliseconds, rest = Toast_hook_rest(toast, ["autoCloseMilliseconds"]);
96973
- var toastId = rest.toastId || "toast-" + Math.random().toString();
96974
- Toast_hook_toasts = Toast_hook_spreadArray([Toast_hook_assign(Toast_hook_assign({}, rest), { toastId: toastId })], Toast_hook_toasts);
96975
- forceUpdate();
96976
- if ((autoCloseMilliseconds || toastAutoCloseMilliseconds) && toastAutoCloseMilliseconds !== 0) {
96977
- setTimeout(function () { return removeToast(toastId); }, autoCloseMilliseconds || toastAutoCloseMilliseconds);
96978
- }
96979
- };
96980
- return {
96981
- toasts: Toast_hook_toasts,
96982
- addToast: addToast,
96983
- removeToast: removeToast,
96984
- removeAllToasts: removeAllToasts
96985
- };
96951
+ var removeAllToasts = function () {
96952
+ triggerEvent(REMOVE_ALL_TOASTS_EVENT);
96986
96953
  };
96954
+ var useToast = function () { return ({
96955
+ addToast: addToast,
96956
+ removeToast: removeToast,
96957
+ removeAllToasts: removeAllToasts
96958
+ }); };
96987
96959
 
96988
96960
  // CONCATENATED MODULE: ./src/components/Components/Toast/Toast.tsx
96989
96961
  var Toast_assign = (undefined && undefined.__assign) || function () {
@@ -97008,18 +96980,41 @@ var Toast_rest = (undefined && undefined.__rest) || function (s, e) {
97008
96980
  }
97009
96981
  return t;
97010
96982
  };
96983
+ var Toast_spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
96984
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
96985
+ to[j] = from[i];
96986
+ return to;
96987
+ };
97011
96988
 
97012
96989
 
97013
96990
 
97014
96991
 
97015
- var ToastContainer = function () {
97016
- var _a = useToast(), removeAllToasts = _a.removeAllToasts, removeToast = _a.removeToast, toasts = _a.toasts;
97017
- Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useEffect"])(function () { return function () {
97018
- removeAllToasts();
97019
- }; }, []);
97020
- var handleCloseToast = function (id) { return function () {
97021
- removeToast(id);
96992
+
96993
+ var ToastContainer = function (_a) {
96994
+ var autoCloseMilliseconds = _a.autoCloseMilliseconds;
96995
+ var _b = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])([]), toasts = _b[0], setToasts = _b[1];
96996
+ var handleCloseToast = function (toastId) { return function () {
96997
+ setToasts(function (prev) { return prev.filter(function (toast) { return toast.toastId !== toastId; }); });
97022
96998
  }; };
96999
+ var handleAddToast = function (event) {
97000
+ var _a = event.detail, toastAutoCloseMilliseconds = _a.autoCloseMilliseconds, rest = Toast_rest(_a, ["autoCloseMilliseconds"]);
97001
+ var toastId = rest.toastId || "toast-" + Math.random().toString();
97002
+ setToasts(function (prev) { return Toast_spreadArray([Toast_assign(Toast_assign({}, rest), { toastId: toastId })], prev); });
97003
+ if ((autoCloseMilliseconds || toastAutoCloseMilliseconds) && toastAutoCloseMilliseconds !== 0) {
97004
+ setTimeout(function () { return handleCloseToast(toastId)(); }, autoCloseMilliseconds || toastAutoCloseMilliseconds);
97005
+ }
97006
+ };
97007
+ var handleRemoveToast = function (event) { return handleCloseToast(event.detail)(); };
97008
+ var handleRemoveAllToasts = function () { return setToasts([]); };
97009
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
97010
+ // @ts-ignore
97011
+ useEventListener(ADD_TOAST_EVENT, handleAddToast, document);
97012
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
97013
+ // @ts-ignore
97014
+ useEventListener(REMOVE_TOAST_EVENT, handleRemoveToast, document);
97015
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
97016
+ // @ts-ignore
97017
+ useEventListener(REMOVE_ALL_TOASTS_EVENT, handleRemoveAllToasts, document);
97023
97018
  return (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: "c-toast__container" },
97024
97019
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(AnimatePresence, null, toasts.map(function (_a) {
97025
97020
  var content = _a.content, toastId = _a.toastId, props = Toast_rest(_a, ["content", "toastId"]);
@@ -98276,27 +98271,28 @@ var Autocomplete2_spreadArray = (undefined && undefined.__spreadArray) || functi
98276
98271
 
98277
98272
 
98278
98273
  var Autocomplete2 = function (_a) {
98279
- var _b;
98280
- var _c = _a.asyncDelayMilliseconds, asyncDelayMilliseconds = _c === void 0 ? 200 : _c, _d = _a.canAlwaysCreateNewItem, canAlwaysCreateNewItem = _d === void 0 ? false : _d, disabledTooltip = _a.disabledTooltip, _e = _a.displayDetails, displayDetails = _e === void 0 ? false : _e, dropdownTheme = _a.dropdownTheme, emptyValueLabel = _a.emptyValueLabel, error = _a.error, _f = _a.filterMinimumLength, filterMinimumLength = _f === void 0 ? 2 : _f, _g = _a.hasFullWidthOptions, hasFullWidthOptions = _g === void 0 ? true : _g, help = _a.help, isDisabled = _a.isDisabled, isLazyLoaded = _a.isLazyLoaded, isLoading = _a.isLoading, _h = _a.items, inputItems = _h === void 0 ? [] : _h, label = _a.label, labelTooltip = _a.labelTooltip, loadItems = _a.loadItems, loadMoreItems = _a.loadMoreItems, name = _a.name, messages = _a.messages, _j = _a.newItemMinimumLength, newItemMinimumLength = _j === void 0 ? 2 : _j, onBlur = _a.onBlur, onChange = _a.onChange, onCreateNewItem = _a.onCreateNewItem, onFocus = _a.onFocus, placeholder = _a.placeholder, testId = _a.testId, theme = _a.theme, value = _a.value;
98281
- var _k = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(false), isDropdownVisible = _k[0], setIsDropdownVisible = _k[1];
98282
- var _l = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(null), buttonValue = _l[0], setButtonValue = _l[1];
98283
- var _m = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(false), typingMode = _m[0], setTypingMode = _m[1];
98284
- var _o = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(''), fulltextValue = _o[0], setFulltextValue = _o[1];
98285
- var _p = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(-1), currentItemPosition = _p[0], setCurrentItemPosition = _p[1];
98286
- var _q = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])([]), items = _q[0], setItems = _q[1];
98287
- 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"])({
98288
98282
  loading: false,
98289
98283
  found: -1
98290
- }), searchState = _r[0], setSearchState = _r[1];
98291
- var _s = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])({
98284
+ }), searchState = _q[0], setSearchState = _q[1];
98285
+ var _r = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])({
98292
98286
  loading: false,
98293
98287
  found: -1
98294
- }), pagingState = _s[0], setPagingState = _s[1];
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)); }, []);
98295
98292
  var loadAsyncItems = function (query) { return Autocomplete2_awaiter(void 0, void 0, void 0, function () {
98296
- var newItems, isCategorised, found;
98297
- var _a;
98298
- return Autocomplete2_generator(this, function (_b) {
98299
- switch (_b.label) {
98293
+ var newItems, categorised, found;
98294
+ return Autocomplete2_generator(this, function (_a) {
98295
+ switch (_a.label) {
98300
98296
  case 0:
98301
98297
  if (!loadItems)
98302
98298
  return [2 /*return*/];
@@ -98304,9 +98300,9 @@ var Autocomplete2 = function (_a) {
98304
98300
  setItems([]);
98305
98301
  return [4 /*yield*/, loadItems(query)];
98306
98302
  case 1:
98307
- newItems = _b.sent();
98308
- isCategorised = !!(newItems && ((_a = newItems[0]) === null || _a === void 0 ? void 0 : _a.items));
98309
- found = isCategorised
98303
+ newItems = _a.sent();
98304
+ categorised = isCategorised(newItems);
98305
+ found = categorised
98310
98306
  ? newItems.reduce(function (acc, curr) { return acc + curr.items.length; }, 0)
98311
98307
  : newItems.length;
98312
98308
  setSearchState({ loading: false, found: found });
@@ -98315,11 +98311,11 @@ var Autocomplete2 = function (_a) {
98315
98311
  }
98316
98312
  });
98317
98313
  }); };
98314
+ var fulltextMatchesEmptyValue = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useMemo"])(function () { return emptyValueLabelPattern.includes(fulltextValue); }, [fulltextValue]);
98318
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];
98319
- var isCategorised = !!(items && ((_b = items[0]) === null || _b === void 0 ? void 0 : _b.items));
98320
98316
  var itemsIndex = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useMemo"])(function () {
98321
98317
  var map;
98322
- if (isCategorised) {
98318
+ if (isCategorised(items)) {
98323
98319
  map = items.reduce(function (acc, category, categoryIndex) {
98324
98320
  return acc.concat(category.items
98325
98321
  .map(function (item, index) { return (!item.isDisabled ? { category: categoryIndex, item: index } : undefined); })
@@ -98331,11 +98327,11 @@ var Autocomplete2 = function (_a) {
98331
98327
  .map(function (item, index) { return (!item.isDisabled ? { category: -1, item: index } : undefined); })
98332
98328
  .filter(Boolean);
98333
98329
  }
98334
- if (emptyValueLabel && map.length > 0 && (fulltextValue === (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) || !value)) {
98330
+ if (emptyValueLabel && (!fulltextValue || fulltextValue === (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) || fulltextMatchesEmptyValue)) {
98335
98331
  return Autocomplete2_spreadArray([{ item: -1, category: -1 }], map);
98336
98332
  }
98337
98333
  return map;
98338
- }, [items, isCategorised, fulltextValue, value, buttonValue]);
98334
+ }, [items, fulltextValue, value, buttonValue]);
98339
98335
  var showCreatable = !!onCreateNewItem &&
98340
98336
  (itemsIndex.length === 0 || canAlwaysCreateNewItem) &&
98341
98337
  typingMode &&
@@ -98346,7 +98342,7 @@ var Autocomplete2 = function (_a) {
98346
98342
  if (val === '' || val === undefined) {
98347
98343
  return { item: -1, category: -1 };
98348
98344
  }
98349
- if (isCategorised) {
98345
+ if (isCategorised(sourceItems)) {
98350
98346
  var index = sourceItems
98351
98347
  .map(function (category, categoryIndex) {
98352
98348
  var item = category.items.findIndex(function (item) { return item.value === val && !item.isDisabled; });
@@ -98368,16 +98364,14 @@ var Autocomplete2 = function (_a) {
98368
98364
  });
98369
98365
  };
98370
98366
  var getFilteredItems = function (filter) {
98371
- var newFilter = stripDiacritics(typeof filter === 'string' ? filter : filter.toString())
98372
- .toLowerCase()
98373
- .trim();
98374
- if (isCategorised) {
98367
+ var newFilter = getSearchString(typeof filter === 'string' ? filter : filter.toString()).trim();
98368
+ if (isCategorised(inputItems)) {
98375
98369
  var filteredCategories_1 = [];
98376
98370
  var unfilteredItems = inputItems;
98377
98371
  unfilteredItems.map(function (category) {
98378
98372
  var filteredCategory = category.items.filter(function (_a) {
98379
98373
  var amount = _a.amount, label = _a.label, perex = _a.perex;
98380
- var text = stripDiacritics(label + " " + (perex || '') + " " + (amount || '')).toLowerCase();
98374
+ var text = getSearchString(label + " " + (perex || '') + " " + (amount || ''));
98381
98375
  return text.includes(newFilter);
98382
98376
  });
98383
98377
  if (filteredCategory.length > 0) {
@@ -98389,7 +98383,7 @@ var Autocomplete2 = function (_a) {
98389
98383
  else {
98390
98384
  var filteredOptions = inputItems.filter(function (_a) {
98391
98385
  var amount = _a.amount, label = _a.label, perex = _a.perex;
98392
- var text = stripDiacritics(label + " " + (perex || '') + " " + (amount || '')).toLowerCase();
98386
+ var text = getSearchString(label + " " + (perex || '') + " " + (amount || ''));
98393
98387
  return text.includes(newFilter);
98394
98388
  });
98395
98389
  return filteredOptions;
@@ -98400,7 +98394,7 @@ var Autocomplete2 = function (_a) {
98400
98394
  setItems(inputItems);
98401
98395
  var _a = getItemIndexByValue(value, inputItems), category = _a.category, item = _a.item;
98402
98396
  if (item > -1) {
98403
- var selectedItem = isCategorised
98397
+ var selectedItem = isCategorised(inputItems)
98404
98398
  ? inputItems[category].items[item]
98405
98399
  : inputItems[item];
98406
98400
  if (selectedItem) {
@@ -98415,7 +98409,7 @@ var Autocomplete2 = function (_a) {
98415
98409
  setCurrentItemPosition(itemIndexPosition);
98416
98410
  var category = itemIndex.category, item = itemIndex.item;
98417
98411
  if (item > -1) {
98418
- var selectedItem = isCategorised
98412
+ var selectedItem = isCategorised(items)
98419
98413
  ? items[category].items[item]
98420
98414
  : items[item];
98421
98415
  if (selectedItem) {
@@ -98439,7 +98433,7 @@ var Autocomplete2 = function (_a) {
98439
98433
  var _a, _b, _c, _d, _e, _f;
98440
98434
  if (category === void 0) { category = -1; }
98441
98435
  if (center === void 0) { center = false; }
98442
- var itemElementId = isCategorised ? name + "_option-" + category + "-" + item : name + "_option-" + item;
98436
+ var itemElementId = isCategorised(items) ? name + "_option-" + category + "-" + item : name + "_option-" + item;
98443
98437
  if (center) {
98444
98438
  var dropdownHalfHeight = (((_a = document.getElementById('autocomplete_dropdown')) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0) / 2;
98445
98439
  var itemHalfHeight = (((_b = document.getElementById(itemElementId)) === null || _b === void 0 ? void 0 : _b.clientHeight) || 0) / 2;
@@ -98555,7 +98549,7 @@ var Autocomplete2 = function (_a) {
98555
98549
  propagateChange();
98556
98550
  return undefined;
98557
98551
  }
98558
- var selectedItem = isCategorised
98552
+ var selectedItem = isCategorised(items)
98559
98553
  ? items[category].items[item]
98560
98554
  : items[item];
98561
98555
  if (selectedItem) {
@@ -98680,7 +98674,7 @@ var Autocomplete2 = function (_a) {
98680
98674
  setTimeout(function () {
98681
98675
  var _a;
98682
98676
  scrollToItem(item_1, category_1);
98683
- var listElementId = isCategorised ? name + "_list-" + category_1 : name + "_list";
98677
+ var listElementId = isCategorised(items) ? name + "_list-" + category_1 : name + "_list";
98684
98678
  (_a = document.getElementById(listElementId)) === null || _a === void 0 ? void 0 : _a.focus();
98685
98679
  });
98686
98680
  }
@@ -98695,16 +98689,15 @@ var Autocomplete2 = function (_a) {
98695
98689
  if (key === KEYS.Enter) {
98696
98690
  event.preventDefault();
98697
98691
  if (isDropdownVisible) {
98698
- var minItemsToAutoselect = emptyValueLabel && !value ? 2 : 1;
98699
98692
  if (showCreatable && itemsIndex.length === 0) {
98700
98693
  handleCreateNewOption();
98701
98694
  }
98702
- else if (fulltextValue && fulltextValue !== (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) && itemsIndex.length >= minItemsToAutoselect) {
98703
- var _a = itemsIndex[minItemsToAutoselect - 1], category = _a.category, item = _a.item;
98704
- 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)
98705
98698
  ? items[category].items[item]
98706
98699
  : items[item];
98707
- setFulltextValue(selectedItem.label);
98700
+ setFulltextValue((selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.label) || '');
98708
98701
  propagateChange(selectedItem);
98709
98702
  setTypingMode(false);
98710
98703
  }
@@ -98730,7 +98723,7 @@ var Autocomplete2 = function (_a) {
98730
98723
  setTimeout(function () {
98731
98724
  var _a;
98732
98725
  scrollToItem(item_2, category_2);
98733
- var listElementId = isCategorised ? name + "_list-" + category_2 : name + "_list";
98726
+ var listElementId = isCategorised(items) ? name + "_list-" + category_2 : name + "_list";
98734
98727
  (_a = document.getElementById(listElementId)) === null || _a === void 0 ? void 0 : _a.focus();
98735
98728
  });
98736
98729
  }
@@ -98761,7 +98754,7 @@ var Autocomplete2 = function (_a) {
98761
98754
  }
98762
98755
  else if (fulltextValue && fulltextValue !== (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) && itemsIndex.length > 0) {
98763
98756
  var _c = itemsIndex[0], category = _c.category, item = _c.item;
98764
- var selectedItem = isCategorised
98757
+ var selectedItem = isCategorised(items)
98765
98758
  ? items[category].items[item]
98766
98759
  : items[item];
98767
98760
  setButtonValue(selectedItem);
@@ -98830,7 +98823,7 @@ var Autocomplete2 = function (_a) {
98830
98823
  messages.loadingItems));
98831
98824
  }
98832
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,
98833
- 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),
98834
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" },
98835
98828
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: "loading", size: "large" }),
98836
98829
  messages.loadingMoreItems)),
@@ -98844,10 +98837,12 @@ var Autocomplete2 = function (_a) {
98844
98837
  messages.createItem, " \"" + fulltextValue + "\""))))));
98845
98838
  };
98846
98839
  var focusedItem = itemsIndex[currentItemPosition];
98840
+ var focusedCategoryIndex = focusedItem ? focusedItem.category : -1;
98841
+ var focusedItemIndex = focusedItem ? focusedItem.item : -1;
98847
98842
  var select2context = {
98848
- emptyValueLabel: itemsIndex.length > 0 && (fulltextValue === (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) || !value) ? emptyValueLabel : undefined,
98849
- focusedCategoryIndex: focusedItem ? focusedItem.category : -1,
98850
- focusedItemIndex: focusedItem ? focusedItem.item : -1,
98843
+ emptyValueLabel: !fulltextValue || fulltextValue === (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) || fulltextMatchesEmptyValue ? emptyValueLabel : undefined,
98844
+ focusedCategoryIndex: focusedCategoryIndex,
98845
+ focusedItemIndex: focusedItemIndex,
98851
98846
  items: items,
98852
98847
  name: name,
98853
98848
  optionClick: handleOptionClick,
@@ -98869,9 +98864,13 @@ var Autocomplete2 = function (_a) {
98869
98864
  return (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(FormGroup2, Autocomplete2_assign({ theme: classBinder_cx({ 'f-group2--open': isDropdownVisible }, theme) }, fromGroupProps),
98870
98865
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(contexts_Select2Context.Provider, { value: select2context },
98871
98866
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Dropdown, { dropdownId: "autocomplete_dropdown", forceVisibility: isDropdownVisible, hasSameWidthAsTrigger: hasFullWidthOptions, placement: "bottom-start", theme: dropdownTheme, trigger: null, triggerComponent: external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: "f-controlWrap", "data-testid": testId, role: "combobox" }, typingMode ? (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: classBinder_cx('f-control2 f-control2--select', { 'f-control2--large': displayDetails }) },
98872
- external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("input", { autoComplete: "off", className: classBinder_cx('f-autocomplete__input'), disabled: isDisabled, id: name + "_input", name: name, placeholder: placeholder, type: "text", value: fulltextValue, onChange: handleFulltextChange, onKeyDown: handleFulltextKeyPress }),
98867
+ external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("input", { "aria-activedescendant": isDropdownVisible && (itemsIndex.length > 0 || showCreatable)
98868
+ ? isCategorised(items)
98869
+ ? name + "_option-" + focusedCategoryIndex + "-" + focusedItemIndex
98870
+ : name + "_option-" + focusedItemIndex
98871
+ : undefined, "aria-autocomplete": "list", "aria-controls": name + "_list", "aria-labelledby": name + "_label", autoComplete: "off", className: classBinder_cx('f-autocomplete__input'), disabled: isDisabled, id: name + "_input", name: name, placeholder: placeholder, type: "text", value: fulltextValue, onChange: handleFulltextChange, onKeyDown: handleFulltextKeyPress }),
98873
98872
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("button", { "aria-invalid": !!error, className: classBinder_cx('f-autocomplete__button'), disabled: isDisabled, id: name + "_toggle_button", name: name, tabIndex: -1, type: "button", onClick: toggleDropdown },
98874
- external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: "arrowDown", size: "small", theme: "f-control2__selectIcon" })))) : (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("button", { "aria-expanded": isDropdownVisible, "aria-haspopup": "listbox", "aria-invalid": !!error, "aria-labelledby": name + "_label " + name, className: classBinder_cx('f-control2 f-control2--select', {
98873
+ external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: "arrowDown", size: "small", theme: "f-control2__selectIcon" })))) : (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("button", { "aria-expanded": isDropdownVisible, "aria-haspopup": "listbox", "aria-invalid": !!error, "aria-labelledby": name + "_label", className: classBinder_cx('f-control2 f-control2--select', {
98875
98874
  'f-control2--large': displayDetails,
98876
98875
  'f-autocomplete__trigger--loading': isLoading
98877
98876
  }), disabled: isDisabled, id: name + "_button", name: name, type: "button", onClick: handleComboBoxClick, onFocus: handleFocus },
@@ -1,2 +1,12 @@
1
- export declare const ToastContainer: () => JSX.Element;
1
+ import { ReactNode } from 'react';
2
+ import { AlertPropsType } from '..';
3
+ export declare type ToastType = Omit<AlertPropsType, 'alertRef' | 'children'> & {
4
+ autoCloseMilliseconds?: number;
5
+ toastId?: string;
6
+ content?: ReactNode;
7
+ };
8
+ export interface ToastContainerPropsType {
9
+ autoCloseMilliseconds?: number;
10
+ }
11
+ export declare const ToastContainer: ({ autoCloseMilliseconds }: ToastContainerPropsType) => JSX.Element;
2
12
  //# sourceMappingURL=Toast.d.ts.map
@@ -1,18 +1,12 @@
1
- import { ReactNode } from 'react';
2
- import { AlertPropsType } from '..';
3
- export declare type ToastType = Omit<AlertPropsType, 'alertRef' | 'children'> & {
4
- autoCloseMilliseconds?: number;
5
- toastId: string;
6
- content?: ReactNode;
7
- };
8
- export interface ToastHookType {
9
- toasts: ToastType[];
1
+ import { ToastType } from '.';
2
+ export declare const ADD_TOAST_EVENT = "toast/add";
3
+ export declare const REMOVE_TOAST_EVENT = "toast/remove";
4
+ export declare const REMOVE_ALL_TOASTS_EVENT = "toast/removeAll";
5
+ interface UseToastType {
10
6
  addToast(toast: ToastType): void;
11
- removeAllToasts(): void;
12
7
  removeToast(toastId?: string): void;
8
+ removeAllToasts(): void;
13
9
  }
14
- export interface UseToastHookPropsType {
15
- autoCloseMilliseconds?: number;
16
- }
17
- export declare const useToast: ({ autoCloseMilliseconds }?: UseToastHookPropsType) => ToastHookType;
10
+ export declare const useToast: () => UseToastType;
11
+ export {};
18
12
  //# sourceMappingURL=Toast.hook.d.ts.map
@@ -1,3 +1,3 @@
1
1
  export * from './Toast';
2
- export * from './Toast.hook';
2
+ export { useToast } from './Toast.hook';
3
3
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmb-digital/ds-lilly",
3
- "version": "0.3.12",
3
+ "version": "0.3.15",
4
4
  "description": "MMB LILLY design system",
5
5
  "license": "UNLICENSED",
6
6
  "sideEffects": false,
package/dist/.DS_Store DELETED
Binary file