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