superdesk-ui-framework 3.0.6 → 3.0.7

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.
@@ -63114,31 +63114,52 @@ var TreeSelect = /** @class */ (function (_super) {
63114
63114
  function TreeSelect(props) {
63115
63115
  var _this = _super.call(this, props) || this;
63116
63116
  _this.htmlId = (0, react_id_generator_1.default)();
63117
+ _this.inputFocus = function () {
63118
+ var _a;
63119
+ (_a = _this.inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
63120
+ };
63121
+ _this.listNavigation = function () {
63122
+ var element = document.querySelector('.suggestion-item--btn');
63123
+ element.focus();
63124
+ };
63125
+ _this.buttonFocus = function () {
63126
+ var _a;
63127
+ (_a = _this.categoryButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
63128
+ };
63117
63129
  _this.componentDidMount = function () {
63118
63130
  _this.recursion(_this.state.options);
63119
63131
  document.addEventListener("mousedown", function (event) {
63132
+ if (!(event.target instanceof HTMLInputElement)) {
63133
+ return;
63134
+ }
63120
63135
  if ((_this.dropdownRef.current && !_this.dropdownRef.current.contains(event.target))
63121
63136
  && (_this.openDropdownRef.current && !_this.openDropdownRef.current.contains(event.target))) {
63122
63137
  _this.setState({ openDropdown: false });
63123
63138
  }
63124
63139
  });
63140
+ document.addEventListener("keydown", function (e) {
63141
+ if (_this.state.openDropdown && _this.ref.current) {
63142
+ keyboardNavigation(e, _this.ref.current, _this.categoryButtonRef.current ? _this.buttonFocus : _this.inputFocus);
63143
+ if (e.key === 'Backspace') {
63144
+ _this.backButton();
63145
+ var buttonTarget = _this.state.buttonTarget;
63146
+ var className = buttonTarget.pop();
63147
+ if (className != null) {
63148
+ var element = document.getElementsByClassName(className)[0];
63149
+ element.focus();
63150
+ }
63151
+ }
63152
+ }
63153
+ });
63125
63154
  };
63126
- _this.backButton = function () {
63127
- if (_this.state.activeTree.length > 0) {
63155
+ _this.backButtonValue = function () {
63156
+ var item = _this.state.buttonTree.pop();
63157
+ if (item != null) {
63128
63158
  _this.setState({
63129
- options: _this.state.activeTree.pop(),
63159
+ buttonValue: item,
63130
63160
  });
63131
- return;
63132
- }
63133
- else {
63134
- return false;
63135
63161
  }
63136
63162
  };
63137
- _this.backButtonValue = function () {
63138
- _this.setState({
63139
- buttonValue: _this.state.buttonTree.pop(),
63140
- });
63141
- };
63142
63163
  _this.debounceFn = (0, debounce_1.default)(_this.handleDebounce, 500);
63143
63164
  _this.state = {
63144
63165
  value: _this.props.value ? _this.props.value : [],
@@ -63148,11 +63169,11 @@ var TreeSelect = /** @class */ (function (_super) {
63148
63169
  filterArr: [],
63149
63170
  searchFieldValue: '',
63150
63171
  buttonTree: [],
63151
- buttonValue: [],
63172
+ buttonValue: null,
63152
63173
  buttonMouseEvent: false,
63153
63174
  openDropdown: false,
63154
63175
  loading: false,
63155
- // provera: false
63176
+ buttonTarget: [],
63156
63177
  };
63157
63178
  _this.removeClick = _this.removeClick.bind(_this);
63158
63179
  _this.handleMultiLevel = _this.handleMultiLevel.bind(_this);
@@ -63161,14 +63182,19 @@ var TreeSelect = /** @class */ (function (_super) {
63161
63182
  _this.backButtonValue = _this.backButtonValue.bind(_this);
63162
63183
  _this.handleTree = _this.handleTree.bind(_this);
63163
63184
  _this.filteredItem = _this.filteredItem.bind(_this);
63164
- _this.banchButton = _this.banchButton.bind(_this);
63185
+ _this.branchButton = _this.branchButton.bind(_this);
63165
63186
  _this.handleDebounce = _this.handleDebounce.bind(_this);
63166
63187
  _this.toggleMenu = _this.toggleMenu.bind(_this);
63167
63188
  _this.dropdownRef = React.createRef();
63189
+ _this.ref = React.createRef();
63190
+ _this.inputRef = React.createRef();
63191
+ _this.categoryButtonRef = React.createRef();
63168
63192
  _this.openDropdownRef = React.createRef();
63193
+ _this.popperInstance = null;
63169
63194
  return _this;
63170
63195
  }
63171
63196
  TreeSelect.prototype.componentDidUpdate = function (prevProps, prevState) {
63197
+ var _a;
63172
63198
  if (!(0, lodash_1.isEqual)(prevState.value, this.state.value)) {
63173
63199
  this.props.onChange(this.state.value);
63174
63200
  }
@@ -63182,11 +63208,13 @@ var TreeSelect = /** @class */ (function (_super) {
63182
63208
  if ((prevState.activeTree !== this.state.activeTree)
63183
63209
  || (prevState.filterArr !== this.state.filterArr)
63184
63210
  || (prevState.options !== this.state.options)) {
63185
- this.popperInstance.update();
63211
+ (_a = this.popperInstance) === null || _a === void 0 ? void 0 : _a.update();
63186
63212
  }
63187
63213
  }
63188
63214
  };
63189
63215
  TreeSelect.prototype.toggleMenu = function () {
63216
+ var _this = this;
63217
+ var _a, _b;
63190
63218
  if (this.state.openDropdown) {
63191
63219
  if (this.openDropdownRef.current && this.dropdownRef.current) {
63192
63220
  this.popperInstance = (0, core_1.createPopper)(this.openDropdownRef.current, this.dropdownRef.current, {
@@ -63201,6 +63229,30 @@ var TreeSelect = /** @class */ (function (_super) {
63201
63229
  ],
63202
63230
  });
63203
63231
  }
63232
+ (_a = this.inputRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('keydown', function (e) {
63233
+ if (e.key === 'ArrowDown') {
63234
+ e.preventDefault();
63235
+ e.stopPropagation();
63236
+ if (_this.categoryButtonRef.current) {
63237
+ _this.buttonFocus();
63238
+ }
63239
+ else {
63240
+ setTimeout(function () {
63241
+ _this.listNavigation();
63242
+ });
63243
+ }
63244
+ }
63245
+ });
63246
+ if (this.inputRef.current) {
63247
+ this.inputFocus();
63248
+ }
63249
+ else {
63250
+ var element = document.querySelector('.suggestion-item--btn');
63251
+ element.focus();
63252
+ }
63253
+ }
63254
+ else {
63255
+ (_b = this.openDropdownRef.current) === null || _b === void 0 ? void 0 : _b.focus();
63204
63256
  }
63205
63257
  };
63206
63258
  TreeSelect.prototype.removeClick = function (i) {
@@ -63220,8 +63272,12 @@ var TreeSelect = /** @class */ (function (_super) {
63220
63272
  }
63221
63273
  };
63222
63274
  TreeSelect.prototype.handleButton = function (item) {
63275
+ var buttonTreeNext = this.state.buttonTree;
63276
+ if (this.state.buttonValue != null) {
63277
+ buttonTreeNext = buttonTreeNext.concat(this.state.buttonValue);
63278
+ }
63223
63279
  this.setState({
63224
- buttonTree: __spreadArray(__spreadArray([], this.state.buttonTree, true), [this.state.buttonValue], false),
63280
+ buttonTree: buttonTreeNext,
63225
63281
  buttonValue: item,
63226
63282
  });
63227
63283
  };
@@ -63236,10 +63292,15 @@ var TreeSelect = /** @class */ (function (_super) {
63236
63292
  }
63237
63293
  if (!event.ctrlKey) {
63238
63294
  if (this.props.getOptions) {
63239
- this.setState({ options: this.state.firstBranchOptions, activeTree: [], openDropdown: false });
63295
+ this.setState({
63296
+ options: this.state.firstBranchOptions,
63297
+ activeTree: [],
63298
+ buttonTarget: [],
63299
+ openDropdown: false,
63300
+ });
63240
63301
  }
63241
63302
  else {
63242
- this.setState({ activeTree: [], openDropdown: false });
63303
+ this.setState({ activeTree: [], buttonTarget: [], openDropdown: false });
63243
63304
  }
63244
63305
  }
63245
63306
  this.setState({ buttonMouseEvent: false });
@@ -63252,7 +63313,12 @@ var TreeSelect = /** @class */ (function (_super) {
63252
63313
  this.setState({ value: [item.value] });
63253
63314
  }
63254
63315
  if (!event.ctrlKey) {
63255
- this.setState({ options: this.state.firstBranchOptions, activeTree: [], openDropdown: false });
63316
+ this.setState({
63317
+ options: this.state.firstBranchOptions,
63318
+ activeTree: [],
63319
+ buttonTarget: [],
63320
+ openDropdown: false,
63321
+ });
63256
63322
  }
63257
63323
  this.setState({ buttonMouseEvent: false });
63258
63324
  }
@@ -63268,7 +63334,12 @@ var TreeSelect = /** @class */ (function (_super) {
63268
63334
  this.setState({ value: __spreadArray(__spreadArray([], this.state.value, true), [item.value], false) });
63269
63335
  }
63270
63336
  if (!event.ctrlKey) {
63271
- this.setState({ options: this.state.firstBranchOptions, activeTree: [], openDropdown: false });
63337
+ this.setState({
63338
+ options: this.state.firstBranchOptions,
63339
+ activeTree: [],
63340
+ buttonTarget: [],
63341
+ openDropdown: false,
63342
+ });
63272
63343
  }
63273
63344
  this.setState({ buttonMouseEvent: false });
63274
63345
  }
@@ -63282,7 +63353,12 @@ var TreeSelect = /** @class */ (function (_super) {
63282
63353
  this.setState({ value: [item.value] });
63283
63354
  }
63284
63355
  if (!event.ctrlKey) {
63285
- this.setState({ options: this.state.firstBranchOptions, activeTree: [], openDropdown: false });
63356
+ this.setState({
63357
+ options: this.state.firstBranchOptions,
63358
+ activeTree: [],
63359
+ buttonTarget: [],
63360
+ openDropdown: false,
63361
+ });
63286
63362
  }
63287
63363
  this.setState({ buttonMouseEvent: false });
63288
63364
  }
@@ -63306,6 +63382,7 @@ var TreeSelect = /** @class */ (function (_super) {
63306
63382
  options: this.state.firstBranchOptions,
63307
63383
  openDropdown: false,
63308
63384
  activeTree: [],
63385
+ buttonTarget: [],
63309
63386
  });
63310
63387
  }
63311
63388
  else {
@@ -63322,6 +63399,7 @@ var TreeSelect = /** @class */ (function (_super) {
63322
63399
  options: this.state.firstBranchOptions,
63323
63400
  openDropdown: false,
63324
63401
  activeTree: [],
63402
+ buttonTarget: [],
63325
63403
  });
63326
63404
  }
63327
63405
  }
@@ -63333,6 +63411,16 @@ var TreeSelect = /** @class */ (function (_super) {
63333
63411
  this.setState({ openDropdown: false });
63334
63412
  }
63335
63413
  }
63414
+ var element = document.querySelector('.suggestion-item--btn');
63415
+ element.focus();
63416
+ };
63417
+ TreeSelect.prototype.backButton = function () {
63418
+ var items = this.state.activeTree.pop();
63419
+ if (items != null) {
63420
+ this.setState({
63421
+ options: items,
63422
+ });
63423
+ }
63336
63424
  };
63337
63425
  TreeSelect.prototype.recursion = function (arr) {
63338
63426
  var _this = this;
@@ -63368,7 +63456,7 @@ var TreeSelect = /** @class */ (function (_super) {
63368
63456
  var selectedItem = _this.state.value.some(function (obj) {
63369
63457
  return _this.props.getId(obj) === _this.props.getId(option.value);
63370
63458
  });
63371
- return React.createElement("li", { key: i, className: "suggestion-item suggestion-item--multi-select", onClick: function (event) {
63459
+ return (React.createElement("li", { key: i, className: "suggestion-item suggestion-item--multi-select", onClick: function (event) {
63372
63460
  _this.setState({
63373
63461
  searchFieldValue: '',
63374
63462
  }),
@@ -63376,17 +63464,19 @@ var TreeSelect = /** @class */ (function (_super) {
63376
63464
  event.stopPropagation();
63377
63465
  _this.handleTree(event, option);
63378
63466
  } },
63379
- _this.props.getBorderColor
63380
- && React.createElement("div", { className: "item-border", style: { backgroundColor: _this.props.getBorderColor(option.value) } }),
63381
- React.createElement("span", { style: _this.props.getBackgroundColor
63382
- ? { backgroundColor: _this.props.getBackgroundColor(option.value),
63383
- color: (0, Label_1.getTextColor)(_this.props.getBackgroundColor(option.value)) }
63384
- : undefined, className: 'suggestion-item--bgcolor'
63385
- + (selectedItem ? ' suggestion-item--disabled' : '') }, _this.props.optionTemplate
63386
- ? _this.props.optionTemplate(option.value)
63387
- : _this.props.getLabel(option.value)),
63388
- option.children && React.createElement("span", { className: "suggestion-item__icon" },
63389
- React.createElement(Icon_1.Icon, { name: "chevron-right-thin" })));
63467
+ React.createElement("button", { className: "suggestion-item--btn" },
63468
+ _this.props.getBorderColor
63469
+ && React.createElement("div", { className: "item-border", style: { backgroundColor: _this.props.getBorderColor(option.value) } }),
63470
+ React.createElement("span", { style: _this.props.getBackgroundColor
63471
+ ? { backgroundColor: _this.props.getBackgroundColor(option.value),
63472
+ color: (0, Label_1.getTextColor)(_this.props.getBackgroundColor(option.value)) }
63473
+ : undefined, className: 'suggestion-item--bgcolor'
63474
+ + (selectedItem ? ' suggestion-item--disabled' : '') }, _this.props.optionTemplate
63475
+ ? _this.props.optionTemplate(option.value)
63476
+ : _this.props.getLabel(option.value)),
63477
+ option.children
63478
+ && React.createElement("span", { className: "suggestion-item__icon" },
63479
+ React.createElement(Icon_1.Icon, { name: "chevron-right-thin" })))));
63390
63480
  });
63391
63481
  }
63392
63482
  }
@@ -63397,26 +63487,47 @@ var TreeSelect = /** @class */ (function (_super) {
63397
63487
  });
63398
63488
  return (React.createElement("li", { key: i, className: "suggestion-item suggestion-item--multi-select", onClick: function (event) {
63399
63489
  _this.handleValue(event, item);
63400
- } }, _this.props.optionTemplate
63401
- ? _this.props.optionTemplate(item.value)
63402
- : React.createElement("span", { className: selectedItem
63403
- ? 'suggestion-item--disabled' : undefined }, _this.props.getLabel(item.value))));
63490
+ } },
63491
+ React.createElement("button", { className: "suggestion-item--btn" }, _this.props.optionTemplate
63492
+ ? _this.props.optionTemplate(item.value)
63493
+ : React.createElement("span", { className: selectedItem
63494
+ ? 'suggestion-item--disabled' : undefined }, _this.props.getLabel(item.value)))));
63404
63495
  });
63405
63496
  }
63406
63497
  else {
63407
63498
  return;
63408
63499
  }
63409
63500
  };
63410
- TreeSelect.prototype.banchButton = function () {
63501
+ TreeSelect.prototype.branchButton = function (buttonValue) {
63411
63502
  var _this = this;
63503
+ setTimeout(function () {
63504
+ var _a;
63505
+ (_a = _this.categoryButtonRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('keydown', function (e) {
63506
+ var _a;
63507
+ if (e.key === 'ArrowDown') {
63508
+ e.preventDefault();
63509
+ e.stopPropagation();
63510
+ setTimeout(function () {
63511
+ var element = document.querySelector('.suggestion-item--btn');
63512
+ element.focus();
63513
+ });
63514
+ }
63515
+ if (e.key === 'ArrowUp') {
63516
+ e.preventDefault();
63517
+ e.stopPropagation();
63518
+ (_a = _this.inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
63519
+ }
63520
+ });
63521
+ });
63412
63522
  var selectedButton = this.state.value.some(function (obj) {
63413
- return _this.props.getId(obj) === _this.props.getId(_this.state.buttonValue.value);
63523
+ return _this.props.getId(obj) === _this.props.getId(buttonValue.value);
63414
63524
  });
63415
63525
  if (!selectedButton) {
63416
- return React.createElement("button", { className: 'autocomplete__button' + (this.props.selectBranchWithChildren ? ' autocomplete__button--multi-select' : ''), onMouseOver: function () { return _this.setState({ buttonMouseEvent: true }); }, onMouseOut: function () { return _this.setState({ buttonMouseEvent: false }); }, value: this.state.buttonValue, onClick: function (event) { return _this.handleBranchValue(event, _this.state.buttonValue); } }, "Choose entire category");
63526
+ return React.createElement("button", { ref: this.categoryButtonRef, className: 'autocomplete__button' + (this.props.selectBranchWithChildren ? ' autocomplete__button--multi-select' : ''), onMouseOver: function () { return _this.setState({ buttonMouseEvent: true }); }, onMouseOut: function () { return _this.setState({ buttonMouseEvent: false }); }, onClick: function (event) { return _this.handleBranchValue(event, buttonValue); } }, "Choose entire category");
63417
63527
  }
63418
63528
  else {
63419
- return React.createElement("button", { className: 'autocomplete__button' + (this.props.selectBranchWithChildren ? ' autocomplete__button--multi-select' : '') + ' autocomplete__button--disabled', value: this.state.buttonValue }, "Category selected");
63529
+ return React.createElement("button", { className: 'autocomplete__button'
63530
+ + (this.props.selectBranchWithChildren ? ' autocomplete__button--multi-select' : '') + ' autocomplete__button--disabled' }, "Category selected");
63420
63531
  }
63421
63532
  };
63422
63533
  TreeSelect.prototype.handleDebounce = function () {
@@ -63426,15 +63537,11 @@ var TreeSelect = /** @class */ (function (_super) {
63426
63537
  if (this.state.searchFieldValue) {
63427
63538
  this.setState({
63428
63539
  loading: true,
63429
- // provera: false
63430
63540
  });
63431
63541
  this.ICancelFn = this.props.searchOptions(this.state.searchFieldValue, function (items) {
63432
- // if (items.length === 0) {
63433
- // this.setState({provera: true, loading: false})
63434
- // } else {
63542
+ var _a;
63435
63543
  _this.setState({ options: items, loading: false });
63436
- _this.popperInstance.update();
63437
- // }
63544
+ (_a = _this.popperInstance) === null || _a === void 0 ? void 0 : _a.update();
63438
63545
  });
63439
63546
  }
63440
63547
  }
@@ -63472,13 +63579,15 @@ var TreeSelect = /** @class */ (function (_super) {
63472
63579
  this.state.value.length > 0
63473
63580
  ? this.props.readOnly
63474
63581
  || React.createElement("button", { className: "tags-input__remove-value", style: { position: 'relative', bottom: '2px' }, onClick: function () { return _this.setState({ value: [] }); } },
63475
- React.createElement(Icon_1.Icon, { name: 'remove-sign' })) : null)
63582
+ React.createElement(Icon_1.Icon, { name: 'remove-sign' }))
63583
+ : null)
63476
63584
  : React.createElement("div", { className: "tags-input__tags" },
63477
63585
  this.props.readOnly
63478
63586
  || React.createElement("button", { className: "tags-input__overlay-button", ref: this.openDropdownRef, onClick: function () { return _this.setState({ openDropdown: !_this.state.openDropdown }); } }),
63479
- this.state.value.length < 1 && React.createElement("span", { className: 'tags-input__single-item'
63480
- + (this.props.readOnly ? ' tags-input__tag-item--readonly' : '') },
63481
- React.createElement("span", { className: "tags-input__placeholder" }, this.props.placeholder)),
63587
+ this.state.value.length < 1
63588
+ && React.createElement("span", { className: 'tags-input__single-item'
63589
+ + (this.props.readOnly ? ' tags-input__tag-item--readonly' : '') },
63590
+ React.createElement("span", { className: "tags-input__placeholder" }, this.props.placeholder)),
63482
63591
  this.state.value.map(function (item, i) {
63483
63592
  var Wrapper = function (_a) {
63484
63593
  var backgroundColor = _a.backgroundColor, borderColor = _a.borderColor, children = _a.children;
@@ -63508,27 +63617,25 @@ var TreeSelect = /** @class */ (function (_super) {
63508
63617
  } },
63509
63618
  React.createElement(Icon_1.Icon, { name: "search", className: "search" })),
63510
63619
  React.createElement("div", { className: 'autocomplete__filter' },
63511
- React.createElement("input", { placeholder: this.props.searchPlaceholder, type: "text", className: "autocomplete__input", ref: function (input) { return input && input.focus(); }, value: this.state.searchFieldValue, onChange: function (event) {
63620
+ React.createElement("input", { placeholder: this.props.searchPlaceholder, type: "text", className: "autocomplete__input", ref: this.inputRef, value: this.state.searchFieldValue, onChange: function (event) {
63621
+ var _a, _b;
63512
63622
  if (_this.props.kind === 'synchronous') {
63513
63623
  _this.setState({ searchFieldValue: event.target.value });
63514
- _this.popperInstance.update();
63624
+ (_a = _this.popperInstance) === null || _a === void 0 ? void 0 : _a.update();
63515
63625
  }
63516
63626
  else if (_this.props.kind === 'asynchronous') {
63517
63627
  if (_this.ICancelFn) {
63518
63628
  _this.ICancelFn();
63519
63629
  }
63520
63630
  _this.setState({ searchFieldValue: event.target.value, options: [] });
63521
- _this.popperInstance.update();
63631
+ (_b = _this.popperInstance) === null || _b === void 0 ? void 0 : _b.update();
63522
63632
  _this.debounceFn();
63523
63633
  }
63524
63634
  else {
63525
63635
  return;
63526
63636
  }
63527
- // if(!this.state.searchFieldValue) {
63528
- // this.setState({provera: false});
63529
- // }
63530
63637
  } }))),
63531
- this.state.activeTree.length > 0
63638
+ (this.state.activeTree.length > 0 && this.state.buttonValue != null)
63532
63639
  && React.createElement("div", { className: 'autocomplete__category-header' },
63533
63640
  React.createElement("div", { className: "autocomplete__icon", onClick: function () {
63534
63641
  _this.backButtonValue();
@@ -63536,16 +63643,17 @@ var TreeSelect = /** @class */ (function (_super) {
63536
63643
  } },
63537
63644
  React.createElement(Icon_1.Icon, { name: "arrow-left", className: "arrow-left" })),
63538
63645
  React.createElement("div", { className: 'autocomplete__filter' },
63539
- React.createElement("button", { className: 'autocomplete__category-title', value: this.state.buttonValue }, this.props.optionTemplate
63646
+ React.createElement("button", { className: 'autocomplete__category-title' }, this.props.optionTemplate
63540
63647
  ? this.props.optionTemplate(this.state.buttonValue.value)
63541
63648
  : this.props.getLabel(this.state.buttonValue.value)),
63542
- this.props.selectBranchWithChildren && this.banchButton())),
63649
+ this.props.selectBranchWithChildren
63650
+ && this.branchButton(this.state.buttonValue))),
63543
63651
  this.state.loading
63544
63652
  ? React.createElement("ul", { className: "suggestion-list--loader" },
63545
63653
  React.createElement(Loader_1.Loader, { overlay: true }))
63546
63654
  : this.state.searchFieldValue === ''
63547
63655
  ? this.props.getOptions
63548
- ? React.createElement("ul", { className: "suggestion-list suggestion-list--multi-select" }, this.state.options
63656
+ ? React.createElement("ul", { className: "suggestion-list suggestion-list--multi-select", ref: this.ref }, this.state.options
63549
63657
  .map(function (option, i) {
63550
63658
  var selectedItem = _this.state.value.some(function (obj) {
63551
63659
  return _this.props.getId(obj) === _this.props.getLabel(option.value);
@@ -63555,23 +63663,90 @@ var TreeSelect = /** @class */ (function (_super) {
63555
63663
  event.stopPropagation();
63556
63664
  _this.handleTree(event, option);
63557
63665
  } },
63558
- (_this.props.getBorderColor && !_this.props.allowMultiple) && React.createElement("div", { className: "item-border", style: { backgroundColor: _this.props.getBorderColor(option.value) } }),
63559
- React.createElement("span", { style: (_this.props.getBackgroundColor && option.value)
63560
- ? { backgroundColor: _this.props.getBackgroundColor(option.value),
63561
- color: (0, Label_1.getTextColor)(_this.props.getBackgroundColor(option.value)) }
63562
- : undefined, className: 'suggestion-item--bgcolor'
63563
- + (selectedItem ? ' suggestion-item--disabled' : '') }, _this.props.optionTemplate
63564
- ? _this.props.optionTemplate(option.value)
63565
- : _this.props.getLabel(option.value)),
63566
- option.children && React.createElement("span", { className: "suggestion-item__icon" },
63567
- React.createElement(Icon_1.Icon, { name: "chevron-right-thin" }))));
63568
- })) : null
63569
- : React.createElement("ul", { className: "suggestion-list suggestion-list--multi-select" }, this.filteredItem(this.props.singleLevelSearch
63666
+ React.createElement("button", { className: "suggestion-item--btn ".concat(_this.props.getId(option.value)), onKeyDown: function (event) {
63667
+ if (event.key === 'Enter' && option.children) {
63668
+ _this.setState({
63669
+ buttonTarget: __spreadArray(__spreadArray([], _this.state.buttonTarget, true), [
63670
+ _this.props.getId(option.value),
63671
+ ], false),
63672
+ });
63673
+ }
63674
+ } },
63675
+ (_this.props.getBorderColor && !_this.props.allowMultiple)
63676
+ && React.createElement("div", { className: "item-border", style: {
63677
+ backgroundColor: _this.props.getBorderColor(option.value),
63678
+ } }),
63679
+ React.createElement("span", { style: (_this.props.getBackgroundColor && option.value)
63680
+ ? {
63681
+ backgroundColor: _this.props.getBackgroundColor(option.value),
63682
+ color: (0, Label_1.getTextColor)(_this.props.getBackgroundColor(option.value)),
63683
+ }
63684
+ : undefined, className: 'suggestion-item--bgcolor'
63685
+ + (selectedItem ? ' suggestion-item--disabled' : '') }, _this.props.optionTemplate
63686
+ ? _this.props.optionTemplate(option.value)
63687
+ : _this.props.getLabel(option.value)),
63688
+ option.children
63689
+ && React.createElement("span", { className: "suggestion-item__icon" },
63690
+ React.createElement(Icon_1.Icon, { name: "chevron-right-thin" })))));
63691
+ }))
63692
+ : null
63693
+ : React.createElement("ul", { className: "suggestion-list suggestion-list--multi-select", ref: this.ref }, this.filteredItem(this.props.singleLevelSearch
63570
63694
  ? this.state.options : this.state.filterArr))))));
63571
63695
  };
63572
63696
  return TreeSelect;
63573
63697
  }(React.Component));
63574
63698
  exports.TreeSelect = TreeSelect;
63699
+ var getButtonList = function (menuRef) {
63700
+ var _a;
63701
+ var list = Array.from((_a = menuRef === null || menuRef === void 0 ? void 0 : menuRef.querySelectorAll(':scope > li')) !== null && _a !== void 0 ? _a : []);
63702
+ var buttons = [];
63703
+ if (list != null) {
63704
+ __spreadArray([], list, true).filter(function (item) {
63705
+ if (item.querySelectorAll('.suggestion-item--btn').length > 0) {
63706
+ buttons.push(item.querySelector('.suggestion-item--btn'));
63707
+ }
63708
+ });
63709
+ }
63710
+ return buttons;
63711
+ };
63712
+ var keyboardNavigation = function (e, menuRef, ref) {
63713
+ var buttons = getButtonList(menuRef);
63714
+ var currentElement = document.activeElement;
63715
+ var currentIndex = Array.prototype.indexOf.call(buttons, currentElement);
63716
+ if (document.activeElement != null && buttons.includes(document.activeElement)) {
63717
+ if ((e === null || e === void 0 ? void 0 : e.key) === 'ArrowDown') {
63718
+ nextElement(buttons, currentIndex, e);
63719
+ }
63720
+ else if ((e === null || e === void 0 ? void 0 : e.key) === 'ArrowUp') {
63721
+ prevElement(buttons, currentIndex, e, ref);
63722
+ }
63723
+ }
63724
+ };
63725
+ var nextElement = function (buttons, currentIndex, e) {
63726
+ e.preventDefault();
63727
+ e.stopPropagation();
63728
+ if (buttons[currentIndex + 1]) {
63729
+ buttons[currentIndex + 1].focus();
63730
+ }
63731
+ else {
63732
+ buttons[0].focus();
63733
+ }
63734
+ };
63735
+ var prevElement = function (buttons, currentIndex, e, ref) {
63736
+ e.preventDefault();
63737
+ e.stopPropagation();
63738
+ if (buttons[currentIndex - 1]) {
63739
+ buttons[currentIndex - 1].focus();
63740
+ }
63741
+ else if (currentIndex === 0) {
63742
+ if (ref) {
63743
+ ref();
63744
+ }
63745
+ }
63746
+ else {
63747
+ buttons[buttons.length - 1].focus();
63748
+ }
63749
+ };
63575
63750
 
63576
63751
 
63577
63752
  /***/ }),
@@ -114376,7 +114551,7 @@ var MultiSelect = /** @class */ (function (_super) {
114376
114551
  React.createElement(multiselect_1.MultiSelect, { panelClassName: classes, value: this.props.value, options: this.props.options, onChange: function (_a) {
114377
114552
  var value = _a.value;
114378
114553
  return _this.props.onChange(value);
114379
- }, display: "chip", zIndex: this.props.zIndex, filter: this.props.filter, filterBy: this.props.optionLabel, appendTo: document.body, placeholder: this.props.placeholder, optionLabel: this.props.optionLabel, emptyFilterMessage: this.props.emptyFilterMessage, filterPlaceholder: this.props.filterPlaceholder, itemTemplate: this.props.itemTemplate, selectedItemTemplate: this.props.selectedItemTemplate, maxSelectedLabels: (_a = this.props.maxSelectedLabels) !== null && _a !== void 0 ? _a : 4, selectedItemsLabel: this.props.selectedItemsLabel, ariaLabelledBy: this.htmlId + 'label', tabIndex: this.props.tabIndex ? this.props.tabIndex : '0', showClear: this.props.showClear, disabled: this.props.disabled, inputId: this.htmlId })));
114554
+ }, display: "chip", zIndex: this.props.zIndex, filter: this.props.filter, appendTo: document.body, placeholder: this.props.placeholder, optionLabel: function (option) { return _this.props.optionLabel(option); }, emptyFilterMessage: this.props.emptyFilterMessage, filterPlaceholder: this.props.filterPlaceholder, itemTemplate: this.props.itemTemplate, selectedItemTemplate: this.props.selectedItemTemplate, maxSelectedLabels: (_a = this.props.maxSelectedLabels) !== null && _a !== void 0 ? _a : 4, selectedItemsLabel: this.props.selectedItemsLabel, ariaLabelledBy: this.htmlId + 'label', tabIndex: this.props.tabIndex ? this.props.tabIndex : '0', showClear: this.props.showClear, disabled: this.props.disabled, inputId: this.htmlId })));
114380
114555
  };
114381
114556
  return MultiSelect;
114382
114557
  }(React.Component));
@@ -114939,21 +115114,25 @@ var MultiSelect = /*#__PURE__*/function (_Component) {
114939
115114
  }, {
114940
115115
  key: "filterOptions",
114941
115116
  value: function filterOptions(options) {
115117
+ var _this7 = this;
115118
+
114942
115119
  if (options) {
114943
115120
  var filterValue = this.state.filter.trim().toLocaleLowerCase(this.props.filterLocale);
114944
- var searchFields = this.props.filterBy ? this.props.filterBy.split(',') : [this.props.optionLabel || 'label'];
114945
- return _FilterUtils.default.filter(options, searchFields, filterValue, this.props.filterMatchMode, this.props.filterLocale);
115121
+ var filterOptions = options.filter(function (option) {
115122
+ return _this7.props.optionLabel(option).trim().toLowerCase().includes(filterValue);
115123
+ });
115124
+ return filterOptions;
114946
115125
  }
114947
115126
  }
114948
115127
  }, {
114949
115128
  key: "getOptionLabel",
114950
115129
  value: function getOptionLabel(option) {
114951
- return this.props.optionLabel ? _ObjectUtils.default.resolveFieldData(option, this.props.optionLabel) : option && option['label'] !== undefined ? option['label'] : option;
115130
+ return this.props.optionLabel != null ? this.props.optionLabel(option) : option && option['label'] !== undefined ? option['label'] : option;
114952
115131
  }
114953
115132
  }, {
114954
115133
  key: "getOptionValue",
114955
115134
  value: function getOptionValue(option) {
114956
- return this.props.optionValue ? _ObjectUtils.default.resolveFieldData(option, this.props.optionValue) : option && option['value'] !== undefined ? option['value'] : option;
115135
+ return this.props.optionValue != null ? this.props.optionValue(option) : option && option['value'] !== undefined ? option['value'] : option;
114957
115136
  }
114958
115137
  }, {
114959
115138
  key: "isEmpty",
@@ -115018,13 +115197,13 @@ var MultiSelect = /*#__PURE__*/function (_Component) {
115018
115197
  }, {
115019
115198
  key: "getLabelContent",
115020
115199
  value: function getLabelContent() {
115021
- var _this7 = this;
115200
+ var _this8 = this;
115022
115201
 
115023
115202
  if (this.props.selectedItemTemplate) {
115024
115203
  if (!this.isEmpty()) {
115025
115204
  if (this.props.value.length <= this.props.maxSelectedLabels) {
115026
115205
  return this.props.value.map(function (val, index) {
115027
- var item = _ObjectUtils.default.getJSXElement(_this7.props.selectedItemTemplate, val);
115206
+ var item = _ObjectUtils.default.getJSXElement(_this8.props.selectedItemTemplate, val);
115028
115207
 
115029
115208
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
115030
115209
  key: index
@@ -115039,17 +115218,17 @@ var MultiSelect = /*#__PURE__*/function (_Component) {
115039
115218
  } else {
115040
115219
  if (this.props.display === 'chip' && !this.isEmpty()) {
115041
115220
  return this.props.value.map(function (val) {
115042
- var label = _this7.getLabelByValue(val);
115221
+ var label = _this8.getLabelByValue(val);
115043
115222
 
115044
115223
  return /*#__PURE__*/_react.default.createElement("div", {
115045
115224
  className: "p-multiselect-token",
115046
115225
  key: label
115047
115226
  }, /*#__PURE__*/_react.default.createElement("span", {
115048
115227
  className: "p-multiselect-token-label"
115049
- }, label), !_this7.props.disabled && /*#__PURE__*/_react.default.createElement("span", {
115228
+ }, label), !_this8.props.disabled && /*#__PURE__*/_react.default.createElement("span", {
115050
115229
  className: "p-multiselect-token-icon pi pi-times-circle",
115051
115230
  onClick: function onClick(e) {
115052
- return _this7.removeChip(e, val);
115231
+ return _this8.removeChip(e, val);
115053
115232
  }
115054
115233
  }));
115055
115234
  });
@@ -115083,7 +115262,7 @@ var MultiSelect = /*#__PURE__*/function (_Component) {
115083
115262
  }, {
115084
115263
  key: "renderClearIcon",
115085
115264
  value: function renderClearIcon() {
115086
- var _this8 = this;
115265
+ var _this9 = this;
115087
115266
 
115088
115267
  var empty = this.isEmpty();
115089
115268
 
@@ -115091,7 +115270,7 @@ var MultiSelect = /*#__PURE__*/function (_Component) {
115091
115270
  return /*#__PURE__*/_react.default.createElement("i", {
115092
115271
  className: "p-multiselect-clear-icon pi pi-times",
115093
115272
  onClick: function onClick(e) {
115094
- return _this8.updateModel(e, null);
115273
+ return _this9.updateModel(e, null);
115095
115274
  }
115096
115275
  });
115097
115276
  }
@@ -115101,7 +115280,7 @@ var MultiSelect = /*#__PURE__*/function (_Component) {
115101
115280
  }, {
115102
115281
  key: "renderLabel",
115103
115282
  value: function renderLabel() {
115104
- var _this9 = this;
115283
+ var _this10 = this;
115105
115284
 
115106
115285
  var empty = this.isEmpty();
115107
115286
  var content = this.getLabelContent();
@@ -115112,7 +115291,7 @@ var MultiSelect = /*#__PURE__*/function (_Component) {
115112
115291
  });
115113
115292
  return /*#__PURE__*/_react.default.createElement("div", {
115114
115293
  ref: function ref(el) {
115115
- return _this9.label = el;
115294
+ return _this10.label = el;
115116
115295
  },
115117
115296
  className: "p-multiselect-label-container"
115118
115297
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -115122,19 +115301,19 @@ var MultiSelect = /*#__PURE__*/function (_Component) {
115122
115301
  }, {
115123
115302
  key: "renderHiddenSelect",
115124
115303
  value: function renderHiddenSelect() {
115125
- var _this10 = this;
115304
+ var _this11 = this;
115126
115305
 
115127
115306
  var selectedOptions = this.props.value ? this.props.value.map(function (option, index) {
115128
115307
  return /*#__PURE__*/_react.default.createElement("option", {
115129
- key: _this10.getOptionLabel(option) + '_' + index,
115130
- value: _this10.getOptionValue(option)
115308
+ key: _this11.getOptionLabel(option) + '_' + index,
115309
+ value: _this11.getOptionValue(option)
115131
115310
  });
115132
115311
  }) : null;
115133
115312
  return /*#__PURE__*/_react.default.createElement("div", {
115134
115313
  className: "p-hidden-accessible p-multiselect-hidden-select"
115135
115314
  }, /*#__PURE__*/_react.default.createElement("select", {
115136
115315
  ref: function ref(el) {
115137
- return _this10.nativeSelect = el;
115316
+ return _this11.nativeSelect = el;
115138
115317
  },
115139
115318
  required: this.props.required,
115140
115319
  name: this.props.name,
@@ -115146,7 +115325,7 @@ var MultiSelect = /*#__PURE__*/function (_Component) {
115146
115325
  }, {
115147
115326
  key: "render",
115148
115327
  value: function render() {
115149
- var _this11 = this;
115328
+ var _this12 = this;
115150
115329
 
115151
115330
  var className = (0, _ClassNames.classNames)('p-multiselect p-component p-inputwrapper', {
115152
115331
  'p-multiselect-chip': this.props.display === 'chip',
@@ -115168,17 +115347,17 @@ var MultiSelect = /*#__PURE__*/function (_Component) {
115168
115347
 
115169
115348
  if (items && items.length) {
115170
115349
  items = items.map(function (option, index) {
115171
- var optionLabel = _this11.getOptionLabel(option);
115350
+ var optionLabel = _this12.getOptionLabel(option);
115172
115351
 
115173
115352
  return /*#__PURE__*/_react.default.createElement(_MultiSelectItem.MultiSelectItem, {
115174
115353
  key: optionLabel + '_' + index,
115175
115354
  label: optionLabel,
115176
115355
  option: option,
115177
- template: _this11.props.itemTemplate,
115178
- selected: _this11.isSelected(option),
115179
- onClick: _this11.onOptionClick,
115180
- onKeyDown: _this11.onOptionKeyDown,
115181
- tabIndex: _this11.props.tabIndex
115356
+ template: _this12.props.itemTemplate,
115357
+ selected: _this12.isSelected(option),
115358
+ onClick: _this12.onOptionClick,
115359
+ onKeyDown: _this12.onOptionKeyDown,
115360
+ tabIndex: _this12.props.tabIndex
115182
115361
  });
115183
115362
  });
115184
115363
  } else if (hasFilter) {
@@ -115195,14 +115374,14 @@ var MultiSelect = /*#__PURE__*/function (_Component) {
115195
115374
  className: className,
115196
115375
  onClick: this.onClick,
115197
115376
  ref: function ref(el) {
115198
- return _this11.container = el;
115377
+ return _this12.container = el;
115199
115378
  },
115200
115379
  style: this.props.style
115201
115380
  }, hiddenSelect, /*#__PURE__*/_react.default.createElement("div", {
115202
115381
  className: "p-hidden-accessible"
115203
115382
  }, /*#__PURE__*/_react.default.createElement("input", {
115204
115383
  ref: function ref(el) {
115205
- return _this11.focusInput = el;
115384
+ return _this12.focusInput = el;
115206
115385
  },
115207
115386
  id: this.props.inputId,
115208
115387
  readOnly: true,
@@ -115234,7 +115413,7 @@ var MultiSelect = /*#__PURE__*/function (_Component) {
115234
115413
  onExited: this.onOverlayExited
115235
115414
  }, /*#__PURE__*/_react.default.createElement(_MultiSelectPanel.MultiSelectPanel, {
115236
115415
  ref: function ref(el) {
115237
- return _this11.panel = el;
115416
+ return _this12.panel = el;
115238
115417
  },
115239
115418
  header: header,
115240
115419
  appendTo: this.props.appendTo,
@@ -115297,8 +115476,8 @@ _defineProperty(MultiSelect, "propTypes", {
115297
115476
  name: _propTypes.default.string,
115298
115477
  value: _propTypes.default.any,
115299
115478
  options: _propTypes.default.array,
115300
- optionLabel: _propTypes.default.string,
115301
- optionValue: _propTypes.default.string,
115479
+ optionLabel: _propTypes.default.func,
115480
+ optionValue: _propTypes.default.func,
115302
115481
  display: _propTypes.default.string,
115303
115482
  style: _propTypes.default.object,
115304
115483
  className: _propTypes.default.string,