@progress/kendo-react-dropdowns 11.0.0-develop.2 → 11.0.0-develop.20
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/common/VirtualScrollStatic.js +1 -1
- package/common/VirtualScrollStatic.mjs +1 -1
- 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 +11 -11
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 Q=require("react"),b=require("prop-types"),V=require("../common/DropDownBase.js"),i=require("@progress/kendo-react-common"),X=require("@progress/kendo-react-labels"),h=require("../common/utils.js"),Z=require("../common/SearchBar.js"),ee=require("../common/ListContainer.js"),te=require("../common/List.js"),se=require("../common/ListFilter.js"),A=require("../common/GroupStickyHeader.js"),ie=require("../package-metadata.js"),oe=require("../common/ClearButton.js"),K=require("@progress/kendo-react-buttons"),L=require("@progress/kendo-svg-icons"),k=require("../messages/index.js"),R=require("@progress/kendo-react-intl"),N=require("@progress/kendo-react-layout"),q=require("../common/withCustomComponent.js");function ae(B){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(B){for(const e in B)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(B,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>B[e]})}}return s.default=B,Object.freeze(s)}const g=ae(Q),ne="Please enter a valid value!",D=class D extends g.Component{constructor(s){super(s),this.state={},this.base=new V(this),this._element=null,this._suggested="",this._skipBlur=!1,this._input=null,this._adaptiveFilterInput=null,this.itemHeight=0,this.duplicates=[],this.hasDuplicates=!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 o=this.props.data;this.duplicates=h.getPlainDataDuplicates(o),this.hasDuplicates=this.duplicates.length>0}},this.handleItemSelect=(e,t)=>{const{virtual:o,dataItemKey:l}=this.props,d=h.getFilteredData(this.props),n=o?o.skip:0,p=d[e-n],r=this.hasDuplicates||!h.areSame(p,this.value,l);this.triggerOnChange(p,t),this.state.text!==void 0&&(t.data.text=void 0),r&&this.base.triggerPageChangeCornerItems(p,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=>{const{skipDisabledItems:t,textField:o}=this.props,l=h.getFilteredData(this.props),d=this.getFocusedIndex(),n=this.getCurrentValueDisabledStatus(o,l,d),p=this.props.opened!==void 0?this.props.opened:this.state.opened,r=this.base.initState();if(r.syntheticEvent=e,!t&&o&&n&&this.clearValueOnToggleBtnClick(e),this.base.togglePopup(r),!p&&this.mobileMode){const a=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text||null;this.base.filterChanged(a,r)}this.applyState(r)},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=h.getItemValue(this.value,this.props.textField),o=h.isPresent(e)?e:t;return g.createElement(se,{value:o,ref:l=>{this._adaptiveFilterInput=l&&l.element},onChange:this.handleMobileFilterChange,onKeyDown:this.onInputKeyDown,size:"large",rounded:this.props.rounded,fillMode:this.props.fillMode})},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:o}=this.base;t.scrollHandler(e);const{groupField:l}=this.props;let d=h.getFilteredData(this.props);if(!l||!d.length)return;const n=this.itemHeight=this.itemHeight||(t.enabled?t.itemHeight:o?o.children[0].offsetHeight:0),r=e.target.scrollTop-t.skip*n;this.props.groupMode==="modern"&&(d=this.base.getGroupedDataModernMode(d,l));let a=d[0][l];for(let m=1;m<d.length&&!(n*m>r);m++)d[m]&&d[m][l]&&(a=d[m][l]);a!==this.state.group&&(this.setState({group:a}),this.props.onGroupScroll&&this.props.onGroupScroll.call(void 0,{group:a}))},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:o}=this.props,l=h.getFilteredData(this.props),d=this.getFocusedIndex(),p=!(d===-1)&&this.getCurrentValueDisabledStatus(o,l,d);t.data.focused=!1,t.events.push({type:"onBlur"}),t.syntheticEvent=e,o&&p&&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,o=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text||null;if(!t&&this.mobileMode){const l=this.base.initState();l.syntheticEvent=e,this.base.togglePopup(l),this.base.filterChanged(o,l),this.applyState(l)}},this.onInputKeyDown=e=>{const{skipDisabledItems:t,textField:o,dataItemKey:l,groupField:d}=this.props,n=h.getFilteredData(this.props),p=this.value,r=Math.max(0,n.findIndex(u=>h.areSame(u,p,l))),a=e.keyCode,m=this.props.opened!==void 0?this.props.opened:this.state.opened,c=this.base.initState();if(c.syntheticEvent=e,!e.altKey&&(a===i.Keys.up||a===i.Keys.down)){if(e.preventDefault(),d!==""&&o)if(!this.props.skipDisabledItems&&m)this.onNavigate(c,a);else{let u=0;if(a===i.Keys.down||a===i.Keys.right){const v=n.slice(r+1<n.length?r+1:r).find(x=>!x.disabled&&x[o]);u=v&&n.findIndex(x=>x[o]===v[o])}else if(a===i.Keys.up||a===i.Keys.left){let v;if(r===0)v=n,u=n.findIndex(x=>!x.disabled&&x[o]);else{v=n.slice(0,r);let x=v.pop();for(;x&&x.disabled;)x=v.pop();u=x&&n.findIndex(S=>S[o]===x[o])}}if(u!==void 0){const v=u-r;this.onNavigate(c,a,v)}else u===void 0&&n.findIndex(v=>v[o]===p[o])===n.length-1&&this.onNavigate(c,a)}else if(!this.props.skipDisabledItems&&m)this.onNavigate(c,a);else{let u=null;if(a===i.Keys.down||a===i.Keys.right)u=n.slice(r+1).find(v=>!v.disabled);else if(a===i.Keys.up||a===i.Keys.left){const v=n.slice(0,r);for(u=v.pop();u&&u.disabled;)u=v.pop()}if(u){const v=u.id-r-1;this.onNavigate(c,a,v)}else this.onNavigate(c,a)}this.applyState(c)}const C=()=>{e.preventDefault(),this.base.togglePopup(c),this.applyState(c)},y=this.getFocusedIndex(),I=y===-1,f=!I&&this.getCurrentValueDisabledStatus(o,n,y);m?a===i.Keys.pageUp?(e.preventDefault(),this.base.scrollPopupByPageSize(-1)):a===i.Keys.pageDown?(e.preventDefault(),this.base.scrollPopupByPageSize(1)):e.altKey&&a===i.Keys.up?C():a===i.Keys.enter?(e.preventDefault(),(o&&!I&&e.currentTarget.value?n[y][o]:void 0)?!t&&o&&f?this.clearValueOnEnterOrEsc(e):f||this.applyValueOnEnter(e.currentTarget.value,c):this.applyValueOnEnter(e.currentTarget.value,c)):a===i.Keys.esc&&(!t&&o&&f&&this.clearValueOnEnterOrEsc(e),this.applyValueOnRejectSuggestions(e.currentTarget.value,c)):!m&&a===i.Keys.esc?this.clearValueOnEnterOrEsc(e):e.altKey&&a===i.Keys.down&&C()},this.inputOnChange=e=>{const t=this.base.initState();t.syntheticEvent=e;const o=this.props.opened!==void 0?this.props.opened:this.state.opened,l=e.currentTarget,d=l.value;if(this.props.suggest){const n=l.selectionEnd===d.length;let p=this.props.filter!==void 0?this.props.filter:this.state.text;h.isPresent(p)||(p=h.getItemValue(this.value,this.props.textField)||"");const r=p&&p===d,a=p&&p.length>d.length;r||a||!n?this._suggested="":this.suggestValue(d)}this.props.filter===void 0&&(t.data.text=d),this.state.focusedItem!==void 0&&(t.data.focusedItem=void 0),o||this.base.togglePopup(t),this.base.filterChanged(d,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||ne)},this.showLicenseWatermark=!i.validatePackage(ie.packageMetadata,{component:"ComboBox"})}get _inputId(){return this.props.id}get document(){if(i.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=h.getFilteredData(this.props),t=this.value;return e.findIndex(o=>h.areSame(o,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:D.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:D.defaultProps.required}componentDidUpdate(s,e){var C;const{dataItemKey:t,virtual:o,groupField:l="",textField:d}=this.props,n=h.getFilteredData(this.props),p=s.virtual?s.virtual.total:0,r=this.props.opened!==void 0?this.props.opened:this.state.opened,a=s.opened!==void 0?s.opened:e.opened;s.data!==n&&this.checkForDuplicatePlainTextRecords();const m=!a&&r,c=this.value;if(this._valueOnDidUpdate=c,this.base.didUpdate(),o&&o.total!==p)this.base.vs.calcScrollElementHeight(),this.base.vs.reset();else{const y=s.value!==void 0?s.value:e.value;let I=this.hasDuplicates?this.navigationIndex||0:n.findIndex(u=>h.areSame(u,c,t));this.props.groupMode==="modern"&&d&&c&&(I=(C=this.base.getGroupedDataModernMode(n,l))==null?void 0:C.map(u=>u[d]).indexOf(c[d]));const f=!h.areSame(y,c,t);m&&o?this.base.scrollToVirtualItem(o,I):m&&!o?(this.onPopupOpened(),n&&n.length!==0&&this.base.resetGroupStickyHeader(n[0][l],this),this.base.scrollToItem(I)):(this.hasDuplicates||r&&a&&c&&f)&&this.base.scrollToItem(I)}m&&this._input&&this._input.focus(),this.setValidity()}componentDidMount(){var s;this.observerResize=i.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.observe(this.document.body),this.checkForDuplicatePlainTextRecords()}componentWillUnmount(){var s;(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.disconnect()}render(){const s=R.provideLocalizationService(this).toLanguageString(k.comboArrowBtnAriaLabelExpand,k.messages[k.comboArrowBtnAriaLabelExpand]),e=R.provideLocalizationService(this).toLanguageString(k.comboArrowBtnAriaLabelCollapse,k.messages[k.comboArrowBtnAriaLabelCollapse]),{dir:t,disabled:o,clearButton:l=D.defaultProps.clearButton,label:d,textField:n,className:p,style:r,loading:a,iconClassName:m,virtual:c,size:C,rounded:y,fillMode:I,opened:f=this.state.opened,placeholder:u,svgIcon:v,unstyled:x}=this.props,S=!this.validityStyles||this.validity.valid,w=this.props.filter!==void 0?this.props.filter:this.state.text,W=h.getItemValue(this.value,n),M=h.isPresent(w)?w:W,j=l&&(!!M||h.isPresent(this.value)),F=this.base.vs,P=this.props.id||this._inputId,T=this.mobileMode,O=x&&x.uComboBox;F.enabled=c!==void 0,c!==void 0&&(F.skip=c.skip,F.total=c.total,F.pageSize=c.pageSize);const[G,U]=q(this.props.prefix||g.Fragment),[$,Y]=q(this.props.suffix||g.Fragment),_=g.createElement(g.Fragment,null,g.createElement("span",{className:i.classNames(i.uComboBox.wrapper({c:O,size:C,rounded:y,fillMode:I,disabled:o,invalid:!S,loading:a,required:this.required}),p),ref:this.componentRef,style:d?{...r,width:void 0}:r,dir:t},this.props.prefix&&g.createElement(G,{...U}),this.renderSearchBar(M||"",P,u),j&&!a&&g.createElement(oe,{onClick:this.clearButtonClick,key:"clearbutton"}),a&&g.createElement(i.IconWrap,{className:i.classNames(i.uComboBox.loadingIcon({c:O})),name:"loading",key:"loading"}),this.props.suffix&&g.createElement($,{...Y}),g.createElement(K.Button,{tabIndex:-1,type:"button","aria-label":f?e:s,icon:m?void 0:"caret-alt-down",svgIcon:v||L.caretAltDownIcon,iconClass:m,size:C,fillMode:I,rounded:null,themeColor:"base",className:i.classNames(i.uComboBox.inputButton({c:O})),onClick:this.toggleBtnClick,onMouseDown:J=>J.preventDefault()}),!T&&this.renderListContainer()),T&&this.renderAdaptiveListContainer());return d?g.createElement(X.FloatingLabel,{label:d,editorId:P,editorValue:M,editorValid:S,editorDisabled:o,style:{width:r?r.width:void 0},children:_,unstyled:x}):_}onNavigate(s,e,t){const{virtual:o={skip:0}}=this.props,l=h.getFilteredData(this.props),d=this.props.filter?this.props.filter:this.state.text;let n=-1,p;const r=this.base.vs,a=this.value;this._suggested="";const m=this.hasDuplicates&&this.duplicates.indexOf(a)!==-1;if(n=this.getFocusedIndex(m),n!==-1&&!h.isPresent(a))this.handleItemSelect(n,s);else if(d==="")this.handleItemSelect(0,s);else{const c=o.skip+n;p=this.base.navigation.navigate({keyCode:e,current:c,max:(r.enabled?r.total:l.length)-1,min:0,skipItems:t||void 0}),p!==void 0&&this.handleItemSelect(p,s)}this.navigationIndex=p}getCurrentValueDisabledStatus(s,e,t){return s&&e&&e[t]&&e[t].disabled}applyValueOnEnter(s,e){const{textField:t,allowCustom:o}=this.props,l=h.getFilteredData(this.props),d=this.props.opened!==void 0?this.props.opened:this.state.opened,p=h.getItemValue(this.value,t)===s?this.index:h.getItemIndexByText(l,s,t),r=p!==-1;let a;if(this._suggested="",r)a=l[p];else if(o)a=t!==void 0?{[t]:s}:s;else return this.selectFocusedItem(s,e);this.triggerOnChange(a,e),d&&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:o}=this.props,l=h.getFilteredData(this.props),d=this.props.opened!==void 0?this.props.opened:this.state.opened,n=h.getItemValue(this.value,t);if(this._suggested="",s===n||s===""&&!h.isPresent(n))return this.closeOpenedApplyStateNonMobileMode(e,d),this.applyState(e);const p=h.getItemIndexByText(l,s,t,!0),r=p!==-1;let a=null;r?a=l[p]:o&&(a=s?t?{[t]:s}:s:null),this.triggerOnChange(a,e),this.state.text!==void 0&&(e.data.text=void 0,this.base.filterChanged("",e)),this.closeOpenedApplyStateNonMobileMode(e,d),this.applyState(e)}selectFocusedItem(s,e){const t=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:o,virtual:l={skip:0},focusedItemIndex:d=h.itemIndexStartsWith}=this.props,n=h.getFilteredData(this.props),p=l.skip,r=s===""&&p===0?0:d(n,s,o);return r!==-1?this.handleItemSelect(r+p,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,{header:e,footer:t,size:o,groupField:l,groupMode:d,list:n,virtual:p,adaptiveTitle:r,groupStickyHeaderItemRender:a,unstyled:m,_adaptiveMode:c}=this.props,C=h.getFilteredData(this.props),y=this.props.opened!==void 0?this.props.opened:this.state.opened,I=this.base.getAdaptiveAnimation(),f=m&&m.uComboBox,u=m&&m.uDropDownsActionSheet;let{group:v}=this.state;v===void 0&&l!==void 0&&(v=h.getItemValue(C[0],l));const x={navigatable:!1,navigatableElements:[],expand:y,animation:I,onClose:S=>this.toggleBtnClick(S),className:i.classNames(i.uDropDownsActionSheet.wrapper({c:u}),"k-adaptive-actionsheet"),animationStyles:s&&c&&s<=c.small?{top:0,width:"100%",height:"100%"}:void 0,position:s&&c&&s<=c.small?"fullscreen":void 0};return g.createElement(N.ActionSheet,{...x},g.createElement(N.ActionSheetHeader,null,g.createElement("div",{className:i.classNames(i.uDropDownsActionSheet.titleBar({c:u}))},g.createElement("div",{className:i.classNames(i.uDropDownsActionSheet.title({c:u}))},g.createElement("div",{className:i.classNames(i.uDropDownsActionSheet.header({c:u}))},r),g.createElement("div",{className:i.classNames(i.uDropDownsActionSheet.subtitle({c:u}))})),g.createElement("div",{className:i.classNames(i.uDropDownsActionSheet.actions({c:u}))},g.createElement(K.Button,{tabIndex:0,"aria-label":"Cancel","aria-disabled":"false",type:"button",fillMode:"flat",themeColor:"base",size:"large",onClick:this.toggleBtnClick,icon:"x",svgIcon:L.xIcon}))),g.createElement("div",{className:i.classNames(i.uDropDownsActionSheet.titleBarGroup({c:u}))},this.renderMobileListFilter())),g.createElement(N.ActionSheetContent,null,g.createElement("div",{className:i.classNames(i.uComboBox.listContainer({c:f}))},g.createElement("div",{className:i.classNames(i.uComboBox.list({c:f,list:n,size:"large",tableSize:o,virtual:p}))},e&&g.createElement("div",{className:i.classNames(i.uComboBox.listHeader({c:f}))},e),!n&&v&&C.length!==0&&g.createElement(A,{group:v,groupMode:d,render:a}),this.renderList(),t&&g.createElement("div",{className:i.classNames(i.uComboBox.listFooter({c:f}),this.props.footerClassName)},t)))))}renderListContainer(){const s=this.base,{dir:e,header:t,footer:o,groupField:l,groupMode:d,size:n,list:p,virtual:r,groupStickyHeaderItemRender:a,unstyled:m}=this.props,c=h.getFilteredData(this.props),C=this.props.opened!==void 0?this.props.opened:this.state.opened,y=s.getPopupSettings(),I=y.width!==void 0?y.width:s.popupWidth,f=m&&m.uComboBox;let{group:u}=this.state;return u===void 0&&l!==void 0&&(u=h.getItemValue(c[0],l)),g.createElement(ee,{width:I,popupSettings:{...y,anchor:y.anchor||this.element,show:C,popupClass:i.classNames(y.popupClass,i.uComboBox.listContainer({c:f,popup:!0}))},dir:e!==void 0?e:this.base.dirCalculated,itemsCount:[c.length]},g.createElement("div",{className:i.classNames(i.uComboBox.list({c:f,list:p,size:n,tableSize:n,virtual:r}))},t&&g.createElement("div",{className:i.classNames(i.uComboBox.listHeader({c:f}))},t),!p&&u&&c.length!==0&&g.createElement(A,{group:u,groupMode:d,render:a}),this.renderList(),o&&g.createElement("div",{className:i.classNames(i.uComboBox.listFooter({c:f}),this.props.footerClassName)},o)),this.showLicenseWatermark&&g.createElement(i.WatermarkOverlay,null))}renderList(){const s=this.base,{textField:e,dataItemKey:t,listNoDataRender:o,itemRender:l,groupHeaderItemRender:d,virtual:n={skip:0,total:void 0},unstyled:p}=this.props,r=h.getFilteredData(this.props),a=s.getPopupSettings(),m=s.vs,c=n.skip,C=this.props.opened!==void 0?this.props.opened:this.state.opened,y=`translateY(${m.translate}px)`,I=C?this.getFocusedIndex(this.hasDuplicates):void 0,f=this.props.filter!==void 0?this.props.filter:this.state.text,u=h.getItemValue(this.value,e),v=h.isPresent(f)&&f!==u?null:this.value,x=this.props.list||te,S=p&&p.uComboBox;return g.createElement(x,{id:s.listBoxId,virtual:!!n,show:C,data:r,focusedIndex:I,value:v,textField:e,valueField:t,groupField:this.props.groupField,groupMode:this.props.groupMode,isMultiColumn:this.props.isMultiColumn,optionsGuid:s.guid,hasDuplicates:this.hasDuplicates,listRef:w=>{m.list=this.base.list=w,this.itemHeight=0},wrapperStyle:this.state.windowWidth&&this.props._adaptiveMode&&this.state.windowWidth>this.props._adaptiveMode.medium?{maxHeight:a.height}:{},wrapperCssClass:i.classNames(i.uComboBox.listContent({c:S,virtual:n})),listStyle:m.enabled?{transform:y}:void 0,key:"listkey",skip:c,onClick:this.handleItemClick,itemRender:l,groupHeaderItemRender:d,noDataRender:o,onMouseDown:w=>w.preventDefault(),onScroll:this.onScroll,wrapperRef:m.scrollerRef,scroller:this.base.renderScrollElement(),ariaSetSize:n.total})}renderSearchBar(s,e,t){const{tabIndex:o,disabled:l,title:d,ariaLabelledBy:n,ariaDescribedBy:p,dataItemKey:r,virtual:a={skip:0},accessKey:m,unstyled:c,inputAttributes:C}=this.props,y=h.getFilteredData(this.props),I=this.props.opened!==void 0?this.props.opened:this.state.opened,f=this.value,u=Math.max(0,y.findIndex(v=>h.areSame(v,f,r)));return this._suggested&&!h.areSame(this._valueOnDidUpdate,f,r)&&(this._suggested=""),g.createElement(Z,{id:e,readOnly:I&&this.mobileMode,placeholder:t,tabIndex:o,title:d,value:s+this._suggested,suggestedText:this._suggested,ref:v=>{this._input=v&&v.input},onClick:this.onInputClick,onKeyDown:this.onInputKeyDown,onChange:this.inputOnChange,onFocus:this.base.handleFocus,onBlur:this.handleBlur,disabled:l,expanded:I,owns:this.base.listBoxId,activedescendant:`option-${this.base.guid}-${u+a.skip}`,role:"combobox",ariaLabelledBy:n,ariaLabel:this.props.ariaLabel,ariaDescribedBy:p,ariaRequired:this.required,render:this.props.valueRender,ariaControls:this.base.listBoxId,unstyled:c,inputAttributes:C})}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&&(!h.isPresent(t)&&!h.isPresent(s)||h.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:o,virtual:l={skip:0},focusedItemIndex:d=h.itemIndexStartsWith,skipDisabledItems:n}=this.props,p=h.getFilteredData(this.props),r=this.props.filter?this.props.filter:this.state.text;return s&&this.navigationIndex!==void 0?this.navigationIndex:h.isPresent(e)&&r===void 0?p.findIndex(a=>h.areSame(a,e,o)):r?d(p,r,t):n&&t&&!r&&l.skip===0?p.findIndex(a=>!a.disabled&&a[t]):l.skip===0?0:-1}suggestValue(s){const{data:e,textField:t}=this.props;this._suggested=h.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})}};D.displayName="ComboBox",D.propTypes={...V.propTypes,size:b.oneOf([null,"small","medium","large"]),rounded:b.oneOf([null,"small","medium","large","full"]),fillMode:b.oneOf([null,"solid","flat","outline"]),dataItemKey:b.string,groupField:b.string,groupMode:b.oneOf([void 0,"classic","modern"]),isMultiColumn:b.bool,suggest:b.bool,placeholder:b.string,title:b.string,allowCustom:b.bool,clearButton:b.bool,iconClassName:b.string,svgIcon:i.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},D.defaultProps={...V.defaultProps,size:"medium",rounded:"medium",fillMode:"solid",allowCustom:!1,clearButton:!0,required:!1,groupMode:"modern",isMultiColumn:!1,skipDisabledItems:!0,prefix:void 0,suffix:void 0};let E=D;const z=i.createPropsContext(),H=i.withIdHOC(i.withPropsContext(z,i.withUnstyledHOC(i.withAdaptiveModeContext(E))));H.displayName="KendoReactComboBox";exports.ComboBox=H;exports.ComboBoxPropsContext=z;exports.ComboBoxWithoutContext=E;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("react"),f=require("prop-types"),E=require("../common/DropDownBase.js"),h=require("@progress/kendo-react-common"),$=require("@progress/kendo-react-labels"),p=require("../common/utils.js"),Y=require("../common/SearchBar.js"),J=require("../common/ListContainer.js"),Q=require("../common/List.js"),X=require("../common/ListFilter.js"),_=require("../common/GroupStickyHeader.js"),Z=require("../package-metadata.js"),ee=require("../common/ClearButton.js"),te=require("@progress/kendo-react-buttons"),se=require("@progress/kendo-svg-icons"),k=require("../messages/index.js"),N=require("@progress/kendo-react-intl"),ie=require("@progress/kendo-react-layout"),K=require("../common/withCustomComponent.js"),oe=require("../common/AdaptiveMode.js");function ae(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 v=ae(G),ne="Please enter a valid value!",S=class S extends v.Component{constructor(s){super(s),this.state={},this.base=new E(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.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 i=this.props.data;this.duplicates=p.getPlainDataDuplicates(i),this.hasDuplicates=this.duplicates.length>0}},this.handleItemSelect=(e,t)=>{const{virtual:i,dataItemKey:r}=this.props,l=p.getFilteredData(this.props),a=i?i.skip:0,d=l[e-a],n=this.hasDuplicates||!p.areSame(d,this.value,r);this.triggerOnChange(d,t),this.state.text!==void 0&&(t.data.text=void 0),n&&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:i}=this.props,r=p.getFilteredData(this.props),l=this.getFocusedIndex(),a=this.getCurrentValueDisabledStatus(i,r,l),d=this.props.opened!==void 0?this.props.opened:this.state.opened,n=this.base.initState();if(n.syntheticEvent=e,!t&&i&&a&&this.clearValueOnToggleBtnClick(e),this.base.togglePopup(n),!d&&this.mobileMode){const o=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text||null;this.base.filterChanged(o,n)}this.applyState(n),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),i=p.isPresent(e)?e:t;return v.createElement(X,{value:i,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:i,groupStickyHeaderItemRender:r,groupField:l,list:a,groupMode:d,unstyled:n,virtual:o}=this.props,c=p.getFilteredData(this.props),u=n&&n.uComboBox;let{group:b}=this.state;return b===void 0&&l!==void 0&&(b=p.getItemValue(c[0],l)),v.createElement("div",{className:h.classNames(h.uComboBox.list({c:u,list:a,size:"large",tableSize:i,virtual:o}))},e&&v.createElement("div",{className:h.classNames(h.uComboBox.listHeader({c:u}))},e),!a&&b&&c.length!==0&&v.createElement(_,{group:b,groupMode:d,render:r}),this.renderList(),t&&v.createElement("div",{className:h.classNames(h.uComboBox.listFooter({c:u}),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:i}=this.base;t.scrollHandler(e);const{groupField:r}=this.props;let l=p.getFilteredData(this.props);if(!r||!l.length)return;const a=this.itemHeight=this.itemHeight||(t.enabled?t.itemHeight:i?i.children[0].offsetHeight:0),n=e.target.scrollTop-t.skip*a;this.props.groupMode==="modern"&&(l=this.base.getGroupedDataModernMode(l,r));let o=l[0][r];for(let c=1;c<l.length&&!(a*c>n);c++)l[c]&&l[c][r]&&(o=l[c][r]);o!==this.state.group&&(this.setState({group:o}),this.props.onGroupScroll&&this.props.onGroupScroll.call(void 0,{group:o}))},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:i}=this.props,r=p.getFilteredData(this.props),l=this.getFocusedIndex(),d=!(l===-1)&&this.getCurrentValueDisabledStatus(i,r,l);t.data.focused=!1,t.events.push({type:"onBlur"}),t.syntheticEvent=e,i&&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,i=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(i,r),this.applyState(r)}},this.onInputKeyDown=e=>{const{skipDisabledItems:t,textField:i,dataItemKey:r,groupField:l}=this.props,a=p.getFilteredData(this.props),d=this.value,n=Math.max(0,a.findIndex(g=>p.areSame(g,d,r))),o=e.keyCode,c=this.props.opened!==void 0?this.props.opened:this.state.opened,u=this.base.initState();if(u.syntheticEvent=e,!e.altKey&&(o===h.Keys.up||o===h.Keys.down)){if(e.preventDefault(),l!==""&&i)if(!this.props.skipDisabledItems&&c)this.onNavigate(u,o);else{let g=0;if(o===h.Keys.down||o===h.Keys.right){const m=a.slice(n+1<a.length?n+1:n).find(x=>!x.disabled&&x[i]);g=m&&a.findIndex(x=>x[i]===m[i])}else if(o===h.Keys.up||o===h.Keys.left){let m;if(n===0)m=a,g=a.findIndex(x=>!x.disabled&&x[i]);else{m=a.slice(0,n);let x=m.pop();for(;x&&x.disabled;)x=m.pop();g=x&&a.findIndex(D=>D[i]===x[i])}}if(g!==void 0){const m=g-n;this.onNavigate(u,o,m)}else g===void 0&&a.findIndex(m=>m[i]===d[i])===a.length-1&&this.onNavigate(u,o)}else if(!this.props.skipDisabledItems&&c)this.onNavigate(u,o);else{let g=null;if(o===h.Keys.down||o===h.Keys.right)g=a.slice(n+1).find(m=>!m.disabled);else if(o===h.Keys.up||o===h.Keys.left){const m=a.slice(0,n);for(g=m.pop();g&&g.disabled;)g=m.pop()}if(g){const m=g.id-n-1;this.onNavigate(u,o,m)}else this.onNavigate(u,o)}this.applyState(u)}const b=()=>{e.preventDefault(),this.base.togglePopup(u),this.applyState(u)},I=this.getFocusedIndex(),C=I===-1,y=!C&&this.getCurrentValueDisabledStatus(i,a,I);c?o===h.Keys.pageUp?(e.preventDefault(),this.base.scrollPopupByPageSize(-1)):o===h.Keys.pageDown?(e.preventDefault(),this.base.scrollPopupByPageSize(1)):e.altKey&&o===h.Keys.up?b():o===h.Keys.enter?(e.preventDefault(),(i&&!C&&e.currentTarget.value?a[I][i]:void 0)?!t&&i&&y?this.clearValueOnEnterOrEsc(e):y||this.applyValueOnEnter(e.currentTarget.value,u):this.applyValueOnEnter(e.currentTarget.value,u)):o===h.Keys.esc&&(!t&&i&&y&&this.clearValueOnEnterOrEsc(e),this.applyValueOnRejectSuggestions(e.currentTarget.value,u)):!c&&o===h.Keys.esc?this.clearValueOnEnterOrEsc(e):e.altKey&&o===h.Keys.down&&b()},this.inputOnChange=e=>{const t=this.base.initState();t.syntheticEvent=e;const i=this.props.opened!==void 0?this.props.opened:this.state.opened,r=e.currentTarget,l=r.value;if(this.props.suggest){const a=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 n=d&&d===l,o=d&&d.length>l.length;n||o||!a?this._suggested="":this.suggestValue(l)}this.props.filter===void 0&&(t.data.text=l),this.state.focusedItem!==void 0&&(t.data.focusedItem=void 0),i||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||ne)},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(Z.packageMetadata,{component:"ComboBox"})}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(i=>p.areSame(i,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:S.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:S.defaultProps.required}componentDidUpdate(s,e){var b;const{dataItemKey:t,virtual:i,groupField:r="",textField:l}=this.props,a=p.getFilteredData(this.props),d=s.virtual?s.virtual.total:0,n=this.props.opened!==void 0?this.props.opened:this.state.opened,o=s.opened!==void 0?s.opened:e.opened;s.data!==a&&this.checkForDuplicatePlainTextRecords();const c=!o&&n,u=this.value;if(this._valueOnDidUpdate=u,this.base.didUpdate(),i&&i.total!==d)this.base.vs.calcScrollElementHeight(),this.base.vs.reset();else{const I=s.value!==void 0?s.value:e.value;let C=this.hasDuplicates?this.navigationIndex||0:a.findIndex(g=>p.areSame(g,u,t));this.props.groupMode==="modern"&&l&&u&&(C=(b=this.base.getGroupedDataModernMode(a,r))==null?void 0:b.map(g=>g[l]).indexOf(u[l]));const y=!p.areSame(I,u,t);c&&i?this.base.scrollToVirtualItem(i,C):c&&!i?(this.onPopupOpened(),a&&a.length!==0&&this.base.resetGroupStickyHeader(a[0][r],this),this.base.scrollToItem(C)):(this.hasDuplicates||n&&o&&u&&y)&&this.base.scrollToItem(C)}c&&this._input&&this._input.focus(),this.setValidity()}componentDidMount(){var s;this.observerResize=h.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.observe(this.document.body),this.checkForDuplicatePlainTextRecords()}componentWillUnmount(){var s;(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.disconnect()}render(){const s=N.provideLocalizationService(this).toLanguageString(k.comboArrowBtnAriaLabelExpand,k.messages[k.comboArrowBtnAriaLabelExpand]),e=N.provideLocalizationService(this).toLanguageString(k.comboArrowBtnAriaLabelCollapse,k.messages[k.comboArrowBtnAriaLabelCollapse]),{dir:t,disabled:i,clearButton:r=S.defaultProps.clearButton,label:l,textField:a,className:d,style:n,loading:o,iconClassName:c,virtual:u,size:b,rounded:I,fillMode:C,opened:y=this.state.opened,placeholder:g,svgIcon:m,unstyled:x}=this.props,D=!this.validityStyles||this.validity.valid,F=this.props.filter!==void 0?this.props.filter:this.state.text,q=p.getItemValue(this.value,a),O=p.isPresent(F)?F:q,A=r&&(!!O||p.isPresent(this.value)),B=this.base.vs,P=this.props.id||this._inputId,V=x&&x.uComboBox;B.enabled=u!==void 0,u!==void 0&&(B.skip=u.skip,B.total=u.total,B.pageSize=u.pageSize);const[z,H]=K(this.props.prefix||v.Fragment),[W,j]=K(this.props.suffix||v.Fragment),T=v.createElement(v.Fragment,null,v.createElement("span",{className:h.classNames(h.uComboBox.wrapper({c:V,size:b,rounded:I,fillMode:C,disabled:i,invalid:!D,loading:o,required:this.required}),d),ref:this.componentRef,style:l?{...n,width:void 0}:n,dir:t,onFocus:this.handleFocus},this.props.prefix&&v.createElement(z,{...H}),this.renderSearchBar(O||"",P,g),A&&!o&&v.createElement(ee,{onClick:this.clearButtonClick,key:"clearbutton"}),o&&v.createElement(h.IconWrap,{className:h.classNames(h.uComboBox.loadingIcon({c:V})),name:"loading",key:"loading"}),this.props.suffix&&v.createElement(W,{...j}),v.createElement(te.Button,{tabIndex:-1,type:"button","aria-label":y?e:s,icon:c?void 0:"caret-alt-down",svgIcon:m||se.caretAltDownIcon,iconClass:c,size:b,fillMode:C,rounded:null,themeColor:"base",className:h.classNames(h.uComboBox.inputButton({c:V})),onClick:this.toggleBtnClick,onMouseDown:U=>U.preventDefault()}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return l?v.createElement($.FloatingLabel,{label:l,editorId:P,editorValue:O,editorValid:D,editorDisabled:i,style:{width:n?n.width:void 0},children:T,unstyled:x}):T}onNavigate(s,e,t){const{virtual:i={skip:0}}=this.props,r=p.getFilteredData(this.props),l=this.props.filter?this.props.filter:this.state.text;let a=-1,d;const n=this.base.vs,o=this.value;this._suggested="";const c=this.hasDuplicates&&this.duplicates.indexOf(o)!==-1;if(a=this.getFocusedIndex(c),a!==-1&&!p.isPresent(o))this.handleItemSelect(a,s);else if(l==="")this.handleItemSelect(0,s);else{const u=i.skip+a;d=this.base.navigation.navigate({keyCode:e,current:u,max:(n.enabled?n.total:r.length)-1,min:0,skipItems:t||void 0}),d!==void 0&&this.handleItemSelect(d,s)}this.navigationIndex=d}getCurrentValueDisabledStatus(s,e,t){return s&&e&&e[t]&&e[t].disabled}applyValueOnEnter(s,e){const{textField:t,allowCustom:i}=this.props,r=p.getFilteredData(this.props),l=this.props.opened!==void 0?this.props.opened:this.state.opened,d=p.getItemValue(this.value,t)===s?this.index:p.getItemIndexByText(r,s,t),n=d!==-1;let o;if(this._suggested="",n)o=r[d];else if(i)o=t!==void 0?{[t]:s}:s;else return this.selectFocusedItem(s,e);this.triggerOnChange(o,e),l&&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:i}=this.props,r=p.getFilteredData(this.props),l=this.props.opened!==void 0?this.props.opened:this.state.opened,a=p.getItemValue(this.value,t);if(this._suggested="",s===a||s===""&&!p.isPresent(a))return this.closeOpenedApplyStateNonMobileMode(e,l),this.applyState(e);const d=p.getItemIndexByText(r,s,t,!0),n=d!==-1;let o=null;n?o=r[d]:i&&(o=s?t?{[t]:s}:s:null),this.triggerOnChange(o,e),this.state.text!==void 0&&(e.data.text=void 0,this.base.filterChanged("",e)),this.closeOpenedApplyStateNonMobileMode(e,l),this.applyState(e)}selectFocusedItem(s,e){const t=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:i,virtual:r={skip:0},focusedItemIndex:l=p.itemIndexStartsWith}=this.props,a=p.getFilteredData(this.props),d=r.skip,n=s===""&&d===0?0:l(a,s,i);return n!==-1?this.handleItemSelect(n+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:i}=this.props,r=p.getFilteredData(this.props),l=this.props.opened!==void 0?this.props.opened:this.state.opened;let{group:a}=this.state;a===void 0&&e!==void 0&&(a=p.getItemValue(r[0],e));const d={title:t||this.props.label,subTitle:i,expand:l,onClose:n=>this.toggleBtnClick(n),windowWidth:s,mobileFilter:this.renderMobileListFilter()};return v.createElement(oe.AdaptiveMode,{...d},v.createElement(ie.ActionSheetContent,null,v.createElement("div",{className:"k-list-container"},this.listContainerContent())))}renderListContainer(){const s=this.base,{dir:e,header:t,footer:i,groupField:r,groupMode:l,size:a,list:d,virtual:n,groupStickyHeaderItemRender:o,unstyled:c}=this.props,u=p.getFilteredData(this.props),b=this.props.opened!==void 0?this.props.opened:this.state.opened,I=s.getPopupSettings(),C=I.width!==void 0?I.width:s.popupWidth,y=c&&c.uComboBox;let{group:g}=this.state;return g===void 0&&r!==void 0&&(g=p.getItemValue(u[0],r)),v.createElement(J,{width:C,popupSettings:{...I,anchor:I.anchor||this.element,show:b,popupClass:h.classNames(I.popupClass,h.uComboBox.listContainer({c:y,popup:!0}))},dir:e!==void 0?e:this.base.dirCalculated,itemsCount:[u.length]},v.createElement("div",{className:h.classNames(h.uComboBox.list({c:y,list:d,size:a,tableSize:a,virtual:n}))},t&&v.createElement("div",{className:h.classNames(h.uComboBox.listHeader({c:y}))},t),!d&&g&&u.length!==0&&v.createElement(_,{group:g,groupMode:l,render:o}),this.renderList(),i&&v.createElement("div",{className:h.classNames(h.uComboBox.listFooter({c:y}),this.props.footerClassName)},i)),this.showLicenseWatermark&&v.createElement(h.WatermarkOverlay,null))}renderList(){const s=this.base,{textField:e,dataItemKey:t,listNoDataRender:i,itemRender:r,groupHeaderItemRender:l,virtual:a={skip:0,total:void 0},unstyled:d}=this.props,n=p.getFilteredData(this.props),o=s.getPopupSettings(),c=s.vs,u=a.skip,b=this.props.opened!==void 0?this.props.opened:this.state.opened,I=`translateY(${c.translate}px)`,C=b?this.getFocusedIndex(this.hasDuplicates):void 0,y=this.props.filter!==void 0?this.props.filter:this.state.text,g=p.getItemValue(this.value,e),m=p.isPresent(y)&&y!==g?null:this.value,x=this.props.list||Q,D=d&&d.uComboBox;return v.createElement(x,{id:s.listBoxId,virtual:!!a,show:b,data:n,focusedIndex:C,value:m,textField:e,valueField:t,groupField:this.props.groupField,groupMode:this.props.groupMode,isMultiColumn:this.props.isMultiColumn,optionsGuid:s.guid,hasDuplicates:this.hasDuplicates,listRef:F=>{c.list=this.base.list=F,this.itemHeight=0},wrapperStyle:this.state.windowWidth&&this.props._adaptiveMode&&this.state.windowWidth>this.props._adaptiveMode.medium?{maxHeight:o.height}:{},wrapperCssClass:h.classNames(h.uComboBox.listContent({c:D,virtual:a})),listStyle:c.enabled?{transform:I}:void 0,key:"listkey",skip:u,onClick:this.handleItemClick,itemRender:r,groupHeaderItemRender:l,noDataRender:i,onMouseDown:F=>F.preventDefault(),onScroll:this.onScroll,wrapperRef:c.scrollerRef,scroller:this.base.renderScrollElement(),ariaSetSize:a.total})}renderSearchBar(s,e,t){const{tabIndex:i,disabled:r,title:l,ariaLabelledBy:a,ariaDescribedBy:d,dataItemKey:n,virtual:o={skip:0},accessKey:c,unstyled:u,inputAttributes:b}=this.props,I=p.getFilteredData(this.props),C=this.props.opened!==void 0?this.props.opened:this.state.opened,y=this.value,g=Math.max(0,I.findIndex(m=>p.areSame(m,y,n)));return this._suggested&&!p.areSame(this._valueOnDidUpdate,y,n)&&(this._suggested=""),v.createElement(Y,{id:e,readOnly:C&&this.mobileMode,placeholder:t,tabIndex:i,title:l,value:s+this._suggested,suggestedText:this._suggested,ref:m=>{this._input=m&&m.input},onClick:this.onInputClick,onKeyDown:this.onInputKeyDown,onChange:this.inputOnChange,onFocus:this.base.handleFocus,onBlur:this.handleBlur,disabled:r,expanded:C,owns:this.base.listBoxId,activedescendant:`option-${this.base.guid}-${g+o.skip}`,role:"combobox",ariaLabelledBy:a,ariaLabel:this.props.ariaLabel,ariaDescribedBy:d,ariaRequired:this.required,render:this.props.valueRender,ariaControls:this.base.listBoxId,unstyled:u,inputAttributes:b})}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:i,virtual:r={skip:0},focusedItemIndex:l=p.itemIndexStartsWith,skipDisabledItems:a}=this.props,d=p.getFilteredData(this.props),n=this.props.filter?this.props.filter:this.state.text;return s&&this.navigationIndex!==void 0?this.navigationIndex:p.isPresent(e)&&n===void 0?d.findIndex(o=>p.areSame(o,e,i)):n?l(d,n,t):a&&t&&!n&&r.skip===0?d.findIndex(o=>!o.disabled&&o[t]):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})}};S.displayName="ComboBox",S.propTypes={...E.propTypes,size:f.oneOf([null,"small","medium","large"]),rounded:f.oneOf([null,"small","medium","large","full"]),fillMode:f.oneOf([null,"solid","flat","outline"]),dataItemKey:f.string,groupField:f.string,groupMode:f.oneOf([void 0,"classic","modern"]),isMultiColumn:f.bool,suggest:f.bool,placeholder:f.string,title:f.string,allowCustom:f.bool,clearButton:f.bool,iconClassName:f.string,svgIcon:h.svgIconPropType,validationMessage:f.string,required:f.bool,id:f.string,ariaLabelledBy:f.string,ariaLabel:f.string,ariaDescribedBy:f.string,list:f.any,valueRender:f.func,skipDisabledItems:f.bool,inputAttributes:f.object},S.defaultProps={...E.defaultProps,size:"medium",rounded:"medium",fillMode:"solid",allowCustom:!1,clearButton:!0,required:!1,groupMode:"modern",isMultiColumn:!1,skipDisabledItems:!0,prefix:void 0,suffix:void 0};let M=S;const L=h.createPropsContext(),R=h.withIdHOC(h.withPropsContext(L,h.withUnstyledHOC(h.withAdaptiveModeContext(M))));R.displayName="KendoReactComboBox";exports.ComboBox=R;exports.ComboBoxPropsContext=L;exports.ComboBoxWithoutContext=M;
|