@progress/kendo-react-dropdowns 15.0.1-develop.4 → 15.0.1-develop.6
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 +4 -4
- package/ComboBox/ComboBox.js +1 -1
- package/ComboBox/ComboBox.mjs +16 -14
- package/DropDownList/DropDownList.js +1 -1
- package/DropDownList/DropDownList.mjs +343 -337
- package/MultiColumnComboBox/MultiColumnComboBox.js +1 -1
- package/MultiColumnComboBox/MultiColumnComboBox.mjs +129 -133
- package/MultiSelectTree/utils.js +1 -1
- package/MultiSelectTree/utils.mjs +17 -17
- package/common/DropDownBase.js +1 -1
- package/common/DropDownBase.mjs +118 -112
- package/dist/cdn/js/kendo-react-dropdowns.js +1 -1
- 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 T=require("react"),h=require("prop-types"),q=require("../common/SearchBar.js"),B=require("../common/ListContainer.js"),N=require("../common/List.js"),x=require("../common/DropDownBase.js"),R=require("../common/GroupStickyHeader.js"),g=require("../common/utils.js"),l=require("@progress/kendo-react-common"),z=require("@progress/kendo-react-labels"),_=require("@progress/kendo-react-intl"),w=require("../messages/index.js"),A=require("../common/ClearButton.js"),H=require("../common/AdaptiveMode.js"),F=require("../common/withCustomComponent.js"),W=require("@progress/kendo-react-layout"),j=require("../common/ListFilter.js");function G(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 f=G(T),U="Please enter a valid value!",{sizeMap:D,roundedMap:$}=l.kendoThemeMaps,y=class y extends f.Component{constructor(){super(...arguments),this.state={},this.base=new x(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.handleKendoPasteValue=e=>{const t=e!=null?String(e):"",s=this.base.initState();s.syntheticEvent={target:this._element,currentTarget:this._element,nativeEvent:new Event("change",{bubbles:!0})},this.triggerOnChange(t,s),this.applyState(s)},this.handleItemSelect=(e,t)=>{const s=g.getFilteredData(this.props),n=g.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=g.getFilteredData(this.props)[e];g.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||U)},this.renderAdaptiveListContainer=()=>{const{windowWidth:e=0}=this.state,t=f.createElement(j,{value:this.value,ref:n=>{this._adaptiveInput=n&&n.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:n=>this.onCancel(n),windowWidth:e,mobileFilter:t};return f.createElement(H.AdaptiveMode,{...s},f.createElement(W.ActionSheetContent,null,f.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;g.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=g.getFilteredData(this.props);let{group:o}=this.state;return o===void 0&&i!==void 0&&(o=g.getItemValue(d[0],i)),f.createElement(f.Fragment,null,e&&f.createElement("div",{className:"k-list-header"},e),f.createElement("div",{className:l.classNames("k-list",{[`k-list-${this.mobileMode?"lg":D[s]||s}`]:this.mobileMode||s})},!a&&o&&d.length!==0&&f.createElement(R,{group:o,render:n}),this.renderList()),t&&f.createElement("div",{className:"k-list-footer"},t))},this.onScroll=e=>{this._isScrolling=!0;const{list:t}=this.base,{groupField:s}=this.props;let n=g.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),c=r&&r===i,p=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){c||p||!a?this._suggested="":this.suggestValue(i);const m=i+this._suggested,v={userInput:i,value:this._suggested};this.triggerOnChange(m,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(),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=g.getFilteredData(this.props);this._isScrolling&&(this._isScrolling=!1);const a=this.focusedIndex(),d=i[a],o=e.keyCode,r=e.altKey,c=this.props.opened!==void 0?this.props.opened:this.state.opened,p=this.base.initState();p.syntheticEvent=e;const b=()=>{c&&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(c&&o===l.Keys.pageUp)b(),this.base.scrollPopupByPageSize(-1);else if(c&&o===l.Keys.pageDown)b(),this.base.scrollPopupByPageSize(1);else if(c&&(o===l.Keys.enter||o===l.Keys.esc))b(),t===!1&&d&&d.disabled?(c&&this.togglePopup(p),this.applyState(p)):this.applyInputValue(e.currentTarget.value,p,e.keyCode);else if(!c&&o===l.Keys.esc)this._suggested="",this.triggerOnChange("",p),this.state.focusedItem!==void 0&&(p.data.focusedItem=void 0),this.applyState(p);else if(o===l.Keys.up||o===l.Keys.down){if(s!==""&&n)if(!this.props.skipDisabledItems&&c)this.onNavigate(p,o);else{let u=0;if(o===l.Keys.down||o===l.Keys.right){const m=i.slice(a+1).find(v=>!v.disabled);u=m&&i.indexOf(m)}else if(o===l.Keys.up||o===l.Keys.left){let m;if(a===-1)m=i,u=i.findIndex(v=>!v.disabled);else{m=i.slice(0,a);let v=m.pop();for(;v&&v.disabled;)v=m.pop();u=v&&i.indexOf(v)}}if(u!==void 0){const m=u-a;this.onNavigate(p,o,m)}else u===void 0&&a===i.length-1&&this.onNavigate(p,o)}else if(!this.props.skipDisabledItems&&c)this.onNavigate(p,o);else{let u=null;if(o===l.Keys.down||o===l.Keys.right)u=i.slice(a+1).find(m=>!m.disabled);else if(o===l.Keys.up||o===l.Keys.left){const m=i.slice(0,a);for(u=m.pop();u&&u.disabled;)u=m.pop()}if(u){const m=u.id-a-1;this.onNavigate(p,o,m)}else this.onNavigate(p,o)}this.applyState(p),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,n=g.getFilteredData(this.props),{data:i=[]}=e,a=this.focusedIndex(),d=n[a],o=i!==n,r=d!==void 0&&t.focusedItem!==d,c=this.props.opened!==void 0?this.props.opened:this.state.opened,p=e.opened!==void 0?e.opened:t.opened,b=!p&&c;if(s==="")(c&&(r||o)||b)&&this.base.scrollToItem(a);else if(!this._isScrolling){const m=(u=this.base.getGroupedDataModernMode(n,s))==null?void 0:u.indexOf(d);b&&(n&&n.length!==0&&this.base.resetGroupStickyHeader(n[0][s],this),this.base.scrollToItem(m)),c&&p&&r&&this.base.scrollToItem(m)}this.setValidity()}componentDidMount(){var t;this.observerResize=l.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(t=this.document)!=null&&t.body&&this.observerResize&&this.observerResize.observe(this.document.body);const e=this.props.name||this.props.id;this.KendoPasteSubscription=l.subscribeToKendoPaste(this._element,{fieldName:e,onValueChange:s=>{this.handleKendoPasteValue(s)}})}componentWillUnmount(){var e;this.observerResize&&this.observerResize.disconnect(),(e=this.KendoPasteSubscription)==null||e.unsubscribe()}render(){const{dir:e,disabled:t,label:s,className:n,style:i,loading:a,suggest:d,size:o,rounded:r,fillMode:c}=this.props,p=!this.validityStyles||this.validity.valid,b=this.base,u=this.value,m=this.props.clearButton!==!1&&!a&&!!u,v=this.props.id||this._inputId,O=this.state.focused;typeof d=="string"&&(this._suggested=d);const[P,K]=F(this.props.prefix||f.Fragment),[V,L]=F(this.props.suffix||f.Fragment),k=f.createElement(f.Fragment,null,f.createElement("span",{className:l.classNames("k-autocomplete k-input",n,{[`k-input-${D[o]||o}`]:o,[`k-rounded-${$[r]||r}`]:r,[`k-input-${c}`]:c,"k-invalid":!p,"k-focus":O&&!t,"k-loading":a,"k-required":this.required,"k-disabled":t}),ref:S=>{this._element=S,b.wrapper=S},style:s?{...i,width:void 0}:i,dir:e,onFocus:this.mobileMode?S=>this.handleWrapperClick(S):this.handleFocus,onBlur:this.handleBlur,onClick:this.handleWrapperClick},this.props.prefix&&f.createElement(P,{...K}),this.renderSearchBar(u||"",v),a&&f.createElement(l.IconWrap,{className:"k-input-loading-icon",name:"loading"}),m&&!a&&f.createElement(A,{onClick:this.clearButtonClick,key:"clearbutton"}),this.props.suffix&&f.createElement(V,{...L}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return s?f.createElement(z.FloatingLabel,{label:s,editorId:v,editorValue:u,editorValid:p,editorDisabled:t,style:{width:i?i.width:void 0},children:k}):k}onNavigate(e,t,s){const n=this.value,{textField:i,focusedItemIndex:a}=this.props,d=g.getFilteredData(this.props),o=this.state.focusedItem!==void 0?d.findIndex(c=>g.areSame(c,this.state.focusedItem,i)):a?a(d,n,i):d.indexOf(g.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=g.getFilteredData(this.props),d=this.focusedIndex(),o=a[d];if(this._suggested="",n&&s===l.Keys.enter&&o&&!o.disabled){const r=g.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,c=this.props.opened!==void 0?this.props.opened:this.state.opened;return f.createElement(q,{id:t,placeholder:n,tabIndex:i,accessKey:this.props.accessKey,value:e,suggestedText:this._suggested,focused:r,name:this.props.name,ref:p=>{this._input=p&&p.input},onKeyDown:this.onInputKeyDown,onChange:this.onChangeHandler,onFocus:s.handleFocus,onBlur:this.handleBlur,disabled:a,readOnly:d,expanded:c,ariaControls:c?s.listBoxId:void 0,activedescendant:`k-${s.guid}-item-${this.focusedIndex()+1}`,role:"combobox",ariaLabelledBy:this.props.ariaLabelledBy,ariaLabel:this.props.ariaLabel,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=g.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=g.getItemValue(n[0],s)),f.createElement(B,{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=_.provideLocalizationService(this),s=e.getPopupSettings(),{textField:n,listNoDataRender:i,itemRender:a,groupHeaderItemRender:d}=this.props,o=g.getFilteredData(this.props),r=this.value,c=this.props.opened!==void 0?this.props.opened:this.state.opened;return f.createElement(N,{id:e.listBoxId,show:c,data:o.slice(),focusedIndex:this.focusedIndex(),value:r,textField:n,valueField:n,highlightSelected:!0,optionsGuid:e.guid,groupField:this.props.groupField,ariaLabel:t.toLanguageString(w.autoCompleteListAriaLabel,w.messages[w.autoCompleteListAriaLabel]),listRef:p=>{e.list=p},wrapperStyle:this.mobileMode?{}:{maxHeight:s.height},wrapperCssClass:"k-list-content",onClick:this.handleItemClick,itemRender:a,groupHeaderItemRender:d,noDataRender:i,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=g.getFilteredData(this.props),n=s[g.itemIndexStartsWith(s,e,t)];if(n){const i=g.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=g.getFilteredData(this.props),a=e!==void 0?e:this.value;if(this.state.focusedItem!==void 0)return i.findIndex(o=>g.areSame(o,this.state.focusedItem,t));if(s)return s(i,a,t);const d=i.indexOf(g.getFocusedItem(i,a,t));return n&&t&&d===-1?i.findIndex(o=>!o.disabled):Math.max(0,d)}calculateMedia(e){for(const t of e)this.setState({windowWidth:t.target.clientWidth})}};y.displayName="AutoComplete",y.propTypes={...x.basicPropTypes,size:h.oneOf(["small","medium","large"]),rounded:h.oneOf(["small","medium","large","full","none"]),fillMode:h.oneOf(["solid","flat","outline"]),groupField:h.string,suggest:h.oneOfType([h.bool,h.string]),placeholder:h.string,value:h.string,defaultValue:h.string,validationMessage:h.string,required:h.bool,readonly:h.bool,clearButton:h.bool,valueRender:h.func,id:h.string,ariaLabelledBy:h.string,ariaLabel:h.string,ariaDescribedBy:h.string,list:h.any,adaptive:h.bool,adaptiveTitle:h.string,adaptiveSubtitle:h.string,onCancel:h.func,skipDisabledItems:h.bool,inputAttributes:h.object},y.defaultProps={...x.defaultProps,size:void 0,rounded:void 0,fillMode:void 0,skipDisabledItems:!0,prefix:void 0,suffix:void 0};let C=y;const M=l.createPropsContext();_.registerForLocalization(C);const E=l.withIdHOC(l.withPropsContext(M,l.withAdaptiveModeContext(C)));E.displayName="KendoReactAutoComplete";exports.AutoComplete=E;exports.AutoCompletePropsContext=M;exports.AutoCompleteWithoutContext=C;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react"),h=require("prop-types"),q=require("../common/SearchBar.js"),B=require("../common/ListContainer.js"),N=require("../common/List.js"),x=require("../common/DropDownBase.js"),R=require("../common/GroupStickyHeader.js"),g=require("../common/utils.js"),l=require("@progress/kendo-react-common"),z=require("@progress/kendo-react-labels"),_=require("@progress/kendo-react-intl"),w=require("../messages/index.js"),A=require("../common/ClearButton.js"),H=require("../common/AdaptiveMode.js"),F=require("../common/withCustomComponent.js"),W=require("@progress/kendo-react-layout"),U=require("../common/ListFilter.js");function j(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 f=j(T),G="Please enter a valid value!",{sizeMap:D,roundedMap:$}=l.kendoThemeMaps,y=class y extends f.Component{constructor(){super(...arguments),this.state={},this.base=new x(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.handleKendoPasteValue=e=>{const t=e!=null?String(e):"",s=this.base.initState();s.syntheticEvent={target:this._element,currentTarget:this._element,nativeEvent:new Event("change",{bubbles:!0})},this.triggerOnChange(t,s),this.applyState(s)},this.handleItemSelect=(e,t)=>{const s=g.getFilteredData(this.props),n=g.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=g.getFilteredData(this.props)[e];g.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||G)},this.renderAdaptiveListContainer=()=>{const{windowWidth:e=0}=this.state,t=f.createElement(U,{value:this.value,ref:n=>{this._adaptiveInput=n&&n.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:n=>this.onCancel(n),windowWidth:e,mobileFilter:t};return f.createElement(H.AdaptiveMode,{...s},f.createElement(W.ActionSheetContent,null,f.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;g.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=g.getFilteredData(this.props);let{group:o}=this.state;return o===void 0&&i!==void 0&&(o=g.getItemValue(d[0],i)),f.createElement(f.Fragment,null,e&&f.createElement("div",{className:"k-list-header"},e),f.createElement("div",{className:l.classNames("k-list",{[`k-list-${this.mobileMode?"lg":D[s]||s}`]:this.mobileMode||s})},!a&&o&&d.length!==0&&f.createElement(R,{group:o,render:n}),this.renderList()),t&&f.createElement("div",{className:"k-list-footer"},t))},this.onScroll=e=>{this._isScrolling=!0;const{list:t}=this.base,{groupField:s}=this.props;let n=g.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),c=r&&r===i,p=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){c||p||!a?this._suggested="":this.suggestValue(i);const m=i+this._suggested,v={userInput:i,value:this._suggested};this.triggerOnChange(m,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(),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=g.getFilteredData(this.props);this._isScrolling&&(this._isScrolling=!1);const a=this.focusedIndex(),d=i[a],o=e.keyCode,r=e.altKey,c=this.props.opened!==void 0?this.props.opened:this.state.opened,p=this.base.initState();p.syntheticEvent=e;const b=()=>{c&&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(c&&o===l.Keys.pageUp)b(),this.base.scrollPopupByPageSize(-1);else if(c&&o===l.Keys.pageDown)b(),this.base.scrollPopupByPageSize(1);else if(c&&(o===l.Keys.enter||o===l.Keys.esc))b(),t===!1&&d&&d.disabled?(c&&this.togglePopup(p),this.applyState(p)):this.applyInputValue(e.currentTarget.value,p,e.keyCode);else if(!c&&o===l.Keys.esc)this._suggested="",this.triggerOnChange("",p),this.state.focusedItem!==void 0&&(p.data.focusedItem=void 0),this.applyState(p);else if(o===l.Keys.up||o===l.Keys.down){if(s!==""&&n)if(!this.props.skipDisabledItems&&c)this.onNavigate(p,o);else{let u=0;if(o===l.Keys.down||o===l.Keys.right){const m=i.slice(a+1).find(v=>!v.disabled);u=m&&i.indexOf(m)}else if(o===l.Keys.up||o===l.Keys.left){let m;if(a===-1)m=i,u=i.findIndex(v=>!v.disabled);else{m=i.slice(0,a);let v=m.pop();for(;v&&v.disabled;)v=m.pop();u=v&&i.indexOf(v)}}if(u!==void 0){const m=u-a;this.onNavigate(p,o,m)}else u===void 0&&a===i.length-1&&this.onNavigate(p,o)}else if(!this.props.skipDisabledItems&&c)this.onNavigate(p,o);else{let u=null;if(o===l.Keys.down||o===l.Keys.right)u=i.slice(a+1).find(m=>!m.disabled);else if(o===l.Keys.up||o===l.Keys.left){const m=i.slice(0,a);for(u=m.pop();u&&u.disabled;)u=m.pop()}if(u){const m=u.id-a-1;this.onNavigate(p,o,m)}else this.onNavigate(p,o)}this.applyState(p),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,n=g.getFilteredData(this.props),{data:i=[]}=e,a=this.focusedIndex(),d=n[a],o=i!==n,r=d!==void 0&&t.focusedItem!==d,c=this.props.opened!==void 0?this.props.opened:this.state.opened,p=e.opened!==void 0?e.opened:t.opened,b=!p&&c;if(this.base.didUpdate(),s==="")(c&&(r||o)||b)&&this.base.scrollToItem(a);else if(!this._isScrolling){const m=(u=this.base.getGroupedDataModernMode(n,s))==null?void 0:u.indexOf(d);b&&(n&&n.length!==0&&this.base.resetGroupStickyHeader(n[0][s],this),this.base.scrollToItem(m)),c&&p&&r&&this.base.scrollToItem(m)}this.setValidity()}componentDidMount(){var t;this.observerResize=l.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(t=this.document)!=null&&t.body&&this.observerResize&&this.observerResize.observe(this.document.body);const e=this.props.name||this.props.id;this.KendoPasteSubscription=l.subscribeToKendoPaste(this._element,{fieldName:e,onValueChange:s=>{this.handleKendoPasteValue(s)}})}componentWillUnmount(){var e;this.observerResize&&this.observerResize.disconnect(),(e=this.KendoPasteSubscription)==null||e.unsubscribe()}render(){const{dir:e,disabled:t,label:s,className:n,style:i,loading:a,suggest:d,size:o,rounded:r,fillMode:c}=this.props,p=!this.validityStyles||this.validity.valid,b=this.base,u=this.value,m=this.props.clearButton!==!1&&!a&&!!u,v=this.props.id||this._inputId,O=this.state.focused;typeof d=="string"&&(this._suggested=d);const[P,K]=F(this.props.prefix||f.Fragment),[V,L]=F(this.props.suffix||f.Fragment),k=f.createElement(f.Fragment,null,f.createElement("span",{className:l.classNames("k-autocomplete k-input",n,{[`k-input-${D[o]||o}`]:o,[`k-rounded-${$[r]||r}`]:r,[`k-input-${c}`]:c,"k-invalid":!p,"k-focus":O&&!t,"k-loading":a,"k-required":this.required,"k-disabled":t}),ref:S=>{this._element=S,b.wrapper=S},style:s?{...i,width:void 0}:i,dir:e,onFocus:this.mobileMode?S=>this.handleWrapperClick(S):this.handleFocus,onBlur:this.handleBlur,onClick:this.handleWrapperClick},this.props.prefix&&f.createElement(P,{...K}),this.renderSearchBar(u||"",v),a&&f.createElement(l.IconWrap,{className:"k-input-loading-icon",name:"loading"}),m&&!a&&f.createElement(A,{onClick:this.clearButtonClick,key:"clearbutton"}),this.props.suffix&&f.createElement(V,{...L}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return s?f.createElement(z.FloatingLabel,{label:s,editorId:v,editorValue:u,editorValid:p,editorDisabled:t,style:{width:i?i.width:void 0},children:k}):k}onNavigate(e,t,s){const n=this.value,{textField:i,focusedItemIndex:a}=this.props,d=g.getFilteredData(this.props),o=this.state.focusedItem!==void 0?d.findIndex(c=>g.areSame(c,this.state.focusedItem,i)):a?a(d,n,i):d.indexOf(g.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=g.getFilteredData(this.props),d=this.focusedIndex(),o=a[d];if(this._suggested="",n&&s===l.Keys.enter&&o&&!o.disabled){const r=g.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,c=this.props.opened!==void 0?this.props.opened:this.state.opened;return f.createElement(q,{id:t,placeholder:n,tabIndex:i,accessKey:this.props.accessKey,value:e,suggestedText:this._suggested,focused:r,name:this.props.name,ref:p=>{this._input=p&&p.input},onKeyDown:this.onInputKeyDown,onChange:this.onChangeHandler,onFocus:s.handleFocus,onBlur:this.handleBlur,disabled:a,readOnly:d,expanded:c,ariaControls:c?s.listBoxId:void 0,activedescendant:`k-${s.guid}-item-${this.focusedIndex()+1}`,role:"combobox",ariaLabelledBy:this.props.ariaLabelledBy,ariaLabel:this.props.ariaLabel,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=g.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=g.getItemValue(n[0],s)),f.createElement(B,{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=_.provideLocalizationService(this),s=e.getPopupSettings(),{textField:n,listNoDataRender:i,itemRender:a,groupHeaderItemRender:d}=this.props,o=g.getFilteredData(this.props),r=this.value,c=this.props.opened!==void 0?this.props.opened:this.state.opened;return f.createElement(N,{id:e.listBoxId,show:c,data:o.slice(),focusedIndex:this.focusedIndex(),value:r,textField:n,valueField:n,highlightSelected:!0,optionsGuid:e.guid,groupField:this.props.groupField,ariaLabel:t.toLanguageString(w.autoCompleteListAriaLabel,w.messages[w.autoCompleteListAriaLabel]),listRef:p=>{e.list=p},wrapperStyle:this.mobileMode?{}:{maxHeight:s.height},wrapperCssClass:"k-list-content",onClick:this.handleItemClick,itemRender:a,groupHeaderItemRender:d,noDataRender:i,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=g.getFilteredData(this.props),n=s[g.itemIndexStartsWith(s,e,t)];if(n){const i=g.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=g.getFilteredData(this.props),a=e!==void 0?e:this.value;if(this.state.focusedItem!==void 0)return i.findIndex(o=>g.areSame(o,this.state.focusedItem,t));if(s)return s(i,a,t);const d=i.indexOf(g.getFocusedItem(i,a,t));return n&&t&&d===-1?i.findIndex(o=>!o.disabled):Math.max(0,d)}calculateMedia(e){for(const t of e)this.setState({windowWidth:t.target.clientWidth})}};y.displayName="AutoComplete",y.propTypes={...x.basicPropTypes,size:h.oneOf(["small","medium","large"]),rounded:h.oneOf(["small","medium","large","full","none"]),fillMode:h.oneOf(["solid","flat","outline"]),groupField:h.string,suggest:h.oneOfType([h.bool,h.string]),placeholder:h.string,value:h.string,defaultValue:h.string,validationMessage:h.string,required:h.bool,readonly:h.bool,clearButton:h.bool,valueRender:h.func,id:h.string,ariaLabelledBy:h.string,ariaLabel:h.string,ariaDescribedBy:h.string,list:h.any,adaptive:h.bool,adaptiveTitle:h.string,adaptiveSubtitle:h.string,onCancel:h.func,skipDisabledItems:h.bool,inputAttributes:h.object},y.defaultProps={...x.defaultProps,size:void 0,rounded:void 0,fillMode:void 0,skipDisabledItems:!0,prefix:void 0,suffix:void 0};let C=y;const M=l.createPropsContext();_.registerForLocalization(C);const E=l.withIdHOC(l.withPropsContext(M,l.withAdaptiveModeContext(C)));E.displayName="KendoReactAutoComplete";exports.AutoComplete=E;exports.AutoCompletePropsContext=M;exports.AutoCompleteWithoutContext=C;
|
|
@@ -13,7 +13,7 @@ import R from "../common/List.mjs";
|
|
|
13
13
|
import S from "../common/DropDownBase.mjs";
|
|
14
14
|
import K from "../common/GroupStickyHeader.mjs";
|
|
15
15
|
import { getFilteredData as b, getItemValue as I, areSame as w, isPresent as A, getFocusedItem as F, itemIndexStartsWith as H } from "../common/utils.mjs";
|
|
16
|
-
import { createPropsContext as q, classNames as k, kendoThemeMaps as W, Keys as f, canUseDOM as E, subscribeToKendoPaste as G, IconWrap as
|
|
16
|
+
import { createPropsContext as q, classNames as k, kendoThemeMaps as W, Keys as f, canUseDOM as E, subscribeToKendoPaste as G, IconWrap as U, withIdHOC as $, withPropsContext as j, withAdaptiveModeContext as J } from "@progress/kendo-react-common";
|
|
17
17
|
import { FloatingLabel as Q } from "@progress/kendo-react-labels";
|
|
18
18
|
import { provideLocalizationService as X, registerForLocalization as Y } from "@progress/kendo-react-intl";
|
|
19
19
|
import { autoCompleteListAriaLabel as M, messages as Z } from "../messages/index.mjs";
|
|
@@ -265,7 +265,7 @@ const oe = "Please enter a valid value!", { sizeMap: P, roundedMap: ne } = W, y
|
|
|
265
265
|
componentDidUpdate(e, t) {
|
|
266
266
|
var h;
|
|
267
267
|
const { groupField: s = "" } = this.props, n = b(this.props), { data: i = [] } = e, a = this.focusedIndex(), d = n[a], o = i !== n, r = d !== void 0 && t.focusedItem !== d, u = this.props.opened !== void 0 ? this.props.opened : this.state.opened, p = e.opened !== void 0 ? e.opened : t.opened, v = !p && u;
|
|
268
|
-
if (s === "")
|
|
268
|
+
if (this.base.didUpdate(), s === "")
|
|
269
269
|
(u && (r || o) || v) && this.base.scrollToItem(a);
|
|
270
270
|
else if (!this._isScrolling) {
|
|
271
271
|
const g = (h = this.base.getGroupedDataModernMode(n, s)) == null ? void 0 : h.indexOf(d);
|
|
@@ -324,7 +324,7 @@ const oe = "Please enter a valid value!", { sizeMap: P, roundedMap: ne } = W, y
|
|
|
324
324
|
},
|
|
325
325
|
this.props.prefix && /* @__PURE__ */ c.createElement(B, { ...T }),
|
|
326
326
|
this.renderSearchBar(h || "", m),
|
|
327
|
-
a && /* @__PURE__ */ c.createElement(
|
|
327
|
+
a && /* @__PURE__ */ c.createElement(U, { className: "k-input-loading-icon", name: "loading" }),
|
|
328
328
|
g && !a && /* @__PURE__ */ c.createElement(ee, { onClick: this.clearButtonClick, key: "clearbutton" }),
|
|
329
329
|
this.props.suffix && /* @__PURE__ */ c.createElement(V, { ...L }),
|
|
330
330
|
!this.mobileMode && this.renderListContainer()
|
|
@@ -523,7 +523,7 @@ y.displayName = "AutoComplete", y.propTypes = {
|
|
|
523
523
|
let x = y;
|
|
524
524
|
const ae = q();
|
|
525
525
|
Y(x);
|
|
526
|
-
const de =
|
|
526
|
+
const de = $(
|
|
527
527
|
j(
|
|
528
528
|
ae,
|
|
529
529
|
J(x)
|
package/ComboBox/ComboBox.js
CHANGED
|
@@ -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 Y=require("react"),b=require("prop-types"),T=require("../common/DropDownBase.js"),h=require("@progress/kendo-react-common"),J=require("@progress/kendo-react-labels"),p=require("../common/utils.js"),Q=require("../common/SearchBar.js"),X=require("../common/ListContainer.js"),Z=require("../common/List.js"),ee=require("../common/ListFilter.js"),K=require("../common/GroupStickyHeader.js"),L=require("../package-metadata.js"),te=require("../common/ClearButton.js"),se=require("@progress/kendo-react-buttons"),ie=require("@progress/kendo-svg-icons"),S=require("../messages/index.js"),N=require("@progress/kendo-react-intl"),oe=require("@progress/kendo-react-layout"),R=require("../common/withCustomComponent.js"),ae=require("../common/AdaptiveMode.js");function ne(w){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(w){for(const e in w)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(w,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>w[e]})}}return s.default=w,Object.freeze(s)}const g=ne(Y),le="Please enter a valid value!",F=class F extends g.Component{constructor(s){super(s),this.state={},this.base=new T(this),this._element=null,this._suggested="",this._skipBlur=!1,this._input=null,this._adaptiveFilterInput=null,this._skipFocus=!1,this.itemHeight=0,this.duplicates=[],this.hasDuplicates=!1,this.scrollToFocused=!1,this.showLicenseWatermark=!1,this.focus=()=>{this._input&&this._input.focus()},this.checkForDuplicatePlainTextRecords=()=>{const e=this.props.textField!==void 0,t=this.props.dataItemKey!==void 0;if(this.props.data&&this.props.data.length>0&&!e&&!t){const n=this.props.data;this.duplicates=p.getPlainDataDuplicates(n),this.hasDuplicates=this.duplicates.length>0}},this.handleKendoPasteValue=e=>{const{data:t,textField:n,allowCustom:r}=this.props;if(!t)return;const l=e!=null?String(e):"",o=p.getItemIndexByText(t,l,n,!1,!0),d=o!==-1;let a=null;if(d?a=t[o]:r&&(a=n?{[n]:l}:l),a===null)return;const i=this.base.initState();i.syntheticEvent={target:this._element,currentTarget:this._element,nativeEvent:new Event("change",{bubbles:!0})},this.state.text!==void 0&&(i.data.text=void 0),this.triggerOnChange(a,i),this.applyState(i)},this.handleItemSelect=(e,t)=>{const{virtual:n,dataItemKey:r}=this.props,l=p.getFilteredData(this.props),o=n?n.skip:0,d=l[e-o],a=this.hasDuplicates||!p.areSame(d,this.value,r);this.triggerOnChange(d,t),this.state.text!==void 0&&(t.data.text=void 0),a&&this.base.triggerPageChangeCornerItems(d,t)},this.onPopupOpened=()=>{setTimeout(()=>{this.mobileMode&&this._adaptiveFilterInput&&(this._skipBlur=!0,this._adaptiveFilterInput.focus(),this._skipBlur=!1)},300)},this.componentRef=e=>{this._element=e,this.base.wrapper=e},this.toggleBtnClick=e=>{this._skipFocus=!0;const{skipDisabledItems:t,textField:n}=this.props,r=p.getFilteredData(this.props),l=this.getFocusedIndex(),o=this.getCurrentValueDisabledStatus(n,r,l),d=this.props.opened!==void 0?this.props.opened:this.state.opened,a=this.base.initState();if(a.syntheticEvent=e,!t&&n&&o&&this.clearValueOnToggleBtnClick(e),this.base.togglePopup(a),!d&&this.mobileMode){const i=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text||null;this.base.filterChanged(i,a)}this.applyState(a),setTimeout(()=>{this._skipFocus=!1},300)},this.closeOpenedApplyStateNonMobileMode=(e,t)=>{t&&!this.mobileMode&&this.base.togglePopup(e)},this.renderMobileListFilter=()=>{const e=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text,t=p.getItemValue(this.value,this.props.textField),n=p.isPresent(e)?e:t;return g.createElement(ee,{value:n,ref:r=>{this._adaptiveFilterInput=r&&r.element},onChange:this.handleMobileFilterChange,onKeyDown:this.onInputKeyDown,size:"large",rounded:this.props.rounded,fillMode:this.props.fillMode,placeholder:this.props.placeholder})},this.listContainerContent=()=>{const{header:e,footer:t,size:n,groupStickyHeaderItemRender:r,groupField:l,list:o,unstyled:d,virtual:a}=this.props,i=p.getFilteredData(this.props),c=d&&d.uComboBox;let{group:u}=this.state;return u===void 0&&l!==void 0&&(u=p.getItemValue(i[0],l)),g.createElement("div",{className:h.classNames(h.uComboBox.list({c,list:o,size:"large",tableSize:n,virtual:a}))},e&&g.createElement("div",{className:h.classNames(h.uComboBox.listHeader({c}))},e),!o&&u&&i.length!==0&&g.createElement(K,{group:u,render:r}),this.renderList(),t&&g.createElement("div",{className:h.classNames(h.uComboBox.listFooter({c}),this.props.footerClassName)},t))},this.handleMobileFilterChange=e=>{const t=this.base.initState();t.syntheticEvent=e.syntheticEvent,t.data.text=e.target.value,this.base.filterChanged(e.target.value,t),this.applyState(t)},this.onScroll=e=>{const{vs:t,list:n}=this.base;t.scrollHandler(e);const{groupField:r}=this.props;this.props.onListScroll&&this.props.onListScroll(e);let l=p.getFilteredData(this.props);if(!r||!l.length)return;const o=this.itemHeight=this.itemHeight||(t.enabled?t.itemHeight:n?n.children[0].offsetHeight:0),a=e.target.scrollTop-t.skip*o;l=this.base.getGroupedDataModernMode(l,r);let i=l[0][r];for(let c=1;c<l.length&&!(o*c>a);c++)l[c]&&l[c][r]&&(i=l[c][r]);i!==this.state.group&&(this.setState({group:i}),this.props.onGroupScroll&&this.props.onGroupScroll.call(void 0,{group:i}))},this.handleItemClick=(e,t)=>{this.navigationIndex=e,this.base.handleItemClick(e,t),this._valueDuringOnChange=void 0},this.handleBlur=e=>{if(this.state.focused&&!this._skipBlur){const t=this.base.initState(),{textField:n}=this.props,r=p.getFilteredData(this.props),l=this.getFocusedIndex(),d=!(l===-1)&&this.getCurrentValueDisabledStatus(n,r,l);t.data.focused=!1,t.events.push({type:"onBlur"}),t.syntheticEvent=e,n&&d&&this.clearValueOnBlur(e),this.applyValueOnRejectSuggestions(e.currentTarget.value,t)}},this.onInputClick=e=>{const t=this.props.opened!==void 0?this.props.opened:this.state.opened,n=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text||null;if(!t&&this.mobileMode){const r=this.base.initState();r.syntheticEvent=e,this.base.togglePopup(r),this.base.filterChanged(n,r),this.applyState(r)}},this.onInputKeyDown=e=>{const{skipDisabledItems:t,textField:n,dataItemKey:r,groupField:l}=this.props,o=p.getFilteredData(this.props),d=this.value,a=Math.max(0,o.findIndex(v=>p.areSame(v,d,r))),i=e.keyCode,c=this.props.opened!==void 0?this.props.opened:this.state.opened,u=this.base.initState();if(u.syntheticEvent=e,!e.altKey&&(i===h.Keys.up||i===h.Keys.down)){if(e.preventDefault(),l!==""&&n)if(!this.props.skipDisabledItems&&c)this.onNavigate(u,i);else{let v=0;if(i===h.Keys.down||i===h.Keys.right){const m=o.slice(a+1<o.length?a+1:a).find(C=>!C.disabled);v=m&&o.indexOf(m)}else if(i===h.Keys.up||i===h.Keys.left){let m;if(a===0)m=o,v=o.findIndex(C=>!C.disabled);else{m=o.slice(0,a);let C=m.pop();for(;C&&C.disabled;)C=m.pop();v=C&&o.indexOf(C)}}if(v!==void 0){const m=v-a;this.onNavigate(u,i,m)}else v===void 0&&a===o.length-1&&this.onNavigate(u,i)}else if(!this.props.skipDisabledItems&&c)this.onNavigate(u,i);else{let v=null;if(i===h.Keys.down||i===h.Keys.right)v=o.slice(a+1).find(m=>!m.disabled);else if(i===h.Keys.up||i===h.Keys.left){const m=o.slice(0,a);for(v=m.pop();v&&v.disabled;)v=m.pop()}if(v){const m=v.id-a-1;this.onNavigate(u,i,m)}else this.onNavigate(u,i)}this.applyState(u)}const f=()=>{e.preventDefault(),this.base.togglePopup(u),this.applyState(u)},y=this.getFocusedIndex(),I=y===-1,x=!I&&this.getCurrentValueDisabledStatus(n,o,y);c?i===h.Keys.pageUp?(e.preventDefault(),this.base.scrollPopupByPageSize(-1)):i===h.Keys.pageDown?(e.preventDefault(),this.base.scrollPopupByPageSize(1)):e.altKey&&i===h.Keys.up?f():i===h.Keys.enter?(e.preventDefault(),(n&&!I&&e.currentTarget.value?o[y][n]:void 0)?!t&&n&&x?this.clearValueOnEnterOrEsc(e):x||this.applyValueOnEnter(e.currentTarget.value,u):this.applyValueOnEnter(e.currentTarget.value,u)):i===h.Keys.esc&&(!t&&n&&x&&this.clearValueOnEnterOrEsc(e),this.applyValueOnRejectSuggestions(e.currentTarget.value,u)):!c&&i===h.Keys.esc?this.clearValueOnEnterOrEsc(e):e.altKey&&i===h.Keys.down&&f()},this.inputOnChange=e=>{const t=this.base.initState();t.syntheticEvent=e;const n=this.props.opened!==void 0?this.props.opened:this.state.opened,r=e.currentTarget,l=r.value;if(this.props.suggest){const o=r.selectionEnd===l.length;let d=this.props.filter!==void 0?this.props.filter:this.state.text;p.isPresent(d)||(d=p.getItemValue(this.value,this.props.textField)||"");const a=d&&d===l,i=d&&d.length>l.length;a||i||!o?this._suggested="":this.suggestValue(l)}this.props.filter===void 0&&(t.data.text=l),this.state.focusedItem!==void 0&&(t.data.focusedItem=void 0),n?this.scrollToFocused=!0:this.base.togglePopup(t),this.base.filterChanged(l,t),this.applyState(t),this.setState({group:void 0})},this.clearButtonClick=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.clearValueOnEnterOrEsc=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.clearValueOnBlur=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.clearValueOnToggleBtnClick=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||le)},this.handleFocus=e=>{if(this._skipFocus)return;const t=this.base.initState();t.syntheticEvent=e,this.mobileMode&&!this._skipFocus&&(this._skipFocus=!0,this.base.togglePopup(t),this.applyState(t),setTimeout(()=>{this._skipFocus=!1},300)),this.base.handleFocus(e)},this.showLicenseWatermark=!h.validatePackage(L.packageMetadata,{component:"ComboBox"}),this.licenseMessage=h.getLicenseMessage(L.packageMetadata)}get _inputId(){return this.props.id}get document(){if(h.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}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 value(){if(this._valueDuringOnChange!==void 0)return this._valueDuringOnChange;if(this.props.value!==void 0)return this.props.value;if(this.state.value!==void 0)return this.state.value;if(this.props.defaultValue!==void 0)return this.props.defaultValue}get index(){const{dataItemKey:s}=this.props,e=p.getFilteredData(this.props),t=this.value;return e.findIndex(n=>p.areSame(n,t,s))}get name(){return this.props.name}get validity(){const s=this.props.validationMessage!==void 0,e=!this.required||this.value!==null&&this.value!==""&&this.value!==void 0,t=this.props.valid!==void 0?this.props.valid:e;return{customError:s,valid:t,valueMissing:this.value===null}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:F.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:F.defaultProps.required}componentDidUpdate(s,e){var f,y;const{dataItemKey:t,virtual:n,groupField:r="",textField:l}=this.props,o=p.getFilteredData(this.props),d=s.virtual?s.virtual.total:0,a=this.props.opened!==void 0?this.props.opened:this.state.opened,i=s.opened!==void 0?s.opened:e.opened;s.data!==o&&this.checkForDuplicatePlainTextRecords();const c=!i&&a,u=this.value;if(this._valueOnDidUpdate=u,this.base.didUpdate(),n&&n.total!==d)this.base.vs.calcScrollElementHeight(),this.base.vs.reset();else{const I=s.value!==void 0?s.value:e.value;let x=this.hasDuplicates?this.navigationIndex||0:o.findIndex(m=>p.areSame(m,u,t));l&&u&&(x=(f=this.base.getGroupedDataModernMode(o,r))==null?void 0:f.map(m=>m[l]).indexOf(u[l]));const v=!p.areSame(I,u,t);if(c&&n?this.base.scrollToVirtualItem(n,x):c&&!n?(this.onPopupOpened(),o&&o.length!==0&&this.base.resetGroupStickyHeader(o[0][r],this),this.base.scrollToItem(x)):(this.hasDuplicates||a&&i&&u&&v)&&this.base.scrollToItem(x),a&&i&&this.scrollToFocused){const m=(y=this.props.filter?this.props.filter:this.state.text)!=null?y:"";if(m){const{focusedItemIndex:C=p.itemIndexStartsWith}=this.props,D=C(o,m,l);this.base.scrollToItem(D)}else this.base.scrollToItem(0)}}this.scrollToFocused=!1,c&&this._input&&this._input.focus(),this.setValidity()}componentDidMount(){var e;this.observerResize=h.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),this.checkForDuplicatePlainTextRecords();const s=this.props.name||this.props.id;this.KendoPasteSubscription=h.subscribeToKendoPaste(this._element,{fieldName:s,onValueChange:t=>{this.handleKendoPasteValue(t)}})}componentWillUnmount(){var s,e;(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.disconnect(),(e=this.KendoPasteSubscription)==null||e.unsubscribe()}render(){const s=N.provideLocalizationService(this),e=s.toLanguageString(S.comboArrowBtnAriaLabelExpand,S.messages[S.comboArrowBtnAriaLabelExpand]),t=s.toLanguageString(S.comboArrowBtnAriaLabelCollapse,S.messages[S.comboArrowBtnAriaLabelCollapse]),{dir:n,disabled:r,clearButton:l=F.defaultProps.clearButton,label:o,textField:d,className:a,style:i,loading:c,iconClassName:u,virtual:f,size:y,rounded:I,fillMode:x,opened:v=this.state.opened,placeholder:m,svgIcon:C,unstyled:D}=this.props,B=!this.validityStyles||this.validity.valid,k=this.props.filter!==void 0?this.props.filter:this.state.text,z=p.getItemValue(this.value,d),M=p.isPresent(k)?k:z,H=l&&(!!M||p.isPresent(this.value)),O=this.base.vs,P=this.props.id||this._inputId,E=D&&D.uComboBox;O.enabled=f!==void 0,f!==void 0&&(O.skip=f.skip,O.total=f.total,O.pageSize=f.pageSize);const[W,j]=R(this.props.prefix||g.Fragment),[U,G]=R(this.props.suffix||g.Fragment),_=g.createElement(g.Fragment,null,g.createElement("span",{className:h.classNames(h.uComboBox.wrapper({c:E,size:y,rounded:I,fillMode:x,disabled:r,invalid:!B,loading:c,required:this.required}),a),ref:this.componentRef,style:o?{...i,width:void 0}:i,dir:n,onFocus:this.handleFocus},this.props.prefix&&g.createElement(W,{...j}),this.renderSearchBar(M||"",P,m),H&&!c&&g.createElement(te,{onClick:this.clearButtonClick,key:"clearbutton"}),c&&g.createElement(h.IconWrap,{className:h.classNames(h.uComboBox.loadingIcon({c:E})),name:"loading",key:"loading"}),this.props.suffix&&g.createElement(U,{...G}),g.createElement(se.Button,{tabIndex:-1,type:"button","aria-label":v?t:e,svgIcon:C||(u?void 0:ie.chevronDownIcon),iconClass:u,size:y,fillMode:x,className:h.classNames(h.uComboBox.inputButton({c:E})),onClick:this.toggleBtnClick,onMouseDown:$=>$.preventDefault()}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return o?g.createElement(J.FloatingLabel,{label:o,editorId:P,editorValue:M,editorValid:B,editorDisabled:r,style:{width:i?i.width:void 0},children:_,unstyled:D}):_}onNavigate(s,e,t){const{virtual:n={skip:0},textField:r}=this.props,l=p.getFilteredData(this.props),o=this.props.filter?this.props.filter:this.state.text;let d=-1,a;const i=this.base.vs,c=this.value;this._suggested="";const u=this.hasDuplicates&&this.duplicates.indexOf(c)!==-1;if(d=this.getFocusedIndex(u),d!==-1&&(!p.isPresent(c)||o&&o!==p.getItemValue(c,r)))this.handleItemSelect(d,s);else if(o==="")this.handleItemSelect(0,s);else{const f=n.skip+d;a=this.base.navigation.navigate({keyCode:e,current:f,max:(i.enabled?i.total:l.length)-1,min:0,skipItems:t||void 0}),a!==void 0&&this.handleItemSelect(a,s)}this.navigationIndex=a}getCurrentValueDisabledStatus(s,e,t){return s&&e&&e[t]&&e[t].disabled}applyValueOnEnter(s,e){const{textField:t,allowCustom:n,ignoreCase:r}=this.props,l=p.getFilteredData(this.props),o=this.props.opened!==void 0?this.props.opened:this.state.opened,a=p.getItemValue(this.value,t)===s?this.index:p.getItemIndexByText(l,s,t,!1,r),i=a!==-1;let c;if(this._suggested="",i)c=l[a];else if(n)c=t!==void 0?{[t]:s}:s;else return this.selectFocusedItem(s,e);this.triggerOnChange(c,e),o&&this.base.togglePopup(e),this.props.filter===void 0&&this.state.text!==void 0&&(e.data.text=void 0),this.applyState(e)}applyValueOnRejectSuggestions(s,e){const{textField:t,allowCustom:n,ignoreCase:r}=this.props,l=p.getFilteredData(this.props),o=this.props.opened!==void 0?this.props.opened:this.state.opened,d=p.getItemValue(this.value,t);if(this._suggested="",s===d||s===""&&!p.isPresent(d))return this.closeOpenedApplyStateNonMobileMode(e,o),this.applyState(e);const a=p.getItemIndexByText(l,s,t,!0,r),i=a!==-1;let c=null;i?c=l[a]:n&&(c=s?t?{[t]:s}:s:null),this.triggerOnChange(c,e),this.state.text!==void 0&&(e.data.text=void 0,this.base.filterChanged("",e)),this.closeOpenedApplyStateNonMobileMode(e,o),this.applyState(e)}selectFocusedItem(s,e){const t=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:n,virtual:r={skip:0},focusedItemIndex:l=p.itemIndexStartsWith}=this.props,o=p.getFilteredData(this.props),d=r.skip,a=s===""&&d===0?0:l(o,s,n);return a!==-1?this.handleItemSelect(a+d,e):(this.triggerOnChange(null,e),this.state.text!==void 0&&(e.data.text=void 0)),t&&this.base.togglePopup(e),this.applyState(e)}renderAdaptiveListContainer(){const{windowWidth:s=0}=this.state,{groupField:e,adaptiveTitle:t=this.props.label,adaptiveSubtitle:n}=this.props,r=p.getFilteredData(this.props),l=this.props.opened!==void 0?this.props.opened:this.state.opened;let{group:o}=this.state;o===void 0&&e!==void 0&&(o=p.getItemValue(r[0],e));const d={title:t||this.props.label,subTitle:n,expand:l,onClose:a=>this.toggleBtnClick(a),windowWidth:s,mobileFilter:this.renderMobileListFilter()};return g.createElement(ae.AdaptiveMode,{...d},g.createElement(oe.ActionSheetContent,null,g.createElement("div",{className:"k-list-container"},this.listContainerContent())))}renderListContainer(){const s=this.base,{dir:e,header:t,footer:n,groupField:r,size:l,list:o,virtual:d,groupStickyHeaderItemRender:a,unstyled:i}=this.props,c=p.getFilteredData(this.props),u=this.props.opened!==void 0?this.props.opened:this.state.opened,f=s.getPopupSettings(),y=f.width!==void 0?f.width:s.popupWidth,I=i&&i.uComboBox;let{group:x}=this.state;return x===void 0&&r!==void 0&&(x=p.getItemValue(c[0],r)),g.createElement(X,{width:y,popupSettings:{...f,anchor:f.anchor||this.element,show:u,popupClass:h.classNames(f.popupClass,h.uComboBox.listContainer({c:I,popup:!0}))},dir:e!==void 0?e:this.base.dirCalculated,itemsCount:[c.length]},g.createElement("div",{className:h.classNames(h.uComboBox.list({c:I,list:o,size:l,tableSize:l,virtual:d}))},t&&g.createElement("div",{className:h.classNames(h.uComboBox.listHeader({c:I}))},t),!o&&x&&c.length!==0&&g.createElement(K,{group:x,render:a}),this.renderList(),n&&g.createElement("div",{className:h.classNames(h.uComboBox.listFooter({c:I}),this.props.footerClassName)},n)),this.showLicenseWatermark&&g.createElement(h.WatermarkOverlay,{message:this.licenseMessage}))}renderList(){const s=this.base,e=N.provideLocalizationService(this),{textField:t,dataItemKey:n,listNoDataRender:r,itemRender:l,groupHeaderItemRender:o,virtual:d={skip:0,total:void 0},unstyled:a}=this.props,i=p.getFilteredData(this.props),c=s.getPopupSettings(),u=s.vs,f=d.skip,y=this.props.opened!==void 0?this.props.opened:this.state.opened,I=`translateY(${u.translate}px)`,x=y?this.getFocusedIndex(this.hasDuplicates):void 0,v=this.props.filter!==void 0?this.props.filter:this.state.text,m=p.getItemValue(this.value,t),C=p.isPresent(v)&&v!==m?null:this.value,D=this.props.list||Z,B=a&&a.uComboBox;return g.createElement(D,{id:s.listBoxId,virtual:!!d,show:y,data:i,focusedIndex:x,value:C,textField:t,valueField:n,groupField:this.props.groupField,isMultiColumn:this.props.isMultiColumn,optionsGuid:s.guid,hasDuplicates:this.hasDuplicates,ariaLabel:e.toLanguageString(S.listAriaLabel,S.messages[S.listAriaLabel]),listRef:k=>{u.list=this.base.list=k,this.itemHeight=0},wrapperStyle:this.mobileMode?{}:{maxHeight:c.height},wrapperCssClass:h.classNames(h.uComboBox.listContent({c:B,virtual:d})),listStyle:u.enabled?{transform:I}:void 0,key:"listkey",skip:f,onClick:this.handleItemClick,itemRender:l,groupHeaderItemRender:o,noDataRender:r,onMouseDown:k=>k.preventDefault(),onScroll:this.onScroll,wrapperRef:u.scrollerRef,scroller:this.base.renderScrollElement(),ariaSetSize:d.total})}renderSearchBar(s,e,t){const{tabIndex:n,accessKey:r,disabled:l,title:o,ariaLabelledBy:d,ariaDescribedBy:a,dataItemKey:i,virtual:c={skip:0},unstyled:u,inputAttributes:f}=this.props;p.getFilteredData(this.props);const y=this.props.opened!==void 0?this.props.opened:this.state.opened,I=y?this.getFocusedIndex(this.hasDuplicates):-1;return this._suggested&&!p.areSame(this._valueOnDidUpdate,this.value,i)&&(this._suggested=""),g.createElement(Q,{id:e,readOnly:y&&this.mobileMode,placeholder:t,tabIndex:n,accessKey:r,title:o,value:s+this._suggested,suggestedText:this._suggested,ref:x=>{this._input=x&&x.input},onClick:this.onInputClick,onKeyDown:this.onInputKeyDown,onChange:this.inputOnChange,onFocus:this.base.handleFocus,onBlur:this.handleBlur,disabled:l,expanded:y,owns:this.base.listBoxId,activedescendant:y&&I>=0?`k-${this.base.guid}-item-${I+c.skip+1}`:void 0,role:"combobox",ariaLabelledBy:d,ariaLabel:this.props.ariaLabel,ariaDescribedBy:a,ariaRequired:this.required,render:this.props.valueRender,ariaControls:y?this.base.listBoxId:void 0,unstyled:u,inputAttributes:f})}clearValue(){const s=this.base.initState();this._suggested="",this.navigationIndex=void 0,this.base.filterChanged("",s),this.props.filter===void 0&&this.state.text!==void 0&&(s.data.text=void 0),this.triggerOnChange(null,s);const e=this.props.opened!==void 0?this.props.opened:this.state.opened,t=this.mobileMode;e&&!t&&this.base.togglePopup(s),this.applyState(s)}triggerOnChange(s,e){const t=this.value;!this.hasDuplicates&&(!p.isPresent(t)&&!p.isPresent(s)||p.areSame(t,s,this.props.dataItemKey))||(this.props.value===void 0&&(e.data.value=s),this._valueDuringOnChange=s,e.events.push({type:"onChange"}))}getFocusedIndex(s){const e=this.value,{textField:t,dataItemKey:n,virtual:r={skip:0},focusedItemIndex:l=p.itemIndexStartsWith,skipDisabledItems:o}=this.props,d=p.getFilteredData(this.props),a=this.props.filter?this.props.filter:this.state.text;return s&&this.navigationIndex!==void 0?this.navigationIndex:p.isPresent(e)&&a===void 0?d.findIndex(i=>p.areSame(i,e,n)):a?l(d,a,t):o&&t&&!a&&r.skip===0?d.findIndex(i=>!i.disabled):r.skip===0?0:-1}suggestValue(s){const{data:e,textField:t}=this.props;this._suggested=p.suggestValue(s,e,t)}applyState(s){this.base.applyState(s),this._valueDuringOnChange=void 0}calculateMedia(s){for(const e of s)this.setState({windowWidth:e.target.clientWidth})}};F.displayName="ComboBox",F.propTypes={...T.propTypes,size:b.oneOf(["small","medium","large"]),rounded:b.oneOf(["small","medium","large","full","none"]),fillMode:b.oneOf(["solid","flat","outline"]),dataItemKey:b.string,groupField:b.string,isMultiColumn:b.bool,suggest:b.bool,placeholder:b.string,title:b.string,allowCustom:b.bool,ignoreCase:b.bool,clearButton:b.bool,iconClassName:b.string,svgIcon:h.svgIconPropType,validationMessage:b.string,required:b.bool,id:b.string,ariaLabelledBy:b.string,ariaLabel:b.string,ariaDescribedBy:b.string,list:b.any,valueRender:b.func,skipDisabledItems:b.bool,inputAttributes:b.object},F.defaultProps={...T.defaultProps,size:void 0,rounded:void 0,fillMode:void 0,allowCustom:!1,ignoreCase:!1,clearButton:!0,required:!1,isMultiColumn:!1,skipDisabledItems:!0,prefix:void 0,suffix:void 0};let V=F;const q=h.createPropsContext(),A=h.withIdHOC(h.withPropsContext(q,h.withUnstyledHOC(h.withAdaptiveModeContext(V))));A.displayName="KendoReactComboBox";exports.ComboBox=A;exports.ComboBoxPropsContext=q;exports.ComboBoxWithoutContext=V;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("react"),b=require("prop-types"),T=require("../common/DropDownBase.js"),h=require("@progress/kendo-react-common"),J=require("@progress/kendo-react-labels"),p=require("../common/utils.js"),Q=require("../common/SearchBar.js"),X=require("../common/ListContainer.js"),Z=require("../common/List.js"),ee=require("../common/ListFilter.js"),K=require("../common/GroupStickyHeader.js"),L=require("../package-metadata.js"),te=require("../common/ClearButton.js"),se=require("@progress/kendo-react-buttons"),ie=require("@progress/kendo-svg-icons"),S=require("../messages/index.js"),N=require("@progress/kendo-react-intl"),oe=require("@progress/kendo-react-layout"),R=require("../common/withCustomComponent.js"),ae=require("../common/AdaptiveMode.js");function ne(w){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(w){for(const e in w)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(w,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>w[e]})}}return s.default=w,Object.freeze(s)}const g=ne(Y),le="Please enter a valid value!",F=class F extends g.Component{constructor(s){super(s),this.state={},this.base=new T(this),this._element=null,this._suggested="",this._skipBlur=!1,this._input=null,this._adaptiveFilterInput=null,this._skipFocus=!1,this.itemHeight=0,this.duplicates=[],this.hasDuplicates=!1,this.scrollToFocused=!1,this.showLicenseWatermark=!1,this.focus=()=>{this._input&&this._input.focus()},this.checkForDuplicatePlainTextRecords=()=>{const e=this.props.textField!==void 0,t=this.props.dataItemKey!==void 0;if(this.props.data&&this.props.data.length>0&&!e&&!t){const n=this.props.data;this.duplicates=p.getPlainDataDuplicates(n),this.hasDuplicates=this.duplicates.length>0}},this.handleKendoPasteValue=e=>{const{data:t,textField:n,allowCustom:r}=this.props;if(!t)return;const l=e!=null?String(e):"",o=p.getItemIndexByText(t,l,n,!1,!0),d=o!==-1;let a=null;if(d?a=t[o]:r&&(a=n?{[n]:l}:l),a===null)return;const i=this.base.initState();i.syntheticEvent={target:this._element,currentTarget:this._element,nativeEvent:new Event("change",{bubbles:!0})},this.state.text!==void 0&&(i.data.text=void 0),this.triggerOnChange(a,i),this.applyState(i)},this.handleItemSelect=(e,t)=>{const{virtual:n,dataItemKey:r}=this.props,l=p.getFilteredData(this.props),o=n?n.skip:0,d=l[e-o],a=this.hasDuplicates||!p.areSame(d,this.value,r);this.triggerOnChange(d,t),this.state.text!==void 0&&(t.data.text=void 0),a&&this.base.triggerPageChangeCornerItems(d,t)},this.onPopupOpened=()=>{setTimeout(()=>{this.mobileMode&&this._adaptiveFilterInput&&(this._skipBlur=!0,this._adaptiveFilterInput.focus(),this._skipBlur=!1)},300)},this.componentRef=e=>{this._element=e,this.base.wrapper=e},this.toggleBtnClick=e=>{this._skipFocus=!0;const{skipDisabledItems:t,textField:n}=this.props,r=p.getFilteredData(this.props),l=this.getFocusedIndex(),o=this.getCurrentValueDisabledStatus(n,r,l),d=this.props.opened!==void 0?this.props.opened:this.state.opened,a=this.base.initState();if(a.syntheticEvent=e,!t&&n&&o&&this.clearValueOnToggleBtnClick(e),this.base.togglePopup(a),!d&&this.mobileMode){const i=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text||null;this.base.filterChanged(i,a)}this.applyState(a),setTimeout(()=>{this._skipFocus=!1},300)},this.closeOpenedApplyStateNonMobileMode=(e,t)=>{t&&!this.mobileMode&&this.base.togglePopup(e)},this.renderMobileListFilter=()=>{const e=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text,t=p.getItemValue(this.value,this.props.textField),n=p.isPresent(e)?e:t;return g.createElement(ee,{value:n,ref:r=>{this._adaptiveFilterInput=r&&r.element},onChange:this.handleMobileFilterChange,onKeyDown:this.onInputKeyDown,size:"large",rounded:this.props.rounded,fillMode:this.props.fillMode,placeholder:this.props.placeholder})},this.listContainerContent=()=>{const{header:e,footer:t,size:n,groupStickyHeaderItemRender:r,groupField:l,list:o,unstyled:d,virtual:a}=this.props,i=p.getFilteredData(this.props),c=d&&d.uComboBox;let{group:u}=this.state;return u===void 0&&l!==void 0&&(u=p.getItemValue(i[0],l)),g.createElement("div",{className:h.classNames(h.uComboBox.list({c,list:o,size:"large",tableSize:n,virtual:a}))},e&&g.createElement("div",{className:h.classNames(h.uComboBox.listHeader({c}))},e),!o&&u&&i.length!==0&&g.createElement(K,{group:u,render:r}),this.renderList(),t&&g.createElement("div",{className:h.classNames(h.uComboBox.listFooter({c}),this.props.footerClassName)},t))},this.handleMobileFilterChange=e=>{const t=this.base.initState();t.syntheticEvent=e.syntheticEvent,t.data.text=e.target.value,this.base.filterChanged(e.target.value,t),this.applyState(t)},this.onScroll=e=>{const{vs:t,list:n}=this.base;t.scrollHandler(e);const{groupField:r}=this.props;this.props.onListScroll&&this.props.onListScroll(e);let l=p.getFilteredData(this.props);if(!r||!l.length)return;const o=this.itemHeight=this.itemHeight||(t.enabled?t.itemHeight:n?n.children[0].offsetHeight:0),a=e.target.scrollTop-t.skip*o;l=this.base.getGroupedDataModernMode(l,r);let i=l[0][r];for(let c=1;c<l.length&&!(o*c>a);c++)l[c]&&l[c][r]&&(i=l[c][r]);i!==this.state.group&&(this.setState({group:i}),this.props.onGroupScroll&&this.props.onGroupScroll.call(void 0,{group:i}))},this.handleItemClick=(e,t)=>{this.navigationIndex=e,this.base.handleItemClick(e,t),this._valueDuringOnChange=void 0},this.handleBlur=e=>{if(this.state.focused&&!this._skipBlur){const t=this.base.initState(),{textField:n}=this.props,r=p.getFilteredData(this.props),l=this.getFocusedIndex(),d=!(l===-1)&&this.getCurrentValueDisabledStatus(n,r,l);t.data.focused=!1,t.events.push({type:"onBlur"}),t.syntheticEvent=e,n&&d&&this.clearValueOnBlur(e),this.applyValueOnRejectSuggestions(e.currentTarget.value,t)}},this.onInputClick=e=>{const t=this.props.opened!==void 0?this.props.opened:this.state.opened,n=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text||null;if(!t&&this.mobileMode){const r=this.base.initState();r.syntheticEvent=e,this.base.togglePopup(r),this.base.filterChanged(n,r),this.applyState(r)}},this.onInputKeyDown=e=>{const{skipDisabledItems:t,textField:n,dataItemKey:r,groupField:l}=this.props,o=p.getFilteredData(this.props),d=this.value,a=Math.max(0,o.findIndex(v=>p.areSame(v,d,r))),i=e.keyCode,c=this.props.opened!==void 0?this.props.opened:this.state.opened,u=this.base.initState();if(u.syntheticEvent=e,!e.altKey&&(i===h.Keys.up||i===h.Keys.down)){if(e.preventDefault(),l!==""&&n)if(!this.props.skipDisabledItems&&c)this.onNavigate(u,i);else{let v=0;if(i===h.Keys.down||i===h.Keys.right){const m=o.slice(a+1<o.length?a+1:a).find(C=>!C.disabled);v=m&&o.indexOf(m)}else if(i===h.Keys.up||i===h.Keys.left){let m;if(a===0)m=o,v=o.findIndex(C=>!C.disabled);else{m=o.slice(0,a);let C=m.pop();for(;C&&C.disabled;)C=m.pop();v=C&&o.indexOf(C)}}if(v!==void 0){const m=v-a;this.onNavigate(u,i,m)}else v===void 0&&a===o.length-1&&this.onNavigate(u,i)}else if(!this.props.skipDisabledItems&&c)this.onNavigate(u,i);else{let v=null;if(i===h.Keys.down||i===h.Keys.right)v=o.slice(a+1).find(m=>!m.disabled);else if(i===h.Keys.up||i===h.Keys.left){const m=o.slice(0,a);for(v=m.pop();v&&v.disabled;)v=m.pop()}if(v){const m=v.id-a-1;this.onNavigate(u,i,m)}else this.onNavigate(u,i)}this.applyState(u)}const f=()=>{e.preventDefault(),this.base.togglePopup(u),this.applyState(u)},y=this.getFocusedIndex(),I=y===-1,x=!I&&this.getCurrentValueDisabledStatus(n,o,y);c?i===h.Keys.pageUp?(e.preventDefault(),this.base.scrollPopupByPageSize(-1)):i===h.Keys.pageDown?(e.preventDefault(),this.base.scrollPopupByPageSize(1)):e.altKey&&i===h.Keys.up?f():i===h.Keys.enter?(e.preventDefault(),(n&&!I&&e.currentTarget.value?o[y][n]:void 0)?!t&&n&&x?this.clearValueOnEnterOrEsc(e):x||this.applyValueOnEnter(e.currentTarget.value,u):this.applyValueOnEnter(e.currentTarget.value,u)):i===h.Keys.esc&&(!t&&n&&x&&this.clearValueOnEnterOrEsc(e),this.applyValueOnRejectSuggestions(e.currentTarget.value,u)):!c&&i===h.Keys.esc?this.clearValueOnEnterOrEsc(e):e.altKey&&i===h.Keys.down&&f()},this.inputOnChange=e=>{const t=this.base.initState();t.syntheticEvent=e;const n=this.props.opened!==void 0?this.props.opened:this.state.opened,r=e.currentTarget,l=r.value;if(this.props.suggest){const o=r.selectionEnd===l.length;let d=this.props.filter!==void 0?this.props.filter:this.state.text;p.isPresent(d)||(d=p.getItemValue(this.value,this.props.textField)||"");const a=d&&d===l,i=d&&d.length>l.length;a||i||!o?this._suggested="":this.suggestValue(l)}this.props.filter===void 0&&(t.data.text=l),this.state.focusedItem!==void 0&&(t.data.focusedItem=void 0),n?this.scrollToFocused=!0:this.base.togglePopup(t),this.base.filterChanged(l,t),this.applyState(t),this.setState({group:void 0})},this.clearButtonClick=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue(),this._skipFocus=!0,this.focus(),setTimeout(()=>{this._skipFocus=!1},300)},this.clearValueOnEnterOrEsc=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.clearValueOnBlur=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.clearValueOnToggleBtnClick=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||le)},this.handleFocus=e=>{if(this._skipFocus)return;const t=this.base.initState();t.syntheticEvent=e,this.mobileMode&&!this._skipFocus&&(this._skipFocus=!0,this.base.togglePopup(t),this.applyState(t),setTimeout(()=>{this._skipFocus=!1},300)),this.base.handleFocus(e)},this.showLicenseWatermark=!h.validatePackage(L.packageMetadata,{component:"ComboBox"}),this.licenseMessage=h.getLicenseMessage(L.packageMetadata)}get _inputId(){return this.props.id}get document(){if(h.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}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 value(){if(this._valueDuringOnChange!==void 0)return this._valueDuringOnChange;if(this.props.value!==void 0)return this.props.value;if(this.state.value!==void 0)return this.state.value;if(this.props.defaultValue!==void 0)return this.props.defaultValue}get index(){const{dataItemKey:s}=this.props,e=p.getFilteredData(this.props),t=this.value;return e.findIndex(n=>p.areSame(n,t,s))}get name(){return this.props.name}get validity(){const s=this.props.validationMessage!==void 0,e=!this.required||this.value!==null&&this.value!==""&&this.value!==void 0,t=this.props.valid!==void 0?this.props.valid:e;return{customError:s,valid:t,valueMissing:this.value===null}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:F.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:F.defaultProps.required}componentDidUpdate(s,e){var f,y;const{dataItemKey:t,virtual:n,groupField:r="",textField:l}=this.props,o=p.getFilteredData(this.props),d=s.virtual?s.virtual.total:0,a=this.props.opened!==void 0?this.props.opened:this.state.opened,i=s.opened!==void 0?s.opened:e.opened;s.data!==o&&this.checkForDuplicatePlainTextRecords();const c=!i&&a,u=this.value;if(this._valueOnDidUpdate=u,this.base.didUpdate(),n&&n.total!==d)this.base.vs.calcScrollElementHeight(),this.base.vs.reset();else{const I=s.value!==void 0?s.value:e.value;let x=this.hasDuplicates?this.navigationIndex||0:o.findIndex(m=>p.areSame(m,u,t));l&&u&&(x=(f=this.base.getGroupedDataModernMode(o,r))==null?void 0:f.map(m=>m[l]).indexOf(u[l]));const v=!p.areSame(I,u,t);if(c&&n?this.base.scrollToVirtualItem(n,x):c&&!n?(this.onPopupOpened(),o&&o.length!==0&&this.base.resetGroupStickyHeader(o[0][r],this),this.base.scrollToItem(x)):(this.hasDuplicates||a&&i&&u&&v)&&this.base.scrollToItem(x),a&&i&&this.scrollToFocused){const m=(y=this.props.filter?this.props.filter:this.state.text)!=null?y:"";if(m){const{focusedItemIndex:C=p.itemIndexStartsWith}=this.props,D=C(o,m,l);this.base.scrollToItem(D)}else this.base.scrollToItem(0)}}this.scrollToFocused=!1,c&&this._input&&this._input.focus(),this.setValidity()}componentDidMount(){var e;this.observerResize=h.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),this.checkForDuplicatePlainTextRecords();const s=this.props.name||this.props.id;this.KendoPasteSubscription=h.subscribeToKendoPaste(this._element,{fieldName:s,onValueChange:t=>{this.handleKendoPasteValue(t)}})}componentWillUnmount(){var s,e;(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.disconnect(),(e=this.KendoPasteSubscription)==null||e.unsubscribe()}render(){const s=N.provideLocalizationService(this),e=s.toLanguageString(S.comboArrowBtnAriaLabelExpand,S.messages[S.comboArrowBtnAriaLabelExpand]),t=s.toLanguageString(S.comboArrowBtnAriaLabelCollapse,S.messages[S.comboArrowBtnAriaLabelCollapse]),{dir:n,disabled:r,clearButton:l=F.defaultProps.clearButton,label:o,textField:d,className:a,style:i,loading:c,iconClassName:u,virtual:f,size:y,rounded:I,fillMode:x,opened:v=this.state.opened,placeholder:m,svgIcon:C,unstyled:D}=this.props,B=!this.validityStyles||this.validity.valid,k=this.props.filter!==void 0?this.props.filter:this.state.text,z=p.getItemValue(this.value,d),M=p.isPresent(k)?k:z,H=l&&(!!M||p.isPresent(this.value)),O=this.base.vs,P=this.props.id||this._inputId,E=D&&D.uComboBox;O.enabled=f!==void 0,f!==void 0&&(O.skip=f.skip,O.total=f.total,O.pageSize=f.pageSize);const[W,j]=R(this.props.prefix||g.Fragment),[U,G]=R(this.props.suffix||g.Fragment),_=g.createElement(g.Fragment,null,g.createElement("span",{className:h.classNames(h.uComboBox.wrapper({c:E,size:y,rounded:I,fillMode:x,disabled:r,invalid:!B,loading:c,required:this.required}),a),ref:this.componentRef,style:o?{...i,width:void 0}:i,dir:n,onFocus:this.handleFocus},this.props.prefix&&g.createElement(W,{...j}),this.renderSearchBar(M||"",P,m),H&&!c&&g.createElement(te,{onClick:this.clearButtonClick,key:"clearbutton"}),c&&g.createElement(h.IconWrap,{className:h.classNames(h.uComboBox.loadingIcon({c:E})),name:"loading",key:"loading"}),this.props.suffix&&g.createElement(U,{...G}),g.createElement(se.Button,{tabIndex:-1,type:"button","aria-label":v?t:e,svgIcon:C||(u?void 0:ie.chevronDownIcon),iconClass:u,size:y,fillMode:x,className:h.classNames(h.uComboBox.inputButton({c:E})),onClick:this.toggleBtnClick,onMouseDown:$=>$.preventDefault()}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return o?g.createElement(J.FloatingLabel,{label:o,editorId:P,editorValue:M,editorValid:B,editorDisabled:r,style:{width:i?i.width:void 0},children:_,unstyled:D}):_}onNavigate(s,e,t){const{virtual:n={skip:0},textField:r}=this.props,l=p.getFilteredData(this.props),o=this.props.filter?this.props.filter:this.state.text;let d=-1,a;const i=this.base.vs,c=this.value;this._suggested="";const u=this.hasDuplicates&&this.duplicates.indexOf(c)!==-1;if(d=this.getFocusedIndex(u),d!==-1&&(!p.isPresent(c)||o&&o!==p.getItemValue(c,r)))this.handleItemSelect(d,s);else if(o==="")this.handleItemSelect(0,s);else{const f=n.skip+d;a=this.base.navigation.navigate({keyCode:e,current:f,max:(i.enabled?i.total:l.length)-1,min:0,skipItems:t||void 0}),a!==void 0&&this.handleItemSelect(a,s)}this.navigationIndex=a}getCurrentValueDisabledStatus(s,e,t){return s&&e&&e[t]&&e[t].disabled}applyValueOnEnter(s,e){const{textField:t,allowCustom:n,ignoreCase:r}=this.props,l=p.getFilteredData(this.props),o=this.props.opened!==void 0?this.props.opened:this.state.opened,a=p.getItemValue(this.value,t)===s?this.index:p.getItemIndexByText(l,s,t,!1,r),i=a!==-1;let c;if(this._suggested="",i)c=l[a];else if(n)c=t!==void 0?{[t]:s}:s;else return this.selectFocusedItem(s,e);this.triggerOnChange(c,e),o&&this.base.togglePopup(e),this.props.filter===void 0&&this.state.text!==void 0&&(e.data.text=void 0),this.applyState(e)}applyValueOnRejectSuggestions(s,e){const{textField:t,allowCustom:n,ignoreCase:r}=this.props,l=p.getFilteredData(this.props),o=this.props.opened!==void 0?this.props.opened:this.state.opened,d=p.getItemValue(this.value,t);if(this._suggested="",s===d||s===""&&!p.isPresent(d))return this.closeOpenedApplyStateNonMobileMode(e,o),this.applyState(e);const a=p.getItemIndexByText(l,s,t,!0,r),i=a!==-1;let c=null;i?c=l[a]:n&&(c=s?t?{[t]:s}:s:null),this.triggerOnChange(c,e),this.state.text!==void 0&&(e.data.text=void 0,this.base.filterChanged("",e)),this.closeOpenedApplyStateNonMobileMode(e,o),this.applyState(e)}selectFocusedItem(s,e){const t=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:n,virtual:r={skip:0},focusedItemIndex:l=p.itemIndexStartsWith}=this.props,o=p.getFilteredData(this.props),d=r.skip,a=s===""&&d===0?0:l(o,s,n);return a!==-1?this.handleItemSelect(a+d,e):(this.triggerOnChange(null,e),this.state.text!==void 0&&(e.data.text=void 0)),t&&this.base.togglePopup(e),this.applyState(e)}renderAdaptiveListContainer(){const{windowWidth:s=0}=this.state,{groupField:e,adaptiveTitle:t=this.props.label,adaptiveSubtitle:n}=this.props,r=p.getFilteredData(this.props),l=this.props.opened!==void 0?this.props.opened:this.state.opened;let{group:o}=this.state;o===void 0&&e!==void 0&&(o=p.getItemValue(r[0],e));const d={title:t||this.props.label,subTitle:n,expand:l,onClose:a=>this.toggleBtnClick(a),windowWidth:s,mobileFilter:this.renderMobileListFilter()};return g.createElement(ae.AdaptiveMode,{...d},g.createElement(oe.ActionSheetContent,null,g.createElement("div",{className:"k-list-container"},this.listContainerContent())))}renderListContainer(){const s=this.base,{dir:e,header:t,footer:n,groupField:r,size:l,list:o,virtual:d,groupStickyHeaderItemRender:a,unstyled:i}=this.props,c=p.getFilteredData(this.props),u=this.props.opened!==void 0?this.props.opened:this.state.opened,f=s.getPopupSettings(),y=f.width!==void 0?f.width:s.popupWidth,I=i&&i.uComboBox;let{group:x}=this.state;return x===void 0&&r!==void 0&&(x=p.getItemValue(c[0],r)),g.createElement(X,{width:y,popupSettings:{...f,anchor:f.anchor||this.element,show:u,popupClass:h.classNames(f.popupClass,h.uComboBox.listContainer({c:I,popup:!0}))},dir:e!==void 0?e:this.base.dirCalculated,itemsCount:[c.length]},g.createElement("div",{className:h.classNames(h.uComboBox.list({c:I,list:o,size:l,tableSize:l,virtual:d}))},t&&g.createElement("div",{className:h.classNames(h.uComboBox.listHeader({c:I}))},t),!o&&x&&c.length!==0&&g.createElement(K,{group:x,render:a}),this.renderList(),n&&g.createElement("div",{className:h.classNames(h.uComboBox.listFooter({c:I}),this.props.footerClassName)},n)),this.showLicenseWatermark&&g.createElement(h.WatermarkOverlay,{message:this.licenseMessage}))}renderList(){const s=this.base,e=N.provideLocalizationService(this),{textField:t,dataItemKey:n,listNoDataRender:r,itemRender:l,groupHeaderItemRender:o,virtual:d={skip:0,total:void 0},unstyled:a}=this.props,i=p.getFilteredData(this.props),c=s.getPopupSettings(),u=s.vs,f=d.skip,y=this.props.opened!==void 0?this.props.opened:this.state.opened,I=`translateY(${u.translate}px)`,x=y?this.getFocusedIndex(this.hasDuplicates):void 0,v=this.props.filter!==void 0?this.props.filter:this.state.text,m=p.getItemValue(this.value,t),C=p.isPresent(v)&&v!==m?null:this.value,D=this.props.list||Z,B=a&&a.uComboBox;return g.createElement(D,{id:s.listBoxId,virtual:!!d,show:y,data:i,focusedIndex:x,value:C,textField:t,valueField:n,groupField:this.props.groupField,isMultiColumn:this.props.isMultiColumn,optionsGuid:s.guid,hasDuplicates:this.hasDuplicates,ariaLabel:e.toLanguageString(S.listAriaLabel,S.messages[S.listAriaLabel]),listRef:k=>{u.list=this.base.list=k,this.itemHeight=0},wrapperStyle:this.mobileMode?{}:{maxHeight:c.height},wrapperCssClass:h.classNames(h.uComboBox.listContent({c:B,virtual:d})),listStyle:u.enabled?{transform:I}:void 0,key:"listkey",skip:f,onClick:this.handleItemClick,itemRender:l,groupHeaderItemRender:o,noDataRender:r,onMouseDown:k=>k.preventDefault(),onScroll:this.onScroll,wrapperRef:u.scrollerRef,scroller:this.base.renderScrollElement(),ariaSetSize:d.total})}renderSearchBar(s,e,t){const{tabIndex:n,accessKey:r,disabled:l,title:o,ariaLabelledBy:d,ariaDescribedBy:a,dataItemKey:i,virtual:c={skip:0},unstyled:u,inputAttributes:f}=this.props;p.getFilteredData(this.props);const y=this.props.opened!==void 0?this.props.opened:this.state.opened,I=y?this.getFocusedIndex(this.hasDuplicates):-1;return this._suggested&&!p.areSame(this._valueOnDidUpdate,this.value,i)&&(this._suggested=""),g.createElement(Q,{id:e,readOnly:y&&this.mobileMode,placeholder:t,tabIndex:n,accessKey:r,title:o,value:s+this._suggested,suggestedText:this._suggested,ref:x=>{this._input=x&&x.input},onClick:this.onInputClick,onKeyDown:this.onInputKeyDown,onChange:this.inputOnChange,onFocus:this.base.handleFocus,onBlur:this.handleBlur,disabled:l,expanded:y,owns:this.base.listBoxId,activedescendant:y&&I>=0?`k-${this.base.guid}-item-${I+c.skip+1}`:void 0,role:"combobox",ariaLabelledBy:d,ariaLabel:this.props.ariaLabel,ariaDescribedBy:a,ariaRequired:this.required,render:this.props.valueRender,ariaControls:y?this.base.listBoxId:void 0,unstyled:u,inputAttributes:f})}clearValue(){const s=this.base.initState();this._suggested="",this.navigationIndex=void 0,this.base.filterChanged("",s),this.props.filter===void 0&&this.state.text!==void 0&&(s.data.text=void 0),this.triggerOnChange(null,s);const e=this.props.opened!==void 0?this.props.opened:this.state.opened,t=this.mobileMode;e&&!t&&this.base.togglePopup(s),this.applyState(s)}triggerOnChange(s,e){const t=this.value;!this.hasDuplicates&&(!p.isPresent(t)&&!p.isPresent(s)||p.areSame(t,s,this.props.dataItemKey))||(this.props.value===void 0&&(e.data.value=s),this._valueDuringOnChange=s,e.events.push({type:"onChange"}))}getFocusedIndex(s){const e=this.value,{textField:t,dataItemKey:n,virtual:r={skip:0},focusedItemIndex:l=p.itemIndexStartsWith,skipDisabledItems:o}=this.props,d=p.getFilteredData(this.props),a=this.props.filter?this.props.filter:this.state.text;return s&&this.navigationIndex!==void 0?this.navigationIndex:p.isPresent(e)&&a===void 0?d.findIndex(i=>p.areSame(i,e,n)):a?l(d,a,t):o&&t&&!a&&r.skip===0?d.findIndex(i=>!i.disabled):r.skip===0?0:-1}suggestValue(s){const{data:e,textField:t}=this.props;this._suggested=p.suggestValue(s,e,t)}applyState(s){this.base.applyState(s),this._valueDuringOnChange=void 0}calculateMedia(s){for(const e of s)this.setState({windowWidth:e.target.clientWidth})}};F.displayName="ComboBox",F.propTypes={...T.propTypes,size:b.oneOf(["small","medium","large"]),rounded:b.oneOf(["small","medium","large","full","none"]),fillMode:b.oneOf(["solid","flat","outline"]),dataItemKey:b.string,groupField:b.string,isMultiColumn:b.bool,suggest:b.bool,placeholder:b.string,title:b.string,allowCustom:b.bool,ignoreCase:b.bool,clearButton:b.bool,iconClassName:b.string,svgIcon:h.svgIconPropType,validationMessage:b.string,required:b.bool,id:b.string,ariaLabelledBy:b.string,ariaLabel:b.string,ariaDescribedBy:b.string,list:b.any,valueRender:b.func,skipDisabledItems:b.bool,inputAttributes:b.object},F.defaultProps={...T.defaultProps,size:void 0,rounded:void 0,fillMode:void 0,allowCustom:!1,ignoreCase:!1,clearButton:!0,required:!1,isMultiColumn:!1,skipDisabledItems:!0,prefix:void 0,suffix:void 0};let V=F;const q=h.createPropsContext(),A=h.withIdHOC(h.withPropsContext(q,h.withUnstyledHOC(h.withAdaptiveModeContext(V))));A.displayName="KendoReactComboBox";exports.ComboBox=A;exports.ComboBoxPropsContext=q;exports.ComboBoxWithoutContext=V;
|
package/ComboBox/ComboBox.mjs
CHANGED
|
@@ -214,7 +214,9 @@ const Dt = "Please enter a valid value!", E = class E extends c.Component {
|
|
|
214
214
|
this.props.filter === void 0 && (e.data.text = l), this.state.focusedItem !== void 0 && (e.data.focusedItem = void 0), n ? this.scrollToFocused = !0 : this.base.togglePopup(e), this.base.filterChanged(l, e), this.applyState(e), this.setState({ group: void 0 });
|
|
215
215
|
}, this.clearButtonClick = (t) => {
|
|
216
216
|
const e = this.base.initState();
|
|
217
|
-
e.syntheticEvent = t, t.stopPropagation(), this.clearValue()
|
|
217
|
+
e.syntheticEvent = t, t.stopPropagation(), this.clearValue(), this._skipFocus = !0, this.focus(), setTimeout(() => {
|
|
218
|
+
this._skipFocus = !1;
|
|
219
|
+
}, 300);
|
|
218
220
|
}, this.clearValueOnEnterOrEsc = (t) => {
|
|
219
221
|
const e = this.base.initState();
|
|
220
222
|
e.syntheticEvent = t, t.stopPropagation(), this.clearValue();
|
|
@@ -315,8 +317,8 @@ const Dt = "Please enter a valid value!", E = class E extends c.Component {
|
|
|
315
317
|
if (d && n ? this.base.scrollToVirtualItem(n, v) : d && !n ? (this.onPopupOpened(), o && o.length !== 0 && this.base.resetGroupStickyHeader(o[0][r], this), this.base.scrollToItem(v)) : (this.hasDuplicates || a && i && h && g) && this.base.scrollToItem(v), a && i && this.scrollToFocused) {
|
|
316
318
|
const u = (b = this.props.filter ? this.props.filter : this.state.text) != null ? b : "";
|
|
317
319
|
if (u) {
|
|
318
|
-
const { focusedItemIndex: C = N } = this.props,
|
|
319
|
-
this.base.scrollToItem(
|
|
320
|
+
const { focusedItemIndex: C = N } = this.props, T = C(o, u, l);
|
|
321
|
+
this.base.scrollToItem(T);
|
|
320
322
|
} else
|
|
321
323
|
this.base.scrollToItem(0);
|
|
322
324
|
}
|
|
@@ -365,8 +367,8 @@ const Dt = "Please enter a valid value!", E = class E extends c.Component {
|
|
|
365
367
|
opened: g = this.state.opened,
|
|
366
368
|
placeholder: u,
|
|
367
369
|
svgIcon: C,
|
|
368
|
-
unstyled:
|
|
369
|
-
} = this.props,
|
|
370
|
+
unstyled: T
|
|
371
|
+
} = this.props, O = !this.validityStyles || this.validity.valid, M = this.props.filter !== void 0 ? this.props.filter : this.state.text, J = k(this.value, p), B = D(M) ? M : J, Q = l && (!!B || D(this.value)), V = this.base.vs, z = this.props.id || this._inputId, _ = T && T.uComboBox;
|
|
370
372
|
V.enabled = m !== void 0, m !== void 0 && (V.skip = m.skip, V.total = m.total, V.pageSize = m.pageSize);
|
|
371
373
|
const [X, Z] = Y(this.props.prefix || c.Fragment), [tt, et] = Y(this.props.suffix || c.Fragment), A = /* @__PURE__ */ c.createElement(c.Fragment, null, /* @__PURE__ */ c.createElement(
|
|
372
374
|
"span",
|
|
@@ -378,7 +380,7 @@ const Dt = "Please enter a valid value!", E = class E extends c.Component {
|
|
|
378
380
|
rounded: y,
|
|
379
381
|
fillMode: v,
|
|
380
382
|
disabled: r,
|
|
381
|
-
invalid: !
|
|
383
|
+
invalid: !O,
|
|
382
384
|
loading: d,
|
|
383
385
|
required: this.required
|
|
384
386
|
}),
|
|
@@ -424,11 +426,11 @@ const Dt = "Please enter a valid value!", E = class E extends c.Component {
|
|
|
424
426
|
label: o,
|
|
425
427
|
editorId: z,
|
|
426
428
|
editorValue: B,
|
|
427
|
-
editorValid:
|
|
429
|
+
editorValid: O,
|
|
428
430
|
editorDisabled: r,
|
|
429
431
|
style: { width: i ? i.width : void 0 },
|
|
430
432
|
children: A,
|
|
431
|
-
unstyled:
|
|
433
|
+
unstyled: T
|
|
432
434
|
}
|
|
433
435
|
) : A;
|
|
434
436
|
}
|
|
@@ -556,9 +558,9 @@ const Dt = "Please enter a valid value!", E = class E extends c.Component {
|
|
|
556
558
|
groupHeaderItemRender: o,
|
|
557
559
|
virtual: p = { skip: 0, total: void 0 },
|
|
558
560
|
unstyled: a
|
|
559
|
-
} = this.props, i = I(this.props), d = s.getPopupSettings(), h = s.vs, m = p.skip, b = this.props.opened !== void 0 ? this.props.opened : this.state.opened, y = `translateY(${h.translate}px)`, v = b ? this.getFocusedIndex(this.hasDuplicates) : void 0, g = this.props.filter !== void 0 ? this.props.filter : this.state.text, u = k(this.value, e), C = D(g) && g !== u ? null : this.value,
|
|
561
|
+
} = this.props, i = I(this.props), d = s.getPopupSettings(), h = s.vs, m = p.skip, b = this.props.opened !== void 0 ? this.props.opened : this.state.opened, y = `translateY(${h.translate}px)`, v = b ? this.getFocusedIndex(this.hasDuplicates) : void 0, g = this.props.filter !== void 0 ? this.props.filter : this.state.text, u = k(this.value, e), C = D(g) && g !== u ? null : this.value, T = this.props.list || xt, O = a && a.uComboBox;
|
|
560
562
|
return /* @__PURE__ */ c.createElement(
|
|
561
|
-
|
|
563
|
+
T,
|
|
562
564
|
{
|
|
563
565
|
id: s.listBoxId,
|
|
564
566
|
virtual: !!p,
|
|
@@ -573,13 +575,13 @@ const Dt = "Please enter a valid value!", E = class E extends c.Component {
|
|
|
573
575
|
optionsGuid: s.guid,
|
|
574
576
|
hasDuplicates: this.hasDuplicates,
|
|
575
577
|
ariaLabel: t.toLanguageString(j, R[j]),
|
|
576
|
-
listRef: (
|
|
577
|
-
h.list = this.base.list =
|
|
578
|
+
listRef: (M) => {
|
|
579
|
+
h.list = this.base.list = M, this.itemHeight = 0;
|
|
578
580
|
},
|
|
579
581
|
wrapperStyle: this.mobileMode ? {} : { maxHeight: d.height },
|
|
580
582
|
wrapperCssClass: S(
|
|
581
583
|
F.listContent({
|
|
582
|
-
c:
|
|
584
|
+
c: O,
|
|
583
585
|
virtual: p
|
|
584
586
|
})
|
|
585
587
|
),
|
|
@@ -590,7 +592,7 @@ const Dt = "Please enter a valid value!", E = class E extends c.Component {
|
|
|
590
592
|
itemRender: l,
|
|
591
593
|
groupHeaderItemRender: o,
|
|
592
594
|
noDataRender: r,
|
|
593
|
-
onMouseDown: (
|
|
595
|
+
onMouseDown: (M) => M.preventDefault(),
|
|
594
596
|
onScroll: this.onScroll,
|
|
595
597
|
wrapperRef: h.scrollerRef,
|
|
596
598
|
scroller: this.base.renderScrollElement(),
|
|
@@ -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 Gt=require("react"),L=require("prop-types"),o=require("@progress/kendo-react-common"),jt=require("@progress/kendo-react-labels"),$t=require("@progress/kendo-svg-icons"),Rt=require("../common/ListContainer.js"),Yt=require("../common/ListFilter.js"),rt=require("../common/GroupStickyHeader.js"),Jt=require("../common/ListDefaultItem.js"),Qt=require("../common/List.js"),st=require("../common/DropDownBase.js"),d=require("../common/utils.js"),ot=require("../package-metadata.js"),Xt=require("@progress/kendo-react-buttons"),Zt=require("@progress/kendo-react-intl"),P=require("../messages/index.js"),en=require("@progress/kendo-react-layout"),tn=require("../common/AdaptiveMode.js");function nn(T){const Y=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(T){for(const q in T)if(q!=="default"){const oe=Object.getOwnPropertyDescriptor(T,q);Object.defineProperty(Y,q,oe.get?oe:{enumerable:!0,get:()=>T[q]})}}return Y.default=T,Object.freeze(Y)}const a=nn(Gt),rn="Please select a value from the list!",fe=a.forwardRef((T,Y)=>{var et;let q=!1;const oe=o.getLicenseMessage(ot.packageMetadata),n=o.usePropsContext(at,T),{delay:it=N.delay,tabIndex:lt=N.tabIndex,ignoreCase:J=N.ignoreCase,size:z=N.size,rounded:Me=N.rounded,fillMode:ve=N.fillMode}=n;if(n.filterable||n.virtual){const e=[];n.filterable&&e.push("filterable"),n.virtual&&e.push("virtualization"),q=!o.validatePackage(ot.packageMetadata,{component:"DropDownList",features:e})}const E=o.useUnstyled(),ye=o.useId(n.id),De=()=>{var e;if(o.canUseDOM)return((e=B.current)==null?void 0:e.ownerDocument)||window.document},dt=()=>{var e,r;(e=t==null?void 0:t.current)!=null&&e.wrapper&&((r=t==null?void 0:t.current)==null||r.wrapper.focus({preventScroll:!0}))},k=()=>{let e;return H.current!==void 0&&H.current!==null?e=H.current:n.value!==void 0?e=n.value:f.value!==void 0&&f.value!==null?e=f.value:n.defaultValue!==void 0&&n.defaultValue!==null&&(e=n.defaultValue),!d.isPresent(e)&&n.defaultItem!==void 0&&n.defaultItem!==null&&(e=n.defaultItem),e},ct=()=>{const{dataItemKey:e}=n,r=d.getFilteredData(n),s=k();return r.findIndex(c=>d.areSame(c,s,e))},Ie=()=>n.required!==void 0?n.required:N.required,he=()=>{const e=n.validationMessage!==void 0,r=k(),s=!Ie()||r!==null&&r!==""&&r!==void 0,c=n.valid!==void 0?n.valid:s;return{customError:e,valid:c,valueMissing:r===null}},ut=()=>n.validityStyles!==void 0?n.validityStyles:N.validityStyles,se=e=>{ae.current=!0,e.focus(),window.setTimeout(()=>ae.current=!1,30)},we=()=>{X.current&&se(X.current),n.adaptive&&setTimeout(()=>{X.current&&se(X.current)},300)},pt=a.useCallback(e=>{for(const r of e)Nt(r.target.clientWidth)},[]),Oe=()=>{var e;(e=ke.current)!=null&&e.setCustomValidity&&ke.current.setCustomValidity(he().valid?"":n.validationMessage||rn)},A=(e,r)=>{const s=k();d.areSame(s,e,n.dataItemKey)||(n.value===void 0&&(r.data.value=e),t.current.updateComponentArgs({value:e}),H.current=e,r.events.push({type:"onChange"}))},K=e=>{var r;(r=t==null?void 0:t.current)==null||r.applyState(e),H.current=void 0},Q=(e,r)=>{var m;const{virtual:s,dataItemKey:c,defaultItem:l}=n,p=d.getFilteredData(n),g=s?s.skip:0,v=k(),u=e===-1&&l!==void 0?l:p[e-g],y=!d.areSame(u,v,c);A(u,r),y&&((m=t==null?void 0:t.current)==null||m.triggerPageChangeCornerItems(u,r))},V=(e,r,s)=>{var C,D;const{defaultItem:c,dataItemKey:l,virtual:p={skip:0,total:0,pageSize:0}}=n,g=k(),v=d.getFilteredData(n),u=(C=t==null?void 0:t.current)==null?void 0:C.vs,y=v.findIndex(I=>d.areSame(I,g,l)),m=(D=t==null?void 0:t.current)==null?void 0:D.navigation.navigate({current:p.skip+y,max:(u!=null&&u.enabled?p.total:v.length)-1,min:c!==void 0?-1:0,keyCode:r,skipItems:s||void 0});m!==void 0&&Q(m,e),K(e)},mt=e=>{B.current=e,t.current.wrapper=e},gt=e=>a.createElement("select",{name:n.name,ref:r=>{ke.current=r},tabIndex:-1,"aria-hidden":!0,title:n.label,style:{opacity:0,width:1,border:0,zIndex:-1,position:"absolute",left:"50%"}},a.createElement("option",{value:n.valueMap?n.valueMap.call(void 0,e):e})),Se=()=>{const{textField:e,dataItemKey:r,virtual:s={skip:0},focusedItemIndex:c=d.itemIndexStartsWith,filterable:l,skipDisabledItems:p=!0}=n,g=k(),v=d.getFilteredData(n),u=n.filter?n.filter:f.text;return p&&e&&!u&&!g?v.findIndex(y=>!y.disabled):d.isPresent(g)&&u===void 0||l&&u===""?v.findIndex(y=>d.areSame(y,g,r)):u?be.current?c(v,u,e):v.findIndex(y=>d.areSame(y,g,r)):s.skip===0?0:-1},Te=(e,r)=>r!==void 0&&r!==-1&&e&&e.length>0&&e[r].disabled,xe=()=>{const e=d.getFilteredData(n),r=t.current.initState(),s=Se();Te(e,s)&&(A(null,r),K(r))},Ce=e=>{if(e.isPropagationStopped())return;const r=t.current.initState();r.syntheticEvent=e,f.focused||(r.data.focused=!0),xe(),t.current.togglePopup(r),K(r)},qe=e=>{var O,me,G,ge,R,tt,nt;e&&e.target instanceof Element&&e.target.nodeName==="INPUT"&&e.stopPropagation&&e.stopPropagation();const{filterable:r,disabled:s,defaultItem:c,leftRightKeysNavigation:l=!0,virtual:p={skip:0,total:0,pageSize:0},dataItemKey:g,groupField:v="",textField:u,skipDisabledItems:y=!0}=n,m=d.getFilteredData(n),C=k(),D=m.findIndex(w=>d.areSame(w,C,g)),I=n.opened!==void 0?n.opened:f.opened,i=e.keyCode,F=i===o.Keys.home||i===o.Keys.end,b=i===o.Keys.up||i===o.Keys.down,$=!I&&(e.altKey&&i===o.Keys.down||i===o.Keys.enter||i===o.Keys.space),re=I&&(e.altKey&&i===o.Keys.up||i===o.Keys.esc),ue=l&&(i===o.Keys.left||i===o.Keys.right),pe=b||ue&&!r||F,h=t.current.initState();if(h.syntheticEvent=e,!s){if(F&&((O=t==null?void 0:t.current)!=null&&O.vs.enabled))i===o.Keys.home?p.skip!==0?((me=t==null?void 0:t.current)==null||me.triggerOnPageChange(h,0,p.pageSize),W.current=!0):A(m[0],h):p.skip<p.total-p.pageSize?((G=t==null?void 0:t.current)==null||G.triggerOnPageChange(h,p.total-p.pageSize,p.pageSize),W.current=!0):A(m[m.length-1],h);else if(I&&i===o.Keys.pageUp)e.preventDefault(),(ge=t==null?void 0:t.current)==null||ge.scrollPopupByPageSize(-1);else if(I&&i===o.Keys.pageDown)e.preventDefault(),(R=t==null?void 0:t.current)==null||R.scrollPopupByPageSize(1);else if(I&&i===o.Keys.enter){const w=Se();Te(m,w)?(A(null,h),K(h)):Q(w,h),(tt=t==null?void 0:t.current)==null||tt.togglePopup(h),e.preventDefault()}else if($||re)re&&xe(),(nt=t==null?void 0:t.current)==null||nt.togglePopup(h),e.preventDefault();else if(pe){if(be.current=!1,v!==""&&u)if(!y&&I)V(h,i);else{let w;if(i===o.Keys.down||i===o.Keys.right){const S=m.slice(D+1).find(x=>!x.disabled);w=S&&m.indexOf(S)}else if(i===o.Keys.up||i===o.Keys.left){let S;if(D===0&&c)w=-1;else if(D===-1)S=m,w=m.findIndex(x=>!x.disabled);else{S=m.slice(0,D);let x=S.pop();for(;x&&x.disabled;)x=S.pop();w=x&&m.indexOf(x)}}if(w!==void 0){const S=w-D;V(h,i,S)}else w===void 0&&D===m.length-1&&V(h,i)}else if(!y&&I||F)V(h,i);else if(u){let w;if(i===o.Keys.down||i===o.Keys.right){const S=m.slice(D+1).find(x=>!x.disabled);w=S&&m.indexOf(S)}else if(i===o.Keys.up||i===o.Keys.left){let S;if(D===0&&c)w=-1;else if(D===-1)S=m,w=m.findIndex(x=>!x.disabled);else{S=m.slice(0,D);let x=S.pop();for(;x&&x.disabled;)x=S.pop();w=x&&m.indexOf(x)}}if(w!==void 0){const S=w-D;V(h,i,S)}else w===void 0&&D===m.length-1&&V(h,i)}else V(h,i);e.preventDefault()}K(h)}},ft=e=>{const r=t.current.initState();r.syntheticEvent=e.syntheticEvent,n.filter===void 0&&(r.data.text=e.target.value),t.current.filterChanged(e.target.value,r),be.current=!0,K(r),ee({group:void 0,text:String(e.target.value)})},ze=e=>{const r=n.filter!==void 0?n.filter:f.text;return n.filterable&&a.createElement(Yt,{value:r,ref:s=>{X.current=s&&s.element},onChange:ft,onKeyDown:qe,size:e?"large":z,rounded:Me,fillMode:ve,renderListFilterWrapper:!0,placeholder:Fe.toLanguageString(P.dropDownListAdaptiveFilterPlaceholder,P.messages[P.dropDownListAdaptiveFilterPlaceholder])})},vt=e=>{var s;const r=t.current.initState();r.syntheticEvent=e,(s=t==null?void 0:t.current)==null||s.togglePopup(r),A(n.defaultItem,r),K(r)},yt=()=>{const{textField:e,defaultItem:r,dataItemKey:s}=n,c=k();return r!==void 0&&a.createElement(Jt,{defaultItem:r,textField:e,selected:d.areSame(c,r,s),key:"defaultitemkey",onClick:vt})},Dt=(e,r)=>{var s;(s=t==null?void 0:t.current)==null||s.handleItemClick(e,r),H.current=void 0},It=e=>{const{vs:r,list:s}=t.current;r.scrollHandler(e);const{groupField:c}=n;let l=d.getFilteredData(n);if(!(!c||!l.length)&&c){const p=Be.current=Be.current||(r.enabled?r.itemHeight:s?s.children[0].offsetHeight:0),v=e.target.scrollTop-r.skip*p;l=t.current.getGroupedDataModernMode(l,c);let u=l[0][c];for(let y=1;y<l.length&&!(p*y>v);y++)l[y]&&l[y][c]&&(u=l[y][c]);u!==f.group&&ee({group:u})}},Ae=()=>{var i;const{textField:e,dataItemKey:r,virtual:s={skip:0,total:void 0},groupHeaderItemRender:c,listNoDataRender:l,itemRender:p}=n,g=d.getFilteredData(n),v=E&&E.uDropDownList,u=t.current.vs,y=s.skip,m=n.opened!==void 0?n.opened:f.opened,C=t.current.getPopupSettings(),D=`translateY(${u.translate}px)`,I=k();return a.createElement(Qt,{id:Ue,show:m,data:g.slice(),focusedIndex:Se(),value:I,textField:e,valueField:r,optionsGuid:Ge,groupField:n.groupField,ariaLabel:Fe.toLanguageString(P.listAriaLabel,P.messages[P.listAriaLabel]),listRef:F=>{u.list=t.current.list=F},wrapperStyle:{maxHeight:U?void 0:C.height},wrapperCssClass:o.classNames(o.uDropDownList.listContent({c:v})),listStyle:u.enabled?{transform:D}:void 0,key:"listkey",skip:y,onClick:Dt,itemRender:p,groupHeaderItemRender:c,noDataRender:l,onScroll:It,wrapperRef:u.scrollerRef,scroller:(i=t==null?void 0:t.current)==null?void 0:i.renderScrollElement(),ariaSetSize:s.total})},ht=()=>{const{groupField:e}=n,r=d.getFilteredData(n),s=n.opened!==void 0?n.opened:f.opened,c=E&&E.uDropDownList,l={title:n.adaptiveTitle||n.label,subTitle:n.adaptiveSubtitle,expand:s,onClose:g=>Ce(g),windowWidth:Ee,mobileFilter:ze(!0)};let{group:p}=f;return p===void 0&&e!==void 0&&(p=d.getItemValue(r[0],e)),a.createElement(tn.AdaptiveMode,{...l},a.createElement(en.ActionSheetContent,null,a.createElement("div",{className:o.classNames(o.uDropDownList.listContainer({c,popup:!1}))},Ct())))},wt=()=>{f.focused&&window.setTimeout(()=>{f.focused&&t.current.wrapper&&se(t.current.wrapper)})},St=e=>{"onMouseDownOutside"in(n.popupSettings||{})&&n.popupSettings.onMouseDownOutside.call(void 0,e)},xt=()=>{const{header:e,footer:r,dir:s,groupField:c,groupStickyHeaderItemRender:l,list:p}=n,g=d.getFilteredData(n),v=t.current,u=v.getPopupSettings(),y=n.opened!==void 0?n.opened:f.opened,m=u.width!==void 0?u.width:v.popupWidth,C=E&&E.uDropDownList,D={dir:s!==void 0?s:v.dirCalculated,width:m,popupSettings:{...u,popupClass:o.classNames(u.popupClass,o.uDropDownList.listContainer({c:C,popup:!0})),anchor:u.anchor||B.current,show:y,onOpen:we,onClose:wt,onMouseDownOutside:St},itemsCount:[g.length]};let{group:I}=f;return I===void 0&&c!==void 0&&(I=d.getItemValue(g[0],c)),a.createElement(Rt,{...D},ze(!1),e&&a.createElement("div",{className:o.classNames(o.uDropDownList.listHeader({c:C}))},e),a.createElement("div",{className:o.classNames(o.uDropDownList.list({c:C,size:z,virtual:t.current.vs.enabled}))},yt(),!p&&I&&g.length!==0&&a.createElement(rt,{group:I,render:l}),Ae()),r&&a.createElement("div",{className:o.classNames(o.uDropDownList.listFooter({c:C}))},r),q&&a.createElement(o.WatermarkOverlay,{message:oe}))},Ct=()=>{const{header:e,footer:r,groupStickyHeaderItemRender:s,groupField:c,list:l}=n,p=d.getFilteredData(n),g=E&&E.uDropDownList;let{group:v}=f;return v===void 0&&c!==void 0&&(v=d.getItemValue(p[0],c)),a.createElement(a.Fragment,null,e&&a.createElement("div",{className:o.classNames(o.uDropDownList.listHeader({c:g}))},e),a.createElement("div",{className:o.classNames("k-list",{[`k-list-${U?"lg":o.sizeMap[z]||z}`]:U||z})},!l&&v&&p.length!==0&&a.createElement(rt,{group:v,render:s}),Ae()),r&&a.createElement("div",{className:"k-list-footer"},r))},Lt=e=>{const{dataItemKey:r}=n,s=d.getFilteredData(n),c=k();let l=s.map((b,$)=>({item:b,itemIndex:$}));const p=j.current.word,g=j.current.last,v=d.sameCharsOnly(p,g);let u=l.length,y=Math.max(0,s.findIndex(b=>d.areSame(b,c,r))),m;n.defaultItem&&(m={item:n.defaultItem,itemIndex:-1},u+=1,y+=1),y+=v?1:0,l=d.shuffleData(l,y,m);let C,D,I,i=0;const{textField:F}=n;for(;i<u;){if(C=d.getItemValue(l[i].item,F),D=v&&d.matchText(C,g,J),I=d.matchText(C,p,J),D||I){i=l[i].itemIndex;break}i++}if(i!==u){const b=t.current.initState();b.syntheticEvent=e,Q(i,b),K(b),H.current=void 0}},kt=e=>{clearTimeout(Ve.current),n.filterable||(Ve.current=window.setTimeout(()=>j.current.word="",it),Lt(e))},bt=e=>{ae.current||t.current.handleFocus(e)},Kt=e=>{if(ae.current||!f.focused)return;const r=n.opened!==void 0?n.opened:f.opened,s=t.current.initState();s.syntheticEvent=e,s.data.focused=!1,s.events.push({type:"onBlur"}),r&&xe(),r&&!U&&t.current.togglePopup(s),K(s)},Et=e=>{if(n.filterable||e.which===0||e.keyCode===o.Keys.enter)return;let r=String.fromCharCode(e.charCode||e.keyCode);J&&(r=r.toLowerCase()),r===" "&&e.preventDefault(),j.current={word:j.current.word+r,last:j.current.last+r},kt(e)},Ft=()=>{const e=t.current.initState();e.data.opened=f.opened,t.current.togglePopup(e),K(e)},Le=a.useRef(null),B=a.useRef(null),ke=a.useRef(null),X=a.useRef(null);a.useImperativeHandle(Le,()=>({get element(){return B.current},get index(){return ct()},get name(){return n.name},get validity(){return he()},get value(){return k()},get focused(){return f.focused},get opened(){return f.opened},focus:dt,props:n,togglePopup:Ft})),a.useImperativeHandle(Y,()=>Le.current),o.useWebMcpRegister("dropdownlist",Le,n,n.webMcp);const Ve=a.useRef(null),j=a.useRef({word:"",last:""}),ae=a.useRef(!1),H=a.useRef(null),W=a.useRef(!1),be=a.useRef(!1),_=a.useRef({}),Ke=a.useRef({}),t=a.useRef(new st({props:n,setState:()=>{},state:{},forceUpdate:()=>{},element:null,value:null,handleItemSelect:()=>{}})),Be=a.useRef(0),Z=a.useRef(null),[f,Pt]=a.useState({}),[Ee,Nt]=a.useState(),[,He]=a.useReducer(e=>e,!0),Fe=Zt.useLocalization(),We=n.name||n.id,Mt=a.useCallback(e=>{if(e==null||!t.current)return;const r=d.getFilteredData(n),{textField:s}=n,c=String(e),l=d.getItemIndexByText(r,c,s,!1,J),p=l!==-1?r[l]:void 0;if(p!==void 0){const g=t.current.initState();g.syntheticEvent={target:B.current},A(p,g),K(g)}},[n,J]);o.useKendoPaste(B,{fieldName:We,onValueChange:Mt,enabled:!!We});const ee=e=>{Pt({...f,...e})};a.useEffect(()=>{t.current.updateComponentArgs({props:n,setState:ee,state:f,forceUpdate:He,element:B.current,handleItemSelect:Q,value:k()})},[ee,f,He,Q,k]),a.useEffect(()=>{var y,m,C,D,I,i,F,b,$,re,ue,pe,h;const{dataItemKey:e,virtual:r,groupField:s="",textField:c}=n,l=d.getFilteredData(n),p=_.current.virtual?_.current.virtual.total:0,g=n.opened!==void 0?n.opened:f.opened,v=_.current.opened!==void 0?_.current.opened:Ke.current.opened,u=!v&&g;if((y=t==null?void 0:t.current)==null||y.didUpdate(),(m=t==null?void 0:t.current)!=null&&m.getPopupSettings().animate||u&&we(),r&&r.total!==p)(C=t==null?void 0:t.current)==null||C.vs.calcScrollElementHeight(),(D=t==null?void 0:t.current)==null||D.vs.reset();else{const O=k(),me=_.current.value!==void 0?_.current.value:Ke.current.value;let G=l.findIndex(R=>d.areSame(R,O,e));s!==""&&O&&c&&(G=(i=(I=t==null?void 0:t.current)==null?void 0:I.getGroupedDataModernMode(l,s))==null?void 0:i.map(R=>R[c]).indexOf(O[c]));const ge=!d.areSame(me,O,e);u&&r?(F=t==null?void 0:t.current)==null||F.scrollToVirtualItem(r,G):u&&!r?(we(),l&&l.length!==0&&((b=t==null?void 0:t.current)==null||b.resetGroupStickyHeader(l[0][s],{setState:ee,group:f.group,state:f})),($=t==null?void 0:t.current)==null||$.scrollToItem(G)):g&&v&&O&&ge&&!W.current?(ue=t==null?void 0:t.current)==null||ue.scrollToItem(G,(re=t==null?void 0:t.current)==null?void 0:re.vs.enabled):g&&v&&W.current&&(W.current&&r&&r.skip===0?(pe=t==null?void 0:t.current)==null||pe.vs.reset():W.current&&r&&r.skip===r.total-r.pageSize&&((h=t==null?void 0:t.current)==null||h.vs.scrollToEnd()))}W.current=!1,Ke.current=f,_.current=n,Oe()}),a.useEffect(()=>{var e,r;return Z.current=o.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(pt.bind(void 0)),(e=t==null?void 0:t.current)==null||e.didMount(),Oe(),(r=De())!=null&&r.body&&Z.current&&Z.current.observe(De().body),()=>{var s;(s=De())!=null&&s.body&&Z.current&&Z.current.disconnect()}},[]);const _e=ye+"-accessibility-id",Ue=ye+"-listbox-id",Ge=ye+"-guid",Ot=Fe.toLanguageString(P.dropDownListArrowBtnAriaLabel,P.messages[P.dropDownListArrowBtnAriaLabel]),{style:ie,className:Tt,label:Pe,dir:qt,virtual:M,adaptive:on,dataItemKey:zt,disabled:le,loading:je,iconClassName:$e,svgIcon:At,valueRender:Re}=n,te=n.opened!==void 0?n.opened:f.opened,de=k(),Ne=d.getItemValue(de,n.textField),Ye=!ut()||he().valid,ce=t.current,Vt=ce.vs,ne=E&&E.uDropDownList;Vt.enabled=M!==void 0;const Je=o.useAdaptiveModeContext(),U=!!(Ee&&Je&&Ee<=Je.medium&&n.adaptive);M!==void 0&&(ce.vs.skip=M.skip,ce.vs.total=M.total,ce.vs.pageSize=M.pageSize);const Bt=d.getFilteredData(n),{focused:Ht}=f,Qe=Bt.findIndex(e=>d.areSame(e,de,zt)),Wt=(et=M==null?void 0:M.skip)!=null?et:0,_t=te&&Qe>=0?`k-${Ge}-item-${Qe+Wt+1}`:void 0,Xe=a.createElement("span",{id:_e,className:o.classNames(o.uDropDownList.inputInner({c:ne}))},Ne&&a.createElement("span",{className:o.classNames(o.uDropDownList.inputText({c:ne}))},Ne)),Ut=Re!==void 0?Re.call(void 0,Xe,de):Xe,Ze=a.createElement(a.Fragment,null,a.createElement("span",{ref:mt,className:o.classNames(o.uDropDownList.wrapper({c:ne,size:z,rounded:Me,fillMode:ve,focused:Ht,disabled:le,invalid:!Ye,loading:je,required:Ie()}),Tt),style:Pe?{...ie,width:void 0}:ie,dir:qt,onMouseDown:te?e=>{e.target.nodeName!=="INPUT"&&(se(t.current.wrapper),e.preventDefault())}:void 0,onFocus:U?e=>Ce(e):bt,onBlur:Kt,tabIndex:o.getTabIndex(lt,le),accessKey:n.accessKey,onKeyDown:qe,onKeyPress:Et,onClick:le?void 0:Ce,role:"combobox","aria-required":Ie()||void 0,"aria-disabled":le||void 0,"aria-haspopup":"listbox","aria-expanded":te||!1,"aria-activedescendant":_t,"aria-label":n.ariaLabel||n.label,"aria-labelledby":n.ariaLabelledBy,"aria-describedby":n.ariaDescribedBy||(te?_e:void 0),"aria-controls":te?Ue:void 0,id:n.id,title:n.title},Ut,je&&a.createElement(o.IconWrap,{className:o.classNames(o.uDropDownList.loadingIcon({c:ne})),name:"loading"}),a.createElement(Xt.Button,{tabIndex:-1,type:"button","aria-label":Ot,size:z,fillMode:ve,className:o.classNames(o.uDropDownList.inputButton({c:ne})),iconClass:$e,svgIcon:$e?void 0:At||$t.chevronDownIcon,onMouseDown:e=>f.focused&&e.preventDefault()}),gt(de),!U&&xt()),U&&ht());return Pe?a.createElement(jt.FloatingLabel,{label:Pe,editorValue:Ne,editorValid:Ye,editorDisabled:n.disabled,style:{width:ie?ie.width:void 0},children:Ze}):Ze});fe.propTypes={delay:L.number,ignoreCase:L.bool,iconClassName:L.string,svgIcon:o.svgIconPropType,defaultItem:L.any,valueRender:L.func,valueMap:L.func,validationMessage:L.string,required:L.bool,id:L.string,ariaLabelledBy:L.string,ariaDescribedBy:L.string,ariaLabel:L.string,leftRightKeysNavigation:L.bool,title:L.string,groupField:L.string,list:L.any,skipDisabledItems:L.bool};const N={delay:500,tabIndex:0,ignoreCase:!0,...st.defaultProps,required:!1,size:void 0,rounded:void 0,fillMode:void 0};fe.displayName="KendoReactDropDownList";const at=o.createPropsContext();fe.displayName="KendoReactDropDownList";exports.DropDownList=fe;exports.DropDownListPropsContext=at;exports.dropDownListDefaultProps=N;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $t=require("react"),L=require("prop-types"),o=require("@progress/kendo-react-common"),Rt=require("@progress/kendo-react-labels"),Yt=require("@progress/kendo-svg-icons"),Jt=require("../common/ListContainer.js"),Qt=require("../common/ListFilter.js"),ot=require("../common/GroupStickyHeader.js"),Xt=require("../common/ListDefaultItem.js"),Zt=require("../common/List.js"),at=require("../common/DropDownBase.js"),d=require("../common/utils.js"),st=require("../package-metadata.js"),en=require("@progress/kendo-react-buttons"),tn=require("@progress/kendo-react-intl"),M=require("../messages/index.js"),nn=require("@progress/kendo-react-layout"),rn=require("../common/AdaptiveMode.js");function on(q){const J=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(q){for(const z in q)if(z!=="default"){const ae=Object.getOwnPropertyDescriptor(q,z);Object.defineProperty(J,z,ae.get?ae:{enumerable:!0,get:()=>q[z]})}}return J.default=q,Object.freeze(J)}const a=on($t),sn="Please select a value from the list!",ve=a.forwardRef((q,J)=>{var nt;let z=!1;const ae=o.getLicenseMessage(st.packageMetadata),n=o.usePropsContext(it,q),{delay:lt=O.delay,tabIndex:dt=O.tabIndex,ignoreCase:Q=O.ignoreCase,size:A=O.size,rounded:Te=O.rounded,fillMode:ye=O.fillMode}=n;if(n.filterable||n.virtual){const e=[];n.filterable&&e.push("filterable"),n.virtual&&e.push("virtualization"),z=!o.validatePackage(st.packageMetadata,{component:"DropDownList",features:e})}const F=o.useUnstyled(),De=o.useId(n.id),he=()=>{var e;if(o.canUseDOM)return((e=N.current)==null?void 0:e.ownerDocument)||window.document},ct=()=>{var e,r;(e=t==null?void 0:t.current)!=null&&e.wrapper&&((r=t==null?void 0:t.current)==null||r.wrapper.focus({preventScroll:!0}))},k=()=>{let e;return H.current!==void 0&&H.current!==null?e=H.current:n.value!==void 0?e=n.value:v.value!==void 0&&v.value!==null?e=v.value:n.defaultValue!==void 0&&n.defaultValue!==null&&(e=n.defaultValue),!d.isPresent(e)&&n.defaultItem!==void 0&&n.defaultItem!==null&&(e=n.defaultItem),e},ut=()=>{const{dataItemKey:e}=n,r=d.getFilteredData(n),s=k();return r.findIndex(c=>d.areSame(c,s,e))},Ie=()=>n.required!==void 0?n.required:O.required,we=()=>{const e=n.validationMessage!==void 0,r=k(),s=!Ie()||r!==null&&r!==""&&r!==void 0,c=n.valid!==void 0?n.valid:s;return{customError:e,valid:c,valueMissing:r===null}},pt=()=>n.validityStyles!==void 0?n.validityStyles:O.validityStyles,ie=e=>{le.current=!0,e.focus(),window.setTimeout(()=>le.current=!1,30)},Se=()=>{Z.current&&ie(Z.current),n.adaptive&&setTimeout(()=>{Z.current&&ie(Z.current)},300)},mt=a.useCallback(e=>{for(const r of e)Mt(r.target.clientWidth)},[]),qe=()=>{var e;(e=be.current)!=null&&e.setCustomValidity&&be.current.setCustomValidity(we().valid?"":n.validationMessage||sn)},V=(e,r)=>{const s=k();d.areSame(s,e,n.dataItemKey)||(n.value===void 0&&(r.data.value=e),t.current.updateComponentArgs({value:e}),H.current=e,r.events.push({type:"onChange"}))},K=e=>{var r;(r=t==null?void 0:t.current)==null||r.applyState(e),H.current=void 0},X=(e,r)=>{var m;const{virtual:s,dataItemKey:c,defaultItem:l}=n,p=d.getFilteredData(n),f=s?s.skip:0,y=k(),u=e===-1&&l!==void 0?l:p[e-f],g=!d.areSame(u,y,c);V(u,r),g&&((m=t==null?void 0:t.current)==null||m.triggerPageChangeCornerItems(u,r))},B=(e,r,s)=>{var C,D;const{defaultItem:c,dataItemKey:l,virtual:p={skip:0,total:0,pageSize:0}}=n,f=k(),y=d.getFilteredData(n),u=(C=t==null?void 0:t.current)==null?void 0:C.vs,g=y.findIndex(h=>d.areSame(h,f,l)),m=(D=t==null?void 0:t.current)==null?void 0:D.navigation.navigate({current:p.skip+g,max:(u!=null&&u.enabled?p.total:y.length)-1,min:c!==void 0?-1:0,keyCode:r,skipItems:s||void 0});m!==void 0&&X(m,e),K(e)},gt=e=>{N.current=e,t.current.wrapper=e},ft=e=>a.createElement("select",{name:n.name,ref:r=>{be.current=r},tabIndex:-1,"aria-hidden":!0,title:n.label,style:{opacity:0,width:1,border:0,zIndex:-1,position:"absolute",left:"50%"}},a.createElement("option",{value:n.valueMap?n.valueMap.call(void 0,e):e})),xe=()=>{const{textField:e,dataItemKey:r,virtual:s={skip:0},focusedItemIndex:c=d.itemIndexStartsWith,filterable:l,skipDisabledItems:p=!0}=n,f=k(),y=d.getFilteredData(n),u=n.filter?n.filter:v.text;return p&&e&&!u&&!f?y.findIndex(g=>!g.disabled):d.isPresent(f)&&u===void 0||l&&u===""?y.findIndex(g=>d.areSame(g,f,r)):u?Ke.current?c(y,u,e):y.findIndex(g=>d.areSame(g,f,r)):s.skip===0?0:-1},ze=(e,r)=>r!==void 0&&r!==-1&&e&&e.length>0&&e[r].disabled,Ce=()=>{const e=d.getFilteredData(n),r=t.current.initState(),s=xe();ze(e,s)&&(V(null,r),K(r))},Le=e=>{if(e.isPropagationStopped())return;const r=t.current.initState();r.syntheticEvent=e,v.focused||(r.data.focused=!0),Ce(),t.current.togglePopup(r),K(r)},Ae=e=>{var se,E,G,j,fe,Y,rt;e&&e.target instanceof Element&&e.target.nodeName==="INPUT"&&e.stopPropagation&&e.stopPropagation();const{filterable:r,disabled:s,defaultItem:c,leftRightKeysNavigation:l=!0,virtual:p={skip:0,total:0,pageSize:0},dataItemKey:f,groupField:y="",textField:u,skipDisabledItems:g=!0}=n,m=d.getFilteredData(n),C=k(),D=m.findIndex(w=>d.areSame(w,C,f)),h=n.opened!==void 0?n.opened:v.opened,i=e.keyCode,P=i===o.Keys.home||i===o.Keys.end,b=i===o.Keys.up||i===o.Keys.down,R=!h&&(e.altKey&&i===o.Keys.down||i===o.Keys.enter||i===o.Keys.space),oe=h&&(e.altKey&&i===o.Keys.up||i===o.Keys.esc),me=l&&(i===o.Keys.left||i===o.Keys.right),ge=b||me&&!r||P,I=t.current.initState();if(I.syntheticEvent=e,!s){if(P&&((se=t==null?void 0:t.current)!=null&&se.vs.enabled))i===o.Keys.home?p.skip!==0?((E=t==null?void 0:t.current)==null||E.triggerOnPageChange(I,0,p.pageSize),W.current=!0):V(m[0],I):p.skip<p.total-p.pageSize?((G=t==null?void 0:t.current)==null||G.triggerOnPageChange(I,p.total-p.pageSize,p.pageSize),W.current=!0):V(m[m.length-1],I);else if(h&&i===o.Keys.pageUp)e.preventDefault(),(j=t==null?void 0:t.current)==null||j.scrollPopupByPageSize(-1);else if(h&&i===o.Keys.pageDown)e.preventDefault(),(fe=t==null?void 0:t.current)==null||fe.scrollPopupByPageSize(1);else if(h&&i===o.Keys.enter){const w=xe();ze(m,w)?(V(null,I),K(I)):X(w,I),(Y=t==null?void 0:t.current)==null||Y.togglePopup(I),e.preventDefault()}else if(R||oe)oe&&Ce(),(rt=t==null?void 0:t.current)==null||rt.togglePopup(I),e.preventDefault();else if(ge){if(Ke.current=!1,y!==""&&u)if(!g&&h)B(I,i);else{let w;if(i===o.Keys.down||i===o.Keys.right){const S=m.slice(D+1).find(x=>!x.disabled);w=S&&m.indexOf(S)}else if(i===o.Keys.up||i===o.Keys.left){let S;if(D===0&&c)w=-1;else if(D===-1)S=m,w=m.findIndex(x=>!x.disabled);else{S=m.slice(0,D);let x=S.pop();for(;x&&x.disabled;)x=S.pop();w=x&&m.indexOf(x)}}if(w!==void 0){const S=w-D;B(I,i,S)}else w===void 0&&D===m.length-1&&B(I,i)}else if(!g&&h||P)B(I,i);else if(u){let w;if(i===o.Keys.down||i===o.Keys.right){const S=m.slice(D+1).find(x=>!x.disabled);w=S&&m.indexOf(S)}else if(i===o.Keys.up||i===o.Keys.left){let S;if(D===0&&c)w=-1;else if(D===-1)S=m,w=m.findIndex(x=>!x.disabled);else{S=m.slice(0,D);let x=S.pop();for(;x&&x.disabled;)x=S.pop();w=x&&m.indexOf(x)}}if(w!==void 0){const S=w-D;B(I,i,S)}else w===void 0&&D===m.length-1&&B(I,i)}else B(I,i);e.preventDefault()}K(I)}},vt=e=>{const r=t.current.initState();r.syntheticEvent=e.syntheticEvent,n.filter===void 0&&(r.data.text=e.target.value),t.current.filterChanged(e.target.value,r),Ke.current=!0,K(r),te({group:void 0,text:String(e.target.value)})},Ve=e=>{const r=n.filter!==void 0?n.filter:v.text;return n.filterable&&a.createElement(Qt,{value:r,ref:s=>{Z.current=s&&s.element},onChange:vt,onKeyDown:Ae,size:e?"large":A,rounded:Te,fillMode:ye,renderListFilterWrapper:!0,placeholder:Ne.toLanguageString(M.dropDownListAdaptiveFilterPlaceholder,M.messages[M.dropDownListAdaptiveFilterPlaceholder])})},yt=e=>{var s;const r=t.current.initState();r.syntheticEvent=e,(s=t==null?void 0:t.current)==null||s.togglePopup(r),V(n.defaultItem,r),K(r)},Dt=()=>{const{textField:e,defaultItem:r,dataItemKey:s}=n,c=k();return r!==void 0&&a.createElement(Xt,{defaultItem:r,textField:e,selected:d.areSame(c,r,s),key:"defaultitemkey",onClick:yt})},ht=(e,r)=>{var s;(s=t==null?void 0:t.current)==null||s.handleItemClick(e,r),H.current=void 0},It=e=>{const{vs:r,list:s}=t.current;r.scrollHandler(e);const{groupField:c}=n;let l=d.getFilteredData(n);if(!(!c||!l.length)&&c){const p=We.current=We.current||(r.enabled?r.itemHeight:s?s.children[0].offsetHeight:0),y=e.target.scrollTop-r.skip*p;l=t.current.getGroupedDataModernMode(l,c);let u=l[0][c];for(let g=1;g<l.length&&!(p*g>y);g++)l[g]&&l[g][c]&&(u=l[g][c]);u!==v.group&&te({group:u})}},Be=()=>{var i;const{textField:e,dataItemKey:r,virtual:s={skip:0,total:void 0},groupHeaderItemRender:c,listNoDataRender:l,itemRender:p}=n,f=d.getFilteredData(n),y=F&&F.uDropDownList,u=t.current.vs,g=s.skip,m=n.opened!==void 0?n.opened:v.opened,C=t.current.getPopupSettings(),D=`translateY(${u.translate}px)`,h=k();return a.createElement(Zt,{id:je,show:m,data:f.slice(),focusedIndex:xe(),value:h,textField:e,valueField:r,optionsGuid:$e,groupField:n.groupField,ariaLabel:Ne.toLanguageString(M.listAriaLabel,M.messages[M.listAriaLabel]),listRef:P=>{u.list=t.current.list=P},wrapperStyle:{maxHeight:U?void 0:C.height},wrapperCssClass:o.classNames(o.uDropDownList.listContent({c:y})),listStyle:u.enabled?{transform:D}:void 0,key:"listkey",skip:g,onClick:ht,itemRender:p,groupHeaderItemRender:c,noDataRender:l,onScroll:It,wrapperRef:u.scrollerRef,scroller:(i=t==null?void 0:t.current)==null?void 0:i.renderScrollElement(),ariaSetSize:s.total})},wt=()=>{const{groupField:e}=n,r=d.getFilteredData(n),s=n.opened!==void 0?n.opened:v.opened,c=F&&F.uDropDownList,l={title:n.adaptiveTitle||n.label,subTitle:n.adaptiveSubtitle,expand:s,onClose:f=>Le(f),windowWidth:Fe,mobileFilter:Ve(!0)};let{group:p}=v;return p===void 0&&e!==void 0&&(p=d.getItemValue(r[0],e)),a.createElement(rn.AdaptiveMode,{...l},a.createElement(nn.ActionSheetContent,null,a.createElement("div",{className:o.classNames(o.uDropDownList.listContainer({c,popup:!1}))},Lt())))},St=()=>{v.focused&&window.setTimeout(()=>{v.focused&&t.current.wrapper&&ie(t.current.wrapper)})},xt=e=>{"onMouseDownOutside"in(n.popupSettings||{})&&n.popupSettings.onMouseDownOutside.call(void 0,e)},Ct=()=>{const{header:e,footer:r,dir:s,groupField:c,groupStickyHeaderItemRender:l,list:p}=n,f=d.getFilteredData(n),y=t.current,u=y.getPopupSettings(),g=n.opened!==void 0?n.opened:v.opened,m=u.width!==void 0?u.width:Pe!=null?Pe:y.popupWidth,C=F&&F.uDropDownList,D={dir:s!==void 0?s:y.dirCalculated,width:m,popupSettings:{...u,popupClass:o.classNames(u.popupClass,o.uDropDownList.listContainer({c:C,popup:!0})),anchor:u.anchor||N.current,show:g,onOpen:Se,onClose:St,onMouseDownOutside:xt},itemsCount:[f.length]};let{group:h}=v;return h===void 0&&c!==void 0&&(h=d.getItemValue(f[0],c)),a.createElement(Jt,{...D},Ve(!1),e&&a.createElement("div",{className:o.classNames(o.uDropDownList.listHeader({c:C}))},e),a.createElement("div",{className:o.classNames(o.uDropDownList.list({c:C,size:A,virtual:t.current.vs.enabled}))},Dt(),!p&&h&&f.length!==0&&a.createElement(ot,{group:h,render:l}),Be()),r&&a.createElement("div",{className:o.classNames(o.uDropDownList.listFooter({c:C}))},r),z&&a.createElement(o.WatermarkOverlay,{message:ae}))},Lt=()=>{const{header:e,footer:r,groupStickyHeaderItemRender:s,groupField:c,list:l}=n,p=d.getFilteredData(n),f=F&&F.uDropDownList;let{group:y}=v;return y===void 0&&c!==void 0&&(y=d.getItemValue(p[0],c)),a.createElement(a.Fragment,null,e&&a.createElement("div",{className:o.classNames(o.uDropDownList.listHeader({c:f}))},e),a.createElement("div",{className:o.classNames("k-list",{[`k-list-${U?"lg":o.sizeMap[A]||A}`]:U||A})},!l&&y&&p.length!==0&&a.createElement(ot,{group:y,render:s}),Be()),r&&a.createElement("div",{className:"k-list-footer"},r))},kt=e=>{const{dataItemKey:r}=n,s=d.getFilteredData(n),c=k();let l=s.map((b,R)=>({item:b,itemIndex:R}));const p=$.current.word,f=$.current.last,y=d.sameCharsOnly(p,f);let u=l.length,g=Math.max(0,s.findIndex(b=>d.areSame(b,c,r))),m;n.defaultItem&&(m={item:n.defaultItem,itemIndex:-1},u+=1,g+=1),g+=y?1:0,l=d.shuffleData(l,g,m);let C,D,h,i=0;const{textField:P}=n;for(;i<u;){if(C=d.getItemValue(l[i].item,P),D=y&&d.matchText(C,f,Q),h=d.matchText(C,p,Q),D||h){i=l[i].itemIndex;break}i++}if(i!==u){const b=t.current.initState();b.syntheticEvent=e,X(i,b),K(b),H.current=void 0}},bt=e=>{clearTimeout(He.current),n.filterable||(He.current=window.setTimeout(()=>$.current.word="",lt),kt(e))},Kt=e=>{le.current||t.current.handleFocus(e)},Et=e=>{if(le.current||!v.focused)return;const r=n.opened!==void 0?n.opened:v.opened,s=t.current.initState();s.syntheticEvent=e,s.data.focused=!1,s.events.push({type:"onBlur"}),r&&Ce(),r&&!U&&t.current.togglePopup(s),K(s)},Ft=e=>{if(n.filterable||e.which===0||e.keyCode===o.Keys.enter)return;let r=String.fromCharCode(e.charCode||e.keyCode);Q&&(r=r.toLowerCase()),r===" "&&e.preventDefault(),$.current={word:$.current.word+r,last:$.current.last+r},bt(e)},Pt=()=>{const e=t.current.initState();e.data.opened=v.opened,t.current.togglePopup(e),K(e)},ke=a.useRef(null),N=a.useRef(null),be=a.useRef(null),Z=a.useRef(null);a.useImperativeHandle(ke,()=>({get element(){return N.current},get index(){return ut()},get name(){return n.name},get validity(){return we()},get value(){return k()},get focused(){return v.focused},get opened(){return v.opened},focus:ct,props:n,togglePopup:Pt})),a.useImperativeHandle(J,()=>ke.current),o.useWebMcpRegister("dropdownlist",ke,n,n.webMcp);const He=a.useRef(null),$=a.useRef({word:"",last:""}),le=a.useRef(!1),H=a.useRef(null),W=a.useRef(!1),Ke=a.useRef(!1),_=a.useRef({}),Ee=a.useRef({}),t=a.useRef(new at({props:n,setState:()=>{},state:{},forceUpdate:()=>{},element:null,value:null,handleItemSelect:()=>{}})),We=a.useRef(0),ee=a.useRef(null),[v,Nt]=a.useState({}),[Fe,Mt]=a.useState(),[,_e]=a.useReducer(e=>e,!0),[Pe,Ot]=a.useState(),Ne=tn.useLocalization(),Ue=n.name||n.id,Tt=a.useCallback(e=>{if(e==null||!t.current)return;const r=d.getFilteredData(n),{textField:s}=n,c=String(e),l=d.getItemIndexByText(r,c,s,!1,Q),p=l!==-1?r[l]:void 0;if(p!==void 0){const f=t.current.initState();f.syntheticEvent={target:N.current},V(p,f),K(f)}},[n,Q]);o.useKendoPaste(N,{fieldName:Ue,onValueChange:Tt,enabled:!!Ue});const te=e=>{Nt({...v,...e})};a.useEffect(()=>{t.current.updateComponentArgs({props:n,setState:te,state:v,forceUpdate:_e,element:N.current,handleItemSelect:X,value:k()})},[te,v,_e,X,k]),a.useEffect(()=>{var m,C,D,h,i,P,b,R,oe,me,ge,I,se;const{dataItemKey:e,virtual:r,groupField:s="",textField:c}=n,l=d.getFilteredData(n),p=_.current.virtual?_.current.virtual.total:0,f=n.opened!==void 0?n.opened:v.opened,y=_.current.opened!==void 0?_.current.opened:Ee.current.opened,u=!y&&f;(m=t==null?void 0:t.current)==null||m.didUpdate();const g=(C=t==null?void 0:t.current)==null?void 0:C.getPopupSettings();if(f&&(g==null?void 0:g.width)===void 0&&N.current){const E=N.current.offsetWidth;Ot(G=>G!==E?E:G)}if(g!=null&&g.animate||u&&Se(),r&&r.total!==p)(D=t==null?void 0:t.current)==null||D.vs.calcScrollElementHeight(),(h=t==null?void 0:t.current)==null||h.vs.reset();else{const E=k(),G=_.current.value!==void 0?_.current.value:Ee.current.value;let j=l.findIndex(Y=>d.areSame(Y,E,e));s!==""&&E&&c&&(j=(P=(i=t==null?void 0:t.current)==null?void 0:i.getGroupedDataModernMode(l,s))==null?void 0:P.map(Y=>Y[c]).indexOf(E[c]));const fe=!d.areSame(G,E,e);u&&r?(b=t==null?void 0:t.current)==null||b.scrollToVirtualItem(r,j):u&&!r?(Se(),l&&l.length!==0&&((R=t==null?void 0:t.current)==null||R.resetGroupStickyHeader(l[0][s],{setState:te,group:v.group,state:v})),(oe=t==null?void 0:t.current)==null||oe.scrollToItem(j)):f&&y&&E&&fe&&!W.current?(ge=t==null?void 0:t.current)==null||ge.scrollToItem(j,(me=t==null?void 0:t.current)==null?void 0:me.vs.enabled):f&&y&&W.current&&(W.current&&r&&r.skip===0?(I=t==null?void 0:t.current)==null||I.vs.reset():W.current&&r&&r.skip===r.total-r.pageSize&&((se=t==null?void 0:t.current)==null||se.vs.scrollToEnd()))}W.current=!1,Ee.current=v,_.current=n,qe()}),a.useEffect(()=>{var e,r;return ee.current=o.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(mt.bind(void 0)),(e=t==null?void 0:t.current)==null||e.didMount(),qe(),(r=he())!=null&&r.body&&ee.current&&ee.current.observe(he().body),()=>{var s;(s=he())!=null&&s.body&&ee.current&&ee.current.disconnect()}},[]);const Ge=De+"-accessibility-id",je=De+"-listbox-id",$e=De+"-guid",qt=Ne.toLanguageString(M.dropDownListArrowBtnAriaLabel,M.messages[M.dropDownListArrowBtnAriaLabel]),{style:de,className:zt,label:Me,dir:At,virtual:T,adaptive:an,dataItemKey:Vt,disabled:ce,loading:Re,iconClassName:Ye,svgIcon:Bt,valueRender:Je}=n,ne=n.opened!==void 0?n.opened:v.opened,ue=k(),Oe=d.getItemValue(ue,n.textField),Qe=!pt()||we().valid,pe=t.current,Ht=pe.vs,re=F&&F.uDropDownList;Ht.enabled=T!==void 0;const Xe=o.useAdaptiveModeContext(),U=!!(Fe&&Xe&&Fe<=Xe.medium&&n.adaptive);T!==void 0&&(pe.vs.skip=T.skip,pe.vs.total=T.total,pe.vs.pageSize=T.pageSize);const Wt=d.getFilteredData(n),{focused:_t}=v,Ze=Wt.findIndex(e=>d.areSame(e,ue,Vt)),Ut=(nt=T==null?void 0:T.skip)!=null?nt:0,Gt=ne&&Ze>=0?`k-${$e}-item-${Ze+Ut+1}`:void 0,et=a.createElement("span",{id:Ge,className:o.classNames(o.uDropDownList.inputInner({c:re}))},Oe&&a.createElement("span",{className:o.classNames(o.uDropDownList.inputText({c:re}))},Oe)),jt=Je!==void 0?Je.call(void 0,et,ue):et,tt=a.createElement(a.Fragment,null,a.createElement("span",{ref:gt,className:o.classNames(o.uDropDownList.wrapper({c:re,size:A,rounded:Te,fillMode:ye,focused:_t,disabled:ce,invalid:!Qe,loading:Re,required:Ie()}),zt),style:Me?{...de,width:void 0}:de,dir:At,onMouseDown:ne?e=>{e.target.nodeName!=="INPUT"&&(ie(t.current.wrapper),e.preventDefault())}:void 0,onFocus:U?e=>Le(e):Kt,onBlur:Et,tabIndex:o.getTabIndex(dt,ce),accessKey:n.accessKey,onKeyDown:Ae,onKeyPress:Ft,onClick:ce?void 0:Le,role:"combobox","aria-required":Ie()||void 0,"aria-disabled":ce||void 0,"aria-haspopup":"listbox","aria-expanded":ne||!1,"aria-activedescendant":Gt,"aria-label":n.ariaLabel||n.label,"aria-labelledby":n.ariaLabelledBy,"aria-describedby":n.ariaDescribedBy||(ne?Ge:void 0),"aria-controls":ne?je:void 0,id:n.id,title:n.title},jt,Re&&a.createElement(o.IconWrap,{className:o.classNames(o.uDropDownList.loadingIcon({c:re})),name:"loading"}),a.createElement(en.Button,{tabIndex:-1,type:"button","aria-label":qt,size:A,fillMode:ye,className:o.classNames(o.uDropDownList.inputButton({c:re})),iconClass:Ye,svgIcon:Ye?void 0:Bt||Yt.chevronDownIcon,onMouseDown:e=>v.focused&&e.preventDefault()}),ft(ue),!U&&Ct()),U&&wt());return Me?a.createElement(Rt.FloatingLabel,{label:Me,editorValue:Oe,editorValid:Qe,editorDisabled:n.disabled,style:{width:de?de.width:void 0},children:tt}):tt});ve.propTypes={delay:L.number,ignoreCase:L.bool,iconClassName:L.string,svgIcon:o.svgIconPropType,defaultItem:L.any,valueRender:L.func,valueMap:L.func,validationMessage:L.string,required:L.bool,id:L.string,ariaLabelledBy:L.string,ariaDescribedBy:L.string,ariaLabel:L.string,leftRightKeysNavigation:L.bool,title:L.string,groupField:L.string,list:L.any,skipDisabledItems:L.bool};const O={delay:500,tabIndex:0,ignoreCase:!0,...at.defaultProps,required:!1,size:void 0,rounded:void 0,fillMode:void 0};ve.displayName="KendoReactDropDownList";const it=o.createPropsContext();ve.displayName="KendoReactDropDownList";exports.DropDownList=ve;exports.DropDownListPropsContext=it;exports.dropDownListDefaultProps=O;
|