@progress/kendo-react-dropdowns 9.2.0-develop.2 → 9.2.0-develop.3

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.
Files changed (70) hide show
  1. package/AutoComplete/AutoComplete.js +2 -2
  2. package/AutoComplete/AutoComplete.mjs +282 -219
  3. package/ComboBox/ComboBox.js +2 -2
  4. package/ComboBox/ComboBox.mjs +38 -39
  5. package/DropDownList/DropDownList.js +2 -2
  6. package/DropDownList/DropDownList.mjs +116 -117
  7. package/DropDownTree/DropDownTree.js +2 -2
  8. package/DropDownTree/DropDownTree.mjs +67 -68
  9. package/DropDownTree/ListNoData.js +1 -1
  10. package/DropDownTree/ListNoData.mjs +1 -1
  11. package/DropDownTree/useDropdownWidth.js +1 -1
  12. package/DropDownTree/useDropdownWidth.mjs +1 -1
  13. package/LICENSE.md +1 -1
  14. package/MultiColumnComboBox/MultiColumnComboBox.js +1 -1
  15. package/MultiColumnComboBox/MultiColumnComboBox.mjs +1 -1
  16. package/MultiSelect/MultiSelect.js +2 -2
  17. package/MultiSelect/MultiSelect.mjs +42 -43
  18. package/MultiSelect/TagList.js +1 -1
  19. package/MultiSelect/TagList.mjs +1 -1
  20. package/MultiSelectTree/MultiSelectTree.js +2 -2
  21. package/MultiSelectTree/MultiSelectTree.mjs +65 -66
  22. package/MultiSelectTree/utils.js +1 -1
  23. package/MultiSelectTree/utils.mjs +1 -1
  24. package/README.md +1 -1
  25. package/common/AdaptiveMode.js +2 -2
  26. package/common/AdaptiveMode.mjs +44 -42
  27. package/common/ClearButton.js +1 -1
  28. package/common/ClearButton.mjs +1 -1
  29. package/common/DropDownBase.js +1 -1
  30. package/common/DropDownBase.mjs +1 -1
  31. package/common/GroupStickyHeader.js +1 -1
  32. package/common/GroupStickyHeader.mjs +1 -1
  33. package/common/List.js +1 -1
  34. package/common/List.mjs +1 -1
  35. package/common/ListContainer.js +1 -1
  36. package/common/ListContainer.mjs +1 -1
  37. package/common/ListDefaultItem.js +1 -1
  38. package/common/ListDefaultItem.mjs +1 -1
  39. package/common/ListFilter.js +1 -1
  40. package/common/ListFilter.mjs +1 -1
  41. package/common/ListGroupItem.js +1 -1
  42. package/common/ListGroupItem.mjs +1 -1
  43. package/common/ListItem.js +1 -1
  44. package/common/ListItem.mjs +1 -1
  45. package/common/MultiColumnList.js +1 -1
  46. package/common/MultiColumnList.mjs +1 -1
  47. package/common/Navigation.js +1 -1
  48. package/common/Navigation.mjs +1 -1
  49. package/common/SearchBar.js +1 -1
  50. package/common/SearchBar.mjs +1 -1
  51. package/common/VirtualScrollStatic.js +1 -1
  52. package/common/VirtualScrollStatic.mjs +1 -1
  53. package/common/settings.js +1 -1
  54. package/common/settings.mjs +1 -1
  55. package/common/utils.js +1 -1
  56. package/common/utils.mjs +1 -1
  57. package/common/withCustomComponent.js +1 -1
  58. package/common/withCustomComponent.mjs +1 -1
  59. package/dist/cdn/js/kendo-react-dropdowns.js +2 -2
  60. package/index.d.mts +31 -2
  61. package/index.d.ts +31 -2
  62. package/index.js +1 -1
  63. package/index.mjs +1 -1
  64. package/messages/index.js +1 -1
  65. package/messages/index.mjs +1 -1
  66. package/package-metadata.js +1 -1
  67. package/package-metadata.mjs +2 -2
  68. package/package.json +9 -9
  69. package/common/constants.js +0 -8
  70. package/common/constants.mjs +0 -13
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @license
3
3
  *-------------------------------------------------------------------------------------------
4
- * Copyright © 2024 Progress Software Corporation. All rights reserved.
4
+ * Copyright © 2025 Progress Software Corporation. All rights reserved.
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react"),f=require("prop-types"),q=require("../common/SearchBar.js"),E=require("../common/ListContainer.js"),T=require("../common/List.js"),k=require("../common/DropDownBase.js"),N=require("../common/GroupStickyHeader.js"),m=require("../common/utils.js"),p=require("@progress/kendo-react-common"),L=require("@progress/kendo-react-labels"),R=require("../package-metadata.js"),H=require("../common/ClearButton.js"),F=require("../common/withCustomComponent.js");function z(x){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(x){for(const e in x)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(x,e);Object.defineProperty(a,e,s.get?s:{enumerable:!0,get:()=>x[e]})}}return a.default=x,Object.freeze(a)}const I=z(B),A="Please enter a valid value!",{sizeMap:_,roundedMap:j}=p.kendoThemeMaps,b=class b extends I.Component{constructor(a){super(a),this.state={},this.base=new k(this),this._element=null,this._suggested="",this._input=null,this._isScrolling=!1,this.itemHeight=0,this.focus=()=>{this._input&&this._input.focus()},this.handleItemSelect=(e,s)=>{const i=m.getFilteredData(this.props),t=m.getItemValue(i[e],this.props.textField);this.triggerOnChange(t,s)},this.itemFocus=(e,s)=>{const{textField:i}=this.props,o=m.getFilteredData(this.props)[e];m.areSame(this.state.focusedItem,o,i)||(s.data.focusedItem=o)},this.togglePopup=e=>{this.base.togglePopup(e)},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||A)},this.onScroll=e=>{this._isScrolling=!0;const{list:s}=this.base,{groupField:i}=this.props;let t=m.getFilteredData(this.props);if(!i||!t.length)return;const o=this.itemHeight||(s?s.children[0].offsetHeight:0),l=e.target.scrollTop;i&&(t=this.base.getGroupedDataModernMode(t,i));let n=t[0][i];for(let r=1;r<t.length&&!(o*r>l);r++)t[r]&&t[r][i]&&(n=t[r][i]);n!==this.state.group&&this.setState({group:n})},this.handleItemClick=(e,s)=>{this.base.handleItemClick(e,s),this._valueDuringOnChange=void 0},this.onChangeHandler=e=>{const i=this.base.initState(),t=e.currentTarget,o=t.value,d=t.selectionEnd===o.length;i.syntheticEvent=e;const l=this._suggested,n=this.value,r=n&&n.substring(0,n.length-l.length),g=r&&r===o,h=r&&r.length>o.length,{suggest:v}=this.props,u=this.props.opened!==void 0?this.props.opened:this.state.opened;if(v!==void 0&&v!==!1){g||h||!d?this._suggested="":this.suggestValue(o);const c=o+this._suggested,y={userInput:o,value:this._suggested};this.triggerOnChange(c,i,{suggestion:y})}else this._suggested="",this.triggerOnChange(o,i);(!u&&o||u&&!o)&&this.togglePopup(i),i.data.focusedItem=void 0,this.applyState(i),this.setState({group:void 0})},this.clearButtonClick=e=>{const i=this.base.initState(),t=this.props.opened!==void 0?this.props.opened:this.state.opened;i.syntheticEvent=e;const o="";this._suggested="",this.triggerOnChange(o,i),this.state.focusedItem!==void 0&&(i.data.focusedItem=void 0),t&&this.togglePopup(i),this.applyState(i)},this.onInputKeyDown=e=>{const{skipDisabledItems:s,groupField:i,textField:t}=this.props,o=m.getFilteredData(this.props);this._isScrolling&&(this._isScrolling=!1);const d=this.focusedIndex(),l=o[d],n=e.keyCode,r=e.altKey,g=this.props.opened!==void 0?this.props.opened:this.state.opened,h=this.base.initState();h.syntheticEvent=e;const v=()=>{g&&e.preventDefault()};if(r&&n===p.Keys.down)this.setState({opened:!0});else if(r&&n===p.Keys.up)this.setState({opened:!1});else if(g&&n===p.Keys.pageUp)v(),this.base.scrollPopupByPageSize(-1);else if(g&&n===p.Keys.pageDown)v(),this.base.scrollPopupByPageSize(1);else if(g&&(n===p.Keys.enter||n===p.Keys.esc))v(),s===!1&&l&&l.disabled?(g&&this.togglePopup(h),this.applyState(h)):this.applyInputValue(e.currentTarget.value,h,e.keyCode);else if(!g&&n===p.Keys.esc){const u="";this._suggested="",this.triggerOnChange(u,h),this.state.focusedItem!==void 0&&(h.data.focusedItem=void 0),this.applyState(h)}else if(n===p.Keys.up||n===p.Keys.down){if(i!==""&&t)if(!this.props.skipDisabledItems&&g)this.onNavigate(h,n);else{let u=0;if(n===p.Keys.down||n===p.Keys.right){const c=o.slice(d+1).find(y=>!y.disabled&&y[t]);u=c&&o.findIndex(y=>y[t]===c[t])}else if(n===p.Keys.up||n===p.Keys.left){let c;if(d===-1)c=o,u=o.findIndex(y=>!y.disabled&&y[t]);else{c=o.slice(0,d);let y=c.pop();for(;y&&y.disabled;)y=c.pop();u=y&&o.findIndex(C=>C[t]===y[t])}}if(u!==void 0){const c=u-d;this.onNavigate(h,n,c)}else u===void 0&&o.findIndex(c=>c[t])===o.length-1&&this.onNavigate(h,n)}else if(!this.props.skipDisabledItems&&g)this.onNavigate(h,n);else{let u=null;if(n===p.Keys.down||n===p.Keys.right)u=o.slice(d+1).find(c=>!c.disabled);else if(n===p.Keys.up||n===p.Keys.left){const c=o.slice(0,d);for(u=c.pop();u&&u.disabled;)u=c.pop()}if(u){const c=u.id-d-1;this.onNavigate(h,n,c)}else this.onNavigate(h,n)}this.applyState(h),v()}},this.handleBlur=e=>{if(this.state.focused){const s=this.base.initState();s.data.focused=!1,s.events.push({type:"onBlur"}),s.syntheticEvent=e,this.applyInputValue(e.currentTarget.value,s)}},p.validatePackage(R.packageMetadata)}get _inputId(){return this.props.id+"-accessibility-id"}get element(){return this._element}get value(){return this._valueDuringOnChange!==void 0?this._valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value!==void 0?this.state.value:this.props.defaultValue!==void 0?this.props.defaultValue:""}get name(){return this.props.name}get validity(){const a=this.props.validationMessage!==void 0,e=!this.required||this.value!=="",s=this.props.valid!==void 0?this.props.valid:e;return{customError:a,valid:s,valueMissing:this.value===null}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:b.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:b.defaultProps.required}componentDidUpdate(a,e){var v;const{groupField:s=""}=this.props,i=m.getFilteredData(this.props),{data:t=[]}=a,o=this.focusedIndex(),d=i[o],l=t!==i,n=d!==void 0&&e.focusedItem!==d,r=this.props.opened!==void 0?this.props.opened:this.state.opened,g=a.opened!==void 0?a.opened:e.opened,h=!g&&r;if(s==="")(r&&(n||l)||h)&&this.base.scrollToItem(o);else if(!this._isScrolling){const u=(v=this.base.getGroupedDataModernMode(i,s))==null?void 0:v.indexOf(d);h&&(i&&i.length!==0&&this.base.resetGroupStickyHeader(i[0][s],this),this.base.scrollToItem(u)),r&&g&&n&&this.base.scrollToItem(u)}this.setValidity()}componentDidMount(){this.base.didMount(),this.setValidity()}render(){const{dir:a,disabled:e,label:s,className:i,style:t,loading:o,suggest:d,size:l,rounded:n,fillMode:r}=this.props,g=!this.validityStyles||this.validity.valid,h=this.base,v=this.value,u=this.props.clearButton!==!1&&!o&&!!v,c=this.props.id||this._inputId,y=this.state.focused;typeof d=="string"&&(this._suggested=d);const[C,K]=F(this.props.prefix||I.Fragment),[V,M]=F(this.props.suffix||I.Fragment),D=I.createElement("span",{className:p.classNames("k-autocomplete k-input",i,{[`k-input-${_[l]||l}`]:l,[`k-rounded-${j[n]||n}`]:n,[`k-input-${r}`]:r,"k-invalid":!g,"k-focus":y&&!e,"k-loading":o,"k-required":this.required,"k-disabled":e}),ref:w=>{this._element=w,h.wrapper=w},style:s?{...t,width:void 0}:t,dir:a},this.props.prefix&&I.createElement(C,{...K}),this.renderSearchBar(v||"",c),o&&I.createElement(p.IconWrap,{className:"k-input-loading-icon",name:"loading"}),u&&!o&&I.createElement(H,{onClick:this.clearButtonClick,key:"clearbutton"}),this.props.suffix&&I.createElement(V,{...M}),this.renderListContainer());return s?I.createElement(L.FloatingLabel,{label:s,editorId:c,editorValue:v,editorValid:g,editorDisabled:e,style:{width:t?t.width:void 0},children:D}):D}onNavigate(a,e,s){const i=this.value,{textField:t,focusedItemIndex:o}=this.props,d=m.getFilteredData(this.props),l=this.state.focusedItem!==void 0?d.findIndex(r=>m.areSame(r,this.state.focusedItem,t)):o?o(d,i,t):d.indexOf(m.getFocusedItem(d,i,t)),n=this.base.navigation.navigate({keyCode:e,current:l,max:d.length-1,min:0,skipItems:s||void 0});n!==void 0&&this.itemFocus(n,a),this.applyState(a)}applyInputValue(a,e,s){const i=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:t}=this.props,o=m.getFilteredData(this.props),d=this.focusedIndex(),l=o[d];if(this._suggested="",i&&s===p.Keys.enter&&l&&!l.disabled){const n=m.getItemValue(o[this.focusedIndex(a)],t);this.triggerOnChange(n,e)}i&&this.togglePopup(e),this.applyState(e)}renderSearchBar(a,e){const s=this.base,{placeholder:i,tabIndex:t,disabled:o,readonly:d,inputAttributes:l}=this.props,{focused:n}=this.state,r=this.props.opened!==void 0?this.props.opened:this.state.opened;return I.createElement(q,{id:e,placeholder:i,tabIndex:t,accessKey:this.props.accessKey,value:a,suggestedText:this._suggested,focused:n,name:this.props.name,ref:g=>this._input=g&&g.input,onKeyDown:this.onInputKeyDown,onChange:this.onChangeHandler,onFocus:s.handleFocus,onBlur:this.handleBlur,disabled:o,readOnly:d,expanded:r,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:l})}renderListContainer(){const a=this.base,{dir:e,header:s,footer:i,size:t,groupField:o,list:d,groupStickyHeaderItemRender:l}=this.props,n=m.getFilteredData(this.props),r=a.getPopupSettings(),g=this.props.opened!==void 0?this.props.opened:this.state.opened,h=r.width!==void 0?r.width:a.popupWidth;let{group:v}=this.state;return v===void 0&&o!==void 0&&(v=m.getItemValue(n[0],o)),I.createElement(E,{width:h,popupSettings:{...r,anchor:r.anchor||this.element,show:g,popupClass:p.classNames(r.popupClass,"k-list-container","k-autocomplete-popup")},dir:e!==void 0?e:this.base.dirCalculated,itemsCount:[n.length]},s&&I.createElement("div",{className:"k-list-header"},s),I.createElement("div",{className:p.classNames("k-list",{[`k-list-${_[t]||t}`]:t})},!d&&v&&n.length!==0&&I.createElement(N,{group:v,groupMode:"modern",render:l}),this.renderList()),i&&I.createElement("div",{className:"k-list-footer"},i))}renderList(){const a=this.base,e=a.getPopupSettings(),{textField:s,listNoDataRender:i,itemRender:t,groupHeaderItemRender:o}=this.props,d=m.getFilteredData(this.props),l=this.value,n=this.props.opened!==void 0?this.props.opened:this.state.opened;return I.createElement(T,{id:a.listBoxId,show:n,data:d.slice(),focusedIndex:this.focusedIndex(),value:l,textField:s,valueField:s,highlightSelected:!1,optionsGuid:a.guid,groupField:this.props.groupField,groupMode:"modern",listRef:r=>a.list=r,wrapperStyle:{maxHeight:e.height},wrapperCssClass:"k-list-content",onClick:this.handleItemClick,itemRender:t,groupHeaderItemRender:o,noDataRender:i,onMouseDown:r=>r.preventDefault(),onScroll:this.onScroll})}triggerOnChange(a,e,s){this.value===a&&!s||(e.data.value=a,this._valueDuringOnChange=a,e.events.push({type:"onChange",...s||{}}))}applyState(a){this.base.applyState(a),this._valueDuringOnChange=void 0}suggestValue(a){if(this._suggested="",a){const{textField:e}=this.props,s=m.getFilteredData(this.props),i=s[m.itemIndexStartsWith(s,a,e)];if(i){const t=m.getItemValue(i,e);a.toLowerCase()!==t.toLowerCase()&&(this._suggested=t.substring(a.length))}}}focusedIndex(a){const{textField:e,focusedItemIndex:s,skipDisabledItems:i}=this.props,t=m.getFilteredData(this.props),o=a!==void 0?a:this.value;if(this.state.focusedItem!==void 0)return t.findIndex(l=>m.areSame(l,this.state.focusedItem,e));if(s)return s(t,o,e);const d=t.indexOf(m.getFocusedItem(t,o,e));return i&&e&&d===-1?t.findIndex(l=>!l.disabled&&l[e]):Math.max(0,d)}};b.displayName="AutoComplete",b.propTypes={...k.basicPropTypes,size:f.oneOf([null,"small","medium","large"]),rounded:f.oneOf([null,"small","medium","large","full"]),fillMode:f.oneOf([null,"solid","flat","outline"]),groupField:f.string,suggest:f.oneOfType([f.bool,f.string]),placeholder:f.string,value:f.string,defaultValue:f.string,validationMessage:f.string,required:f.bool,readonly:f.bool,clearButton:f.bool,valueRender:f.func,id:f.string,ariaLabelledBy:f.string,ariaDescribedBy:f.string,list:f.any,skipDisabledItems:f.bool,inputAttributes:f.object},b.defaultProps={...k.defaultProps,size:"medium",rounded:"medium",fillMode:"solid",skipDisabledItems:!0,prefix:void 0,suffix:void 0};let S=b;const O=p.createPropsContext(),P=p.withIdHOC(p.withPropsContext(O,S));P.displayName="KendoReactAutoComplete";exports.AutoComplete=P;exports.AutoCompletePropsContext=O;exports.AutoCompleteWithoutContext=S;
8
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react"),u=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"),c=require("../common/utils.js"),l=require("@progress/kendo-react-common"),R=require("@progress/kendo-react-labels"),A=require("../package-metadata.js"),L=require("../common/ClearButton.js"),z=require("../common/AdaptiveMode.js"),F=require("../common/withCustomComponent.js"),H=require("@progress/kendo-react-layout"),W=require("../common/ListFilter.js");function j(C){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(C){for(const e in C)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(C,e);Object.defineProperty(a,e,t.get?t:{enumerable:!0,get:()=>C[e]})}}return a.default=C,Object.freeze(a)}const g=j(B),G="Please enter a valid value!",{sizeMap:_,roundedMap:U}=l.kendoThemeMaps,I=class I extends g.Component{constructor(a){super(a),this.state={},this.base=new w(this),this._element=null,this._suggested="",this._input=null,this._adaptiveInput=null,this._skipFocusEvent=!1,this._isScrolling=!1,this.itemHeight=0,this.focus=()=>{this._input&&this._input.focus()},this.handleItemSelect=(e,t)=>{const s=c.getFilteredData(this.props),i=c.getItemValue(s[e],this.props.textField);this.state.text&&!this.mobileMode&&(this.state.text&&(t.data.text=""),this.base.filterChanged("",t)),this._adaptiveInput&&this._adaptiveInput.blur(),this.triggerOnChange(i,t)},this.itemFocus=(e,t)=>{const{textField:s}=this.props,o=c.getFilteredData(this.props)[e];c.areSame(this.state.focusedItem,o,s)||(t.data.focusedItem=o)},this.togglePopup=e=>{this.base.togglePopup(e)},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||G)},this.renderAdaptiveListContainer=()=>{const{adaptiveTitle:e}=this.props,{windowWidth:t=0}=this.state,s=g.createElement(W,{value:this.value,ref:o=>this._adaptiveInput=o&&o.element,onChange:this.onChangeHandler,onKeyDown:this.onInputKeyDown,size:this.props.size,rounded:this.props.rounded,fillMode:this.props.fillMode}),i={title:e,expand:this.opened,onClose:o=>this.onCancel(o),windowWidth:t,mobileFilter:s};return g.createElement(z.AdaptiveMode,{...i},g.createElement(H.ActionSheetContent,{overflowHidden:!0},g.createElement("div",{className:"k-list-container"},this.listContainerContent())))},this.onCancel=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.opened&&this.base.togglePopup(t),t.events.push({type:"onCancel"});const s=this.state.text;c.isPresent(s)&&s!==""&&this.base.filterChanged("",t),this.state.text&&(t.data.text=""),this.applyState(t)},this.listContainerContent=()=>{const{header:e,footer:t,size:s,groupStickyHeaderItemRender:i,groupField:o,list:d}=this.props,r=c.getFilteredData(this.props);let{group:n}=this.state;return n===void 0&&o!==void 0&&(n=c.getItemValue(r[0],o)),g.createElement(g.Fragment,null,e&&g.createElement("div",{className:"k-list-header"},e),g.createElement("div",{className:l.classNames("k-list",{[`k-list-${this.mobileMode?"lg":_[s]||s}`]:s})},!d&&n&&r.length!==0&&g.createElement(N,{group:n,groupMode:"modern",render:i}),this.renderList()),t&&g.createElement("div",{className:"k-list-footer"},t))},this.onScroll=e=>{this._isScrolling=!0;const{list:t}=this.base,{groupField:s}=this.props;let i=c.getFilteredData(this.props);if(!s||!i.length)return;const o=this.itemHeight||(t?t.children[0].offsetHeight:0),r=e.target.scrollTop;s&&(i=this.base.getGroupedDataModernMode(i,s));let n=i[0][s];for(let p=1;p<i.length&&!(o*p>r);p++)i[p]&&i[p][s]&&(n=i[p][s]);n!==this.state.group&&this.setState({group:n})},this.handleItemClick=(e,t)=>{this.base.handleItemClick(e,t),this._valueDuringOnChange=void 0},this.onChangeHandler=e=>{const s=this.base.initState(),i=this.mobileMode?e.target.element:e.currentTarget,o=i.value,d=i.selectionEnd===o.length;s.syntheticEvent=e;const r=this._suggested,n=this.value,p=n&&n.substring(0,n.length-r.length),v=p&&p===o,m=p&&p.length>o.length,{suggest:y}=this.props,h=this.props.opened!==void 0?this.props.opened:this.state.opened;if(y!==void 0&&y!==!1){v||m||!d?this._suggested="":this.suggestValue(o);const f=o+this._suggested,b={userInput:o,value:this._suggested};this.triggerOnChange(f,s,{suggestion:b})}else this._suggested="",this.triggerOnChange(o,s);(!h&&o||h&&!o)&&this.togglePopup(s),s.data.focusedItem=void 0,this.applyState(s),this.setState({group:void 0})},this.clearButtonClick=e=>{const s=this.base.initState(),i=this.props.opened!==void 0?this.props.opened:this.state.opened;s.syntheticEvent=e;const o="";this._suggested="",this.triggerOnChange(o,s),this.state.focusedItem!==void 0&&(s.data.focusedItem=void 0),i&&this.togglePopup(s),this.applyState(s)},this.onInputKeyDown=e=>{const{skipDisabledItems:t,groupField:s,textField:i}=this.props,o=c.getFilteredData(this.props);this._isScrolling&&(this._isScrolling=!1);const d=this.focusedIndex(),r=o[d],n=e.keyCode,p=e.altKey,v=this.props.opened!==void 0?this.props.opened:this.state.opened,m=this.base.initState();m.syntheticEvent=e;const y=()=>{v&&e.preventDefault()};if(p&&n===l.Keys.down)this.setState({opened:!0});else if(p&&n===l.Keys.up)this.setState({opened:!1});else if(v&&n===l.Keys.pageUp)y(),this.base.scrollPopupByPageSize(-1);else if(v&&n===l.Keys.pageDown)y(),this.base.scrollPopupByPageSize(1);else if(v&&(n===l.Keys.enter||n===l.Keys.esc))y(),t===!1&&r&&r.disabled?(v&&this.togglePopup(m),this.applyState(m)):this.applyInputValue(e.currentTarget.value,m,e.keyCode);else if(!v&&n===l.Keys.esc){const h="";this._suggested="",this.triggerOnChange(h,m),this.state.focusedItem!==void 0&&(m.data.focusedItem=void 0),this.applyState(m)}else if(n===l.Keys.up||n===l.Keys.down){if(s!==""&&i)if(!this.props.skipDisabledItems&&v)this.onNavigate(m,n);else{let h=0;if(n===l.Keys.down||n===l.Keys.right){const f=o.slice(d+1).find(b=>!b.disabled&&b[i]);h=f&&o.findIndex(b=>b[i]===f[i])}else if(n===l.Keys.up||n===l.Keys.left){let f;if(d===-1)f=o,h=o.findIndex(b=>!b.disabled&&b[i]);else{f=o.slice(0,d);let b=f.pop();for(;b&&b.disabled;)b=f.pop();h=b&&o.findIndex(S=>S[i]===b[i])}}if(h!==void 0){const f=h-d;this.onNavigate(m,n,f)}else h===void 0&&o.findIndex(f=>f[i])===o.length-1&&this.onNavigate(m,n)}else if(!this.props.skipDisabledItems&&v)this.onNavigate(m,n);else{let h=null;if(n===l.Keys.down||n===l.Keys.right)h=o.slice(d+1).find(f=>!f.disabled);else if(n===l.Keys.up||n===l.Keys.left){const f=o.slice(0,d);for(h=f.pop();h&&h.disabled;)h=f.pop()}if(h){const f=h.id-d-1;this.onNavigate(m,n,f)}else this.onNavigate(m,n)}this.applyState(m),y()}},this.handleFocus=e=>{this._skipFocusEvent||this.base.handleFocus(e)},this.handleBlur=e=>{const t=this.base.initState();!this.state.focused||this._skipFocusEvent||(t.syntheticEvent=e,t.data.focused=!1,t.events.push({type:"onBlur"}),this.opened&&!this.mobileMode&&(this.state.opened&&(t.data.opened=!1),t.events.push({type:"onClose"})),this.applyState(t))},this.handleWrapperClick=e=>{const t=this._input;!this.opened&&t&&this.focusElement(t);const s=this.base.initState();s.syntheticEvent=e,!this.state.focused&&!this.mobileMode&&(s.events.push({type:"onFocus"}),s.data.focused=!0),this.mobileMode&&window.setTimeout(()=>this._adaptiveInput&&this._adaptiveInput.focus(),300),this.base.togglePopup(s),this.applyState(s)},l.validatePackage(A.packageMetadata)}get _inputId(){return this.props.id+"-accessibility-id"}get document(){if(l.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get value(){return this._valueDuringOnChange!==void 0?this._valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value!==void 0?this.state.value:this.props.defaultValue!==void 0?this.props.defaultValue:""}get name(){return this.props.name}get validity(){const a=this.props.validationMessage!==void 0,e=!this.required||this.value!=="",t=this.props.valid!==void 0?this.props.valid:e;return{customError:a,valid:t,valueMissing:this.value===null}}get opened(){return!!(this.props.opened!==void 0?this.props.opened:this.state.opened)}get mobileMode(){return!!(this.state.windowWidth&&this.state.windowWidth<=l.ADAPTIVE_MEDIUM_BREAKPOINT&&this.props.adaptive)}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:I.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:I.defaultProps.required}componentDidUpdate(a,e){var y;const{groupField:t=""}=this.props,s=c.getFilteredData(this.props),{data:i=[]}=a,o=this.focusedIndex(),d=s[o],r=i!==s,n=d!==void 0&&e.focusedItem!==d,p=this.props.opened!==void 0?this.props.opened:this.state.opened,v=a.opened!==void 0?a.opened:e.opened,m=!v&&p;if(t==="")(p&&(n||r)||m)&&this.base.scrollToItem(o);else if(!this._isScrolling){const h=(y=this.base.getGroupedDataModernMode(s,t))==null?void 0:y.indexOf(d);m&&(s&&s.length!==0&&this.base.resetGroupStickyHeader(s[0][t],this),this.base.scrollToItem(h)),p&&v&&n&&this.base.scrollToItem(h)}this.setValidity()}componentDidMount(){var a;this.observerResize=l.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(a=this.document)!=null&&a.body&&this.observerResize&&this.observerResize.observe(this.document.body)}render(){const{dir:a,disabled:e,label:t,className:s,style:i,loading:o,suggest:d,size:r,rounded:n,fillMode:p}=this.props,v=!this.validityStyles||this.validity.valid,m=this.base,y=this.value,h=this.props.clearButton!==!1&&!o&&!!y,f=this.props.id||this._inputId,b=this.state.focused;typeof d=="string"&&(this._suggested=d);const[S,O]=F(this.props.prefix||g.Fragment),[P,K]=F(this.props.suffix||g.Fragment),k=g.createElement(g.Fragment,null,g.createElement("span",{className:l.classNames("k-autocomplete k-input",s,{[`k-input-${_[r]||r}`]:r,[`k-rounded-${U[n]||n}`]:n,[`k-input-${p}`]:p,"k-invalid":!v,"k-focus":b&&!e,"k-loading":o,"k-required":this.required,"k-disabled":e}),ref:D=>{this._element=D,m.wrapper=D},style:t?{...i,width:void 0}:i,dir:a,onFocus:this.handleFocus,onBlur:this.handleBlur,onClick:this.handleWrapperClick},this.props.prefix&&g.createElement(S,{...O}),this.renderSearchBar(y||"",f),o&&g.createElement(l.IconWrap,{className:"k-input-loading-icon",name:"loading"}),h&&!o&&g.createElement(L,{onClick:this.clearButtonClick,key:"clearbutton"}),this.props.suffix&&g.createElement(P,{...K}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return t?g.createElement(R.FloatingLabel,{label:t,editorId:f,editorValue:y,editorValid:v,editorDisabled:e,style:{width:i?i.width:void 0},children:k}):k}onNavigate(a,e,t){const s=this.value,{textField:i,focusedItemIndex:o}=this.props,d=c.getFilteredData(this.props),r=this.state.focusedItem!==void 0?d.findIndex(p=>c.areSame(p,this.state.focusedItem,i)):o?o(d,s,i):d.indexOf(c.getFocusedItem(d,s,i)),n=this.base.navigation.navigate({keyCode:e,current:r,max:d.length-1,min:0,skipItems:t||void 0});n!==void 0&&this.itemFocus(n,a),this.applyState(a)}applyInputValue(a,e,t){const s=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:i}=this.props,o=c.getFilteredData(this.props),d=this.focusedIndex(),r=o[d];if(this._suggested="",s&&t===l.Keys.enter&&r&&!r.disabled){const n=c.getItemValue(o[this.focusedIndex(a)],i);this.triggerOnChange(n,e)}s&&this.togglePopup(e),this.applyState(e)}renderSearchBar(a,e){const t=this.base,{placeholder:s,tabIndex:i,disabled:o,readonly:d,inputAttributes:r}=this.props,{focused:n}=this.state,p=this.props.opened!==void 0?this.props.opened:this.state.opened;return g.createElement(T,{id:e,placeholder:s,tabIndex:i,accessKey:this.props.accessKey,value:a,suggestedText:this._suggested,focused:n,name:this.props.name,ref:v=>this._input=v&&v.input,onKeyDown:this.onInputKeyDown,onChange:this.onChangeHandler,onFocus:t.handleFocus,onBlur:this.handleBlur,disabled:o,readOnly:d,expanded:p,owns:t.listBoxId,activedescendant:"option-"+t.guid+"-"+this.focusedIndex(),role:"combobox",ariaLabelledBy:this.props.ariaLabelledBy,ariaDescribedBy:this.props.ariaDescribedBy,ariaRequired:this.required,render:this.props.valueRender,inputAttributes:r})}renderListContainer(){const a=this.base,{dir:e,groupField:t}=this.props,s=c.getFilteredData(this.props),i=a.getPopupSettings(),o=this.props.opened!==void 0?this.props.opened:this.state.opened,d=i.width!==void 0?i.width:a.popupWidth;let{group:r}=this.state;return r===void 0&&t!==void 0&&(r=c.getItemValue(s[0],t)),g.createElement(V,{width:d,popupSettings:{...i,anchor:i.anchor||this.element,show:o,popupClass:l.classNames(i.popupClass,"k-list-container","k-autocomplete-popup")},dir:e!==void 0?e:this.base.dirCalculated,itemsCount:[s.length]},this.listContainerContent())}renderList(){const a=this.base,e=a.getPopupSettings(),{textField:t,listNoDataRender:s,itemRender:i,groupHeaderItemRender:o}=this.props,d=c.getFilteredData(this.props),r=this.value,n=this.props.opened!==void 0?this.props.opened:this.state.opened;return g.createElement(q,{id:a.listBoxId,show:n,data:d.slice(),focusedIndex:this.focusedIndex(),value:r,textField:t,valueField:t,highlightSelected:!1,optionsGuid:a.guid,groupField:this.props.groupField,groupMode:"modern",listRef:p=>a.list=p,wrapperStyle:this.mobileMode?{}:{maxHeight:e.height},wrapperCssClass:"k-list-content",onClick:this.handleItemClick,itemRender:i,groupHeaderItemRender:o,noDataRender:s,onMouseDown:p=>p.preventDefault(),onScroll:this.onScroll})}triggerOnChange(a,e,t){this.value===a&&!t||(e.data.value=a,this._valueDuringOnChange=a,e.events.push({type:"onChange",...t||{}}))}focusElement(a){this._skipFocusEvent=!0,a.focus(),window.setTimeout(()=>this._skipFocusEvent=!1,0)}applyState(a){this.base.applyState(a),this._valueDuringOnChange=void 0}suggestValue(a){if(this._suggested="",a){const{textField:e}=this.props,t=c.getFilteredData(this.props),s=t[c.itemIndexStartsWith(t,a,e)];if(s){const i=c.getItemValue(s,e);a.toLowerCase()!==i.toLowerCase()&&(this._suggested=i.substring(a.length))}}}focusedIndex(a){const{textField:e,focusedItemIndex:t,skipDisabledItems:s}=this.props,i=c.getFilteredData(this.props),o=a!==void 0?a:this.value;if(this.state.focusedItem!==void 0)return i.findIndex(r=>c.areSame(r,this.state.focusedItem,e));if(t)return t(i,o,e);const d=i.indexOf(c.getFocusedItem(i,o,e));return s&&e&&d===-1?i.findIndex(r=>!r.disabled&&r[e]):Math.max(0,d)}calculateMedia(a){for(const e of a)this.setState({windowWidth:e.target.clientWidth})}};I.displayName="AutoComplete",I.propTypes={...w.basicPropTypes,size:u.oneOf([null,"small","medium","large"]),rounded:u.oneOf([null,"small","medium","large","full"]),fillMode:u.oneOf([null,"solid","flat","outline"]),groupField:u.string,suggest:u.oneOfType([u.bool,u.string]),placeholder:u.string,value:u.string,defaultValue:u.string,validationMessage:u.string,required:u.bool,readonly:u.bool,clearButton:u.bool,valueRender:u.func,id:u.string,ariaLabelledBy:u.string,ariaDescribedBy:u.string,list:u.any,adaptive:u.bool,adaptiveTitle:u.string,onCancel:u.func,skipDisabledItems:u.bool,inputAttributes:u.object},I.defaultProps={...w.defaultProps,size:"medium",rounded:"medium",fillMode:"solid",skipDisabledItems:!0,prefix:void 0,suffix:void 0};let x=I;const M=l.createPropsContext(),E=l.withIdHOC(l.withPropsContext(M,x));E.displayName="KendoReactAutoComplete";exports.AutoComplete=E;exports.AutoCompletePropsContext=M;exports.AutoCompleteWithoutContext=x;