@progress/kendo-react-dropdowns 5.13.0-dev.202304180747 → 5.13.0-dev.202304200917
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/DropDownTree/DropDownTree.js +81 -26
- package/dist/es/DropDownTree/DropDownTreeProps.d.ts +8 -0
- package/dist/es/MultiColumnComboBox/MultiColumnComboBox.js +7 -5
- package/dist/es/MultiSelect/MultiSelect.d.ts +5 -0
- package/dist/es/MultiSelect/MultiSelect.js +51 -10
- package/dist/es/MultiSelect/MultiSelectProps.d.ts +22 -0
- package/dist/es/common/AdaptiveMode.js +1 -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/DropDownTree/DropDownTree.js +80 -25
- package/dist/npm/DropDownTree/DropDownTreeProps.d.ts +8 -0
- package/dist/npm/MultiColumnComboBox/MultiColumnComboBox.js +7 -5
- package/dist/npm/MultiSelect/MultiSelect.d.ts +5 -0
- package/dist/npm/MultiSelect/MultiSelect.js +51 -10
- package/dist/npm/MultiSelect/MultiSelectProps.d.ts +22 -0
- package/dist/npm/common/AdaptiveMode.js +1 -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
|
@@ -18,9 +18,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
18
18
|
}
|
|
19
19
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
20
|
};
|
|
21
|
+
var _this = this;
|
|
21
22
|
import * as React from 'react';
|
|
22
23
|
import * as PropTypes from 'prop-types';
|
|
23
|
-
import { classNames, noop, useRtl, getTabIndex, Keys, mapTree, extendDataItem, guid, createPropsContext, kendoThemeMaps, usePropsContext, IconWrap } from '@progress/kendo-react-common';
|
|
24
|
+
import { classNames, noop, useRtl, getTabIndex, Keys, mapTree, extendDataItem, guid, createPropsContext, kendoThemeMaps, usePropsContext, IconWrap, canUseDOM } from '@progress/kendo-react-common';
|
|
24
25
|
import { Popup } from '@progress/kendo-react-popup';
|
|
25
26
|
import { useLocalization } from '@progress/kendo-react-intl';
|
|
26
27
|
import { TreeView } from '@progress/kendo-react-treeview';
|
|
@@ -34,6 +35,9 @@ import { FloatingLabel } from '@progress/kendo-react-labels';
|
|
|
34
35
|
import ListFilter from '../common/ListFilter';
|
|
35
36
|
import { Button } from '@progress/kendo-react-buttons';
|
|
36
37
|
import { xIcon, caretAltDownIcon } from '@progress/kendo-svg-icons';
|
|
38
|
+
import { AdaptiveMode } from '../common/AdaptiveMode';
|
|
39
|
+
import { ActionSheetContent } from '@progress/kendo-react-layout';
|
|
40
|
+
import { MOBILE_MEDIUM_DEVISE } from '../common/constants';
|
|
37
41
|
var sizeMap = kendoThemeMaps.sizeMap, roundedMap = kendoThemeMaps.roundedMap;
|
|
38
42
|
var VALIDATION_MESSAGE = 'Please select a value from the list!';
|
|
39
43
|
var ValueHolder = function (props) {
|
|
@@ -88,6 +92,7 @@ export var DropDownTree = React.forwardRef(function (directProps, ref) {
|
|
|
88
92
|
var target = React.useRef(null);
|
|
89
93
|
var elementRef = React.useRef(null);
|
|
90
94
|
var inputRef = React.useRef(null);
|
|
95
|
+
var adaptiveInputRef = React.useRef(null);
|
|
91
96
|
var selectRef = React.useRef(null);
|
|
92
97
|
var treeViewRef = React.useRef(null);
|
|
93
98
|
var skipFocusRef = React.useRef(false);
|
|
@@ -113,6 +118,8 @@ export var DropDownTree = React.forwardRef(function (directProps, ref) {
|
|
|
113
118
|
var isOpen = opened !== undefined ? opened : open;
|
|
114
119
|
var _l = React.useState(false), focused = _l[0], setFocused = _l[1];
|
|
115
120
|
var _m = React.useState(''), filter = _m[0], setFilter = _m[1];
|
|
121
|
+
var _o = React.useState(), windowWidth = _o[0], setWindowWidth = _o[1];
|
|
122
|
+
var isAdaptive = !!(windowWidth && windowWidth <= MOBILE_MEDIUM_DEVISE && props.adaptive);
|
|
116
123
|
var setValidity = React.useCallback(function () {
|
|
117
124
|
if (selectRef.current && selectRef.current.setCustomValidity) {
|
|
118
125
|
selectRef.current.setCustomValidity(validity.valid
|
|
@@ -121,6 +128,17 @@ export var DropDownTree = React.forwardRef(function (directProps, ref) {
|
|
|
121
128
|
}
|
|
122
129
|
}, [validationMessage, validity]);
|
|
123
130
|
React.useEffect(setValidity);
|
|
131
|
+
React.useEffect(function () {
|
|
132
|
+
var observerResize = canUseDOM && window.ResizeObserver && new window.ResizeObserver(calculateMedia.bind(_this));
|
|
133
|
+
if ((document === null || document === void 0 ? void 0 : document.body) && observerResize) {
|
|
134
|
+
observerResize.observe(document.body);
|
|
135
|
+
}
|
|
136
|
+
return function () {
|
|
137
|
+
if ((document === null || document === void 0 ? void 0 : document.body) && observerResize) {
|
|
138
|
+
observerResize.disconnect();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}, []);
|
|
124
142
|
var openPopup = React.useCallback(function (event) {
|
|
125
143
|
if (!isOpen) {
|
|
126
144
|
if (onOpen) {
|
|
@@ -140,9 +158,14 @@ export var DropDownTree = React.forwardRef(function (directProps, ref) {
|
|
|
140
158
|
}
|
|
141
159
|
if (opened === undefined) {
|
|
142
160
|
setOpen(false);
|
|
161
|
+
if (isAdaptive) {
|
|
162
|
+
setTimeout(function () {
|
|
163
|
+
focusElement(adaptiveInputRef.current);
|
|
164
|
+
}, 300);
|
|
165
|
+
}
|
|
143
166
|
}
|
|
144
167
|
}
|
|
145
|
-
}, [isOpen, opened, onClose]);
|
|
168
|
+
}, [isOpen, opened, onClose, isAdaptive]);
|
|
146
169
|
var onWrapperClick = React.useCallback(function (event) {
|
|
147
170
|
if (!event.isDefaultPrevented() && target.current) {
|
|
148
171
|
setFocused(true);
|
|
@@ -258,7 +281,9 @@ export var DropDownTree = React.forwardRef(function (directProps, ref) {
|
|
|
258
281
|
var focusEvent = __assign({}, ev);
|
|
259
282
|
props.onBlur.call(undefined, focusEvent);
|
|
260
283
|
}
|
|
261
|
-
|
|
284
|
+
if (!isAdaptive) {
|
|
285
|
+
closePopup(ev);
|
|
286
|
+
}
|
|
262
287
|
}
|
|
263
288
|
}, [focused, props.onBlur, isOpen, opened, onClose]);
|
|
264
289
|
var onWrapperMouseDown = React.useCallback(function () {
|
|
@@ -266,7 +291,12 @@ export var DropDownTree = React.forwardRef(function (directProps, ref) {
|
|
|
266
291
|
// moving focus from treeview to dropdown triggers Focus and Blur events.
|
|
267
292
|
switchFocus(noop);
|
|
268
293
|
}
|
|
269
|
-
|
|
294
|
+
if (isAdaptive) {
|
|
295
|
+
setTimeout(function () {
|
|
296
|
+
focusElement(adaptiveInputRef.current);
|
|
297
|
+
}, 300);
|
|
298
|
+
}
|
|
299
|
+
}, [focused, isAdaptive]);
|
|
270
300
|
var changeValue = React.useCallback(function (event, newValue, hierarchicalIndex) {
|
|
271
301
|
if (props.onChange) {
|
|
272
302
|
var changeEvent = __assign({ value: newValue, level: hierarchicalIndex ? toLevel(hierarchicalIndex) : [] }, event);
|
|
@@ -331,6 +361,27 @@ export var DropDownTree = React.forwardRef(function (directProps, ref) {
|
|
|
331
361
|
}
|
|
332
362
|
}
|
|
333
363
|
}, [props.onFilterChange, props.filter, props.textField]);
|
|
364
|
+
var renderAdaptiveListContainer = function () {
|
|
365
|
+
var mobileFilter = props.filterable ? (React.createElement(ListFilter, { value: props.filter === undefined ? filter : props.filter, inputRef: adaptiveInputRef, onChange: onFilterChange, onKeyDown: onInputKeyDown, size: size, rounded: rounded, fillMode: fillMode })) : null;
|
|
366
|
+
var actionSheetProps = {
|
|
367
|
+
adaptiveTitle: props.adaptiveTitle,
|
|
368
|
+
expand: isOpen,
|
|
369
|
+
onClose: function (event) { return closePopup(event); },
|
|
370
|
+
windowWidth: windowWidth,
|
|
371
|
+
mobileFilter: mobileFilter
|
|
372
|
+
};
|
|
373
|
+
return (React.createElement(AdaptiveMode, __assign({}, actionSheetProps),
|
|
374
|
+
React.createElement(ActionSheetContent, { className: '!k-overflow-hidden' },
|
|
375
|
+
React.createElement("div", { className: 'k-list-container' },
|
|
376
|
+
React.createElement("div", { className: 'k-list k-list-lg' }, data.length > 0 ? (React.createElement(TreeView, { ref: treeViewRef, tabIndex: tabIndex, data: treeViewData, focusIdField: dataItemKey, textField: props.textField, selectField: selectField, expandField: props.expandField, childrenField: subItemsField, expandIcons: true, onItemClick: onChange, onExpandChange: onExpand, size: size, item: props.item })) : (React.createElement(NoData, null, localization.toLanguageString(nodata, messages[nodata]))))))));
|
|
377
|
+
};
|
|
378
|
+
var calculateMedia = React.useCallback(function (entries) {
|
|
379
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
380
|
+
var entry = entries_1[_i];
|
|
381
|
+
setWindowWidth(entry.target.clientWidth);
|
|
382
|
+
}
|
|
383
|
+
;
|
|
384
|
+
}, []);
|
|
334
385
|
var treeViewData = React.useMemo(function () {
|
|
335
386
|
return (controlled || !hasValue) ? data :
|
|
336
387
|
mapTree(data, subItemsField, function (item) {
|
|
@@ -343,27 +394,29 @@ export var DropDownTree = React.forwardRef(function (directProps, ref) {
|
|
|
343
394
|
var localization = useLocalization();
|
|
344
395
|
var isValid = !validityStyles || validity.valid;
|
|
345
396
|
var size = props.size, rounded = props.rounded, fillMode = props.fillMode;
|
|
346
|
-
var dropdowntree = (React.createElement(
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
React.createElement(
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
React.createElement(
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
React.createElement("
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
397
|
+
var dropdowntree = (React.createElement(React.Fragment, null,
|
|
398
|
+
React.createElement("span", { className: classNames('k-dropdowntree k-picker', props.className, (_a = {},
|
|
399
|
+
_a["k-picker-".concat(sizeMap[size] || size)] = size,
|
|
400
|
+
_a["k-rounded-".concat(roundedMap[rounded] || rounded)] = rounded,
|
|
401
|
+
_a["k-picker-".concat(fillMode)] = fillMode,
|
|
402
|
+
_a['k-focus'] = focused,
|
|
403
|
+
_a['k-invalid'] = !isValid,
|
|
404
|
+
_a['k-loading'] = props.loading,
|
|
405
|
+
_a['k-required'] = required,
|
|
406
|
+
_a['k-disabled'] = props.disabled,
|
|
407
|
+
_a)), tabIndex: tabIndex, accessKey: props.accessKey, id: id, style: label ? __assign(__assign({}, style), { width: undefined }) : style, dir: dir, ref: elementRef, onKeyDown: disabled ? undefined : onWrapperKeyDown, onMouseDown: onWrapperMouseDown, onClick: disabled ? undefined : onWrapperClick, onFocus: onFocus, onBlur: onBlur, role: "combobox", "aria-haspopup": "tree", "aria-expanded": isOpen, "aria-disabled": disabled, "aria-label": label, "aria-labelledby": props.ariaLabelledBy, "aria-describedby": props.ariaDescribedBy, "aria-required": required },
|
|
408
|
+
React.createElement("span", { className: "k-input-inner" },
|
|
409
|
+
React.createElement(ValueComponent, { item: value }, currentValueText || placeholder)),
|
|
410
|
+
props.loading && React.createElement(IconWrap, { className: "k-input-loading-icon", name: 'loading' }),
|
|
411
|
+
hasValue && !disabled && (React.createElement("span", { onClick: onClear, className: "k-clear-value", title: localization.toLanguageString(clear, messages[clear]), role: "button", tabIndex: -1, onMouseDown: function (e) { return e.preventDefault(); } },
|
|
412
|
+
React.createElement(IconWrap, { name: 'x', icon: xIcon }))),
|
|
413
|
+
React.createElement(Button, { tabIndex: -1, type: "button", "aria-label": "select", className: "k-input-button", size: size, fillMode: fillMode, themeColor: "base", rounded: null, icon: "caret-alt-down", svgIcon: caretAltDownIcon }),
|
|
414
|
+
React.createElement("select", { name: name, ref: selectRef, tabIndex: -1, "aria-hidden": true, title: label, style: { opacity: 0, width: 1, border: 0, zIndex: -1, position: 'absolute', left: '50%' } },
|
|
415
|
+
React.createElement("option", { value: props.valueMap ? props.valueMap.call(undefined, value) : value })),
|
|
416
|
+
!isAdaptive && React.createElement(Popup, { className: classNames(popupSettings.className, { 'k-rtl': dir === 'rtl' }), popupClass: classNames(popupSettings.popupClass, 'k-list-container', 'k-dropdowntree-popup'), style: popupStyles, animate: popupSettings.animate, anchor: elementRef.current, show: isOpen, onOpen: onPopupOpened, onClose: onPopupClosed, appendTo: popupSettings.appendTo },
|
|
417
|
+
props.filterable && (React.createElement(ListFilter, { value: props.filter === undefined ? filter : props.filter, inputRef: inputRef, onChange: onFilterChange, onKeyDown: onInputKeyDown, size: size, rounded: rounded, fillMode: fillMode })),
|
|
418
|
+
data.length > 0 ? (React.createElement(TreeView, { ref: treeViewRef, tabIndex: tabIndex, data: treeViewData, focusIdField: dataItemKey, textField: props.textField, selectField: selectField, expandField: props.expandField, childrenField: subItemsField, expandIcons: true, onItemClick: onChange, onExpandChange: onExpand, size: size, item: props.item })) : (React.createElement(NoData, null, localization.toLanguageString(nodata, messages[nodata]))))),
|
|
419
|
+
isAdaptive && renderAdaptiveListContainer()));
|
|
367
420
|
return label ? (React.createElement(FloatingLabel, { label: label, editorValue: currentValueText, editorPlaceholder: placeholder, editorValid: isValid, editorDisabled: disabled, editorId: id, style: { width: style ? style.width : undefined }, children: dropdowntree, dir: dir })) : dropdowntree;
|
|
368
421
|
});
|
|
369
422
|
var propTypes = {
|
|
@@ -415,7 +468,9 @@ var propTypes = {
|
|
|
415
468
|
onExpandChange: PropTypes.func,
|
|
416
469
|
item: PropTypes.func,
|
|
417
470
|
valueHolder: PropTypes.func,
|
|
418
|
-
listNoData: PropTypes.func
|
|
471
|
+
listNoData: PropTypes.func,
|
|
472
|
+
adaptiveTitle: PropTypes.string,
|
|
473
|
+
adaptive: PropTypes.bool
|
|
419
474
|
};
|
|
420
475
|
DropDownTree.displayName = 'KendoReactDropDownTree';
|
|
421
476
|
DropDownTree.defaultProps = defaultProps;
|
|
@@ -283,4 +283,12 @@ export interface DropDownTreeProps extends FormComponentProps {
|
|
|
283
283
|
* @default `solid`
|
|
284
284
|
*/
|
|
285
285
|
fillMode?: null | 'solid' | 'flat' | 'outline';
|
|
286
|
+
/**
|
|
287
|
+
* Providing different rendering of the popup element based on the screen dimensions.
|
|
288
|
+
*/
|
|
289
|
+
adaptive?: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Specifies the text that is rendered as title in the adaptive popup.
|
|
292
|
+
*/
|
|
293
|
+
adaptiveTitle?: string;
|
|
286
294
|
}
|
|
@@ -73,6 +73,9 @@ export var MultiColumnComboBox = React.forwardRef(function (directProps, ref) {
|
|
|
73
73
|
}, [props.data, props.groupField]);
|
|
74
74
|
var _c = React.useState(initialGroupHeader), groupHeader = _c[0], setGroupHeader = _c[1];
|
|
75
75
|
var header = React.useMemo(function () {
|
|
76
|
+
var renderer = (React.createElement("th", { className: 'k-table-th', colSpan: columns.length },
|
|
77
|
+
groupHeader,
|
|
78
|
+
" "));
|
|
76
79
|
return (React.createElement(React.Fragment, null,
|
|
77
80
|
props.header,
|
|
78
81
|
React.createElement("div", { className: "k-table-header-wrap" },
|
|
@@ -84,8 +87,7 @@ export var MultiColumnComboBox = React.forwardRef(function (directProps, ref) {
|
|
|
84
87
|
React.createElement("tr", { className: 'k-table-row' }, columns.map(function (column, i) {
|
|
85
88
|
return (React.createElement("th", { className: "k-table-th", key: column.uniqueKey ? column.uniqueKey : i }, column.header || '\u00A0'));
|
|
86
89
|
})),
|
|
87
|
-
groupHeader && React.createElement("tr", { className: 'k-table-group-row' },
|
|
88
|
-
React.createElement("th", { className: 'k-table-th', colSpan: columns.length }, groupHeader)))))));
|
|
90
|
+
groupHeader && React.createElement("tr", { className: 'k-table-group-row' }, props.groupStickyHeaderItemRender ? props.groupStickyHeaderItemRender.call(undefined, renderer, {}) : renderer))))));
|
|
89
91
|
}, [props.header, columns, groupHeader]);
|
|
90
92
|
var popupWidth = React.useMemo(function () {
|
|
91
93
|
// These additional 4px are coming from the child elements side borders (fixes horizontal scrollbar)
|
|
@@ -93,7 +95,7 @@ export var MultiColumnComboBox = React.forwardRef(function (directProps, ref) {
|
|
|
93
95
|
}, [columns, scrollbarWidth]);
|
|
94
96
|
var skip = props.virtual ? props.virtual.skip : 0;
|
|
95
97
|
var itemRender = React.useCallback(function (li, liProps) {
|
|
96
|
-
var children = columns.map(function (column, i) { return (React.createElement("span", { className:
|
|
98
|
+
var children = columns.map(function (column, i) { return (React.createElement("span", { className: !props.itemRender ? 'k-table-td' : undefined, style: !props.itemRender ? { width: column.width ? column.width : defaultProps.width } : undefined, key: column.uniqueKey ? column.uniqueKey : i }, column.field ? getter(column.field)(liProps.dataItem) : '')); });
|
|
97
99
|
var group = undefined;
|
|
98
100
|
var curGroup, prevGroup, groupGetter, data = props.data || [];
|
|
99
101
|
var index = liProps.index - skip;
|
|
@@ -105,7 +107,7 @@ export var MultiColumnComboBox = React.forwardRef(function (directProps, ref) {
|
|
|
105
107
|
group = curGroup;
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
|
-
if (group) {
|
|
110
|
+
if (group && props.groupMode === 'classic') {
|
|
109
111
|
children.push(React.createElement("div", { key: "group", className: "k-table-td k-table-group-td" },
|
|
110
112
|
React.createElement("span", null, group)));
|
|
111
113
|
}
|
|
@@ -134,7 +136,7 @@ export var MultiColumnComboBox = React.forwardRef(function (directProps, ref) {
|
|
|
134
136
|
}, []);
|
|
135
137
|
React.useEffect(function () { setScrollbarWidth(); });
|
|
136
138
|
var List = React.useCallback(function (listProps) { return React.createElement(MultiColumnList, __assign({}, listProps)); }, []);
|
|
137
|
-
return (React.createElement(ComboBox, __assign({}, other, { list: List, popupSettings: __assign(__assign({ width: popupWidth }, popupSettings), { popupClass: 'k-dropdowngrid-popup k-reset', className: popupSettings.className }), ref: comboBoxRef, header: header, itemRender: itemRender, size: props.size, rounded: props.rounded, fillMode: props.fillMode, onOpen: onOpenHandler, onClose: onCloseHandler, onFocus: onFocusHandler, onBlur: onBlurHandler, onChange: onChangeHandler, onFilterChange: onFilterChangeHandler, onPageChange: onPageChangeHandler, onGroupScroll: onGroupScroll, className: classNames('k-dropdowngrid', className), required: props.required })));
|
|
139
|
+
return (React.createElement(ComboBox, __assign({}, other, { list: List, popupSettings: __assign(__assign({ width: popupWidth }, popupSettings), { popupClass: 'k-dropdowngrid-popup k-reset', className: popupSettings.className }), ref: comboBoxRef, header: header, itemRender: itemRender, groupHeaderItemRender: props.groupHeaderItemRender, size: props.size, rounded: props.rounded, fillMode: props.fillMode, groupMode: props.groupMode, groupField: props.groupField, isMultiColumn: true, onOpen: onOpenHandler, onClose: onCloseHandler, onFocus: onFocusHandler, onBlur: onBlurHandler, onChange: onChangeHandler, onFilterChange: onFilterChangeHandler, onPageChange: onPageChangeHandler, onGroupScroll: onGroupScroll, className: classNames('k-dropdowngrid', className), required: props.required })));
|
|
138
140
|
});
|
|
139
141
|
var propTypes = __assign(__assign({}, ComboBoxWithoutContext.propTypes), { columns: PropTypes.any.isRequired });
|
|
140
142
|
var defaultProps = {
|
|
@@ -41,6 +41,8 @@ export declare class MultiSelectWithoutContext extends React.Component<MultiSele
|
|
|
41
41
|
id: PropTypes.Requireable<string>;
|
|
42
42
|
ariaLabelledBy: PropTypes.Requireable<string>;
|
|
43
43
|
ariaDescribedBy: PropTypes.Requireable<string>;
|
|
44
|
+
groupField: PropTypes.Requireable<string>;
|
|
45
|
+
list: PropTypes.Requireable<any>;
|
|
44
46
|
filterable: PropTypes.Requireable<boolean>;
|
|
45
47
|
filter: PropTypes.Requireable<string>;
|
|
46
48
|
virtual: PropTypes.Requireable<PropTypes.InferProps<{
|
|
@@ -91,6 +93,7 @@ export declare class MultiSelectWithoutContext extends React.Component<MultiSele
|
|
|
91
93
|
size: "small" | "medium" | "large" | null | undefined;
|
|
92
94
|
rounded: "small" | "medium" | "full" | "large" | null | undefined;
|
|
93
95
|
fillMode: "flat" | "outline" | "solid" | null | undefined;
|
|
96
|
+
groupMode: string | undefined;
|
|
94
97
|
popupSettings: {
|
|
95
98
|
height: string;
|
|
96
99
|
};
|
|
@@ -107,6 +110,7 @@ export declare class MultiSelectWithoutContext extends React.Component<MultiSele
|
|
|
107
110
|
private readonly _tags;
|
|
108
111
|
private _input;
|
|
109
112
|
private _skipFocusEvent;
|
|
113
|
+
private itemHeight;
|
|
110
114
|
protected scrollToFocused: boolean;
|
|
111
115
|
constructor(props: MultiSelectProps);
|
|
112
116
|
/**
|
|
@@ -175,6 +179,7 @@ export declare class MultiSelectWithoutContext extends React.Component<MultiSele
|
|
|
175
179
|
private getFocusedState;
|
|
176
180
|
private renderListContainer;
|
|
177
181
|
private renderList;
|
|
182
|
+
private onScroll;
|
|
178
183
|
private customItemSelect;
|
|
179
184
|
private handleWrapperClick;
|
|
180
185
|
private handleItemClick;
|
|
@@ -40,6 +40,7 @@ import { plusIcon } from '@progress/kendo-svg-icons';
|
|
|
40
40
|
import { FloatingLabel } from '@progress/kendo-react-labels';
|
|
41
41
|
import ListContainer from '../common/ListContainer';
|
|
42
42
|
import List from '../common/List';
|
|
43
|
+
import GroupStickyHeader from '../common/GroupStickyHeader';
|
|
43
44
|
import TagList from './TagList';
|
|
44
45
|
import SearchBar from '../common/SearchBar';
|
|
45
46
|
import DropDownBase from '../common/DropDownBase';
|
|
@@ -76,6 +77,7 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
|
|
|
76
77
|
_this._tags = [];
|
|
77
78
|
_this._input = null;
|
|
78
79
|
_this._skipFocusEvent = false;
|
|
80
|
+
_this.itemHeight = 0;
|
|
79
81
|
_this.scrollToFocused = false;
|
|
80
82
|
/**
|
|
81
83
|
* @hidden
|
|
@@ -250,7 +252,7 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
|
|
|
250
252
|
_this.renderListContainer = function () {
|
|
251
253
|
var _a, _b;
|
|
252
254
|
var base = _this.base;
|
|
253
|
-
var _c = _this.props, header = _c.header, footer = _c.footer, allowCustom = _c.allowCustom, dir = _c.dir, _d = _c.data, data = _d === void 0 ? [] : _d, size = _c.size;
|
|
255
|
+
var _c = _this.props, header = _c.header, footer = _c.footer, allowCustom = _c.allowCustom, dir = _c.dir, _d = _c.data, data = _d === void 0 ? [] : _d, size = _c.size, groupStickyHeaderItemRender = _c.groupStickyHeaderItemRender, groupField = _c.groupField, list = _c.list;
|
|
254
256
|
var popupSettings = _this.base.getPopupSettings();
|
|
255
257
|
var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
|
|
256
258
|
var text = _this.props.filter !== undefined ? _this.props.filter : _this.state.text;
|
|
@@ -277,26 +279,60 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
|
|
|
277
279
|
React.createElement("div", { className: classNames('k-list-item k-custom-item', { 'k-focus': isCustom(focusedType) }), style: { fontStyle: 'italic' } },
|
|
278
280
|
text,
|
|
279
281
|
React.createElement(IconWrap, { name: 'plus', icon: plusIcon, style: { position: 'absolute', right: '0.5em' } }))));
|
|
282
|
+
var group = _this.state.group;
|
|
283
|
+
if (group === undefined && groupField !== undefined) {
|
|
284
|
+
group = getItemValue(data[0], groupField);
|
|
285
|
+
}
|
|
280
286
|
return (React.createElement(ListContainer, __assign({}, listContainerProps),
|
|
281
287
|
header && React.createElement("div", { className: "k-list-header" }, header),
|
|
282
288
|
customItem,
|
|
283
289
|
React.createElement("div", { className: classNames('k-list', (_b = {},
|
|
284
290
|
_b["k-list-".concat(sizeMap[size] || size)] = size,
|
|
285
291
|
_b['k-virtual-list'] = _this.base.vs.enabled,
|
|
286
|
-
_b)) },
|
|
292
|
+
_b)) },
|
|
293
|
+
!list && group && React.createElement(GroupStickyHeader, { group: group, groupMode: 'modern', render: groupStickyHeaderItemRender }),
|
|
294
|
+
_this.renderList()),
|
|
287
295
|
footer && React.createElement("div", { className: "k-list-footer" }, footer)));
|
|
288
296
|
};
|
|
289
297
|
_this.renderList = function () {
|
|
290
|
-
var _a = _this.props, _b = _a.data, data = _b === void 0 ? [] : _b, textField = _a.textField, listNoDataRender = _a.listNoDataRender, itemRender = _a.itemRender, dataItemKey = _a.dataItemKey, virtual = _a.virtual;
|
|
298
|
+
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;
|
|
291
299
|
var vs = _this.base.vs;
|
|
292
300
|
var skip = virtual ? virtual.skip : 0;
|
|
293
301
|
var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
|
|
294
302
|
var focusedIndex = _this.getFocusedState().focusedIndex;
|
|
295
303
|
var popupSettings = _this.base.getPopupSettings();
|
|
296
304
|
var translate = "translateY(".concat(vs.translate, "px)");
|
|
297
|
-
return (React.createElement(List, { id: _this.base.listBoxId, show: opened, data: data.slice(), focusedIndex: focusedIndex - skip, value: _this.value, textField: textField, valueField: dataItemKey, optionsGuid: _this.base.guid, listRef: function (list) { vs.list = _this.base.list = list; }, wrapperStyle: { maxHeight: popupSettings.height }, wrapperCssClass: "k-list-content", listStyle: vs.enabled ? { transform: translate } : undefined, key: "listKey", skip: skip, onClick: _this.handleItemClick, itemRender: itemRender, noDataRender: listNoDataRender, onMouseDown: preventDefault, onBlur: _this.handleBlur, onScroll:
|
|
298
|
-
|
|
299
|
-
|
|
305
|
+
return (React.createElement(List, { id: _this.base.listBoxId, show: opened, data: data.slice(), focusedIndex: focusedIndex - skip, value: _this.value, textField: textField, valueField: dataItemKey, optionsGuid: _this.base.guid, groupField: _this.props.groupField, groupMode: 'modern', listRef: function (list) { vs.list = _this.base.list = list; }, wrapperStyle: { maxHeight: popupSettings.height }, wrapperCssClass: "k-list-content", listStyle: vs.enabled ? { transform: translate } : undefined, key: "listKey", skip: skip, onClick: _this.handleItemClick, itemRender: itemRender, groupHeaderItemRender: groupHeaderItemRender, noDataRender: listNoDataRender, onMouseDown: preventDefault, onBlur: _this.handleBlur, onScroll: _this.onScroll, wrapperRef: vs.scrollerRef, scroller: _this.base.renderScrollElement() }));
|
|
306
|
+
};
|
|
307
|
+
_this.onScroll = function (event) {
|
|
308
|
+
var _a = _this.base, vs = _a.vs, list = _a.list;
|
|
309
|
+
vs.scrollHandler(event);
|
|
310
|
+
var groupField = _this.props.groupField;
|
|
311
|
+
var _b = _this.props.data, data = _b === void 0 ? [] : _b;
|
|
312
|
+
if (!groupField || !data.length) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (groupField) {
|
|
316
|
+
var itemHeight = _this.itemHeight =
|
|
317
|
+
_this.itemHeight || (vs.enabled ? vs.itemHeight : (list ? list.children[0].offsetHeight : 0));
|
|
318
|
+
var target = event.target;
|
|
319
|
+
var scrollTop = target.scrollTop - (vs.skip * itemHeight);
|
|
320
|
+
data = _this.base.getGroupedDataModernMode(data, groupField);
|
|
321
|
+
var group = data[0][groupField];
|
|
322
|
+
for (var i = 1; i < data.length; i++) {
|
|
323
|
+
if (itemHeight * i > scrollTop) {
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
if (data[i] && data[i][groupField]) {
|
|
327
|
+
group = data[i][groupField];
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (group !== _this.state.group) {
|
|
331
|
+
_this.setState({
|
|
332
|
+
group: group
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
300
336
|
};
|
|
301
337
|
_this.customItemSelect = function (event) {
|
|
302
338
|
var _a;
|
|
@@ -478,7 +514,9 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
|
|
|
478
514
|
* @hidden
|
|
479
515
|
*/
|
|
480
516
|
MultiSelectWithoutContext.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
481
|
-
var
|
|
517
|
+
var _a;
|
|
518
|
+
var _b = this.props, virtual = _b.virtual, _c = _b.groupField, groupField = _c === void 0 ? '' : _c;
|
|
519
|
+
var _d = this.props.data, data = _d === void 0 ? [] : _d;
|
|
482
520
|
var skip = virtual ? virtual.skip : 0;
|
|
483
521
|
var prevTotal = prevProps.virtual ? prevProps.virtual.total : 0;
|
|
484
522
|
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
@@ -494,7 +532,10 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
|
|
|
494
532
|
this.base.vs.reset();
|
|
495
533
|
}
|
|
496
534
|
else {
|
|
497
|
-
var
|
|
535
|
+
var _e = this.getFocusedState(), focusedItem = _e.focusedItem, focusedIndex = _e.focusedIndex;
|
|
536
|
+
if (groupField !== '') {
|
|
537
|
+
focusedIndex = (_a = this.base.getGroupedDataModernMode(data, groupField)) === null || _a === void 0 ? void 0 : _a.indexOf(focusedItem);
|
|
538
|
+
}
|
|
498
539
|
if (opening && virtual) {
|
|
499
540
|
this.base.scrollToVirtualItem(virtual, focusedIndex - skip);
|
|
500
541
|
}
|
|
@@ -743,11 +784,11 @@ var MultiSelectWithoutContext = /** @class */ (function (_super) {
|
|
|
743
784
|
MultiSelectWithoutContext.propTypes = __assign(__assign({}, DropDownBase.propTypes), { autoClose: PropTypes.bool, value: PropTypes.arrayOf(PropTypes.any), defaultValue: PropTypes.arrayOf(PropTypes.any), dataItemKey: PropTypes.string, placeholder: PropTypes.string, tags: PropTypes.arrayOf(PropTypes.shape({
|
|
744
785
|
text: PropTypes.string,
|
|
745
786
|
data: PropTypes.arrayOf(PropTypes.any)
|
|
746
|
-
})), tagRender: PropTypes.func, id: PropTypes.string, ariaLabelledBy: PropTypes.string, ariaDescribedBy: PropTypes.string });
|
|
787
|
+
})), tagRender: PropTypes.func, id: PropTypes.string, ariaLabelledBy: PropTypes.string, ariaDescribedBy: PropTypes.string, groupField: PropTypes.string, list: PropTypes.any });
|
|
747
788
|
/**
|
|
748
789
|
* @hidden
|
|
749
790
|
*/
|
|
750
|
-
MultiSelectWithoutContext.defaultProps = __assign(__assign({}, DropDownBase.defaultProps), { autoClose: true, required: false, size: 'medium', rounded: 'medium', fillMode: 'solid' });
|
|
791
|
+
MultiSelectWithoutContext.defaultProps = __assign(__assign({}, DropDownBase.defaultProps), { autoClose: true, required: false, size: 'medium', rounded: 'medium', fillMode: 'solid', groupMode: 'modern' });
|
|
751
792
|
return MultiSelectWithoutContext;
|
|
752
793
|
}(React.Component));
|
|
753
794
|
export { MultiSelectWithoutContext };
|
|
@@ -3,6 +3,8 @@ import { MultiSelect } from './MultiSelect';
|
|
|
3
3
|
import { FormComponentProps } from '@progress/kendo-react-common';
|
|
4
4
|
import { FilterChangeEvent, ChangeEvent, OpenEvent, CloseEvent, FocusEvent, BlurEvent, PageChangeEvent } from './../common/events';
|
|
5
5
|
import { VirtualizationSettings, DropDownsPopupSettings } from '../common/settings';
|
|
6
|
+
import { ListGroupItemProps } from '../common/ListGroupItem';
|
|
7
|
+
import { GroupStickyHeaderProps } from '../common/GroupStickyHeader';
|
|
6
8
|
import { ListItemProps } from '../common/ListItem';
|
|
7
9
|
import { TagData } from './TagList';
|
|
8
10
|
/**
|
|
@@ -264,4 +266,24 @@ export interface MultiSelectProps extends FormComponentProps {
|
|
|
264
266
|
* @default `solid`
|
|
265
267
|
*/
|
|
266
268
|
fillMode?: null | 'solid' | 'flat' | 'outline';
|
|
269
|
+
/**
|
|
270
|
+
* Sets the data item field that represents the start of a group. Applicable to objects data.
|
|
271
|
+
*/
|
|
272
|
+
groupField?: string;
|
|
273
|
+
/**
|
|
274
|
+
* Fires when a DropDownList's group header item is about to be rendered. Used to override the default appearance of the group's headers.
|
|
275
|
+
*/
|
|
276
|
+
groupHeaderItemRender?: (li: React.ReactElement<HTMLLIElement>, itemProps: ListGroupItemProps) => React.ReactNode;
|
|
277
|
+
/**
|
|
278
|
+
* 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.
|
|
279
|
+
*/
|
|
280
|
+
groupStickyHeaderItemRender?: (div: React.ReactElement<HTMLDivElement>, stickyHeaderProps: GroupStickyHeaderProps) => React.ReactNode;
|
|
281
|
+
/**
|
|
282
|
+
* @hidden
|
|
283
|
+
*/
|
|
284
|
+
list?: any;
|
|
285
|
+
/**
|
|
286
|
+
* @hidden
|
|
287
|
+
*/
|
|
288
|
+
groupMode?: string;
|
|
267
289
|
}
|
|
@@ -22,7 +22,7 @@ export var AdaptiveMode = function (props) {
|
|
|
22
22
|
navigatable: navigatable || false,
|
|
23
23
|
navigatableElements: navigatableElements || [],
|
|
24
24
|
expand: expand,
|
|
25
|
-
animation: animation
|
|
25
|
+
animation: animation === false ? false : true,
|
|
26
26
|
onClose: onClose,
|
|
27
27
|
animationStyles: windowWidth <= MOBILE_SMALL_DEVISE ? { top: 0, width: '100%', height: '100%' } : undefined,
|
|
28
28
|
className: windowWidth <= MOBILE_SMALL_DEVISE
|
|
@@ -160,4 +160,5 @@ export default class DropDownBase {
|
|
|
160
160
|
scrollToVirtualItem: (virtual: VirtualizationSettings, selectedItemIndex: number) => void;
|
|
161
161
|
renderScrollElement: () => false | JSX.Element;
|
|
162
162
|
getPopupSettings(): DropDownsPopupSettings;
|
|
163
|
+
getGroupedDataModernMode(data: any[], groupField: string): any[];
|
|
163
164
|
}
|
|
@@ -209,6 +209,19 @@ var DropDownBase = /** @class */ (function () {
|
|
|
209
209
|
return Object
|
|
210
210
|
.assign({}, DropDownBase.defaultProps.popupSettings, this.component.props.popupSettings);
|
|
211
211
|
};
|
|
212
|
+
DropDownBase.prototype.getGroupedDataModernMode = function (data, groupField) {
|
|
213
|
+
var newData = [];
|
|
214
|
+
data.forEach(function (el, index) {
|
|
215
|
+
if (data[index - 1] && el[groupField] !== data[index - 1][groupField]) {
|
|
216
|
+
newData.push({ position: el[groupField] });
|
|
217
|
+
newData.push(data[index]);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
newData.push(data[index]);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
return newData;
|
|
224
|
+
};
|
|
212
225
|
DropDownBase.basicPropTypes = {
|
|
213
226
|
opened: PropTypes.bool,
|
|
214
227
|
disabled: PropTypes.bool,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the props of the GroupStickyHeader component.
|
|
4
|
+
*/
|
|
5
|
+
export interface GroupStickyHeaderProps {
|
|
6
|
+
/**
|
|
7
|
+
* The group that will be rendered.
|
|
8
|
+
*/
|
|
9
|
+
group?: string;
|
|
10
|
+
/**
|
|
11
|
+
* @hidden
|
|
12
|
+
*/
|
|
13
|
+
groupMode?: string;
|
|
14
|
+
/**
|
|
15
|
+
* 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.
|
|
16
|
+
*/
|
|
17
|
+
render?: (div: React.ReactElement<HTMLDivElement>, itemProps: GroupStickyHeaderProps) => React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @hidden
|
|
21
|
+
*/
|
|
22
|
+
export default class GroupStickyHeader extends React.Component<GroupStickyHeaderProps, {}> {
|
|
23
|
+
render(): string | number | boolean | React.ReactFragment | JSX.Element | null | undefined;
|
|
24
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import * as React from 'react';
|
|
17
|
+
/**
|
|
18
|
+
* @hidden
|
|
19
|
+
*/
|
|
20
|
+
var GroupStickyHeader = /** @class */ (function (_super) {
|
|
21
|
+
__extends(GroupStickyHeader, _super);
|
|
22
|
+
function GroupStickyHeader() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
GroupStickyHeader.prototype.render = function () {
|
|
26
|
+
var _a = this.props, group = _a.group, groupMode = _a.groupMode, renderer = _a.render;
|
|
27
|
+
var item = (React.createElement("div", { className: "k-list-group-sticky-header" }, groupMode === 'classic'
|
|
28
|
+
? group
|
|
29
|
+
: React.createElement("div", { className: "k-list-header-text" }, group)));
|
|
30
|
+
return renderer !== undefined ? renderer.call(undefined, item, this.props) : item;
|
|
31
|
+
};
|
|
32
|
+
return GroupStickyHeader;
|
|
33
|
+
}(React.Component));
|
|
34
|
+
export default GroupStickyHeader;
|
package/dist/es/common/List.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ListItemProps } from './ListItem';
|
|
3
|
+
import { ListGroupItemProps } from './ListGroupItem';
|
|
3
4
|
import { LocalizationService } from '@progress/kendo-react-intl';
|
|
4
5
|
/**
|
|
5
6
|
* @hidden
|
|
@@ -13,6 +14,8 @@ export interface ListProps {
|
|
|
13
14
|
textField?: string;
|
|
14
15
|
valueField?: string;
|
|
15
16
|
groupField?: string;
|
|
17
|
+
groupMode?: string;
|
|
18
|
+
isMultiColumn?: boolean;
|
|
16
19
|
optionsGuid?: string;
|
|
17
20
|
listRef?: React.Ref<HTMLUListElement>;
|
|
18
21
|
wrapperRef?: React.Ref<HTMLDivElement>;
|
|
@@ -25,6 +28,7 @@ export interface ListProps {
|
|
|
25
28
|
highlightSelected?: boolean;
|
|
26
29
|
onClick: (index: number, event: React.MouseEvent<HTMLLIElement>) => void;
|
|
27
30
|
itemRender?: (li: React.ReactElement<HTMLLIElement>, itemProps: ListItemProps) => React.ReactNode;
|
|
31
|
+
groupHeaderItemRender?: (li: React.ReactElement<HTMLLIElement>, groupItemProps: ListGroupItemProps) => React.ReactNode;
|
|
28
32
|
noDataRender?: (element: React.ReactElement<HTMLDivElement>) => React.ReactNode;
|
|
29
33
|
onMouseDown?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
30
34
|
onBlur?: (event: React.FocusEvent<HTMLDivElement>) => void;
|
|
@@ -35,7 +39,7 @@ export interface ListProps {
|
|
|
35
39
|
* @hidden
|
|
36
40
|
*/
|
|
37
41
|
export default class List extends React.Component<ListProps> {
|
|
38
|
-
renderItems(): JSX.Element[];
|
|
42
|
+
renderItems(): (false | JSX.Element)[][];
|
|
39
43
|
renderNoValueElement(localizationService: LocalizationService): string | number | boolean | React.ReactFragment | JSX.Element | null | undefined;
|
|
40
44
|
render(): string | number | boolean | React.ReactFragment | JSX.Element | null | undefined;
|
|
41
45
|
}
|
package/dist/es/common/List.js
CHANGED
|
@@ -15,6 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
})();
|
|
16
16
|
import * as React from 'react';
|
|
17
17
|
import ListItem from './ListItem';
|
|
18
|
+
import ListGroupItem from './ListGroupItem';
|
|
18
19
|
import { areSame, getItemValue } from './utils';
|
|
19
20
|
import { registerForLocalization, provideLocalizationService } from '@progress/kendo-react-intl';
|
|
20
21
|
import { messages, nodata } from '../messages';
|
|
@@ -28,10 +29,12 @@ var List = /** @class */ (function (_super) {
|
|
|
28
29
|
}
|
|
29
30
|
List.prototype.renderItems = function () {
|
|
30
31
|
var _this = this;
|
|
31
|
-
var _a = this.props, textField = _a.textField, valueField = _a.valueField, groupField = _a.groupField, optionsGuid = _a.optionsGuid, _b = _a.skip, skip = _b === void 0 ? 0 : _b, virtual = _a.virtual, focusedIndex = _a.focusedIndex, _c = _a.highlightSelected, highlightSelected = _c === void 0 ? true : _c, value = _a.value, data = _a.data, itemRender = _a.itemRender;
|
|
32
|
+
var _a = this.props, textField = _a.textField, valueField = _a.valueField, groupField = _a.groupField, groupMode = _a.groupMode, isMultiColumn = _a.isMultiColumn, optionsGuid = _a.optionsGuid, _b = _a.skip, skip = _b === void 0 ? 0 : _b, virtual = _a.virtual, focusedIndex = _a.focusedIndex, _c = _a.highlightSelected, highlightSelected = _c === void 0 ? true : _c, value = _a.value, data = _a.data, itemRender = _a.itemRender, groupHeaderItemRender = _a.groupHeaderItemRender;
|
|
32
33
|
var isArray = Array.isArray(value);
|
|
34
|
+
var groupCounter = 0;
|
|
33
35
|
return data.map(function (item, index) {
|
|
34
36
|
var realIndex = skip + index;
|
|
37
|
+
var idIndex = skip + index + groupCounter;
|
|
35
38
|
var selected = highlightSelected &&
|
|
36
39
|
((!isArray && areSame(item, value, valueField)) ||
|
|
37
40
|
(isArray && value.findIndex(function (i) { return areSame(i, item, valueField); }) !== -1));
|
|
@@ -44,7 +47,11 @@ var List = /** @class */ (function (_super) {
|
|
|
44
47
|
group = current;
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
|
-
|
|
50
|
+
group !== undefined && groupMode === 'modern' ? groupCounter += 1 : '';
|
|
51
|
+
return [
|
|
52
|
+
group !== undefined && groupMode === 'modern' && React.createElement(ListGroupItem, { id: "option-".concat(optionsGuid, "-").concat(idIndex), virtual: virtual, key: realIndex + '-group-item', group: group, isMultiColumn: isMultiColumn, render: groupHeaderItemRender }),
|
|
53
|
+
React.createElement(ListItem, { id: "option-".concat(optionsGuid, "-").concat(group !== undefined && groupMode === 'modern' ? idIndex + 1 : idIndex), virtual: virtual, dataItem: item, groupMode: groupMode, selected: selected, focused: focusedIndex === index, index: realIndex, key: realIndex, onClick: _this.props.onClick, textField: textField, group: group, render: itemRender })
|
|
54
|
+
];
|
|
48
55
|
});
|
|
49
56
|
};
|
|
50
57
|
List.prototype.renderNoValueElement = function (localizationService) {
|