@progress/kendo-react-dropdowns 5.17.0-dev.202308081122 → 5.17.0-dev.202308091121
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/AutoComplete/AutoComplete.d.ts +5 -7
- package/dist/es/AutoComplete/AutoComplete.js +95 -13
- package/dist/es/AutoComplete/AutoCompleteProps.d.ts +4 -0
- package/dist/es/ComboBox/ComboBox.d.ts +7 -1
- package/dist/es/ComboBox/ComboBox.js +137 -23
- package/dist/es/ComboBox/ComboBoxProps.d.ts +4 -0
- package/dist/es/DropDownList/DropDownList.d.ts +5 -5
- package/dist/es/DropDownList/DropDownList.js +128 -22
- package/dist/es/DropDownList/DropDownListProps.d.ts +4 -0
- package/dist/es/MultiColumnComboBox/MultiColumnComboBox.js +2 -1
- package/dist/es/MultiSelect/MultiSelect.d.ts +3 -1
- package/dist/es/MultiSelect/MultiSelect.js +80 -9
- package/dist/es/MultiSelect/MultiSelectProps.d.ts +4 -0
- package/dist/es/common/List.js +2 -2
- package/dist/es/common/ListItem.d.ts +4 -0
- package/dist/es/common/ListItem.js +4 -3
- package/dist/es/common/Navigation.d.ts +1 -0
- package/dist/es/common/Navigation.js +2 -2
- package/dist/es/package-metadata.js +1 -1
- package/dist/npm/AutoComplete/AutoComplete.d.ts +5 -7
- package/dist/npm/AutoComplete/AutoComplete.js +95 -13
- package/dist/npm/AutoComplete/AutoCompleteProps.d.ts +4 -0
- package/dist/npm/ComboBox/ComboBox.d.ts +7 -1
- package/dist/npm/ComboBox/ComboBox.js +137 -23
- package/dist/npm/ComboBox/ComboBoxProps.d.ts +4 -0
- package/dist/npm/DropDownList/DropDownList.d.ts +5 -5
- package/dist/npm/DropDownList/DropDownList.js +127 -21
- package/dist/npm/DropDownList/DropDownListProps.d.ts +4 -0
- package/dist/npm/MultiColumnComboBox/MultiColumnComboBox.js +2 -1
- package/dist/npm/MultiSelect/MultiSelect.d.ts +3 -1
- package/dist/npm/MultiSelect/MultiSelect.js +80 -9
- package/dist/npm/MultiSelect/MultiSelectProps.d.ts +4 -0
- package/dist/npm/common/List.js +2 -2
- package/dist/npm/common/ListItem.d.ts +4 -0
- package/dist/npm/common/ListItem.js +4 -3
- package/dist/npm/common/Navigation.d.ts +1 -0
- package/dist/npm/common/Navigation.js +2 -2
- package/dist/npm/package-metadata.js +1 -1
- package/dist/systemjs/kendo-react-dropdowns.js +1 -1
- package/package.json +16 -16
|
@@ -41,6 +41,7 @@ export declare class AutoCompleteWithoutContext extends React.Component<AutoComp
|
|
|
41
41
|
ariaLabelledBy: PropTypes.Requireable<string>;
|
|
42
42
|
ariaDescribedBy: PropTypes.Requireable<string>;
|
|
43
43
|
list: PropTypes.Requireable<any>;
|
|
44
|
+
skipDisabledItems: PropTypes.Requireable<boolean>;
|
|
44
45
|
opened: PropTypes.Requireable<boolean>;
|
|
45
46
|
disabled: PropTypes.Requireable<boolean>;
|
|
46
47
|
dir: PropTypes.Requireable<string>;
|
|
@@ -59,9 +60,7 @@ export declare class AutoCompleteWithoutContext extends React.Component<AutoComp
|
|
|
59
60
|
popupClass: PropTypes.Requireable<string>;
|
|
60
61
|
className: PropTypes.Requireable<string>;
|
|
61
62
|
appendTo: PropTypes.Requireable<any>;
|
|
62
|
-
width: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
63
|
-
* @hidden
|
|
64
|
-
*/
|
|
63
|
+
width: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
65
64
|
height: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
66
65
|
}>>;
|
|
67
66
|
onOpen: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -82,13 +81,12 @@ export declare class AutoCompleteWithoutContext extends React.Component<AutoComp
|
|
|
82
81
|
size: "small" | "medium" | "large" | null | undefined;
|
|
83
82
|
rounded: "small" | "medium" | "full" | "large" | null | undefined;
|
|
84
83
|
fillMode: "flat" | "outline" | "solid" | null | undefined;
|
|
84
|
+
skipDisabledItems: boolean;
|
|
85
85
|
popupSettings: {
|
|
86
86
|
height: string;
|
|
87
87
|
};
|
|
88
88
|
required: boolean;
|
|
89
|
-
validityStyles: boolean;
|
|
90
|
-
* The value of the AutoComplete.
|
|
91
|
-
*/
|
|
89
|
+
validityStyles: boolean;
|
|
92
90
|
};
|
|
93
91
|
/**
|
|
94
92
|
* @hidden
|
|
@@ -158,7 +156,7 @@ export declare class AutoCompleteWithoutContext extends React.Component<AutoComp
|
|
|
158
156
|
/**
|
|
159
157
|
* @hidden
|
|
160
158
|
*/
|
|
161
|
-
onNavigate(state: AutoCompleteInternalState, keyCode: number): void;
|
|
159
|
+
onNavigate(state: AutoCompleteInternalState, keyCode: number, skipItems?: number): void;
|
|
162
160
|
/**
|
|
163
161
|
* @hidden
|
|
164
162
|
*/
|
|
@@ -183,9 +183,12 @@ var AutoCompleteWithoutContext = /** @class */ (function (_super) {
|
|
|
183
183
|
_this.applyState(state);
|
|
184
184
|
};
|
|
185
185
|
_this.onInputKeyDown = function (event) {
|
|
186
|
+
var _a = _this.props, _b = _a.data, data = _b === void 0 ? [] : _b, skipDisabledItems = _a.skipDisabledItems, groupField = _a.groupField, textField = _a.textField;
|
|
186
187
|
if (_this._isScrolling) {
|
|
187
188
|
_this._isScrolling = false;
|
|
188
189
|
}
|
|
190
|
+
var focusedIndex = _this.focusedIndex();
|
|
191
|
+
var focusedItem = data[focusedIndex];
|
|
189
192
|
var keyCode = event.keyCode;
|
|
190
193
|
var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
|
|
191
194
|
var state = _this.base.initState();
|
|
@@ -197,11 +200,76 @@ var AutoCompleteWithoutContext = /** @class */ (function (_super) {
|
|
|
197
200
|
};
|
|
198
201
|
if (keyCode === Keys.enter || keyCode === Keys.esc) {
|
|
199
202
|
preventDefault();
|
|
200
|
-
|
|
203
|
+
if (skipDisabledItems === false && focusedItem.disabled) {
|
|
204
|
+
if (opened) {
|
|
205
|
+
_this.togglePopup(state);
|
|
206
|
+
}
|
|
207
|
+
_this.applyState(state);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
_this.applyInputValue(event.currentTarget.value, state, event.keyCode);
|
|
211
|
+
}
|
|
201
212
|
}
|
|
202
213
|
else if (keyCode === Keys.up || keyCode === Keys.down) {
|
|
214
|
+
if (groupField !== '' && textField) {
|
|
215
|
+
if (!_this.props.skipDisabledItems && opened) {
|
|
216
|
+
_this.onNavigate(state, keyCode);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
var newIndex = 0;
|
|
220
|
+
if (keyCode === Keys.down || keyCode === Keys.right) {
|
|
221
|
+
var tempnewIndex_1 = data.slice(focusedIndex + 1).find(function (i) { return !i.disabled && i[textField]; });
|
|
222
|
+
newIndex = tempnewIndex_1 && data.findIndex(function (el) { return el[textField] === tempnewIndex_1[textField]; });
|
|
223
|
+
}
|
|
224
|
+
else if (keyCode === Keys.up || keyCode === Keys.left) {
|
|
225
|
+
var dataToSearch = void 0;
|
|
226
|
+
if (focusedIndex === -1) {
|
|
227
|
+
dataToSearch = data;
|
|
228
|
+
newIndex = data.findIndex(function (i) { return !i.disabled && i[textField]; });
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
dataToSearch = data.slice(0, focusedIndex);
|
|
232
|
+
var tempnewIndex_2 = dataToSearch.pop();
|
|
233
|
+
while (tempnewIndex_2 && tempnewIndex_2.disabled) {
|
|
234
|
+
tempnewIndex_2 = dataToSearch.pop();
|
|
235
|
+
}
|
|
236
|
+
newIndex = tempnewIndex_2 && data.findIndex(function (el) { return el[textField] === tempnewIndex_2[textField]; });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (newIndex !== undefined) {
|
|
240
|
+
var skipItems = newIndex - focusedIndex;
|
|
241
|
+
_this.onNavigate(state, keyCode, skipItems);
|
|
242
|
+
}
|
|
243
|
+
else if (newIndex === undefined && data.findIndex(function (el) { return el[textField]; }) === data.length - 1) {
|
|
244
|
+
_this.onNavigate(state, keyCode);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
else if (!_this.props.skipDisabledItems && opened) {
|
|
249
|
+
_this.onNavigate(state, keyCode);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
var newIndex = null;
|
|
253
|
+
if (keyCode === Keys.down || keyCode === Keys.right) {
|
|
254
|
+
newIndex = data.slice(focusedIndex + 1).find(function (i) { return !i.disabled; });
|
|
255
|
+
}
|
|
256
|
+
else if (keyCode === Keys.up || keyCode === Keys.left) {
|
|
257
|
+
var dataTest = data.slice(0, focusedIndex);
|
|
258
|
+
newIndex = dataTest.pop();
|
|
259
|
+
while (newIndex && newIndex.disabled) {
|
|
260
|
+
newIndex = dataTest.pop();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (newIndex) {
|
|
264
|
+
var skipItems = newIndex.id - focusedIndex - 1;
|
|
265
|
+
_this.onNavigate(state, keyCode, skipItems);
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
_this.onNavigate(state, keyCode);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
_this.applyState(state);
|
|
203
272
|
preventDefault();
|
|
204
|
-
_this.onNavigate(state, keyCode);
|
|
205
273
|
}
|
|
206
274
|
};
|
|
207
275
|
_this.handleBlur = function (event) {
|
|
@@ -383,7 +451,7 @@ var AutoCompleteWithoutContext = /** @class */ (function (_super) {
|
|
|
383
451
|
/**
|
|
384
452
|
* @hidden
|
|
385
453
|
*/
|
|
386
|
-
AutoCompleteWithoutContext.prototype.onNavigate = function (state, keyCode) {
|
|
454
|
+
AutoCompleteWithoutContext.prototype.onNavigate = function (state, keyCode, skipItems) {
|
|
387
455
|
var _this = this;
|
|
388
456
|
var typedText = this.value;
|
|
389
457
|
var _a = this.props, _b = _a.data, data = _b === void 0 ? [] : _b, textField = _a.textField, focusedItemIndex = _a.focusedItemIndex;
|
|
@@ -395,7 +463,8 @@ var AutoCompleteWithoutContext = /** @class */ (function (_super) {
|
|
|
395
463
|
keyCode: keyCode,
|
|
396
464
|
current: focusedIndex,
|
|
397
465
|
max: data.length - 1,
|
|
398
|
-
min: 0
|
|
466
|
+
min: 0,
|
|
467
|
+
skipItems: skipItems ? skipItems : undefined
|
|
399
468
|
});
|
|
400
469
|
if (newFocused !== undefined) {
|
|
401
470
|
this.itemFocus(newFocused, state);
|
|
@@ -408,10 +477,14 @@ var AutoCompleteWithoutContext = /** @class */ (function (_super) {
|
|
|
408
477
|
AutoCompleteWithoutContext.prototype.applyInputValue = function (value, state, eventKey) {
|
|
409
478
|
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
410
479
|
var _a = this.props, _b = _a.data, data = _b === void 0 ? [] : _b, textField = _a.textField;
|
|
480
|
+
var focusedIndex = this.focusedIndex();
|
|
481
|
+
var focusedItem = data[focusedIndex];
|
|
411
482
|
this._suggested = '';
|
|
412
483
|
if (opened && eventKey === Keys.enter) {
|
|
413
|
-
|
|
414
|
-
|
|
484
|
+
if (!focusedItem.disabled) {
|
|
485
|
+
var newValue = getItemValue(data[this.focusedIndex(value)], textField);
|
|
486
|
+
this.triggerOnChange(newValue, state);
|
|
487
|
+
}
|
|
415
488
|
}
|
|
416
489
|
if (opened) {
|
|
417
490
|
this.togglePopup(state);
|
|
@@ -488,22 +561,31 @@ var AutoCompleteWithoutContext = /** @class */ (function (_super) {
|
|
|
488
561
|
};
|
|
489
562
|
AutoCompleteWithoutContext.prototype.focusedIndex = function (value) {
|
|
490
563
|
var _this = this;
|
|
491
|
-
var _a = this.props, _b = _a.data, data = _b === void 0 ? [] : _b, textField = _a.textField, focusedItemIndex = _a.focusedItemIndex;
|
|
564
|
+
var _a = this.props, _b = _a.data, data = _b === void 0 ? [] : _b, textField = _a.textField, focusedItemIndex = _a.focusedItemIndex, skipDisabledItems = _a.skipDisabledItems;
|
|
492
565
|
var inputValue = value !== undefined ? value : this.value;
|
|
493
|
-
|
|
494
|
-
data.findIndex(function (i) { return areSame(i, _this.state.focusedItem, textField); })
|
|
495
|
-
|
|
496
|
-
|
|
566
|
+
if (this.state.focusedItem !== undefined) {
|
|
567
|
+
return data.findIndex(function (i) { return areSame(i, _this.state.focusedItem, textField); });
|
|
568
|
+
}
|
|
569
|
+
else if (focusedItemIndex) {
|
|
570
|
+
return focusedItemIndex(data, inputValue, textField);
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
var indexOfFocusedItem = data.indexOf(getFocusedItem(data, inputValue, textField));
|
|
574
|
+
if (skipDisabledItems && textField && indexOfFocusedItem === -1) {
|
|
575
|
+
return data.findIndex(function (i) { return !i.disabled && i[textField]; });
|
|
576
|
+
}
|
|
577
|
+
return Math.max(0, indexOfFocusedItem);
|
|
578
|
+
}
|
|
497
579
|
};
|
|
498
580
|
AutoCompleteWithoutContext.displayName = 'AutoComplete';
|
|
499
581
|
/**
|
|
500
582
|
* @hidden
|
|
501
583
|
*/
|
|
502
|
-
AutoCompleteWithoutContext.propTypes = __assign(__assign({}, DropDownBase.basicPropTypes), { size: PropTypes.oneOf([null, 'small', 'medium', 'large']), rounded: PropTypes.oneOf([null, 'small', 'medium', 'large', 'full']), fillMode: PropTypes.oneOf([null, 'solid', 'flat', 'outline']), groupField: PropTypes.string, suggest: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]), placeholder: PropTypes.string, value: PropTypes.string, defaultValue: PropTypes.string, validationMessage: PropTypes.string, required: PropTypes.bool, readonly: PropTypes.bool, clearButton: PropTypes.bool, valueRender: PropTypes.func, id: PropTypes.string, ariaLabelledBy: PropTypes.string, ariaDescribedBy: PropTypes.string, list: PropTypes.any });
|
|
584
|
+
AutoCompleteWithoutContext.propTypes = __assign(__assign({}, DropDownBase.basicPropTypes), { size: PropTypes.oneOf([null, 'small', 'medium', 'large']), rounded: PropTypes.oneOf([null, 'small', 'medium', 'large', 'full']), fillMode: PropTypes.oneOf([null, 'solid', 'flat', 'outline']), groupField: PropTypes.string, suggest: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]), placeholder: PropTypes.string, value: PropTypes.string, defaultValue: PropTypes.string, validationMessage: PropTypes.string, required: PropTypes.bool, readonly: PropTypes.bool, clearButton: PropTypes.bool, valueRender: PropTypes.func, id: PropTypes.string, ariaLabelledBy: PropTypes.string, ariaDescribedBy: PropTypes.string, list: PropTypes.any, skipDisabledItems: PropTypes.bool });
|
|
503
585
|
/**
|
|
504
586
|
* @hidden
|
|
505
587
|
*/
|
|
506
|
-
AutoCompleteWithoutContext.defaultProps = __assign(__assign({}, DropDownBase.defaultProps), { size: 'medium', rounded: 'medium', fillMode: 'solid' });
|
|
588
|
+
AutoCompleteWithoutContext.defaultProps = __assign(__assign({}, DropDownBase.defaultProps), { size: 'medium', rounded: 'medium', fillMode: 'solid', skipDisabledItems: true });
|
|
507
589
|
return AutoCompleteWithoutContext;
|
|
508
590
|
}(React.Component));
|
|
509
591
|
export { AutoCompleteWithoutContext };
|
|
@@ -236,4 +236,8 @@ export interface AutoCompleteProps extends FormComponentProps {
|
|
|
236
236
|
* Sets the key for comparing the data items of the AutoComplete. If `dataItemKey` is not set, the AutoComplete compares the items by reference.
|
|
237
237
|
*/
|
|
238
238
|
dataItemKey?: string;
|
|
239
|
+
/**
|
|
240
|
+
* Defines if AutoComplete's disabled items will be skipped or focused when navigating through the list of items using a keyboard. Defaults to `true`.
|
|
241
|
+
*/
|
|
242
|
+
skipDisabledItems?: boolean;
|
|
239
243
|
}
|
|
@@ -45,6 +45,7 @@ export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProp
|
|
|
45
45
|
ariaDescribedBy: PropTypes.Requireable<string>;
|
|
46
46
|
list: PropTypes.Requireable<any>;
|
|
47
47
|
valueRender: PropTypes.Requireable<(...args: any[]) => any>;
|
|
48
|
+
skipDisabledItems: PropTypes.Requireable<boolean>;
|
|
48
49
|
value: PropTypes.Requireable<any>;
|
|
49
50
|
defaultValue: PropTypes.Requireable<any>;
|
|
50
51
|
filterable: PropTypes.Requireable<boolean>;
|
|
@@ -98,6 +99,7 @@ export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProp
|
|
|
98
99
|
required: boolean;
|
|
99
100
|
groupMode: string | undefined;
|
|
100
101
|
isMultiColumn: boolean;
|
|
102
|
+
skipDisabledItems: boolean;
|
|
101
103
|
popupSettings: {
|
|
102
104
|
height: string;
|
|
103
105
|
};
|
|
@@ -156,7 +158,7 @@ export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProp
|
|
|
156
158
|
/** @hidden */
|
|
157
159
|
handleItemSelect: (index: number, state: ComboInternalState) => void;
|
|
158
160
|
/** @hidden */
|
|
159
|
-
onNavigate(state: InternalState, keyCode: number): void;
|
|
161
|
+
onNavigate(state: InternalState, keyCode: number, skipItems?: number): void;
|
|
160
162
|
private onPopupOpened;
|
|
161
163
|
private componentRef;
|
|
162
164
|
private toggleBtnClick;
|
|
@@ -175,7 +177,11 @@ export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProp
|
|
|
175
177
|
private onInputClick;
|
|
176
178
|
private onInputKeyDown;
|
|
177
179
|
private inputOnChange;
|
|
180
|
+
private clearValue;
|
|
178
181
|
private clearButtonClick;
|
|
182
|
+
private clearValueOnEnterOrEsc;
|
|
183
|
+
private clearValueOnBlur;
|
|
184
|
+
private clearValueOnToggleBtnClick;
|
|
179
185
|
private triggerOnChange;
|
|
180
186
|
private getFocusedIndex;
|
|
181
187
|
private suggestValue;
|
|
@@ -95,9 +95,15 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
95
95
|
_this.base.wrapper = element;
|
|
96
96
|
};
|
|
97
97
|
_this.toggleBtnClick = function (event) {
|
|
98
|
+
var _a = _this.props, _b = _a.data, data = _b === void 0 ? [] : _b, skipDisabledItems = _a.skipDisabledItems, textField = _a.textField;
|
|
99
|
+
var focusedIndex = _this.getFocusedIndex();
|
|
100
|
+
var isCurrentValueDisabled = textField && data[focusedIndex].disabled;
|
|
98
101
|
var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
|
|
99
102
|
var state = _this.base.initState();
|
|
100
103
|
state.syntheticEvent = event;
|
|
104
|
+
if (!skipDisabledItems && textField && isCurrentValueDisabled) {
|
|
105
|
+
_this.clearValueOnToggleBtnClick(event);
|
|
106
|
+
}
|
|
101
107
|
_this.base.togglePopup(state);
|
|
102
108
|
if (!opened && _this.mobileMode) {
|
|
103
109
|
var mobileText = _this.props.adaptiveFilter !== undefined ? _this.props.adaptiveFilter : _this.state.text || null;
|
|
@@ -158,9 +164,16 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
158
164
|
_this.handleBlur = function (event) {
|
|
159
165
|
if (_this.state.focused && !_this._skipBlur) {
|
|
160
166
|
var state = _this.base.initState();
|
|
167
|
+
var _a = _this.props, textField = _a.textField, data = _a.data;
|
|
168
|
+
var focusedIndex = _this.getFocusedIndex();
|
|
169
|
+
var isCustomValue = focusedIndex === -1;
|
|
170
|
+
var isCurrentValueDisabled = textField && !isCustomValue && data && data[focusedIndex].disabled;
|
|
161
171
|
state.data.focused = false;
|
|
162
172
|
state.events.push({ type: 'onBlur' });
|
|
163
173
|
state.syntheticEvent = event;
|
|
174
|
+
if (textField && isCurrentValueDisabled) {
|
|
175
|
+
_this.clearValueOnBlur(event);
|
|
176
|
+
}
|
|
164
177
|
_this.applyValueOnRejectSuggestions(event.currentTarget.value, state);
|
|
165
178
|
}
|
|
166
179
|
};
|
|
@@ -176,30 +189,105 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
176
189
|
}
|
|
177
190
|
};
|
|
178
191
|
_this.onInputKeyDown = function (event) {
|
|
192
|
+
var _a = _this.props, _b = _a.data, data = _b === void 0 ? [] : _b, skipDisabledItems = _a.skipDisabledItems, textField = _a.textField, dataItemKey = _a.dataItemKey, groupField = _a.groupField;
|
|
193
|
+
var value = _this.value;
|
|
194
|
+
var selectedIndex = Math.max(0, data.findIndex(function (i) { return areSame(i, value, dataItemKey); }));
|
|
179
195
|
var keyCode = event.keyCode;
|
|
180
196
|
var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
|
|
181
197
|
var state = _this.base.initState();
|
|
182
198
|
state.syntheticEvent = event;
|
|
183
199
|
if (!event.altKey && (keyCode === Keys.up || keyCode === Keys.down)) {
|
|
184
200
|
event.preventDefault();
|
|
185
|
-
|
|
201
|
+
if (groupField !== '' && textField) {
|
|
202
|
+
if (!_this.props.skipDisabledItems && opened) {
|
|
203
|
+
_this.onNavigate(state, keyCode);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
var newIndex = 0;
|
|
207
|
+
if (keyCode === Keys.down || keyCode === Keys.right) {
|
|
208
|
+
var tempnewIndex_1 = data.slice(selectedIndex + 1).find(function (i) { return !i.disabled && i[textField]; });
|
|
209
|
+
newIndex = tempnewIndex_1 && data.findIndex(function (el) { return el[textField] === tempnewIndex_1[textField]; });
|
|
210
|
+
}
|
|
211
|
+
else if (keyCode === Keys.up || keyCode === Keys.left) {
|
|
212
|
+
var dataToSearch = void 0;
|
|
213
|
+
if (selectedIndex === 0) {
|
|
214
|
+
dataToSearch = data;
|
|
215
|
+
newIndex = data.findIndex(function (i) { return !i.disabled && i[textField]; });
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
dataToSearch = data.slice(0, selectedIndex);
|
|
219
|
+
var tempnewIndex_2 = dataToSearch.pop();
|
|
220
|
+
while (tempnewIndex_2 && tempnewIndex_2.disabled) {
|
|
221
|
+
tempnewIndex_2 = dataToSearch.pop();
|
|
222
|
+
}
|
|
223
|
+
newIndex = tempnewIndex_2 && data.findIndex(function (el) { return el[textField] === tempnewIndex_2[textField]; });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (newIndex !== undefined) {
|
|
227
|
+
var skipItems = newIndex - selectedIndex;
|
|
228
|
+
_this.onNavigate(state, keyCode, skipItems);
|
|
229
|
+
}
|
|
230
|
+
else if (newIndex === undefined && data.findIndex(function (el) { return el[textField] === value[textField]; }) === data.length - 1) {
|
|
231
|
+
_this.onNavigate(state, keyCode);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
else if (!_this.props.skipDisabledItems && opened) {
|
|
236
|
+
_this.onNavigate(state, keyCode);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
var newIndex = null;
|
|
240
|
+
if (keyCode === Keys.down || keyCode === Keys.right) {
|
|
241
|
+
newIndex = data.slice(selectedIndex + 1).find(function (i) { return !i.disabled; });
|
|
242
|
+
}
|
|
243
|
+
else if (keyCode === Keys.up || keyCode === Keys.left) {
|
|
244
|
+
var dataTest = data.slice(0, selectedIndex);
|
|
245
|
+
newIndex = dataTest.pop();
|
|
246
|
+
while (newIndex && newIndex.disabled) {
|
|
247
|
+
newIndex = dataTest.pop();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (newIndex) {
|
|
251
|
+
var skipItems = newIndex.id - selectedIndex - 1;
|
|
252
|
+
_this.onNavigate(state, keyCode, skipItems);
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
_this.onNavigate(state, keyCode);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
186
258
|
_this.applyState(state);
|
|
187
|
-
return;
|
|
188
259
|
}
|
|
189
260
|
var togglePopup = function () {
|
|
190
261
|
event.preventDefault();
|
|
191
262
|
_this.base.togglePopup(state);
|
|
192
263
|
_this.applyState(state);
|
|
193
264
|
};
|
|
265
|
+
var focusedIndex = _this.getFocusedIndex();
|
|
266
|
+
var isCustomValue = focusedIndex === -1;
|
|
267
|
+
var isCurrentValueDisabled = textField && !isCustomValue && data[focusedIndex].disabled;
|
|
194
268
|
if (opened) {
|
|
195
269
|
if (event.altKey && keyCode === Keys.up) {
|
|
196
270
|
togglePopup();
|
|
197
271
|
}
|
|
198
272
|
else if (keyCode === Keys.enter) {
|
|
199
273
|
event.preventDefault();
|
|
200
|
-
|
|
274
|
+
var currentValueText = textField && !isCustomValue && event.currentTarget.value ? data[focusedIndex][textField] : undefined;
|
|
275
|
+
if (currentValueText) {
|
|
276
|
+
if (!skipDisabledItems && textField && isCurrentValueDisabled) {
|
|
277
|
+
_this.clearValueOnEnterOrEsc(event);
|
|
278
|
+
}
|
|
279
|
+
else if (!isCurrentValueDisabled) {
|
|
280
|
+
_this.applyValueOnEnter(event.currentTarget.value, state);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
_this.applyValueOnEnter(event.currentTarget.value, state);
|
|
285
|
+
}
|
|
201
286
|
}
|
|
202
287
|
else if (keyCode === Keys.esc) {
|
|
288
|
+
if (!skipDisabledItems && textField && isCurrentValueDisabled) {
|
|
289
|
+
_this.clearValueOnEnterOrEsc(event);
|
|
290
|
+
}
|
|
203
291
|
_this.applyValueOnRejectSuggestions(event.currentTarget.value, state);
|
|
204
292
|
}
|
|
205
293
|
}
|
|
@@ -245,18 +333,25 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
245
333
|
var state = _this.base.initState();
|
|
246
334
|
state.syntheticEvent = event;
|
|
247
335
|
event.stopPropagation();
|
|
248
|
-
_this.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
336
|
+
_this.clearValue();
|
|
337
|
+
};
|
|
338
|
+
_this.clearValueOnEnterOrEsc = function (event) {
|
|
339
|
+
var state = _this.base.initState();
|
|
340
|
+
state.syntheticEvent = event;
|
|
341
|
+
event.stopPropagation();
|
|
342
|
+
_this.clearValue();
|
|
343
|
+
};
|
|
344
|
+
_this.clearValueOnBlur = function (event) {
|
|
345
|
+
var state = _this.base.initState();
|
|
346
|
+
state.syntheticEvent = event;
|
|
347
|
+
event.stopPropagation();
|
|
348
|
+
_this.clearValue();
|
|
349
|
+
};
|
|
350
|
+
_this.clearValueOnToggleBtnClick = function (event) {
|
|
351
|
+
var state = _this.base.initState();
|
|
352
|
+
state.syntheticEvent = event;
|
|
353
|
+
event.stopPropagation();
|
|
354
|
+
_this.clearValue();
|
|
260
355
|
};
|
|
261
356
|
_this.setValidity = function () {
|
|
262
357
|
if (_this._input && _this._input.setCustomValidity) {
|
|
@@ -385,7 +480,7 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
385
480
|
/** @hidden */
|
|
386
481
|
ComboBoxWithoutContext.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
387
482
|
var _a;
|
|
388
|
-
var _b = this.props, dataItemKey = _b.dataItemKey, virtual = _b.virtual, _c = _b.groupField, groupField = _c === void 0 ? '' : _c, _d = _b.data, data = _d === void 0 ? [] : _d;
|
|
483
|
+
var _b = this.props, dataItemKey = _b.dataItemKey, virtual = _b.virtual, _c = _b.groupField, groupField = _c === void 0 ? '' : _c, _d = _b.data, data = _d === void 0 ? [] : _d, textField = _b.textField;
|
|
389
484
|
var prevTotal = prevProps.virtual ? prevProps.virtual.total : 0;
|
|
390
485
|
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
391
486
|
var prevOpened = prevProps.opened !== undefined ? prevProps.opened : prevState.opened;
|
|
@@ -400,8 +495,8 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
400
495
|
var prevSelectedItem = prevProps.value !== undefined ? prevProps.value : prevState.value;
|
|
401
496
|
var selectedItemIndex = data.findIndex(function (i) { return areSame(i, selectedItem, dataItemKey); });
|
|
402
497
|
// Needed to calculate the proper item index when in 'modern' grouping mode
|
|
403
|
-
if (this.props.groupMode === 'modern') {
|
|
404
|
-
selectedItemIndex = (_a = this.base.getGroupedDataModernMode(data, groupField)) === null || _a === void 0 ? void 0 : _a.indexOf(selectedItem);
|
|
498
|
+
if (this.props.groupMode === 'modern' && textField && selectedItem) {
|
|
499
|
+
selectedItemIndex = (_a = this.base.getGroupedDataModernMode(data, groupField)) === null || _a === void 0 ? void 0 : _a.map(function (el) { return el[textField]; }).indexOf(selectedItem[textField]);
|
|
405
500
|
}
|
|
406
501
|
var selectedItemChanged = !areSame(prevSelectedItem, selectedItem, dataItemKey);
|
|
407
502
|
if (opening && virtual) {
|
|
@@ -484,7 +579,7 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
484
579
|
: combobox;
|
|
485
580
|
};
|
|
486
581
|
/** @hidden */
|
|
487
|
-
ComboBoxWithoutContext.prototype.onNavigate = function (state, keyCode) {
|
|
582
|
+
ComboBoxWithoutContext.prototype.onNavigate = function (state, keyCode, skipItems) {
|
|
488
583
|
var _a = this.props, _b = _a.data, data = _b === void 0 ? [] : _b, _c = _a.virtual, virtual = _c === void 0 ? { skip: 0 } : _c;
|
|
489
584
|
var text = this.props.filter ? this.props.filter : this.state.text;
|
|
490
585
|
var focusedIndex = this.getFocusedIndex();
|
|
@@ -503,7 +598,8 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
503
598
|
keyCode: keyCode,
|
|
504
599
|
current: currentIndex,
|
|
505
600
|
max: (vs.enabled ? vs.total : data.length) - 1,
|
|
506
|
-
min: 0
|
|
601
|
+
min: 0,
|
|
602
|
+
skipItems: skipItems ? skipItems : undefined
|
|
507
603
|
});
|
|
508
604
|
if (newIndex !== undefined) {
|
|
509
605
|
this.handleItemSelect(newIndex, state);
|
|
@@ -703,6 +799,21 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
703
799
|
}
|
|
704
800
|
return (React.createElement(SearchBar, { id: id, readOnly: (opened && this.mobileMode), placeholder: placeholder, tabIndex: tabIndex, title: this.props.title, accessKey: this.props.accessKey, value: text + this._suggested, suggestedText: this._suggested, ref: function (el) { return _this._input = el && el.input; }, onClick: this.onInputClick, onKeyDown: this.onInputKeyDown, onChange: this.inputOnChange, onFocus: this.base.handleFocus, onBlur: this.handleBlur, disabled: disabled, expanded: opened, owns: this.base.listBoxId, activedescendant: "option-".concat(this.base.guid, "-").concat(selectedIndex + virtual.skip), role: "combobox", ariaLabelledBy: this.props.ariaLabelledBy, ariaDescribedBy: this.props.ariaDescribedBy, ariaRequired: this.required, render: this.props.valueRender }));
|
|
705
801
|
};
|
|
802
|
+
ComboBoxWithoutContext.prototype.clearValue = function () {
|
|
803
|
+
var state = this.base.initState();
|
|
804
|
+
this._suggested = '';
|
|
805
|
+
this.base.filterChanged('', state);
|
|
806
|
+
if (this.props.filter === undefined && this.state.text !== undefined) {
|
|
807
|
+
state.data.text = undefined;
|
|
808
|
+
}
|
|
809
|
+
this.triggerOnChange(null, state);
|
|
810
|
+
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
811
|
+
var isAdaptive = this.mobileMode;
|
|
812
|
+
if (opened && !isAdaptive) {
|
|
813
|
+
this.base.togglePopup(state);
|
|
814
|
+
}
|
|
815
|
+
this.applyState(state);
|
|
816
|
+
};
|
|
706
817
|
ComboBoxWithoutContext.prototype.triggerOnChange = function (item, state) {
|
|
707
818
|
var value = this.value;
|
|
708
819
|
if ((!isPresent(value) && !isPresent(item)) || areSame(value, item, this.props.dataItemKey)) {
|
|
@@ -716,7 +827,7 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
716
827
|
};
|
|
717
828
|
ComboBoxWithoutContext.prototype.getFocusedIndex = function () {
|
|
718
829
|
var value = this.value;
|
|
719
|
-
var _a = this.props, _b = _a.data, data = _b === void 0 ? [] : _b, textField = _a.textField, dataItemKey = _a.dataItemKey, _c = _a.virtual, virtual = _c === void 0 ? { skip: 0 } : _c, _d = _a.focusedItemIndex, focusedItemIndex = _d === void 0 ? itemIndexStartsWith : _d;
|
|
830
|
+
var _a = this.props, _b = _a.data, data = _b === void 0 ? [] : _b, textField = _a.textField, dataItemKey = _a.dataItemKey, _c = _a.virtual, virtual = _c === void 0 ? { skip: 0 } : _c, _d = _a.focusedItemIndex, focusedItemIndex = _d === void 0 ? itemIndexStartsWith : _d, skipDisabledItems = _a.skipDisabledItems;
|
|
720
831
|
var text = this.props.filter ? this.props.filter : this.state.text;
|
|
721
832
|
if (isPresent(value) && text === undefined) {
|
|
722
833
|
return data.findIndex(function (i) { return areSame(i, value, dataItemKey); });
|
|
@@ -724,6 +835,9 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
724
835
|
else if (text) {
|
|
725
836
|
return focusedItemIndex(data, text, textField);
|
|
726
837
|
}
|
|
838
|
+
else if (skipDisabledItems && textField && !text && virtual.skip === 0) {
|
|
839
|
+
return data.findIndex(function (i) { return !i.disabled && i[textField]; });
|
|
840
|
+
}
|
|
727
841
|
else {
|
|
728
842
|
return virtual.skip === 0 ? 0 : -1;
|
|
729
843
|
}
|
|
@@ -746,9 +860,9 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
746
860
|
;
|
|
747
861
|
ComboBoxWithoutContext.displayName = 'ComboBox';
|
|
748
862
|
/** @hidden */
|
|
749
|
-
ComboBoxWithoutContext.propTypes = __assign(__assign({}, DropDownBase.propTypes), { size: PropTypes.oneOf([null, 'small', 'medium', 'large']), rounded: PropTypes.oneOf([null, 'small', 'medium', 'large', 'full']), fillMode: PropTypes.oneOf([null, 'solid', 'flat', 'outline']), dataItemKey: PropTypes.string, groupField: PropTypes.string, groupMode: PropTypes.oneOf([undefined, 'classic', 'modern']), isMultiColumn: PropTypes.bool, suggest: PropTypes.bool, placeholder: PropTypes.string, title: PropTypes.string, allowCustom: PropTypes.bool, clearButton: PropTypes.bool, iconClassName: PropTypes.string, svgIcon: svgIconPropType, validationMessage: PropTypes.string, required: PropTypes.bool, id: PropTypes.string, ariaLabelledBy: PropTypes.string, ariaDescribedBy: PropTypes.string, list: PropTypes.any, valueRender: PropTypes.func });
|
|
863
|
+
ComboBoxWithoutContext.propTypes = __assign(__assign({}, DropDownBase.propTypes), { size: PropTypes.oneOf([null, 'small', 'medium', 'large']), rounded: PropTypes.oneOf([null, 'small', 'medium', 'large', 'full']), fillMode: PropTypes.oneOf([null, 'solid', 'flat', 'outline']), dataItemKey: PropTypes.string, groupField: PropTypes.string, groupMode: PropTypes.oneOf([undefined, 'classic', 'modern']), isMultiColumn: PropTypes.bool, suggest: PropTypes.bool, placeholder: PropTypes.string, title: PropTypes.string, allowCustom: PropTypes.bool, clearButton: PropTypes.bool, iconClassName: PropTypes.string, svgIcon: svgIconPropType, validationMessage: PropTypes.string, required: PropTypes.bool, id: PropTypes.string, ariaLabelledBy: PropTypes.string, ariaDescribedBy: PropTypes.string, list: PropTypes.any, valueRender: PropTypes.func, skipDisabledItems: PropTypes.bool });
|
|
750
864
|
/** @hidden */
|
|
751
|
-
ComboBoxWithoutContext.defaultProps = __assign(__assign({}, DropDownBase.defaultProps), { size: 'medium', rounded: 'medium', fillMode: 'solid', allowCustom: false, clearButton: true, required: false, groupMode: 'classic', isMultiColumn: false });
|
|
865
|
+
ComboBoxWithoutContext.defaultProps = __assign(__assign({}, DropDownBase.defaultProps), { size: 'medium', rounded: 'medium', fillMode: 'solid', allowCustom: false, clearButton: true, required: false, groupMode: 'classic', isMultiColumn: false, skipDisabledItems: true });
|
|
752
866
|
return ComboBoxWithoutContext;
|
|
753
867
|
}(React.Component));
|
|
754
868
|
export { ComboBoxWithoutContext };
|
|
@@ -306,4 +306,8 @@ export interface ComboBoxProps extends FormComponentProps {
|
|
|
306
306
|
* Specifies the text that is rendered as title in the adaptive popup.
|
|
307
307
|
*/
|
|
308
308
|
adaptiveTitle?: string;
|
|
309
|
+
/**
|
|
310
|
+
* Defines if Combobox's disabled items will be skipped or focused when navigating through the list of items using a keyboard. Defaults to `true`.
|
|
311
|
+
*/
|
|
312
|
+
skipDisabledItems?: boolean;
|
|
309
313
|
}
|
|
@@ -58,9 +58,6 @@ export declare class DropDownListWithoutContext extends React.Component<DropDown
|
|
|
58
58
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
59
59
|
itemRender: PropTypes.Requireable<(...args: any[]) => any>;
|
|
60
60
|
listNoDataRender: PropTypes.Requireable<(...args: any[]) => any>;
|
|
61
|
-
/**
|
|
62
|
-
* @hidden
|
|
63
|
-
*/
|
|
64
61
|
focusedItemIndex: PropTypes.Requireable<(...args: any[]) => any>;
|
|
65
62
|
header: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
66
63
|
footer: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
@@ -85,6 +82,7 @@ export declare class DropDownListWithoutContext extends React.Component<DropDown
|
|
|
85
82
|
title: PropTypes.Requireable<string>;
|
|
86
83
|
groupField: PropTypes.Requireable<string>;
|
|
87
84
|
list: PropTypes.Requireable<any>;
|
|
85
|
+
skipDisabledItems: PropTypes.Requireable<boolean>;
|
|
88
86
|
};
|
|
89
87
|
/**
|
|
90
88
|
* @hidden
|
|
@@ -116,6 +114,7 @@ export declare class DropDownListWithoutContext extends React.Component<DropDown
|
|
|
116
114
|
private _filterInput;
|
|
117
115
|
private _valueDuringOnChange;
|
|
118
116
|
private _navigated;
|
|
117
|
+
private _lastKeypressIsFilter;
|
|
119
118
|
private _inputId;
|
|
120
119
|
private itemHeight;
|
|
121
120
|
private observerResize?;
|
|
@@ -171,7 +170,7 @@ export declare class DropDownListWithoutContext extends React.Component<DropDown
|
|
|
171
170
|
/**
|
|
172
171
|
* @hidden
|
|
173
172
|
*/
|
|
174
|
-
onNavigate(state: InternalState, keyCode: number): void;
|
|
173
|
+
onNavigate(state: InternalState, keyCode: number, skipItems?: number): void;
|
|
175
174
|
private componentRef;
|
|
176
175
|
private dummySelect;
|
|
177
176
|
private renderAdaptiveListContainer;
|
|
@@ -192,12 +191,13 @@ export declare class DropDownListWithoutContext extends React.Component<DropDown
|
|
|
192
191
|
private handleListFilterChange;
|
|
193
192
|
private onPopupOpened;
|
|
194
193
|
private onPopupClosed;
|
|
195
|
-
private
|
|
194
|
+
private getFocusedIndex;
|
|
196
195
|
private focusElement;
|
|
197
196
|
private setValidity;
|
|
198
197
|
private triggerOnChange;
|
|
199
198
|
private applyState;
|
|
200
199
|
private calculateMedia;
|
|
200
|
+
private resetValueIfDisabledItem;
|
|
201
201
|
}
|
|
202
202
|
/**
|
|
203
203
|
* Represents the PropsContext of the `DropDownList` component.
|