@progress/kendo-react-dropdowns 11.2.0-develop.2 → 11.2.0-develop.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ComboBox/ComboBox.js +1 -1
- package/ComboBox/ComboBox.mjs +103 -104
- package/DropDownTree/DropDownTree.js +1 -1
- package/DropDownTree/DropDownTree.mjs +82 -81
- package/DropDownTree/useDropdownWidth.js +1 -1
- package/DropDownTree/useDropdownWidth.mjs +8 -8
- package/MultiColumnComboBox/MultiColumnComboBox.js +1 -1
- package/MultiColumnComboBox/MultiColumnComboBox.mjs +66 -61
- package/MultiSelect/MultiSelect.js +1 -1
- package/MultiSelect/MultiSelect.mjs +12 -15
- package/dist/cdn/js/kendo-react-dropdowns.js +1 -1
- package/index.d.mts +0 -1
- package/index.d.ts +0 -1
- 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 G=require("react"),f=require("prop-types"),E=require("../common/DropDownBase.js"),h=require("@progress/kendo-react-common"),$=require("@progress/kendo-react-labels"),p=require("../common/utils.js"),Y=require("../common/SearchBar.js"),J=require("../common/ListContainer.js"),Q=require("../common/List.js"),X=require("../common/ListFilter.js"),_=require("../common/GroupStickyHeader.js"),Z=require("../package-metadata.js"),ee=require("../common/ClearButton.js"),te=require("@progress/kendo-react-buttons"),se=require("@progress/kendo-svg-icons"),k=require("../messages/index.js"),N=require("@progress/kendo-react-intl"),ie=require("@progress/kendo-react-layout"),K=require("../common/withCustomComponent.js"),oe=require("../common/AdaptiveMode.js");function ae(w){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(w){for(const e in w)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(w,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>w[e]})}}return s.default=w,Object.freeze(s)}const v=ae(G),ne="Please enter a valid value!",S=class S extends v.Component{constructor(s){super(s),this.state={},this.base=new E(this),this._element=null,this._suggested="",this._skipBlur=!1,this._input=null,this._adaptiveFilterInput=null,this._skipFocus=!1,this.itemHeight=0,this.duplicates=[],this.hasDuplicates=!1,this.showLicenseWatermark=!1,this.focus=()=>{this._input&&this._input.focus()},this.checkForDuplicatePlainTextRecords=()=>{const e=this.props.textField!==void 0,t=this.props.dataItemKey!==void 0;if(this.props.data&&this.props.data.length>0&&!e&&!t){const i=this.props.data;this.duplicates=p.getPlainDataDuplicates(i),this.hasDuplicates=this.duplicates.length>0}},this.handleItemSelect=(e,t)=>{const{virtual:i,dataItemKey:r}=this.props,l=p.getFilteredData(this.props),a=i?i.skip:0,d=l[e-a],n=this.hasDuplicates||!p.areSame(d,this.value,r);this.triggerOnChange(d,t),this.state.text!==void 0&&(t.data.text=void 0),n&&this.base.triggerPageChangeCornerItems(d,t)},this.onPopupOpened=()=>{setTimeout(()=>{this.mobileMode&&this._adaptiveFilterInput&&(this._skipBlur=!0,this._adaptiveFilterInput.focus(),this._skipBlur=!1)},300)},this.componentRef=e=>{this._element=e,this.base.wrapper=e},this.toggleBtnClick=e=>{this._skipFocus=!0;const{skipDisabledItems:t,textField:i}=this.props,r=p.getFilteredData(this.props),l=this.getFocusedIndex(),a=this.getCurrentValueDisabledStatus(i,r,l),d=this.props.opened!==void 0?this.props.opened:this.state.opened,n=this.base.initState();if(n.syntheticEvent=e,!t&&i&&a&&this.clearValueOnToggleBtnClick(e),this.base.togglePopup(n),!d&&this.mobileMode){const o=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text||null;this.base.filterChanged(o,n)}this.applyState(n),setTimeout(()=>{this._skipFocus=!1},300)},this.closeOpenedApplyStateNonMobileMode=(e,t)=>{t&&!this.mobileMode&&this.base.togglePopup(e)},this.renderMobileListFilter=()=>{const e=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text,t=p.getItemValue(this.value,this.props.textField),i=p.isPresent(e)?e:t;return v.createElement(X,{value:i,ref:r=>{this._adaptiveFilterInput=r&&r.element},onChange:this.handleMobileFilterChange,onKeyDown:this.onInputKeyDown,size:"large",rounded:this.props.rounded,fillMode:this.props.fillMode,placeholder:this.props.placeholder})},this.listContainerContent=()=>{const{header:e,footer:t,size:i,groupStickyHeaderItemRender:r,groupField:l,list:a,groupMode:d,unstyled:n,virtual:o}=this.props,c=p.getFilteredData(this.props),u=n&&n.uComboBox;let{group:b}=this.state;return b===void 0&&l!==void 0&&(b=p.getItemValue(c[0],l)),v.createElement("div",{className:h.classNames(h.uComboBox.list({c:u,list:a,size:"large",tableSize:i,virtual:o}))},e&&v.createElement("div",{className:h.classNames(h.uComboBox.listHeader({c:u}))},e),!a&&b&&c.length!==0&&v.createElement(_,{group:b,groupMode:d,render:r}),this.renderList(),t&&v.createElement("div",{className:h.classNames(h.uComboBox.listFooter({c:u}),this.props.footerClassName)},t))},this.handleMobileFilterChange=e=>{const t=this.base.initState();t.syntheticEvent=e.syntheticEvent,t.data.text=e.target.value,this.base.filterChanged(e.target.value,t),this.applyState(t)},this.onScroll=e=>{const{vs:t,list:i}=this.base;t.scrollHandler(e);const{groupField:r}=this.props;let l=p.getFilteredData(this.props);if(!r||!l.length)return;const a=this.itemHeight=this.itemHeight||(t.enabled?t.itemHeight:i?i.children[0].offsetHeight:0),n=e.target.scrollTop-t.skip*a;this.props.groupMode==="modern"&&(l=this.base.getGroupedDataModernMode(l,r));let o=l[0][r];for(let c=1;c<l.length&&!(a*c>n);c++)l[c]&&l[c][r]&&(o=l[c][r]);o!==this.state.group&&(this.setState({group:o}),this.props.onGroupScroll&&this.props.onGroupScroll.call(void 0,{group:o}))},this.handleItemClick=(e,t)=>{this.navigationIndex=e,this.base.handleItemClick(e,t),this._valueDuringOnChange=void 0},this.handleBlur=e=>{if(this.state.focused&&!this._skipBlur){const t=this.base.initState(),{textField:i}=this.props,r=p.getFilteredData(this.props),l=this.getFocusedIndex(),d=!(l===-1)&&this.getCurrentValueDisabledStatus(i,r,l);t.data.focused=!1,t.events.push({type:"onBlur"}),t.syntheticEvent=e,i&&d&&this.clearValueOnBlur(e),this.applyValueOnRejectSuggestions(e.currentTarget.value,t)}},this.onInputClick=e=>{const t=this.props.opened!==void 0?this.props.opened:this.state.opened,i=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text||null;if(!t&&this.mobileMode){const r=this.base.initState();r.syntheticEvent=e,this.base.togglePopup(r),this.base.filterChanged(i,r),this.applyState(r)}},this.onInputKeyDown=e=>{const{skipDisabledItems:t,textField:i,dataItemKey:r,groupField:l}=this.props,a=p.getFilteredData(this.props),d=this.value,n=Math.max(0,a.findIndex(g=>p.areSame(g,d,r))),o=e.keyCode,c=this.props.opened!==void 0?this.props.opened:this.state.opened,u=this.base.initState();if(u.syntheticEvent=e,!e.altKey&&(o===h.Keys.up||o===h.Keys.down)){if(e.preventDefault(),l!==""&&i)if(!this.props.skipDisabledItems&&c)this.onNavigate(u,o);else{let g=0;if(o===h.Keys.down||o===h.Keys.right){const m=a.slice(n+1<a.length?n+1:n).find(x=>!x.disabled&&x[i]);g=m&&a.findIndex(x=>x[i]===m[i])}else if(o===h.Keys.up||o===h.Keys.left){let m;if(n===0)m=a,g=a.findIndex(x=>!x.disabled&&x[i]);else{m=a.slice(0,n);let x=m.pop();for(;x&&x.disabled;)x=m.pop();g=x&&a.findIndex(D=>D[i]===x[i])}}if(g!==void 0){const m=g-n;this.onNavigate(u,o,m)}else g===void 0&&a.findIndex(m=>m[i]===d[i])===a.length-1&&this.onNavigate(u,o)}else if(!this.props.skipDisabledItems&&c)this.onNavigate(u,o);else{let g=null;if(o===h.Keys.down||o===h.Keys.right)g=a.slice(n+1).find(m=>!m.disabled);else if(o===h.Keys.up||o===h.Keys.left){const m=a.slice(0,n);for(g=m.pop();g&&g.disabled;)g=m.pop()}if(g){const m=g.id-n-1;this.onNavigate(u,o,m)}else this.onNavigate(u,o)}this.applyState(u)}const b=()=>{e.preventDefault(),this.base.togglePopup(u),this.applyState(u)},I=this.getFocusedIndex(),C=I===-1,y=!C&&this.getCurrentValueDisabledStatus(i,a,I);c?o===h.Keys.pageUp?(e.preventDefault(),this.base.scrollPopupByPageSize(-1)):o===h.Keys.pageDown?(e.preventDefault(),this.base.scrollPopupByPageSize(1)):e.altKey&&o===h.Keys.up?b():o===h.Keys.enter?(e.preventDefault(),(i&&!C&&e.currentTarget.value?a[I][i]:void 0)?!t&&i&&y?this.clearValueOnEnterOrEsc(e):y||this.applyValueOnEnter(e.currentTarget.value,u):this.applyValueOnEnter(e.currentTarget.value,u)):o===h.Keys.esc&&(!t&&i&&y&&this.clearValueOnEnterOrEsc(e),this.applyValueOnRejectSuggestions(e.currentTarget.value,u)):!c&&o===h.Keys.esc?this.clearValueOnEnterOrEsc(e):e.altKey&&o===h.Keys.down&&b()},this.inputOnChange=e=>{const t=this.base.initState();t.syntheticEvent=e;const i=this.props.opened!==void 0?this.props.opened:this.state.opened,r=e.currentTarget,l=r.value;if(this.props.suggest){const a=r.selectionEnd===l.length;let d=this.props.filter!==void 0?this.props.filter:this.state.text;p.isPresent(d)||(d=p.getItemValue(this.value,this.props.textField)||"");const n=d&&d===l,o=d&&d.length>l.length;n||o||!a?this._suggested="":this.suggestValue(l)}this.props.filter===void 0&&(t.data.text=l),this.state.focusedItem!==void 0&&(t.data.focusedItem=void 0),i||this.base.togglePopup(t),this.base.filterChanged(l,t),this.applyState(t),this.setState({group:void 0})},this.clearButtonClick=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.clearValueOnEnterOrEsc=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.clearValueOnBlur=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.clearValueOnToggleBtnClick=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||ne)},this.handleFocus=e=>{if(this._skipFocus)return;const t=this.base.initState();t.syntheticEvent=e,this.mobileMode&&!this._skipFocus&&(this._skipFocus=!0,this.base.togglePopup(t),this.applyState(t),setTimeout(()=>{this._skipFocus=!1},300)),this.base.handleFocus(e)},this.showLicenseWatermark=!h.validatePackage(Z.packageMetadata,{component:"ComboBox"})}get _inputId(){return this.props.id}get document(){if(h.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get mobileMode(){var e;return!!(this.state.windowWidth&&this.props._adaptiveMode&&this.state.windowWidth<=((e=this.props._adaptiveMode)==null?void 0:e.medium)&&this.props.adaptive)}get value(){if(this._valueDuringOnChange!==void 0)return this._valueDuringOnChange;if(this.props.value!==void 0)return this.props.value;if(this.state.value!==void 0)return this.state.value;if(this.props.defaultValue!==void 0)return this.props.defaultValue}get index(){const{dataItemKey:s}=this.props,e=p.getFilteredData(this.props),t=this.value;return e.findIndex(i=>p.areSame(i,t,s))}get name(){return this.props.name}get validity(){const s=this.props.validationMessage!==void 0,e=!this.required||this.value!==null&&this.value!==""&&this.value!==void 0,t=this.props.valid!==void 0?this.props.valid:e;return{customError:s,valid:t,valueMissing:this.value===null}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:S.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:S.defaultProps.required}componentDidUpdate(s,e){var b;const{dataItemKey:t,virtual:i,groupField:r="",textField:l}=this.props,a=p.getFilteredData(this.props),d=s.virtual?s.virtual.total:0,n=this.props.opened!==void 0?this.props.opened:this.state.opened,o=s.opened!==void 0?s.opened:e.opened;s.data!==a&&this.checkForDuplicatePlainTextRecords();const c=!o&&n,u=this.value;if(this._valueOnDidUpdate=u,this.base.didUpdate(),i&&i.total!==d)this.base.vs.calcScrollElementHeight(),this.base.vs.reset();else{const I=s.value!==void 0?s.value:e.value;let C=this.hasDuplicates?this.navigationIndex||0:a.findIndex(g=>p.areSame(g,u,t));this.props.groupMode==="modern"&&l&&u&&(C=(b=this.base.getGroupedDataModernMode(a,r))==null?void 0:b.map(g=>g[l]).indexOf(u[l]));const y=!p.areSame(I,u,t);c&&i?this.base.scrollToVirtualItem(i,C):c&&!i?(this.onPopupOpened(),a&&a.length!==0&&this.base.resetGroupStickyHeader(a[0][r],this),this.base.scrollToItem(C)):(this.hasDuplicates||n&&o&&u&&y)&&this.base.scrollToItem(C)}c&&this._input&&this._input.focus(),this.setValidity()}componentDidMount(){var s;this.observerResize=h.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.observe(this.document.body),this.checkForDuplicatePlainTextRecords()}componentWillUnmount(){var s;(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.disconnect()}render(){const s=N.provideLocalizationService(this).toLanguageString(k.comboArrowBtnAriaLabelExpand,k.messages[k.comboArrowBtnAriaLabelExpand]),e=N.provideLocalizationService(this).toLanguageString(k.comboArrowBtnAriaLabelCollapse,k.messages[k.comboArrowBtnAriaLabelCollapse]),{dir:t,disabled:i,clearButton:r=S.defaultProps.clearButton,label:l,textField:a,className:d,style:n,loading:o,iconClassName:c,virtual:u,size:b,rounded:I,fillMode:C,opened:y=this.state.opened,placeholder:g,svgIcon:m,unstyled:x}=this.props,D=!this.validityStyles||this.validity.valid,F=this.props.filter!==void 0?this.props.filter:this.state.text,q=p.getItemValue(this.value,a),O=p.isPresent(F)?F:q,A=r&&(!!O||p.isPresent(this.value)),B=this.base.vs,P=this.props.id||this._inputId,V=x&&x.uComboBox;B.enabled=u!==void 0,u!==void 0&&(B.skip=u.skip,B.total=u.total,B.pageSize=u.pageSize);const[z,H]=K(this.props.prefix||v.Fragment),[W,j]=K(this.props.suffix||v.Fragment),T=v.createElement(v.Fragment,null,v.createElement("span",{className:h.classNames(h.uComboBox.wrapper({c:V,size:b,rounded:I,fillMode:C,disabled:i,invalid:!D,loading:o,required:this.required}),d),ref:this.componentRef,style:l?{...n,width:void 0}:n,dir:t,onFocus:this.handleFocus},this.props.prefix&&v.createElement(z,{...H}),this.renderSearchBar(O||"",P,g),A&&!o&&v.createElement(ee,{onClick:this.clearButtonClick,key:"clearbutton"}),o&&v.createElement(h.IconWrap,{className:h.classNames(h.uComboBox.loadingIcon({c:V})),name:"loading",key:"loading"}),this.props.suffix&&v.createElement(W,{...j}),v.createElement(te.Button,{tabIndex:-1,type:"button","aria-label":y?e:s,icon:c?void 0:"caret-alt-down",svgIcon:m||se.caretAltDownIcon,iconClass:c,size:b,fillMode:C,rounded:null,themeColor:"base",className:h.classNames(h.uComboBox.inputButton({c:V})),onClick:this.toggleBtnClick,onMouseDown:U=>U.preventDefault()}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return l?v.createElement($.FloatingLabel,{label:l,editorId:P,editorValue:O,editorValid:D,editorDisabled:i,style:{width:n?n.width:void 0},children:T,unstyled:x}):T}onNavigate(s,e,t){const{virtual:i={skip:0}}=this.props,r=p.getFilteredData(this.props),l=this.props.filter?this.props.filter:this.state.text;let a=-1,d;const n=this.base.vs,o=this.value;this._suggested="";const c=this.hasDuplicates&&this.duplicates.indexOf(o)!==-1;if(a=this.getFocusedIndex(c),a!==-1&&!p.isPresent(o))this.handleItemSelect(a,s);else if(l==="")this.handleItemSelect(0,s);else{const u=i.skip+a;d=this.base.navigation.navigate({keyCode:e,current:u,max:(n.enabled?n.total:r.length)-1,min:0,skipItems:t||void 0}),d!==void 0&&this.handleItemSelect(d,s)}this.navigationIndex=d}getCurrentValueDisabledStatus(s,e,t){return s&&e&&e[t]&&e[t].disabled}applyValueOnEnter(s,e){const{textField:t,allowCustom:i}=this.props,r=p.getFilteredData(this.props),l=this.props.opened!==void 0?this.props.opened:this.state.opened,d=p.getItemValue(this.value,t)===s?this.index:p.getItemIndexByText(r,s,t),n=d!==-1;let o;if(this._suggested="",n)o=r[d];else if(i)o=t!==void 0?{[t]:s}:s;else return this.selectFocusedItem(s,e);this.triggerOnChange(o,e),l&&this.base.togglePopup(e),this.props.filter===void 0&&this.state.text!==void 0&&(e.data.text=void 0),this.applyState(e)}applyValueOnRejectSuggestions(s,e){const{textField:t,allowCustom:i}=this.props,r=p.getFilteredData(this.props),l=this.props.opened!==void 0?this.props.opened:this.state.opened,a=p.getItemValue(this.value,t);if(this._suggested="",s===a||s===""&&!p.isPresent(a))return this.closeOpenedApplyStateNonMobileMode(e,l),this.applyState(e);const d=p.getItemIndexByText(r,s,t,!0),n=d!==-1;let o=null;n?o=r[d]:i&&(o=s?t?{[t]:s}:s:null),this.triggerOnChange(o,e),this.state.text!==void 0&&(e.data.text=void 0,this.base.filterChanged("",e)),this.closeOpenedApplyStateNonMobileMode(e,l),this.applyState(e)}selectFocusedItem(s,e){const t=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:i,virtual:r={skip:0},focusedItemIndex:l=p.itemIndexStartsWith}=this.props,a=p.getFilteredData(this.props),d=r.skip,n=s===""&&d===0?0:l(a,s,i);return n!==-1?this.handleItemSelect(n+d,e):(this.triggerOnChange(null,e),this.state.text!==void 0&&(e.data.text=void 0)),t&&this.base.togglePopup(e),this.applyState(e)}renderAdaptiveListContainer(){const{windowWidth:s=0}=this.state,{groupField:e,adaptiveTitle:t=this.props.label,adaptiveSubtitle:i}=this.props,r=p.getFilteredData(this.props),l=this.props.opened!==void 0?this.props.opened:this.state.opened;let{group:a}=this.state;a===void 0&&e!==void 0&&(a=p.getItemValue(r[0],e));const d={title:t||this.props.label,subTitle:i,expand:l,onClose:n=>this.toggleBtnClick(n),windowWidth:s,mobileFilter:this.renderMobileListFilter()};return v.createElement(oe.AdaptiveMode,{...d},v.createElement(ie.ActionSheetContent,null,v.createElement("div",{className:"k-list-container"},this.listContainerContent())))}renderListContainer(){const s=this.base,{dir:e,header:t,footer:i,groupField:r,groupMode:l,size:a,list:d,virtual:n,groupStickyHeaderItemRender:o,unstyled:c}=this.props,u=p.getFilteredData(this.props),b=this.props.opened!==void 0?this.props.opened:this.state.opened,I=s.getPopupSettings(),C=I.width!==void 0?I.width:s.popupWidth,y=c&&c.uComboBox;let{group:g}=this.state;return g===void 0&&r!==void 0&&(g=p.getItemValue(u[0],r)),v.createElement(J,{width:C,popupSettings:{...I,anchor:I.anchor||this.element,show:b,popupClass:h.classNames(I.popupClass,h.uComboBox.listContainer({c:y,popup:!0}))},dir:e!==void 0?e:this.base.dirCalculated,itemsCount:[u.length]},v.createElement("div",{className:h.classNames(h.uComboBox.list({c:y,list:d,size:a,tableSize:a,virtual:n}))},t&&v.createElement("div",{className:h.classNames(h.uComboBox.listHeader({c:y}))},t),!d&&g&&u.length!==0&&v.createElement(_,{group:g,groupMode:l,render:o}),this.renderList(),i&&v.createElement("div",{className:h.classNames(h.uComboBox.listFooter({c:y}),this.props.footerClassName)},i)),this.showLicenseWatermark&&v.createElement(h.WatermarkOverlay,null))}renderList(){const s=this.base,{textField:e,dataItemKey:t,listNoDataRender:i,itemRender:r,groupHeaderItemRender:l,virtual:a={skip:0,total:void 0},unstyled:d}=this.props,n=p.getFilteredData(this.props),o=s.getPopupSettings(),c=s.vs,u=a.skip,b=this.props.opened!==void 0?this.props.opened:this.state.opened,I=`translateY(${c.translate}px)`,C=b?this.getFocusedIndex(this.hasDuplicates):void 0,y=this.props.filter!==void 0?this.props.filter:this.state.text,g=p.getItemValue(this.value,e),m=p.isPresent(y)&&y!==g?null:this.value,x=this.props.list||Q,D=d&&d.uComboBox;return v.createElement(x,{id:s.listBoxId,virtual:!!a,show:b,data:n,focusedIndex:C,value:m,textField:e,valueField:t,groupField:this.props.groupField,groupMode:this.props.groupMode,isMultiColumn:this.props.isMultiColumn,optionsGuid:s.guid,hasDuplicates:this.hasDuplicates,listRef:F=>{c.list=this.base.list=F,this.itemHeight=0},wrapperStyle:this.state.windowWidth&&this.props._adaptiveMode&&this.state.windowWidth>this.props._adaptiveMode.medium?{maxHeight:o.height}:{},wrapperCssClass:h.classNames(h.uComboBox.listContent({c:D,virtual:a})),listStyle:c.enabled?{transform:I}:void 0,key:"listkey",skip:u,onClick:this.handleItemClick,itemRender:r,groupHeaderItemRender:l,noDataRender:i,onMouseDown:F=>F.preventDefault(),onScroll:this.onScroll,wrapperRef:c.scrollerRef,scroller:this.base.renderScrollElement(),ariaSetSize:a.total})}renderSearchBar(s,e,t){const{tabIndex:i,disabled:r,title:l,ariaLabelledBy:a,ariaDescribedBy:d,dataItemKey:n,virtual:o={skip:0},accessKey:c,unstyled:u,inputAttributes:b}=this.props,I=p.getFilteredData(this.props),C=this.props.opened!==void 0?this.props.opened:this.state.opened,y=this.value,g=Math.max(0,I.findIndex(m=>p.areSame(m,y,n)));return this._suggested&&!p.areSame(this._valueOnDidUpdate,y,n)&&(this._suggested=""),v.createElement(Y,{id:e,readOnly:C&&this.mobileMode,placeholder:t,tabIndex:i,title:l,value:s+this._suggested,suggestedText:this._suggested,ref:m=>{this._input=m&&m.input},onClick:this.onInputClick,onKeyDown:this.onInputKeyDown,onChange:this.inputOnChange,onFocus:this.base.handleFocus,onBlur:this.handleBlur,disabled:r,expanded:C,owns:this.base.listBoxId,activedescendant:`option-${this.base.guid}-${g+o.skip}`,role:"combobox",ariaLabelledBy:a,ariaLabel:this.props.ariaLabel,ariaDescribedBy:d,ariaRequired:this.required,render:this.props.valueRender,ariaControls:this.base.listBoxId,unstyled:u,inputAttributes:b})}clearValue(){const s=this.base.initState();this._suggested="",this.navigationIndex=void 0,this.base.filterChanged("",s),this.props.filter===void 0&&this.state.text!==void 0&&(s.data.text=void 0),this.triggerOnChange(null,s);const e=this.props.opened!==void 0?this.props.opened:this.state.opened,t=this.mobileMode;e&&!t&&this.base.togglePopup(s),this.applyState(s)}triggerOnChange(s,e){const t=this.value;!this.hasDuplicates&&(!p.isPresent(t)&&!p.isPresent(s)||p.areSame(t,s,this.props.dataItemKey))||(this.props.value===void 0&&(e.data.value=s),this._valueDuringOnChange=s,e.events.push({type:"onChange"}))}getFocusedIndex(s){const e=this.value,{textField:t,dataItemKey:i,virtual:r={skip:0},focusedItemIndex:l=p.itemIndexStartsWith,skipDisabledItems:a}=this.props,d=p.getFilteredData(this.props),n=this.props.filter?this.props.filter:this.state.text;return s&&this.navigationIndex!==void 0?this.navigationIndex:p.isPresent(e)&&n===void 0?d.findIndex(o=>p.areSame(o,e,i)):n?l(d,n,t):a&&t&&!n&&r.skip===0?d.findIndex(o=>!o.disabled&&o[t]):r.skip===0?0:-1}suggestValue(s){const{data:e,textField:t}=this.props;this._suggested=p.suggestValue(s,e,t)}applyState(s){this.base.applyState(s),this._valueDuringOnChange=void 0}calculateMedia(s){for(const e of s)this.setState({windowWidth:e.target.clientWidth})}};S.displayName="ComboBox",S.propTypes={...E.propTypes,size:f.oneOf([null,"small","medium","large"]),rounded:f.oneOf([null,"small","medium","large","full"]),fillMode:f.oneOf([null,"solid","flat","outline"]),dataItemKey:f.string,groupField:f.string,groupMode:f.oneOf([void 0,"classic","modern"]),isMultiColumn:f.bool,suggest:f.bool,placeholder:f.string,title:f.string,allowCustom:f.bool,clearButton:f.bool,iconClassName:f.string,svgIcon:h.svgIconPropType,validationMessage:f.string,required:f.bool,id:f.string,ariaLabelledBy:f.string,ariaLabel:f.string,ariaDescribedBy:f.string,list:f.any,valueRender:f.func,skipDisabledItems:f.bool,inputAttributes:f.object},S.defaultProps={...E.defaultProps,size:"medium",rounded:"medium",fillMode:"solid",allowCustom:!1,clearButton:!0,required:!1,groupMode:"modern",isMultiColumn:!1,skipDisabledItems:!0,prefix:void 0,suffix:void 0};let M=S;const L=h.createPropsContext(),R=h.withIdHOC(h.withPropsContext(L,h.withUnstyledHOC(h.withAdaptiveModeContext(M))));R.displayName="KendoReactComboBox";exports.ComboBox=R;exports.ComboBoxPropsContext=L;exports.ComboBoxWithoutContext=M;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("react"),f=require("prop-types"),E=require("../common/DropDownBase.js"),h=require("@progress/kendo-react-common"),$=require("@progress/kendo-react-labels"),p=require("../common/utils.js"),Y=require("../common/SearchBar.js"),J=require("../common/ListContainer.js"),Q=require("../common/List.js"),X=require("../common/ListFilter.js"),_=require("../common/GroupStickyHeader.js"),Z=require("../package-metadata.js"),ee=require("../common/ClearButton.js"),te=require("@progress/kendo-react-buttons"),se=require("@progress/kendo-svg-icons"),k=require("../messages/index.js"),N=require("@progress/kendo-react-intl"),ie=require("@progress/kendo-react-layout"),K=require("../common/withCustomComponent.js"),oe=require("../common/AdaptiveMode.js");function ae(w){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(w){for(const e in w)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(w,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>w[e]})}}return s.default=w,Object.freeze(s)}const m=ae(G),ne="Please enter a valid value!",S=class S extends m.Component{constructor(s){super(s),this.state={},this.base=new E(this),this._element=null,this._suggested="",this._skipBlur=!1,this._input=null,this._adaptiveFilterInput=null,this._skipFocus=!1,this.itemHeight=0,this.duplicates=[],this.hasDuplicates=!1,this.showLicenseWatermark=!1,this.focus=()=>{this._input&&this._input.focus()},this.checkForDuplicatePlainTextRecords=()=>{const e=this.props.textField!==void 0,t=this.props.dataItemKey!==void 0;if(this.props.data&&this.props.data.length>0&&!e&&!t){const i=this.props.data;this.duplicates=p.getPlainDataDuplicates(i),this.hasDuplicates=this.duplicates.length>0}},this.handleItemSelect=(e,t)=>{const{virtual:i,dataItemKey:r}=this.props,l=p.getFilteredData(this.props),a=i?i.skip:0,d=l[e-a],n=this.hasDuplicates||!p.areSame(d,this.value,r);this.triggerOnChange(d,t),this.state.text!==void 0&&(t.data.text=void 0),n&&this.base.triggerPageChangeCornerItems(d,t)},this.onPopupOpened=()=>{setTimeout(()=>{this.mobileMode&&this._adaptiveFilterInput&&(this._skipBlur=!0,this._adaptiveFilterInput.focus(),this._skipBlur=!1)},300)},this.componentRef=e=>{this._element=e,this.base.wrapper=e},this.toggleBtnClick=e=>{this._skipFocus=!0;const{skipDisabledItems:t,textField:i}=this.props,r=p.getFilteredData(this.props),l=this.getFocusedIndex(),a=this.getCurrentValueDisabledStatus(i,r,l),d=this.props.opened!==void 0?this.props.opened:this.state.opened,n=this.base.initState();if(n.syntheticEvent=e,!t&&i&&a&&this.clearValueOnToggleBtnClick(e),this.base.togglePopup(n),!d&&this.mobileMode){const o=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text||null;this.base.filterChanged(o,n)}this.applyState(n),setTimeout(()=>{this._skipFocus=!1},300)},this.closeOpenedApplyStateNonMobileMode=(e,t)=>{t&&!this.mobileMode&&this.base.togglePopup(e)},this.renderMobileListFilter=()=>{const e=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text,t=p.getItemValue(this.value,this.props.textField),i=p.isPresent(e)?e:t;return m.createElement(X,{value:i,ref:r=>{this._adaptiveFilterInput=r&&r.element},onChange:this.handleMobileFilterChange,onKeyDown:this.onInputKeyDown,size:"large",rounded:this.props.rounded,fillMode:this.props.fillMode,placeholder:this.props.placeholder})},this.listContainerContent=()=>{const{header:e,footer:t,size:i,groupStickyHeaderItemRender:r,groupField:l,list:a,groupMode:d,unstyled:n,virtual:o}=this.props,g=p.getFilteredData(this.props),u=n&&n.uComboBox;let{group:b}=this.state;return b===void 0&&l!==void 0&&(b=p.getItemValue(g[0],l)),m.createElement("div",{className:h.classNames(h.uComboBox.list({c:u,list:a,size:"large",tableSize:i,virtual:o}))},e&&m.createElement("div",{className:h.classNames(h.uComboBox.listHeader({c:u}))},e),!a&&b&&g.length!==0&&m.createElement(_,{group:b,groupMode:d,render:r}),this.renderList(),t&&m.createElement("div",{className:h.classNames(h.uComboBox.listFooter({c:u}),this.props.footerClassName)},t))},this.handleMobileFilterChange=e=>{const t=this.base.initState();t.syntheticEvent=e.syntheticEvent,t.data.text=e.target.value,this.base.filterChanged(e.target.value,t),this.applyState(t)},this.onScroll=e=>{const{vs:t,list:i}=this.base;t.scrollHandler(e);const{groupField:r}=this.props;let l=p.getFilteredData(this.props);if(!r||!l.length)return;const a=this.itemHeight=this.itemHeight||(t.enabled?t.itemHeight:i?i.children[0].offsetHeight:0),n=e.target.scrollTop-t.skip*a;this.props.groupMode==="modern"&&(l=this.base.getGroupedDataModernMode(l,r));let o=l[0][r];for(let g=1;g<l.length&&!(a*g>n);g++)l[g]&&l[g][r]&&(o=l[g][r]);o!==this.state.group&&(this.setState({group:o}),this.props.onGroupScroll&&this.props.onGroupScroll.call(void 0,{group:o}))},this.handleItemClick=(e,t)=>{this.navigationIndex=e,this.base.handleItemClick(e,t),this._valueDuringOnChange=void 0},this.handleBlur=e=>{if(this.state.focused&&!this._skipBlur){const t=this.base.initState(),{textField:i}=this.props,r=p.getFilteredData(this.props),l=this.getFocusedIndex(),d=!(l===-1)&&this.getCurrentValueDisabledStatus(i,r,l);t.data.focused=!1,t.events.push({type:"onBlur"}),t.syntheticEvent=e,i&&d&&this.clearValueOnBlur(e),this.applyValueOnRejectSuggestions(e.currentTarget.value,t)}},this.onInputClick=e=>{const t=this.props.opened!==void 0?this.props.opened:this.state.opened,i=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text||null;if(!t&&this.mobileMode){const r=this.base.initState();r.syntheticEvent=e,this.base.togglePopup(r),this.base.filterChanged(i,r),this.applyState(r)}},this.onInputKeyDown=e=>{const{skipDisabledItems:t,textField:i,dataItemKey:r,groupField:l}=this.props,a=p.getFilteredData(this.props),d=this.value,n=Math.max(0,a.findIndex(c=>p.areSame(c,d,r))),o=e.keyCode,g=this.props.opened!==void 0?this.props.opened:this.state.opened,u=this.base.initState();if(u.syntheticEvent=e,!e.altKey&&(o===h.Keys.up||o===h.Keys.down)){if(e.preventDefault(),l!==""&&i)if(!this.props.skipDisabledItems&&g)this.onNavigate(u,o);else{let c=0;if(o===h.Keys.down||o===h.Keys.right){const v=a.slice(n+1<a.length?n+1:n).find(x=>!x.disabled&&x[i]);c=v&&a.findIndex(x=>x[i]===v[i])}else if(o===h.Keys.up||o===h.Keys.left){let v;if(n===0)v=a,c=a.findIndex(x=>!x.disabled&&x[i]);else{v=a.slice(0,n);let x=v.pop();for(;x&&x.disabled;)x=v.pop();c=x&&a.findIndex(D=>D[i]===x[i])}}if(c!==void 0){const v=c-n;this.onNavigate(u,o,v)}else c===void 0&&a.findIndex(v=>v[i]===d[i])===a.length-1&&this.onNavigate(u,o)}else if(!this.props.skipDisabledItems&&g)this.onNavigate(u,o);else{let c=null;if(o===h.Keys.down||o===h.Keys.right)c=a.slice(n+1).find(v=>!v.disabled);else if(o===h.Keys.up||o===h.Keys.left){const v=a.slice(0,n);for(c=v.pop();c&&c.disabled;)c=v.pop()}if(c){const v=c.id-n-1;this.onNavigate(u,o,v)}else this.onNavigate(u,o)}this.applyState(u)}const b=()=>{e.preventDefault(),this.base.togglePopup(u),this.applyState(u)},y=this.getFocusedIndex(),I=y===-1,C=!I&&this.getCurrentValueDisabledStatus(i,a,y);g?o===h.Keys.pageUp?(e.preventDefault(),this.base.scrollPopupByPageSize(-1)):o===h.Keys.pageDown?(e.preventDefault(),this.base.scrollPopupByPageSize(1)):e.altKey&&o===h.Keys.up?b():o===h.Keys.enter?(e.preventDefault(),(i&&!I&&e.currentTarget.value?a[y][i]:void 0)?!t&&i&&C?this.clearValueOnEnterOrEsc(e):C||this.applyValueOnEnter(e.currentTarget.value,u):this.applyValueOnEnter(e.currentTarget.value,u)):o===h.Keys.esc&&(!t&&i&&C&&this.clearValueOnEnterOrEsc(e),this.applyValueOnRejectSuggestions(e.currentTarget.value,u)):!g&&o===h.Keys.esc?this.clearValueOnEnterOrEsc(e):e.altKey&&o===h.Keys.down&&b()},this.inputOnChange=e=>{const t=this.base.initState();t.syntheticEvent=e;const i=this.props.opened!==void 0?this.props.opened:this.state.opened,r=e.currentTarget,l=r.value;if(this.props.suggest){const a=r.selectionEnd===l.length;let d=this.props.filter!==void 0?this.props.filter:this.state.text;p.isPresent(d)||(d=p.getItemValue(this.value,this.props.textField)||"");const n=d&&d===l,o=d&&d.length>l.length;n||o||!a?this._suggested="":this.suggestValue(l)}this.props.filter===void 0&&(t.data.text=l),this.state.focusedItem!==void 0&&(t.data.focusedItem=void 0),i||this.base.togglePopup(t),this.base.filterChanged(l,t),this.applyState(t),this.setState({group:void 0})},this.clearButtonClick=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.clearValueOnEnterOrEsc=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.clearValueOnBlur=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.clearValueOnToggleBtnClick=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.clearValue()},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||ne)},this.handleFocus=e=>{if(this._skipFocus)return;const t=this.base.initState();t.syntheticEvent=e,this.mobileMode&&!this._skipFocus&&(this._skipFocus=!0,this.base.togglePopup(t),this.applyState(t),setTimeout(()=>{this._skipFocus=!1},300)),this.base.handleFocus(e)},this.showLicenseWatermark=!h.validatePackage(Z.packageMetadata,{component:"ComboBox"})}get _inputId(){return this.props.id}get document(){if(h.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get mobileMode(){var e;return!!(this.state.windowWidth&&this.props._adaptiveMode&&this.state.windowWidth<=((e=this.props._adaptiveMode)==null?void 0:e.medium)&&this.props.adaptive)}get value(){if(this._valueDuringOnChange!==void 0)return this._valueDuringOnChange;if(this.props.value!==void 0)return this.props.value;if(this.state.value!==void 0)return this.state.value;if(this.props.defaultValue!==void 0)return this.props.defaultValue}get index(){const{dataItemKey:s}=this.props,e=p.getFilteredData(this.props),t=this.value;return e.findIndex(i=>p.areSame(i,t,s))}get name(){return this.props.name}get validity(){const s=this.props.validationMessage!==void 0,e=!this.required||this.value!==null&&this.value!==""&&this.value!==void 0,t=this.props.valid!==void 0?this.props.valid:e;return{customError:s,valid:t,valueMissing:this.value===null}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:S.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:S.defaultProps.required}componentDidUpdate(s,e){var b;const{dataItemKey:t,virtual:i,groupField:r="",textField:l}=this.props,a=p.getFilteredData(this.props),d=s.virtual?s.virtual.total:0,n=this.props.opened!==void 0?this.props.opened:this.state.opened,o=s.opened!==void 0?s.opened:e.opened;s.data!==a&&this.checkForDuplicatePlainTextRecords();const g=!o&&n,u=this.value;if(this._valueOnDidUpdate=u,this.base.didUpdate(),i&&i.total!==d)this.base.vs.calcScrollElementHeight(),this.base.vs.reset();else{const y=s.value!==void 0?s.value:e.value;let I=this.hasDuplicates?this.navigationIndex||0:a.findIndex(c=>p.areSame(c,u,t));this.props.groupMode==="modern"&&l&&u&&(I=(b=this.base.getGroupedDataModernMode(a,r))==null?void 0:b.map(c=>c[l]).indexOf(u[l]));const C=!p.areSame(y,u,t);g&&i?this.base.scrollToVirtualItem(i,I):g&&!i?(this.onPopupOpened(),a&&a.length!==0&&this.base.resetGroupStickyHeader(a[0][r],this),this.base.scrollToItem(I)):(this.hasDuplicates||n&&o&&u&&C)&&this.base.scrollToItem(I)}g&&this._input&&this._input.focus(),this.setValidity()}componentDidMount(){var s;this.observerResize=h.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.observe(this.document.body),this.checkForDuplicatePlainTextRecords()}componentWillUnmount(){var s;(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.disconnect()}render(){const s=N.provideLocalizationService(this).toLanguageString(k.comboArrowBtnAriaLabelExpand,k.messages[k.comboArrowBtnAriaLabelExpand]),e=N.provideLocalizationService(this).toLanguageString(k.comboArrowBtnAriaLabelCollapse,k.messages[k.comboArrowBtnAriaLabelCollapse]),{dir:t,disabled:i,clearButton:r=S.defaultProps.clearButton,label:l,textField:a,className:d,style:n,loading:o,iconClassName:g,virtual:u,size:b,rounded:y,fillMode:I,opened:C=this.state.opened,placeholder:c,svgIcon:v,unstyled:x}=this.props,D=!this.validityStyles||this.validity.valid,F=this.props.filter!==void 0?this.props.filter:this.state.text,q=p.getItemValue(this.value,a),O=p.isPresent(F)?F:q,A=r&&(!!O||p.isPresent(this.value)),B=this.base.vs,P=this.props.id||this._inputId,V=x&&x.uComboBox;B.enabled=u!==void 0,u!==void 0&&(B.skip=u.skip,B.total=u.total,B.pageSize=u.pageSize);const[z,H]=K(this.props.prefix||m.Fragment),[W,j]=K(this.props.suffix||m.Fragment),T=m.createElement(m.Fragment,null,m.createElement("span",{className:h.classNames(h.uComboBox.wrapper({c:V,size:b,rounded:y,fillMode:I,disabled:i,invalid:!D,loading:o,required:this.required}),d),ref:this.componentRef,style:l?{...n,width:void 0}:n,dir:t,onFocus:this.handleFocus},this.props.prefix&&m.createElement(z,{...H}),this.renderSearchBar(O||"",P,c),A&&!o&&m.createElement(ee,{onClick:this.clearButtonClick,key:"clearbutton"}),o&&m.createElement(h.IconWrap,{className:h.classNames(h.uComboBox.loadingIcon({c:V})),name:"loading",key:"loading"}),this.props.suffix&&m.createElement(W,{...j}),m.createElement(te.Button,{tabIndex:-1,type:"button","aria-label":C?e:s,icon:g?void 0:"caret-alt-down",svgIcon:v||se.caretAltDownIcon,iconClass:g,size:b,fillMode:I,rounded:null,themeColor:"base",className:h.classNames(h.uComboBox.inputButton({c:V})),onClick:this.toggleBtnClick,onMouseDown:U=>U.preventDefault()}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return l?m.createElement($.FloatingLabel,{label:l,editorId:P,editorValue:O,editorValid:D,editorDisabled:i,style:{width:n?n.width:void 0},children:T,unstyled:x}):T}onNavigate(s,e,t){const{virtual:i={skip:0}}=this.props,r=p.getFilteredData(this.props),l=this.props.filter?this.props.filter:this.state.text;let a=-1,d;const n=this.base.vs,o=this.value;this._suggested="";const g=this.hasDuplicates&&this.duplicates.indexOf(o)!==-1;if(a=this.getFocusedIndex(g),a!==-1&&!p.isPresent(o))this.handleItemSelect(a,s);else if(l==="")this.handleItemSelect(0,s);else{const u=i.skip+a;d=this.base.navigation.navigate({keyCode:e,current:u,max:(n.enabled?n.total:r.length)-1,min:0,skipItems:t||void 0}),d!==void 0&&this.handleItemSelect(d,s)}this.navigationIndex=d}getCurrentValueDisabledStatus(s,e,t){return s&&e&&e[t]&&e[t].disabled}applyValueOnEnter(s,e){const{textField:t,allowCustom:i}=this.props,r=p.getFilteredData(this.props),l=this.props.opened!==void 0?this.props.opened:this.state.opened,d=p.getItemValue(this.value,t)===s?this.index:p.getItemIndexByText(r,s,t),n=d!==-1;let o;if(this._suggested="",n)o=r[d];else if(i)o=t!==void 0?{[t]:s}:s;else return this.selectFocusedItem(s,e);this.triggerOnChange(o,e),l&&this.base.togglePopup(e),this.props.filter===void 0&&this.state.text!==void 0&&(e.data.text=void 0),this.applyState(e)}applyValueOnRejectSuggestions(s,e){const{textField:t,allowCustom:i}=this.props,r=p.getFilteredData(this.props),l=this.props.opened!==void 0?this.props.opened:this.state.opened,a=p.getItemValue(this.value,t);if(this._suggested="",s===a||s===""&&!p.isPresent(a))return this.closeOpenedApplyStateNonMobileMode(e,l),this.applyState(e);const d=p.getItemIndexByText(r,s,t,!0),n=d!==-1;let o=null;n?o=r[d]:i&&(o=s?t?{[t]:s}:s:null),this.triggerOnChange(o,e),this.state.text!==void 0&&(e.data.text=void 0,this.base.filterChanged("",e)),this.closeOpenedApplyStateNonMobileMode(e,l),this.applyState(e)}selectFocusedItem(s,e){const t=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:i,virtual:r={skip:0},focusedItemIndex:l=p.itemIndexStartsWith}=this.props,a=p.getFilteredData(this.props),d=r.skip,n=s===""&&d===0?0:l(a,s,i);return n!==-1?this.handleItemSelect(n+d,e):(this.triggerOnChange(null,e),this.state.text!==void 0&&(e.data.text=void 0)),t&&this.base.togglePopup(e),this.applyState(e)}renderAdaptiveListContainer(){const{windowWidth:s=0}=this.state,{groupField:e,adaptiveTitle:t=this.props.label,adaptiveSubtitle:i}=this.props,r=p.getFilteredData(this.props),l=this.props.opened!==void 0?this.props.opened:this.state.opened;let{group:a}=this.state;a===void 0&&e!==void 0&&(a=p.getItemValue(r[0],e));const d={title:t||this.props.label,subTitle:i,expand:l,onClose:n=>this.toggleBtnClick(n),windowWidth:s,mobileFilter:this.renderMobileListFilter()};return m.createElement(oe.AdaptiveMode,{...d},m.createElement(ie.ActionSheetContent,null,m.createElement("div",{className:"k-list-container"},this.listContainerContent())))}renderListContainer(){const s=this.base,{dir:e,header:t,footer:i,groupField:r,groupMode:l,size:a,list:d,virtual:n,groupStickyHeaderItemRender:o,unstyled:g}=this.props,u=p.getFilteredData(this.props),b=this.props.opened!==void 0?this.props.opened:this.state.opened,y=s.getPopupSettings(),I=y.width!==void 0?y.width:s.popupWidth,C=g&&g.uComboBox;let{group:c}=this.state;return c===void 0&&r!==void 0&&(c=p.getItemValue(u[0],r)),m.createElement(J,{width:I,popupSettings:{...y,anchor:y.anchor||this.element,show:b,popupClass:h.classNames(y.popupClass,h.uComboBox.listContainer({c:C,popup:!0}))},dir:e!==void 0?e:this.base.dirCalculated,itemsCount:[u.length]},m.createElement("div",{className:h.classNames(h.uComboBox.list({c:C,list:d,size:a,tableSize:a,virtual:n}))},t&&m.createElement("div",{className:h.classNames(h.uComboBox.listHeader({c:C}))},t),!d&&c&&u.length!==0&&m.createElement(_,{group:c,groupMode:l,render:o}),this.renderList(),i&&m.createElement("div",{className:h.classNames(h.uComboBox.listFooter({c:C}),this.props.footerClassName)},i)),this.showLicenseWatermark&&m.createElement(h.WatermarkOverlay,null))}renderList(){const s=this.base,{textField:e,dataItemKey:t,listNoDataRender:i,itemRender:r,groupHeaderItemRender:l,virtual:a={skip:0,total:void 0},unstyled:d}=this.props,n=p.getFilteredData(this.props),o=s.getPopupSettings(),g=s.vs,u=a.skip,b=this.props.opened!==void 0?this.props.opened:this.state.opened,y=`translateY(${g.translate}px)`,I=b?this.getFocusedIndex(this.hasDuplicates):void 0,C=this.props.filter!==void 0?this.props.filter:this.state.text,c=p.getItemValue(this.value,e),v=p.isPresent(C)&&C!==c?null:this.value,x=this.props.list||Q,D=d&&d.uComboBox;return m.createElement(x,{id:s.listBoxId,virtual:!!a,show:b,data:n,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:F=>{g.list=this.base.list=F,this.itemHeight=0},wrapperStyle:this.state.windowWidth&&this.props._adaptiveMode&&this.state.windowWidth>this.props._adaptiveMode.medium?{maxHeight:o.height}:{},wrapperCssClass:h.classNames(h.uComboBox.listContent({c:D,virtual:a})),listStyle:g.enabled?{transform:y}:void 0,key:"listkey",skip:u,onClick:this.handleItemClick,itemRender:r,groupHeaderItemRender:l,noDataRender:i,onMouseDown:F=>F.preventDefault(),onScroll:this.onScroll,wrapperRef:g.scrollerRef,scroller:this.base.renderScrollElement(),ariaSetSize:a.total})}renderSearchBar(s,e,t){const{tabIndex:i,disabled:r,title:l,ariaLabelledBy:a,ariaDescribedBy:d,dataItemKey:n,virtual:o={skip:0},unstyled:g,inputAttributes:u}=this.props,b=p.getFilteredData(this.props),y=this.props.opened!==void 0?this.props.opened:this.state.opened,I=this.value,C=Math.max(0,b.findIndex(c=>p.areSame(c,I,n)));return this._suggested&&!p.areSame(this._valueOnDidUpdate,I,n)&&(this._suggested=""),m.createElement(Y,{id:e,readOnly:y&&this.mobileMode,placeholder:t,tabIndex:i,title:l,value:s+this._suggested,suggestedText:this._suggested,ref:c=>{this._input=c&&c.input},onClick:this.onInputClick,onKeyDown:this.onInputKeyDown,onChange:this.inputOnChange,onFocus:this.base.handleFocus,onBlur:this.handleBlur,disabled:r,expanded:y,owns:this.base.listBoxId,activedescendant:`option-${this.base.guid}-${C+o.skip}`,role:"combobox",ariaLabelledBy:a,ariaLabel:this.props.ariaLabel,ariaDescribedBy:d,ariaRequired:this.required,render:this.props.valueRender,ariaControls:this.base.listBoxId,unstyled:g,inputAttributes:u})}clearValue(){const s=this.base.initState();this._suggested="",this.navigationIndex=void 0,this.base.filterChanged("",s),this.props.filter===void 0&&this.state.text!==void 0&&(s.data.text=void 0),this.triggerOnChange(null,s);const e=this.props.opened!==void 0?this.props.opened:this.state.opened,t=this.mobileMode;e&&!t&&this.base.togglePopup(s),this.applyState(s)}triggerOnChange(s,e){const t=this.value;!this.hasDuplicates&&(!p.isPresent(t)&&!p.isPresent(s)||p.areSame(t,s,this.props.dataItemKey))||(this.props.value===void 0&&(e.data.value=s),this._valueDuringOnChange=s,e.events.push({type:"onChange"}))}getFocusedIndex(s){const e=this.value,{textField:t,dataItemKey:i,virtual:r={skip:0},focusedItemIndex:l=p.itemIndexStartsWith,skipDisabledItems:a}=this.props,d=p.getFilteredData(this.props),n=this.props.filter?this.props.filter:this.state.text;return s&&this.navigationIndex!==void 0?this.navigationIndex:p.isPresent(e)&&n===void 0?d.findIndex(o=>p.areSame(o,e,i)):n?l(d,n,t):a&&t&&!n&&r.skip===0?d.findIndex(o=>!o.disabled&&o[t]):r.skip===0?0:-1}suggestValue(s){const{data:e,textField:t}=this.props;this._suggested=p.suggestValue(s,e,t)}applyState(s){this.base.applyState(s),this._valueDuringOnChange=void 0}calculateMedia(s){for(const e of s)this.setState({windowWidth:e.target.clientWidth})}};S.displayName="ComboBox",S.propTypes={...E.propTypes,size:f.oneOf([null,"small","medium","large"]),rounded:f.oneOf([null,"small","medium","large","full"]),fillMode:f.oneOf([null,"solid","flat","outline"]),dataItemKey:f.string,groupField:f.string,groupMode:f.oneOf([void 0,"classic","modern"]),isMultiColumn:f.bool,suggest:f.bool,placeholder:f.string,title:f.string,allowCustom:f.bool,clearButton:f.bool,iconClassName:f.string,svgIcon:h.svgIconPropType,validationMessage:f.string,required:f.bool,id:f.string,ariaLabelledBy:f.string,ariaLabel:f.string,ariaDescribedBy:f.string,list:f.any,valueRender:f.func,skipDisabledItems:f.bool,inputAttributes:f.object},S.defaultProps={...E.defaultProps,size:"medium",rounded:"medium",fillMode:"solid",allowCustom:!1,clearButton:!0,required:!1,groupMode:"modern",isMultiColumn:!1,skipDisabledItems:!0,prefix:void 0,suffix:void 0};let M=S;const L=h.createPropsContext(),R=h.withIdHOC(h.withPropsContext(L,h.withUnstyledHOC(h.withAdaptiveModeContext(M))));R.displayName="KendoReactComboBox";exports.ComboBox=R;exports.ComboBoxPropsContext=L;exports.ComboBoxWithoutContext=M;
|
package/ComboBox/ComboBox.mjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import * as
|
|
8
|
+
import * as c from "react";
|
|
9
9
|
import m from "prop-types";
|
|
10
10
|
import _ from "../common/DropDownBase.mjs";
|
|
11
11
|
import { classNames as S, uComboBox as k, Keys as y, validatePackage as tt, svgIconPropType as et, canUseDOM as R, IconWrap as st, WatermarkOverlay as it, createPropsContext as ot, withIdHOC as at, withPropsContext as nt, withUnstyledHOC as lt, withAdaptiveModeContext as rt } from "@progress/kendo-react-common";
|
|
@@ -25,7 +25,7 @@ import { provideLocalizationService as G } from "@progress/kendo-react-intl";
|
|
|
25
25
|
import { ActionSheetContent as It } from "@progress/kendo-react-layout";
|
|
26
26
|
import U from "../common/withCustomComponent.mjs";
|
|
27
27
|
import { AdaptiveMode as yt } from "../common/AdaptiveMode.mjs";
|
|
28
|
-
const Ct = "Please enter a valid value!", M = class M extends
|
|
28
|
+
const Ct = "Please enter a valid value!", M = class M extends c.Component {
|
|
29
29
|
constructor(s) {
|
|
30
30
|
super(s), this.state = {}, this.base = new _(this), this._element = null, this._suggested = "", this._skipBlur = !1, this._input = null, this._adaptiveFilterInput = null, this._skipFocus = !1, this.itemHeight = 0, this.duplicates = [], this.hasDuplicates = !1, this.showLicenseWatermark = !1, this.focus = () => {
|
|
31
31
|
this._input && this._input.focus();
|
|
@@ -58,7 +58,7 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
58
58
|
e && !this.mobileMode && this.base.togglePopup(t);
|
|
59
59
|
}, this.renderMobileListFilter = () => {
|
|
60
60
|
const t = this.props.adaptiveFilter !== void 0 ? this.props.adaptiveFilter : this.state.text, e = D(this.value, this.props.textField), i = w(t) ? t : e;
|
|
61
|
-
return /* @__PURE__ */
|
|
61
|
+
return /* @__PURE__ */ c.createElement(
|
|
62
62
|
mt,
|
|
63
63
|
{
|
|
64
64
|
value: i,
|
|
@@ -74,9 +74,9 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
74
74
|
}
|
|
75
75
|
);
|
|
76
76
|
}, this.listContainerContent = () => {
|
|
77
|
-
const { header: t, footer: e, size: i, groupStickyHeaderItemRender: r, groupField: l, list: a, groupMode: p, unstyled: n, virtual: o } = this.props,
|
|
77
|
+
const { header: t, footer: e, size: i, groupStickyHeaderItemRender: r, groupField: l, list: a, groupMode: p, unstyled: n, virtual: o } = this.props, u = C(this.props), d = n && n.uComboBox;
|
|
78
78
|
let { group: v } = this.state;
|
|
79
|
-
return v === void 0 && l !== void 0 && (v = D(
|
|
79
|
+
return v === void 0 && l !== void 0 && (v = D(u[0], l)), /* @__PURE__ */ c.createElement(
|
|
80
80
|
"div",
|
|
81
81
|
{
|
|
82
82
|
className: S(
|
|
@@ -89,10 +89,10 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
89
89
|
})
|
|
90
90
|
)
|
|
91
91
|
},
|
|
92
|
-
t && /* @__PURE__ */
|
|
93
|
-
!a && v &&
|
|
92
|
+
t && /* @__PURE__ */ c.createElement("div", { className: S(k.listHeader({ c: d })) }, t),
|
|
93
|
+
!a && v && u.length !== 0 && /* @__PURE__ */ c.createElement(K, { group: v, groupMode: p, render: r }),
|
|
94
94
|
this.renderList(),
|
|
95
|
-
e && /* @__PURE__ */
|
|
95
|
+
e && /* @__PURE__ */ c.createElement(
|
|
96
96
|
"div",
|
|
97
97
|
{
|
|
98
98
|
className: S(k.listFooter({ c: d }), this.props.footerClassName)
|
|
@@ -113,8 +113,8 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
113
113
|
const a = this.itemHeight = this.itemHeight || (e.enabled ? e.itemHeight : i ? i.children[0].offsetHeight : 0), n = t.target.scrollTop - e.skip * a;
|
|
114
114
|
this.props.groupMode === "modern" && (l = this.base.getGroupedDataModernMode(l, r));
|
|
115
115
|
let o = l[0][r];
|
|
116
|
-
for (let
|
|
117
|
-
l[
|
|
116
|
+
for (let u = 1; u < l.length && !(a * u > n); u++)
|
|
117
|
+
l[u] && l[u][r] && (o = l[u][r]);
|
|
118
118
|
o !== this.state.group && (this.setState({
|
|
119
119
|
group: o
|
|
120
120
|
}), this.props.onGroupScroll && this.props.onGroupScroll.call(void 0, { group: o }));
|
|
@@ -134,48 +134,48 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
134
134
|
}, this.onInputKeyDown = (t) => {
|
|
135
135
|
const { skipDisabledItems: e, textField: i, dataItemKey: r, groupField: l } = this.props, a = C(this.props), p = this.value, n = Math.max(
|
|
136
136
|
0,
|
|
137
|
-
a.findIndex((
|
|
138
|
-
), o = t.keyCode,
|
|
137
|
+
a.findIndex((h) => F(h, p, r))
|
|
138
|
+
), o = t.keyCode, u = this.props.opened !== void 0 ? this.props.opened : this.state.opened, d = this.base.initState();
|
|
139
139
|
if (d.syntheticEvent = t, !t.altKey && (o === y.up || o === y.down)) {
|
|
140
140
|
if (t.preventDefault(), l !== "" && i)
|
|
141
|
-
if (!this.props.skipDisabledItems &&
|
|
141
|
+
if (!this.props.skipDisabledItems && u)
|
|
142
142
|
this.onNavigate(d, o);
|
|
143
143
|
else {
|
|
144
|
-
let
|
|
144
|
+
let h = 0;
|
|
145
145
|
if (o === y.down || o === y.right) {
|
|
146
|
-
const
|
|
147
|
-
|
|
146
|
+
const g = a.slice(n + 1 < a.length ? n + 1 : n).find((f) => !f.disabled && f[i]);
|
|
147
|
+
h = g && a.findIndex((f) => f[i] === g[i]);
|
|
148
148
|
} else if (o === y.up || o === y.left) {
|
|
149
|
-
let
|
|
149
|
+
let g;
|
|
150
150
|
if (n === 0)
|
|
151
|
-
|
|
151
|
+
g = a, h = a.findIndex((f) => !f.disabled && f[i]);
|
|
152
152
|
else {
|
|
153
|
-
|
|
154
|
-
let f =
|
|
153
|
+
g = a.slice(0, n);
|
|
154
|
+
let f = g.pop();
|
|
155
155
|
for (; f && f.disabled; )
|
|
156
|
-
f =
|
|
157
|
-
|
|
156
|
+
f = g.pop();
|
|
157
|
+
h = f && a.findIndex((E) => E[i] === f[i]);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
if (
|
|
161
|
-
const
|
|
162
|
-
this.onNavigate(d, o,
|
|
163
|
-
} else
|
|
160
|
+
if (h !== void 0) {
|
|
161
|
+
const g = h - n;
|
|
162
|
+
this.onNavigate(d, o, g);
|
|
163
|
+
} else h === void 0 && a.findIndex((g) => g[i] === p[i]) === a.length - 1 && this.onNavigate(d, o);
|
|
164
164
|
}
|
|
165
|
-
else if (!this.props.skipDisabledItems &&
|
|
165
|
+
else if (!this.props.skipDisabledItems && u)
|
|
166
166
|
this.onNavigate(d, o);
|
|
167
167
|
else {
|
|
168
|
-
let
|
|
168
|
+
let h = null;
|
|
169
169
|
if (o === y.down || o === y.right)
|
|
170
|
-
|
|
170
|
+
h = a.slice(n + 1).find((g) => !g.disabled);
|
|
171
171
|
else if (o === y.up || o === y.left) {
|
|
172
|
-
const
|
|
173
|
-
for (
|
|
174
|
-
|
|
172
|
+
const g = a.slice(0, n);
|
|
173
|
+
for (h = g.pop(); h && h.disabled; )
|
|
174
|
+
h = g.pop();
|
|
175
175
|
}
|
|
176
|
-
if (
|
|
177
|
-
const
|
|
178
|
-
this.onNavigate(d, o,
|
|
176
|
+
if (h) {
|
|
177
|
+
const g = h.id - n - 1;
|
|
178
|
+
this.onNavigate(d, o, g);
|
|
179
179
|
} else
|
|
180
180
|
this.onNavigate(d, o);
|
|
181
181
|
}
|
|
@@ -183,8 +183,8 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
183
183
|
}
|
|
184
184
|
const v = () => {
|
|
185
185
|
t.preventDefault(), this.base.togglePopup(d), this.applyState(d);
|
|
186
|
-
},
|
|
187
|
-
|
|
186
|
+
}, b = this.getFocusedIndex(), x = b === -1, I = !x && this.getCurrentValueDisabledStatus(i, a, b);
|
|
187
|
+
u ? o === y.pageUp ? (t.preventDefault(), this.base.scrollPopupByPageSize(-1)) : o === y.pageDown ? (t.preventDefault(), this.base.scrollPopupByPageSize(1)) : t.altKey && o === y.up ? v() : o === y.enter ? (t.preventDefault(), (i && !x && t.currentTarget.value ? a[b][i] : void 0) ? !e && i && I ? this.clearValueOnEnterOrEsc(t) : I || this.applyValueOnEnter(t.currentTarget.value, d) : this.applyValueOnEnter(t.currentTarget.value, d)) : o === y.esc && (!e && i && I && this.clearValueOnEnterOrEsc(t), this.applyValueOnRejectSuggestions(t.currentTarget.value, d)) : !u && o === y.esc ? this.clearValueOnEnterOrEsc(t) : t.altKey && o === y.down && v();
|
|
188
188
|
}, this.inputOnChange = (t) => {
|
|
189
189
|
const e = this.base.initState();
|
|
190
190
|
e.syntheticEvent = t;
|
|
@@ -289,17 +289,17 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
289
289
|
var v;
|
|
290
290
|
const { dataItemKey: e, virtual: i, groupField: r = "", textField: l } = this.props, a = C(this.props), p = s.virtual ? s.virtual.total : 0, n = this.props.opened !== void 0 ? this.props.opened : this.state.opened, o = s.opened !== void 0 ? s.opened : t.opened;
|
|
291
291
|
s.data !== a && this.checkForDuplicatePlainTextRecords();
|
|
292
|
-
const
|
|
292
|
+
const u = !o && n, d = this.value;
|
|
293
293
|
if (this._valueOnDidUpdate = d, this.base.didUpdate(), i && i.total !== p)
|
|
294
294
|
this.base.vs.calcScrollElementHeight(), this.base.vs.reset();
|
|
295
295
|
else {
|
|
296
|
-
const
|
|
297
|
-
let
|
|
298
|
-
this.props.groupMode === "modern" && l && d && (
|
|
299
|
-
const
|
|
300
|
-
|
|
296
|
+
const b = s.value !== void 0 ? s.value : t.value;
|
|
297
|
+
let x = this.hasDuplicates ? this.navigationIndex || 0 : a.findIndex((h) => F(h, d, e));
|
|
298
|
+
this.props.groupMode === "modern" && l && d && (x = (v = this.base.getGroupedDataModernMode(a, r)) == null ? void 0 : v.map((h) => h[l]).indexOf(d[l]));
|
|
299
|
+
const I = !F(b, d, e);
|
|
300
|
+
u && i ? this.base.scrollToVirtualItem(i, x) : u && !i ? (this.onPopupOpened(), a && a.length !== 0 && this.base.resetGroupStickyHeader(a[0][r], this), this.base.scrollToItem(x)) : (this.hasDuplicates || n && o && d && I) && this.base.scrollToItem(x);
|
|
301
301
|
}
|
|
302
|
-
|
|
302
|
+
u && this._input && this._input.focus(), this.setValidity();
|
|
303
303
|
}
|
|
304
304
|
/** @hidden */
|
|
305
305
|
componentDidMount() {
|
|
@@ -328,26 +328,26 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
328
328
|
className: p,
|
|
329
329
|
style: n,
|
|
330
330
|
loading: o,
|
|
331
|
-
iconClassName:
|
|
331
|
+
iconClassName: u,
|
|
332
332
|
virtual: d,
|
|
333
333
|
size: v,
|
|
334
|
-
rounded:
|
|
335
|
-
fillMode:
|
|
336
|
-
opened:
|
|
337
|
-
placeholder:
|
|
338
|
-
svgIcon:
|
|
334
|
+
rounded: b,
|
|
335
|
+
fillMode: x,
|
|
336
|
+
opened: I = this.state.opened,
|
|
337
|
+
placeholder: h,
|
|
338
|
+
svgIcon: g,
|
|
339
339
|
unstyled: f
|
|
340
340
|
} = this.props, E = !this.validityStyles || this.validity.valid, O = this.props.filter !== void 0 ? this.props.filter : this.state.text, j = D(this.value, a), V = w(O) ? O : j, $ = r && (!!V || w(this.value)), B = this.base.vs, L = this.props.id || this._inputId, T = f && f.uComboBox;
|
|
341
341
|
B.enabled = d !== void 0, d !== void 0 && (B.skip = d.skip, B.total = d.total, B.pageSize = d.pageSize);
|
|
342
|
-
const [Y, J] = U(this.props.prefix ||
|
|
342
|
+
const [Y, J] = U(this.props.prefix || c.Fragment), [Q, X] = U(this.props.suffix || c.Fragment), N = /* @__PURE__ */ c.createElement(c.Fragment, null, /* @__PURE__ */ c.createElement(
|
|
343
343
|
"span",
|
|
344
344
|
{
|
|
345
345
|
className: S(
|
|
346
346
|
k.wrapper({
|
|
347
347
|
c: T,
|
|
348
348
|
size: v,
|
|
349
|
-
rounded:
|
|
350
|
-
fillMode:
|
|
349
|
+
rounded: b,
|
|
350
|
+
fillMode: x,
|
|
351
351
|
disabled: i,
|
|
352
352
|
invalid: !E,
|
|
353
353
|
loading: o,
|
|
@@ -360,10 +360,10 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
360
360
|
dir: e,
|
|
361
361
|
onFocus: this.handleFocus
|
|
362
362
|
},
|
|
363
|
-
this.props.prefix && /* @__PURE__ */
|
|
364
|
-
this.renderSearchBar(V || "", L,
|
|
365
|
-
$ && !o && /* @__PURE__ */
|
|
366
|
-
o && /* @__PURE__ */
|
|
363
|
+
this.props.prefix && /* @__PURE__ */ c.createElement(Y, { ...J }),
|
|
364
|
+
this.renderSearchBar(V || "", L, h),
|
|
365
|
+
$ && !o && /* @__PURE__ */ c.createElement(ft, { onClick: this.clearButtonClick, key: "clearbutton" }),
|
|
366
|
+
o && /* @__PURE__ */ c.createElement(
|
|
367
367
|
st,
|
|
368
368
|
{
|
|
369
369
|
className: S(k.loadingIcon({ c: T })),
|
|
@@ -371,18 +371,18 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
371
371
|
key: "loading"
|
|
372
372
|
}
|
|
373
373
|
),
|
|
374
|
-
this.props.suffix && /* @__PURE__ */
|
|
375
|
-
/* @__PURE__ */
|
|
374
|
+
this.props.suffix && /* @__PURE__ */ c.createElement(Q, { ...X }),
|
|
375
|
+
/* @__PURE__ */ c.createElement(
|
|
376
376
|
bt,
|
|
377
377
|
{
|
|
378
378
|
tabIndex: -1,
|
|
379
379
|
type: "button",
|
|
380
|
-
"aria-label":
|
|
381
|
-
icon:
|
|
382
|
-
svgIcon:
|
|
383
|
-
iconClass:
|
|
380
|
+
"aria-label": I ? t : s,
|
|
381
|
+
icon: u ? void 0 : "caret-alt-down",
|
|
382
|
+
svgIcon: g || xt,
|
|
383
|
+
iconClass: u,
|
|
384
384
|
size: v,
|
|
385
|
-
fillMode:
|
|
385
|
+
fillMode: x,
|
|
386
386
|
rounded: null,
|
|
387
387
|
themeColor: "base",
|
|
388
388
|
className: S(k.inputButton({ c: T })),
|
|
@@ -392,7 +392,7 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
392
392
|
),
|
|
393
393
|
!this.mobileMode && this.renderListContainer()
|
|
394
394
|
), this.mobileMode && this.renderAdaptiveListContainer());
|
|
395
|
-
return l ? /* @__PURE__ */
|
|
395
|
+
return l ? /* @__PURE__ */ c.createElement(
|
|
396
396
|
pt,
|
|
397
397
|
{
|
|
398
398
|
label: l,
|
|
@@ -412,8 +412,8 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
412
412
|
let a = -1, p;
|
|
413
413
|
const n = this.base.vs, o = this.value;
|
|
414
414
|
this._suggested = "";
|
|
415
|
-
const
|
|
416
|
-
if (a = this.getFocusedIndex(
|
|
415
|
+
const u = this.hasDuplicates && this.duplicates.indexOf(o) !== -1;
|
|
416
|
+
if (a = this.getFocusedIndex(u), a !== -1 && !w(o))
|
|
417
417
|
this.handleItemSelect(a, s);
|
|
418
418
|
else if (l === "")
|
|
419
419
|
this.handleItemSelect(0, s);
|
|
@@ -467,7 +467,7 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
467
467
|
windowWidth: s,
|
|
468
468
|
mobileFilter: this.renderMobileListFilter()
|
|
469
469
|
};
|
|
470
|
-
return /* @__PURE__ */
|
|
470
|
+
return /* @__PURE__ */ c.createElement(yt, { ...p }, /* @__PURE__ */ c.createElement(It, null, /* @__PURE__ */ c.createElement("div", { className: "k-list-container" }, this.listContainerContent())));
|
|
471
471
|
}
|
|
472
472
|
renderListContainer() {
|
|
473
473
|
const s = this.base, {
|
|
@@ -480,21 +480,21 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
480
480
|
list: p,
|
|
481
481
|
virtual: n,
|
|
482
482
|
groupStickyHeaderItemRender: o,
|
|
483
|
-
unstyled:
|
|
484
|
-
} = this.props, d = C(this.props), v = this.props.opened !== void 0 ? this.props.opened : this.state.opened,
|
|
485
|
-
let { group:
|
|
486
|
-
return
|
|
483
|
+
unstyled: u
|
|
484
|
+
} = this.props, d = C(this.props), v = this.props.opened !== void 0 ? this.props.opened : this.state.opened, b = s.getPopupSettings(), x = b.width !== void 0 ? b.width : s.popupWidth, I = u && u.uComboBox;
|
|
485
|
+
let { group: h } = this.state;
|
|
486
|
+
return h === void 0 && r !== void 0 && (h = D(d[0], r)), /* @__PURE__ */ c.createElement(
|
|
487
487
|
ct,
|
|
488
488
|
{
|
|
489
|
-
width:
|
|
489
|
+
width: x,
|
|
490
490
|
popupSettings: {
|
|
491
|
-
...
|
|
492
|
-
anchor:
|
|
491
|
+
...b,
|
|
492
|
+
anchor: b.anchor || this.element,
|
|
493
493
|
show: v,
|
|
494
494
|
popupClass: S(
|
|
495
|
-
|
|
495
|
+
b.popupClass,
|
|
496
496
|
k.listContainer({
|
|
497
|
-
c:
|
|
497
|
+
c: I,
|
|
498
498
|
popup: !0
|
|
499
499
|
})
|
|
500
500
|
)
|
|
@@ -502,12 +502,12 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
502
502
|
dir: t !== void 0 ? t : this.base.dirCalculated,
|
|
503
503
|
itemsCount: [d.length]
|
|
504
504
|
},
|
|
505
|
-
/* @__PURE__ */
|
|
505
|
+
/* @__PURE__ */ c.createElement(
|
|
506
506
|
"div",
|
|
507
507
|
{
|
|
508
508
|
className: S(
|
|
509
509
|
k.list({
|
|
510
|
-
c:
|
|
510
|
+
c: I,
|
|
511
511
|
list: p,
|
|
512
512
|
size: a,
|
|
513
513
|
tableSize: a,
|
|
@@ -515,21 +515,21 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
515
515
|
})
|
|
516
516
|
)
|
|
517
517
|
},
|
|
518
|
-
e && /* @__PURE__ */
|
|
519
|
-
!p &&
|
|
518
|
+
e && /* @__PURE__ */ c.createElement("div", { className: S(k.listHeader({ c: I })) }, e),
|
|
519
|
+
!p && h && d.length !== 0 && /* @__PURE__ */ c.createElement(K, { group: h, groupMode: l, render: o }),
|
|
520
520
|
this.renderList(),
|
|
521
|
-
i && /* @__PURE__ */
|
|
521
|
+
i && /* @__PURE__ */ c.createElement(
|
|
522
522
|
"div",
|
|
523
523
|
{
|
|
524
524
|
className: S(
|
|
525
|
-
k.listFooter({ c:
|
|
525
|
+
k.listFooter({ c: I }),
|
|
526
526
|
this.props.footerClassName
|
|
527
527
|
)
|
|
528
528
|
},
|
|
529
529
|
i
|
|
530
530
|
)
|
|
531
531
|
),
|
|
532
|
-
this.showLicenseWatermark && /* @__PURE__ */
|
|
532
|
+
this.showLicenseWatermark && /* @__PURE__ */ c.createElement(it, null)
|
|
533
533
|
);
|
|
534
534
|
}
|
|
535
535
|
renderList() {
|
|
@@ -541,16 +541,16 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
541
541
|
groupHeaderItemRender: l,
|
|
542
542
|
virtual: a = { skip: 0, total: void 0 },
|
|
543
543
|
unstyled: p
|
|
544
|
-
} = this.props, n = C(this.props), o = s.getPopupSettings(),
|
|
545
|
-
return /* @__PURE__ */
|
|
544
|
+
} = this.props, n = C(this.props), o = s.getPopupSettings(), u = s.vs, d = a.skip, v = this.props.opened !== void 0 ? this.props.opened : this.state.opened, b = `translateY(${u.translate}px)`, x = v ? this.getFocusedIndex(this.hasDuplicates) : void 0, I = this.props.filter !== void 0 ? this.props.filter : this.state.text, h = D(this.value, t), g = w(I) && I !== h ? null : this.value, f = this.props.list || gt, E = p && p.uComboBox;
|
|
545
|
+
return /* @__PURE__ */ c.createElement(
|
|
546
546
|
f,
|
|
547
547
|
{
|
|
548
548
|
id: s.listBoxId,
|
|
549
549
|
virtual: !!a,
|
|
550
550
|
show: v,
|
|
551
551
|
data: n,
|
|
552
|
-
focusedIndex:
|
|
553
|
-
value:
|
|
552
|
+
focusedIndex: x,
|
|
553
|
+
value: g,
|
|
554
554
|
textField: t,
|
|
555
555
|
valueField: e,
|
|
556
556
|
groupField: this.props.groupField,
|
|
@@ -559,7 +559,7 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
559
559
|
optionsGuid: s.guid,
|
|
560
560
|
hasDuplicates: this.hasDuplicates,
|
|
561
561
|
listRef: (O) => {
|
|
562
|
-
|
|
562
|
+
u.list = this.base.list = O, this.itemHeight = 0;
|
|
563
563
|
},
|
|
564
564
|
wrapperStyle: this.state.windowWidth && this.props._adaptiveMode && this.state.windowWidth > this.props._adaptiveMode.medium ? { maxHeight: o.height } : {},
|
|
565
565
|
wrapperCssClass: S(
|
|
@@ -568,7 +568,7 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
568
568
|
virtual: a
|
|
569
569
|
})
|
|
570
570
|
),
|
|
571
|
-
listStyle:
|
|
571
|
+
listStyle: u.enabled ? { transform: b } : void 0,
|
|
572
572
|
key: "listkey",
|
|
573
573
|
skip: d,
|
|
574
574
|
onClick: this.handleItemClick,
|
|
@@ -577,7 +577,7 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
577
577
|
noDataRender: i,
|
|
578
578
|
onMouseDown: (O) => O.preventDefault(),
|
|
579
579
|
onScroll: this.onScroll,
|
|
580
|
-
wrapperRef:
|
|
580
|
+
wrapperRef: u.scrollerRef,
|
|
581
581
|
scroller: this.base.renderScrollElement(),
|
|
582
582
|
ariaSetSize: a.total
|
|
583
583
|
}
|
|
@@ -592,25 +592,24 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
592
592
|
ariaDescribedBy: p,
|
|
593
593
|
dataItemKey: n,
|
|
594
594
|
virtual: o = { skip: 0 },
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
} = this.props, x = C(this.props), I = this.props.opened !== void 0 ? this.props.opened : this.state.opened, b = this.value, u = Math.max(
|
|
595
|
+
unstyled: u,
|
|
596
|
+
inputAttributes: d
|
|
597
|
+
} = this.props, v = C(this.props), b = this.props.opened !== void 0 ? this.props.opened : this.state.opened, x = this.value, I = Math.max(
|
|
599
598
|
0,
|
|
600
|
-
|
|
599
|
+
v.findIndex((h) => F(h, x, n))
|
|
601
600
|
);
|
|
602
|
-
return this._suggested && !F(this._valueOnDidUpdate,
|
|
601
|
+
return this._suggested && !F(this._valueOnDidUpdate, x, n) && (this._suggested = ""), /* @__PURE__ */ c.createElement(
|
|
603
602
|
ut,
|
|
604
603
|
{
|
|
605
604
|
id: t,
|
|
606
|
-
readOnly:
|
|
605
|
+
readOnly: b && this.mobileMode,
|
|
607
606
|
placeholder: e,
|
|
608
607
|
tabIndex: i,
|
|
609
608
|
title: l,
|
|
610
609
|
value: s + this._suggested,
|
|
611
610
|
suggestedText: this._suggested,
|
|
612
|
-
ref: (
|
|
613
|
-
this._input =
|
|
611
|
+
ref: (h) => {
|
|
612
|
+
this._input = h && h.input;
|
|
614
613
|
},
|
|
615
614
|
onClick: this.onInputClick,
|
|
616
615
|
onKeyDown: this.onInputKeyDown,
|
|
@@ -618,9 +617,9 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
618
617
|
onFocus: this.base.handleFocus,
|
|
619
618
|
onBlur: this.handleBlur,
|
|
620
619
|
disabled: r,
|
|
621
|
-
expanded:
|
|
620
|
+
expanded: b,
|
|
622
621
|
owns: this.base.listBoxId,
|
|
623
|
-
activedescendant: `option-${this.base.guid}-${
|
|
622
|
+
activedescendant: `option-${this.base.guid}-${I + o.skip}`,
|
|
624
623
|
role: "combobox",
|
|
625
624
|
ariaLabelledBy: a,
|
|
626
625
|
ariaLabel: this.props.ariaLabel,
|
|
@@ -628,8 +627,8 @@ const Ct = "Please enter a valid value!", M = class M extends g.Component {
|
|
|
628
627
|
ariaRequired: this.required,
|
|
629
628
|
render: this.props.valueRender,
|
|
630
629
|
ariaControls: this.base.listBoxId,
|
|
631
|
-
unstyled:
|
|
632
|
-
inputAttributes:
|
|
630
|
+
unstyled: u,
|
|
631
|
+
inputAttributes: d
|
|
633
632
|
}
|
|
634
633
|
);
|
|
635
634
|
}
|