@progress/kendo-react-dropdowns 13.3.0 → 13.4.0-develop.2
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/AutoComplete/AutoComplete.d.ts +274 -0
- package/AutoComplete/AutoComplete.js +1 -1
- package/AutoComplete/AutoComplete.mjs +67 -69
- package/AutoComplete/AutoCompleteProps.d.ts +509 -0
- package/ComboBox/ComboBox.d.ts +279 -0
- package/ComboBox/ComboBox.js +1 -1
- package/ComboBox/ComboBox.mjs +281 -297
- package/ComboBox/ComboBoxProps.d.ts +632 -0
- package/DropDownList/DropDownList.d.ts +41 -0
- package/DropDownList/DropDownList.js +1 -1
- package/DropDownList/DropDownList.mjs +78 -83
- package/DropDownList/DropDownListProps.d.ts +594 -0
- package/DropDownList/models/index.d.ts +54 -0
- package/DropDownTree/DropDownTree.d.ts +76 -0
- package/DropDownTree/DropDownTree.js +1 -1
- package/DropDownTree/DropDownTree.mjs +6 -8
- package/DropDownTree/DropDownTreeProps.d.ts +506 -0
- package/DropDownTree/ListNoData.d.ts +13 -0
- package/DropDownTree/useDropdownWidth.d.ts +13 -0
- package/MultiColumnComboBox/MultiColumnComboBox.d.ts +299 -0
- package/MultiColumnComboBox/MultiColumnComboBox.js +1 -1
- package/MultiColumnComboBox/MultiColumnComboBox.mjs +45 -48
- package/MultiSelect/MultiSelect.d.ts +281 -0
- package/MultiSelect/MultiSelect.js +1 -1
- package/MultiSelect/MultiSelect.mjs +13 -15
- package/MultiSelect/MultiSelectProps.d.ts +592 -0
- package/MultiSelect/TagList.d.ts +45 -0
- package/MultiSelectTree/MultiSelectTree.d.ts +87 -0
- package/MultiSelectTree/MultiSelectTree.js +1 -1
- package/MultiSelectTree/MultiSelectTree.mjs +7 -7
- package/MultiSelectTree/MultiSelectTreeProps.d.ts +554 -0
- package/MultiSelectTree/utils.d.ts +24 -0
- package/common/AdaptiveMode.d.ts +22 -0
- package/common/ClearButton.d.ts +19 -0
- package/common/DropDownBase.d.ts +186 -0
- package/common/DropDownBase.js +1 -1
- package/common/DropDownBase.mjs +1 -1
- package/common/GroupStickyHeader.d.ts +26 -0
- package/common/GroupStickyHeader.js +1 -1
- package/common/GroupStickyHeader.mjs +6 -6
- package/common/List.d.ts +54 -0
- package/common/List.js +1 -1
- package/common/List.mjs +129 -77
- package/common/ListContainer.d.ts +24 -0
- package/common/ListDefaultItem.d.ts +22 -0
- package/common/ListFilter.d.ts +29 -0
- package/common/ListFilter.js +1 -1
- package/common/ListFilter.mjs +12 -12
- package/common/ListGroupItem.d.ts +54 -0
- package/common/ListGroupItem.js +1 -1
- package/common/ListGroupItem.mjs +21 -13
- package/common/ListItem.d.ts +87 -0
- package/common/ListItem.js +1 -1
- package/common/ListItem.mjs +62 -21
- package/common/ListItemIcon.d.ts +26 -0
- package/common/ListItemIcon.js +8 -0
- package/common/ListItemIcon.mjs +21 -0
- package/common/MultiColumnList.d.ts +13 -0
- package/common/Navigation.d.ts +20 -0
- package/common/SearchBar.d.ts +55 -0
- package/common/VirtualScrollStatic.d.ts +44 -0
- package/common/events.d.ts +82 -0
- package/common/filterDescriptor.d.ts +48 -0
- package/common/settings.d.ts +112 -0
- package/common/utils.d.ts +82 -0
- package/common/utils.js +1 -1
- package/common/utils.mjs +50 -47
- package/common/withCustomComponent.d.ts +12 -0
- package/dist/cdn/js/kendo-react-dropdowns.js +1 -1
- package/index.d.mts +28 -5545
- package/index.d.ts +28 -5545
- package/messages/index.d.ts +52 -0
- package/package-metadata.d.ts +12 -0
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +10 -16
- package/package.json +10 -10
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
import { default as PropTypes } from 'prop-types';
|
|
9
|
+
import { AutoCompleteProps } from './AutoCompleteProps.js';
|
|
10
|
+
import { DropDownStateBase, InternalState } from './../common/settings.js';
|
|
11
|
+
import { default as DropDownBase } from '../common/DropDownBase.js';
|
|
12
|
+
import { FormComponent, FormComponentValidity } from '@progress/kendo-react-common';
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
/**
|
|
15
|
+
* @hidden
|
|
16
|
+
*/
|
|
17
|
+
export interface AutoCompleteState extends DropDownStateBase {
|
|
18
|
+
focusedItem?: any;
|
|
19
|
+
value?: string;
|
|
20
|
+
windowWidth?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @hidden
|
|
24
|
+
*/
|
|
25
|
+
export interface AutoCompleteInternalState extends InternalState {
|
|
26
|
+
data: AutoCompleteState;
|
|
27
|
+
}
|
|
28
|
+
/** @hidden */
|
|
29
|
+
export declare class AutoCompleteWithoutContext extends React.Component<AutoCompleteProps, AutoCompleteState> implements FormComponent {
|
|
30
|
+
static displayName: string;
|
|
31
|
+
/**
|
|
32
|
+
* @hidden
|
|
33
|
+
*/
|
|
34
|
+
static propTypes: {
|
|
35
|
+
size: PropTypes.Requireable<"small" | "medium" | "large" | undefined>;
|
|
36
|
+
rounded: PropTypes.Requireable<"small" | "medium" | "large" | "full" | undefined>;
|
|
37
|
+
fillMode: PropTypes.Requireable<"flat" | "solid" | "outline" | undefined>;
|
|
38
|
+
groupField: PropTypes.Requireable<string>;
|
|
39
|
+
suggest: PropTypes.Requireable<NonNullable<string | boolean | null | undefined>>;
|
|
40
|
+
placeholder: PropTypes.Requireable<string>;
|
|
41
|
+
value: PropTypes.Requireable<string>;
|
|
42
|
+
defaultValue: PropTypes.Requireable<string>;
|
|
43
|
+
validationMessage: PropTypes.Requireable<string>;
|
|
44
|
+
required: PropTypes.Requireable<boolean>;
|
|
45
|
+
readonly: PropTypes.Requireable<boolean>;
|
|
46
|
+
clearButton: PropTypes.Requireable<boolean>;
|
|
47
|
+
valueRender: PropTypes.Requireable<(...args: any[]) => any>;
|
|
48
|
+
id: PropTypes.Requireable<string>;
|
|
49
|
+
ariaLabelledBy: PropTypes.Requireable<string>;
|
|
50
|
+
ariaDescribedBy: PropTypes.Requireable<string>;
|
|
51
|
+
list: PropTypes.Requireable<any>;
|
|
52
|
+
adaptive: PropTypes.Requireable<boolean>;
|
|
53
|
+
adaptiveTitle: PropTypes.Requireable<string>;
|
|
54
|
+
adaptiveSubtitle: PropTypes.Requireable<string>;
|
|
55
|
+
onCancel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
56
|
+
skipDisabledItems: PropTypes.Requireable<boolean>;
|
|
57
|
+
inputAttributes: PropTypes.Requireable<object>;
|
|
58
|
+
opened: PropTypes.Requireable<boolean>;
|
|
59
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
60
|
+
dir: PropTypes.Requireable<string>;
|
|
61
|
+
tabIndex: PropTypes.Requireable<number>;
|
|
62
|
+
accessKey: PropTypes.Requireable<string>;
|
|
63
|
+
data: PropTypes.Requireable<any[]>;
|
|
64
|
+
textField: PropTypes.Requireable<string>;
|
|
65
|
+
className: PropTypes.Requireable<string>;
|
|
66
|
+
label: PropTypes.Requireable<string>;
|
|
67
|
+
loading: PropTypes.Requireable<boolean>;
|
|
68
|
+
popupSettings: PropTypes.Requireable<PropTypes.InferProps<{
|
|
69
|
+
animate: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{
|
|
70
|
+
openDuration: PropTypes.Requireable<number>;
|
|
71
|
+
closeDuration: PropTypes.Requireable<number>;
|
|
72
|
+
}> | null | undefined>>;
|
|
73
|
+
popupClass: PropTypes.Requireable<string>;
|
|
74
|
+
className: PropTypes.Requireable<string>;
|
|
75
|
+
appendTo: PropTypes.Requireable<any>;
|
|
76
|
+
width: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
77
|
+
height: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
78
|
+
}>>;
|
|
79
|
+
onOpen: PropTypes.Requireable<(...args: any[]) => any>;
|
|
80
|
+
onClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
81
|
+
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
82
|
+
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
83
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
84
|
+
itemRender: PropTypes.Requireable<(...args: any[]) => any>;
|
|
85
|
+
listNoDataRender: PropTypes.Requireable<(...args: any[]) => any>;
|
|
86
|
+
focusedItemIndex: PropTypes.Requireable<(...args: any[]) => any>;
|
|
87
|
+
header: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
88
|
+
footer: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* @hidden
|
|
92
|
+
*/
|
|
93
|
+
static defaultProps: {
|
|
94
|
+
size: "small" | "medium" | "large" | undefined;
|
|
95
|
+
rounded: "small" | "medium" | "large" | "full" | undefined;
|
|
96
|
+
fillMode: "flat" | "solid" | "outline" | undefined;
|
|
97
|
+
skipDisabledItems: boolean;
|
|
98
|
+
prefix: undefined;
|
|
99
|
+
suffix: undefined;
|
|
100
|
+
popupSettings: {
|
|
101
|
+
height: string;
|
|
102
|
+
};
|
|
103
|
+
required: boolean;
|
|
104
|
+
validityStyles: boolean;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* @hidden
|
|
108
|
+
*/
|
|
109
|
+
readonly state: AutoCompleteState;
|
|
110
|
+
protected readonly base: DropDownBase;
|
|
111
|
+
private _element;
|
|
112
|
+
private get _inputId();
|
|
113
|
+
private _suggested;
|
|
114
|
+
private _input;
|
|
115
|
+
private _adaptiveInput;
|
|
116
|
+
private _skipFocusEvent;
|
|
117
|
+
private _valueDuringOnChange?;
|
|
118
|
+
private _isScrolling;
|
|
119
|
+
private itemHeight;
|
|
120
|
+
private observerResize?;
|
|
121
|
+
private get document();
|
|
122
|
+
/**
|
|
123
|
+
* @hidden
|
|
124
|
+
*/
|
|
125
|
+
focus: () => void;
|
|
126
|
+
/**
|
|
127
|
+
* @hidden
|
|
128
|
+
*/
|
|
129
|
+
get element(): HTMLSpanElement | null;
|
|
130
|
+
/**
|
|
131
|
+
* The value of the AutoComplete.
|
|
132
|
+
*/
|
|
133
|
+
get value(): string;
|
|
134
|
+
/**
|
|
135
|
+
* Gets the `name` property of the AutoComplete.
|
|
136
|
+
*/
|
|
137
|
+
get name(): string | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* Represents the validity state into which the AutoComplete is set.
|
|
140
|
+
*/
|
|
141
|
+
get validity(): FormComponentValidity;
|
|
142
|
+
/** @hidden */
|
|
143
|
+
get opened(): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* The mobile mode of the AutoComplete.
|
|
146
|
+
*/
|
|
147
|
+
get mobileMode(): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* @hidden
|
|
150
|
+
*/
|
|
151
|
+
protected get validityStyles(): boolean;
|
|
152
|
+
/**
|
|
153
|
+
* @hidden
|
|
154
|
+
*/
|
|
155
|
+
protected get required(): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* @hidden
|
|
158
|
+
*/
|
|
159
|
+
componentDidUpdate(prevProps: AutoCompleteProps, prevState: AutoCompleteState): void;
|
|
160
|
+
/**
|
|
161
|
+
* @hidden
|
|
162
|
+
*/
|
|
163
|
+
componentDidMount(): void;
|
|
164
|
+
/**
|
|
165
|
+
* @hidden
|
|
166
|
+
*/
|
|
167
|
+
componentWillUnmount(): void;
|
|
168
|
+
/**
|
|
169
|
+
* @hidden
|
|
170
|
+
*/
|
|
171
|
+
render(): React.JSX.Element;
|
|
172
|
+
/**
|
|
173
|
+
* @hidden
|
|
174
|
+
*/
|
|
175
|
+
handleItemSelect: (index: number, state: AutoCompleteInternalState) => void;
|
|
176
|
+
/**
|
|
177
|
+
* @hidden
|
|
178
|
+
*/
|
|
179
|
+
itemFocus: (index: number, state: AutoCompleteInternalState) => void;
|
|
180
|
+
/**
|
|
181
|
+
* @hidden
|
|
182
|
+
*/
|
|
183
|
+
togglePopup: (state: InternalState) => void;
|
|
184
|
+
/**
|
|
185
|
+
* @hidden
|
|
186
|
+
*/
|
|
187
|
+
onNavigate(state: AutoCompleteInternalState, keyCode: number, skipItems?: number): void;
|
|
188
|
+
/**
|
|
189
|
+
* @hidden
|
|
190
|
+
*/
|
|
191
|
+
applyInputValue(value: string, state: AutoCompleteInternalState, eventKey?: number): void;
|
|
192
|
+
private setValidity;
|
|
193
|
+
private renderSearchBar;
|
|
194
|
+
private renderAdaptiveListContainer;
|
|
195
|
+
private onCancel;
|
|
196
|
+
private renderListContainer;
|
|
197
|
+
private listContainerContent;
|
|
198
|
+
private renderList;
|
|
199
|
+
private onScroll;
|
|
200
|
+
private handleItemClick;
|
|
201
|
+
private onChangeHandler;
|
|
202
|
+
private clearButtonClick;
|
|
203
|
+
private onInputKeyDown;
|
|
204
|
+
private handleFocus;
|
|
205
|
+
private handleBlur;
|
|
206
|
+
private handleWrapperClick;
|
|
207
|
+
private triggerOnChange;
|
|
208
|
+
private focusElement;
|
|
209
|
+
private applyState;
|
|
210
|
+
private suggestValue;
|
|
211
|
+
private focusedIndex;
|
|
212
|
+
private calculateMedia;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Represents the PropsContext of the `AutoComplete` component.
|
|
216
|
+
* Used for global configuration of all `AutoComplete` instances.
|
|
217
|
+
*
|
|
218
|
+
* For more information, refer to the [Dropdowns Props Context](https://www.telerik.com/kendo-react-ui/components/dropdowns/props-context) article.
|
|
219
|
+
*/
|
|
220
|
+
export declare const AutoCompletePropsContext: React.Context<(p: AutoCompleteProps) => AutoCompleteProps>;
|
|
221
|
+
/**
|
|
222
|
+
* Represent the `ref` of the AutoComplete component.
|
|
223
|
+
*/
|
|
224
|
+
export interface AutoCompleteHandle extends Pick<AutoCompleteWithoutContext, keyof AutoCompleteWithoutContext> {
|
|
225
|
+
/**
|
|
226
|
+
* The AutoComplete element.
|
|
227
|
+
*/
|
|
228
|
+
element: HTMLSpanElement | null;
|
|
229
|
+
/**
|
|
230
|
+
* Gets the mobile mode of the AutoComplete component.
|
|
231
|
+
*/
|
|
232
|
+
mobileMode: boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Gets the `name` property of the AutoComplete.
|
|
235
|
+
*/
|
|
236
|
+
name: string | undefined;
|
|
237
|
+
/**
|
|
238
|
+
* Gets whether the AutoComplete popup is open.
|
|
239
|
+
*/
|
|
240
|
+
opened: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Represents the validity state into which the AutoComplete is set.
|
|
243
|
+
*/
|
|
244
|
+
validity: FormComponentValidity;
|
|
245
|
+
/**
|
|
246
|
+
* The value of the AutoComplete.
|
|
247
|
+
*/
|
|
248
|
+
value: string;
|
|
249
|
+
}
|
|
250
|
+
/** @hidden */
|
|
251
|
+
export type AutoComplete = AutoCompleteHandle;
|
|
252
|
+
/**
|
|
253
|
+
* Represents the [KendoReact AutoComplete component](https://www.telerik.com/kendo-react-ui/components/dropdowns/autocomplete).
|
|
254
|
+
*
|
|
255
|
+
* Accepts properties of type [AutoCompleteProps](https://www.telerik.com/kendo-react-ui/components/dropdowns/api/autocompleteprops).
|
|
256
|
+
* Obtaining the `ref` returns an object of type [AutoCompleteHandle](https://www.telerik.com/kendo-react-ui/components/dropdowns/api/autocompletehandle).
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```jsx
|
|
260
|
+
* const App = () => {
|
|
261
|
+
* const autocomplete = React.useRef(null);
|
|
262
|
+
* return (
|
|
263
|
+
* <div>
|
|
264
|
+
* <AutoComplete
|
|
265
|
+
* data={[ "Albania", "Andorra", "Austria", "Belarus" ]}
|
|
266
|
+
* ref={autocomplete}
|
|
267
|
+
* />
|
|
268
|
+
* <Button onClick={() => alert(autocomplete.current.value)}>alert value</Button>
|
|
269
|
+
* </div>
|
|
270
|
+
* );
|
|
271
|
+
* }
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
export declare const AutoComplete: React.ForwardRefExoticComponent<AutoCompleteProps & React.RefAttributes<any>>;
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react"),g=require("prop-types"),T=require("../common/SearchBar.js"),V=require("../common/ListContainer.js"),q=require("../common/List.js"),w=require("../common/DropDownBase.js"),N=require("../common/GroupStickyHeader.js"),f=require("../common/utils.js"),l=require("@progress/kendo-react-common"),R=require("@progress/kendo-react-labels"),L=require("../common/ClearButton.js"),z=require("../common/AdaptiveMode.js"),F=require("../common/withCustomComponent.js"),A=require("@progress/kendo-react-layout"),H=require("../common/ListFilter.js");function W(I){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(I){for(const t in I)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(I,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>I[t]})}}return e.default=I,Object.freeze(e)}const m=W(B),j="Please enter a valid value!",{sizeMap:D,roundedMap:G}=l.kendoThemeMaps,y=class y extends m.Component{constructor(){super(...arguments),this.state={},this.base=new w(this),this._element=null,this._suggested="",this._input=null,this._adaptiveInput=null,this._skipFocusEvent=!1,this._isScrolling=!1,this.itemHeight=0,this.focus=()=>{this._input&&this._input.focus()},this.handleItemSelect=(e,t)=>{const s=f.getFilteredData(this.props),o=f.getItemValue(s[e],this.props.textField);this.state.text&&!this.mobileMode&&(this.state.text&&(t.data.text=""),this.base.filterChanged("",t)),this._adaptiveInput&&this._adaptiveInput.blur(),this.triggerOnChange(o,t)},this.itemFocus=(e,t)=>{const{textField:s}=this.props,i=f.getFilteredData(this.props)[e];f.areSame(this.state.focusedItem,i,s)||(t.data.focusedItem=i)},this.togglePopup=e=>{this.base.togglePopup(e)},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||j)},this.renderAdaptiveListContainer=()=>{const{windowWidth:e=0}=this.state,t=m.createElement(H,{value:this.value,ref:o=>{this._adaptiveInput=o&&o.element},onChange:this.onChangeHandler,onKeyDown:this.onInputKeyDown,size:"large",rounded:this.props.rounded,fillMode:this.props.fillMode,placeholder:this.props.placeholder}),s={title:this.props.adaptiveTitle||this.props.label,subTitle:this.props.adaptiveSubtitle,expand:this.opened,onClose:o=>this.onCancel(o),windowWidth:e,mobileFilter:t};return m.createElement(z.AdaptiveMode,{...s},m.createElement(A.ActionSheetContent,null,m.createElement("div",{className:"k-list-container"},this.listContainerContent())))},this.onCancel=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.opened&&this.base.togglePopup(t),t.events.push({type:"onCancel"});const s=this.state.text;f.isPresent(s)&&s!==""&&this.base.filterChanged("",t),this.state.text&&(t.data.text=""),this.applyState(t)},this.listContainerContent=()=>{const{header:e,footer:t,size:s,groupStickyHeaderItemRender:o,groupField:i,list:a}=this.props,d=f.getFilteredData(this.props);let{group:n}=this.state;return n===void 0&&i!==void 0&&(n=f.getItemValue(d[0],i)),m.createElement(m.Fragment,null,e&&m.createElement("div",{className:"k-list-header"},e),m.createElement("div",{className:l.classNames("k-list",{[`k-list-${this.mobileMode?"lg":D[s]||s}`]:s})},!a&&n&&d.length!==0&&m.createElement(N,{group:n,groupMode:"modern",render:o}),this.renderList()),t&&m.createElement("div",{className:"k-list-footer"},t))},this.onScroll=e=>{this._isScrolling=!0;const{list:t}=this.base,{groupField:s}=this.props;let o=f.getFilteredData(this.props);if(!s||!o.length)return;const i=this.itemHeight||(t?t.children[0].offsetHeight:0),d=e.target.scrollTop;s&&(o=this.base.getGroupedDataModernMode(o,s));let n=o[0][s];for(let r=1;r<o.length&&!(i*r>d);r++)o[r]&&o[r][s]&&(n=o[r][s]);n!==this.state.group&&this.setState({group:n})},this.handleItemClick=(e,t)=>{this.base.handleItemClick(e,t),this._valueDuringOnChange=void 0},this.onChangeHandler=e=>{const s=this.base.initState(),o=this.mobileMode?e.target.element:e.currentTarget,i=o.value,a=o.selectionEnd===i.length;s.syntheticEvent=e;const d=this._suggested,n=this.value,r=n&&n.substring(0,n.length-d.length),h=r&&r===i,u=r&&r.length>i.length,{suggest:b}=this.props,p=this.props.opened!==void 0?this.props.opened:this.state.opened;if(b!==void 0&&b!==!1){h||u||!a?this._suggested="":this.suggestValue(i);const c=i+this._suggested,v={userInput:i,value:this._suggested};this.triggerOnChange(c,s,{suggestion:v})}else this._suggested="",this.triggerOnChange(i,s);(!p&&i||p&&!i)&&this.togglePopup(s),s.data.focusedItem=void 0,this.applyState(s),this.setState({group:void 0})},this.clearButtonClick=e=>{const s=this.base.initState(),o=this.props.opened!==void 0?this.props.opened:this.state.opened;s.syntheticEvent=e;const i="";this._suggested="",this.triggerOnChange(i,s),this.state.focusedItem!==void 0&&(s.data.focusedItem=void 0),o&&this.togglePopup(s),this.applyState(s)},this.onInputKeyDown=e=>{const{skipDisabledItems:t,groupField:s,textField:o}=this.props,i=f.getFilteredData(this.props);this._isScrolling&&(this._isScrolling=!1);const a=this.focusedIndex(),d=i[a],n=e.keyCode,r=e.altKey,h=this.props.opened!==void 0?this.props.opened:this.state.opened,u=this.base.initState();u.syntheticEvent=e;const b=()=>{h&&e.preventDefault()};if(r&&n===l.Keys.down)this.setState({opened:!0});else if(r&&n===l.Keys.up)this.setState({opened:!1});else if(h&&n===l.Keys.pageUp)b(),this.base.scrollPopupByPageSize(-1);else if(h&&n===l.Keys.pageDown)b(),this.base.scrollPopupByPageSize(1);else if(h&&(n===l.Keys.enter||n===l.Keys.esc))b(),t===!1&&d&&d.disabled?(h&&this.togglePopup(u),this.applyState(u)):this.applyInputValue(e.currentTarget.value,u,e.keyCode);else if(!h&&n===l.Keys.esc){const p="";this._suggested="",this.triggerOnChange(p,u),this.state.focusedItem!==void 0&&(u.data.focusedItem=void 0),this.applyState(u)}else if(n===l.Keys.up||n===l.Keys.down){if(s!==""&&o)if(!this.props.skipDisabledItems&&h)this.onNavigate(u,n);else{let p=0;if(n===l.Keys.down||n===l.Keys.right){const c=i.slice(a+1).find(v=>!v.disabled&&v[o]);p=c&&i.findIndex(v=>v[o]===c[o])}else if(n===l.Keys.up||n===l.Keys.left){let c;if(a===-1)c=i,p=i.findIndex(v=>!v.disabled&&v[o]);else{c=i.slice(0,a);let v=c.pop();for(;v&&v.disabled;)v=c.pop();p=v&&i.findIndex(S=>S[o]===v[o])}}if(p!==void 0){const c=p-a;this.onNavigate(u,n,c)}else p===void 0&&i.findIndex(c=>c[o])===i.length-1&&this.onNavigate(u,n)}else if(!this.props.skipDisabledItems&&h)this.onNavigate(u,n);else{let p=null;if(n===l.Keys.down||n===l.Keys.right)p=i.slice(a+1).find(c=>!c.disabled);else if(n===l.Keys.up||n===l.Keys.left){const c=i.slice(0,a);for(p=c.pop();p&&p.disabled;)p=c.pop()}if(p){const c=p.id-a-1;this.onNavigate(u,n,c)}else this.onNavigate(u,n)}this.applyState(u),b()}},this.handleFocus=e=>{this._skipFocusEvent||this.base.handleFocus(e)},this.handleBlur=e=>{const t=this.base.initState();!this.state.focused||this._skipFocusEvent||(t.syntheticEvent=e,t.data.focused=!1,t.events.push({type:"onBlur"}),this.opened&&!this.mobileMode&&(this.state.opened&&(t.data.opened=!1),t.events.push({type:"onClose"})),this.applyState(t))},this.handleWrapperClick=e=>{const t=this._input;!this.opened&&t&&this.focusElement(t);const s=this.base.initState();s.syntheticEvent=e,!this.state.focused&&!this.mobileMode&&(s.events.push({type:"onFocus"}),s.data.focused=!0),this.mobileMode&&window.setTimeout(()=>this._adaptiveInput&&this._adaptiveInput.focus(),300),this.base.togglePopup(s),this.applyState(s)}}get _inputId(){return this.props.id+"-accessibility-id"}get document(){if(l.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get value(){return this._valueDuringOnChange!==void 0?this._valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value!==void 0?this.state.value:this.props.defaultValue!==void 0?this.props.defaultValue:""}get name(){return this.props.name}get validity(){const e=this.props.validationMessage!==void 0,t=!this.required||this.value!=="",s=this.props.valid!==void 0?this.props.valid:t;return{customError:e,valid:s,valueMissing:this.value===null}}get opened(){return!!(this.props.opened!==void 0?this.props.opened:this.state.opened)}get mobileMode(){var t;return!!(this.state.windowWidth&&this.props._adaptiveMode&&this.state.windowWidth<=((t=this.props._adaptiveMode)==null?void 0:t.medium)&&this.props.adaptive)}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:y.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:y.defaultProps.required}componentDidUpdate(e,t){var p;const{groupField:s=""}=this.props,o=f.getFilteredData(this.props),{data:i=[]}=e,a=this.focusedIndex(),d=o[a],n=i!==o,r=d!==void 0&&t.focusedItem!==d,h=this.props.opened!==void 0?this.props.opened:this.state.opened,u=e.opened!==void 0?e.opened:t.opened,b=!u&&h;if(s==="")(h&&(r||n)||b)&&this.base.scrollToItem(a);else if(!this._isScrolling){const c=(p=this.base.getGroupedDataModernMode(o,s))==null?void 0:p.indexOf(d);b&&(o&&o.length!==0&&this.base.resetGroupStickyHeader(o[0][s],this),this.base.scrollToItem(c)),h&&u&&r&&this.base.scrollToItem(c)}this.setValidity()}componentDidMount(){var e;this.observerResize=l.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(e=this.document)!=null&&e.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentWillUnmount(){this.observerResize&&this.observerResize.disconnect()}render(){const{dir:e,disabled:t,label:s,className:o,style:i,loading:a,suggest:d,size:n,rounded:r,fillMode:h}=this.props,u=!this.validityStyles||this.validity.valid,b=this.base,p=this.value,c=this.props.clearButton!==!1&&!a&&!!p,v=this.props.id||this._inputId,S=this.state.focused;typeof d=="string"&&(this._suggested=d);const[E,O]=F(this.props.prefix||m.Fragment),[P,K]=F(this.props.suffix||m.Fragment),k=m.createElement(m.Fragment,null,m.createElement("span",{className:l.classNames("k-autocomplete k-input",o,{[`k-input-${D[n]||n}`]:n,[`k-rounded-${G[r]||r}`]:r,[`k-input-${h}`]:h,"k-invalid":!u,"k-focus":S&&!t,"k-loading":a,"k-required":this.required,"k-disabled":t}),ref:C=>{this._element=C,b.wrapper=C},style:s?{...i,width:void 0}:i,dir:e,onFocus:this.mobileMode?C=>this.handleWrapperClick(C):this.handleFocus,onBlur:this.handleBlur,onClick:this.handleWrapperClick},this.props.prefix&&m.createElement(E,{...O}),this.renderSearchBar(p||"",v),a&&m.createElement(l.IconWrap,{className:"k-input-loading-icon",name:"loading"}),c&&!a&&m.createElement(L,{onClick:this.clearButtonClick,key:"clearbutton"}),this.props.suffix&&m.createElement(P,{...K}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return s?m.createElement(R.FloatingLabel,{label:s,editorId:v,editorValue:p,editorValid:u,editorDisabled:t,style:{width:i?i.width:void 0},children:k}):k}onNavigate(e,t,s){const o=this.value,{textField:i,focusedItemIndex:a}=this.props,d=f.getFilteredData(this.props),n=this.state.focusedItem!==void 0?d.findIndex(h=>f.areSame(h,this.state.focusedItem,i)):a?a(d,o,i):d.indexOf(f.getFocusedItem(d,o,i)),r=this.base.navigation.navigate({keyCode:t,current:n,max:d.length-1,min:0,skipItems:s||void 0});r!==void 0&&this.itemFocus(r,e),this.applyState(e)}applyInputValue(e,t,s){const o=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:i}=this.props,a=f.getFilteredData(this.props),d=this.focusedIndex(),n=a[d];if(this._suggested="",o&&s===l.Keys.enter&&n&&!n.disabled){const r=f.getItemValue(a[this.focusedIndex(e)],i);this.triggerOnChange(r,t)}o&&this.togglePopup(t),this.applyState(t)}renderSearchBar(e,t){const s=this.base,{placeholder:o,tabIndex:i,disabled:a,readonly:d,inputAttributes:n}=this.props,{focused:r}=this.state,h=this.props.opened!==void 0?this.props.opened:this.state.opened;return m.createElement(T,{id:t,placeholder:o,tabIndex:i,accessKey:this.props.accessKey,value:e,suggestedText:this._suggested,focused:r,name:this.props.name,ref:u=>{this._input=u&&u.input},onKeyDown:this.onInputKeyDown,onChange:this.onChangeHandler,onFocus:s.handleFocus,onBlur:this.handleBlur,disabled:a,readOnly:d,expanded:h,owns:s.listBoxId,activedescendant:"option-"+s.guid+"-"+this.focusedIndex(),role:"combobox",ariaLabelledBy:this.props.ariaLabelledBy,ariaDescribedBy:this.props.ariaDescribedBy,ariaRequired:this.required,render:this.props.valueRender,inputAttributes:n})}renderListContainer(){const e=this.base,{dir:t,groupField:s}=this.props,o=f.getFilteredData(this.props),i=e.getPopupSettings(),a=this.props.opened!==void 0?this.props.opened:this.state.opened,d=i.width!==void 0?i.width:e.popupWidth;let{group:n}=this.state;return n===void 0&&s!==void 0&&(n=f.getItemValue(o[0],s)),m.createElement(V,{width:d,popupSettings:{...i,anchor:i.anchor||this.element,show:a,popupClass:l.classNames(i.popupClass,"k-list-container","k-autocomplete-popup")},dir:t!==void 0?t:this.base.dirCalculated,itemsCount:[o.length]},this.listContainerContent())}renderList(){const e=this.base,t=e.getPopupSettings(),{textField:s,listNoDataRender:o,itemRender:i,groupHeaderItemRender:a}=this.props,d=f.getFilteredData(this.props),n=this.value,r=this.props.opened!==void 0?this.props.opened:this.state.opened;return m.createElement(q,{id:e.listBoxId,show:r,data:d.slice(),focusedIndex:this.focusedIndex(),value:n,textField:s,valueField:s,highlightSelected:!1,optionsGuid:e.guid,groupField:this.props.groupField,groupMode:"modern",listRef:h=>{e.list=h},wrapperStyle:this.mobileMode?{}:{maxHeight:t.height},wrapperCssClass:"k-list-content",onClick:this.handleItemClick,itemRender:i,groupHeaderItemRender:a,noDataRender:o,onMouseDown:h=>h.preventDefault(),onScroll:this.onScroll})}triggerOnChange(e,t,s){this.value===e&&!s||(t.data.value=e,this._valueDuringOnChange=e,t.events.push({type:"onChange",...s||{}}))}focusElement(e){this._skipFocusEvent=!0,e.focus(),window.setTimeout(()=>this._skipFocusEvent=!1,0)}applyState(e){this.base.applyState(e),this._valueDuringOnChange=void 0}suggestValue(e){if(this._suggested="",e){const{textField:t}=this.props,s=f.getFilteredData(this.props),o=s[f.itemIndexStartsWith(s,e,t)];if(o){const i=f.getItemValue(o,t);e.toLowerCase()!==i.toLowerCase()&&(this._suggested=i.substring(e.length))}}}focusedIndex(e){const{textField:t,focusedItemIndex:s,skipDisabledItems:o}=this.props,i=f.getFilteredData(this.props),a=e!==void 0?e:this.value;if(this.state.focusedItem!==void 0)return i.findIndex(n=>f.areSame(n,this.state.focusedItem,t));if(s)return s(i,a,t);const d=i.indexOf(f.getFocusedItem(i,a,t));return o&&t&&d===-1?i.findIndex(n=>!n.disabled&&n[t]):Math.max(0,d)}calculateMedia(e){for(const t of e)this.setState({windowWidth:t.target.clientWidth})}};y.displayName="AutoComplete",y.propTypes={...w.basicPropTypes,size:g.oneOf([null,"small","medium","large"]),rounded:g.oneOf([null,"small","medium","large","full"]),fillMode:g.oneOf([null,"solid","flat","outline"]),groupField:g.string,suggest:g.oneOfType([g.bool,g.string]),placeholder:g.string,value:g.string,defaultValue:g.string,validationMessage:g.string,required:g.bool,readonly:g.bool,clearButton:g.bool,valueRender:g.func,id:g.string,ariaLabelledBy:g.string,ariaDescribedBy:g.string,list:g.any,adaptive:g.bool,adaptiveTitle:g.string,adaptiveSubtitle:g.string,onCancel:g.func,skipDisabledItems:g.bool,inputAttributes:g.object},y.defaultProps={...w.defaultProps,size:"medium",rounded:"medium",fillMode:"solid",skipDisabledItems:!0,prefix:void 0,suffix:void 0};let x=y;const _=l.createPropsContext(),M=l.withIdHOC(l.withPropsContext(_,l.withAdaptiveModeContext(x)));M.displayName="KendoReactAutoComplete";exports.AutoComplete=M;exports.AutoCompletePropsContext=_;exports.AutoCompleteWithoutContext=x;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("react"),g=require("prop-types"),B=require("../common/SearchBar.js"),T=require("../common/ListContainer.js"),q=require("../common/List.js"),w=require("../common/DropDownBase.js"),N=require("../common/GroupStickyHeader.js"),f=require("../common/utils.js"),l=require("@progress/kendo-react-common"),R=require("@progress/kendo-react-labels"),L=require("../common/ClearButton.js"),z=require("../common/AdaptiveMode.js"),F=require("../common/withCustomComponent.js"),A=require("@progress/kendo-react-layout"),H=require("../common/ListFilter.js");function W(I){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(I){for(const t in I)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(I,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>I[t]})}}return e.default=I,Object.freeze(e)}const m=W(V),j="Please enter a valid value!",{sizeMap:D,roundedMap:G}=l.kendoThemeMaps,y=class y extends m.Component{constructor(){super(...arguments),this.state={},this.base=new w(this),this._element=null,this._suggested="",this._input=null,this._adaptiveInput=null,this._skipFocusEvent=!1,this._isScrolling=!1,this.itemHeight=0,this.focus=()=>{this._input&&this._input.focus()},this.handleItemSelect=(e,t)=>{const s=f.getFilteredData(this.props),o=f.getItemValue(s[e],this.props.textField);this.state.text&&!this.mobileMode&&(this.state.text&&(t.data.text=""),this.base.filterChanged("",t)),this._adaptiveInput&&this._adaptiveInput.blur(),this.triggerOnChange(o,t)},this.itemFocus=(e,t)=>{const{textField:s}=this.props,i=f.getFilteredData(this.props)[e];f.areSame(this.state.focusedItem,i,s)||(t.data.focusedItem=i)},this.togglePopup=e=>{this.base.togglePopup(e)},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||j)},this.renderAdaptiveListContainer=()=>{const{windowWidth:e=0}=this.state,t=m.createElement(H,{value:this.value,ref:o=>{this._adaptiveInput=o&&o.element},onChange:this.onChangeHandler,onKeyDown:this.onInputKeyDown,size:"large",rounded:this.props.rounded,fillMode:this.props.fillMode,placeholder:this.props.placeholder}),s={title:this.props.adaptiveTitle||this.props.label,subTitle:this.props.adaptiveSubtitle,expand:this.opened,onClose:o=>this.onCancel(o),windowWidth:e,mobileFilter:t};return m.createElement(z.AdaptiveMode,{...s},m.createElement(A.ActionSheetContent,null,m.createElement("div",{className:"k-list-container"},this.listContainerContent())))},this.onCancel=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.opened&&this.base.togglePopup(t),t.events.push({type:"onCancel"});const s=this.state.text;f.isPresent(s)&&s!==""&&this.base.filterChanged("",t),this.state.text&&(t.data.text=""),this.applyState(t)},this.listContainerContent=()=>{const{header:e,footer:t,size:s,groupStickyHeaderItemRender:o,groupField:i,list:a}=this.props,d=f.getFilteredData(this.props);let{group:n}=this.state;return n===void 0&&i!==void 0&&(n=f.getItemValue(d[0],i)),m.createElement(m.Fragment,null,e&&m.createElement("div",{className:"k-list-header"},e),m.createElement("div",{className:l.classNames("k-list",{[`k-list-${this.mobileMode?"lg":D[s]||s}`]:this.mobileMode||s})},!a&&n&&d.length!==0&&m.createElement(N,{group:n,render:o}),this.renderList()),t&&m.createElement("div",{className:"k-list-footer"},t))},this.onScroll=e=>{this._isScrolling=!0;const{list:t}=this.base,{groupField:s}=this.props;let o=f.getFilteredData(this.props);if(!s||!o.length)return;const i=this.itemHeight||(t?t.children[0].offsetHeight:0),d=e.target.scrollTop;s&&(o=this.base.getGroupedDataModernMode(o,s));let n=o[0][s];for(let r=1;r<o.length&&!(i*r>d);r++)o[r]&&o[r][s]&&(n=o[r][s]);n!==this.state.group&&this.setState({group:n})},this.handleItemClick=(e,t)=>{this.base.handleItemClick(e,t),this._valueDuringOnChange=void 0},this.onChangeHandler=e=>{const s=this.base.initState(),o=this.mobileMode?e.target.element:e.currentTarget,i=o.value,a=o.selectionEnd===i.length;s.syntheticEvent=e;const d=this._suggested,n=this.value,r=n&&n.substring(0,n.length-d.length),p=r&&r===i,h=r&&r.length>i.length,{suggest:b}=this.props,u=this.props.opened!==void 0?this.props.opened:this.state.opened;if(b!==void 0&&b!==!1){p||h||!a?this._suggested="":this.suggestValue(i);const c=i+this._suggested,v={userInput:i,value:this._suggested};this.triggerOnChange(c,s,{suggestion:v})}else this._suggested="",this.triggerOnChange(i,s);(!u&&i||u&&!i)&&this.togglePopup(s),s.data.focusedItem=void 0,this.applyState(s),this.setState({group:void 0})},this.clearButtonClick=e=>{const s=this.base.initState(),o=this.props.opened!==void 0?this.props.opened:this.state.opened;s.syntheticEvent=e;const i="";this._suggested="",this.triggerOnChange(i,s),this.state.focusedItem!==void 0&&(s.data.focusedItem=void 0),o&&this.togglePopup(s),this.applyState(s)},this.onInputKeyDown=e=>{const{skipDisabledItems:t,groupField:s,textField:o}=this.props,i=f.getFilteredData(this.props);this._isScrolling&&(this._isScrolling=!1);const a=this.focusedIndex(),d=i[a],n=e.keyCode,r=e.altKey,p=this.props.opened!==void 0?this.props.opened:this.state.opened,h=this.base.initState();h.syntheticEvent=e;const b=()=>{p&&e.preventDefault()};if(r&&n===l.Keys.down)this.setState({opened:!0});else if(r&&n===l.Keys.up)this.setState({opened:!1});else if(p&&n===l.Keys.pageUp)b(),this.base.scrollPopupByPageSize(-1);else if(p&&n===l.Keys.pageDown)b(),this.base.scrollPopupByPageSize(1);else if(p&&(n===l.Keys.enter||n===l.Keys.esc))b(),t===!1&&d&&d.disabled?(p&&this.togglePopup(h),this.applyState(h)):this.applyInputValue(e.currentTarget.value,h,e.keyCode);else if(!p&&n===l.Keys.esc)this._suggested="",this.triggerOnChange("",h),this.state.focusedItem!==void 0&&(h.data.focusedItem=void 0),this.applyState(h);else if(n===l.Keys.up||n===l.Keys.down){if(s!==""&&o)if(!this.props.skipDisabledItems&&p)this.onNavigate(h,n);else{let u=0;if(n===l.Keys.down||n===l.Keys.right){const c=i.slice(a+1).find(v=>!v.disabled&&v[o]);u=c&&i.findIndex(v=>v[o]===c[o])}else if(n===l.Keys.up||n===l.Keys.left){let c;if(a===-1)c=i,u=i.findIndex(v=>!v.disabled&&v[o]);else{c=i.slice(0,a);let v=c.pop();for(;v&&v.disabled;)v=c.pop();u=v&&i.findIndex(S=>S[o]===v[o])}}if(u!==void 0){const c=u-a;this.onNavigate(h,n,c)}else u===void 0&&i.findIndex(c=>c[o])===i.length-1&&this.onNavigate(h,n)}else if(!this.props.skipDisabledItems&&p)this.onNavigate(h,n);else{let u=null;if(n===l.Keys.down||n===l.Keys.right)u=i.slice(a+1).find(c=>!c.disabled);else if(n===l.Keys.up||n===l.Keys.left){const c=i.slice(0,a);for(u=c.pop();u&&u.disabled;)u=c.pop()}if(u){const c=u.id-a-1;this.onNavigate(h,n,c)}else this.onNavigate(h,n)}this.applyState(h),b()}},this.handleFocus=e=>{this._skipFocusEvent||this.base.handleFocus(e)},this.handleBlur=e=>{const t=this.base.initState();!this.state.focused||this._skipFocusEvent||(t.syntheticEvent=e,t.data.focused=!1,t.events.push({type:"onBlur"}),this.opened&&!this.mobileMode&&(this.state.opened&&(t.data.opened=!1),t.events.push({type:"onClose"})),this.applyState(t))},this.handleWrapperClick=e=>{const t=this._input;!this.opened&&t&&this.focusElement(t);const s=this.base.initState();s.syntheticEvent=e,!this.state.focused&&!this.mobileMode&&(s.events.push({type:"onFocus"}),s.data.focused=!0),this.mobileMode&&window.setTimeout(()=>this._adaptiveInput&&this._adaptiveInput.focus(),300),this.base.togglePopup(s),this.applyState(s)}}get _inputId(){return this.props.id+"-accessibility-id"}get document(){if(l.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get value(){return this._valueDuringOnChange!==void 0?this._valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value!==void 0?this.state.value:this.props.defaultValue!==void 0?this.props.defaultValue:""}get name(){return this.props.name}get validity(){const e=this.props.validationMessage!==void 0,t=!this.required||this.value!=="",s=this.props.valid!==void 0?this.props.valid:t;return{customError:e,valid:s,valueMissing:this.value===null}}get opened(){return!!(this.props.opened!==void 0?this.props.opened:this.state.opened)}get mobileMode(){var t;return!!(this.state.windowWidth&&this.props._adaptiveMode&&this.state.windowWidth<=((t=this.props._adaptiveMode)==null?void 0:t.medium)&&this.props.adaptive)}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:y.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:y.defaultProps.required}componentDidUpdate(e,t){var u;const{groupField:s=""}=this.props,o=f.getFilteredData(this.props),{data:i=[]}=e,a=this.focusedIndex(),d=o[a],n=i!==o,r=d!==void 0&&t.focusedItem!==d,p=this.props.opened!==void 0?this.props.opened:this.state.opened,h=e.opened!==void 0?e.opened:t.opened,b=!h&&p;if(s==="")(p&&(r||n)||b)&&this.base.scrollToItem(a);else if(!this._isScrolling){const c=(u=this.base.getGroupedDataModernMode(o,s))==null?void 0:u.indexOf(d);b&&(o&&o.length!==0&&this.base.resetGroupStickyHeader(o[0][s],this),this.base.scrollToItem(c)),p&&h&&r&&this.base.scrollToItem(c)}this.setValidity()}componentDidMount(){var e;this.observerResize=l.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(e=this.document)!=null&&e.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentWillUnmount(){this.observerResize&&this.observerResize.disconnect()}render(){const{dir:e,disabled:t,label:s,className:o,style:i,loading:a,suggest:d,size:n,rounded:r,fillMode:p}=this.props,h=!this.validityStyles||this.validity.valid,b=this.base,u=this.value,c=this.props.clearButton!==!1&&!a&&!!u,v=this.props.id||this._inputId,S=this.state.focused;typeof d=="string"&&(this._suggested=d);const[E,O]=F(this.props.prefix||m.Fragment),[P,K]=F(this.props.suffix||m.Fragment),k=m.createElement(m.Fragment,null,m.createElement("span",{className:l.classNames("k-autocomplete k-input",o,{[`k-input-${D[n]||n}`]:n,[`k-rounded-${G[r]||r}`]:r,[`k-input-${p}`]:p,"k-invalid":!h,"k-focus":S&&!t,"k-loading":a,"k-required":this.required,"k-disabled":t}),ref:C=>{this._element=C,b.wrapper=C},style:s?{...i,width:void 0}:i,dir:e,onFocus:this.mobileMode?C=>this.handleWrapperClick(C):this.handleFocus,onBlur:this.handleBlur,onClick:this.handleWrapperClick},this.props.prefix&&m.createElement(E,{...O}),this.renderSearchBar(u||"",v),a&&m.createElement(l.IconWrap,{className:"k-input-loading-icon",name:"loading"}),c&&!a&&m.createElement(L,{onClick:this.clearButtonClick,key:"clearbutton"}),this.props.suffix&&m.createElement(P,{...K}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return s?m.createElement(R.FloatingLabel,{label:s,editorId:v,editorValue:u,editorValid:h,editorDisabled:t,style:{width:i?i.width:void 0},children:k}):k}onNavigate(e,t,s){const o=this.value,{textField:i,focusedItemIndex:a}=this.props,d=f.getFilteredData(this.props),n=this.state.focusedItem!==void 0?d.findIndex(p=>f.areSame(p,this.state.focusedItem,i)):a?a(d,o,i):d.indexOf(f.getFocusedItem(d,o,i)),r=this.base.navigation.navigate({keyCode:t,current:n,max:d.length-1,min:0,skipItems:s||void 0});r!==void 0&&this.itemFocus(r,e),this.applyState(e)}applyInputValue(e,t,s){const o=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:i}=this.props,a=f.getFilteredData(this.props),d=this.focusedIndex(),n=a[d];if(this._suggested="",o&&s===l.Keys.enter&&n&&!n.disabled){const r=f.getItemValue(a[this.focusedIndex(e)],i);this.triggerOnChange(r,t)}o&&this.togglePopup(t),this.applyState(t)}renderSearchBar(e,t){const s=this.base,{placeholder:o,tabIndex:i,disabled:a,readonly:d,inputAttributes:n}=this.props,{focused:r}=this.state,p=this.props.opened!==void 0?this.props.opened:this.state.opened;return m.createElement(B,{id:t,placeholder:o,tabIndex:i,accessKey:this.props.accessKey,value:e,suggestedText:this._suggested,focused:r,name:this.props.name,ref:h=>{this._input=h&&h.input},onKeyDown:this.onInputKeyDown,onChange:this.onChangeHandler,onFocus:s.handleFocus,onBlur:this.handleBlur,disabled:a,readOnly:d,expanded:p,owns:s.listBoxId,activedescendant:"option-"+s.guid+"-"+this.focusedIndex(),role:"combobox",ariaLabelledBy:this.props.ariaLabelledBy,ariaDescribedBy:this.props.ariaDescribedBy,ariaRequired:this.required,render:this.props.valueRender,inputAttributes:n})}renderListContainer(){const e=this.base,{dir:t,groupField:s}=this.props,o=f.getFilteredData(this.props),i=e.getPopupSettings(),a=this.props.opened!==void 0?this.props.opened:this.state.opened,d=i.width!==void 0?i.width:e.popupWidth;let{group:n}=this.state;return n===void 0&&s!==void 0&&(n=f.getItemValue(o[0],s)),m.createElement(T,{width:d,popupSettings:{...i,anchor:i.anchor||this.element,show:a,popupClass:l.classNames(i.popupClass,"k-list-container","k-autocomplete-popup")},dir:t!==void 0?t:this.base.dirCalculated,itemsCount:[o.length]},this.listContainerContent())}renderList(){const e=this.base,t=e.getPopupSettings(),{textField:s,listNoDataRender:o,itemRender:i,groupHeaderItemRender:a}=this.props,d=f.getFilteredData(this.props),n=this.value,r=this.props.opened!==void 0?this.props.opened:this.state.opened;return m.createElement(q,{id:e.listBoxId,show:r,data:d.slice(),focusedIndex:this.focusedIndex(),value:n,textField:s,valueField:s,highlightSelected:!1,optionsGuid:e.guid,groupField:this.props.groupField,listRef:p=>{e.list=p},wrapperStyle:this.mobileMode?{}:{maxHeight:t.height},wrapperCssClass:"k-list-content",onClick:this.handleItemClick,itemRender:i,groupHeaderItemRender:a,noDataRender:o,onMouseDown:p=>p.preventDefault(),onScroll:this.onScroll})}triggerOnChange(e,t,s){this.value===e&&!s||(t.data.value=e,this._valueDuringOnChange=e,t.events.push({type:"onChange",...s||{}}))}focusElement(e){this._skipFocusEvent=!0,e.focus(),window.setTimeout(()=>this._skipFocusEvent=!1,0)}applyState(e){this.base.applyState(e),this._valueDuringOnChange=void 0}suggestValue(e){if(this._suggested="",e){const{textField:t}=this.props,s=f.getFilteredData(this.props),o=s[f.itemIndexStartsWith(s,e,t)];if(o){const i=f.getItemValue(o,t);e.toLowerCase()!==i.toLowerCase()&&(this._suggested=i.substring(e.length))}}}focusedIndex(e){const{textField:t,focusedItemIndex:s,skipDisabledItems:o}=this.props,i=f.getFilteredData(this.props),a=e!==void 0?e:this.value;if(this.state.focusedItem!==void 0)return i.findIndex(n=>f.areSame(n,this.state.focusedItem,t));if(s)return s(i,a,t);const d=i.indexOf(f.getFocusedItem(i,a,t));return o&&t&&d===-1?i.findIndex(n=>!n.disabled&&n[t]):Math.max(0,d)}calculateMedia(e){for(const t of e)this.setState({windowWidth:t.target.clientWidth})}};y.displayName="AutoComplete",y.propTypes={...w.basicPropTypes,size:g.oneOf(["small","medium","large"]),rounded:g.oneOf(["small","medium","large","full"]),fillMode:g.oneOf(["solid","flat","outline"]),groupField:g.string,suggest:g.oneOfType([g.bool,g.string]),placeholder:g.string,value:g.string,defaultValue:g.string,validationMessage:g.string,required:g.bool,readonly:g.bool,clearButton:g.bool,valueRender:g.func,id:g.string,ariaLabelledBy:g.string,ariaDescribedBy:g.string,list:g.any,adaptive:g.bool,adaptiveTitle:g.string,adaptiveSubtitle:g.string,onCancel:g.func,skipDisabledItems:g.bool,inputAttributes:g.object},y.defaultProps={...w.defaultProps,size:void 0,rounded:void 0,fillMode:void 0,skipDisabledItems:!0,prefix:void 0,suffix:void 0};let x=y;const _=l.createPropsContext(),M=l.withIdHOC(l.withPropsContext(_,l.withAdaptiveModeContext(x)));M.displayName="KendoReactAutoComplete";exports.AutoComplete=M;exports.AutoCompletePropsContext=_;exports.AutoCompleteWithoutContext=x;
|