@progress/kendo-react-dropdowns 14.5.0-develop.13 → 14.5.0-develop.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AutoComplete/AutoComplete.d.ts +4 -23
- package/AutoComplete/AutoComplete.js +1 -1
- package/AutoComplete/AutoComplete.mjs +206 -196
- package/AutoComplete/AutoCompleteProps.d.ts +18 -1
- package/AutoCompleteMcpWrapper.d.ts +17 -0
- package/AutoCompleteMcpWrapper.js +8 -0
- package/AutoCompleteMcpWrapper.mjs +18 -0
- package/ComboBox/ComboBox.d.ts +1 -1
- package/ComboBox/ComboBox.js +1 -1
- package/ComboBox/ComboBox.mjs +224 -224
- package/ComboBox/ComboBoxProps.d.ts +6 -1
- package/ComboBoxMcpWrapper.d.ts +17 -0
- package/ComboBoxMcpWrapper.js +8 -0
- package/ComboBoxMcpWrapper.mjs +18 -0
- package/DropDownList/DropDownList.js +1 -1
- package/DropDownList/DropDownList.mjs +283 -282
- package/DropDownList/DropDownListProps.d.ts +6 -1
- package/DropDownTree/DropDownTree.js +1 -1
- package/DropDownTree/DropDownTree.mjs +206 -200
- package/DropDownTree/DropDownTreeProps.d.ts +18 -1
- package/MultiSelect/MultiSelect.d.ts +2 -1
- package/MultiSelect/MultiSelect.js +1 -1
- package/MultiSelect/MultiSelect.mjs +182 -175
- package/MultiSelect/MultiSelectProps.d.ts +6 -1
- package/MultiSelect/TagList.js +1 -1
- package/MultiSelect/TagList.mjs +1 -1
- package/MultiSelectMcpWrapper.d.ts +17 -0
- package/MultiSelectMcpWrapper.js +8 -0
- package/MultiSelectMcpWrapper.mjs +18 -0
- package/MultiSelectTree/MultiSelectTree.js +1 -1
- package/MultiSelectTree/MultiSelectTree.mjs +237 -221
- package/MultiSelectTree/MultiSelectTreeProps.d.ts +12 -0
- package/common/ClearButton.js +1 -1
- package/common/ClearButton.mjs +6 -7
- package/common/List.d.ts +1 -0
- package/common/List.js +1 -1
- package/common/List.mjs +84 -81
- package/common/ListFilter.js +1 -1
- package/common/ListFilter.mjs +20 -17
- package/common/SearchBar.d.ts +1 -0
- package/common/SearchBar.js +1 -1
- package/common/SearchBar.mjs +7 -7
- package/dist/cdn/js/kendo-react-dropdowns.js +1 -1
- package/index.d.mts +9 -3
- package/index.d.ts +9 -3
- package/index.js +1 -1
- package/index.mjs +51 -47
- package/messages/index.d.ts +14 -4
- package/messages/index.js +1 -1
- package/messages/index.mjs +15 -11
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +10 -10
|
@@ -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 { FormComponentProps } from '@progress/kendo-react-common';
|
|
8
|
+
import { FormComponentProps, WebMcpProps } from '@progress/kendo-react-common';
|
|
9
9
|
import { ItemRenderProps } from '@progress/kendo-react-treeview';
|
|
10
10
|
import { FilterChangeEvent, ChangeEvent, OpenEvent, CloseEvent, FocusEvent, BlurEvent, DropdownEvent } from '../common/events';
|
|
11
11
|
import { DropDownsPopupSettings } from '../common/settings.js';
|
|
@@ -232,6 +232,18 @@ export interface DropDownTreeProps extends FormComponentProps {
|
|
|
232
232
|
* This property is related to accessibility.
|
|
233
233
|
*/
|
|
234
234
|
ariaLabelledBy?: string;
|
|
235
|
+
/**
|
|
236
|
+
* Defines a string value that labels the component.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```jsx
|
|
240
|
+
* <DropDownTree ariaLabel="Select item" />
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @remarks
|
|
244
|
+
* This property is related to accessibility.
|
|
245
|
+
*/
|
|
246
|
+
ariaLabel?: string;
|
|
235
247
|
/**
|
|
236
248
|
* Enables the filtering functionality of the DropDownTree ([more information and examples](https://www.telerik.com/kendo-react-ui/components/dropdowns/dropdowntree/filtering)).
|
|
237
249
|
*
|
|
@@ -515,4 +527,9 @@ export interface DropDownTreeProps extends FormComponentProps {
|
|
|
515
527
|
* ```
|
|
516
528
|
*/
|
|
517
529
|
adaptiveSubtitle?: string;
|
|
530
|
+
/**
|
|
531
|
+
* Enables Web MCP tool registration for this component.
|
|
532
|
+
* Requires a parent `WebMcpProvider` from `@progress/kendo-react-webmcp`.
|
|
533
|
+
*/
|
|
534
|
+
webMcp?: boolean | WebMcpProps;
|
|
518
535
|
}
|
|
@@ -73,13 +73,14 @@ export declare class MultiSelectWithoutContext extends React.Component<MultiSele
|
|
|
73
73
|
loading: PropTypes.Requireable<boolean>;
|
|
74
74
|
popupSettings: PropTypes.Requireable<PropTypes.InferProps<{
|
|
75
75
|
animate: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{
|
|
76
|
-
openDuration: PropTypes.Requireable<number>;
|
|
76
|
+
openDuration: PropTypes.Requireable<number>; /** @hidden */
|
|
77
77
|
closeDuration: PropTypes.Requireable<number>;
|
|
78
78
|
}> | null | undefined>>;
|
|
79
79
|
popupClass: PropTypes.Requireable<string>;
|
|
80
80
|
className: PropTypes.Requireable<string>;
|
|
81
81
|
appendTo: PropTypes.Requireable<any>;
|
|
82
82
|
width: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
83
|
+
/** @hidden */
|
|
83
84
|
height: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
84
85
|
}>>;
|
|
85
86
|
onOpen: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -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 W=require("react"),y=require("prop-types"),r=require("@progress/kendo-react-common"),$=require("@progress/kendo-svg-icons"),j=require("@progress/kendo-react-labels"),G=require("../common/ListContainer.js"),U=require("../common/List.js"),Y=require("../common/GroupStickyHeader.js"),J=require("./TagList.js"),Q=require("../common/SearchBar.js"),T=require("../common/DropDownBase.js"),D=require("../common/settings.js"),g=require("../common/utils.js"),E=require("../package-metadata.js"),X=require("../common/ClearButton.js"),Z=require("../common/AdaptiveMode.js"),ee=require("@progress/kendo-react-layout"),te=require("../common/ListFilter.js"),_=require("../common/withCustomComponent.js");function se(S){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(S){for(const e in S)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(S,e);Object.defineProperty(n,e,t.get?t:{enumerable:!0,get:()=>S[e]})}}return n.default=S,Object.freeze(n)}const m=se(W),{sizeMap:w,roundedMap:ie}=r.kendoThemeMaps,ae="Please enter a valid value!",N=S=>S.preventDefault(),R=S=>S===2,C=class C extends m.Component{constructor(n){super(n),this.state={activedescendant:D.ActiveDescendant.PopupList,currentValue:[]},this._element=null,this._valueItemsDuringOnChange=null,this.base=new T(this),this._tags=[],this._input=null,this._adaptiveInput=null,this._skipFocusEvent=!1,this._lastSelectedOrDeslectedItemIndex=null,this.itemHeight=0,this.scrollToFocused=!1,this.showLicenseWatermark=!1,this.focus=()=>{this._input&&this._input.focus()},this.handleKendoPasteValue=e=>{if(e==null)return;const t=g.getFilteredData(this.props),{textField:a,dataItemKey:s}=this.props,o=String(e).split(",").map(c=>c.trim()).filter(c=>c).reduce((c,h)=>{const d=g.getItemIndexByText(t,h,a,!1,!0);if(d!==-1){const l=t[d];c.some(p=>g.areSame(p,l,s))||c.push(l)}return c},[]);if(o.length===0)return;const i=this.base.initState();i.syntheticEvent={target:this._element},this.triggerOnChange(o,i),this.applyState(i)},this.handleItemSelect=(e,t)=>{const{dataItemKey:a,virtual:s}=this.props,o=g.getFilteredData(this.props),i=s?s.skip:0,c=o[e-i],h=this.value.findIndex(p=>g.areSame(p,c,a));this._lastSelectedOrDeslectedItemIndex=o.findIndex(p=>g.areSame(p,c,a));let d=[];h!==-1?(d=this.value,d.splice(h,1)):d=[...this.value,c],(this.props.filter!==void 0?this.props.filter:this.state.text)&&!this.mobileMode&&(this.state.text&&(t.data.text=""),this.base.filterChanged("",t)),this._adaptiveInput&&this._adaptiveInput.blur(),this.state.focusedIndex!==void 0&&(t.data.focusedIndex=void 0),this.triggerOnChange(d,t),this.base.triggerPageChangeCornerItems(c,t)},this.onTagDelete=(e,t)=>{const a=this.base.initState();a.syntheticEvent=t,this.opened&&this.base.togglePopup(a),!this.state.focused&&!this.mobileMode&&(a.data.focused=!0,this.focus());const s=this.value;g.removeDataItems(s,e,this.props.dataItemKey),this.triggerOnChange(s,a),this.applyState(a)},this.itemFocus=(e,t)=>{const{allowCustom:a,virtual:s}=this.props,o=g.getFilteredData(this.props),i=s?s.skip:0,c=s?s.pageSize:0,h=this.props.filter!==void 0?this.props.filter:this.state.text,{focusedIndex:d}=this.getFocusedState(),l=a&&h,p=o[e-i];if(s&&!p&&e>=0&&d!==e){const f=Math.floor(e/c)*c;if(f!==i){this.state.focusedIndex!==e&&(t.data.focusedIndex=e,t.data.activedescendant=D.ActiveDescendant.PopupList),this.base.triggerOnPageChange(t,f,c);return}}p&&d!==e?this.state.focusedIndex!==e&&(t.data.focusedIndex=e,t.data.activedescendant=D.ActiveDescendant.PopupList):l&&e===-1&&this.state.focusedIndex!==void 0&&(t.data.focusedIndex=void 0),this.base.triggerPageChangeCornerItems(p,t)},this.componentRef=e=>{this._element=e,this.base.wrapper=e},this.searchbarRef=e=>{const t=this._input=e&&e.input;t&&this.state.focused&&window.setTimeout(()=>t.focus(),0)},this.onChangeHandler=e=>{const t=this.base.initState(),a=e.target.value;t.syntheticEvent=e,this.props.filter===void 0&&(t.data.text=a),t.data.focusedIndex=void 0,this.opened?this.scrollToFocused=!0:(this.base.togglePopup(t),this.setState({currentValue:this.value})),this.base.filterChanged(a,t),this.applyState(t),this.setState({group:void 0})},this.clearButtonClick=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.value.length>0&&this.triggerOnChange([],t),this.state.focusedIndex!==void 0&&(t.data.focusedIndex=void 0),this.opened&&this.base.togglePopup(t);const a=this.props.filter!==void 0?this.props.filter:this.state.text;g.isPresent(a)&&a!==""&&this.base.filterChanged("",t),this.state.text&&(t.data.text=""),this._lastSelectedOrDeslectedItemIndex=null,this.applyState(t)},this.onInputKeyDown=e=>{const{textField:t,groupField:a,virtual:s}=this.props,o=g.getFilteredData(this.props),i=e.keyCode,c=this.props.filter!==void 0?this.props.filter:this.state.text,h=this.props.opened!==void 0?this.props.opened:this.state.opened,{focusedItem:d,focusedIndex:l}=this.getFocusedState(),p=this.base.initState();if(p.syntheticEvent=e,!c&&this.value.length>0&&(i===r.Keys.left||i===r.Keys.right||i===r.Keys.home||i===r.Keys.end||i===r.Keys.delete||i===r.Keys.backspace)&&!e.shiftKey)return this.onTagsNavigate(e,p);const f=()=>{e.preventDefault(),this.base.togglePopup(p),this.applyState(p)};if(this.opened)if(i===r.Keys.pageUp)e.preventDefault(),this.base.scrollPopupByPageSize(-1);else if(i===r.Keys.pageDown)e.preventDefault(),this.base.scrollPopupByPageSize(1);else if((e.ctrlKey||e.metaKey)&&e.code==="KeyA"){const b=(this.state.value&&this.state.value.length)===o.length?[]:o;this.updateStateOnKeyboardNavigation(b,p)}else if((e.ctrlKey||e.metaKey)&&e.shiftKey&&e.keyCode===r.Keys.end){const u=o.slice(this.getFocusedState().focusedIndex);this.itemFocus(o.length-1,p),this.updateStateOnKeyboardNavigation(u,p)}else if((e.ctrlKey||e.metaKey)&&e.shiftKey&&e.keyCode===r.Keys.home){const u=o.slice(0,this.getFocusedState().focusedIndex+1);this.itemFocus(0,p),this.updateStateOnKeyboardNavigation(u,p)}else if(e.shiftKey&&e.keyCode===r.Keys.up){let u;const b=this.getLastSelectedOrDeselectedIndex(1,l);b===null?u=l!==0?o.slice(l-1,l):[o[l]]:b===l?u=[o[b-1]]:l>=0&&(u=b>l?o.slice(l-1,b):o.slice(b-1,l)),u&&u.length>0&&(l>=1&&this.itemFocus(l-1,p),this.updateStateOnKeyboardNavigation(u,p))}else if(e.shiftKey&&e.keyCode===r.Keys.down){let u;const b=this.getLastSelectedOrDeselectedIndex(0,l);b===null?u=l!==o.length-1?o.slice(l,l+1):[o[l]]:b===l?u=o.slice(l,l+2):l>=0&&(u=b>l?o.slice(l+1,b+1):o.slice(b,l+2)),u&&u.length>=1&&(this.itemFocus(l+1,p),this.updateStateOnKeyboardNavigation(u,p))}else if(e.altKey&&i===r.Keys.up)f();else if(i===r.Keys.up||i===r.Keys.down){const u=s?s.skip:0,b=l-u;if(a!==""&&t)if(!this.props.skipDisabledItems&&h)this.onNavigate(p,i);else{let v=0;if(i===r.Keys.down||i===r.Keys.right){const I=o.slice(b+1).find(x=>!x.disabled);v=I&&o.indexOf(I),v&&v!==-1&&(v=v+u)}else if(i===r.Keys.up||i===r.Keys.left){let I;if(l===-1)I=o,v=o.findIndex(x=>!x.disabled),v!==-1&&(v=v+u);else{I=o.slice(0,b);let x=I.pop();for(;x&&x.disabled;)x=I.pop();v=x&&o.indexOf(x),v&&v!==-1&&(v=v+u)}}if(v){const I=v-l;this.onNavigate(p,i,I)}else this.onNavigate(p,i)}else if(!this.props.skipDisabledItems&&h)this.onNavigate(p,i);else{let v=null;if(i===r.Keys.down||i===r.Keys.right)v=o.slice(b+1).find(I=>!I.disabled);else if(i===r.Keys.up||i===r.Keys.left){const I=o.slice(0,b);for(v=I.pop();v&&v.disabled;)v=I.pop()}if(v){const I=o.indexOf(v);if(I!==-1){const x=u+I-l;this.onNavigate(p,i,x)}else this.onNavigate(p,i)}else this.onNavigate(p,i)}this.applyState(p),e.preventDefault()}else i===r.Keys.enter?(e.preventDefault(),this.props.allowCustom&&c&&d===null?this.customItemSelect(e):d&&d.disabled?f():this.selectFocusedItem(e)):i===r.Keys.esc&&f();else e.altKey&&i===r.Keys.down?f():i===r.Keys.esc&&this.clearButtonClick(e)},this.listContainerContent=()=>{const{header:e,footer:t,allowCustom:a,size:s,groupStickyHeaderItemRender:o,groupField:i,list:c}=this.props,h=g.getFilteredData(this.props),d=this.props.filter!==void 0?this.props.filter:this.state.text,{focusedType:l}=this.getFocusedState(),p=a&&d&&m.createElement("div",{className:r.classNames("k-list",{[`k-list-${w[s]||s}`]:s}),key:"customitem",onClick:this.customItemSelect,onMouseDown:N},m.createElement("div",{className:r.classNames("k-list-item k-custom-item",{"k-focus":R(l)}),style:{fontStyle:"italic"}},d,m.createElement(r.IconWrap,{name:"plus",icon:$.plusIcon,style:{position:"absolute",right:"0.5em"}})));let{group:f}=this.state;return f===void 0&&i!==void 0&&(f=g.getItemValue(h[0],i)),m.createElement(m.Fragment,null,e&&m.createElement("div",{className:"k-list-header"},e),p,m.createElement("div",{className:r.classNames("k-list",{[`k-list-${this.mobileMode?"lg":w[s]||s}`]:this.mobileMode||s,"k-virtual-list":this.base.vs.enabled})},!c&&f&&h.length!==0&&m.createElement(Y,{group:f,render:o}),this.renderList()),this.showLicenseWatermark&&m.createElement(r.WatermarkOverlay,{message:this.licenseMessage}),t&&m.createElement("div",{className:"k-list-footer"},t))},this.renderListContainer=()=>{const e=this.base,{dir:t}=this.props,a=g.getFilteredData(this.props),s=this.base.getPopupSettings(),o=s.width!==void 0?s.width:e.popupWidth,i={dir:t!==void 0?t:e.dirCalculated,width:o,popupSettings:{...s,popupClass:r.classNames(s.popupClass,"k-list-container","k-multiselect-popup"),anchor:s.anchor||this.element,show:this.opened,onOpen:this.onPopupOpened,onClose:this.onPopupClosed},itemsCount:[a.length,this.value.length]};return m.createElement(G,{...i},this.listContainerContent())},this.renderAdaptiveListContainer=()=>{const{adaptiveTitle:e,adaptiveSubtitle:t,filterable:a,filter:s}=this.props,{windowWidth:o=0}=this.state,i=s!==void 0?s:this.state.text,c=a?m.createElement(te,{value:i,ref:d=>{this._adaptiveInput=d&&d.element},onChange:this.onChangeHandler,onKeyDown:this.onInputKeyDown,size:"large",rounded:this.props.rounded,fillMode:this.props.fillMode,placeholder:this.props.placeholder}):null,h={title:e||this.props.label,subTitle:t,expand:this.opened,onClose:d=>this.closePopup(d),windowWidth:o,mobileFilter:c};return m.createElement(Z.AdaptiveMode,{...h},m.createElement(ee.ActionSheetContent,null,m.createElement("div",{className:"k-list-container"},this.listContainerContent())))},this.closePopup=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.state.focusedIndex!==void 0&&(t.data.focusedIndex=void 0),this.opened&&this.base.togglePopup(t),t.events.push({type:"onClose"});const a=this.props.filter!==void 0?this.props.filter:this.state.text;g.isPresent(a)&&a!==""&&this.base.filterChanged("",t),this.state.text&&(t.data.text=""),this.applyState(t)},this.onCancel=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.state.focusedIndex!==void 0&&(t.data.focusedIndex=void 0),this.opened&&this.base.togglePopup(t),t.events.push({type:"onCancel"});const a=this.props.filter!==void 0?this.props.filter:this.state.text;g.isPresent(a)&&a!==""&&this.base.filterChanged("",t),this.state.text&&(t.data.text=""),this.applyState(t)},this.renderList=()=>{const{textField:e,listNoDataRender:t,itemRender:a,groupHeaderItemRender:s,dataItemKey:o,virtual:i={skip:0,total:void 0}}=this.props,c=g.getFilteredData(this.props),h=this.base.vs,{focusedIndex:d}=this.getFocusedState(),l=this.base.getPopupSettings(),p=`translateY(${h.translate}px)`;return m.createElement(U,{id:this.base.listBoxId,show:this.opened,data:c.slice(),focusedIndex:d-i.skip,value:this.value,textField:e,valueField:o,optionsGuid:this.base.guid,groupField:this.props.groupField,listRef:f=>{h.list=this.base.list=f},wrapperStyle:this.mobileMode?{}:{maxHeight:l.height},wrapperCssClass:"k-list-content",listStyle:h.enabled?{transform:p}:void 0,key:"listKey",skip:i.skip,onClick:this.handleItemClick,itemRender:a,groupHeaderItemRender:s,noDataRender:t,onMouseDown:N,onBlur:this.handleBlur,onScroll:this.onScroll,wrapperRef:h.scrollerRef,scroller:this.base.renderScrollElement(),ariaSetSize:i.total})},this.onScroll=e=>{const{vs:t,list:a}=this.base;t.scrollHandler(e);const{groupField:s}=this.props;let o=g.getFilteredData(this.props);if(!(!s||!o.length)&&s){const i=this.itemHeight=this.itemHeight||(t.enabled?t.itemHeight:a?a.children[0].offsetHeight:0),h=e.target.scrollTop-t.skip*i;o=this.base.getGroupedDataModernMode(o,s);let d=o[0][s];for(let l=1;l<o.length&&!(i*l>h);l++)o[l]&&o[l][s]&&(d=o[l][s]);d!==this.state.group&&this.setState({group:d})}},this.customItemSelect=e=>{const t=this.props.filter!==void 0?this.props.filter:this.state.text,{textField:a}=this.props;if(!t)return;const s=this.base.initState();s.syntheticEvent=e;const o=a?{[a]:t}:t;this.state.text!==void 0&&(s.data.text=""),s.data.focusedIndex=void 0,this.base.filterChanged("",s);const i=[...this.value,o];this.triggerOnChange(i,s),this.base.togglePopup(s),this.applyState(s)},this.handleWrapperClick=e=>{const t=this._input;!this.opened&&t&&this.focusElement(t);const a=this.base.initState();a.syntheticEvent=e,!this.state.focused&&!this.mobileMode&&(a.events.push({type:"onFocus"}),a.data.focused=!0),this.mobileMode&&(this.setState({currentValue:this.tagsToRender}),this.mobileMode&&window.setTimeout(()=>this._adaptiveInput&&this._adaptiveInput.focus(),300)),this.base.togglePopup(a),this.applyState(a)},this.handleItemClick=(e,t)=>{const a=this.base.initState();a.syntheticEvent=t,this.handleItemSelect(e,a),this.props.autoClose&&this.base.togglePopup(a),t.stopPropagation(),this.applyState(a)},this.handleBlur=e=>{if(!this.state.focused||this._skipFocusEvent)return;const t=this.base.initState(),{allowCustom:a,filterable:s}=this.props;t.syntheticEvent=e,t.data.focused=!1,t.events.push({type:"onBlur"}),this.opened&&!this.mobileMode&&(this.state.opened&&(t.data.opened=!1),t.events.push({type:"onClose"})),!a&&!s&&this.state.text&&(t.data.text=""),this.applyState(t)},this.handleFocus=e=>{this._skipFocusEvent||this.base.handleFocus(e)},this.onPopupOpened=()=>{this._input&&this.state.focused&&!this.mobileMode&&this.focusElement(this._input)},this.onPopupClosed=()=>{this.state.focused&&window.setTimeout(()=>{this.state.focused&&this.focusElement(this._input)},0)},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||ae)},this.validate(n),this.licenseMessage=r.getLicenseMessage(E.packageMetadata)}get _inputId(){return this.props.id}get document(){if(r.canUseDOM)return this.element&&this.element.ownerDocument||document}validate(n){if(n.filterable||n.virtual){const e=[];n.filterable&&e.push("filterable"),n.virtual&&e.push("virtualization"),this.showLicenseWatermark=!r.validatePackage(E.packageMetadata,{component:"MultiSelect",features:e})}}get element(){return this._element}get opened(){return!!(this.props.opened!==void 0?this.props.opened:this.state.opened)}get tagsToRender(){const{tags:n,textField:e}=this.props,t=[];return n===void 0?this.value.forEach(a=>{t.push({text:g.getItemValue(a,e),data:[a]})}):t.push(...n),t}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(){const n=[];return this._valueItemsDuringOnChange?n.push(...this._valueItemsDuringOnChange):this.props.value?n.push(...this.props.value):this.state.value?n.push(...this.state.value):this.props.defaultValue&&n.push(...this.props.defaultValue),n}get name(){return this.props.name}get validity(){const n=this.props.validationMessage!==void 0,e=!this.required||this.value!==null&&this.value.length>0&&this.value!==void 0,t=this.props.valid!==void 0?this.props.valid:e;return{customError:n,valid:t,valueMissing:this.value===null}}get required(){return this.props.required!==void 0?this.props.required:C.defaultProps.required}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:C.defaultProps.validityStyles}componentDidUpdate(n,e){var p;const{virtual:t,groupField:a=""}=this.props,s=g.getFilteredData(this.props),o=t?t.skip:0,i=n.virtual?n.virtual.total:0,c=n.opened!==void 0?n.opened:e.opened,h=!c&&this.opened,d=c&&!this.opened,l=this.base.getPopupSettings();if(this.validate(this.props),this.base.didUpdate(),!l.animate&&d&&this.onPopupClosed(),t&&t.total!==i)this.base.vs.calcScrollElementHeight(),this.base.vs.reset();else{let{focusedItem:f,focusedIndex:u}=this.getFocusedState();a!==""&&(u=(p=this.base.getGroupedDataModernMode(s,a))==null?void 0:p.indexOf(f)),h&&t?this.base.scrollToVirtualItem(t,u-o):h&&!t?(s&&s.length!==0&&this.base.resetGroupStickyHeader(s[0][a],this),this.base.scrollToItem(u)):this.opened&&c&&f&&this.scrollToFocused&&this.base.scrollToItem(u-o)}this.scrollToFocused=!1,this.setValidity()}componentDidMount(){var e;this.observerResize=r.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);const n=this.props.name||this.props.id;this.KendoPasteSubscription=r.subscribeToKendoPaste(this._element,{fieldName:n,onValueChange:t=>{this.handleKendoPasteValue(t)}})}componentWillUnmount(){var n,e;(n=this.document)!=null&&n.body&&this.observerResize&&this.observerResize.disconnect(),(e=this.KendoPasteSubscription)==null||e.unsubscribe()}onNavigate(n,e,t){const{allowCustom:a}=this.props,s=g.getFilteredData(this.props),o=this.props.filter!==void 0?this.props.filter:this.state.text,{focusedType:i,focusedIndex:c}=this.getFocusedState(),h=a&&o,d=R(i),l=this.base,p=l.vs;if(this.opened&&e===r.Keys.up&&d)this.state.focusedIndex!==void 0&&(n.data.focusedIndex=void 0);else{const f=l.navigation.navigate({keyCode:e,current:c,max:(p.enabled?p.total:s.length)-1,min:h?-1:0,skipItems:t||void 0});f!==void 0&&(this.itemFocus(f,n),this.scrollToFocused=!0)}this.applyState(n)}render(){const{style:n,className:e,label:t,dir:a,disabled:s,textField:o,dataItemKey:i,virtual:c,size:h,rounded:d,fillMode:l,loading:p,filter:f}=this.props,{text:u,focused:b,focusedTag:v,currentValue:I}=this.state,x=this.base.vs,M=this.props.id||this._inputId;x.enabled=c!==void 0,c!==void 0&&(x.skip=c.skip,x.total=c.total,x.pageSize=c.pageSize);const k=this.mobileMode&&this.opened?I:this.tagsToRender;this.setItems(this.tagsToRender,this._tags);const O=!this.validityStyles||this.validity.valid,B=!!(f!==void 0?f:u)||k&&k.length>0,[V,z]=_(this.props.prefix||m.Fragment),[A,H]=_(this.props.suffix||m.Fragment),P=m.createElement(m.Fragment,null,m.createElement("div",{ref:this.componentRef,className:r.classNames("k-multiselect k-input",e,{[`k-input-${w[h]||h}`]:h,[`k-rounded-${ie[d]||d}`]:d,[`k-input-${l}`]:l,"k-focus":b&&!s,"k-invalid":!O,"k-disabled":s,"k-loading":p,"k-required":this.required}),style:t?{...n,width:void 0}:n,dir:a,onFocus:K=>{this.mobileMode?this.handleWrapperClick(K):this.handleFocus(K)},onBlur:this.handleBlur,onClick:this.handleWrapperClick,onMouseDown:g.preventDefaultNonInputs},this.props.prefix&&m.createElement(V,{...z}),m.createElement("div",{className:r.classNames("k-input-values")},m.createElement("div",{className:r.classNames("k-chip-list",{[`k-chip-list-${w[h]||h}`]:h}),role:"listbox",id:"tagslist-"+this.base.guid},k&&k.length>0&&m.createElement(J,{tagRender:this.props.tagRender,onTagDelete:this.onTagDelete,data:k,guid:this.base.guid,focused:v?k.find(K=>g.matchTags(K,v,i)):void 0,size:h})),this.renderSearchBar(M)),p&&m.createElement(r.IconWrap,{className:"k-input-loading-icon",name:"loading"}),this.props.suffix&&m.createElement(A,{...H}),B&&m.createElement(X,{onClick:this.clearButtonClick}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return t?m.createElement(j.FloatingLabel,{label:t,editorId:M,editorValue:u||g.getItemValue(this.value[0],o),editorValid:O,editorDisabled:s,style:{width:n?n.width:void 0},children:P}):P}renderSearchBar(n){const{activedescendant:e,focusedTag:t,currentValue:a}=this.state,{disabled:s,placeholder:o,ariaDescribedBy:i,ariaLabelledBy:c,ariaLabel:h,inputAttributes:d}=this.props,l=!this.mobileMode&&(this.props.filter!==void 0?this.props.filter:this.state.text)||"",{focusedIndex:p}=this.getFocusedState(),f=this.value.length===0&&!l?o:void 0,u=a&&a.length>0?void 0:o,b=e===D.ActiveDescendant.TagsList&&t!==void 0?`tag-${this.base.guid}-${t.text.replace(/\s+/g,"-")}`:`option-${this.base.guid}-${p}`,v={accessKey:this.props.accessKey,tabIndex:this.props.tabIndex};return m.createElement(Q,{id:n,name:this.props.name,size:Math.max((f||"").length,l.length,1),placeholder:this.mobileMode&&this.opened?u:f,value:l,onChange:this.onChangeHandler,onKeyDown:this.onInputKeyDown,ref:this.searchbarRef,disabled:s,expanded:this.opened,owns:this.base.listBoxId,role:"combobox",activedescendant:b,ariaDescribedBy:`tagslist-${this.base.guid}${i?" "+i:""}`,ariaLabelledBy:c,ariaRequired:this.required,ariaLabel:h,inputAttributes:d,...v})}onTagsNavigate(n,e){const t=n.keyCode,{focusedTag:a}=this.state,s=this._tags,o=this.props.dataItemKey;let i=a?s.findIndex(d=>g.matchTags(d,a,o)):-1,c;const h=i!==-1;if(t===r.Keys.left)h?i=Math.max(0,i-1):i=s.length-1,c=s[i];else if(t===r.Keys.right)i===s.length-1?c=void 0:h&&(i=Math.min(s.length-1,i+1),c=s[i]);else if(t===r.Keys.home&&!n.shiftKey)c=s[0];else if(t===r.Keys.end&&!n.shiftKey)c=s[s.length-1];else if(t===r.Keys.delete){if(h){const d=this.value;g.removeDataItems(d,s[i].data,o),this.triggerOnChange(d,e)}}else if(t===r.Keys.backspace){const d=this.value;if(h)g.removeDataItems(d,s[i].data,o),this.triggerOnChange(d,e);else if(!h&&s.length){const l=s.pop();g.removeDataItems(d,l.data,o),this.triggerOnChange(d,e)}}c!==a&&(e.data.focusedTag=c,e.data.activedescendant=D.ActiveDescendant.TagsList),this.applyState(e)}triggerOnChange(n,e){this.props.value===void 0&&(e.data.value=[...n]),this._valueItemsDuringOnChange=[],this.setItems(n,this._valueItemsDuringOnChange),e.events.push({type:"onChange"})}selectFocusedItem(n,e){const{virtual:t}=this.props,a=g.getFilteredData(this.props),{focusedIndex:s}=e||this.getFocusedState(),o=t?t.skip:0;a[s-o]!==void 0&&this.handleItemClick(s,n)}setItems(n,e){e.length=0,e.push(...n)}getFocusedState(){const{focusedIndex:n}=this.state,e=this.props.filter!==void 0?this.props.filter:this.state.text,{allowCustom:t,dataItemKey:a,virtual:s,textField:o,focusedItemIndex:i=g.itemIndexStartsWith,skipDisabledItems:c}=this.props,h=g.getFilteredData(this.props),d=s&&s.skip||0;let l;if(n!==void 0)return{focusedIndex:n,focusedItem:h[n-d],focusedType:1};const p=this.value;if(t&&e)return{focusedItem:null,focusedIndex:-1,focusedType:2};if(e)return l=i(h,e,o),{focusedItem:h[l],focusedIndex:l+d,focusedType:1};if(p.length){const f=p[p.length-1];return l=h.findIndex(u=>g.areSame(u,f,a)),h[l]!==void 0?{focusedIndex:l+d,focusedItem:h[l],focusedType:1}:{focusedType:0,focusedIndex:-1}}else if(c&&o&&!e&&d===0){const f=h.findIndex(u=>!u.disabled);return{focusedIndex:f,focusedItem:h[f-d],focusedType:1}}return d===0?{focusedItem:h[0],focusedIndex:0,focusedType:1}:{focusedType:0,focusedIndex:-1}}focusElement(n){this._skipFocusEvent=!0,n.focus(),window.setTimeout(()=>this._skipFocusEvent=!1,0)}applyState(n){this.base.applyState(n),this._valueItemsDuringOnChange=null}calculateMedia(n){for(const e of n)this.setState({windowWidth:e.target.clientWidth})}updateStateOnKeyboardNavigation(n,e){this.setState({value:n}),this.triggerOnChange(n,e),this.applyState(e)}getLastSelectedOrDeselectedIndex(n,e){return this._lastSelectedOrDeslectedItemIndex===null&&(this._lastSelectedOrDeslectedItemIndex=e),this._lastSelectedOrDeslectedItemIndex!==null?this._lastSelectedOrDeslectedItemIndex+n:null}};C.displayName="MultiSelect",C.propTypes={...T.propTypes,autoClose:y.bool,value:y.arrayOf(y.any),defaultValue:y.arrayOf(y.any),dataItemKey:y.string,placeholder:y.string,tags:y.arrayOf(y.shape({text:y.string,data:y.arrayOf(y.any)})),tagRender:y.func,id:y.string,ariaLabelledBy:y.string,ariaDescribedBy:y.string,groupField:y.string,list:y.any,adaptive:y.bool,adaptiveTitle:y.string,adaptiveSubtitle:y.string,onCancel:y.func,skipDisabledItems:y.bool,inputAttributes:y.object},C.defaultProps={...T.defaultProps,autoClose:!0,required:!1,size:void 0,rounded:void 0,fillMode:void 0,skipDisabledItems:!0,prefix:void 0,suffix:void 0};let F=C;const L=r.createPropsContext(),q=r.withIdHOC(r.withPropsContext(L,r.withAdaptiveModeContext(F)));q.displayName="KendoReactMultiSelect";exports.MultiSelect=q;exports.MultiSelectPropsContext=L;exports.MultiSelectWithoutContext=F;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("react"),y=require("prop-types"),r=require("@progress/kendo-react-common"),U=require("@progress/kendo-svg-icons"),Y=require("@progress/kendo-react-labels"),O=require("@progress/kendo-react-intl"),J=require("../common/ListContainer.js"),Q=require("../common/List.js"),X=require("../common/GroupStickyHeader.js"),Z=require("./TagList.js"),ee=require("../common/SearchBar.js"),M=require("../common/DropDownBase.js"),K=require("../common/settings.js"),g=require("../common/utils.js"),L=require("../package-metadata.js"),te=require("../common/ClearButton.js"),se=require("../common/AdaptiveMode.js"),ie=require("@progress/kendo-react-layout"),ae=require("../common/ListFilter.js"),N=require("../common/withCustomComponent.js"),D=require("../messages/index.js");function oe(S){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(S){for(const e in S)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(S,e);Object.defineProperty(n,e,t.get?t:{enumerable:!0,get:()=>S[e]})}}return n.default=S,Object.freeze(n)}const m=oe(G),{sizeMap:T,roundedMap:ne}=r.kendoThemeMaps,le="Please enter a valid value!",R=S=>S.preventDefault(),q=S=>S===2,C=class C extends m.Component{constructor(n){super(n),this.state={activedescendant:K.ActiveDescendant.PopupList,currentValue:[]},this._element=null,this._valueItemsDuringOnChange=null,this.base=new M(this),this._tags=[],this._input=null,this._adaptiveInput=null,this._skipFocusEvent=!1,this._lastSelectedOrDeslectedItemIndex=null,this.itemHeight=0,this.scrollToFocused=!1,this.showLicenseWatermark=!1,this.focus=()=>{this._input&&this._input.focus()},this.handleKendoPasteValue=e=>{if(e==null)return;const t=g.getFilteredData(this.props),{textField:a,dataItemKey:s}=this.props,o=String(e).split(",").map(h=>h.trim()).filter(h=>h).reduce((h,p)=>{const d=g.getItemIndexByText(t,p,a,!1,!0);if(d!==-1){const l=t[d];h.some(c=>g.areSame(c,l,s))||h.push(l)}return h},[]);if(o.length===0)return;const i=this.base.initState();i.syntheticEvent={target:this._element},this.triggerOnChange(o,i),this.applyState(i)},this.handleItemSelect=(e,t)=>{const{dataItemKey:a,virtual:s}=this.props,o=g.getFilteredData(this.props),i=s?s.skip:0,h=o[e-i],p=this.value.findIndex(c=>g.areSame(c,h,a));this._lastSelectedOrDeslectedItemIndex=o.findIndex(c=>g.areSame(c,h,a));let d=[];p!==-1?(d=this.value,d.splice(p,1)):d=[...this.value,h],(this.props.filter!==void 0?this.props.filter:this.state.text)&&!this.mobileMode&&(this.state.text&&(t.data.text=""),this.base.filterChanged("",t)),this._adaptiveInput&&this._adaptiveInput.blur(),this.state.focusedIndex!==void 0&&(t.data.focusedIndex=void 0),this.triggerOnChange(d,t),this.base.triggerPageChangeCornerItems(h,t)},this.onTagDelete=(e,t)=>{const a=this.base.initState();a.syntheticEvent=t,this.opened&&this.base.togglePopup(a),!this.state.focused&&!this.mobileMode&&(a.data.focused=!0,this.focus());const s=this.value;g.removeDataItems(s,e,this.props.dataItemKey),this.triggerOnChange(s,a),this.applyState(a)},this.itemFocus=(e,t)=>{const{allowCustom:a,virtual:s}=this.props,o=g.getFilteredData(this.props),i=s?s.skip:0,h=s?s.pageSize:0,p=this.props.filter!==void 0?this.props.filter:this.state.text,{focusedIndex:d}=this.getFocusedState(),l=a&&p,c=o[e-i];if(s&&!c&&e>=0&&d!==e){const f=Math.floor(e/h)*h;if(f!==i){this.state.focusedIndex!==e&&(t.data.focusedIndex=e,t.data.activedescendant=K.ActiveDescendant.PopupList),this.base.triggerOnPageChange(t,f,h);return}}c&&d!==e?this.state.focusedIndex!==e&&(t.data.focusedIndex=e,t.data.activedescendant=K.ActiveDescendant.PopupList):l&&e===-1&&this.state.focusedIndex!==void 0&&(t.data.focusedIndex=void 0),this.base.triggerPageChangeCornerItems(c,t)},this.componentRef=e=>{this._element=e,this.base.wrapper=e},this.searchbarRef=e=>{const t=this._input=e&&e.input;t&&this.state.focused&&window.setTimeout(()=>t.focus(),0)},this.onChangeHandler=e=>{const t=this.base.initState(),a=e.target.value;t.syntheticEvent=e,this.props.filter===void 0&&(t.data.text=a),t.data.focusedIndex=void 0,this.opened?this.scrollToFocused=!0:(this.base.togglePopup(t),this.setState({currentValue:this.value})),this.base.filterChanged(a,t),this.applyState(t),this.setState({group:void 0})},this.clearButtonClick=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.value.length>0&&this.triggerOnChange([],t),this.state.focusedIndex!==void 0&&(t.data.focusedIndex=void 0),this.opened&&this.base.togglePopup(t);const a=this.props.filter!==void 0?this.props.filter:this.state.text;g.isPresent(a)&&a!==""&&this.base.filterChanged("",t),this.state.text&&(t.data.text=""),this._lastSelectedOrDeslectedItemIndex=null,this.applyState(t)},this.onInputKeyDown=e=>{const{textField:t,groupField:a,virtual:s}=this.props,o=g.getFilteredData(this.props),i=e.keyCode,h=this.props.filter!==void 0?this.props.filter:this.state.text,p=this.props.opened!==void 0?this.props.opened:this.state.opened,{focusedItem:d,focusedIndex:l}=this.getFocusedState(),c=this.base.initState();if(c.syntheticEvent=e,!h&&this.value.length>0&&(i===r.Keys.left||i===r.Keys.right||i===r.Keys.home||i===r.Keys.end||i===r.Keys.delete||i===r.Keys.backspace)&&!e.shiftKey)return this.onTagsNavigate(e,c);const f=()=>{e.preventDefault(),this.base.togglePopup(c),this.applyState(c)};if(this.opened)if(i===r.Keys.pageUp)e.preventDefault(),this.base.scrollPopupByPageSize(-1);else if(i===r.Keys.pageDown)e.preventDefault(),this.base.scrollPopupByPageSize(1);else if((e.ctrlKey||e.metaKey)&&e.code==="KeyA"){const b=(this.state.value&&this.state.value.length)===o.length?[]:o;this.updateStateOnKeyboardNavigation(b,c)}else if((e.ctrlKey||e.metaKey)&&e.shiftKey&&e.keyCode===r.Keys.end){const u=o.slice(this.getFocusedState().focusedIndex);this.itemFocus(o.length-1,c),this.updateStateOnKeyboardNavigation(u,c)}else if((e.ctrlKey||e.metaKey)&&e.shiftKey&&e.keyCode===r.Keys.home){const u=o.slice(0,this.getFocusedState().focusedIndex+1);this.itemFocus(0,c),this.updateStateOnKeyboardNavigation(u,c)}else if(e.shiftKey&&e.keyCode===r.Keys.up){let u;const b=this.getLastSelectedOrDeselectedIndex(1,l);b===null?u=l!==0?o.slice(l-1,l):[o[l]]:b===l?u=[o[b-1]]:l>=0&&(u=b>l?o.slice(l-1,b):o.slice(b-1,l)),u&&u.length>0&&(l>=1&&this.itemFocus(l-1,c),this.updateStateOnKeyboardNavigation(u,c))}else if(e.shiftKey&&e.keyCode===r.Keys.down){let u;const b=this.getLastSelectedOrDeselectedIndex(0,l);b===null?u=l!==o.length-1?o.slice(l,l+1):[o[l]]:b===l?u=o.slice(l,l+2):l>=0&&(u=b>l?o.slice(l+1,b+1):o.slice(b,l+2)),u&&u.length>=1&&(this.itemFocus(l+1,c),this.updateStateOnKeyboardNavigation(u,c))}else if(e.altKey&&i===r.Keys.up)f();else if(i===r.Keys.up||i===r.Keys.down){const u=s?s.skip:0,b=l-u;if(a!==""&&t)if(!this.props.skipDisabledItems&&p)this.onNavigate(c,i);else{let v=0;if(i===r.Keys.down||i===r.Keys.right){const I=o.slice(b+1).find(x=>!x.disabled);v=I&&o.indexOf(I),v&&v!==-1&&(v=v+u)}else if(i===r.Keys.up||i===r.Keys.left){let I;if(l===-1)I=o,v=o.findIndex(x=>!x.disabled),v!==-1&&(v=v+u);else{I=o.slice(0,b);let x=I.pop();for(;x&&x.disabled;)x=I.pop();v=x&&o.indexOf(x),v&&v!==-1&&(v=v+u)}}if(v){const I=v-l;this.onNavigate(c,i,I)}else this.onNavigate(c,i)}else if(!this.props.skipDisabledItems&&p)this.onNavigate(c,i);else{let v=null;if(i===r.Keys.down||i===r.Keys.right)v=o.slice(b+1).find(I=>!I.disabled);else if(i===r.Keys.up||i===r.Keys.left){const I=o.slice(0,b);for(v=I.pop();v&&v.disabled;)v=I.pop()}if(v){const I=o.indexOf(v);if(I!==-1){const x=u+I-l;this.onNavigate(c,i,x)}else this.onNavigate(c,i)}else this.onNavigate(c,i)}this.applyState(c),e.preventDefault()}else i===r.Keys.enter?(e.preventDefault(),this.props.allowCustom&&h&&d===null?this.customItemSelect(e):d&&d.disabled?f():this.selectFocusedItem(e)):i===r.Keys.esc&&f();else e.altKey&&i===r.Keys.down?f():i===r.Keys.esc&&this.clearButtonClick(e)},this.listContainerContent=()=>{const{header:e,footer:t,allowCustom:a,size:s,groupStickyHeaderItemRender:o,groupField:i,list:h}=this.props,p=g.getFilteredData(this.props),d=this.props.filter!==void 0?this.props.filter:this.state.text,{focusedType:l}=this.getFocusedState(),c=a&&d&&m.createElement("div",{className:r.classNames("k-list",{[`k-list-${T[s]||s}`]:s}),key:"customitem",onClick:this.customItemSelect,onMouseDown:R},m.createElement("div",{className:r.classNames("k-list-item k-custom-item",{"k-focus":q(l)}),style:{fontStyle:"italic"}},d,m.createElement(r.IconWrap,{name:"plus",icon:U.plusIcon,style:{position:"absolute",right:"0.5em"}})));let{group:f}=this.state;return f===void 0&&i!==void 0&&(f=g.getItemValue(p[0],i)),m.createElement(m.Fragment,null,e&&m.createElement("div",{className:"k-list-header"},e),c,m.createElement("div",{className:r.classNames("k-list",{[`k-list-${this.mobileMode?"lg":T[s]||s}`]:this.mobileMode||s,"k-virtual-list":this.base.vs.enabled})},!h&&f&&p.length!==0&&m.createElement(X,{group:f,render:o}),this.renderList()),this.showLicenseWatermark&&m.createElement(r.WatermarkOverlay,{message:this.licenseMessage}),t&&m.createElement("div",{className:"k-list-footer"},t))},this.renderListContainer=()=>{const e=this.base,{dir:t}=this.props,a=g.getFilteredData(this.props),s=this.base.getPopupSettings(),o=s.width!==void 0?s.width:e.popupWidth,i={dir:t!==void 0?t:e.dirCalculated,width:o,popupSettings:{...s,popupClass:r.classNames(s.popupClass,"k-list-container","k-multiselect-popup"),anchor:s.anchor||this.element,show:this.opened,onOpen:this.onPopupOpened,onClose:this.onPopupClosed},itemsCount:[a.length,this.value.length]};return m.createElement(J,{...i},this.listContainerContent())},this.renderAdaptiveListContainer=()=>{const{adaptiveTitle:e,adaptiveSubtitle:t,filterable:a,filter:s}=this.props,{windowWidth:o=0}=this.state,i=s!==void 0?s:this.state.text,h=a?m.createElement(ae,{value:i,ref:d=>{this._adaptiveInput=d&&d.element},onChange:this.onChangeHandler,onKeyDown:this.onInputKeyDown,size:"large",rounded:this.props.rounded,fillMode:this.props.fillMode,placeholder:this.props.placeholder}):null,p={title:e||this.props.label,subTitle:t,expand:this.opened,onClose:d=>this.closePopup(d),windowWidth:o,mobileFilter:h};return m.createElement(se.AdaptiveMode,{...p},m.createElement(ie.ActionSheetContent,null,m.createElement("div",{className:"k-list-container"},this.listContainerContent())))},this.closePopup=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.state.focusedIndex!==void 0&&(t.data.focusedIndex=void 0),this.opened&&this.base.togglePopup(t),t.events.push({type:"onClose"});const a=this.props.filter!==void 0?this.props.filter:this.state.text;g.isPresent(a)&&a!==""&&this.base.filterChanged("",t),this.state.text&&(t.data.text=""),this.applyState(t)},this.onCancel=e=>{const t=this.base.initState();t.syntheticEvent=e,e.stopPropagation(),this.state.focusedIndex!==void 0&&(t.data.focusedIndex=void 0),this.opened&&this.base.togglePopup(t),t.events.push({type:"onCancel"});const a=this.props.filter!==void 0?this.props.filter:this.state.text;g.isPresent(a)&&a!==""&&this.base.filterChanged("",t),this.state.text&&(t.data.text=""),this.applyState(t)},this.renderList=()=>{const e=O.provideLocalizationService(this),{textField:t,listNoDataRender:a,itemRender:s,groupHeaderItemRender:o,dataItemKey:i,virtual:h={skip:0,total:void 0}}=this.props,p=g.getFilteredData(this.props),d=this.base.vs,{focusedIndex:l}=this.getFocusedState(),c=this.base.getPopupSettings(),f=`translateY(${d.translate}px)`;return m.createElement(Q,{id:this.base.listBoxId,show:this.opened,data:p.slice(),focusedIndex:l-h.skip,value:this.value,textField:t,valueField:i,optionsGuid:this.base.guid,groupField:this.props.groupField,ariaLabel:e.toLanguageString(D.listAriaLabel,D.messages[D.listAriaLabel]),listRef:u=>{d.list=this.base.list=u},wrapperStyle:this.mobileMode?{}:{maxHeight:c.height},wrapperCssClass:"k-list-content",listStyle:d.enabled?{transform:f}:void 0,key:"listKey",skip:h.skip,onClick:this.handleItemClick,itemRender:s,groupHeaderItemRender:o,noDataRender:a,onMouseDown:R,onBlur:this.handleBlur,onScroll:this.onScroll,wrapperRef:d.scrollerRef,scroller:this.base.renderScrollElement(),ariaSetSize:h.total})},this.onScroll=e=>{const{vs:t,list:a}=this.base;t.scrollHandler(e);const{groupField:s}=this.props;let o=g.getFilteredData(this.props);if(!(!s||!o.length)&&s){const i=this.itemHeight=this.itemHeight||(t.enabled?t.itemHeight:a?a.children[0].offsetHeight:0),p=e.target.scrollTop-t.skip*i;o=this.base.getGroupedDataModernMode(o,s);let d=o[0][s];for(let l=1;l<o.length&&!(i*l>p);l++)o[l]&&o[l][s]&&(d=o[l][s]);d!==this.state.group&&this.setState({group:d})}},this.customItemSelect=e=>{const t=this.props.filter!==void 0?this.props.filter:this.state.text,{textField:a}=this.props;if(!t)return;const s=this.base.initState();s.syntheticEvent=e;const o=a?{[a]:t}:t;this.state.text!==void 0&&(s.data.text=""),s.data.focusedIndex=void 0,this.base.filterChanged("",s);const i=[...this.value,o];this.triggerOnChange(i,s),this.base.togglePopup(s),this.applyState(s)},this.handleWrapperClick=e=>{const t=this._input;!this.opened&&t&&this.focusElement(t);const a=this.base.initState();a.syntheticEvent=e,!this.state.focused&&!this.mobileMode&&(a.events.push({type:"onFocus"}),a.data.focused=!0),this.mobileMode&&(this.setState({currentValue:this.tagsToRender}),this.mobileMode&&window.setTimeout(()=>this._adaptiveInput&&this._adaptiveInput.focus(),300)),this.base.togglePopup(a),this.applyState(a)},this.handleItemClick=(e,t)=>{const a=this.base.initState();a.syntheticEvent=t,this.handleItemSelect(e,a),this.props.autoClose&&this.base.togglePopup(a),t.stopPropagation(),this.applyState(a)},this.handleBlur=e=>{if(!this.state.focused||this._skipFocusEvent)return;const t=this.base.initState(),{allowCustom:a,filterable:s}=this.props;t.syntheticEvent=e,t.data.focused=!1,t.events.push({type:"onBlur"}),this.opened&&!this.mobileMode&&(this.state.opened&&(t.data.opened=!1),t.events.push({type:"onClose"})),!a&&!s&&this.state.text&&(t.data.text=""),this.applyState(t)},this.handleFocus=e=>{this._skipFocusEvent||this.base.handleFocus(e)},this.onPopupOpened=()=>{this._input&&this.state.focused&&!this.mobileMode&&this.focusElement(this._input)},this.onPopupClosed=()=>{this.state.focused&&window.setTimeout(()=>{this.state.focused&&this.focusElement(this._input)},0)},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||le)},this.validate(n),this.licenseMessage=r.getLicenseMessage(L.packageMetadata)}get _inputId(){return this.props.id}get document(){if(r.canUseDOM)return this.element&&this.element.ownerDocument||document}validate(n){if(n.filterable||n.virtual){const e=[];n.filterable&&e.push("filterable"),n.virtual&&e.push("virtualization"),this.showLicenseWatermark=!r.validatePackage(L.packageMetadata,{component:"MultiSelect",features:e})}}get element(){return this._element}get opened(){return!!(this.props.opened!==void 0?this.props.opened:this.state.opened)}get tagsToRender(){const{tags:n,textField:e}=this.props,t=[];return n===void 0?this.value.forEach(a=>{t.push({text:g.getItemValue(a,e),data:[a]})}):t.push(...n),t}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(){const n=[];return this._valueItemsDuringOnChange?n.push(...this._valueItemsDuringOnChange):this.props.value?n.push(...this.props.value):this.state.value?n.push(...this.state.value):this.props.defaultValue&&n.push(...this.props.defaultValue),n}get name(){return this.props.name}get validity(){const n=this.props.validationMessage!==void 0,e=!this.required||this.value!==null&&this.value.length>0&&this.value!==void 0,t=this.props.valid!==void 0?this.props.valid:e;return{customError:n,valid:t,valueMissing:this.value===null}}get required(){return this.props.required!==void 0?this.props.required:C.defaultProps.required}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:C.defaultProps.validityStyles}componentDidUpdate(n,e){var c;const{virtual:t,groupField:a=""}=this.props,s=g.getFilteredData(this.props),o=t?t.skip:0,i=n.virtual?n.virtual.total:0,h=n.opened!==void 0?n.opened:e.opened,p=!h&&this.opened,d=h&&!this.opened,l=this.base.getPopupSettings();if(this.validate(this.props),this.base.didUpdate(),!l.animate&&d&&this.onPopupClosed(),t&&t.total!==i)this.base.vs.calcScrollElementHeight(),this.base.vs.reset();else{let{focusedItem:f,focusedIndex:u}=this.getFocusedState();a!==""&&(u=(c=this.base.getGroupedDataModernMode(s,a))==null?void 0:c.indexOf(f)),p&&t?this.base.scrollToVirtualItem(t,u-o):p&&!t?(s&&s.length!==0&&this.base.resetGroupStickyHeader(s[0][a],this),this.base.scrollToItem(u)):this.opened&&h&&f&&this.scrollToFocused&&this.base.scrollToItem(u-o)}this.scrollToFocused=!1,this.setValidity()}componentDidMount(){var e;this.observerResize=r.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);const n=this.props.name||this.props.id;this.KendoPasteSubscription=r.subscribeToKendoPaste(this._element,{fieldName:n,onValueChange:t=>{this.handleKendoPasteValue(t)}})}componentWillUnmount(){var n,e;(n=this.document)!=null&&n.body&&this.observerResize&&this.observerResize.disconnect(),(e=this.KendoPasteSubscription)==null||e.unsubscribe()}onNavigate(n,e,t){const{allowCustom:a}=this.props,s=g.getFilteredData(this.props),o=this.props.filter!==void 0?this.props.filter:this.state.text,{focusedType:i,focusedIndex:h}=this.getFocusedState(),p=a&&o,d=q(i),l=this.base,c=l.vs;if(this.opened&&e===r.Keys.up&&d)this.state.focusedIndex!==void 0&&(n.data.focusedIndex=void 0);else{const f=l.navigation.navigate({keyCode:e,current:h,max:(c.enabled?c.total:s.length)-1,min:p?-1:0,skipItems:t||void 0});f!==void 0&&(this.itemFocus(f,n),this.scrollToFocused=!0)}this.applyState(n)}render(){const{style:n,className:e,label:t,dir:a,disabled:s,textField:o,dataItemKey:i,virtual:h,size:p,rounded:d,fillMode:l,loading:c,filter:f}=this.props,{text:u,focused:b,focusedTag:v,currentValue:I}=this.state,x=this.base.vs,P=this.props.id||this._inputId;x.enabled=h!==void 0,h!==void 0&&(x.skip=h.skip,x.total=h.total,x.pageSize=h.pageSize);const k=this.mobileMode&&this.opened?I:this.tagsToRender;this.setItems(this.tagsToRender,this._tags);const E=!this.validityStyles||this.validity.valid,B=O.provideLocalizationService(this),V=!!(f!==void 0?f:u)||k&&k.length>0,[H,W]=N(this.props.prefix||m.Fragment),[$,j]=N(this.props.suffix||m.Fragment),_=m.createElement(m.Fragment,null,m.createElement("div",{ref:this.componentRef,className:r.classNames("k-multiselect k-input",e,{[`k-input-${T[p]||p}`]:p,[`k-rounded-${ne[d]||d}`]:d,[`k-input-${l}`]:l,"k-focus":b&&!s,"k-invalid":!E,"k-disabled":s,"k-loading":c,"k-required":this.required}),style:t?{...n,width:void 0}:n,dir:a,onFocus:w=>{this.mobileMode?this.handleWrapperClick(w):this.handleFocus(w)},onBlur:this.handleBlur,onClick:this.handleWrapperClick,onMouseDown:g.preventDefaultNonInputs},this.props.prefix&&m.createElement(H,{...W}),m.createElement("div",{className:r.classNames("k-input-values")},m.createElement("div",{className:r.classNames("k-chip-list",{[`k-chip-list-${T[p]||p}`]:p}),role:"listbox","aria-label":B.toLanguageString(D.chipListAriaLabel,D.messages[D.chipListAriaLabel]),"aria-orientation":"horizontal",id:"tagslist-"+this.base.guid},k&&k.length>0&&m.createElement(Z,{tagRender:this.props.tagRender,onTagDelete:this.onTagDelete,data:k,guid:this.base.guid,focused:v?k.find(w=>g.matchTags(w,v,i)):void 0,size:p})),this.renderSearchBar(P)),c&&m.createElement(r.IconWrap,{className:"k-input-loading-icon",name:"loading"}),this.props.suffix&&m.createElement($,{...j}),V&&m.createElement(te,{onClick:this.clearButtonClick}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return t?m.createElement(Y.FloatingLabel,{label:t,editorId:P,editorValue:u||g.getItemValue(this.value[0],o),editorValid:E,editorDisabled:s,style:{width:n?n.width:void 0},children:_}):_}renderSearchBar(n){const{activedescendant:e,focusedTag:t,currentValue:a}=this.state,{disabled:s,placeholder:o,ariaDescribedBy:i,ariaLabelledBy:h,ariaLabel:p,inputAttributes:d}=this.props,l=!this.mobileMode&&(this.props.filter!==void 0?this.props.filter:this.state.text)||"",{focusedIndex:c}=this.getFocusedState(),f=this.value.length===0&&!l?o:void 0,u=a&&a.length>0?void 0:o,b=e===K.ActiveDescendant.TagsList&&t!==void 0?`tag-${this.base.guid}-${t.text.replace(/\s+/g,"-")}`:`k-${this.base.guid}-item-${c+1}`,v=i?` ${i}`:"",I=this.value.length>0?`tagslist-${this.base.guid}${v}`:i,x={accessKey:this.props.accessKey,tabIndex:this.props.tabIndex};return m.createElement(ee,{id:n,name:this.props.name,size:Math.max((f||"").length,l.length,1),placeholder:this.mobileMode&&this.opened?u:f,value:l,onChange:this.onChangeHandler,onKeyDown:this.onInputKeyDown,ref:this.searchbarRef,disabled:s,expanded:this.opened,ariaControls:this.base.listBoxId,role:"combobox",activedescendant:b,ariaDescribedBy:I,ariaLabelledBy:h,ariaRequired:this.required,ariaLabel:p,ariaAutoComplete:"list",inputAttributes:d,...x})}onTagsNavigate(n,e){const t=n.keyCode,{focusedTag:a}=this.state,s=this._tags,o=this.props.dataItemKey;let i=a?s.findIndex(d=>g.matchTags(d,a,o)):-1,h;const p=i!==-1;if(t===r.Keys.left)p?i=Math.max(0,i-1):i=s.length-1,h=s[i];else if(t===r.Keys.right)i===s.length-1?h=void 0:p&&(i=Math.min(s.length-1,i+1),h=s[i]);else if(t===r.Keys.home&&!n.shiftKey)h=s[0];else if(t===r.Keys.end&&!n.shiftKey)h=s[s.length-1];else if(t===r.Keys.delete){if(p){const d=this.value;g.removeDataItems(d,s[i].data,o),this.triggerOnChange(d,e)}}else if(t===r.Keys.backspace){const d=this.value;if(p)g.removeDataItems(d,s[i].data,o),this.triggerOnChange(d,e);else if(!p&&s.length){const l=s.pop();g.removeDataItems(d,l.data,o),this.triggerOnChange(d,e)}}h!==a&&(e.data.focusedTag=h,e.data.activedescendant=K.ActiveDescendant.TagsList),this.applyState(e)}triggerOnChange(n,e){this.props.value===void 0&&(e.data.value=[...n]),this._valueItemsDuringOnChange=[],this.setItems(n,this._valueItemsDuringOnChange),e.events.push({type:"onChange"})}selectFocusedItem(n,e){const{virtual:t}=this.props,a=g.getFilteredData(this.props),{focusedIndex:s}=e||this.getFocusedState(),o=t?t.skip:0;a[s-o]!==void 0&&this.handleItemClick(s,n)}setItems(n,e){e.length=0,e.push(...n)}getFocusedState(){const{focusedIndex:n}=this.state,e=this.props.filter!==void 0?this.props.filter:this.state.text,{allowCustom:t,dataItemKey:a,virtual:s,textField:o,focusedItemIndex:i=g.itemIndexStartsWith,skipDisabledItems:h}=this.props,p=g.getFilteredData(this.props),d=s&&s.skip||0;let l;if(n!==void 0)return{focusedIndex:n,focusedItem:p[n-d],focusedType:1};const c=this.value;if(t&&e)return{focusedItem:null,focusedIndex:-1,focusedType:2};if(e)return l=i(p,e,o),{focusedItem:p[l],focusedIndex:l+d,focusedType:1};if(c.length){const f=c[c.length-1];return l=p.findIndex(u=>g.areSame(u,f,a)),p[l]!==void 0?{focusedIndex:l+d,focusedItem:p[l],focusedType:1}:{focusedType:0,focusedIndex:-1}}else if(h&&o&&!e&&d===0){const f=p.findIndex(u=>!u.disabled);return{focusedIndex:f,focusedItem:p[f-d],focusedType:1}}return d===0?{focusedItem:p[0],focusedIndex:0,focusedType:1}:{focusedType:0,focusedIndex:-1}}focusElement(n){this._skipFocusEvent=!0,n.focus(),window.setTimeout(()=>this._skipFocusEvent=!1,0)}applyState(n){this.base.applyState(n),this._valueItemsDuringOnChange=null}calculateMedia(n){for(const e of n)this.setState({windowWidth:e.target.clientWidth})}updateStateOnKeyboardNavigation(n,e){this.setState({value:n}),this.triggerOnChange(n,e),this.applyState(e)}getLastSelectedOrDeselectedIndex(n,e){return this._lastSelectedOrDeslectedItemIndex===null&&(this._lastSelectedOrDeslectedItemIndex=e),this._lastSelectedOrDeslectedItemIndex!==null?this._lastSelectedOrDeslectedItemIndex+n:null}};C.displayName="MultiSelect",C.propTypes={...M.propTypes,autoClose:y.bool,value:y.arrayOf(y.any),defaultValue:y.arrayOf(y.any),dataItemKey:y.string,placeholder:y.string,tags:y.arrayOf(y.shape({text:y.string,data:y.arrayOf(y.any)})),tagRender:y.func,id:y.string,ariaLabelledBy:y.string,ariaDescribedBy:y.string,groupField:y.string,list:y.any,adaptive:y.bool,adaptiveTitle:y.string,adaptiveSubtitle:y.string,onCancel:y.func,skipDisabledItems:y.bool,inputAttributes:y.object},C.defaultProps={...M.defaultProps,autoClose:!0,required:!1,size:void 0,rounded:void 0,fillMode:void 0,skipDisabledItems:!0,prefix:void 0,suffix:void 0};let F=C;const z=r.createPropsContext(),A=r.withIdHOC(r.withPropsContext(z,r.withAdaptiveModeContext(F)));A.displayName="KendoReactMultiSelect";O.registerForLocalization(F);exports.MultiSelect=A;exports.MultiSelectPropsContext=z;exports.MultiSelectWithoutContext=F;
|