@progress/kendo-react-dropdowns 11.0.0-develop.2 → 11.0.0-develop.4
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 +139 -136
- package/ComboBox/ComboBox.js +1 -1
- package/ComboBox/ComboBox.mjs +425 -461
- package/DropDownList/DropDownList.js +1 -1
- package/DropDownList/DropDownList.mjs +414 -436
- package/DropDownTree/DropDownTree.js +1 -1
- package/DropDownTree/DropDownTree.mjs +158 -155
- package/MultiColumnComboBox/MultiColumnComboBox.js +1 -1
- package/MultiColumnComboBox/MultiColumnComboBox.mjs +25 -24
- package/MultiSelect/MultiSelect.js +1 -1
- package/MultiSelect/MultiSelect.mjs +173 -181
- package/MultiSelectTree/MultiSelectTree.js +1 -1
- package/MultiSelectTree/MultiSelectTree.mjs +264 -269
- package/common/AdaptiveMode.js +1 -1
- package/common/AdaptiveMode.mjs +14 -13
- package/common/ListFilter.js +1 -1
- package/common/ListFilter.mjs +22 -20
- package/dist/cdn/js/kendo-react-dropdowns.js +1 -1
- package/index.d.mts +101 -15
- package/index.d.ts +101 -15
- package/messages/index.js +1 -1
- package/messages/index.mjs +16 -14
- 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 B=require("react"),g=require("prop-types"),V=require("../common/SearchBar.js"),q=require("../common/ListContainer.js"),T=require("../common/List.js"),S=require("../common/DropDownBase.js"),N=require("../common/GroupStickyHeader.js"),f=require("../common/utils.js"),l=require("@progress/kendo-react-common"),R=require("@progress/kendo-react-labels"),L=require("../common/ClearButton.js"),z=require("../common/AdaptiveMode.js"),F=require("../common/withCustomComponent.js"),A=require("@progress/kendo-react-layout"),H=require("../common/ListFilter.js");function W(I){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(I){for(const t in I)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(I,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>I[t]})}}return e.default=I,Object.freeze(e)}const m=W(B),j="Please enter a valid value!",{sizeMap:D,roundedMap:G}=l.kendoThemeMaps,y=class y extends m.Component{constructor(){super(...arguments),this.state={},this.base=new S(this),this._element=null,this._suggested="",this._input=null,this._adaptiveInput=null,this._skipFocusEvent=!1,this._isScrolling=!1,this.itemHeight=0,this.focus=()=>{this._input&&this._input.focus()},this.handleItemSelect=(e,t)=>{const s=f.getFilteredData(this.props),n=f.getItemValue(s[e],this.props.textField);this.state.text&&!this.mobileMode&&(this.state.text&&(t.data.text=""),this.base.filterChanged("",t)),this._adaptiveInput&&this._adaptiveInput.blur(),this.triggerOnChange(n,t)},this.itemFocus=(e,t)=>{const{textField:s}=this.props,i=f.getFilteredData(this.props)[e];f.areSame(this.state.focusedItem,i,s)||(t.data.focusedItem=i)},this.togglePopup=e=>{this.base.togglePopup(e)},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||j)},this.renderAdaptiveListContainer=()=>{const{adaptiveTitle:e}=this.props,{windowWidth:t=0}=this.state,s=m.createElement(H,{value:this.value,ref:i=>{this._adaptiveInput=i&&i.element},onChange:this.onChangeHandler,onKeyDown:this.onInputKeyDown,size:this.props.size,rounded:this.props.rounded,fillMode:this.props.fillMode}),n={title:e,expand:this.opened,onClose:i=>this.onCancel(i),windowWidth:t,mobileFilter:s};return m.createElement(z.AdaptiveMode,{...n},m.createElement(A.ActionSheetContent,null,m.createElement("div",{className:"k-list-container"},this.listContainerContent())))},this.onCancel=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.opened&&this.base.togglePopup(t),t.events.push({type:"onCancel"});const s=this.state.text;f.isPresent(s)&&s!==""&&this.base.filterChanged("",t),this.state.text&&(t.data.text=""),this.applyState(t)},this.listContainerContent=()=>{const{header:e,footer:t,size:s,groupStickyHeaderItemRender:n,groupField:i,list:a}=this.props,d=f.getFilteredData(this.props);let{group:o}=this.state;return o===void 0&&i!==void 0&&(o=f.getItemValue(d[0],i)),m.createElement(m.Fragment,null,e&&m.createElement("div",{className:"k-list-header"},e),m.createElement("div",{className:l.classNames("k-list",{[`k-list-${this.mobileMode?"lg":D[s]||s}`]:s})},!a&&o&&d.length!==0&&m.createElement(N,{group:o,groupMode:"modern",render:n}),this.renderList()),t&&m.createElement("div",{className:"k-list-footer"},t))},this.onScroll=e=>{this._isScrolling=!0;const{list:t}=this.base,{groupField:s}=this.props;let n=f.getFilteredData(this.props);if(!s||!n.length)return;const i=this.itemHeight||(t?t.children[0].offsetHeight:0),d=e.target.scrollTop;s&&(n=this.base.getGroupedDataModernMode(n,s));let o=n[0][s];for(let r=1;r<n.length&&!(i*r>d);r++)n[r]&&n[r][s]&&(o=n[r][s]);o!==this.state.group&&this.setState({group:o})},this.handleItemClick=(e,t)=>{this.base.handleItemClick(e,t),this._valueDuringOnChange=void 0},this.onChangeHandler=e=>{const s=this.base.initState(),n=this.mobileMode?e.target.element:e.currentTarget,i=n.value,a=n.selectionEnd===i.length;s.syntheticEvent=e;const d=this._suggested,o=this.value,r=o&&o.substring(0,o.length-d.length),h=r&&r===i,u=r&&r.length>i.length,{suggest:b}=this.props,p=this.props.opened!==void 0?this.props.opened:this.state.opened;if(b!==void 0&&b!==!1){h||u||!a?this._suggested="":this.suggestValue(i);const c=i+this._suggested,v={userInput:i,value:this._suggested};this.triggerOnChange(c,s,{suggestion:v})}else this._suggested="",this.triggerOnChange(i,s);(!p&&i||p&&!i)&&this.togglePopup(s),s.data.focusedItem=void 0,this.applyState(s),this.setState({group:void 0})},this.clearButtonClick=e=>{const s=this.base.initState(),n=this.props.opened!==void 0?this.props.opened:this.state.opened;s.syntheticEvent=e;const i="";this._suggested="",this.triggerOnChange(i,s),this.state.focusedItem!==void 0&&(s.data.focusedItem=void 0),n&&this.togglePopup(s),this.applyState(s)},this.onInputKeyDown=e=>{const{skipDisabledItems:t,groupField:s,textField:n}=this.props,i=f.getFilteredData(this.props);this._isScrolling&&(this._isScrolling=!1);const a=this.focusedIndex(),d=i[a],o=e.keyCode,r=e.altKey,h=this.props.opened!==void 0?this.props.opened:this.state.opened,u=this.base.initState();u.syntheticEvent=e;const b=()=>{h&&e.preventDefault()};if(r&&o===l.Keys.down)this.setState({opened:!0});else if(r&&o===l.Keys.up)this.setState({opened:!1});else if(h&&o===l.Keys.pageUp)b(),this.base.scrollPopupByPageSize(-1);else if(h&&o===l.Keys.pageDown)b(),this.base.scrollPopupByPageSize(1);else if(h&&(o===l.Keys.enter||o===l.Keys.esc))b(),t===!1&&d&&d.disabled?(h&&this.togglePopup(u),this.applyState(u)):this.applyInputValue(e.currentTarget.value,u,e.keyCode);else if(!h&&o===l.Keys.esc){const p="";this._suggested="",this.triggerOnChange(p,u),this.state.focusedItem!==void 0&&(u.data.focusedItem=void 0),this.applyState(u)}else if(o===l.Keys.up||o===l.Keys.down){if(s!==""&&n)if(!this.props.skipDisabledItems&&h)this.onNavigate(u,o);else{let p=0;if(o===l.Keys.down||o===l.Keys.right){const c=i.slice(a+1).find(v=>!v.disabled&&v[n]);p=c&&i.findIndex(v=>v[n]===c[n])}else if(o===l.Keys.up||o===l.Keys.left){let c;if(a===-1)c=i,p=i.findIndex(v=>!v.disabled&&v[n]);else{c=i.slice(0,a);let v=c.pop();for(;v&&v.disabled;)v=c.pop();p=v&&i.findIndex(x=>x[n]===v[n])}}if(p!==void 0){const c=p-a;this.onNavigate(u,o,c)}else p===void 0&&i.findIndex(c=>c[n])===i.length-1&&this.onNavigate(u,o)}else if(!this.props.skipDisabledItems&&h)this.onNavigate(u,o);else{let p=null;if(o===l.Keys.down||o===l.Keys.right)p=i.slice(a+1).find(c=>!c.disabled);else if(o===l.Keys.up||o===l.Keys.left){const c=i.slice(0,a);for(p=c.pop();p&&p.disabled;)p=c.pop()}if(p){const c=p.id-a-1;this.onNavigate(u,o,c)}else this.onNavigate(u,o)}this.applyState(u),b()}},this.handleFocus=e=>{this._skipFocusEvent||this.base.handleFocus(e)},this.handleBlur=e=>{const t=this.base.initState();!this.state.focused||this._skipFocusEvent||(t.syntheticEvent=e,t.data.focused=!1,t.events.push({type:"onBlur"}),this.opened&&!this.mobileMode&&(this.state.opened&&(t.data.opened=!1),t.events.push({type:"onClose"})),this.applyState(t))},this.handleWrapperClick=e=>{const t=this._input;!this.opened&&t&&this.focusElement(t);const s=this.base.initState();s.syntheticEvent=e,!this.state.focused&&!this.mobileMode&&(s.events.push({type:"onFocus"}),s.data.focused=!0),this.mobileMode&&window.setTimeout(()=>this._adaptiveInput&&this._adaptiveInput.focus(),300),this.base.togglePopup(s),this.applyState(s)}}get _inputId(){return this.props.id+"-accessibility-id"}get document(){if(l.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get value(){return this._valueDuringOnChange!==void 0?this._valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value!==void 0?this.state.value:this.props.defaultValue!==void 0?this.props.defaultValue:""}get name(){return this.props.name}get validity(){const e=this.props.validationMessage!==void 0,t=!this.required||this.value!=="",s=this.props.valid!==void 0?this.props.valid:t;return{customError:e,valid:s,valueMissing:this.value===null}}get opened(){return!!(this.props.opened!==void 0?this.props.opened:this.state.opened)}get mobileMode(){var t;return!!(this.state.windowWidth&&this.props._adaptiveMode&&this.state.windowWidth<=((t=this.props._adaptiveMode)==null?void 0:t.medium)&&this.props.adaptive)}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:y.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:y.defaultProps.required}componentDidUpdate(e,t){var p;const{groupField:s=""}=this.props,n=f.getFilteredData(this.props),{data:i=[]}=e,a=this.focusedIndex(),d=n[a],o=i!==n,r=d!==void 0&&t.focusedItem!==d,h=this.props.opened!==void 0?this.props.opened:this.state.opened,u=e.opened!==void 0?e.opened:t.opened,b=!u&&h;if(s==="")(h&&(r||o)||b)&&this.base.scrollToItem(a);else if(!this._isScrolling){const c=(p=this.base.getGroupedDataModernMode(n,s))==null?void 0:p.indexOf(d);b&&(n&&n.length!==0&&this.base.resetGroupStickyHeader(n[0][s],this),this.base.scrollToItem(c)),h&&u&&r&&this.base.scrollToItem(c)}this.setValidity()}componentDidMount(){var e;this.observerResize=l.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(e=this.document)!=null&&e.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentWillUnmount(){this.observerResize&&this.observerResize.disconnect()}render(){const{dir:e,disabled:t,label:s,className:n,style:i,loading:a,suggest:d,size:o,rounded:r,fillMode:h}=this.props,u=!this.validityStyles||this.validity.valid,b=this.base,p=this.value,c=this.props.clearButton!==!1&&!a&&!!p,v=this.props.id||this._inputId,x=this.state.focused;typeof d=="string"&&(this._suggested=d);const[E,O]=F(this.props.prefix||m.Fragment),[P,K]=F(this.props.suffix||m.Fragment),w=m.createElement(m.Fragment,null,m.createElement("span",{className:l.classNames("k-autocomplete k-input",n,{[`k-input-${D[o]||o}`]:o,[`k-rounded-${G[r]||r}`]:r,[`k-input-${h}`]:h,"k-invalid":!u,"k-focus":x&&!t,"k-loading":a,"k-required":this.required,"k-disabled":t}),ref:k=>{this._element=k,b.wrapper=k},style:s?{...i,width:void 0}:i,dir:e,onFocus:this.handleFocus,onBlur:this.handleBlur,onClick:this.handleWrapperClick},this.props.prefix&&m.createElement(E,{...O}),this.renderSearchBar(p||"",v),a&&m.createElement(l.IconWrap,{className:"k-input-loading-icon",name:"loading"}),c&&!a&&m.createElement(L,{onClick:this.clearButtonClick,key:"clearbutton"}),this.props.suffix&&m.createElement(P,{...K}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return s?m.createElement(R.FloatingLabel,{label:s,editorId:v,editorValue:p,editorValid:u,editorDisabled:t,style:{width:i?i.width:void 0},children:w}):w}onNavigate(e,t,s){const n=this.value,{textField:i,focusedItemIndex:a}=this.props,d=f.getFilteredData(this.props),o=this.state.focusedItem!==void 0?d.findIndex(h=>f.areSame(h,this.state.focusedItem,i)):a?a(d,n,i):d.indexOf(f.getFocusedItem(d,n,i)),r=this.base.navigation.navigate({keyCode:t,current:o,max:d.length-1,min:0,skipItems:s||void 0});r!==void 0&&this.itemFocus(r,e),this.applyState(e)}applyInputValue(e,t,s){const n=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:i}=this.props,a=f.getFilteredData(this.props),d=this.focusedIndex(),o=a[d];if(this._suggested="",n&&s===l.Keys.enter&&o&&!o.disabled){const r=f.getItemValue(a[this.focusedIndex(e)],i);this.triggerOnChange(r,t)}n&&this.togglePopup(t),this.applyState(t)}renderSearchBar(e,t){const s=this.base,{placeholder:n,tabIndex:i,disabled:a,readonly:d,inputAttributes:o}=this.props,{focused:r}=this.state,h=this.props.opened!==void 0?this.props.opened:this.state.opened;return m.createElement(V,{id:t,placeholder:n,tabIndex:i,accessKey:this.props.accessKey,value:e,suggestedText:this._suggested,focused:r,name:this.props.name,ref:u=>{this._input=u&&u.input},onKeyDown:this.onInputKeyDown,onChange:this.onChangeHandler,onFocus:s.handleFocus,onBlur:this.handleBlur,disabled:a,readOnly:d,expanded:h,owns:s.listBoxId,activedescendant:"option-"+s.guid+"-"+this.focusedIndex(),role:"combobox",ariaLabelledBy:this.props.ariaLabelledBy,ariaDescribedBy:this.props.ariaDescribedBy,ariaRequired:this.required,render:this.props.valueRender,inputAttributes:o})}renderListContainer(){const e=this.base,{dir:t,groupField:s}=this.props,n=f.getFilteredData(this.props),i=e.getPopupSettings(),a=this.props.opened!==void 0?this.props.opened:this.state.opened,d=i.width!==void 0?i.width:e.popupWidth;let{group:o}=this.state;return o===void 0&&s!==void 0&&(o=f.getItemValue(n[0],s)),m.createElement(q,{width:d,popupSettings:{...i,anchor:i.anchor||this.element,show:a,popupClass:l.classNames(i.popupClass,"k-list-container","k-autocomplete-popup")},dir:t!==void 0?t:this.base.dirCalculated,itemsCount:[n.length]},this.listContainerContent())}renderList(){const e=this.base,t=e.getPopupSettings(),{textField:s,listNoDataRender:n,itemRender:i,groupHeaderItemRender:a}=this.props,d=f.getFilteredData(this.props),o=this.value,r=this.props.opened!==void 0?this.props.opened:this.state.opened;return m.createElement(T,{id:e.listBoxId,show:r,data:d.slice(),focusedIndex:this.focusedIndex(),value:o,textField:s,valueField:s,highlightSelected:!1,optionsGuid:e.guid,groupField:this.props.groupField,groupMode:"modern",listRef:h=>{e.list=h},wrapperStyle:this.mobileMode?{}:{maxHeight:t.height},wrapperCssClass:"k-list-content",onClick:this.handleItemClick,itemRender:i,groupHeaderItemRender:a,noDataRender:n,onMouseDown:h=>h.preventDefault(),onScroll:this.onScroll})}triggerOnChange(e,t,s){this.value===e&&!s||(t.data.value=e,this._valueDuringOnChange=e,t.events.push({type:"onChange",...s||{}}))}focusElement(e){this._skipFocusEvent=!0,e.focus(),window.setTimeout(()=>this._skipFocusEvent=!1,0)}applyState(e){this.base.applyState(e),this._valueDuringOnChange=void 0}suggestValue(e){if(this._suggested="",e){const{textField:t}=this.props,s=f.getFilteredData(this.props),n=s[f.itemIndexStartsWith(s,e,t)];if(n){const i=f.getItemValue(n,t);e.toLowerCase()!==i.toLowerCase()&&(this._suggested=i.substring(e.length))}}}focusedIndex(e){const{textField:t,focusedItemIndex:s,skipDisabledItems:n}=this.props,i=f.getFilteredData(this.props),a=e!==void 0?e:this.value;if(this.state.focusedItem!==void 0)return i.findIndex(o=>f.areSame(o,this.state.focusedItem,t));if(s)return s(i,a,t);const d=i.indexOf(f.getFocusedItem(i,a,t));return n&&t&&d===-1?i.findIndex(o=>!o.disabled&&o[t]):Math.max(0,d)}calculateMedia(e){for(const t of e)this.setState({windowWidth:t.target.clientWidth})}};y.displayName="AutoComplete",y.propTypes={...S.basicPropTypes,size:g.oneOf([null,"small","medium","large"]),rounded:g.oneOf([null,"small","medium","large","full"]),fillMode:g.oneOf([null,"solid","flat","outline"]),groupField:g.string,suggest:g.oneOfType([g.bool,g.string]),placeholder:g.string,value:g.string,defaultValue:g.string,validationMessage:g.string,required:g.bool,readonly:g.bool,clearButton:g.bool,valueRender:g.func,id:g.string,ariaLabelledBy:g.string,ariaDescribedBy:g.string,list:g.any,adaptive:g.bool,adaptiveTitle:g.string,onCancel:g.func,skipDisabledItems:g.bool,inputAttributes:g.object},y.defaultProps={...S.defaultProps,size:"medium",rounded:"medium",fillMode:"solid",skipDisabledItems:!0,prefix:void 0,suffix:void 0};let C=y;const _=l.createPropsContext(),M=l.withIdHOC(l.withPropsContext(_,l.withAdaptiveModeContext(C)));M.displayName="KendoReactAutoComplete";exports.AutoComplete=M;exports.AutoCompletePropsContext=_;exports.AutoCompleteWithoutContext=C;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react"),g=require("prop-types"),T=require("../common/SearchBar.js"),V=require("../common/ListContainer.js"),q=require("../common/List.js"),w=require("../common/DropDownBase.js"),N=require("../common/GroupStickyHeader.js"),f=require("../common/utils.js"),l=require("@progress/kendo-react-common"),R=require("@progress/kendo-react-labels"),L=require("../common/ClearButton.js"),z=require("../common/AdaptiveMode.js"),F=require("../common/withCustomComponent.js"),A=require("@progress/kendo-react-layout"),H=require("../common/ListFilter.js");function W(I){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(I){for(const t in I)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(I,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>I[t]})}}return e.default=I,Object.freeze(e)}const m=W(B),j="Please enter a valid value!",{sizeMap:D,roundedMap:G}=l.kendoThemeMaps,y=class y extends m.Component{constructor(){super(...arguments),this.state={},this.base=new w(this),this._element=null,this._suggested="",this._input=null,this._adaptiveInput=null,this._skipFocusEvent=!1,this._isScrolling=!1,this.itemHeight=0,this.focus=()=>{this._input&&this._input.focus()},this.handleItemSelect=(e,t)=>{const s=f.getFilteredData(this.props),o=f.getItemValue(s[e],this.props.textField);this.state.text&&!this.mobileMode&&(this.state.text&&(t.data.text=""),this.base.filterChanged("",t)),this._adaptiveInput&&this._adaptiveInput.blur(),this.triggerOnChange(o,t)},this.itemFocus=(e,t)=>{const{textField:s}=this.props,i=f.getFilteredData(this.props)[e];f.areSame(this.state.focusedItem,i,s)||(t.data.focusedItem=i)},this.togglePopup=e=>{this.base.togglePopup(e)},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||j)},this.renderAdaptiveListContainer=()=>{const{windowWidth:e=0}=this.state,t=m.createElement(H,{value:this.value,ref:o=>{this._adaptiveInput=o&&o.element},onChange:this.onChangeHandler,onKeyDown:this.onInputKeyDown,size:"large",rounded:this.props.rounded,fillMode:this.props.fillMode,placeholder:this.props.placeholder}),s={title:this.props.adaptiveTitle||this.props.label,subTitle:this.props.adaptiveSubtitle,expand:this.opened,onClose:o=>this.onCancel(o),windowWidth:e,mobileFilter:t};return m.createElement(z.AdaptiveMode,{...s},m.createElement(A.ActionSheetContent,null,m.createElement("div",{className:"k-list-container"},this.listContainerContent())))},this.onCancel=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.opened&&this.base.togglePopup(t),t.events.push({type:"onCancel"});const s=this.state.text;f.isPresent(s)&&s!==""&&this.base.filterChanged("",t),this.state.text&&(t.data.text=""),this.applyState(t)},this.listContainerContent=()=>{const{header:e,footer:t,size:s,groupStickyHeaderItemRender:o,groupField:i,list:a}=this.props,d=f.getFilteredData(this.props);let{group:n}=this.state;return n===void 0&&i!==void 0&&(n=f.getItemValue(d[0],i)),m.createElement(m.Fragment,null,e&&m.createElement("div",{className:"k-list-header"},e),m.createElement("div",{className:l.classNames("k-list",{[`k-list-${this.mobileMode?"lg":D[s]||s}`]:s})},!a&&n&&d.length!==0&&m.createElement(N,{group:n,groupMode:"modern",render:o}),this.renderList()),t&&m.createElement("div",{className:"k-list-footer"},t))},this.onScroll=e=>{this._isScrolling=!0;const{list:t}=this.base,{groupField:s}=this.props;let o=f.getFilteredData(this.props);if(!s||!o.length)return;const i=this.itemHeight||(t?t.children[0].offsetHeight:0),d=e.target.scrollTop;s&&(o=this.base.getGroupedDataModernMode(o,s));let n=o[0][s];for(let r=1;r<o.length&&!(i*r>d);r++)o[r]&&o[r][s]&&(n=o[r][s]);n!==this.state.group&&this.setState({group:n})},this.handleItemClick=(e,t)=>{this.base.handleItemClick(e,t),this._valueDuringOnChange=void 0},this.onChangeHandler=e=>{const s=this.base.initState(),o=this.mobileMode?e.target.element:e.currentTarget,i=o.value,a=o.selectionEnd===i.length;s.syntheticEvent=e;const d=this._suggested,n=this.value,r=n&&n.substring(0,n.length-d.length),h=r&&r===i,u=r&&r.length>i.length,{suggest:b}=this.props,p=this.props.opened!==void 0?this.props.opened:this.state.opened;if(b!==void 0&&b!==!1){h||u||!a?this._suggested="":this.suggestValue(i);const c=i+this._suggested,v={userInput:i,value:this._suggested};this.triggerOnChange(c,s,{suggestion:v})}else this._suggested="",this.triggerOnChange(i,s);(!p&&i||p&&!i)&&this.togglePopup(s),s.data.focusedItem=void 0,this.applyState(s),this.setState({group:void 0})},this.clearButtonClick=e=>{const s=this.base.initState(),o=this.props.opened!==void 0?this.props.opened:this.state.opened;s.syntheticEvent=e;const i="";this._suggested="",this.triggerOnChange(i,s),this.state.focusedItem!==void 0&&(s.data.focusedItem=void 0),o&&this.togglePopup(s),this.applyState(s)},this.onInputKeyDown=e=>{const{skipDisabledItems:t,groupField:s,textField:o}=this.props,i=f.getFilteredData(this.props);this._isScrolling&&(this._isScrolling=!1);const a=this.focusedIndex(),d=i[a],n=e.keyCode,r=e.altKey,h=this.props.opened!==void 0?this.props.opened:this.state.opened,u=this.base.initState();u.syntheticEvent=e;const b=()=>{h&&e.preventDefault()};if(r&&n===l.Keys.down)this.setState({opened:!0});else if(r&&n===l.Keys.up)this.setState({opened:!1});else if(h&&n===l.Keys.pageUp)b(),this.base.scrollPopupByPageSize(-1);else if(h&&n===l.Keys.pageDown)b(),this.base.scrollPopupByPageSize(1);else if(h&&(n===l.Keys.enter||n===l.Keys.esc))b(),t===!1&&d&&d.disabled?(h&&this.togglePopup(u),this.applyState(u)):this.applyInputValue(e.currentTarget.value,u,e.keyCode);else if(!h&&n===l.Keys.esc){const p="";this._suggested="",this.triggerOnChange(p,u),this.state.focusedItem!==void 0&&(u.data.focusedItem=void 0),this.applyState(u)}else if(n===l.Keys.up||n===l.Keys.down){if(s!==""&&o)if(!this.props.skipDisabledItems&&h)this.onNavigate(u,n);else{let p=0;if(n===l.Keys.down||n===l.Keys.right){const c=i.slice(a+1).find(v=>!v.disabled&&v[o]);p=c&&i.findIndex(v=>v[o]===c[o])}else if(n===l.Keys.up||n===l.Keys.left){let c;if(a===-1)c=i,p=i.findIndex(v=>!v.disabled&&v[o]);else{c=i.slice(0,a);let v=c.pop();for(;v&&v.disabled;)v=c.pop();p=v&&i.findIndex(S=>S[o]===v[o])}}if(p!==void 0){const c=p-a;this.onNavigate(u,n,c)}else p===void 0&&i.findIndex(c=>c[o])===i.length-1&&this.onNavigate(u,n)}else if(!this.props.skipDisabledItems&&h)this.onNavigate(u,n);else{let p=null;if(n===l.Keys.down||n===l.Keys.right)p=i.slice(a+1).find(c=>!c.disabled);else if(n===l.Keys.up||n===l.Keys.left){const c=i.slice(0,a);for(p=c.pop();p&&p.disabled;)p=c.pop()}if(p){const c=p.id-a-1;this.onNavigate(u,n,c)}else this.onNavigate(u,n)}this.applyState(u),b()}},this.handleFocus=e=>{this._skipFocusEvent||this.base.handleFocus(e)},this.handleBlur=e=>{const t=this.base.initState();!this.state.focused||this._skipFocusEvent||(t.syntheticEvent=e,t.data.focused=!1,t.events.push({type:"onBlur"}),this.opened&&!this.mobileMode&&(this.state.opened&&(t.data.opened=!1),t.events.push({type:"onClose"})),this.applyState(t))},this.handleWrapperClick=e=>{const t=this._input;!this.opened&&t&&this.focusElement(t);const s=this.base.initState();s.syntheticEvent=e,!this.state.focused&&!this.mobileMode&&(s.events.push({type:"onFocus"}),s.data.focused=!0),this.mobileMode&&window.setTimeout(()=>this._adaptiveInput&&this._adaptiveInput.focus(),300),this.base.togglePopup(s),this.applyState(s)}}get _inputId(){return this.props.id+"-accessibility-id"}get document(){if(l.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get value(){return this._valueDuringOnChange!==void 0?this._valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value!==void 0?this.state.value:this.props.defaultValue!==void 0?this.props.defaultValue:""}get name(){return this.props.name}get validity(){const e=this.props.validationMessage!==void 0,t=!this.required||this.value!=="",s=this.props.valid!==void 0?this.props.valid:t;return{customError:e,valid:s,valueMissing:this.value===null}}get opened(){return!!(this.props.opened!==void 0?this.props.opened:this.state.opened)}get mobileMode(){var t;return!!(this.state.windowWidth&&this.props._adaptiveMode&&this.state.windowWidth<=((t=this.props._adaptiveMode)==null?void 0:t.medium)&&this.props.adaptive)}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:y.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:y.defaultProps.required}componentDidUpdate(e,t){var p;const{groupField:s=""}=this.props,o=f.getFilteredData(this.props),{data:i=[]}=e,a=this.focusedIndex(),d=o[a],n=i!==o,r=d!==void 0&&t.focusedItem!==d,h=this.props.opened!==void 0?this.props.opened:this.state.opened,u=e.opened!==void 0?e.opened:t.opened,b=!u&&h;if(s==="")(h&&(r||n)||b)&&this.base.scrollToItem(a);else if(!this._isScrolling){const c=(p=this.base.getGroupedDataModernMode(o,s))==null?void 0:p.indexOf(d);b&&(o&&o.length!==0&&this.base.resetGroupStickyHeader(o[0][s],this),this.base.scrollToItem(c)),h&&u&&r&&this.base.scrollToItem(c)}this.setValidity()}componentDidMount(){var e;this.observerResize=l.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(e=this.document)!=null&&e.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentWillUnmount(){this.observerResize&&this.observerResize.disconnect()}render(){const{dir:e,disabled:t,label:s,className:o,style:i,loading:a,suggest:d,size:n,rounded:r,fillMode:h}=this.props,u=!this.validityStyles||this.validity.valid,b=this.base,p=this.value,c=this.props.clearButton!==!1&&!a&&!!p,v=this.props.id||this._inputId,S=this.state.focused;typeof d=="string"&&(this._suggested=d);const[E,O]=F(this.props.prefix||m.Fragment),[P,K]=F(this.props.suffix||m.Fragment),k=m.createElement(m.Fragment,null,m.createElement("span",{className:l.classNames("k-autocomplete k-input",o,{[`k-input-${D[n]||n}`]:n,[`k-rounded-${G[r]||r}`]:r,[`k-input-${h}`]:h,"k-invalid":!u,"k-focus":S&&!t,"k-loading":a,"k-required":this.required,"k-disabled":t}),ref:C=>{this._element=C,b.wrapper=C},style:s?{...i,width:void 0}:i,dir:e,onFocus:this.mobileMode?C=>this.handleWrapperClick(C):this.handleFocus,onBlur:this.handleBlur,onClick:this.handleWrapperClick},this.props.prefix&&m.createElement(E,{...O}),this.renderSearchBar(p||"",v),a&&m.createElement(l.IconWrap,{className:"k-input-loading-icon",name:"loading"}),c&&!a&&m.createElement(L,{onClick:this.clearButtonClick,key:"clearbutton"}),this.props.suffix&&m.createElement(P,{...K}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return s?m.createElement(R.FloatingLabel,{label:s,editorId:v,editorValue:p,editorValid:u,editorDisabled:t,style:{width:i?i.width:void 0},children:k}):k}onNavigate(e,t,s){const o=this.value,{textField:i,focusedItemIndex:a}=this.props,d=f.getFilteredData(this.props),n=this.state.focusedItem!==void 0?d.findIndex(h=>f.areSame(h,this.state.focusedItem,i)):a?a(d,o,i):d.indexOf(f.getFocusedItem(d,o,i)),r=this.base.navigation.navigate({keyCode:t,current:n,max:d.length-1,min:0,skipItems:s||void 0});r!==void 0&&this.itemFocus(r,e),this.applyState(e)}applyInputValue(e,t,s){const o=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:i}=this.props,a=f.getFilteredData(this.props),d=this.focusedIndex(),n=a[d];if(this._suggested="",o&&s===l.Keys.enter&&n&&!n.disabled){const r=f.getItemValue(a[this.focusedIndex(e)],i);this.triggerOnChange(r,t)}o&&this.togglePopup(t),this.applyState(t)}renderSearchBar(e,t){const s=this.base,{placeholder:o,tabIndex:i,disabled:a,readonly:d,inputAttributes:n}=this.props,{focused:r}=this.state,h=this.props.opened!==void 0?this.props.opened:this.state.opened;return m.createElement(T,{id:t,placeholder:o,tabIndex:i,accessKey:this.props.accessKey,value:e,suggestedText:this._suggested,focused:r,name:this.props.name,ref:u=>{this._input=u&&u.input},onKeyDown:this.onInputKeyDown,onChange:this.onChangeHandler,onFocus:s.handleFocus,onBlur:this.handleBlur,disabled:a,readOnly:d,expanded:h,owns:s.listBoxId,activedescendant:"option-"+s.guid+"-"+this.focusedIndex(),role:"combobox",ariaLabelledBy:this.props.ariaLabelledBy,ariaDescribedBy:this.props.ariaDescribedBy,ariaRequired:this.required,render:this.props.valueRender,inputAttributes:n})}renderListContainer(){const e=this.base,{dir:t,groupField:s}=this.props,o=f.getFilteredData(this.props),i=e.getPopupSettings(),a=this.props.opened!==void 0?this.props.opened:this.state.opened,d=i.width!==void 0?i.width:e.popupWidth;let{group:n}=this.state;return n===void 0&&s!==void 0&&(n=f.getItemValue(o[0],s)),m.createElement(V,{width:d,popupSettings:{...i,anchor:i.anchor||this.element,show:a,popupClass:l.classNames(i.popupClass,"k-list-container","k-autocomplete-popup")},dir:t!==void 0?t:this.base.dirCalculated,itemsCount:[o.length]},this.listContainerContent())}renderList(){const e=this.base,t=e.getPopupSettings(),{textField:s,listNoDataRender:o,itemRender:i,groupHeaderItemRender:a}=this.props,d=f.getFilteredData(this.props),n=this.value,r=this.props.opened!==void 0?this.props.opened:this.state.opened;return m.createElement(q,{id:e.listBoxId,show:r,data:d.slice(),focusedIndex:this.focusedIndex(),value:n,textField:s,valueField:s,highlightSelected:!1,optionsGuid:e.guid,groupField:this.props.groupField,groupMode:"modern",listRef:h=>{e.list=h},wrapperStyle:this.mobileMode?{}:{maxHeight:t.height},wrapperCssClass:"k-list-content",onClick:this.handleItemClick,itemRender:i,groupHeaderItemRender:a,noDataRender:o,onMouseDown:h=>h.preventDefault(),onScroll:this.onScroll})}triggerOnChange(e,t,s){this.value===e&&!s||(t.data.value=e,this._valueDuringOnChange=e,t.events.push({type:"onChange",...s||{}}))}focusElement(e){this._skipFocusEvent=!0,e.focus(),window.setTimeout(()=>this._skipFocusEvent=!1,0)}applyState(e){this.base.applyState(e),this._valueDuringOnChange=void 0}suggestValue(e){if(this._suggested="",e){const{textField:t}=this.props,s=f.getFilteredData(this.props),o=s[f.itemIndexStartsWith(s,e,t)];if(o){const i=f.getItemValue(o,t);e.toLowerCase()!==i.toLowerCase()&&(this._suggested=i.substring(e.length))}}}focusedIndex(e){const{textField:t,focusedItemIndex:s,skipDisabledItems:o}=this.props,i=f.getFilteredData(this.props),a=e!==void 0?e:this.value;if(this.state.focusedItem!==void 0)return i.findIndex(n=>f.areSame(n,this.state.focusedItem,t));if(s)return s(i,a,t);const d=i.indexOf(f.getFocusedItem(i,a,t));return o&&t&&d===-1?i.findIndex(n=>!n.disabled&&n[t]):Math.max(0,d)}calculateMedia(e){for(const t of e)this.setState({windowWidth:t.target.clientWidth})}};y.displayName="AutoComplete",y.propTypes={...w.basicPropTypes,size:g.oneOf([null,"small","medium","large"]),rounded:g.oneOf([null,"small","medium","large","full"]),fillMode:g.oneOf([null,"solid","flat","outline"]),groupField:g.string,suggest:g.oneOfType([g.bool,g.string]),placeholder:g.string,value:g.string,defaultValue:g.string,validationMessage:g.string,required:g.bool,readonly:g.bool,clearButton:g.bool,valueRender:g.func,id:g.string,ariaLabelledBy:g.string,ariaDescribedBy:g.string,list:g.any,adaptive:g.bool,adaptiveTitle:g.string,adaptiveSubtitle:g.string,onCancel:g.func,skipDisabledItems:g.bool,inputAttributes:g.object},y.defaultProps={...w.defaultProps,size:"medium",rounded:"medium",fillMode:"solid",skipDisabledItems:!0,prefix:void 0,suffix:void 0};let x=y;const _=l.createPropsContext(),M=l.withIdHOC(l.withPropsContext(_,l.withAdaptiveModeContext(x)));M.displayName="KendoReactAutoComplete";exports.AutoComplete=M;exports.AutoCompletePropsContext=_;exports.AutoCompleteWithoutContext=x;
|
|
@@ -5,31 +5,31 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import * as
|
|
9
|
-
import
|
|
8
|
+
import * as g from "react";
|
|
9
|
+
import c from "prop-types";
|
|
10
10
|
import N from "../common/SearchBar.mjs";
|
|
11
11
|
import R from "../common/ListContainer.mjs";
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { getFilteredData as b, getItemValue as y, areSame as
|
|
16
|
-
import { classNames as
|
|
12
|
+
import L from "../common/List.mjs";
|
|
13
|
+
import S from "../common/DropDownBase.mjs";
|
|
14
|
+
import z from "../common/GroupStickyHeader.mjs";
|
|
15
|
+
import { getFilteredData as b, getItemValue as y, areSame as w, isPresent as H, getFocusedItem as M, itemIndexStartsWith as A } from "../common/utils.mjs";
|
|
16
|
+
import { classNames as k, Keys as m, canUseDOM as D, IconWrap as K, createPropsContext as q, withIdHOC as W, withPropsContext as G, withAdaptiveModeContext as U, kendoThemeMaps as $ } from "@progress/kendo-react-common";
|
|
17
17
|
import { FloatingLabel as j } from "@progress/kendo-react-labels";
|
|
18
18
|
import J from "../common/ClearButton.mjs";
|
|
19
19
|
import { AdaptiveMode as Q } from "../common/AdaptiveMode.mjs";
|
|
20
20
|
import E from "../common/withCustomComponent.mjs";
|
|
21
21
|
import { ActionSheetContent as X } from "@progress/kendo-react-layout";
|
|
22
22
|
import Y from "../common/ListFilter.mjs";
|
|
23
|
-
const Z = "Please enter a valid value!", { sizeMap: O, roundedMap: ee } = $, I = class I extends
|
|
23
|
+
const Z = "Please enter a valid value!", { sizeMap: O, roundedMap: ee } = $, I = class I extends g.Component {
|
|
24
24
|
constructor() {
|
|
25
|
-
super(...arguments), this.state = {}, this.base = new
|
|
25
|
+
super(...arguments), this.state = {}, this.base = new S(this), this._element = null, this._suggested = "", this._input = null, this._adaptiveInput = null, this._skipFocusEvent = !1, this._isScrolling = !1, this.itemHeight = 0, this.focus = () => {
|
|
26
26
|
this._input && this._input.focus();
|
|
27
27
|
}, this.handleItemSelect = (e, t) => {
|
|
28
|
-
const s = b(this.props),
|
|
29
|
-
this.state.text && !this.mobileMode && (this.state.text && (t.data.text = ""), this.base.filterChanged("", t)), this._adaptiveInput && this._adaptiveInput.blur(), this.triggerOnChange(
|
|
28
|
+
const s = b(this.props), o = y(s[e], this.props.textField);
|
|
29
|
+
this.state.text && !this.mobileMode && (this.state.text && (t.data.text = ""), this.base.filterChanged("", t)), this._adaptiveInput && this._adaptiveInput.blur(), this.triggerOnChange(o, t);
|
|
30
30
|
}, this.itemFocus = (e, t) => {
|
|
31
31
|
const { textField: s } = this.props, i = b(this.props)[e];
|
|
32
|
-
|
|
32
|
+
w(this.state.focusedItem, i, s) || (t.data.focusedItem = i);
|
|
33
33
|
}, this.togglePopup = (e) => {
|
|
34
34
|
this.base.togglePopup(e);
|
|
35
35
|
}, this.setValidity = () => {
|
|
@@ -37,65 +37,67 @@ const Z = "Please enter a valid value!", { sizeMap: O, roundedMap: ee } = $, I =
|
|
|
37
37
|
this.validity.valid ? "" : this.props.validationMessage || Z
|
|
38
38
|
);
|
|
39
39
|
}, this.renderAdaptiveListContainer = () => {
|
|
40
|
-
const {
|
|
40
|
+
const { windowWidth: e = 0 } = this.state, t = /* @__PURE__ */ g.createElement(
|
|
41
41
|
Y,
|
|
42
42
|
{
|
|
43
43
|
value: this.value,
|
|
44
|
-
ref: (
|
|
45
|
-
this._adaptiveInput =
|
|
44
|
+
ref: (o) => {
|
|
45
|
+
this._adaptiveInput = o && o.element;
|
|
46
46
|
},
|
|
47
47
|
onChange: this.onChangeHandler,
|
|
48
48
|
onKeyDown: this.onInputKeyDown,
|
|
49
|
-
size:
|
|
49
|
+
size: "large",
|
|
50
50
|
rounded: this.props.rounded,
|
|
51
|
-
fillMode: this.props.fillMode
|
|
51
|
+
fillMode: this.props.fillMode,
|
|
52
|
+
placeholder: this.props.placeholder
|
|
52
53
|
}
|
|
53
|
-
),
|
|
54
|
-
title:
|
|
54
|
+
), s = {
|
|
55
|
+
title: this.props.adaptiveTitle || this.props.label,
|
|
56
|
+
subTitle: this.props.adaptiveSubtitle,
|
|
55
57
|
expand: this.opened,
|
|
56
|
-
onClose: (
|
|
57
|
-
windowWidth:
|
|
58
|
-
mobileFilter:
|
|
58
|
+
onClose: (o) => this.onCancel(o),
|
|
59
|
+
windowWidth: e,
|
|
60
|
+
mobileFilter: t
|
|
59
61
|
};
|
|
60
|
-
return /* @__PURE__ */
|
|
62
|
+
return /* @__PURE__ */ g.createElement(Q, { ...s }, /* @__PURE__ */ g.createElement(X, null, /* @__PURE__ */ g.createElement("div", { className: "k-list-container" }, this.listContainerContent())));
|
|
61
63
|
}, this.onCancel = (e) => {
|
|
62
64
|
const t = this.base.initState();
|
|
63
65
|
t.syntheticEvent = e, e.stopPropagation(), this.opened && this.base.togglePopup(t), t.events.push({ type: "onCancel" });
|
|
64
66
|
const s = this.state.text;
|
|
65
67
|
H(s) && s !== "" && this.base.filterChanged("", t), this.state.text && (t.data.text = ""), this.applyState(t);
|
|
66
68
|
}, this.listContainerContent = () => {
|
|
67
|
-
const { header: e, footer: t, size: s, groupStickyHeaderItemRender:
|
|
68
|
-
let { group:
|
|
69
|
-
return
|
|
69
|
+
const { header: e, footer: t, size: s, groupStickyHeaderItemRender: o, groupField: i, list: a } = this.props, d = b(this.props);
|
|
70
|
+
let { group: n } = this.state;
|
|
71
|
+
return n === void 0 && i !== void 0 && (n = y(d[0], i)), /* @__PURE__ */ g.createElement(g.Fragment, null, e && /* @__PURE__ */ g.createElement("div", { className: "k-list-header" }, e), /* @__PURE__ */ g.createElement(
|
|
70
72
|
"div",
|
|
71
73
|
{
|
|
72
|
-
className:
|
|
74
|
+
className: k("k-list", {
|
|
73
75
|
[`k-list-${this.mobileMode ? "lg" : O[s] || s}`]: s
|
|
74
76
|
})
|
|
75
77
|
},
|
|
76
|
-
!a &&
|
|
78
|
+
!a && n && d.length !== 0 && /* @__PURE__ */ g.createElement(z, { group: n, groupMode: "modern", render: o }),
|
|
77
79
|
this.renderList()
|
|
78
|
-
), t && /* @__PURE__ */
|
|
80
|
+
), t && /* @__PURE__ */ g.createElement("div", { className: "k-list-footer" }, t));
|
|
79
81
|
}, this.onScroll = (e) => {
|
|
80
82
|
this._isScrolling = !0;
|
|
81
83
|
const { list: t } = this.base, { groupField: s } = this.props;
|
|
82
|
-
let
|
|
83
|
-
if (!s || !
|
|
84
|
+
let o = b(this.props);
|
|
85
|
+
if (!s || !o.length)
|
|
84
86
|
return;
|
|
85
87
|
const i = this.itemHeight || (t ? t.children[0].offsetHeight : 0), d = e.target.scrollTop;
|
|
86
|
-
s && (
|
|
87
|
-
let
|
|
88
|
-
for (let r = 1; r <
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
group:
|
|
88
|
+
s && (o = this.base.getGroupedDataModernMode(o, s));
|
|
89
|
+
let n = o[0][s];
|
|
90
|
+
for (let r = 1; r < o.length && !(i * r > d); r++)
|
|
91
|
+
o[r] && o[r][s] && (n = o[r][s]);
|
|
92
|
+
n !== this.state.group && this.setState({
|
|
93
|
+
group: n
|
|
92
94
|
});
|
|
93
95
|
}, this.handleItemClick = (e, t) => {
|
|
94
96
|
this.base.handleItemClick(e, t), this._valueDuringOnChange = void 0;
|
|
95
97
|
}, this.onChangeHandler = (e) => {
|
|
96
|
-
const s = this.base.initState(),
|
|
98
|
+
const s = this.base.initState(), o = this.mobileMode ? e.target.element : e.currentTarget, i = o.value, a = o.selectionEnd === i.length;
|
|
97
99
|
s.syntheticEvent = e;
|
|
98
|
-
const d = this._suggested,
|
|
100
|
+
const d = this._suggested, n = this.value, r = n && n.substring(0, n.length - d.length), l = r && r === i, h = r && r.length > i.length, { suggest: v } = this.props, p = this.props.opened !== void 0 ? this.props.opened : this.state.opened;
|
|
99
101
|
if (v !== void 0 && v !== !1) {
|
|
100
102
|
l || h || !a ? this._suggested = "" : this.suggestValue(i);
|
|
101
103
|
const u = i + this._suggested, f = { userInput: i, value: this._suggested };
|
|
@@ -104,77 +106,77 @@ const Z = "Please enter a valid value!", { sizeMap: O, roundedMap: ee } = $, I =
|
|
|
104
106
|
this._suggested = "", this.triggerOnChange(i, s);
|
|
105
107
|
(!p && i || p && !i) && this.togglePopup(s), s.data.focusedItem = void 0, this.applyState(s), this.setState({ group: void 0 });
|
|
106
108
|
}, this.clearButtonClick = (e) => {
|
|
107
|
-
const s = this.base.initState(),
|
|
109
|
+
const s = this.base.initState(), o = this.props.opened !== void 0 ? this.props.opened : this.state.opened;
|
|
108
110
|
s.syntheticEvent = e;
|
|
109
111
|
const i = "";
|
|
110
|
-
this._suggested = "", this.triggerOnChange(i, s), this.state.focusedItem !== void 0 && (s.data.focusedItem = void 0),
|
|
112
|
+
this._suggested = "", this.triggerOnChange(i, s), this.state.focusedItem !== void 0 && (s.data.focusedItem = void 0), o && this.togglePopup(s), this.applyState(s);
|
|
111
113
|
}, this.onInputKeyDown = (e) => {
|
|
112
|
-
const { skipDisabledItems: t, groupField: s, textField:
|
|
114
|
+
const { skipDisabledItems: t, groupField: s, textField: o } = this.props, i = b(this.props);
|
|
113
115
|
this._isScrolling && (this._isScrolling = !1);
|
|
114
|
-
const a = this.focusedIndex(), d = i[a],
|
|
116
|
+
const a = this.focusedIndex(), d = i[a], n = e.keyCode, r = e.altKey, l = this.props.opened !== void 0 ? this.props.opened : this.state.opened, h = this.base.initState();
|
|
115
117
|
h.syntheticEvent = e;
|
|
116
118
|
const v = () => {
|
|
117
119
|
l && e.preventDefault();
|
|
118
120
|
};
|
|
119
|
-
if (r &&
|
|
121
|
+
if (r && n === m.down)
|
|
120
122
|
this.setState({
|
|
121
123
|
opened: !0
|
|
122
124
|
});
|
|
123
|
-
else if (r &&
|
|
125
|
+
else if (r && n === m.up)
|
|
124
126
|
this.setState({
|
|
125
127
|
opened: !1
|
|
126
128
|
});
|
|
127
|
-
else if (l &&
|
|
129
|
+
else if (l && n === m.pageUp)
|
|
128
130
|
v(), this.base.scrollPopupByPageSize(-1);
|
|
129
|
-
else if (l &&
|
|
131
|
+
else if (l && n === m.pageDown)
|
|
130
132
|
v(), this.base.scrollPopupByPageSize(1);
|
|
131
|
-
else if (l && (
|
|
133
|
+
else if (l && (n === m.enter || n === m.esc))
|
|
132
134
|
v(), t === !1 && d && d.disabled ? (l && this.togglePopup(h), this.applyState(h)) : this.applyInputValue(e.currentTarget.value, h, e.keyCode);
|
|
133
|
-
else if (!l &&
|
|
135
|
+
else if (!l && n === m.esc) {
|
|
134
136
|
const p = "";
|
|
135
137
|
this._suggested = "", this.triggerOnChange(p, h), this.state.focusedItem !== void 0 && (h.data.focusedItem = void 0), this.applyState(h);
|
|
136
|
-
} else if (
|
|
137
|
-
if (s !== "" &&
|
|
138
|
+
} else if (n === m.up || n === m.down) {
|
|
139
|
+
if (s !== "" && o)
|
|
138
140
|
if (!this.props.skipDisabledItems && l)
|
|
139
|
-
this.onNavigate(h,
|
|
141
|
+
this.onNavigate(h, n);
|
|
140
142
|
else {
|
|
141
143
|
let p = 0;
|
|
142
|
-
if (
|
|
143
|
-
const u = i.slice(a + 1).find((f) => !f.disabled && f[
|
|
144
|
-
p = u && i.findIndex((f) => f[
|
|
145
|
-
} else if (
|
|
144
|
+
if (n === m.down || n === m.right) {
|
|
145
|
+
const u = i.slice(a + 1).find((f) => !f.disabled && f[o]);
|
|
146
|
+
p = u && i.findIndex((f) => f[o] === u[o]);
|
|
147
|
+
} else if (n === m.up || n === m.left) {
|
|
146
148
|
let u;
|
|
147
149
|
if (a === -1)
|
|
148
|
-
u = i, p = i.findIndex((f) => !f.disabled && f[
|
|
150
|
+
u = i, p = i.findIndex((f) => !f.disabled && f[o]);
|
|
149
151
|
else {
|
|
150
152
|
u = i.slice(0, a);
|
|
151
153
|
let f = u.pop();
|
|
152
154
|
for (; f && f.disabled; )
|
|
153
155
|
f = u.pop();
|
|
154
|
-
p = f && i.findIndex((
|
|
156
|
+
p = f && i.findIndex((C) => C[o] === f[o]);
|
|
155
157
|
}
|
|
156
158
|
}
|
|
157
159
|
if (p !== void 0) {
|
|
158
160
|
const u = p - a;
|
|
159
|
-
this.onNavigate(h,
|
|
160
|
-
} else p === void 0 && i.findIndex((u) => u[
|
|
161
|
+
this.onNavigate(h, n, u);
|
|
162
|
+
} else p === void 0 && i.findIndex((u) => u[o]) === i.length - 1 && this.onNavigate(h, n);
|
|
161
163
|
}
|
|
162
164
|
else if (!this.props.skipDisabledItems && l)
|
|
163
|
-
this.onNavigate(h,
|
|
165
|
+
this.onNavigate(h, n);
|
|
164
166
|
else {
|
|
165
167
|
let p = null;
|
|
166
|
-
if (
|
|
168
|
+
if (n === m.down || n === m.right)
|
|
167
169
|
p = i.slice(a + 1).find((u) => !u.disabled);
|
|
168
|
-
else if (
|
|
170
|
+
else if (n === m.up || n === m.left) {
|
|
169
171
|
const u = i.slice(0, a);
|
|
170
172
|
for (p = u.pop(); p && p.disabled; )
|
|
171
173
|
p = u.pop();
|
|
172
174
|
}
|
|
173
175
|
if (p) {
|
|
174
176
|
const u = p.id - a - 1;
|
|
175
|
-
this.onNavigate(h,
|
|
177
|
+
this.onNavigate(h, n, u);
|
|
176
178
|
} else
|
|
177
|
-
this.onNavigate(h,
|
|
179
|
+
this.onNavigate(h, n);
|
|
178
180
|
}
|
|
179
181
|
this.applyState(h), v();
|
|
180
182
|
}
|
|
@@ -254,12 +256,12 @@ const Z = "Please enter a valid value!", { sizeMap: O, roundedMap: ee } = $, I =
|
|
|
254
256
|
*/
|
|
255
257
|
componentDidUpdate(e, t) {
|
|
256
258
|
var p;
|
|
257
|
-
const { groupField: s = "" } = this.props,
|
|
259
|
+
const { groupField: s = "" } = this.props, o = b(this.props), { data: i = [] } = e, a = this.focusedIndex(), d = o[a], n = i !== o, r = d !== void 0 && t.focusedItem !== d, l = this.props.opened !== void 0 ? this.props.opened : this.state.opened, h = e.opened !== void 0 ? e.opened : t.opened, v = !h && l;
|
|
258
260
|
if (s === "")
|
|
259
|
-
(l && (r ||
|
|
261
|
+
(l && (r || n) || v) && this.base.scrollToItem(a);
|
|
260
262
|
else if (!this._isScrolling) {
|
|
261
|
-
const u = (p = this.base.getGroupedDataModernMode(
|
|
262
|
-
v && (
|
|
263
|
+
const u = (p = this.base.getGroupedDataModernMode(o, s)) == null ? void 0 : p.indexOf(d);
|
|
264
|
+
v && (o && o.length !== 0 && this.base.resetGroupStickyHeader(o[0][s], this), this.base.scrollToItem(u)), l && h && r && this.base.scrollToItem(u);
|
|
263
265
|
}
|
|
264
266
|
this.setValidity();
|
|
265
267
|
}
|
|
@@ -280,38 +282,38 @@ const Z = "Please enter a valid value!", { sizeMap: O, roundedMap: ee } = $, I =
|
|
|
280
282
|
* @hidden
|
|
281
283
|
*/
|
|
282
284
|
render() {
|
|
283
|
-
const { dir: e, disabled: t, label: s, className:
|
|
285
|
+
const { dir: e, disabled: t, label: s, className: o, style: i, loading: a, suggest: d, size: n, rounded: r, fillMode: l } = this.props, h = !this.validityStyles || this.validity.valid, v = this.base, p = this.value, u = this.props.clearButton !== !1 && !a && !!p, f = this.props.id || this._inputId, C = this.state.focused;
|
|
284
286
|
typeof d == "string" && (this._suggested = d);
|
|
285
|
-
const [P, B] = E(this.props.prefix ||
|
|
287
|
+
const [P, B] = E(this.props.prefix || g.Fragment), [T, V] = E(this.props.suffix || g.Fragment), F = /* @__PURE__ */ g.createElement(g.Fragment, null, /* @__PURE__ */ g.createElement(
|
|
286
288
|
"span",
|
|
287
289
|
{
|
|
288
|
-
className:
|
|
289
|
-
[`k-input-${O[
|
|
290
|
+
className: k("k-autocomplete k-input", o, {
|
|
291
|
+
[`k-input-${O[n] || n}`]: n,
|
|
290
292
|
[`k-rounded-${ee[r] || r}`]: r,
|
|
291
293
|
[`k-input-${l}`]: l,
|
|
292
294
|
"k-invalid": !h,
|
|
293
|
-
"k-focus":
|
|
295
|
+
"k-focus": C && !t,
|
|
294
296
|
"k-loading": a,
|
|
295
297
|
"k-required": this.required,
|
|
296
298
|
"k-disabled": t
|
|
297
299
|
}),
|
|
298
|
-
ref: (
|
|
299
|
-
this._element =
|
|
300
|
+
ref: (x) => {
|
|
301
|
+
this._element = x, v.wrapper = x;
|
|
300
302
|
},
|
|
301
303
|
style: s ? { ...i, width: void 0 } : i,
|
|
302
304
|
dir: e,
|
|
303
|
-
onFocus: this.handleFocus,
|
|
305
|
+
onFocus: this.mobileMode ? (x) => this.handleWrapperClick(x) : this.handleFocus,
|
|
304
306
|
onBlur: this.handleBlur,
|
|
305
307
|
onClick: this.handleWrapperClick
|
|
306
308
|
},
|
|
307
|
-
this.props.prefix && /* @__PURE__ */
|
|
309
|
+
this.props.prefix && /* @__PURE__ */ g.createElement(P, { ...B }),
|
|
308
310
|
this.renderSearchBar(p || "", f),
|
|
309
|
-
a && /* @__PURE__ */
|
|
310
|
-
u && !a && /* @__PURE__ */
|
|
311
|
-
this.props.suffix && /* @__PURE__ */
|
|
311
|
+
a && /* @__PURE__ */ g.createElement(K, { className: "k-input-loading-icon", name: "loading" }),
|
|
312
|
+
u && !a && /* @__PURE__ */ g.createElement(J, { onClick: this.clearButtonClick, key: "clearbutton" }),
|
|
313
|
+
this.props.suffix && /* @__PURE__ */ g.createElement(T, { ...V }),
|
|
312
314
|
!this.mobileMode && this.renderListContainer()
|
|
313
315
|
), this.mobileMode && this.renderAdaptiveListContainer());
|
|
314
|
-
return s ? /* @__PURE__ */
|
|
316
|
+
return s ? /* @__PURE__ */ g.createElement(
|
|
315
317
|
j,
|
|
316
318
|
{
|
|
317
319
|
label: s,
|
|
@@ -320,17 +322,17 @@ const Z = "Please enter a valid value!", { sizeMap: O, roundedMap: ee } = $, I =
|
|
|
320
322
|
editorValid: h,
|
|
321
323
|
editorDisabled: t,
|
|
322
324
|
style: { width: i ? i.width : void 0 },
|
|
323
|
-
children:
|
|
325
|
+
children: F
|
|
324
326
|
}
|
|
325
|
-
) :
|
|
327
|
+
) : F;
|
|
326
328
|
}
|
|
327
329
|
/**
|
|
328
330
|
* @hidden
|
|
329
331
|
*/
|
|
330
332
|
onNavigate(e, t, s) {
|
|
331
|
-
const
|
|
333
|
+
const o = this.value, { textField: i, focusedItemIndex: a } = this.props, d = b(this.props), n = this.state.focusedItem !== void 0 ? d.findIndex((l) => w(l, this.state.focusedItem, i)) : a ? a(d, o, i) : d.indexOf(M(d, o, i)), r = this.base.navigation.navigate({
|
|
332
334
|
keyCode: t,
|
|
333
|
-
current:
|
|
335
|
+
current: n,
|
|
334
336
|
max: d.length - 1,
|
|
335
337
|
min: 0,
|
|
336
338
|
skipItems: s || void 0
|
|
@@ -341,20 +343,20 @@ const Z = "Please enter a valid value!", { sizeMap: O, roundedMap: ee } = $, I =
|
|
|
341
343
|
* @hidden
|
|
342
344
|
*/
|
|
343
345
|
applyInputValue(e, t, s) {
|
|
344
|
-
const
|
|
345
|
-
if (this._suggested = "",
|
|
346
|
+
const o = this.props.opened !== void 0 ? this.props.opened : this.state.opened, { textField: i } = this.props, a = b(this.props), d = this.focusedIndex(), n = a[d];
|
|
347
|
+
if (this._suggested = "", o && s === m.enter && n && !n.disabled) {
|
|
346
348
|
const r = y(a[this.focusedIndex(e)], i);
|
|
347
349
|
this.triggerOnChange(r, t);
|
|
348
350
|
}
|
|
349
|
-
|
|
351
|
+
o && this.togglePopup(t), this.applyState(t);
|
|
350
352
|
}
|
|
351
353
|
renderSearchBar(e, t) {
|
|
352
|
-
const s = this.base, { placeholder:
|
|
353
|
-
return /* @__PURE__ */
|
|
354
|
+
const s = this.base, { placeholder: o, tabIndex: i, disabled: a, readonly: d, inputAttributes: n } = this.props, { focused: r } = this.state, l = this.props.opened !== void 0 ? this.props.opened : this.state.opened;
|
|
355
|
+
return /* @__PURE__ */ g.createElement(
|
|
354
356
|
N,
|
|
355
357
|
{
|
|
356
358
|
id: t,
|
|
357
|
-
placeholder:
|
|
359
|
+
placeholder: o,
|
|
358
360
|
tabIndex: i,
|
|
359
361
|
accessKey: this.props.accessKey,
|
|
360
362
|
value: e,
|
|
@@ -378,14 +380,14 @@ const Z = "Please enter a valid value!", { sizeMap: O, roundedMap: ee } = $, I =
|
|
|
378
380
|
ariaDescribedBy: this.props.ariaDescribedBy,
|
|
379
381
|
ariaRequired: this.required,
|
|
380
382
|
render: this.props.valueRender,
|
|
381
|
-
inputAttributes:
|
|
383
|
+
inputAttributes: n
|
|
382
384
|
}
|
|
383
385
|
);
|
|
384
386
|
}
|
|
385
387
|
renderListContainer() {
|
|
386
|
-
const e = this.base, { dir: t, groupField: s } = this.props,
|
|
387
|
-
let { group:
|
|
388
|
-
return
|
|
388
|
+
const e = this.base, { dir: t, groupField: s } = this.props, o = b(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;
|
|
389
|
+
let { group: n } = this.state;
|
|
390
|
+
return n === void 0 && s !== void 0 && (n = y(o[0], s)), /* @__PURE__ */ g.createElement(
|
|
389
391
|
R,
|
|
390
392
|
{
|
|
391
393
|
width: d,
|
|
@@ -393,24 +395,24 @@ const Z = "Please enter a valid value!", { sizeMap: O, roundedMap: ee } = $, I =
|
|
|
393
395
|
...i,
|
|
394
396
|
anchor: i.anchor || this.element,
|
|
395
397
|
show: a,
|
|
396
|
-
popupClass:
|
|
398
|
+
popupClass: k(i.popupClass, "k-list-container", "k-autocomplete-popup")
|
|
397
399
|
},
|
|
398
400
|
dir: t !== void 0 ? t : this.base.dirCalculated,
|
|
399
|
-
itemsCount: [
|
|
401
|
+
itemsCount: [o.length]
|
|
400
402
|
},
|
|
401
403
|
this.listContainerContent()
|
|
402
404
|
);
|
|
403
405
|
}
|
|
404
406
|
renderList() {
|
|
405
|
-
const e = this.base, t = e.getPopupSettings(), { textField: s, listNoDataRender:
|
|
406
|
-
return /* @__PURE__ */
|
|
407
|
-
|
|
407
|
+
const e = this.base, t = e.getPopupSettings(), { textField: s, listNoDataRender: o, itemRender: i, groupHeaderItemRender: a } = this.props, d = b(this.props), n = this.value, r = this.props.opened !== void 0 ? this.props.opened : this.state.opened;
|
|
408
|
+
return /* @__PURE__ */ g.createElement(
|
|
409
|
+
L,
|
|
408
410
|
{
|
|
409
411
|
id: e.listBoxId,
|
|
410
412
|
show: r,
|
|
411
413
|
data: d.slice(),
|
|
412
414
|
focusedIndex: this.focusedIndex(),
|
|
413
|
-
value:
|
|
415
|
+
value: n,
|
|
414
416
|
textField: s,
|
|
415
417
|
valueField: s,
|
|
416
418
|
highlightSelected: !1,
|
|
@@ -425,7 +427,7 @@ const Z = "Please enter a valid value!", { sizeMap: O, roundedMap: ee } = $, I =
|
|
|
425
427
|
onClick: this.handleItemClick,
|
|
426
428
|
itemRender: i,
|
|
427
429
|
groupHeaderItemRender: a,
|
|
428
|
-
noDataRender:
|
|
430
|
+
noDataRender: o,
|
|
429
431
|
onMouseDown: (l) => l.preventDefault(),
|
|
430
432
|
onScroll: this.onScroll
|
|
431
433
|
}
|
|
@@ -442,21 +444,21 @@ const Z = "Please enter a valid value!", { sizeMap: O, roundedMap: ee } = $, I =
|
|
|
442
444
|
}
|
|
443
445
|
suggestValue(e) {
|
|
444
446
|
if (this._suggested = "", e) {
|
|
445
|
-
const { textField: t } = this.props, s = b(this.props),
|
|
446
|
-
if (
|
|
447
|
-
const i = y(
|
|
447
|
+
const { textField: t } = this.props, s = b(this.props), o = s[A(s, e, t)];
|
|
448
|
+
if (o) {
|
|
449
|
+
const i = y(o, t);
|
|
448
450
|
e.toLowerCase() !== i.toLowerCase() && (this._suggested = i.substring(e.length));
|
|
449
451
|
}
|
|
450
452
|
}
|
|
451
453
|
}
|
|
452
454
|
focusedIndex(e) {
|
|
453
|
-
const { textField: t, focusedItemIndex: s, skipDisabledItems:
|
|
455
|
+
const { textField: t, focusedItemIndex: s, skipDisabledItems: o } = this.props, i = b(this.props), a = e !== void 0 ? e : this.value;
|
|
454
456
|
if (this.state.focusedItem !== void 0)
|
|
455
|
-
return i.findIndex((
|
|
457
|
+
return i.findIndex((n) => w(n, this.state.focusedItem, t));
|
|
456
458
|
if (s)
|
|
457
459
|
return s(i, a, t);
|
|
458
460
|
const d = i.indexOf(M(i, a, t));
|
|
459
|
-
return
|
|
461
|
+
return o && t && d === -1 ? i.findIndex((n) => !n.disabled && n[t]) : Math.max(0, d);
|
|
460
462
|
}
|
|
461
463
|
calculateMedia(e) {
|
|
462
464
|
for (const t of e)
|
|
@@ -464,31 +466,32 @@ const Z = "Please enter a valid value!", { sizeMap: O, roundedMap: ee } = $, I =
|
|
|
464
466
|
}
|
|
465
467
|
};
|
|
466
468
|
I.displayName = "AutoComplete", I.propTypes = {
|
|
467
|
-
...
|
|
468
|
-
size:
|
|
469
|
-
rounded:
|
|
470
|
-
fillMode:
|
|
471
|
-
groupField:
|
|
472
|
-
suggest:
|
|
473
|
-
placeholder:
|
|
474
|
-
value:
|
|
475
|
-
defaultValue:
|
|
476
|
-
validationMessage:
|
|
477
|
-
required:
|
|
478
|
-
readonly:
|
|
479
|
-
clearButton:
|
|
480
|
-
valueRender:
|
|
481
|
-
id:
|
|
482
|
-
ariaLabelledBy:
|
|
483
|
-
ariaDescribedBy:
|
|
484
|
-
list:
|
|
485
|
-
adaptive:
|
|
486
|
-
adaptiveTitle:
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
469
|
+
...S.basicPropTypes,
|
|
470
|
+
size: c.oneOf([null, "small", "medium", "large"]),
|
|
471
|
+
rounded: c.oneOf([null, "small", "medium", "large", "full"]),
|
|
472
|
+
fillMode: c.oneOf([null, "solid", "flat", "outline"]),
|
|
473
|
+
groupField: c.string,
|
|
474
|
+
suggest: c.oneOfType([c.bool, c.string]),
|
|
475
|
+
placeholder: c.string,
|
|
476
|
+
value: c.string,
|
|
477
|
+
defaultValue: c.string,
|
|
478
|
+
validationMessage: c.string,
|
|
479
|
+
required: c.bool,
|
|
480
|
+
readonly: c.bool,
|
|
481
|
+
clearButton: c.bool,
|
|
482
|
+
valueRender: c.func,
|
|
483
|
+
id: c.string,
|
|
484
|
+
ariaLabelledBy: c.string,
|
|
485
|
+
ariaDescribedBy: c.string,
|
|
486
|
+
list: c.any,
|
|
487
|
+
adaptive: c.bool,
|
|
488
|
+
adaptiveTitle: c.string,
|
|
489
|
+
adaptiveSubtitle: c.string,
|
|
490
|
+
onCancel: c.func,
|
|
491
|
+
skipDisabledItems: c.bool,
|
|
492
|
+
inputAttributes: c.object
|
|
490
493
|
}, I.defaultProps = {
|
|
491
|
-
...
|
|
494
|
+
...S.defaultProps,
|
|
492
495
|
size: "medium",
|
|
493
496
|
rounded: "medium",
|
|
494
497
|
fillMode: "solid",
|
|
@@ -496,16 +499,16 @@ I.displayName = "AutoComplete", I.propTypes = {
|
|
|
496
499
|
prefix: void 0,
|
|
497
500
|
suffix: void 0
|
|
498
501
|
};
|
|
499
|
-
let
|
|
502
|
+
let _ = I;
|
|
500
503
|
const te = q(), se = W(
|
|
501
504
|
G(
|
|
502
505
|
te,
|
|
503
|
-
U(
|
|
506
|
+
U(_)
|
|
504
507
|
)
|
|
505
508
|
);
|
|
506
509
|
se.displayName = "KendoReactAutoComplete";
|
|
507
510
|
export {
|
|
508
511
|
se as AutoComplete,
|
|
509
512
|
te as AutoCompletePropsContext,
|
|
510
|
-
|
|
513
|
+
_ as AutoCompleteWithoutContext
|
|
511
514
|
};
|