@progress/kendo-react-dropdowns 9.5.0 → 10.0.0-develop.1
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.js +1 -1
- package/AutoComplete/AutoComplete.mjs +251 -252
- package/ComboBox/ComboBox.js +1 -1
- package/ComboBox/ComboBox.mjs +53 -52
- package/DropDownList/DropDownList.js +1 -1
- package/DropDownList/DropDownList.mjs +217 -210
- package/DropDownTree/DropDownTree.js +1 -1
- package/DropDownTree/DropDownTree.mjs +91 -91
- package/MultiSelect/MultiSelect.js +1 -1
- package/MultiSelect/MultiSelect.mjs +114 -105
- package/MultiSelectTree/MultiSelectTree.js +1 -1
- package/MultiSelectTree/MultiSelectTree.mjs +222 -223
- package/dist/cdn/js/kendo-react-dropdowns.js +1 -1
- package/index.d.mts +8 -3
- package/index.d.ts +8 -3
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +10 -10
|
@@ -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 q=require("react"),u=require("prop-types"),B=require("../common/SearchBar.js"),V=require("../common/ListContainer.js"),T=require("../common/List.js"),w=require("../common/DropDownBase.js"),N=require("../common/GroupStickyHeader.js"),c=require("../common/utils.js"),l=require("@progress/kendo-react-common"),R=require("@progress/kendo-react-labels"),L=require("../package-metadata.js"),z=require("../common/ClearButton.js"),A=require("../common/AdaptiveMode.js"),D=require("../common/withCustomComponent.js"),H=require("@progress/kendo-react-layout"),W=require("../common/ListFilter.js");function j(C){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(C){for(const e in C)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(C,e);Object.defineProperty(a,e,t.get?t:{enumerable:!0,get:()=>C[e]})}}return a.default=C,Object.freeze(a)}const g=j(q),G="Please enter a valid value!",{sizeMap:_,roundedMap:U}=l.kendoThemeMaps,I=class I extends g.Component{constructor(a){super(a),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=c.getFilteredData(this.props),i=c.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(i,t)},this.itemFocus=(e,t)=>{const{textField:s}=this.props,o=c.getFilteredData(this.props)[e];c.areSame(this.state.focusedItem,o,s)||(t.data.focusedItem=o)},this.togglePopup=e=>{this.base.togglePopup(e)},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||G)},this.renderAdaptiveListContainer=()=>{const{adaptiveTitle:e}=this.props,{windowWidth:t=0}=this.state,s=g.createElement(W,{value:this.value,ref:o=>this._adaptiveInput=o&&o.element,onChange:this.onChangeHandler,onKeyDown:this.onInputKeyDown,size:this.props.size,rounded:this.props.rounded,fillMode:this.props.fillMode}),i={title:e,expand:this.opened,onClose:o=>this.onCancel(o),windowWidth:t,mobileFilter:s};return g.createElement(A.AdaptiveMode,{...i},g.createElement(H.ActionSheetContent,{overflowHidden:!0},g.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;c.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:i,groupField:o,list:d}=this.props,r=c.getFilteredData(this.props);let{group:n}=this.state;return n===void 0&&o!==void 0&&(n=c.getItemValue(r[0],o)),g.createElement(g.Fragment,null,e&&g.createElement("div",{className:"k-list-header"},e),g.createElement("div",{className:l.classNames("k-list",{[`k-list-${this.mobileMode?"lg":_[s]||s}`]:s})},!d&&n&&r.length!==0&&g.createElement(N,{group:n,groupMode:"modern",render:i}),this.renderList()),t&&g.createElement("div",{className:"k-list-footer"},t))},this.onScroll=e=>{this._isScrolling=!0;const{list:t}=this.base,{groupField:s}=this.props;let i=c.getFilteredData(this.props);if(!s||!i.length)return;const o=this.itemHeight||(t?t.children[0].offsetHeight:0),r=e.target.scrollTop;s&&(i=this.base.getGroupedDataModernMode(i,s));let n=i[0][s];for(let p=1;p<i.length&&!(o*p>r);p++)i[p]&&i[p][s]&&(n=i[p][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(),i=this.mobileMode?e.target.element:e.currentTarget,o=i.value,d=i.selectionEnd===o.length;s.syntheticEvent=e;const r=this._suggested,n=this.value,p=n&&n.substring(0,n.length-r.length),v=p&&p===o,m=p&&p.length>o.length,{suggest:y}=this.props,h=this.props.opened!==void 0?this.props.opened:this.state.opened;if(y!==void 0&&y!==!1){v||m||!d?this._suggested="":this.suggestValue(o);const f=o+this._suggested,b={userInput:o,value:this._suggested};this.triggerOnChange(f,s,{suggestion:b})}else this._suggested="",this.triggerOnChange(o,s);(!h&&o||h&&!o)&&this.togglePopup(s),s.data.focusedItem=void 0,this.applyState(s),this.setState({group:void 0})},this.clearButtonClick=e=>{const s=this.base.initState(),i=this.props.opened!==void 0?this.props.opened:this.state.opened;s.syntheticEvent=e;const o="";this._suggested="",this.triggerOnChange(o,s),this.state.focusedItem!==void 0&&(s.data.focusedItem=void 0),i&&this.togglePopup(s),this.applyState(s)},this.onInputKeyDown=e=>{const{skipDisabledItems:t,groupField:s,textField:i}=this.props,o=c.getFilteredData(this.props);this._isScrolling&&(this._isScrolling=!1);const d=this.focusedIndex(),r=o[d],n=e.keyCode,p=e.altKey,v=this.props.opened!==void 0?this.props.opened:this.state.opened,m=this.base.initState();m.syntheticEvent=e;const y=()=>{v&&e.preventDefault()};if(p&&n===l.Keys.down)this.setState({opened:!0});else if(p&&n===l.Keys.up)this.setState({opened:!1});else if(v&&n===l.Keys.pageUp)y(),this.base.scrollPopupByPageSize(-1);else if(v&&n===l.Keys.pageDown)y(),this.base.scrollPopupByPageSize(1);else if(v&&(n===l.Keys.enter||n===l.Keys.esc))y(),t===!1&&r&&r.disabled?(v&&this.togglePopup(m),this.applyState(m)):this.applyInputValue(e.currentTarget.value,m,e.keyCode);else if(!v&&n===l.Keys.esc){const h="";this._suggested="",this.triggerOnChange(h,m),this.state.focusedItem!==void 0&&(m.data.focusedItem=void 0),this.applyState(m)}else if(n===l.Keys.up||n===l.Keys.down){if(s!==""&&i)if(!this.props.skipDisabledItems&&v)this.onNavigate(m,n);else{let h=0;if(n===l.Keys.down||n===l.Keys.right){const f=o.slice(d+1).find(b=>!b.disabled&&b[i]);h=f&&o.findIndex(b=>b[i]===f[i])}else if(n===l.Keys.up||n===l.Keys.left){let f;if(d===-1)f=o,h=o.findIndex(b=>!b.disabled&&b[i]);else{f=o.slice(0,d);let b=f.pop();for(;b&&b.disabled;)b=f.pop();h=b&&o.findIndex(S=>S[i]===b[i])}}if(h!==void 0){const f=h-d;this.onNavigate(m,n,f)}else h===void 0&&o.findIndex(f=>f[i])===o.length-1&&this.onNavigate(m,n)}else if(!this.props.skipDisabledItems&&v)this.onNavigate(m,n);else{let h=null;if(n===l.Keys.down||n===l.Keys.right)h=o.slice(d+1).find(f=>!f.disabled);else if(n===l.Keys.up||n===l.Keys.left){const f=o.slice(0,d);for(h=f.pop();h&&h.disabled;)h=f.pop()}if(h){const f=h.id-d-1;this.onNavigate(m,n,f)}else this.onNavigate(m,n)}this.applyState(m),y()}},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)},l.validatePackage(L.packageMetadata)}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 a=this.props.validationMessage!==void 0,e=!this.required||this.value!=="",t=this.props.valid!==void 0?this.props.valid:e;return{customError:a,valid:t,valueMissing:this.value===null}}get opened(){return!!(this.props.opened!==void 0?this.props.opened:this.state.opened)}get mobileMode(){var e;return!!(this.state.windowWidth&&this.props._adaptiveMode&&this.state.windowWidth<=((e=this.props._adaptiveMode)==null?void 0:e.medium)&&this.props.adaptive)}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:I.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:I.defaultProps.required}componentDidUpdate(a,e){var y;const{groupField:t=""}=this.props,s=c.getFilteredData(this.props),{data:i=[]}=a,o=this.focusedIndex(),d=s[o],r=i!==s,n=d!==void 0&&e.focusedItem!==d,p=this.props.opened!==void 0?this.props.opened:this.state.opened,v=a.opened!==void 0?a.opened:e.opened,m=!v&&p;if(t==="")(p&&(n||r)||m)&&this.base.scrollToItem(o);else if(!this._isScrolling){const h=(y=this.base.getGroupedDataModernMode(s,t))==null?void 0:y.indexOf(d);m&&(s&&s.length!==0&&this.base.resetGroupStickyHeader(s[0][t],this),this.base.scrollToItem(h)),p&&v&&n&&this.base.scrollToItem(h)}this.setValidity()}componentDidMount(){var a;this.observerResize=l.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(a=this.document)!=null&&a.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentWillUnmount(){this.observerResize&&this.observerResize.disconnect()}render(){const{dir:a,disabled:e,label:t,className:s,style:i,loading:o,suggest:d,size:r,rounded:n,fillMode:p}=this.props,v=!this.validityStyles||this.validity.valid,m=this.base,y=this.value,h=this.props.clearButton!==!1&&!o&&!!y,f=this.props.id||this._inputId,b=this.state.focused;typeof d=="string"&&(this._suggested=d);const[S,O]=D(this.props.prefix||g.Fragment),[P,K]=D(this.props.suffix||g.Fragment),k=g.createElement(g.Fragment,null,g.createElement("span",{className:l.classNames("k-autocomplete k-input",s,{[`k-input-${_[r]||r}`]:r,[`k-rounded-${U[n]||n}`]:n,[`k-input-${p}`]:p,"k-invalid":!v,"k-focus":b&&!e,"k-loading":o,"k-required":this.required,"k-disabled":e}),ref:F=>{this._element=F,m.wrapper=F},style:t?{...i,width:void 0}:i,dir:a,onFocus:this.handleFocus,onBlur:this.handleBlur,onClick:this.handleWrapperClick},this.props.prefix&&g.createElement(S,{...O}),this.renderSearchBar(y||"",f),o&&g.createElement(l.IconWrap,{className:"k-input-loading-icon",name:"loading"}),h&&!o&&g.createElement(z,{onClick:this.clearButtonClick,key:"clearbutton"}),this.props.suffix&&g.createElement(P,{...K}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return t?g.createElement(R.FloatingLabel,{label:t,editorId:f,editorValue:y,editorValid:v,editorDisabled:e,style:{width:i?i.width:void 0},children:k}):k}onNavigate(a,e,t){const s=this.value,{textField:i,focusedItemIndex:o}=this.props,d=c.getFilteredData(this.props),r=this.state.focusedItem!==void 0?d.findIndex(p=>c.areSame(p,this.state.focusedItem,i)):o?o(d,s,i):d.indexOf(c.getFocusedItem(d,s,i)),n=this.base.navigation.navigate({keyCode:e,current:r,max:d.length-1,min:0,skipItems:t||void 0});n!==void 0&&this.itemFocus(n,a),this.applyState(a)}applyInputValue(a,e,t){const s=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:i}=this.props,o=c.getFilteredData(this.props),d=this.focusedIndex(),r=o[d];if(this._suggested="",s&&t===l.Keys.enter&&r&&!r.disabled){const n=c.getItemValue(o[this.focusedIndex(a)],i);this.triggerOnChange(n,e)}s&&this.togglePopup(e),this.applyState(e)}renderSearchBar(a,e){const t=this.base,{placeholder:s,tabIndex:i,disabled:o,readonly:d,inputAttributes:r}=this.props,{focused:n}=this.state,p=this.props.opened!==void 0?this.props.opened:this.state.opened;return g.createElement(B,{id:e,placeholder:s,tabIndex:i,accessKey:this.props.accessKey,value:a,suggestedText:this._suggested,focused:n,name:this.props.name,ref:v=>this._input=v&&v.input,onKeyDown:this.onInputKeyDown,onChange:this.onChangeHandler,onFocus:t.handleFocus,onBlur:this.handleBlur,disabled:o,readOnly:d,expanded:p,owns:t.listBoxId,activedescendant:"option-"+t.guid+"-"+this.focusedIndex(),role:"combobox",ariaLabelledBy:this.props.ariaLabelledBy,ariaDescribedBy:this.props.ariaDescribedBy,ariaRequired:this.required,render:this.props.valueRender,inputAttributes:r})}renderListContainer(){const a=this.base,{dir:e,groupField:t}=this.props,s=c.getFilteredData(this.props),i=a.getPopupSettings(),o=this.props.opened!==void 0?this.props.opened:this.state.opened,d=i.width!==void 0?i.width:a.popupWidth;let{group:r}=this.state;return r===void 0&&t!==void 0&&(r=c.getItemValue(s[0],t)),g.createElement(V,{width:d,popupSettings:{...i,anchor:i.anchor||this.element,show:o,popupClass:l.classNames(i.popupClass,"k-list-container","k-autocomplete-popup")},dir:e!==void 0?e:this.base.dirCalculated,itemsCount:[s.length]},this.listContainerContent())}renderList(){const a=this.base,e=a.getPopupSettings(),{textField:t,listNoDataRender:s,itemRender:i,groupHeaderItemRender:o}=this.props,d=c.getFilteredData(this.props),r=this.value,n=this.props.opened!==void 0?this.props.opened:this.state.opened;return g.createElement(T,{id:a.listBoxId,show:n,data:d.slice(),focusedIndex:this.focusedIndex(),value:r,textField:t,valueField:t,highlightSelected:!1,optionsGuid:a.guid,groupField:this.props.groupField,groupMode:"modern",listRef:p=>a.list=p,wrapperStyle:this.mobileMode?{}:{maxHeight:e.height},wrapperCssClass:"k-list-content",onClick:this.handleItemClick,itemRender:i,groupHeaderItemRender:o,noDataRender:s,onMouseDown:p=>p.preventDefault(),onScroll:this.onScroll})}triggerOnChange(a,e,t){this.value===a&&!t||(e.data.value=a,this._valueDuringOnChange=a,e.events.push({type:"onChange",...t||{}}))}focusElement(a){this._skipFocusEvent=!0,a.focus(),window.setTimeout(()=>this._skipFocusEvent=!1,0)}applyState(a){this.base.applyState(a),this._valueDuringOnChange=void 0}suggestValue(a){if(this._suggested="",a){const{textField:e}=this.props,t=c.getFilteredData(this.props),s=t[c.itemIndexStartsWith(t,a,e)];if(s){const i=c.getItemValue(s,e);a.toLowerCase()!==i.toLowerCase()&&(this._suggested=i.substring(a.length))}}}focusedIndex(a){const{textField:e,focusedItemIndex:t,skipDisabledItems:s}=this.props,i=c.getFilteredData(this.props),o=a!==void 0?a:this.value;if(this.state.focusedItem!==void 0)return i.findIndex(r=>c.areSame(r,this.state.focusedItem,e));if(t)return t(i,o,e);const d=i.indexOf(c.getFocusedItem(i,o,e));return s&&e&&d===-1?i.findIndex(r=>!r.disabled&&r[e]):Math.max(0,d)}calculateMedia(a){for(const e of a)this.setState({windowWidth:e.target.clientWidth})}};I.displayName="AutoComplete",I.propTypes={...w.basicPropTypes,size:u.oneOf([null,"small","medium","large"]),rounded:u.oneOf([null,"small","medium","large","full"]),fillMode:u.oneOf([null,"solid","flat","outline"]),groupField:u.string,suggest:u.oneOfType([u.bool,u.string]),placeholder:u.string,value:u.string,defaultValue:u.string,validationMessage:u.string,required:u.bool,readonly:u.bool,clearButton:u.bool,valueRender:u.func,id:u.string,ariaLabelledBy:u.string,ariaDescribedBy:u.string,list:u.any,adaptive:u.bool,adaptiveTitle:u.string,onCancel:u.func,skipDisabledItems:u.bool,inputAttributes:u.object},I.defaultProps={...w.defaultProps,size:"medium",rounded:"medium",fillMode:"solid",skipDisabledItems:!0,prefix:void 0,suffix:void 0};let x=I;const M=l.createPropsContext(),E=l.withIdHOC(l.withPropsContext(M,l.withAdaptiveModeContext(x)));E.displayName="KendoReactAutoComplete";exports.AutoComplete=E;exports.AutoCompletePropsContext=M;exports.AutoCompleteWithoutContext=x;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react"),g=require("prop-types"),V=require("../common/SearchBar.js"),q=require("../common/ListContainer.js"),T=require("../common/List.js"),S=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 S(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),n=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(n,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{adaptiveTitle:e}=this.props,{windowWidth:t=0}=this.state,s=m.createElement(H,{value:this.value,ref:i=>this._adaptiveInput=i&&i.element,onChange:this.onChangeHandler,onKeyDown:this.onInputKeyDown,size:this.props.size,rounded:this.props.rounded,fillMode:this.props.fillMode}),n={title:e,expand:this.opened,onClose:i=>this.onCancel(i),windowWidth:t,mobileFilter:s};return m.createElement(z.AdaptiveMode,{...n},m.createElement(A.ActionSheetContent,{overflowHidden:!0},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:n,groupField:i,list:a}=this.props,d=f.getFilteredData(this.props);let{group:o}=this.state;return o===void 0&&i!==void 0&&(o=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&&o&&d.length!==0&&m.createElement(N,{group:o,groupMode:"modern",render:n}),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 n=f.getFilteredData(this.props);if(!s||!n.length)return;const i=this.itemHeight||(t?t.children[0].offsetHeight:0),d=e.target.scrollTop;s&&(n=this.base.getGroupedDataModernMode(n,s));let o=n[0][s];for(let r=1;r<n.length&&!(i*r>d);r++)n[r]&&n[r][s]&&(o=n[r][s]);o!==this.state.group&&this.setState({group:o})},this.handleItemClick=(e,t)=>{this.base.handleItemClick(e,t),this._valueDuringOnChange=void 0},this.onChangeHandler=e=>{const s=this.base.initState(),n=this.mobileMode?e.target.element:e.currentTarget,i=n.value,a=n.selectionEnd===i.length;s.syntheticEvent=e;const d=this._suggested,o=this.value,r=o&&o.substring(0,o.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(),n=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),n&&this.togglePopup(s),this.applyState(s)},this.onInputKeyDown=e=>{const{skipDisabledItems:t,groupField:s,textField:n}=this.props,i=f.getFilteredData(this.props);this._isScrolling&&(this._isScrolling=!1);const a=this.focusedIndex(),d=i[a],o=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&&o===l.Keys.down)this.setState({opened:!0});else if(r&&o===l.Keys.up)this.setState({opened:!1});else if(h&&o===l.Keys.pageUp)b(),this.base.scrollPopupByPageSize(-1);else if(h&&o===l.Keys.pageDown)b(),this.base.scrollPopupByPageSize(1);else if(h&&(o===l.Keys.enter||o===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&&o===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(o===l.Keys.up||o===l.Keys.down){if(s!==""&&n)if(!this.props.skipDisabledItems&&h)this.onNavigate(u,o);else{let p=0;if(o===l.Keys.down||o===l.Keys.right){const c=i.slice(a+1).find(v=>!v.disabled&&v[n]);p=c&&i.findIndex(v=>v[n]===c[n])}else if(o===l.Keys.up||o===l.Keys.left){let c;if(a===-1)c=i,p=i.findIndex(v=>!v.disabled&&v[n]);else{c=i.slice(0,a);let v=c.pop();for(;v&&v.disabled;)v=c.pop();p=v&&i.findIndex(x=>x[n]===v[n])}}if(p!==void 0){const c=p-a;this.onNavigate(u,o,c)}else p===void 0&&i.findIndex(c=>c[n])===i.length-1&&this.onNavigate(u,o)}else if(!this.props.skipDisabledItems&&h)this.onNavigate(u,o);else{let p=null;if(o===l.Keys.down||o===l.Keys.right)p=i.slice(a+1).find(c=>!c.disabled);else if(o===l.Keys.up||o===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,o,c)}else this.onNavigate(u,o)}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,n=f.getFilteredData(this.props),{data:i=[]}=e,a=this.focusedIndex(),d=n[a],o=i!==n,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||o)||b)&&this.base.scrollToItem(a);else if(!this._isScrolling){const c=(p=this.base.getGroupedDataModernMode(n,s))==null?void 0:p.indexOf(d);b&&(n&&n.length!==0&&this.base.resetGroupStickyHeader(n[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:n,style:i,loading:a,suggest:d,size:o,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,x=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),w=m.createElement(m.Fragment,null,m.createElement("span",{className:l.classNames("k-autocomplete k-input",n,{[`k-input-${D[o]||o}`]:o,[`k-rounded-${G[r]||r}`]:r,[`k-input-${h}`]:h,"k-invalid":!u,"k-focus":x&&!t,"k-loading":a,"k-required":this.required,"k-disabled":t}),ref:k=>{this._element=k,b.wrapper=k},style:s?{...i,width:void 0}:i,dir:e,onFocus: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:w}):w}onNavigate(e,t,s){const n=this.value,{textField:i,focusedItemIndex:a}=this.props,d=f.getFilteredData(this.props),o=this.state.focusedItem!==void 0?d.findIndex(h=>f.areSame(h,this.state.focusedItem,i)):a?a(d,n,i):d.indexOf(f.getFocusedItem(d,n,i)),r=this.base.navigation.navigate({keyCode:t,current:o,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 n=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:i}=this.props,a=f.getFilteredData(this.props),d=this.focusedIndex(),o=a[d];if(this._suggested="",n&&s===l.Keys.enter&&o&&!o.disabled){const r=f.getItemValue(a[this.focusedIndex(e)],i);this.triggerOnChange(r,t)}n&&this.togglePopup(t),this.applyState(t)}renderSearchBar(e,t){const s=this.base,{placeholder:n,tabIndex:i,disabled:a,readonly:d,inputAttributes:o}=this.props,{focused:r}=this.state,h=this.props.opened!==void 0?this.props.opened:this.state.opened;return m.createElement(V,{id:t,placeholder:n,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:o})}renderListContainer(){const e=this.base,{dir:t,groupField:s}=this.props,n=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:o}=this.state;return o===void 0&&s!==void 0&&(o=f.getItemValue(n[0],s)),m.createElement(q,{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:[n.length]},this.listContainerContent())}renderList(){const e=this.base,t=e.getPopupSettings(),{textField:s,listNoDataRender:n,itemRender:i,groupHeaderItemRender:a}=this.props,d=f.getFilteredData(this.props),o=this.value,r=this.props.opened!==void 0?this.props.opened:this.state.opened;return m.createElement(T,{id:e.listBoxId,show:r,data:d.slice(),focusedIndex:this.focusedIndex(),value:o,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:n,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),n=s[f.itemIndexStartsWith(s,e,t)];if(n){const i=f.getItemValue(n,t);e.toLowerCase()!==i.toLowerCase()&&(this._suggested=i.substring(e.length))}}}focusedIndex(e){const{textField:t,focusedItemIndex:s,skipDisabledItems:n}=this.props,i=f.getFilteredData(this.props),a=e!==void 0?e:this.value;if(this.state.focusedItem!==void 0)return i.findIndex(o=>f.areSame(o,this.state.focusedItem,t));if(s)return s(i,a,t);const d=i.indexOf(f.getFocusedItem(i,a,t));return n&&t&&d===-1?i.findIndex(o=>!o.disabled&&o[t]):Math.max(0,d)}calculateMedia(e){for(const t of e)this.setState({windowWidth:t.target.clientWidth})}};y.displayName="AutoComplete",y.propTypes={...S.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,onCancel:g.func,skipDisabledItems:g.bool,inputAttributes:g.object},y.defaultProps={...S.defaultProps,size:"medium",rounded:"medium",fillMode:"solid",skipDisabledItems:!0,prefix:void 0,suffix:void 0};let C=y;const _=l.createPropsContext(),M=l.withIdHOC(l.withPropsContext(_,l.withAdaptiveModeContext(C)));M.displayName="KendoReactAutoComplete";exports.AutoComplete=M;exports.AutoCompletePropsContext=_;exports.AutoCompleteWithoutContext=C;
|