@progress/kendo-react-dropdowns 5.12.0-dev.202303130940 → 5.12.0-dev.202303141413
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/ComboBox/ComboBox.d.ts +33 -42
- package/dist/es/ComboBox/ComboBox.js +175 -56
- package/dist/es/ComboBox/ComboBoxProps.d.ts +12 -0
- package/dist/es/common/DropDownBase.d.ts +1 -1
- package/dist/es/common/DropDownBase.js +7 -1
- package/dist/es/common/SearchBar.d.ts +1 -0
- package/dist/es/common/SearchBar.js +1 -1
- package/dist/es/package-metadata.js +1 -1
- package/dist/npm/ComboBox/ComboBox.d.ts +33 -42
- package/dist/npm/ComboBox/ComboBox.js +174 -55
- package/dist/npm/ComboBox/ComboBoxProps.d.ts +12 -0
- package/dist/npm/common/DropDownBase.d.ts +1 -1
- package/dist/npm/common/DropDownBase.js +7 -1
- package/dist/npm/common/SearchBar.d.ts +1 -0
- package/dist/npm/common/SearchBar.js +1 -1
- package/dist/npm/package-metadata.js +1 -1
- package/dist/systemjs/kendo-react-dropdowns.js +1 -1
- package/package.json +13 -12
|
@@ -4,25 +4,21 @@ import { ComboBoxProps } from './ComboBoxProps';
|
|
|
4
4
|
import { DropDownStateBase, InternalState } from './../common/settings';
|
|
5
5
|
import DropDownBase from '../common/DropDownBase';
|
|
6
6
|
import { FormComponent, FormComponentValidity } from '@progress/kendo-react-common';
|
|
7
|
-
/**
|
|
8
|
-
* @hidden
|
|
9
|
-
*/
|
|
7
|
+
/** @hidden */
|
|
10
8
|
export interface ComboBoxState extends DropDownStateBase {
|
|
9
|
+
filterText?: string;
|
|
11
10
|
suggestedText?: string;
|
|
12
11
|
focusedItem?: any;
|
|
12
|
+
windowWidth?: number;
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
* @hidden
|
|
16
|
-
*/
|
|
14
|
+
/** @hidden */
|
|
17
15
|
export interface ComboInternalState extends InternalState {
|
|
18
16
|
data: ComboBoxState;
|
|
19
17
|
}
|
|
20
18
|
/** @hidden */
|
|
21
19
|
export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProps, ComboBoxState> implements FormComponent {
|
|
22
20
|
static displayName: string;
|
|
23
|
-
/**
|
|
24
|
-
* @hidden
|
|
25
|
-
*/
|
|
21
|
+
/** @hidden */
|
|
26
22
|
static propTypes: {
|
|
27
23
|
size: PropTypes.Requireable<"small" | "medium" | "large" | null | undefined>;
|
|
28
24
|
rounded: PropTypes.Requireable<"small" | "medium" | "full" | "large" | null | undefined>;
|
|
@@ -55,13 +51,14 @@ export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProp
|
|
|
55
51
|
skip: PropTypes.Validator<number>;
|
|
56
52
|
total: PropTypes.Validator<number>;
|
|
57
53
|
}>>;
|
|
54
|
+
/** @hidden */
|
|
58
55
|
onFilterChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
59
56
|
onPageChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
60
57
|
opened: PropTypes.Requireable<boolean>;
|
|
61
58
|
disabled: PropTypes.Requireable<boolean>;
|
|
62
59
|
dir: PropTypes.Requireable<string>;
|
|
63
60
|
tabIndex: PropTypes.Requireable<number>;
|
|
64
|
-
accessKey: PropTypes.Requireable<string>;
|
|
61
|
+
accessKey: PropTypes.Requireable<string>; /** @hidden */
|
|
65
62
|
data: PropTypes.Requireable<any[]>;
|
|
66
63
|
textField: PropTypes.Requireable<string>;
|
|
67
64
|
className: PropTypes.Requireable<string>;
|
|
@@ -81,9 +78,7 @@ export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProp
|
|
|
81
78
|
onOpen: PropTypes.Requireable<(...args: any[]) => any>;
|
|
82
79
|
onClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
83
80
|
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
84
|
-
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
85
|
-
* @hidden
|
|
86
|
-
*/
|
|
81
|
+
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
87
82
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
88
83
|
itemRender: PropTypes.Requireable<(...args: any[]) => any>;
|
|
89
84
|
listNoDataRender: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -91,9 +86,7 @@ export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProp
|
|
|
91
86
|
header: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
92
87
|
footer: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
93
88
|
};
|
|
94
|
-
/**
|
|
95
|
-
* @hidden
|
|
96
|
-
*/
|
|
89
|
+
/** @hidden */
|
|
97
90
|
static defaultProps: {
|
|
98
91
|
size: "small" | "medium" | "large" | null | undefined;
|
|
99
92
|
rounded: "small" | "medium" | "full" | "large" | null | undefined;
|
|
@@ -106,9 +99,7 @@ export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProp
|
|
|
106
99
|
};
|
|
107
100
|
validityStyles: boolean;
|
|
108
101
|
};
|
|
109
|
-
/**
|
|
110
|
-
* @hidden
|
|
111
|
-
*/
|
|
102
|
+
/** @hidden */
|
|
112
103
|
readonly state: ComboBoxState;
|
|
113
104
|
protected readonly base: DropDownBase;
|
|
114
105
|
private _element;
|
|
@@ -116,17 +107,21 @@ export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProp
|
|
|
116
107
|
private _valueDuringOnChange;
|
|
117
108
|
private _valueOnDidUpdate;
|
|
118
109
|
private _suggested;
|
|
110
|
+
private _skipBlur;
|
|
119
111
|
private _input;
|
|
112
|
+
private _adaptiveFilterInput;
|
|
120
113
|
private itemHeight;
|
|
114
|
+
private observerResize;
|
|
115
|
+
private get document();
|
|
121
116
|
constructor(props: ComboBoxProps);
|
|
122
|
-
/**
|
|
123
|
-
* @hidden
|
|
124
|
-
*/
|
|
117
|
+
/** @hidden */
|
|
125
118
|
focus: () => void;
|
|
119
|
+
/** @hidden */
|
|
120
|
+
get element(): HTMLSpanElement | null;
|
|
126
121
|
/**
|
|
127
|
-
*
|
|
122
|
+
* The mobile mode of the ComboBox.
|
|
128
123
|
*/
|
|
129
|
-
get
|
|
124
|
+
get mobileMode(): boolean;
|
|
130
125
|
/**
|
|
131
126
|
* The value of the ComboBox.
|
|
132
127
|
*/
|
|
@@ -144,41 +139,36 @@ export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProp
|
|
|
144
139
|
*/
|
|
145
140
|
get validity(): FormComponentValidity;
|
|
146
141
|
protected get validityStyles(): boolean;
|
|
147
|
-
/**
|
|
148
|
-
* @hidden
|
|
149
|
-
*/
|
|
142
|
+
/** @hidden */
|
|
150
143
|
protected get required(): boolean;
|
|
151
|
-
/**
|
|
152
|
-
* @hidden
|
|
153
|
-
*/
|
|
144
|
+
/** @hidden */
|
|
154
145
|
componentDidUpdate(prevProps: ComboBoxProps, prevState: ComboBoxState): void;
|
|
155
|
-
/**
|
|
156
|
-
* @hidden
|
|
157
|
-
*/
|
|
146
|
+
/** @hidden */
|
|
158
147
|
componentDidMount(): void;
|
|
159
|
-
/**
|
|
160
|
-
|
|
161
|
-
|
|
148
|
+
/** @hidden */
|
|
149
|
+
componentWillUnmount(): void;
|
|
150
|
+
/** @hidden */
|
|
162
151
|
render(): JSX.Element;
|
|
163
|
-
/**
|
|
164
|
-
* @hidden
|
|
165
|
-
*/
|
|
152
|
+
/** @hidden */
|
|
166
153
|
handleItemSelect: (index: number, state: ComboInternalState) => void;
|
|
167
|
-
/**
|
|
168
|
-
* @hidden
|
|
169
|
-
*/
|
|
154
|
+
/** @hidden */
|
|
170
155
|
onNavigate(state: InternalState, keyCode: number): void;
|
|
156
|
+
private onPopupOpened;
|
|
171
157
|
private componentRef;
|
|
172
158
|
private toggleBtnClick;
|
|
173
159
|
private applyValueOnEnter;
|
|
174
160
|
private applyValueOnRejectSuggestions;
|
|
175
161
|
private selectFocusedItem;
|
|
162
|
+
private renderAdaptiveListContainer;
|
|
163
|
+
private renderMobileListFilter;
|
|
176
164
|
private renderListContainer;
|
|
177
165
|
private renderList;
|
|
166
|
+
private handleMobileFilterChange;
|
|
178
167
|
private renderSearchBar;
|
|
179
168
|
private onScroll;
|
|
180
169
|
private handleItemClick;
|
|
181
170
|
private handleBlur;
|
|
171
|
+
private onInputClick;
|
|
182
172
|
private onInputKeyDown;
|
|
183
173
|
private inputOnChange;
|
|
184
174
|
private clearButtonClick;
|
|
@@ -187,6 +177,7 @@ export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProp
|
|
|
187
177
|
private suggestValue;
|
|
188
178
|
private applyState;
|
|
189
179
|
private setValidity;
|
|
180
|
+
private calculateMedia;
|
|
190
181
|
}
|
|
191
182
|
/**
|
|
192
183
|
* Represents the PropsContext of the `ComboBox` component.
|
|
@@ -33,41 +33,42 @@ import { areSame, itemIndexStartsWith, getItemIndexByText, getItemValue, isPrese
|
|
|
33
33
|
import SearchBar from '../common/SearchBar';
|
|
34
34
|
import ListContainer from '../common/ListContainer';
|
|
35
35
|
import List from '../common/List';
|
|
36
|
-
import
|
|
36
|
+
import ListFilter from '../common/ListFilter';
|
|
37
|
+
import { validatePackage, canUseDOM } from '@progress/kendo-react-common';
|
|
37
38
|
import { packageMetadata } from '../package-metadata';
|
|
38
39
|
import ClearButton from '../common/ClearButton';
|
|
39
40
|
import { Button } from '@progress/kendo-react-buttons';
|
|
40
41
|
import { caretAltDownIcon } from '@progress/kendo-svg-icons';
|
|
41
42
|
import { messages, comboArrowBtnAriaLabelExpand, comboArrowBtnAriaLabelCollapse } from './../messages';
|
|
42
43
|
import { provideLocalizationService } from '@progress/kendo-react-intl';
|
|
44
|
+
import { ActionSheet, ActionSheetContent, ActionSheetHeader } from '@progress/kendo-react-layout';
|
|
43
45
|
var VALIDATION_MESSAGE = 'Please enter a valid value!';
|
|
46
|
+
var MOBILE_SMALL_DEVISE = 500;
|
|
47
|
+
var MOBILE_MEDIUM_DEVISE = 768;
|
|
44
48
|
var sizeMap = kendoThemeMaps.sizeMap, roundedMap = kendoThemeMaps.roundedMap;
|
|
45
49
|
/** @hidden */
|
|
46
50
|
var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
47
51
|
__extends(ComboBoxWithoutContext, _super);
|
|
48
52
|
function ComboBoxWithoutContext(props) {
|
|
49
53
|
var _this = _super.call(this, props) || this;
|
|
50
|
-
/**
|
|
51
|
-
* @hidden
|
|
52
|
-
*/
|
|
54
|
+
/** @hidden */
|
|
53
55
|
_this.state = {};
|
|
54
56
|
_this.base = new DropDownBase(_this);
|
|
55
57
|
_this._element = null;
|
|
56
58
|
_this._inputId = guid();
|
|
57
59
|
_this._suggested = '';
|
|
60
|
+
_this._skipBlur = false;
|
|
58
61
|
_this._input = null;
|
|
62
|
+
_this._adaptiveFilterInput = null;
|
|
59
63
|
_this.itemHeight = 0;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*/
|
|
64
|
+
_this.observerResize = (window === null || window === void 0 ? void 0 : window.ResizeObserver) && new window.ResizeObserver(_this.calculateMedia.bind(_this));
|
|
65
|
+
/** @hidden */
|
|
63
66
|
_this.focus = function () {
|
|
64
67
|
if (_this._input) {
|
|
65
68
|
_this._input.focus();
|
|
66
69
|
}
|
|
67
70
|
};
|
|
68
|
-
/**
|
|
69
|
-
* @hidden
|
|
70
|
-
*/
|
|
71
|
+
/** @hidden */
|
|
71
72
|
_this.handleItemSelect = function (index, state) {
|
|
72
73
|
var _a = _this.props, _b = _a.data, data = _b === void 0 ? [] : _b, virtual = _a.virtual, dataItemKey = _a.dataItemKey;
|
|
73
74
|
var skip = virtual ? virtual.skip : 0;
|
|
@@ -81,14 +82,41 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
81
82
|
_this.base.triggerPageChangeCornerItems(item, state);
|
|
82
83
|
}
|
|
83
84
|
};
|
|
85
|
+
_this.onPopupOpened = function () {
|
|
86
|
+
setTimeout(function () {
|
|
87
|
+
if (_this.mobileMode && _this._adaptiveFilterInput) {
|
|
88
|
+
_this._skipBlur = true;
|
|
89
|
+
_this._adaptiveFilterInput.focus();
|
|
90
|
+
_this._skipBlur = false;
|
|
91
|
+
}
|
|
92
|
+
}, 300);
|
|
93
|
+
};
|
|
84
94
|
_this.componentRef = function (element) {
|
|
85
95
|
_this._element = element;
|
|
86
96
|
_this.base.wrapper = element;
|
|
87
97
|
};
|
|
88
98
|
_this.toggleBtnClick = function (event) {
|
|
99
|
+
var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
|
|
89
100
|
var state = _this.base.initState();
|
|
90
101
|
state.syntheticEvent = event;
|
|
91
102
|
_this.base.togglePopup(state);
|
|
103
|
+
if (!opened && _this.mobileMode) {
|
|
104
|
+
var mobileText = _this.props.adaptiveFilter !== undefined ? _this.props.adaptiveFilter : _this.state.text || null;
|
|
105
|
+
_this.base.filterChanged(mobileText, state);
|
|
106
|
+
}
|
|
107
|
+
_this.applyState(state);
|
|
108
|
+
};
|
|
109
|
+
_this.renderMobileListFilter = function () {
|
|
110
|
+
var mobileText = _this.props.adaptiveFilter !== undefined ? _this.props.adaptiveFilter : _this.state.text;
|
|
111
|
+
var selectedItemText = getItemValue(_this.value, _this.props.textField);
|
|
112
|
+
var mobileInputText = isPresent(mobileText) ? mobileText : selectedItemText;
|
|
113
|
+
return (React.createElement(ListFilter, { value: mobileInputText, ref: function (filter) { return _this._adaptiveFilterInput = filter && filter.input; }, onChange: _this.handleMobileFilterChange, onKeyDown: _this.onInputKeyDown, size: _this.props.size, rounded: _this.props.rounded, fillMode: _this.props.fillMode }));
|
|
114
|
+
};
|
|
115
|
+
_this.handleMobileFilterChange = function (event) {
|
|
116
|
+
var state = _this.base.initState();
|
|
117
|
+
state.syntheticEvent = event;
|
|
118
|
+
state.data.text = event.target.value;
|
|
119
|
+
_this.base.filterChanged(event.target.value, state);
|
|
92
120
|
_this.applyState(state);
|
|
93
121
|
};
|
|
94
122
|
_this.onScroll = function (event) {
|
|
@@ -125,7 +153,7 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
125
153
|
_this._valueDuringOnChange = undefined;
|
|
126
154
|
};
|
|
127
155
|
_this.handleBlur = function (event) {
|
|
128
|
-
if (_this.state.focused) {
|
|
156
|
+
if (_this.state.focused && !_this._skipBlur) {
|
|
129
157
|
var state = _this.base.initState();
|
|
130
158
|
state.data.focused = false;
|
|
131
159
|
state.events.push({ type: 'onBlur' });
|
|
@@ -133,6 +161,17 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
133
161
|
_this.applyValueOnRejectSuggestions(event.currentTarget.value, state);
|
|
134
162
|
}
|
|
135
163
|
};
|
|
164
|
+
_this.onInputClick = function (event) {
|
|
165
|
+
var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
|
|
166
|
+
var mobileText = _this.props.adaptiveFilter !== undefined ? _this.props.adaptiveFilter : _this.state.text || null;
|
|
167
|
+
if (!opened && _this.mobileMode) {
|
|
168
|
+
var state = _this.base.initState();
|
|
169
|
+
state.syntheticEvent = event;
|
|
170
|
+
_this.base.togglePopup(state);
|
|
171
|
+
_this.base.filterChanged(mobileText, state);
|
|
172
|
+
_this.applyState(state);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
136
175
|
_this.onInputKeyDown = function (event) {
|
|
137
176
|
var keyCode = event.keyCode;
|
|
138
177
|
var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
|
|
@@ -209,7 +248,8 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
209
248
|
}
|
|
210
249
|
_this.triggerOnChange(null, state);
|
|
211
250
|
var opened = _this.props.opened !== undefined ? _this.props.opened : _this.state.opened;
|
|
212
|
-
|
|
251
|
+
var isAdaptive = _this.mobileMode;
|
|
252
|
+
if (opened && !isAdaptive) {
|
|
213
253
|
_this.base.togglePopup(state);
|
|
214
254
|
}
|
|
215
255
|
_this.applyState(state);
|
|
@@ -224,12 +264,32 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
224
264
|
validatePackage(packageMetadata);
|
|
225
265
|
return _this;
|
|
226
266
|
}
|
|
267
|
+
Object.defineProperty(ComboBoxWithoutContext.prototype, "document", {
|
|
268
|
+
get: function () {
|
|
269
|
+
if (!canUseDOM) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
// useful only for user actions
|
|
273
|
+
return (this.element && this.element.ownerDocument) || document;
|
|
274
|
+
},
|
|
275
|
+
enumerable: false,
|
|
276
|
+
configurable: true
|
|
277
|
+
});
|
|
227
278
|
Object.defineProperty(ComboBoxWithoutContext.prototype, "element", {
|
|
279
|
+
/** @hidden */
|
|
280
|
+
get: function () {
|
|
281
|
+
return this._element;
|
|
282
|
+
},
|
|
283
|
+
enumerable: false,
|
|
284
|
+
configurable: true
|
|
285
|
+
});
|
|
286
|
+
Object.defineProperty(ComboBoxWithoutContext.prototype, "mobileMode", {
|
|
228
287
|
/**
|
|
229
|
-
*
|
|
288
|
+
* The mobile mode of the ComboBox.
|
|
230
289
|
*/
|
|
231
290
|
get: function () {
|
|
232
|
-
|
|
291
|
+
var isAdaptive = this.state.windowWidth && this.state.windowWidth <= MOBILE_MEDIUM_DEVISE && this.props.adaptive;
|
|
292
|
+
return !!isAdaptive;
|
|
233
293
|
},
|
|
234
294
|
enumerable: false,
|
|
235
295
|
configurable: true
|
|
@@ -309,9 +369,7 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
309
369
|
configurable: true
|
|
310
370
|
});
|
|
311
371
|
Object.defineProperty(ComboBoxWithoutContext.prototype, "required", {
|
|
312
|
-
/**
|
|
313
|
-
* @hidden
|
|
314
|
-
*/
|
|
372
|
+
/** @hidden */
|
|
315
373
|
get: function () {
|
|
316
374
|
return this.props.required !== undefined
|
|
317
375
|
? this.props.required
|
|
@@ -320,9 +378,7 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
320
378
|
enumerable: false,
|
|
321
379
|
configurable: true
|
|
322
380
|
});
|
|
323
|
-
/**
|
|
324
|
-
* @hidden
|
|
325
|
-
*/
|
|
381
|
+
/** @hidden */
|
|
326
382
|
ComboBoxWithoutContext.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
327
383
|
var _a = this.props, _b = _a.data, data = _b === void 0 ? [] : _b, dataItemKey = _a.dataItemKey, virtual = _a.virtual;
|
|
328
384
|
var prevTotal = prevProps.virtual ? prevProps.virtual.total : 0;
|
|
@@ -343,6 +399,7 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
343
399
|
this.base.scrollToVirtualItem(virtual, selectedItemIndex);
|
|
344
400
|
}
|
|
345
401
|
else if (opening && !virtual) {
|
|
402
|
+
this.onPopupOpened();
|
|
346
403
|
this.base.scrollToItem(selectedItemIndex);
|
|
347
404
|
}
|
|
348
405
|
else if (opened && prevOpened && selectedItem && selectedItemChanged) {
|
|
@@ -354,21 +411,29 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
354
411
|
}
|
|
355
412
|
this.setValidity();
|
|
356
413
|
};
|
|
357
|
-
/**
|
|
358
|
-
* @hidden
|
|
359
|
-
*/
|
|
414
|
+
/** @hidden */
|
|
360
415
|
ComboBoxWithoutContext.prototype.componentDidMount = function () {
|
|
416
|
+
var _a;
|
|
361
417
|
this.base.didMount();
|
|
362
418
|
this.setValidity();
|
|
419
|
+
if (((_a = this.document) === null || _a === void 0 ? void 0 : _a.body) && this.observerResize) {
|
|
420
|
+
this.observerResize.observe(this.document.body);
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
/** @hidden */
|
|
424
|
+
ComboBoxWithoutContext.prototype.componentWillUnmount = function () {
|
|
425
|
+
var _a;
|
|
426
|
+
if (((_a = this.document) === null || _a === void 0 ? void 0 : _a.body) && this.observerResize) {
|
|
427
|
+
this.observerResize.disconnect();
|
|
428
|
+
}
|
|
363
429
|
};
|
|
364
|
-
/**
|
|
365
|
-
* @hidden
|
|
366
|
-
*/
|
|
430
|
+
/** @hidden */
|
|
367
431
|
ComboBoxWithoutContext.prototype.render = function () {
|
|
368
432
|
var _a;
|
|
369
433
|
var btnAriaLabelExpand = provideLocalizationService(this).toLanguageString(comboArrowBtnAriaLabelExpand, messages[comboArrowBtnAriaLabelExpand]);
|
|
370
434
|
var btnAriaLabelCollapse = provideLocalizationService(this).toLanguageString(comboArrowBtnAriaLabelCollapse, messages[comboArrowBtnAriaLabelCollapse]);
|
|
371
|
-
var _b = this.props, dir = _b.dir, disabled = _b.disabled, _c = _b.clearButton, clearButton = _c === void 0 ? ComboBoxWithoutContext.defaultProps.clearButton : _c, label = _b.label, textField = _b.textField, className = _b.className, style = _b.style, loading = _b.loading, iconClassName = _b.iconClassName, virtual = _b.virtual, size = _b.size, rounded = _b.rounded, fillMode = _b.fillMode, _d = _b.opened, opened = _d === void 0 ? this.state.opened : _d;
|
|
435
|
+
var _b = this.props, dir = _b.dir, disabled = _b.disabled, _c = _b.clearButton, clearButton = _c === void 0 ? ComboBoxWithoutContext.defaultProps.clearButton : _c, label = _b.label, textField = _b.textField, adaptive = _b.adaptive, className = _b.className, style = _b.style, loading = _b.loading, iconClassName = _b.iconClassName, virtual = _b.virtual, size = _b.size, rounded = _b.rounded, fillMode = _b.fillMode, _d = _b.opened, opened = _d === void 0 ? this.state.opened : _d, placeholder = _b.placeholder;
|
|
436
|
+
var _e = this.state.windowWidth, windowWidth = _e === void 0 ? 0 : _e;
|
|
372
437
|
var isValid = !this.validityStyles || this.validity.valid;
|
|
373
438
|
var text = this.props.filter !== undefined ? this.props.filter : this.state.text;
|
|
374
439
|
var selectedItemText = getItemValue(this.value, textField);
|
|
@@ -377,33 +442,34 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
377
442
|
var base = this.base;
|
|
378
443
|
var vs = base.vs;
|
|
379
444
|
var id = this.props.id || this._inputId;
|
|
445
|
+
var renderAdaptive = windowWidth <= MOBILE_MEDIUM_DEVISE && adaptive;
|
|
380
446
|
vs.enabled = virtual !== undefined;
|
|
381
447
|
if (virtual !== undefined) {
|
|
382
448
|
vs.skip = virtual.skip;
|
|
383
449
|
vs.total = virtual.total;
|
|
384
450
|
vs.pageSize = virtual.pageSize;
|
|
385
451
|
}
|
|
386
|
-
var combobox = (React.createElement(
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
452
|
+
var combobox = (React.createElement(React.Fragment, null,
|
|
453
|
+
React.createElement("span", { className: classNames('k-combobox k-input', (_a = {},
|
|
454
|
+
_a["k-input-".concat(sizeMap[size] || size)] = size,
|
|
455
|
+
_a["k-rounded-".concat(roundedMap[rounded] || rounded)] = rounded,
|
|
456
|
+
_a["k-input-".concat(fillMode)] = fillMode,
|
|
457
|
+
_a['k-invalid'] = !isValid,
|
|
458
|
+
_a['k-loading'] = loading,
|
|
459
|
+
_a['k-required'] = this.required,
|
|
460
|
+
_a['k-disabled'] = disabled,
|
|
461
|
+
_a), className), ref: this.componentRef, style: !label ? style : __assign(__assign({}, style), { width: undefined }), dir: dir },
|
|
462
|
+
this.renderSearchBar(inputText || '', id, placeholder),
|
|
463
|
+
renderClearButton && !loading && React.createElement(ClearButton, { onClick: this.clearButtonClick, key: "clearbutton" }),
|
|
464
|
+
loading && React.createElement("span", { className: "k-icon k-i-loading k-input-loading-icon", key: "loading" }),
|
|
465
|
+
React.createElement(Button, { tabIndex: -1, type: "button", "aria-label": opened ? btnAriaLabelCollapse : btnAriaLabelExpand, icon: !iconClassName ? 'caret-alt-down' : undefined, svgIcon: !iconClassName ? caretAltDownIcon : this.props.svgIcon, iconClass: iconClassName, size: size, fillMode: fillMode, rounded: null, themeColor: 'base', className: "k-input-button", onClick: this.toggleBtnClick, onMouseDown: function (e) { return e.preventDefault(); } }),
|
|
466
|
+
!renderAdaptive && this.renderListContainer()),
|
|
467
|
+
renderAdaptive && this.renderAdaptiveListContainer()));
|
|
400
468
|
return label
|
|
401
469
|
? (React.createElement(FloatingLabel, { label: label, editorId: id, editorValue: inputText, editorValid: isValid, editorDisabled: disabled, style: { width: style ? style.width : undefined }, children: combobox }))
|
|
402
470
|
: combobox;
|
|
403
471
|
};
|
|
404
|
-
/**
|
|
405
|
-
* @hidden
|
|
406
|
-
*/
|
|
472
|
+
/** @hidden */
|
|
407
473
|
ComboBoxWithoutContext.prototype.onNavigate = function (state, keyCode) {
|
|
408
474
|
var _a = this.props, _b = _a.data, data = _b === void 0 ? [] : _b, _c = _a.virtual, virtual = _c === void 0 ? { skip: 0 } : _c;
|
|
409
475
|
var text = this.props.filter ? this.props.filter : this.state.text;
|
|
@@ -430,6 +496,7 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
430
496
|
}
|
|
431
497
|
}
|
|
432
498
|
};
|
|
499
|
+
;
|
|
433
500
|
ComboBoxWithoutContext.prototype.applyValueOnEnter = function (value, state) {
|
|
434
501
|
var _a;
|
|
435
502
|
var _b = this.props, _c = _b.data, data = _c === void 0 ? [] : _c, textField = _b.textField, allowCustom = _b.allowCustom;
|
|
@@ -465,9 +532,10 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
465
532
|
var _b = this.props, _c = _b.data, data = _c === void 0 ? [] : _c, textField = _b.textField, allowCustom = _b.allowCustom;
|
|
466
533
|
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
467
534
|
var valueItemText = getItemValue(this.value, textField);
|
|
535
|
+
var isMobileDevice = this.state.windowWidth && this.state.windowWidth <= MOBILE_MEDIUM_DEVISE;
|
|
468
536
|
this._suggested = '';
|
|
469
537
|
if (text === valueItemText || (text === '' && !isPresent(valueItemText))) {
|
|
470
|
-
if (opened) {
|
|
538
|
+
if (opened && !isMobileDevice) {
|
|
471
539
|
this.base.togglePopup(state);
|
|
472
540
|
}
|
|
473
541
|
return this.applyState(state);
|
|
@@ -486,7 +554,7 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
486
554
|
state.data.text = undefined;
|
|
487
555
|
this.base.filterChanged('', state);
|
|
488
556
|
}
|
|
489
|
-
if (opened) {
|
|
557
|
+
if (opened && !isMobileDevice) {
|
|
490
558
|
this.base.togglePopup(state);
|
|
491
559
|
}
|
|
492
560
|
this.applyState(state);
|
|
@@ -511,6 +579,51 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
511
579
|
}
|
|
512
580
|
return this.applyState(state);
|
|
513
581
|
};
|
|
582
|
+
ComboBoxWithoutContext.prototype.renderAdaptiveListContainer = function () {
|
|
583
|
+
var _a;
|
|
584
|
+
var _this = this;
|
|
585
|
+
var _b = this.state.windowWidth, windowWidth = _b === void 0 ? 0 : _b;
|
|
586
|
+
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;
|
|
587
|
+
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
588
|
+
var group = this.state.group;
|
|
589
|
+
if (group === undefined && groupField !== undefined) {
|
|
590
|
+
group = getItemValue(data[0], groupField);
|
|
591
|
+
}
|
|
592
|
+
var actionSheetProps = {
|
|
593
|
+
navigatable: false,
|
|
594
|
+
navigatableElements: [],
|
|
595
|
+
expand: opened,
|
|
596
|
+
animation: true,
|
|
597
|
+
onClose: function (event) { return _this.toggleBtnClick(event); },
|
|
598
|
+
animationStyles: windowWidth <= MOBILE_SMALL_DEVISE ? { top: 0, width: '100%', height: '100%' } : undefined,
|
|
599
|
+
className: windowWidth <= MOBILE_SMALL_DEVISE
|
|
600
|
+
? 'k-adaptive-actionsheet k-actionsheet-fullscreen'
|
|
601
|
+
: 'k-adaptive-actionsheet k-actionsheet-bottom'
|
|
602
|
+
};
|
|
603
|
+
return (React.createElement(React.Fragment, null,
|
|
604
|
+
React.createElement(ActionSheet, __assign({}, actionSheetProps),
|
|
605
|
+
React.createElement(ActionSheetHeader, { className: 'k-text-center' },
|
|
606
|
+
React.createElement("div", { className: "k-actionsheet-titlebar-group k-hbox" },
|
|
607
|
+
React.createElement("div", { className: "k-actionsheet-title" },
|
|
608
|
+
React.createElement("div", null, adaptiveTitle)),
|
|
609
|
+
React.createElement("div", { className: "k-actionsheet-actions" },
|
|
610
|
+
React.createElement(Button, { tabIndex: 0, "aria-label": "Cancel", "aria-disabled": "false", type: "button", fillMode: "flat", onClick: this.toggleBtnClick },
|
|
611
|
+
React.createElement("span", { className: "k-button-icon k-icon k-i-x" })))),
|
|
612
|
+
React.createElement("div", { className: "k-actionsheet-titlebar-group k-actionsheet-filter" }, this.renderMobileListFilter())),
|
|
613
|
+
React.createElement(ActionSheetContent, { className: '!k-overflow-hidden' },
|
|
614
|
+
React.createElement("div", { className: 'k-list-container' },
|
|
615
|
+
React.createElement("div", { className: classNames((_a = {},
|
|
616
|
+
_a['k-list'] = !list,
|
|
617
|
+
_a['k-list-lg'] = true,
|
|
618
|
+
_a['k-virtual-list'] = virtual,
|
|
619
|
+
_a['k-data-table'] = list,
|
|
620
|
+
_a["k-table-".concat(sizeMap[size] || size)] = list && size,
|
|
621
|
+
_a)) },
|
|
622
|
+
header && React.createElement("div", { className: "k-table-header" }, header),
|
|
623
|
+
!list && group && React.createElement("div", { className: "k-list-group-sticky-header" }, group),
|
|
624
|
+
this.renderList(),
|
|
625
|
+
footer && React.createElement("div", { className: "k-list-footer" }, footer)))))));
|
|
626
|
+
};
|
|
514
627
|
ComboBoxWithoutContext.prototype.renderListContainer = function () {
|
|
515
628
|
var _a;
|
|
516
629
|
var base = this.base;
|
|
@@ -557,20 +670,22 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
557
670
|
var selectedItemText = getItemValue(this.value, textField);
|
|
558
671
|
var value = isPresent(text) && text !== selectedItemText ? null : this.value;
|
|
559
672
|
var ListComponent = this.props.list || List;
|
|
560
|
-
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:
|
|
673
|
+
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)
|
|
674
|
+
? { maxHeight: popupSettings.height }
|
|
675
|
+
: {}, wrapperCssClass: classNames('k-list-content', (_a = {},
|
|
561
676
|
_a['k-list-scroller'] = !virtual,
|
|
562
677
|
_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() }));
|
|
563
678
|
};
|
|
564
|
-
ComboBoxWithoutContext.prototype.renderSearchBar = function (text, id) {
|
|
679
|
+
ComboBoxWithoutContext.prototype.renderSearchBar = function (text, id, placeholder) {
|
|
565
680
|
var _this = this;
|
|
566
|
-
var _a = this.props,
|
|
681
|
+
var _a = this.props, tabIndex = _a.tabIndex, disabled = _a.disabled, _b = _a.data, data = _b === void 0 ? [] : _b, dataItemKey = _a.dataItemKey, _c = _a.virtual, virtual = _c === void 0 ? { skip: 0 } : _c;
|
|
567
682
|
var opened = this.props.opened !== undefined ? this.props.opened : this.state.opened;
|
|
568
683
|
var value = this.value;
|
|
569
684
|
var selectedIndex = Math.max(0, data.findIndex(function (i) { return areSame(i, value, dataItemKey); }));
|
|
570
685
|
if (this._suggested && !areSame(this._valueOnDidUpdate, value, dataItemKey)) {
|
|
571
686
|
this._suggested = '';
|
|
572
687
|
}
|
|
573
|
-
return (React.createElement(SearchBar, { id: id, placeholder: placeholder, tabIndex: tabIndex, accessKey: this.props.accessKey, value: text + this._suggested, suggestedText: this._suggested, ref: function (el) { return _this._input = el && el.input; }, onKeyDown: this.onInputKeyDown, onChange: this.inputOnChange, onFocus: this.base.handleFocus, onBlur: this.handleBlur, disabled: disabled, expanded: opened, owns: this.base.listBoxId, activedescendant: "option-".concat(this.base.guid, "-").concat(selectedIndex + virtual.skip), role: "combobox", ariaLabelledBy: this.props.ariaLabelledBy, ariaDescribedBy: this.props.ariaDescribedBy, ariaRequired: this.required, render: this.props.valueRender }));
|
|
688
|
+
return (React.createElement(SearchBar, { id: id, readOnly: (opened && this.mobileMode), placeholder: placeholder, tabIndex: tabIndex, accessKey: this.props.accessKey, value: text + this._suggested, suggestedText: this._suggested, ref: function (el) { return _this._input = el && el.input; }, onClick: this.onInputClick, onKeyDown: this.onInputKeyDown, onChange: this.inputOnChange, onFocus: this.base.handleFocus, onBlur: this.handleBlur, disabled: disabled, expanded: opened, owns: this.base.listBoxId, activedescendant: "option-".concat(this.base.guid, "-").concat(selectedIndex + virtual.skip), role: "combobox", ariaLabelledBy: this.props.ariaLabelledBy, ariaDescribedBy: this.props.ariaDescribedBy, ariaRequired: this.required, render: this.props.valueRender }));
|
|
574
689
|
};
|
|
575
690
|
ComboBoxWithoutContext.prototype.triggerOnChange = function (item, state) {
|
|
576
691
|
var value = this.value;
|
|
@@ -605,14 +720,18 @@ var ComboBoxWithoutContext = /** @class */ (function (_super) {
|
|
|
605
720
|
this.base.applyState(state);
|
|
606
721
|
this._valueDuringOnChange = undefined;
|
|
607
722
|
};
|
|
723
|
+
ComboBoxWithoutContext.prototype.calculateMedia = function (entries) {
|
|
724
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
725
|
+
var entry = entries_1[_i];
|
|
726
|
+
this.setState({ windowWidth: entry.target.clientWidth });
|
|
727
|
+
}
|
|
728
|
+
;
|
|
729
|
+
};
|
|
730
|
+
;
|
|
608
731
|
ComboBoxWithoutContext.displayName = 'ComboBox';
|
|
609
|
-
/**
|
|
610
|
-
* @hidden
|
|
611
|
-
*/
|
|
732
|
+
/** @hidden */
|
|
612
733
|
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 });
|
|
613
|
-
/**
|
|
614
|
-
* @hidden
|
|
615
|
-
*/
|
|
734
|
+
/** @hidden */
|
|
616
735
|
ComboBoxWithoutContext.defaultProps = __assign(__assign({}, DropDownBase.defaultProps), { size: 'medium', rounded: 'medium', fillMode: 'solid', allowCustom: false, clearButton: true, required: false });
|
|
617
736
|
return ComboBoxWithoutContext;
|
|
618
737
|
}(React.Component));
|
|
@@ -107,6 +107,10 @@ export interface ComboBoxProps extends FormComponentProps {
|
|
|
107
107
|
* Sets the value of ComboBox input. Useful for making the ComboBox input a [controlled component](https://reactjs.org/docs/forms.html#controlled-components).
|
|
108
108
|
*/
|
|
109
109
|
filter?: string | null;
|
|
110
|
+
/**
|
|
111
|
+
* Sets the value of the adaptive filtering input of the of ComboBox.
|
|
112
|
+
*/
|
|
113
|
+
adaptiveFilter?: string;
|
|
110
114
|
/**
|
|
111
115
|
* Sets the loading state of the ComboBox ([see example]({% slug filtering_combobox %}#toc-basic-configuration)).
|
|
112
116
|
*/
|
|
@@ -268,4 +272,12 @@ export interface ComboBoxProps extends FormComponentProps {
|
|
|
268
272
|
* @default `solid`
|
|
269
273
|
*/
|
|
270
274
|
fillMode?: null | 'solid' | 'flat' | 'outline';
|
|
275
|
+
/**
|
|
276
|
+
* Providing different rendering of the popup element based on the screen dimensions.
|
|
277
|
+
*/
|
|
278
|
+
adaptive?: boolean;
|
|
279
|
+
/**
|
|
280
|
+
* Specifies the text that is rendered as title in the adaptive popup.
|
|
281
|
+
*/
|
|
282
|
+
adaptiveTitle?: string;
|
|
271
283
|
}
|
|
@@ -147,7 +147,7 @@ export default class DropDownBase {
|
|
|
147
147
|
didMount(): void;
|
|
148
148
|
calculateDir(): void;
|
|
149
149
|
calculatePopupWidth(): void;
|
|
150
|
-
scrollToItem(itemIndex: number, vsEnabled?: boolean): void;
|
|
150
|
+
scrollToItem(itemIndex: number, vsEnabled?: boolean, once?: boolean): void;
|
|
151
151
|
handleItemClick: (index: number, event: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLInputElement>) => void;
|
|
152
152
|
handleFocus: React.FocusEventHandler<HTMLSpanElement>;
|
|
153
153
|
filterChanged: (text: string | null, state: InternalState) => void;
|
|
@@ -136,8 +136,14 @@ var DropDownBase = /** @class */ (function () {
|
|
|
136
136
|
this.popupWidth = this.wrapper.offsetWidth + 'px';
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
|
-
DropDownBase.prototype.scrollToItem = function (itemIndex, vsEnabled) {
|
|
139
|
+
DropDownBase.prototype.scrollToItem = function (itemIndex, vsEnabled, once) {
|
|
140
|
+
var _this = this;
|
|
140
141
|
var list = this.list || this.vs.list;
|
|
142
|
+
if (!list && !once) {
|
|
143
|
+
setTimeout(function () {
|
|
144
|
+
_this.scrollToItem(itemIndex, vsEnabled, true);
|
|
145
|
+
}, 10);
|
|
146
|
+
}
|
|
141
147
|
if (list && itemIndex >= 0) {
|
|
142
148
|
var vs = this.vs;
|
|
143
149
|
var scrollElement = (vs.container || list.parentNode);
|
|
@@ -15,6 +15,7 @@ export interface SearchBarProps {
|
|
|
15
15
|
onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;
|
|
16
16
|
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
|
17
17
|
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
|
18
|
+
onClick?: React.MouseEventHandler<HTMLInputElement>;
|
|
18
19
|
disabled?: boolean;
|
|
19
20
|
readOnly?: boolean;
|
|
20
21
|
expanded?: boolean;
|