@progress/kendo-react-dropdowns 5.13.0-dev.202304200559 → 5.13.0-dev.202304201241
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/js/kendo-react-dropdowns.js +1 -1
- package/dist/es/AutoComplete/AutoComplete.d.ts +11 -2
- package/dist/es/AutoComplete/AutoComplete.js +60 -9
- package/dist/es/AutoComplete/AutoCompleteProps.d.ts +22 -0
- package/dist/es/ComboBox/ComboBox.d.ts +5 -1
- package/dist/es/ComboBox/ComboBox.js +22 -11
- package/dist/es/ComboBox/ComboBoxProps.d.ts +18 -0
- package/dist/es/DropDownList/DropDownList.d.ts +5 -0
- package/dist/es/DropDownList/DropDownList.js +54 -9
- package/dist/es/DropDownList/DropDownListProps.d.ts +22 -0
- package/dist/es/MultiColumnComboBox/MultiColumnComboBox.js +7 -5
- package/dist/es/MultiSelect/MultiSelect.d.ts +44 -45
- package/dist/es/MultiSelect/MultiSelect.js +277 -128
- package/dist/es/MultiSelect/MultiSelectProps.d.ts +44 -1
- package/dist/es/common/DropDownBase.d.ts +1 -0
- package/dist/es/common/DropDownBase.js +13 -0
- package/dist/es/common/GroupStickyHeader.d.ts +24 -0
- package/dist/es/common/GroupStickyHeader.js +34 -0
- package/dist/es/common/List.d.ts +5 -1
- package/dist/es/common/List.js +9 -2
- package/dist/es/common/ListGroupItem.d.ts +33 -0
- package/dist/es/common/ListGroupItem.js +33 -0
- package/dist/es/common/ListItem.d.ts +4 -0
- package/dist/es/common/ListItem.js +3 -3
- package/dist/es/package-metadata.js +1 -1
- package/dist/npm/AutoComplete/AutoComplete.d.ts +11 -2
- package/dist/npm/AutoComplete/AutoComplete.js +60 -9
- package/dist/npm/AutoComplete/AutoCompleteProps.d.ts +22 -0
- package/dist/npm/ComboBox/ComboBox.d.ts +5 -1
- package/dist/npm/ComboBox/ComboBox.js +22 -11
- package/dist/npm/ComboBox/ComboBoxProps.d.ts +18 -0
- package/dist/npm/DropDownList/DropDownList.d.ts +5 -0
- package/dist/npm/DropDownList/DropDownList.js +54 -9
- package/dist/npm/DropDownList/DropDownListProps.d.ts +22 -0
- package/dist/npm/MultiColumnComboBox/MultiColumnComboBox.js +7 -5
- package/dist/npm/MultiSelect/MultiSelect.d.ts +44 -45
- package/dist/npm/MultiSelect/MultiSelect.js +276 -127
- package/dist/npm/MultiSelect/MultiSelectProps.d.ts +44 -1
- package/dist/npm/common/DropDownBase.d.ts +1 -0
- package/dist/npm/common/DropDownBase.js +13 -0
- package/dist/npm/common/GroupStickyHeader.d.ts +24 -0
- package/dist/npm/common/GroupStickyHeader.js +36 -0
- package/dist/npm/common/List.d.ts +5 -1
- package/dist/npm/common/List.js +9 -2
- package/dist/npm/common/ListGroupItem.d.ts +33 -0
- package/dist/npm/common/ListGroupItem.js +35 -0
- package/dist/npm/common/ListItem.d.ts +4 -0
- package/dist/npm/common/ListItem.js +3 -3
- package/dist/npm/package-metadata.js +1 -1
- package/dist/systemjs/kendo-react-dropdowns.js +1 -1
- package/package.json +13 -13
|
@@ -27,6 +27,7 @@ export declare class AutoCompleteWithoutContext extends React.Component<AutoComp
|
|
|
27
27
|
size: PropTypes.Requireable<"small" | "medium" | "large" | null | undefined>;
|
|
28
28
|
rounded: PropTypes.Requireable<"small" | "medium" | "full" | "large" | null | undefined>;
|
|
29
29
|
fillMode: PropTypes.Requireable<"flat" | "outline" | "solid" | null | undefined>;
|
|
30
|
+
groupField: PropTypes.Requireable<string>;
|
|
30
31
|
suggest: PropTypes.Requireable<NonNullable<string | boolean | null | undefined>>;
|
|
31
32
|
placeholder: PropTypes.Requireable<string>;
|
|
32
33
|
value: PropTypes.Requireable<string>;
|
|
@@ -39,6 +40,7 @@ export declare class AutoCompleteWithoutContext extends React.Component<AutoComp
|
|
|
39
40
|
id: PropTypes.Requireable<string>;
|
|
40
41
|
ariaLabelledBy: PropTypes.Requireable<string>;
|
|
41
42
|
ariaDescribedBy: PropTypes.Requireable<string>;
|
|
43
|
+
list: PropTypes.Requireable<any>;
|
|
42
44
|
opened: PropTypes.Requireable<boolean>;
|
|
43
45
|
disabled: PropTypes.Requireable<boolean>;
|
|
44
46
|
dir: PropTypes.Requireable<string>;
|
|
@@ -57,7 +59,9 @@ export declare class AutoCompleteWithoutContext extends React.Component<AutoComp
|
|
|
57
59
|
popupClass: PropTypes.Requireable<string>;
|
|
58
60
|
className: PropTypes.Requireable<string>;
|
|
59
61
|
appendTo: PropTypes.Requireable<any>;
|
|
60
|
-
width: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
62
|
+
width: PropTypes.Requireable<NonNullable<string | number | null | undefined>>; /**
|
|
63
|
+
* @hidden
|
|
64
|
+
*/
|
|
61
65
|
height: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
62
66
|
}>>;
|
|
63
67
|
onOpen: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -82,7 +86,9 @@ export declare class AutoCompleteWithoutContext extends React.Component<AutoComp
|
|
|
82
86
|
height: string;
|
|
83
87
|
};
|
|
84
88
|
required: boolean;
|
|
85
|
-
validityStyles: boolean;
|
|
89
|
+
validityStyles: boolean; /**
|
|
90
|
+
* The value of the AutoComplete.
|
|
91
|
+
*/
|
|
86
92
|
};
|
|
87
93
|
/**
|
|
88
94
|
* @hidden
|
|
@@ -94,6 +100,8 @@ export declare class AutoCompleteWithoutContext extends React.Component<AutoComp
|
|
|
94
100
|
private _suggested;
|
|
95
101
|
private _input;
|
|
96
102
|
private _valueDuringOnChange?;
|
|
103
|
+
private _isScrolling;
|
|
104
|
+
private itemHeight;
|
|
97
105
|
constructor(props: AutoCompleteProps);
|
|
98
106
|
/**
|
|
99
107
|
* @hidden
|
|
@@ -159,6 +167,7 @@ export declare class AutoCompleteWithoutContext extends React.Component<AutoComp
|
|
|
159
167
|
private renderSearchBar;
|
|
160
168
|
private renderListContainer;
|
|
161
169
|
private renderList;
|
|
170
|
+
private onScroll;
|
|
162
171
|
private handleItemClick;
|
|
163
172
|
private onChangeHandler;
|
|
164
173
|
private clearButtonClick;
|
|
@@ -30,6 +30,7 @@ import SearchBar from './../common/SearchBar';
|
|
|
30
30
|
import ListContainer from './../common/ListContainer';
|
|
31
31
|
import List from './../common/List';
|
|
32
32
|
import DropDownBase from '../common/DropDownBase';
|
|
33
|
+
import GroupStickyHeader from '../common/GroupStickyHeader';
|
|
33
34
|
import { itemIndexStartsWith, getItemValue, areSame, getFocusedItem } from '../common/utils';
|
|
34
35
|
import { guid, Keys, classNames, createPropsContext, withPropsContext, kendoThemeMaps, IconWrap } from '@progress/kendo-react-common';
|
|
35
36
|
import { FloatingLabel } from '@progress/kendo-react-labels';
|
|
@@ -52,6 +53,8 @@ var AutoCompleteWithoutContext = /** @class */ (function (_super) {
|
|
|
52
53
|
_this._inputId = guid();
|
|
53
54
|
_this._suggested = '';
|
|
54
55
|
_this._input = null;
|
|
56
|
+
_this._isScrolling = false;
|
|
57
|
+
_this.itemHeight = 0;
|
|
55
58
|
/**
|
|
56
59
|
* @hidden
|
|
57
60
|
*/
|
|
@@ -91,6 +94,36 @@ var AutoCompleteWithoutContext = /** @class */ (function (_super) {
|
|
|
91
94
|
: _this.props.validationMessage || VALIDATION_MESSAGE);
|
|
92
95
|
}
|
|
93
96
|
};
|
|
97
|
+
_this.onScroll = function (event) {
|
|
98
|
+
_this._isScrolling = true;
|
|
99
|
+
var list = _this.base.list;
|
|
100
|
+
var groupField = _this.props.groupField;
|
|
101
|
+
var _a = _this.props.data, data = _a === void 0 ? [] : _a;
|
|
102
|
+
if (!groupField || !data.length) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
var itemHeight = _this.itemHeight || (list ? list.children[0].offsetHeight : 0);
|
|
106
|
+
var target = event.target;
|
|
107
|
+
var scrollTop = target.scrollTop;
|
|
108
|
+
if (groupField) {
|
|
109
|
+
data = _this.base.getGroupedDataModernMode(data, groupField);
|
|
110
|
+
}
|
|
111
|
+
;
|
|
112
|
+
var group = data[0][groupField];
|
|
113
|
+
for (var i = 1; i < data.length; i++) {
|
|
114
|
+
if (itemHeight * i > scrollTop) {
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
if (data[i] && data[i][groupField]) {
|
|
118
|
+
group = data[i][groupField];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (group !== _this.state.group) {
|
|
122
|
+
_this.setState({
|
|
123
|
+
group: group
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
};
|
|
94
127
|
_this.handleItemClick = function (index, event) {
|
|
95
128
|
_this.base.handleItemClick(index, event);
|
|
96
129
|
_this._valueDuringOnChange = undefined;
|
|
@@ -149,6 +182,9 @@ var AutoCompleteWithoutContext = /** @class */ (function (_super) {
|
|
|
149
182
|
_this.applyState(state);
|
|
150
183
|
};
|
|
151
184
|
_this.onInputKeyDown = function (event) {
|
|
185
|
+
if (_this._isScrolling) {
|
|
186
|
+
_this._isScrolling = false;
|
|
187
|
+
}
|
|
152
188
|
var keyCode = event.keyCode;
|
|
153
189
|
var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
|
|
154
190
|
var state = _this.base.initState();
|
|
@@ -268,8 +304,9 @@ var AutoCompleteWithoutContext = /** @class */ (function (_super) {
|
|
|
268
304
|
* @hidden
|
|
269
305
|
*/
|
|
270
306
|
AutoCompleteWithoutContext.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
271
|
-
var _a
|
|
272
|
-
var _b =
|
|
307
|
+
var _a;
|
|
308
|
+
var _b = this.props, _c = _b.groupField, groupField = _c === void 0 ? '' : _c, _d = _b.data, data = _d === void 0 ? [] : _d;
|
|
309
|
+
var _e = prevProps.data, prevData = _e === void 0 ? [] : _e;
|
|
273
310
|
var focusedIndex = this.focusedIndex();
|
|
274
311
|
var focusedItem = data[focusedIndex];
|
|
275
312
|
var dataChanged = prevData !== data;
|
|
@@ -277,8 +314,16 @@ var AutoCompleteWithoutContext = /** @class */ (function (_super) {
|
|
|
277
314
|
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
278
315
|
var prevOpened = prevProps.opened !== undefined ? prevProps.opened : prevState.opened;
|
|
279
316
|
var opening = !prevOpened && opened;
|
|
280
|
-
if (
|
|
281
|
-
|
|
317
|
+
if (groupField === '') {
|
|
318
|
+
if ((opened && (focusedItemChanged || dataChanged)) || opening) {
|
|
319
|
+
this.base.scrollToItem(focusedIndex);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
else if (!this._isScrolling) {
|
|
323
|
+
var focusedItemIndex = (_a = this.base.getGroupedDataModernMode(data, groupField)) === null || _a === void 0 ? void 0 : _a.indexOf(focusedItem);
|
|
324
|
+
if (opened && prevOpened && focusedItemChanged) {
|
|
325
|
+
this.base.scrollToItem(focusedItemIndex);
|
|
326
|
+
}
|
|
282
327
|
}
|
|
283
328
|
this.setValidity();
|
|
284
329
|
};
|
|
@@ -375,10 +420,14 @@ var AutoCompleteWithoutContext = /** @class */ (function (_super) {
|
|
|
375
420
|
AutoCompleteWithoutContext.prototype.renderListContainer = function () {
|
|
376
421
|
var _a;
|
|
377
422
|
var base = this.base;
|
|
378
|
-
var _b = this.props, dir = _b.dir, header = _b.header, footer = _b.footer, _c = _b.data, data = _c === void 0 ? [] : _c, size = _b.size;
|
|
423
|
+
var _b = this.props, dir = _b.dir, header = _b.header, footer = _b.footer, _c = _b.data, data = _c === void 0 ? [] : _c, size = _b.size, groupField = _b.groupField, list = _b.list, groupStickyHeaderItemRender = _b.groupStickyHeaderItemRender;
|
|
379
424
|
var popupSettings = base.getPopupSettings();
|
|
380
425
|
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
381
426
|
var popupWidth = popupSettings.width !== undefined ? popupSettings.width : base.popupWidth;
|
|
427
|
+
var group = this.state.group;
|
|
428
|
+
if (group === undefined && groupField !== undefined) {
|
|
429
|
+
group = getItemValue(data[0], groupField);
|
|
430
|
+
}
|
|
382
431
|
return (React.createElement(ListContainer, { width: popupWidth, popupSettings: {
|
|
383
432
|
animate: popupSettings.animate,
|
|
384
433
|
anchor: this.element,
|
|
@@ -390,16 +439,18 @@ var AutoCompleteWithoutContext = /** @class */ (function (_super) {
|
|
|
390
439
|
header && React.createElement("div", { className: "k-list-header" }, header),
|
|
391
440
|
React.createElement("div", { className: classNames('k-list', (_a = {},
|
|
392
441
|
_a["k-list-".concat(sizeMap[size] || size)] = size,
|
|
393
|
-
_a)) },
|
|
442
|
+
_a)) },
|
|
443
|
+
!list && group && React.createElement(GroupStickyHeader, { group: group, groupMode: 'modern', render: groupStickyHeaderItemRender }),
|
|
444
|
+
this.renderList()),
|
|
394
445
|
footer && React.createElement("div", { className: "k-list-footer" }, footer)));
|
|
395
446
|
};
|
|
396
447
|
AutoCompleteWithoutContext.prototype.renderList = function () {
|
|
397
448
|
var base = this.base;
|
|
398
449
|
var popupSettings = base.getPopupSettings();
|
|
399
|
-
var _a = this.props, textField = _a.textField, _b = _a.data, data = _b === void 0 ? [] : _b, listNoDataRender = _a.listNoDataRender, itemRender = _a.itemRender;
|
|
450
|
+
var _a = this.props, textField = _a.textField, _b = _a.data, data = _b === void 0 ? [] : _b, listNoDataRender = _a.listNoDataRender, itemRender = _a.itemRender, groupHeaderItemRender = _a.groupHeaderItemRender;
|
|
400
451
|
var value = this.value;
|
|
401
452
|
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
402
|
-
return (React.createElement(List, { id: base.listBoxId, show: opened, data: data.slice(), focusedIndex: this.focusedIndex(), value: value, textField: textField, valueField: textField, highlightSelected: false, optionsGuid: base.guid, listRef: function (list) { return base.list = list; }, wrapperStyle: { maxHeight: popupSettings.height }, wrapperCssClass: "k-list-content", onClick: this.handleItemClick, itemRender: itemRender, noDataRender: listNoDataRender, onMouseDown: function (e) { return e.preventDefault(); } }));
|
|
453
|
+
return (React.createElement(List, { id: base.listBoxId, show: opened, data: data.slice(), focusedIndex: this.focusedIndex(), value: value, textField: textField, valueField: textField, highlightSelected: false, optionsGuid: base.guid, groupField: this.props.groupField, groupMode: 'modern', listRef: function (list) { return base.list = list; }, wrapperStyle: { maxHeight: popupSettings.height }, wrapperCssClass: "k-list-content", onClick: this.handleItemClick, itemRender: itemRender, groupHeaderItemRender: groupHeaderItemRender, noDataRender: listNoDataRender, onMouseDown: function (e) { return e.preventDefault(); }, onScroll: this.onScroll }));
|
|
403
454
|
};
|
|
404
455
|
AutoCompleteWithoutContext.prototype.triggerOnChange = function (newValue, state, eventArgs) {
|
|
405
456
|
if (this.value === newValue && !eventArgs) {
|
|
@@ -439,7 +490,7 @@ var AutoCompleteWithoutContext = /** @class */ (function (_super) {
|
|
|
439
490
|
/**
|
|
440
491
|
* @hidden
|
|
441
492
|
*/
|
|
442
|
-
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']), 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 });
|
|
493
|
+
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 });
|
|
443
494
|
/**
|
|
444
495
|
* @hidden
|
|
445
496
|
*/
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { AutoComplete } from './AutoComplete';
|
|
3
3
|
import { ChangeEvent, OpenEvent, CloseEvent, FocusEvent, BlurEvent } from './../common/events';
|
|
4
4
|
import { DropDownsPopupSettings, Suggestion } from '../common/settings';
|
|
5
|
+
import { ListGroupItemProps } from '../common/ListGroupItem';
|
|
6
|
+
import { GroupStickyHeaderProps } from '../common/GroupStickyHeader';
|
|
5
7
|
import { ListItemProps } from '../common/ListItem';
|
|
6
8
|
import { FormComponentProps } from '@progress/kendo-react-common';
|
|
7
9
|
/**
|
|
@@ -214,4 +216,24 @@ export interface AutoCompleteProps extends FormComponentProps {
|
|
|
214
216
|
* @default `solid`
|
|
215
217
|
*/
|
|
216
218
|
fillMode?: null | 'solid' | 'flat' | 'outline';
|
|
219
|
+
/**
|
|
220
|
+
* Sets the data item field that represents the start of a group. Applicable to objects data.
|
|
221
|
+
*/
|
|
222
|
+
groupField?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Fires when a AutoComplete group header item is about to be rendered. Used to override the default appearance of the group's headers.
|
|
225
|
+
*/
|
|
226
|
+
groupHeaderItemRender?: (li: React.ReactElement<HTMLLIElement>, itemProps: ListGroupItemProps) => React.ReactNode;
|
|
227
|
+
/**
|
|
228
|
+
* Fires when a AutoComplete sticky group header item is about to be rendered. Used to override the default appearance of the sticky group header of the component.
|
|
229
|
+
*/
|
|
230
|
+
groupStickyHeaderItemRender?: (div: React.ReactElement<HTMLDivElement>, stickyHeaderProps: GroupStickyHeaderProps) => React.ReactNode;
|
|
231
|
+
/**
|
|
232
|
+
* @hidden
|
|
233
|
+
*/
|
|
234
|
+
list?: any;
|
|
235
|
+
/**
|
|
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
|
+
*/
|
|
238
|
+
dataItemKey?: string;
|
|
217
239
|
}
|
|
@@ -25,6 +25,8 @@ export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProp
|
|
|
25
25
|
fillMode: PropTypes.Requireable<"flat" | "outline" | "solid" | null | undefined>;
|
|
26
26
|
dataItemKey: PropTypes.Requireable<string>;
|
|
27
27
|
groupField: PropTypes.Requireable<string>;
|
|
28
|
+
groupMode: PropTypes.Requireable<string | undefined>;
|
|
29
|
+
isMultiColumn: PropTypes.Requireable<boolean>;
|
|
28
30
|
suggest: PropTypes.Requireable<boolean>;
|
|
29
31
|
placeholder: PropTypes.Requireable<string>;
|
|
30
32
|
allowCustom: PropTypes.Requireable<boolean>;
|
|
@@ -56,7 +58,7 @@ export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProp
|
|
|
56
58
|
opened: PropTypes.Requireable<boolean>;
|
|
57
59
|
disabled: PropTypes.Requireable<boolean>;
|
|
58
60
|
dir: PropTypes.Requireable<string>;
|
|
59
|
-
tabIndex: PropTypes.Requireable<number>;
|
|
61
|
+
tabIndex: PropTypes.Requireable<number>; /** @hidden */
|
|
60
62
|
accessKey: PropTypes.Requireable<string>;
|
|
61
63
|
data: PropTypes.Requireable<any[]>;
|
|
62
64
|
textField: PropTypes.Requireable<string>;
|
|
@@ -93,6 +95,8 @@ export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProp
|
|
|
93
95
|
allowCustom: boolean;
|
|
94
96
|
clearButton: boolean;
|
|
95
97
|
required: boolean;
|
|
98
|
+
groupMode: string | undefined;
|
|
99
|
+
isMultiColumn: boolean;
|
|
96
100
|
popupSettings: {
|
|
97
101
|
height: string;
|
|
98
102
|
};
|
|
@@ -34,6 +34,7 @@ import SearchBar from '../common/SearchBar';
|
|
|
34
34
|
import ListContainer from '../common/ListContainer';
|
|
35
35
|
import List from '../common/List';
|
|
36
36
|
import ListFilter from '../common/ListFilter';
|
|
37
|
+
import GroupStickyHeader from '../common/GroupStickyHeader';
|
|
37
38
|
import { validatePackage, canUseDOM } from '@progress/kendo-react-common';
|
|
38
39
|
import { packageMetadata } from '../package-metadata';
|
|
39
40
|
import ClearButton from '../common/ClearButton';
|
|
@@ -120,7 +121,8 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
120
121
|
_this.onScroll = function (event) {
|
|
121
122
|
var _a = _this.base, vs = _a.vs, list = _a.list;
|
|
122
123
|
vs.scrollHandler(event);
|
|
123
|
-
var
|
|
124
|
+
var groupField = _this.props.groupField;
|
|
125
|
+
var _b = _this.props.data, data = _b === void 0 ? [] : _b;
|
|
124
126
|
if (!groupField || !data.length) {
|
|
125
127
|
return;
|
|
126
128
|
}
|
|
@@ -128,6 +130,9 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
128
130
|
_this.itemHeight || (vs.enabled ? vs.itemHeight : (list ? list.children[0].offsetHeight : 0));
|
|
129
131
|
var target = event.target;
|
|
130
132
|
var scrollTop = target.scrollTop - (vs.skip * itemHeight);
|
|
133
|
+
if (_this.props.groupMode === 'modern') {
|
|
134
|
+
data = _this.base.getGroupedDataModernMode(data, groupField);
|
|
135
|
+
}
|
|
131
136
|
var group = data[0][groupField];
|
|
132
137
|
for (var i = 1; i < data.length; i++) {
|
|
133
138
|
if (itemHeight * i > scrollTop) {
|
|
@@ -378,7 +383,9 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
378
383
|
});
|
|
379
384
|
/** @hidden */
|
|
380
385
|
ComboBoxWithoutContext.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
381
|
-
var _a
|
|
386
|
+
var _a;
|
|
387
|
+
var _b = this.props, dataItemKey = _b.dataItemKey, virtual = _b.virtual, _c = _b.groupField, groupField = _c === void 0 ? '' : _c;
|
|
388
|
+
var _d = this.props.data, data = _d === void 0 ? [] : _d;
|
|
382
389
|
var prevTotal = prevProps.virtual ? prevProps.virtual.total : 0;
|
|
383
390
|
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
384
391
|
var prevOpened = prevProps.opened !== undefined ? prevProps.opened : prevState.opened;
|
|
@@ -392,6 +399,10 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
392
399
|
else {
|
|
393
400
|
var prevSelectedItem = prevProps.value !== undefined ? prevProps.value : prevState.value;
|
|
394
401
|
var selectedItemIndex = data.findIndex(function (i) { return areSame(i, selectedItem, dataItemKey); });
|
|
402
|
+
// 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);
|
|
405
|
+
}
|
|
395
406
|
var selectedItemChanged = !areSame(prevSelectedItem, selectedItem, dataItemKey);
|
|
396
407
|
if (opening && virtual) {
|
|
397
408
|
this.base.scrollToVirtualItem(virtual, selectedItemIndex);
|
|
@@ -582,7 +593,7 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
582
593
|
var _a;
|
|
583
594
|
var _this = this;
|
|
584
595
|
var _b = this.state.windowWidth, windowWidth = _b === void 0 ? 0 : _b;
|
|
585
|
-
var _c = this.props, header = _c.header, footer = _c.footer, size = _c.size, _d = _c.data, data = _d === void 0 ? [] : _d, groupField = _c.groupField, list = _c.list, virtual = _c.virtual, adaptiveTitle = _c.adaptiveTitle;
|
|
596
|
+
var _c = this.props, header = _c.header, footer = _c.footer, size = _c.size, _d = _c.data, data = _d === void 0 ? [] : _d, groupField = _c.groupField, groupMode = _c.groupMode, list = _c.list, virtual = _c.virtual, adaptiveTitle = _c.adaptiveTitle, groupStickyHeaderItemRender = _c.groupStickyHeaderItemRender;
|
|
586
597
|
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
587
598
|
var group = this.state.group;
|
|
588
599
|
if (group === undefined && groupField !== undefined) {
|
|
@@ -618,14 +629,14 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
618
629
|
_a["k-table-".concat(sizeMap[size] || size)] = list && size,
|
|
619
630
|
_a)) },
|
|
620
631
|
header && React.createElement("div", { className: "k-table-header" }, header),
|
|
621
|
-
!list && group && React.createElement(
|
|
632
|
+
!list && group && React.createElement(GroupStickyHeader, { group: group, groupMode: groupMode, render: groupStickyHeaderItemRender }),
|
|
622
633
|
this.renderList(),
|
|
623
634
|
footer && React.createElement("div", { className: "k-list-footer" }, footer)))))));
|
|
624
635
|
};
|
|
625
636
|
ComboBoxWithoutContext.prototype.renderListContainer = function () {
|
|
626
637
|
var _a;
|
|
627
638
|
var base = this.base;
|
|
628
|
-
var _b = this.props, dir = _b.dir, header = _b.header, footer = _b.footer, _c = _b.data, data = _c === void 0 ? [] : _c, groupField = _b.groupField, size = _b.size, list = _b.list, virtual = _b.virtual;
|
|
639
|
+
var _b = this.props, dir = _b.dir, header = _b.header, footer = _b.footer, _c = _b.data, data = _c === void 0 ? [] : _c, groupField = _b.groupField, groupMode = _b.groupMode, size = _b.size, list = _b.list, virtual = _b.virtual, groupStickyHeaderItemRender = _b.groupStickyHeaderItemRender;
|
|
629
640
|
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
630
641
|
var popupSettings = base.getPopupSettings();
|
|
631
642
|
var popupWidth = popupSettings.width !== undefined ? popupSettings.width : base.popupWidth;
|
|
@@ -649,7 +660,7 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
649
660
|
_a["k-table-".concat(sizeMap[size] || size)] = list && size,
|
|
650
661
|
_a)) },
|
|
651
662
|
header && React.createElement("div", { className: "k-table-header" }, header),
|
|
652
|
-
!list && group && React.createElement(
|
|
663
|
+
!list && group && React.createElement(GroupStickyHeader, { group: group, groupMode: groupMode, render: groupStickyHeaderItemRender }),
|
|
653
664
|
this.renderList(),
|
|
654
665
|
footer && React.createElement("div", { className: "k-list-footer" }, footer))));
|
|
655
666
|
};
|
|
@@ -657,7 +668,7 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
657
668
|
var _a;
|
|
658
669
|
var _this = this;
|
|
659
670
|
var base = this.base;
|
|
660
|
-
var _b = this.props, textField = _b.textField, dataItemKey = _b.dataItemKey, listNoDataRender = _b.listNoDataRender, itemRender = _b.itemRender, _c = _b.data, data = _c === void 0 ? [] : _c, _d = _b.virtual, virtual = _d === void 0 ? { skip: 0 } : _d;
|
|
671
|
+
var _b = this.props, textField = _b.textField, dataItemKey = _b.dataItemKey, listNoDataRender = _b.listNoDataRender, itemRender = _b.itemRender, groupHeaderItemRender = _b.groupHeaderItemRender, _c = _b.data, data = _c === void 0 ? [] : _c, _d = _b.virtual, virtual = _d === void 0 ? { skip: 0 } : _d;
|
|
661
672
|
var popupSettings = base.getPopupSettings();
|
|
662
673
|
var vs = base.vs;
|
|
663
674
|
var skip = virtual.skip;
|
|
@@ -668,11 +679,11 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
668
679
|
var selectedItemText = getItemValue(this.value, textField);
|
|
669
680
|
var value = isPresent(text) && text !== selectedItemText ? null : this.value;
|
|
670
681
|
var ListComponent = this.props.list || List;
|
|
671
|
-
return (React.createElement(ListComponent, { id: base.listBoxId, virtual: Boolean(virtual), show: opened, data: data, focusedIndex: focusedIndex, value: value, textField: textField, valueField: dataItemKey, groupField: this.props.groupField, optionsGuid: base.guid, listRef: function (list) { vs.list = _this.base.list = list; _this.itemHeight = 0; }, wrapperStyle: (this.state.windowWidth && this.state.windowWidth > MOBILE_MEDIUM_DEVISE)
|
|
682
|
+
return (React.createElement(ListComponent, { id: base.listBoxId, virtual: Boolean(virtual), show: opened, data: data, focusedIndex: focusedIndex, value: value, textField: textField, valueField: dataItemKey, groupField: this.props.groupField, groupMode: this.props.groupMode, isMultiColumn: this.props.isMultiColumn, optionsGuid: base.guid, listRef: function (list) { vs.list = _this.base.list = list; _this.itemHeight = 0; }, wrapperStyle: (this.state.windowWidth && this.state.windowWidth > MOBILE_MEDIUM_DEVISE)
|
|
672
683
|
? { maxHeight: popupSettings.height }
|
|
673
684
|
: {}, wrapperCssClass: classNames('k-list-content', (_a = {},
|
|
674
685
|
_a['k-list-scroller'] = !virtual,
|
|
675
|
-
_a)), listStyle: vs.enabled ? { transform: translate } : undefined, key: "listkey", skip: skip, onClick: this.handleItemClick, itemRender: itemRender, noDataRender: listNoDataRender, onMouseDown: function (e) { return e.preventDefault(); }, onScroll: this.onScroll, wrapperRef: vs.scrollerRef, scroller: this.base.renderScrollElement() }));
|
|
686
|
+
_a)), listStyle: vs.enabled ? { transform: translate } : undefined, key: "listkey", skip: skip, onClick: this.handleItemClick, itemRender: itemRender, groupHeaderItemRender: groupHeaderItemRender, noDataRender: listNoDataRender, onMouseDown: function (e) { return e.preventDefault(); }, onScroll: this.onScroll, wrapperRef: vs.scrollerRef, scroller: this.base.renderScrollElement() }));
|
|
676
687
|
};
|
|
677
688
|
ComboBoxWithoutContext.prototype.renderSearchBar = function (text, id, placeholder) {
|
|
678
689
|
var _this = this;
|
|
@@ -728,9 +739,9 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
728
739
|
;
|
|
729
740
|
ComboBoxWithoutContext.displayName = 'ComboBox';
|
|
730
741
|
/** @hidden */
|
|
731
|
-
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, suggest: PropTypes.bool, placeholder: 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 });
|
|
742
|
+
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, 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 });
|
|
732
743
|
/** @hidden */
|
|
733
|
-
ComboBoxWithoutContext.defaultProps = __assign(__assign({}, DropDownBase.defaultProps), { size: 'medium', rounded: 'medium', fillMode: 'solid', allowCustom: false, clearButton: true, required: false });
|
|
744
|
+
ComboBoxWithoutContext.defaultProps = __assign(__assign({}, DropDownBase.defaultProps), { size: 'medium', rounded: 'medium', fillMode: 'solid', allowCustom: false, clearButton: true, required: false, groupMode: 'classic', isMultiColumn: false });
|
|
734
745
|
return ComboBoxWithoutContext;
|
|
735
746
|
}(React.Component));
|
|
736
747
|
export { ComboBoxWithoutContext };
|
|
@@ -4,6 +4,8 @@ import { FilterChangeEvent, ChangeEvent, OpenEvent, CloseEvent, FocusEvent, Blur
|
|
|
4
4
|
import { FormComponentProps, SVGIcon } from '@progress/kendo-react-common';
|
|
5
5
|
import { VirtualizationSettings, DropDownsPopupSettings } from '../common/settings';
|
|
6
6
|
import { ListItemProps } from '../common/ListItem';
|
|
7
|
+
import { ListGroupItemProps } from '../common/ListGroupItem';
|
|
8
|
+
import { GroupStickyHeaderProps } from '../common/GroupStickyHeader';
|
|
7
9
|
/**
|
|
8
10
|
* Represents the object of the `FilterChange` ComboBox event.
|
|
9
11
|
*/
|
|
@@ -131,6 +133,14 @@ export interface ComboBoxProps extends FormComponentProps {
|
|
|
131
133
|
* Sets the data item field that represents the start of a group. Applicable to objects data.
|
|
132
134
|
*/
|
|
133
135
|
groupField?: string;
|
|
136
|
+
/**
|
|
137
|
+
* Defines the `classic` or `modern` type of the grouping's visualization. Defaults to `classic`.
|
|
138
|
+
*/
|
|
139
|
+
groupMode?: string;
|
|
140
|
+
/**
|
|
141
|
+
* @hidden Used to indicate if the ComboBox is with multiple columns
|
|
142
|
+
*/
|
|
143
|
+
isMultiColumn?: boolean;
|
|
134
144
|
/**
|
|
135
145
|
* Sets the key for comparing the data items of the ComboBox. If `dataItemKey` is not set, the ComboBox compares the items by reference ([see example]({% slug binding_combobox %}#toc-datasets-of-objects)).
|
|
136
146
|
*/
|
|
@@ -213,6 +223,14 @@ export interface ComboBoxProps extends FormComponentProps {
|
|
|
213
223
|
* Fires when a ComboBox list item is about to be rendered ([see example]({% slug customrendering_combobox %}#toc-items)). Used to override the default appearance of the list items.
|
|
214
224
|
*/
|
|
215
225
|
itemRender?: (li: React.ReactElement<HTMLLIElement>, itemProps: ListItemProps) => React.ReactNode;
|
|
226
|
+
/**
|
|
227
|
+
* Fires when a ComboBox group header item is about to be rendered. Used to override the default appearance of the group's headers when the component is configured in `modern` group mode.
|
|
228
|
+
*/
|
|
229
|
+
groupHeaderItemRender?: (li: React.ReactElement<HTMLLIElement>, itemProps: ListGroupItemProps) => React.ReactNode;
|
|
230
|
+
/**
|
|
231
|
+
* Fires when a ComboBox sticky group header item is about to be rendered. Used to override the default appearance of the sticky group header of the component.
|
|
232
|
+
*/
|
|
233
|
+
groupStickyHeaderItemRender?: (div: React.ReactElement<HTMLDivElement>, stickyHeaderProps: GroupStickyHeaderProps) => React.ReactNode;
|
|
216
234
|
/**
|
|
217
235
|
* Fires when the element which indicates no data in the popup is about to be rendered. Used to override the default appearance of the element.
|
|
218
236
|
*/
|
|
@@ -80,6 +80,8 @@ export declare class DropDownListWithoutContext extends React.Component<DropDown
|
|
|
80
80
|
ariaLabel: PropTypes.Requireable<string>;
|
|
81
81
|
leftRightKeysNavigation: PropTypes.Requireable<boolean>;
|
|
82
82
|
title: PropTypes.Requireable<string>;
|
|
83
|
+
groupField: PropTypes.Requireable<string>;
|
|
84
|
+
list: PropTypes.Requireable<any>;
|
|
83
85
|
};
|
|
84
86
|
/**
|
|
85
87
|
* @hidden
|
|
@@ -89,6 +91,7 @@ export declare class DropDownListWithoutContext extends React.Component<DropDown
|
|
|
89
91
|
size: "small" | "medium" | "large" | null | undefined;
|
|
90
92
|
rounded: "small" | "medium" | "full" | "large" | null | undefined;
|
|
91
93
|
fillMode: "flat" | "outline" | "solid" | null | undefined;
|
|
94
|
+
groupMode: string | undefined;
|
|
92
95
|
popupSettings: {
|
|
93
96
|
height: string;
|
|
94
97
|
};
|
|
@@ -111,6 +114,7 @@ export declare class DropDownListWithoutContext extends React.Component<DropDown
|
|
|
111
114
|
private _valueDuringOnChange;
|
|
112
115
|
private _navigated;
|
|
113
116
|
private _inputId;
|
|
117
|
+
private itemHeight;
|
|
114
118
|
private observerResize?;
|
|
115
119
|
private get document();
|
|
116
120
|
constructor(props: DropDownListProps);
|
|
@@ -170,6 +174,7 @@ export declare class DropDownListWithoutContext extends React.Component<DropDown
|
|
|
170
174
|
private renderAdaptiveListContainer;
|
|
171
175
|
private renderListContainer;
|
|
172
176
|
private renderList;
|
|
177
|
+
private onScroll;
|
|
173
178
|
private renderListFilter;
|
|
174
179
|
private renderDefaultItem;
|
|
175
180
|
private search;
|
|
@@ -31,6 +31,7 @@ import { FloatingLabel } from '@progress/kendo-react-labels';
|
|
|
31
31
|
import { caretAltDownIcon, xIcon } from '@progress/kendo-svg-icons';
|
|
32
32
|
import ListContainer from '../common/ListContainer';
|
|
33
33
|
import ListFilter from '../common/ListFilter';
|
|
34
|
+
import GroupStickyHeader from '../common/GroupStickyHeader';
|
|
34
35
|
import ListDefaultItem from '../common/ListDefaultItem';
|
|
35
36
|
import List from '../common/List';
|
|
36
37
|
import DropDownBase from '../common/DropDownBase';
|
|
@@ -63,6 +64,7 @@ var DropDownListWithoutContext = /** @class */ (function (_super) {
|
|
|
63
64
|
_this._filterInput = null;
|
|
64
65
|
_this._navigated = false;
|
|
65
66
|
_this._inputId = guid();
|
|
67
|
+
_this.itemHeight = 0;
|
|
66
68
|
/**
|
|
67
69
|
* @hidden
|
|
68
70
|
*/
|
|
@@ -96,7 +98,7 @@ var DropDownListWithoutContext = /** @class */ (function (_super) {
|
|
|
96
98
|
};
|
|
97
99
|
_this.renderListContainer = function () {
|
|
98
100
|
var _a;
|
|
99
|
-
var _b = _this.props, header = _b.header, footer = _b.footer, dir = _b.dir, _c = _b.data, data = _c === void 0 ? [] : _c, size = _b.size;
|
|
101
|
+
var _b = _this.props, header = _b.header, footer = _b.footer, dir = _b.dir, _c = _b.data, data = _c === void 0 ? [] : _c, size = _b.size, groupField = _b.groupField, groupStickyHeaderItemRender = _b.groupStickyHeaderItemRender, list = _b.list;
|
|
100
102
|
var base = _this.base;
|
|
101
103
|
var popupSettings = base.getPopupSettings();
|
|
102
104
|
var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
|
|
@@ -116,24 +118,57 @@ var DropDownListWithoutContext = /** @class */ (function (_super) {
|
|
|
116
118
|
},
|
|
117
119
|
itemsCount: [data.length]
|
|
118
120
|
};
|
|
121
|
+
var group = _this.state.group;
|
|
122
|
+
if (group === undefined && groupField !== undefined) {
|
|
123
|
+
group = getItemValue(data[0], groupField);
|
|
124
|
+
}
|
|
119
125
|
return (React.createElement(ListContainer, __assign({}, listContainerProps),
|
|
120
126
|
_this.renderListFilter(),
|
|
121
127
|
header && React.createElement("div", { className: "k-list-header" }, header),
|
|
122
128
|
React.createElement("div", { className: classNames('k-list', (_a = {}, _a["k-list-".concat(sizeMap[size] || size)] = size, _a['k-virtual-list'] = _this.base.vs.enabled, _a)) },
|
|
123
129
|
_this.renderDefaultItem(),
|
|
130
|
+
!list && group && React.createElement(GroupStickyHeader, { group: group, groupMode: 'modern', render: groupStickyHeaderItemRender }),
|
|
124
131
|
_this.renderList()),
|
|
125
132
|
footer && React.createElement("div", { className: "k-list-footer" }, footer)));
|
|
126
133
|
};
|
|
127
134
|
_this.renderList = function () {
|
|
128
|
-
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, listNoDataRender = _a.listNoDataRender, itemRender = _a.itemRender;
|
|
135
|
+
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, groupHeaderItemRender = _a.groupHeaderItemRender, listNoDataRender = _a.listNoDataRender, itemRender = _a.itemRender;
|
|
129
136
|
var vs = _this.base.vs;
|
|
130
137
|
var skip = virtual.skip;
|
|
131
138
|
var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
|
|
132
139
|
var popupSettings = _this.base.getPopupSettings();
|
|
133
140
|
var translate = "translateY(".concat(vs.translate, "px)");
|
|
134
|
-
return (React.createElement(List, { id: _this.base.listBoxId, show: opened, data: data.slice(), focusedIndex: _this.focusedIndex(), value: _this.value, textField: textField, valueField: dataItemKey, optionsGuid: _this.base.guid, listRef: function (list) { return vs.list = _this.base.list = list; }, wrapperStyle: { maxHeight: popupSettings.height }, wrapperCssClass: "k-list-content", listStyle: vs.enabled ? { transform: translate } : undefined, key: "listkey", skip: skip, onClick: _this.handleItemClick, itemRender: itemRender, noDataRender: listNoDataRender, onScroll:
|
|
135
|
-
|
|
136
|
-
|
|
141
|
+
return (React.createElement(List, { id: _this.base.listBoxId, show: opened, data: data.slice(), focusedIndex: _this.focusedIndex(), value: _this.value, textField: textField, valueField: dataItemKey, optionsGuid: _this.base.guid, groupField: _this.props.groupField, groupMode: 'modern', listRef: function (list) { return vs.list = _this.base.list = list; }, wrapperStyle: { maxHeight: popupSettings.height }, wrapperCssClass: "k-list-content", listStyle: vs.enabled ? { transform: translate } : undefined, key: "listkey", skip: skip, onClick: _this.handleItemClick, itemRender: itemRender, groupHeaderItemRender: groupHeaderItemRender, noDataRender: listNoDataRender, onScroll: _this.onScroll, wrapperRef: vs.scrollerRef, scroller: _this.base.renderScrollElement() }));
|
|
142
|
+
};
|
|
143
|
+
_this.onScroll = function (event) {
|
|
144
|
+
var _a = _this.base, vs = _a.vs, list = _a.list;
|
|
145
|
+
vs.scrollHandler(event);
|
|
146
|
+
var groupField = _this.props.groupField;
|
|
147
|
+
var _b = _this.props.data, data = _b === void 0 ? [] : _b;
|
|
148
|
+
if (!groupField || !data.length) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (groupField) {
|
|
152
|
+
var itemHeight = _this.itemHeight =
|
|
153
|
+
_this.itemHeight || (vs.enabled ? vs.itemHeight : (list ? list.children[0].offsetHeight : 0));
|
|
154
|
+
var target = event.target;
|
|
155
|
+
var scrollTop = target.scrollTop - (vs.skip * itemHeight);
|
|
156
|
+
data = _this.base.getGroupedDataModernMode(data, groupField);
|
|
157
|
+
var group = data[0][groupField];
|
|
158
|
+
for (var i = 1; i < data.length; i++) {
|
|
159
|
+
if (itemHeight * i > scrollTop) {
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
if (data[i] && data[i][groupField]) {
|
|
163
|
+
group = data[i][groupField];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (group !== _this.state.group) {
|
|
167
|
+
_this.setState({
|
|
168
|
+
group: group
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
137
172
|
};
|
|
138
173
|
_this.renderListFilter = function () {
|
|
139
174
|
var filterText = _this.props.filter !== undefined ? _this.props.filter : _this.state.text;
|
|
@@ -454,7 +489,9 @@ var DropDownListWithoutContext = /** @class */ (function (_super) {
|
|
|
454
489
|
* @hidden
|
|
455
490
|
*/
|
|
456
491
|
DropDownListWithoutContext.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
457
|
-
var _a
|
|
492
|
+
var _a;
|
|
493
|
+
var _b = this.props, dataItemKey = _b.dataItemKey, virtual = _b.virtual, _c = _b.groupField, groupField = _c === void 0 ? '' : _c;
|
|
494
|
+
var _d = this.props.data, data = _d === void 0 ? [] : _d;
|
|
458
495
|
var prevTotal = prevProps.virtual ? prevProps.virtual.total : 0;
|
|
459
496
|
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
460
497
|
var prevOpened = prevProps.opened !== undefined ? prevProps.opened : prevState.opened;
|
|
@@ -476,6 +513,9 @@ var DropDownListWithoutContext = /** @class */ (function (_super) {
|
|
|
476
513
|
var selectedItem_1 = this.value;
|
|
477
514
|
var prevSelectedItem = prevProps.value !== undefined ? prevProps.value : prevState.value;
|
|
478
515
|
var selectedItemIndex = data.findIndex(function (i) { return areSame(i, selectedItem_1, dataItemKey); });
|
|
516
|
+
if (groupField !== '') {
|
|
517
|
+
selectedItemIndex = (_a = this.base.getGroupedDataModernMode(data, groupField)) === null || _a === void 0 ? void 0 : _a.indexOf(selectedItem_1);
|
|
518
|
+
}
|
|
479
519
|
var selectedItemChanged = !areSame(prevSelectedItem, selectedItem_1, dataItemKey);
|
|
480
520
|
if (opening && virtual) {
|
|
481
521
|
this.base.scrollToVirtualItem(virtual, selectedItemIndex);
|
|
@@ -596,7 +636,7 @@ var DropDownListWithoutContext = /** @class */ (function (_super) {
|
|
|
596
636
|
var _a;
|
|
597
637
|
var _this = this;
|
|
598
638
|
var _b = this.state.windowWidth, windowWidth = _b === void 0 ? 0 : _b;
|
|
599
|
-
var _c = this.props, header = _c.header, footer = _c.footer, size = _c.size, adaptiveTitle = _c.adaptiveTitle;
|
|
639
|
+
var _c = this.props, header = _c.header, footer = _c.footer, size = _c.size, adaptiveTitle = _c.adaptiveTitle, groupField = _c.groupField, groupStickyHeaderItemRender = _c.groupStickyHeaderItemRender, list = _c.list, _d = _c.data, data = _d === void 0 ? [] : _d;
|
|
600
640
|
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
601
641
|
var actionSheetProps = {
|
|
602
642
|
navigatable: false,
|
|
@@ -609,6 +649,10 @@ var DropDownListWithoutContext = /** @class */ (function (_super) {
|
|
|
609
649
|
? 'k-adaptive-actionsheet k-actionsheet-fullscreen'
|
|
610
650
|
: 'k-adaptive-actionsheet k-actionsheet-bottom'
|
|
611
651
|
};
|
|
652
|
+
var group = this.state.group;
|
|
653
|
+
if (group === undefined && groupField !== undefined) {
|
|
654
|
+
group = getItemValue(data[0], groupField);
|
|
655
|
+
}
|
|
612
656
|
return (React.createElement(React.Fragment, null,
|
|
613
657
|
React.createElement(ActionSheet, __assign({}, actionSheetProps),
|
|
614
658
|
React.createElement(ActionSheetHeader, { className: 'k-text-center' },
|
|
@@ -622,6 +666,7 @@ var DropDownListWithoutContext = /** @class */ (function (_super) {
|
|
|
622
666
|
header && React.createElement("div", { className: "k-list-header" }, header),
|
|
623
667
|
React.createElement("div", { className: classNames('k-list', (_a = {}, _a["k-list-".concat(sizeMap[size] || size)] = size, _a['k-virtual-list'] = this.base.vs.enabled, _a)) },
|
|
624
668
|
this.renderDefaultItem(),
|
|
669
|
+
!list && group && React.createElement(GroupStickyHeader, { group: group, groupMode: 'modern', render: groupStickyHeaderItemRender }),
|
|
625
670
|
this.renderList()),
|
|
626
671
|
footer && React.createElement("div", { className: "k-list-footer" }, footer)))));
|
|
627
672
|
};
|
|
@@ -671,11 +716,11 @@ var DropDownListWithoutContext = /** @class */ (function (_super) {
|
|
|
671
716
|
/**
|
|
672
717
|
* @hidden
|
|
673
718
|
*/
|
|
674
|
-
DropDownListWithoutContext.propTypes = __assign({ delay: PropTypes.number, ignoreCase: PropTypes.bool, iconClassName: PropTypes.string, svgIcon: svgIconPropType, defaultItem: PropTypes.any, valueRender: PropTypes.func, valueMap: PropTypes.func, validationMessage: PropTypes.string, required: PropTypes.bool, id: PropTypes.string, ariaLabelledBy: PropTypes.string, ariaDescribedBy: PropTypes.string, ariaLabel: PropTypes.string, leftRightKeysNavigation: PropTypes.bool, title: PropTypes.string }, DropDownBase.propTypes);
|
|
719
|
+
DropDownListWithoutContext.propTypes = __assign({ delay: PropTypes.number, ignoreCase: PropTypes.bool, iconClassName: PropTypes.string, svgIcon: svgIconPropType, defaultItem: PropTypes.any, valueRender: PropTypes.func, valueMap: PropTypes.func, validationMessage: PropTypes.string, required: PropTypes.bool, id: PropTypes.string, ariaLabelledBy: PropTypes.string, ariaDescribedBy: PropTypes.string, ariaLabel: PropTypes.string, leftRightKeysNavigation: PropTypes.bool, title: PropTypes.string, groupField: PropTypes.string, list: PropTypes.any }, DropDownBase.propTypes);
|
|
675
720
|
/**
|
|
676
721
|
* @hidden
|
|
677
722
|
*/
|
|
678
|
-
DropDownListWithoutContext.defaultProps = __assign(__assign({ delay: 500, tabIndex: 0, ignoreCase: true }, DropDownBase.defaultProps), { required: false, size: 'medium', rounded: 'medium', fillMode: 'solid' });
|
|
723
|
+
DropDownListWithoutContext.defaultProps = __assign(__assign({ delay: 500, tabIndex: 0, ignoreCase: true }, DropDownBase.defaultProps), { required: false, size: 'medium', rounded: 'medium', fillMode: 'solid', groupMode: 'modern' });
|
|
679
724
|
return DropDownListWithoutContext;
|
|
680
725
|
}(React.Component));
|
|
681
726
|
export { DropDownListWithoutContext };
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { DropDownList } from './DropDownList';
|
|
3
3
|
import { FilterChangeEvent, ChangeEvent, OpenEvent, CloseEvent, FocusEvent, BlurEvent, PageChangeEvent } from './../common/events';
|
|
4
4
|
import { VirtualizationSettings, DropDownsPopupSettings } from '../common/settings';
|
|
5
|
+
import { ListGroupItemProps } from '../common/ListGroupItem';
|
|
6
|
+
import { GroupStickyHeaderProps } from '../common/GroupStickyHeader';
|
|
5
7
|
import { ListItemProps } from '../common/ListItem';
|
|
6
8
|
import { FormComponentProps, SVGIcon } from '@progress/kendo-react-common';
|
|
7
9
|
/**
|
|
@@ -297,4 +299,24 @@ export interface DropDownListProps extends FormComponentProps {
|
|
|
297
299
|
* Specifies the text that is rendered as title in the adaptive popup.
|
|
298
300
|
*/
|
|
299
301
|
adaptiveTitle?: string;
|
|
302
|
+
/**
|
|
303
|
+
* Sets the data item field that represents the start of a group. Applicable to objects data.
|
|
304
|
+
*/
|
|
305
|
+
groupField?: string;
|
|
306
|
+
/**
|
|
307
|
+
* Fires when a DropDownList's group header item is about to be rendered. Used to override the default appearance of the group's headers.
|
|
308
|
+
*/
|
|
309
|
+
groupHeaderItemRender?: (li: React.ReactElement<HTMLLIElement>, itemProps: ListGroupItemProps) => React.ReactNode;
|
|
310
|
+
/**
|
|
311
|
+
* Fires when a DropDownList's sticky group header item is about to be rendered. Used to override the default appearance of the sticky group header of the component.
|
|
312
|
+
*/
|
|
313
|
+
groupStickyHeaderItemRender?: (div: React.ReactElement<HTMLDivElement>, stickyHeaderProps: GroupStickyHeaderProps) => React.ReactNode;
|
|
314
|
+
/**
|
|
315
|
+
* @hidden
|
|
316
|
+
*/
|
|
317
|
+
list?: any;
|
|
318
|
+
/**
|
|
319
|
+
* @hidden
|
|
320
|
+
*/
|
|
321
|
+
groupMode?: string;
|
|
300
322
|
}
|