@progress/kendo-react-dropdowns 7.4.0-develop.5 → 7.4.0-develop.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ComboBox/ComboBox.js +1 -1
- package/ComboBox/ComboBox.mjs +103 -101
- package/dist/cdn/js/kendo-react-dropdowns.js +1 -1
- package/index.d.mts +1 -0
- package/index.d.ts +1 -0
- package/package-metadata.mjs +1 -1
- package/package.json +9 -9
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 client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("react"),I=require("prop-types"),F=require("../common/DropDownBase.js"),g=require("@progress/kendo-react-common"),ee=require("@progress/kendo-react-labels"),u=require("../common/utils.js"),te=require("../common/SearchBar.js"),se=require("../common/ListContainer.js"),ie=require("../common/List.js"),ae=require("../common/ListFilter.js"),R=require("../common/GroupStickyHeader.js"),oe=require("../package-metadata.js"),ne=require("../common/ClearButton.js"),q=require("@progress/kendo-react-buttons"),A=require("@progress/kendo-svg-icons"),C=require("../messages/index.js"),z=require("@progress/kendo-react-intl"),P=require("@progress/kendo-react-layout"),E=require("../common/constants.js"),H=require("../common/withCustomComponent.js");function le(D){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(D){for(const e in D)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(D,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>D[e]})}}return s.default=D,Object.freeze(s)}const h=le(Z),re="Please enter a valid value!",{sizeMap:M,roundedMap:de}=g.kendoThemeMaps,S=class S extends h.Component{constructor(s){super(s),this.state={},this.base=new F(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=u.getPlainDataDuplicates(o),this.hasDuplicates=this.duplicates.length>0}},this.handleItemSelect=(e,t)=>{const{data:o=[],virtual:a,dataItemKey:n}=this.props,d=a?a.skip:0,l=o[e-d],r=this.hasDuplicates||!u.areSame(l,this.value,n);this.triggerOnChange(l,t),this.state.text!==void 0&&(t.data.text=void 0),r&&this.base.triggerPageChangeCornerItems(l,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{data:t=[],skipDisabledItems:o,textField:a}=this.props,n=this.getFocusedIndex(),d=this.getCurrentValueDisabledStatus(a,t,n),l=this.props.opened!==void 0?this.props.opened:this.state.opened,r=this.base.initState();if(r.syntheticEvent=e,!o&&a&&d&&this.clearValueOnToggleBtnClick(e),this.base.togglePopup(r),!l&&this.mobileMode){const i=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text||null;this.base.filterChanged(i,r)}this.applyState(r)},this.renderMobileListFilter=()=>{const e=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text,t=u.getItemValue(this.value,this.props.textField),o=u.isPresent(e)?e:t;return h.createElement(ae,{value:o,ref:a=>this._adaptiveFilterInput=a&&a.element,onChange:this.handleMobileFilterChange,onKeyDown:this.onInputKeyDown,size:this.props.size,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:a}=this.props;let{data:n=[]}=this.props;if(!a||!n.length)return;const d=this.itemHeight=this.itemHeight||(t.enabled?t.itemHeight:o?o.children[0].offsetHeight:0),r=e.target.scrollTop-t.skip*d;this.props.groupMode==="modern"&&(n=this.base.getGroupedDataModernMode(n,a));let i=n[0][a];for(let c=1;c<n.length&&!(d*c>r);c++)n[c]&&n[c][a]&&(i=n[c][a]);i!==this.state.group&&(this.setState({group:i}),this.props.onGroupScroll&&this.props.onGroupScroll.call(void 0,{group:i}))},this.handleItemClick=(e,t)=>{this.navigationIndex=e,this.base.handleItemClick(e,t),this._valueDuringOnChange=void 0},this.handleBlur=e=>{if(this.state.focused&&!this._skipBlur){const t=this.base.initState(),{textField:o,data:a=[]}=this.props,n=this.getFocusedIndex(),l=!(n===-1)&&this.getCurrentValueDisabledStatus(o,a,n);t.data.focused=!1,t.events.push({type:"onBlur"}),t.syntheticEvent=e,o&&l&&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 a=this.base.initState();a.syntheticEvent=e,this.base.togglePopup(a),this.base.filterChanged(o,a),this.applyState(a)}},this.onInputKeyDown=e=>{const{data:t=[],skipDisabledItems:o,textField:a,dataItemKey:n,groupField:d}=this.props,l=this.value,r=Math.max(0,t.findIndex(v=>u.areSame(v,l,n))),i=e.keyCode,c=this.props.opened!==void 0?this.props.opened:this.state.opened,p=this.base.initState();if(p.syntheticEvent=e,!e.altKey&&(i===g.Keys.up||i===g.Keys.down)){if(e.preventDefault(),d!==""&&a)if(!this.props.skipDisabledItems&&c)this.onNavigate(p,i);else{let v=0;if(i===g.Keys.down||i===g.Keys.right){const f=t.slice(r+1<t.length?r+1:r).find(x=>!x.disabled&&x[a]);v=f&&t.findIndex(x=>x[a]===f[a])}else if(i===g.Keys.up||i===g.Keys.left){let f;if(r===0)f=t,v=t.findIndex(x=>!x.disabled&&x[a]);else{f=t.slice(0,r);let x=f.pop();for(;x&&x.disabled;)x=f.pop();v=x&&t.findIndex(O=>O[a]===x[a])}}if(v!==void 0){const f=v-r;this.onNavigate(p,i,f)}else v===void 0&&t.findIndex(f=>f[a]===l[a])===t.length-1&&this.onNavigate(p,i)}else if(!this.props.skipDisabledItems&&c)this.onNavigate(p,i);else{let v=null;if(i===g.Keys.down||i===g.Keys.right)v=t.slice(r+1).find(f=>!f.disabled);else if(i===g.Keys.up||i===g.Keys.left){const f=t.slice(0,r);for(v=f.pop();v&&v.disabled;)v=f.pop()}if(v){const f=v.id-r-1;this.onNavigate(p,i,f)}else this.onNavigate(p,i)}this.applyState(p)}const m=()=>{e.preventDefault(),this.base.togglePopup(p),this.applyState(p)},y=this.getFocusedIndex(),b=y===-1,k=!b&&this.getCurrentValueDisabledStatus(a,t,y);c?i===g.Keys.pageUp?this.base.scrollPopupByPageSize(-1):i===g.Keys.pageDown?this.base.scrollPopupByPageSize(1):e.altKey&&i===g.Keys.up?m():i===g.Keys.enter?(e.preventDefault(),(a&&!b&&e.currentTarget.value?t[y][a]:void 0)?!o&&a&&k?this.clearValueOnEnterOrEsc(e):k||this.applyValueOnEnter(e.currentTarget.value,p):this.applyValueOnEnter(e.currentTarget.value,p)):i===g.Keys.esc&&(!o&&a&&k&&this.clearValueOnEnterOrEsc(e),this.applyValueOnRejectSuggestions(e.currentTarget.value,p)):!c&&i===g.Keys.esc?this.clearValueOnEnterOrEsc(e):e.altKey&&i===g.Keys.down&&m()},this.inputOnChange=e=>{const t=this.base.initState();t.syntheticEvent=e;const o=this.props.opened!==void 0?this.props.opened:this.state.opened,a=e.currentTarget,n=a.value;if(this.props.suggest){const d=a.selectionEnd===n.length;let l=this.props.filter!==void 0?this.props.filter:this.state.text;u.isPresent(l)||(l=u.getItemValue(this.value,this.props.textField)||"");const r=l&&l===n,i=l&&l.length>n.length;r||i||!d?this._suggested="":this.suggestValue(n)}this.props.filter===void 0&&(t.data.text=n),this.state.focusedItem!==void 0&&(t.data.focusedItem=void 0),o||this.base.togglePopup(t),this.base.filterChanged(n,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||re)},g.validatePackage(oe.packageMetadata)}get _inputId(){return this.props.id}get document(){if(g.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get mobileMode(){return!!(this.state.windowWidth&&this.state.windowWidth<=E.MOBILE_MEDIUM_DEVISE&&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{data:s=[],dataItemKey:e}=this.props,t=this.value;return s.findIndex(o=>u.areSame(o,t,e))}get name(){return this.props.name}get validity(){const s=this.props.validationMessage!==void 0,e=!this.required||this.value!==null&&this.value!==""&&this.value!==void 0,t=this.props.valid!==void 0?this.props.valid:e;return{customError:s,valid:t,valueMissing:this.value===null}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:S.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:S.defaultProps.required}componentDidUpdate(s,e){var m;const{dataItemKey:t,virtual:o,groupField:a="",data:n=[],textField:d}=this.props,l=s.virtual?s.virtual.total:0,r=this.props.opened!==void 0?this.props.opened:this.state.opened,i=s.opened!==void 0?s.opened:e.opened;s.data!==n&&this.checkForDuplicatePlainTextRecords();const c=!i&&r,p=this.value;if(this._valueOnDidUpdate=p,o&&o.total!==l)this.base.vs.calcScrollElementHeight(),this.base.vs.reset();else{const y=s.value!==void 0?s.value:e.value;let b=this.hasDuplicates?this.navigationIndex||0:n.findIndex(v=>u.areSame(v,p,t));this.props.groupMode==="modern"&&d&&p&&(b=(m=this.base.getGroupedDataModernMode(n,a))==null?void 0:m.map(v=>v[d]).indexOf(p[d]));const k=!u.areSame(y,p,t);c&&o?this.base.scrollToVirtualItem(o,b):c&&!o?(this.onPopupOpened(),n&&n.length!==0&&this.base.resetGroupStickyHeader(n[0][a],this),this.base.scrollToItem(b)):(this.hasDuplicates||r&&i&&p&&k)&&this.base.scrollToItem(b)}c&&this._input&&this._input.focus(),this.setValidity()}componentDidMount(){var s;this.observerResize=g.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=z.provideLocalizationService(this).toLanguageString(C.comboArrowBtnAriaLabelExpand,C.messages[C.comboArrowBtnAriaLabelExpand]),e=z.provideLocalizationService(this).toLanguageString(C.comboArrowBtnAriaLabelCollapse,C.messages[C.comboArrowBtnAriaLabelCollapse]),{dir:t,disabled:o,clearButton:a=S.defaultProps.clearButton,label:n,textField:d,adaptive:l,className:r,style:i,loading:c,iconClassName:p,virtual:m,size:y,rounded:b,fillMode:k,opened:v=this.state.opened,placeholder:f,svgIcon:x}=this.props,{windowWidth:O=0}=this.state,_=!this.validityStyles||this.validity.valid,T=this.props.filter!==void 0?this.props.filter:this.state.text,$=u.getItemValue(this.value,d),B=u.isPresent(T)?T:$,j=a&&(!!B||u.isPresent(this.value)),w=this.base.vs,L=this.props.id||this._inputId,N=O<=E.MOBILE_MEDIUM_DEVISE&&l;w.enabled=m!==void 0,m!==void 0&&(w.skip=m.skip,w.total=m.total,w.pageSize=m.pageSize);const[G,Y]=H(this.props.prefix||h.Fragment),[J,Q]=H(this.props.suffix||h.Fragment),K=h.createElement(h.Fragment,null,h.createElement("span",{className:g.classNames("k-combobox k-input",{[`k-input-${M[y]||y}`]:y,[`k-rounded-${de[b]||b}`]:b,[`k-input-${k}`]:k,"k-invalid":!_,"k-loading":c,"k-required":this.required,"k-disabled":o},r),ref:this.componentRef,style:n?{...i,width:void 0}:i,dir:t},this.props.prefix&&h.createElement(G,{...Y}),this.renderSearchBar(B||"",L,f),j&&!c&&h.createElement(ne,{onClick:this.clearButtonClick,key:"clearbutton"}),c&&h.createElement(g.IconWrap,{className:"k-input-loading-icon",name:"loading",key:"loading"}),this.props.suffix&&h.createElement(J,{...Q}),h.createElement(q.Button,{tabIndex:-1,type:"button","aria-label":v?e:s,icon:p?void 0:"caret-alt-down",svgIcon:x||A.caretAltDownIcon,iconClass:p,size:y,fillMode:k,rounded:null,themeColor:"base",className:"k-input-button",onClick:this.toggleBtnClick,onMouseDown:X=>X.preventDefault()}),!N&&this.renderListContainer()),N&&this.renderAdaptiveListContainer());return n?h.createElement(ee.FloatingLabel,{label:n,editorId:L,editorValue:B,editorValid:_,editorDisabled:o,style:{width:i?i.width:void 0},children:K}):K}onNavigate(s,e,t){const{data:o=[],virtual:a={skip:0}}=this.props,n=this.props.filter?this.props.filter:this.state.text;let d=-1,l;const r=this.base.vs,i=this.value;this._suggested="";const c=this.hasDuplicates&&this.duplicates.indexOf(i)!==-1;if(d=this.getFocusedIndex(c),d!==-1&&!u.isPresent(i))this.handleItemSelect(d,s);else if(n==="")this.handleItemSelect(0,s);else{const p=a.skip+d;l=this.base.navigation.navigate({keyCode:e,current:p,max:(r.enabled?r.total:o.length)-1,min:0,skipItems:t||void 0}),l!==void 0&&this.handleItemSelect(l,s)}this.navigationIndex=l}getCurrentValueDisabledStatus(s,e,t){return s&&e&&e[t]&&e[t].disabled}applyValueOnEnter(s,e){const{data:t=[],textField:o,allowCustom:a}=this.props,n=this.props.opened!==void 0?this.props.opened:this.state.opened,l=u.getItemValue(this.value,o)===s?this.index:u.getItemIndexByText(t,s,o),r=l!==-1;let i;if(this._suggested="",r)i=t[l];else if(a)i=o!==void 0?{[o]:s}:s;else return this.selectFocusedItem(s,e);this.triggerOnChange(i,e),n&&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{data:t=[],textField:o,allowCustom:a}=this.props,n=this.props.opened!==void 0?this.props.opened:this.state.opened,d=u.getItemValue(this.value,o),l=this.state.windowWidth&&this.state.windowWidth<=E.MOBILE_MEDIUM_DEVISE;if(this._suggested="",s===d||s===""&&!u.isPresent(d))return n&&!l&&this.base.togglePopup(e),this.applyState(e);const r=u.getItemIndexByText(t,s,o,!0),i=r!==-1;let c=null;i?c=t[r]:a&&(c=s?o?{[o]:s}:s:null),this.triggerOnChange(c,e),this.state.text!==void 0&&(e.data.text=void 0,this.base.filterChanged("",e)),n&&!l&&this.base.togglePopup(e),this.applyState(e)}selectFocusedItem(s,e){const t=this.props.opened!==void 0?this.props.opened:this.state.opened,{data:o=[],textField:a,virtual:n={skip:0},focusedItemIndex:d=u.itemIndexStartsWith}=this.props,l=n.skip,r=s===""&&l===0?0:d(o,s,a);return r!==-1?this.handleItemSelect(r+l,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,data:a=[],groupField:n,groupMode:d,list:l,virtual:r,adaptiveTitle:i,groupStickyHeaderItemRender:c}=this.props,p=this.props.opened!==void 0?this.props.opened:this.state.opened;let{group:m}=this.state;m===void 0&&n!==void 0&&(m=u.getItemValue(a[0],n));const y={navigatable:!1,navigatableElements:[],expand:p,animation:!0,onClose:b=>this.toggleBtnClick(b),animationStyles:s<=E.MOBILE_SMALL_DEVISE?{top:0,width:"100%",height:"100%"}:void 0,className:s<=E.MOBILE_SMALL_DEVISE?"k-adaptive-actionsheet k-actionsheet-fullscreen":"k-adaptive-actionsheet k-actionsheet-bottom"};return h.createElement(P.ActionSheet,{...y},h.createElement(P.ActionSheetHeader,{className:"k-text-center"},h.createElement("div",{className:"k-actionsheet-titlebar-group k-hbox"},h.createElement("div",{className:"k-actionsheet-title"},h.createElement("div",null,i)),h.createElement("div",{className:"k-actionsheet-actions"},h.createElement(q.Button,{tabIndex:0,"aria-label":"Cancel","aria-disabled":"false",type:"button",fillMode:"flat",onClick:this.toggleBtnClick,icon:"x",svgIcon:A.xIcon}))),h.createElement("div",{className:"k-actionsheet-titlebar-group k-actionsheet-filter"},this.renderMobileListFilter())),h.createElement(P.ActionSheetContent,{className:"!k-overflow-hidden"},h.createElement("div",{className:"k-list-container"},h.createElement("div",{className:g.classNames({"k-list":!l,"k-list-lg":!0,"k-virtual-list":r,"k-data-table":l,[`k-table-${M[o]||o}`]:l&&o})},e&&h.createElement("div",{className:"k-table-header"},e),!l&&m&&a.length!==0&&h.createElement(R,{group:m,groupMode:d,render:c}),this.renderList(),t&&h.createElement("div",{className:"k-list-footer"},t)))))}renderListContainer(){const s=this.base,{dir:e,header:t,footer:o,data:a=[],groupField:n,groupMode:d,size:l,list:r,virtual:i,groupStickyHeaderItemRender:c}=this.props,p=this.props.opened!==void 0?this.props.opened:this.state.opened,m=s.getPopupSettings(),y=m.width!==void 0?m.width:s.popupWidth;let{group:b}=this.state;return b===void 0&&n!==void 0&&(b=u.getItemValue(a[0],n)),h.createElement(se,{width:y,popupSettings:{...m,anchor:m.anchor||this.element,show:p,popupClass:g.classNames(m.popupClass,"k-list-container","k-combobox-popup")},dir:e!==void 0?e:this.base.dirCalculated,itemsCount:[a.length]},h.createElement("div",{className:g.classNames({"k-list":!r,[`k-list-${M[l]||l}`]:!r&&l,"k-virtual-list":i,"k-data-table":r,[`k-table-${M[l]||l}`]:r&&l})},t&&h.createElement("div",{className:"k-table-header"},t),!r&&b&&a.length!==0&&h.createElement(R,{group:b,groupMode:d,render:c}),this.renderList(),o&&h.createElement("div",{className:g.classNames({"k-list-footer":!this.props.footerClassName},this.props.footerClassName)},o)))}renderList(){const s=this.base,{textField:e,dataItemKey:t,listNoDataRender:o,itemRender:a,groupHeaderItemRender:n,data:d=[],virtual:l={skip:0,total:void 0}}=this.props,r=s.getPopupSettings(),i=s.vs,c=l.skip,p=this.props.opened!==void 0?this.props.opened:this.state.opened,m=`translateY(${i.translate}px)`,y=p?this.getFocusedIndex(this.hasDuplicates):void 0,b=this.props.filter!==void 0?this.props.filter:this.state.text,k=u.getItemValue(this.value,e),v=u.isPresent(b)&&b!==k?null:this.value,f=this.props.list||ie;return h.createElement(f,{id:s.listBoxId,virtual:!!l,show:p,data:d,focusedIndex:y,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:x=>{i.list=this.base.list=x,this.itemHeight=0},wrapperStyle:this.state.windowWidth&&this.state.windowWidth>E.MOBILE_MEDIUM_DEVISE?{maxHeight:r.height}:{},wrapperCssClass:g.classNames("k-list-content",{"k-list-scroller":!l}),listStyle:i.enabled?{transform:m}:void 0,key:"listkey",skip:c,onClick:this.handleItemClick,itemRender:a,groupHeaderItemRender:n,noDataRender:o,onMouseDown:x=>x.preventDefault(),onScroll:this.onScroll,wrapperRef:i.scrollerRef,scroller:this.base.renderScrollElement(),ariaSetSize:l.total})}renderSearchBar(s,e,t){const{tabIndex:o,disabled:a,data:n=[],dataItemKey:d,virtual:l={skip:0}}=this.props,r=this.props.opened!==void 0?this.props.opened:this.state.opened,i=this.value,c=Math.max(0,n.findIndex(p=>u.areSame(p,i,d)));return this._suggested&&!u.areSame(this._valueOnDidUpdate,i,d)&&(this._suggested=""),h.createElement(te,{id:e,readOnly:r&&this.mobileMode,placeholder:t,tabIndex:o,title:this.props.title,accessKey:this.props.accessKey,value:s+this._suggested,suggestedText:this._suggested,ref:p=>this._input=p&&p.input,onClick:this.onInputClick,onKeyDown:this.onInputKeyDown,onChange:this.inputOnChange,onFocus:this.base.handleFocus,onBlur:this.handleBlur,disabled:a,expanded:r,owns:this.base.listBoxId,activedescendant:`option-${this.base.guid}-${c+l.skip}`,role:"combobox",ariaLabelledBy:this.props.ariaLabelledBy,ariaDescribedBy:this.props.ariaDescribedBy,ariaRequired:this.required,render:this.props.valueRender})}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&&(!u.isPresent(t)&&!u.isPresent(s)||u.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,{data:t=[],textField:o,dataItemKey:a,virtual:n={skip:0},focusedItemIndex:d=u.itemIndexStartsWith,skipDisabledItems:l}=this.props,r=this.props.filter?this.props.filter:this.state.text;return s&&this.navigationIndex!==void 0?this.navigationIndex:u.isPresent(e)&&r===void 0?t.findIndex(i=>u.areSame(i,e,a)):r?d(t,r,o):l&&o&&!r&&n.skip===0?t.findIndex(i=>!i.disabled&&i[o]):n.skip===0?0:-1}suggestValue(s){const{data:e,textField:t}=this.props;this._suggested=u.suggestValue(s,e,t)}applyState(s){this.base.applyState(s),this._valueDuringOnChange=void 0}calculateMedia(s){for(const e of s)this.setState({windowWidth:e.target.clientWidth})}};S.displayName="ComboBox",S.propTypes={...F.propTypes,size:I.oneOf([null,"small","medium","large"]),rounded:I.oneOf([null,"small","medium","large","full"]),fillMode:I.oneOf([null,"solid","flat","outline"]),dataItemKey:I.string,groupField:I.string,groupMode:I.oneOf([void 0,"classic","modern"]),isMultiColumn:I.bool,suggest:I.bool,placeholder:I.string,title:I.string,allowCustom:I.bool,clearButton:I.bool,iconClassName:I.string,svgIcon:g.svgIconPropType,validationMessage:I.string,required:I.bool,id:I.string,ariaLabelledBy:I.string,ariaDescribedBy:I.string,list:I.any,valueRender:I.func,skipDisabledItems:I.bool},S.defaultProps={...F.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 V=S;const W=g.createPropsContext(),U=g.withIdHOC(g.withPropsContext(W,V));U.displayName="KendoReactComboBox";exports.ComboBox=U;exports.ComboBoxPropsContext=W;exports.ComboBoxWithoutContext=V;
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const X=require("react"),I=require("prop-types"),B=require("../common/DropDownBase.js"),u=require("@progress/kendo-react-common"),Z=require("@progress/kendo-react-labels"),c=require("../common/utils.js"),ee=require("../common/SearchBar.js"),te=require("../common/ListContainer.js"),se=require("../common/List.js"),ie=require("../common/ListFilter.js"),L=require("../common/GroupStickyHeader.js"),ae=require("../package-metadata.js"),oe=require("../common/ClearButton.js"),R=require("@progress/kendo-react-buttons"),q=require("@progress/kendo-svg-icons"),C=require("../messages/index.js"),A=require("@progress/kendo-react-intl"),P=require("@progress/kendo-react-layout"),w=require("../common/constants.js"),z=require("../common/withCustomComponent.js");function ne(E){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(E){for(const e in E)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(E,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>E[e]})}}return s.default=E,Object.freeze(s)}const h=ne(X),le="Please enter a valid value!",{sizeMap:O,roundedMap:re}=u.kendoThemeMaps,S=class S extends h.Component{constructor(s){super(s),this.state={},this.base=new B(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=c.getPlainDataDuplicates(o),this.hasDuplicates=this.duplicates.length>0}},this.handleItemSelect=(e,t)=>{const{data:o=[],virtual:a,dataItemKey:n}=this.props,d=a?a.skip:0,l=o[e-d],r=this.hasDuplicates||!c.areSame(l,this.value,n);this.triggerOnChange(l,t),this.state.text!==void 0&&(t.data.text=void 0),r&&this.base.triggerPageChangeCornerItems(l,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{data:t=[],skipDisabledItems:o,textField:a}=this.props,n=this.getFocusedIndex(),d=this.getCurrentValueDisabledStatus(a,t,n),l=this.props.opened!==void 0?this.props.opened:this.state.opened,r=this.base.initState();if(r.syntheticEvent=e,!o&&a&&d&&this.clearValueOnToggleBtnClick(e),this.base.togglePopup(r),!l&&this.mobileMode){const i=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text||null;this.base.filterChanged(i,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=c.getItemValue(this.value,this.props.textField),o=c.isPresent(e)?e:t;return h.createElement(ie,{value:o,ref:a=>this._adaptiveFilterInput=a&&a.element,onChange:this.handleMobileFilterChange,onKeyDown:this.onInputKeyDown,size:this.props.size,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:a}=this.props;let{data:n=[]}=this.props;if(!a||!n.length)return;const d=this.itemHeight=this.itemHeight||(t.enabled?t.itemHeight:o?o.children[0].offsetHeight:0),r=e.target.scrollTop-t.skip*d;this.props.groupMode==="modern"&&(n=this.base.getGroupedDataModernMode(n,a));let i=n[0][a];for(let g=1;g<n.length&&!(d*g>r);g++)n[g]&&n[g][a]&&(i=n[g][a]);i!==this.state.group&&(this.setState({group:i}),this.props.onGroupScroll&&this.props.onGroupScroll.call(void 0,{group:i}))},this.handleItemClick=(e,t)=>{this.navigationIndex=e,this.base.handleItemClick(e,t),this._valueDuringOnChange=void 0},this.handleBlur=e=>{if(this.state.focused&&!this._skipBlur){const t=this.base.initState(),{textField:o,data:a=[]}=this.props,n=this.getFocusedIndex(),l=!(n===-1)&&this.getCurrentValueDisabledStatus(o,a,n);t.data.focused=!1,t.events.push({type:"onBlur"}),t.syntheticEvent=e,o&&l&&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 a=this.base.initState();a.syntheticEvent=e,this.base.togglePopup(a),this.base.filterChanged(o,a),this.applyState(a)}},this.onInputKeyDown=e=>{const{data:t=[],skipDisabledItems:o,textField:a,dataItemKey:n,groupField:d}=this.props,l=this.value,r=Math.max(0,t.findIndex(m=>c.areSame(m,l,n))),i=e.keyCode,g=this.props.opened!==void 0?this.props.opened:this.state.opened,p=this.base.initState();if(p.syntheticEvent=e,!e.altKey&&(i===u.Keys.up||i===u.Keys.down)){if(e.preventDefault(),d!==""&&a)if(!this.props.skipDisabledItems&&g)this.onNavigate(p,i);else{let m=0;if(i===u.Keys.down||i===u.Keys.right){const f=t.slice(r+1<t.length?r+1:r).find(x=>!x.disabled&&x[a]);m=f&&t.findIndex(x=>x[a]===f[a])}else if(i===u.Keys.up||i===u.Keys.left){let f;if(r===0)f=t,m=t.findIndex(x=>!x.disabled&&x[a]);else{f=t.slice(0,r);let x=f.pop();for(;x&&x.disabled;)x=f.pop();m=x&&t.findIndex(D=>D[a]===x[a])}}if(m!==void 0){const f=m-r;this.onNavigate(p,i,f)}else m===void 0&&t.findIndex(f=>f[a]===l[a])===t.length-1&&this.onNavigate(p,i)}else if(!this.props.skipDisabledItems&&g)this.onNavigate(p,i);else{let m=null;if(i===u.Keys.down||i===u.Keys.right)m=t.slice(r+1).find(f=>!f.disabled);else if(i===u.Keys.up||i===u.Keys.left){const f=t.slice(0,r);for(m=f.pop();m&&m.disabled;)m=f.pop()}if(m){const f=m.id-r-1;this.onNavigate(p,i,f)}else this.onNavigate(p,i)}this.applyState(p)}const v=()=>{e.preventDefault(),this.base.togglePopup(p),this.applyState(p)},y=this.getFocusedIndex(),b=y===-1,k=!b&&this.getCurrentValueDisabledStatus(a,t,y);g?i===u.Keys.pageUp?this.base.scrollPopupByPageSize(-1):i===u.Keys.pageDown?this.base.scrollPopupByPageSize(1):e.altKey&&i===u.Keys.up?v():i===u.Keys.enter?(e.preventDefault(),(a&&!b&&e.currentTarget.value?t[y][a]:void 0)?!o&&a&&k?this.clearValueOnEnterOrEsc(e):k||this.applyValueOnEnter(e.currentTarget.value,p):this.applyValueOnEnter(e.currentTarget.value,p)):i===u.Keys.esc&&(!o&&a&&k&&this.clearValueOnEnterOrEsc(e),this.applyValueOnRejectSuggestions(e.currentTarget.value,p)):!g&&i===u.Keys.esc?this.clearValueOnEnterOrEsc(e):e.altKey&&i===u.Keys.down&&v()},this.inputOnChange=e=>{const t=this.base.initState();t.syntheticEvent=e;const o=this.props.opened!==void 0?this.props.opened:this.state.opened,a=e.currentTarget,n=a.value;if(this.props.suggest){const d=a.selectionEnd===n.length;let l=this.props.filter!==void 0?this.props.filter:this.state.text;c.isPresent(l)||(l=c.getItemValue(this.value,this.props.textField)||"");const r=l&&l===n,i=l&&l.length>n.length;r||i||!d?this._suggested="":this.suggestValue(n)}this.props.filter===void 0&&(t.data.text=n),this.state.focusedItem!==void 0&&(t.data.focusedItem=void 0),o||this.base.togglePopup(t),this.base.filterChanged(n,t),this.applyState(t),this.setState({group:void 0})},this.clearButtonClick=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.clearValueOnEnterOrEsc=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.clearValueOnBlur=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.clearValueOnToggleBtnClick=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||le)},u.validatePackage(ae.packageMetadata)}get _inputId(){return this.props.id}get document(){if(u.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get mobileMode(){return!!(this.state.windowWidth&&this.state.windowWidth<=w.MOBILE_MEDIUM_DEVISE&&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{data:s=[],dataItemKey:e}=this.props,t=this.value;return s.findIndex(o=>c.areSame(o,t,e))}get name(){return this.props.name}get validity(){const s=this.props.validationMessage!==void 0,e=!this.required||this.value!==null&&this.value!==""&&this.value!==void 0,t=this.props.valid!==void 0?this.props.valid:e;return{customError:s,valid:t,valueMissing:this.value===null}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:S.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:S.defaultProps.required}componentDidUpdate(s,e){var v;const{dataItemKey:t,virtual:o,groupField:a="",data:n=[],textField:d}=this.props,l=s.virtual?s.virtual.total:0,r=this.props.opened!==void 0?this.props.opened:this.state.opened,i=s.opened!==void 0?s.opened:e.opened;s.data!==n&&this.checkForDuplicatePlainTextRecords();const g=!i&&r,p=this.value;if(this._valueOnDidUpdate=p,o&&o.total!==l)this.base.vs.calcScrollElementHeight(),this.base.vs.reset();else{const y=s.value!==void 0?s.value:e.value;let b=this.hasDuplicates?this.navigationIndex||0:n.findIndex(m=>c.areSame(m,p,t));this.props.groupMode==="modern"&&d&&p&&(b=(v=this.base.getGroupedDataModernMode(n,a))==null?void 0:v.map(m=>m[d]).indexOf(p[d]));const k=!c.areSame(y,p,t);g&&o?this.base.scrollToVirtualItem(o,b):g&&!o?(this.onPopupOpened(),n&&n.length!==0&&this.base.resetGroupStickyHeader(n[0][a],this),this.base.scrollToItem(b)):(this.hasDuplicates||r&&i&&p&&k)&&this.base.scrollToItem(b)}g&&this._input&&this._input.focus(),this.setValidity()}componentDidMount(){var s;this.observerResize=u.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=A.provideLocalizationService(this).toLanguageString(C.comboArrowBtnAriaLabelExpand,C.messages[C.comboArrowBtnAriaLabelExpand]),e=A.provideLocalizationService(this).toLanguageString(C.comboArrowBtnAriaLabelCollapse,C.messages[C.comboArrowBtnAriaLabelCollapse]),{dir:t,disabled:o,clearButton:a=S.defaultProps.clearButton,label:n,textField:d,adaptive:l,className:r,style:i,loading:g,iconClassName:p,virtual:v,size:y,rounded:b,fillMode:k,opened:m=this.state.opened,placeholder:f,svgIcon:x}=this.props,D=!this.validityStyles||this.validity.valid,T=this.props.filter!==void 0?this.props.filter:this.state.text,U=c.getItemValue(this.value,d),F=c.isPresent(T)?T:U,$=a&&(!!F||c.isPresent(this.value)),M=this.base.vs,_=this.props.id||this._inputId,N=this.mobileMode;M.enabled=v!==void 0,v!==void 0&&(M.skip=v.skip,M.total=v.total,M.pageSize=v.pageSize);const[j,G]=z(this.props.prefix||h.Fragment),[Y,J]=z(this.props.suffix||h.Fragment),K=h.createElement(h.Fragment,null,h.createElement("span",{className:u.classNames("k-combobox k-input",{[`k-input-${O[y]||y}`]:y,[`k-rounded-${re[b]||b}`]:b,[`k-input-${k}`]:k,"k-invalid":!D,"k-loading":g,"k-required":this.required,"k-disabled":o},r),ref:this.componentRef,style:n?{...i,width:void 0}:i,dir:t},this.props.prefix&&h.createElement(j,{...G}),this.renderSearchBar(F||"",_,f),$&&!g&&h.createElement(oe,{onClick:this.clearButtonClick,key:"clearbutton"}),g&&h.createElement(u.IconWrap,{className:"k-input-loading-icon",name:"loading",key:"loading"}),this.props.suffix&&h.createElement(Y,{...J}),h.createElement(R.Button,{tabIndex:-1,type:"button","aria-label":m?e:s,icon:p?void 0:"caret-alt-down",svgIcon:x||q.caretAltDownIcon,iconClass:p,size:y,fillMode:k,rounded:null,themeColor:"base",className:"k-input-button",onClick:this.toggleBtnClick,onMouseDown:Q=>Q.preventDefault()}),!N&&this.renderListContainer()),N&&this.renderAdaptiveListContainer());return n?h.createElement(Z.FloatingLabel,{label:n,editorId:_,editorValue:F,editorValid:D,editorDisabled:o,style:{width:i?i.width:void 0},children:K}):K}onNavigate(s,e,t){const{data:o=[],virtual:a={skip:0}}=this.props,n=this.props.filter?this.props.filter:this.state.text;let d=-1,l;const r=this.base.vs,i=this.value;this._suggested="";const g=this.hasDuplicates&&this.duplicates.indexOf(i)!==-1;if(d=this.getFocusedIndex(g),d!==-1&&!c.isPresent(i))this.handleItemSelect(d,s);else if(n==="")this.handleItemSelect(0,s);else{const p=a.skip+d;l=this.base.navigation.navigate({keyCode:e,current:p,max:(r.enabled?r.total:o.length)-1,min:0,skipItems:t||void 0}),l!==void 0&&this.handleItemSelect(l,s)}this.navigationIndex=l}getCurrentValueDisabledStatus(s,e,t){return s&&e&&e[t]&&e[t].disabled}applyValueOnEnter(s,e){const{data:t=[],textField:o,allowCustom:a}=this.props,n=this.props.opened!==void 0?this.props.opened:this.state.opened,l=c.getItemValue(this.value,o)===s?this.index:c.getItemIndexByText(t,s,o),r=l!==-1;let i;if(this._suggested="",r)i=t[l];else if(a)i=o!==void 0?{[o]:s}:s;else return this.selectFocusedItem(s,e);this.triggerOnChange(i,e),n&&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{data:t=[],textField:o,allowCustom:a}=this.props,n=this.props.opened!==void 0?this.props.opened:this.state.opened,d=c.getItemValue(this.value,o);if(this._suggested="",s===d||s===""&&!c.isPresent(d))return this.closeOpenedApplyStateNonMobileMode(e,n),this.applyState(e);const l=c.getItemIndexByText(t,s,o,!0),r=l!==-1;let i=null;r?i=t[l]:a&&(i=s?o?{[o]:s}:s:null),this.triggerOnChange(i,e),this.state.text!==void 0&&(e.data.text=void 0,this.base.filterChanged("",e)),this.closeOpenedApplyStateNonMobileMode(e,n),this.applyState(e)}selectFocusedItem(s,e){const t=this.props.opened!==void 0?this.props.opened:this.state.opened,{data:o=[],textField:a,virtual:n={skip:0},focusedItemIndex:d=c.itemIndexStartsWith}=this.props,l=n.skip,r=s===""&&l===0?0:d(o,s,a);return r!==-1?this.handleItemSelect(r+l,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,data:a=[],groupField:n,groupMode:d,list:l,virtual:r,adaptiveTitle:i,groupStickyHeaderItemRender:g}=this.props,p=this.props.opened!==void 0?this.props.opened:this.state.opened;let{group:v}=this.state;v===void 0&&n!==void 0&&(v=c.getItemValue(a[0],n));const y={navigatable:!1,navigatableElements:[],expand:p,animation:!0,onClose:b=>this.toggleBtnClick(b),animationStyles:s<=w.MOBILE_SMALL_DEVISE?{top:0,width:"100%",height:"100%"}:void 0,className:s<=w.MOBILE_SMALL_DEVISE?"k-adaptive-actionsheet k-actionsheet-fullscreen":"k-adaptive-actionsheet k-actionsheet-bottom"};return h.createElement(P.ActionSheet,{...y},h.createElement(P.ActionSheetHeader,{className:"k-text-center"},h.createElement("div",{className:"k-actionsheet-titlebar-group k-hbox"},h.createElement("div",{className:"k-actionsheet-title"},h.createElement("div",null,i)),h.createElement("div",{className:"k-actionsheet-actions"},h.createElement(R.Button,{tabIndex:0,"aria-label":"Cancel","aria-disabled":"false",type:"button",fillMode:"flat",onClick:this.toggleBtnClick,icon:"x",svgIcon:q.xIcon}))),h.createElement("div",{className:"k-actionsheet-titlebar-group k-actionsheet-filter"},this.renderMobileListFilter())),h.createElement(P.ActionSheetContent,{className:"!k-overflow-hidden"},h.createElement("div",{className:"k-list-container"},h.createElement("div",{className:u.classNames({"k-list":!l,"k-list-lg":!0,"k-virtual-list":r,"k-data-table":l,[`k-table-${O[o]||o}`]:l&&o})},e&&h.createElement("div",{className:"k-table-header"},e),!l&&v&&a.length!==0&&h.createElement(L,{group:v,groupMode:d,render:g}),this.renderList(),t&&h.createElement("div",{className:"k-list-footer"},t)))))}renderListContainer(){const s=this.base,{dir:e,header:t,footer:o,data:a=[],groupField:n,groupMode:d,size:l,list:r,virtual:i,groupStickyHeaderItemRender:g}=this.props,p=this.props.opened!==void 0?this.props.opened:this.state.opened,v=s.getPopupSettings(),y=v.width!==void 0?v.width:s.popupWidth;let{group:b}=this.state;return b===void 0&&n!==void 0&&(b=c.getItemValue(a[0],n)),h.createElement(te,{width:y,popupSettings:{...v,anchor:v.anchor||this.element,show:p,popupClass:u.classNames(v.popupClass,"k-list-container","k-combobox-popup")},dir:e!==void 0?e:this.base.dirCalculated,itemsCount:[a.length]},h.createElement("div",{className:u.classNames({"k-list":!r,[`k-list-${O[l]||l}`]:!r&&l,"k-virtual-list":i,"k-data-table":r,[`k-table-${O[l]||l}`]:r&&l})},t&&h.createElement("div",{className:"k-table-header"},t),!r&&b&&a.length!==0&&h.createElement(L,{group:b,groupMode:d,render:g}),this.renderList(),o&&h.createElement("div",{className:u.classNames({"k-list-footer":!this.props.footerClassName},this.props.footerClassName)},o)))}renderList(){const s=this.base,{textField:e,dataItemKey:t,listNoDataRender:o,itemRender:a,groupHeaderItemRender:n,data:d=[],virtual:l={skip:0,total:void 0}}=this.props,r=s.getPopupSettings(),i=s.vs,g=l.skip,p=this.props.opened!==void 0?this.props.opened:this.state.opened,v=`translateY(${i.translate}px)`,y=p?this.getFocusedIndex(this.hasDuplicates):void 0,b=this.props.filter!==void 0?this.props.filter:this.state.text,k=c.getItemValue(this.value,e),m=c.isPresent(b)&&b!==k?null:this.value,f=this.props.list||se;return h.createElement(f,{id:s.listBoxId,virtual:!!l,show:p,data:d,focusedIndex:y,value:m,textField:e,valueField:t,groupField:this.props.groupField,groupMode:this.props.groupMode,isMultiColumn:this.props.isMultiColumn,optionsGuid:s.guid,hasDuplicates:this.hasDuplicates,listRef:x=>{i.list=this.base.list=x,this.itemHeight=0},wrapperStyle:this.state.windowWidth&&this.state.windowWidth>w.MOBILE_MEDIUM_DEVISE?{maxHeight:r.height}:{},wrapperCssClass:u.classNames("k-list-content",{"k-list-scroller":!l}),listStyle:i.enabled?{transform:v}:void 0,key:"listkey",skip:g,onClick:this.handleItemClick,itemRender:a,groupHeaderItemRender:n,noDataRender:o,onMouseDown:x=>x.preventDefault(),onScroll:this.onScroll,wrapperRef:i.scrollerRef,scroller:this.base.renderScrollElement(),ariaSetSize:l.total})}renderSearchBar(s,e,t){const{tabIndex:o,disabled:a,data:n=[],dataItemKey:d,virtual:l={skip:0}}=this.props,r=this.props.opened!==void 0?this.props.opened:this.state.opened,i=this.value,g=Math.max(0,n.findIndex(p=>c.areSame(p,i,d)));return this._suggested&&!c.areSame(this._valueOnDidUpdate,i,d)&&(this._suggested=""),h.createElement(ee,{id:e,readOnly:r&&this.mobileMode,placeholder:t,tabIndex:o,title:this.props.title,accessKey:this.props.accessKey,value:s+this._suggested,suggestedText:this._suggested,ref:p=>this._input=p&&p.input,onClick:this.onInputClick,onKeyDown:this.onInputKeyDown,onChange:this.inputOnChange,onFocus:this.base.handleFocus,onBlur:this.handleBlur,disabled:a,expanded:r,owns:this.base.listBoxId,activedescendant:`option-${this.base.guid}-${g+l.skip}`,role:"combobox",ariaLabelledBy:this.props.ariaLabelledBy,ariaDescribedBy:this.props.ariaDescribedBy,ariaRequired:this.required,render:this.props.valueRender})}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&&(!c.isPresent(t)&&!c.isPresent(s)||c.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,{data:t=[],textField:o,dataItemKey:a,virtual:n={skip:0},focusedItemIndex:d=c.itemIndexStartsWith,skipDisabledItems:l}=this.props,r=this.props.filter?this.props.filter:this.state.text;return s&&this.navigationIndex!==void 0?this.navigationIndex:c.isPresent(e)&&r===void 0?t.findIndex(i=>c.areSame(i,e,a)):r?d(t,r,o):l&&o&&!r&&n.skip===0?t.findIndex(i=>!i.disabled&&i[o]):n.skip===0?0:-1}suggestValue(s){const{data:e,textField:t}=this.props;this._suggested=c.suggestValue(s,e,t)}applyState(s){this.base.applyState(s),this._valueDuringOnChange=void 0}calculateMedia(s){for(const e of s)this.setState({windowWidth:e.target.clientWidth})}};S.displayName="ComboBox",S.propTypes={...B.propTypes,size:I.oneOf([null,"small","medium","large"]),rounded:I.oneOf([null,"small","medium","large","full"]),fillMode:I.oneOf([null,"solid","flat","outline"]),dataItemKey:I.string,groupField:I.string,groupMode:I.oneOf([void 0,"classic","modern"]),isMultiColumn:I.bool,suggest:I.bool,placeholder:I.string,title:I.string,allowCustom:I.bool,clearButton:I.bool,iconClassName:I.string,svgIcon:u.svgIconPropType,validationMessage:I.string,required:I.bool,id:I.string,ariaLabelledBy:I.string,ariaDescribedBy:I.string,list:I.any,valueRender:I.func,skipDisabledItems:I.bool},S.defaultProps={...B.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 V=S;const H=u.createPropsContext(),W=u.withIdHOC(u.withPropsContext(H,V));W.displayName="KendoReactComboBox";exports.ComboBox=W;exports.ComboBoxPropsContext=H;exports.ComboBoxWithoutContext=V;
|
package/ComboBox/ComboBox.mjs
CHANGED
|
@@ -8,36 +8,36 @@
|
|
|
8
8
|
"use client";
|
|
9
9
|
import * as h from "react";
|
|
10
10
|
import f from "prop-types";
|
|
11
|
-
import
|
|
12
|
-
import { Keys as x, validatePackage as
|
|
13
|
-
import { FloatingLabel as
|
|
14
|
-
import { getPlainDataDuplicates as
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import { packageMetadata as
|
|
21
|
-
import
|
|
22
|
-
import { Button as
|
|
23
|
-
import { caretAltDownIcon as
|
|
24
|
-
import { comboArrowBtnAriaLabelExpand as
|
|
25
|
-
import { provideLocalizationService as
|
|
26
|
-
import { ActionSheet as
|
|
27
|
-
import { MOBILE_MEDIUM_DEVISE as
|
|
28
|
-
import
|
|
29
|
-
const Se = "Please enter a valid value!", { sizeMap:
|
|
11
|
+
import V from "../common/DropDownBase.mjs";
|
|
12
|
+
import { Keys as x, validatePackage as se, svgIconPropType as ie, canUseDOM as L, classNames as E, IconWrap as oe, createPropsContext as ae, withIdHOC as ne, withPropsContext as le, kendoThemeMaps as re } from "@progress/kendo-react-common";
|
|
13
|
+
import { FloatingLabel as de } from "@progress/kendo-react-labels";
|
|
14
|
+
import { getPlainDataDuplicates as pe, areSame as S, getItemValue as C, isPresent as k, getItemIndexByText as R, suggestValue as he, itemIndexStartsWith as A } from "../common/utils.mjs";
|
|
15
|
+
import ce from "../common/SearchBar.mjs";
|
|
16
|
+
import ue from "../common/ListContainer.mjs";
|
|
17
|
+
import ge from "../common/List.mjs";
|
|
18
|
+
import me from "../common/ListFilter.mjs";
|
|
19
|
+
import K from "../common/GroupStickyHeader.mjs";
|
|
20
|
+
import { packageMetadata as ve } from "../package-metadata.mjs";
|
|
21
|
+
import fe from "../common/ClearButton.mjs";
|
|
22
|
+
import { Button as z } from "@progress/kendo-react-buttons";
|
|
23
|
+
import { caretAltDownIcon as be, xIcon as xe } from "@progress/kendo-svg-icons";
|
|
24
|
+
import { comboArrowBtnAriaLabelExpand as H, messages as q, comboArrowBtnAriaLabelCollapse as $ } from "../messages/index.mjs";
|
|
25
|
+
import { provideLocalizationService as G } from "@progress/kendo-react-intl";
|
|
26
|
+
import { ActionSheet as Ie, ActionSheetHeader as ye, ActionSheetContent as ke } from "@progress/kendo-react-layout";
|
|
27
|
+
import { MOBILE_MEDIUM_DEVISE as W, MOBILE_SMALL_DEVISE as U } from "../common/constants.mjs";
|
|
28
|
+
import j from "../common/withCustomComponent.mjs";
|
|
29
|
+
const Se = "Please enter a valid value!", { sizeMap: F, roundedMap: Ce } = re, D = class D extends h.Component {
|
|
30
30
|
constructor(s) {
|
|
31
|
-
super(s), this.state = {}, this.base = new
|
|
31
|
+
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 = () => {
|
|
32
32
|
this._input && this._input.focus();
|
|
33
33
|
}, this.checkForDuplicatePlainTextRecords = () => {
|
|
34
34
|
const e = this.props.textField !== void 0, t = this.props.dataItemKey !== void 0;
|
|
35
35
|
if (this.props.data && this.props.data.length > 0 && !e && !t) {
|
|
36
36
|
const a = this.props.data;
|
|
37
|
-
this.duplicates =
|
|
37
|
+
this.duplicates = pe(a), this.hasDuplicates = this.duplicates.length > 0;
|
|
38
38
|
}
|
|
39
39
|
}, this.handleItemSelect = (e, t) => {
|
|
40
|
-
const { data: a = [], virtual: o, dataItemKey: n } = this.props, d = o ? o.skip : 0, l = a[e - d], r = this.hasDuplicates || !
|
|
40
|
+
const { data: a = [], virtual: o, dataItemKey: n } = this.props, d = o ? o.skip : 0, l = a[e - d], r = this.hasDuplicates || !S(l, this.value, n);
|
|
41
41
|
this.triggerOnChange(l, t), this.state.text !== void 0 && (t.data.text = void 0), r && this.base.triggerPageChangeCornerItems(l, t);
|
|
42
42
|
}, this.onPopupOpened = () => {
|
|
43
43
|
setTimeout(() => {
|
|
@@ -52,10 +52,12 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
52
52
|
this.base.filterChanged(i, r);
|
|
53
53
|
}
|
|
54
54
|
this.applyState(r);
|
|
55
|
+
}, this.closeOpenedApplyStateNonMobileMode = (e, t) => {
|
|
56
|
+
t && !this.mobileMode && this.base.togglePopup(e);
|
|
55
57
|
}, this.renderMobileListFilter = () => {
|
|
56
|
-
const e = this.props.adaptiveFilter !== void 0 ? this.props.adaptiveFilter : this.state.text, t =
|
|
58
|
+
const e = this.props.adaptiveFilter !== void 0 ? this.props.adaptiveFilter : this.state.text, t = C(this.value, this.props.textField), a = k(e) ? e : t;
|
|
57
59
|
return /* @__PURE__ */ h.createElement(
|
|
58
|
-
|
|
60
|
+
me,
|
|
59
61
|
{
|
|
60
62
|
value: a,
|
|
61
63
|
ref: (o) => this._adaptiveFilterInput = o && o.element,
|
|
@@ -98,7 +100,7 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
98
100
|
o.syntheticEvent = e, this.base.togglePopup(o), this.base.filterChanged(a, o), this.applyState(o);
|
|
99
101
|
}
|
|
100
102
|
}, this.onInputKeyDown = (e) => {
|
|
101
|
-
const { data: t = [], skipDisabledItems: a, textField: o, dataItemKey: n, groupField: d } = this.props, l = this.value, r = Math.max(0, t.findIndex((u) =>
|
|
103
|
+
const { data: t = [], skipDisabledItems: a, textField: o, dataItemKey: n, groupField: d } = this.props, l = this.value, r = Math.max(0, t.findIndex((u) => S(u, l, n))), i = e.keyCode, c = this.props.opened !== void 0 ? this.props.opened : this.state.opened, p = this.base.initState();
|
|
102
104
|
if (p.syntheticEvent = e, !e.altKey && (i === x.up || i === x.down)) {
|
|
103
105
|
if (e.preventDefault(), d !== "" && o)
|
|
104
106
|
if (!this.props.skipDisabledItems && c)
|
|
@@ -117,7 +119,7 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
117
119
|
let b = m.pop();
|
|
118
120
|
for (; b && b.disabled; )
|
|
119
121
|
b = m.pop();
|
|
120
|
-
u = b && t.findIndex((
|
|
122
|
+
u = b && t.findIndex((w) => w[o] === b[o]);
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
125
|
if (u !== void 0) {
|
|
@@ -156,7 +158,7 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
156
158
|
if (this.props.suggest) {
|
|
157
159
|
const d = o.selectionEnd === n.length;
|
|
158
160
|
let l = this.props.filter !== void 0 ? this.props.filter : this.state.text;
|
|
159
|
-
k(l) || (l =
|
|
161
|
+
k(l) || (l = C(this.value, this.props.textField) || "");
|
|
160
162
|
const r = l && l === n, i = l && l.length > n.length;
|
|
161
163
|
r || i || !d ? this._suggested = "" : this.suggestValue(n);
|
|
162
164
|
}
|
|
@@ -177,13 +179,13 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
177
179
|
this._input && this._input.setCustomValidity && this._input.setCustomValidity(
|
|
178
180
|
this.validity.valid ? "" : this.props.validationMessage || Se
|
|
179
181
|
);
|
|
180
|
-
},
|
|
182
|
+
}, se(ve);
|
|
181
183
|
}
|
|
182
184
|
get _inputId() {
|
|
183
185
|
return this.props.id;
|
|
184
186
|
}
|
|
185
187
|
get document() {
|
|
186
|
-
if (
|
|
188
|
+
if (L)
|
|
187
189
|
return this.element && this.element.ownerDocument || document;
|
|
188
190
|
}
|
|
189
191
|
/** @hidden */
|
|
@@ -194,7 +196,7 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
194
196
|
* The mobile mode of the ComboBox.
|
|
195
197
|
*/
|
|
196
198
|
get mobileMode() {
|
|
197
|
-
return !!(this.state.windowWidth && this.state.windowWidth <=
|
|
199
|
+
return !!(this.state.windowWidth && this.state.windowWidth <= W && this.props.adaptive);
|
|
198
200
|
}
|
|
199
201
|
/**
|
|
200
202
|
* The value of the ComboBox.
|
|
@@ -214,7 +216,7 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
214
216
|
*/
|
|
215
217
|
get index() {
|
|
216
218
|
const { data: s = [], dataItemKey: e } = this.props, t = this.value;
|
|
217
|
-
return s.findIndex((a) =>
|
|
219
|
+
return s.findIndex((a) => S(a, t, e));
|
|
218
220
|
}
|
|
219
221
|
/**
|
|
220
222
|
* Gets the `name` property of the ComboBox.
|
|
@@ -234,11 +236,11 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
234
236
|
};
|
|
235
237
|
}
|
|
236
238
|
get validityStyles() {
|
|
237
|
-
return this.props.validityStyles !== void 0 ? this.props.validityStyles :
|
|
239
|
+
return this.props.validityStyles !== void 0 ? this.props.validityStyles : D.defaultProps.validityStyles;
|
|
238
240
|
}
|
|
239
241
|
/** @hidden */
|
|
240
242
|
get required() {
|
|
241
|
-
return this.props.required !== void 0 ? this.props.required :
|
|
243
|
+
return this.props.required !== void 0 ? this.props.required : D.defaultProps.required;
|
|
242
244
|
}
|
|
243
245
|
/** @hidden */
|
|
244
246
|
componentDidUpdate(s, e) {
|
|
@@ -250,9 +252,9 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
250
252
|
this.base.vs.calcScrollElementHeight(), this.base.vs.reset();
|
|
251
253
|
else {
|
|
252
254
|
const I = s.value !== void 0 ? s.value : e.value;
|
|
253
|
-
let v = this.hasDuplicates ? this.navigationIndex || 0 : n.findIndex((u) =>
|
|
255
|
+
let v = this.hasDuplicates ? this.navigationIndex || 0 : n.findIndex((u) => S(u, p, t));
|
|
254
256
|
this.props.groupMode === "modern" && d && p && (v = (g = this.base.getGroupedDataModernMode(n, o)) == null ? void 0 : g.map((u) => u[d]).indexOf(p[d]));
|
|
255
|
-
const y = !
|
|
257
|
+
const y = !S(I, p, t);
|
|
256
258
|
c && a ? this.base.scrollToVirtualItem(a, v) : c && !a ? (this.onPopupOpened(), n && n.length !== 0 && this.base.resetGroupStickyHeader(n[0][o], this), this.base.scrollToItem(v)) : (this.hasDuplicates || r && i && p && y) && this.base.scrollToItem(v);
|
|
257
259
|
}
|
|
258
260
|
c && this._input && this._input.focus(), this.setValidity();
|
|
@@ -260,7 +262,7 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
260
262
|
/** @hidden */
|
|
261
263
|
componentDidMount() {
|
|
262
264
|
var s;
|
|
263
|
-
this.observerResize =
|
|
265
|
+
this.observerResize = L && 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();
|
|
264
266
|
}
|
|
265
267
|
/** @hidden */
|
|
266
268
|
componentWillUnmount() {
|
|
@@ -269,13 +271,13 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
269
271
|
}
|
|
270
272
|
/** @hidden */
|
|
271
273
|
render() {
|
|
272
|
-
const s =
|
|
273
|
-
|
|
274
|
-
$
|
|
274
|
+
const s = G(this).toLanguageString(H, q[H]), e = G(this).toLanguageString(
|
|
275
|
+
$,
|
|
276
|
+
q[$]
|
|
275
277
|
), {
|
|
276
278
|
dir: t,
|
|
277
279
|
disabled: a,
|
|
278
|
-
clearButton: o =
|
|
280
|
+
clearButton: o = D.defaultProps.clearButton,
|
|
279
281
|
label: n,
|
|
280
282
|
textField: d,
|
|
281
283
|
adaptive: l,
|
|
@@ -290,18 +292,18 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
290
292
|
opened: u = this.state.opened,
|
|
291
293
|
placeholder: m,
|
|
292
294
|
svgIcon: b
|
|
293
|
-
} = this.props,
|
|
294
|
-
|
|
295
|
-
const [
|
|
295
|
+
} = this.props, w = !this.validityStyles || this.validity.valid, T = this.props.filter !== void 0 ? this.props.filter : this.state.text, Y = C(this.value, d), O = k(T) ? T : Y, J = o && (!!O || k(this.value)), M = this.base.vs, _ = this.props.id || this._inputId, N = this.mobileMode;
|
|
296
|
+
M.enabled = g !== void 0, g !== void 0 && (M.skip = g.skip, M.total = g.total, M.pageSize = g.pageSize);
|
|
297
|
+
const [Q, X] = j(this.props.prefix || h.Fragment), [Z, ee] = j(this.props.suffix || h.Fragment), P = /* @__PURE__ */ h.createElement(h.Fragment, null, /* @__PURE__ */ h.createElement(
|
|
296
298
|
"span",
|
|
297
299
|
{
|
|
298
|
-
className:
|
|
300
|
+
className: E(
|
|
299
301
|
"k-combobox k-input",
|
|
300
302
|
{
|
|
301
|
-
[`k-input-${
|
|
302
|
-
[`k-rounded-${
|
|
303
|
+
[`k-input-${F[I] || I}`]: I,
|
|
304
|
+
[`k-rounded-${Ce[v] || v}`]: v,
|
|
303
305
|
[`k-input-${y}`]: y,
|
|
304
|
-
"k-invalid": !
|
|
306
|
+
"k-invalid": !w,
|
|
305
307
|
"k-loading": c,
|
|
306
308
|
"k-required": this.required,
|
|
307
309
|
"k-disabled": a
|
|
@@ -312,19 +314,19 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
312
314
|
style: n ? { ...i, width: void 0 } : i,
|
|
313
315
|
dir: t
|
|
314
316
|
},
|
|
315
|
-
this.props.prefix && /* @__PURE__ */ h.createElement(
|
|
316
|
-
this.renderSearchBar(O || "",
|
|
317
|
-
|
|
318
|
-
c && /* @__PURE__ */ h.createElement(
|
|
319
|
-
this.props.suffix && /* @__PURE__ */ h.createElement(
|
|
317
|
+
this.props.prefix && /* @__PURE__ */ h.createElement(Q, { ...X }),
|
|
318
|
+
this.renderSearchBar(O || "", _, m),
|
|
319
|
+
J && !c && /* @__PURE__ */ h.createElement(fe, { onClick: this.clearButtonClick, key: "clearbutton" }),
|
|
320
|
+
c && /* @__PURE__ */ h.createElement(oe, { className: "k-input-loading-icon", name: "loading", key: "loading" }),
|
|
321
|
+
this.props.suffix && /* @__PURE__ */ h.createElement(Z, { ...ee }),
|
|
320
322
|
/* @__PURE__ */ h.createElement(
|
|
321
|
-
|
|
323
|
+
z,
|
|
322
324
|
{
|
|
323
325
|
tabIndex: -1,
|
|
324
326
|
type: "button",
|
|
325
327
|
"aria-label": u ? e : s,
|
|
326
328
|
icon: p ? void 0 : "caret-alt-down",
|
|
327
|
-
svgIcon: b ||
|
|
329
|
+
svgIcon: b || be,
|
|
328
330
|
iconClass: p,
|
|
329
331
|
size: I,
|
|
330
332
|
fillMode: y,
|
|
@@ -332,23 +334,23 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
332
334
|
themeColor: "base",
|
|
333
335
|
className: "k-input-button",
|
|
334
336
|
onClick: this.toggleBtnClick,
|
|
335
|
-
onMouseDown: (
|
|
337
|
+
onMouseDown: (te) => te.preventDefault()
|
|
336
338
|
}
|
|
337
339
|
),
|
|
338
|
-
!
|
|
339
|
-
),
|
|
340
|
+
!N && this.renderListContainer()
|
|
341
|
+
), N && this.renderAdaptiveListContainer());
|
|
340
342
|
return n ? /* @__PURE__ */ h.createElement(
|
|
341
|
-
|
|
343
|
+
de,
|
|
342
344
|
{
|
|
343
345
|
label: n,
|
|
344
|
-
editorId:
|
|
346
|
+
editorId: _,
|
|
345
347
|
editorValue: O,
|
|
346
|
-
editorValid:
|
|
348
|
+
editorValid: w,
|
|
347
349
|
editorDisabled: a,
|
|
348
350
|
style: { width: i ? i.width : void 0 },
|
|
349
|
-
children:
|
|
351
|
+
children: P
|
|
350
352
|
}
|
|
351
|
-
) :
|
|
353
|
+
) : P;
|
|
352
354
|
}
|
|
353
355
|
/** @hidden */
|
|
354
356
|
onNavigate(s, e, t) {
|
|
@@ -377,7 +379,7 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
377
379
|
return s && e && e[t] && e[t].disabled;
|
|
378
380
|
}
|
|
379
381
|
applyValueOnEnter(s, e) {
|
|
380
|
-
const { data: t = [], textField: a, allowCustom: o } = this.props, n = this.props.opened !== void 0 ? this.props.opened : this.state.opened, l =
|
|
382
|
+
const { data: t = [], textField: a, allowCustom: o } = this.props, n = this.props.opened !== void 0 ? this.props.opened : this.state.opened, l = C(this.value, a) === s ? this.index : R(t, s, a), r = l !== -1;
|
|
381
383
|
let i;
|
|
382
384
|
if (this._suggested = "", r)
|
|
383
385
|
i = t[l];
|
|
@@ -388,12 +390,12 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
388
390
|
this.triggerOnChange(i, e), n && this.base.togglePopup(e), this.props.filter === void 0 && this.state.text !== void 0 && (e.data.text = void 0), this.applyState(e);
|
|
389
391
|
}
|
|
390
392
|
applyValueOnRejectSuggestions(s, e) {
|
|
391
|
-
const { data: t = [], textField: a, allowCustom: o } = this.props, n = this.props.opened !== void 0 ? this.props.opened : this.state.opened, d =
|
|
393
|
+
const { data: t = [], textField: a, allowCustom: o } = this.props, n = this.props.opened !== void 0 ? this.props.opened : this.state.opened, d = C(this.value, a);
|
|
392
394
|
if (this._suggested = "", s === d || s === "" && !k(d))
|
|
393
|
-
return
|
|
394
|
-
const
|
|
395
|
-
let
|
|
396
|
-
|
|
395
|
+
return this.closeOpenedApplyStateNonMobileMode(e, n), this.applyState(e);
|
|
396
|
+
const l = R(t, s, a, !0), r = l !== -1;
|
|
397
|
+
let i = null;
|
|
398
|
+
r ? i = t[l] : o && (i = s ? a ? { [a]: s } : s : null), this.triggerOnChange(i, e), this.state.text !== void 0 && (e.data.text = void 0, this.base.filterChanged("", e)), this.closeOpenedApplyStateNonMobileMode(e, n), this.applyState(e);
|
|
397
399
|
}
|
|
398
400
|
selectFocusedItem(s, e) {
|
|
399
401
|
const t = this.props.opened !== void 0 ? this.props.opened : this.state.opened, { data: a = [], textField: o, virtual: n = { skip: 0 }, focusedItemIndex: d = A } = this.props, l = n.skip, r = s === "" && l === 0 ? 0 : d(a, s, o);
|
|
@@ -402,18 +404,18 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
402
404
|
renderAdaptiveListContainer() {
|
|
403
405
|
const { windowWidth: s = 0 } = this.state, { header: e, footer: t, size: a, data: o = [], groupField: n, groupMode: d, list: l, virtual: r, adaptiveTitle: i, groupStickyHeaderItemRender: c } = this.props, p = this.props.opened !== void 0 ? this.props.opened : this.state.opened;
|
|
404
406
|
let { group: g } = this.state;
|
|
405
|
-
g === void 0 && n !== void 0 && (g =
|
|
407
|
+
g === void 0 && n !== void 0 && (g = C(o[0], n));
|
|
406
408
|
const I = {
|
|
407
409
|
navigatable: !1,
|
|
408
410
|
navigatableElements: [],
|
|
409
411
|
expand: p,
|
|
410
412
|
animation: !0,
|
|
411
413
|
onClose: (v) => this.toggleBtnClick(v),
|
|
412
|
-
animationStyles: s <=
|
|
413
|
-
className: s <=
|
|
414
|
+
animationStyles: s <= U ? { top: 0, width: "100%", height: "100%" } : void 0,
|
|
415
|
+
className: s <= U ? "k-adaptive-actionsheet k-actionsheet-fullscreen" : "k-adaptive-actionsheet k-actionsheet-bottom"
|
|
414
416
|
};
|
|
415
|
-
return /* @__PURE__ */ h.createElement(
|
|
416
|
-
|
|
417
|
+
return /* @__PURE__ */ h.createElement(Ie, { ...I }, /* @__PURE__ */ h.createElement(ye, { className: "k-text-center" }, /* @__PURE__ */ h.createElement("div", { className: "k-actionsheet-titlebar-group k-hbox" }, /* @__PURE__ */ h.createElement("div", { className: "k-actionsheet-title" }, /* @__PURE__ */ h.createElement("div", null, i)), /* @__PURE__ */ h.createElement("div", { className: "k-actionsheet-actions" }, /* @__PURE__ */ h.createElement(
|
|
418
|
+
z,
|
|
417
419
|
{
|
|
418
420
|
tabIndex: 0,
|
|
419
421
|
"aria-label": "Cancel",
|
|
@@ -422,30 +424,30 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
422
424
|
fillMode: "flat",
|
|
423
425
|
onClick: this.toggleBtnClick,
|
|
424
426
|
icon: "x",
|
|
425
|
-
svgIcon:
|
|
427
|
+
svgIcon: xe
|
|
426
428
|
}
|
|
427
|
-
))), /* @__PURE__ */ h.createElement("div", { className: "k-actionsheet-titlebar-group k-actionsheet-filter" }, this.renderMobileListFilter())), /* @__PURE__ */ h.createElement(
|
|
429
|
+
))), /* @__PURE__ */ h.createElement("div", { className: "k-actionsheet-titlebar-group k-actionsheet-filter" }, this.renderMobileListFilter())), /* @__PURE__ */ h.createElement(ke, { className: "!k-overflow-hidden" }, /* @__PURE__ */ h.createElement("div", { className: "k-list-container" }, /* @__PURE__ */ h.createElement("div", { className: E(
|
|
428
430
|
{
|
|
429
431
|
"k-list": !l,
|
|
430
432
|
"k-list-lg": !0,
|
|
431
433
|
"k-virtual-list": r,
|
|
432
434
|
"k-data-table": l,
|
|
433
|
-
[`k-table-${
|
|
435
|
+
[`k-table-${F[a] || a}`]: l && a
|
|
434
436
|
}
|
|
435
|
-
) }, e && /* @__PURE__ */ h.createElement("div", { className: "k-table-header" }, e), !l && g && o.length !== 0 && /* @__PURE__ */ h.createElement(
|
|
437
|
+
) }, e && /* @__PURE__ */ h.createElement("div", { className: "k-table-header" }, e), !l && g && o.length !== 0 && /* @__PURE__ */ h.createElement(K, { group: g, groupMode: d, render: c }), this.renderList(), t && /* @__PURE__ */ h.createElement("div", { className: "k-list-footer" }, t)))));
|
|
436
438
|
}
|
|
437
439
|
renderListContainer() {
|
|
438
440
|
const s = this.base, { dir: e, header: t, footer: a, data: o = [], groupField: n, groupMode: d, size: l, list: r, virtual: i, groupStickyHeaderItemRender: c } = this.props, p = this.props.opened !== void 0 ? this.props.opened : this.state.opened, g = s.getPopupSettings(), I = g.width !== void 0 ? g.width : s.popupWidth;
|
|
439
441
|
let { group: v } = this.state;
|
|
440
|
-
return v === void 0 && n !== void 0 && (v =
|
|
441
|
-
|
|
442
|
+
return v === void 0 && n !== void 0 && (v = C(o[0], n)), /* @__PURE__ */ h.createElement(
|
|
443
|
+
ue,
|
|
442
444
|
{
|
|
443
445
|
width: I,
|
|
444
446
|
popupSettings: {
|
|
445
447
|
...g,
|
|
446
448
|
anchor: g.anchor || this.element,
|
|
447
449
|
show: p,
|
|
448
|
-
popupClass:
|
|
450
|
+
popupClass: E(
|
|
449
451
|
g.popupClass,
|
|
450
452
|
"k-list-container",
|
|
451
453
|
"k-combobox-popup"
|
|
@@ -454,15 +456,15 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
454
456
|
dir: e !== void 0 ? e : this.base.dirCalculated,
|
|
455
457
|
itemsCount: [o.length]
|
|
456
458
|
},
|
|
457
|
-
/* @__PURE__ */ h.createElement("div", { className:
|
|
459
|
+
/* @__PURE__ */ h.createElement("div", { className: E(
|
|
458
460
|
{
|
|
459
461
|
"k-list": !r,
|
|
460
|
-
[`k-list-${
|
|
462
|
+
[`k-list-${F[l] || l}`]: !r && l,
|
|
461
463
|
"k-virtual-list": i,
|
|
462
464
|
"k-data-table": r,
|
|
463
|
-
[`k-table-${
|
|
465
|
+
[`k-table-${F[l] || l}`]: r && l
|
|
464
466
|
}
|
|
465
|
-
) }, t && /* @__PURE__ */ h.createElement("div", { className: "k-table-header" }, t), !r && v && o.length !== 0 && /* @__PURE__ */ h.createElement(
|
|
467
|
+
) }, t && /* @__PURE__ */ h.createElement("div", { className: "k-table-header" }, t), !r && v && o.length !== 0 && /* @__PURE__ */ h.createElement(K, { group: v, groupMode: d, render: c }), this.renderList(), a && /* @__PURE__ */ h.createElement("div", { className: E(
|
|
466
468
|
{
|
|
467
469
|
"k-list-footer": !this.props.footerClassName
|
|
468
470
|
},
|
|
@@ -479,7 +481,7 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
479
481
|
groupHeaderItemRender: n,
|
|
480
482
|
data: d = [],
|
|
481
483
|
virtual: l = { skip: 0, total: void 0 }
|
|
482
|
-
} = this.props, r = s.getPopupSettings(), i = s.vs, c = l.skip, p = this.props.opened !== void 0 ? this.props.opened : this.state.opened, g = `translateY(${i.translate}px)`, I = p ? this.getFocusedIndex(this.hasDuplicates) : void 0, v = this.props.filter !== void 0 ? this.props.filter : this.state.text, y =
|
|
484
|
+
} = this.props, r = s.getPopupSettings(), i = s.vs, c = l.skip, p = this.props.opened !== void 0 ? this.props.opened : this.state.opened, g = `translateY(${i.translate}px)`, I = p ? this.getFocusedIndex(this.hasDuplicates) : void 0, v = this.props.filter !== void 0 ? this.props.filter : this.state.text, y = C(this.value, e), u = k(v) && v !== y ? null : this.value, m = this.props.list || ge;
|
|
483
485
|
return /* @__PURE__ */ h.createElement(
|
|
484
486
|
m,
|
|
485
487
|
{
|
|
@@ -499,8 +501,8 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
499
501
|
listRef: (b) => {
|
|
500
502
|
i.list = this.base.list = b, this.itemHeight = 0;
|
|
501
503
|
},
|
|
502
|
-
wrapperStyle: this.state.windowWidth && this.state.windowWidth >
|
|
503
|
-
wrapperCssClass:
|
|
504
|
+
wrapperStyle: this.state.windowWidth && this.state.windowWidth > W ? { maxHeight: r.height } : {},
|
|
505
|
+
wrapperCssClass: E(
|
|
504
506
|
"k-list-content",
|
|
505
507
|
{
|
|
506
508
|
"k-list-scroller": !l
|
|
@@ -528,9 +530,9 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
528
530
|
data: n = [],
|
|
529
531
|
dataItemKey: d,
|
|
530
532
|
virtual: l = { skip: 0 }
|
|
531
|
-
} = this.props, r = this.props.opened !== void 0 ? this.props.opened : this.state.opened, i = this.value, c = Math.max(0, n.findIndex((p) =>
|
|
532
|
-
return this._suggested && !
|
|
533
|
-
|
|
533
|
+
} = this.props, r = this.props.opened !== void 0 ? this.props.opened : this.state.opened, i = this.value, c = Math.max(0, n.findIndex((p) => S(p, i, d)));
|
|
534
|
+
return this._suggested && !S(this._valueOnDidUpdate, i, d) && (this._suggested = ""), /* @__PURE__ */ h.createElement(
|
|
535
|
+
ce,
|
|
534
536
|
{
|
|
535
537
|
id: e,
|
|
536
538
|
readOnly: r && this.mobileMode,
|
|
@@ -566,15 +568,15 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
566
568
|
}
|
|
567
569
|
triggerOnChange(s, e) {
|
|
568
570
|
const t = this.value;
|
|
569
|
-
!this.hasDuplicates && (!k(t) && !k(s) ||
|
|
571
|
+
!this.hasDuplicates && (!k(t) && !k(s) || S(t, s, this.props.dataItemKey)) || (this.props.value === void 0 && (e.data.value = s), this._valueDuringOnChange = s, e.events.push({ type: "onChange" }));
|
|
570
572
|
}
|
|
571
573
|
getFocusedIndex(s) {
|
|
572
574
|
const e = this.value, { data: t = [], textField: a, dataItemKey: o, virtual: n = { skip: 0 }, focusedItemIndex: d = A, skipDisabledItems: l } = this.props, r = this.props.filter ? this.props.filter : this.state.text;
|
|
573
|
-
return s && this.navigationIndex !== void 0 ? this.navigationIndex : k(e) && r === void 0 ? t.findIndex((i) =>
|
|
575
|
+
return s && this.navigationIndex !== void 0 ? this.navigationIndex : k(e) && r === void 0 ? t.findIndex((i) => S(i, e, o)) : r ? d(t, r, a) : l && a && !r && n.skip === 0 ? t.findIndex((i) => !i.disabled && i[a]) : n.skip === 0 ? 0 : -1;
|
|
574
576
|
}
|
|
575
577
|
suggestValue(s) {
|
|
576
578
|
const { data: e, textField: t } = this.props;
|
|
577
|
-
this._suggested =
|
|
579
|
+
this._suggested = he(s, e, t);
|
|
578
580
|
}
|
|
579
581
|
applyState(s) {
|
|
580
582
|
this.base.applyState(s), this._valueDuringOnChange = void 0;
|
|
@@ -584,8 +586,8 @@ const Se = "Please enter a valid value!", { sizeMap: M, roundedMap: we } = de, w
|
|
|
584
586
|
this.setState({ windowWidth: e.target.clientWidth });
|
|
585
587
|
}
|
|
586
588
|
};
|
|
587
|
-
|
|
588
|
-
...
|
|
589
|
+
D.displayName = "ComboBox", D.propTypes = {
|
|
590
|
+
...V.propTypes,
|
|
589
591
|
size: f.oneOf([null, "small", "medium", "large"]),
|
|
590
592
|
rounded: f.oneOf([null, "small", "medium", "large", "full"]),
|
|
591
593
|
fillMode: f.oneOf([null, "solid", "flat", "outline"]),
|
|
@@ -599,7 +601,7 @@ w.displayName = "ComboBox", w.propTypes = {
|
|
|
599
601
|
allowCustom: f.bool,
|
|
600
602
|
clearButton: f.bool,
|
|
601
603
|
iconClassName: f.string,
|
|
602
|
-
svgIcon:
|
|
604
|
+
svgIcon: ie,
|
|
603
605
|
validationMessage: f.string,
|
|
604
606
|
required: f.bool,
|
|
605
607
|
id: f.string,
|
|
@@ -608,8 +610,8 @@ w.displayName = "ComboBox", w.propTypes = {
|
|
|
608
610
|
list: f.any,
|
|
609
611
|
valueRender: f.func,
|
|
610
612
|
skipDisabledItems: f.bool
|
|
611
|
-
},
|
|
612
|
-
...
|
|
613
|
+
}, D.defaultProps = {
|
|
614
|
+
...V.defaultProps,
|
|
613
615
|
size: "medium",
|
|
614
616
|
rounded: "medium",
|
|
615
617
|
fillMode: "solid",
|
|
@@ -622,11 +624,11 @@ w.displayName = "ComboBox", w.propTypes = {
|
|
|
622
624
|
prefix: void 0,
|
|
623
625
|
suffix: void 0
|
|
624
626
|
};
|
|
625
|
-
let
|
|
626
|
-
const De =
|
|
627
|
+
let B = D;
|
|
628
|
+
const De = ae(), Ee = ne(le(De, B));
|
|
627
629
|
Ee.displayName = "KendoReactComboBox";
|
|
628
630
|
export {
|
|
629
631
|
Ee as ComboBox,
|
|
630
632
|
De as ComboBoxPropsContext,
|
|
631
|
-
|
|
633
|
+
B as ComboBoxWithoutContext
|
|
632
634
|
};
|