superdesk-ui-framework 3.0.6 → 3.0.8

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 (33) hide show
  1. package/app/styles/_sd-tag-input.scss +29 -10
  2. package/app-typescript/components/Lists/ContentList.tsx +28 -27
  3. package/app-typescript/components/Lists/TableList.tsx +140 -126
  4. package/app-typescript/components/MultiSelect.tsx +2 -3
  5. package/app-typescript/components/SingleAndDoubleClickFunction.tsx +21 -0
  6. package/app-typescript/components/TreeSelect.tsx +506 -243
  7. package/dist/examples.bundle.js +1468 -1186
  8. package/dist/playgrounds/react-playgrounds/EditorTest.tsx +18 -10
  9. package/dist/playgrounds/react-playgrounds/Multiedit.tsx +15 -13
  10. package/dist/playgrounds/react-playgrounds/RundownEditor.tsx +136 -125
  11. package/dist/react/Dropdowns.tsx +134 -85
  12. package/dist/react/MultiSelect.tsx +2 -2
  13. package/dist/react/TreeSelect.tsx +39 -27
  14. package/dist/superdesk-ui.bundle.css +26 -9
  15. package/dist/superdesk-ui.bundle.js +1015 -809
  16. package/dist/vendor.bundle.js +14 -14
  17. package/examples/pages/playgrounds/react-playgrounds/EditorTest.tsx +18 -10
  18. package/examples/pages/playgrounds/react-playgrounds/Multiedit.tsx +15 -13
  19. package/examples/pages/playgrounds/react-playgrounds/RundownEditor.tsx +136 -125
  20. package/examples/pages/react/Dropdowns.tsx +134 -85
  21. package/examples/pages/react/MultiSelect.tsx +2 -2
  22. package/examples/pages/react/TreeSelect.tsx +39 -27
  23. package/package.json +2 -2
  24. package/react/components/Lists/ContentList.d.ts +2 -5
  25. package/react/components/Lists/ContentList.js +20 -25
  26. package/react/components/Lists/TableList.d.ts +4 -7
  27. package/react/components/Lists/TableList.js +66 -60
  28. package/react/components/MultiSelect.d.ts +1 -1
  29. package/react/components/MultiSelect.js +1 -1
  30. package/react/components/SingleAndDoubleClickFunction.d.ts +6 -0
  31. package/react/components/SingleAndDoubleClickFunction.js +19 -0
  32. package/react/components/TreeSelect.d.ts +17 -9
  33. package/react/components/TreeSelect.js +249 -74
@@ -61,30 +61,51 @@ var TreeSelect = /** @class */ (function (_super) {
61
61
  function TreeSelect(props) {
62
62
  var _this = _super.call(this, props) || this;
63
63
  _this.htmlId = (0, react_id_generator_1.default)();
64
+ _this.inputFocus = function () {
65
+ var _a;
66
+ (_a = _this.inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
67
+ };
68
+ _this.listNavigation = function () {
69
+ var element = document.querySelector('.suggestion-item--btn');
70
+ element.focus();
71
+ };
72
+ _this.buttonFocus = function () {
73
+ var _a;
74
+ (_a = _this.categoryButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
75
+ };
64
76
  _this.componentDidMount = function () {
65
77
  _this.recursion(_this.state.options);
66
78
  document.addEventListener("mousedown", function (event) {
79
+ if (!(event.target instanceof HTMLInputElement)) {
80
+ return;
81
+ }
67
82
  if ((_this.dropdownRef.current && !_this.dropdownRef.current.contains(event.target))
68
83
  && (_this.openDropdownRef.current && !_this.openDropdownRef.current.contains(event.target))) {
69
84
  _this.setState({ openDropdown: false });
70
85
  }
71
86
  });
87
+ document.addEventListener("keydown", function (e) {
88
+ if (_this.state.openDropdown && _this.ref.current) {
89
+ keyboardNavigation(e, _this.ref.current, _this.categoryButtonRef.current ? _this.buttonFocus : _this.inputFocus);
90
+ if (e.key === 'Backspace') {
91
+ _this.backButton();
92
+ var buttonTarget = _this.state.buttonTarget;
93
+ var className = buttonTarget.pop();
94
+ if (className != null) {
95
+ var element = document.getElementsByClassName(className)[0];
96
+ element.focus();
97
+ }
98
+ }
99
+ }
100
+ });
72
101
  };
73
- _this.backButton = function () {
74
- if (_this.state.activeTree.length > 0) {
102
+ _this.backButtonValue = function () {
103
+ var item = _this.state.buttonTree.pop();
104
+ if (item != null) {
75
105
  _this.setState({
76
- options: _this.state.activeTree.pop(),
106
+ buttonValue: item,
77
107
  });
78
- return;
79
108
  }
80
- else {
81
- return false;
82
- }
83
- };
84
- _this.backButtonValue = function () {
85
- _this.setState({
86
- buttonValue: _this.state.buttonTree.pop(),
87
- });
88
109
  };
89
110
  _this.debounceFn = (0, debounce_1.default)(_this.handleDebounce, 500);
90
111
  _this.state = {
@@ -95,11 +116,11 @@ var TreeSelect = /** @class */ (function (_super) {
95
116
  filterArr: [],
96
117
  searchFieldValue: '',
97
118
  buttonTree: [],
98
- buttonValue: [],
119
+ buttonValue: null,
99
120
  buttonMouseEvent: false,
100
121
  openDropdown: false,
101
122
  loading: false,
102
- // provera: false
123
+ buttonTarget: [],
103
124
  };
104
125
  _this.removeClick = _this.removeClick.bind(_this);
105
126
  _this.handleMultiLevel = _this.handleMultiLevel.bind(_this);
@@ -108,14 +129,19 @@ var TreeSelect = /** @class */ (function (_super) {
108
129
  _this.backButtonValue = _this.backButtonValue.bind(_this);
109
130
  _this.handleTree = _this.handleTree.bind(_this);
110
131
  _this.filteredItem = _this.filteredItem.bind(_this);
111
- _this.banchButton = _this.banchButton.bind(_this);
132
+ _this.branchButton = _this.branchButton.bind(_this);
112
133
  _this.handleDebounce = _this.handleDebounce.bind(_this);
113
134
  _this.toggleMenu = _this.toggleMenu.bind(_this);
114
135
  _this.dropdownRef = React.createRef();
136
+ _this.ref = React.createRef();
137
+ _this.inputRef = React.createRef();
138
+ _this.categoryButtonRef = React.createRef();
115
139
  _this.openDropdownRef = React.createRef();
140
+ _this.popperInstance = null;
116
141
  return _this;
117
142
  }
118
143
  TreeSelect.prototype.componentDidUpdate = function (prevProps, prevState) {
144
+ var _a;
119
145
  if (!(0, lodash_1.isEqual)(prevState.value, this.state.value)) {
120
146
  this.props.onChange(this.state.value);
121
147
  }
@@ -129,11 +155,13 @@ var TreeSelect = /** @class */ (function (_super) {
129
155
  if ((prevState.activeTree !== this.state.activeTree)
130
156
  || (prevState.filterArr !== this.state.filterArr)
131
157
  || (prevState.options !== this.state.options)) {
132
- this.popperInstance.update();
158
+ (_a = this.popperInstance) === null || _a === void 0 ? void 0 : _a.update();
133
159
  }
134
160
  }
135
161
  };
136
162
  TreeSelect.prototype.toggleMenu = function () {
163
+ var _this = this;
164
+ var _a, _b;
137
165
  if (this.state.openDropdown) {
138
166
  if (this.openDropdownRef.current && this.dropdownRef.current) {
139
167
  this.popperInstance = (0, core_1.createPopper)(this.openDropdownRef.current, this.dropdownRef.current, {
@@ -148,6 +176,30 @@ var TreeSelect = /** @class */ (function (_super) {
148
176
  ],
149
177
  });
150
178
  }
179
+ (_a = this.inputRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('keydown', function (e) {
180
+ if (e.key === 'ArrowDown') {
181
+ e.preventDefault();
182
+ e.stopPropagation();
183
+ if (_this.categoryButtonRef.current) {
184
+ _this.buttonFocus();
185
+ }
186
+ else {
187
+ setTimeout(function () {
188
+ _this.listNavigation();
189
+ });
190
+ }
191
+ }
192
+ });
193
+ if (this.inputRef.current) {
194
+ this.inputFocus();
195
+ }
196
+ else {
197
+ var element = document.querySelector('.suggestion-item--btn');
198
+ element.focus();
199
+ }
200
+ }
201
+ else {
202
+ (_b = this.openDropdownRef.current) === null || _b === void 0 ? void 0 : _b.focus();
151
203
  }
152
204
  };
153
205
  TreeSelect.prototype.removeClick = function (i) {
@@ -167,8 +219,12 @@ var TreeSelect = /** @class */ (function (_super) {
167
219
  }
168
220
  };
169
221
  TreeSelect.prototype.handleButton = function (item) {
222
+ var buttonTreeNext = this.state.buttonTree;
223
+ if (this.state.buttonValue != null) {
224
+ buttonTreeNext = buttonTreeNext.concat(this.state.buttonValue);
225
+ }
170
226
  this.setState({
171
- buttonTree: __spreadArray(__spreadArray([], this.state.buttonTree, true), [this.state.buttonValue], false),
227
+ buttonTree: buttonTreeNext,
172
228
  buttonValue: item,
173
229
  });
174
230
  };
@@ -183,10 +239,15 @@ var TreeSelect = /** @class */ (function (_super) {
183
239
  }
184
240
  if (!event.ctrlKey) {
185
241
  if (this.props.getOptions) {
186
- this.setState({ options: this.state.firstBranchOptions, activeTree: [], openDropdown: false });
242
+ this.setState({
243
+ options: this.state.firstBranchOptions,
244
+ activeTree: [],
245
+ buttonTarget: [],
246
+ openDropdown: false,
247
+ });
187
248
  }
188
249
  else {
189
- this.setState({ activeTree: [], openDropdown: false });
250
+ this.setState({ activeTree: [], buttonTarget: [], openDropdown: false });
190
251
  }
191
252
  }
192
253
  this.setState({ buttonMouseEvent: false });
@@ -199,7 +260,12 @@ var TreeSelect = /** @class */ (function (_super) {
199
260
  this.setState({ value: [item.value] });
200
261
  }
201
262
  if (!event.ctrlKey) {
202
- this.setState({ options: this.state.firstBranchOptions, activeTree: [], openDropdown: false });
263
+ this.setState({
264
+ options: this.state.firstBranchOptions,
265
+ activeTree: [],
266
+ buttonTarget: [],
267
+ openDropdown: false,
268
+ });
203
269
  }
204
270
  this.setState({ buttonMouseEvent: false });
205
271
  }
@@ -215,7 +281,12 @@ var TreeSelect = /** @class */ (function (_super) {
215
281
  this.setState({ value: __spreadArray(__spreadArray([], this.state.value, true), [item.value], false) });
216
282
  }
217
283
  if (!event.ctrlKey) {
218
- this.setState({ options: this.state.firstBranchOptions, activeTree: [], openDropdown: false });
284
+ this.setState({
285
+ options: this.state.firstBranchOptions,
286
+ activeTree: [],
287
+ buttonTarget: [],
288
+ openDropdown: false,
289
+ });
219
290
  }
220
291
  this.setState({ buttonMouseEvent: false });
221
292
  }
@@ -229,7 +300,12 @@ var TreeSelect = /** @class */ (function (_super) {
229
300
  this.setState({ value: [item.value] });
230
301
  }
231
302
  if (!event.ctrlKey) {
232
- this.setState({ options: this.state.firstBranchOptions, activeTree: [], openDropdown: false });
303
+ this.setState({
304
+ options: this.state.firstBranchOptions,
305
+ activeTree: [],
306
+ buttonTarget: [],
307
+ openDropdown: false,
308
+ });
233
309
  }
234
310
  this.setState({ buttonMouseEvent: false });
235
311
  }
@@ -253,6 +329,7 @@ var TreeSelect = /** @class */ (function (_super) {
253
329
  options: this.state.firstBranchOptions,
254
330
  openDropdown: false,
255
331
  activeTree: [],
332
+ buttonTarget: [],
256
333
  });
257
334
  }
258
335
  else {
@@ -269,6 +346,7 @@ var TreeSelect = /** @class */ (function (_super) {
269
346
  options: this.state.firstBranchOptions,
270
347
  openDropdown: false,
271
348
  activeTree: [],
349
+ buttonTarget: [],
272
350
  });
273
351
  }
274
352
  }
@@ -280,6 +358,16 @@ var TreeSelect = /** @class */ (function (_super) {
280
358
  this.setState({ openDropdown: false });
281
359
  }
282
360
  }
361
+ var element = document.querySelector('.suggestion-item--btn');
362
+ element.focus();
363
+ };
364
+ TreeSelect.prototype.backButton = function () {
365
+ var items = this.state.activeTree.pop();
366
+ if (items != null) {
367
+ this.setState({
368
+ options: items,
369
+ });
370
+ }
283
371
  };
284
372
  TreeSelect.prototype.recursion = function (arr) {
285
373
  var _this = this;
@@ -315,7 +403,7 @@ var TreeSelect = /** @class */ (function (_super) {
315
403
  var selectedItem = _this.state.value.some(function (obj) {
316
404
  return _this.props.getId(obj) === _this.props.getId(option.value);
317
405
  });
318
- return React.createElement("li", { key: i, className: "suggestion-item suggestion-item--multi-select", onClick: function (event) {
406
+ return (React.createElement("li", { key: i, className: "suggestion-item suggestion-item--multi-select", onClick: function (event) {
319
407
  _this.setState({
320
408
  searchFieldValue: '',
321
409
  }),
@@ -323,17 +411,19 @@ var TreeSelect = /** @class */ (function (_super) {
323
411
  event.stopPropagation();
324
412
  _this.handleTree(event, option);
325
413
  } },
326
- _this.props.getBorderColor
327
- && React.createElement("div", { className: "item-border", style: { backgroundColor: _this.props.getBorderColor(option.value) } }),
328
- React.createElement("span", { style: _this.props.getBackgroundColor
329
- ? { backgroundColor: _this.props.getBackgroundColor(option.value),
330
- color: (0, Label_1.getTextColor)(_this.props.getBackgroundColor(option.value)) }
331
- : undefined, className: 'suggestion-item--bgcolor'
332
- + (selectedItem ? ' suggestion-item--disabled' : '') }, _this.props.optionTemplate
333
- ? _this.props.optionTemplate(option.value)
334
- : _this.props.getLabel(option.value)),
335
- option.children && React.createElement("span", { className: "suggestion-item__icon" },
336
- React.createElement(Icon_1.Icon, { name: "chevron-right-thin" })));
414
+ React.createElement("button", { className: "suggestion-item--btn" },
415
+ _this.props.getBorderColor
416
+ && React.createElement("div", { className: "item-border", style: { backgroundColor: _this.props.getBorderColor(option.value) } }),
417
+ React.createElement("span", { style: _this.props.getBackgroundColor
418
+ ? { backgroundColor: _this.props.getBackgroundColor(option.value),
419
+ color: (0, Label_1.getTextColor)(_this.props.getBackgroundColor(option.value)) }
420
+ : undefined, className: 'suggestion-item--bgcolor'
421
+ + (selectedItem ? ' suggestion-item--disabled' : '') }, _this.props.optionTemplate
422
+ ? _this.props.optionTemplate(option.value)
423
+ : _this.props.getLabel(option.value)),
424
+ option.children
425
+ && React.createElement("span", { className: "suggestion-item__icon" },
426
+ React.createElement(Icon_1.Icon, { name: "chevron-right-thin" })))));
337
427
  });
338
428
  }
339
429
  }
@@ -344,26 +434,47 @@ var TreeSelect = /** @class */ (function (_super) {
344
434
  });
345
435
  return (React.createElement("li", { key: i, className: "suggestion-item suggestion-item--multi-select", onClick: function (event) {
346
436
  _this.handleValue(event, item);
347
- } }, _this.props.optionTemplate
348
- ? _this.props.optionTemplate(item.value)
349
- : React.createElement("span", { className: selectedItem
350
- ? 'suggestion-item--disabled' : undefined }, _this.props.getLabel(item.value))));
437
+ } },
438
+ React.createElement("button", { className: "suggestion-item--btn" }, _this.props.optionTemplate
439
+ ? _this.props.optionTemplate(item.value)
440
+ : React.createElement("span", { className: selectedItem
441
+ ? 'suggestion-item--disabled' : undefined }, _this.props.getLabel(item.value)))));
351
442
  });
352
443
  }
353
444
  else {
354
445
  return;
355
446
  }
356
447
  };
357
- TreeSelect.prototype.banchButton = function () {
448
+ TreeSelect.prototype.branchButton = function (buttonValue) {
358
449
  var _this = this;
450
+ setTimeout(function () {
451
+ var _a;
452
+ (_a = _this.categoryButtonRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('keydown', function (e) {
453
+ var _a;
454
+ if (e.key === 'ArrowDown') {
455
+ e.preventDefault();
456
+ e.stopPropagation();
457
+ setTimeout(function () {
458
+ var element = document.querySelector('.suggestion-item--btn');
459
+ element.focus();
460
+ });
461
+ }
462
+ if (e.key === 'ArrowUp') {
463
+ e.preventDefault();
464
+ e.stopPropagation();
465
+ (_a = _this.inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
466
+ }
467
+ });
468
+ });
359
469
  var selectedButton = this.state.value.some(function (obj) {
360
- return _this.props.getId(obj) === _this.props.getId(_this.state.buttonValue.value);
470
+ return _this.props.getId(obj) === _this.props.getId(buttonValue.value);
361
471
  });
362
472
  if (!selectedButton) {
363
- 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");
473
+ 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");
364
474
  }
365
475
  else {
366
- return React.createElement("button", { className: 'autocomplete__button' + (this.props.selectBranchWithChildren ? ' autocomplete__button--multi-select' : '') + ' autocomplete__button--disabled', value: this.state.buttonValue }, "Category selected");
476
+ return React.createElement("button", { className: 'autocomplete__button'
477
+ + (this.props.selectBranchWithChildren ? ' autocomplete__button--multi-select' : '') + ' autocomplete__button--disabled' }, "Category selected");
367
478
  }
368
479
  };
369
480
  TreeSelect.prototype.handleDebounce = function () {
@@ -373,15 +484,11 @@ var TreeSelect = /** @class */ (function (_super) {
373
484
  if (this.state.searchFieldValue) {
374
485
  this.setState({
375
486
  loading: true,
376
- // provera: false
377
487
  });
378
488
  this.ICancelFn = this.props.searchOptions(this.state.searchFieldValue, function (items) {
379
- // if (items.length === 0) {
380
- // this.setState({provera: true, loading: false})
381
- // } else {
489
+ var _a;
382
490
  _this.setState({ options: items, loading: false });
383
- _this.popperInstance.update();
384
- // }
491
+ (_a = _this.popperInstance) === null || _a === void 0 ? void 0 : _a.update();
385
492
  });
386
493
  }
387
494
  }
@@ -419,13 +526,15 @@ var TreeSelect = /** @class */ (function (_super) {
419
526
  this.state.value.length > 0
420
527
  ? this.props.readOnly
421
528
  || React.createElement("button", { className: "tags-input__remove-value", style: { position: 'relative', bottom: '2px' }, onClick: function () { return _this.setState({ value: [] }); } },
422
- React.createElement(Icon_1.Icon, { name: 'remove-sign' })) : null)
529
+ React.createElement(Icon_1.Icon, { name: 'remove-sign' }))
530
+ : null)
423
531
  : React.createElement("div", { className: "tags-input__tags" },
424
532
  this.props.readOnly
425
533
  || React.createElement("button", { className: "tags-input__overlay-button", ref: this.openDropdownRef, onClick: function () { return _this.setState({ openDropdown: !_this.state.openDropdown }); } }),
426
- this.state.value.length < 1 && React.createElement("span", { className: 'tags-input__single-item'
427
- + (this.props.readOnly ? ' tags-input__tag-item--readonly' : '') },
428
- React.createElement("span", { className: "tags-input__placeholder" }, this.props.placeholder)),
534
+ this.state.value.length < 1
535
+ && React.createElement("span", { className: 'tags-input__single-item'
536
+ + (this.props.readOnly ? ' tags-input__tag-item--readonly' : '') },
537
+ React.createElement("span", { className: "tags-input__placeholder" }, this.props.placeholder)),
429
538
  this.state.value.map(function (item, i) {
430
539
  var Wrapper = function (_a) {
431
540
  var backgroundColor = _a.backgroundColor, borderColor = _a.borderColor, children = _a.children;
@@ -455,27 +564,25 @@ var TreeSelect = /** @class */ (function (_super) {
455
564
  } },
456
565
  React.createElement(Icon_1.Icon, { name: "search", className: "search" })),
457
566
  React.createElement("div", { className: 'autocomplete__filter' },
458
- 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) {
567
+ React.createElement("input", { placeholder: this.props.searchPlaceholder, type: "text", className: "autocomplete__input", ref: this.inputRef, value: this.state.searchFieldValue, onChange: function (event) {
568
+ var _a, _b;
459
569
  if (_this.props.kind === 'synchronous') {
460
570
  _this.setState({ searchFieldValue: event.target.value });
461
- _this.popperInstance.update();
571
+ (_a = _this.popperInstance) === null || _a === void 0 ? void 0 : _a.update();
462
572
  }
463
573
  else if (_this.props.kind === 'asynchronous') {
464
574
  if (_this.ICancelFn) {
465
575
  _this.ICancelFn();
466
576
  }
467
577
  _this.setState({ searchFieldValue: event.target.value, options: [] });
468
- _this.popperInstance.update();
578
+ (_b = _this.popperInstance) === null || _b === void 0 ? void 0 : _b.update();
469
579
  _this.debounceFn();
470
580
  }
471
581
  else {
472
582
  return;
473
583
  }
474
- // if(!this.state.searchFieldValue) {
475
- // this.setState({provera: false});
476
- // }
477
584
  } }))),
478
- this.state.activeTree.length > 0
585
+ (this.state.activeTree.length > 0 && this.state.buttonValue != null)
479
586
  && React.createElement("div", { className: 'autocomplete__category-header' },
480
587
  React.createElement("div", { className: "autocomplete__icon", onClick: function () {
481
588
  _this.backButtonValue();
@@ -483,16 +590,17 @@ var TreeSelect = /** @class */ (function (_super) {
483
590
  } },
484
591
  React.createElement(Icon_1.Icon, { name: "arrow-left", className: "arrow-left" })),
485
592
  React.createElement("div", { className: 'autocomplete__filter' },
486
- React.createElement("button", { className: 'autocomplete__category-title', value: this.state.buttonValue }, this.props.optionTemplate
593
+ React.createElement("button", { className: 'autocomplete__category-title' }, this.props.optionTemplate
487
594
  ? this.props.optionTemplate(this.state.buttonValue.value)
488
595
  : this.props.getLabel(this.state.buttonValue.value)),
489
- this.props.selectBranchWithChildren && this.banchButton())),
596
+ this.props.selectBranchWithChildren
597
+ && this.branchButton(this.state.buttonValue))),
490
598
  this.state.loading
491
599
  ? React.createElement("ul", { className: "suggestion-list--loader" },
492
600
  React.createElement(Loader_1.Loader, { overlay: true }))
493
601
  : this.state.searchFieldValue === ''
494
602
  ? this.props.getOptions
495
- ? React.createElement("ul", { className: "suggestion-list suggestion-list--multi-select" }, this.state.options
603
+ ? React.createElement("ul", { className: "suggestion-list suggestion-list--multi-select", ref: this.ref }, this.state.options
496
604
  .map(function (option, i) {
497
605
  var selectedItem = _this.state.value.some(function (obj) {
498
606
  return _this.props.getId(obj) === _this.props.getLabel(option.value);
@@ -502,20 +610,87 @@ var TreeSelect = /** @class */ (function (_super) {
502
610
  event.stopPropagation();
503
611
  _this.handleTree(event, option);
504
612
  } },
505
- (_this.props.getBorderColor && !_this.props.allowMultiple) && React.createElement("div", { className: "item-border", style: { backgroundColor: _this.props.getBorderColor(option.value) } }),
506
- React.createElement("span", { style: (_this.props.getBackgroundColor && option.value)
507
- ? { backgroundColor: _this.props.getBackgroundColor(option.value),
508
- color: (0, Label_1.getTextColor)(_this.props.getBackgroundColor(option.value)) }
509
- : undefined, className: 'suggestion-item--bgcolor'
510
- + (selectedItem ? ' suggestion-item--disabled' : '') }, _this.props.optionTemplate
511
- ? _this.props.optionTemplate(option.value)
512
- : _this.props.getLabel(option.value)),
513
- option.children && React.createElement("span", { className: "suggestion-item__icon" },
514
- React.createElement(Icon_1.Icon, { name: "chevron-right-thin" }))));
515
- })) : null
516
- : React.createElement("ul", { className: "suggestion-list suggestion-list--multi-select" }, this.filteredItem(this.props.singleLevelSearch
613
+ React.createElement("button", { className: "suggestion-item--btn ".concat(_this.props.getId(option.value)), onKeyDown: function (event) {
614
+ if (event.key === 'Enter' && option.children) {
615
+ _this.setState({
616
+ buttonTarget: __spreadArray(__spreadArray([], _this.state.buttonTarget, true), [
617
+ _this.props.getId(option.value),
618
+ ], false),
619
+ });
620
+ }
621
+ } },
622
+ (_this.props.getBorderColor && !_this.props.allowMultiple)
623
+ && React.createElement("div", { className: "item-border", style: {
624
+ backgroundColor: _this.props.getBorderColor(option.value),
625
+ } }),
626
+ React.createElement("span", { style: (_this.props.getBackgroundColor && option.value)
627
+ ? {
628
+ backgroundColor: _this.props.getBackgroundColor(option.value),
629
+ color: (0, Label_1.getTextColor)(_this.props.getBackgroundColor(option.value)),
630
+ }
631
+ : undefined, className: 'suggestion-item--bgcolor'
632
+ + (selectedItem ? ' suggestion-item--disabled' : '') }, _this.props.optionTemplate
633
+ ? _this.props.optionTemplate(option.value)
634
+ : _this.props.getLabel(option.value)),
635
+ option.children
636
+ && React.createElement("span", { className: "suggestion-item__icon" },
637
+ React.createElement(Icon_1.Icon, { name: "chevron-right-thin" })))));
638
+ }))
639
+ : null
640
+ : React.createElement("ul", { className: "suggestion-list suggestion-list--multi-select", ref: this.ref }, this.filteredItem(this.props.singleLevelSearch
517
641
  ? this.state.options : this.state.filterArr))))));
518
642
  };
519
643
  return TreeSelect;
520
644
  }(React.Component));
521
645
  exports.TreeSelect = TreeSelect;
646
+ var getButtonList = function (menuRef) {
647
+ var _a;
648
+ var list = Array.from((_a = menuRef === null || menuRef === void 0 ? void 0 : menuRef.querySelectorAll(':scope > li')) !== null && _a !== void 0 ? _a : []);
649
+ var buttons = [];
650
+ if (list != null) {
651
+ __spreadArray([], list, true).filter(function (item) {
652
+ if (item.querySelectorAll('.suggestion-item--btn').length > 0) {
653
+ buttons.push(item.querySelector('.suggestion-item--btn'));
654
+ }
655
+ });
656
+ }
657
+ return buttons;
658
+ };
659
+ var keyboardNavigation = function (e, menuRef, ref) {
660
+ var buttons = getButtonList(menuRef);
661
+ var currentElement = document.activeElement;
662
+ var currentIndex = Array.prototype.indexOf.call(buttons, currentElement);
663
+ if (document.activeElement != null && buttons.includes(document.activeElement)) {
664
+ if ((e === null || e === void 0 ? void 0 : e.key) === 'ArrowDown') {
665
+ nextElement(buttons, currentIndex, e);
666
+ }
667
+ else if ((e === null || e === void 0 ? void 0 : e.key) === 'ArrowUp') {
668
+ prevElement(buttons, currentIndex, e, ref);
669
+ }
670
+ }
671
+ };
672
+ var nextElement = function (buttons, currentIndex, e) {
673
+ e.preventDefault();
674
+ e.stopPropagation();
675
+ if (buttons[currentIndex + 1]) {
676
+ buttons[currentIndex + 1].focus();
677
+ }
678
+ else {
679
+ buttons[0].focus();
680
+ }
681
+ };
682
+ var prevElement = function (buttons, currentIndex, e, ref) {
683
+ e.preventDefault();
684
+ e.stopPropagation();
685
+ if (buttons[currentIndex - 1]) {
686
+ buttons[currentIndex - 1].focus();
687
+ }
688
+ else if (currentIndex === 0) {
689
+ if (ref) {
690
+ ref();
691
+ }
692
+ }
693
+ else {
694
+ buttons[buttons.length - 1].focus();
695
+ }
696
+ };