@progress/kendo-react-dropdowns 6.1.1 → 7.0.0-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{dist/es/AutoComplete → AutoComplete}/AutoComplete.d.ts +12 -8
- package/{dist/npm/AutoComplete → AutoComplete}/AutoCompleteProps.d.ts +4 -1
- package/{dist/es/ComboBox → ComboBox}/ComboBox.d.ts +12 -8
- package/{dist/es/ComboBox → ComboBox}/ComboBoxProps.d.ts +4 -1
- package/{dist/es/DropDownList → DropDownList}/DropDownList.d.ts +9 -5
- package/{dist/es/DropDownList → DropDownList}/DropDownListProps.d.ts +4 -1
- package/{dist/es/DropDownTree → DropDownTree}/DropDownTree.d.ts +4 -0
- package/{dist/npm/DropDownTree → DropDownTree}/DropDownTreeProps.d.ts +4 -1
- package/DropDownTree/ListNoData.d.ts +10 -0
- package/DropDownTree/useDropdownWidth.d.ts +9 -0
- package/LICENSE.md +1 -1
- package/{dist/es/MultiColumnComboBox → MultiColumnComboBox}/MultiColumnComboBox.d.ts +4 -0
- package/{dist/npm/MultiSelect → MultiSelect}/MultiSelect.d.ts +9 -5
- package/{dist/es/MultiSelect → MultiSelect}/MultiSelectProps.d.ts +4 -1
- package/{dist/npm/MultiSelect → MultiSelect}/TagList.d.ts +5 -1
- package/{dist/es/MultiSelectTree → MultiSelectTree}/MultiSelectTree.d.ts +4 -0
- package/{dist/es/MultiSelectTree → MultiSelectTree}/MultiSelectTreeProps.d.ts +5 -1
- package/{dist/npm/MultiSelectTree → MultiSelectTree}/utils.d.ts +5 -1
- package/{dist/npm/common → common}/AdaptiveMode.d.ts +5 -1
- package/common/ClearButton.d.ts +18 -0
- package/{dist/npm/common → common}/DropDownBase.d.ts +5 -1
- package/{dist/es/common → common}/GroupStickyHeader.d.ts +5 -1
- package/{dist/es/common → common}/List.d.ts +7 -3
- package/common/ListContainer.d.ts +22 -0
- package/common/ListDefaultItem.d.ts +20 -0
- package/{dist/npm/common → common}/ListFilter.d.ts +4 -0
- package/{dist/npm/common → common}/ListGroupItem.d.ts +5 -1
- package/{dist/npm/common → common}/ListItem.d.ts +5 -1
- package/common/MultiColumnList.d.ts +9 -0
- package/common/Navigation.d.ts +17 -0
- package/{dist/es/common → common}/SearchBar.d.ts +5 -1
- package/{dist/npm/common → common}/VirtualScroll.d.ts +4 -1
- package/common/constants.d.ts +8 -0
- package/{dist/es/common → common}/events.d.ts +4 -1
- package/{dist/npm/common → common}/filterDescriptor.d.ts +4 -0
- package/{dist/es/common → common}/settings.d.ts +5 -2
- package/{dist/npm/common → common}/utils.d.ts +4 -0
- package/dist/cdn/js/kendo-react-dropdowns.js +5 -1
- package/index.d.ts +29 -0
- package/index.js +5 -0
- package/index.mjs +4383 -0
- package/{dist/npm/messages → messages}/index.d.ts +4 -0
- package/package-metadata.d.ts +9 -0
- package/package.json +34 -62
- package/about.md +0 -3
- package/dist/es/AutoComplete/AutoComplete.js +0 -652
- package/dist/es/AutoComplete/AutoCompleteProps.d.ts +0 -243
- package/dist/es/AutoComplete/AutoCompleteProps.js +0 -2
- package/dist/es/ComboBox/ComboBox.js +0 -915
- package/dist/es/ComboBox/ComboBoxProps.js +0 -2
- package/dist/es/DropDownList/DropDownList.js +0 -887
- package/dist/es/DropDownList/DropDownListProps.js +0 -2
- package/dist/es/DropDownTree/DropDownTree.js +0 -540
- package/dist/es/DropDownTree/DropDownTreeProps.d.ts +0 -294
- package/dist/es/DropDownTree/DropDownTreeProps.js +0 -2
- package/dist/es/DropDownTree/ListNoData.d.ts +0 -6
- package/dist/es/DropDownTree/ListNoData.js +0 -8
- package/dist/es/DropDownTree/useDropdownWidth.d.ts +0 -5
- package/dist/es/DropDownTree/useDropdownWidth.js +0 -13
- package/dist/es/MultiColumnComboBox/MultiColumnComboBox.js +0 -213
- package/dist/es/MultiSelect/MultiSelect.d.ts +0 -256
- package/dist/es/MultiSelect/MultiSelect.js +0 -1110
- package/dist/es/MultiSelect/MultiSelectProps.js +0 -2
- package/dist/es/MultiSelect/TagList.d.ts +0 -38
- package/dist/es/MultiSelect/TagList.js +0 -39
- package/dist/es/MultiSelectTree/MultiSelectTree.js +0 -619
- package/dist/es/MultiSelectTree/MultiSelectTreeProps.js +0 -2
- package/dist/es/MultiSelectTree/utils.d.ts +0 -17
- package/dist/es/MultiSelectTree/utils.js +0 -191
- package/dist/es/common/AdaptiveMode.d.ts +0 -21
- package/dist/es/common/AdaptiveMode.js +0 -45
- package/dist/es/common/ClearButton.d.ts +0 -14
- package/dist/es/common/ClearButton.js +0 -39
- package/dist/es/common/DropDownBase.d.ts +0 -175
- package/dist/es/common/DropDownBase.js +0 -297
- package/dist/es/common/GroupStickyHeader.js +0 -34
- package/dist/es/common/List.js +0 -75
- package/dist/es/common/ListContainer.d.ts +0 -18
- package/dist/es/common/ListContainer.js +0 -43
- package/dist/es/common/ListDefaultItem.d.ts +0 -16
- package/dist/es/common/ListDefaultItem.js +0 -36
- package/dist/es/common/ListFilter.d.ts +0 -19
- package/dist/es/common/ListFilter.js +0 -37
- package/dist/es/common/ListGroupItem.d.ts +0 -33
- package/dist/es/common/ListGroupItem.js +0 -33
- package/dist/es/common/ListItem.d.ts +0 -61
- package/dist/es/common/ListItem.js +0 -44
- package/dist/es/common/MultiColumnList.d.ts +0 -6
- package/dist/es/common/MultiColumnList.js +0 -22
- package/dist/es/common/Navigation.d.ts +0 -13
- package/dist/es/common/Navigation.js +0 -34
- package/dist/es/common/SearchBar.js +0 -62
- package/dist/es/common/VirtualScroll.d.ts +0 -42
- package/dist/es/common/VirtualScroll.js +0 -161
- package/dist/es/common/constants.d.ts +0 -4
- package/dist/es/common/constants.js +0 -4
- package/dist/es/common/events.js +0 -1
- package/dist/es/common/filterDescriptor.d.ts +0 -41
- package/dist/es/common/filterDescriptor.js +0 -2
- package/dist/es/common/settings.js +0 -8
- package/dist/es/common/utils.d.ts +0 -62
- package/dist/es/common/utils.js +0 -194
- package/dist/es/main.d.ts +0 -25
- package/dist/es/main.js +0 -19
- package/dist/es/messages/index.d.ts +0 -40
- package/dist/es/messages/index.js +0 -41
- package/dist/es/package-metadata.d.ts +0 -5
- package/dist/es/package-metadata.js +0 -11
- package/dist/npm/AutoComplete/AutoComplete.d.ts +0 -230
- package/dist/npm/AutoComplete/AutoComplete.js +0 -655
- package/dist/npm/AutoComplete/AutoCompleteProps.js +0 -3
- package/dist/npm/ComboBox/ComboBox.d.ts +0 -248
- package/dist/npm/ComboBox/ComboBox.js +0 -918
- package/dist/npm/ComboBox/ComboBoxProps.d.ts +0 -313
- package/dist/npm/ComboBox/ComboBoxProps.js +0 -3
- package/dist/npm/DropDownList/DropDownList.d.ts +0 -258
- package/dist/npm/DropDownList/DropDownList.js +0 -890
- package/dist/npm/DropDownList/DropDownListProps.d.ts +0 -326
- package/dist/npm/DropDownList/DropDownListProps.js +0 -3
- package/dist/npm/DropDownTree/DropDownTree.d.ts +0 -70
- package/dist/npm/DropDownTree/DropDownTree.js +0 -543
- package/dist/npm/DropDownTree/DropDownTreeProps.js +0 -3
- package/dist/npm/DropDownTree/ListNoData.d.ts +0 -6
- package/dist/npm/DropDownTree/ListNoData.js +0 -12
- package/dist/npm/DropDownTree/useDropdownWidth.d.ts +0 -5
- package/dist/npm/DropDownTree/useDropdownWidth.js +0 -17
- package/dist/npm/MultiColumnComboBox/MultiColumnComboBox.d.ts +0 -287
- package/dist/npm/MultiColumnComboBox/MultiColumnComboBox.js +0 -216
- package/dist/npm/MultiSelect/MultiSelect.js +0 -1113
- package/dist/npm/MultiSelect/MultiSelectProps.d.ts +0 -314
- package/dist/npm/MultiSelect/MultiSelectProps.js +0 -3
- package/dist/npm/MultiSelect/TagList.js +0 -41
- package/dist/npm/MultiSelectTree/MultiSelectTree.d.ts +0 -81
- package/dist/npm/MultiSelectTree/MultiSelectTree.js +0 -622
- package/dist/npm/MultiSelectTree/MultiSelectTreeProps.d.ts +0 -320
- package/dist/npm/MultiSelectTree/MultiSelectTreeProps.js +0 -3
- package/dist/npm/MultiSelectTree/utils.js +0 -196
- package/dist/npm/common/AdaptiveMode.js +0 -49
- package/dist/npm/common/ClearButton.d.ts +0 -14
- package/dist/npm/common/ClearButton.js +0 -41
- package/dist/npm/common/DropDownBase.js +0 -299
- package/dist/npm/common/GroupStickyHeader.d.ts +0 -24
- package/dist/npm/common/GroupStickyHeader.js +0 -36
- package/dist/npm/common/List.d.ts +0 -45
- package/dist/npm/common/List.js +0 -77
- package/dist/npm/common/ListContainer.d.ts +0 -18
- package/dist/npm/common/ListContainer.js +0 -45
- package/dist/npm/common/ListDefaultItem.d.ts +0 -16
- package/dist/npm/common/ListDefaultItem.js +0 -38
- package/dist/npm/common/ListFilter.js +0 -39
- package/dist/npm/common/ListGroupItem.js +0 -35
- package/dist/npm/common/ListItem.js +0 -46
- package/dist/npm/common/MultiColumnList.d.ts +0 -6
- package/dist/npm/common/MultiColumnList.js +0 -26
- package/dist/npm/common/Navigation.d.ts +0 -13
- package/dist/npm/common/Navigation.js +0 -37
- package/dist/npm/common/SearchBar.d.ts +0 -43
- package/dist/npm/common/SearchBar.js +0 -64
- package/dist/npm/common/VirtualScroll.js +0 -163
- package/dist/npm/common/constants.d.ts +0 -4
- package/dist/npm/common/constants.js +0 -7
- package/dist/npm/common/events.d.ts +0 -73
- package/dist/npm/common/events.js +0 -2
- package/dist/npm/common/filterDescriptor.js +0 -3
- package/dist/npm/common/settings.d.ts +0 -114
- package/dist/npm/common/settings.js +0 -11
- package/dist/npm/common/utils.js +0 -211
- package/dist/npm/main.d.ts +0 -25
- package/dist/npm/main.js +0 -62
- package/dist/npm/messages/index.js +0 -44
- package/dist/npm/package-metadata.d.ts +0 -5
- package/dist/npm/package-metadata.js +0 -14
- package/dist/systemjs/kendo-react-dropdowns.js +0 -1
- package/e2e-next/combobox.basic.ts +0 -24
- package/e2e-next/dropdownlist.basic.tests.ts +0 -24
- package/e2e-next/dropdowntree.basic.tests.ts +0 -24
- package/e2e-next/multicolumncombobox.basic.tests.ts +0 -24
|
@@ -1,1113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
29
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
30
|
-
if (ar || !(i in from)) {
|
|
31
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
32
|
-
ar[i] = from[i];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.MultiSelect = exports.MultiSelectPropsContext = exports.MultiSelectWithoutContext = void 0;
|
|
39
|
-
var React = require("react");
|
|
40
|
-
var PropTypes = require("prop-types");
|
|
41
|
-
var kendo_react_common_1 = require("@progress/kendo-react-common");
|
|
42
|
-
var kendo_svg_icons_1 = require("@progress/kendo-svg-icons");
|
|
43
|
-
var kendo_react_labels_1 = require("@progress/kendo-react-labels");
|
|
44
|
-
var ListContainer_1 = require("../common/ListContainer");
|
|
45
|
-
var List_1 = require("../common/List");
|
|
46
|
-
var GroupStickyHeader_1 = require("../common/GroupStickyHeader");
|
|
47
|
-
var TagList_1 = require("./TagList");
|
|
48
|
-
var SearchBar_1 = require("../common/SearchBar");
|
|
49
|
-
var DropDownBase_1 = require("../common/DropDownBase");
|
|
50
|
-
var settings_1 = require("./../common/settings");
|
|
51
|
-
var utils_1 = require("../common/utils");
|
|
52
|
-
var kendo_react_common_2 = require("@progress/kendo-react-common");
|
|
53
|
-
var package_metadata_1 = require("../package-metadata");
|
|
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");
|
|
61
|
-
var sizeMap = kendo_react_common_1.kendoThemeMaps.sizeMap, roundedMap = kendo_react_common_1.kendoThemeMaps.roundedMap;
|
|
62
|
-
var VALIDATION_MESSAGE = 'Please enter a valid value!';
|
|
63
|
-
var preventDefault = function (event) { return event.preventDefault(); };
|
|
64
|
-
var isCustom = function (type) { return type === FocusedItemType.CustomItem; };
|
|
65
|
-
var FocusedItemType;
|
|
66
|
-
(function (FocusedItemType) {
|
|
67
|
-
FocusedItemType[FocusedItemType["None"] = 0] = "None";
|
|
68
|
-
FocusedItemType[FocusedItemType["ListItem"] = 1] = "ListItem";
|
|
69
|
-
FocusedItemType[FocusedItemType["CustomItem"] = 2] = "CustomItem";
|
|
70
|
-
})(FocusedItemType || (FocusedItemType = {}));
|
|
71
|
-
/** @hidden */
|
|
72
|
-
var MultiSelectWithoutContext = /** @class */ (function (_super) {
|
|
73
|
-
__extends(MultiSelectWithoutContext, _super);
|
|
74
|
-
function MultiSelectWithoutContext(props) {
|
|
75
|
-
var _this = _super.call(this, props) || this;
|
|
76
|
-
/** @hidden */
|
|
77
|
-
_this.state = {
|
|
78
|
-
activedescendant: settings_1.ActiveDescendant.PopupList,
|
|
79
|
-
currentValue: []
|
|
80
|
-
};
|
|
81
|
-
_this._element = null;
|
|
82
|
-
_this._valueItemsDuringOnChange = null;
|
|
83
|
-
_this._inputId = (0, kendo_react_common_1.guid)();
|
|
84
|
-
_this.base = new DropDownBase_1.default(_this);
|
|
85
|
-
_this._tags = [];
|
|
86
|
-
_this._input = null;
|
|
87
|
-
_this._adaptiveInput = null;
|
|
88
|
-
_this._skipFocusEvent = false;
|
|
89
|
-
_this._lastSelectedOrDeslectedItemIndex = null; // Needed for handling the Shift + Up/Down Keyboard Navigation requirement
|
|
90
|
-
_this.itemHeight = 0;
|
|
91
|
-
_this.scrollToFocused = false;
|
|
92
|
-
_this.localization = null;
|
|
93
|
-
/** @hidden */
|
|
94
|
-
_this.focus = function () {
|
|
95
|
-
if (_this._input) {
|
|
96
|
-
_this._input.focus();
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
/** @hidden */
|
|
100
|
-
_this.handleItemSelect = function (index, state) {
|
|
101
|
-
var _a = _this.props, _b = _a.data, data = _b === void 0 ? [] : _b, dataItemKey = _a.dataItemKey, virtual = _a.virtual;
|
|
102
|
-
var skip = virtual ? virtual.skip : 0;
|
|
103
|
-
var dataItem = data[index - skip];
|
|
104
|
-
var indexInValue = _this.value.findIndex(function (i) { return (0, utils_1.areSame)(i, dataItem, dataItemKey); });
|
|
105
|
-
_this._lastSelectedOrDeslectedItemIndex = data.findIndex(function (i) { return (0, utils_1.areSame)(i, dataItem, dataItemKey); });
|
|
106
|
-
var newItems = [];
|
|
107
|
-
if (indexInValue !== -1) { // item is already selected
|
|
108
|
-
newItems = _this.value;
|
|
109
|
-
newItems.splice(indexInValue, 1);
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
newItems = __spreadArray(__spreadArray([], _this.value, true), [dataItem], false);
|
|
113
|
-
}
|
|
114
|
-
var text = _this.props.filter !== undefined ? _this.props.filter : _this.state.text;
|
|
115
|
-
if (text && !_this.mobileMode) {
|
|
116
|
-
if (_this.state.text) {
|
|
117
|
-
state.data.text = '';
|
|
118
|
-
}
|
|
119
|
-
_this.base.filterChanged('', state);
|
|
120
|
-
}
|
|
121
|
-
if (_this._adaptiveInput) {
|
|
122
|
-
_this._adaptiveInput.blur();
|
|
123
|
-
}
|
|
124
|
-
;
|
|
125
|
-
if (_this.state.focusedIndex !== undefined) {
|
|
126
|
-
state.data.focusedIndex = undefined;
|
|
127
|
-
}
|
|
128
|
-
_this.triggerOnChange(newItems, state);
|
|
129
|
-
_this.base.triggerPageChangeCornerItems(dataItem, state);
|
|
130
|
-
};
|
|
131
|
-
/** @hidden */
|
|
132
|
-
_this.onTagDelete = function (itemsToRemove, event) {
|
|
133
|
-
var state = _this.base.initState();
|
|
134
|
-
state.syntheticEvent = event;
|
|
135
|
-
if (_this.opened) {
|
|
136
|
-
_this.base.togglePopup(state);
|
|
137
|
-
}
|
|
138
|
-
if (!_this.state.focused && !_this.mobileMode) {
|
|
139
|
-
state.data.focused = true;
|
|
140
|
-
_this.focus();
|
|
141
|
-
}
|
|
142
|
-
var selected = _this.value;
|
|
143
|
-
(0, utils_1.removeDataItems)(selected, itemsToRemove, _this.props.dataItemKey);
|
|
144
|
-
_this.triggerOnChange(selected, state);
|
|
145
|
-
_this.applyState(state);
|
|
146
|
-
};
|
|
147
|
-
/** @hidden */
|
|
148
|
-
_this.itemFocus = function (index, state) {
|
|
149
|
-
var _a = _this.props, _b = _a.data, data = _b === void 0 ? [] : _b, allowCustom = _a.allowCustom, virtual = _a.virtual;
|
|
150
|
-
var skip = virtual ? virtual.skip : 0;
|
|
151
|
-
var text = _this.props.filter !== undefined ? _this.props.filter : _this.state.text;
|
|
152
|
-
var focusedIndex = _this.getFocusedState().focusedIndex;
|
|
153
|
-
var customItem = allowCustom && text;
|
|
154
|
-
var nextFocusedItem = data[index - skip];
|
|
155
|
-
if (nextFocusedItem && focusedIndex !== index) {
|
|
156
|
-
if (_this.state.focusedIndex !== index) {
|
|
157
|
-
state.data.focusedIndex = index;
|
|
158
|
-
state.data.activedescendant = settings_1.ActiveDescendant.PopupList;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
else if (customItem && index === -1) {
|
|
162
|
-
if (_this.state.focusedIndex !== undefined) {
|
|
163
|
-
state.data.focusedIndex = undefined;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
_this.base.triggerPageChangeCornerItems(nextFocusedItem, state);
|
|
167
|
-
};
|
|
168
|
-
_this.componentRef = function (element) {
|
|
169
|
-
_this._element = element;
|
|
170
|
-
_this.base.wrapper = element;
|
|
171
|
-
};
|
|
172
|
-
_this.searchbarRef = function (searchbar) {
|
|
173
|
-
var input = _this._input = searchbar && searchbar.input;
|
|
174
|
-
if (input && _this.state.focused) {
|
|
175
|
-
window.setTimeout(function () { return input.focus(); }, 0);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
_this.onChangeHandler = function (event) {
|
|
179
|
-
var state = _this.base.initState();
|
|
180
|
-
var value = event.target.value;
|
|
181
|
-
state.syntheticEvent = event;
|
|
182
|
-
if (_this.props.filter === undefined) {
|
|
183
|
-
state.data.text = value;
|
|
184
|
-
}
|
|
185
|
-
state.data.focusedIndex = undefined;
|
|
186
|
-
if (!_this.opened) {
|
|
187
|
-
_this.base.togglePopup(state);
|
|
188
|
-
_this.setState({ currentValue: _this.value });
|
|
189
|
-
}
|
|
190
|
-
_this.base.filterChanged(value, state);
|
|
191
|
-
_this.applyState(state);
|
|
192
|
-
_this.setState({ group: undefined });
|
|
193
|
-
};
|
|
194
|
-
_this.clearButtonClick = function (event) {
|
|
195
|
-
var state = _this.base.initState();
|
|
196
|
-
state.syntheticEvent = event;
|
|
197
|
-
event.stopPropagation();
|
|
198
|
-
if (_this.value.length > 0) {
|
|
199
|
-
_this.triggerOnChange([], state);
|
|
200
|
-
}
|
|
201
|
-
if (_this.state.focusedIndex !== undefined) {
|
|
202
|
-
state.data.focusedIndex = undefined;
|
|
203
|
-
}
|
|
204
|
-
if (_this.opened) {
|
|
205
|
-
_this.base.togglePopup(state);
|
|
206
|
-
}
|
|
207
|
-
var text = _this.props.filter !== undefined ? _this.props.filter : _this.state.text;
|
|
208
|
-
if ((0, utils_1.isPresent)(text) && text !== '') {
|
|
209
|
-
_this.base.filterChanged('', state);
|
|
210
|
-
}
|
|
211
|
-
if (_this.state.text) {
|
|
212
|
-
state.data.text = '';
|
|
213
|
-
}
|
|
214
|
-
_this._lastSelectedOrDeslectedItemIndex = null; // Resets the last selected/deselected item according to the Keyboard navigation requirements
|
|
215
|
-
_this.applyState(state);
|
|
216
|
-
};
|
|
217
|
-
_this.onInputKeyDown = function (event) {
|
|
218
|
-
var _a = _this.props, _b = _a.data, data = _b === void 0 ? [] : _b, textField = _a.textField, groupField = _a.groupField;
|
|
219
|
-
var keyCode = event.keyCode;
|
|
220
|
-
var text = _this.props.filter !== undefined ? _this.props.filter : _this.state.text;
|
|
221
|
-
var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
|
|
222
|
-
var _c = _this.getFocusedState(), focusedItem = _c.focusedItem, focusedIndex = _c.focusedIndex;
|
|
223
|
-
var state = _this.base.initState();
|
|
224
|
-
state.syntheticEvent = event;
|
|
225
|
-
if (!text && _this.value.length > 0 &&
|
|
226
|
-
(keyCode === kendo_react_common_1.Keys.left || keyCode === kendo_react_common_1.Keys.right ||
|
|
227
|
-
keyCode === kendo_react_common_1.Keys.home || keyCode === kendo_react_common_1.Keys.end ||
|
|
228
|
-
keyCode === kendo_react_common_1.Keys.delete || keyCode === kendo_react_common_1.Keys.backspace) && !event.shiftKey) {
|
|
229
|
-
return _this.onTagsNavigate(event, state);
|
|
230
|
-
}
|
|
231
|
-
var togglePopup = function () {
|
|
232
|
-
event.preventDefault();
|
|
233
|
-
_this.base.togglePopup(state);
|
|
234
|
-
_this.applyState(state);
|
|
235
|
-
};
|
|
236
|
-
if (_this.opened) {
|
|
237
|
-
if (keyCode === kendo_react_common_1.Keys.pageUp) {
|
|
238
|
-
_this.base.scrollPopupByPageSize(-1);
|
|
239
|
-
}
|
|
240
|
-
else if (keyCode === kendo_react_common_1.Keys.pageDown) {
|
|
241
|
-
_this.base.scrollPopupByPageSize(1);
|
|
242
|
-
}
|
|
243
|
-
else if ((event.ctrlKey || event.metaKey) && event.code === 'KeyA') {
|
|
244
|
-
// Ctrl or Command + "A" Key selects/deselects all items
|
|
245
|
-
var currentValuesLength = _this.state.value && _this.state.value.length;
|
|
246
|
-
var dataToSet = currentValuesLength === data.length ? [] : data;
|
|
247
|
-
_this.updateStateOnKeyboardNavigation(dataToSet, state);
|
|
248
|
-
}
|
|
249
|
-
else if ((event.ctrlKey || event.metaKey) && event.shiftKey && event.keyCode === kendo_react_common_1.Keys.end) {
|
|
250
|
-
// Ctrl or Command + Shift + End from the Keyboard specifications
|
|
251
|
-
var dataToSet = data.slice(_this.getFocusedState().focusedIndex);
|
|
252
|
-
_this.itemFocus(data.length - 1, state);
|
|
253
|
-
_this.updateStateOnKeyboardNavigation(dataToSet, state);
|
|
254
|
-
}
|
|
255
|
-
else if ((event.ctrlKey || event.metaKey) && event.shiftKey && event.keyCode === kendo_react_common_1.Keys.home) {
|
|
256
|
-
// Ctrl or Command + Shift + Home from the Keyboard specifications
|
|
257
|
-
var dataToSet = data.slice(0, _this.getFocusedState().focusedIndex + 1);
|
|
258
|
-
_this.itemFocus(0, state);
|
|
259
|
-
_this.updateStateOnKeyboardNavigation(dataToSet, state);
|
|
260
|
-
}
|
|
261
|
-
else if (event.shiftKey && event.keyCode === kendo_react_common_1.Keys.up) {
|
|
262
|
-
// Shift + Up from the Keyboard specifications
|
|
263
|
-
var dataToSet = void 0;
|
|
264
|
-
var lastSelectedOrDeselectedIndex = _this.getLastSelectedOrDeselectedIndex(1, focusedIndex);
|
|
265
|
-
if (lastSelectedOrDeselectedIndex === null) {
|
|
266
|
-
dataToSet = focusedIndex !== 0 ? data.slice(focusedIndex - 1, focusedIndex) : [data[focusedIndex]];
|
|
267
|
-
}
|
|
268
|
-
else if (lastSelectedOrDeselectedIndex === focusedIndex) {
|
|
269
|
-
dataToSet = [data[lastSelectedOrDeselectedIndex - 1]];
|
|
270
|
-
}
|
|
271
|
-
else if (focusedIndex >= 0) {
|
|
272
|
-
dataToSet = lastSelectedOrDeselectedIndex > focusedIndex
|
|
273
|
-
? data.slice(focusedIndex - 1, lastSelectedOrDeselectedIndex)
|
|
274
|
-
: data.slice(lastSelectedOrDeselectedIndex - 1, focusedIndex);
|
|
275
|
-
}
|
|
276
|
-
if (dataToSet && dataToSet.length > 0) {
|
|
277
|
-
if (focusedIndex >= 1) {
|
|
278
|
-
_this.itemFocus(focusedIndex - 1, state);
|
|
279
|
-
}
|
|
280
|
-
_this.updateStateOnKeyboardNavigation(dataToSet, state);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
else if (event.shiftKey && event.keyCode === kendo_react_common_1.Keys.down) {
|
|
284
|
-
// Shift + Down from the Keyboard specifications
|
|
285
|
-
var dataToSet = void 0;
|
|
286
|
-
var lastSelectedOrDeselectedIndex = _this.getLastSelectedOrDeselectedIndex(0, focusedIndex);
|
|
287
|
-
if (lastSelectedOrDeselectedIndex === null) {
|
|
288
|
-
dataToSet = focusedIndex !== data.length - 1 ? data.slice(focusedIndex, focusedIndex + 1) : [data[focusedIndex]];
|
|
289
|
-
}
|
|
290
|
-
else if (lastSelectedOrDeselectedIndex === focusedIndex) {
|
|
291
|
-
dataToSet = data.slice(focusedIndex, focusedIndex + 2);
|
|
292
|
-
}
|
|
293
|
-
else if (focusedIndex >= 0) {
|
|
294
|
-
// dataToSet = data.slice(focusedIndex, lastSelectedOrDeselectedIndex);
|
|
295
|
-
dataToSet = lastSelectedOrDeselectedIndex > focusedIndex
|
|
296
|
-
? data.slice(focusedIndex + 1, lastSelectedOrDeselectedIndex + 1)
|
|
297
|
-
: data.slice(lastSelectedOrDeselectedIndex, focusedIndex + 2);
|
|
298
|
-
}
|
|
299
|
-
if (dataToSet && dataToSet.length >= 1) {
|
|
300
|
-
_this.itemFocus(focusedIndex + 1, state);
|
|
301
|
-
_this.updateStateOnKeyboardNavigation(dataToSet, state);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
else if (event.altKey && keyCode === kendo_react_common_1.Keys.up) {
|
|
305
|
-
togglePopup();
|
|
306
|
-
}
|
|
307
|
-
else if (keyCode === kendo_react_common_1.Keys.up || keyCode === kendo_react_common_1.Keys.down) {
|
|
308
|
-
if (groupField !== '' && textField) {
|
|
309
|
-
if (!_this.props.skipDisabledItems && opened) {
|
|
310
|
-
_this.onNavigate(state, keyCode);
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
var newIndex = 0;
|
|
314
|
-
if (keyCode === kendo_react_common_1.Keys.down || keyCode === kendo_react_common_1.Keys.right) {
|
|
315
|
-
var tempnewIndex_1 = data.slice(focusedIndex + 1).find(function (i) { return !i.disabled && i[textField]; });
|
|
316
|
-
newIndex = tempnewIndex_1 && data.findIndex(function (el) { return el[textField] === tempnewIndex_1[textField]; });
|
|
317
|
-
}
|
|
318
|
-
else if (keyCode === kendo_react_common_1.Keys.up || keyCode === kendo_react_common_1.Keys.left) {
|
|
319
|
-
var dataToSearch = void 0;
|
|
320
|
-
if (focusedIndex === -1) {
|
|
321
|
-
dataToSearch = data;
|
|
322
|
-
newIndex = data.findIndex(function (i) { return !i.disabled && i[textField]; });
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
dataToSearch = data.slice(0, focusedIndex);
|
|
326
|
-
var tempnewIndex_2 = dataToSearch.pop();
|
|
327
|
-
while (tempnewIndex_2 && tempnewIndex_2.disabled) {
|
|
328
|
-
tempnewIndex_2 = dataToSearch.pop();
|
|
329
|
-
}
|
|
330
|
-
newIndex = tempnewIndex_2 && data.findIndex(function (el) { return el[textField] === tempnewIndex_2[textField]; });
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
if (newIndex) {
|
|
334
|
-
var skipItems = newIndex - focusedIndex;
|
|
335
|
-
_this.onNavigate(state, keyCode, skipItems);
|
|
336
|
-
}
|
|
337
|
-
else if (newIndex !== undefined) {
|
|
338
|
-
_this.onNavigate(state, keyCode);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
else if (!_this.props.skipDisabledItems && opened) {
|
|
343
|
-
_this.onNavigate(state, keyCode);
|
|
344
|
-
}
|
|
345
|
-
else {
|
|
346
|
-
var newIndex = null;
|
|
347
|
-
if (keyCode === kendo_react_common_1.Keys.down || keyCode === kendo_react_common_1.Keys.right) {
|
|
348
|
-
newIndex = data.slice(focusedIndex + 1).find(function (i) { return !i.disabled; });
|
|
349
|
-
}
|
|
350
|
-
else if (keyCode === kendo_react_common_1.Keys.up || keyCode === kendo_react_common_1.Keys.left) {
|
|
351
|
-
var dataTest = data.slice(0, focusedIndex);
|
|
352
|
-
newIndex = dataTest.pop();
|
|
353
|
-
while (newIndex && newIndex.disabled) {
|
|
354
|
-
newIndex = dataTest.pop();
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
if (newIndex) {
|
|
358
|
-
var skipItems = newIndex.id - focusedIndex - 1;
|
|
359
|
-
_this.onNavigate(state, keyCode, skipItems);
|
|
360
|
-
}
|
|
361
|
-
else {
|
|
362
|
-
_this.onNavigate(state, keyCode);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
_this.applyState(state);
|
|
366
|
-
event.preventDefault();
|
|
367
|
-
}
|
|
368
|
-
else if (keyCode === kendo_react_common_1.Keys.enter) {
|
|
369
|
-
event.preventDefault();
|
|
370
|
-
if (_this.props.allowCustom && text && focusedItem === null) {
|
|
371
|
-
_this.customItemSelect(event);
|
|
372
|
-
}
|
|
373
|
-
else if (focusedItem && focusedItem.disabled) {
|
|
374
|
-
togglePopup();
|
|
375
|
-
}
|
|
376
|
-
else {
|
|
377
|
-
_this.selectFocusedItem(event);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
else if (keyCode === kendo_react_common_1.Keys.esc) {
|
|
381
|
-
togglePopup();
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
else if (event.altKey && keyCode === kendo_react_common_1.Keys.down) {
|
|
385
|
-
togglePopup();
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
_this.listContainerContent = function () {
|
|
389
|
-
var _a, _b;
|
|
390
|
-
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;
|
|
391
|
-
var text = _this.props.filter !== undefined ? _this.props.filter : _this.state.text;
|
|
392
|
-
var focusedType = _this.getFocusedState().focusedType;
|
|
393
|
-
var customItem = allowCustom && text && (React.createElement("div", { className: (0, kendo_react_common_1.classNames)('k-list', (_a = {},
|
|
394
|
-
_a["k-list-".concat(sizeMap[size] || size)] = size,
|
|
395
|
-
_a)), key: "customitem", onClick: _this.customItemSelect, onMouseDown: preventDefault },
|
|
396
|
-
React.createElement("div", { className: (0, kendo_react_common_1.classNames)('k-list-item k-custom-item', { 'k-focus': isCustom(focusedType) }), style: { fontStyle: 'italic' } },
|
|
397
|
-
text,
|
|
398
|
-
React.createElement(kendo_react_common_1.IconWrap, { name: 'plus', icon: kendo_svg_icons_1.plusIcon, style: { position: 'absolute', right: '0.5em' } }))));
|
|
399
|
-
var group = _this.state.group;
|
|
400
|
-
if (group === undefined && groupField !== undefined) {
|
|
401
|
-
group = (0, utils_1.getItemValue)(data[0], groupField);
|
|
402
|
-
}
|
|
403
|
-
return (React.createElement(React.Fragment, null,
|
|
404
|
-
header && React.createElement("div", { className: "k-list-header" }, header),
|
|
405
|
-
customItem,
|
|
406
|
-
React.createElement("div", { className: (0, kendo_react_common_1.classNames)('k-list', (_b = {},
|
|
407
|
-
_b["k-list-".concat(_this.mobileMode ? 'lg' : sizeMap[size] || size)] = size,
|
|
408
|
-
_b['k-virtual-list'] = _this.base.vs.enabled,
|
|
409
|
-
_b)) },
|
|
410
|
-
!list && group && data.length !== 0 && React.createElement(GroupStickyHeader_1.default, { group: group, groupMode: 'modern', render: groupStickyHeaderItemRender }),
|
|
411
|
-
_this.renderList()),
|
|
412
|
-
footer && React.createElement("div", { className: "k-list-footer" }, footer)));
|
|
413
|
-
};
|
|
414
|
-
_this.renderListContainer = function () {
|
|
415
|
-
var base = _this.base;
|
|
416
|
-
var _a = _this.props, dir = _a.dir, _b = _a.data, data = _b === void 0 ? [] : _b;
|
|
417
|
-
var popupSettings = _this.base.getPopupSettings();
|
|
418
|
-
var popupWidth = popupSettings.width !== undefined ? popupSettings.width : base.popupWidth;
|
|
419
|
-
var listContainerProps = {
|
|
420
|
-
dir: dir !== undefined ? dir : base.dirCalculated,
|
|
421
|
-
width: popupWidth,
|
|
422
|
-
popupSettings: {
|
|
423
|
-
popupClass: (0, kendo_react_common_1.classNames)(popupSettings.popupClass, 'k-list-container', 'k-multiselect-popup'),
|
|
424
|
-
className: popupSettings.className,
|
|
425
|
-
animate: popupSettings.animate,
|
|
426
|
-
anchor: _this.element,
|
|
427
|
-
show: _this.opened,
|
|
428
|
-
onOpen: _this.onPopupOpened,
|
|
429
|
-
onClose: _this.onPopupClosed,
|
|
430
|
-
appendTo: popupSettings.appendTo
|
|
431
|
-
},
|
|
432
|
-
itemsCount: [data.length, _this.value.length]
|
|
433
|
-
};
|
|
434
|
-
return (React.createElement(ListContainer_1.default, __assign({}, listContainerProps), _this.listContainerContent()));
|
|
435
|
-
};
|
|
436
|
-
_this.renderAdaptiveListContainer = function () {
|
|
437
|
-
var _a = _this.props, adaptiveTitle = _a.adaptiveTitle, filterable = _a.filterable, filter = _a.filter;
|
|
438
|
-
var _b = _this.state.windowWidth, windowWidth = _b === void 0 ? 0 : _b;
|
|
439
|
-
var mobileText = filter !== undefined ? filter : _this.state.text;
|
|
440
|
-
_this.localization = (0, kendo_react_intl_1.provideLocalizationService)(_this);
|
|
441
|
-
var mobileFilter = filterable ? (React.createElement(ListFilter_1.default, { value: mobileText, ref: function (adaptiveFilter) { return _this._adaptiveInput = adaptiveFilter && adaptiveFilter.element; }, onChange: _this.onChangeHandler, onKeyDown: _this.onInputKeyDown, size: _this.props.size, rounded: _this.props.rounded, fillMode: _this.props.fillMode })) : null;
|
|
442
|
-
var actionSheetProps = {
|
|
443
|
-
adaptiveTitle: adaptiveTitle,
|
|
444
|
-
expand: _this.opened,
|
|
445
|
-
onClose: function (event) { return _this.onCancel(event); },
|
|
446
|
-
windowWidth: windowWidth,
|
|
447
|
-
mobileFilter: mobileFilter,
|
|
448
|
-
footer: {
|
|
449
|
-
cancelText: _this.localization.toLanguageString(messages_1.adaptiveModeFooterCancel, messages_1.messages[messages_1.adaptiveModeFooterCancel]),
|
|
450
|
-
onCancel: _this.onCancel,
|
|
451
|
-
applyText: _this.localization.toLanguageString(messages_1.adaptiveModeFooterApply, messages_1.messages[messages_1.adaptiveModeFooterApply]),
|
|
452
|
-
onApply: _this.closePopup
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
return (React.createElement(AdaptiveMode_1.AdaptiveMode, __assign({}, actionSheetProps),
|
|
456
|
-
React.createElement(kendo_react_layout_1.ActionSheetContent, { className: '!k-overflow-hidden' },
|
|
457
|
-
React.createElement("div", { className: 'k-list-container' }, _this.listContainerContent()))));
|
|
458
|
-
};
|
|
459
|
-
_this.closePopup = function (event) {
|
|
460
|
-
var state = _this.base.initState();
|
|
461
|
-
state.syntheticEvent = event;
|
|
462
|
-
event.stopPropagation();
|
|
463
|
-
if (_this.state.focusedIndex !== undefined) {
|
|
464
|
-
state.data.focusedIndex = undefined;
|
|
465
|
-
}
|
|
466
|
-
if (_this.opened) {
|
|
467
|
-
_this.base.togglePopup(state);
|
|
468
|
-
}
|
|
469
|
-
state.events.push({ type: 'onClose' });
|
|
470
|
-
var text = _this.props.filter !== undefined ? _this.props.filter : _this.state.text;
|
|
471
|
-
if ((0, utils_1.isPresent)(text) && text !== '') {
|
|
472
|
-
_this.base.filterChanged('', state);
|
|
473
|
-
}
|
|
474
|
-
if (_this.state.text) {
|
|
475
|
-
state.data.text = '';
|
|
476
|
-
}
|
|
477
|
-
_this.applyState(state);
|
|
478
|
-
};
|
|
479
|
-
_this.onCancel = function (event) {
|
|
480
|
-
var state = _this.base.initState();
|
|
481
|
-
state.syntheticEvent = event;
|
|
482
|
-
event.stopPropagation();
|
|
483
|
-
if (_this.state.focusedIndex !== undefined) {
|
|
484
|
-
state.data.focusedIndex = undefined;
|
|
485
|
-
}
|
|
486
|
-
if (_this.opened) {
|
|
487
|
-
_this.base.togglePopup(state);
|
|
488
|
-
}
|
|
489
|
-
state.events.push({ type: 'onCancel' });
|
|
490
|
-
var text = _this.props.filter !== undefined ? _this.props.filter : _this.state.text;
|
|
491
|
-
if ((0, utils_1.isPresent)(text) && text !== '') {
|
|
492
|
-
_this.base.filterChanged('', state);
|
|
493
|
-
}
|
|
494
|
-
if (_this.state.text) {
|
|
495
|
-
state.data.text = '';
|
|
496
|
-
}
|
|
497
|
-
_this.applyState(state);
|
|
498
|
-
};
|
|
499
|
-
_this.renderList = function () {
|
|
500
|
-
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;
|
|
501
|
-
var vs = _this.base.vs;
|
|
502
|
-
var skip = virtual ? virtual.skip : 0;
|
|
503
|
-
var focusedIndex = _this.getFocusedState().focusedIndex;
|
|
504
|
-
var popupSettings = _this.base.getPopupSettings();
|
|
505
|
-
var translate = "translateY(".concat(vs.translate, "px)");
|
|
506
|
-
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() }));
|
|
507
|
-
};
|
|
508
|
-
_this.onScroll = function (event) {
|
|
509
|
-
var _a = _this.base, vs = _a.vs, list = _a.list;
|
|
510
|
-
vs.scrollHandler(event);
|
|
511
|
-
var groupField = _this.props.groupField;
|
|
512
|
-
var _b = _this.props.data, data = _b === void 0 ? [] : _b;
|
|
513
|
-
if (!groupField || !data.length) {
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
if (groupField) {
|
|
517
|
-
var itemHeight = _this.itemHeight =
|
|
518
|
-
_this.itemHeight || (vs.enabled ? vs.itemHeight : (list ? list.children[0].offsetHeight : 0));
|
|
519
|
-
var target = event.target;
|
|
520
|
-
var scrollTop = target.scrollTop - (vs.skip * itemHeight);
|
|
521
|
-
data = _this.base.getGroupedDataModernMode(data, groupField);
|
|
522
|
-
var group = data[0][groupField];
|
|
523
|
-
for (var i = 1; i < data.length; i++) {
|
|
524
|
-
if (itemHeight * i > scrollTop) {
|
|
525
|
-
break;
|
|
526
|
-
}
|
|
527
|
-
if (data[i] && data[i][groupField]) {
|
|
528
|
-
group = data[i][groupField];
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
if (group !== _this.state.group) {
|
|
532
|
-
_this.setState({
|
|
533
|
-
group: group
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
_this.customItemSelect = function (event) {
|
|
539
|
-
var _a;
|
|
540
|
-
var itemText = _this.props.filter !== undefined ? _this.props.filter : _this.state.text;
|
|
541
|
-
var textField = _this.props.textField;
|
|
542
|
-
if (!itemText) {
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
var state = _this.base.initState();
|
|
546
|
-
state.syntheticEvent = event;
|
|
547
|
-
var item = textField ? (_a = {}, _a[textField] = itemText, _a) : itemText;
|
|
548
|
-
if (_this.state.text !== undefined) {
|
|
549
|
-
state.data.text = '';
|
|
550
|
-
}
|
|
551
|
-
state.data.focusedIndex = undefined;
|
|
552
|
-
_this.base.filterChanged('', state);
|
|
553
|
-
var newItems = __spreadArray(__spreadArray([], _this.value, true), [item], false);
|
|
554
|
-
_this.triggerOnChange(newItems, state);
|
|
555
|
-
_this.base.togglePopup(state);
|
|
556
|
-
_this.applyState(state);
|
|
557
|
-
};
|
|
558
|
-
_this.handleWrapperClick = function (event) {
|
|
559
|
-
var input = _this._input;
|
|
560
|
-
if (!_this.opened && input) {
|
|
561
|
-
_this.focusElement(input);
|
|
562
|
-
}
|
|
563
|
-
var state = _this.base.initState();
|
|
564
|
-
state.syntheticEvent = event;
|
|
565
|
-
if (!_this.state.focused && !_this.mobileMode) {
|
|
566
|
-
state.events.push({ type: 'onFocus' });
|
|
567
|
-
state.data.focused = true;
|
|
568
|
-
}
|
|
569
|
-
if (_this.mobileMode) {
|
|
570
|
-
_this.setState({ currentValue: _this.tagsToRender });
|
|
571
|
-
if (_this.mobileMode) {
|
|
572
|
-
window.setTimeout(function () { return _this._adaptiveInput && _this._adaptiveInput.focus(); }, 300);
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
_this.base.togglePopup(state);
|
|
576
|
-
_this.applyState(state);
|
|
577
|
-
};
|
|
578
|
-
_this.handleItemClick = function (index, event) {
|
|
579
|
-
var state = _this.base.initState();
|
|
580
|
-
state.syntheticEvent = event;
|
|
581
|
-
_this.handleItemSelect(index, state);
|
|
582
|
-
if (_this.props.autoClose && !_this.mobileMode) {
|
|
583
|
-
_this.base.togglePopup(state);
|
|
584
|
-
}
|
|
585
|
-
event.stopPropagation();
|
|
586
|
-
_this.applyState(state);
|
|
587
|
-
};
|
|
588
|
-
_this.handleBlur = function (event) {
|
|
589
|
-
if (!_this.state.focused || _this._skipFocusEvent) {
|
|
590
|
-
return;
|
|
591
|
-
}
|
|
592
|
-
var state = _this.base.initState();
|
|
593
|
-
var _a = _this.props, allowCustom = _a.allowCustom, filterable = _a.filterable;
|
|
594
|
-
state.syntheticEvent = event;
|
|
595
|
-
state.data.focused = false;
|
|
596
|
-
state.events.push({ type: 'onBlur' });
|
|
597
|
-
if (_this.opened && !_this.mobileMode) {
|
|
598
|
-
if (_this.state.opened) {
|
|
599
|
-
state.data.opened = false;
|
|
600
|
-
}
|
|
601
|
-
state.events.push({ type: 'onClose' });
|
|
602
|
-
}
|
|
603
|
-
if (!allowCustom && !filterable && _this.state.text) {
|
|
604
|
-
state.data.text = '';
|
|
605
|
-
}
|
|
606
|
-
_this.applyState(state);
|
|
607
|
-
};
|
|
608
|
-
_this.handleFocus = function (event) {
|
|
609
|
-
if (_this._skipFocusEvent) {
|
|
610
|
-
return;
|
|
611
|
-
}
|
|
612
|
-
_this.base.handleFocus(event);
|
|
613
|
-
};
|
|
614
|
-
_this.onPopupOpened = function () {
|
|
615
|
-
if (_this._input && _this.state.focused && !_this.mobileMode) {
|
|
616
|
-
_this.focusElement(_this._input);
|
|
617
|
-
}
|
|
618
|
-
};
|
|
619
|
-
_this.onPopupClosed = function () {
|
|
620
|
-
if (_this.state.focused) {
|
|
621
|
-
window.setTimeout(function () { if (_this.state.focused) {
|
|
622
|
-
_this.focusElement(_this._input);
|
|
623
|
-
} }, 0);
|
|
624
|
-
}
|
|
625
|
-
};
|
|
626
|
-
_this.setValidity = function () {
|
|
627
|
-
if (_this._input && _this._input.setCustomValidity) {
|
|
628
|
-
_this._input.setCustomValidity(_this.validity.valid
|
|
629
|
-
? ''
|
|
630
|
-
: _this.props.validationMessage || VALIDATION_MESSAGE);
|
|
631
|
-
}
|
|
632
|
-
};
|
|
633
|
-
(0, kendo_react_common_2.validatePackage)(package_metadata_1.packageMetadata);
|
|
634
|
-
return _this;
|
|
635
|
-
}
|
|
636
|
-
Object.defineProperty(MultiSelectWithoutContext.prototype, "document", {
|
|
637
|
-
get: function () {
|
|
638
|
-
if (!kendo_react_common_1.canUseDOM) {
|
|
639
|
-
return;
|
|
640
|
-
}
|
|
641
|
-
// useful only for user actions
|
|
642
|
-
return (this.element && this.element.ownerDocument) || document;
|
|
643
|
-
},
|
|
644
|
-
enumerable: false,
|
|
645
|
-
configurable: true
|
|
646
|
-
});
|
|
647
|
-
Object.defineProperty(MultiSelectWithoutContext.prototype, "element", {
|
|
648
|
-
/** @hidden */
|
|
649
|
-
get: function () {
|
|
650
|
-
return this._element;
|
|
651
|
-
},
|
|
652
|
-
enumerable: false,
|
|
653
|
-
configurable: true
|
|
654
|
-
});
|
|
655
|
-
Object.defineProperty(MultiSelectWithoutContext.prototype, "opened", {
|
|
656
|
-
/** @hidden */
|
|
657
|
-
get: function () {
|
|
658
|
-
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
659
|
-
return !!opened;
|
|
660
|
-
},
|
|
661
|
-
enumerable: false,
|
|
662
|
-
configurable: true
|
|
663
|
-
});
|
|
664
|
-
Object.defineProperty(MultiSelectWithoutContext.prototype, "tagsToRender", {
|
|
665
|
-
/** @hidden */
|
|
666
|
-
get: function () {
|
|
667
|
-
var _a = this.props, tags = _a.tags, textField = _a.textField;
|
|
668
|
-
var tagsToRender = [];
|
|
669
|
-
if (tags === undefined) {
|
|
670
|
-
this.value.forEach(function (item) {
|
|
671
|
-
tagsToRender.push({ text: (0, utils_1.getItemValue)(item, textField), data: [item] });
|
|
672
|
-
});
|
|
673
|
-
}
|
|
674
|
-
else {
|
|
675
|
-
tagsToRender.push.apply(tagsToRender, tags);
|
|
676
|
-
}
|
|
677
|
-
return tagsToRender;
|
|
678
|
-
},
|
|
679
|
-
enumerable: false,
|
|
680
|
-
configurable: true
|
|
681
|
-
});
|
|
682
|
-
Object.defineProperty(MultiSelectWithoutContext.prototype, "mobileMode", {
|
|
683
|
-
/**
|
|
684
|
-
* The mobile mode of the ComboBox.
|
|
685
|
-
*/
|
|
686
|
-
get: function () {
|
|
687
|
-
var isAdaptive = this.state.windowWidth && this.state.windowWidth <= constants_1.MOBILE_MEDIUM_DEVISE && this.props.adaptive;
|
|
688
|
-
return !!isAdaptive;
|
|
689
|
-
},
|
|
690
|
-
enumerable: false,
|
|
691
|
-
configurable: true
|
|
692
|
-
});
|
|
693
|
-
Object.defineProperty(MultiSelectWithoutContext.prototype, "value", {
|
|
694
|
-
/**
|
|
695
|
-
* Represents the value of the MultiSelect.
|
|
696
|
-
*/
|
|
697
|
-
get: function () {
|
|
698
|
-
var result = [];
|
|
699
|
-
if (this._valueItemsDuringOnChange) {
|
|
700
|
-
result.push.apply(result, this._valueItemsDuringOnChange);
|
|
701
|
-
}
|
|
702
|
-
else if (this.props.value) {
|
|
703
|
-
result.push.apply(result, this.props.value);
|
|
704
|
-
}
|
|
705
|
-
else if (this.state.value) {
|
|
706
|
-
result.push.apply(result, this.state.value);
|
|
707
|
-
}
|
|
708
|
-
else if (this.props.defaultValue) {
|
|
709
|
-
result.push.apply(result, this.props.defaultValue);
|
|
710
|
-
}
|
|
711
|
-
return result;
|
|
712
|
-
},
|
|
713
|
-
enumerable: false,
|
|
714
|
-
configurable: true
|
|
715
|
-
});
|
|
716
|
-
Object.defineProperty(MultiSelectWithoutContext.prototype, "name", {
|
|
717
|
-
/**
|
|
718
|
-
* Gets the `name` property of the MultiSelect.
|
|
719
|
-
*/
|
|
720
|
-
get: function () {
|
|
721
|
-
return this.props.name;
|
|
722
|
-
},
|
|
723
|
-
enumerable: false,
|
|
724
|
-
configurable: true
|
|
725
|
-
});
|
|
726
|
-
Object.defineProperty(MultiSelectWithoutContext.prototype, "validity", {
|
|
727
|
-
/**
|
|
728
|
-
* Represents the validity state into which the MultiSelect is set.
|
|
729
|
-
*/
|
|
730
|
-
get: function () {
|
|
731
|
-
var customError = this.props.validationMessage !== undefined;
|
|
732
|
-
var isValid = (!this.required
|
|
733
|
-
|| (this.value !== null && this.value.length > 0 && this.value !== undefined));
|
|
734
|
-
var valid = this.props.valid !== undefined ? this.props.valid : isValid;
|
|
735
|
-
return {
|
|
736
|
-
customError: customError,
|
|
737
|
-
valid: valid,
|
|
738
|
-
valueMissing: this.value === null
|
|
739
|
-
};
|
|
740
|
-
},
|
|
741
|
-
enumerable: false,
|
|
742
|
-
configurable: true
|
|
743
|
-
});
|
|
744
|
-
Object.defineProperty(MultiSelectWithoutContext.prototype, "required", {
|
|
745
|
-
/** @hidden */
|
|
746
|
-
get: function () {
|
|
747
|
-
return this.props.required !== undefined
|
|
748
|
-
? this.props.required
|
|
749
|
-
: MultiSelectWithoutContext.defaultProps.required;
|
|
750
|
-
},
|
|
751
|
-
enumerable: false,
|
|
752
|
-
configurable: true
|
|
753
|
-
});
|
|
754
|
-
Object.defineProperty(MultiSelectWithoutContext.prototype, "validityStyles", {
|
|
755
|
-
get: function () {
|
|
756
|
-
return this.props.validityStyles !== undefined
|
|
757
|
-
? this.props.validityStyles
|
|
758
|
-
: MultiSelectWithoutContext.defaultProps.validityStyles;
|
|
759
|
-
},
|
|
760
|
-
enumerable: false,
|
|
761
|
-
configurable: true
|
|
762
|
-
});
|
|
763
|
-
/** @hidden */
|
|
764
|
-
MultiSelectWithoutContext.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
765
|
-
var _a;
|
|
766
|
-
var _b = this.props, virtual = _b.virtual, _c = _b.groupField, groupField = _c === void 0 ? '' : _c, _d = _b.data, data = _d === void 0 ? [] : _d;
|
|
767
|
-
var skip = virtual ? virtual.skip : 0;
|
|
768
|
-
var prevTotal = prevProps.virtual ? prevProps.virtual.total : 0;
|
|
769
|
-
var prevOpened = prevProps.opened !== undefined ? prevProps.opened : prevState.opened;
|
|
770
|
-
var opening = !prevOpened && this.opened;
|
|
771
|
-
var closing = prevOpened && !this.opened;
|
|
772
|
-
var popupSettings = this.base.getPopupSettings();
|
|
773
|
-
if (!popupSettings.animate && closing) {
|
|
774
|
-
this.onPopupClosed();
|
|
775
|
-
}
|
|
776
|
-
if (virtual && virtual.total !== prevTotal) {
|
|
777
|
-
this.base.vs.calcScrollElementHeight();
|
|
778
|
-
this.base.vs.reset();
|
|
779
|
-
}
|
|
780
|
-
else {
|
|
781
|
-
var _e = this.getFocusedState(), focusedItem = _e.focusedItem, focusedIndex = _e.focusedIndex;
|
|
782
|
-
if (groupField !== '') {
|
|
783
|
-
focusedIndex = (_a = this.base.getGroupedDataModernMode(data, groupField)) === null || _a === void 0 ? void 0 : _a.indexOf(focusedItem);
|
|
784
|
-
}
|
|
785
|
-
if (opening && virtual) {
|
|
786
|
-
this.base.scrollToVirtualItem(virtual, focusedIndex - skip);
|
|
787
|
-
}
|
|
788
|
-
else if (opening && !virtual) {
|
|
789
|
-
// Resets the sticky header group value for scenarios with open/close of component's popup
|
|
790
|
-
if (data && data.length !== 0) {
|
|
791
|
-
this.base.resetGroupStickyHeader(data[0][groupField], this);
|
|
792
|
-
}
|
|
793
|
-
this.base.scrollToItem(focusedIndex);
|
|
794
|
-
}
|
|
795
|
-
else if (this.opened && prevOpened && focusedItem && this.scrollToFocused) {
|
|
796
|
-
this.base.scrollToItem(focusedIndex - skip);
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
this.scrollToFocused = false;
|
|
800
|
-
this.setValidity();
|
|
801
|
-
};
|
|
802
|
-
/** @hidden */
|
|
803
|
-
MultiSelectWithoutContext.prototype.componentDidMount = function () {
|
|
804
|
-
var _a;
|
|
805
|
-
this.observerResize = kendo_react_common_1.canUseDOM && window.ResizeObserver && new window.ResizeObserver(this.calculateMedia.bind(this));
|
|
806
|
-
this.base.didMount();
|
|
807
|
-
this.setValidity();
|
|
808
|
-
if (((_a = this.document) === null || _a === void 0 ? void 0 : _a.body) && this.observerResize) {
|
|
809
|
-
this.observerResize.observe(this.document.body);
|
|
810
|
-
}
|
|
811
|
-
};
|
|
812
|
-
/** @hidden */
|
|
813
|
-
MultiSelectWithoutContext.prototype.componentWillUnmount = function () {
|
|
814
|
-
var _a;
|
|
815
|
-
if (((_a = this.document) === null || _a === void 0 ? void 0 : _a.body) && this.observerResize) {
|
|
816
|
-
this.observerResize.disconnect();
|
|
817
|
-
}
|
|
818
|
-
};
|
|
819
|
-
/** @hidden */
|
|
820
|
-
MultiSelectWithoutContext.prototype.onNavigate = function (state, keyCode, skipItems) {
|
|
821
|
-
var _a = this.props, allowCustom = _a.allowCustom, _b = _a.data, data = _b === void 0 ? [] : _b;
|
|
822
|
-
var text = this.props.filter !== undefined ? this.props.filter : this.state.text;
|
|
823
|
-
var _c = this.getFocusedState(), focusedType = _c.focusedType, focusedIndex = _c.focusedIndex;
|
|
824
|
-
var customItem = allowCustom && text;
|
|
825
|
-
var customItemFocused = isCustom(focusedType);
|
|
826
|
-
var base = this.base;
|
|
827
|
-
var vs = base.vs;
|
|
828
|
-
if (this.opened && keyCode === kendo_react_common_1.Keys.up && customItemFocused) {
|
|
829
|
-
if (this.state.focusedIndex !== undefined) {
|
|
830
|
-
state.data.focusedIndex = undefined;
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
else {
|
|
834
|
-
var newFocused = base.navigation.navigate({
|
|
835
|
-
keyCode: keyCode,
|
|
836
|
-
current: focusedIndex,
|
|
837
|
-
max: (vs.enabled ? vs.total : data.length) - 1,
|
|
838
|
-
min: customItem ? -1 : 0,
|
|
839
|
-
skipItems: skipItems ? skipItems : undefined
|
|
840
|
-
});
|
|
841
|
-
if (newFocused !== undefined) {
|
|
842
|
-
this.itemFocus(newFocused, state);
|
|
843
|
-
this.scrollToFocused = true;
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
this.applyState(state);
|
|
847
|
-
};
|
|
848
|
-
/** @hidden */
|
|
849
|
-
MultiSelectWithoutContext.prototype.render = function () {
|
|
850
|
-
var _a, _b;
|
|
851
|
-
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;
|
|
852
|
-
var _d = this.state, text = _d.text, focused = _d.focused, focusedTag = _d.focusedTag, currentValue = _d.currentValue;
|
|
853
|
-
var vs = this.base.vs;
|
|
854
|
-
var id = this.props.id || this._inputId;
|
|
855
|
-
vs.enabled = virtual !== undefined;
|
|
856
|
-
if (virtual !== undefined) {
|
|
857
|
-
vs.skip = virtual.skip;
|
|
858
|
-
vs.total = virtual.total;
|
|
859
|
-
vs.pageSize = virtual.pageSize;
|
|
860
|
-
}
|
|
861
|
-
var currentTagsToRender = (this.mobileMode && this.opened) ? currentValue : this.tagsToRender;
|
|
862
|
-
this.setItems(this.tagsToRender, this._tags);
|
|
863
|
-
var isValid = !this.validityStyles || this.validity.valid;
|
|
864
|
-
var clearButton = Boolean(filter !== undefined ? filter : text)
|
|
865
|
-
|| (currentTagsToRender && currentTagsToRender.length > 0);
|
|
866
|
-
var component = (React.createElement(React.Fragment, null,
|
|
867
|
-
React.createElement("div", { ref: this.componentRef, className: (0, kendo_react_common_1.classNames)('k-multiselect k-input', className, (_a = {},
|
|
868
|
-
_a["k-input-".concat(sizeMap[size] || size)] = size,
|
|
869
|
-
_a["k-rounded-".concat(roundedMap[rounded] || rounded)] = rounded,
|
|
870
|
-
_a["k-input-".concat(fillMode)] = fillMode,
|
|
871
|
-
_a['k-focus'] = focused && !disabled,
|
|
872
|
-
_a['k-invalid'] = !isValid,
|
|
873
|
-
_a['k-disabled'] = disabled,
|
|
874
|
-
_a['k-loading'] = loading,
|
|
875
|
-
_a['k-required'] = this.required,
|
|
876
|
-
_a)), style: !label
|
|
877
|
-
? style
|
|
878
|
-
: __assign(__assign({}, style), { width: undefined }), dir: dir, onFocus: this.handleFocus, onBlur: this.handleBlur, onClick: this.handleWrapperClick, onMouseDown: utils_1.preventDefaultNonInputs },
|
|
879
|
-
React.createElement("div", { className: (0, kendo_react_common_1.classNames)('k-input-values') },
|
|
880
|
-
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 })),
|
|
881
|
-
this.renderSearchBar(id)),
|
|
882
|
-
loading && React.createElement(kendo_react_common_1.IconWrap, { className: "k-input-loading-icon", name: 'loading' }),
|
|
883
|
-
clearButton && React.createElement(ClearButton_1.default, { onClick: this.clearButtonClick }),
|
|
884
|
-
!this.mobileMode && this.renderListContainer()),
|
|
885
|
-
this.mobileMode && this.renderAdaptiveListContainer()));
|
|
886
|
-
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;
|
|
887
|
-
};
|
|
888
|
-
MultiSelectWithoutContext.prototype.renderSearchBar = function (id) {
|
|
889
|
-
var _a = this.state, activedescendant = _a.activedescendant, focusedTag = _a.focusedTag, currentValue = _a.currentValue;
|
|
890
|
-
var _b = this.props, disabled = _b.disabled, placeholder = _b.placeholder, ariaDescribedBy = _b.ariaDescribedBy;
|
|
891
|
-
var text = !this.mobileMode && (this.props.filter !== undefined ? this.props.filter : this.state.text) || '';
|
|
892
|
-
var focusedIndex = this.getFocusedState().focusedIndex;
|
|
893
|
-
var placeholderToShow = this.value.length === 0 && !text ? placeholder : undefined;
|
|
894
|
-
var adaptivePlaceholder = (currentValue && currentValue.length > 0) ? undefined : placeholder;
|
|
895
|
-
var ariaActivedescendant = activedescendant === settings_1.ActiveDescendant.TagsList && focusedTag !== undefined ?
|
|
896
|
-
"tag-".concat(this.base.guid, "-").concat(focusedTag.text.replace(/\s+/g, '-')) :
|
|
897
|
-
"option-".concat(this.base.guid, "-").concat(focusedIndex);
|
|
898
|
-
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 }));
|
|
899
|
-
};
|
|
900
|
-
MultiSelectWithoutContext.prototype.onTagsNavigate = function (event, state) {
|
|
901
|
-
var keyCode = event.keyCode;
|
|
902
|
-
var focusedTag = this.state.focusedTag;
|
|
903
|
-
var tags = this._tags;
|
|
904
|
-
var itemsKey = this.props.dataItemKey;
|
|
905
|
-
var focusedIndex = focusedTag ?
|
|
906
|
-
tags.findIndex(function (t) { return (0, utils_1.matchTags)(t, focusedTag, itemsKey); }) : -1;
|
|
907
|
-
var newFocusedTag = undefined;
|
|
908
|
-
var hasFocused = focusedIndex !== -1;
|
|
909
|
-
if (keyCode === kendo_react_common_1.Keys.left) {
|
|
910
|
-
if (hasFocused) {
|
|
911
|
-
focusedIndex = Math.max(0, focusedIndex - 1);
|
|
912
|
-
}
|
|
913
|
-
else {
|
|
914
|
-
focusedIndex = tags.length - 1;
|
|
915
|
-
}
|
|
916
|
-
newFocusedTag = tags[focusedIndex];
|
|
917
|
-
}
|
|
918
|
-
else if (keyCode === kendo_react_common_1.Keys.right) {
|
|
919
|
-
if (focusedIndex === tags.length - 1) {
|
|
920
|
-
newFocusedTag = undefined;
|
|
921
|
-
}
|
|
922
|
-
else if (hasFocused) {
|
|
923
|
-
focusedIndex = Math.min(tags.length - 1, focusedIndex + 1);
|
|
924
|
-
newFocusedTag = tags[focusedIndex];
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
else if (keyCode === kendo_react_common_1.Keys.home && !event.shiftKey) {
|
|
928
|
-
newFocusedTag = tags[0];
|
|
929
|
-
}
|
|
930
|
-
else if (keyCode === kendo_react_common_1.Keys.end && !event.shiftKey) {
|
|
931
|
-
newFocusedTag = tags[tags.length - 1];
|
|
932
|
-
}
|
|
933
|
-
else if (keyCode === kendo_react_common_1.Keys.delete) {
|
|
934
|
-
if (hasFocused) {
|
|
935
|
-
var items = this.value;
|
|
936
|
-
(0, utils_1.removeDataItems)(items, tags[focusedIndex].data, itemsKey);
|
|
937
|
-
this.triggerOnChange(items, state);
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
else if (keyCode === kendo_react_common_1.Keys.backspace) {
|
|
941
|
-
var items = this.value;
|
|
942
|
-
if (hasFocused) {
|
|
943
|
-
(0, utils_1.removeDataItems)(items, tags[focusedIndex].data, itemsKey);
|
|
944
|
-
this.triggerOnChange(items, state);
|
|
945
|
-
}
|
|
946
|
-
else if (!hasFocused && tags.length) {
|
|
947
|
-
var removed = tags.pop();
|
|
948
|
-
(0, utils_1.removeDataItems)(items, removed.data, itemsKey);
|
|
949
|
-
this.triggerOnChange(items, state);
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
if (newFocusedTag !== focusedTag) {
|
|
953
|
-
state.data.focusedTag = newFocusedTag;
|
|
954
|
-
state.data.activedescendant = settings_1.ActiveDescendant.TagsList;
|
|
955
|
-
}
|
|
956
|
-
this.applyState(state);
|
|
957
|
-
};
|
|
958
|
-
MultiSelectWithoutContext.prototype.triggerOnChange = function (items, state) {
|
|
959
|
-
if (this.props.value === undefined) {
|
|
960
|
-
state.data.value = __spreadArray([], items, true);
|
|
961
|
-
}
|
|
962
|
-
this._valueItemsDuringOnChange = [];
|
|
963
|
-
this.setItems(items, this._valueItemsDuringOnChange);
|
|
964
|
-
state.events.push({ type: 'onChange' });
|
|
965
|
-
};
|
|
966
|
-
MultiSelectWithoutContext.prototype.selectFocusedItem = function (event, itemtoSelect) {
|
|
967
|
-
var _a = this.props, _b = _a.data, data = _b === void 0 ? [] : _b, virtual = _a.virtual;
|
|
968
|
-
var focusedIndex = (itemtoSelect || this.getFocusedState()).focusedIndex;
|
|
969
|
-
var skip = virtual ? virtual.skip : 0;
|
|
970
|
-
if (data[focusedIndex - skip] !== undefined) {
|
|
971
|
-
this.handleItemClick(focusedIndex, event);
|
|
972
|
-
}
|
|
973
|
-
};
|
|
974
|
-
MultiSelectWithoutContext.prototype.setItems = function (srcItems, destItems) {
|
|
975
|
-
destItems.length = 0;
|
|
976
|
-
destItems.push.apply(destItems, srcItems);
|
|
977
|
-
};
|
|
978
|
-
MultiSelectWithoutContext.prototype.getFocusedState = function () {
|
|
979
|
-
var focusedIndex = this.state.focusedIndex;
|
|
980
|
-
var text = this.props.filter !== undefined ? this.props.filter : this.state.text;
|
|
981
|
-
var _a = this.props, allowCustom = _a.allowCustom, _b = _a.data, data = _b === void 0 ? [] : _b, dataItemKey = _a.dataItemKey, virtual = _a.virtual, textField = _a.textField, _c = _a.focusedItemIndex, focusedItemIndex = _c === void 0 ? utils_1.itemIndexStartsWith : _c, skipDisabledItems = _a.skipDisabledItems;
|
|
982
|
-
var skip = (virtual && virtual.skip) || 0;
|
|
983
|
-
var focusedInd;
|
|
984
|
-
if (focusedIndex !== undefined) {
|
|
985
|
-
return {
|
|
986
|
-
focusedIndex: focusedIndex,
|
|
987
|
-
focusedItem: data[focusedIndex - skip],
|
|
988
|
-
focusedType: FocusedItemType.ListItem
|
|
989
|
-
};
|
|
990
|
-
}
|
|
991
|
-
var selected = this.value;
|
|
992
|
-
if (allowCustom && text) {
|
|
993
|
-
return { focusedItem: null, focusedIndex: -1, focusedType: FocusedItemType.CustomItem };
|
|
994
|
-
}
|
|
995
|
-
else if (text) {
|
|
996
|
-
focusedInd = focusedItemIndex(data, text, textField);
|
|
997
|
-
return {
|
|
998
|
-
focusedItem: data[focusedInd],
|
|
999
|
-
focusedIndex: focusedInd + skip,
|
|
1000
|
-
focusedType: FocusedItemType.ListItem
|
|
1001
|
-
};
|
|
1002
|
-
}
|
|
1003
|
-
else if (selected.length) {
|
|
1004
|
-
var last_1 = selected[selected.length - 1];
|
|
1005
|
-
focusedInd = data.findIndex(function (i) { return (0, utils_1.areSame)(i, last_1, dataItemKey); });
|
|
1006
|
-
if (data[focusedInd] !== undefined) {
|
|
1007
|
-
return {
|
|
1008
|
-
focusedIndex: focusedInd + skip,
|
|
1009
|
-
focusedItem: data[focusedInd],
|
|
1010
|
-
focusedType: FocusedItemType.ListItem
|
|
1011
|
-
};
|
|
1012
|
-
}
|
|
1013
|
-
return { focusedType: FocusedItemType.None, focusedIndex: -1 };
|
|
1014
|
-
}
|
|
1015
|
-
else if (skipDisabledItems && textField && !text && skip === 0) {
|
|
1016
|
-
var newIndex = data.findIndex(function (i) { return !i.disabled && i[textField]; });
|
|
1017
|
-
return {
|
|
1018
|
-
focusedIndex: newIndex,
|
|
1019
|
-
focusedItem: data[newIndex - skip],
|
|
1020
|
-
focusedType: FocusedItemType.ListItem
|
|
1021
|
-
};
|
|
1022
|
-
}
|
|
1023
|
-
return skip === 0 ?
|
|
1024
|
-
{ focusedItem: data[0], focusedIndex: 0, focusedType: FocusedItemType.ListItem } :
|
|
1025
|
-
{ focusedType: FocusedItemType.None, focusedIndex: -1 };
|
|
1026
|
-
};
|
|
1027
|
-
MultiSelectWithoutContext.prototype.focusElement = function (element) {
|
|
1028
|
-
var _this = this;
|
|
1029
|
-
this._skipFocusEvent = true;
|
|
1030
|
-
element.focus();
|
|
1031
|
-
window.setTimeout(function () { return _this._skipFocusEvent = false; }, 0);
|
|
1032
|
-
};
|
|
1033
|
-
MultiSelectWithoutContext.prototype.applyState = function (state) {
|
|
1034
|
-
this.base.applyState(state);
|
|
1035
|
-
this._valueItemsDuringOnChange = null;
|
|
1036
|
-
};
|
|
1037
|
-
MultiSelectWithoutContext.prototype.calculateMedia = function (entries) {
|
|
1038
|
-
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
1039
|
-
var entry = entries_1[_i];
|
|
1040
|
-
this.setState({ windowWidth: entry.target.clientWidth });
|
|
1041
|
-
}
|
|
1042
|
-
;
|
|
1043
|
-
};
|
|
1044
|
-
;
|
|
1045
|
-
/**
|
|
1046
|
-
* Updates the state of the MultiSelect when the complex keyboard navigation that
|
|
1047
|
-
* includes key combinations with the Ctrl/Command, Shift, Home and End keys
|
|
1048
|
-
*
|
|
1049
|
-
* @param {Array<string | Object>} dataToSet Defines the array of new values that will be applied to the MultiSelect
|
|
1050
|
-
* @param {MultiSelectInternalState} state The current state of the MultiSelect
|
|
1051
|
-
*/
|
|
1052
|
-
MultiSelectWithoutContext.prototype.updateStateOnKeyboardNavigation = function (dataToSet, state) {
|
|
1053
|
-
this.setState({ value: dataToSet });
|
|
1054
|
-
this.triggerOnChange(dataToSet, state);
|
|
1055
|
-
this.applyState(state);
|
|
1056
|
-
};
|
|
1057
|
-
/**
|
|
1058
|
-
* Returns the last element that was selected or deselected. Needed for the keyboard navigation specifications
|
|
1059
|
-
*
|
|
1060
|
-
* @param {number} correction A correction is needed depending on if UP or DOWN key is pressed
|
|
1061
|
-
*/
|
|
1062
|
-
MultiSelectWithoutContext.prototype.getLastSelectedOrDeselectedIndex = function (correction, focusedIndex) {
|
|
1063
|
-
if (this._lastSelectedOrDeslectedItemIndex === null) {
|
|
1064
|
-
this._lastSelectedOrDeslectedItemIndex = focusedIndex;
|
|
1065
|
-
}
|
|
1066
|
-
return this._lastSelectedOrDeslectedItemIndex !== null ? this._lastSelectedOrDeslectedItemIndex + correction : null;
|
|
1067
|
-
};
|
|
1068
|
-
MultiSelectWithoutContext.displayName = 'MultiSelect';
|
|
1069
|
-
/** @hidden */
|
|
1070
|
-
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({
|
|
1071
|
-
text: PropTypes.string,
|
|
1072
|
-
data: PropTypes.arrayOf(PropTypes.any)
|
|
1073
|
-
})), 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, skipDisabledItems: PropTypes.bool });
|
|
1074
|
-
/** @hidden */
|
|
1075
|
-
MultiSelectWithoutContext.defaultProps = __assign(__assign({}, DropDownBase_1.default.defaultProps), { autoClose: true, required: false, size: 'medium', rounded: 'medium', fillMode: 'solid', groupMode: 'modern', skipDisabledItems: true });
|
|
1076
|
-
return MultiSelectWithoutContext;
|
|
1077
|
-
}(React.Component));
|
|
1078
|
-
exports.MultiSelectWithoutContext = MultiSelectWithoutContext;
|
|
1079
|
-
/**
|
|
1080
|
-
* Represents the PropsContext of the `MultiSelect` component.
|
|
1081
|
-
* Used for global configuration of all `MultiSelect` instances.
|
|
1082
|
-
*
|
|
1083
|
-
* For more information, refer to the [Dropdowns Props Context]({% slug props-context_dropdowns %}) article.
|
|
1084
|
-
*/
|
|
1085
|
-
exports.MultiSelectPropsContext = (0, kendo_react_common_1.createPropsContext)();
|
|
1086
|
-
/* eslint-disable @typescript-eslint/no-redeclare -- intentionally naming the component the same as the type */
|
|
1087
|
-
/**
|
|
1088
|
-
* Represents the [KendoReact MultiSelect component]({% slug overview_multiselect %}).
|
|
1089
|
-
*
|
|
1090
|
-
* Accepts properties of type [MultiSelectProps]({% slug api_dropdowns_multiselectprops %}).
|
|
1091
|
-
* Obtaining the `ref` returns an object of type [MultiSelectHandle]({% slug api_dropdowns_multiselecthandle %}).
|
|
1092
|
-
*
|
|
1093
|
-
* @example
|
|
1094
|
-
* ```jsx
|
|
1095
|
-
* class App extends React.Component {
|
|
1096
|
-
* multiselect = null;
|
|
1097
|
-
* render() {
|
|
1098
|
-
* return (
|
|
1099
|
-
* <div>
|
|
1100
|
-
* <MultiSelect
|
|
1101
|
-
* data={[ "Albania", "Andorra", "Austria", "Belarus" ]}
|
|
1102
|
-
* ref={component => this.multiselect = component}
|
|
1103
|
-
* />
|
|
1104
|
-
* <button onClick={() => alert(this.multiselect.value)}>alert value</button>
|
|
1105
|
-
* </div>
|
|
1106
|
-
* );
|
|
1107
|
-
* }
|
|
1108
|
-
* }
|
|
1109
|
-
* ReactDOM.render(<App />, document.querySelector('my-app'));
|
|
1110
|
-
* ```
|
|
1111
|
-
*/
|
|
1112
|
-
exports.MultiSelect = (0, kendo_react_common_1.withPropsContext)(exports.MultiSelectPropsContext, MultiSelectWithoutContext);
|
|
1113
|
-
exports.MultiSelect.displayName = 'KendoReactMultiSelect';
|