@progress/kendo-react-dropdowns 7.5.0-develop.4 → 7.5.0-develop.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DropDownTree/DropDownTree.js +1 -1
- package/DropDownTree/DropDownTree.mjs +63 -63
- package/DropDownTree/useDropdownWidth.js +1 -1
- package/DropDownTree/useDropdownWidth.mjs +12 -9
- package/MultiSelectTree/MultiSelectTree.js +1 -1
- package/MultiSelectTree/MultiSelectTree.mjs +104 -104
- package/dist/cdn/js/kendo-react-dropdowns.js +1 -1
- package/package-metadata.mjs +1 -1
- package/package.json +9 -9
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ge=require("react"),n=require("prop-types"),r=require("@progress/kendo-react-common"),Je=require("@progress/kendo-react-popup"),Qe=require("@progress/kendo-react-intl"),Ce=require("@progress/kendo-react-treeview"),Xe=require("../package-metadata.js"),U=require("../common/utils.js"),Ye=require("./useDropdownWidth.js"),Ze=require("./ListNoData.js"),h=require("../messages/index.js"),et=require("@progress/kendo-react-labels"),we=require("../common/ListFilter.js"),tt=require("@progress/kendo-react-buttons"),xe=require("@progress/kendo-svg-icons"),nt=require("../common/AdaptiveMode.js"),at=require("@progress/kendo-react-layout"),ot=require("../common/constants.js");function rt(u){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const s in u)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(u,s);Object.defineProperty(f,s,o.get?o:{enumerable:!0,get:()=>u[s]})}}return f.default=u,Object.freeze(f)}const t=rt(Ge),{sizeMap:st,roundedMap:it}=r.kendoThemeMaps,lt="Please select a value from the list!",ct=u=>t.createElement("span",{className:"k-input-value-text"},u.children),De=u=>u.split("_").map(f=>parseInt(f,10)),ut=(u,f)=>{const{validationMessage:s,valid:o,required:G}=u;return{customError:s!==void 0,valid:!!(o!==void 0?o:!G||f),valueMissing:!f}},Ie={selectField:"selected",subItemsField:"items",popupSettings:{animate:!0,width:"200px",height:"200px"},data:[],required:!1,style:{},validityStyles:!0,size:"medium",rounded:"medium",fillMode:"solid"},Fe=r.createPropsContext(),oe=t.forwardRef((u,f)=>{r.validatePackage(Xe.packageMetadata);const s=r.usePropsContext(Fe,u),o={...Ie,...s},G=r.useId(),re=o.id||G,{data:M,dataItemKey:T,popupSettings:E={},style:N,opened:d,disabled:S,onOpen:P=r.noop,onClose:v=r.noop,placeholder:J,label:O,name:Se,selectField:H,subItemsField:V,validationMessage:_,valid:Re,required:Q,validityStyles:qe}=o,X=r.getTabIndex(o.tabIndex,S),i=t.useRef(null),g=t.useRef(null),R=t.useRef(null),Y=t.useRef(null),j=t.useRef(null),k=t.useRef(null),$=t.useRef(!1),[se,Ke]=t.useState(void 0),w=o.value!==void 0,b=w?o.value:se!==void 0?se:o.defaultValue,L=U.isPresent(b),Z=L?U.getItemValue(b,o.textField):"",ee=ut({validationMessage:_,valid:Re,required:Q},L),Me=t.useCallback(()=>g.current&&g.current.focus(),[]);t.useImperativeHandle(i,()=>({props:o,element:g.current,focus:Me})),t.useImperativeHandle(f,()=>i.current);const x=r.useRtl(g,o.dir),Te={width:Ye.useDropdownWidth(g,Ie,E,N),...x!==void 0?{direction:x}:{}},[Ne,ie]=t.useState(!1),l=d!==void 0?d:Ne,[p,te]=t.useState(!1),[ne,Pe]=t.useState(),D=!!(ne&&ne<=ot.MOBILE_MEDIUM_DEVISE&&o.adaptive),[le,Oe]=t.useState(""),Ve=t.useCallback(()=>{j.current&&j.current.setCustomValidity&&j.current.setCustomValidity(ee.valid?"":_===void 0?lt:_)},[_,ee]);t.useEffect(Ve),t.useEffect(()=>{const e=r.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver($e.bind(void 0));return document!=null&&document.body&&e&&e.observe(document.body),()=>{document!=null&&document.body&&e&&e.disconnect()}},[]);const ce=t.useCallback(e=>{if(!l){if(P){const a={...e};P.call(void 0,a)}d===void 0&&ie(!0)}},[l,d,P]),I=t.useCallback(e=>{if(l){if(v){const a={...e};v.call(void 0,a)}d===void 0&&(ie(!1),D&&setTimeout(()=>{var a;y((a=Y.current)==null?void 0:a.element)},300))}},[l,d,v,D]),Le=t.useCallback(e=>{if(!e.isDefaultPrevented()&&i.current){te(!0);const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};(l?I:ce)(a)}},[l,d,P,v]),q=t.useCallback(e=>{$.current=!0,e(),window.setTimeout(()=>$.current=!1,0)},[]),Be=t.useCallback(e=>{var F,Ee;const{keyCode:a,altKey:c}=e,m=k.current&&k.current.element;if(!i.current||e.isDefaultPrevented()&&((F=R.current)==null?void 0:F.element)===e.target)return;const K={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};if(l)if(a===r.Keys.esc||c&&a===r.Keys.up)e.preventDefault(),I(K);else if(m&&m.querySelector(".k-focus")&&(a===r.Keys.up||a===r.Keys.down||a===r.Keys.left||a===r.Keys.right||a===r.Keys.home||a===r.Keys.end)){if(a===r.Keys.up&&((Ee=R.current)!=null&&Ee.element)){const A=Array.from(m.querySelectorAll(".k-treeview-item")),ke=[...A].reverse().find(z=>!!(z&&z.querySelector(".k-focus")));if(ke&&A.indexOf(ke)===0)return q(()=>{var z;y((z=R.current)==null?void 0:z.element)})}q(r.noop)}else a===r.Keys.down&&q(()=>{var A;y(((A=R.current)==null?void 0:A.element)||m)});else c&&a===r.Keys.down?(e.preventDefault(),ce(K)):l||a===r.Keys.esc&&fe(e)},[l,d,P,v]),ue=t.useCallback(e=>{const{keyCode:a,altKey:c}=e;c||a!==r.Keys.up&&a!==r.Keys.down||(e.preventDefault(),q(a===r.Keys.up?()=>{y(g.current)}:()=>{y(k.current&&k.current.element)}))},[]),y=t.useCallback(e=>{e&&q(()=>e.focus())},[]),We=t.useCallback(()=>{var e;!p&&l&&!d?I({target:i.current}):s.filterable?y((e=R.current)==null?void 0:e.element):y(k.current&&k.current.element)},[v,s.filterable,p,d,l]),Ae=t.useCallback(()=>{p&&y(g.current)},[p]),ze=t.useCallback(e=>{if(!p&&!$.current&&(te(!0),s.onFocus&&i.current)){const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};s.onFocus.call(void 0,a)}},[p,s.onFocus]),He=t.useCallback(e=>{if(p&&!$.current&&i.current){te(!1);const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};if(s.onBlur){const c={...a};s.onBlur.call(void 0,c)}D||I(a)}},[p,s.onBlur,l,d,v]),_e=t.useCallback(()=>{p&&q(r.noop),D&&setTimeout(()=>{var e;y((e=Y.current)==null?void 0:e.element)},300)},[p,D]),de=t.useCallback((e,a,c)=>{if(s.onChange){const m={value:a,level:c?De(c):[],...e};s.onChange.call(void 0,m)}w||Ke(a)},[s.onChange,w]),pe=t.useCallback(e=>{if(U.areSame(e.item,b,T)||!i.current)return;const{item:a,itemHierarchicalIndex:c,nativeEvent:m,syntheticEvent:K}=e,F={syntheticEvent:K,nativeEvent:m,target:i.current};de(F,a,c),I(F)},[w,b,s.onChange,T,l,d,v]),fe=t.useCallback(e=>{if(!i.current)return;const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};de(a,null),I(a),e.preventDefault()},[w,s.onChange,l,d,v]),me=t.useCallback(e=>{if(e.syntheticEvent.stopPropagation(),s.onExpandChange&&i.current){const{item:a,itemHierarchicalIndex:c,nativeEvent:m,syntheticEvent:K}=e,F={level:De(c),item:a,nativeEvent:m,syntheticEvent:K,target:i.current};s.onExpandChange.call(void 0,F)}},[s.onExpandChange]),ve=t.useCallback(e=>{if(s.onFilterChange&&i.current){const c={filter:{field:s.textField,operator:"contains",value:e.target.value},syntheticEvent:e.syntheticEvent,nativeEvent:e.nativeEvent,target:i.current};s.onFilterChange.call(void 0,c),s.filter===void 0&&Oe(e.target.value)}},[s.onFilterChange,s.filter,s.textField]),je=()=>{const e=o.filterable?t.createElement(we,{value:o.filter===void 0?le:o.filter,ref:Y,onChange:ve,onKeyDown:ue,size:C,rounded:B,fillMode:W}):null,a={adaptiveTitle:o.adaptiveTitle,expand:l,onClose:c=>I(c),windowWidth:ne,mobileFilter:e};return t.createElement(nt.AdaptiveMode,{...a},t.createElement(at.ActionSheetContent,{className:"!k-overflow-hidden"},t.createElement("div",{className:"k-list-container"},t.createElement("div",{className:"k-list k-list-lg"},M.length>0?t.createElement(Ce.TreeView,{ref:k,tabIndex:X,data:ge,focusIdField:T,textField:o.textField,selectField:H,expandField:o.expandField,childrenField:V,expandIcons:!0,onItemClick:pe,onExpandChange:me,size:C,item:o.item,dir:x,animate:E.animate}):t.createElement(be,null,ae.toLanguageString(h.nodata,h.messages[h.nodata]))))))},$e=t.useCallback(e=>{for(let a of e)Pe(a.target.clientWidth)},[]),ge=t.useMemo(()=>w||!L?M:r.mapTree(M,V,e=>r.extendDataItem(e,V,{[H]:U.areSame(e,b,T)})),[M,b,w,L,H,V]),be=o.listNoData||Ze.ListNoData,Ue=o.valueHolder||ct,ae=Qe.useLocalization(),ye=!qe||ee.valid,{size:C,rounded:B,fillMode:W}=o,he=t.createElement(t.Fragment,null,t.createElement("span",{className:r.classNames("k-dropdowntree k-picker",o.className,{[`k-picker-${st[C]||C}`]:C,[`k-rounded-${it[B]||B}`]:B,[`k-picker-${W}`]:W,"k-focus":p,"k-invalid":!ye,"k-loading":o.loading,"k-required":Q,"k-disabled":o.disabled}),tabIndex:X,accessKey:o.accessKey,id:re,style:O?{...N,width:void 0}:N,dir:x,ref:g,onKeyDown:S?void 0:Be,onMouseDown:_e,onClick:S?void 0:Le,onFocus:ze,onBlur:He,role:"combobox","aria-haspopup":"tree","aria-expanded":l,"aria-disabled":S,"aria-label":O,"aria-labelledby":o.ariaLabelledBy,"aria-describedby":o.ariaDescribedBy,"aria-required":Q},t.createElement("span",{className:"k-input-inner"},(Z||J)&&t.createElement(Ue,{item:b},Z||J)),o.loading&&t.createElement(r.IconWrap,{className:"k-input-loading-icon",name:"loading"}),L&&!S&&t.createElement("span",{onClick:fe,className:"k-clear-value",title:ae.toLanguageString(h.clear,h.messages[h.clear]),role:"button",tabIndex:-1,onMouseDown:e=>e.preventDefault()},t.createElement(r.IconWrap,{name:"x",icon:xe.xIcon})),t.createElement(tt.Button,{tabIndex:-1,type:"button","aria-label":"select",className:"k-input-button",size:C,fillMode:W,themeColor:"base",rounded:null,icon:"caret-alt-down",svgIcon:xe.caretAltDownIcon}),t.createElement("select",{name:Se,ref:j,tabIndex:-1,"aria-hidden":!0,title:O,style:{opacity:0,width:1,border:0,zIndex:-1,position:"absolute",left:"50%"}},t.createElement("option",{value:o.valueMap?o.valueMap.call(void 0,b):b})),!D&&t.createElement(Je.Popup,{...E,className:r.classNames(E.className,{"k-rtl":x==="rtl"}),popupClass:r.classNames(E.popupClass,"k-dropdowntree-popup k-list-container"),style:Te,anchor:E.anchor||g.current,show:l,onOpen:We,onClose:Ae},o.filterable&&t.createElement(we,{value:o.filter===void 0?le:o.filter,ref:R,onChange:ve,onKeyDown:ue,size:C,rounded:B,fillMode:W,renderListFilterWrapper:!0,renderPrefixSeparator:!0}),M.length>0?t.createElement(Ce.TreeView,{style:{height:E.height},ref:k,tabIndex:X,data:ge,focusIdField:T,textField:o.textField,selectField:H,expandField:o.expandField,childrenField:V,expandIcons:!0,onItemClick:pe,onExpandChange:me,size:C,item:o.item,dir:x,animate:E.animate}):t.createElement(be,null,ae.toLanguageString(h.nodata,h.messages[h.nodata])))),D&&je());return O?t.createElement(et.FloatingLabel,{label:O,editorValue:Z,editorPlaceholder:J,editorValid:ye,editorDisabled:S,editorId:re,style:{width:N?N.width:void 0},children:he,dir:x}):he}),dt={opened:n.bool,disabled:n.bool,dir:n.string,tabIndex:n.number,accessKey:n.string,data:n.array,value:n.any,valueMap:n.func,placeholder:n.string,dataItemKey:n.string.isRequired,textField:n.string.isRequired,selectField:n.string,expandField:n.string,subItemsField:n.string,className:n.string,style:n.object,label:n.string,validationMessage:n.string,validityStyles:n.bool,valid:n.bool,required:n.bool,name:n.string,id:n.string,ariaLabelledBy:n.string,ariaDescribedBy:n.string,filterable:n.bool,filter:n.string,loading:n.bool,popupSettings:n.shape({animate:n.oneOfType([n.bool,n.shape({openDuration:n.number,closeDuration:n.number})]),popupClass:n.string,className:n.string,appendTo:n.any,width:n.oneOfType([n.string,n.number]),height:n.oneOfType([n.string,n.number])}),onOpen:n.func,onClose:n.func,onFocus:n.func,onBlur:n.func,onChange:n.func,onFilterChange:n.func,onExpandChange:n.func,item:n.func,valueHolder:n.func,listNoData:n.func,adaptiveTitle:n.string,adaptive:n.bool};oe.displayName="KendoReactDropDownTree";oe.propTypes=dt;exports.DropDownTree=oe;exports.DropDownTreePropsContext=Fe;
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ge=require("react"),n=require("prop-types"),r=require("@progress/kendo-react-common"),Je=require("@progress/kendo-react-popup"),Qe=require("@progress/kendo-react-intl"),we=require("@progress/kendo-react-treeview"),Xe=require("../package-metadata.js"),U=require("../common/utils.js"),Ye=require("./useDropdownWidth.js"),Ze=require("./ListNoData.js"),h=require("../messages/index.js"),et=require("@progress/kendo-react-labels"),xe=require("../common/ListFilter.js"),tt=require("@progress/kendo-react-buttons"),De=require("@progress/kendo-svg-icons"),nt=require("../common/AdaptiveMode.js"),at=require("@progress/kendo-react-layout"),ot=require("../common/constants.js");function rt(u){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const s in u)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(u,s);Object.defineProperty(f,s,o.get?o:{enumerable:!0,get:()=>u[s]})}}return f.default=u,Object.freeze(f)}const t=rt(Ge),{sizeMap:st,roundedMap:it}=r.kendoThemeMaps,lt="Please select a value from the list!",ct=u=>t.createElement("span",{className:"k-input-value-text"},u.children),Ie=u=>u.split("_").map(f=>parseInt(f,10)),ut=(u,f)=>{const{validationMessage:s,valid:o,required:G}=u;return{customError:s!==void 0,valid:!!(o!==void 0?o:!G||f),valueMissing:!f}},oe={selectField:"selected",subItemsField:"items",popupSettings:{animate:!0,width:"200px",height:"200px"},data:[],required:!1,style:{},validityStyles:!0,size:"medium",rounded:"medium",fillMode:"solid"},Fe=r.createPropsContext(),re=t.forwardRef((u,f)=>{r.validatePackage(Xe.packageMetadata);const s=r.usePropsContext(Fe,u),o={...oe,...s},G=r.useId(),se=o.id||G,{data:M,dataItemKey:T,popupSettings:E={},style:N,opened:d,disabled:S,onOpen:P=r.noop,onClose:v=r.noop,placeholder:J,label:O,name:Se,selectField:H,subItemsField:V,validationMessage:_,valid:Re,required:Q,validityStyles:qe}=o,X=r.getTabIndex(o.tabIndex,S),i=t.useRef(null),g=t.useRef(null),R=t.useRef(null),Y=t.useRef(null),j=t.useRef(null),k=t.useRef(null),$=t.useRef(!1),[ie,Ke]=t.useState(void 0),w=o.value!==void 0,b=w?o.value:ie!==void 0?ie:o.defaultValue,L=U.isPresent(b),Z=L?U.getItemValue(b,o.textField):"",ee=ut({validationMessage:_,valid:Re,required:Q},L),Me=t.useCallback(()=>g.current&&g.current.focus(),[]);t.useImperativeHandle(i,()=>({props:o,element:g.current,focus:Me})),t.useImperativeHandle(f,()=>i.current);const x=r.useRtl(g,o.dir),Te={width:Ye.useDropdownWidth(g,oe,{...oe.popupSettings,...E},N),...x!==void 0?{direction:x}:{}},[Ne,le]=t.useState(!1),l=d!==void 0?d:Ne,[p,te]=t.useState(!1),[ne,Pe]=t.useState(),D=!!(ne&&ne<=ot.MOBILE_MEDIUM_DEVISE&&o.adaptive),[ce,Oe]=t.useState(""),Ve=t.useCallback(()=>{j.current&&j.current.setCustomValidity&&j.current.setCustomValidity(ee.valid?"":_===void 0?lt:_)},[_,ee]);t.useEffect(Ve),t.useEffect(()=>{const e=r.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver($e.bind(void 0));return document!=null&&document.body&&e&&e.observe(document.body),()=>{document!=null&&document.body&&e&&e.disconnect()}},[]);const ue=t.useCallback(e=>{if(!l){if(P){const a={...e};P.call(void 0,a)}d===void 0&&le(!0)}},[l,d,P]),I=t.useCallback(e=>{if(l){if(v){const a={...e};v.call(void 0,a)}d===void 0&&(le(!1),D&&setTimeout(()=>{var a;y((a=Y.current)==null?void 0:a.element)},300))}},[l,d,v,D]),Le=t.useCallback(e=>{if(!e.isDefaultPrevented()&&i.current){te(!0);const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};(l?I:ue)(a)}},[l,d,P,v]),q=t.useCallback(e=>{$.current=!0,e(),window.setTimeout(()=>$.current=!1,0)},[]),Be=t.useCallback(e=>{var F,ke;const{keyCode:a,altKey:c}=e,m=k.current&&k.current.element;if(!i.current||e.isDefaultPrevented()&&((F=R.current)==null?void 0:F.element)===e.target)return;const K={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};if(l)if(a===r.Keys.esc||c&&a===r.Keys.up)e.preventDefault(),I(K);else if(m&&m.querySelector(".k-focus")&&(a===r.Keys.up||a===r.Keys.down||a===r.Keys.left||a===r.Keys.right||a===r.Keys.home||a===r.Keys.end)){if(a===r.Keys.up&&((ke=R.current)!=null&&ke.element)){const A=Array.from(m.querySelectorAll(".k-treeview-item")),Ce=[...A].reverse().find(z=>!!(z&&z.querySelector(".k-focus")));if(Ce&&A.indexOf(Ce)===0)return q(()=>{var z;y((z=R.current)==null?void 0:z.element)})}q(r.noop)}else a===r.Keys.down&&q(()=>{var A;y(((A=R.current)==null?void 0:A.element)||m)});else c&&a===r.Keys.down?(e.preventDefault(),ue(K)):l||a===r.Keys.esc&&me(e)},[l,d,P,v]),de=t.useCallback(e=>{const{keyCode:a,altKey:c}=e;c||a!==r.Keys.up&&a!==r.Keys.down||(e.preventDefault(),q(a===r.Keys.up?()=>{y(g.current)}:()=>{y(k.current&&k.current.element)}))},[]),y=t.useCallback(e=>{e&&q(()=>e.focus())},[]),We=t.useCallback(()=>{var e;!p&&l&&!d?I({target:i.current}):s.filterable?y((e=R.current)==null?void 0:e.element):y(k.current&&k.current.element)},[v,s.filterable,p,d,l]),Ae=t.useCallback(()=>{p&&y(g.current)},[p]),ze=t.useCallback(e=>{if(!p&&!$.current&&(te(!0),s.onFocus&&i.current)){const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};s.onFocus.call(void 0,a)}},[p,s.onFocus]),He=t.useCallback(e=>{if(p&&!$.current&&i.current){te(!1);const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};if(s.onBlur){const c={...a};s.onBlur.call(void 0,c)}D||I(a)}},[p,s.onBlur,l,d,v]),_e=t.useCallback(()=>{p&&q(r.noop),D&&setTimeout(()=>{var e;y((e=Y.current)==null?void 0:e.element)},300)},[p,D]),pe=t.useCallback((e,a,c)=>{if(s.onChange){const m={value:a,level:c?Ie(c):[],...e};s.onChange.call(void 0,m)}w||Ke(a)},[s.onChange,w]),fe=t.useCallback(e=>{if(U.areSame(e.item,b,T)||!i.current)return;const{item:a,itemHierarchicalIndex:c,nativeEvent:m,syntheticEvent:K}=e,F={syntheticEvent:K,nativeEvent:m,target:i.current};pe(F,a,c),I(F)},[w,b,s.onChange,T,l,d,v]),me=t.useCallback(e=>{if(!i.current)return;const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};pe(a,null),I(a),e.preventDefault()},[w,s.onChange,l,d,v]),ve=t.useCallback(e=>{if(e.syntheticEvent.stopPropagation(),s.onExpandChange&&i.current){const{item:a,itemHierarchicalIndex:c,nativeEvent:m,syntheticEvent:K}=e,F={level:Ie(c),item:a,nativeEvent:m,syntheticEvent:K,target:i.current};s.onExpandChange.call(void 0,F)}},[s.onExpandChange]),ge=t.useCallback(e=>{if(s.onFilterChange&&i.current){const c={filter:{field:s.textField,operator:"contains",value:e.target.value},syntheticEvent:e.syntheticEvent,nativeEvent:e.nativeEvent,target:i.current};s.onFilterChange.call(void 0,c),s.filter===void 0&&Oe(e.target.value)}},[s.onFilterChange,s.filter,s.textField]),je=()=>{const e=o.filterable?t.createElement(xe,{value:o.filter===void 0?ce:o.filter,ref:Y,onChange:ge,onKeyDown:de,size:C,rounded:B,fillMode:W}):null,a={adaptiveTitle:o.adaptiveTitle,expand:l,onClose:c=>I(c),windowWidth:ne,mobileFilter:e};return t.createElement(nt.AdaptiveMode,{...a},t.createElement(at.ActionSheetContent,{className:"!k-overflow-hidden"},t.createElement("div",{className:"k-list-container"},t.createElement("div",{className:"k-list k-list-lg"},M.length>0?t.createElement(we.TreeView,{ref:k,tabIndex:X,data:be,focusIdField:T,textField:o.textField,selectField:H,expandField:o.expandField,childrenField:V,expandIcons:!0,onItemClick:fe,onExpandChange:ve,size:C,item:o.item,dir:x,animate:E.animate}):t.createElement(ye,null,ae.toLanguageString(h.nodata,h.messages[h.nodata]))))))},$e=t.useCallback(e=>{for(let a of e)Pe(a.target.clientWidth)},[]),be=t.useMemo(()=>w||!L?M:r.mapTree(M,V,e=>r.extendDataItem(e,V,{[H]:U.areSame(e,b,T)})),[M,b,w,L,H,V]),ye=o.listNoData||Ze.ListNoData,Ue=o.valueHolder||ct,ae=Qe.useLocalization(),he=!qe||ee.valid,{size:C,rounded:B,fillMode:W}=o,Ee=t.createElement(t.Fragment,null,t.createElement("span",{className:r.classNames("k-dropdowntree k-picker",o.className,{[`k-picker-${st[C]||C}`]:C,[`k-rounded-${it[B]||B}`]:B,[`k-picker-${W}`]:W,"k-focus":p,"k-invalid":!he,"k-loading":o.loading,"k-required":Q,"k-disabled":o.disabled}),tabIndex:X,accessKey:o.accessKey,id:se,style:O?{...N,width:void 0}:N,dir:x,ref:g,onKeyDown:S?void 0:Be,onMouseDown:_e,onClick:S?void 0:Le,onFocus:ze,onBlur:He,role:"combobox","aria-haspopup":"tree","aria-expanded":l,"aria-disabled":S,"aria-label":O,"aria-labelledby":o.ariaLabelledBy,"aria-describedby":o.ariaDescribedBy,"aria-required":Q},t.createElement("span",{className:"k-input-inner"},(Z||J)&&t.createElement(Ue,{item:b},Z||J)),o.loading&&t.createElement(r.IconWrap,{className:"k-input-loading-icon",name:"loading"}),L&&!S&&t.createElement("span",{onClick:me,className:"k-clear-value",title:ae.toLanguageString(h.clear,h.messages[h.clear]),role:"button",tabIndex:-1,onMouseDown:e=>e.preventDefault()},t.createElement(r.IconWrap,{name:"x",icon:De.xIcon})),t.createElement(tt.Button,{tabIndex:-1,type:"button","aria-label":"select",className:"k-input-button",size:C,fillMode:W,themeColor:"base",rounded:null,icon:"caret-alt-down",svgIcon:De.caretAltDownIcon}),t.createElement("select",{name:Se,ref:j,tabIndex:-1,"aria-hidden":!0,title:O,style:{opacity:0,width:1,border:0,zIndex:-1,position:"absolute",left:"50%"}},t.createElement("option",{value:o.valueMap?o.valueMap.call(void 0,b):b})),!D&&t.createElement(Je.Popup,{...E,className:r.classNames(E.className,{"k-rtl":x==="rtl"}),popupClass:r.classNames(E.popupClass,"k-dropdowntree-popup k-list-container"),style:Te,anchor:E.anchor||g.current,show:l,onOpen:We,onClose:Ae},o.filterable&&t.createElement(xe,{value:o.filter===void 0?ce:o.filter,ref:R,onChange:ge,onKeyDown:de,size:C,rounded:B,fillMode:W,renderListFilterWrapper:!0,renderPrefixSeparator:!0}),M.length>0?t.createElement(we.TreeView,{style:{height:E.height},ref:k,tabIndex:X,data:be,focusIdField:T,textField:o.textField,selectField:H,expandField:o.expandField,childrenField:V,expandIcons:!0,onItemClick:fe,onExpandChange:ve,size:C,item:o.item,dir:x,animate:E.animate}):t.createElement(ye,null,ae.toLanguageString(h.nodata,h.messages[h.nodata])))),D&&je());return O?t.createElement(et.FloatingLabel,{label:O,editorValue:Z,editorPlaceholder:J,editorValid:he,editorDisabled:S,editorId:se,style:{width:N?N.width:void 0},children:Ee,dir:x}):Ee}),dt={opened:n.bool,disabled:n.bool,dir:n.string,tabIndex:n.number,accessKey:n.string,data:n.array,value:n.any,valueMap:n.func,placeholder:n.string,dataItemKey:n.string.isRequired,textField:n.string.isRequired,selectField:n.string,expandField:n.string,subItemsField:n.string,className:n.string,style:n.object,label:n.string,validationMessage:n.string,validityStyles:n.bool,valid:n.bool,required:n.bool,name:n.string,id:n.string,ariaLabelledBy:n.string,ariaDescribedBy:n.string,filterable:n.bool,filter:n.string,loading:n.bool,popupSettings:n.shape({animate:n.oneOfType([n.bool,n.shape({openDuration:n.number,closeDuration:n.number})]),popupClass:n.string,className:n.string,appendTo:n.any,width:n.oneOfType([n.string,n.number]),height:n.oneOfType([n.string,n.number])}),onOpen:n.func,onClose:n.func,onFocus:n.func,onBlur:n.func,onChange:n.func,onFilterChange:n.func,onExpandChange:n.func,item:n.func,valueHolder:n.func,listNoData:n.func,adaptiveTitle:n.string,adaptive:n.bool};re.displayName="KendoReactDropDownTree";re.propTypes=dt;exports.DropDownTree=re;exports.DropDownTreePropsContext=Fe;
|
|
@@ -8,30 +8,30 @@
|
|
|
8
8
|
"use client";
|
|
9
9
|
import * as t from "react";
|
|
10
10
|
import n from "prop-types";
|
|
11
|
-
import { createPropsContext as Xe, validatePackage as Ye, usePropsContext as Ze, useId as et, getTabIndex as tt, useRtl as nt, canUseDOM as at, Keys as c, noop as U, mapTree as ot, extendDataItem as rt, classNames as oe, IconWrap as
|
|
11
|
+
import { createPropsContext as Xe, validatePackage as Ye, usePropsContext as Ze, useId as et, getTabIndex as tt, useRtl as nt, canUseDOM as at, Keys as c, noop as U, mapTree as ot, extendDataItem as rt, classNames as oe, IconWrap as we, kendoThemeMaps as it } from "@progress/kendo-react-common";
|
|
12
12
|
import { Popup as lt } from "@progress/kendo-react-popup";
|
|
13
13
|
import { useLocalization as st } from "@progress/kendo-react-intl";
|
|
14
|
-
import { TreeView as
|
|
14
|
+
import { TreeView as Fe } from "@progress/kendo-react-treeview";
|
|
15
15
|
import { packageMetadata as ct } from "../package-metadata.mjs";
|
|
16
|
-
import { getItemValue as ut, areSame as
|
|
16
|
+
import { getItemValue as ut, areSame as De, isPresent as dt } from "../common/utils.mjs";
|
|
17
17
|
import { useDropdownWidth as pt } from "./useDropdownWidth.mjs";
|
|
18
18
|
import { ListNoData as ft } from "./ListNoData.mjs";
|
|
19
|
-
import { clear as
|
|
19
|
+
import { clear as Ie, messages as re, nodata as j } from "../messages/index.mjs";
|
|
20
20
|
import { FloatingLabel as mt } from "@progress/kendo-react-labels";
|
|
21
|
-
import
|
|
21
|
+
import Se from "../common/ListFilter.mjs";
|
|
22
22
|
import { Button as vt } from "@progress/kendo-react-buttons";
|
|
23
23
|
import { xIcon as gt, caretAltDownIcon as bt } from "@progress/kendo-svg-icons";
|
|
24
24
|
import { AdaptiveMode as ht } from "../common/AdaptiveMode.mjs";
|
|
25
25
|
import { ActionSheetContent as yt } from "@progress/kendo-react-layout";
|
|
26
26
|
import { MOBILE_MEDIUM_DEVISE as Et } from "../common/constants.mjs";
|
|
27
|
-
const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the list!", wt = (E) => /* @__PURE__ */ t.createElement("span", { className: "k-input-value-text" }, E.children),
|
|
27
|
+
const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the list!", wt = (E) => /* @__PURE__ */ t.createElement("span", { className: "k-input-value-text" }, E.children), Me = (E) => E.split("_").map((D) => parseInt(D, 10)), Ft = (E, D) => {
|
|
28
28
|
const { validationMessage: r, valid: o, required: G } = E;
|
|
29
29
|
return {
|
|
30
30
|
customError: r !== void 0,
|
|
31
31
|
valid: !!(o !== void 0 ? o : !G || D),
|
|
32
32
|
valueMissing: !D
|
|
33
33
|
};
|
|
34
|
-
},
|
|
34
|
+
}, ie = {
|
|
35
35
|
selectField: "selected",
|
|
36
36
|
subItemsField: "items",
|
|
37
37
|
popupSettings: {
|
|
@@ -49,9 +49,9 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
49
49
|
}, Dt = Xe(), Re = t.forwardRef((E, D) => {
|
|
50
50
|
Ye(ct);
|
|
51
51
|
const r = Ze(Dt, E), o = {
|
|
52
|
-
...
|
|
52
|
+
...ie,
|
|
53
53
|
...r
|
|
54
|
-
}, G = et(),
|
|
54
|
+
}, G = et(), le = o.id || G, {
|
|
55
55
|
data: T,
|
|
56
56
|
dataItemKey: N,
|
|
57
57
|
popupSettings: b = {},
|
|
@@ -69,7 +69,7 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
69
69
|
valid: Ne,
|
|
70
70
|
required: Q,
|
|
71
71
|
validityStyles: Pe
|
|
72
|
-
} = o, X = tt(o.tabIndex, I), i = t.useRef(null), m = t.useRef(null), S = t.useRef(null), Y = t.useRef(null), _ = t.useRef(null), h = t.useRef(null), $ = t.useRef(!1), [
|
|
72
|
+
} = o, X = tt(o.tabIndex, I), i = t.useRef(null), m = t.useRef(null), S = t.useRef(null), Y = t.useRef(null), _ = t.useRef(null), h = t.useRef(null), $ = t.useRef(!1), [se, Ve] = t.useState(void 0), C = o.value !== void 0, v = C ? o.value : se !== void 0 ? se : o.defaultValue, L = dt(v), Z = L ? ut(v, o.textField) : "", ee = Ft({ validationMessage: H, valid: Ne, required: Q }, L), Oe = t.useCallback(() => m.current && m.current.focus(), []);
|
|
73
73
|
t.useImperativeHandle(
|
|
74
74
|
i,
|
|
75
75
|
() => ({
|
|
@@ -79,9 +79,9 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
79
79
|
})
|
|
80
80
|
), t.useImperativeHandle(D, () => i.current);
|
|
81
81
|
const k = nt(m, o.dir), Ke = {
|
|
82
|
-
width: pt(m,
|
|
82
|
+
width: pt(m, ie, { ...ie.popupSettings, ...b }, P),
|
|
83
83
|
...k !== void 0 ? { direction: k } : {}
|
|
84
|
-
}, [Le,
|
|
84
|
+
}, [Le, ce] = t.useState(!1), l = u !== void 0 ? u : Le, [d, te] = t.useState(!1), [ne, Be] = t.useState(), x = !!(ne && ne <= Et && o.adaptive), [ue, We] = t.useState(""), qe = t.useCallback(
|
|
85
85
|
() => {
|
|
86
86
|
_.current && _.current.setCustomValidity && _.current.setCustomValidity(
|
|
87
87
|
ee.valid ? "" : H === void 0 ? xt : H
|
|
@@ -95,14 +95,14 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
95
95
|
document != null && document.body && e && e.disconnect();
|
|
96
96
|
};
|
|
97
97
|
}, []);
|
|
98
|
-
const
|
|
98
|
+
const de = t.useCallback(
|
|
99
99
|
(e) => {
|
|
100
100
|
if (!l) {
|
|
101
101
|
if (V) {
|
|
102
102
|
const a = { ...e };
|
|
103
103
|
V.call(void 0, a);
|
|
104
104
|
}
|
|
105
|
-
u === void 0 &&
|
|
105
|
+
u === void 0 && ce(!0);
|
|
106
106
|
}
|
|
107
107
|
},
|
|
108
108
|
[l, u, V]
|
|
@@ -113,7 +113,7 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
113
113
|
const a = { ...e };
|
|
114
114
|
f.call(void 0, a);
|
|
115
115
|
}
|
|
116
|
-
u === void 0 && (
|
|
116
|
+
u === void 0 && (ce(!1), x && setTimeout(() => {
|
|
117
117
|
var a;
|
|
118
118
|
g((a = Y.current) == null ? void 0 : a.element);
|
|
119
119
|
}, 300));
|
|
@@ -129,7 +129,7 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
129
129
|
nativeEvent: e.nativeEvent,
|
|
130
130
|
target: i.current
|
|
131
131
|
};
|
|
132
|
-
(l ? w :
|
|
132
|
+
(l ? w : de)(a);
|
|
133
133
|
}
|
|
134
134
|
},
|
|
135
135
|
[l, u, V, f]
|
|
@@ -140,7 +140,7 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
140
140
|
[]
|
|
141
141
|
), ze = t.useCallback(
|
|
142
142
|
(e) => {
|
|
143
|
-
var F,
|
|
143
|
+
var F, ke;
|
|
144
144
|
const { keyCode: a, altKey: s } = e, p = h.current && h.current.element;
|
|
145
145
|
if (!i.current || e.isDefaultPrevented() && ((F = S.current) == null ? void 0 : F.element) === e.target)
|
|
146
146
|
return;
|
|
@@ -153,9 +153,9 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
153
153
|
if (a === c.esc || s && a === c.up)
|
|
154
154
|
e.preventDefault(), w(R);
|
|
155
155
|
else if (p && p.querySelector(".k-focus") && (a === c.up || a === c.down || a === c.left || a === c.right || a === c.home || a === c.end)) {
|
|
156
|
-
if (a === c.up && ((
|
|
157
|
-
const q = Array.from(p.querySelectorAll(".k-treeview-item")),
|
|
158
|
-
if (
|
|
156
|
+
if (a === c.up && ((ke = S.current) != null && ke.element)) {
|
|
157
|
+
const q = Array.from(p.querySelectorAll(".k-treeview-item")), xe = [...q].reverse().find((A) => !!(A && A.querySelector(".k-focus")));
|
|
158
|
+
if (xe && q.indexOf(xe) === 0)
|
|
159
159
|
return M(() => {
|
|
160
160
|
var A;
|
|
161
161
|
g((A = S.current) == null ? void 0 : A.element);
|
|
@@ -168,10 +168,10 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
168
168
|
g(((q = S.current) == null ? void 0 : q.element) || p);
|
|
169
169
|
});
|
|
170
170
|
else
|
|
171
|
-
s && a === c.down ? (e.preventDefault(),
|
|
171
|
+
s && a === c.down ? (e.preventDefault(), de(R)) : l || a === c.esc && ve(e);
|
|
172
172
|
},
|
|
173
173
|
[l, u, V, f]
|
|
174
|
-
),
|
|
174
|
+
), pe = t.useCallback(
|
|
175
175
|
(e) => {
|
|
176
176
|
const { keyCode: a, altKey: s } = e;
|
|
177
177
|
s || a !== c.up && a !== c.down || (e.preventDefault(), M(
|
|
@@ -236,12 +236,12 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
236
236
|
}, 300);
|
|
237
237
|
},
|
|
238
238
|
[d, x]
|
|
239
|
-
),
|
|
239
|
+
), fe = t.useCallback(
|
|
240
240
|
(e, a, s) => {
|
|
241
241
|
if (r.onChange) {
|
|
242
242
|
const p = {
|
|
243
243
|
value: a,
|
|
244
|
-
level: s ?
|
|
244
|
+
level: s ? Me(s) : [],
|
|
245
245
|
...e
|
|
246
246
|
};
|
|
247
247
|
r.onChange.call(void 0, p);
|
|
@@ -249,19 +249,19 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
249
249
|
C || Ve(a);
|
|
250
250
|
},
|
|
251
251
|
[r.onChange, C]
|
|
252
|
-
),
|
|
252
|
+
), me = t.useCallback(
|
|
253
253
|
(e) => {
|
|
254
|
-
if (
|
|
254
|
+
if (De(e.item, v, N) || !i.current)
|
|
255
255
|
return;
|
|
256
256
|
const { item: a, itemHierarchicalIndex: s, nativeEvent: p, syntheticEvent: R } = e, F = {
|
|
257
257
|
syntheticEvent: R,
|
|
258
258
|
nativeEvent: p,
|
|
259
259
|
target: i.current
|
|
260
260
|
};
|
|
261
|
-
|
|
261
|
+
fe(F, a, s), w(F);
|
|
262
262
|
},
|
|
263
263
|
[C, v, r.onChange, N, l, u, f]
|
|
264
|
-
),
|
|
264
|
+
), ve = t.useCallback(
|
|
265
265
|
(e) => {
|
|
266
266
|
if (!i.current)
|
|
267
267
|
return;
|
|
@@ -270,14 +270,14 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
270
270
|
nativeEvent: e.nativeEvent,
|
|
271
271
|
target: i.current
|
|
272
272
|
};
|
|
273
|
-
|
|
273
|
+
fe(a, null), w(a), e.preventDefault();
|
|
274
274
|
},
|
|
275
275
|
[C, r.onChange, l, u, f]
|
|
276
|
-
),
|
|
276
|
+
), ge = t.useCallback(
|
|
277
277
|
(e) => {
|
|
278
278
|
if (e.syntheticEvent.stopPropagation(), r.onExpandChange && i.current) {
|
|
279
279
|
const { item: a, itemHierarchicalIndex: s, nativeEvent: p, syntheticEvent: R } = e, F = {
|
|
280
|
-
level:
|
|
280
|
+
level: Me(s),
|
|
281
281
|
item: a,
|
|
282
282
|
nativeEvent: p,
|
|
283
283
|
syntheticEvent: R,
|
|
@@ -287,7 +287,7 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
287
287
|
}
|
|
288
288
|
},
|
|
289
289
|
[r.onExpandChange]
|
|
290
|
-
),
|
|
290
|
+
), be = t.useCallback(
|
|
291
291
|
(e) => {
|
|
292
292
|
if (r.onFilterChange && i.current) {
|
|
293
293
|
const s = {
|
|
@@ -302,12 +302,12 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
302
302
|
[r.onFilterChange, r.filter, r.textField]
|
|
303
303
|
), Ge = () => {
|
|
304
304
|
const e = o.filterable ? /* @__PURE__ */ t.createElement(
|
|
305
|
-
|
|
305
|
+
Se,
|
|
306
306
|
{
|
|
307
|
-
value: o.filter === void 0 ?
|
|
307
|
+
value: o.filter === void 0 ? ue : o.filter,
|
|
308
308
|
ref: Y,
|
|
309
|
-
onChange:
|
|
310
|
-
onKeyDown:
|
|
309
|
+
onChange: be,
|
|
310
|
+
onKeyDown: pe,
|
|
311
311
|
size: y,
|
|
312
312
|
rounded: B,
|
|
313
313
|
fillMode: W
|
|
@@ -320,43 +320,43 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
320
320
|
mobileFilter: e
|
|
321
321
|
};
|
|
322
322
|
return /* @__PURE__ */ t.createElement(ht, { ...a }, /* @__PURE__ */ t.createElement(yt, { className: "!k-overflow-hidden" }, /* @__PURE__ */ t.createElement("div", { className: "k-list-container" }, /* @__PURE__ */ t.createElement("div", { className: "k-list k-list-lg" }, T.length > 0 ? /* @__PURE__ */ t.createElement(
|
|
323
|
-
|
|
323
|
+
Fe,
|
|
324
324
|
{
|
|
325
325
|
ref: h,
|
|
326
326
|
tabIndex: X,
|
|
327
|
-
data:
|
|
327
|
+
data: he,
|
|
328
328
|
focusIdField: N,
|
|
329
329
|
textField: o.textField,
|
|
330
330
|
selectField: z,
|
|
331
331
|
expandField: o.expandField,
|
|
332
332
|
childrenField: K,
|
|
333
333
|
expandIcons: !0,
|
|
334
|
-
onItemClick:
|
|
335
|
-
onExpandChange:
|
|
334
|
+
onItemClick: me,
|
|
335
|
+
onExpandChange: ge,
|
|
336
336
|
size: y,
|
|
337
337
|
item: o.item,
|
|
338
338
|
dir: k,
|
|
339
339
|
animate: b.animate
|
|
340
340
|
}
|
|
341
|
-
) : /* @__PURE__ */ t.createElement(
|
|
341
|
+
) : /* @__PURE__ */ t.createElement(ye, null, ae.toLanguageString(j, re[j]))))));
|
|
342
342
|
}, Je = t.useCallback(
|
|
343
343
|
(e) => {
|
|
344
344
|
for (let a of e)
|
|
345
345
|
Be(a.target.clientWidth);
|
|
346
346
|
},
|
|
347
347
|
[]
|
|
348
|
-
),
|
|
348
|
+
), he = t.useMemo(
|
|
349
349
|
() => C || !L ? T : ot(
|
|
350
350
|
T,
|
|
351
351
|
K,
|
|
352
352
|
(e) => rt(
|
|
353
353
|
e,
|
|
354
354
|
K,
|
|
355
|
-
{ [z]:
|
|
355
|
+
{ [z]: De(e, v, N) }
|
|
356
356
|
)
|
|
357
357
|
),
|
|
358
358
|
[T, v, C, L, z, K]
|
|
359
|
-
),
|
|
359
|
+
), ye = o.listNoData || ft, Qe = o.valueHolder || wt, ae = st(), Ee = !Pe || ee.valid, { size: y, rounded: B, fillMode: W } = o, Ce = /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement(
|
|
360
360
|
"span",
|
|
361
361
|
{
|
|
362
362
|
className: oe("k-dropdowntree k-picker", o.className, {
|
|
@@ -364,14 +364,14 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
364
364
|
[`k-rounded-${kt[B] || B}`]: B,
|
|
365
365
|
[`k-picker-${W}`]: W,
|
|
366
366
|
"k-focus": d,
|
|
367
|
-
"k-invalid": !
|
|
367
|
+
"k-invalid": !Ee,
|
|
368
368
|
"k-loading": o.loading,
|
|
369
369
|
"k-required": Q,
|
|
370
370
|
"k-disabled": o.disabled
|
|
371
371
|
}),
|
|
372
372
|
tabIndex: X,
|
|
373
373
|
accessKey: o.accessKey,
|
|
374
|
-
id:
|
|
374
|
+
id: le,
|
|
375
375
|
style: O ? { ...P, width: void 0 } : P,
|
|
376
376
|
dir: k,
|
|
377
377
|
ref: m,
|
|
@@ -390,18 +390,18 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
390
390
|
"aria-required": Q
|
|
391
391
|
},
|
|
392
392
|
/* @__PURE__ */ t.createElement("span", { className: "k-input-inner" }, (Z || J) && /* @__PURE__ */ t.createElement(Qe, { item: v }, Z || J)),
|
|
393
|
-
o.loading && /* @__PURE__ */ t.createElement(
|
|
393
|
+
o.loading && /* @__PURE__ */ t.createElement(we, { className: "k-input-loading-icon", name: "loading" }),
|
|
394
394
|
L && !I && /* @__PURE__ */ t.createElement(
|
|
395
395
|
"span",
|
|
396
396
|
{
|
|
397
|
-
onClick:
|
|
397
|
+
onClick: ve,
|
|
398
398
|
className: "k-clear-value",
|
|
399
|
-
title: ae.toLanguageString(
|
|
399
|
+
title: ae.toLanguageString(Ie, re[Ie]),
|
|
400
400
|
role: "button",
|
|
401
401
|
tabIndex: -1,
|
|
402
402
|
onMouseDown: (e) => e.preventDefault()
|
|
403
403
|
},
|
|
404
|
-
/* @__PURE__ */ t.createElement(
|
|
404
|
+
/* @__PURE__ */ t.createElement(we, { name: "x", icon: gt })
|
|
405
405
|
),
|
|
406
406
|
/* @__PURE__ */ t.createElement(
|
|
407
407
|
vt,
|
|
@@ -443,12 +443,12 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
443
443
|
onClose: _e
|
|
444
444
|
},
|
|
445
445
|
o.filterable && /* @__PURE__ */ t.createElement(
|
|
446
|
-
|
|
446
|
+
Se,
|
|
447
447
|
{
|
|
448
|
-
value: o.filter === void 0 ?
|
|
448
|
+
value: o.filter === void 0 ? ue : o.filter,
|
|
449
449
|
ref: S,
|
|
450
|
-
onChange:
|
|
451
|
-
onKeyDown:
|
|
450
|
+
onChange: be,
|
|
451
|
+
onKeyDown: pe,
|
|
452
452
|
size: y,
|
|
453
453
|
rounded: B,
|
|
454
454
|
fillMode: W,
|
|
@@ -457,26 +457,26 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
457
457
|
}
|
|
458
458
|
),
|
|
459
459
|
T.length > 0 ? /* @__PURE__ */ t.createElement(
|
|
460
|
-
|
|
460
|
+
Fe,
|
|
461
461
|
{
|
|
462
462
|
style: { height: b.height },
|
|
463
463
|
ref: h,
|
|
464
464
|
tabIndex: X,
|
|
465
|
-
data:
|
|
465
|
+
data: he,
|
|
466
466
|
focusIdField: N,
|
|
467
467
|
textField: o.textField,
|
|
468
468
|
selectField: z,
|
|
469
469
|
expandField: o.expandField,
|
|
470
470
|
childrenField: K,
|
|
471
471
|
expandIcons: !0,
|
|
472
|
-
onItemClick:
|
|
473
|
-
onExpandChange:
|
|
472
|
+
onItemClick: me,
|
|
473
|
+
onExpandChange: ge,
|
|
474
474
|
size: y,
|
|
475
475
|
item: o.item,
|
|
476
476
|
dir: k,
|
|
477
477
|
animate: b.animate
|
|
478
478
|
}
|
|
479
|
-
) : /* @__PURE__ */ t.createElement(
|
|
479
|
+
) : /* @__PURE__ */ t.createElement(ye, null, ae.toLanguageString(j, re[j]))
|
|
480
480
|
)
|
|
481
481
|
), x && Ge());
|
|
482
482
|
return O ? /* @__PURE__ */ t.createElement(
|
|
@@ -485,14 +485,14 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
485
485
|
label: O,
|
|
486
486
|
editorValue: Z,
|
|
487
487
|
editorPlaceholder: J,
|
|
488
|
-
editorValid:
|
|
488
|
+
editorValid: Ee,
|
|
489
489
|
editorDisabled: I,
|
|
490
|
-
editorId:
|
|
490
|
+
editorId: le,
|
|
491
491
|
style: { width: P ? P.width : void 0 },
|
|
492
|
-
children:
|
|
492
|
+
children: Ce,
|
|
493
493
|
dir: k
|
|
494
494
|
}
|
|
495
|
-
) :
|
|
495
|
+
) : Ce;
|
|
496
496
|
}), It = {
|
|
497
497
|
opened: n.bool,
|
|
498
498
|
disabled: n.bool,
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react");function h(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,i.get?i:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const p=h(f);function a(t,n,e){const[i,o]=p.useState(n);return p.useEffect(()=>{i!==void 0&&t.current&&o(t.current.offsetWidth)},e),i}function c(t){return typeof t=="string"?Number(t.replace("px","")):t||void 0}function l(t,n,e,i){const o=c(n.popupSettings.width),d=(e.width!==void 0&&c(e.width))!==o,u=i.width!==void 0,s=d?e.width:u?i.width:o,r=c(a(t,s));return d||u?s:r&&o&&r>o?r:o}exports.useDropdownWidth=l;
|
|
@@ -7,19 +7,22 @@
|
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
9
|
import * as p from "react";
|
|
10
|
-
function u(
|
|
11
|
-
const [
|
|
10
|
+
function u(t, e, n) {
|
|
11
|
+
const [d, i] = p.useState(e);
|
|
12
12
|
return p.useEffect(
|
|
13
13
|
() => {
|
|
14
|
-
|
|
14
|
+
d !== void 0 && t.current && i(t.current.offsetWidth);
|
|
15
15
|
},
|
|
16
|
-
|
|
17
|
-
),
|
|
16
|
+
n
|
|
17
|
+
), d;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
function r(t) {
|
|
20
|
+
return typeof t == "string" ? Number(t.replace("px", "")) : t || void 0;
|
|
21
|
+
}
|
|
22
|
+
function W(t, e, n, d) {
|
|
23
|
+
const i = r(e.popupSettings.width), s = (n.width !== void 0 && r(n.width)) !== i, c = d.width !== void 0, h = s ? n.width : c ? d.width : i, o = r(u(t, h));
|
|
24
|
+
return s || c ? h : o && i && o > i ? o : i;
|
|
22
25
|
}
|
|
23
26
|
export {
|
|
24
|
-
|
|
27
|
+
W as useDropdownWidth
|
|
25
28
|
};
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ze=require("react"),a=require("prop-types"),s=require("@progress/kendo-react-common"),et=require("@progress/kendo-react-popup"),tt=require("@progress/kendo-react-intl"),we=require("@progress/kendo-react-treeview"),nt=require("../package-metadata.js"),ee=require("../common/utils.js"),at=require("../DropDownTree/useDropdownWidth.js"),rt=require("../DropDownTree/ListNoData.js"),m=require("../messages/index.js"),st=require("@progress/kendo-react-labels"),it=require("../MultiSelect/TagList.js"),ot=require("../common/ClearButton.js"),Ie=require("../common/ListFilter.js"),lt=require("../common/AdaptiveMode.js"),ct=require("@progress/kendo-react-layout"),ut=require("../common/constants.js");function dt(h){const b=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const t in h)if(t!=="default"){const w=Object.getOwnPropertyDescriptor(h,t);Object.defineProperty(b,t,w.get?w:{enumerable:!0,get:()=>h[t]})}}return b.default=h,Object.freeze(b)}const n=dt(Ze),pt="Please select a value from the list!",{sizeMap:Te,roundedMap:ft}=s.kendoThemeMaps,gt=h=>h.split("_").map(b=>parseInt(b,10)),vt=(h,b)=>{const{validationMessage:t,valid:w,required:I}=h;return{customError:t!==void 0,valid:!!(w!==void 0?w:!I||b),valueMissing:!b}},q={checkField:"checkField",checkIndeterminateField:"checkIndeterminateField",subItemsField:"items",popupSettings:{animate:!0,width:"200px",height:"200px"},size:"medium",rounded:"medium",fillMode:"solid",required:!1,validityStyles:!0},Ke=s.createPropsContext(),te=n.forwardRef((h,b)=>{const t=s.usePropsContext(Ke,h);s.validatePackage(nt.packageMetadata);const w=s.useId(),I=t.id||w,{data:B=[],dataItemKey:T,popupSettings:N={},style:L={},opened:K,disabled:F,onOpen:ne=s.noop,onClose:W=s.noop,placeholder:ue,label:V,name:Me,checkField:de=q.checkField,checkIndeterminateField:pe=q.checkIndeterminateField,subItemsField:fe=q.subItemsField,validationMessage:z,valid:Re,tags:ge,value:g,required:ve=q.required,validityStyles:De=q.validityStyles}=t,_=s.getTabIndex(t.tabIndex,F),o=n.useRef(null),E=n.useRef(null),M=n.useRef(null),ae=n.useRef(null),j=n.useRef(null),x=n.useRef(null),$=n.useRef(!1),H=n.useRef([]),G=n.useRef(null),[P,qe]=n.useState(),[Ne,me]=n.useState(!1),[d,re]=n.useState(!1),[se,Pe]=n.useState(),[Oe,Le]=n.useState([]),[he,Ve]=n.useState(""),O=!!(se&&se<=ut.MOBILE_MEDIUM_DEVISE&&t.adaptive),l=K!==void 0?K:Ne,ie=!!(Array.isArray(g)&&g.length),oe=vt({validationMessage:z,valid:Re,required:ve},ie),R=s.useRtl(E,t.dir),Ae={width:at.useDropdownWidth(E,q,N,L),...R!==void 0?{direction:R}:{}},Be=n.useCallback(()=>E.current&&E.current.focus(),[]);H.current=ge===void 0?(g||[]).map(e=>({text:ee.getItemValue(e,t.textField),data:[e]})):[...ge],n.useImperativeHandle(o,()=>({props:t,element:E.current,focus:Be})),n.useImperativeHandle(b,()=>o.current);const We=n.useCallback(()=>{j.current&&j.current.setCustomValidity&&j.current.setCustomValidity(oe.valid?"":z===void 0?pt:z)},[z,oe]);n.useEffect(We),n.useEffect(()=>{const e=s.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(Xe.bind(void 0));return document!=null&&document.body&&e&&e.observe(document.body),()=>{e&&e.disconnect()}},[]),n.useEffect(()=>{G.current&&l&&G.current.setPosition(G.current._popup)},[g,l]);const S=n.useCallback((e,r,i)=>{if(t.onChange){const k={items:r,operation:i,...e};t.onChange.call(void 0,k)}},[t.onChange]),U=n.useCallback(e=>{if(ee.areSame(e.item,g,T)||!o.current)return;const{item:r,nativeEvent:i,syntheticEvent:k}=e,D={syntheticEvent:k,nativeEvent:i,target:o.current};S(D,[r],"toggle")},[g,T,S]),J=n.useCallback(e=>{if(!l){if(ne){const r={...e};ne.call(void 0,r)}K===void 0&&(me(!0),Le(g||[]),O&&setTimeout(()=>{var r;u((r=ae.current)==null?void 0:r.element)},300))}},[l,K,ne,O,ae]),v=n.useCallback(e=>{if(l){if(W){const r={...e};W.call(void 0,r)}K===void 0&&me(!1)}},[l,K,W]),C=n.useCallback(e=>{$.current=!0,e(),window.setTimeout(()=>$.current=!1,0)},[]),u=n.useCallback(e=>{e&&C(()=>e.focus())},[C]),ze=n.useCallback(()=>{var e;!d&&l?v({target:o.current}):t.filterable?u((e=M.current)==null?void 0:e.element):u(x.current&&x.current.element)},[d,l,u,v,t.filterable]),_e=n.useCallback(()=>{d&&u(E.current)},[d,u]),je=n.useCallback(e=>{if(!d&&!$.current&&(re(!0),t.onFocus&&o.current)){const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};t.onFocus.call(void 0,r)}},[d,t.onFocus]),$e=n.useCallback(e=>{if(d&&!$.current&&o.current){re(!1);const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};if(t.onBlur){const i={...r};t.onBlur.call(void 0,i)}O||v(r)}},[d,t.onBlur,l,K,W]),He=n.useCallback(()=>{d&&C(s.noop)},[d,C]),Ge=n.useCallback(e=>{if(!e.isDefaultPrevented()&&o.current){re(!0);const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};l||J(r)}},[l,J]),Ue=n.useCallback(e=>{var Z,Se;const{keyCode:r,altKey:i}=e,k=x.current&&x.current.element;if(!o.current||e.isDefaultPrevented()&&((Z=M.current)==null?void 0:Z.element)===e.target)return;const D={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};if(g&&g.length>0&&(r===s.Keys.left||r===s.Keys.right||r===s.Keys.home||r===s.Keys.end||r===s.Keys.delete)){const c=H.current;let p=P?c.findIndex(Ye=>ee.matchTags(Ye,P,T)):-1,f;const ce=p!==-1;r===s.Keys.left?(ce?p=Math.max(0,p-1):p=c.length-1,f=c[p]):r===s.Keys.right?p===c.length-1?f=void 0:ce&&(p=Math.min(c.length-1,p+1),f=c[p]):r===s.Keys.home?f=c[0]:r===s.Keys.end?f=c[c.length-1]:r===s.Keys.delete&&ce&&S(D,c[p].data,"delete"),f!==P&&qe(f)}if(l)if(r===s.Keys.esc||i&&r===s.Keys.up)e.preventDefault(),v(D);else if(k&&k.querySelector(".k-focus")&&(r===s.Keys.up||r===s.Keys.down||r===s.Keys.left||r===s.Keys.right||r===s.Keys.home||r===s.Keys.end)){if(r===s.Keys.up&&((Se=M.current)!=null&&Se.element)){const c=Array.from(k.querySelectorAll(".k-treeview-item")),p=[...c].reverse().find(f=>!!(f&&f.querySelector(".k-focus")));if(p&&c.indexOf(p)===0)return C(()=>{var f;u((f=M.current)==null?void 0:f.element)})}C(s.noop)}else r===s.Keys.down&&C(()=>{var c;u(((c=M.current)==null?void 0:c.element)||k)});else i&&r===s.Keys.down&&(e.preventDefault(),J(D))},[l,v,u,C,J,P,T,g,S]),ye=n.useCallback(e=>{const{keyCode:r,altKey:i}=e;i||r!==s.Keys.up&&r!==s.Keys.down||(e.preventDefault(),C(r===s.Keys.up?()=>{u(E.current)}:()=>{u(x.current&&x.current.element)}))},[u,C]),le=n.useCallback(e=>{if(!o.current)return;const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};S(r,[],"clear"),v(r),e.preventDefault()},[S,v]),Je=n.useCallback((e,r)=>{var i;v({target:o.current}),d||u((i=M.current)==null?void 0:i.element),S({syntheticEvent:r,nativeEvent:r.nativeEvent,target:o.current},e,"delete")},[S,v,u,d]),be=n.useCallback(e=>{if(t.onExpandChange&&o.current){const{item:r,itemHierarchicalIndex:i,nativeEvent:k,syntheticEvent:D}=e,Z={level:gt(i),item:r,nativeEvent:k,syntheticEvent:D,target:o.current};t.onExpandChange.call(void 0,Z)}},[t.onExpandChange]),Ce=n.useCallback(e=>{if(t.onFilterChange&&o.current){const i={filter:{field:t.textField,operator:"contains",value:e.target.value},syntheticEvent:e.syntheticEvent,nativeEvent:e.nativeEvent,target:o.current};t.onFilterChange.call(void 0,i),t.filter===void 0&&Ve(e.target.value)}},[t.onFilterChange,t.filter,t.textField]),ke=n.useCallback(e=>{if(!o.current)return;const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};t.onCancel&&t.onCancel.call(void 0,r),v(r),e.preventDefault()},[t.onCancel,v]),Qe=()=>{const e=t.filterable?n.createElement(Ie,{value:t.filter===void 0?he:t.filter,ref:ae,onChange:Ce,onKeyDown:ye,size:y,rounded:A,fillMode:X}):null,r={adaptiveTitle:t.adaptiveTitle,expand:l,onClose:i=>t.onCancel?ke(i):le(i),windowWidth:se,mobileFilter:e,footer:{cancelText:Q.toLanguageString(m.adaptiveModeFooterCancel,m.messages[m.adaptiveModeFooterCancel]),onCancel:i=>t.onCancel?ke(i):le(i),applyText:Q.toLanguageString(m.adaptiveModeFooterApply,m.messages[m.adaptiveModeFooterApply]),onApply:i=>v(i)}};return n.createElement(lt.AdaptiveMode,{...r},n.createElement(ct.ActionSheetContent,{className:"!k-overflow-hidden"},n.createElement("div",{className:"k-list-container"},n.createElement("div",{className:"k-list k-list-lg"},B.length>0?n.createElement(we.TreeView,{ref:x,tabIndex:_,data:B,focusIdField:T,textField:t.textField,checkField:de,checkIndeterminateField:pe,expandField:t.expandField,childrenField:fe,expandIcons:!0,onItemClick:U,onCheckChange:U,onExpandChange:be,checkboxes:!0,size:y,item:t.item,dir:R}):n.createElement(Ee,null,Q.toLanguageString(m.nodata,m.messages[m.nodata]))))))},Xe=n.useCallback(e=>{for(let r of e)Pe(r.target.clientWidth)},[]),Ee=t.listNoData||rt.ListNoData,Q=tt.useLocalization(),Fe=!De||oe.valid,{size:y,rounded:A,fillMode:X}=t,Y=O&&l?Oe:H.current,xe=n.createElement(n.Fragment,null,n.createElement("span",{className:s.classNames("k-multiselecttree k-input",t.className,{[`k-input-${Te[y]||y}`]:y,[`k-rounded-${ft[A]||A}`]:A,[`k-input-${X}`]:X,"k-focus":d&&!F,"k-invalid":!Fe,"k-disabled":F,"k-loading":t.loading,"k-required":ve}),tabIndex:_,accessKey:t.accessKey,id:I,style:V?{...L,width:void 0}:L,dir:R,ref:E,onKeyDown:F?void 0:Ue,onMouseDown:He,onFocus:je,onBlur:$e,role:"combobox","aria-haspopup":"tree","aria-expanded":l,"aria-disabled":F,"aria-label":V,"aria-labelledby":t.ariaLabelledBy,"aria-describedby":t.ariaDescribedBy?t.ariaDescribedBy:"tagslist-"+I,"aria-required":t.required,onClick:F?void 0:Ge},n.createElement("div",{id:"tagslist-"+I,className:s.classNames("k-input-values k-chip-list",{[`k-chip-list-${Te[y]||y}`]:y})},Y.length>0&&n.createElement(it,{tag:t.tag,onTagDelete:Je,data:Y,guid:I,focused:P?H.current.find(e=>ee.matchTags(e,P,T)):void 0,size:y})),n.createElement("span",{className:"k-input-inner"},Y.length===0&&n.createElement("span",{className:"k-input-value-text"},ue)),t.loading&&n.createElement(s.IconWrap,{className:"k-input-loading-icon",name:"loading"}),ie&&!F&&Y.length>0&&n.createElement(ot,{onClick:le}),n.createElement("select",{name:Me,ref:j,tabIndex:-1,"aria-hidden":!0,title:V,style:{opacity:0,width:1,border:0,zIndex:-1,position:"absolute",left:"50%"}},n.createElement("option",{value:t.valueMap?t.valueMap.call(void 0,g):g})),!O&&n.createElement(et.Popup,{...N,popupClass:s.classNames(N.popupClass,"k-multiselecttree-popup"),className:s.classNames(N.className,{"k-rtl":R==="rtl"}),style:Ae,anchor:N.anchor||E.current,show:l,onOpen:ze,onClose:_e,ref:G},t.filterable&&n.createElement(Ie,{value:t.filter===void 0?he:t.filter,ref:M,onChange:Ce,onKeyDown:ye,tabIndex:_,size:y,rounded:A,fillMode:X,renderListFilterWrapper:!0,renderPrefixSeparator:!0}),B.length>0?n.createElement(we.TreeView,{style:{height:N.height},ref:x,tabIndex:_,data:B,focusIdField:T,textField:t.textField,checkField:de,checkIndeterminateField:pe,expandField:t.expandField,childrenField:fe,expandIcons:!0,onItemClick:U,onCheckChange:U,onExpandChange:be,checkboxes:!0,size:y,item:t.item,dir:R}):n.createElement(Ee,null,Q.toLanguageString(m.nodata,m.messages[m.nodata])))),O&&Qe());return V?n.createElement(st.FloatingLabel,{label:V,editorValue:ie,editorPlaceholder:ue,editorValid:Fe,editorDisabled:F,editorId:I,style:{width:L?L.width:void 0},children:xe,dir:R}):xe}),mt={opened:a.bool,disabled:a.bool,dir:a.string,tabIndex:a.number,accessKey:a.string,data:a.array,value:a.any,valueMap:a.func,placeholder:a.string,dataItemKey:a.string.isRequired,textField:a.string.isRequired,checkField:a.string,checkIndeterminateField:a.string,expandField:a.string,subItemsField:a.string,className:a.string,style:a.object,label:a.string,validationMessage:a.string,validityStyles:a.bool,valid:a.bool,required:a.bool,name:a.string,id:a.string,ariaLabelledBy:a.string,ariaDescribedBy:a.string,filterable:a.bool,filter:a.string,loading:a.bool,tags:a.arrayOf(a.shape({text:a.string,data:a.arrayOf(a.any)})),popupSettings:a.shape({animate:a.oneOfType([a.bool,a.shape({openDuration:a.number,closeDuration:a.number})]),popupClass:a.string,className:a.string,appendTo:a.any,width:a.oneOfType([a.string,a.number]),height:a.oneOfType([a.string,a.number])}),onOpen:a.func,onClose:a.func,onFocus:a.func,onBlur:a.func,onChange:a.func,onFilterChange:a.func,onExpandChange:a.func,onCancel:a.func,item:a.func,listNoData:a.func,adaptiveTitle:a.string,adaptive:a.bool};te.displayName="KendoReactMultiSelectTree";te.defaultProps=q;te.propTypes=mt;exports.MultiSelectTree=te;exports.MultiSelectTreePropsContext=Ke;
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ze=require("react"),a=require("prop-types"),s=require("@progress/kendo-react-common"),et=require("@progress/kendo-react-popup"),tt=require("@progress/kendo-react-intl"),we=require("@progress/kendo-react-treeview"),nt=require("../package-metadata.js"),ee=require("../common/utils.js"),at=require("../DropDownTree/useDropdownWidth.js"),rt=require("../DropDownTree/ListNoData.js"),m=require("../messages/index.js"),st=require("@progress/kendo-react-labels"),it=require("../MultiSelect/TagList.js"),ot=require("../common/ClearButton.js"),Ie=require("../common/ListFilter.js"),lt=require("../common/AdaptiveMode.js"),ct=require("@progress/kendo-react-layout"),ut=require("../common/constants.js");function dt(h){const b=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const t in h)if(t!=="default"){const I=Object.getOwnPropertyDescriptor(h,t);Object.defineProperty(b,t,I.get?I:{enumerable:!0,get:()=>h[t]})}}return b.default=h,Object.freeze(b)}const n=dt(Ze),pt="Please select a value from the list!",{sizeMap:Te,roundedMap:ft}=s.kendoThemeMaps,gt=h=>h.split("_").map(b=>parseInt(b,10)),vt=(h,b)=>{const{validationMessage:t,valid:I,required:T}=h;return{customError:t!==void 0,valid:!!(I!==void 0?I:!T||b),valueMissing:!b}},w={checkField:"checkField",checkIndeterminateField:"checkIndeterminateField",subItemsField:"items",popupSettings:{animate:!0,width:"200px",height:"200px"},size:"medium",rounded:"medium",fillMode:"solid",required:!1,validityStyles:!0},Ke=s.createPropsContext(),te=n.forwardRef((h,b)=>{const t=s.usePropsContext(Ke,h);s.validatePackage(nt.packageMetadata);const I=s.useId(),T=t.id||I,{data:B=[],dataItemKey:K,popupSettings:N={},style:L={},opened:M,disabled:F,onOpen:ne=s.noop,onClose:W=s.noop,placeholder:ue,label:V,name:Me,checkField:de=w.checkField,checkIndeterminateField:pe=w.checkIndeterminateField,subItemsField:fe=w.subItemsField,validationMessage:z,valid:Re,tags:ge,value:g,required:ve=w.required,validityStyles:De=w.validityStyles}=t,_=s.getTabIndex(t.tabIndex,F),o=n.useRef(null),E=n.useRef(null),R=n.useRef(null),ae=n.useRef(null),j=n.useRef(null),x=n.useRef(null),$=n.useRef(!1),H=n.useRef([]),G=n.useRef(null),[P,qe]=n.useState(),[Ne,me]=n.useState(!1),[d,re]=n.useState(!1),[se,Pe]=n.useState(),[Oe,Le]=n.useState([]),[he,Ve]=n.useState(""),O=!!(se&&se<=ut.MOBILE_MEDIUM_DEVISE&&t.adaptive),l=M!==void 0?M:Ne,ie=!!(Array.isArray(g)&&g.length),oe=vt({validationMessage:z,valid:Re,required:ve},ie),D=s.useRtl(E,t.dir),Ae={width:at.useDropdownWidth(E,w,{...w.popupSettings,...N},L),...D!==void 0?{direction:D}:{}},Be=n.useCallback(()=>E.current&&E.current.focus(),[]);H.current=ge===void 0?(g||[]).map(e=>({text:ee.getItemValue(e,t.textField),data:[e]})):[...ge],n.useImperativeHandle(o,()=>({props:t,element:E.current,focus:Be})),n.useImperativeHandle(b,()=>o.current);const We=n.useCallback(()=>{j.current&&j.current.setCustomValidity&&j.current.setCustomValidity(oe.valid?"":z===void 0?pt:z)},[z,oe]);n.useEffect(We),n.useEffect(()=>{const e=s.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(Xe.bind(void 0));return document!=null&&document.body&&e&&e.observe(document.body),()=>{e&&e.disconnect()}},[]),n.useEffect(()=>{G.current&&l&&G.current.setPosition(G.current._popup)},[g,l]);const S=n.useCallback((e,r,i)=>{if(t.onChange){const k={items:r,operation:i,...e};t.onChange.call(void 0,k)}},[t.onChange]),U=n.useCallback(e=>{if(ee.areSame(e.item,g,K)||!o.current)return;const{item:r,nativeEvent:i,syntheticEvent:k}=e,q={syntheticEvent:k,nativeEvent:i,target:o.current};S(q,[r],"toggle")},[g,K,S]),J=n.useCallback(e=>{if(!l){if(ne){const r={...e};ne.call(void 0,r)}M===void 0&&(me(!0),Le(g||[]),O&&setTimeout(()=>{var r;u((r=ae.current)==null?void 0:r.element)},300))}},[l,M,ne,O,ae]),v=n.useCallback(e=>{if(l){if(W){const r={...e};W.call(void 0,r)}M===void 0&&me(!1)}},[l,M,W]),C=n.useCallback(e=>{$.current=!0,e(),window.setTimeout(()=>$.current=!1,0)},[]),u=n.useCallback(e=>{e&&C(()=>e.focus())},[C]),ze=n.useCallback(()=>{var e;!d&&l?v({target:o.current}):t.filterable?u((e=R.current)==null?void 0:e.element):u(x.current&&x.current.element)},[d,l,u,v,t.filterable]),_e=n.useCallback(()=>{d&&u(E.current)},[d,u]),je=n.useCallback(e=>{if(!d&&!$.current&&(re(!0),t.onFocus&&o.current)){const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};t.onFocus.call(void 0,r)}},[d,t.onFocus]),$e=n.useCallback(e=>{if(d&&!$.current&&o.current){re(!1);const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};if(t.onBlur){const i={...r};t.onBlur.call(void 0,i)}O||v(r)}},[d,t.onBlur,l,M,W]),He=n.useCallback(()=>{d&&C(s.noop)},[d,C]),Ge=n.useCallback(e=>{if(!e.isDefaultPrevented()&&o.current){re(!0);const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};l||J(r)}},[l,J]),Ue=n.useCallback(e=>{var Z,Se;const{keyCode:r,altKey:i}=e,k=x.current&&x.current.element;if(!o.current||e.isDefaultPrevented()&&((Z=R.current)==null?void 0:Z.element)===e.target)return;const q={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};if(g&&g.length>0&&(r===s.Keys.left||r===s.Keys.right||r===s.Keys.home||r===s.Keys.end||r===s.Keys.delete)){const c=H.current;let p=P?c.findIndex(Ye=>ee.matchTags(Ye,P,K)):-1,f;const ce=p!==-1;r===s.Keys.left?(ce?p=Math.max(0,p-1):p=c.length-1,f=c[p]):r===s.Keys.right?p===c.length-1?f=void 0:ce&&(p=Math.min(c.length-1,p+1),f=c[p]):r===s.Keys.home?f=c[0]:r===s.Keys.end?f=c[c.length-1]:r===s.Keys.delete&&ce&&S(q,c[p].data,"delete"),f!==P&&qe(f)}if(l)if(r===s.Keys.esc||i&&r===s.Keys.up)e.preventDefault(),v(q);else if(k&&k.querySelector(".k-focus")&&(r===s.Keys.up||r===s.Keys.down||r===s.Keys.left||r===s.Keys.right||r===s.Keys.home||r===s.Keys.end)){if(r===s.Keys.up&&((Se=R.current)!=null&&Se.element)){const c=Array.from(k.querySelectorAll(".k-treeview-item")),p=[...c].reverse().find(f=>!!(f&&f.querySelector(".k-focus")));if(p&&c.indexOf(p)===0)return C(()=>{var f;u((f=R.current)==null?void 0:f.element)})}C(s.noop)}else r===s.Keys.down&&C(()=>{var c;u(((c=R.current)==null?void 0:c.element)||k)});else i&&r===s.Keys.down&&(e.preventDefault(),J(q))},[l,v,u,C,J,P,K,g,S]),ye=n.useCallback(e=>{const{keyCode:r,altKey:i}=e;i||r!==s.Keys.up&&r!==s.Keys.down||(e.preventDefault(),C(r===s.Keys.up?()=>{u(E.current)}:()=>{u(x.current&&x.current.element)}))},[u,C]),le=n.useCallback(e=>{if(!o.current)return;const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};S(r,[],"clear"),v(r),e.preventDefault()},[S,v]),Je=n.useCallback((e,r)=>{var i;v({target:o.current}),d||u((i=R.current)==null?void 0:i.element),S({syntheticEvent:r,nativeEvent:r.nativeEvent,target:o.current},e,"delete")},[S,v,u,d]),be=n.useCallback(e=>{if(t.onExpandChange&&o.current){const{item:r,itemHierarchicalIndex:i,nativeEvent:k,syntheticEvent:q}=e,Z={level:gt(i),item:r,nativeEvent:k,syntheticEvent:q,target:o.current};t.onExpandChange.call(void 0,Z)}},[t.onExpandChange]),Ce=n.useCallback(e=>{if(t.onFilterChange&&o.current){const i={filter:{field:t.textField,operator:"contains",value:e.target.value},syntheticEvent:e.syntheticEvent,nativeEvent:e.nativeEvent,target:o.current};t.onFilterChange.call(void 0,i),t.filter===void 0&&Ve(e.target.value)}},[t.onFilterChange,t.filter,t.textField]),ke=n.useCallback(e=>{if(!o.current)return;const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};t.onCancel&&t.onCancel.call(void 0,r),v(r),e.preventDefault()},[t.onCancel,v]),Qe=()=>{const e=t.filterable?n.createElement(Ie,{value:t.filter===void 0?he:t.filter,ref:ae,onChange:Ce,onKeyDown:ye,size:y,rounded:A,fillMode:X}):null,r={adaptiveTitle:t.adaptiveTitle,expand:l,onClose:i=>t.onCancel?ke(i):le(i),windowWidth:se,mobileFilter:e,footer:{cancelText:Q.toLanguageString(m.adaptiveModeFooterCancel,m.messages[m.adaptiveModeFooterCancel]),onCancel:i=>t.onCancel?ke(i):le(i),applyText:Q.toLanguageString(m.adaptiveModeFooterApply,m.messages[m.adaptiveModeFooterApply]),onApply:i=>v(i)}};return n.createElement(lt.AdaptiveMode,{...r},n.createElement(ct.ActionSheetContent,{className:"!k-overflow-hidden"},n.createElement("div",{className:"k-list-container"},n.createElement("div",{className:"k-list k-list-lg"},B.length>0?n.createElement(we.TreeView,{ref:x,tabIndex:_,data:B,focusIdField:K,textField:t.textField,checkField:de,checkIndeterminateField:pe,expandField:t.expandField,childrenField:fe,expandIcons:!0,onItemClick:U,onCheckChange:U,onExpandChange:be,checkboxes:!0,size:y,item:t.item,dir:D}):n.createElement(Ee,null,Q.toLanguageString(m.nodata,m.messages[m.nodata]))))))},Xe=n.useCallback(e=>{for(let r of e)Pe(r.target.clientWidth)},[]),Ee=t.listNoData||rt.ListNoData,Q=tt.useLocalization(),Fe=!De||oe.valid,{size:y,rounded:A,fillMode:X}=t,Y=O&&l?Oe:H.current,xe=n.createElement(n.Fragment,null,n.createElement("span",{className:s.classNames("k-multiselecttree k-input",t.className,{[`k-input-${Te[y]||y}`]:y,[`k-rounded-${ft[A]||A}`]:A,[`k-input-${X}`]:X,"k-focus":d&&!F,"k-invalid":!Fe,"k-disabled":F,"k-loading":t.loading,"k-required":ve}),tabIndex:_,accessKey:t.accessKey,id:T,style:V?{...L,width:void 0}:L,dir:D,ref:E,onKeyDown:F?void 0:Ue,onMouseDown:He,onFocus:je,onBlur:$e,role:"combobox","aria-haspopup":"tree","aria-expanded":l,"aria-disabled":F,"aria-label":V,"aria-labelledby":t.ariaLabelledBy,"aria-describedby":t.ariaDescribedBy?t.ariaDescribedBy:"tagslist-"+T,"aria-required":t.required,onClick:F?void 0:Ge},n.createElement("div",{id:"tagslist-"+T,className:s.classNames("k-input-values k-chip-list",{[`k-chip-list-${Te[y]||y}`]:y})},Y.length>0&&n.createElement(it,{tag:t.tag,onTagDelete:Je,data:Y,guid:T,focused:P?H.current.find(e=>ee.matchTags(e,P,K)):void 0,size:y})),n.createElement("span",{className:"k-input-inner"},Y.length===0&&n.createElement("span",{className:"k-input-value-text"},ue)),t.loading&&n.createElement(s.IconWrap,{className:"k-input-loading-icon",name:"loading"}),ie&&!F&&Y.length>0&&n.createElement(ot,{onClick:le}),n.createElement("select",{name:Me,ref:j,tabIndex:-1,"aria-hidden":!0,title:V,style:{opacity:0,width:1,border:0,zIndex:-1,position:"absolute",left:"50%"}},n.createElement("option",{value:t.valueMap?t.valueMap.call(void 0,g):g})),!O&&n.createElement(et.Popup,{...N,popupClass:s.classNames(N.popupClass,"k-multiselecttree-popup"),className:s.classNames(N.className,{"k-rtl":D==="rtl"}),style:Ae,anchor:N.anchor||E.current,show:l,onOpen:ze,onClose:_e,ref:G},t.filterable&&n.createElement(Ie,{value:t.filter===void 0?he:t.filter,ref:R,onChange:Ce,onKeyDown:ye,tabIndex:_,size:y,rounded:A,fillMode:X,renderListFilterWrapper:!0,renderPrefixSeparator:!0}),B.length>0?n.createElement(we.TreeView,{style:{height:N.height},ref:x,tabIndex:_,data:B,focusIdField:K,textField:t.textField,checkField:de,checkIndeterminateField:pe,expandField:t.expandField,childrenField:fe,expandIcons:!0,onItemClick:U,onCheckChange:U,onExpandChange:be,checkboxes:!0,size:y,item:t.item,dir:D}):n.createElement(Ee,null,Q.toLanguageString(m.nodata,m.messages[m.nodata])))),O&&Qe());return V?n.createElement(st.FloatingLabel,{label:V,editorValue:ie,editorPlaceholder:ue,editorValid:Fe,editorDisabled:F,editorId:T,style:{width:L?L.width:void 0},children:xe,dir:D}):xe}),mt={opened:a.bool,disabled:a.bool,dir:a.string,tabIndex:a.number,accessKey:a.string,data:a.array,value:a.any,valueMap:a.func,placeholder:a.string,dataItemKey:a.string.isRequired,textField:a.string.isRequired,checkField:a.string,checkIndeterminateField:a.string,expandField:a.string,subItemsField:a.string,className:a.string,style:a.object,label:a.string,validationMessage:a.string,validityStyles:a.bool,valid:a.bool,required:a.bool,name:a.string,id:a.string,ariaLabelledBy:a.string,ariaDescribedBy:a.string,filterable:a.bool,filter:a.string,loading:a.bool,tags:a.arrayOf(a.shape({text:a.string,data:a.arrayOf(a.any)})),popupSettings:a.shape({animate:a.oneOfType([a.bool,a.shape({openDuration:a.number,closeDuration:a.number})]),popupClass:a.string,className:a.string,appendTo:a.any,width:a.oneOfType([a.string,a.number]),height:a.oneOfType([a.string,a.number])}),onOpen:a.func,onClose:a.func,onFocus:a.func,onBlur:a.func,onChange:a.func,onFilterChange:a.func,onExpandChange:a.func,onCancel:a.func,item:a.func,listNoData:a.func,adaptiveTitle:a.string,adaptive:a.bool};te.displayName="KendoReactMultiSelectTree";te.defaultProps=w;te.propTypes=mt;exports.MultiSelectTree=te;exports.MultiSelectTreePropsContext=Ke;
|