@mmb-digital/ds-lilly 0.3.0 → 0.3.1

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.
Files changed (2) hide show
  1. package/dist/ds-lilly.js +19 -9
  2. package/package.json +2 -1
package/dist/ds-lilly.js CHANGED
@@ -98281,7 +98281,7 @@ var Autocomplete2 = function (_a) {
98281
98281
  var _j = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(false), isDropdownVisible = _j[0], setIsDropdownVisible = _j[1];
98282
98282
  var _k = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(null), buttonValue = _k[0], setButtonValue = _k[1];
98283
98283
  var _l = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(false), typingMode = _l[0], setTypingMode = _l[1];
98284
- var _m = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(value || ''), fulltextValue = _m[0], setFulltextValue = _m[1];
98284
+ var _m = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(''), fulltextValue = _m[0], setFulltextValue = _m[1];
98285
98285
  var _o = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(-1), currentItemPosition = _o[0], setCurrentItemPosition = _o[1];
98286
98286
  var _p = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])([]), items = _p[0], setItems = _p[1];
98287
98287
  var _q = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])({
@@ -98341,12 +98341,13 @@ var Autocomplete2 = function (_a) {
98341
98341
  typingMode &&
98342
98342
  fulltextValue.length >= newItemMinimumLength &&
98343
98343
  (!loadItems || (!!loadItems && searchState.found === 0));
98344
- var getItemIndexByValue = function (val) {
98344
+ var getItemIndexByValue = function (val, sourceItems) {
98345
+ if (sourceItems === void 0) { sourceItems = items; }
98345
98346
  if (val === '' || val === undefined) {
98346
98347
  return { item: -1, category: -1 };
98347
98348
  }
98348
98349
  if (isCategorised) {
98349
- var index = items
98350
+ var index = sourceItems
98350
98351
  .map(function (category, categoryIndex) {
98351
98352
  var item = category.items.findIndex(function (item) { return item.value === val && !item.isDisabled; });
98352
98353
  return { item: item, category: categoryIndex };
@@ -98357,7 +98358,7 @@ var Autocomplete2 = function (_a) {
98357
98358
  });
98358
98359
  return index || { item: -1, category: -1 };
98359
98360
  }
98360
- var item = items.findIndex(function (item) { return item.value === val && !item.isDisabled; });
98361
+ var item = sourceItems.findIndex(function (item) { return item.value === val && !item.isDisabled; });
98361
98362
  return { item: item, category: -1 };
98362
98363
  };
98363
98364
  var getItemIndexPosition = function (index) {
@@ -98397,8 +98398,17 @@ var Autocomplete2 = function (_a) {
98397
98398
  Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useEffect"])(function () {
98398
98399
  if (inputItems.length) {
98399
98400
  setItems(inputItems);
98401
+ var _a = getItemIndexByValue(value, inputItems), category = _a.category, item = _a.item;
98402
+ if (item > -1) {
98403
+ var selectedItem = isCategorised
98404
+ ? inputItems[category].items[item]
98405
+ : inputItems[item];
98406
+ if (selectedItem) {
98407
+ setButtonValue(selectedItem);
98408
+ }
98409
+ }
98400
98410
  }
98401
- }, [inputItems]);
98411
+ }, [value, inputItems]);
98402
98412
  Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useEffect"])(function () {
98403
98413
  var itemIndex = getItemIndexByValue(value);
98404
98414
  var itemIndexPosition = getItemIndexPosition(itemIndex);
@@ -98774,20 +98784,20 @@ var Autocomplete2 = function (_a) {
98774
98784
  }
98775
98785
  };
98776
98786
  var renderDropdownContent = function () {
98777
- if (loadItems && items.length === 0 && !searchState.loading && searchState.found === -1) {
98787
+ if (loadItems && items.length === 0 && !searchState.loading && searchState.found === -1 && messages.typeToFilter) {
98778
98788
  return external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: "f-autocomplete__message" }, messages.typeToFilter);
98779
98789
  }
98780
- if (searchState.loading) {
98790
+ if (searchState.loading && messages.loadingItems) {
98781
98791
  return (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: "f-autocomplete__message" },
98782
98792
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: "loading", size: "large" }),
98783
98793
  messages.loadingItems));
98784
98794
  }
98785
98795
  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,
98786
98796
  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),
98787
- pagingState.loading && (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: "f-autocomplete__message", id: "autocomplete_loading-more-items" },
98797
+ 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" },
98788
98798
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: "loading", size: "large" }),
98789
98799
  messages.loadingMoreItems)),
98790
- (searchState.found === 0 || items.length === 0) && (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: "f-autocomplete__message" }, messages.nohingFound)),
98800
+ (searchState.found === 0 || items.length === 0) && messages.nohingFound && (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: "f-autocomplete__message" }, messages.nohingFound)),
98791
98801
  showCreatable && (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(DropdownMenu, { activeDescendant: name + "_option-createNew", id: name + "_list-createNew", role: "listbox", tabIndex: -1, onKeyDown: handleOptionKeyPress },
98792
98802
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(DropdownItem, { id: name + "_option-createNew", isFocused: currentItemPosition === itemsIndex.length, role: "option", theme: "c-dropdown__footer", onClick: handleCreateNewOption, onMouseOver: function () {
98793
98803
  setCurrentItemPosition(itemsIndex.length);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmb-digital/ds-lilly",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "MMB LILLY design system",
5
5
  "license": "UNLICENSED",
6
6
  "sideEffects": false,
@@ -104,6 +104,7 @@
104
104
  "@types/react-text-mask": "^5.4.7",
105
105
  "@typescript-eslint/eslint-plugin": "^4.25.0",
106
106
  "@typescript-eslint/parser": "^4.25.0",
107
+ "@whitespace/storybook-addon-html": "^5.0.0",
107
108
  "@wojtekmaj/enzyme-adapter-react-17": "^0.6.1",
108
109
  "awesome-typescript-loader": "^5.2.1",
109
110
  "babel-loader": "8.1.0",