@progress/kendo-react-dropdowns 9.5.0 → 10.0.0-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AutoComplete/AutoComplete.js +1 -1
- package/AutoComplete/AutoComplete.mjs +251 -252
- package/ComboBox/ComboBox.js +1 -1
- package/ComboBox/ComboBox.mjs +53 -52
- package/DropDownList/DropDownList.js +1 -1
- package/DropDownList/DropDownList.mjs +217 -210
- package/DropDownTree/DropDownTree.js +1 -1
- package/DropDownTree/DropDownTree.mjs +91 -91
- package/MultiSelect/MultiSelect.js +1 -1
- package/MultiSelect/MultiSelect.mjs +114 -105
- package/MultiSelectTree/MultiSelectTree.js +1 -1
- package/MultiSelectTree/MultiSelectTree.mjs +222 -223
- package/dist/cdn/js/kendo-react-dropdowns.js +1 -1
- package/index.d.mts +8 -3
- package/index.d.ts +8 -3
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +10 -10
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"),R=require("@progress/kendo-svg-icons"),k=require("../messages/index.js"),L=require("@progress/kendo-react-intl"),N=require("@progress/kendo-react-layout"),q=require("../common/withCustomComponent.js");function ae(F){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(F){for(const e in F)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(F,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>F[e]})}}return s.default=F,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.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)},i.validatePackage(ie.packageMetadata)}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=L.provideLocalizationService(this).toLanguageString(k.comboArrowBtnAriaLabelExpand,k.messages[k.comboArrowBtnAriaLabelExpand]),e=L.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),E=h.isPresent(w)?w:W,j=l&&(!!E||h.isPresent(this.value)),B=this.base.vs,P=this.props.id||this._inputId,T=this.mobileMode,O=x&&x.uComboBox;B.enabled=c!==void 0,c!==void 0&&(B.skip=c.skip,B.total=c.total,B.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(E||"",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||R.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:E,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:R.xIcon}))),g.createElement("div",{className:i.classNames(i.uDropDownsActionSheet.titleBarGroup({c:u}))},this.renderMobileListFilter())),g.createElement(N.ActionSheetContent,{overflowHidden:!0},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)))}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 M=D;const z=i.createPropsContext(),H=i.withIdHOC(i.withPropsContext(z,i.withUnstyledHOC(i.withAdaptiveModeContext(M))));H.displayName="KendoReactComboBox";exports.ComboBox=H;exports.ComboBoxPropsContext=z;exports.ComboBoxWithoutContext=M;
|
|
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,{overflowHidden:!0},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;
|
package/ComboBox/ComboBox.mjs
CHANGED
|
@@ -8,31 +8,31 @@
|
|
|
8
8
|
import * as c from "react";
|
|
9
9
|
import v from "prop-types";
|
|
10
10
|
import N from "../common/DropDownBase.mjs";
|
|
11
|
-
import { Keys as C, validatePackage as ie, svgIconPropType as oe, canUseDOM as z, classNames as I, uComboBox as w, IconWrap as ae, uDropDownsActionSheet as B,
|
|
12
|
-
import { FloatingLabel as
|
|
13
|
-
import { getPlainDataDuplicates as
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import { packageMetadata as
|
|
20
|
-
import
|
|
21
|
-
import { Button as
|
|
22
|
-
import { caretAltDownIcon as
|
|
23
|
-
import { comboArrowBtnAriaLabelExpand as
|
|
11
|
+
import { Keys as C, validatePackage as ie, svgIconPropType as oe, canUseDOM as z, classNames as I, uComboBox as w, IconWrap as ae, uDropDownsActionSheet as B, WatermarkOverlay as ne, createPropsContext as le, withIdHOC as re, withPropsContext as de, withUnstyledHOC as pe, withAdaptiveModeContext as he } from "@progress/kendo-react-common";
|
|
12
|
+
import { FloatingLabel as ce } from "@progress/kendo-react-labels";
|
|
13
|
+
import { getPlainDataDuplicates as ue, getFilteredData as S, areSame as k, getItemValue as M, isPresent as D, getItemIndexByText as K, suggestValue as ge, itemIndexStartsWith as H } from "../common/utils.mjs";
|
|
14
|
+
import me from "../common/SearchBar.mjs";
|
|
15
|
+
import ve from "../common/ListContainer.mjs";
|
|
16
|
+
import fe from "../common/List.mjs";
|
|
17
|
+
import be from "../common/ListFilter.mjs";
|
|
18
|
+
import W from "../common/GroupStickyHeader.mjs";
|
|
19
|
+
import { packageMetadata as xe } from "../package-metadata.mjs";
|
|
20
|
+
import Ie from "../common/ClearButton.mjs";
|
|
21
|
+
import { Button as q } from "@progress/kendo-react-buttons";
|
|
22
|
+
import { caretAltDownIcon as ye, xIcon as Ce } from "@progress/kendo-svg-icons";
|
|
23
|
+
import { comboArrowBtnAriaLabelExpand as G, messages as U, comboArrowBtnAriaLabelCollapse as j } from "../messages/index.mjs";
|
|
24
24
|
import { provideLocalizationService as $ } from "@progress/kendo-react-intl";
|
|
25
|
-
import { ActionSheet as
|
|
25
|
+
import { ActionSheet as Se, ActionSheetHeader as we, ActionSheetContent as De } from "@progress/kendo-react-layout";
|
|
26
26
|
import Y from "../common/withCustomComponent.mjs";
|
|
27
|
-
const
|
|
27
|
+
const ke = "Please enter a valid value!", F = class F extends c.Component {
|
|
28
28
|
constructor(s) {
|
|
29
|
-
super(s), this.state = {}, this.base = new N(this), this._element = null, this._suggested = "", this._skipBlur = !1, this._input = null, this._adaptiveFilterInput = null, this.itemHeight = 0, this.duplicates = [], this.hasDuplicates = !1, this.focus = () => {
|
|
29
|
+
super(s), this.state = {}, this.base = new N(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 = () => {
|
|
30
30
|
this._input && this._input.focus();
|
|
31
31
|
}, this.checkForDuplicatePlainTextRecords = () => {
|
|
32
32
|
const e = this.props.textField !== void 0, t = this.props.dataItemKey !== void 0;
|
|
33
33
|
if (this.props.data && this.props.data.length > 0 && !e && !t) {
|
|
34
34
|
const i = this.props.data;
|
|
35
|
-
this.duplicates =
|
|
35
|
+
this.duplicates = ue(i), this.hasDuplicates = this.duplicates.length > 0;
|
|
36
36
|
}
|
|
37
37
|
}, this.handleItemSelect = (e, t) => {
|
|
38
38
|
const { virtual: i, dataItemKey: n } = this.props, r = S(this.props), a = i ? i.skip : 0, d = r[e - a], l = this.hasDuplicates || !k(d, this.value, n);
|
|
@@ -55,7 +55,7 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
55
55
|
}, this.renderMobileListFilter = () => {
|
|
56
56
|
const e = this.props.adaptiveFilter !== void 0 ? this.props.adaptiveFilter : this.state.text, t = M(this.value, this.props.textField), i = D(e) ? e : t;
|
|
57
57
|
return /* @__PURE__ */ c.createElement(
|
|
58
|
-
|
|
58
|
+
be,
|
|
59
59
|
{
|
|
60
60
|
value: i,
|
|
61
61
|
ref: (n) => this._adaptiveFilterInput = n && n.element,
|
|
@@ -178,9 +178,9 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
178
178
|
t.syntheticEvent = e, e.stopPropagation(), this.clearValue();
|
|
179
179
|
}, this.setValidity = () => {
|
|
180
180
|
this._input && this._input.setCustomValidity && this._input.setCustomValidity(
|
|
181
|
-
this.validity.valid ? "" : this.props.validationMessage ||
|
|
181
|
+
this.validity.valid ? "" : this.props.validationMessage || ke
|
|
182
182
|
);
|
|
183
|
-
}, ie(
|
|
183
|
+
}, this.showLicenseWatermark = !ie(xe, { component: "ComboBox" });
|
|
184
184
|
}
|
|
185
185
|
get _inputId() {
|
|
186
186
|
return this.props.id;
|
|
@@ -274,11 +274,11 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
274
274
|
/** @hidden */
|
|
275
275
|
render() {
|
|
276
276
|
const s = $(this).toLanguageString(
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
G,
|
|
278
|
+
U[G]
|
|
279
279
|
), e = $(this).toLanguageString(
|
|
280
280
|
j,
|
|
281
|
-
|
|
281
|
+
U[j]
|
|
282
282
|
), {
|
|
283
283
|
dir: t,
|
|
284
284
|
disabled: i,
|
|
@@ -297,9 +297,9 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
297
297
|
placeholder: h,
|
|
298
298
|
svgIcon: g,
|
|
299
299
|
unstyled: f
|
|
300
|
-
} = this.props, E = !this.validityStyles || this.validity.valid, O = this.props.filter !== void 0 ? this.props.filter : this.state.text, J = M(this.value, a), T = D(O) ? O : J, Q = n && (!!T || D(this.value)), V = this.base.vs, A = this.props.id || this._inputId,
|
|
300
|
+
} = this.props, E = !this.validityStyles || this.validity.valid, O = this.props.filter !== void 0 ? this.props.filter : this.state.text, J = M(this.value, a), T = D(O) ? O : J, Q = n && (!!T || D(this.value)), V = this.base.vs, A = this.props.id || this._inputId, L = this.mobileMode, _ = f && f.uComboBox;
|
|
301
301
|
V.enabled = p !== void 0, p !== void 0 && (V.skip = p.skip, V.total = p.total, V.pageSize = p.pageSize);
|
|
302
|
-
const [X, Z] = Y(this.props.prefix || c.Fragment), [ee, te] = Y(this.props.suffix || c.Fragment),
|
|
302
|
+
const [X, Z] = Y(this.props.prefix || c.Fragment), [ee, te] = Y(this.props.suffix || c.Fragment), R = /* @__PURE__ */ c.createElement(c.Fragment, null, /* @__PURE__ */ c.createElement(
|
|
303
303
|
"span",
|
|
304
304
|
{
|
|
305
305
|
className: I(
|
|
@@ -321,7 +321,7 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
321
321
|
},
|
|
322
322
|
this.props.prefix && /* @__PURE__ */ c.createElement(X, { ...Z }),
|
|
323
323
|
this.renderSearchBar(T || "", A, h),
|
|
324
|
-
Q && !o && /* @__PURE__ */ c.createElement(
|
|
324
|
+
Q && !o && /* @__PURE__ */ c.createElement(Ie, { onClick: this.clearButtonClick, key: "clearbutton" }),
|
|
325
325
|
o && /* @__PURE__ */ c.createElement(
|
|
326
326
|
ae,
|
|
327
327
|
{
|
|
@@ -332,13 +332,13 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
332
332
|
),
|
|
333
333
|
this.props.suffix && /* @__PURE__ */ c.createElement(ee, { ...te }),
|
|
334
334
|
/* @__PURE__ */ c.createElement(
|
|
335
|
-
|
|
335
|
+
q,
|
|
336
336
|
{
|
|
337
337
|
tabIndex: -1,
|
|
338
338
|
type: "button",
|
|
339
339
|
"aria-label": m ? e : s,
|
|
340
340
|
icon: u ? void 0 : "caret-alt-down",
|
|
341
|
-
svgIcon: g ||
|
|
341
|
+
svgIcon: g || ye,
|
|
342
342
|
iconClass: u,
|
|
343
343
|
size: y,
|
|
344
344
|
fillMode: x,
|
|
@@ -349,10 +349,10 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
349
349
|
onMouseDown: (se) => se.preventDefault()
|
|
350
350
|
}
|
|
351
351
|
),
|
|
352
|
-
!
|
|
353
|
-
),
|
|
352
|
+
!L && this.renderListContainer()
|
|
353
|
+
), L && this.renderAdaptiveListContainer());
|
|
354
354
|
return r ? /* @__PURE__ */ c.createElement(
|
|
355
|
-
|
|
355
|
+
ce,
|
|
356
356
|
{
|
|
357
357
|
label: r,
|
|
358
358
|
editorId: A,
|
|
@@ -360,10 +360,10 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
360
360
|
editorValid: E,
|
|
361
361
|
editorDisabled: i,
|
|
362
362
|
style: { width: l ? l.width : void 0 },
|
|
363
|
-
children:
|
|
363
|
+
children: R,
|
|
364
364
|
unstyled: f
|
|
365
365
|
}
|
|
366
|
-
) :
|
|
366
|
+
) : R;
|
|
367
367
|
}
|
|
368
368
|
/** @hidden */
|
|
369
369
|
onNavigate(s, e, t) {
|
|
@@ -445,8 +445,8 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
445
445
|
animationStyles: s && p && s <= p.small ? { top: 0, width: "100%", height: "100%" } : void 0,
|
|
446
446
|
position: s && p && s <= p.small ? "fullscreen" : void 0
|
|
447
447
|
};
|
|
448
|
-
return /* @__PURE__ */ c.createElement(
|
|
449
|
-
|
|
448
|
+
return /* @__PURE__ */ c.createElement(Se, { ...f }, /* @__PURE__ */ c.createElement(we, null, /* @__PURE__ */ c.createElement("div", { className: I(B.titleBar({ c: h })) }, /* @__PURE__ */ c.createElement("div", { className: I(B.title({ c: h })) }, /* @__PURE__ */ c.createElement("div", { className: I(B.header({ c: h })) }, l), /* @__PURE__ */ c.createElement("div", { className: I(B.subtitle({ c: h })) })), /* @__PURE__ */ c.createElement("div", { className: I(B.actions({ c: h })) }, /* @__PURE__ */ c.createElement(
|
|
449
|
+
q,
|
|
450
450
|
{
|
|
451
451
|
tabIndex: 0,
|
|
452
452
|
"aria-label": "Cancel",
|
|
@@ -457,9 +457,9 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
457
457
|
size: "large",
|
|
458
458
|
onClick: this.toggleBtnClick,
|
|
459
459
|
icon: "x",
|
|
460
|
-
svgIcon:
|
|
460
|
+
svgIcon: Ce
|
|
461
461
|
}
|
|
462
|
-
))), /* @__PURE__ */ c.createElement("div", { className: I(B.titleBarGroup({ c: h })) }, this.renderMobileListFilter())), /* @__PURE__ */ c.createElement(
|
|
462
|
+
))), /* @__PURE__ */ c.createElement("div", { className: I(B.titleBarGroup({ c: h })) }, this.renderMobileListFilter())), /* @__PURE__ */ c.createElement(De, { overflowHidden: !0 }, /* @__PURE__ */ c.createElement(
|
|
463
463
|
"div",
|
|
464
464
|
{
|
|
465
465
|
className: I(
|
|
@@ -483,7 +483,7 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
483
483
|
},
|
|
484
484
|
e && /* @__PURE__ */ c.createElement("div", { className: I(w.listHeader({ c: m })) }, e),
|
|
485
485
|
!a && g && y.length !== 0 && /* @__PURE__ */ c.createElement(
|
|
486
|
-
|
|
486
|
+
W,
|
|
487
487
|
{
|
|
488
488
|
group: g,
|
|
489
489
|
groupMode: r,
|
|
@@ -519,7 +519,7 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
519
519
|
} = this.props, p = S(this.props), y = this.props.opened !== void 0 ? this.props.opened : this.state.opened, b = s.getPopupSettings(), x = b.width !== void 0 ? b.width : s.popupWidth, m = u && u.uComboBox;
|
|
520
520
|
let { group: h } = this.state;
|
|
521
521
|
return h === void 0 && n !== void 0 && (h = M(p[0], n)), /* @__PURE__ */ c.createElement(
|
|
522
|
-
|
|
522
|
+
ve,
|
|
523
523
|
{
|
|
524
524
|
width: x,
|
|
525
525
|
popupSettings: {
|
|
@@ -551,7 +551,7 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
551
551
|
)
|
|
552
552
|
},
|
|
553
553
|
t && /* @__PURE__ */ c.createElement("div", { className: I(w.listHeader({ c: m })) }, t),
|
|
554
|
-
!d && h && p.length !== 0 && /* @__PURE__ */ c.createElement(
|
|
554
|
+
!d && h && p.length !== 0 && /* @__PURE__ */ c.createElement(W, { group: h, groupMode: r, render: o }),
|
|
555
555
|
this.renderList(),
|
|
556
556
|
i && /* @__PURE__ */ c.createElement(
|
|
557
557
|
"div",
|
|
@@ -563,7 +563,8 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
563
563
|
},
|
|
564
564
|
i
|
|
565
565
|
)
|
|
566
|
-
)
|
|
566
|
+
),
|
|
567
|
+
this.showLicenseWatermark && /* @__PURE__ */ c.createElement(ne, null)
|
|
567
568
|
);
|
|
568
569
|
}
|
|
569
570
|
renderList() {
|
|
@@ -575,7 +576,7 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
575
576
|
groupHeaderItemRender: r,
|
|
576
577
|
virtual: a = { skip: 0, total: void 0 },
|
|
577
578
|
unstyled: d
|
|
578
|
-
} = this.props, l = S(this.props), o = s.getPopupSettings(), u = s.vs, p = a.skip, y = this.props.opened !== void 0 ? this.props.opened : this.state.opened, b = `translateY(${u.translate}px)`, x = y ? this.getFocusedIndex(this.hasDuplicates) : void 0, m = this.props.filter !== void 0 ? this.props.filter : this.state.text, h = M(this.value, e), g = D(m) && m !== h ? null : this.value, f = this.props.list ||
|
|
579
|
+
} = this.props, l = S(this.props), o = s.getPopupSettings(), u = s.vs, p = a.skip, y = this.props.opened !== void 0 ? this.props.opened : this.state.opened, b = `translateY(${u.translate}px)`, x = y ? this.getFocusedIndex(this.hasDuplicates) : void 0, m = this.props.filter !== void 0 ? this.props.filter : this.state.text, h = M(this.value, e), g = D(m) && m !== h ? null : this.value, f = this.props.list || fe, E = d && d.uComboBox;
|
|
579
580
|
return /* @__PURE__ */ c.createElement(
|
|
580
581
|
f,
|
|
581
582
|
{
|
|
@@ -634,7 +635,7 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
634
635
|
b.findIndex((g) => k(g, m, l))
|
|
635
636
|
);
|
|
636
637
|
return this._suggested && !k(this._valueOnDidUpdate, m, l) && (this._suggested = ""), /* @__PURE__ */ c.createElement(
|
|
637
|
-
|
|
638
|
+
me,
|
|
638
639
|
{
|
|
639
640
|
id: e,
|
|
640
641
|
readOnly: x && this.mobileMode,
|
|
@@ -687,7 +688,7 @@ const De = "Please enter a valid value!", F = class F extends c.Component {
|
|
|
687
688
|
}
|
|
688
689
|
suggestValue(s) {
|
|
689
690
|
const { data: e, textField: t } = this.props;
|
|
690
|
-
this._suggested =
|
|
691
|
+
this._suggested = ge(s, e, t);
|
|
691
692
|
}
|
|
692
693
|
applyState(s) {
|
|
693
694
|
this.base.applyState(s), this._valueDuringOnChange = void 0;
|
|
@@ -738,17 +739,17 @@ F.displayName = "ComboBox", F.propTypes = {
|
|
|
738
739
|
suffix: void 0
|
|
739
740
|
};
|
|
740
741
|
let P = F;
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
742
|
+
const Ee = le(), Me = re(
|
|
743
|
+
de(
|
|
744
|
+
Ee,
|
|
745
|
+
pe(
|
|
746
|
+
he(P)
|
|
746
747
|
)
|
|
747
748
|
)
|
|
748
749
|
);
|
|
749
|
-
|
|
750
|
+
Me.displayName = "KendoReactComboBox";
|
|
750
751
|
export {
|
|
751
|
-
|
|
752
|
-
|
|
752
|
+
Me as ComboBox,
|
|
753
|
+
Ee as ComboBoxPropsContext,
|
|
753
754
|
P as ComboBoxWithoutContext
|
|
754
755
|
};
|
|
@@ -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 Bt=require("react"),k=require("prop-types"),o=require("@progress/kendo-react-common"),Ht=require("@progress/kendo-react-labels"),tt=require("@progress/kendo-svg-icons"),_t=require("../common/ListContainer.js"),Wt=require("../common/ListFilter.js"),nt=require("../common/GroupStickyHeader.js"),Ut=require("../common/ListDefaultItem.js"),Gt=require("../common/List.js"),ot=require("../common/DropDownBase.js"),u=require("../common/utils.js"),jt=require("../package-metadata.js"),rt=require("@progress/kendo-react-buttons"),Yt=require("@progress/kendo-react-intl"),Pe=require("../messages/index.js"),Fe=require("@progress/kendo-react-layout");function $t(I){const Y=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(I){for(const E in I)if(E!=="default"){const B=Object.getOwnPropertyDescriptor(I,E);Object.defineProperty(Y,E,B.get?B:{enumerable:!0,get:()=>I[E]})}}return Y.default=I,Object.freeze(Y)}const s=$t(Bt),Jt="Please select a value from the list!",pe=s.forwardRef((I,Y)=>{o.validatePackage(jt.packageMetadata);const E=o.useUnstyled(),B=o.useId(I.id),r=o.usePropsContext(at,I),{delay:st=F.delay,tabIndex:it=F.tabIndex,ignoreCase:me=F.ignoreCase,size:$=F.size,rounded:Me=F.rounded,fillMode:ge=F.fillMode,groupMode:Qt=F.groupMode}=r,fe=()=>{var e;if(o.canUseDOM)return((e=Q.current)==null?void 0:e.ownerDocument)||window.document},lt=()=>{var e,n;(e=t==null?void 0:t.current)!=null&&e.wrapper&&((n=t==null?void 0:t.current)==null||n.wrapper.focus({preventScroll:!0}))},N=()=>{let e;return O.current!==void 0&&O.current!==null?e=O.current:r.value!==void 0?e=r.value:g.value!==void 0&&g.value!==null?e=g.value:r.defaultValue!==void 0&&r.defaultValue!==null&&(e=r.defaultValue),!u.isPresent(e)&&r.defaultItem!==void 0&&r.defaultItem!==null&&(e=r.defaultItem),e},dt=()=>{const{dataItemKey:e}=r,n=u.getFilteredData(I),i=N();return n.findIndex(p=>u.areSame(p,i,e))},ve=()=>r.required!==void 0?r.required:F.required,De=()=>{const e=r.validationMessage!==void 0,n=N(),i=!ve()||n!==null&&n!==""&&n!==void 0,p=r.valid!==void 0?r.valid:i;return{customError:e,valid:p,valueMissing:n===null}},ct=()=>r.validityStyles!==void 0?r.validityStyles:F.validityStyles,ne=e=>{re.current=!0,e.focus(),window.setTimeout(()=>re.current=!1,30)},ye=()=>{X.current&&ne(X.current),r.adaptive&&setTimeout(()=>{X.current&&ne(X.current)},300)},ut=s.useCallback(e=>{for(const n of e)Kt(n.target.clientWidth)},[]),Te=()=>{var e;(e=Se.current)!=null&&e.setCustomValidity&&Se.current.setCustomValidity(De().valid?"":r.validationMessage||Jt)},H=(e,n)=>{const i=N();u.areSame(i,e,r.dataItemKey)||(r.value===void 0&&(n.data.value=e),t.current.updateComponentArgs({value:e}),O.current=e,n.events.push({type:"onChange"}))},b=e=>{var n;(n=t==null?void 0:t.current)==null||n.applyState(e),O.current=void 0},J=(e,n)=>{var d;const{virtual:i,dataItemKey:p,defaultItem:m}=r,f=u.getFilteredData(I),D=i?i.skip:0,v=N(),a=e===-1&&m!==void 0?m:f[e-D],c=!u.areSame(a,v,p);H(a,n),c&&((d=t==null?void 0:t.current)==null||d.triggerPageChangeCornerItems(a,n))},T=(e,n,i)=>{var h,w;const{defaultItem:p,dataItemKey:m,virtual:f={skip:0,total:0,pageSize:0}}=r,D=N(),v=u.getFilteredData(I),a=(h=t==null?void 0:t.current)==null?void 0:h.vs,c=v.findIndex(S=>u.areSame(S,D,m)),d=(w=t==null?void 0:t.current)==null?void 0:w.navigation.navigate({current:f.skip+c,max:(a!=null&&a.enabled?f.total:v.length)-1,min:p!==void 0?-1:0,keyCode:n,skipItems:i||void 0});d!==void 0&&J(d,e),b(e)},pt=e=>{Q.current=e,t.current.wrapper=e},mt=e=>s.createElement("select",{name:r.name,ref:n=>{Se.current=n},tabIndex:-1,"aria-hidden":!0,title:r.label,style:{opacity:0,width:1,border:0,zIndex:-1,position:"absolute",left:"50%"}},s.createElement("option",{value:r.valueMap?r.valueMap.call(void 0,e):e})),we=()=>{const{textField:e,dataItemKey:n,virtual:i={skip:0},focusedItemIndex:p=u.itemIndexStartsWith,filterable:m,skipDisabledItems:f=!0}=r,D=N(),v=u.getFilteredData(I),a=r.filter?r.filter:g.text;return f&&e&&!a&&!D?v.findIndex(c=>!c.disabled&&c[e]):u.isPresent(D)&&a===void 0||m&&a===""?v.findIndex(c=>u.areSame(c,D,n)):a?xe.current?p(v,a,e):v.findIndex(c=>u.areSame(c,D,n)):i.skip===0?0:-1},Oe=(e,n)=>n!==void 0&&n!==-1&&e&&e.length>0&&e[n].disabled,he=()=>{const e=u.getFilteredData(I),n=t.current.initState(),i=we();Oe(e,i)&&(H(null,n),b(n))},Ie=e=>{if(e.isPropagationStopped())return;const n=t.current.initState();n.syntheticEvent=e,g.focused||(n.data.focused=!0),he(),t.current.togglePopup(n),b(n)},qe=e=>{var M,ce,V,ue,j,Re,et;e&&e.target instanceof Element&&e.target.nodeName==="INPUT"&&e.stopPropagation&&e.stopPropagation();const{filterable:n,disabled:i,defaultItem:p,leftRightKeysNavigation:m=!0,virtual:f={skip:0,total:0,pageSize:0},dataItemKey:D,groupField:v="",textField:a,skipDisabledItems:c=!0}=r,d=u.getFilteredData(I),h=N(),w=d.findIndex(L=>u.areSame(L,h,D)),S=r.opened!==void 0?r.opened:g.opened,l=e.keyCode,P=l===o.Keys.home||l===o.Keys.end,K=l===o.Keys.up||l===o.Keys.down,G=!S&&(e.altKey&&l===o.Keys.down||l===o.Keys.enter||l===o.Keys.space),te=S&&(e.altKey&&l===o.Keys.up||l===o.Keys.esc),le=m&&(l===o.Keys.left||l===o.Keys.right),de=K||le&&!n||P,C=t.current.initState();if(C.syntheticEvent=e,!i){if(P&&((M=t==null?void 0:t.current)!=null&&M.vs.enabled))l===o.Keys.home?f.skip!==0?((ce=t==null?void 0:t.current)==null||ce.triggerOnPageChange(C,0,f.pageSize),q.current=!0):H(d[0],C):f.skip<f.total-f.pageSize?((V=t==null?void 0:t.current)==null||V.triggerOnPageChange(C,f.total-f.pageSize,f.pageSize),q.current=!0):H(d[d.length-1],C);else if(S&&l===o.Keys.pageUp)e.preventDefault(),(ue=t==null?void 0:t.current)==null||ue.scrollPopupByPageSize(-1);else if(S&&l===o.Keys.pageDown)e.preventDefault(),(j=t==null?void 0:t.current)==null||j.scrollPopupByPageSize(1);else if(S&&l===o.Keys.enter){const L=we();Oe(d,L)?(H(null,C),b(C)):J(L,C),(Re=t==null?void 0:t.current)==null||Re.togglePopup(C),e.preventDefault()}else if(G||te)te&&he(),(et=t==null?void 0:t.current)==null||et.togglePopup(C),e.preventDefault();else if(de){if(xe.current=!1,v!==""&&a)if(!c&&S)T(C,l);else{let L;if(l===o.Keys.down||l===o.Keys.right){const x=d.slice(w+1).find(y=>!y.disabled&&y[a]);L=x&&d.findIndex(y=>y[a]===x[a])}else if(l===o.Keys.up||l===o.Keys.left){let x;if(w===0&&p)L=-1;else if(w===-1)x=d,L=d.findIndex(y=>!y.disabled&&y[a]);else{x=d.slice(0,w);let y=x.pop();for(;y&&y.disabled;)y=x.pop();L=y&&d.findIndex(be=>be[a]===y[a])}}if(L!==void 0){const x=L-w;T(C,l,x)}else L===void 0&&d.findIndex(x=>x[a]===h[a])===d.length-1&&T(C,l)}else if(!c&&S||P)T(C,l);else if(a){let L;if(l===o.Keys.down||l===o.Keys.right){const x=d.slice(w+1).find(y=>!y.disabled&&y[a]);L=x&&d.findIndex(y=>y[a]===x[a])}else if(l===o.Keys.up||l===o.Keys.left){let x;if(w===0&&p)L=-1;else if(w===-1)x=d,L=d.find(y=>!y.disabled&&y[a]);else{x=d.slice(0,w);let y=x.pop();for(;y&&y.disabled;)y=x.pop();L=y&&d.findIndex(be=>be[a]===y[a])}}if(L!==void 0){const x=L-w;T(C,l,x)}else L===void 0&&d.findIndex(x=>x[a]===h[a])===d.length-1&&T(C,l)}else T(C,l);e.preventDefault()}b(C)}},gt=e=>{const n=t.current.initState();n.syntheticEvent=e.syntheticEvent,r.filter===void 0&&(n.data.text=e.target.value),t.current.filterChanged(e.target.value,n),xe.current=!0,b(n),R({group:void 0,text:String(e.target.value)})},Ae=()=>{const e=r.filter!==void 0?r.filter:g.text;return r.filterable&&s.createElement(Wt,{value:e,ref:n=>X.current=n&&n.element,onChange:gt,onKeyDown:qe,size:$,rounded:Me,fillMode:ge,renderListFilterWrapper:!0})},ft=e=>{var i;const n=t.current.initState();n.syntheticEvent=e,(i=t==null?void 0:t.current)==null||i.togglePopup(n),H(r.defaultItem,n),b(n)},ze=()=>{const{textField:e,defaultItem:n,dataItemKey:i}=r,p=N();return n!==void 0&&s.createElement(Ut,{defaultItem:n,textField:e,selected:u.areSame(p,n,i),key:"defaultitemkey",onClick:ft})},vt=(e,n)=>{var i;(i=t==null?void 0:t.current)==null||i.handleItemClick(e,n),O.current=void 0},Dt=e=>{const{vs:n,list:i}=t.current;n.scrollHandler(e);const{groupField:p}=r;let m=u.getFilteredData(I);if(!(!p||!m.length)&&p){const f=_e.current=_e.current||(n.enabled?n.itemHeight:i?i.children[0].offsetHeight:0),v=e.target.scrollTop-n.skip*f;m=t.current.getGroupedDataModernMode(m,p);let a=m[0][p];for(let c=1;c<m.length&&!(f*c>v);c++)m[c]&&m[c][p]&&(a=m[c][p]);a!==g.group&&R({group:a})}},Ve=()=>{var l;const{textField:e,dataItemKey:n,virtual:i={skip:0,total:void 0},groupHeaderItemRender:p,listNoDataRender:m,itemRender:f}=r,D=u.getFilteredData(I),v=E&&E.uDropDownList,a=t.current.vs,c=i.skip,d=r.opened!==void 0?r.opened:g.opened,h=t.current.getPopupSettings(),w=`translateY(${a.translate}px)`,S=N();return s.createElement(Gt,{id:Le,show:d,data:D.slice(),focusedIndex:we(),value:S,textField:e,valueField:n,optionsGuid:Ge,groupField:r.groupField,groupMode:"modern",listRef:P=>a.list=t.current.list=P,wrapperStyle:{maxHeight:h.height},wrapperCssClass:o.classNames(o.uDropDownList.listContent({c:v})),listStyle:a.enabled?{transform:w}:void 0,key:"listkey",skip:c,onClick:vt,itemRender:f,groupHeaderItemRender:p,noDataRender:m,onScroll:Dt,wrapperRef:a.scrollerRef,scroller:(l=t==null?void 0:t.current)==null?void 0:l.renderScrollElement(),ariaSetSize:i.total})},yt=()=>{var w;const{header:e,footer:n,adaptiveTitle:i,groupField:p,groupStickyHeaderItemRender:m,list:f}=r,D=u.getFilteredData(I),v=r.opened!==void 0?r.opened:g.opened,a=E&&E.uDropDownList,c=E&&E.uDropDownsActionSheet,d={navigatable:!1,navigatableElements:[],expand:v,animation:!0,onClose:S=>Ie(S),className:o.classNames(o.uDropDownsActionSheet.wrapper({c}),"k-adaptive-actionsheet"),animationStyles:W&&U&&W<=U.small?{top:0,width:"100%",height:"100%"}:void 0,position:W&&U&&W<=U.small?"fullscreen":void 0};let{group:h}=g;return h===void 0&&p!==void 0&&(h=u.getItemValue(D[0],p)),s.createElement(Fe.ActionSheet,{...d},s.createElement(Fe.ActionSheetHeader,{className:o.classNames(o.uDropDownsActionSheet.header({c}))},s.createElement("div",{className:o.classNames(o.uDropDownsActionSheet.titleBar({c}))},s.createElement("div",{className:o.classNames(o.uDropDownsActionSheet.title({c}))},s.createElement("div",null,i)),s.createElement("div",{className:o.classNames(o.uDropDownsActionSheet.actions({c}))},s.createElement(rt.Button,{tabIndex:0,"aria-label":"Cancel","aria-disabled":"false",type:"button",fillMode:"flat",onClick:Ie,icon:"x",svgIcon:tt.xIcon}))),s.createElement("div",{className:o.classNames(o.uDropDownsActionSheet.titleBarGroup({c}))},Ae())),s.createElement(Fe.ActionSheetContent,{overflowHidden:!0},e&&s.createElement("div",{className:o.classNames(o.uDropDownList.listHeader({c:a}))},e),s.createElement("div",{className:o.classNames(o.uDropDownList.list({c:a,size:$,virtual:(w=t==null?void 0:t.current)==null?void 0:w.vs.enabled}))},ze(),!f&&h&&D.length!==0&&s.createElement(nt,{group:h,groupMode:"modern",render:m}),Ve()),n&&s.createElement("div",{className:o.classNames(o.uDropDownList.listFooter({c:a}))},n)))},wt=()=>{g.focused&&window.setTimeout(()=>{g.focused&&t.current.wrapper&&ne(t.current.wrapper)})},ht=e=>{var n;(n=r.popupSettings)!=null&&n.onMouseDownOutside&&r.popupSettings.onMouseDownOutside.call(void 0,e)},It=()=>{const{header:e,footer:n,dir:i,groupField:p,groupStickyHeaderItemRender:m,list:f}=r,D=u.getFilteredData(I),v=t.current,a=v.getPopupSettings(),c=r.opened!==void 0?r.opened:g.opened,d=a.width!==void 0?a.width:v.popupWidth,h=E&&E.uDropDownList,w={dir:i!==void 0?i:v.dirCalculated,width:d,popupSettings:{...a,popupClass:o.classNames(a.popupClass,o.uDropDownList.listContainer({c:h})),anchor:a.anchor||Q.current,show:c,onOpen:ye,onClose:wt,onMouseDownOutside:ht},itemsCount:[D.length]};let{group:S}=g;return S===void 0&&p!==void 0&&(S=u.getItemValue(D[0],p)),s.createElement(_t,{...w},Ae(),e&&s.createElement("div",{className:o.classNames(o.uDropDownList.listHeader({c:h}))},e),s.createElement("div",{className:o.classNames(o.uDropDownList.list({c:h,size:$,virtual:t.current.vs.enabled}))},ze(),!f&&S&&D.length!==0&&s.createElement(nt,{group:S,groupMode:"modern",render:m}),Ve()),n&&s.createElement("div",{className:o.classNames(o.uDropDownList.listFooter({c:h}))},n))},St=e=>{const{dataItemKey:n}=r,i=u.getFilteredData(I),p=N();let m=i.map((K,G)=>({item:K,itemIndex:G}));const f=_.current.word,D=_.current.last,v=u.sameCharsOnly(f,D);let a=m.length,c=Math.max(0,i.findIndex(K=>u.areSame(K,p,n))),d;r.defaultItem&&(d={item:r.defaultItem,itemIndex:-1},a+=1,c+=1),c+=v?1:0,m=u.shuffleData(m,c,d);let h,w,S,l=0;const{textField:P}=r;for(;l<a;){if(h=u.getItemValue(m[l].item,P),w=v&&u.matchText(h,D,me),S=u.matchText(h,f,me),w||S){l=m[l].itemIndex;break}l++}if(l!==a){const K=t.current.initState();K.syntheticEvent=e,J(l,K),b(K),O.current=void 0}},xt=e=>{clearTimeout(He.current),r.filterable||(He.current=window.setTimeout(()=>_.current.word="",st),St(e))},Ct=e=>{re.current||t.current.handleFocus(e)},Lt=e=>{if(re.current||!g.focused)return;const n=r.opened!==void 0?r.opened:g.opened,i=t.current.initState();i.syntheticEvent=e,i.data.focused=!1,i.events.push({type:"onBlur"}),n&&he(),n&&!Ke&&t.current.togglePopup(i),b(i)},kt=e=>{if(r.filterable||e.which===0||e.keyCode===o.Keys.enter)return;let n=String.fromCharCode(e.charCode||e.keyCode);me&&(n=n.toLowerCase()),n===" "&&e.preventDefault(),_.current={word:_.current.word+n,last:_.current.last+n},xt(e)},Et=()=>{const e=t.current.initState();e.data.opened=g.opened,t.current.togglePopup(e),b(e)},Be=s.useRef(null),Q=s.useRef(null),Se=s.useRef(),X=s.useRef(null);s.useImperativeHandle(Be,()=>({get element(){return Q.current},get index(){return dt()},get name(){return r.name},get validity(){return De()},get value(){return N()},get focused(){return g.focused},get opened(){return g.opened},focus:lt,props:r,togglePopup:Et})),s.useImperativeHandle(Y,()=>Be.current);const He=s.useRef(null),_=s.useRef({word:"",last:""}),re=s.useRef(!1),O=s.useRef(null),q=s.useRef(!1),xe=s.useRef(!1),A=s.useRef({}),Ce=s.useRef({}),t=s.useRef(new ot({props:I,setState:()=>{},state:{},forceUpdate:()=>{},element:null,value:null,handleItemSelect:()=>{}})),_e=s.useRef(0),Z=s.useRef(null),[g,Nt]=s.useState({}),[W,Kt]=s.useState(),[,We]=s.useReducer(e=>e,!0),bt=Yt.useLocalization(),R=e=>{Nt({...g,...e})};s.useEffect(()=>{t.current.updateComponentArgs({props:I,setState:R,state:g,forceUpdate:We,element:Q.current,handleItemSelect:J,value:N()})},[R,g,We,J,N]),s.useEffect(()=>{var c,d,h,w,S,l,P,K,G,te,le,de,C;const{dataItemKey:e,virtual:n,groupField:i="",textField:p}=r,m=u.getFilteredData(I),f=A.current.virtual?A.current.virtual.total:0,D=r.opened!==void 0?r.opened:g.opened,v=A.current.opened!==void 0?A.current.opened:Ce.current.opened,a=!v&&D;if((c=t==null?void 0:t.current)==null||c.didUpdate(),(d=t==null?void 0:t.current)!=null&&d.getPopupSettings().animate||a&&ye(),n&&n.total!==f)(h=t==null?void 0:t.current)==null||h.vs.calcScrollElementHeight(),(w=t==null?void 0:t.current)==null||w.vs.reset();else{const M=N(),ce=A.current.value!==void 0?A.current.value:Ce.current.value;let V=m.findIndex(j=>u.areSame(j,M,e));i!==""&&M&&p&&(V=(l=(S=t==null?void 0:t.current)==null?void 0:S.getGroupedDataModernMode(m,i))==null?void 0:l.map(j=>j[p]).indexOf(M[p]));const ue=!u.areSame(ce,M,e);a&&n?(P=t==null?void 0:t.current)==null||P.scrollToVirtualItem(n,V):a&&!n?(ye(),m&&m.length!==0&&((K=t==null?void 0:t.current)==null||K.resetGroupStickyHeader(m[0][i],{setState:R,group:g.group,state:g})),(G=t==null?void 0:t.current)==null||G.scrollToItem(V)):D&&v&&M&&ue&&!q.current?(le=t==null?void 0:t.current)==null||le.scrollToItem(V,(te=t==null?void 0:t.current)==null?void 0:te.vs.enabled):D&&v&&q.current&&(q.current&&n&&n.skip===0?(de=t==null?void 0:t.current)==null||de.vs.reset():q.current&&n&&n.skip===n.total-n.pageSize&&((C=t==null?void 0:t.current)==null||C.vs.scrollToEnd()))}q.current=!1,Ce.current=g,A.current=r,Te()}),s.useEffect(()=>{var e,n;return Z.current=o.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(ut.bind(void 0)),(e=t==null?void 0:t.current)==null||e.didMount(),Te(),(n=fe())!=null&&n.body&&Z.current&&Z.current.observe(fe().body),()=>{var i;(i=fe())!=null&&i.body&&Z.current&&Z.current.disconnect()}},[]);const Ue=B+"-accessibility-id",Le=B+"-listbox-id",Ge=B+"-guid",Pt=bt.toLanguageString(Pe.dropDownListArrowBtnAriaLabel,Pe.messages[Pe.dropDownListArrowBtnAriaLabel]),{style:oe,className:Ft,label:ke,dir:Mt,virtual:z,adaptive:Xt,dataItemKey:Tt,disabled:ae,loading:je,iconClassName:Ye,svgIcon:$e,valueRender:Je}=r,Ee=r.opened!==void 0?r.opened:g.opened,se=N(),Ne=u.getItemValue(se,r.textField),Qe=!ct()||De().valid,ie=t.current,Ot=ie.vs,ee=E&&E.uDropDownList;Ot.enabled=z!==void 0;const U=o.useAdaptiveModeContext(),Ke=!!(W&&U&&W<=U.medium&&I.adaptive);z!==void 0&&(ie.vs.skip=z.skip,ie.vs.total=z.total,ie.vs.pageSize=z.pageSize);const qt=u.getFilteredData(I),{focused:At}=g,zt=qt.findIndex(e=>u.areSame(e,se,Tt)),Xe=s.createElement("span",{id:Ue,className:o.classNames(o.uDropDownList.inputInner({c:ee}))},Ne&&s.createElement("span",{className:o.classNames(o.uDropDownList.inputText({c:ee}))},Ne)),Vt=Je!==void 0?Je.call(void 0,Xe,se):Xe,Ze=s.createElement(s.Fragment,null,s.createElement("span",{ref:pt,className:o.classNames(o.uDropDownList.wrapper({c:ee,size:$,rounded:Me,fillMode:ge,focused:At,disabled:ae,invalid:!Qe,loading:je,required:ve()}),Ft),style:ke?{...oe,width:void 0}:oe,dir:Mt,onMouseDown:Ee?e=>{e.target.nodeName!=="INPUT"&&(ne(t.current.wrapper),e.preventDefault())}:void 0,onFocus:Ct,onBlur:Lt,tabIndex:o.getTabIndex(it,ae),accessKey:r.accessKey,onKeyDown:qe,onKeyPress:kt,onClick:ae?void 0:Ie,role:"combobox","aria-required":ve(),"aria-disabled":ae||void 0,"aria-haspopup":"listbox","aria-expanded":Ee||!1,"aria-owns":Le,"aria-activedescendant":Ee?"option-"+Ge+"-"+(zt+(z?z.skip:0)):void 0,"aria-label":r.ariaLabel||r.label,"aria-labelledby":r.ariaLabelledBy,"aria-describedby":r.ariaDescribedBy||Ue,"aria-controls":Le,id:r.id,title:r.title},Vt,je&&s.createElement(o.IconWrap,{className:o.classNames(o.uDropDownList.loadingIcon({c:ee})),name:"loading"}),s.createElement(rt.Button,{tabIndex:-1,type:"button","aria-label":Pt,size:$,fillMode:ge,iconClass:Ye,className:o.classNames(o.uDropDownList.inputButton({c:ee})),rounded:null,themeColor:"base",icon:Ye?void 0:"caret-alt-down",svgIcon:$e||tt.caretAltDownIcon,onMouseDown:e=>g.focused&&e.preventDefault()}),mt(se),!Ke&&It()),Ke&&yt());return ke?s.createElement(Ht.FloatingLabel,{label:ke,editorValue:Ne,editorValid:Qe,editorDisabled:r.disabled,style:{width:oe?oe.width:void 0},children:Ze}):Ze});pe.propTypes={delay:k.number,ignoreCase:k.bool,iconClassName:k.string,svgIcon:o.svgIconPropType,defaultItem:k.any,valueRender:k.func,valueMap:k.func,validationMessage:k.string,required:k.bool,id:k.string,ariaLabelledBy:k.string,ariaDescribedBy:k.string,ariaLabel:k.string,leftRightKeysNavigation:k.bool,title:k.string,groupField:k.string,list:k.any,skipDisabledItems:k.bool};const F={delay:500,tabIndex:0,ignoreCase:!0,...ot.defaultProps,required:!1,size:"medium",rounded:"medium",fillMode:"solid",groupMode:"modern"};pe.displayName="KendoReactDropDownList";const at=o.createPropsContext();pe.displayName="KendoReactDropDownList";exports.DropDownList=pe;exports.DropDownListPropsContext=at;exports.dropDownListDefaultProps=F;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ht=require("react"),k=require("prop-types"),o=require("@progress/kendo-react-common"),Wt=require("@progress/kendo-react-labels"),nt=require("@progress/kendo-svg-icons"),_t=require("../common/ListContainer.js"),Ut=require("../common/ListFilter.js"),rt=require("../common/GroupStickyHeader.js"),Gt=require("../common/ListDefaultItem.js"),jt=require("../common/List.js"),at=require("../common/DropDownBase.js"),u=require("../common/utils.js"),Yt=require("../package-metadata.js"),ot=require("@progress/kendo-react-buttons"),$t=require("@progress/kendo-react-intl"),Fe=require("../messages/index.js"),Me=require("@progress/kendo-react-layout");function Jt(v){const Y=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(v){for(const T in v)if(T!=="default"){const N=Object.getOwnPropertyDescriptor(v,T);Object.defineProperty(Y,T,N.get?N:{enumerable:!0,get:()=>v[T]})}}return Y.default=v,Object.freeze(Y)}const s=Jt(Ht),Qt="Please select a value from the list!",pe=s.forwardRef((v,Y)=>{let T=!1;if(v.filterable||v.virtual){const e=[];v.filterable&&e.push("filterable"),v.virtual&&e.push("virtualization"),T=!o.validatePackage(Yt.packageMetadata,{component:"DropDownList",features:e})}const N=o.useUnstyled(),me=o.useId(v.id),r=o.usePropsContext(st,v),{delay:it=F.delay,tabIndex:lt=F.tabIndex,ignoreCase:fe=F.ignoreCase,size:$=F.size,rounded:Te=F.rounded,fillMode:ge=F.fillMode,groupMode:Xt=F.groupMode}=r,ve=()=>{var e;if(o.canUseDOM)return((e=Q.current)==null?void 0:e.ownerDocument)||window.document},ct=()=>{var e,n;(e=t==null?void 0:t.current)!=null&&e.wrapper&&((n=t==null?void 0:t.current)==null||n.wrapper.focus({preventScroll:!0}))},E=()=>{let e;return q.current!==void 0&&q.current!==null?e=q.current:r.value!==void 0?e=r.value:f.value!==void 0&&f.value!==null?e=f.value:r.defaultValue!==void 0&&r.defaultValue!==null&&(e=r.defaultValue),!u.isPresent(e)&&r.defaultItem!==void 0&&r.defaultItem!==null&&(e=r.defaultItem),e},dt=()=>{const{dataItemKey:e}=r,n=u.getFilteredData(v),i=E();return n.findIndex(p=>u.areSame(p,i,e))},De=()=>r.required!==void 0?r.required:F.required,ye=()=>{const e=r.validationMessage!==void 0,n=E(),i=!De()||n!==null&&n!==""&&n!==void 0,p=r.valid!==void 0?r.valid:i;return{customError:e,valid:p,valueMissing:n===null}},ut=()=>r.validityStyles!==void 0?r.validityStyles:F.validityStyles,ne=e=>{re.current=!0,e.focus(),window.setTimeout(()=>re.current=!1,30)},he=()=>{X.current&&ne(X.current),r.adaptive&&setTimeout(()=>{X.current&&ne(X.current)},300)},pt=s.useCallback(e=>{for(const n of e)Kt(n.target.clientWidth)},[]),Oe=()=>{var e;(e=xe.current)!=null&&e.setCustomValidity&&xe.current.setCustomValidity(ye().valid?"":r.validationMessage||Qt)},H=(e,n)=>{const i=E();u.areSame(i,e,r.dataItemKey)||(r.value===void 0&&(n.data.value=e),t.current.updateComponentArgs({value:e}),q.current=e,n.events.push({type:"onChange"}))},K=e=>{var n;(n=t==null?void 0:t.current)==null||n.applyState(e),q.current=void 0},J=(e,n)=>{var c;const{virtual:i,dataItemKey:p,defaultItem:m}=r,g=u.getFilteredData(v),y=i?i.skip:0,D=E(),a=e===-1&&m!==void 0?m:g[e-y],d=!u.areSame(a,D,p);H(a,n),d&&((c=t==null?void 0:t.current)==null||c.triggerPageChangeCornerItems(a,n))},O=(e,n,i)=>{var I,w;const{defaultItem:p,dataItemKey:m,virtual:g={skip:0,total:0,pageSize:0}}=r,y=E(),D=u.getFilteredData(v),a=(I=t==null?void 0:t.current)==null?void 0:I.vs,d=D.findIndex(S=>u.areSame(S,y,m)),c=(w=t==null?void 0:t.current)==null?void 0:w.navigation.navigate({current:g.skip+d,max:(a!=null&&a.enabled?g.total:D.length)-1,min:p!==void 0?-1:0,keyCode:n,skipItems:i||void 0});c!==void 0&&J(c,e),K(e)},mt=e=>{Q.current=e,t.current.wrapper=e},ft=e=>s.createElement("select",{name:r.name,ref:n=>{xe.current=n},tabIndex:-1,"aria-hidden":!0,title:r.label,style:{opacity:0,width:1,border:0,zIndex:-1,position:"absolute",left:"50%"}},s.createElement("option",{value:r.valueMap?r.valueMap.call(void 0,e):e})),we=()=>{const{textField:e,dataItemKey:n,virtual:i={skip:0},focusedItemIndex:p=u.itemIndexStartsWith,filterable:m,skipDisabledItems:g=!0}=r,y=E(),D=u.getFilteredData(v),a=r.filter?r.filter:f.text;return g&&e&&!a&&!y?D.findIndex(d=>!d.disabled&&d[e]):u.isPresent(y)&&a===void 0||m&&a===""?D.findIndex(d=>u.areSame(d,y,n)):a?Ce.current?p(D,a,e):D.findIndex(d=>u.areSame(d,y,n)):i.skip===0?0:-1},qe=(e,n)=>n!==void 0&&n!==-1&&e&&e.length>0&&e[n].disabled,Ie=()=>{const e=u.getFilteredData(v),n=t.current.initState(),i=we();qe(e,i)&&(H(null,n),K(n))},Se=e=>{if(e.isPropagationStopped())return;const n=t.current.initState();n.syntheticEvent=e,f.focused||(n.data.focused=!0),Ie(),t.current.togglePopup(n),K(n)},Ae=e=>{var M,de,B,ue,j,et,tt;e&&e.target instanceof Element&&e.target.nodeName==="INPUT"&&e.stopPropagation&&e.stopPropagation();const{filterable:n,disabled:i,defaultItem:p,leftRightKeysNavigation:m=!0,virtual:g={skip:0,total:0,pageSize:0},dataItemKey:y,groupField:D="",textField:a,skipDisabledItems:d=!0}=r,c=u.getFilteredData(v),I=E(),w=c.findIndex(L=>u.areSame(L,I,y)),S=r.opened!==void 0?r.opened:f.opened,l=e.keyCode,P=l===o.Keys.home||l===o.Keys.end,b=l===o.Keys.up||l===o.Keys.down,G=!S&&(e.altKey&&l===o.Keys.down||l===o.Keys.enter||l===o.Keys.space),te=S&&(e.altKey&&l===o.Keys.up||l===o.Keys.esc),le=m&&(l===o.Keys.left||l===o.Keys.right),ce=b||le&&!n||P,C=t.current.initState();if(C.syntheticEvent=e,!i){if(P&&((M=t==null?void 0:t.current)!=null&&M.vs.enabled))l===o.Keys.home?g.skip!==0?((de=t==null?void 0:t.current)==null||de.triggerOnPageChange(C,0,g.pageSize),A.current=!0):H(c[0],C):g.skip<g.total-g.pageSize?((B=t==null?void 0:t.current)==null||B.triggerOnPageChange(C,g.total-g.pageSize,g.pageSize),A.current=!0):H(c[c.length-1],C);else if(S&&l===o.Keys.pageUp)e.preventDefault(),(ue=t==null?void 0:t.current)==null||ue.scrollPopupByPageSize(-1);else if(S&&l===o.Keys.pageDown)e.preventDefault(),(j=t==null?void 0:t.current)==null||j.scrollPopupByPageSize(1);else if(S&&l===o.Keys.enter){const L=we();qe(c,L)?(H(null,C),K(C)):J(L,C),(et=t==null?void 0:t.current)==null||et.togglePopup(C),e.preventDefault()}else if(G||te)te&&Ie(),(tt=t==null?void 0:t.current)==null||tt.togglePopup(C),e.preventDefault();else if(ce){if(Ce.current=!1,D!==""&&a)if(!d&&S)O(C,l);else{let L;if(l===o.Keys.down||l===o.Keys.right){const x=c.slice(w+1).find(h=>!h.disabled&&h[a]);L=x&&c.findIndex(h=>h[a]===x[a])}else if(l===o.Keys.up||l===o.Keys.left){let x;if(w===0&&p)L=-1;else if(w===-1)x=c,L=c.findIndex(h=>!h.disabled&&h[a]);else{x=c.slice(0,w);let h=x.pop();for(;h&&h.disabled;)h=x.pop();L=h&&c.findIndex(Pe=>Pe[a]===h[a])}}if(L!==void 0){const x=L-w;O(C,l,x)}else L===void 0&&c.findIndex(x=>x[a]===I[a])===c.length-1&&O(C,l)}else if(!d&&S||P)O(C,l);else if(a){let L;if(l===o.Keys.down||l===o.Keys.right){const x=c.slice(w+1).find(h=>!h.disabled&&h[a]);L=x&&c.findIndex(h=>h[a]===x[a])}else if(l===o.Keys.up||l===o.Keys.left){let x;if(w===0&&p)L=-1;else if(w===-1)x=c,L=c.find(h=>!h.disabled&&h[a]);else{x=c.slice(0,w);let h=x.pop();for(;h&&h.disabled;)h=x.pop();L=h&&c.findIndex(Pe=>Pe[a]===h[a])}}if(L!==void 0){const x=L-w;O(C,l,x)}else L===void 0&&c.findIndex(x=>x[a]===I[a])===c.length-1&&O(C,l)}else O(C,l);e.preventDefault()}K(C)}},gt=e=>{const n=t.current.initState();n.syntheticEvent=e.syntheticEvent,r.filter===void 0&&(n.data.text=e.target.value),t.current.filterChanged(e.target.value,n),Ce.current=!0,K(n),R({group:void 0,text:String(e.target.value)})},ze=()=>{const e=r.filter!==void 0?r.filter:f.text;return r.filterable&&s.createElement(Ut,{value:e,ref:n=>X.current=n&&n.element,onChange:gt,onKeyDown:Ae,size:$,rounded:Te,fillMode:ge,renderListFilterWrapper:!0})},vt=e=>{var i;const n=t.current.initState();n.syntheticEvent=e,(i=t==null?void 0:t.current)==null||i.togglePopup(n),H(r.defaultItem,n),K(n)},Ve=()=>{const{textField:e,defaultItem:n,dataItemKey:i}=r,p=E();return n!==void 0&&s.createElement(Gt,{defaultItem:n,textField:e,selected:u.areSame(p,n,i),key:"defaultitemkey",onClick:vt})},Dt=(e,n)=>{var i;(i=t==null?void 0:t.current)==null||i.handleItemClick(e,n),q.current=void 0},yt=e=>{const{vs:n,list:i}=t.current;n.scrollHandler(e);const{groupField:p}=r;let m=u.getFilteredData(v);if(!(!p||!m.length)&&p){const g=_e.current=_e.current||(n.enabled?n.itemHeight:i?i.children[0].offsetHeight:0),D=e.target.scrollTop-n.skip*g;m=t.current.getGroupedDataModernMode(m,p);let a=m[0][p];for(let d=1;d<m.length&&!(g*d>D);d++)m[d]&&m[d][p]&&(a=m[d][p]);a!==f.group&&R({group:a})}},Be=()=>{var l;const{textField:e,dataItemKey:n,virtual:i={skip:0,total:void 0},groupHeaderItemRender:p,listNoDataRender:m,itemRender:g}=r,y=u.getFilteredData(v),D=N&&N.uDropDownList,a=t.current.vs,d=i.skip,c=r.opened!==void 0?r.opened:f.opened,I=t.current.getPopupSettings(),w=`translateY(${a.translate}px)`,S=E();return s.createElement(jt,{id:ke,show:c,data:y.slice(),focusedIndex:we(),value:S,textField:e,valueField:n,optionsGuid:je,groupField:r.groupField,groupMode:"modern",listRef:P=>a.list=t.current.list=P,wrapperStyle:{maxHeight:I.height},wrapperCssClass:o.classNames(o.uDropDownList.listContent({c:D})),listStyle:a.enabled?{transform:w}:void 0,key:"listkey",skip:d,onClick:Dt,itemRender:g,groupHeaderItemRender:p,noDataRender:m,onScroll:yt,wrapperRef:a.scrollerRef,scroller:(l=t==null?void 0:t.current)==null?void 0:l.renderScrollElement(),ariaSetSize:i.total})},ht=()=>{var w;const{header:e,footer:n,adaptiveTitle:i,groupField:p,groupStickyHeaderItemRender:m,list:g}=r,y=u.getFilteredData(v),D=r.opened!==void 0?r.opened:f.opened,a=N&&N.uDropDownList,d=N&&N.uDropDownsActionSheet,c={navigatable:!1,navigatableElements:[],expand:D,animation:!0,onClose:S=>Se(S),className:o.classNames(o.uDropDownsActionSheet.wrapper({c:d}),"k-adaptive-actionsheet"),animationStyles:_&&U&&_<=U.small?{top:0,width:"100%",height:"100%"}:void 0,position:_&&U&&_<=U.small?"fullscreen":void 0};let{group:I}=f;return I===void 0&&p!==void 0&&(I=u.getItemValue(y[0],p)),s.createElement(Me.ActionSheet,{...c},s.createElement(Me.ActionSheetHeader,{className:o.classNames(o.uDropDownsActionSheet.header({c:d}))},s.createElement("div",{className:o.classNames(o.uDropDownsActionSheet.titleBar({c:d}))},s.createElement("div",{className:o.classNames(o.uDropDownsActionSheet.title({c:d}))},s.createElement("div",null,i)),s.createElement("div",{className:o.classNames(o.uDropDownsActionSheet.actions({c:d}))},s.createElement(ot.Button,{tabIndex:0,"aria-label":"Cancel","aria-disabled":"false",type:"button",fillMode:"flat",onClick:Se,icon:"x",svgIcon:nt.xIcon}))),s.createElement("div",{className:o.classNames(o.uDropDownsActionSheet.titleBarGroup({c:d}))},ze())),s.createElement(Me.ActionSheetContent,{overflowHidden:!0},e&&s.createElement("div",{className:o.classNames(o.uDropDownList.listHeader({c:a}))},e),s.createElement("div",{className:o.classNames(o.uDropDownList.list({c:a,size:$,virtual:(w=t==null?void 0:t.current)==null?void 0:w.vs.enabled}))},Ve(),!g&&I&&y.length!==0&&s.createElement(rt,{group:I,groupMode:"modern",render:m}),Be()),n&&s.createElement("div",{className:o.classNames(o.uDropDownList.listFooter({c:a}))},n)))},wt=()=>{f.focused&&window.setTimeout(()=>{f.focused&&t.current.wrapper&&ne(t.current.wrapper)})},It=e=>{var n;(n=r.popupSettings)!=null&&n.onMouseDownOutside&&r.popupSettings.onMouseDownOutside.call(void 0,e)},St=()=>{const{header:e,footer:n,dir:i,groupField:p,groupStickyHeaderItemRender:m,list:g}=r,y=u.getFilteredData(v),D=t.current,a=D.getPopupSettings(),d=r.opened!==void 0?r.opened:f.opened,c=a.width!==void 0?a.width:D.popupWidth,I=N&&N.uDropDownList,w={dir:i!==void 0?i:D.dirCalculated,width:c,popupSettings:{...a,popupClass:o.classNames(a.popupClass,o.uDropDownList.listContainer({c:I})),anchor:a.anchor||Q.current,show:d,onOpen:he,onClose:wt,onMouseDownOutside:It},itemsCount:[y.length]};let{group:S}=f;return S===void 0&&p!==void 0&&(S=u.getItemValue(y[0],p)),s.createElement(_t,{...w},ze(),e&&s.createElement("div",{className:o.classNames(o.uDropDownList.listHeader({c:I}))},e),s.createElement("div",{className:o.classNames(o.uDropDownList.list({c:I,size:$,virtual:t.current.vs.enabled}))},Ve(),!g&&S&&y.length!==0&&s.createElement(rt,{group:S,groupMode:"modern",render:m}),Be()),n&&s.createElement("div",{className:o.classNames(o.uDropDownList.listFooter({c:I}))},n),T&&s.createElement(o.WatermarkOverlay,null))},xt=e=>{const{dataItemKey:n}=r,i=u.getFilteredData(v),p=E();let m=i.map((b,G)=>({item:b,itemIndex:G}));const g=W.current.word,y=W.current.last,D=u.sameCharsOnly(g,y);let a=m.length,d=Math.max(0,i.findIndex(b=>u.areSame(b,p,n))),c;r.defaultItem&&(c={item:r.defaultItem,itemIndex:-1},a+=1,d+=1),d+=D?1:0,m=u.shuffleData(m,d,c);let I,w,S,l=0;const{textField:P}=r;for(;l<a;){if(I=u.getItemValue(m[l].item,P),w=D&&u.matchText(I,y,fe),S=u.matchText(I,g,fe),w||S){l=m[l].itemIndex;break}l++}if(l!==a){const b=t.current.initState();b.syntheticEvent=e,J(l,b),K(b),q.current=void 0}},Ct=e=>{clearTimeout(We.current),r.filterable||(We.current=window.setTimeout(()=>W.current.word="",it),xt(e))},Lt=e=>{re.current||t.current.handleFocus(e)},kt=e=>{if(re.current||!f.focused)return;const n=r.opened!==void 0?r.opened:f.opened,i=t.current.initState();i.syntheticEvent=e,i.data.focused=!1,i.events.push({type:"onBlur"}),n&&Ie(),n&&!Ke&&t.current.togglePopup(i),K(i)},Et=e=>{if(r.filterable||e.which===0||e.keyCode===o.Keys.enter)return;let n=String.fromCharCode(e.charCode||e.keyCode);fe&&(n=n.toLowerCase()),n===" "&&e.preventDefault(),W.current={word:W.current.word+n,last:W.current.last+n},Ct(e)},Nt=()=>{const e=t.current.initState();e.data.opened=f.opened,t.current.togglePopup(e),K(e)},He=s.useRef(null),Q=s.useRef(null),xe=s.useRef(),X=s.useRef(null);s.useImperativeHandle(He,()=>({get element(){return Q.current},get index(){return dt()},get name(){return r.name},get validity(){return ye()},get value(){return E()},get focused(){return f.focused},get opened(){return f.opened},focus:ct,props:r,togglePopup:Nt})),s.useImperativeHandle(Y,()=>He.current);const We=s.useRef(null),W=s.useRef({word:"",last:""}),re=s.useRef(!1),q=s.useRef(null),A=s.useRef(!1),Ce=s.useRef(!1),z=s.useRef({}),Le=s.useRef({}),t=s.useRef(new at({props:v,setState:()=>{},state:{},forceUpdate:()=>{},element:null,value:null,handleItemSelect:()=>{}})),_e=s.useRef(0),Z=s.useRef(null),[f,bt]=s.useState({}),[_,Kt]=s.useState(),[,Ue]=s.useReducer(e=>e,!0),Pt=$t.useLocalization(),R=e=>{bt({...f,...e})};s.useEffect(()=>{t.current.updateComponentArgs({props:v,setState:R,state:f,forceUpdate:Ue,element:Q.current,handleItemSelect:J,value:E()})},[R,f,Ue,J,E]),s.useEffect(()=>{var d,c,I,w,S,l,P,b,G,te,le,ce,C;const{dataItemKey:e,virtual:n,groupField:i="",textField:p}=r,m=u.getFilteredData(v),g=z.current.virtual?z.current.virtual.total:0,y=r.opened!==void 0?r.opened:f.opened,D=z.current.opened!==void 0?z.current.opened:Le.current.opened,a=!D&&y;if((d=t==null?void 0:t.current)==null||d.didUpdate(),(c=t==null?void 0:t.current)!=null&&c.getPopupSettings().animate||a&&he(),n&&n.total!==g)(I=t==null?void 0:t.current)==null||I.vs.calcScrollElementHeight(),(w=t==null?void 0:t.current)==null||w.vs.reset();else{const M=E(),de=z.current.value!==void 0?z.current.value:Le.current.value;let B=m.findIndex(j=>u.areSame(j,M,e));i!==""&&M&&p&&(B=(l=(S=t==null?void 0:t.current)==null?void 0:S.getGroupedDataModernMode(m,i))==null?void 0:l.map(j=>j[p]).indexOf(M[p]));const ue=!u.areSame(de,M,e);a&&n?(P=t==null?void 0:t.current)==null||P.scrollToVirtualItem(n,B):a&&!n?(he(),m&&m.length!==0&&((b=t==null?void 0:t.current)==null||b.resetGroupStickyHeader(m[0][i],{setState:R,group:f.group,state:f})),(G=t==null?void 0:t.current)==null||G.scrollToItem(B)):y&&D&&M&&ue&&!A.current?(le=t==null?void 0:t.current)==null||le.scrollToItem(B,(te=t==null?void 0:t.current)==null?void 0:te.vs.enabled):y&&D&&A.current&&(A.current&&n&&n.skip===0?(ce=t==null?void 0:t.current)==null||ce.vs.reset():A.current&&n&&n.skip===n.total-n.pageSize&&((C=t==null?void 0:t.current)==null||C.vs.scrollToEnd()))}A.current=!1,Le.current=f,z.current=r,Oe()}),s.useEffect(()=>{var e,n;return Z.current=o.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(pt.bind(void 0)),(e=t==null?void 0:t.current)==null||e.didMount(),Oe(),(n=ve())!=null&&n.body&&Z.current&&Z.current.observe(ve().body),()=>{var i;(i=ve())!=null&&i.body&&Z.current&&Z.current.disconnect()}},[]);const Ge=me+"-accessibility-id",ke=me+"-listbox-id",je=me+"-guid",Ft=Pt.toLanguageString(Fe.dropDownListArrowBtnAriaLabel,Fe.messages[Fe.dropDownListArrowBtnAriaLabel]),{style:oe,className:Mt,label:Ee,dir:Tt,virtual:V,adaptive:Zt,dataItemKey:Ot,disabled:ae,loading:Ye,iconClassName:$e,svgIcon:Je,valueRender:Qe}=r,Ne=r.opened!==void 0?r.opened:f.opened,se=E(),be=u.getItemValue(se,r.textField),Xe=!ut()||ye().valid,ie=t.current,qt=ie.vs,ee=N&&N.uDropDownList;qt.enabled=V!==void 0;const U=o.useAdaptiveModeContext(),Ke=!!(_&&U&&_<=U.medium&&v.adaptive);V!==void 0&&(ie.vs.skip=V.skip,ie.vs.total=V.total,ie.vs.pageSize=V.pageSize);const At=u.getFilteredData(v),{focused:zt}=f,Vt=At.findIndex(e=>u.areSame(e,se,Ot)),Ze=s.createElement("span",{id:Ge,className:o.classNames(o.uDropDownList.inputInner({c:ee}))},be&&s.createElement("span",{className:o.classNames(o.uDropDownList.inputText({c:ee}))},be)),Bt=Qe!==void 0?Qe.call(void 0,Ze,se):Ze,Re=s.createElement(s.Fragment,null,s.createElement("span",{ref:mt,className:o.classNames(o.uDropDownList.wrapper({c:ee,size:$,rounded:Te,fillMode:ge,focused:zt,disabled:ae,invalid:!Xe,loading:Ye,required:De()}),Mt),style:Ee?{...oe,width:void 0}:oe,dir:Tt,onMouseDown:Ne?e=>{e.target.nodeName!=="INPUT"&&(ne(t.current.wrapper),e.preventDefault())}:void 0,onFocus:Lt,onBlur:kt,tabIndex:o.getTabIndex(lt,ae),accessKey:r.accessKey,onKeyDown:Ae,onKeyPress:Et,onClick:ae?void 0:Se,role:"combobox","aria-required":De(),"aria-disabled":ae||void 0,"aria-haspopup":"listbox","aria-expanded":Ne||!1,"aria-owns":ke,"aria-activedescendant":Ne?"option-"+je+"-"+(Vt+(V?V.skip:0)):void 0,"aria-label":r.ariaLabel||r.label,"aria-labelledby":r.ariaLabelledBy,"aria-describedby":r.ariaDescribedBy||Ge,"aria-controls":ke,id:r.id,title:r.title},Bt,Ye&&s.createElement(o.IconWrap,{className:o.classNames(o.uDropDownList.loadingIcon({c:ee})),name:"loading"}),s.createElement(ot.Button,{tabIndex:-1,type:"button","aria-label":Ft,size:$,fillMode:ge,iconClass:$e,className:o.classNames(o.uDropDownList.inputButton({c:ee})),rounded:null,themeColor:"base",icon:$e?void 0:"caret-alt-down",svgIcon:Je||nt.caretAltDownIcon,onMouseDown:e=>f.focused&&e.preventDefault()}),ft(se),!Ke&&St()),Ke&&ht());return Ee?s.createElement(Wt.FloatingLabel,{label:Ee,editorValue:be,editorValid:Xe,editorDisabled:r.disabled,style:{width:oe?oe.width:void 0},children:Re}):Re});pe.propTypes={delay:k.number,ignoreCase:k.bool,iconClassName:k.string,svgIcon:o.svgIconPropType,defaultItem:k.any,valueRender:k.func,valueMap:k.func,validationMessage:k.string,required:k.bool,id:k.string,ariaLabelledBy:k.string,ariaDescribedBy:k.string,ariaLabel:k.string,leftRightKeysNavigation:k.bool,title:k.string,groupField:k.string,list:k.any,skipDisabledItems:k.bool};const F={delay:500,tabIndex:0,ignoreCase:!0,...at.defaultProps,required:!1,size:"medium",rounded:"medium",fillMode:"solid",groupMode:"modern"};pe.displayName="KendoReactDropDownList";const st=o.createPropsContext();pe.displayName="KendoReactDropDownList";exports.DropDownList=pe;exports.DropDownListPropsContext=st;exports.dropDownListDefaultProps=F;
|