@progress/kendo-react-dropdowns 5.13.0-dev.202304200917 → 5.13.0-dev.202304201241

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.
@@ -35,7 +35,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
35
35
  };
36
36
  import * as React from 'react';
37
37
  import * as PropTypes from 'prop-types';
38
- import { classNames, Keys, guid, createPropsContext, kendoThemeMaps, withPropsContext, IconWrap } from '@progress/kendo-react-common';
38
+ import { classNames, Keys, guid, createPropsContext, kendoThemeMaps, withPropsContext, IconWrap, canUseDOM } from '@progress/kendo-react-common';
39
39
  import { plusIcon } from '@progress/kendo-svg-icons';
40
40
  import { FloatingLabel } from '@progress/kendo-react-labels';
41
41
  import ListContainer from '../common/ListContainer';
@@ -49,6 +49,12 @@ import { itemIndexStartsWith, getItemValue, areSame, removeDataItems, isPresent,
49
49
  import { validatePackage } from '@progress/kendo-react-common';
50
50
  import { packageMetadata } from '../package-metadata';
51
51
  import ClearButton from '../common/ClearButton';
52
+ import { AdaptiveMode } from '../common/AdaptiveMode';
53
+ import { ActionSheetContent } from '@progress/kendo-react-layout';
54
+ import { MOBILE_MEDIUM_DEVISE } from '../common/constants';
55
+ import { provideLocalizationService } from '@progress/kendo-react-intl';
56
+ import { adaptiveModeFooterApply, adaptiveModeFooterCancel, messages } from '../messages';
57
+ import ListFilter from '../common/ListFilter';
52
58
  var sizeMap = kendoThemeMaps.sizeMap, roundedMap = kendoThemeMaps.roundedMap;
53
59
  var VALIDATION_MESSAGE = 'Please enter a valid value!';
54
60
  var preventDefault = function (event) { return event.preventDefault(); };
@@ -64,11 +70,10 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
64
70
  __extends(MultiSelectWithoutContext, _super);
65
71
  function MultiSelectWithoutContext(props) {
66
72
  var _this = _super.call(this, props) || this;
67
- /**
68
- * @hidden
69
- */
73
+ /** @hidden */
70
74
  _this.state = {
71
- activedescendant: ActiveDescendant.PopupList
75
+ activedescendant: ActiveDescendant.PopupList,
76
+ currentTreeValue: []
72
77
  };
73
78
  _this._element = null;
74
79
  _this._valueItemsDuringOnChange = null;
@@ -76,20 +81,18 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
76
81
  _this.base = new DropDownBase(_this);
77
82
  _this._tags = [];
78
83
  _this._input = null;
84
+ _this._adaptiveInput = null;
79
85
  _this._skipFocusEvent = false;
80
86
  _this.itemHeight = 0;
81
87
  _this.scrollToFocused = false;
82
- /**
83
- * @hidden
84
- */
88
+ _this.localization = null;
89
+ /** @hidden */
85
90
  _this.focus = function () {
86
91
  if (_this._input) {
87
92
  _this._input.focus();
88
93
  }
89
94
  };
90
- /**
91
- * @hidden
92
- */
95
+ /** @hidden */
93
96
  _this.handleItemSelect = function (index, state) {
94
97
  var _a = _this.props, _b = _a.data, data = _b === void 0 ? [] : _b, dataItemKey = _a.dataItemKey, virtual = _a.virtual;
95
98
  var skip = virtual ? virtual.skip : 0;
@@ -116,14 +119,11 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
116
119
  _this.triggerOnChange(newItems, state);
117
120
  _this.base.triggerPageChangeCornerItems(dataItem, state);
118
121
  };
119
- /**
120
- * @hidden
121
- */
122
+ /** @hidden */
122
123
  _this.onTagDelete = function (itemsToRemove, event) {
123
- var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
124
124
  var state = _this.base.initState();
125
125
  state.syntheticEvent = event;
126
- if (opened) {
126
+ if (_this.opened) {
127
127
  _this.base.togglePopup(state);
128
128
  }
129
129
  if (!_this.state.focused) {
@@ -135,9 +135,7 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
135
135
  _this.triggerOnChange(selected, state);
136
136
  _this.applyState(state);
137
137
  };
138
- /**
139
- * @hidden
140
- */
138
+ /** @hidden */
141
139
  _this.itemFocus = function (index, state) {
142
140
  var _a = _this.props, _b = _a.data, data = _b === void 0 ? [] : _b, allowCustom = _a.allowCustom, virtual = _a.virtual;
143
141
  var skip = virtual ? virtual.skip : 0;
@@ -171,20 +169,19 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
171
169
  _this.onChangeHandler = function (event) {
172
170
  var state = _this.base.initState();
173
171
  var value = event.currentTarget.value;
174
- var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
175
172
  state.syntheticEvent = event;
176
173
  if (_this.props.filter === undefined) {
177
174
  state.data.text = value;
178
175
  }
179
176
  state.data.focusedIndex = undefined;
180
- if (!opened) {
177
+ if (!_this.opened) {
181
178
  _this.base.togglePopup(state);
179
+ _this.setState({ currentTreeValue: _this.value });
182
180
  }
183
181
  _this.base.filterChanged(value, state);
184
182
  _this.applyState(state);
185
183
  };
186
184
  _this.clearButtonClick = function (event) {
187
- var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
188
185
  var state = _this.base.initState();
189
186
  state.syntheticEvent = event;
190
187
  event.stopPropagation();
@@ -194,7 +191,7 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
194
191
  if (_this.state.focusedIndex !== undefined) {
195
192
  state.data.focusedIndex = undefined;
196
193
  }
197
- if (opened) {
194
+ if (_this.opened) {
198
195
  _this.base.togglePopup(state);
199
196
  }
200
197
  var text = _this.props.filter !== undefined ? _this.props.filter : _this.state.text;
@@ -209,7 +206,6 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
209
206
  _this.onInputKeyDown = function (event) {
210
207
  var keyCode = event.keyCode;
211
208
  var text = _this.props.filter !== undefined ? _this.props.filter : _this.state.text;
212
- var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
213
209
  var focusedItem = _this.getFocusedState().focusedItem;
214
210
  var state = _this.base.initState();
215
211
  state.syntheticEvent = event;
@@ -224,7 +220,7 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
224
220
  _this.base.togglePopup(state);
225
221
  _this.applyState(state);
226
222
  };
227
- if (opened) {
223
+ if (_this.opened) {
228
224
  if (event.altKey && keyCode === Keys.up) {
229
225
  togglePopup();
230
226
  }
@@ -249,29 +245,10 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
249
245
  togglePopup();
250
246
  }
251
247
  };
252
- _this.renderListContainer = function () {
248
+ _this.listContainerContent = function () {
253
249
  var _a, _b;
254
- var base = _this.base;
255
- var _c = _this.props, header = _c.header, footer = _c.footer, allowCustom = _c.allowCustom, dir = _c.dir, _d = _c.data, data = _d === void 0 ? [] : _d, size = _c.size, groupStickyHeaderItemRender = _c.groupStickyHeaderItemRender, groupField = _c.groupField, list = _c.list;
256
- var popupSettings = _this.base.getPopupSettings();
257
- var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
250
+ var _c = _this.props, header = _c.header, footer = _c.footer, allowCustom = _c.allowCustom, size = _c.size, _d = _c.data, data = _d === void 0 ? [] : _d, groupStickyHeaderItemRender = _c.groupStickyHeaderItemRender, groupField = _c.groupField, list = _c.list;
258
251
  var text = _this.props.filter !== undefined ? _this.props.filter : _this.state.text;
259
- var popupWidth = popupSettings.width !== undefined ? popupSettings.width : base.popupWidth;
260
- var listContainerProps = {
261
- dir: dir !== undefined ? dir : base.dirCalculated,
262
- width: popupWidth,
263
- popupSettings: {
264
- popupClass: classNames(popupSettings.popupClass, 'k-list-container', 'k-multiselect-popup'),
265
- className: popupSettings.className,
266
- animate: popupSettings.animate,
267
- anchor: _this.element,
268
- show: opened,
269
- onOpen: _this.onPopupOpened,
270
- onClose: _this.onPopupClosed,
271
- appendTo: popupSettings.appendTo
272
- },
273
- itemsCount: [data.length, _this.value.length]
274
- };
275
252
  var focusedType = _this.getFocusedState().focusedType;
276
253
  var customItem = allowCustom && text && (React.createElement("div", { className: classNames('k-list', (_a = {},
277
254
  _a["k-list-".concat(sizeMap[size] || size)] = size,
@@ -283,26 +260,109 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
283
260
  if (group === undefined && groupField !== undefined) {
284
261
  group = getItemValue(data[0], groupField);
285
262
  }
286
- return (React.createElement(ListContainer, __assign({}, listContainerProps),
263
+ return (React.createElement(React.Fragment, null,
287
264
  header && React.createElement("div", { className: "k-list-header" }, header),
288
265
  customItem,
289
266
  React.createElement("div", { className: classNames('k-list', (_b = {},
290
- _b["k-list-".concat(sizeMap[size] || size)] = size,
267
+ _b["k-list-".concat(_this.mobileMode ? 'lg' : sizeMap[size] || size)] = size,
291
268
  _b['k-virtual-list'] = _this.base.vs.enabled,
292
269
  _b)) },
293
270
  !list && group && React.createElement(GroupStickyHeader, { group: group, groupMode: 'modern', render: groupStickyHeaderItemRender }),
294
271
  _this.renderList()),
295
272
  footer && React.createElement("div", { className: "k-list-footer" }, footer)));
296
273
  };
274
+ _this.renderListContainer = function () {
275
+ var base = _this.base;
276
+ var _a = _this.props, dir = _a.dir, _b = _a.data, data = _b === void 0 ? [] : _b;
277
+ var popupSettings = _this.base.getPopupSettings();
278
+ var popupWidth = popupSettings.width !== undefined ? popupSettings.width : base.popupWidth;
279
+ var listContainerProps = {
280
+ dir: dir !== undefined ? dir : base.dirCalculated,
281
+ width: popupWidth,
282
+ popupSettings: {
283
+ popupClass: classNames(popupSettings.popupClass, 'k-list-container', 'k-multiselect-popup'),
284
+ className: popupSettings.className,
285
+ animate: popupSettings.animate,
286
+ anchor: _this.element,
287
+ show: _this.opened,
288
+ onOpen: _this.onPopupOpened,
289
+ onClose: _this.onPopupClosed,
290
+ appendTo: popupSettings.appendTo
291
+ },
292
+ itemsCount: [data.length, _this.value.length]
293
+ };
294
+ return (React.createElement(ListContainer, __assign({}, listContainerProps), _this.listContainerContent()));
295
+ };
296
+ _this.renderAdaptiveListContainer = function () {
297
+ var _a = _this.props, adaptiveTitle = _a.adaptiveTitle, filterable = _a.filterable, filter = _a.filter;
298
+ var _b = _this.state.windowWidth, windowWidth = _b === void 0 ? 0 : _b;
299
+ var mobileText = filter !== undefined ? filter : _this.state.text;
300
+ _this.localization = provideLocalizationService(_this);
301
+ var actionSheetProps = {
302
+ adaptiveTitle: adaptiveTitle,
303
+ expand: _this.opened,
304
+ onClose: function (event) { return _this.onCancel(event); },
305
+ windowWidth: windowWidth,
306
+ footer: {
307
+ cancelText: _this.localization.toLanguageString(adaptiveModeFooterCancel, messages[adaptiveModeFooterCancel]),
308
+ onCancel: function (event) { return _this.onCancel(event); },
309
+ applyText: _this.localization.toLanguageString(adaptiveModeFooterApply, messages[adaptiveModeFooterApply]),
310
+ onApply: function (event) { return _this.closePopup(event); }
311
+ }
312
+ };
313
+ return (React.createElement(AdaptiveMode, __assign({}, actionSheetProps),
314
+ React.createElement(ActionSheetContent, { className: '!k-overflow-hidden' },
315
+ filterable && React.createElement(ListFilter, { value: mobileText, ref: function (adaptiveFilter) { return _this._adaptiveInput = adaptiveFilter && adaptiveFilter.input; }, onChange: _this.onChangeHandler, onKeyDown: _this.onInputKeyDown, size: _this.props.size, rounded: _this.props.rounded, fillMode: _this.props.fillMode }),
316
+ _this.listContainerContent())));
317
+ };
318
+ _this.closePopup = function (event) {
319
+ var state = _this.base.initState();
320
+ state.syntheticEvent = event;
321
+ event.stopPropagation();
322
+ if (_this.state.focusedIndex !== undefined) {
323
+ state.data.focusedIndex = undefined;
324
+ }
325
+ if (_this.opened) {
326
+ _this.base.togglePopup(state);
327
+ }
328
+ state.events.push({ type: 'onClose' });
329
+ var text = _this.props.filter !== undefined ? _this.props.filter : _this.state.text;
330
+ if (isPresent(text) && text !== '') {
331
+ _this.base.filterChanged('', state);
332
+ }
333
+ if (_this.state.text) {
334
+ state.data.text = '';
335
+ }
336
+ _this.applyState(state);
337
+ };
338
+ _this.onCancel = function (event) {
339
+ var state = _this.base.initState();
340
+ state.syntheticEvent = event;
341
+ event.stopPropagation();
342
+ if (_this.state.focusedIndex !== undefined) {
343
+ state.data.focusedIndex = undefined;
344
+ }
345
+ if (_this.opened) {
346
+ _this.base.togglePopup(state);
347
+ }
348
+ state.events.push({ type: 'onCancel' });
349
+ var text = _this.props.filter !== undefined ? _this.props.filter : _this.state.text;
350
+ if (isPresent(text) && text !== '') {
351
+ _this.base.filterChanged('', state);
352
+ }
353
+ if (_this.state.text) {
354
+ state.data.text = '';
355
+ }
356
+ _this.applyState(state);
357
+ };
297
358
  _this.renderList = function () {
298
359
  var _a = _this.props, _b = _a.data, data = _b === void 0 ? [] : _b, textField = _a.textField, listNoDataRender = _a.listNoDataRender, itemRender = _a.itemRender, groupHeaderItemRender = _a.groupHeaderItemRender, dataItemKey = _a.dataItemKey, virtual = _a.virtual;
299
360
  var vs = _this.base.vs;
300
361
  var skip = virtual ? virtual.skip : 0;
301
- var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
302
362
  var focusedIndex = _this.getFocusedState().focusedIndex;
303
363
  var popupSettings = _this.base.getPopupSettings();
304
364
  var translate = "translateY(".concat(vs.translate, "px)");
305
- return (React.createElement(List, { id: _this.base.listBoxId, show: opened, data: data.slice(), focusedIndex: focusedIndex - skip, value: _this.value, textField: textField, valueField: dataItemKey, optionsGuid: _this.base.guid, groupField: _this.props.groupField, groupMode: 'modern', listRef: function (list) { vs.list = _this.base.list = list; }, wrapperStyle: { maxHeight: popupSettings.height }, wrapperCssClass: "k-list-content", listStyle: vs.enabled ? { transform: translate } : undefined, key: "listKey", skip: skip, onClick: _this.handleItemClick, itemRender: itemRender, groupHeaderItemRender: groupHeaderItemRender, noDataRender: listNoDataRender, onMouseDown: preventDefault, onBlur: _this.handleBlur, onScroll: _this.onScroll, wrapperRef: vs.scrollerRef, scroller: _this.base.renderScrollElement() }));
365
+ return (React.createElement(List, { id: _this.base.listBoxId, show: _this.opened, data: data.slice(), focusedIndex: focusedIndex - skip, value: _this.value, textField: textField, valueField: dataItemKey, optionsGuid: _this.base.guid, groupField: _this.props.groupField, groupMode: 'modern', listRef: function (list) { vs.list = _this.base.list = list; }, wrapperStyle: _this.mobileMode ? {} : { maxHeight: popupSettings.height }, wrapperCssClass: "k-list-content", listStyle: vs.enabled ? { transform: translate } : undefined, key: "listKey", skip: skip, onClick: _this.handleItemClick, itemRender: itemRender, groupHeaderItemRender: groupHeaderItemRender, noDataRender: listNoDataRender, onMouseDown: preventDefault, onBlur: _this.handleBlur, onScroll: _this.onScroll, wrapperRef: vs.scrollerRef, scroller: _this.base.renderScrollElement() }));
306
366
  };
307
367
  _this.onScroll = function (event) {
308
368
  var _a = _this.base, vs = _a.vs, list = _a.list;
@@ -355,17 +415,22 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
355
415
  _this.applyState(state);
356
416
  };
357
417
  _this.handleWrapperClick = function (event) {
358
- var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
359
418
  var input = _this._input;
360
- if (!opened && input) {
419
+ if (!_this.opened && input) {
361
420
  _this.focusElement(input);
362
421
  }
363
422
  var state = _this.base.initState();
364
423
  state.syntheticEvent = event;
365
- if (!_this.state.focused) {
424
+ if (!_this.state.focused && !_this.mobileMode) {
366
425
  state.events.push({ type: 'onFocus' });
367
426
  state.data.focused = true;
368
427
  }
428
+ if (_this.mobileMode) {
429
+ _this.setState({ currentTreeValue: _this.tagsToRender });
430
+ if (_this.mobileMode) {
431
+ window.setTimeout(function () { return _this._adaptiveInput && _this._adaptiveInput.focus(); }, 300);
432
+ }
433
+ }
369
434
  _this.base.togglePopup(state);
370
435
  _this.applyState(state);
371
436
  };
@@ -373,7 +438,7 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
373
438
  var state = _this.base.initState();
374
439
  state.syntheticEvent = event;
375
440
  _this.handleItemSelect(index, state);
376
- if (_this.props.autoClose) {
441
+ if (_this.props.autoClose && !_this.mobileMode) {
377
442
  _this.base.togglePopup(state);
378
443
  }
379
444
  event.stopPropagation();
@@ -383,13 +448,12 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
383
448
  if (!_this.state.focused || _this._skipFocusEvent) {
384
449
  return;
385
450
  }
386
- var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
387
451
  var state = _this.base.initState();
388
452
  var _a = _this.props, allowCustom = _a.allowCustom, filterable = _a.filterable;
389
453
  state.syntheticEvent = event;
390
454
  state.data.focused = false;
391
455
  state.events.push({ type: 'onBlur' });
392
- if (opened) {
456
+ if (_this.opened && !_this.mobileMode) {
393
457
  if (_this.state.opened) {
394
458
  state.data.opened = false;
395
459
  }
@@ -407,7 +471,7 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
407
471
  _this.base.handleFocus(event);
408
472
  };
409
473
  _this.onPopupOpened = function () {
410
- if (_this._input && _this.state.focused) {
474
+ if (_this._input && _this.state.focused && !_this.mobileMode) {
411
475
  _this.focusElement(_this._input);
412
476
  }
413
477
  };
@@ -428,12 +492,59 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
428
492
  validatePackage(packageMetadata);
429
493
  return _this;
430
494
  }
495
+ Object.defineProperty(MultiSelectWithoutContext.prototype, "document", {
496
+ get: function () {
497
+ if (!canUseDOM) {
498
+ return;
499
+ }
500
+ // useful only for user actions
501
+ return (this.element && this.element.ownerDocument) || document;
502
+ },
503
+ enumerable: false,
504
+ configurable: true
505
+ });
431
506
  Object.defineProperty(MultiSelectWithoutContext.prototype, "element", {
507
+ /** @hidden */
508
+ get: function () {
509
+ return this._element;
510
+ },
511
+ enumerable: false,
512
+ configurable: true
513
+ });
514
+ Object.defineProperty(MultiSelectWithoutContext.prototype, "opened", {
515
+ /** @hidden */
516
+ get: function () {
517
+ var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
518
+ return !!opened;
519
+ },
520
+ enumerable: false,
521
+ configurable: true
522
+ });
523
+ Object.defineProperty(MultiSelectWithoutContext.prototype, "tagsToRender", {
524
+ /** @hidden */
525
+ get: function () {
526
+ var _a = this.props, tags = _a.tags, textField = _a.textField;
527
+ var tagsToRender = [];
528
+ if (tags === undefined) {
529
+ this.value.forEach(function (item) {
530
+ tagsToRender.push({ text: getItemValue(item, textField), data: [item] });
531
+ });
532
+ }
533
+ else {
534
+ tagsToRender.push.apply(tagsToRender, tags);
535
+ }
536
+ return tagsToRender;
537
+ },
538
+ enumerable: false,
539
+ configurable: true
540
+ });
541
+ Object.defineProperty(MultiSelectWithoutContext.prototype, "mobileMode", {
432
542
  /**
433
- * @hidden
543
+ * The mobile mode of the ComboBox.
434
544
  */
435
545
  get: function () {
436
- return this._element;
546
+ var isAdaptive = this.state.windowWidth && this.state.windowWidth <= MOBILE_MEDIUM_DEVISE && this.props.adaptive;
547
+ return !!isAdaptive;
437
548
  },
438
549
  enumerable: false,
439
550
  configurable: true
@@ -490,9 +601,7 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
490
601
  configurable: true
491
602
  });
492
603
  Object.defineProperty(MultiSelectWithoutContext.prototype, "required", {
493
- /**
494
- * @hidden
495
- */
604
+ /** @hidden */
496
605
  get: function () {
497
606
  return this.props.required !== undefined
498
607
  ? this.props.required
@@ -510,19 +619,16 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
510
619
  enumerable: false,
511
620
  configurable: true
512
621
  });
513
- /**
514
- * @hidden
515
- */
622
+ /** @hidden */
516
623
  MultiSelectWithoutContext.prototype.componentDidUpdate = function (prevProps, prevState) {
517
624
  var _a;
518
625
  var _b = this.props, virtual = _b.virtual, _c = _b.groupField, groupField = _c === void 0 ? '' : _c;
519
626
  var _d = this.props.data, data = _d === void 0 ? [] : _d;
520
627
  var skip = virtual ? virtual.skip : 0;
521
628
  var prevTotal = prevProps.virtual ? prevProps.virtual.total : 0;
522
- var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
523
629
  var prevOpened = prevProps.opened !== undefined ? prevProps.opened : prevState.opened;
524
- var opening = !prevOpened && opened;
525
- var closing = prevOpened && !opened;
630
+ var opening = !prevOpened && this.opened;
631
+ var closing = prevOpened && !this.opened;
526
632
  var popupSettings = this.base.getPopupSettings();
527
633
  if (!popupSettings.animate && closing) {
528
634
  this.onPopupClosed();
@@ -542,33 +648,40 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
542
648
  else if (opening && !virtual) {
543
649
  this.base.scrollToItem(focusedIndex);
544
650
  }
545
- else if (opened && prevOpened && focusedItem && this.scrollToFocused) {
651
+ else if (this.opened && prevOpened && focusedItem && this.scrollToFocused) {
546
652
  this.base.scrollToItem(focusedIndex - skip);
547
653
  }
548
654
  }
549
655
  this.scrollToFocused = false;
550
656
  this.setValidity();
551
657
  };
552
- /**
553
- * @hidden
554
- */
658
+ /** @hidden */
555
659
  MultiSelectWithoutContext.prototype.componentDidMount = function () {
660
+ var _a;
661
+ this.observerResize = canUseDOM && window.ResizeObserver && new window.ResizeObserver(this.calculateMedia.bind(this));
556
662
  this.base.didMount();
557
663
  this.setValidity();
664
+ if (((_a = this.document) === null || _a === void 0 ? void 0 : _a.body) && this.observerResize) {
665
+ this.observerResize.observe(this.document.body);
666
+ }
558
667
  };
559
- /**
560
- * @hidden
561
- */
668
+ /** @hidden */
669
+ MultiSelectWithoutContext.prototype.componentWillUnmount = function () {
670
+ var _a;
671
+ if (((_a = this.document) === null || _a === void 0 ? void 0 : _a.body) && this.observerResize) {
672
+ this.observerResize.disconnect();
673
+ }
674
+ };
675
+ /** @hidden */
562
676
  MultiSelectWithoutContext.prototype.onNavigate = function (state, keyCode) {
563
677
  var _a = this.props, allowCustom = _a.allowCustom, _b = _a.data, data = _b === void 0 ? [] : _b;
564
- var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
565
678
  var text = this.props.filter !== undefined ? this.props.filter : this.state.text;
566
679
  var _c = this.getFocusedState(), focusedType = _c.focusedType, focusedIndex = _c.focusedIndex;
567
680
  var customItem = allowCustom && text;
568
681
  var customItemFocused = isCustom(focusedType);
569
682
  var base = this.base;
570
683
  var vs = base.vs;
571
- if (opened && keyCode === Keys.up && customItemFocused) {
684
+ if (this.opened && keyCode === Keys.up && customItemFocused) {
572
685
  if (this.state.focusedIndex !== undefined) {
573
686
  state.data.focusedIndex = undefined;
574
687
  }
@@ -587,13 +700,11 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
587
700
  }
588
701
  this.applyState(state);
589
702
  };
590
- /**
591
- * @hidden
592
- */
703
+ /** @hidden */
593
704
  MultiSelectWithoutContext.prototype.render = function () {
594
705
  var _a, _b;
595
- var _c = this.props, style = _c.style, className = _c.className, label = _c.label, dir = _c.dir, disabled = _c.disabled, tags = _c.tags, textField = _c.textField, dataItemKey = _c.dataItemKey, virtual = _c.virtual, size = _c.size, rounded = _c.rounded, fillMode = _c.fillMode, loading = _c.loading, filter = _c.filter;
596
- var _d = this.state, text = _d.text, focused = _d.focused, focusedTag = _d.focusedTag;
706
+ var _c = this.props, style = _c.style, className = _c.className, label = _c.label, dir = _c.dir, disabled = _c.disabled, textField = _c.textField, dataItemKey = _c.dataItemKey, virtual = _c.virtual, size = _c.size, rounded = _c.rounded, fillMode = _c.fillMode, loading = _c.loading, filter = _c.filter;
707
+ var _d = this.state, text = _d.text, focused = _d.focused, focusedTag = _d.focusedTag, currentTreeValue = _d.currentTreeValue;
597
708
  var vs = this.base.vs;
598
709
  var id = this.props.id || this._inputId;
599
710
  vs.enabled = virtual !== undefined;
@@ -602,51 +713,44 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
602
713
  vs.total = virtual.total;
603
714
  vs.pageSize = virtual.pageSize;
604
715
  }
605
- var tagsToRender = [];
606
- if (tags === undefined) {
607
- this.value.forEach(function (item) {
608
- tagsToRender.push({ text: getItemValue(item, textField), data: [item] });
609
- });
610
- }
611
- else {
612
- tagsToRender.push.apply(tagsToRender, tags);
613
- }
614
- this.setItems(tagsToRender, this._tags);
716
+ var currentTagsToRender = (this.mobileMode && this.opened) ? currentTreeValue : this.tagsToRender;
717
+ this.setItems(this.tagsToRender, this._tags);
615
718
  var isValid = !this.validityStyles || this.validity.valid;
616
- var clearButton = Boolean(filter !== undefined ? filter : text) || this.value.length > 0;
617
- var component = (React.createElement("div", { ref: this.componentRef, className: classNames('k-multiselect k-input', className, (_a = {},
618
- _a["k-input-".concat(sizeMap[size] || size)] = size,
619
- _a["k-rounded-".concat(roundedMap[rounded] || rounded)] = rounded,
620
- _a["k-input-".concat(fillMode)] = fillMode,
621
- _a['k-focus'] = focused && !disabled,
622
- _a['k-invalid'] = !isValid,
623
- _a['k-disabled'] = disabled,
624
- _a['k-loading'] = loading,
625
- _a['k-required'] = this.required,
626
- _a)), style: !label
627
- ? style
628
- : __assign(__assign({}, style), { width: undefined }), dir: dir, onFocus: this.handleFocus, onBlur: this.handleBlur, onClick: this.handleWrapperClick, onMouseDown: preventDefaultNonInputs },
629
- React.createElement("div", { className: classNames('k-input-values') },
630
- React.createElement("div", { className: classNames('k-chip-list', (_b = {},
631
- _b["k-chip-list-".concat(sizeMap[size] || size)] = size,
632
- _b)), role: "listbox", id: 'tagslist-' + this.base.guid }, tagsToRender.length > 0 && React.createElement(TagList, { tagRender: this.props.tagRender, onTagDelete: this.onTagDelete, data: tagsToRender, guid: this.base.guid, focused: focusedTag ? tagsToRender.find(function (t) { return matchTags(t, focusedTag, dataItemKey); }) : undefined, size: size })),
633
- this.renderSearchbar(id)),
634
- loading && React.createElement(IconWrap, { className: "k-input-loading-icon", name: 'loading' }),
635
- clearButton && React.createElement(ClearButton, { onClick: this.clearButtonClick }),
636
- this.renderListContainer()));
719
+ var clearButton = Boolean(filter !== undefined ? filter : text)
720
+ || (currentTagsToRender && currentTagsToRender.length > 0);
721
+ var component = (React.createElement(React.Fragment, null,
722
+ React.createElement("div", { ref: this.componentRef, className: classNames('k-multiselect k-input', className, (_a = {},
723
+ _a["k-input-".concat(sizeMap[size] || size)] = size,
724
+ _a["k-rounded-".concat(roundedMap[rounded] || rounded)] = rounded,
725
+ _a["k-input-".concat(fillMode)] = fillMode,
726
+ _a['k-focus'] = focused && !disabled,
727
+ _a['k-invalid'] = !isValid,
728
+ _a['k-disabled'] = disabled,
729
+ _a['k-loading'] = loading,
730
+ _a['k-required'] = this.required,
731
+ _a)), style: !label
732
+ ? style
733
+ : __assign(__assign({}, style), { width: undefined }), dir: dir, onFocus: this.handleFocus, onBlur: this.handleBlur, onClick: this.handleWrapperClick, onMouseDown: preventDefaultNonInputs },
734
+ React.createElement("div", { className: classNames('k-input-values') },
735
+ React.createElement("div", { className: classNames('k-chip-list', (_b = {}, _b["k-chip-list-".concat(sizeMap[size] || size)] = size, _b)), role: "listbox", id: 'tagslist-' + this.base.guid }, currentTagsToRender && currentTagsToRender.length > 0 && React.createElement(TagList, { tagRender: this.props.tagRender, onTagDelete: this.onTagDelete, data: currentTagsToRender, guid: this.base.guid, focused: focusedTag ? currentTagsToRender.find(function (t) { return matchTags(t, focusedTag, dataItemKey); }) : undefined, size: size })),
736
+ this.renderSearchBar(id)),
737
+ loading && React.createElement(IconWrap, { className: "k-input-loading-icon", name: 'loading' }),
738
+ clearButton && React.createElement(ClearButton, { onClick: this.clearButtonClick }),
739
+ !this.mobileMode && this.renderListContainer()),
740
+ this.mobileMode && this.renderAdaptiveListContainer()));
637
741
  return label ? (React.createElement(FloatingLabel, { label: label, editorId: id, editorValue: text || getItemValue(this.value[0], textField), editorValid: isValid, editorDisabled: disabled, style: { width: style ? style.width : undefined }, children: component })) : component;
638
742
  };
639
- MultiSelectWithoutContext.prototype.renderSearchbar = function (id) {
640
- var _a = this.state, activedescendant = _a.activedescendant, focusedTag = _a.focusedTag;
743
+ MultiSelectWithoutContext.prototype.renderSearchBar = function (id) {
744
+ var _a = this.state, activedescendant = _a.activedescendant, focusedTag = _a.focusedTag, currentTreeValue = _a.currentTreeValue;
641
745
  var _b = this.props, disabled = _b.disabled, placeholder = _b.placeholder, ariaDescribedBy = _b.ariaDescribedBy;
642
- var text = (this.props.filter !== undefined ? this.props.filter : this.state.text) || '';
643
- var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
746
+ var text = !this.mobileMode && (this.props.filter !== undefined ? this.props.filter : this.state.text) || '';
644
747
  var focusedIndex = this.getFocusedState().focusedIndex;
645
748
  var placeholderToShow = this.value.length === 0 && !text ? placeholder : undefined;
749
+ var adaptivePlaceholder = (currentTreeValue && currentTreeValue.length > 0) ? undefined : placeholder;
646
750
  var ariaActivedescendant = activedescendant === ActiveDescendant.TagsList && focusedTag !== undefined ?
647
751
  "tag-".concat(this.base.guid, "-").concat(focusedTag.text.replace(/\s+/g, '-')) :
648
752
  "option-".concat(this.base.guid, "-").concat(focusedIndex);
649
- return (React.createElement(SearchBar, { id: id, size: Math.max((placeholderToShow || '').length, text.length, 1), tabIndex: this.props.tabIndex, accessKey: this.props.accessKey, placeholder: placeholderToShow, value: text, onChange: this.onChangeHandler, onKeyDown: this.onInputKeyDown, ref: this.searchbarRef, disabled: disabled, expanded: opened, owns: this.base.listBoxId, role: 'combobox', activedescendant: ariaActivedescendant, ariaDescribedBy: "tagslist-".concat(this.base.guid).concat(ariaDescribedBy ? (' ' + ariaDescribedBy) : ''), ariaLabelledBy: this.props.ariaLabelledBy, ariaRequired: this.required }));
753
+ return (React.createElement(SearchBar, { id: id, size: Math.max((placeholderToShow || '').length, text.length, 1), tabIndex: this.props.tabIndex, accessKey: this.props.accessKey, placeholder: this.mobileMode && this.opened ? adaptivePlaceholder : placeholderToShow, value: text, onChange: this.onChangeHandler, onKeyDown: this.onInputKeyDown, ref: this.searchbarRef, disabled: disabled, expanded: this.opened, owns: this.base.listBoxId, role: 'combobox', activedescendant: ariaActivedescendant, ariaDescribedBy: "tagslist-".concat(this.base.guid).concat(ariaDescribedBy ? (' ' + ariaDescribedBy) : ''), ariaLabelledBy: this.props.ariaLabelledBy, ariaRequired: this.required }));
650
754
  };
651
755
  MultiSelectWithoutContext.prototype.onTagsNavigate = function (event, state) {
652
756
  var keyCode = event.keyCode;
@@ -777,17 +881,21 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
777
881
  this.base.applyState(state);
778
882
  this._valueItemsDuringOnChange = null;
779
883
  };
884
+ MultiSelectWithoutContext.prototype.calculateMedia = function (entries) {
885
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
886
+ var entry = entries_1[_i];
887
+ this.setState({ windowWidth: entry.target.clientWidth });
888
+ }
889
+ ;
890
+ };
891
+ ;
780
892
  MultiSelectWithoutContext.displayName = 'MultiSelect';
781
- /**
782
- * @hidden
783
- */
893
+ /** @hidden */
784
894
  MultiSelectWithoutContext.propTypes = __assign(__assign({}, DropDownBase.propTypes), { autoClose: PropTypes.bool, value: PropTypes.arrayOf(PropTypes.any), defaultValue: PropTypes.arrayOf(PropTypes.any), dataItemKey: PropTypes.string, placeholder: PropTypes.string, tags: PropTypes.arrayOf(PropTypes.shape({
785
895
  text: PropTypes.string,
786
896
  data: PropTypes.arrayOf(PropTypes.any)
787
- })), tagRender: PropTypes.func, id: PropTypes.string, ariaLabelledBy: PropTypes.string, ariaDescribedBy: PropTypes.string, groupField: PropTypes.string, list: PropTypes.any });
788
- /**
789
- * @hidden
790
- */
897
+ })), tagRender: PropTypes.func, id: PropTypes.string, ariaLabelledBy: PropTypes.string, ariaDescribedBy: PropTypes.string, groupField: PropTypes.string, list: PropTypes.any, adaptive: PropTypes.bool, adaptiveTitle: PropTypes.string, onCancel: PropTypes.func });
898
+ /** @hidden */
791
899
  MultiSelectWithoutContext.defaultProps = __assign(__assign({}, DropDownBase.defaultProps), { autoClose: true, required: false, size: 'medium', rounded: 'medium', fillMode: 'solid', groupMode: 'modern' });
792
900
  return MultiSelectWithoutContext;
793
901
  }(React.Component));