@progress/kendo-react-treeview 7.0.0-develop.9 → 7.0.1-develop.1
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/TreeView.d.ts +6 -1
- package/TreeViewItem.d.ts +8 -2
- package/TreeViewProps.d.ts +4 -0
- package/dist/cdn/js/kendo-react-treeview.js +1 -1
- package/index.d.ts +4 -2
- package/index.js +1 -1
- package/index.mjs +50 -41
- package/package.json +4 -3
package/TreeView.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ export declare class TreeView extends React.Component<TreeViewProps, TreeViewSta
|
|
|
84
84
|
private blurRequest;
|
|
85
85
|
private fieldsSvc;
|
|
86
86
|
private allowExplicitFocus;
|
|
87
|
-
private treeGuid;
|
|
87
|
+
private get treeGuid();
|
|
88
88
|
private _element;
|
|
89
89
|
/**
|
|
90
90
|
* @hidden
|
|
@@ -126,3 +126,8 @@ export declare class TreeView extends React.Component<TreeViewProps, TreeViewSta
|
|
|
126
126
|
*/
|
|
127
127
|
get guid(): string;
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Represent the `ref` of the TreeView component.
|
|
131
|
+
*/
|
|
132
|
+
export interface TreeViewHandle extends Pick<TreeView, keyof TreeView> {
|
|
133
|
+
}
|
package/TreeViewItem.d.ts
CHANGED
|
@@ -57,6 +57,13 @@ export interface TreeViewItemProps {
|
|
|
57
57
|
* @hidden
|
|
58
58
|
*/
|
|
59
59
|
onContextMenu: (event: React.MouseEvent<HTMLElement>, item: any, itemId: string) => void;
|
|
60
|
+
/**
|
|
61
|
+
* @hidden
|
|
62
|
+
* This prop comes from the `TreeView`component.
|
|
63
|
+
* It replaces the previously used guid() function and is used to generate unique `id` for
|
|
64
|
+
* the checkbox and label in the TreeViewItem.
|
|
65
|
+
*/
|
|
66
|
+
id?: string;
|
|
60
67
|
}
|
|
61
68
|
/**
|
|
62
69
|
* @hidden
|
|
@@ -64,7 +71,6 @@ export interface TreeViewItemProps {
|
|
|
64
71
|
declare class TreeViewItemWithoutContext extends React.Component<TreeViewItemProps> {
|
|
65
72
|
private itemElement;
|
|
66
73
|
private checkboxElement;
|
|
67
|
-
private itemGuid;
|
|
68
74
|
static defaultProps: {
|
|
69
75
|
position: string;
|
|
70
76
|
};
|
|
@@ -96,5 +102,5 @@ declare class TreeViewItemWithoutContext extends React.Component<TreeViewItemPro
|
|
|
96
102
|
/**
|
|
97
103
|
* @hidden
|
|
98
104
|
*/
|
|
99
|
-
export declare const TreeViewItem: React.ForwardRefExoticComponent<TreeViewItemProps & React.RefAttributes<TreeViewItemWithoutContext>>;
|
|
105
|
+
export declare const TreeViewItem: React.ForwardRefExoticComponent<Omit<TreeViewItemProps & React.RefAttributes<TreeViewItemWithoutContext>, "ref"> & React.RefAttributes<any>>;
|
|
100
106
|
export {};
|
package/TreeViewProps.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ export interface TreeViewProps {
|
|
|
14
14
|
* Sets a class of the TreeView DOM element.
|
|
15
15
|
*/
|
|
16
16
|
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Sets an `id` of the TreeView DOM element.
|
|
19
|
+
*/
|
|
20
|
+
id?: string;
|
|
17
21
|
/**
|
|
18
22
|
* Sets the data of the TreeView ([more information and examples]({% slug databinding_treeview %})).
|
|
19
23
|
*/
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
(function(p,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react"),require("prop-types"),require("@progress/kendo-react-common"),require("@progress/kendo-svg-icons"),require("@progress/kendo-react-animation")):typeof define=="function"&&define.amd?define(["exports","react","prop-types","@progress/kendo-react-common","@progress/kendo-svg-icons","@progress/kendo-react-animation"],m):(p=typeof globalThis<"u"?globalThis:p||self,m(p.KendoReactTreeview={},p.React,p.PropTypes,p.KendoReactCommon,p.KendoSvgIcons,p.KendoReactAnimation))})(this,function(p,m,G,s,b,z){"use strict";function N(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const c=N(m),u=N(G);function S(n,e,t,i,r){switch(i){case s.Keys.left:return l();case s.Keys.right:return d();case s.Keys.up:return a();case s.Keys.down:return I();case s.Keys.home:return s.treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID;case s.Keys.end:return g();default:return e}function l(){return s.treeIdUtils.isIdZeroLevel(e)||r.expanded(n)&&s.isEnabledAndAllParentsEnabled(e,t,r)?e:s.treeIdUtils.getDirectParentId(e)}function d(){return s.isItemExpandedAndWithChildren(n,r)?s.treeIdUtils.getFirstChildId(e):e}function a(){const f=Number(s.treeIdUtils.getShortId(e)),h=s.treeIdUtils.getDirectParentId(e);return f?T(s.treeIdUtils.createId(f-1,h),t,r):s.treeIdUtils.isIdZeroLevel(e)?e:h}function I(){return s.isItemExpandedAndWithChildren(n,r)?s.treeIdUtils.getFirstChildId(e):C(e,t,r)||e}function g(){let f=(t.length-1).toString(),h=t[t.length-1],o;for(;s.isItemExpandedAndWithChildren(h,r);)o=h[r.getChildrenField()],f=s.treeIdUtils.createId(o.length-1,f),h=o[o.length-1];return f}}function C(n,e,t){const i=s.treeIdUtils.getDirectParentId(n),r=i?s.treeIdUtils.getItemById(i,e,t.getChildrenField()):void 0,l=r?r[t.getChildrenField()]:e,d=Number(s.treeIdUtils.getShortId(n));return d<l.length-1?s.treeIdUtils.createId(d+1,i):r?C(i,e,t):void 0}function T(n,e,t){const i=s.treeIdUtils.getItemById(n,e,t.getChildrenField());return s.isItemExpandedAndWithChildren(i,t)?T(s.treeIdUtils.createId(i[t.getChildrenField()].length-1,n),e,t):n}const P="expanded",B="text",W="disabled",E="items",H="hasChildren",U="selected",v="checked",_="checkIndeterminate",x="_kendoItemId",M="_kendoTreeViewGuid",{sizeMap:$}=s.kendoThemeMaps,O=c.createContext(n=>n);class A extends c.Component{constructor(){super(...arguments),this.itemGuid=s.guid(),this.onCheckChange=e=>{this.props.onCheckChange(e,this.item,this.itemId)},this.onExpandChange=e=>{this.props.onExpandChange(e,this.item,this.itemId)},this.onItemClick=e=>{this.props.onItemClick(e,this.item,this.itemId)},this.onPress=e=>{this.props.onPress(e.event,this.item,this.itemId)},this.onDrag=e=>{this.props.onDrag(e.event,this.item,this.itemId)},this.onRelease=e=>{this.props.onRelease(e.event,this.item,this.itemId)},this.onContextMenu=e=>{this.props.onContextMenu(e,this.item,this.itemId)},this.assignDraggableMeta=e=>{e&&(e[x]=this.props.itemId,e[M]=this.props.treeGuid)}}render(){const e=this.renderSubitemsIfApplicable(),t=this.renderItemInPart();return c.createElement("li",{className:s.classNames("k-treeview-item"),tabIndex:this.tabIndex,role:"treeitem","aria-expanded":this.ariaExpanded,"aria-selected":this.ariaSelected,"aria-checked":this.ariaChecked,"aria-disabled":this.disabled?!0:void 0,ref:i=>this.itemElement=i},c.createElement("div",{className:`k-treeview-${this.props.position}`,ref:this.assignDraggableMeta},this.renderExpandIcon(),this.renderCheckbox(),this.props.draggable?c.createElement(s.Draggable,{onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease},t):t),this.props.animate?c.createElement(z.Reveal,{transitionEnterDuration:200,transitionExitDuration:200,style:{display:"block"},children:e}):e)}componentDidMount(){const e=this.props.focusedItemId,t=this.itemId;e&&e===t&&this.props.onFocusDomElNeeded(this.itemElement),this.checkboxElement&&(this.checkboxElement.indeterminate=this.fieldsSvc.checkIndeterminate(this.item))}componentDidUpdate(e){const t=this.props.focusedItemId;if(t&&t!==e.focusedItemId&&t===this.itemId&&this.props.onFocusDomElNeeded(this.itemElement),this.checkboxElement){const i=this.fieldsSvc.checkIndeterminate(this.item);i!==e.fieldsService.checkIndeterminate(e.item)&&(this.checkboxElement.indeterminate=i)}}renderCheckbox(){if(this.props.checkboxes){const e=this.props.size;return c.createElement("div",{className:s.classNames("k-checkbox-wrap")},c.createElement("input",{type:"checkbox",className:s.classNames("k-checkbox k-rounded-md",{[`k-checkbox-${$[e]||e}`]:e,"k-disabled":this.disabled}),"aria-label":this.item.text,checked:!!this.fieldsSvc.checked(this.item),id:this.itemGuid,tabIndex:-1,onChange:this.onCheckChange,ref:t=>this.checkboxElement=t}),c.createElement("label",{className:"k-checkbox-label",htmlFor:this.itemGuid}))}else return}renderExpandIcon(){return this.props.expandIcons&&(this.fieldsSvc.hasChildren(this.item)||s.hasChildren(this.item,this.fieldsSvc.getChildrenField()))&&c.createElement("span",{className:s.classNames("k-treeview-toggle",{"k-disabled":this.disabled}),onClick:this.onExpandChange},c.createElement(s.IconWrap,{...this.getIconProps()}))}renderSubitemsIfApplicable(){const e=this.fieldsSvc.children(this.item);return s.isItemExpandedAndWithChildren(this.item,this.fieldsSvc)?c.createElement("ul",{className:"k-treeview-group",role:"group"},e.map((t,i)=>c.createElement(D,{item:t,position:i===0?"top":i===e.length-1?"bot":"mid",itemId:s.treeIdUtils.createId(i,this.itemId),treeGuid:this.props.treeGuid,animate:this.props.animate,focusedItemId:this.props.focusedItemId,tabbableItemId:this.props.tabbableItemId,fieldsService:this.props.fieldsService,itemUI:this.props.itemUI,checkboxes:this.props.checkboxes,ariaMultiSelectable:this.props.ariaMultiSelectable,onItemClick:this.props.onItemClick,onFocusDomElNeeded:this.props.onFocusDomElNeeded,draggable:this.props.draggable,onPress:this.props.onPress,onDrag:this.props.onDrag,onRelease:this.props.onRelease,expandIcons:this.props.expandIcons,onExpandChange:this.props.onExpandChange,onCheckChange:this.props.onCheckChange,onContextMenu:this.props.onContextMenu,key:i,size:this.props.size,disabled:this.disabled,isRtl:this.props.isRtl}))):void 0}renderItemInPart(){return c.createElement("span",{className:s.classNames("k-treeview-leaf",{"k-focus":this.props.focusedItemId===this.itemId,"k-selected":this.fieldsSvc.selected(this.item),"k-disabled":this.disabled}),style:{touchAction:"none"},onClick:this.onItemClick,onContextMenu:this.onContextMenu},c.createElement("span",{className:"k-treeview-leaf-text"},this.props.itemUI?c.createElement(this.props.itemUI,{item:this.item,itemHierarchicalIndex:this.itemId}):this.fieldsSvc.text(this.item)))}get fieldsSvc(){return this.props.fieldsService}get itemId(){return this.props.itemId}get item(){return this.props.item}get tabIndex(){return(this.props.focusedItemId||this.props.tabbableItemId)===this.itemId?0:-1}get ariaExpanded(){return this.fieldsSvc.hasChildren(this.item)||s.hasChildren(this.item,this.fieldsSvc.getChildrenField())?!!this.fieldsSvc.expanded(this.item):void 0}get disabled(){return this.props.disabled||this.fieldsSvc.disabled(this.item)}get ariaChecked(){if(this.props.checkboxes)return this.fieldsSvc.checked(this.item)?"true":this.fieldsSvc.checkIndeterminate(this.item)?"mixed":"false"}get ariaSelected(){return this.fieldsSvc.selected(this.item)?!0:this.props.ariaMultiSelectable?this.disabled?void 0:!1:void 0}getIconProps(){const e=this.fieldsSvc.expanded(this.item);return e&&!s.hasChildren(this.item,this.fieldsSvc.getChildrenField())?{name:"loading"}:e?{name:"caret-alt-down",icon:b.caretAltDownIcon}:{name:this.props.isRtl?"caret-alt-left":"caret-alt-right",icon:this.props.isRtl?b.caretAltLeftIcon:b.caretAltRightIcon}}}A.defaultProps={position:"top"};const D=c.forwardRef((n,e)=>{const i=c.useContext(O).call(void 0,n);return c.createElement(A,{ref:e,...i})});D.displayName="TreeViewItem";const j={name:"@progress/kendo-react-treeview",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:0,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},{sizeMap:q}=s.kendoThemeMaps;class y extends c.Component{constructor(e){super(e),this.state={focusedItemId:void 0,focusedItemPublicId:void 0,tabbableItemId:s.treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID},this.fieldsSvc=null,this.allowExplicitFocus=!1,this.treeGuid=s.guid(),this._element=null,this.onFocusDomElNeeded=t=>{this.allowExplicitFocus&&this.focusDomItem(t)},this.onCheckChange=(t,i,r)=>{this.setFocus(r),this.dispatchCheckChange(t,i,r)},this.onExpandChange=(t,i,r)=>{this.setFocus(r),this.dispatchExpandChange(t,i,r)},this.onPress=(t,i,r)=>{this.props.onItemDragStart&&this.props.onItemDragStart.call(void 0,{target:this,item:i,itemHierarchicalIndex:r})},this.onDrag=(t,i,r)=>{const{pageX:l,pageY:d,clientX:a,clientY:I}=t;this.props.onItemDragOver&&this.props.onItemDragOver.call(void 0,{target:this,item:i,itemHierarchicalIndex:r,pageX:l,pageY:d,clientX:a,clientY:I})},this.onRelease=(t,i,r)=>{const{pageX:l,pageY:d,clientX:a,clientY:I}=t;this.props.onItemDragEnd&&this.props.onItemDragEnd.call(void 0,{target:this,item:i,itemHierarchicalIndex:r,pageX:l,pageY:d,clientX:a,clientY:I})},this.onItemClick=(t,i,r)=>{this.setFocus(r),this.dispatchItemClick(t,i,r)},this.onFocus=()=>{clearTimeout(this.blurRequest),this.state.focusedItemId===void 0&&this.data.length&&this.setFocus(this.state.tabbableItemId)},this.onBlur=()=>{clearTimeout(this.blurRequest),this.blurRequest=window.setTimeout(()=>this.setFocus(void 0),0)},this.onKeyDown=t=>{const i=this.getFocusedItem();if(i&&this.fieldsSvc){const r=S(i,this.state.focusedItemId,this.data,t.keyCode,this.fieldsSvc);r!==this.state.focusedItemId&&(t.preventDefault(),this.allowExplicitFocus=!0,this.setFocus(r)),this.dispatchEventsOnKeyDown(t,i)}},this.onContextMenu=(t,i,r)=>{if(this.props.onContextMenu){const l={target:this,syntheticEvent:t,nativeEvent:t.nativeEvent,item:i,itemID:r};this.props.onContextMenu.call(void 0,l)}},s.validatePackage(j)}get element(){return this._element}render(){this.fieldsSvc=new s.TreeFieldsService(this.props);const{size:e,className:t}=this.props;return c.createElement("div",{className:s.classNames("k-treeview",{[`k-treeview-${q[e]||e}`]:e,["k-user-select-none"]:this.props.draggable,["k-rtl"]:this.props.dir==="rtl"},t),onKeyDown:this.onKeyDown,onFocus:this.onFocus,onBlur:this.onBlur,role:"tree","aria-multiselectable":this.ariaMultiSelectable?!0:void 0,"aria-label":this.props["aria-label"],"aria-labelledby":this.props["aria-labelledby"],ref:i=>this._element=i,tabIndex:this.props.tabIndex},c.createElement("ul",{className:"k-treeview-lines k-treeview-group",role:"group"},this.data.map((i,r)=>c.createElement(D,{item:i,position:r===0?"top":r===this.data.length-1?"bot":"mid",itemId:r.toString(),treeGuid:this.treeGuid,animate:this.props.animate,focusedItemId:this.state.focusedItemId,tabbableItemId:this.state.tabbableItemId,fieldsService:this.fieldsSvc,itemUI:this.props.item,checkboxes:this.props.checkboxes,ariaMultiSelectable:this.ariaMultiSelectable,onItemClick:this.onItemClick,onFocusDomElNeeded:this.onFocusDomElNeeded,draggable:this.props.draggable,onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease,expandIcons:this.props.expandIcons,onExpandChange:this.onExpandChange,onCheckChange:this.onCheckChange,onContextMenu:this.onContextMenu,key:r,size:e,isRtl:this.props.dir==="rtl"}))))}componentDidUpdate(){this.allowExplicitFocus=!1,this.refocusDueToFocusIdField()}dispatchEventsOnKeyDown(e,t){if(this.fieldsSvc===null)return;const i=()=>this.fieldsSvc&&s.isEnabledAndAllParentsEnabled(this.state.focusedItemId,this.data,this.fieldsSvc);e.keyCode===s.Keys.left&&this.fieldsSvc.expanded(t)&&i()?this.dispatchExpandChange(e,t,this.state.focusedItemId):e.keyCode===s.Keys.right&&!this.fieldsSvc.expanded(t)&&(this.fieldsSvc.hasChildren(t)||s.hasChildren(t,this.props.childrenField))&&i()?this.dispatchExpandChange(e,t,this.state.focusedItemId):e.keyCode===s.Keys.enter&&i()?this.dispatchItemClick(e,t,this.state.focusedItemId):e.keyCode===s.Keys.space&&i()&&(e.preventDefault(),this.dispatchCheckChange(e,t,this.state.focusedItemId))}setFocus(e){if(e&&this.fieldsSvc)if(this.fieldsSvc.focusIdField){const t=this.getItemById(e);this.setState({focusedItemId:e,focusedItemPublicId:this.fieldsSvc.focusId(t)})}else this.setState({focusedItemId:e});else this.setState(t=>({focusedItemId:void 0,focusedItemPublicId:void 0,tabbableItemId:t.focusedItemId}))}getFocusedItem(){return this.state.focusedItemId?this.getItemById(this.state.focusedItemId):void 0}getItemById(e){return s.treeIdUtils.getItemById(e,this.data,this.props.childrenField||E)}dispatchCheckChange(e,t,i){s.dispatchEvent(this.props.onCheckChange,e,this,{item:t,itemHierarchicalIndex:i})}dispatchExpandChange(e,t,i){s.dispatchEvent(this.props.onExpandChange,e,this,{item:t,itemHierarchicalIndex:i})}dispatchItemClick(e,t,i){s.dispatchEvent(this.props.onItemClick,e,this,{item:t,itemHierarchicalIndex:i})}refocusDueToFocusIdField(){if(this.fieldsSvc&&this.fieldsSvc.focusIdField){const e=this.state.focusedItemPublicId;if(e){const t=this.props.getFocusHierarchicalIndex?this.props.getFocusHierarchicalIndex(e):s.resolveItemId(e,this.fieldsSvc.focusIdField,this.data,this.props.childrenField);t!==this.state.focusedItemId&&(this.allowExplicitFocus=!0,this.setState({focusedItemId:t}))}}}get ariaMultiSelectable(){return this.props["aria-multiselectable"]===!0||this.props["aria-multiselectable"]==="true"}get data(){return this.props.data||[]}focusDomItem(e){e.focus()}get guid(){return this.treeGuid}}y.propTypes={data:u.arrayOf(u.any),animate:u.bool,tabIndex:u.number,focusIdField:u.string,getHierarchicalIndexById:u.func,onExpandChange:u.func,onItemClick:u.func,expandField:u.string,selectField:u.string,childrenField:u.string,hasChildrenField:u.string,textField:u.string,disableField:u.string,item:u.any,"aria-multiselectable":(n,e,t)=>n[e]!==void 0&&n[e]!==!0&&n[e]!==!1&&n[e]!=="true"&&n[e]!=="false"?new Error("Invalid prop `"+e+"` supplied to `"+t+"`. Validation failed."):null,"aria-label":u.string,"aria-labelledby":u.string,size:u.oneOf([null,"small","medium","large"]),dir:u.string},y.defaultProps={animate:!0,expandField:P,selectField:U,hasChildrenField:H,childrenField:E,textField:B,disableField:W,checkField:v,checkIndeterminateField:_,size:"medium"};function Y(n,e){if(!n||!n.length)return[];let t=n;const i=e.cloneField||"cloned",r=e.expandField||P,l=e.selectField||U,d=e.checkField||v,a=e.childrenField||E;return t=F(t,r,e.expand,i,a),t=F(t,l,e.select,i,a),t=F(t,d,e.check,i,a),Z(t,a,e.check),t}function F(n,e,t,i,r){if(t){let{ids:l,field:d}=V(t,e),a=!s.isArray(t)&&t.idField?s.resolveItemsIds(l,t.idField,n,r):l;return X(n,a,d,i,r)}else return n}function V(n,e){let t,i;return s.isArray(n)?(t=n,i=e):(t=n.ids||[],i=n.operationField||e),{ids:t,field:i}}function X(n,e,t,i,r){let l=n;return e.forEach(d=>{l=s.updateItem(l,d,a=>k(t,a),i,r)}),l}function k(n,e){const t=(n||"").split(".");let i=e;for(let r=0;r<t.length;r++){const l=t[r];if(r===t.length-1)i[l]=!0;else if(i[l]!==void 0)i[l]={...i[l]},i=i[l];else return}}function Z(n,e,t){if(t&&!s.isArray(t)&&t.applyCheckIndeterminate){const{field:i}=V(t,v),r=t.checkIndeterminateField||_;for(let l=0;l<n.length;l++){const d=n[l],a=d[e];a&&w(a,s.getNestedValue(i,d)?[]:[d],e,i,r)}}}function w(n,e,t,i,r){let l=!1;for(let d=0;d<n.length;d++){const a=n[d];if(s.getNestedValue(i,a)){if(!l)for(let I=0;I<e.length;I++)k(r,e[I]);l=!0,a[t]&&w(a[t],[],t,i,r)}else a[t]&&w(a[t],l?[a]:e.concat([a]),t,i,r)}}function Q(n,e,t,i,r,l){const d=l||E;if(!f())return I();const a=s.treeIdUtils.getItemById(n,e,d);if(!a)return I();if(!r||r===e){if(!g())return I();const h=s.removeItem(n,d,e),o=s.addItem(a,t,d,s.treeIdUtils.getDecrementedItemIdAfterRemoval(n,i),h);return r?{sourceData:o,targetData:o}:o}else{const h=s.removeItem(n,d,e),o=s.addItem(a,t,d,i,r);return{sourceData:h,targetData:o}}function I(){return r?{sourceData:e,targetData:r}:e}function g(){return!`${i}_`.startsWith(`${n}_`)}function f(){if(!e||!e.length||!n||!i||r&&!r.length)return!1;const h=!r||r===e?e:r;return!!s.treeIdUtils.getItemById(i,h,d)}}function J(n,e,t,i={},r){if(!t||!t.length)return[];const{ids:l,idField:d}=R(e),a=d?s.getNestedValue(d,n.item):n.itemHierarchicalIndex,I=l.indexOf(a),g=I===-1,f=r||E;let h;return i.singleMode?h=g?[a]:[]:(h=l.slice(),g?h.push(a):h.splice(I,1),i.checkChildren&&ee(n.item,n.itemHierarchicalIndex,g,d,f,h),i.checkParents&&te(n.itemHierarchicalIndex,g,d,f,h,t)),s.isArray(e)?h:Object.assign({},e,{ids:h})}function R(n){let e,t;return s.isArray(n)?e=n:(e=n.ids||[],t=n.idField),{ids:e,idField:t}}function ee(n,e,t,i,r,l){s.getAllDirectIndirectChildrenIds(n,e,r,i).forEach(d=>{t&&l.indexOf(d)===-1?l.push(d):!t&&l.indexOf(d)>-1&&l.splice(l.indexOf(d),1)})}function te(n,e,t,i,r,l){const d=f();let a=d.next();e?I():g();function I(){for(;!a.done;){const{id:h,item:o}=a.value;if(r.indexOf(h)===-1&&s.areAllDirectChildrenChecked(o,h,t,i,r))r.push(h),a=d.next();else break}}function g(){for(;!a.done;){const{id:h}=a.value,o=r.indexOf(h);if(o>-1)r.splice(o,1),a=d.next();else break}}function*f(){if(t){const h=s.getAllParents(n,i,l);for(let o=h.length-1;o>-1;o--)yield{id:s.getNestedValue(t,h[o]),item:e?h[o]:void 0}}else{let h=s.treeIdUtils.getDirectParentId(n);for(;h;)yield{id:h,item:e?s.treeIdUtils.getItemById(h,l,i):void 0},h=s.treeIdUtils.getDirectParentId(h)}}}class K extends c.PureComponent{constructor(){super(...arguments),this.state={visible:!1,top:0,left:0,text:"",operationClassName:"cancel"}}render(){const e={top:this.state.top+"px",left:this.state.left+"px"};return this.state.visible&&c.createElement("div",{className:"k-header k-drag-clue",style:{...this.props.style,...e}},c.createElement(s.IconWrap,{className:s.classNames("k-drag-status"),name:this.state.operationClassName&&s.toIconName(this.state.operationClassName),icon:this.state.operationClassName==="k-i-plus"?b.plusIcon:this.state.operationClassName==="k-i-insert-up"?b.insertTopIcon:this.state.operationClassName==="k-i-insert-up"?b.insertBottomIcon:this.state.operationClassName==="k-i-insert-middle"?b.insertMiddleIcon:b.cancelIcon}),this.state.text)}show(e,t,i,r){this.setState({visible:!0,top:e,left:t,text:i,operationClassName:r})}hide(){this.setState({visible:!1})}}K.defaultProps={style:{display:"block",position:"absolute",zIndex:2e4,padding:"4px 6px"}};const L=6;class ie{constructor(e){this.event=e,this.initialized=!1,this.destItemId="",this.destTreeViewGuid="",this.itemId=e.itemHierarchicalIndex,this.treeViewGuid=e.target.guid}init(){return this.initialized||(this.setDestimationMeta(document.elementFromPoint(this.event.clientX,this.event.clientY)),this.initialized=!0),this}get isDropAllowed(){return this.initialized&&this.destItemId&&this.destTreeViewGuid?!`${this.destTreeViewGuid}_${this.destItemId}_`.startsWith(`${this.treeViewGuid}_${this.itemId}_`):!1}get destinationMeta(){return{itemHierarchicalIndex:this.destItemId,treeViewGuid:this.destTreeViewGuid}}getDropOperation(){if(this.initialized&&this.isDropAllowed){const{top:e,height:t}=this.destDomNodeWithMeta.getBoundingClientRect();return e+t-this.event.clientY<L?"after":this.event.clientY-e<L?"before":"child"}else return}setDestimationMeta(e){let t=e;for(;t&&!t[x];)t=t.parentNode;t&&t[x]&&(this.destDomNodeWithMeta=t,this.destItemId=t[x],this.destTreeViewGuid=t[M])}}Object.defineProperty(p,"FieldsService",{enumerable:!0,get:()=>s.TreeFieldsService}),p.TreeView=y,p.TreeViewDragAnalyzer=ie,p.TreeViewDragClue=K,p.TreeViewItemPropsContext=O,p.getItemIdUponKeyboardNavigation=S,p.handleTreeViewCheckChange=J,p.moveTreeViewItem=Q,p.processTreeViewItems=Y,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
|
5
|
+
(function(o,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react"),require("prop-types"),require("@progress/kendo-react-common"),require("@progress/kendo-svg-icons"),require("@progress/kendo-react-animation")):typeof define=="function"&&define.amd?define(["exports","react","prop-types","@progress/kendo-react-common","@progress/kendo-svg-icons","@progress/kendo-react-animation"],m):(o=typeof globalThis<"u"?globalThis:o||self,m(o.KendoReactTreeview={},o.React,o.PropTypes,o.KendoReactCommon,o.KendoSvgIcons,o.KendoReactAnimation))})(this,function(o,m,B,s,b,G){"use strict";"use client";function N(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const c=N(m),u=N(B);function C(n,e,t,i,r){switch(i){case s.Keys.left:return l();case s.Keys.right:return d();case s.Keys.up:return a();case s.Keys.down:return I();case s.Keys.home:return s.treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID;case s.Keys.end:return g();default:return e}function l(){return s.treeIdUtils.isIdZeroLevel(e)||r.expanded(n)&&s.isEnabledAndAllParentsEnabled(e,t,r)?e:s.treeIdUtils.getDirectParentId(e)}function d(){return s.isItemExpandedAndWithChildren(n,r)?s.treeIdUtils.getFirstChildId(e):e}function a(){const f=Number(s.treeIdUtils.getShortId(e)),h=s.treeIdUtils.getDirectParentId(e);return f?T(s.treeIdUtils.createId(f-1,h),t,r):s.treeIdUtils.isIdZeroLevel(e)?e:h}function I(){return s.isItemExpandedAndWithChildren(n,r)?s.treeIdUtils.getFirstChildId(e):S(e,t,r)||e}function g(){let f=(t.length-1).toString(),h=t[t.length-1],p;for(;s.isItemExpandedAndWithChildren(h,r);)p=h[r.getChildrenField()],f=s.treeIdUtils.createId(p.length-1,f),h=p[p.length-1];return f}}function S(n,e,t){const i=s.treeIdUtils.getDirectParentId(n),r=i?s.treeIdUtils.getItemById(i,e,t.getChildrenField()):void 0,l=r?r[t.getChildrenField()]:e,d=Number(s.treeIdUtils.getShortId(n));return d<l.length-1?s.treeIdUtils.createId(d+1,i):r?S(i,e,t):void 0}function T(n,e,t){const i=s.treeIdUtils.getItemById(n,e,t.getChildrenField());return s.isItemExpandedAndWithChildren(i,t)?T(s.treeIdUtils.createId(i[t.getChildrenField()].length-1,n),e,t):n}const P="expanded",H="text",W="disabled",E="items",$="hasChildren",U="selected",y="checked",_="checkIndeterminate",x="_kendoItemId",O="_kendoTreeViewGuid",{sizeMap:j}=s.kendoThemeMaps,M=c.createContext(n=>n);class V extends c.Component{constructor(){super(...arguments),this.onCheckChange=e=>{this.props.onCheckChange(e,this.item,this.itemId)},this.onExpandChange=e=>{this.props.onExpandChange(e,this.item,this.itemId)},this.onItemClick=e=>{this.props.onItemClick(e,this.item,this.itemId)},this.onPress=e=>{this.props.onPress(e.event,this.item,this.itemId)},this.onDrag=e=>{this.props.onDrag(e.event,this.item,this.itemId)},this.onRelease=e=>{this.props.onRelease(e.event,this.item,this.itemId)},this.onContextMenu=e=>{this.props.onContextMenu(e,this.item,this.itemId)},this.assignDraggableMeta=e=>{e&&(e[x]=this.props.itemId,e[O]=this.props.treeGuid)}}render(){const e=this.renderSubitemsIfApplicable(),t=this.renderItemInPart();return c.createElement("li",{className:s.classNames("k-treeview-item"),tabIndex:this.tabIndex,role:"treeitem","aria-expanded":this.ariaExpanded,"aria-selected":this.ariaSelected,"aria-checked":this.ariaChecked,"aria-disabled":this.disabled?!0:void 0,ref:i=>this.itemElement=i},c.createElement("div",{className:`k-treeview-${this.props.position}`,ref:this.assignDraggableMeta},this.renderExpandIcon(),this.renderCheckbox(),this.props.draggable?c.createElement(s.Draggable,{onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease},t):t),this.props.animate?c.createElement(G.Reveal,{transitionEnterDuration:200,transitionExitDuration:200,style:{display:"block"},children:e}):e)}componentDidMount(){const e=this.props.focusedItemId,t=this.itemId;e&&e===t&&this.props.onFocusDomElNeeded(this.itemElement),this.checkboxElement&&(this.checkboxElement.indeterminate=this.fieldsSvc.checkIndeterminate(this.item))}componentDidUpdate(e){const t=this.props.focusedItemId;if(t&&t!==e.focusedItemId&&t===this.itemId&&this.props.onFocusDomElNeeded(this.itemElement),this.checkboxElement){const i=this.fieldsSvc.checkIndeterminate(this.item);i!==e.fieldsService.checkIndeterminate(e.item)&&(this.checkboxElement.indeterminate=i)}}renderCheckbox(){if(this.props.checkboxes){const e=this.props.size;return c.createElement("div",{className:s.classNames("k-checkbox-wrap")},c.createElement("input",{type:"checkbox",className:s.classNames("k-checkbox k-rounded-md",{[`k-checkbox-${j[e]||e}`]:e,"k-disabled":this.disabled}),"aria-label":this.item.text,checked:!!this.fieldsSvc.checked(this.item),id:this.props.id,tabIndex:-1,onChange:this.onCheckChange,ref:t=>this.checkboxElement=t}),c.createElement("label",{className:"k-checkbox-label",htmlFor:this.props.id}))}else return}renderExpandIcon(){return this.props.expandIcons&&(this.fieldsSvc.hasChildren(this.item)||s.hasChildren(this.item,this.fieldsSvc.getChildrenField()))&&c.createElement("span",{className:s.classNames("k-treeview-toggle",{"k-disabled":this.disabled}),onClick:this.onExpandChange},c.createElement(s.IconWrap,{...this.getIconProps()}))}renderSubitemsIfApplicable(){const e=this.fieldsSvc.children(this.item);return s.isItemExpandedAndWithChildren(this.item,this.fieldsSvc)?c.createElement("ul",{className:"k-treeview-group",role:"group"},e.map((t,i)=>c.createElement(D,{item:t,position:i===0?"top":i===e.length-1?"bot":"mid",itemId:s.treeIdUtils.createId(i,this.itemId),treeGuid:this.props.treeGuid,animate:this.props.animate,focusedItemId:this.props.focusedItemId,tabbableItemId:this.props.tabbableItemId,fieldsService:this.props.fieldsService,itemUI:this.props.itemUI,checkboxes:this.props.checkboxes,ariaMultiSelectable:this.props.ariaMultiSelectable,onItemClick:this.props.onItemClick,onFocusDomElNeeded:this.props.onFocusDomElNeeded,draggable:this.props.draggable,onPress:this.props.onPress,onDrag:this.props.onDrag,onRelease:this.props.onRelease,expandIcons:this.props.expandIcons,onExpandChange:this.props.onExpandChange,onCheckChange:this.props.onCheckChange,onContextMenu:this.props.onContextMenu,key:i,size:this.props.size,disabled:this.disabled,isRtl:this.props.isRtl}))):void 0}renderItemInPart(){return c.createElement("span",{className:s.classNames("k-treeview-leaf",{"k-focus":this.props.focusedItemId===this.itemId,"k-selected":this.fieldsSvc.selected(this.item),"k-disabled":this.disabled}),style:{touchAction:"none"},onClick:this.onItemClick,onContextMenu:this.onContextMenu},c.createElement("span",{className:"k-treeview-leaf-text"},this.props.itemUI?c.createElement(this.props.itemUI,{item:this.item,itemHierarchicalIndex:this.itemId}):this.fieldsSvc.text(this.item)))}get fieldsSvc(){return this.props.fieldsService}get itemId(){return this.props.itemId}get item(){return this.props.item}get tabIndex(){return(this.props.focusedItemId||this.props.tabbableItemId)===this.itemId?0:-1}get ariaExpanded(){return this.fieldsSvc.hasChildren(this.item)||s.hasChildren(this.item,this.fieldsSvc.getChildrenField())?!!this.fieldsSvc.expanded(this.item):void 0}get disabled(){return this.props.disabled||this.fieldsSvc.disabled(this.item)}get ariaChecked(){if(this.props.checkboxes)return this.fieldsSvc.checked(this.item)?"true":this.fieldsSvc.checkIndeterminate(this.item)?"mixed":"false"}get ariaSelected(){return this.fieldsSvc.selected(this.item)?!0:this.props.ariaMultiSelectable?this.disabled?void 0:!1:void 0}getIconProps(){const e=this.fieldsSvc.expanded(this.item);return e&&!s.hasChildren(this.item,this.fieldsSvc.getChildrenField())?{name:"loading"}:e?{name:"caret-alt-down",icon:b.caretAltDownIcon}:{name:this.props.isRtl?"caret-alt-left":"caret-alt-right",icon:this.props.isRtl?b.caretAltLeftIcon:b.caretAltRightIcon}}}V.defaultProps={position:"top"};const D=s.withIdHOC(c.forwardRef((n,e)=>{const i=c.useContext(M).call(void 0,n);return c.createElement(V,{ref:e,...i})}));D.displayName="TreeViewItem";const q={name:"@progress/kendo-react-treeview",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:0,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},{sizeMap:Y}=s.kendoThemeMaps;let v=class extends c.Component{constructor(e){super(e),this.state={focusedItemId:void 0,focusedItemPublicId:void 0,tabbableItemId:s.treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID},this.fieldsSvc=null,this.allowExplicitFocus=!1,this._element=null,this.onFocusDomElNeeded=t=>{this.allowExplicitFocus&&this.focusDomItem(t)},this.onCheckChange=(t,i,r)=>{this.setFocus(r),this.dispatchCheckChange(t,i,r)},this.onExpandChange=(t,i,r)=>{this.setFocus(r),this.dispatchExpandChange(t,i,r)},this.onPress=(t,i,r)=>{this.props.onItemDragStart&&this.props.onItemDragStart.call(void 0,{target:this,item:i,itemHierarchicalIndex:r})},this.onDrag=(t,i,r)=>{const{pageX:l,pageY:d,clientX:a,clientY:I}=t;this.props.onItemDragOver&&this.props.onItemDragOver.call(void 0,{target:this,item:i,itemHierarchicalIndex:r,pageX:l,pageY:d,clientX:a,clientY:I})},this.onRelease=(t,i,r)=>{const{pageX:l,pageY:d,clientX:a,clientY:I}=t;this.props.onItemDragEnd&&this.props.onItemDragEnd.call(void 0,{target:this,item:i,itemHierarchicalIndex:r,pageX:l,pageY:d,clientX:a,clientY:I})},this.onItemClick=(t,i,r)=>{this.setFocus(r),this.dispatchItemClick(t,i,r)},this.onFocus=()=>{clearTimeout(this.blurRequest),this.state.focusedItemId===void 0&&this.data.length&&this.setFocus(this.state.tabbableItemId)},this.onBlur=()=>{clearTimeout(this.blurRequest),this.blurRequest=window.setTimeout(()=>this.setFocus(void 0),0)},this.onKeyDown=t=>{const i=this.getFocusedItem();if(i&&this.fieldsSvc){const r=C(i,this.state.focusedItemId,this.data,t.keyCode,this.fieldsSvc);r!==this.state.focusedItemId&&(t.preventDefault(),this.allowExplicitFocus=!0,this.setFocus(r)),this.dispatchEventsOnKeyDown(t,i)}},this.onContextMenu=(t,i,r)=>{if(this.props.onContextMenu){const l={target:this,syntheticEvent:t,nativeEvent:t.nativeEvent,item:i,itemID:r};this.props.onContextMenu.call(void 0,l)}},s.validatePackage(q)}get treeGuid(){return this.props.id+"-accessibility-id"}get element(){return this._element}render(){this.fieldsSvc=new s.TreeFieldsService(this.props);const{size:e,className:t}=this.props;return c.createElement("div",{id:this.props.id,className:s.classNames("k-treeview",{[`k-treeview-${Y[e]||e}`]:e,["k-user-select-none"]:this.props.draggable,["k-rtl"]:this.props.dir==="rtl"},t),onKeyDown:this.onKeyDown,onFocus:this.onFocus,onBlur:this.onBlur,role:"tree","aria-multiselectable":this.ariaMultiSelectable?!0:void 0,"aria-label":this.props["aria-label"],"aria-labelledby":this.props["aria-labelledby"],ref:i=>this._element=i,tabIndex:this.props.tabIndex},c.createElement("ul",{className:"k-treeview-lines k-treeview-group",role:"group"},this.data.map((i,r)=>c.createElement(D,{id:this.props.id+"-item-"+r,item:i,position:r===0?"top":r===this.data.length-1?"bot":"mid",itemId:r.toString(),treeGuid:this.treeGuid,animate:this.props.animate,focusedItemId:this.state.focusedItemId,tabbableItemId:this.state.tabbableItemId,fieldsService:this.fieldsSvc,itemUI:this.props.item,checkboxes:this.props.checkboxes,ariaMultiSelectable:this.ariaMultiSelectable,onItemClick:this.onItemClick,onFocusDomElNeeded:this.onFocusDomElNeeded,draggable:this.props.draggable,onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease,expandIcons:this.props.expandIcons,onExpandChange:this.onExpandChange,onCheckChange:this.onCheckChange,onContextMenu:this.onContextMenu,key:r,size:e,isRtl:this.props.dir==="rtl"}))))}componentDidUpdate(){this.allowExplicitFocus=!1,this.refocusDueToFocusIdField()}dispatchEventsOnKeyDown(e,t){if(this.fieldsSvc===null)return;const i=()=>this.fieldsSvc&&s.isEnabledAndAllParentsEnabled(this.state.focusedItemId,this.data,this.fieldsSvc);e.keyCode===s.Keys.left&&this.fieldsSvc.expanded(t)&&i()?this.dispatchExpandChange(e,t,this.state.focusedItemId):e.keyCode===s.Keys.right&&!this.fieldsSvc.expanded(t)&&(this.fieldsSvc.hasChildren(t)||s.hasChildren(t,this.props.childrenField))&&i()?this.dispatchExpandChange(e,t,this.state.focusedItemId):e.keyCode===s.Keys.enter&&i()?this.dispatchItemClick(e,t,this.state.focusedItemId):e.keyCode===s.Keys.space&&i()&&(e.preventDefault(),this.dispatchCheckChange(e,t,this.state.focusedItemId))}setFocus(e){if(e&&this.fieldsSvc)if(this.fieldsSvc.focusIdField){const t=this.getItemById(e);this.setState({focusedItemId:e,focusedItemPublicId:this.fieldsSvc.focusId(t)})}else this.setState({focusedItemId:e});else this.setState(t=>({focusedItemId:void 0,focusedItemPublicId:void 0,tabbableItemId:t.focusedItemId}))}getFocusedItem(){return this.state.focusedItemId?this.getItemById(this.state.focusedItemId):void 0}getItemById(e){return s.treeIdUtils.getItemById(e,this.data,this.props.childrenField||E)}dispatchCheckChange(e,t,i){s.dispatchEvent(this.props.onCheckChange,e,this,{item:t,itemHierarchicalIndex:i})}dispatchExpandChange(e,t,i){s.dispatchEvent(this.props.onExpandChange,e,this,{item:t,itemHierarchicalIndex:i})}dispatchItemClick(e,t,i){s.dispatchEvent(this.props.onItemClick,e,this,{item:t,itemHierarchicalIndex:i})}refocusDueToFocusIdField(){if(this.fieldsSvc&&this.fieldsSvc.focusIdField){const e=this.state.focusedItemPublicId;if(e){const t=this.props.getFocusHierarchicalIndex?this.props.getFocusHierarchicalIndex(e):s.resolveItemId(e,this.fieldsSvc.focusIdField,this.data,this.props.childrenField);t!==this.state.focusedItemId&&(this.allowExplicitFocus=!0,this.setState({focusedItemId:t}))}}}get ariaMultiSelectable(){return this.props["aria-multiselectable"]===!0||this.props["aria-multiselectable"]==="true"}get data(){return this.props.data||[]}focusDomItem(e){e.focus()}get guid(){return this.treeGuid}};v.propTypes={data:u.arrayOf(u.any),animate:u.bool,tabIndex:u.number,focusIdField:u.string,getHierarchicalIndexById:u.func,onExpandChange:u.func,onItemClick:u.func,expandField:u.string,selectField:u.string,childrenField:u.string,hasChildrenField:u.string,textField:u.string,disableField:u.string,item:u.any,"aria-multiselectable":(n,e,t)=>n[e]!==void 0&&n[e]!==!0&&n[e]!==!1&&n[e]!=="true"&&n[e]!=="false"?new Error("Invalid prop `"+e+"` supplied to `"+t+"`. Validation failed."):null,"aria-label":u.string,"aria-labelledby":u.string,size:u.oneOf([null,"small","medium","large"]),dir:u.string},v.defaultProps={animate:!0,expandField:P,selectField:U,hasChildrenField:$,childrenField:E,textField:H,disableField:W,checkField:y,checkIndeterminateField:_,size:"medium"};function X(n,e){if(!n||!n.length)return[];let t=n;const i=e.cloneField||"cloned",r=e.expandField||P,l=e.selectField||U,d=e.checkField||y,a=e.childrenField||E;return t=F(t,r,e.expand,i,a),t=F(t,l,e.select,i,a),t=F(t,d,e.check,i,a),Q(t,a,e.check),t}function F(n,e,t,i,r){if(t){let{ids:l,field:d}=A(t,e),a=!s.isArray(t)&&t.idField?s.resolveItemsIds(l,t.idField,n,r):l;return Z(n,a,d,i,r)}else return n}function A(n,e){let t,i;return s.isArray(n)?(t=n,i=e):(t=n.ids||[],i=n.operationField||e),{ids:t,field:i}}function Z(n,e,t,i,r){let l=n;return e.forEach(d=>{l=s.updateItem(l,d,a=>K(t,a),i,r)}),l}function K(n,e){const t=(n||"").split(".");let i=e;for(let r=0;r<t.length;r++){const l=t[r];if(r===t.length-1)i[l]=!0;else if(i[l]!==void 0)i[l]={...i[l]},i=i[l];else return}}function Q(n,e,t){if(t&&!s.isArray(t)&&t.applyCheckIndeterminate){const{field:i}=A(t,y),r=t.checkIndeterminateField||_;for(let l=0;l<n.length;l++){const d=n[l],a=d[e];a&&w(a,s.getNestedValue(i,d)?[]:[d],e,i,r)}}}function w(n,e,t,i,r){let l=!1;for(let d=0;d<n.length;d++){const a=n[d];if(s.getNestedValue(i,a)){if(!l)for(let I=0;I<e.length;I++)K(r,e[I]);l=!0,a[t]&&w(a[t],[],t,i,r)}else a[t]&&w(a[t],l?[a]:e.concat([a]),t,i,r)}}function J(n,e,t,i,r,l){const d=l||E;if(!f())return I();const a=s.treeIdUtils.getItemById(n,e,d);if(!a)return I();if(!r||r===e){if(!g())return I();const h=s.removeItem(n,d,e),p=s.addItem(a,t,d,s.treeIdUtils.getDecrementedItemIdAfterRemoval(n,i),h);return r?{sourceData:p,targetData:p}:p}else{const h=s.removeItem(n,d,e),p=s.addItem(a,t,d,i,r);return{sourceData:h,targetData:p}}function I(){return r?{sourceData:e,targetData:r}:e}function g(){return!`${i}_`.startsWith(`${n}_`)}function f(){if(!e||!e.length||!n||!i||r&&!r.length)return!1;const h=!r||r===e?e:r;return!!s.treeIdUtils.getItemById(i,h,d)}}function R(n,e,t,i={},r){if(!t||!t.length)return[];const{ids:l,idField:d}=ee(e),a=d?s.getNestedValue(d,n.item):n.itemHierarchicalIndex,I=l.indexOf(a),g=I===-1,f=r||E;let h;return i.singleMode?h=g?[a]:[]:(h=l.slice(),g?h.push(a):h.splice(I,1),i.checkChildren&&te(n.item,n.itemHierarchicalIndex,g,d,f,h),i.checkParents&&ie(n.itemHierarchicalIndex,g,d,f,h,t)),s.isArray(e)?h:Object.assign({},e,{ids:h})}function ee(n){let e,t;return s.isArray(n)?e=n:(e=n.ids||[],t=n.idField),{ids:e,idField:t}}function te(n,e,t,i,r,l){s.getAllDirectIndirectChildrenIds(n,e,r,i).forEach(d=>{t&&l.indexOf(d)===-1?l.push(d):!t&&l.indexOf(d)>-1&&l.splice(l.indexOf(d),1)})}function ie(n,e,t,i,r,l){const d=f();let a=d.next();e?I():g();function I(){for(;!a.done;){const{id:h,item:p}=a.value;if(r.indexOf(h)===-1&&s.areAllDirectChildrenChecked(p,h,t,i,r))r.push(h),a=d.next();else break}}function g(){for(;!a.done;){const{id:h}=a.value,p=r.indexOf(h);if(p>-1)r.splice(p,1),a=d.next();else break}}function*f(){if(t){const h=s.getAllParents(n,i,l);for(let p=h.length-1;p>-1;p--)yield{id:s.getNestedValue(t,h[p]),item:e?h[p]:void 0}}else{let h=s.treeIdUtils.getDirectParentId(n);for(;h;)yield{id:h,item:e?s.treeIdUtils.getItemById(h,l,i):void 0},h=s.treeIdUtils.getDirectParentId(h)}}}class k extends c.PureComponent{constructor(){super(...arguments),this.state={visible:!1,top:0,left:0,text:"",operationClassName:"cancel"}}render(){const e={top:this.state.top+"px",left:this.state.left+"px"};return this.state.visible&&c.createElement("div",{className:"k-header k-drag-clue",style:{...this.props.style,...e}},c.createElement(s.IconWrap,{className:s.classNames("k-drag-status"),name:this.state.operationClassName&&s.toIconName(this.state.operationClassName),icon:this.state.operationClassName==="k-i-plus"?b.plusIcon:this.state.operationClassName==="k-i-insert-up"?b.insertTopIcon:this.state.operationClassName==="k-i-insert-up"?b.insertBottomIcon:this.state.operationClassName==="k-i-insert-middle"?b.insertMiddleIcon:b.cancelIcon}),this.state.text)}show(e,t,i,r){this.setState({visible:!0,top:e,left:t,text:i,operationClassName:r})}hide(){this.setState({visible:!1})}}k.defaultProps={style:{display:"block",position:"absolute",zIndex:2e4,padding:"4px 6px"}};const L=6;class se{constructor(e){this.event=e,this.initialized=!1,this.destItemId="",this.destTreeViewGuid="",this.itemId=e.itemHierarchicalIndex,this.treeViewGuid=e.target.guid}init(){return this.initialized||(this.setDestimationMeta(document.elementFromPoint(this.event.clientX,this.event.clientY)),this.initialized=!0),this}get isDropAllowed(){return this.initialized&&this.destItemId&&this.destTreeViewGuid?!`${this.destTreeViewGuid}_${this.destItemId}_`.startsWith(`${this.treeViewGuid}_${this.itemId}_`):!1}get destinationMeta(){return{itemHierarchicalIndex:this.destItemId,treeViewGuid:this.destTreeViewGuid}}getDropOperation(){if(this.initialized&&this.isDropAllowed){const{top:e,height:t}=this.destDomNodeWithMeta.getBoundingClientRect();return e+t-this.event.clientY<L?"after":this.event.clientY-e<L?"before":"child"}else return}setDestimationMeta(e){let t=e;for(;t&&!t[x];)t=t.parentNode;t&&t[x]&&(this.destDomNodeWithMeta=t,this.destItemId=t[x],this.destTreeViewGuid=t[O])}}const z=s.withIdHOC(v);z.displayName="KendoReactTreeView",Object.defineProperty(o,"FieldsService",{enumerable:!0,get:()=>s.TreeFieldsService}),o.TreeView=z,o.TreeViewClassComponent=v,o.TreeViewDragAnalyzer=se,o.TreeViewDragClue=k,o.TreeViewItemPropsContext=M,o.getItemIdUponKeyboardNavigation=C,o.handleTreeViewCheckChange=R,o.moveTreeViewItem=J,o.processTreeViewItems=X,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
package/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { TreeView } from './TreeView';
|
|
5
|
+
import { TreeView as TreeViewClassComponent, type TreeViewHandle } from './TreeView';
|
|
6
6
|
import type { TreeViewItemClickEvent, TreeViewExpandChangeEvent, TreeViewCheckChangeEvent, TreeViewItemDragOverEvent, TreeViewItemDragStartEvent, TreeViewItemDragEndEvent } from './events';
|
|
7
7
|
import { processTreeViewItems } from './processTreeViewItems';
|
|
8
8
|
import { moveTreeViewItem } from './moveTreeViewItem';
|
|
@@ -15,4 +15,6 @@ import { TreeViewDragAnalyzer } from './TreeViewDragAnalyzer';
|
|
|
15
15
|
import { TreeViewItemPropsContext } from './TreeViewItem';
|
|
16
16
|
import getItemIdUponKeyboardNavigation from './utils/getItemIdUponKeyboardNavigation';
|
|
17
17
|
import { TreeFieldsService as FieldsService } from '@progress/kendo-react-common';
|
|
18
|
-
|
|
18
|
+
/** @hidden */
|
|
19
|
+
declare const TreeView: import("react").ForwardRefExoticComponent<TreeViewProps & import("react").RefAttributes<any>>;
|
|
20
|
+
export { TreeViewItemPropsContext, TreeViewClassComponent, TreeView, TreeViewHandle, processTreeViewItems, handleTreeViewCheckChange, TreeViewCheckChangeSettings, TreeViewItemClickEvent, TreeViewExpandChangeEvent, TreeViewCheckChangeEvent, TreeViewItemDragOverEvent, TreeViewItemDragStartEvent, TreeViewItemDragEndEvent, TreeViewOperationDescriptor, TreeViewOperationDescriptors, TreeViewCheckDescriptor, TreeViewProps, ItemRenderProps, TreeViewDragClue, moveTreeViewItem, TreeViewDragAnalyzer, getItemIdUponKeyboardNavigation, FieldsService };
|
package/index.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("react"),K=require("prop-types"),s=require("@progress/kendo-react-common"),f=require("@progress/kendo-svg-icons"),L=require("@progress/kendo-react-animation");function F(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const c=F(V),p=F(K);function y(r,e,t,i,n){switch(i){case s.Keys.left:return d();case s.Keys.right:return l();case s.Keys.up:return a();case s.Keys.down:return u();case s.Keys.home:return s.treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID;case s.Keys.end:return I();default:return e}function d(){return s.treeIdUtils.isIdZeroLevel(e)||n.expanded(r)&&s.isEnabledAndAllParentsEnabled(e,t,n)?e:s.treeIdUtils.getDirectParentId(e)}function l(){return s.isItemExpandedAndWithChildren(r,n)?s.treeIdUtils.getFirstChildId(e):e}function a(){const m=Number(s.treeIdUtils.getShortId(e)),o=s.treeIdUtils.getDirectParentId(e);return m?S(s.treeIdUtils.createId(m-1,o),t,n):s.treeIdUtils.isIdZeroLevel(e)?e:o}function u(){return s.isItemExpandedAndWithChildren(r,n)?s.treeIdUtils.getFirstChildId(e):w(e,t,n)||e}function I(){let m=(t.length-1).toString(),o=t[t.length-1],h;for(;s.isItemExpandedAndWithChildren(o,n);)h=o[n.getChildrenField()],m=s.treeIdUtils.createId(h.length-1,m),o=h[h.length-1];return m}}function w(r,e,t){const i=s.treeIdUtils.getDirectParentId(r),n=i?s.treeIdUtils.getItemById(i,e,t.getChildrenField()):void 0,d=n?n[t.getChildrenField()]:e,l=Number(s.treeIdUtils.getShortId(r));return l<d.length-1?s.treeIdUtils.createId(l+1,i):n?w(i,e,t):void 0}function S(r,e,t){const i=s.treeIdUtils.getItemById(r,e,t.getChildrenField());return s.isItemExpandedAndWithChildren(i,t)?S(s.treeIdUtils.createId(i[t.getChildrenField()].length-1,r),e,t):r}const N="expanded",G="text",z="disabled",g="items",B="hasChildren",T="selected",x="checked",P="checkIndeterminate",b="_kendoItemId",U="_kendoTreeViewGuid",{sizeMap:W}=s.kendoThemeMaps,_=c.createContext(r=>r);class M extends c.Component{constructor(){super(...arguments),this.itemGuid=s.guid(),this.onCheckChange=e=>{this.props.onCheckChange(e,this.item,this.itemId)},this.onExpandChange=e=>{this.props.onExpandChange(e,this.item,this.itemId)},this.onItemClick=e=>{this.props.onItemClick(e,this.item,this.itemId)},this.onPress=e=>{this.props.onPress(e.event,this.item,this.itemId)},this.onDrag=e=>{this.props.onDrag(e.event,this.item,this.itemId)},this.onRelease=e=>{this.props.onRelease(e.event,this.item,this.itemId)},this.onContextMenu=e=>{this.props.onContextMenu(e,this.item,this.itemId)},this.assignDraggableMeta=e=>{e&&(e[b]=this.props.itemId,e[U]=this.props.treeGuid)}}render(){const e=this.renderSubitemsIfApplicable(),t=this.renderItemInPart();return c.createElement("li",{className:s.classNames("k-treeview-item"),tabIndex:this.tabIndex,role:"treeitem","aria-expanded":this.ariaExpanded,"aria-selected":this.ariaSelected,"aria-checked":this.ariaChecked,"aria-disabled":this.disabled?!0:void 0,ref:i=>this.itemElement=i},c.createElement("div",{className:`k-treeview-${this.props.position}`,ref:this.assignDraggableMeta},this.renderExpandIcon(),this.renderCheckbox(),this.props.draggable?c.createElement(s.Draggable,{onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease},t):t),this.props.animate?c.createElement(L.Reveal,{transitionEnterDuration:200,transitionExitDuration:200,style:{display:"block"},children:e}):e)}componentDidMount(){const e=this.props.focusedItemId,t=this.itemId;e&&e===t&&this.props.onFocusDomElNeeded(this.itemElement),this.checkboxElement&&(this.checkboxElement.indeterminate=this.fieldsSvc.checkIndeterminate(this.item))}componentDidUpdate(e){const t=this.props.focusedItemId;if(t&&t!==e.focusedItemId&&t===this.itemId&&this.props.onFocusDomElNeeded(this.itemElement),this.checkboxElement){const i=this.fieldsSvc.checkIndeterminate(this.item);i!==e.fieldsService.checkIndeterminate(e.item)&&(this.checkboxElement.indeterminate=i)}}renderCheckbox(){if(this.props.checkboxes){const e=this.props.size;return c.createElement("div",{className:s.classNames("k-checkbox-wrap")},c.createElement("input",{type:"checkbox",className:s.classNames("k-checkbox k-rounded-md",{[`k-checkbox-${W[e]||e}`]:e,"k-disabled":this.disabled}),"aria-label":this.item.text,checked:!!this.fieldsSvc.checked(this.item),id:this.itemGuid,tabIndex:-1,onChange:this.onCheckChange,ref:t=>this.checkboxElement=t}),c.createElement("label",{className:"k-checkbox-label",htmlFor:this.itemGuid}))}else return}renderExpandIcon(){return this.props.expandIcons&&(this.fieldsSvc.hasChildren(this.item)||s.hasChildren(this.item,this.fieldsSvc.getChildrenField()))&&c.createElement("span",{className:s.classNames("k-treeview-toggle",{"k-disabled":this.disabled}),onClick:this.onExpandChange},c.createElement(s.IconWrap,{...this.getIconProps()}))}renderSubitemsIfApplicable(){const e=this.fieldsSvc.children(this.item);return s.isItemExpandedAndWithChildren(this.item,this.fieldsSvc)?c.createElement("ul",{className:"k-treeview-group",role:"group"},e.map((t,i)=>c.createElement(k,{item:t,position:i===0?"top":i===e.length-1?"bot":"mid",itemId:s.treeIdUtils.createId(i,this.itemId),treeGuid:this.props.treeGuid,animate:this.props.animate,focusedItemId:this.props.focusedItemId,tabbableItemId:this.props.tabbableItemId,fieldsService:this.props.fieldsService,itemUI:this.props.itemUI,checkboxes:this.props.checkboxes,ariaMultiSelectable:this.props.ariaMultiSelectable,onItemClick:this.props.onItemClick,onFocusDomElNeeded:this.props.onFocusDomElNeeded,draggable:this.props.draggable,onPress:this.props.onPress,onDrag:this.props.onDrag,onRelease:this.props.onRelease,expandIcons:this.props.expandIcons,onExpandChange:this.props.onExpandChange,onCheckChange:this.props.onCheckChange,onContextMenu:this.props.onContextMenu,key:i,size:this.props.size,disabled:this.disabled,isRtl:this.props.isRtl}))):void 0}renderItemInPart(){return c.createElement("span",{className:s.classNames("k-treeview-leaf",{"k-focus":this.props.focusedItemId===this.itemId,"k-selected":this.fieldsSvc.selected(this.item),"k-disabled":this.disabled}),style:{touchAction:"none"},onClick:this.onItemClick,onContextMenu:this.onContextMenu},c.createElement("span",{className:"k-treeview-leaf-text"},this.props.itemUI?c.createElement(this.props.itemUI,{item:this.item,itemHierarchicalIndex:this.itemId}):this.fieldsSvc.text(this.item)))}get fieldsSvc(){return this.props.fieldsService}get itemId(){return this.props.itemId}get item(){return this.props.item}get tabIndex(){return(this.props.focusedItemId||this.props.tabbableItemId)===this.itemId?0:-1}get ariaExpanded(){return this.fieldsSvc.hasChildren(this.item)||s.hasChildren(this.item,this.fieldsSvc.getChildrenField())?!!this.fieldsSvc.expanded(this.item):void 0}get disabled(){return this.props.disabled||this.fieldsSvc.disabled(this.item)}get ariaChecked(){if(this.props.checkboxes)return this.fieldsSvc.checked(this.item)?"true":this.fieldsSvc.checkIndeterminate(this.item)?"mixed":"false"}get ariaSelected(){return this.fieldsSvc.selected(this.item)?!0:this.props.ariaMultiSelectable?this.disabled?void 0:!1:void 0}getIconProps(){const e=this.fieldsSvc.expanded(this.item);return e&&!s.hasChildren(this.item,this.fieldsSvc.getChildrenField())?{name:"loading"}:e?{name:"caret-alt-down",icon:f.caretAltDownIcon}:{name:this.props.isRtl?"caret-alt-left":"caret-alt-right",icon:this.props.isRtl?f.caretAltLeftIcon:f.caretAltRightIcon}}}M.defaultProps={position:"top"};const k=c.forwardRef((r,e)=>{const i=c.useContext(_).call(void 0,r);return c.createElement(M,{ref:e,...i})});k.displayName="TreeViewItem";const H={name:"@progress/kendo-react-treeview",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:0,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},{sizeMap:$}=s.kendoThemeMaps;class v extends c.Component{constructor(e){super(e),this.state={focusedItemId:void 0,focusedItemPublicId:void 0,tabbableItemId:s.treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID},this.fieldsSvc=null,this.allowExplicitFocus=!1,this.treeGuid=s.guid(),this._element=null,this.onFocusDomElNeeded=t=>{this.allowExplicitFocus&&this.focusDomItem(t)},this.onCheckChange=(t,i,n)=>{this.setFocus(n),this.dispatchCheckChange(t,i,n)},this.onExpandChange=(t,i,n)=>{this.setFocus(n),this.dispatchExpandChange(t,i,n)},this.onPress=(t,i,n)=>{this.props.onItemDragStart&&this.props.onItemDragStart.call(void 0,{target:this,item:i,itemHierarchicalIndex:n})},this.onDrag=(t,i,n)=>{const{pageX:d,pageY:l,clientX:a,clientY:u}=t;this.props.onItemDragOver&&this.props.onItemDragOver.call(void 0,{target:this,item:i,itemHierarchicalIndex:n,pageX:d,pageY:l,clientX:a,clientY:u})},this.onRelease=(t,i,n)=>{const{pageX:d,pageY:l,clientX:a,clientY:u}=t;this.props.onItemDragEnd&&this.props.onItemDragEnd.call(void 0,{target:this,item:i,itemHierarchicalIndex:n,pageX:d,pageY:l,clientX:a,clientY:u})},this.onItemClick=(t,i,n)=>{this.setFocus(n),this.dispatchItemClick(t,i,n)},this.onFocus=()=>{clearTimeout(this.blurRequest),this.state.focusedItemId===void 0&&this.data.length&&this.setFocus(this.state.tabbableItemId)},this.onBlur=()=>{clearTimeout(this.blurRequest),this.blurRequest=window.setTimeout(()=>this.setFocus(void 0),0)},this.onKeyDown=t=>{const i=this.getFocusedItem();if(i&&this.fieldsSvc){const n=y(i,this.state.focusedItemId,this.data,t.keyCode,this.fieldsSvc);n!==this.state.focusedItemId&&(t.preventDefault(),this.allowExplicitFocus=!0,this.setFocus(n)),this.dispatchEventsOnKeyDown(t,i)}},this.onContextMenu=(t,i,n)=>{if(this.props.onContextMenu){const d={target:this,syntheticEvent:t,nativeEvent:t.nativeEvent,item:i,itemID:n};this.props.onContextMenu.call(void 0,d)}},s.validatePackage(H)}get element(){return this._element}render(){this.fieldsSvc=new s.TreeFieldsService(this.props);const{size:e,className:t}=this.props;return c.createElement("div",{className:s.classNames("k-treeview",{[`k-treeview-${$[e]||e}`]:e,["k-user-select-none"]:this.props.draggable,["k-rtl"]:this.props.dir==="rtl"},t),onKeyDown:this.onKeyDown,onFocus:this.onFocus,onBlur:this.onBlur,role:"tree","aria-multiselectable":this.ariaMultiSelectable?!0:void 0,"aria-label":this.props["aria-label"],"aria-labelledby":this.props["aria-labelledby"],ref:i=>this._element=i,tabIndex:this.props.tabIndex},c.createElement("ul",{className:"k-treeview-lines k-treeview-group",role:"group"},this.data.map((i,n)=>c.createElement(k,{item:i,position:n===0?"top":n===this.data.length-1?"bot":"mid",itemId:n.toString(),treeGuid:this.treeGuid,animate:this.props.animate,focusedItemId:this.state.focusedItemId,tabbableItemId:this.state.tabbableItemId,fieldsService:this.fieldsSvc,itemUI:this.props.item,checkboxes:this.props.checkboxes,ariaMultiSelectable:this.ariaMultiSelectable,onItemClick:this.onItemClick,onFocusDomElNeeded:this.onFocusDomElNeeded,draggable:this.props.draggable,onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease,expandIcons:this.props.expandIcons,onExpandChange:this.onExpandChange,onCheckChange:this.onCheckChange,onContextMenu:this.onContextMenu,key:n,size:e,isRtl:this.props.dir==="rtl"}))))}componentDidUpdate(){this.allowExplicitFocus=!1,this.refocusDueToFocusIdField()}dispatchEventsOnKeyDown(e,t){if(this.fieldsSvc===null)return;const i=()=>this.fieldsSvc&&s.isEnabledAndAllParentsEnabled(this.state.focusedItemId,this.data,this.fieldsSvc);e.keyCode===s.Keys.left&&this.fieldsSvc.expanded(t)&&i()?this.dispatchExpandChange(e,t,this.state.focusedItemId):e.keyCode===s.Keys.right&&!this.fieldsSvc.expanded(t)&&(this.fieldsSvc.hasChildren(t)||s.hasChildren(t,this.props.childrenField))&&i()?this.dispatchExpandChange(e,t,this.state.focusedItemId):e.keyCode===s.Keys.enter&&i()?this.dispatchItemClick(e,t,this.state.focusedItemId):e.keyCode===s.Keys.space&&i()&&(e.preventDefault(),this.dispatchCheckChange(e,t,this.state.focusedItemId))}setFocus(e){if(e&&this.fieldsSvc)if(this.fieldsSvc.focusIdField){const t=this.getItemById(e);this.setState({focusedItemId:e,focusedItemPublicId:this.fieldsSvc.focusId(t)})}else this.setState({focusedItemId:e});else this.setState(t=>({focusedItemId:void 0,focusedItemPublicId:void 0,tabbableItemId:t.focusedItemId}))}getFocusedItem(){return this.state.focusedItemId?this.getItemById(this.state.focusedItemId):void 0}getItemById(e){return s.treeIdUtils.getItemById(e,this.data,this.props.childrenField||g)}dispatchCheckChange(e,t,i){s.dispatchEvent(this.props.onCheckChange,e,this,{item:t,itemHierarchicalIndex:i})}dispatchExpandChange(e,t,i){s.dispatchEvent(this.props.onExpandChange,e,this,{item:t,itemHierarchicalIndex:i})}dispatchItemClick(e,t,i){s.dispatchEvent(this.props.onItemClick,e,this,{item:t,itemHierarchicalIndex:i})}refocusDueToFocusIdField(){if(this.fieldsSvc&&this.fieldsSvc.focusIdField){const e=this.state.focusedItemPublicId;if(e){const t=this.props.getFocusHierarchicalIndex?this.props.getFocusHierarchicalIndex(e):s.resolveItemId(e,this.fieldsSvc.focusIdField,this.data,this.props.childrenField);t!==this.state.focusedItemId&&(this.allowExplicitFocus=!0,this.setState({focusedItemId:t}))}}}get ariaMultiSelectable(){return this.props["aria-multiselectable"]===!0||this.props["aria-multiselectable"]==="true"}get data(){return this.props.data||[]}focusDomItem(e){e.focus()}get guid(){return this.treeGuid}}v.propTypes={data:p.arrayOf(p.any),animate:p.bool,tabIndex:p.number,focusIdField:p.string,getHierarchicalIndexById:p.func,onExpandChange:p.func,onItemClick:p.func,expandField:p.string,selectField:p.string,childrenField:p.string,hasChildrenField:p.string,textField:p.string,disableField:p.string,item:p.any,"aria-multiselectable":(r,e,t)=>r[e]!==void 0&&r[e]!==!0&&r[e]!==!1&&r[e]!=="true"&&r[e]!=="false"?new Error("Invalid prop `"+e+"` supplied to `"+t+"`. Validation failed."):null,"aria-label":p.string,"aria-labelledby":p.string,size:p.oneOf([null,"small","medium","large"]),dir:p.string};v.defaultProps={animate:!0,expandField:N,selectField:T,hasChildrenField:B,childrenField:g,textField:G,disableField:z,checkField:x,checkIndeterminateField:P,size:"medium"};function j(r,e){if(!r||!r.length)return[];let t=r;const i=e.cloneField||"cloned",n=e.expandField||N,d=e.selectField||T,l=e.checkField||x,a=e.childrenField||g;return t=C(t,n,e.expand,i,a),t=C(t,d,e.select,i,a),t=C(t,l,e.check,i,a),Y(t,a,e.check),t}function C(r,e,t,i,n){if(t){let{ids:d,field:l}=O(t,e),a=!s.isArray(t)&&t.idField?s.resolveItemsIds(d,t.idField,r,n):d;return q(r,a,l,i,n)}else return r}function O(r,e){let t,i;return s.isArray(r)?(t=r,i=e):(t=r.ids||[],i=r.operationField||e),{ids:t,field:i}}function q(r,e,t,i,n){let d=r;return e.forEach(l=>{d=s.updateItem(d,l,a=>R(t,a),i,n)}),d}function R(r,e){const t=(r||"").split(".");let i=e;for(let n=0;n<t.length;n++){const d=t[n];if(n===t.length-1)i[d]=!0;else if(i[d]!==void 0)i[d]={...i[d]},i=i[d];else return}}function Y(r,e,t){if(t&&!s.isArray(t)&&t.applyCheckIndeterminate){const{field:i}=O(t,x),n=t.checkIndeterminateField||P;for(let d=0;d<r.length;d++){const l=r[d],a=l[e];a&&E(a,s.getNestedValue(i,l)?[]:[l],e,i,n)}}}function E(r,e,t,i,n){let d=!1;for(let l=0;l<r.length;l++){const a=r[l];if(s.getNestedValue(i,a)){if(!d)for(let u=0;u<e.length;u++)R(n,e[u]);d=!0,a[t]&&E(a[t],[],t,i,n)}else a[t]&&E(a[t],d?[a]:e.concat([a]),t,i,n)}}function X(r,e,t,i,n,d){const l=d||g;if(!m())return u();const a=s.treeIdUtils.getItemById(r,e,l);if(!a)return u();if(!n||n===e){if(!I())return u();const o=s.removeItem(r,l,e),h=s.addItem(a,t,l,s.treeIdUtils.getDecrementedItemIdAfterRemoval(r,i),o);return n?{sourceData:h,targetData:h}:h}else{const o=s.removeItem(r,l,e),h=s.addItem(a,t,l,i,n);return{sourceData:o,targetData:h}}function u(){return n?{sourceData:e,targetData:n}:e}function I(){return!`${i}_`.startsWith(`${r}_`)}function m(){if(!e||!e.length||!r||!i||n&&!n.length)return!1;const o=!n||n===e?e:n;return!!s.treeIdUtils.getItemById(i,o,l)}}function Z(r,e,t,i={},n){if(!t||!t.length)return[];const{ids:d,idField:l}=Q(e),a=l?s.getNestedValue(l,r.item):r.itemHierarchicalIndex,u=d.indexOf(a),I=u===-1,m=n||g;let o;return i.singleMode?o=I?[a]:[]:(o=d.slice(),I?o.push(a):o.splice(u,1),i.checkChildren&&J(r.item,r.itemHierarchicalIndex,I,l,m,o),i.checkParents&&ee(r.itemHierarchicalIndex,I,l,m,o,t)),s.isArray(e)?o:Object.assign({},e,{ids:o})}function Q(r){let e,t;return s.isArray(r)?e=r:(e=r.ids||[],t=r.idField),{ids:e,idField:t}}function J(r,e,t,i,n,d){s.getAllDirectIndirectChildrenIds(r,e,n,i).forEach(l=>{t&&d.indexOf(l)===-1?d.push(l):!t&&d.indexOf(l)>-1&&d.splice(d.indexOf(l),1)})}function ee(r,e,t,i,n,d){const l=m();let a=l.next();e?u():I();function u(){for(;!a.done;){const{id:o,item:h}=a.value;if(n.indexOf(o)===-1&&s.areAllDirectChildrenChecked(h,o,t,i,n))n.push(o),a=l.next();else break}}function I(){for(;!a.done;){const{id:o}=a.value,h=n.indexOf(o);if(h>-1)n.splice(h,1),a=l.next();else break}}function*m(){if(t){const o=s.getAllParents(r,i,d);for(let h=o.length-1;h>-1;h--)yield{id:s.getNestedValue(t,o[h]),item:e?o[h]:void 0}}else{let o=s.treeIdUtils.getDirectParentId(r);for(;o;)yield{id:o,item:e?s.treeIdUtils.getItemById(o,d,i):void 0},o=s.treeIdUtils.getDirectParentId(o)}}}class A extends c.PureComponent{constructor(){super(...arguments),this.state={visible:!1,top:0,left:0,text:"",operationClassName:"cancel"}}render(){const e={top:this.state.top+"px",left:this.state.left+"px"};return this.state.visible&&c.createElement("div",{className:"k-header k-drag-clue",style:{...this.props.style,...e}},c.createElement(s.IconWrap,{className:s.classNames("k-drag-status"),name:this.state.operationClassName&&s.toIconName(this.state.operationClassName),icon:this.state.operationClassName==="k-i-plus"?f.plusIcon:this.state.operationClassName==="k-i-insert-up"?f.insertTopIcon:this.state.operationClassName==="k-i-insert-up"?f.insertBottomIcon:this.state.operationClassName==="k-i-insert-middle"?f.insertMiddleIcon:f.cancelIcon}),this.state.text)}show(e,t,i,n){this.setState({visible:!0,top:e,left:t,text:i,operationClassName:n})}hide(){this.setState({visible:!1})}}A.defaultProps={style:{display:"block",position:"absolute",zIndex:2e4,padding:"4px 6px"}};const D=6;class te{constructor(e){this.event=e,this.initialized=!1,this.destItemId="",this.destTreeViewGuid="",this.itemId=e.itemHierarchicalIndex,this.treeViewGuid=e.target.guid}init(){return this.initialized||(this.setDestimationMeta(document.elementFromPoint(this.event.clientX,this.event.clientY)),this.initialized=!0),this}get isDropAllowed(){return this.initialized&&this.destItemId&&this.destTreeViewGuid?!`${this.destTreeViewGuid}_${this.destItemId}_`.startsWith(`${this.treeViewGuid}_${this.itemId}_`):!1}get destinationMeta(){return{itemHierarchicalIndex:this.destItemId,treeViewGuid:this.destTreeViewGuid}}getDropOperation(){if(this.initialized&&this.isDropAllowed){const{top:e,height:t}=this.destDomNodeWithMeta.getBoundingClientRect();return e+t-this.event.clientY<D?"after":this.event.clientY-e<D?"before":"child"}else return}setDestimationMeta(e){let t=e;for(;t&&!t[b];)t=t.parentNode;t&&t[b]&&(this.destDomNodeWithMeta=t,this.destItemId=t[b],this.destTreeViewGuid=t[U])}}Object.defineProperty(exports,"FieldsService",{enumerable:!0,get:()=>s.TreeFieldsService});exports.TreeView=v;exports.TreeViewDragAnalyzer=te;exports.TreeViewDragClue=A;exports.TreeViewItemPropsContext=_;exports.getItemIdUponKeyboardNavigation=y;exports.handleTreeViewCheckChange=Z;exports.moveTreeViewItem=X;exports.processTreeViewItems=j;
|
|
5
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const K=require("react"),L=require("prop-types"),s=require("@progress/kendo-react-common"),f=require("@progress/kendo-svg-icons"),z=require("@progress/kendo-react-animation");function F(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const c=F(K),p=F(L);function y(r,e,t,i,n){switch(i){case s.Keys.left:return d();case s.Keys.right:return l();case s.Keys.up:return a();case s.Keys.down:return u();case s.Keys.home:return s.treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID;case s.Keys.end:return I();default:return e}function d(){return s.treeIdUtils.isIdZeroLevel(e)||n.expanded(r)&&s.isEnabledAndAllParentsEnabled(e,t,n)?e:s.treeIdUtils.getDirectParentId(e)}function l(){return s.isItemExpandedAndWithChildren(r,n)?s.treeIdUtils.getFirstChildId(e):e}function a(){const m=Number(s.treeIdUtils.getShortId(e)),o=s.treeIdUtils.getDirectParentId(e);return m?S(s.treeIdUtils.createId(m-1,o),t,n):s.treeIdUtils.isIdZeroLevel(e)?e:o}function u(){return s.isItemExpandedAndWithChildren(r,n)?s.treeIdUtils.getFirstChildId(e):w(e,t,n)||e}function I(){let m=(t.length-1).toString(),o=t[t.length-1],h;for(;s.isItemExpandedAndWithChildren(o,n);)h=o[n.getChildrenField()],m=s.treeIdUtils.createId(h.length-1,m),o=h[h.length-1];return m}}function w(r,e,t){const i=s.treeIdUtils.getDirectParentId(r),n=i?s.treeIdUtils.getItemById(i,e,t.getChildrenField()):void 0,d=n?n[t.getChildrenField()]:e,l=Number(s.treeIdUtils.getShortId(r));return l<d.length-1?s.treeIdUtils.createId(l+1,i):n?w(i,e,t):void 0}function S(r,e,t){const i=s.treeIdUtils.getItemById(r,e,t.getChildrenField());return s.isItemExpandedAndWithChildren(i,t)?S(s.treeIdUtils.createId(i[t.getChildrenField()].length-1,r),e,t):r}const N="expanded",B="text",G="disabled",g="items",H="hasChildren",T="selected",x="checked",P="checkIndeterminate",b="_kendoItemId",U="_kendoTreeViewGuid",{sizeMap:W}=s.kendoThemeMaps,_=c.createContext(r=>r);class O extends c.Component{constructor(){super(...arguments),this.onCheckChange=e=>{this.props.onCheckChange(e,this.item,this.itemId)},this.onExpandChange=e=>{this.props.onExpandChange(e,this.item,this.itemId)},this.onItemClick=e=>{this.props.onItemClick(e,this.item,this.itemId)},this.onPress=e=>{this.props.onPress(e.event,this.item,this.itemId)},this.onDrag=e=>{this.props.onDrag(e.event,this.item,this.itemId)},this.onRelease=e=>{this.props.onRelease(e.event,this.item,this.itemId)},this.onContextMenu=e=>{this.props.onContextMenu(e,this.item,this.itemId)},this.assignDraggableMeta=e=>{e&&(e[b]=this.props.itemId,e[U]=this.props.treeGuid)}}render(){const e=this.renderSubitemsIfApplicable(),t=this.renderItemInPart();return c.createElement("li",{className:s.classNames("k-treeview-item"),tabIndex:this.tabIndex,role:"treeitem","aria-expanded":this.ariaExpanded,"aria-selected":this.ariaSelected,"aria-checked":this.ariaChecked,"aria-disabled":this.disabled?!0:void 0,ref:i=>this.itemElement=i},c.createElement("div",{className:`k-treeview-${this.props.position}`,ref:this.assignDraggableMeta},this.renderExpandIcon(),this.renderCheckbox(),this.props.draggable?c.createElement(s.Draggable,{onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease},t):t),this.props.animate?c.createElement(z.Reveal,{transitionEnterDuration:200,transitionExitDuration:200,style:{display:"block"},children:e}):e)}componentDidMount(){const e=this.props.focusedItemId,t=this.itemId;e&&e===t&&this.props.onFocusDomElNeeded(this.itemElement),this.checkboxElement&&(this.checkboxElement.indeterminate=this.fieldsSvc.checkIndeterminate(this.item))}componentDidUpdate(e){const t=this.props.focusedItemId;if(t&&t!==e.focusedItemId&&t===this.itemId&&this.props.onFocusDomElNeeded(this.itemElement),this.checkboxElement){const i=this.fieldsSvc.checkIndeterminate(this.item);i!==e.fieldsService.checkIndeterminate(e.item)&&(this.checkboxElement.indeterminate=i)}}renderCheckbox(){if(this.props.checkboxes){const e=this.props.size;return c.createElement("div",{className:s.classNames("k-checkbox-wrap")},c.createElement("input",{type:"checkbox",className:s.classNames("k-checkbox k-rounded-md",{[`k-checkbox-${W[e]||e}`]:e,"k-disabled":this.disabled}),"aria-label":this.item.text,checked:!!this.fieldsSvc.checked(this.item),id:this.props.id,tabIndex:-1,onChange:this.onCheckChange,ref:t=>this.checkboxElement=t}),c.createElement("label",{className:"k-checkbox-label",htmlFor:this.props.id}))}else return}renderExpandIcon(){return this.props.expandIcons&&(this.fieldsSvc.hasChildren(this.item)||s.hasChildren(this.item,this.fieldsSvc.getChildrenField()))&&c.createElement("span",{className:s.classNames("k-treeview-toggle",{"k-disabled":this.disabled}),onClick:this.onExpandChange},c.createElement(s.IconWrap,{...this.getIconProps()}))}renderSubitemsIfApplicable(){const e=this.fieldsSvc.children(this.item);return s.isItemExpandedAndWithChildren(this.item,this.fieldsSvc)?c.createElement("ul",{className:"k-treeview-group",role:"group"},e.map((t,i)=>c.createElement(v,{item:t,position:i===0?"top":i===e.length-1?"bot":"mid",itemId:s.treeIdUtils.createId(i,this.itemId),treeGuid:this.props.treeGuid,animate:this.props.animate,focusedItemId:this.props.focusedItemId,tabbableItemId:this.props.tabbableItemId,fieldsService:this.props.fieldsService,itemUI:this.props.itemUI,checkboxes:this.props.checkboxes,ariaMultiSelectable:this.props.ariaMultiSelectable,onItemClick:this.props.onItemClick,onFocusDomElNeeded:this.props.onFocusDomElNeeded,draggable:this.props.draggable,onPress:this.props.onPress,onDrag:this.props.onDrag,onRelease:this.props.onRelease,expandIcons:this.props.expandIcons,onExpandChange:this.props.onExpandChange,onCheckChange:this.props.onCheckChange,onContextMenu:this.props.onContextMenu,key:i,size:this.props.size,disabled:this.disabled,isRtl:this.props.isRtl}))):void 0}renderItemInPart(){return c.createElement("span",{className:s.classNames("k-treeview-leaf",{"k-focus":this.props.focusedItemId===this.itemId,"k-selected":this.fieldsSvc.selected(this.item),"k-disabled":this.disabled}),style:{touchAction:"none"},onClick:this.onItemClick,onContextMenu:this.onContextMenu},c.createElement("span",{className:"k-treeview-leaf-text"},this.props.itemUI?c.createElement(this.props.itemUI,{item:this.item,itemHierarchicalIndex:this.itemId}):this.fieldsSvc.text(this.item)))}get fieldsSvc(){return this.props.fieldsService}get itemId(){return this.props.itemId}get item(){return this.props.item}get tabIndex(){return(this.props.focusedItemId||this.props.tabbableItemId)===this.itemId?0:-1}get ariaExpanded(){return this.fieldsSvc.hasChildren(this.item)||s.hasChildren(this.item,this.fieldsSvc.getChildrenField())?!!this.fieldsSvc.expanded(this.item):void 0}get disabled(){return this.props.disabled||this.fieldsSvc.disabled(this.item)}get ariaChecked(){if(this.props.checkboxes)return this.fieldsSvc.checked(this.item)?"true":this.fieldsSvc.checkIndeterminate(this.item)?"mixed":"false"}get ariaSelected(){return this.fieldsSvc.selected(this.item)?!0:this.props.ariaMultiSelectable?this.disabled?void 0:!1:void 0}getIconProps(){const e=this.fieldsSvc.expanded(this.item);return e&&!s.hasChildren(this.item,this.fieldsSvc.getChildrenField())?{name:"loading"}:e?{name:"caret-alt-down",icon:f.caretAltDownIcon}:{name:this.props.isRtl?"caret-alt-left":"caret-alt-right",icon:this.props.isRtl?f.caretAltLeftIcon:f.caretAltRightIcon}}}O.defaultProps={position:"top"};const v=s.withIdHOC(c.forwardRef((r,e)=>{const i=c.useContext(_).call(void 0,r);return c.createElement(O,{ref:e,...i})}));v.displayName="TreeViewItem";const $={name:"@progress/kendo-react-treeview",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:0,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},{sizeMap:j}=s.kendoThemeMaps;let C=class extends c.Component{constructor(e){super(e),this.state={focusedItemId:void 0,focusedItemPublicId:void 0,tabbableItemId:s.treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID},this.fieldsSvc=null,this.allowExplicitFocus=!1,this._element=null,this.onFocusDomElNeeded=t=>{this.allowExplicitFocus&&this.focusDomItem(t)},this.onCheckChange=(t,i,n)=>{this.setFocus(n),this.dispatchCheckChange(t,i,n)},this.onExpandChange=(t,i,n)=>{this.setFocus(n),this.dispatchExpandChange(t,i,n)},this.onPress=(t,i,n)=>{this.props.onItemDragStart&&this.props.onItemDragStart.call(void 0,{target:this,item:i,itemHierarchicalIndex:n})},this.onDrag=(t,i,n)=>{const{pageX:d,pageY:l,clientX:a,clientY:u}=t;this.props.onItemDragOver&&this.props.onItemDragOver.call(void 0,{target:this,item:i,itemHierarchicalIndex:n,pageX:d,pageY:l,clientX:a,clientY:u})},this.onRelease=(t,i,n)=>{const{pageX:d,pageY:l,clientX:a,clientY:u}=t;this.props.onItemDragEnd&&this.props.onItemDragEnd.call(void 0,{target:this,item:i,itemHierarchicalIndex:n,pageX:d,pageY:l,clientX:a,clientY:u})},this.onItemClick=(t,i,n)=>{this.setFocus(n),this.dispatchItemClick(t,i,n)},this.onFocus=()=>{clearTimeout(this.blurRequest),this.state.focusedItemId===void 0&&this.data.length&&this.setFocus(this.state.tabbableItemId)},this.onBlur=()=>{clearTimeout(this.blurRequest),this.blurRequest=window.setTimeout(()=>this.setFocus(void 0),0)},this.onKeyDown=t=>{const i=this.getFocusedItem();if(i&&this.fieldsSvc){const n=y(i,this.state.focusedItemId,this.data,t.keyCode,this.fieldsSvc);n!==this.state.focusedItemId&&(t.preventDefault(),this.allowExplicitFocus=!0,this.setFocus(n)),this.dispatchEventsOnKeyDown(t,i)}},this.onContextMenu=(t,i,n)=>{if(this.props.onContextMenu){const d={target:this,syntheticEvent:t,nativeEvent:t.nativeEvent,item:i,itemID:n};this.props.onContextMenu.call(void 0,d)}},s.validatePackage($)}get treeGuid(){return this.props.id+"-accessibility-id"}get element(){return this._element}render(){this.fieldsSvc=new s.TreeFieldsService(this.props);const{size:e,className:t}=this.props;return c.createElement("div",{id:this.props.id,className:s.classNames("k-treeview",{[`k-treeview-${j[e]||e}`]:e,["k-user-select-none"]:this.props.draggable,["k-rtl"]:this.props.dir==="rtl"},t),onKeyDown:this.onKeyDown,onFocus:this.onFocus,onBlur:this.onBlur,role:"tree","aria-multiselectable":this.ariaMultiSelectable?!0:void 0,"aria-label":this.props["aria-label"],"aria-labelledby":this.props["aria-labelledby"],ref:i=>this._element=i,tabIndex:this.props.tabIndex},c.createElement("ul",{className:"k-treeview-lines k-treeview-group",role:"group"},this.data.map((i,n)=>c.createElement(v,{id:this.props.id+"-item-"+n,item:i,position:n===0?"top":n===this.data.length-1?"bot":"mid",itemId:n.toString(),treeGuid:this.treeGuid,animate:this.props.animate,focusedItemId:this.state.focusedItemId,tabbableItemId:this.state.tabbableItemId,fieldsService:this.fieldsSvc,itemUI:this.props.item,checkboxes:this.props.checkboxes,ariaMultiSelectable:this.ariaMultiSelectable,onItemClick:this.onItemClick,onFocusDomElNeeded:this.onFocusDomElNeeded,draggable:this.props.draggable,onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease,expandIcons:this.props.expandIcons,onExpandChange:this.onExpandChange,onCheckChange:this.onCheckChange,onContextMenu:this.onContextMenu,key:n,size:e,isRtl:this.props.dir==="rtl"}))))}componentDidUpdate(){this.allowExplicitFocus=!1,this.refocusDueToFocusIdField()}dispatchEventsOnKeyDown(e,t){if(this.fieldsSvc===null)return;const i=()=>this.fieldsSvc&&s.isEnabledAndAllParentsEnabled(this.state.focusedItemId,this.data,this.fieldsSvc);e.keyCode===s.Keys.left&&this.fieldsSvc.expanded(t)&&i()?this.dispatchExpandChange(e,t,this.state.focusedItemId):e.keyCode===s.Keys.right&&!this.fieldsSvc.expanded(t)&&(this.fieldsSvc.hasChildren(t)||s.hasChildren(t,this.props.childrenField))&&i()?this.dispatchExpandChange(e,t,this.state.focusedItemId):e.keyCode===s.Keys.enter&&i()?this.dispatchItemClick(e,t,this.state.focusedItemId):e.keyCode===s.Keys.space&&i()&&(e.preventDefault(),this.dispatchCheckChange(e,t,this.state.focusedItemId))}setFocus(e){if(e&&this.fieldsSvc)if(this.fieldsSvc.focusIdField){const t=this.getItemById(e);this.setState({focusedItemId:e,focusedItemPublicId:this.fieldsSvc.focusId(t)})}else this.setState({focusedItemId:e});else this.setState(t=>({focusedItemId:void 0,focusedItemPublicId:void 0,tabbableItemId:t.focusedItemId}))}getFocusedItem(){return this.state.focusedItemId?this.getItemById(this.state.focusedItemId):void 0}getItemById(e){return s.treeIdUtils.getItemById(e,this.data,this.props.childrenField||g)}dispatchCheckChange(e,t,i){s.dispatchEvent(this.props.onCheckChange,e,this,{item:t,itemHierarchicalIndex:i})}dispatchExpandChange(e,t,i){s.dispatchEvent(this.props.onExpandChange,e,this,{item:t,itemHierarchicalIndex:i})}dispatchItemClick(e,t,i){s.dispatchEvent(this.props.onItemClick,e,this,{item:t,itemHierarchicalIndex:i})}refocusDueToFocusIdField(){if(this.fieldsSvc&&this.fieldsSvc.focusIdField){const e=this.state.focusedItemPublicId;if(e){const t=this.props.getFocusHierarchicalIndex?this.props.getFocusHierarchicalIndex(e):s.resolveItemId(e,this.fieldsSvc.focusIdField,this.data,this.props.childrenField);t!==this.state.focusedItemId&&(this.allowExplicitFocus=!0,this.setState({focusedItemId:t}))}}}get ariaMultiSelectable(){return this.props["aria-multiselectable"]===!0||this.props["aria-multiselectable"]==="true"}get data(){return this.props.data||[]}focusDomItem(e){e.focus()}get guid(){return this.treeGuid}};C.propTypes={data:p.arrayOf(p.any),animate:p.bool,tabIndex:p.number,focusIdField:p.string,getHierarchicalIndexById:p.func,onExpandChange:p.func,onItemClick:p.func,expandField:p.string,selectField:p.string,childrenField:p.string,hasChildrenField:p.string,textField:p.string,disableField:p.string,item:p.any,"aria-multiselectable":(r,e,t)=>r[e]!==void 0&&r[e]!==!0&&r[e]!==!1&&r[e]!=="true"&&r[e]!=="false"?new Error("Invalid prop `"+e+"` supplied to `"+t+"`. Validation failed."):null,"aria-label":p.string,"aria-labelledby":p.string,size:p.oneOf([null,"small","medium","large"]),dir:p.string};C.defaultProps={animate:!0,expandField:N,selectField:T,hasChildrenField:H,childrenField:g,textField:B,disableField:G,checkField:x,checkIndeterminateField:P,size:"medium"};function q(r,e){if(!r||!r.length)return[];let t=r;const i=e.cloneField||"cloned",n=e.expandField||N,d=e.selectField||T,l=e.checkField||x,a=e.childrenField||g;return t=E(t,n,e.expand,i,a),t=E(t,d,e.select,i,a),t=E(t,l,e.check,i,a),X(t,a,e.check),t}function E(r,e,t,i,n){if(t){let{ids:d,field:l}=R(t,e),a=!s.isArray(t)&&t.idField?s.resolveItemsIds(d,t.idField,r,n):d;return Y(r,a,l,i,n)}else return r}function R(r,e){let t,i;return s.isArray(r)?(t=r,i=e):(t=r.ids||[],i=r.operationField||e),{ids:t,field:i}}function Y(r,e,t,i,n){let d=r;return e.forEach(l=>{d=s.updateItem(d,l,a=>M(t,a),i,n)}),d}function M(r,e){const t=(r||"").split(".");let i=e;for(let n=0;n<t.length;n++){const d=t[n];if(n===t.length-1)i[d]=!0;else if(i[d]!==void 0)i[d]={...i[d]},i=i[d];else return}}function X(r,e,t){if(t&&!s.isArray(t)&&t.applyCheckIndeterminate){const{field:i}=R(t,x),n=t.checkIndeterminateField||P;for(let d=0;d<r.length;d++){const l=r[d],a=l[e];a&&k(a,s.getNestedValue(i,l)?[]:[l],e,i,n)}}}function k(r,e,t,i,n){let d=!1;for(let l=0;l<r.length;l++){const a=r[l];if(s.getNestedValue(i,a)){if(!d)for(let u=0;u<e.length;u++)M(n,e[u]);d=!0,a[t]&&k(a[t],[],t,i,n)}else a[t]&&k(a[t],d?[a]:e.concat([a]),t,i,n)}}function Z(r,e,t,i,n,d){const l=d||g;if(!m())return u();const a=s.treeIdUtils.getItemById(r,e,l);if(!a)return u();if(!n||n===e){if(!I())return u();const o=s.removeItem(r,l,e),h=s.addItem(a,t,l,s.treeIdUtils.getDecrementedItemIdAfterRemoval(r,i),o);return n?{sourceData:h,targetData:h}:h}else{const o=s.removeItem(r,l,e),h=s.addItem(a,t,l,i,n);return{sourceData:o,targetData:h}}function u(){return n?{sourceData:e,targetData:n}:e}function I(){return!`${i}_`.startsWith(`${r}_`)}function m(){if(!e||!e.length||!r||!i||n&&!n.length)return!1;const o=!n||n===e?e:n;return!!s.treeIdUtils.getItemById(i,o,l)}}function Q(r,e,t,i={},n){if(!t||!t.length)return[];const{ids:d,idField:l}=J(e),a=l?s.getNestedValue(l,r.item):r.itemHierarchicalIndex,u=d.indexOf(a),I=u===-1,m=n||g;let o;return i.singleMode?o=I?[a]:[]:(o=d.slice(),I?o.push(a):o.splice(u,1),i.checkChildren&&ee(r.item,r.itemHierarchicalIndex,I,l,m,o),i.checkParents&&te(r.itemHierarchicalIndex,I,l,m,o,t)),s.isArray(e)?o:Object.assign({},e,{ids:o})}function J(r){let e,t;return s.isArray(r)?e=r:(e=r.ids||[],t=r.idField),{ids:e,idField:t}}function ee(r,e,t,i,n,d){s.getAllDirectIndirectChildrenIds(r,e,n,i).forEach(l=>{t&&d.indexOf(l)===-1?d.push(l):!t&&d.indexOf(l)>-1&&d.splice(d.indexOf(l),1)})}function te(r,e,t,i,n,d){const l=m();let a=l.next();e?u():I();function u(){for(;!a.done;){const{id:o,item:h}=a.value;if(n.indexOf(o)===-1&&s.areAllDirectChildrenChecked(h,o,t,i,n))n.push(o),a=l.next();else break}}function I(){for(;!a.done;){const{id:o}=a.value,h=n.indexOf(o);if(h>-1)n.splice(h,1),a=l.next();else break}}function*m(){if(t){const o=s.getAllParents(r,i,d);for(let h=o.length-1;h>-1;h--)yield{id:s.getNestedValue(t,o[h]),item:e?o[h]:void 0}}else{let o=s.treeIdUtils.getDirectParentId(r);for(;o;)yield{id:o,item:e?s.treeIdUtils.getItemById(o,d,i):void 0},o=s.treeIdUtils.getDirectParentId(o)}}}class V extends c.PureComponent{constructor(){super(...arguments),this.state={visible:!1,top:0,left:0,text:"",operationClassName:"cancel"}}render(){const e={top:this.state.top+"px",left:this.state.left+"px"};return this.state.visible&&c.createElement("div",{className:"k-header k-drag-clue",style:{...this.props.style,...e}},c.createElement(s.IconWrap,{className:s.classNames("k-drag-status"),name:this.state.operationClassName&&s.toIconName(this.state.operationClassName),icon:this.state.operationClassName==="k-i-plus"?f.plusIcon:this.state.operationClassName==="k-i-insert-up"?f.insertTopIcon:this.state.operationClassName==="k-i-insert-up"?f.insertBottomIcon:this.state.operationClassName==="k-i-insert-middle"?f.insertMiddleIcon:f.cancelIcon}),this.state.text)}show(e,t,i,n){this.setState({visible:!0,top:e,left:t,text:i,operationClassName:n})}hide(){this.setState({visible:!1})}}V.defaultProps={style:{display:"block",position:"absolute",zIndex:2e4,padding:"4px 6px"}};const D=6;class ie{constructor(e){this.event=e,this.initialized=!1,this.destItemId="",this.destTreeViewGuid="",this.itemId=e.itemHierarchicalIndex,this.treeViewGuid=e.target.guid}init(){return this.initialized||(this.setDestimationMeta(document.elementFromPoint(this.event.clientX,this.event.clientY)),this.initialized=!0),this}get isDropAllowed(){return this.initialized&&this.destItemId&&this.destTreeViewGuid?!`${this.destTreeViewGuid}_${this.destItemId}_`.startsWith(`${this.treeViewGuid}_${this.itemId}_`):!1}get destinationMeta(){return{itemHierarchicalIndex:this.destItemId,treeViewGuid:this.destTreeViewGuid}}getDropOperation(){if(this.initialized&&this.isDropAllowed){const{top:e,height:t}=this.destDomNodeWithMeta.getBoundingClientRect();return e+t-this.event.clientY<D?"after":this.event.clientY-e<D?"before":"child"}else return}setDestimationMeta(e){let t=e;for(;t&&!t[b];)t=t.parentNode;t&&t[b]&&(this.destDomNodeWithMeta=t,this.destItemId=t[b],this.destTreeViewGuid=t[U])}}const A=s.withIdHOC(C);A.displayName="KendoReactTreeView";Object.defineProperty(exports,"FieldsService",{enumerable:!0,get:()=>s.TreeFieldsService});exports.TreeView=A;exports.TreeViewClassComponent=C;exports.TreeViewDragAnalyzer=ie;exports.TreeViewDragClue=V;exports.TreeViewItemPropsContext=_;exports.getItemIdUponKeyboardNavigation=y;exports.handleTreeViewCheckChange=Q;exports.moveTreeViewItem=Z;exports.processTreeViewItems=q;
|
package/index.mjs
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
"use client";
|
|
5
6
|
import * as a from "react";
|
|
6
7
|
import * as p from "prop-types";
|
|
7
|
-
import { Keys as f, treeIdUtils as h, isEnabledAndAllParentsEnabled as
|
|
8
|
-
import { TreeFieldsService as
|
|
8
|
+
import { Keys as f, treeIdUtils as h, isEnabledAndAllParentsEnabled as R, isItemExpandedAndWithChildren as b, withIdHOC as M, classNames as g, Draggable as W, hasChildren as x, IconWrap as O, kendoThemeMaps as V, validatePackage as Y, TreeFieldsService as X, dispatchEvent as F, resolveItemId as Z, isArray as C, resolveItemsIds as q, updateItem as j, getNestedValue as v, removeItem as T, addItem as P, getAllDirectIndirectChildrenIds as Q, areAllDirectChildrenChecked as J, getAllParents as ee, toIconName as te } from "@progress/kendo-react-common";
|
|
9
|
+
import { TreeFieldsService as Ve } from "@progress/kendo-react-common";
|
|
9
10
|
import { caretAltDownIcon as ie, caretAltLeftIcon as se, caretAltRightIcon as ne, plusIcon as re, insertTopIcon as oe, insertBottomIcon as de, insertMiddleIcon as le, cancelIcon as ae } from "@progress/kendo-svg-icons";
|
|
10
11
|
import { Reveal as he } from "@progress/kendo-react-animation";
|
|
11
12
|
function ce(n, e, t, i, s) {
|
|
@@ -26,7 +27,7 @@ function ce(n, e, t, i, s) {
|
|
|
26
27
|
return e;
|
|
27
28
|
}
|
|
28
29
|
function r() {
|
|
29
|
-
return h.isIdZeroLevel(e) || s.expanded(n) &&
|
|
30
|
+
return h.isIdZeroLevel(e) || s.expanded(n) && R(e, t, s) ? e : h.getDirectParentId(e);
|
|
30
31
|
}
|
|
31
32
|
function o() {
|
|
32
33
|
return b(n, s) ? h.getFirstChildId(e) : e;
|
|
@@ -53,10 +54,10 @@ function L(n, e, t) {
|
|
|
53
54
|
const i = h.getItemById(n, e, t.getChildrenField());
|
|
54
55
|
return b(i, t) ? L(h.createId(i[t.getChildrenField()].length - 1, n), e, t) : n;
|
|
55
56
|
}
|
|
56
|
-
const
|
|
57
|
-
class
|
|
57
|
+
const U = "expanded", pe = "text", ue = "disabled", E = "items", me = "hasChildren", K = "selected", S = "checked", B = "checkIndeterminate", k = "_kendoItemId", z = "_kendoTreeViewGuid", { sizeMap: Ie } = V, fe = a.createContext((n) => n);
|
|
58
|
+
class G extends a.Component {
|
|
58
59
|
constructor() {
|
|
59
|
-
super(...arguments), this.
|
|
60
|
+
super(...arguments), this.onCheckChange = (e) => {
|
|
60
61
|
this.props.onCheckChange(e, this.item, this.itemId);
|
|
61
62
|
}, this.onExpandChange = (e) => {
|
|
62
63
|
this.props.onExpandChange(e, this.item, this.itemId);
|
|
@@ -71,7 +72,7 @@ class K extends a.Component {
|
|
|
71
72
|
}, this.onContextMenu = (e) => {
|
|
72
73
|
this.props.onContextMenu(e, this.item, this.itemId);
|
|
73
74
|
}, this.assignDraggableMeta = (e) => {
|
|
74
|
-
e && (e[k] = this.props.itemId, e[
|
|
75
|
+
e && (e[k] = this.props.itemId, e[z] = this.props.treeGuid);
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
78
|
render() {
|
|
@@ -127,12 +128,12 @@ class K extends a.Component {
|
|
|
127
128
|
),
|
|
128
129
|
"aria-label": this.item.text,
|
|
129
130
|
checked: !!this.fieldsSvc.checked(this.item),
|
|
130
|
-
id: this.
|
|
131
|
+
id: this.props.id,
|
|
131
132
|
tabIndex: -1,
|
|
132
133
|
onChange: this.onCheckChange,
|
|
133
134
|
ref: (t) => this.checkboxElement = t
|
|
134
135
|
}
|
|
135
|
-
), /* @__PURE__ */ a.createElement("label", { className: "k-checkbox-label", htmlFor: this.
|
|
136
|
+
), /* @__PURE__ */ a.createElement("label", { className: "k-checkbox-label", htmlFor: this.props.id }));
|
|
136
137
|
} else
|
|
137
138
|
return;
|
|
138
139
|
}
|
|
@@ -141,7 +142,7 @@ class K extends a.Component {
|
|
|
141
142
|
// or if the item actually has children, then render the icon.
|
|
142
143
|
(this.fieldsSvc.hasChildren(this.item) || x(this.item, this.fieldsSvc.getChildrenField())) && // Allowing the toggle-button even with `disabled=true` might be a valid case!
|
|
143
144
|
// Re-evaluate the classes bellow if such scenario occurs
|
|
144
|
-
/* @__PURE__ */ a.createElement("span", { className: g("k-treeview-toggle", { "k-disabled": this.disabled }), onClick: this.onExpandChange }, /* @__PURE__ */ a.createElement(
|
|
145
|
+
/* @__PURE__ */ a.createElement("span", { className: g("k-treeview-toggle", { "k-disabled": this.disabled }), onClick: this.onExpandChange }, /* @__PURE__ */ a.createElement(O, { ...this.getIconProps() }));
|
|
145
146
|
}
|
|
146
147
|
renderSubitemsIfApplicable() {
|
|
147
148
|
const e = this.fieldsSvc.children(this.item);
|
|
@@ -225,31 +226,31 @@ class K extends a.Component {
|
|
|
225
226
|
return e && !x(this.item, this.fieldsSvc.getChildrenField()) ? { name: "loading" } : e ? { name: "caret-alt-down", icon: ie } : { name: this.props.isRtl ? "caret-alt-left" : "caret-alt-right", icon: this.props.isRtl ? se : ne };
|
|
226
227
|
}
|
|
227
228
|
}
|
|
228
|
-
|
|
229
|
+
G.defaultProps = {
|
|
229
230
|
position: "top"
|
|
230
231
|
};
|
|
231
|
-
const y = a.forwardRef((n, e) => {
|
|
232
|
+
const y = M(a.forwardRef((n, e) => {
|
|
232
233
|
const i = a.useContext(fe).call(void 0, n);
|
|
233
234
|
return /* @__PURE__ */ a.createElement(
|
|
234
|
-
|
|
235
|
+
G,
|
|
235
236
|
{
|
|
236
237
|
ref: e,
|
|
237
238
|
...i
|
|
238
239
|
}
|
|
239
240
|
);
|
|
240
|
-
});
|
|
241
|
+
}));
|
|
241
242
|
y.displayName = "TreeViewItem";
|
|
242
243
|
const ge = {
|
|
243
244
|
name: "@progress/kendo-react-treeview",
|
|
244
245
|
productName: "KendoReact",
|
|
245
246
|
productCodes: ["KENDOUIREACT", "KENDOUICOMPLETE"],
|
|
246
|
-
publishDate:
|
|
247
|
+
publishDate: 1702313826,
|
|
247
248
|
version: "",
|
|
248
249
|
licensingDocsUrl: "https://www.telerik.com/kendo-react-ui/components/my-license/"
|
|
249
|
-
}, { sizeMap: be } =
|
|
250
|
-
class
|
|
250
|
+
}, { sizeMap: be } = V;
|
|
251
|
+
let N = class extends a.Component {
|
|
251
252
|
constructor(e) {
|
|
252
|
-
super(e), this.state = { focusedItemId: void 0, focusedItemPublicId: void 0, tabbableItemId: h.ZERO_LEVEL_ZERO_NODE_ID }, this.fieldsSvc = null, this.allowExplicitFocus = !1, this.
|
|
253
|
+
super(e), this.state = { focusedItemId: void 0, focusedItemPublicId: void 0, tabbableItemId: h.ZERO_LEVEL_ZERO_NODE_ID }, this.fieldsSvc = null, this.allowExplicitFocus = !1, this._element = null, this.onFocusDomElNeeded = (t) => {
|
|
253
254
|
this.allowExplicitFocus && this.focusDomItem(t);
|
|
254
255
|
}, this.onCheckChange = (t, i, s) => {
|
|
255
256
|
this.setFocus(s), this.dispatchCheckChange(t, i, s);
|
|
@@ -313,6 +314,9 @@ class z extends a.Component {
|
|
|
313
314
|
}
|
|
314
315
|
}, Y(ge);
|
|
315
316
|
}
|
|
317
|
+
get treeGuid() {
|
|
318
|
+
return this.props.id + "-accessibility-id";
|
|
319
|
+
}
|
|
316
320
|
/**
|
|
317
321
|
* @hidden
|
|
318
322
|
*/
|
|
@@ -328,6 +332,7 @@ class z extends a.Component {
|
|
|
328
332
|
return /* @__PURE__ */ a.createElement(
|
|
329
333
|
"div",
|
|
330
334
|
{
|
|
335
|
+
id: this.props.id,
|
|
331
336
|
className: g(
|
|
332
337
|
"k-treeview",
|
|
333
338
|
{
|
|
@@ -350,6 +355,7 @@ class z extends a.Component {
|
|
|
350
355
|
/* @__PURE__ */ a.createElement("ul", { className: "k-treeview-lines k-treeview-group", role: "group" }, this.data.map((i, s) => /* @__PURE__ */ a.createElement(
|
|
351
356
|
y,
|
|
352
357
|
{
|
|
358
|
+
id: this.props.id + "-item-" + s,
|
|
353
359
|
item: i,
|
|
354
360
|
position: s === 0 ? "top" : s === this.data.length - 1 ? "bot" : "mid",
|
|
355
361
|
itemId: s.toString(),
|
|
@@ -387,7 +393,7 @@ class z extends a.Component {
|
|
|
387
393
|
dispatchEventsOnKeyDown(e, t) {
|
|
388
394
|
if (this.fieldsSvc === null)
|
|
389
395
|
return;
|
|
390
|
-
const i = () => this.fieldsSvc &&
|
|
396
|
+
const i = () => this.fieldsSvc && R(this.state.focusedItemId, this.data, this.fieldsSvc);
|
|
391
397
|
e.keyCode === f.left && this.fieldsSvc.expanded(t) && i() ? this.dispatchExpandChange(e, t, this.state.focusedItemId) : e.keyCode === f.right && !this.fieldsSvc.expanded(t) && (this.fieldsSvc.hasChildren(t) || x(t, this.props.childrenField)) && i() ? this.dispatchExpandChange(e, t, this.state.focusedItemId) : e.keyCode === f.enter && i() ? this.dispatchItemClick(e, t, this.state.focusedItemId) : e.keyCode === f.space && i() && (e.preventDefault(), this.dispatchCheckChange(e, t, this.state.focusedItemId));
|
|
392
398
|
}
|
|
393
399
|
setFocus(e) {
|
|
@@ -443,8 +449,8 @@ class z extends a.Component {
|
|
|
443
449
|
get guid() {
|
|
444
450
|
return this.treeGuid;
|
|
445
451
|
}
|
|
446
|
-
}
|
|
447
|
-
|
|
452
|
+
};
|
|
453
|
+
N.propTypes = {
|
|
448
454
|
data: p.arrayOf(p.any),
|
|
449
455
|
animate: p.bool,
|
|
450
456
|
tabIndex: p.number,
|
|
@@ -467,23 +473,23 @@ z.propTypes = {
|
|
|
467
473
|
size: p.oneOf([null, "small", "medium", "large"]),
|
|
468
474
|
dir: p.string
|
|
469
475
|
};
|
|
470
|
-
|
|
476
|
+
N.defaultProps = {
|
|
471
477
|
animate: !0,
|
|
472
|
-
expandField:
|
|
473
|
-
selectField:
|
|
478
|
+
expandField: U,
|
|
479
|
+
selectField: K,
|
|
474
480
|
hasChildrenField: me,
|
|
475
481
|
childrenField: E,
|
|
476
482
|
textField: pe,
|
|
477
483
|
disableField: ue,
|
|
478
484
|
checkField: S,
|
|
479
|
-
checkIndeterminateField:
|
|
485
|
+
checkIndeterminateField: B,
|
|
480
486
|
size: "medium"
|
|
481
487
|
};
|
|
482
|
-
function
|
|
488
|
+
function Te(n, e) {
|
|
483
489
|
if (!n || !n.length)
|
|
484
490
|
return [];
|
|
485
491
|
let t = n;
|
|
486
|
-
const i = e.cloneField || "cloned", s = e.expandField ||
|
|
492
|
+
const i = e.cloneField || "cloned", s = e.expandField || U, r = e.selectField || K, o = e.checkField || S, d = e.childrenField || E;
|
|
487
493
|
return t = D(t, s, e.expand, i, d), t = D(t, r, e.select, i, d), t = D(t, o, e.check, i, d), Ee(t, d, e.check), t;
|
|
488
494
|
}
|
|
489
495
|
function D(n, e, t, i, s) {
|
|
@@ -518,7 +524,7 @@ function $(n, e) {
|
|
|
518
524
|
}
|
|
519
525
|
function Ee(n, e, t) {
|
|
520
526
|
if (t && !C(t) && t.applyCheckIndeterminate) {
|
|
521
|
-
const { field: i } = H(t, S), s = t.checkIndeterminateField ||
|
|
527
|
+
const { field: i } = H(t, S), s = t.checkIndeterminateField || B;
|
|
522
528
|
for (let r = 0; r < n.length; r++) {
|
|
523
529
|
const o = n[r], d = o[e];
|
|
524
530
|
d && w(
|
|
@@ -550,7 +556,7 @@ function w(n, e, t, i, s) {
|
|
|
550
556
|
);
|
|
551
557
|
}
|
|
552
558
|
}
|
|
553
|
-
function
|
|
559
|
+
function Pe(n, e, t, i, s, r) {
|
|
554
560
|
const o = r || E;
|
|
555
561
|
if (!m())
|
|
556
562
|
return u();
|
|
@@ -560,7 +566,7 @@ function Ne(n, e, t, i, s, r) {
|
|
|
560
566
|
if (!s || s === e) {
|
|
561
567
|
if (!I())
|
|
562
568
|
return u();
|
|
563
|
-
const l =
|
|
569
|
+
const l = T(n, o, e), c = P(
|
|
564
570
|
d,
|
|
565
571
|
t,
|
|
566
572
|
o,
|
|
@@ -569,7 +575,7 @@ function Ne(n, e, t, i, s, r) {
|
|
|
569
575
|
);
|
|
570
576
|
return s ? { sourceData: c, targetData: c } : c;
|
|
571
577
|
} else {
|
|
572
|
-
const l =
|
|
578
|
+
const l = T(n, o, e), c = P(d, t, o, i, s);
|
|
573
579
|
return { sourceData: l, targetData: c };
|
|
574
580
|
}
|
|
575
581
|
function u() {
|
|
@@ -585,7 +591,7 @@ function Ne(n, e, t, i, s, r) {
|
|
|
585
591
|
return !!h.getItemById(i, l, o);
|
|
586
592
|
}
|
|
587
593
|
}
|
|
588
|
-
function
|
|
594
|
+
function _e(n, e, t, i = {}, s) {
|
|
589
595
|
if (!t || !t.length)
|
|
590
596
|
return [];
|
|
591
597
|
const { ids: r, idField: o } = xe(e), d = o ? v(o, n.item) : n.itemHierarchicalIndex, u = r.indexOf(d), I = u === -1, m = s || E;
|
|
@@ -651,7 +657,7 @@ class Fe extends a.PureComponent {
|
|
|
651
657
|
render() {
|
|
652
658
|
const e = { top: this.state.top + "px", left: this.state.left + "px" };
|
|
653
659
|
return this.state.visible && /* @__PURE__ */ a.createElement("div", { className: "k-header k-drag-clue", style: { ...this.props.style, ...e } }, /* @__PURE__ */ a.createElement(
|
|
654
|
-
|
|
660
|
+
O,
|
|
655
661
|
{
|
|
656
662
|
className: g("k-drag-status"),
|
|
657
663
|
name: this.state.operationClassName && te(this.state.operationClassName),
|
|
@@ -679,7 +685,7 @@ class Fe extends a.PureComponent {
|
|
|
679
685
|
}
|
|
680
686
|
Fe.defaultProps = { style: { display: "block", position: "absolute", zIndex: 2e4, padding: "4px 6px" } };
|
|
681
687
|
const _ = 6;
|
|
682
|
-
class
|
|
688
|
+
class Re {
|
|
683
689
|
/**
|
|
684
690
|
* @param event - The event that will be analyzed.
|
|
685
691
|
*/
|
|
@@ -729,17 +735,20 @@ class _e {
|
|
|
729
735
|
let t = e;
|
|
730
736
|
for (; t && !t[k]; )
|
|
731
737
|
t = t.parentNode;
|
|
732
|
-
t && t[k] && (this.destDomNodeWithMeta = t, this.destItemId = t[k], this.destTreeViewGuid = t[
|
|
738
|
+
t && t[k] && (this.destDomNodeWithMeta = t, this.destItemId = t[k], this.destTreeViewGuid = t[z]);
|
|
733
739
|
}
|
|
734
740
|
}
|
|
741
|
+
const De = M(N);
|
|
742
|
+
De.displayName = "KendoReactTreeView";
|
|
735
743
|
export {
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
744
|
+
Ve as FieldsService,
|
|
745
|
+
De as TreeView,
|
|
746
|
+
N as TreeViewClassComponent,
|
|
747
|
+
Re as TreeViewDragAnalyzer,
|
|
739
748
|
Fe as TreeViewDragClue,
|
|
740
749
|
fe as TreeViewItemPropsContext,
|
|
741
750
|
ce as getItemIdUponKeyboardNavigation,
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
751
|
+
_e as handleTreeViewCheckChange,
|
|
752
|
+
Pe as moveTreeViewItem,
|
|
753
|
+
Te as processTreeViewItems
|
|
745
754
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-treeview",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1-develop.1",
|
|
4
4
|
"description": "React TreeView displays hierarchical data in a traditional tree structure, supports user interaction. KendoReact TreeView package",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
7
|
"homepage": "https://www.telerik.com/kendo-react-ui",
|
|
8
8
|
"main": "./index.js",
|
|
9
|
+
"module": "./index.mjs",
|
|
9
10
|
"types": "./index.d.ts",
|
|
10
11
|
"exports": {
|
|
11
12
|
".": {
|
|
@@ -16,8 +17,8 @@
|
|
|
16
17
|
"sideEffects": false,
|
|
17
18
|
"peerDependencies": {
|
|
18
19
|
"@progress/kendo-licensing": "^1.3.0",
|
|
19
|
-
"@progress/kendo-react-animation": "7.0.
|
|
20
|
-
"@progress/kendo-react-common": "7.0.
|
|
20
|
+
"@progress/kendo-react-animation": "7.0.1-develop.1",
|
|
21
|
+
"@progress/kendo-react-common": "7.0.1-develop.1",
|
|
21
22
|
"@progress/kendo-svg-icons": "^2.0.0",
|
|
22
23
|
"react": "^16.8.2 || ^17.0.0 || ^18.0.0",
|
|
23
24
|
"react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0"
|