@progress/kendo-react-dropdowns 14.5.0-develop.1 → 14.5.0-develop.10
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.d.ts +1 -1
- package/ComboBox/ComboBox.js +1 -1
- package/ComboBox/ComboBox.mjs +1 -1
- package/DropDownList/DropDownList.js +1 -1
- package/DropDownList/DropDownList.mjs +69 -69
- package/DropDownTree/DropDownTree.js +1 -1
- package/DropDownTree/DropDownTree.mjs +13 -13
- package/common/AdaptiveMode.js +1 -1
- package/common/AdaptiveMode.mjs +10 -9
- package/dist/cdn/js/kendo-react-dropdowns.js +1 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +16 -11
package/ComboBox/ComboBox.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ export declare class ComboBoxWithoutContext extends React.Component<ComboBoxProp
|
|
|
74
74
|
data: PropTypes.Requireable<any[]>;
|
|
75
75
|
textField: PropTypes.Requireable<string>;
|
|
76
76
|
className: PropTypes.Requireable<string>;
|
|
77
|
-
label: PropTypes.Requireable<string>;
|
|
77
|
+
label: PropTypes.Requireable<string>; /** @hidden */
|
|
78
78
|
loading: PropTypes.Requireable<boolean>;
|
|
79
79
|
popupSettings: PropTypes.Requireable<PropTypes.InferProps<{
|
|
80
80
|
animate: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{
|
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 $=require("react"),f=require("prop-types"),E=require("../common/DropDownBase.js"),p=require("@progress/kendo-react-common"),Y=require("@progress/kendo-react-labels"),d=require("../common/utils.js"),J=require("../common/SearchBar.js"),Q=require("../common/ListContainer.js"),X=require("../common/List.js"),Z=require("../common/ListFilter.js"),_=require("../common/GroupStickyHeader.js"),K=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"),L=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($),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.scrollToFocused=!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 a=this.props.data;this.duplicates=d.getPlainDataDuplicates(a),this.hasDuplicates=this.duplicates.length>0}},this.handleKendoPasteValue=e=>{const{data:t,textField:a,allowCustom:r}=this.props;if(!t)return;const l=e!=null?String(e):"",o=d.getItemIndexByText(t,l,a,!1,!0),h=o!==-1;let n=null;if(h?n=t[o]:r&&(n=a?{[a]:l}:l),n===null)return;const i=this.base.initState();i.syntheticEvent={target:this._element,currentTarget:this._element,nativeEvent:new Event("change",{bubbles:!0})},this.state.text!==void 0&&(i.data.text=void 0),this.triggerOnChange(n,i),this.applyState(i)},this.handleItemSelect=(e,t)=>{const{virtual:a,dataItemKey:r}=this.props,l=d.getFilteredData(this.props),o=a?a.skip:0,h=l[e-o],n=this.hasDuplicates||!d.areSame(h,this.value,r);this.triggerOnChange(h,t),this.state.text!==void 0&&(t.data.text=void 0),n&&this.base.triggerPageChangeCornerItems(h,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:a}=this.props,r=d.getFilteredData(this.props),l=this.getFocusedIndex(),o=this.getCurrentValueDisabledStatus(a,r,l),h=this.props.opened!==void 0?this.props.opened:this.state.opened,n=this.base.initState();if(n.syntheticEvent=e,!t&&a&&o&&this.clearValueOnToggleBtnClick(e),this.base.togglePopup(n),!h&&this.mobileMode){const i=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text||null;this.base.filterChanged(i,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=d.getItemValue(this.value,this.props.textField),a=d.isPresent(e)?e:t;return m.createElement(Z,{value:a,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:a,groupStickyHeaderItemRender:r,groupField:l,list:o,unstyled:h,virtual:n}=this.props,i=d.getFilteredData(this.props),c=h&&h.uComboBox;let{group:u}=this.state;return u===void 0&&l!==void 0&&(u=d.getItemValue(i[0],l)),m.createElement("div",{className:p.classNames(p.uComboBox.list({c,list:o,size:"large",tableSize:a,virtual:n}))},e&&m.createElement("div",{className:p.classNames(p.uComboBox.listHeader({c}))},e),!o&&u&&i.length!==0&&m.createElement(_,{group:u,render:r}),this.renderList(),t&&m.createElement("div",{className:p.classNames(p.uComboBox.listFooter({c}),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:a}=this.base;t.scrollHandler(e);const{groupField:r}=this.props;this.props.onListScroll&&this.props.onListScroll(e);let l=d.getFilteredData(this.props);if(!r||!l.length)return;const o=this.itemHeight=this.itemHeight||(t.enabled?t.itemHeight:a?a.children[0].offsetHeight:0),n=e.target.scrollTop-t.skip*o;l=this.base.getGroupedDataModernMode(l,r);let i=l[0][r];for(let c=1;c<l.length&&!(o*c>n);c++)l[c]&&l[c][r]&&(i=l[c][r]);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:a}=this.props,r=d.getFilteredData(this.props),l=this.getFocusedIndex(),h=!(l===-1)&&this.getCurrentValueDisabledStatus(a,r,l);t.data.focused=!1,t.events.push({type:"onBlur"}),t.syntheticEvent=e,a&&h&&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,a=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(a,r),this.applyState(r)}},this.onInputKeyDown=e=>{const{skipDisabledItems:t,textField:a,dataItemKey:r,groupField:l}=this.props,o=d.getFilteredData(this.props),h=this.value,n=Math.max(0,o.findIndex(v=>d.areSame(v,h,r))),i=e.keyCode,c=this.props.opened!==void 0?this.props.opened:this.state.opened,u=this.base.initState();if(u.syntheticEvent=e,!e.altKey&&(i===p.Keys.up||i===p.Keys.down)){if(e.preventDefault(),l!==""&&a)if(!this.props.skipDisabledItems&&c)this.onNavigate(u,i);else{let v=0;if(i===p.Keys.down||i===p.Keys.right){const g=o.slice(n+1<o.length?n+1:n).find(I=>!I.disabled);v=g&&o.indexOf(g)}else if(i===p.Keys.up||i===p.Keys.left){let g;if(n===0)g=o,v=o.findIndex(I=>!I.disabled);else{g=o.slice(0,n);let I=g.pop();for(;I&&I.disabled;)I=g.pop();v=I&&o.indexOf(I)}}if(v!==void 0){const g=v-n;this.onNavigate(u,i,g)}else v===void 0&&n===o.length-1&&this.onNavigate(u,i)}else if(!this.props.skipDisabledItems&&c)this.onNavigate(u,i);else{let v=null;if(i===p.Keys.down||i===p.Keys.right)v=o.slice(n+1).find(g=>!g.disabled);else if(i===p.Keys.up||i===p.Keys.left){const g=o.slice(0,n);for(v=g.pop();v&&v.disabled;)v=g.pop()}if(v){const g=v.id-n-1;this.onNavigate(u,i,g)}else this.onNavigate(u,i)}this.applyState(u)}const x=()=>{e.preventDefault(),this.base.togglePopup(u),this.applyState(u)},C=this.getFocusedIndex(),y=C===-1,b=!y&&this.getCurrentValueDisabledStatus(a,o,C);c?i===p.Keys.pageUp?(e.preventDefault(),this.base.scrollPopupByPageSize(-1)):i===p.Keys.pageDown?(e.preventDefault(),this.base.scrollPopupByPageSize(1)):e.altKey&&i===p.Keys.up?x():i===p.Keys.enter?(e.preventDefault(),(a&&!y&&e.currentTarget.value?o[C][a]:void 0)?!t&&a&&b?this.clearValueOnEnterOrEsc(e):b||this.applyValueOnEnter(e.currentTarget.value,u):this.applyValueOnEnter(e.currentTarget.value,u)):i===p.Keys.esc&&(!t&&a&&b&&this.clearValueOnEnterOrEsc(e),this.applyValueOnRejectSuggestions(e.currentTarget.value,u)):!c&&i===p.Keys.esc?this.clearValueOnEnterOrEsc(e):e.altKey&&i===p.Keys.down&&x()},this.inputOnChange=e=>{const t=this.base.initState();t.syntheticEvent=e;const a=this.props.opened!==void 0?this.props.opened:this.state.opened,r=e.currentTarget,l=r.value;if(this.props.suggest){const o=r.selectionEnd===l.length;let h=this.props.filter!==void 0?this.props.filter:this.state.text;d.isPresent(h)||(h=d.getItemValue(this.value,this.props.textField)||"");const n=h&&h===l,i=h&&h.length>l.length;n||i||!o?this._suggested="":this.suggestValue(l)}this.props.filter===void 0&&(t.data.text=l),this.state.focusedItem!==void 0&&(t.data.focusedItem=void 0),a?this.scrollToFocused=!0: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=!p.validatePackage(K.packageMetadata,{component:"ComboBox"}),this.licenseMessage=p.getLicenseMessage(K.packageMetadata)}get _inputId(){return this.props.id}get document(){if(p.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=d.getFilteredData(this.props),t=this.value;return e.findIndex(a=>d.areSame(a,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 x,C;const{dataItemKey:t,virtual:a,groupField:r="",textField:l}=this.props,o=d.getFilteredData(this.props),h=s.virtual?s.virtual.total:0,n=this.props.opened!==void 0?this.props.opened:this.state.opened,i=s.opened!==void 0?s.opened:e.opened;s.data!==o&&this.checkForDuplicatePlainTextRecords();const c=!i&&n,u=this.value;if(this._valueOnDidUpdate=u,this.base.didUpdate(),a&&a.total!==h)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:o.findIndex(g=>d.areSame(g,u,t));l&&u&&(b=(x=this.base.getGroupedDataModernMode(o,r))==null?void 0:x.map(g=>g[l]).indexOf(u[l]));const v=!d.areSame(y,u,t);if(c&&a?this.base.scrollToVirtualItem(a,b):c&&!a?(this.onPopupOpened(),o&&o.length!==0&&this.base.resetGroupStickyHeader(o[0][r],this),this.base.scrollToItem(b)):(this.hasDuplicates||n&&i&&u&&v)&&this.base.scrollToItem(b),n&&i&&this.scrollToFocused){const g=(C=this.props.filter?this.props.filter:this.state.text)!=null?C:"";if(g){const{focusedItemIndex:I=d.itemIndexStartsWith}=this.props,F=I(o,g,l);this.base.scrollToItem(F)}else this.base.scrollToItem(0)}}this.scrollToFocused=!1,c&&this._input&&this._input.focus(),this.setValidity()}componentDidMount(){var e;this.observerResize=p.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(e=this.document)!=null&&e.body&&this.observerResize&&this.observerResize.observe(this.document.body),this.checkForDuplicatePlainTextRecords();const s=this.props.name||this.props.id;this.KendoPasteSubscription=p.subscribeToKendoPaste(this._element,{fieldName:s,onValueChange:t=>{this.handleKendoPasteValue(t)}})}componentWillUnmount(){var s,e;(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.disconnect(),(e=this.KendoPasteSubscription)==null||e.unsubscribe()}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:a,clearButton:r=S.defaultProps.clearButton,label:l,textField:o,className:h,style:n,loading:i,iconClassName:c,virtual:u,size:x,rounded:C,fillMode:y,opened:b=this.state.opened,placeholder:v,svgIcon:g,unstyled:I}=this.props,F=!this.validityStyles||this.validity.valid,D=this.props.filter!==void 0?this.props.filter:this.state.text,A=d.getItemValue(this.value,o),O=d.isPresent(D)?D:A,z=r&&(!!O||d.isPresent(this.value)),B=this.base.vs,T=this.props.id||this._inputId,V=I&&I.uComboBox;B.enabled=u!==void 0,u!==void 0&&(B.skip=u.skip,B.total=u.total,B.pageSize=u.pageSize);const[H,W]=L(this.props.prefix||m.Fragment),[j,U]=L(this.props.suffix||m.Fragment),P=m.createElement(m.Fragment,null,m.createElement("span",{className:p.classNames(p.uComboBox.wrapper({c:V,size:x,rounded:C,fillMode:y,disabled:a,invalid:!F,loading:i,required:this.required}),h),ref:this.componentRef,style:l?{...n,width:void 0}:n,dir:t,onFocus:this.handleFocus},this.props.prefix&&m.createElement(H,{...W}),this.renderSearchBar(O||"",T,v),z&&!i&&m.createElement(ee,{onClick:this.clearButtonClick,key:"clearbutton"}),i&&m.createElement(p.IconWrap,{className:p.classNames(p.uComboBox.loadingIcon({c:V})),name:"loading",key:"loading"}),this.props.suffix&&m.createElement(j,{...U}),m.createElement(te.Button,{tabIndex:-1,type:"button","aria-label":b?e:s,svgIcon:g||(c?void 0:se.caretAltDownIcon),iconClass:c,size:x,fillMode:y,className:p.classNames(p.uComboBox.inputButton({c:V})),onClick:this.toggleBtnClick,onMouseDown:G=>G.preventDefault()}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return l?m.createElement(Y.FloatingLabel,{label:l,editorId:T,editorValue:O,editorValid:F,editorDisabled:a,style:{width:n?n.width:void 0},children:P,unstyled:I}):P}onNavigate(s,e,t){const{virtual:a={skip:0}}=this.props,r=d.getFilteredData(this.props),l=this.props.filter?this.props.filter:this.state.text;let o=-1,h;const n=this.base.vs,i=this.value;this._suggested="";const c=this.hasDuplicates&&this.duplicates.indexOf(i)!==-1;if(o=this.getFocusedIndex(c),o!==-1&&!d.isPresent(i))this.handleItemSelect(o,s);else if(l==="")this.handleItemSelect(0,s);else{const u=a.skip+o;h=this.base.navigation.navigate({keyCode:e,current:u,max:(n.enabled?n.total:r.length)-1,min:0,skipItems:t||void 0}),h!==void 0&&this.handleItemSelect(h,s)}this.navigationIndex=h}getCurrentValueDisabledStatus(s,e,t){return s&&e&&e[t]&&e[t].disabled}applyValueOnEnter(s,e){const{textField:t,allowCustom:a,ignoreCase:r}=this.props,l=d.getFilteredData(this.props),o=this.props.opened!==void 0?this.props.opened:this.state.opened,n=d.getItemValue(this.value,t)===s?this.index:d.getItemIndexByText(l,s,t,!1,r),i=n!==-1;let c;if(this._suggested="",i)c=l[n];else if(a)c=t!==void 0?{[t]:s}:s;else return this.selectFocusedItem(s,e);this.triggerOnChange(c,e),o&&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:a,ignoreCase:r}=this.props,l=d.getFilteredData(this.props),o=this.props.opened!==void 0?this.props.opened:this.state.opened,h=d.getItemValue(this.value,t);if(this._suggested="",s===h||s===""&&!d.isPresent(h))return this.closeOpenedApplyStateNonMobileMode(e,o),this.applyState(e);const n=d.getItemIndexByText(l,s,t,!0,r),i=n!==-1;let c=null;i?c=l[n]:a&&(c=s?t?{[t]:s}:s:null),this.triggerOnChange(c,e),this.state.text!==void 0&&(e.data.text=void 0,this.base.filterChanged("",e)),this.closeOpenedApplyStateNonMobileMode(e,o),this.applyState(e)}selectFocusedItem(s,e){const t=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:a,virtual:r={skip:0},focusedItemIndex:l=d.itemIndexStartsWith}=this.props,o=d.getFilteredData(this.props),h=r.skip,n=s===""&&h===0?0:l(o,s,a);return n!==-1?this.handleItemSelect(n+h,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:a}=this.props,r=d.getFilteredData(this.props),l=this.props.opened!==void 0?this.props.opened:this.state.opened;let{group:o}=this.state;o===void 0&&e!==void 0&&(o=d.getItemValue(r[0],e));const h={title:t||this.props.label,subTitle:a,expand:l,onClose:n=>this.toggleBtnClick(n),windowWidth:s,mobileFilter:this.renderMobileListFilter()};return m.createElement(oe.AdaptiveMode,{...h},m.createElement(ie.ActionSheetContent,null,m.createElement("div",{className:"k-list-container"},this.listContainerContent())))}renderListContainer(){const s=this.base,{dir:e,header:t,footer:a,groupField:r,size:l,list:o,virtual:h,groupStickyHeaderItemRender:n,unstyled:i}=this.props,c=d.getFilteredData(this.props),u=this.props.opened!==void 0?this.props.opened:this.state.opened,x=s.getPopupSettings(),C=x.width!==void 0?x.width:s.popupWidth,y=i&&i.uComboBox;let{group:b}=this.state;return b===void 0&&r!==void 0&&(b=d.getItemValue(c[0],r)),m.createElement(Q,{width:C,popupSettings:{...x,anchor:x.anchor||this.element,show:u,popupClass:p.classNames(x.popupClass,p.uComboBox.listContainer({c:y,popup:!0}))},dir:e!==void 0?e:this.base.dirCalculated,itemsCount:[c.length]},m.createElement("div",{className:p.classNames(p.uComboBox.list({c:y,list:o,size:l,tableSize:l,virtual:h}))},t&&m.createElement("div",{className:p.classNames(p.uComboBox.listHeader({c:y}))},t),!o&&b&&c.length!==0&&m.createElement(_,{group:b,render:n}),this.renderList(),a&&m.createElement("div",{className:p.classNames(p.uComboBox.listFooter({c:y}),this.props.footerClassName)},a)),this.showLicenseWatermark&&m.createElement(p.WatermarkOverlay,{message:this.licenseMessage}))}renderList(){const s=this.base,{textField:e,dataItemKey:t,listNoDataRender:a,itemRender:r,groupHeaderItemRender:l,virtual:o={skip:0,total:void 0},unstyled:h}=this.props,n=d.getFilteredData(this.props),i=s.getPopupSettings(),c=s.vs,u=o.skip,x=this.props.opened!==void 0?this.props.opened:this.state.opened,C=`translateY(${c.translate}px)`,y=x?this.getFocusedIndex(this.hasDuplicates):void 0,b=this.props.filter!==void 0?this.props.filter:this.state.text,v=d.getItemValue(this.value,e),g=d.isPresent(b)&&b!==v?null:this.value,I=this.props.list||X,F=h&&h.uComboBox;return m.createElement(I,{id:s.listBoxId,virtual:!!o,show:x,data:n,focusedIndex:y,value:g,textField:e,valueField:t,groupField:this.props.groupField,isMultiColumn:this.props.isMultiColumn,optionsGuid:s.guid,hasDuplicates:this.hasDuplicates,listRef:D=>{c.list=this.base.list=D,this.itemHeight=0},wrapperStyle:this.mobileMode?{}:{maxHeight:i.height},wrapperCssClass:p.classNames(p.uComboBox.listContent({c:F,virtual:o})),listStyle:c.enabled?{transform:C}:void 0,key:"listkey",skip:u,onClick:this.handleItemClick,itemRender:r,groupHeaderItemRender:l,noDataRender:a,onMouseDown:D=>D.preventDefault(),onScroll:this.onScroll,wrapperRef:c.scrollerRef,scroller:this.base.renderScrollElement(),ariaSetSize:o.total})}renderSearchBar(s,e,t){const{tabIndex:a,accessKey:r,disabled:l,title:o,ariaLabelledBy:h,ariaDescribedBy:n,dataItemKey:i,virtual:c={skip:0},unstyled:u,inputAttributes:x}=this.props,C=d.getFilteredData(this.props),y=this.props.opened!==void 0?this.props.opened:this.state.opened,b=this.value,v=Math.max(0,C.findIndex(g=>d.areSame(g,b,i)));return this._suggested&&!d.areSame(this._valueOnDidUpdate,b,i)&&(this._suggested=""),m.createElement(J,{id:e,readOnly:y&&this.mobileMode,placeholder:t,tabIndex:a,accessKey:r,title:o,value:s+this._suggested,suggestedText:this._suggested,ref:g=>{this._input=g&&g.input},onClick:this.onInputClick,onKeyDown:this.onInputKeyDown,onChange:this.inputOnChange,onFocus:this.base.handleFocus,onBlur:this.handleBlur,disabled:l,expanded:y,owns:this.base.listBoxId,activedescendant:`option-${this.base.guid}-${v+c.skip}`,role:"combobox",ariaLabelledBy:h,ariaLabel:this.props.ariaLabel,ariaDescribedBy:n,ariaRequired:this.required,render:this.props.valueRender,ariaControls:y?this.base.listBoxId:void 0,unstyled:u,inputAttributes:x})}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&&(!d.isPresent(t)&&!d.isPresent(s)||d.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:a,virtual:r={skip:0},focusedItemIndex:l=d.itemIndexStartsWith,skipDisabledItems:o}=this.props,h=d.getFilteredData(this.props),n=this.props.filter?this.props.filter:this.state.text;return s&&this.navigationIndex!==void 0?this.navigationIndex:d.isPresent(e)&&n===void 0?h.findIndex(i=>d.areSame(i,e,a)):n?l(h,n,t):o&&t&&!n&&r.skip===0?h.findIndex(i=>!i.disabled):r.skip===0?0:-1}suggestValue(s){const{data:e,textField:t}=this.props;this._suggested=d.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(["small","medium","large"]),rounded:f.oneOf(["small","medium","large","full","none"]),fillMode:f.oneOf(["solid","flat","outline"]),dataItemKey:f.string,groupField:f.string,isMultiColumn:f.bool,suggest:f.bool,placeholder:f.string,title:f.string,allowCustom:f.bool,ignoreCase:f.bool,clearButton:f.bool,iconClassName:f.string,svgIcon:p.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:void 0,rounded:void 0,fillMode:void 0,allowCustom:!1,ignoreCase:!1,clearButton:!0,required:!1,isMultiColumn:!1,skipDisabledItems:!0,prefix:void 0,suffix:void 0};let M=S;const R=p.createPropsContext(),q=p.withIdHOC(p.withPropsContext(R,p.withUnstyledHOC(p.withAdaptiveModeContext(M))));q.displayName="KendoReactComboBox";exports.ComboBox=q;exports.ComboBoxPropsContext=R;exports.ComboBoxWithoutContext=M;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("react"),f=require("prop-types"),E=require("../common/DropDownBase.js"),p=require("@progress/kendo-react-common"),Y=require("@progress/kendo-react-labels"),d=require("../common/utils.js"),J=require("../common/SearchBar.js"),Q=require("../common/ListContainer.js"),X=require("../common/List.js"),Z=require("../common/ListFilter.js"),_=require("../common/GroupStickyHeader.js"),K=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"),L=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($),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.scrollToFocused=!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 a=this.props.data;this.duplicates=d.getPlainDataDuplicates(a),this.hasDuplicates=this.duplicates.length>0}},this.handleKendoPasteValue=e=>{const{data:t,textField:a,allowCustom:r}=this.props;if(!t)return;const l=e!=null?String(e):"",o=d.getItemIndexByText(t,l,a,!1,!0),h=o!==-1;let n=null;if(h?n=t[o]:r&&(n=a?{[a]:l}:l),n===null)return;const i=this.base.initState();i.syntheticEvent={target:this._element,currentTarget:this._element,nativeEvent:new Event("change",{bubbles:!0})},this.state.text!==void 0&&(i.data.text=void 0),this.triggerOnChange(n,i),this.applyState(i)},this.handleItemSelect=(e,t)=>{const{virtual:a,dataItemKey:r}=this.props,l=d.getFilteredData(this.props),o=a?a.skip:0,h=l[e-o],n=this.hasDuplicates||!d.areSame(h,this.value,r);this.triggerOnChange(h,t),this.state.text!==void 0&&(t.data.text=void 0),n&&this.base.triggerPageChangeCornerItems(h,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:a}=this.props,r=d.getFilteredData(this.props),l=this.getFocusedIndex(),o=this.getCurrentValueDisabledStatus(a,r,l),h=this.props.opened!==void 0?this.props.opened:this.state.opened,n=this.base.initState();if(n.syntheticEvent=e,!t&&a&&o&&this.clearValueOnToggleBtnClick(e),this.base.togglePopup(n),!h&&this.mobileMode){const i=this.props.adaptiveFilter!==void 0?this.props.adaptiveFilter:this.state.text||null;this.base.filterChanged(i,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=d.getItemValue(this.value,this.props.textField),a=d.isPresent(e)?e:t;return m.createElement(Z,{value:a,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:a,groupStickyHeaderItemRender:r,groupField:l,list:o,unstyled:h,virtual:n}=this.props,i=d.getFilteredData(this.props),c=h&&h.uComboBox;let{group:u}=this.state;return u===void 0&&l!==void 0&&(u=d.getItemValue(i[0],l)),m.createElement("div",{className:p.classNames(p.uComboBox.list({c,list:o,size:"large",tableSize:a,virtual:n}))},e&&m.createElement("div",{className:p.classNames(p.uComboBox.listHeader({c}))},e),!o&&u&&i.length!==0&&m.createElement(_,{group:u,render:r}),this.renderList(),t&&m.createElement("div",{className:p.classNames(p.uComboBox.listFooter({c}),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:a}=this.base;t.scrollHandler(e);const{groupField:r}=this.props;this.props.onListScroll&&this.props.onListScroll(e);let l=d.getFilteredData(this.props);if(!r||!l.length)return;const o=this.itemHeight=this.itemHeight||(t.enabled?t.itemHeight:a?a.children[0].offsetHeight:0),n=e.target.scrollTop-t.skip*o;l=this.base.getGroupedDataModernMode(l,r);let i=l[0][r];for(let c=1;c<l.length&&!(o*c>n);c++)l[c]&&l[c][r]&&(i=l[c][r]);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:a}=this.props,r=d.getFilteredData(this.props),l=this.getFocusedIndex(),h=!(l===-1)&&this.getCurrentValueDisabledStatus(a,r,l);t.data.focused=!1,t.events.push({type:"onBlur"}),t.syntheticEvent=e,a&&h&&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,a=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(a,r),this.applyState(r)}},this.onInputKeyDown=e=>{const{skipDisabledItems:t,textField:a,dataItemKey:r,groupField:l}=this.props,o=d.getFilteredData(this.props),h=this.value,n=Math.max(0,o.findIndex(v=>d.areSame(v,h,r))),i=e.keyCode,c=this.props.opened!==void 0?this.props.opened:this.state.opened,u=this.base.initState();if(u.syntheticEvent=e,!e.altKey&&(i===p.Keys.up||i===p.Keys.down)){if(e.preventDefault(),l!==""&&a)if(!this.props.skipDisabledItems&&c)this.onNavigate(u,i);else{let v=0;if(i===p.Keys.down||i===p.Keys.right){const g=o.slice(n+1<o.length?n+1:n).find(I=>!I.disabled);v=g&&o.indexOf(g)}else if(i===p.Keys.up||i===p.Keys.left){let g;if(n===0)g=o,v=o.findIndex(I=>!I.disabled);else{g=o.slice(0,n);let I=g.pop();for(;I&&I.disabled;)I=g.pop();v=I&&o.indexOf(I)}}if(v!==void 0){const g=v-n;this.onNavigate(u,i,g)}else v===void 0&&n===o.length-1&&this.onNavigate(u,i)}else if(!this.props.skipDisabledItems&&c)this.onNavigate(u,i);else{let v=null;if(i===p.Keys.down||i===p.Keys.right)v=o.slice(n+1).find(g=>!g.disabled);else if(i===p.Keys.up||i===p.Keys.left){const g=o.slice(0,n);for(v=g.pop();v&&v.disabled;)v=g.pop()}if(v){const g=v.id-n-1;this.onNavigate(u,i,g)}else this.onNavigate(u,i)}this.applyState(u)}const x=()=>{e.preventDefault(),this.base.togglePopup(u),this.applyState(u)},C=this.getFocusedIndex(),y=C===-1,b=!y&&this.getCurrentValueDisabledStatus(a,o,C);c?i===p.Keys.pageUp?(e.preventDefault(),this.base.scrollPopupByPageSize(-1)):i===p.Keys.pageDown?(e.preventDefault(),this.base.scrollPopupByPageSize(1)):e.altKey&&i===p.Keys.up?x():i===p.Keys.enter?(e.preventDefault(),(a&&!y&&e.currentTarget.value?o[C][a]:void 0)?!t&&a&&b?this.clearValueOnEnterOrEsc(e):b||this.applyValueOnEnter(e.currentTarget.value,u):this.applyValueOnEnter(e.currentTarget.value,u)):i===p.Keys.esc&&(!t&&a&&b&&this.clearValueOnEnterOrEsc(e),this.applyValueOnRejectSuggestions(e.currentTarget.value,u)):!c&&i===p.Keys.esc?this.clearValueOnEnterOrEsc(e):e.altKey&&i===p.Keys.down&&x()},this.inputOnChange=e=>{const t=this.base.initState();t.syntheticEvent=e;const a=this.props.opened!==void 0?this.props.opened:this.state.opened,r=e.currentTarget,l=r.value;if(this.props.suggest){const o=r.selectionEnd===l.length;let h=this.props.filter!==void 0?this.props.filter:this.state.text;d.isPresent(h)||(h=d.getItemValue(this.value,this.props.textField)||"");const n=h&&h===l,i=h&&h.length>l.length;n||i||!o?this._suggested="":this.suggestValue(l)}this.props.filter===void 0&&(t.data.text=l),this.state.focusedItem!==void 0&&(t.data.focusedItem=void 0),a?this.scrollToFocused=!0: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=!p.validatePackage(K.packageMetadata,{component:"ComboBox"}),this.licenseMessage=p.getLicenseMessage(K.packageMetadata)}get _inputId(){return this.props.id}get document(){if(p.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=d.getFilteredData(this.props),t=this.value;return e.findIndex(a=>d.areSame(a,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 x,C;const{dataItemKey:t,virtual:a,groupField:r="",textField:l}=this.props,o=d.getFilteredData(this.props),h=s.virtual?s.virtual.total:0,n=this.props.opened!==void 0?this.props.opened:this.state.opened,i=s.opened!==void 0?s.opened:e.opened;s.data!==o&&this.checkForDuplicatePlainTextRecords();const c=!i&&n,u=this.value;if(this._valueOnDidUpdate=u,this.base.didUpdate(),a&&a.total!==h)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:o.findIndex(g=>d.areSame(g,u,t));l&&u&&(b=(x=this.base.getGroupedDataModernMode(o,r))==null?void 0:x.map(g=>g[l]).indexOf(u[l]));const v=!d.areSame(y,u,t);if(c&&a?this.base.scrollToVirtualItem(a,b):c&&!a?(this.onPopupOpened(),o&&o.length!==0&&this.base.resetGroupStickyHeader(o[0][r],this),this.base.scrollToItem(b)):(this.hasDuplicates||n&&i&&u&&v)&&this.base.scrollToItem(b),n&&i&&this.scrollToFocused){const g=(C=this.props.filter?this.props.filter:this.state.text)!=null?C:"";if(g){const{focusedItemIndex:I=d.itemIndexStartsWith}=this.props,F=I(o,g,l);this.base.scrollToItem(F)}else this.base.scrollToItem(0)}}this.scrollToFocused=!1,c&&this._input&&this._input.focus(),this.setValidity()}componentDidMount(){var e;this.observerResize=p.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(e=this.document)!=null&&e.body&&this.observerResize&&this.observerResize.observe(this.document.body),this.checkForDuplicatePlainTextRecords();const s=this.props.name||this.props.id;this.KendoPasteSubscription=p.subscribeToKendoPaste(this._element,{fieldName:s,onValueChange:t=>{this.handleKendoPasteValue(t)}})}componentWillUnmount(){var s,e;(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.disconnect(),(e=this.KendoPasteSubscription)==null||e.unsubscribe()}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:a,clearButton:r=S.defaultProps.clearButton,label:l,textField:o,className:h,style:n,loading:i,iconClassName:c,virtual:u,size:x,rounded:C,fillMode:y,opened:b=this.state.opened,placeholder:v,svgIcon:g,unstyled:I}=this.props,F=!this.validityStyles||this.validity.valid,D=this.props.filter!==void 0?this.props.filter:this.state.text,A=d.getItemValue(this.value,o),O=d.isPresent(D)?D:A,z=r&&(!!O||d.isPresent(this.value)),B=this.base.vs,T=this.props.id||this._inputId,V=I&&I.uComboBox;B.enabled=u!==void 0,u!==void 0&&(B.skip=u.skip,B.total=u.total,B.pageSize=u.pageSize);const[H,W]=L(this.props.prefix||m.Fragment),[j,U]=L(this.props.suffix||m.Fragment),P=m.createElement(m.Fragment,null,m.createElement("span",{className:p.classNames(p.uComboBox.wrapper({c:V,size:x,rounded:C,fillMode:y,disabled:a,invalid:!F,loading:i,required:this.required}),h),ref:this.componentRef,style:l?{...n,width:void 0}:n,dir:t,onFocus:this.handleFocus},this.props.prefix&&m.createElement(H,{...W}),this.renderSearchBar(O||"",T,v),z&&!i&&m.createElement(ee,{onClick:this.clearButtonClick,key:"clearbutton"}),i&&m.createElement(p.IconWrap,{className:p.classNames(p.uComboBox.loadingIcon({c:V})),name:"loading",key:"loading"}),this.props.suffix&&m.createElement(j,{...U}),m.createElement(te.Button,{tabIndex:-1,type:"button","aria-label":b?e:s,svgIcon:g||(c?void 0:se.chevronDownIcon),iconClass:c,size:x,fillMode:y,className:p.classNames(p.uComboBox.inputButton({c:V})),onClick:this.toggleBtnClick,onMouseDown:G=>G.preventDefault()}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return l?m.createElement(Y.FloatingLabel,{label:l,editorId:T,editorValue:O,editorValid:F,editorDisabled:a,style:{width:n?n.width:void 0},children:P,unstyled:I}):P}onNavigate(s,e,t){const{virtual:a={skip:0}}=this.props,r=d.getFilteredData(this.props),l=this.props.filter?this.props.filter:this.state.text;let o=-1,h;const n=this.base.vs,i=this.value;this._suggested="";const c=this.hasDuplicates&&this.duplicates.indexOf(i)!==-1;if(o=this.getFocusedIndex(c),o!==-1&&!d.isPresent(i))this.handleItemSelect(o,s);else if(l==="")this.handleItemSelect(0,s);else{const u=a.skip+o;h=this.base.navigation.navigate({keyCode:e,current:u,max:(n.enabled?n.total:r.length)-1,min:0,skipItems:t||void 0}),h!==void 0&&this.handleItemSelect(h,s)}this.navigationIndex=h}getCurrentValueDisabledStatus(s,e,t){return s&&e&&e[t]&&e[t].disabled}applyValueOnEnter(s,e){const{textField:t,allowCustom:a,ignoreCase:r}=this.props,l=d.getFilteredData(this.props),o=this.props.opened!==void 0?this.props.opened:this.state.opened,n=d.getItemValue(this.value,t)===s?this.index:d.getItemIndexByText(l,s,t,!1,r),i=n!==-1;let c;if(this._suggested="",i)c=l[n];else if(a)c=t!==void 0?{[t]:s}:s;else return this.selectFocusedItem(s,e);this.triggerOnChange(c,e),o&&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:a,ignoreCase:r}=this.props,l=d.getFilteredData(this.props),o=this.props.opened!==void 0?this.props.opened:this.state.opened,h=d.getItemValue(this.value,t);if(this._suggested="",s===h||s===""&&!d.isPresent(h))return this.closeOpenedApplyStateNonMobileMode(e,o),this.applyState(e);const n=d.getItemIndexByText(l,s,t,!0,r),i=n!==-1;let c=null;i?c=l[n]:a&&(c=s?t?{[t]:s}:s:null),this.triggerOnChange(c,e),this.state.text!==void 0&&(e.data.text=void 0,this.base.filterChanged("",e)),this.closeOpenedApplyStateNonMobileMode(e,o),this.applyState(e)}selectFocusedItem(s,e){const t=this.props.opened!==void 0?this.props.opened:this.state.opened,{textField:a,virtual:r={skip:0},focusedItemIndex:l=d.itemIndexStartsWith}=this.props,o=d.getFilteredData(this.props),h=r.skip,n=s===""&&h===0?0:l(o,s,a);return n!==-1?this.handleItemSelect(n+h,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:a}=this.props,r=d.getFilteredData(this.props),l=this.props.opened!==void 0?this.props.opened:this.state.opened;let{group:o}=this.state;o===void 0&&e!==void 0&&(o=d.getItemValue(r[0],e));const h={title:t||this.props.label,subTitle:a,expand:l,onClose:n=>this.toggleBtnClick(n),windowWidth:s,mobileFilter:this.renderMobileListFilter()};return m.createElement(oe.AdaptiveMode,{...h},m.createElement(ie.ActionSheetContent,null,m.createElement("div",{className:"k-list-container"},this.listContainerContent())))}renderListContainer(){const s=this.base,{dir:e,header:t,footer:a,groupField:r,size:l,list:o,virtual:h,groupStickyHeaderItemRender:n,unstyled:i}=this.props,c=d.getFilteredData(this.props),u=this.props.opened!==void 0?this.props.opened:this.state.opened,x=s.getPopupSettings(),C=x.width!==void 0?x.width:s.popupWidth,y=i&&i.uComboBox;let{group:b}=this.state;return b===void 0&&r!==void 0&&(b=d.getItemValue(c[0],r)),m.createElement(Q,{width:C,popupSettings:{...x,anchor:x.anchor||this.element,show:u,popupClass:p.classNames(x.popupClass,p.uComboBox.listContainer({c:y,popup:!0}))},dir:e!==void 0?e:this.base.dirCalculated,itemsCount:[c.length]},m.createElement("div",{className:p.classNames(p.uComboBox.list({c:y,list:o,size:l,tableSize:l,virtual:h}))},t&&m.createElement("div",{className:p.classNames(p.uComboBox.listHeader({c:y}))},t),!o&&b&&c.length!==0&&m.createElement(_,{group:b,render:n}),this.renderList(),a&&m.createElement("div",{className:p.classNames(p.uComboBox.listFooter({c:y}),this.props.footerClassName)},a)),this.showLicenseWatermark&&m.createElement(p.WatermarkOverlay,{message:this.licenseMessage}))}renderList(){const s=this.base,{textField:e,dataItemKey:t,listNoDataRender:a,itemRender:r,groupHeaderItemRender:l,virtual:o={skip:0,total:void 0},unstyled:h}=this.props,n=d.getFilteredData(this.props),i=s.getPopupSettings(),c=s.vs,u=o.skip,x=this.props.opened!==void 0?this.props.opened:this.state.opened,C=`translateY(${c.translate}px)`,y=x?this.getFocusedIndex(this.hasDuplicates):void 0,b=this.props.filter!==void 0?this.props.filter:this.state.text,v=d.getItemValue(this.value,e),g=d.isPresent(b)&&b!==v?null:this.value,I=this.props.list||X,F=h&&h.uComboBox;return m.createElement(I,{id:s.listBoxId,virtual:!!o,show:x,data:n,focusedIndex:y,value:g,textField:e,valueField:t,groupField:this.props.groupField,isMultiColumn:this.props.isMultiColumn,optionsGuid:s.guid,hasDuplicates:this.hasDuplicates,listRef:D=>{c.list=this.base.list=D,this.itemHeight=0},wrapperStyle:this.mobileMode?{}:{maxHeight:i.height},wrapperCssClass:p.classNames(p.uComboBox.listContent({c:F,virtual:o})),listStyle:c.enabled?{transform:C}:void 0,key:"listkey",skip:u,onClick:this.handleItemClick,itemRender:r,groupHeaderItemRender:l,noDataRender:a,onMouseDown:D=>D.preventDefault(),onScroll:this.onScroll,wrapperRef:c.scrollerRef,scroller:this.base.renderScrollElement(),ariaSetSize:o.total})}renderSearchBar(s,e,t){const{tabIndex:a,accessKey:r,disabled:l,title:o,ariaLabelledBy:h,ariaDescribedBy:n,dataItemKey:i,virtual:c={skip:0},unstyled:u,inputAttributes:x}=this.props,C=d.getFilteredData(this.props),y=this.props.opened!==void 0?this.props.opened:this.state.opened,b=this.value,v=Math.max(0,C.findIndex(g=>d.areSame(g,b,i)));return this._suggested&&!d.areSame(this._valueOnDidUpdate,b,i)&&(this._suggested=""),m.createElement(J,{id:e,readOnly:y&&this.mobileMode,placeholder:t,tabIndex:a,accessKey:r,title:o,value:s+this._suggested,suggestedText:this._suggested,ref:g=>{this._input=g&&g.input},onClick:this.onInputClick,onKeyDown:this.onInputKeyDown,onChange:this.inputOnChange,onFocus:this.base.handleFocus,onBlur:this.handleBlur,disabled:l,expanded:y,owns:this.base.listBoxId,activedescendant:`option-${this.base.guid}-${v+c.skip}`,role:"combobox",ariaLabelledBy:h,ariaLabel:this.props.ariaLabel,ariaDescribedBy:n,ariaRequired:this.required,render:this.props.valueRender,ariaControls:y?this.base.listBoxId:void 0,unstyled:u,inputAttributes:x})}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&&(!d.isPresent(t)&&!d.isPresent(s)||d.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:a,virtual:r={skip:0},focusedItemIndex:l=d.itemIndexStartsWith,skipDisabledItems:o}=this.props,h=d.getFilteredData(this.props),n=this.props.filter?this.props.filter:this.state.text;return s&&this.navigationIndex!==void 0?this.navigationIndex:d.isPresent(e)&&n===void 0?h.findIndex(i=>d.areSame(i,e,a)):n?l(h,n,t):o&&t&&!n&&r.skip===0?h.findIndex(i=>!i.disabled):r.skip===0?0:-1}suggestValue(s){const{data:e,textField:t}=this.props;this._suggested=d.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(["small","medium","large"]),rounded:f.oneOf(["small","medium","large","full","none"]),fillMode:f.oneOf(["solid","flat","outline"]),dataItemKey:f.string,groupField:f.string,isMultiColumn:f.bool,suggest:f.bool,placeholder:f.string,title:f.string,allowCustom:f.bool,ignoreCase:f.bool,clearButton:f.bool,iconClassName:f.string,svgIcon:p.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:void 0,rounded:void 0,fillMode:void 0,allowCustom:!1,ignoreCase:!1,clearButton:!0,required:!1,isMultiColumn:!1,skipDisabledItems:!0,prefix:void 0,suffix:void 0};let M=S;const R=p.createPropsContext(),q=p.withIdHOC(p.withPropsContext(R,p.withUnstyledHOC(p.withAdaptiveModeContext(M))));q.displayName="KendoReactComboBox";exports.ComboBox=q;exports.ComboBoxPropsContext=R;exports.ComboBoxWithoutContext=M;
|
package/ComboBox/ComboBox.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import z from "../common/GroupStickyHeader.mjs";
|
|
|
19
19
|
import { packageMetadata as H } from "../package-metadata.mjs";
|
|
20
20
|
import xt from "../common/ClearButton.mjs";
|
|
21
21
|
import { Button as It } from "@progress/kendo-react-buttons";
|
|
22
|
-
import {
|
|
22
|
+
import { chevronDownIcon as yt } from "@progress/kendo-svg-icons";
|
|
23
23
|
import { comboArrowBtnAriaLabelExpand as q, messages as W, comboArrowBtnAriaLabelCollapse as G } from "../messages/index.mjs";
|
|
24
24
|
import { provideLocalizationService as U } from "@progress/kendo-react-intl";
|
|
25
25
|
import { ActionSheetContent as Ct } from "@progress/kendo-react-layout";
|
|
@@ -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 Wt=require("react"),L=require("prop-types"),o=require("@progress/kendo-react-common"),_t=require("@progress/kendo-react-labels"),Ut=require("@progress/kendo-svg-icons"),Gt=require("../common/ListContainer.js"),jt=require("../common/ListFilter.js"),tt=require("../common/GroupStickyHeader.js"),$t=require("../common/ListDefaultItem.js"),Yt=require("../common/List.js"),rt=require("../common/DropDownBase.js"),d=require("../common/utils.js"),nt=require("../package-metadata.js"),Jt=require("@progress/kendo-react-buttons"),Qt=require("@progress/kendo-react-intl"),Y=require("../messages/index.js"),Rt=require("@progress/kendo-react-layout"),Xt=require("../common/AdaptiveMode.js");function Zt(M){const J=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(M){for(const O in M)if(O!=="default"){const re=Object.getOwnPropertyDescriptor(M,O);Object.defineProperty(J,O,re.get?re:{enumerable:!0,get:()=>M[O]})}}return J.default=M,Object.freeze(J)}const s=Zt(Wt),en="Please select a value from the list!",fe=s.forwardRef((M,J)=>{let O=!1;const re=o.getLicenseMessage(nt.packageMetadata),n=o.usePropsContext(ot,M),{delay:at=P.delay,tabIndex:st=P.tabIndex,ignoreCase:Q=P.ignoreCase,size:T=P.size,rounded:Ne=P.rounded,fillMode:ve=P.fillMode}=n;if(n.filterable||n.virtual){const e=[];n.filterable&&e.push("filterable"),n.virtual&&e.push("virtualization"),O=!o.validatePackage(nt.packageMetadata,{component:"DropDownList",features:e})}const E=o.useUnstyled(),ye=o.useId(n.id),De=()=>{var e;if(o.canUseDOM)return((e=V.current)==null?void 0:e.ownerDocument)||window.document},it=()=>{var e,r;(e=t==null?void 0:t.current)!=null&&e.wrapper&&((r=t==null?void 0:t.current)==null||r.wrapper.focus({preventScroll:!0}))},k=()=>{let e;return A.current!==void 0&&A.current!==null?e=A.current:n.value!==void 0?e=n.value:f.value!==void 0&&f.value!==null?e=f.value:n.defaultValue!==void 0&&n.defaultValue!==null&&(e=n.defaultValue),!d.isPresent(e)&&n.defaultItem!==void 0&&n.defaultItem!==null&&(e=n.defaultItem),e},lt=()=>{const{dataItemKey:e}=n,r=d.getFilteredData(n),a=k();return r.findIndex(c=>d.areSame(c,a,e))},Ie=()=>n.required!==void 0?n.required:P.required,he=()=>{const e=n.validationMessage!==void 0,r=k(),a=!Ie()||r!==null&&r!==""&&r!==void 0,c=n.valid!==void 0?n.valid:a;return{customError:e,valid:c,valueMissing:r===null}},dt=()=>n.validityStyles!==void 0?n.validityStyles:P.validityStyles,oe=e=>{ae.current=!0,e.focus(),window.setTimeout(()=>ae.current=!1,30)},we=()=>{X.current&&oe(X.current),n.adaptive&&setTimeout(()=>{X.current&&oe(X.current)},300)},ct=s.useCallback(e=>{for(const r of e)Ft(r.target.clientWidth)},[]),Me=()=>{var e;(e=Le.current)!=null&&e.setCustomValidity&&Le.current.setCustomValidity(he().valid?"":n.validationMessage||en)},q=(e,r)=>{const a=k();d.areSame(a,e,n.dataItemKey)||(n.value===void 0&&(r.data.value=e),t.current.updateComponentArgs({value:e}),A.current=e,r.events.push({type:"onChange"}))},b=e=>{var r;(r=t==null?void 0:t.current)==null||r.applyState(e),A.current=void 0},R=(e,r)=>{var m;const{virtual:a,dataItemKey:c,defaultItem:l}=n,p=d.getFilteredData(n),g=a?a.skip:0,v=k(),u=e===-1&&l!==void 0?l:p[e-g],y=!d.areSame(u,v,c);q(u,r),y&&((m=t==null?void 0:t.current)==null||m.triggerPageChangeCornerItems(u,r))},z=(e,r,a)=>{var C,D;const{defaultItem:c,dataItemKey:l,virtual:p={skip:0,total:0,pageSize:0}}=n,g=k(),v=d.getFilteredData(n),u=(C=t==null?void 0:t.current)==null?void 0:C.vs,y=v.findIndex(I=>d.areSame(I,g,l)),m=(D=t==null?void 0:t.current)==null?void 0:D.navigation.navigate({current:p.skip+y,max:(u!=null&&u.enabled?p.total:v.length)-1,min:c!==void 0?-1:0,keyCode:r,skipItems:a||void 0});m!==void 0&&R(m,e),b(e)},ut=e=>{V.current=e,t.current.wrapper=e},pt=e=>s.createElement("select",{name:n.name,ref:r=>{Le.current=r},tabIndex:-1,"aria-hidden":!0,title:n.label,style:{opacity:0,width:1,border:0,zIndex:-1,position:"absolute",left:"50%"}},s.createElement("option",{value:n.valueMap?n.valueMap.call(void 0,e):e})),Se=()=>{const{textField:e,dataItemKey:r,virtual:a={skip:0},focusedItemIndex:c=d.itemIndexStartsWith,filterable:l,skipDisabledItems:p=!0}=n,g=k(),v=d.getFilteredData(n),u=n.filter?n.filter:f.text;return p&&e&&!u&&!g?v.findIndex(y=>!y.disabled):d.isPresent(g)&&u===void 0||l&&u===""?v.findIndex(y=>d.areSame(y,g,r)):u?ke.current?c(v,u,e):v.findIndex(y=>d.areSame(y,g,r)):a.skip===0?0:-1},Oe=(e,r)=>r!==void 0&&r!==-1&&e&&e.length>0&&e[r].disabled,xe=()=>{const e=d.getFilteredData(n),r=t.current.initState(),a=Se();Oe(e,a)&&(q(null,r),b(r))},Ce=e=>{if(e.isPropagationStopped())return;const r=t.current.initState();r.syntheticEvent=e,f.focused||(r.data.focused=!0),xe(),t.current.togglePopup(r),b(r)},Te=e=>{var N,me,U,ge,$,Ze,et;e&&e.target instanceof Element&&e.target.nodeName==="INPUT"&&e.stopPropagation&&e.stopPropagation();const{filterable:r,disabled:a,defaultItem:c,leftRightKeysNavigation:l=!0,virtual:p={skip:0,total:0,pageSize:0},dataItemKey:g,groupField:v="",textField:u,skipDisabledItems:y=!0}=n,m=d.getFilteredData(n),C=k(),D=m.findIndex(w=>d.areSame(w,C,g)),I=n.opened!==void 0?n.opened:f.opened,i=e.keyCode,F=i===o.Keys.home||i===o.Keys.end,K=i===o.Keys.up||i===o.Keys.down,j=!I&&(e.altKey&&i===o.Keys.down||i===o.Keys.enter||i===o.Keys.space),ne=I&&(e.altKey&&i===o.Keys.up||i===o.Keys.esc),ue=l&&(i===o.Keys.left||i===o.Keys.right),pe=K||ue&&!r||F,h=t.current.initState();if(h.syntheticEvent=e,!a){if(F&&((N=t==null?void 0:t.current)!=null&&N.vs.enabled))i===o.Keys.home?p.skip!==0?((me=t==null?void 0:t.current)==null||me.triggerOnPageChange(h,0,p.pageSize),B.current=!0):q(m[0],h):p.skip<p.total-p.pageSize?((U=t==null?void 0:t.current)==null||U.triggerOnPageChange(h,p.total-p.pageSize,p.pageSize),B.current=!0):q(m[m.length-1],h);else if(I&&i===o.Keys.pageUp)e.preventDefault(),(ge=t==null?void 0:t.current)==null||ge.scrollPopupByPageSize(-1);else if(I&&i===o.Keys.pageDown)e.preventDefault(),($=t==null?void 0:t.current)==null||$.scrollPopupByPageSize(1);else if(I&&i===o.Keys.enter){const w=Se();Oe(m,w)?(q(null,h),b(h)):R(w,h),(Ze=t==null?void 0:t.current)==null||Ze.togglePopup(h),e.preventDefault()}else if(j||ne)ne&&xe(),(et=t==null?void 0:t.current)==null||et.togglePopup(h),e.preventDefault();else if(pe){if(ke.current=!1,v!==""&&u)if(!y&&I)z(h,i);else{let w;if(i===o.Keys.down||i===o.Keys.right){const S=m.slice(D+1).find(x=>!x.disabled);w=S&&m.indexOf(S)}else if(i===o.Keys.up||i===o.Keys.left){let S;if(D===0&&c)w=-1;else if(D===-1)S=m,w=m.findIndex(x=>!x.disabled);else{S=m.slice(0,D);let x=S.pop();for(;x&&x.disabled;)x=S.pop();w=x&&m.indexOf(x)}}if(w!==void 0){const S=w-D;z(h,i,S)}else w===void 0&&D===m.length-1&&z(h,i)}else if(!y&&I||F)z(h,i);else if(u){let w;if(i===o.Keys.down||i===o.Keys.right){const S=m.slice(D+1).find(x=>!x.disabled);w=S&&m.indexOf(S)}else if(i===o.Keys.up||i===o.Keys.left){let S;if(D===0&&c)w=-1;else if(D===-1)S=m,w=m.findIndex(x=>!x.disabled);else{S=m.slice(0,D);let x=S.pop();for(;x&&x.disabled;)x=S.pop();w=x&&m.indexOf(x)}}if(w!==void 0){const S=w-D;z(h,i,S)}else w===void 0&&D===m.length-1&&z(h,i)}else z(h,i);e.preventDefault()}b(h)}},mt=e=>{const r=t.current.initState();r.syntheticEvent=e.syntheticEvent,n.filter===void 0&&(r.data.text=e.target.value),t.current.filterChanged(e.target.value,r),ke.current=!0,b(r),ee({group:void 0,text:String(e.target.value)})},qe=e=>{const r=n.filter!==void 0?n.filter:f.text;return n.filterable&&s.createElement(jt,{value:r,ref:a=>{X.current=a&&a.element},onChange:mt,onKeyDown:Te,size:e?"large":T,rounded:Ne,fillMode:ve,renderListFilterWrapper:!0,placeholder:We.toLanguageString(Y.dropDownListAdaptiveFilterPlaceholder,Y.messages[Y.dropDownListAdaptiveFilterPlaceholder])})},gt=e=>{var a;const r=t.current.initState();r.syntheticEvent=e,(a=t==null?void 0:t.current)==null||a.togglePopup(r),q(n.defaultItem,r),b(r)},ft=()=>{const{textField:e,defaultItem:r,dataItemKey:a}=n,c=k();return r!==void 0&&s.createElement($t,{defaultItem:r,textField:e,selected:d.areSame(c,r,a),key:"defaultitemkey",onClick:gt})},vt=(e,r)=>{var a;(a=t==null?void 0:t.current)==null||a.handleItemClick(e,r),A.current=void 0},yt=e=>{const{vs:r,list:a}=t.current;r.scrollHandler(e);const{groupField:c}=n;let l=d.getFilteredData(n);if(!(!c||!l.length)&&c){const p=Be.current=Be.current||(r.enabled?r.itemHeight:a?a.children[0].offsetHeight:0),v=e.target.scrollTop-r.skip*p;l=t.current.getGroupedDataModernMode(l,c);let u=l[0][c];for(let y=1;y<l.length&&!(p*y>v);y++)l[y]&&l[y][c]&&(u=l[y][c]);u!==f.group&&ee({group:u})}},ze=()=>{var i;const{textField:e,dataItemKey:r,virtual:a={skip:0,total:void 0},groupHeaderItemRender:c,listNoDataRender:l,itemRender:p}=n,g=d.getFilteredData(n),v=E&&E.uDropDownList,u=t.current.vs,y=a.skip,m=n.opened!==void 0?n.opened:f.opened,C=t.current.getPopupSettings(),D=`translateY(${u.translate}px)`,I=k();return s.createElement(Yt,{id:Ee,show:m,data:g.slice(),focusedIndex:Se(),value:I,textField:e,valueField:r,optionsGuid:Ge,groupField:n.groupField,listRef:F=>{u.list=t.current.list=F},wrapperStyle:{maxHeight:_?void 0:C.height},wrapperCssClass:o.classNames(o.uDropDownList.listContent({c:v})),listStyle:u.enabled?{transform:D}:void 0,key:"listkey",skip:y,onClick:vt,itemRender:p,groupHeaderItemRender:c,noDataRender:l,onScroll:yt,wrapperRef:u.scrollerRef,scroller:(i=t==null?void 0:t.current)==null?void 0:i.renderScrollElement(),ariaSetSize:a.total})},Dt=()=>{const{groupField:e}=n,r=d.getFilteredData(n),a=n.opened!==void 0?n.opened:f.opened,c=E&&E.uDropDownList,l={title:n.adaptiveTitle||n.label,subTitle:n.adaptiveSubtitle,expand:a,onClose:g=>Ce(g),windowWidth:be,mobileFilter:qe(!0)};let{group:p}=f;return p===void 0&&e!==void 0&&(p=d.getItemValue(r[0],e)),s.createElement(Xt.AdaptiveMode,{...l},s.createElement(Rt.ActionSheetContent,null,s.createElement("div",{className:o.classNames(o.uDropDownList.listContainer({c,popup:!1}))},St())))},It=()=>{f.focused&&window.setTimeout(()=>{f.focused&&t.current.wrapper&&oe(t.current.wrapper)})},ht=e=>{"onMouseDownOutside"in(n.popupSettings||{})&&n.popupSettings.onMouseDownOutside.call(void 0,e)},wt=()=>{const{header:e,footer:r,dir:a,groupField:c,groupStickyHeaderItemRender:l,list:p}=n,g=d.getFilteredData(n),v=t.current,u=v.getPopupSettings(),y=n.opened!==void 0?n.opened:f.opened,m=u.width!==void 0?u.width:v.popupWidth,C=E&&E.uDropDownList,D={dir:a!==void 0?a:v.dirCalculated,width:m,popupSettings:{...u,popupClass:o.classNames(u.popupClass,o.uDropDownList.listContainer({c:C,popup:!0})),anchor:u.anchor||V.current,show:y,onOpen:we,onClose:It,onMouseDownOutside:ht},itemsCount:[g.length]};let{group:I}=f;return I===void 0&&c!==void 0&&(I=d.getItemValue(g[0],c)),s.createElement(Gt,{...D},qe(!1),e&&s.createElement("div",{className:o.classNames(o.uDropDownList.listHeader({c:C}))},e),s.createElement("div",{className:o.classNames(o.uDropDownList.list({c:C,size:T,virtual:t.current.vs.enabled}))},ft(),!p&&I&&g.length!==0&&s.createElement(tt,{group:I,render:l}),ze()),r&&s.createElement("div",{className:o.classNames(o.uDropDownList.listFooter({c:C}))},r),O&&s.createElement(o.WatermarkOverlay,{message:re}))},St=()=>{const{header:e,footer:r,groupStickyHeaderItemRender:a,groupField:c,list:l}=n,p=d.getFilteredData(n),g=E&&E.uDropDownList;let{group:v}=f;return v===void 0&&c!==void 0&&(v=d.getItemValue(p[0],c)),s.createElement(s.Fragment,null,e&&s.createElement("div",{className:o.classNames(o.uDropDownList.listHeader({c:g}))},e),s.createElement("div",{className:o.classNames("k-list",{[`k-list-${_?"lg":o.sizeMap[T]||T}`]:_||T})},!l&&v&&p.length!==0&&s.createElement(tt,{group:v,render:a}),ze()),r&&s.createElement("div",{className:"k-list-footer"},r))},xt=e=>{const{dataItemKey:r}=n,a=d.getFilteredData(n),c=k();let l=a.map((K,j)=>({item:K,itemIndex:j}));const p=G.current.word,g=G.current.last,v=d.sameCharsOnly(p,g);let u=l.length,y=Math.max(0,a.findIndex(K=>d.areSame(K,c,r))),m;n.defaultItem&&(m={item:n.defaultItem,itemIndex:-1},u+=1,y+=1),y+=v?1:0,l=d.shuffleData(l,y,m);let C,D,I,i=0;const{textField:F}=n;for(;i<u;){if(C=d.getItemValue(l[i].item,F),D=v&&d.matchText(C,g,Q),I=d.matchText(C,p,Q),D||I){i=l[i].itemIndex;break}i++}if(i!==u){const K=t.current.initState();K.syntheticEvent=e,R(i,K),b(K),A.current=void 0}},Ct=e=>{clearTimeout(Ae.current),n.filterable||(Ae.current=window.setTimeout(()=>G.current.word="",at),xt(e))},Lt=e=>{ae.current||t.current.handleFocus(e)},kt=e=>{if(ae.current||!f.focused)return;const r=n.opened!==void 0?n.opened:f.opened,a=t.current.initState();a.syntheticEvent=e,a.data.focused=!1,a.events.push({type:"onBlur"}),r&&xe(),r&&!_&&t.current.togglePopup(a),b(a)},Kt=e=>{if(n.filterable||e.which===0||e.keyCode===o.Keys.enter)return;let r=String.fromCharCode(e.charCode||e.keyCode);Q&&(r=r.toLowerCase()),r===" "&&e.preventDefault(),G.current={word:G.current.word+r,last:G.current.last+r},Ct(e)},bt=()=>{const e=t.current.initState();e.data.opened=f.opened,t.current.togglePopup(e),b(e)},Ve=s.useRef(null),V=s.useRef(null),Le=s.useRef(null),X=s.useRef(null);s.useImperativeHandle(Ve,()=>({get element(){return V.current},get index(){return lt()},get name(){return n.name},get validity(){return he()},get value(){return k()},get focused(){return f.focused},get opened(){return f.opened},focus:it,props:n,togglePopup:bt})),s.useImperativeHandle(J,()=>Ve.current);const Ae=s.useRef(null),G=s.useRef({word:"",last:""}),ae=s.useRef(!1),A=s.useRef(null),B=s.useRef(!1),ke=s.useRef(!1),H=s.useRef({}),Ke=s.useRef({}),t=s.useRef(new rt({props:n,setState:()=>{},state:{},forceUpdate:()=>{},element:null,value:null,handleItemSelect:()=>{}})),Be=s.useRef(0),Z=s.useRef(null),[f,Et]=s.useState({}),[be,Ft]=s.useState(),[,He]=s.useReducer(e=>e,!0),We=Qt.useLocalization(),_e=n.name||n.id,Pt=s.useCallback(e=>{if(e==null||!t.current)return;const r=d.getFilteredData(n),{textField:a}=n,c=String(e),l=d.getItemIndexByText(r,c,a,!1,Q),p=l!==-1?r[l]:void 0;if(p!==void 0){const g=t.current.initState();g.syntheticEvent={target:V.current},q(p,g),b(g)}},[n,Q]);o.useKendoPaste(V,{fieldName:_e,onValueChange:Pt,enabled:!!_e});const ee=e=>{Et({...f,...e})};s.useEffect(()=>{t.current.updateComponentArgs({props:n,setState:ee,state:f,forceUpdate:He,element:V.current,handleItemSelect:R,value:k()})},[ee,f,He,R,k]),s.useEffect(()=>{var y,m,C,D,I,i,F,K,j,ne,ue,pe,h;const{dataItemKey:e,virtual:r,groupField:a="",textField:c}=n,l=d.getFilteredData(n),p=H.current.virtual?H.current.virtual.total:0,g=n.opened!==void 0?n.opened:f.opened,v=H.current.opened!==void 0?H.current.opened:Ke.current.opened,u=!v&&g;if((y=t==null?void 0:t.current)==null||y.didUpdate(),(m=t==null?void 0:t.current)!=null&&m.getPopupSettings().animate||u&&we(),r&&r.total!==p)(C=t==null?void 0:t.current)==null||C.vs.calcScrollElementHeight(),(D=t==null?void 0:t.current)==null||D.vs.reset();else{const N=k(),me=H.current.value!==void 0?H.current.value:Ke.current.value;let U=l.findIndex($=>d.areSame($,N,e));a!==""&&N&&c&&(U=(i=(I=t==null?void 0:t.current)==null?void 0:I.getGroupedDataModernMode(l,a))==null?void 0:i.map($=>$[c]).indexOf(N[c]));const ge=!d.areSame(me,N,e);u&&r?(F=t==null?void 0:t.current)==null||F.scrollToVirtualItem(r,U):u&&!r?(we(),l&&l.length!==0&&((K=t==null?void 0:t.current)==null||K.resetGroupStickyHeader(l[0][a],{setState:ee,group:f.group,state:f})),(j=t==null?void 0:t.current)==null||j.scrollToItem(U)):g&&v&&N&&ge&&!B.current?(ue=t==null?void 0:t.current)==null||ue.scrollToItem(U,(ne=t==null?void 0:t.current)==null?void 0:ne.vs.enabled):g&&v&&B.current&&(B.current&&r&&r.skip===0?(pe=t==null?void 0:t.current)==null||pe.vs.reset():B.current&&r&&r.skip===r.total-r.pageSize&&((h=t==null?void 0:t.current)==null||h.vs.scrollToEnd()))}B.current=!1,Ke.current=f,H.current=n,Me()}),s.useEffect(()=>{var e,r;return Z.current=o.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(ct.bind(void 0)),(e=t==null?void 0:t.current)==null||e.didMount(),Me(),(r=De())!=null&&r.body&&Z.current&&Z.current.observe(De().body),()=>{var a;(a=De())!=null&&a.body&&Z.current&&Z.current.disconnect()}},[]);const Ue=ye+"-accessibility-id",Ee=ye+"-listbox-id",Ge=ye+"-guid",Nt=We.toLanguageString(Y.dropDownListArrowBtnAriaLabel,Y.messages[Y.dropDownListArrowBtnAriaLabel]),{style:se,className:Mt,label:Fe,dir:Ot,virtual:W,adaptive:tn,dataItemKey:Tt,disabled:ie,loading:je,iconClassName:$e,svgIcon:qt,valueRender:Ye}=n,le=n.opened!==void 0?n.opened:f.opened,de=k(),Pe=d.getItemValue(de,n.textField),Je=!dt()||he().valid,ce=t.current,zt=ce.vs,te=E&&E.uDropDownList;zt.enabled=W!==void 0;const Qe=o.useAdaptiveModeContext(),_=!!(be&&Qe&&be<=Qe.medium&&n.adaptive);W!==void 0&&(ce.vs.skip=W.skip,ce.vs.total=W.total,ce.vs.pageSize=W.pageSize);const Vt=d.getFilteredData(n),{focused:At}=f,Bt=Vt.findIndex(e=>d.areSame(e,de,Tt)),Re=s.createElement("span",{id:Ue,className:o.classNames(o.uDropDownList.inputInner({c:te}))},Pe&&s.createElement("span",{className:o.classNames(o.uDropDownList.inputText({c:te}))},Pe)),Ht=Ye!==void 0?Ye.call(void 0,Re,de):Re,Xe=s.createElement(s.Fragment,null,s.createElement("span",{ref:ut,className:o.classNames(o.uDropDownList.wrapper({c:te,size:T,rounded:Ne,fillMode:ve,focused:At,disabled:ie,invalid:!Je,loading:je,required:Ie()}),Mt),style:Fe?{...se,width:void 0}:se,dir:Ot,onMouseDown:le?e=>{e.target.nodeName!=="INPUT"&&(oe(t.current.wrapper),e.preventDefault())}:void 0,onFocus:_?e=>Ce(e):Lt,onBlur:kt,tabIndex:o.getTabIndex(st,ie),accessKey:n.accessKey,onKeyDown:Te,onKeyPress:Kt,onClick:ie?void 0:Ce,role:"combobox","aria-required":Ie(),"aria-disabled":ie||void 0,"aria-haspopup":"listbox","aria-expanded":le||!1,"aria-owns":Ee,"aria-activedescendant":le?"option-"+Ge+"-"+(Bt+(W?W.skip:0)):void 0,"aria-label":n.ariaLabel||n.label,"aria-labelledby":n.ariaLabelledBy,"aria-describedby":n.ariaDescribedBy||Ue,"aria-controls":le?Ee:void 0,id:n.id,title:n.title},Ht,je&&s.createElement(o.IconWrap,{className:o.classNames(o.uDropDownList.loadingIcon({c:te})),name:"loading"}),s.createElement(Jt.Button,{tabIndex:-1,type:"button","aria-label":Nt,size:T,fillMode:ve,className:o.classNames(o.uDropDownList.inputButton({c:te})),iconClass:$e,svgIcon:$e?void 0:qt||Ut.caretAltDownIcon,onMouseDown:e=>f.focused&&e.preventDefault()}),pt(de),!_&&wt()),_&&Dt());return Fe?s.createElement(_t.FloatingLabel,{label:Fe,editorValue:Pe,editorValid:Je,editorDisabled:n.disabled,style:{width:se?se.width:void 0},children:Xe}):Xe});fe.propTypes={delay:L.number,ignoreCase:L.bool,iconClassName:L.string,svgIcon:o.svgIconPropType,defaultItem:L.any,valueRender:L.func,valueMap:L.func,validationMessage:L.string,required:L.bool,id:L.string,ariaLabelledBy:L.string,ariaDescribedBy:L.string,ariaLabel:L.string,leftRightKeysNavigation:L.bool,title:L.string,groupField:L.string,list:L.any,skipDisabledItems:L.bool};const P={delay:500,tabIndex:0,ignoreCase:!0,...rt.defaultProps,required:!1,size:void 0,rounded:void 0,fillMode:void 0};fe.displayName="KendoReactDropDownList";const ot=o.createPropsContext();fe.displayName="KendoReactDropDownList";exports.DropDownList=fe;exports.DropDownListPropsContext=ot;exports.dropDownListDefaultProps=P;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Wt=require("react"),L=require("prop-types"),o=require("@progress/kendo-react-common"),_t=require("@progress/kendo-react-labels"),Ut=require("@progress/kendo-svg-icons"),Gt=require("../common/ListContainer.js"),jt=require("../common/ListFilter.js"),tt=require("../common/GroupStickyHeader.js"),$t=require("../common/ListDefaultItem.js"),Yt=require("../common/List.js"),rt=require("../common/DropDownBase.js"),d=require("../common/utils.js"),nt=require("../package-metadata.js"),Jt=require("@progress/kendo-react-buttons"),Qt=require("@progress/kendo-react-intl"),Y=require("../messages/index.js"),Rt=require("@progress/kendo-react-layout"),Xt=require("../common/AdaptiveMode.js");function Zt(M){const J=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(M){for(const O in M)if(O!=="default"){const re=Object.getOwnPropertyDescriptor(M,O);Object.defineProperty(J,O,re.get?re:{enumerable:!0,get:()=>M[O]})}}return J.default=M,Object.freeze(J)}const a=Zt(Wt),en="Please select a value from the list!",fe=a.forwardRef((M,J)=>{let O=!1;const re=o.getLicenseMessage(nt.packageMetadata),n=o.usePropsContext(ot,M),{delay:st=P.delay,tabIndex:at=P.tabIndex,ignoreCase:Q=P.ignoreCase,size:T=P.size,rounded:Ne=P.rounded,fillMode:ve=P.fillMode}=n;if(n.filterable||n.virtual){const e=[];n.filterable&&e.push("filterable"),n.virtual&&e.push("virtualization"),O=!o.validatePackage(nt.packageMetadata,{component:"DropDownList",features:e})}const E=o.useUnstyled(),ye=o.useId(n.id),De=()=>{var e;if(o.canUseDOM)return((e=V.current)==null?void 0:e.ownerDocument)||window.document},it=()=>{var e,r;(e=t==null?void 0:t.current)!=null&&e.wrapper&&((r=t==null?void 0:t.current)==null||r.wrapper.focus({preventScroll:!0}))},k=()=>{let e;return A.current!==void 0&&A.current!==null?e=A.current:n.value!==void 0?e=n.value:f.value!==void 0&&f.value!==null?e=f.value:n.defaultValue!==void 0&&n.defaultValue!==null&&(e=n.defaultValue),!d.isPresent(e)&&n.defaultItem!==void 0&&n.defaultItem!==null&&(e=n.defaultItem),e},lt=()=>{const{dataItemKey:e}=n,r=d.getFilteredData(n),s=k();return r.findIndex(c=>d.areSame(c,s,e))},he=()=>n.required!==void 0?n.required:P.required,Ie=()=>{const e=n.validationMessage!==void 0,r=k(),s=!he()||r!==null&&r!==""&&r!==void 0,c=n.valid!==void 0?n.valid:s;return{customError:e,valid:c,valueMissing:r===null}},dt=()=>n.validityStyles!==void 0?n.validityStyles:P.validityStyles,oe=e=>{se.current=!0,e.focus(),window.setTimeout(()=>se.current=!1,30)},we=()=>{X.current&&oe(X.current),n.adaptive&&setTimeout(()=>{X.current&&oe(X.current)},300)},ct=a.useCallback(e=>{for(const r of e)Ft(r.target.clientWidth)},[]),Me=()=>{var e;(e=Le.current)!=null&&e.setCustomValidity&&Le.current.setCustomValidity(Ie().valid?"":n.validationMessage||en)},q=(e,r)=>{const s=k();d.areSame(s,e,n.dataItemKey)||(n.value===void 0&&(r.data.value=e),t.current.updateComponentArgs({value:e}),A.current=e,r.events.push({type:"onChange"}))},b=e=>{var r;(r=t==null?void 0:t.current)==null||r.applyState(e),A.current=void 0},R=(e,r)=>{var m;const{virtual:s,dataItemKey:c,defaultItem:l}=n,p=d.getFilteredData(n),g=s?s.skip:0,v=k(),u=e===-1&&l!==void 0?l:p[e-g],y=!d.areSame(u,v,c);q(u,r),y&&((m=t==null?void 0:t.current)==null||m.triggerPageChangeCornerItems(u,r))},z=(e,r,s)=>{var C,D;const{defaultItem:c,dataItemKey:l,virtual:p={skip:0,total:0,pageSize:0}}=n,g=k(),v=d.getFilteredData(n),u=(C=t==null?void 0:t.current)==null?void 0:C.vs,y=v.findIndex(h=>d.areSame(h,g,l)),m=(D=t==null?void 0:t.current)==null?void 0:D.navigation.navigate({current:p.skip+y,max:(u!=null&&u.enabled?p.total:v.length)-1,min:c!==void 0?-1:0,keyCode:r,skipItems:s||void 0});m!==void 0&&R(m,e),b(e)},ut=e=>{V.current=e,t.current.wrapper=e},pt=e=>a.createElement("select",{name:n.name,ref:r=>{Le.current=r},tabIndex:-1,"aria-hidden":!0,title:n.label,style:{opacity:0,width:1,border:0,zIndex:-1,position:"absolute",left:"50%"}},a.createElement("option",{value:n.valueMap?n.valueMap.call(void 0,e):e})),Se=()=>{const{textField:e,dataItemKey:r,virtual:s={skip:0},focusedItemIndex:c=d.itemIndexStartsWith,filterable:l,skipDisabledItems:p=!0}=n,g=k(),v=d.getFilteredData(n),u=n.filter?n.filter:f.text;return p&&e&&!u&&!g?v.findIndex(y=>!y.disabled):d.isPresent(g)&&u===void 0||l&&u===""?v.findIndex(y=>d.areSame(y,g,r)):u?ke.current?c(v,u,e):v.findIndex(y=>d.areSame(y,g,r)):s.skip===0?0:-1},Oe=(e,r)=>r!==void 0&&r!==-1&&e&&e.length>0&&e[r].disabled,xe=()=>{const e=d.getFilteredData(n),r=t.current.initState(),s=Se();Oe(e,s)&&(q(null,r),b(r))},Ce=e=>{if(e.isPropagationStopped())return;const r=t.current.initState();r.syntheticEvent=e,f.focused||(r.data.focused=!0),xe(),t.current.togglePopup(r),b(r)},Te=e=>{var N,me,U,ge,$,Ze,et;e&&e.target instanceof Element&&e.target.nodeName==="INPUT"&&e.stopPropagation&&e.stopPropagation();const{filterable:r,disabled:s,defaultItem:c,leftRightKeysNavigation:l=!0,virtual:p={skip:0,total:0,pageSize:0},dataItemKey:g,groupField:v="",textField:u,skipDisabledItems:y=!0}=n,m=d.getFilteredData(n),C=k(),D=m.findIndex(w=>d.areSame(w,C,g)),h=n.opened!==void 0?n.opened:f.opened,i=e.keyCode,F=i===o.Keys.home||i===o.Keys.end,K=i===o.Keys.up||i===o.Keys.down,j=!h&&(e.altKey&&i===o.Keys.down||i===o.Keys.enter||i===o.Keys.space),ne=h&&(e.altKey&&i===o.Keys.up||i===o.Keys.esc),ue=l&&(i===o.Keys.left||i===o.Keys.right),pe=K||ue&&!r||F,I=t.current.initState();if(I.syntheticEvent=e,!s){if(F&&((N=t==null?void 0:t.current)!=null&&N.vs.enabled))i===o.Keys.home?p.skip!==0?((me=t==null?void 0:t.current)==null||me.triggerOnPageChange(I,0,p.pageSize),B.current=!0):q(m[0],I):p.skip<p.total-p.pageSize?((U=t==null?void 0:t.current)==null||U.triggerOnPageChange(I,p.total-p.pageSize,p.pageSize),B.current=!0):q(m[m.length-1],I);else if(h&&i===o.Keys.pageUp)e.preventDefault(),(ge=t==null?void 0:t.current)==null||ge.scrollPopupByPageSize(-1);else if(h&&i===o.Keys.pageDown)e.preventDefault(),($=t==null?void 0:t.current)==null||$.scrollPopupByPageSize(1);else if(h&&i===o.Keys.enter){const w=Se();Oe(m,w)?(q(null,I),b(I)):R(w,I),(Ze=t==null?void 0:t.current)==null||Ze.togglePopup(I),e.preventDefault()}else if(j||ne)ne&&xe(),(et=t==null?void 0:t.current)==null||et.togglePopup(I),e.preventDefault();else if(pe){if(ke.current=!1,v!==""&&u)if(!y&&h)z(I,i);else{let w;if(i===o.Keys.down||i===o.Keys.right){const S=m.slice(D+1).find(x=>!x.disabled);w=S&&m.indexOf(S)}else if(i===o.Keys.up||i===o.Keys.left){let S;if(D===0&&c)w=-1;else if(D===-1)S=m,w=m.findIndex(x=>!x.disabled);else{S=m.slice(0,D);let x=S.pop();for(;x&&x.disabled;)x=S.pop();w=x&&m.indexOf(x)}}if(w!==void 0){const S=w-D;z(I,i,S)}else w===void 0&&D===m.length-1&&z(I,i)}else if(!y&&h||F)z(I,i);else if(u){let w;if(i===o.Keys.down||i===o.Keys.right){const S=m.slice(D+1).find(x=>!x.disabled);w=S&&m.indexOf(S)}else if(i===o.Keys.up||i===o.Keys.left){let S;if(D===0&&c)w=-1;else if(D===-1)S=m,w=m.findIndex(x=>!x.disabled);else{S=m.slice(0,D);let x=S.pop();for(;x&&x.disabled;)x=S.pop();w=x&&m.indexOf(x)}}if(w!==void 0){const S=w-D;z(I,i,S)}else w===void 0&&D===m.length-1&&z(I,i)}else z(I,i);e.preventDefault()}b(I)}},mt=e=>{const r=t.current.initState();r.syntheticEvent=e.syntheticEvent,n.filter===void 0&&(r.data.text=e.target.value),t.current.filterChanged(e.target.value,r),ke.current=!0,b(r),ee({group:void 0,text:String(e.target.value)})},qe=e=>{const r=n.filter!==void 0?n.filter:f.text;return n.filterable&&a.createElement(jt,{value:r,ref:s=>{X.current=s&&s.element},onChange:mt,onKeyDown:Te,size:e?"large":T,rounded:Ne,fillMode:ve,renderListFilterWrapper:!0,placeholder:We.toLanguageString(Y.dropDownListAdaptiveFilterPlaceholder,Y.messages[Y.dropDownListAdaptiveFilterPlaceholder])})},gt=e=>{var s;const r=t.current.initState();r.syntheticEvent=e,(s=t==null?void 0:t.current)==null||s.togglePopup(r),q(n.defaultItem,r),b(r)},ft=()=>{const{textField:e,defaultItem:r,dataItemKey:s}=n,c=k();return r!==void 0&&a.createElement($t,{defaultItem:r,textField:e,selected:d.areSame(c,r,s),key:"defaultitemkey",onClick:gt})},vt=(e,r)=>{var s;(s=t==null?void 0:t.current)==null||s.handleItemClick(e,r),A.current=void 0},yt=e=>{const{vs:r,list:s}=t.current;r.scrollHandler(e);const{groupField:c}=n;let l=d.getFilteredData(n);if(!(!c||!l.length)&&c){const p=Be.current=Be.current||(r.enabled?r.itemHeight:s?s.children[0].offsetHeight:0),v=e.target.scrollTop-r.skip*p;l=t.current.getGroupedDataModernMode(l,c);let u=l[0][c];for(let y=1;y<l.length&&!(p*y>v);y++)l[y]&&l[y][c]&&(u=l[y][c]);u!==f.group&&ee({group:u})}},ze=()=>{var i;const{textField:e,dataItemKey:r,virtual:s={skip:0,total:void 0},groupHeaderItemRender:c,listNoDataRender:l,itemRender:p}=n,g=d.getFilteredData(n),v=E&&E.uDropDownList,u=t.current.vs,y=s.skip,m=n.opened!==void 0?n.opened:f.opened,C=t.current.getPopupSettings(),D=`translateY(${u.translate}px)`,h=k();return a.createElement(Yt,{id:Ee,show:m,data:g.slice(),focusedIndex:Se(),value:h,textField:e,valueField:r,optionsGuid:Ge,groupField:n.groupField,listRef:F=>{u.list=t.current.list=F},wrapperStyle:{maxHeight:_?void 0:C.height},wrapperCssClass:o.classNames(o.uDropDownList.listContent({c:v})),listStyle:u.enabled?{transform:D}:void 0,key:"listkey",skip:y,onClick:vt,itemRender:p,groupHeaderItemRender:c,noDataRender:l,onScroll:yt,wrapperRef:u.scrollerRef,scroller:(i=t==null?void 0:t.current)==null?void 0:i.renderScrollElement(),ariaSetSize:s.total})},Dt=()=>{const{groupField:e}=n,r=d.getFilteredData(n),s=n.opened!==void 0?n.opened:f.opened,c=E&&E.uDropDownList,l={title:n.adaptiveTitle||n.label,subTitle:n.adaptiveSubtitle,expand:s,onClose:g=>Ce(g),windowWidth:be,mobileFilter:qe(!0)};let{group:p}=f;return p===void 0&&e!==void 0&&(p=d.getItemValue(r[0],e)),a.createElement(Xt.AdaptiveMode,{...l},a.createElement(Rt.ActionSheetContent,null,a.createElement("div",{className:o.classNames(o.uDropDownList.listContainer({c,popup:!1}))},St())))},ht=()=>{f.focused&&window.setTimeout(()=>{f.focused&&t.current.wrapper&&oe(t.current.wrapper)})},It=e=>{"onMouseDownOutside"in(n.popupSettings||{})&&n.popupSettings.onMouseDownOutside.call(void 0,e)},wt=()=>{const{header:e,footer:r,dir:s,groupField:c,groupStickyHeaderItemRender:l,list:p}=n,g=d.getFilteredData(n),v=t.current,u=v.getPopupSettings(),y=n.opened!==void 0?n.opened:f.opened,m=u.width!==void 0?u.width:v.popupWidth,C=E&&E.uDropDownList,D={dir:s!==void 0?s:v.dirCalculated,width:m,popupSettings:{...u,popupClass:o.classNames(u.popupClass,o.uDropDownList.listContainer({c:C,popup:!0})),anchor:u.anchor||V.current,show:y,onOpen:we,onClose:ht,onMouseDownOutside:It},itemsCount:[g.length]};let{group:h}=f;return h===void 0&&c!==void 0&&(h=d.getItemValue(g[0],c)),a.createElement(Gt,{...D},qe(!1),e&&a.createElement("div",{className:o.classNames(o.uDropDownList.listHeader({c:C}))},e),a.createElement("div",{className:o.classNames(o.uDropDownList.list({c:C,size:T,virtual:t.current.vs.enabled}))},ft(),!p&&h&&g.length!==0&&a.createElement(tt,{group:h,render:l}),ze()),r&&a.createElement("div",{className:o.classNames(o.uDropDownList.listFooter({c:C}))},r),O&&a.createElement(o.WatermarkOverlay,{message:re}))},St=()=>{const{header:e,footer:r,groupStickyHeaderItemRender:s,groupField:c,list:l}=n,p=d.getFilteredData(n),g=E&&E.uDropDownList;let{group:v}=f;return v===void 0&&c!==void 0&&(v=d.getItemValue(p[0],c)),a.createElement(a.Fragment,null,e&&a.createElement("div",{className:o.classNames(o.uDropDownList.listHeader({c:g}))},e),a.createElement("div",{className:o.classNames("k-list",{[`k-list-${_?"lg":o.sizeMap[T]||T}`]:_||T})},!l&&v&&p.length!==0&&a.createElement(tt,{group:v,render:s}),ze()),r&&a.createElement("div",{className:"k-list-footer"},r))},xt=e=>{const{dataItemKey:r}=n,s=d.getFilteredData(n),c=k();let l=s.map((K,j)=>({item:K,itemIndex:j}));const p=G.current.word,g=G.current.last,v=d.sameCharsOnly(p,g);let u=l.length,y=Math.max(0,s.findIndex(K=>d.areSame(K,c,r))),m;n.defaultItem&&(m={item:n.defaultItem,itemIndex:-1},u+=1,y+=1),y+=v?1:0,l=d.shuffleData(l,y,m);let C,D,h,i=0;const{textField:F}=n;for(;i<u;){if(C=d.getItemValue(l[i].item,F),D=v&&d.matchText(C,g,Q),h=d.matchText(C,p,Q),D||h){i=l[i].itemIndex;break}i++}if(i!==u){const K=t.current.initState();K.syntheticEvent=e,R(i,K),b(K),A.current=void 0}},Ct=e=>{clearTimeout(Ae.current),n.filterable||(Ae.current=window.setTimeout(()=>G.current.word="",st),xt(e))},Lt=e=>{se.current||t.current.handleFocus(e)},kt=e=>{if(se.current||!f.focused)return;const r=n.opened!==void 0?n.opened:f.opened,s=t.current.initState();s.syntheticEvent=e,s.data.focused=!1,s.events.push({type:"onBlur"}),r&&xe(),r&&!_&&t.current.togglePopup(s),b(s)},Kt=e=>{if(n.filterable||e.which===0||e.keyCode===o.Keys.enter)return;let r=String.fromCharCode(e.charCode||e.keyCode);Q&&(r=r.toLowerCase()),r===" "&&e.preventDefault(),G.current={word:G.current.word+r,last:G.current.last+r},Ct(e)},bt=()=>{const e=t.current.initState();e.data.opened=f.opened,t.current.togglePopup(e),b(e)},Ve=a.useRef(null),V=a.useRef(null),Le=a.useRef(null),X=a.useRef(null);a.useImperativeHandle(Ve,()=>({get element(){return V.current},get index(){return lt()},get name(){return n.name},get validity(){return Ie()},get value(){return k()},get focused(){return f.focused},get opened(){return f.opened},focus:it,props:n,togglePopup:bt})),a.useImperativeHandle(J,()=>Ve.current);const Ae=a.useRef(null),G=a.useRef({word:"",last:""}),se=a.useRef(!1),A=a.useRef(null),B=a.useRef(!1),ke=a.useRef(!1),H=a.useRef({}),Ke=a.useRef({}),t=a.useRef(new rt({props:n,setState:()=>{},state:{},forceUpdate:()=>{},element:null,value:null,handleItemSelect:()=>{}})),Be=a.useRef(0),Z=a.useRef(null),[f,Et]=a.useState({}),[be,Ft]=a.useState(),[,He]=a.useReducer(e=>e,!0),We=Qt.useLocalization(),_e=n.name||n.id,Pt=a.useCallback(e=>{if(e==null||!t.current)return;const r=d.getFilteredData(n),{textField:s}=n,c=String(e),l=d.getItemIndexByText(r,c,s,!1,Q),p=l!==-1?r[l]:void 0;if(p!==void 0){const g=t.current.initState();g.syntheticEvent={target:V.current},q(p,g),b(g)}},[n,Q]);o.useKendoPaste(V,{fieldName:_e,onValueChange:Pt,enabled:!!_e});const ee=e=>{Et({...f,...e})};a.useEffect(()=>{t.current.updateComponentArgs({props:n,setState:ee,state:f,forceUpdate:He,element:V.current,handleItemSelect:R,value:k()})},[ee,f,He,R,k]),a.useEffect(()=>{var y,m,C,D,h,i,F,K,j,ne,ue,pe,I;const{dataItemKey:e,virtual:r,groupField:s="",textField:c}=n,l=d.getFilteredData(n),p=H.current.virtual?H.current.virtual.total:0,g=n.opened!==void 0?n.opened:f.opened,v=H.current.opened!==void 0?H.current.opened:Ke.current.opened,u=!v&&g;if((y=t==null?void 0:t.current)==null||y.didUpdate(),(m=t==null?void 0:t.current)!=null&&m.getPopupSettings().animate||u&&we(),r&&r.total!==p)(C=t==null?void 0:t.current)==null||C.vs.calcScrollElementHeight(),(D=t==null?void 0:t.current)==null||D.vs.reset();else{const N=k(),me=H.current.value!==void 0?H.current.value:Ke.current.value;let U=l.findIndex($=>d.areSame($,N,e));s!==""&&N&&c&&(U=(i=(h=t==null?void 0:t.current)==null?void 0:h.getGroupedDataModernMode(l,s))==null?void 0:i.map($=>$[c]).indexOf(N[c]));const ge=!d.areSame(me,N,e);u&&r?(F=t==null?void 0:t.current)==null||F.scrollToVirtualItem(r,U):u&&!r?(we(),l&&l.length!==0&&((K=t==null?void 0:t.current)==null||K.resetGroupStickyHeader(l[0][s],{setState:ee,group:f.group,state:f})),(j=t==null?void 0:t.current)==null||j.scrollToItem(U)):g&&v&&N&&ge&&!B.current?(ue=t==null?void 0:t.current)==null||ue.scrollToItem(U,(ne=t==null?void 0:t.current)==null?void 0:ne.vs.enabled):g&&v&&B.current&&(B.current&&r&&r.skip===0?(pe=t==null?void 0:t.current)==null||pe.vs.reset():B.current&&r&&r.skip===r.total-r.pageSize&&((I=t==null?void 0:t.current)==null||I.vs.scrollToEnd()))}B.current=!1,Ke.current=f,H.current=n,Me()}),a.useEffect(()=>{var e,r;return Z.current=o.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(ct.bind(void 0)),(e=t==null?void 0:t.current)==null||e.didMount(),Me(),(r=De())!=null&&r.body&&Z.current&&Z.current.observe(De().body),()=>{var s;(s=De())!=null&&s.body&&Z.current&&Z.current.disconnect()}},[]);const Ue=ye+"-accessibility-id",Ee=ye+"-listbox-id",Ge=ye+"-guid",Nt=We.toLanguageString(Y.dropDownListArrowBtnAriaLabel,Y.messages[Y.dropDownListArrowBtnAriaLabel]),{style:ae,className:Mt,label:Fe,dir:Ot,virtual:W,adaptive:tn,dataItemKey:Tt,disabled:ie,loading:je,iconClassName:$e,svgIcon:qt,valueRender:Ye}=n,le=n.opened!==void 0?n.opened:f.opened,de=k(),Pe=d.getItemValue(de,n.textField),Je=!dt()||Ie().valid,ce=t.current,zt=ce.vs,te=E&&E.uDropDownList;zt.enabled=W!==void 0;const Qe=o.useAdaptiveModeContext(),_=!!(be&&Qe&&be<=Qe.medium&&n.adaptive);W!==void 0&&(ce.vs.skip=W.skip,ce.vs.total=W.total,ce.vs.pageSize=W.pageSize);const Vt=d.getFilteredData(n),{focused:At}=f,Bt=Vt.findIndex(e=>d.areSame(e,de,Tt)),Re=a.createElement("span",{id:Ue,className:o.classNames(o.uDropDownList.inputInner({c:te}))},Pe&&a.createElement("span",{className:o.classNames(o.uDropDownList.inputText({c:te}))},Pe)),Ht=Ye!==void 0?Ye.call(void 0,Re,de):Re,Xe=a.createElement(a.Fragment,null,a.createElement("span",{ref:ut,className:o.classNames(o.uDropDownList.wrapper({c:te,size:T,rounded:Ne,fillMode:ve,focused:At,disabled:ie,invalid:!Je,loading:je,required:he()}),Mt),style:Fe?{...ae,width:void 0}:ae,dir:Ot,onMouseDown:le?e=>{e.target.nodeName!=="INPUT"&&(oe(t.current.wrapper),e.preventDefault())}:void 0,onFocus:_?e=>Ce(e):Lt,onBlur:kt,tabIndex:o.getTabIndex(at,ie),accessKey:n.accessKey,onKeyDown:Te,onKeyPress:Kt,onClick:ie?void 0:Ce,role:"combobox","aria-required":he(),"aria-disabled":ie||void 0,"aria-haspopup":"listbox","aria-expanded":le||!1,"aria-owns":Ee,"aria-activedescendant":le?"option-"+Ge+"-"+(Bt+(W?W.skip:0)):void 0,"aria-label":n.ariaLabel||n.label,"aria-labelledby":n.ariaLabelledBy,"aria-describedby":n.ariaDescribedBy||Ue,"aria-controls":le?Ee:void 0,id:n.id,title:n.title},Ht,je&&a.createElement(o.IconWrap,{className:o.classNames(o.uDropDownList.loadingIcon({c:te})),name:"loading"}),a.createElement(Jt.Button,{tabIndex:-1,type:"button","aria-label":Nt,size:T,fillMode:ve,className:o.classNames(o.uDropDownList.inputButton({c:te})),iconClass:$e,svgIcon:$e?void 0:qt||Ut.chevronDownIcon,onMouseDown:e=>f.focused&&e.preventDefault()}),pt(de),!_&&wt()),_&&Dt());return Fe?a.createElement(_t.FloatingLabel,{label:Fe,editorValue:Pe,editorValid:Je,editorDisabled:n.disabled,style:{width:ae?ae.width:void 0},children:Xe}):Xe});fe.propTypes={delay:L.number,ignoreCase:L.bool,iconClassName:L.string,svgIcon:o.svgIconPropType,defaultItem:L.any,valueRender:L.func,valueMap:L.func,validationMessage:L.string,required:L.bool,id:L.string,ariaLabelledBy:L.string,ariaDescribedBy:L.string,ariaLabel:L.string,leftRightKeysNavigation:L.bool,title:L.string,groupField:L.string,list:L.any,skipDisabledItems:L.bool};const P={delay:500,tabIndex:0,ignoreCase:!0,...rt.defaultProps,required:!1,size:void 0,rounded:void 0,fillMode:void 0};fe.displayName="KendoReactDropDownList";const ot=o.createPropsContext();fe.displayName="KendoReactDropDownList";exports.DropDownList=fe;exports.DropDownListPropsContext=ot;exports.dropDownListDefaultProps=P;
|