@apia/tree 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -74,6 +74,7 @@ declare class TreeDataController<NodeProps extends Record<string, unknown> = Rec
|
|
|
74
74
|
*/
|
|
75
75
|
remove(removeNode: NodeType | TId, removeChildren?: boolean): void;
|
|
76
76
|
removeMultiple(nodes: TId[], removeChildren?: boolean): void;
|
|
77
|
+
previousNodes: TId[];
|
|
77
78
|
/**
|
|
78
79
|
* Borra todos los nodos del árbol.
|
|
79
80
|
*/
|
|
@@ -331,4 +332,3 @@ declare function useTreeData<NodeProps extends Record<string, unknown> = Record<
|
|
|
331
332
|
};
|
|
332
333
|
|
|
333
334
|
export { TDataNode, TTreeLabelRenderer, TTreeProps, _default as Tree, TreeDataController, useTreeContext, useTreeData, useTreeDataController, useTreeSelector, useTreeSelectorByName };
|
|
334
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{jsx as f,jsxs as O,Fragment as U}from"react/jsx-runtime";import{useMount as D,useDebounceFn as Se,useUnmount as me}from"ahooks";import p,{useState as ve,useEffect as be,memo as Ne}from"react";import{shallowEqual as N}from"react-redux";import{Box as m,Spinner as k}from"theme-ui";import{EventEmitter as T,PropsStore as Fe,addBoundary as Pe,getSpecificParent as _,usePropsSelector as b,formatMessage as ye,useLatest as Ee}from"@apia/util";import{IconButton as Oe}from"@apia/components";import{getVariant as A}from"@apia/theme";import{Icon as K}from"@apia/icons";import{uniqueId as we}from"lodash-es";const x=(t,e,r)=>{const o=t.propsStore.getFieldProps(e);if(e!=="root"&&(o.isDisabled||!o.isExpanded)||o.children.length===0)return null;for(let l=o.children.length-1;l>=0;l--){const s=o.children[l],d=t.propsStore.getFieldProps(s);if(!r||!d.isFiltered){const n=x(t,s,r);return n!==null?n:s}}return null},Ie=(t,e,r)=>{var o,l;const s=t.propsStore.getFieldProps(e),d=t.propsStore.getFieldProps(s.parentId);let n=(l=(o=d.children)==null?void 0:o.findIndex(i=>i===s.id))!=null?l:-1;for(;n>0;){const i=t.propsStore.getFieldProps(d.children[n-1]),a=x(t,i.id,r);if(a!==null)return a;if(!r||!i.isFiltered)return i.id;n--}return s.parentId==="root"?null:s.parentId},L=(t,e)=>{const r=t.propsStore.getFieldProps(e);for(const o of r.children)if(!t.propsStore.getFieldProps(o).isFiltered)return o;return null},P=(t,e,r,o)=>{var l,s;const d=t.propsStore.getFieldProps(e),n=t.propsStore.getFieldProps(d.parentId);let i=(s=(l=n.children)==null?void 0:l.findIndex(a=>a===d.id))!=null?s:1/0;if(!r&&d.isExpanded){if(!o&&d.children.length>0)return d.children[0];const a=L(t,d.id);if(a!==null)return a}for(;i<n.children.length-1;){const a=n.children[i+1];if(!o||!t.propsStore.getFieldProps(a).isFiltered)return a;i++}return d.parentId==="root"?null:P(t,n.id,!0,o)},_e=(t,e,r,o)=>{let l=e;do if(l=P(t,l,!1,o),l!==null){const n=t.propsStore.getFieldProps(l);if((!n.isFiltered||!o)&&n.label.toUpperCase().startsWith(r.toUpperCase()))return l}while(l!==null);const s=t.propsStore.getFieldProps(e),d=t.propsStore.getFieldProps(s.parentId).children.findIndex(n=>n===e);if(s.parentId!=="root"||d>0){const[n]=t.propsStore.getFieldProps("root").children,i=t.propsStore.getFieldProps(n);if(n&&(!o||!i.isFiltered)&&i.label.toUpperCase().startsWith(r.toUpperCase()))return n;l=n;do if(l=P(t,l,!1,o),l){const a=t.propsStore.getFieldProps(l);if((!o||!a.isFiltered)&&a.label.toUpperCase().startsWith(r.toUpperCase()))return l}while(l!==e&&l!==null)}return null},M=(t,e)=>{const r=[e];let o=e;do o=t.propsStore.getFieldProps(o).parentId,r.unshift(o);while(o!=="root");return r},xe=(t,e,r)=>{const o=M(t,e),l=M(t,r);for(let s=o.length-1;s>=0;s--){const d=l.indexOf(o[s]);if(d!==-1)return{commonAncestor:o[s],oneNodeAncestorChild:o[s+1],anotherNodeAncestorChild:l[d+1]}}return console.warn("This point should have never been reached since the root node is common to all nodes",{oneNodeId:e,anotherNodeId:r,oneNodePath:o,anotherNodePath:l}),null},R=t=>{t.state.filteredNodes.forEach(r=>{t.propsStore.updateField(r,{isFiltered:!1},{noEmit:!0})});const e=t.propsStore.getFieldProps("root").children[0];e&&t.setFocusedNode(e),t.setState({filteredNodes:[]})},B=(t,e,r="root")=>{let o=!1,l=null;const s=t.propsStore.getFieldProps(r);r!=="root"&&s.label.match(new RegExp(e,"i"))&&(t.propsStore.updateField(r,{isFiltered:!1}),o=!0,l=s.id,t.setState({filteredNodes:t.state.filteredNodes.filter(n=>n!==r)}));let d=!1;return s.children.forEach(n=>{d=B(t,e,n)||o,o=d||o,o&&!l&&(l=n)}),d&&(t.propsStore.updateField(r,{isExpanded:!0}),o&&!l&&(l=r)),o||(t.propsStore.updateField(r,{isFiltered:!0},{noEmit:!0}),t.setState({filteredNodes:[...t.state.filteredNodes,r]})),l!==null&&t.setFocusedNode(l),o},C=(t,e,r,o)=>{const l=xe(t,e,r);if(l){const{anotherNodeAncestorChild:s,commonAncestor:d,oneNodeAncestorChild:n}=l,i=t.propsStore.getFieldProps(d),a=i.children.findIndex(g=>g===n),c=i.children.findIndex(g=>g===s);let u=a>=c?r:e;const h=a<c?r:e;t.toggleNodeSelectedState(u,!0);do u=P(t,u,o),u!==null&&t.toggleNodeSelectedState(u,!0);while(u!==h&&u!==null)}};var Le=Object.defineProperty,Ce=Object.defineProperties,$e=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertySymbols,je=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable,G=(t,e,r)=>e in t?Le(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,v=(t,e)=>{for(var r in e||(e={}))je.call(e,r)&&G(t,r,e[r]);if(z)for(var r of z(e))Ue.call(e,r)&&G(t,r,e[r]);return t},H=(t,e)=>Ce(t,$e(e));const y={},W=new class extends T{emit(t,e){super.emit(t,e),y[e.name]=e.controller}};function q(t){const[e,r]=ve(y[t]);return be(()=>(y[t]!==e&&r(y[t]),W.on("addController",o=>{o.name===t&&r(o.controller)})),[]),e}function De(t){return y[t]}class V extends T{constructor(e,r,o=new Fe({logCommands:{propsStore:`treeProps_${e}`,propsLog:`treeLog_${e}`,propsSuscriptors:`propsSuscriptors_${e}`,updateProp:`updateProp_${e}`}})){var l;super(),this.name=e,this.propsStore=o,this.hasApendedFirstChild=!1,this.missingParents=[],this.nonEmittedUpdates=[],this.stateKey="treeState",this._configuration=r??{current:{emitUpdates:!0}},this._configuration.current.emitUpdates=(l=this._configuration.current.emitUpdates)!=null?l:!0,this.setState(this.getInitialState()),W.emit("addController",{name:e,controller:this}),this.initRoot()}get configuration(){return v({},this._configuration)}get state(){return this.propsStore.getFieldProps(this.stateKey)}get stateStore(){return this.propsStore}destructor(){this.propsStore.destructor()}append(e){var r,o,l,s,d,n;const i=H(v({},e),{nodeProps:(r=e.nodeProps)!=null?r:{}});if((o=this.propsStore.getFieldProps(i.id))!=null&&o.children){console.error("DUPLICATED NODE: The conflict origin is ",i,this);return}let a;i.parentId!==void 0&&(l=this.propsStore.getFieldProps(i.parentId))!=null&&l.children?a=i.parentId:(a="root",i.parentId&&this.missingParents.push(i.parentId),i.actualParentId=i.parentId,i.parentId="root"),this.propsStore.updateField(i.id,H(v({},i),{children:(s=i.children)!=null?s:[]}),{isUrgent:!0}),this.setState({length:this.state.length+1}),this.missingParents.includes(i.id)&&(this.propsStore.getFieldProps("root").children.forEach(c=>{this.propsStore.getFieldProps(c).actualParentId===i.id&&this.move(c,i.id)}),this.missingParents=this.missingParents.filter(c=>c!==i.id)),this.propsStore.updateField(a,{children:[...this.propsStore.getFieldProps(a).children,i.id]},{noEmit:!((d=this._configuration.current)!=null&&d.emitUpdates)}),(n=this._configuration.current)!=null&&n.emitUpdates||this.nonEmittedUpdates.push(a),this.hasApendedFirstChild||(this.hasApendedFirstChild=!0,this.setFocusedNode(i.id,!0)),i.isExpanded&&this.toggleNodeExpandedState(i.id,!0)}batchInit(){this.config({emitUpdates:!1}),this.setState({isLoading:!0},{isUrgent:!0})}batchFinish(){this.config({emitUpdates:!0}),setTimeout(()=>this.setState({isLoading:!1}),0)}config(e){var r;!((r=this._configuration.current)!=null&&r.emitUpdates)&&e.emitUpdates&&(this.nonEmittedUpdates.forEach(o=>this.propsStore.updateField(o,{children:[...this.propsStore.getFieldProps(o).children]})),this.nonEmittedUpdates=[]),Object.assign(this._configuration.current,e)}deselectAll(){this.state.selectedNodes.forEach(e=>this.propsStore.updateField(e,{isSelected:!1})),this.setState({selectedNodes:[]})}forceEmitUpdate(){var e;this.propsStore.updateField("root",{forceUpdate:((e=this.propsStore.getFieldProps("root").forceUpdate)!=null?e:0)+1})}getInitialState(){return{expandedNodes:[],filteredNodes:[],focusedNode:null,isLoading:!1,length:0,selectedNodes:[]}}getNodesAsArray(){const e=v({},this.propsStore.fields);return delete e[this.stateKey],delete e.root,Object.values(e)}getNodesIds(){const e=v({},this.propsStore.fields);return delete e[this.stateKey],delete e.root,Object.keys(e)}getParentId(e){return this.propsStore.getFieldProps(e).parentId}handleKey(e){var r;const o=this.state.focusedNode,l=this.propsStore.getFieldProps(o);if(e.key==="*"){if(this.state.focusedNode===null)return;this.propsStore.getFieldProps(this.propsStore.getFieldProps(this.state.focusedNode).parentId).children.forEach(s=>this.toggleNodeExpandedState(s,!0))}else if(e.key.match(/^\w$/)){const s=_e(this,o,e.key,!0);s!==null&&(this.setFocusedNode(s),this.emit("mustFocus",s))}else switch(e.code){case"Home":{const s=L(this,"root");if(s===null)return;e.shiftKey&&e.ctrlKey&&this.state.focusedNode!==null&&C(this,s,this.state.focusedNode,!0),this.setFocusedNode(s),this.emit("mustFocus",s);break}case"End":{const s=x(this,"root",!0);s!==null&&(e.shiftKey&&e.ctrlKey&&this.state.focusedNode!==null&&C(this,s,this.state.focusedNode,!0),this.setFocusedNode(s),this.emit("mustFocus",s));break}case"ArrowRight":{if(l.isLeaf)return;if(e.preventDefault(),l.isExpanded){const s=L(this,l.id);s!==null&&(this.setFocusedNode(s),this.emit("mustFocus",s))}else this.toggleNodeExpandedState(l.id,!0);break}case"ArrowLeft":{e.preventDefault(),l.isLeaf||!l.isExpanded?l.parentId!=="root"&&l.parentId!==void 0&&(this.setFocusedNode(l.parentId),this.emit("mustFocus",l.parentId)):this.toggleNodeExpandedState(l.id,!1);break}case"ArrowUp":{e.preventDefault();const s=Ie(this,l.id,!0);s!==null?(e.shiftKey&&this.toggleNodeSelectedState(s,!0),this.setFocusedNode(s),this.emit("mustFocus",s)):this.emit("onArrowUpOnFirstElement",!0);break}case"ArrowDown":{e.preventDefault();const s=P(this,l.id,!1,!0);s!==null&&(e.shiftKey&&this.toggleNodeSelectedState(s,!0),this.setFocusedNode(s),this.emit("mustFocus",s));break}case"Space":{if((r=this._configuration.current)!=null&&r.disableSelection)return;e.preventDefault(),this.toggleNodeSelectedState(l.id);break}}}isNode(e){return typeof e=="object"&&"parentId"in e}isNodeContainer(e){return typeof e=="object"&&!this.isNode(e)}includes(e){return!!this.propsStore.getFieldProps(e.id)}initRoot(){this.propsStore.updateField("root",{children:[],id:"root"},{isUrgent:!0})}move(e,r,o){var l,s;const d=this.propsStore.getFieldProps(this.propsStore.getFieldProps(e).parentId),n=this.propsStore.getFieldProps(r);if(!d){console.warn("The current node does not belong to the tree.",e);return}if(!n){console.warn("The destination node does not belong to the tree. No action will be made",r);return}if(d.children=(l=d.children)==null?void 0:l.filter(i=>i!==e),n.children||(n.children=[]),!o)n.children.push(e);else if(o.position)n.children.splice(o.position-1,0,e);else{const i=o.after?o.after:o.before,a=i&&this.isNode(i)?i.id:i,c=n.children.findIndex(h=>h===a),u=Pe(o.before!==void 0?c:c+1,0);u===-1||u===n.children.length?n.children.push(e):n.children.splice(u,0,e)}this.propsStore.updateField(d.id,{children:[...(s=d.children)!=null?s:[]]}),this.propsStore.updateField(n.id,{children:[...n.children]}),this.propsStore.updateField(e,{parentId:n.id})}remove(e,r=!0){var o,l;const s=this.isNode(e)?e.id:e,d=this.propsStore.getFieldProps(s);if(!d)return;const n=this.propsStore.getFieldProps(d.parentId);n&&this.propsStore.updateField(n.id,{children:(o=n.children)==null?void 0:o.filter(i=>i!==s)}),(l=d.children)==null||l.forEach(i=>{r?this.remove(i):this.move(i,"root")}),this.setState({selectedNodes:this.state.selectedNodes.filter(i=>i!==s),focusedNode:this.state.focusedNode===s?null:this.state.focusedNode,length:this.state.length-1}),this.propsStore.removeField(s)}removeMultiple(e,r=!0){e.forEach(o=>this.remove(o,r))}removeAll(){this.hasApendedFirstChild=!1,this.setState({focusedNode:null},{isUrgent:!0}),this.setSelectedNodes([]),this.initRoot(),Object.keys(this.propsStore.fields).forEach(e=>{["root",this.stateKey].includes(e)||this.propsStore.removeField(e)})}selectAll(){this.setState({selectedNodes:this.getNodesIds()}),this.state.selectedNodes.forEach(e=>this.propsStore.updateField(e,{isSelected:!0}))}setFocusedNode(e,r){var o,l;this.state.focusedNode!==null&&this.propsStore.updateField(this.state.focusedNode,{isFocused:!1}),this.setState({focusedNode:e}),!((o=this._configuration.current)!=null&&o.isMultiple)&&!r&&((l=this._configuration.current)==null?void 0:l.selectionMode)!=="explicit"&&this.setSelectedNodes([e]),this.propsStore.updateField(e,{isFocused:!0})}setSelectedNodes(e,r=!1){var o;(o=this._configuration.current)!=null&&o.disableSelection&&!r||(this.state.selectedNodes.forEach(l=>this.propsStore.updateField(l,{isSelected:!1})),this.setState({selectedNodes:e.filter(l=>{const{isSelectable:s}=this.propsStore.getFieldProps(l);return s!==!1&&this.propsStore.updateField(l,{isSelected:!0}),s!==!1})}))}setSelectedNodesByClickEvent(e){var r,o,l,s;if((r=this._configuration.current)!=null&&r.disableSelection)return;const d=(o=_(e.target,n=>n.getAttribute("role")==="treeitem"))==null?void 0:o.getAttribute("data-key");if(d){const n=this.propsStore.getFieldProps(d);if(n.isDisabled||n.isSelectable===!1)return;const i=[...this.state.selectedNodes],a=(l=this._configuration.current)!=null&&l.isMultiple?n.isSelected?i.filter(c=>c!==d):[...i,d]:[d];this.setState({selectedNodes:a}),i.forEach(c=>{a.includes(c)||this.propsStore.updateField(c,{isSelected:!1})}),this.propsStore.updateField(d,{isSelected:(s=this._configuration.current)!=null&&s.isMultiple?!n.isSelected:!0})}else console.warn("Cannot set selection, no treeitem found",e)}setState(e,r){this.propsStore.updateField(this.stateKey,v(v({},this.state),e),r)}toggleNodeExpandedState(e,r){var o,l,s,d,n;const i=this.propsStore.getFieldProps(e);if(!(i.isDisabled||i.isLeaf||i.isLoading))if((o=this._configuration.current)!=null&&o.onLoadData&&!i.hasLoaded)this.propsStore.updateField(e,{isLoading:!0}),(l=this._configuration.current)==null||l.onLoadData(i).finally(()=>{var a,c;this.propsStore.updateField(e,{isLoading:!1,isExpanded:!0,hasLoaded:!0}),this.setState({expandedNodes:[...this.state.expandedNodes,e]}),(c=(a=this._configuration.current)==null?void 0:a.onExpand)==null||c.call(a,this.propsStore.getFieldProps(e))});else{const{expandedNodes:a}=this.state,c=r!==void 0?r:!a.includes(e);if((s=this.propsStore.getFieldProps(e))!=null&&s.isDisabled)return;this.setState({expandedNodes:c?[...a,e]:a.filter(u=>u!==e)}),this.propsStore.updateField(e,{isExpanded:c}),(n=(d=this._configuration.current)==null?void 0:d.onExpand)==null||n.call(d,this.propsStore.getFieldProps(e))}}toggleNodeSelectedState(e,r){var o,l;if((o=this._configuration.current)!=null&&o.disableSelection)return;const s=this.propsStore.getFieldProps(e);if(s.isDisabled||s.isSelectable===!1)return;const d=r!==void 0?r:!this.state.selectedNodes.includes(e);d&&!((l=this._configuration.current)!=null&&l.isMultiple)&&this.state.selectedNodes[0]&&this.toggleNodeSelectedState(this.state.selectedNodes[0],!1),this.propsStore.updateField(e,{isSelected:d}),this.setState({selectedNodes:d?[...this.state.selectedNodes,e]:this.state.selectedNodes.filter(n=>n!==e)})}}function Y(t,e){var r;return b((r=t?.stateKey)!=null?r:"__NO__TREE__KEY__",v({propsStore:t?.propsStore},e))}function ke(t,e){var r;const o=q(t);return{selection:b((r=o?.stateKey)!=null?r:"__NO__TREE__KEY__",v({propsStore:o?.propsStore},e)),handler:o}}var Te=Object.defineProperty,Ae=Object.defineProperties,Ke=Object.getOwnPropertyDescriptors,J=Object.getOwnPropertySymbols,Me=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable,Q=(t,e,r)=>e in t?Te(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Be=(t,e)=>{for(var r in e||(e={}))Me.call(e,r)&&Q(t,r,e[r]);if(J)for(var r of J(e))Re.call(e,r)&&Q(t,r,e[r]);return t},ze=(t,e)=>Ae(t,Ke(e));function X(t,e){return`${t}__${e}`}function Ge(t,e,r,o){var l;switch(r){case"node":{const s=o,d=De(e);return ze(Be({"aria-disabled":s.isDisabled,"aria-expanded":s.isLeaf?void 0:!!s.isExpanded,"aria-label":s.label},(l=d.configuration.current)!=null&&l.disableSelection?void 0:{"aria-selected":s.isSelectable!==!1&&!s.isDisabled?!!s.isSelected:void 0}),{className:s.className,color:s.color,"data-key":s.id,id:X(e,s.id),role:"treeitem",title:s.title})}default:return{role:"tree","aria-multiselectable":o.isMultiple}}}var He=Object.defineProperty,Z=Object.getOwnPropertySymbols,We=Object.prototype.hasOwnProperty,qe=Object.prototype.propertyIsEnumerable,ee=(t,e,r)=>e in t?He(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ve=(t,e)=>{for(var r in e||(e={}))We.call(e,r)&&ee(t,r,e[r]);if(Z)for(var r of Z(e))qe.call(e,r)&&ee(t,r,e[r]);return t};const Ye=({isLoading:t,onDelete:e,searchString:r})=>!r&&!t?null:f(m,{className:`tree__searchLabelBox ${t?"isLoading":""}`,children:t?f(k,{className:"tree__loading"}):O(m,{as:"label",className:"tree__searchLabel",children:[ye(window.LBL_FILTERING_BY,{TOK1:r}),f(Oe,Ve({icon:"Close","aria-label":window.LBL_DELETE_FILTER,onClick:e,title:window.LBL_DELETE_FILTER,size:"sm"},A("icon-inherit")))]})}),te=p.createContext({});function w(){const t=p.useContext(te);if(!t)throw new Error("There is no tree context");return t}const Je=({children:t,value:e})=>{const r=p.useMemo(()=>te.Provider,[]);return f(r,{value:e,children:t})},Qe=t=>{var e;return f(K,{name:t.icon,title:"",size:(e=t.iconSize)!=null?e:"iconsm"})},Xe=t=>f(m,{as:"span",children:t.label}),Ze=({level:t})=>f(U,{children:Array(t).fill("").map((e,r)=>r).map(e=>f(m,{className:"spacer"},e))});var et=Object.defineProperty,tt=Object.defineProperties,rt=Object.getOwnPropertyDescriptors,re=Object.getOwnPropertySymbols,ot=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable,oe=(t,e,r)=>e in t?et(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,se=(t,e)=>{for(var r in e||(e={}))ot.call(e,r)&&oe(t,r,e[r]);if(re)for(var r of re(e))st.call(e,r)&&oe(t,r,e[r]);return t},it=(t,e)=>tt(t,rt(e));const lt=({level:t,treeKey:e})=>{var r,o,l;const{handler:s,treeProps:{toggleNodesOnLabelClick:d}}=w(),n=b(e,{selector:h=>h,comparator:(h,g)=>N(h,g)&&N(h?.children,g?.children),propsStore:s.propsStore}),i=p.useMemo(()=>{var h;return(h=n.labelRenderer)!=null?h:Xe},[n.labelRenderer]),a=p.useCallback(()=>{s.toggleNodeExpandedState(e)},[s,e]),c=p.useMemo(()=>typeof n.icon=="string"?Qe:n.icon,[n.icon]),u=p.useCallback(()=>{n.allowToggleExpandedFromLabel!==!1&&s.toggleNodeExpandedState(e)},[s,n.allowToggleExpandedFromLabel,e]);return O(m,{as:"span",className:`tree__nodeItemLabel ${n.isFocused?"focus":""}`,children:[f(Ze,{level:t}),(n.isLoading||n.isExpanded&&n.isLeaf!==!0||n.isLeaf===!1||((o=(r=n.children)==null?void 0:r.length)!=null?o:0)>0||n.isLeaf===void 0&&!n.hasLoaded&&((l=s.configuration.current)==null?void 0:l.onLoadData))&&f(m,{className:"tree__expanderWrapper",children:n.isLoading?f(k,{sx:{width:"iconSm",height:"iconSm"}}):f(K,{className:"tree__expandIcon",onClick:a,name:n.isExpanded?"MinusFilled":"PlusFilled",title:"",size:"iconSm"})}),n.icon&&c&&f(c,se({},n)),f(m,{as:"span",className:"tree__nodeItemLabelRenderer",onClick:d!==!1?u:void 0,children:f(i,it(se({},n),{level:t}))})]})};var nt=p.memo(lt),dt=Object.defineProperty,at=Object.defineProperties,ct=Object.getOwnPropertyDescriptors,ie=Object.getOwnPropertySymbols,pt=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,le=(t,e,r)=>e in t?dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ht=(t,e)=>{for(var r in e||(e={}))pt.call(e,r)&&le(t,r,e[r]);if(ie)for(var r of ie(e))ut.call(e,r)&&le(t,r,e[r]);return t},ft=(t,e)=>at(t,ct(e));const gt=({level:t,treeKey:e})=>{const{handler:r,name:o,forceUpdate:l,treeProps:s}=w(),d=b(e,{selector:i=>i,comparator:(i,a)=>N(i,a)&&N(i?.children,a?.children),propsStore:r.propsStore}),n=p.useMemo(()=>{var i,a;return(a=(i=d.children)==null?void 0:i.map(c=>r.propsStore.getFieldProps(c)))!=null?a:[]},[d.children,r.propsStore]);return f(U,{children:O(m,ft(ht({as:"li"},Ge(s,o,"node",d)),{children:[f(nt,{level:t,treeKey:e}),f(pe,{forceUpdate:l,role:"group",level:t,nodes:n})]}))})};var St=p.memo(gt),mt=Object.defineProperty,vt=Object.defineProperties,bt=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,ne=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,ae=(t,e,r)=>e in t?mt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Nt=(t,e)=>{for(var r in e||(e={}))ne.call(e,r)&&ae(t,r,e[r]);if(I)for(var r of I(e))de.call(e,r)&&ae(t,r,e[r]);return t},Ft=(t,e)=>vt(t,bt(e)),Pt=(t,e)=>{var r={};for(var o in t)ne.call(t,o)&&e.indexOf(o)<0&&(r[o]=t[o]);if(t!=null&&I)for(var o of I(t))e.indexOf(o)<0&&de.call(t,o)&&(r[o]=t[o]);return r};const ce=p.forwardRef((t,e)=>{var r=t,{level:o,nodes:l,forceUpdate:s}=r,d=Pt(r,["level","nodes","forceUpdate"]);const{handler:n}=w();return f(m,Ft(Nt({ref:e,as:"ul"},d),{children:l?.map(i=>{const a=n.propsStore.getFieldProps(i.id);return a?a.isFiltered?null:f(St,{level:o+1,treeKey:i.id},i.id):null})}))});ce.displayName="TreeItemChildren";var pe=p.memo(ce);function ue({name:t,treeProps:e}){const r=Ee(e),o=p.useMemo(()=>new V(t,r),[]);D(()=>{var i;(i=e?.initialNodes)==null||i.forEach(a=>o.append(a))});const l=b("root",{comparator:N,propsStore:o.propsStore,selector:i=>{var a;return{children:(a=i.children)!=null?a:[],forceUpdate:i.forceUpdate}}}),s=p.useMemo(()=>`keyHandler${we()}`,[]),d=p.useRef(null),n=p.useCallback((i,a=3)=>{var c,u;if(d.current){const h=d.current.querySelector(`[data-key="${i}"]`);if((c=d.current)==null||c.focus(),h){const g=((u=e.focusGetter)!=null?u:S=>S.querySelector(":scope > .tree__nodeItemLabel"))(h),F=o.propsStore.getFieldProps(i);(!e.focusGetter||!F.labelRenderer)&&g.classList.add("focused"),g.scrollIntoView({inline:"nearest",block:"nearest"})}else a>0&&setTimeout(()=>n(i,a-1),30)}},[o.propsStore,e.focusGetter]);return p.useEffect(()=>{const i=o.on("mustFocus",c=>n(c)),a=o.on("onArrowUpOnFirstElement",()=>{var c;return(c=e.onArrowUpOnFirstElement)==null?void 0:c.call(e)});return()=>{i(),a()}},[n,o,e]),{data:l,handler:o,keyHandler:{id:s,onKeyDown:p.useCallback(i=>{var a;if(i.key==="Enter"){const c=o.state.focusedNode;if(c){const u=o.propsStore.getFieldProps(c);(a=e.onNodeClick)==null||a.call(e,i,u)}}else o.handleKey(i)},[o,e]),onMouseDown:p.useCallback(i=>{var a;o.state.focusedNode!==null&&i.shiftKey&&(a=o.configuration.current)!=null&&a.isMultiple&&i.preventDefault()},[o.configuration,o.state.focusedNode]),onClick:p.useCallback(i=>{var a,c;if(_(i.target,h=>h.classList.contains("tree__expandIcon")))return;const u=_(i.target,h=>!!h.getAttribute("data-key"));if(u){const h=o.state.focusedNode,g=u.getAttribute("data-key"),F=o.propsStore.getFieldProps(g);(a=e.onNodeClick)==null||a.call(e,i,F),h!==null&&i.shiftKey&&(c=o.configuration.current)!=null&&c.isMultiple?C(o,h,g,!0):(o.setFocusedNode(g),o.setSelectedNodesByClickEvent(i)),g&&n(g)}},[n,o,e]),ref:d}}}var yt=Object.defineProperty,Et=Object.defineProperties,Ot=Object.getOwnPropertyDescriptors,he=Object.getOwnPropertySymbols,wt=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable,fe=(t,e,r)=>e in t?yt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,$=(t,e)=>{for(var r in e||(e={}))wt.call(e,r)&&fe(t,r,e[r]);if(he)for(var r of he(e))It.call(e,r)&&fe(t,r,e[r]);return t},_t=(t,e)=>Et(t,Ot(e));const xt=t=>{var e,r,o;const{data:l,handler:s,keyHandler:d}=ue({name:t.name,treeProps:$({},t)}),[n,i]=p.useState(!1),[a,c]=p.useState(""),u=Y(s,{selector:S=>S.isLoading});p.useEffect(()=>{i(u)},[u]);const h=Se(()=>{t.filterString!==void 0&&(i(!0),p.startTransition(()=>{c(t.filterString)}),t.filterString!==void 0&&t.filterString!==""?(R(s),B(s,t.filterString),s.forceEmitUpdate()):(R(s),s.forceEmitUpdate()),setTimeout(()=>i(!1),0))},{wait:200});p.useEffect(()=>{h.run(),t.filterString||h.flush()},[t.filterString]),b(s.stateKey,{propsStore:s.propsStore,selector:S=>S,comparator:(S,E)=>{var j;return t.onSelect&&!N(S?.selectedNodes,E?.selectedNodes)&&t.onSelect(((j=E?.selectedNodes)!=null?j:[]).map(ge=>s.propsStore.getFieldProps(ge))),!0}});const{focusedNode:g}=b(s.stateKey,{propsStore:s.propsStore,selector:S=>({focusedNode:S.focusedNode})});D(()=>{t.getHandler&&t.getHandler(s)}),me(()=>s.destructor());const F=p.useMemo(()=>({handler:s,name:t.name,forceUpdate:l.forceUpdate,focusGetter:t.focusGetter,treeProps:t}),[s,t,l.forceUpdate]);return f(Je,{value:F,children:O(m,_t($({className:`tree ${(e=t.className)!=null?e:""}`},A((r=t.variant)!=null?r:"layout.common.trees.primary")),{children:[f(Ye,{isLoading:(o=t.isLoading)!=null?o:n,onDelete:t.onDeleteFilterString,searchString:t.hideSearchLabel?"":a}),f(pe,$({"aria-activedescendant":g!==null?X(t.name,g):void 0,"aria-label":t.label,as:"ul",forceUpdate:l.forceUpdate,level:-1,nodes:p.useMemo(()=>l.children.map(S=>s.propsStore.getFieldProps(S)),[l.children,s.propsStore]),role:"tree",tabIndex:0},d))]}))})};var Lt=Ne(xt);export{Lt as Tree,V as TreeDataController,w as useTreeContext,ue as useTreeData,q as useTreeDataController,Y as useTreeSelector,ke as useTreeSelectorByName};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{jsx as f,jsxs as O,Fragment as k}from"react/jsx-runtime";import{useMount as D,useDebounceFn as ve,useUnmount as be}from"ahooks";import p,{useState as Ne,useEffect as Fe,memo as ye}from"react";import{shallowEqual as N}from"react-redux";import{Spinner as T,Box as m}from"theme-ui";import{EventEmitter as A,PropsStore as Pe,addBoundary as Ee,getSpecificParent as _,usePropsSelector as b,formatMessage as Oe,useLatest as we}from"@apia/util";import{IconButton as Ie}from"@apia/components";import{makeStyledComponent as _e,getVariant as x}from"@apia/theme";import{Icon as K}from"@apia/icons";import{uniqueId as xe}from"lodash-es";const $=(t,e,r)=>{const o=t.propsStore.getFieldProps(e);if(e!=="root"&&(o.isDisabled||!o.isExpanded)||o.children.length===0)return null;for(let l=o.children.length-1;l>=0;l--){const s=o.children[l],d=t.propsStore.getFieldProps(s);if(!r||!d.isFiltered){const i=$(t,s,r);return i!==null?i:s}}return null},$e=(t,e,r)=>{var o,l;const s=t.propsStore.getFieldProps(e),d=t.propsStore.getFieldProps(s.parentId);let i=(l=(o=d.children)==null?void 0:o.findIndex(n=>n===s.id))!=null?l:-1;for(;i>0;){const n=t.propsStore.getFieldProps(d.children[i-1]),a=$(t,n.id,r);if(a!==null)return a;if(!r||!n.isFiltered)return n.id;i--}return s.parentId==="root"?null:s.parentId},L=(t,e)=>{const r=t.propsStore.getFieldProps(e);for(const o of r.children)if(!t.propsStore.getFieldProps(o).isFiltered)return o;return null},y=(t,e,r,o)=>{var l,s;const d=t.propsStore.getFieldProps(e),i=t.propsStore.getFieldProps(d.parentId);let n=(s=(l=i.children)==null?void 0:l.findIndex(a=>a===d.id))!=null?s:1/0;if(!r&&d.isExpanded){if(!o&&d.children.length>0)return d.children[0];const a=L(t,d.id);if(a!==null)return a}for(;n<i.children.length-1;){const a=i.children[n+1];if(!o||!t.propsStore.getFieldProps(a).isFiltered)return a;n++}return d.parentId==="root"?null:y(t,i.id,!0,o)},Le=(t,e,r,o)=>{let l=e;do if(l=y(t,l,!1,o),l!==null){const i=t.propsStore.getFieldProps(l);if((!i.isFiltered||!o)&&i.label.toUpperCase().startsWith(r.toUpperCase()))return l}while(l!==null);const s=t.propsStore.getFieldProps(e),d=t.propsStore.getFieldProps(s.parentId).children.findIndex(i=>i===e);if(s.parentId!=="root"||d>0){const[i]=t.propsStore.getFieldProps("root").children,n=t.propsStore.getFieldProps(i);if(i&&(!o||!n.isFiltered)&&n.label.toUpperCase().startsWith(r.toUpperCase()))return i;l=i;do if(l=y(t,l,!1,o),l){const a=t.propsStore.getFieldProps(l);if((!o||!a.isFiltered)&&a.label.toUpperCase().startsWith(r.toUpperCase()))return l}while(l!==e&&l!==null)}return null},M=(t,e)=>{const r=[e];let o=e;do o=t.propsStore.getFieldProps(o).parentId,r.unshift(o);while(o!=="root");return r},je=(t,e,r)=>{const o=M(t,e),l=M(t,r);for(let s=o.length-1;s>=0;s--){const d=l.indexOf(o[s]);if(d!==-1)return{commonAncestor:o[s],oneNodeAncestorChild:o[s+1],anotherNodeAncestorChild:l[d+1]}}return console.warn("This point should have never been reached since the root node is common to all nodes",{oneNodeId:e,anotherNodeId:r,oneNodePath:o,anotherNodePath:l}),null},R=t=>{t.state.filteredNodes.forEach(r=>{t.propsStore.updateField(r,{isFiltered:!1},{noEmit:!0})});const e=t.propsStore.getFieldProps("root").children[0];e&&t.setFocusedNode(e),t.setState({filteredNodes:[]})},B=(t,e,r="root")=>{let o=!1,l=null;const s=t.propsStore.getFieldProps(r);r!=="root"&&s.label.match(new RegExp(e,"i"))&&(t.propsStore.updateField(r,{isFiltered:!1}),o=!0,l=s.id,t.setState({filteredNodes:t.state.filteredNodes.filter(i=>i!==r)}));let d=!1;return s.children.forEach(i=>{d=B(t,e,i)||o,o=d||o,o&&!l&&(l=i)}),d&&(t.propsStore.updateField(r,{isExpanded:!0}),o&&!l&&(l=r)),o||(t.propsStore.updateField(r,{isFiltered:!0},{noEmit:!0}),t.setState({filteredNodes:[...t.state.filteredNodes,r]})),l!==null&&t.setFocusedNode(l),o},j=(t,e,r,o)=>{const l=je(t,e,r);if(l){const{anotherNodeAncestorChild:s,commonAncestor:d,oneNodeAncestorChild:i}=l,n=t.propsStore.getFieldProps(d),a=n.children.findIndex(g=>g===i),c=n.children.findIndex(g=>g===s);let u=a>=c?r:e;const h=a<c?r:e;t.toggleNodeSelectedState(u,!0);do u=y(t,u,o),u!==null&&t.toggleNodeSelectedState(u,!0);while(u!==h&&u!==null)}};var Ce=Object.defineProperty,Ue=Object.defineProperties,ke=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertySymbols,De=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable,G=(t,e,r)=>e in t?Ce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,v=(t,e)=>{for(var r in e||(e={}))De.call(e,r)&&G(t,r,e[r]);if(z)for(var r of z(e))Te.call(e,r)&&G(t,r,e[r]);return t},H=(t,e)=>Ue(t,ke(e));const P={},W=new class extends A{emit(t,e){super.emit(t,e),P[e.name]=e.controller}};function q(t){const[e,r]=Ne(P[t]);return Fe(()=>(P[t]!==e&&r(P[t]),W.on("addController",o=>{o.name===t&&r(o.controller)})),[]),e}function Ae(t){return P[t]}class V extends A{constructor(e,r,o=new Pe({logCommands:{propsStore:`treeProps_${e}`,propsLog:`treeLog_${e}`,propsSuscriptors:`propsSuscriptors_${e}`,updateProp:`updateProp_${e}`}})){var l;super(),this.name=e,this.propsStore=o,this.hasApendedFirstChild=!1,this.missingParents=[],this.nonEmittedUpdates=[],this.stateKey="treeState",this.previousNodes=[],this._configuration=r??{current:{emitUpdates:!0}},this._configuration.current.emitUpdates=(l=this._configuration.current.emitUpdates)!=null?l:!0,this.setState(this.getInitialState()),W.emit("addController",{name:e,controller:this}),this.initRoot()}get configuration(){return v({},this._configuration)}get state(){return this.propsStore.getFieldProps(this.stateKey)}get stateStore(){return this.propsStore}destructor(){this.propsStore.destructor()}append(e){var r,o,l,s,d;const i=H(v({},e),{nodeProps:(r=e.nodeProps)!=null?r:{}});let n;i.parentId!==void 0&&(o=this.propsStore.getFieldProps(i.parentId))!=null&&o.children?n=i.parentId:(n="root",i.parentId&&this.missingParents.push(i.parentId),i.actualParentId=i.parentId,i.parentId="root"),this.propsStore.updateField(i.id,H(v({},i),{children:(l=i.children)!=null?l:[]}),{isUrgent:!0}),this.setState({length:this.state.length+1}),this.missingParents.includes(i.id)&&(this.propsStore.getFieldProps("root").children.forEach(a=>{this.propsStore.getFieldProps(a).actualParentId===i.id&&this.move(a,i.id)}),this.missingParents=this.missingParents.filter(a=>a!==i.id)),this.propsStore.updateField(n,{children:[...this.propsStore.getFieldProps(n).children,i.id]},{noEmit:!((s=this._configuration.current)!=null&&s.emitUpdates)}),(d=this._configuration.current)!=null&&d.emitUpdates||this.nonEmittedUpdates.push(n),this.hasApendedFirstChild||(this.hasApendedFirstChild=!0,this.setFocusedNode(i.id,!0)),i.isExpanded&&this.toggleNodeExpandedState(i.id,!0)}batchInit(){this.config({emitUpdates:!1}),this.setState({isLoading:!0},{isUrgent:!0})}batchFinish(){this.config({emitUpdates:!0}),setTimeout(()=>this.setState({isLoading:!1}),0);const e=[...this.getNodesIds()];this.previousNodes.filter(r=>!e.find(o=>o===r)).forEach(r=>this.remove(r)),this.config({emitUpdates:!0}),setTimeout(()=>this.setState({isLoading:!1}),0)}config(e){var r;!((r=this._configuration.current)!=null&&r.emitUpdates)&&e.emitUpdates&&(this.nonEmittedUpdates.forEach(o=>this.propsStore.updateField(o,{children:[...this.propsStore.getFieldProps(o).children]})),this.nonEmittedUpdates=[]),Object.assign(this._configuration.current,e)}deselectAll(){this.state.selectedNodes.forEach(e=>this.propsStore.updateField(e,{isSelected:!1})),this.setState({selectedNodes:[]})}forceEmitUpdate(){var e;this.propsStore.updateField("root",{forceUpdate:((e=this.propsStore.getFieldProps("root").forceUpdate)!=null?e:0)+1})}getInitialState(){return{expandedNodes:[],filteredNodes:[],focusedNode:null,isLoading:!1,length:0,selectedNodes:[]}}getNodesAsArray(){const e=v({},this.propsStore.fields);return delete e[this.stateKey],delete e.root,Object.values(e)}getNodesIds(){const e=v({},this.propsStore.fields);return delete e[this.stateKey],delete e.root,Object.keys(e)}getParentId(e){return this.propsStore.getFieldProps(e).parentId}handleKey(e){var r;const o=this.state.focusedNode,l=this.propsStore.getFieldProps(o);if(e.key==="*"){if(this.state.focusedNode===null)return;this.propsStore.getFieldProps(this.propsStore.getFieldProps(this.state.focusedNode).parentId).children.forEach(s=>this.toggleNodeExpandedState(s,!0))}else if(e.key.match(/^\w$/)){const s=Le(this,o,e.key,!0);s!==null&&(this.setFocusedNode(s),this.emit("mustFocus",s))}else switch(e.code){case"Home":{const s=L(this,"root");if(s===null)return;e.shiftKey&&e.ctrlKey&&this.state.focusedNode!==null&&j(this,s,this.state.focusedNode,!0),this.setFocusedNode(s),this.emit("mustFocus",s);break}case"End":{const s=$(this,"root",!0);s!==null&&(e.shiftKey&&e.ctrlKey&&this.state.focusedNode!==null&&j(this,s,this.state.focusedNode,!0),this.setFocusedNode(s),this.emit("mustFocus",s));break}case"ArrowRight":{if(l.isLeaf)return;if(e.preventDefault(),l.isExpanded){const s=L(this,l.id);s!==null&&(this.setFocusedNode(s),this.emit("mustFocus",s))}else this.toggleNodeExpandedState(l.id,!0);break}case"ArrowLeft":{e.preventDefault(),l.isLeaf||!l.isExpanded?l.parentId!=="root"&&l.parentId!==void 0&&(this.setFocusedNode(l.parentId),this.emit("mustFocus",l.parentId)):this.toggleNodeExpandedState(l.id,!1);break}case"ArrowUp":{e.preventDefault();const s=$e(this,l.id,!0);s!==null?(e.shiftKey&&this.toggleNodeSelectedState(s,!0),this.setFocusedNode(s),this.emit("mustFocus",s)):this.emit("onArrowUpOnFirstElement",!0);break}case"ArrowDown":{e.preventDefault();const s=y(this,l.id,!1,!0);s!==null&&(e.shiftKey&&this.toggleNodeSelectedState(s,!0),this.setFocusedNode(s),this.emit("mustFocus",s));break}case"Space":{if((r=this._configuration.current)!=null&&r.disableSelection)return;e.preventDefault(),this.toggleNodeSelectedState(l.id);break}}}isNode(e){return typeof e=="object"&&"parentId"in e}isNodeContainer(e){return typeof e=="object"&&!this.isNode(e)}includes(e){return!!this.propsStore.getFieldProps(e.id)}initRoot(){this.propsStore.updateField("root",{children:[],id:"root"},{isUrgent:!0})}move(e,r,o){var l,s;const d=this.propsStore.getFieldProps(this.propsStore.getFieldProps(e).parentId),i=this.propsStore.getFieldProps(r);if(!d){console.warn("The current node does not belong to the tree.",e);return}if(!i){console.warn("The destination node does not belong to the tree. No action will be made",r);return}if(d.children=(l=d.children)==null?void 0:l.filter(n=>n!==e),i.children||(i.children=[]),!o)i.children.push(e);else if(o.position)i.children.splice(o.position-1,0,e);else{const n=o.after?o.after:o.before,a=n&&this.isNode(n)?n.id:n,c=i.children.findIndex(h=>h===a),u=Ee(o.before!==void 0?c:c+1,0);u===-1||u===i.children.length?i.children.push(e):i.children.splice(u,0,e)}this.propsStore.updateField(d.id,{children:[...(s=d.children)!=null?s:[]]}),this.propsStore.updateField(i.id,{children:[...i.children]}),this.propsStore.updateField(e,{parentId:i.id})}remove(e,r=!0){var o,l;const s=this.isNode(e)?e.id:e,d=this.propsStore.getFieldProps(s);if(!d)return;const i=this.propsStore.getFieldProps(d.parentId);i&&this.propsStore.updateField(i.id,{children:(o=i.children)==null?void 0:o.filter(n=>n!==s)}),(l=d.children)==null||l.forEach(n=>{r?this.remove(n):this.move(n,"root")}),this.setState({selectedNodes:this.state.selectedNodes.filter(n=>n!==s),focusedNode:this.state.focusedNode===s?null:this.state.focusedNode,length:this.state.length-1}),this.propsStore.removeField(s)}removeMultiple(e,r=!0){e.forEach(o=>this.remove(o,r))}removeAll(){var e;((e=this.configuration.current)==null?void 0:e.emitUpdates)===!1?(this.previousNodes=this.getNodesIds(),this.propsStore.updateField("root",{children:[],id:"root"},{isUrgent:!0,noEmit:!0})):(this.hasApendedFirstChild=!1,this.setState({focusedNode:null},{isUrgent:!0}),this.setSelectedNodes([]),this.initRoot(),Object.keys(this.propsStore.fields).forEach(r=>{["root",this.stateKey].includes(r)||this.propsStore.removeField(r)}))}selectAll(){this.setState({selectedNodes:this.getNodesIds()}),this.state.selectedNodes.forEach(e=>this.propsStore.updateField(e,{isSelected:!0}))}setFocusedNode(e,r){var o,l;this.state.focusedNode!==null&&this.propsStore.updateField(this.state.focusedNode,{isFocused:!1}),this.setState({focusedNode:e}),!((o=this._configuration.current)!=null&&o.isMultiple)&&!r&&((l=this._configuration.current)==null?void 0:l.selectionMode)!=="explicit"&&this.setSelectedNodes([e]),this.propsStore.updateField(e,{isFocused:!0})}setSelectedNodes(e,r=!1){var o;(o=this._configuration.current)!=null&&o.disableSelection&&!r||(this.state.selectedNodes.forEach(l=>this.propsStore.updateField(l,{isSelected:!1})),this.setState({selectedNodes:e.filter(l=>{const{isSelectable:s}=this.propsStore.getFieldProps(l);return s!==!1&&this.propsStore.updateField(l,{isSelected:!0}),s!==!1})}))}setSelectedNodesByClickEvent(e){var r,o,l,s;if((r=this._configuration.current)!=null&&r.disableSelection)return;const d=(o=_(e.target,i=>i.getAttribute("role")==="treeitem"))==null?void 0:o.getAttribute("data-key");if(d){const i=this.propsStore.getFieldProps(d);if(i.isDisabled||i.isSelectable===!1)return;const n=[...this.state.selectedNodes],a=(l=this._configuration.current)!=null&&l.isMultiple?i.isSelected?n.filter(c=>c!==d):[...n,d]:[d];this.setState({selectedNodes:a}),n.forEach(c=>{a.includes(c)||this.propsStore.updateField(c,{isSelected:!1})}),this.propsStore.updateField(d,{isSelected:(s=this._configuration.current)!=null&&s.isMultiple?!i.isSelected:!0})}else console.warn("Cannot set selection, no treeitem found",e)}setState(e,r){this.propsStore.updateField(this.stateKey,v(v({},this.state),e),r)}toggleNodeExpandedState(e,r){var o,l,s,d,i;const n=this.propsStore.getFieldProps(e);if(!(n.isDisabled||n.isLeaf||n.isLoading))if((o=this._configuration.current)!=null&&o.onLoadData&&!n.hasLoaded)this.propsStore.updateField(e,{isLoading:!0}),(l=this._configuration.current)==null||l.onLoadData(n).finally(()=>{var a,c;this.propsStore.updateField(e,{isLoading:!1,isExpanded:!0,hasLoaded:!0}),this.setState({expandedNodes:[...this.state.expandedNodes,e]}),(c=(a=this._configuration.current)==null?void 0:a.onExpand)==null||c.call(a,this.propsStore.getFieldProps(e))});else{const{expandedNodes:a}=this.state,c=r!==void 0?r:!a.includes(e);if((s=this.propsStore.getFieldProps(e))!=null&&s.isDisabled)return;this.setState({expandedNodes:c?[...a,e]:a.filter(u=>u!==e)}),this.propsStore.updateField(e,{isExpanded:c}),(i=(d=this._configuration.current)==null?void 0:d.onExpand)==null||i.call(d,this.propsStore.getFieldProps(e))}}toggleNodeSelectedState(e,r){var o,l;if((o=this._configuration.current)!=null&&o.disableSelection)return;const s=this.propsStore.getFieldProps(e);if(s.isDisabled||s.isSelectable===!1)return;const d=r!==void 0?r:!this.state.selectedNodes.includes(e);d&&!((l=this._configuration.current)!=null&&l.isMultiple)&&this.state.selectedNodes[0]&&this.toggleNodeSelectedState(this.state.selectedNodes[0],!1),this.propsStore.updateField(e,{isSelected:d}),this.setState({selectedNodes:d?[...this.state.selectedNodes,e]:this.state.selectedNodes.filter(i=>i!==e)})}}function Y(t,e){var r;return b((r=t?.stateKey)!=null?r:"__NO__TREE__KEY__",v({propsStore:t?.propsStore},e))}function Ke(t,e){var r;const o=q(t);return{selection:b((r=o?.stateKey)!=null?r:"__NO__TREE__KEY__",v({propsStore:o?.propsStore},e)),handler:o}}var Me=Object.defineProperty,Re=Object.defineProperties,Be=Object.getOwnPropertyDescriptors,J=Object.getOwnPropertySymbols,ze=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable,Q=(t,e,r)=>e in t?Me(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,He=(t,e)=>{for(var r in e||(e={}))ze.call(e,r)&&Q(t,r,e[r]);if(J)for(var r of J(e))Ge.call(e,r)&&Q(t,r,e[r]);return t},We=(t,e)=>Re(t,Be(e));function X(t,e){return`${t}__${e}`}function qe(t,e,r,o){var l;switch(r){case"node":{const s=o,d=Ae(e);return We(He({"aria-disabled":s.isDisabled,"aria-expanded":s.isLeaf?void 0:!!s.isExpanded,"aria-label":s.label},(l=d.configuration.current)!=null&&l.disableSelection?void 0:{"aria-selected":s.isSelectable!==!1&&!s.isDisabled?!!s.isSelected:void 0}),{className:s.className,color:s.color,"data-key":s.id,id:X(e,s.id),role:"treeitem",title:s.title})}default:return{role:"tree","aria-multiselectable":o.isMultiple}}}var Ve=Object.defineProperty,Ye=Object.defineProperties,Je=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertySymbols,Qe=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,ee=(t,e,r)=>e in t?Ve(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ze=(t,e)=>{for(var r in e||(e={}))Qe.call(e,r)&&ee(t,r,e[r]);if(Z)for(var r of Z(e))Xe.call(e,r)&&ee(t,r,e[r]);return t},et=(t,e)=>Ye(t,Je(e));const tt={height:"iconmd",width:"iconmd",background:"palette.background.paper"},rt=_e("LoaderSpinner","layout.common.components.loaderSpinner",tt,({className:t})=>f(T,et(Ze({},x("layout.common.components.loaderSpinner")),{className:t})));var ot=Object.defineProperty,te=Object.getOwnPropertySymbols,st=Object.prototype.hasOwnProperty,it=Object.prototype.propertyIsEnumerable,re=(t,e,r)=>e in t?ot(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,lt=(t,e)=>{for(var r in e||(e={}))st.call(e,r)&&re(t,r,e[r]);if(te)for(var r of te(e))it.call(e,r)&&re(t,r,e[r]);return t};const nt=({isLoading:t,onDelete:e,searchString:r})=>!r&&!t?null:f(m,{className:`tree__searchLabelBox ${t?"isLoading":""}`,children:t?f(rt,{className:"tree__loading"}):O(m,{as:"label",className:"tree__searchLabel",children:[Oe(window.LBL_FILTERING_BY,{TOK1:r}),f(Ie,lt({icon:"Close","aria-label":window.LBL_DELETE_FILTER,onClick:e,title:window.LBL_DELETE_FILTER,size:"Sm"},x("icon-inherit")))]})}),oe=p.createContext({});function w(){const t=p.useContext(oe);if(!t)throw new Error("There is no tree context");return t}const dt=({children:t,value:e})=>{const r=p.useMemo(()=>oe.Provider,[]);return f(r,{value:e,children:t})},at=t=>{var e;return f(K,{name:t.icon,title:"",size:(e=t.iconSize)!=null?e:"iconSm"})},ct=t=>f(m,{as:"span",children:t.label}),pt=({level:t})=>f(k,{children:Array(t).fill("").map((e,r)=>r).map(e=>f(m,{className:"spacer"},e))});var ut=Object.defineProperty,ht=Object.defineProperties,ft=Object.getOwnPropertyDescriptors,se=Object.getOwnPropertySymbols,gt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,ie=(t,e,r)=>e in t?ut(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,le=(t,e)=>{for(var r in e||(e={}))gt.call(e,r)&&ie(t,r,e[r]);if(se)for(var r of se(e))St.call(e,r)&&ie(t,r,e[r]);return t},mt=(t,e)=>ht(t,ft(e));const vt=({level:t,treeKey:e})=>{var r,o,l;const{handler:s,treeProps:{toggleNodesOnLabelClick:d}}=w(),i=b(e,{selector:h=>h,comparator:(h,g)=>N(h,g)&&N(h?.children,g?.children),propsStore:s.propsStore}),n=p.useMemo(()=>{var h;return(h=i.labelRenderer)!=null?h:ct},[i.labelRenderer]),a=p.useCallback(()=>{s.toggleNodeExpandedState(e)},[s,e]),c=p.useMemo(()=>typeof i.icon=="string"?at:i.icon,[i.icon]),u=p.useCallback(()=>{i.allowToggleExpandedFromLabel!==!1&&s.toggleNodeExpandedState(e)},[s,i.allowToggleExpandedFromLabel,e]);return O(m,{as:"span",className:`tree__nodeItemLabel ${i.isFocused?"focus":""}`,children:[f(pt,{level:t}),(i.isLoading||i.isExpanded&&i.isLeaf!==!0||i.isLeaf===!1||((o=(r=i.children)==null?void 0:r.length)!=null?o:0)>0||i.isLeaf===void 0&&!i.hasLoaded&&((l=s.configuration.current)==null?void 0:l.onLoadData))&&f(m,{className:"tree__expanderWrapper",children:i.isLoading?f(T,{sx:{width:"iconSm",height:"iconSm"}}):f(K,{className:"tree__expandIcon",onClick:a,name:i.isExpanded?"MinusFilled":"PlusFilled",title:"",size:"iconSm"})}),i.icon&&c&&f(c,le({},i)),f(m,{as:"span",className:"tree__nodeItemLabelRenderer",onClick:d!==!1?u:void 0,children:f(n,mt(le({},i),{level:t}))})]})};var bt=p.memo(vt),Nt=Object.defineProperty,Ft=Object.defineProperties,yt=Object.getOwnPropertyDescriptors,ne=Object.getOwnPropertySymbols,Pt=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable,de=(t,e,r)=>e in t?Nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ot=(t,e)=>{for(var r in e||(e={}))Pt.call(e,r)&&de(t,r,e[r]);if(ne)for(var r of ne(e))Et.call(e,r)&&de(t,r,e[r]);return t},wt=(t,e)=>Ft(t,yt(e));const It=({level:t,treeKey:e})=>{const{handler:r,name:o,forceUpdate:l,treeProps:s}=w(),d=b(e,{selector:n=>n,comparator:(n,a)=>N(n,a)&&N(n?.children,a?.children),propsStore:r.propsStore}),i=p.useMemo(()=>{var n,a;return(a=(n=d.children)==null?void 0:n.map(c=>r.propsStore.getFieldProps(c)))!=null?a:[]},[d.children,r.propsStore]);return f(k,{children:O(m,wt(Ot({as:"li"},qe(s,o,"node",d)),{children:[f(bt,{level:t,treeKey:e}),f(he,{forceUpdate:l,role:"group",level:t,nodes:i})]}))})};var _t=p.memo(It),xt=Object.defineProperty,$t=Object.defineProperties,Lt=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,ae=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,pe=(t,e,r)=>e in t?xt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,jt=(t,e)=>{for(var r in e||(e={}))ae.call(e,r)&&pe(t,r,e[r]);if(I)for(var r of I(e))ce.call(e,r)&&pe(t,r,e[r]);return t},Ct=(t,e)=>$t(t,Lt(e)),Ut=(t,e)=>{var r={};for(var o in t)ae.call(t,o)&&e.indexOf(o)<0&&(r[o]=t[o]);if(t!=null&&I)for(var o of I(t))e.indexOf(o)<0&&ce.call(t,o)&&(r[o]=t[o]);return r};const ue=p.forwardRef((t,e)=>{var r=t,{level:o,nodes:l,forceUpdate:s}=r,d=Ut(r,["level","nodes","forceUpdate"]);const{handler:i}=w();return f(m,Ct(jt({ref:e,as:"ul"},d),{children:l?.map(n=>{const a=i.propsStore.getFieldProps(n.id);return a?a.isFiltered?null:f(_t,{level:o+1,treeKey:n.id},n.id):null})}))});ue.displayName="TreeItemChildren";var he=p.memo(ue);function fe({name:t,treeProps:e}){const r=we(e),o=p.useMemo(()=>new V(t,r),[]);D(()=>{var n;(n=e?.initialNodes)==null||n.forEach(a=>o.append(a))});const l=b("root",{comparator:N,propsStore:o.propsStore,selector:n=>{var a;return{children:(a=n.children)!=null?a:[],forceUpdate:n.forceUpdate}}}),s=p.useMemo(()=>`keyHandler${xe()}`,[]),d=p.useRef(null),i=p.useCallback((n,a=3)=>{var c,u;if(d.current){const h=d.current.querySelector(`[data-key="${n}"]`);if((c=d.current)==null||c.focus(),h){const g=((u=e.focusGetter)!=null?u:S=>S.querySelector(":scope > .tree__nodeItemLabel"))(h),F=o.propsStore.getFieldProps(n);(!e.focusGetter||!F.labelRenderer)&&g.classList.add("focused"),g.scrollIntoView({inline:"nearest",block:"nearest"})}else a>0&&setTimeout(()=>i(n,a-1),30)}},[o.propsStore,e.focusGetter]);return p.useEffect(()=>{const n=o.on("mustFocus",c=>i(c)),a=o.on("onArrowUpOnFirstElement",()=>{var c;return(c=e.onArrowUpOnFirstElement)==null?void 0:c.call(e)});return()=>{n(),a()}},[i,o,e]),{data:l,handler:o,keyHandler:{id:s,onKeyDown:p.useCallback(n=>{var a;if(n.key==="Enter"){const c=o.state.focusedNode;if(c){const u=o.propsStore.getFieldProps(c);(a=e.onNodeClick)==null||a.call(e,n,u)}}else o.handleKey(n)},[o,e]),onMouseDown:p.useCallback(n=>{var a;o.state.focusedNode!==null&&n.shiftKey&&(a=o.configuration.current)!=null&&a.isMultiple&&n.preventDefault()},[o.configuration,o.state.focusedNode]),onClick:p.useCallback(n=>{var a,c;if(_(n.target,h=>h.classList.contains("tree__expandIcon")))return;const u=_(n.target,h=>!!h.getAttribute("data-key"));if(u){const h=o.state.focusedNode,g=u.getAttribute("data-key"),F=o.propsStore.getFieldProps(g);(a=e.onNodeClick)==null||a.call(e,n,F),h!==null&&n.shiftKey&&(c=o.configuration.current)!=null&&c.isMultiple?j(o,h,g,!0):(o.setFocusedNode(g),o.setSelectedNodesByClickEvent(n)),g&&i(g)}},[i,o,e]),ref:d}}}var kt=Object.defineProperty,Dt=Object.defineProperties,Tt=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertySymbols,At=Object.prototype.hasOwnProperty,Kt=Object.prototype.propertyIsEnumerable,Se=(t,e,r)=>e in t?kt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,C=(t,e)=>{for(var r in e||(e={}))At.call(e,r)&&Se(t,r,e[r]);if(ge)for(var r of ge(e))Kt.call(e,r)&&Se(t,r,e[r]);return t},Mt=(t,e)=>Dt(t,Tt(e));const Rt=t=>{var e,r,o;const{data:l,handler:s,keyHandler:d}=fe({name:t.name,treeProps:C({},t)}),[i,n]=p.useState(!1),[a,c]=p.useState(""),u=Y(s,{selector:S=>S.isLoading});p.useEffect(()=>{n(u)},[u]);const h=ve(()=>{t.filterString!==void 0&&(n(!0),p.startTransition(()=>{c(t.filterString)}),t.filterString!==void 0&&t.filterString!==""?(R(s),B(s,t.filterString),s.forceEmitUpdate()):(R(s),s.forceEmitUpdate()),setTimeout(()=>n(!1),0))},{wait:200});p.useEffect(()=>{h.run(),t.filterString||h.flush()},[t.filterString]),b(s.stateKey,{propsStore:s.propsStore,selector:S=>S,comparator:(S,E)=>{var U;return t.onSelect&&!N(S?.selectedNodes,E?.selectedNodes)&&t.onSelect(((U=E?.selectedNodes)!=null?U:[]).map(me=>s.propsStore.getFieldProps(me))),!0}});const{focusedNode:g}=b(s.stateKey,{propsStore:s.propsStore,selector:S=>({focusedNode:S.focusedNode})});D(()=>{t.getHandler&&t.getHandler(s)}),be(()=>s.destructor());const F=p.useMemo(()=>({handler:s,name:t.name,forceUpdate:l.forceUpdate,focusGetter:t.focusGetter,treeProps:t}),[s,t,l.forceUpdate]);return f(dt,{value:F,children:O(m,Mt(C({className:`tree ${(e=t.className)!=null?e:""}`},x((r=t.variant)!=null?r:"layout.common.trees.primary")),{children:[f(nt,{isLoading:(o=t.isLoading)!=null?o:i,onDelete:t.onDeleteFilterString,searchString:t.hideSearchLabel?"":a}),f(he,C({"aria-activedescendant":g!==null?X(t.name,g):void 0,"aria-label":t.label,as:"ul",forceUpdate:l.forceUpdate,level:-1,nodes:p.useMemo(()=>l.children.map(S=>s.propsStore.getFieldProps(S)),[l.children,s.propsStore]),role:"tree",tabIndex:0},d))]}))})};var Bt=ye(Rt);export{Bt as Tree,V as TreeDataController,w as useTreeContext,fe as useTreeData,q as useTreeDataController,Y as useTreeSelector,Ke as useTreeSelectorByName};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/util.ts","../src/TreeDataController.ts","../src/getDomProps.ts","../src/SearchLabel.tsx","../src/TreeContext.tsx","../src/renderers/DefaultIconRenderer.tsx","../src/renderers/DefaultLabelRenderer.tsx","../src/renderers/Spacer.tsx","../src/TreeItemLabel.tsx","../src/TreeItem.tsx","../src/TreeItemChildren.tsx","../src/useTreeData.ts","../src/Tree.tsx"],"sourcesContent":["import TreeDataController from './TreeDataController';\nimport { TDataNode, TId } from './types';\n\nexport const getLastVisibleChild: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n id: TId,\n avoidFiltered?: boolean,\n) => TId | null = (handler, id, avoidFiltered) => {\n const nodeProps = handler.propsStore.getFieldProps(id);\n if (\n (id !== 'root' && (nodeProps.isDisabled || !nodeProps.isExpanded)) ||\n nodeProps.children.length === 0\n )\n return null;\n\n for (let i = nodeProps.children.length - 1; i >= 0; i--) {\n const currentId = nodeProps.children[i];\n const currentProps = handler.propsStore.getFieldProps(currentId);\n if (!avoidFiltered || !currentProps.isFiltered) {\n const lastChildrenLastChildren = getLastVisibleChild(\n handler,\n currentId,\n avoidFiltered,\n );\n return lastChildrenLastChildren !== null\n ? lastChildrenLastChildren\n : currentId;\n }\n }\n return null;\n};\n\nexport const getPreviousChild: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n id: TId,\n avoidFiltered?: boolean,\n) => TId | null = (handler, id, avoidFiltered) => {\n const nodeProps = handler.propsStore.getFieldProps(id);\n const fatherProps = handler.propsStore.getFieldProps(nodeProps.parentId);\n let childPosition =\n fatherProps.children?.findIndex((current) => current === nodeProps.id) ??\n -1;\n\n while (childPosition > 0) {\n const prevSibling = handler.propsStore.getFieldProps(\n fatherProps.children[childPosition - 1],\n );\n const prevSiblingLastChild = getLastVisibleChild(\n handler,\n prevSibling.id,\n avoidFiltered,\n );\n if (prevSiblingLastChild !== null) return prevSiblingLastChild;\n if (!avoidFiltered || !prevSibling.isFiltered) return prevSibling.id;\n\n childPosition--;\n }\n if (nodeProps.parentId === 'root') return null;\n return nodeProps.parentId;\n};\n\nexport const getFirstNonFilteredChild: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n id: TId,\n) => null | TId = (handler, id) => {\n const nodeProps = handler.propsStore.getFieldProps(id);\n // eslint-disable-next-line no-restricted-syntax\n for (const child of nodeProps.children) {\n if (!handler.propsStore.getFieldProps(child).isFiltered) return child;\n }\n return null;\n};\n\nexport const getNextChild: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n id: TId,\n avoidChildren?: boolean,\n avoidFiltered?: boolean,\n) => TId | null = (handler, id, avoidChildren, avoidFiltered) => {\n const nodeProps = handler.propsStore.getFieldProps(id);\n const fatherProps = handler.propsStore.getFieldProps(nodeProps.parentId);\n let childPosition =\n fatherProps.children?.findIndex((current) => current === nodeProps.id) ??\n Infinity;\n if (!avoidChildren && nodeProps.isExpanded) {\n if (!avoidFiltered && nodeProps.children.length > 0)\n return nodeProps.children[0];\n\n const firstNonFilteredChild = getFirstNonFilteredChild(\n handler,\n nodeProps.id,\n );\n if (firstNonFilteredChild !== null) return firstNonFilteredChild;\n }\n while (childPosition < fatherProps.children.length - 1) {\n const nextSibling = fatherProps.children[childPosition + 1];\n if (\n !avoidFiltered ||\n !handler.propsStore.getFieldProps(nextSibling).isFiltered\n )\n return nextSibling;\n childPosition++;\n }\n if (nodeProps.parentId === 'root') return null;\n return getNextChild(handler, fatherProps.id, true, avoidFiltered);\n};\n\nexport const getNextNodeWithKey: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n id: TId,\n firstKey: string,\n avoidFiltered?: boolean,\n) => TId | null = (handler, id, firstKey, avoidFiltered) => {\n let nextChildWithKey: TId | null = id;\n do {\n nextChildWithKey = getNextChild(\n handler,\n nextChildWithKey,\n false,\n avoidFiltered,\n );\n if (nextChildWithKey !== null) {\n const nodeProps = handler.propsStore.getFieldProps(nextChildWithKey);\n if (\n (!nodeProps.isFiltered || !avoidFiltered) &&\n nodeProps.label.toUpperCase().startsWith(firstKey.toUpperCase())\n )\n return nextChildWithKey;\n }\n } while (nextChildWithKey !== null);\n\n const nodeProps = handler.propsStore.getFieldProps(id);\n const positionInParent = handler.propsStore\n .getFieldProps(nodeProps.parentId)\n .children.findIndex((current) => current === id);\n\n if (nodeProps.parentId !== 'root' || positionInParent > 0) {\n const [firstChildOfTree] =\n handler.propsStore.getFieldProps('root').children;\n const firstChildProps = handler.propsStore.getFieldProps(firstChildOfTree);\n\n if (\n firstChildOfTree &&\n (!avoidFiltered || !firstChildProps.isFiltered) &&\n firstChildProps.label.toUpperCase().startsWith(firstKey.toUpperCase())\n )\n return firstChildOfTree;\n\n nextChildWithKey = firstChildOfTree;\n do {\n nextChildWithKey = getNextChild(\n handler,\n nextChildWithKey,\n false,\n avoidFiltered,\n );\n if (nextChildWithKey) {\n const currentNodeProps =\n handler.propsStore.getFieldProps(nextChildWithKey);\n if (\n (!avoidFiltered || !currentNodeProps.isFiltered) &&\n currentNodeProps.label\n .toUpperCase()\n .startsWith(firstKey.toUpperCase())\n )\n return nextChildWithKey;\n }\n } while (nextChildWithKey !== id && nextChildWithKey !== null);\n }\n\n return null;\n};\n\nexport const getNodePath: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n nodeId: TId,\n) => TId[] = (handler, nodeId) => {\n const path: TId[] = [nodeId];\n let currentStep: TId = nodeId;\n do {\n currentStep = handler.propsStore.getFieldProps(currentStep).parentId;\n path.unshift(currentStep);\n } while (currentStep !== 'root');\n return path;\n};\n\nexport const getCommonAncestor: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n oneNodeId: TId,\n anotherNodeId: TId,\n) => {\n commonAncestor: TId;\n oneNodeAncestorChild: TId;\n anotherNodeAncestorChild: TId;\n} | null = (handler, oneNodeId, anotherNodeId) => {\n const oneNodePath = getNodePath(handler, oneNodeId);\n const anotherNodePath = getNodePath(handler, anotherNodeId);\n\n for (let i = oneNodePath.length - 1; i >= 0; i--) {\n const anotherNodeIndex = anotherNodePath.indexOf(oneNodePath[i]);\n if (anotherNodeIndex !== -1)\n return {\n commonAncestor: oneNodePath[i],\n oneNodeAncestorChild: oneNodePath[i + 1],\n anotherNodeAncestorChild: anotherNodePath[anotherNodeIndex + 1],\n };\n }\n\n console.warn(\n 'This point should have never been reached since the root node is common to all nodes',\n { oneNodeId, anotherNodeId, oneNodePath, anotherNodePath },\n );\n return null;\n};\n\nexport const unfilterNodes: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n) => void = (handler) => {\n handler.state.filteredNodes.forEach((current) => {\n handler.propsStore.updateField(\n current,\n { isFiltered: false },\n { noEmit: true },\n );\n });\n\n const firstChild = handler.propsStore.getFieldProps('root').children[0];\n if (firstChild) handler.setFocusedNode(firstChild);\n handler.setState({ filteredNodes: [] });\n};\n\nexport const matchNodesAgainstString: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n searchString: string,\n nodeId?: TId,\n) => boolean = (handler, searchString, nodeId = 'root') => {\n let hasMatched = false;\n let matchNode: TId | null = null;\n const nodeProps = handler.propsStore.getFieldProps(nodeId);\n if (\n nodeId !== 'root' &&\n nodeProps.label.match(new RegExp(searchString, 'i'))\n ) {\n handler.propsStore.updateField(nodeId, { isFiltered: false });\n hasMatched = true;\n matchNode = nodeProps.id;\n handler.setState({\n filteredNodes: handler.state.filteredNodes.filter(\n (current) => current !== nodeId,\n ),\n });\n }\n let hasChildrenMatched = false;\n nodeProps.children.forEach((current) => {\n hasChildrenMatched =\n matchNodesAgainstString(handler, searchString, current) || hasMatched;\n hasMatched = hasChildrenMatched || hasMatched;\n if (hasMatched && !matchNode) matchNode = current;\n });\n if (hasChildrenMatched) {\n handler.propsStore.updateField(nodeId, { isExpanded: true });\n if (hasMatched && !matchNode) matchNode = nodeId;\n }\n if (!hasMatched) {\n handler.propsStore.updateField(\n nodeId,\n { isFiltered: true },\n { noEmit: true },\n );\n handler.setState({\n filteredNodes: [...handler.state.filteredNodes, nodeId],\n });\n }\n if (matchNode !== null) handler.setFocusedNode(matchNode);\n return hasMatched;\n};\n\nexport const selectAllNodesBetweenTwoNodes: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n oneNodeId: TId,\n anotherNodeId: TId,\n avoidFiltered?: boolean,\n) => void = (handler, oneNodeId, anotherNodeId, avoidFiltered) => {\n const commonAncestorData = getCommonAncestor(\n handler,\n oneNodeId,\n anotherNodeId,\n );\n if (commonAncestorData) {\n const { anotherNodeAncestorChild, commonAncestor, oneNodeAncestorChild } =\n commonAncestorData;\n const ancestorProps = handler.propsStore.getFieldProps(commonAncestor);\n const oneNodePosition = ancestorProps.children.findIndex(\n (current) => current === oneNodeAncestorChild,\n );\n const anotherNodePosition = ancestorProps.children.findIndex(\n (current) => current === anotherNodeAncestorChild,\n );\n\n let currentId: TId | null =\n oneNodePosition >= anotherNodePosition ? anotherNodeId : oneNodeId;\n const lastNodeId =\n oneNodePosition < anotherNodePosition ? anotherNodeId : oneNodeId;\n handler.toggleNodeSelectedState(currentId, true);\n do {\n currentId = getNextChild(handler, currentId, avoidFiltered);\n if (currentId !== null) handler.toggleNodeSelectedState(currentId, true);\n } while (currentId !== lastNodeId && currentId !== null);\n }\n};\n","/* eslint-disable @typescript-eslint/no-dynamic-delete */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable max-classes-per-file */\nimport React, { RefObject, useEffect, useState } from 'react';\nimport {\n TDataNode,\n TDataNodeContainer,\n TId,\n TTreeDataControllerConfig,\n TTreeDataControllerState,\n} from './types';\nimport {\n getFirstNonFilteredChild,\n getLastVisibleChild,\n getNextChild,\n getNextNodeWithKey,\n getPreviousChild,\n selectAllNodesBetweenTwoNodes,\n} from './util';\nimport {\n EventEmitter,\n PropsStore,\n TModify,\n TRequireOnlyOne,\n addBoundary,\n getSpecificParent,\n TUpdateFieldConfiguration,\n TPropsConfiguration,\n usePropsSelector,\n} from '@apia/util';\n\nconst trees: Record<string, TreeDataController> = {};\nconst treesRecordEmitter = new (class TreesRecordEmitter extends EventEmitter<{\n addController: { name: string; controller: TreeDataController };\n}> {\n emit<K extends 'addController'>(\n eventName: K,\n params: {\n addController: {\n name: string;\n controller: TreeDataController;\n };\n }[K],\n ): void {\n super.emit(eventName, params);\n\n trees[params.name] = params.controller;\n }\n})();\n\nexport function useTreeDataController<\n TreeType extends TreeDataController<any, any> = TreeDataController<any, any>,\n>(name: string) {\n const [controller, setDataController] = useState<TreeDataController>(\n trees[name],\n );\n\n useEffect(() => {\n if (trees[name] !== controller) setDataController(trees[name]);\n\n return treesRecordEmitter.on('addController', (ev) => {\n if (ev.name === name) setDataController(ev.controller);\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return controller as unknown as TreeType;\n}\n\nexport function getTreeDataController<TreeType = TreeDataController>(\n name: string,\n) {\n return trees[name] as unknown as TreeType;\n}\n\nexport function deleteTreeDataController(name: string) {\n delete trees[name];\n}\n\nclass TreeDataController<\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n> extends EventEmitter<{\n onArrowUpOnFirstElement: boolean;\n expandNode: NodeType;\n mustFocus: TId;\n}> {\n _configuration: RefObject<TTreeDataControllerConfig<NodeProps, NodeType>>;\n\n get configuration() {\n return { ...this._configuration };\n }\n\n hasApendedFirstChild = false;\n\n /**\n * Este array se usa para conocer los padres faltantes al momento de la\n * construcción del árbol, de forma de optimizar el proceso\n */\n missingParents: TId[] = [];\n\n nonEmittedUpdates: TId[] = [];\n\n get state() {\n return this.propsStore.getFieldProps<TTreeDataControllerState>(\n this.stateKey,\n );\n }\n\n stateKey = 'treeState';\n\n get stateStore() {\n return this.propsStore as unknown as PropsStore<TTreeDataControllerState>;\n }\n\n constructor(\n public name: string,\n configuration: RefObject<\n Partial<TTreeDataControllerConfig<NodeProps, NodeType>>\n >,\n public propsStore = new PropsStore<NodeType>({\n logCommands: {\n propsStore: `treeProps_${name}`,\n propsLog: `treeLog_${name}`,\n propsSuscriptors: `propsSuscriptors_${name}`,\n updateProp: `updateProp_${name}`,\n },\n }),\n ) {\n super();\n\n this._configuration = (configuration ?? {\n current: { emitUpdates: true },\n }) as RefObject<Partial<TTreeDataControllerConfig<NodeProps, NodeType>>>;\n\n (this._configuration.current as TTreeDataControllerConfig).emitUpdates =\n (this._configuration.current as TTreeDataControllerConfig).emitUpdates ??\n true;\n\n this.setState(this.getInitialState());\n treesRecordEmitter.emit('addController', {\n name,\n controller: this as unknown as TreeDataController,\n });\n this.initRoot();\n }\n\n destructor() {\n this.propsStore.destructor();\n }\n\n append(\n node: Omit<\n TModify<\n NodeType,\n { children?: NodeType['children']; parentId?: NodeType['parentId'] }\n >,\n 'nodeProps' | 'actualParentId'\n > &\n Partial<Pick<NodeType, 'nodeProps'>>,\n ) {\n const newNode = { ...(node as NodeType), nodeProps: node.nodeProps ?? {} };\n // Evitar que se ingresen nodos duplicados\n if (this.propsStore.getFieldProps(newNode.id)?.children) {\n console.error('DUPLICATED NODE: The conflict origin is ', newNode, this);\n return;\n }\n\n // Se busca el padre, si el padre no existe se agrega a la raíz\n let father: TId;\n if (\n newNode.parentId !== undefined &&\n this.propsStore.getFieldProps(newNode.parentId)?.children\n ) {\n father = newNode.parentId;\n } else {\n father = 'root';\n if (newNode.parentId) this.missingParents.push(newNode.parentId);\n newNode.actualParentId = newNode.parentId;\n newNode.parentId = 'root';\n }\n\n this.propsStore.updateField(\n newNode.id,\n {\n ...newNode,\n children: newNode.children ?? [],\n },\n { isUrgent: true },\n );\n this.setState({ length: this.state.length + 1 });\n\n // Se buscan elementos que estén en la raíz y sean hijos del nodo que se\n // está agregando. De esta forma al crear el árbol nos aseguramos que ningún\n // nodo quede afuera y evitamos iteraciones innecesarias\n if (this.missingParents.includes(newNode.id)) {\n this.propsStore.getFieldProps('root').children.forEach((currentChild) => {\n if (\n this.propsStore.getFieldProps(currentChild).actualParentId ===\n newNode.id\n ) {\n this.move(currentChild, newNode.id);\n }\n });\n this.missingParents = this.missingParents.filter(\n (current) => current !== newNode.id,\n );\n }\n\n // Se agrega el nodo a los hijos del padre\n this.propsStore.updateField(\n father,\n {\n children: [\n ...this.propsStore.getFieldProps(father).children,\n newNode.id,\n ],\n },\n { noEmit: !this._configuration.current?.emitUpdates },\n );\n\n if (!this._configuration.current?.emitUpdates)\n this.nonEmittedUpdates.push(father);\n\n if (!this.hasApendedFirstChild) {\n this.hasApendedFirstChild = true;\n this.setFocusedNode(newNode.id, true);\n }\n\n if (newNode.isExpanded) this.toggleNodeExpandedState(newNode.id, true);\n }\n\n /**\n * Cuando se quieren agregar muchos nodos, es conveniente llamar primero al\n * método batchInit y luego de finalizar, al método batchFinish()\n */\n batchInit() {\n this.config({ emitUpdates: false });\n this.setState({ isLoading: true }, { isUrgent: true });\n }\n\n /**\n * Cuando se quieren agregar muchos nodos, es conveniente llamar primero al\n * método batchInit y luego de finalizar, al método batchFinish()\n */\n batchFinish() {\n this.config({ emitUpdates: true });\n setTimeout(() => this.setState({ isLoading: false }), 0);\n }\n\n config(newConf: Partial<TTreeDataControllerConfig<NodeProps, NodeType>>) {\n if (!this._configuration.current?.emitUpdates && newConf.emitUpdates) {\n this.nonEmittedUpdates.forEach((current) =>\n this.propsStore.updateField(current, {\n children: [...this.propsStore.getFieldProps(current).children],\n }),\n );\n this.nonEmittedUpdates = [];\n }\n Object.assign(\n this._configuration.current as TTreeDataControllerConfig,\n newConf,\n );\n }\n\n deselectAll() {\n this.state.selectedNodes.forEach((currentId) =>\n this.propsStore.updateField(currentId, { isSelected: false }),\n );\n this.setState({ selectedNodes: [] });\n }\n\n forceEmitUpdate() {\n this.propsStore.updateField<{ forceUpdate: number }>('root', {\n forceUpdate:\n (this.propsStore.getFieldProps<{ forceUpdate: number }>('root')\n .forceUpdate ?? 0) + 1,\n });\n }\n\n getInitialState(): TTreeDataControllerState {\n return {\n expandedNodes: [],\n filteredNodes: [],\n focusedNode: null,\n isLoading: false,\n length: 0,\n selectedNodes: [],\n };\n }\n\n getNodesAsArray() {\n const allFields = { ...this.propsStore.fields };\n delete allFields[this.stateKey];\n delete allFields.root;\n return Object.values(allFields);\n }\n\n /**\n * Devuelve un array que contiene el id de todos los nodos pertenecientes al\n * árbol\n */\n getNodesIds() {\n const allFields = { ...this.propsStore.fields };\n delete allFields[this.stateKey];\n delete allFields.root;\n return Object.keys(allFields);\n }\n\n getParentId(parentId: TId) {\n return this.propsStore.getFieldProps(parentId).parentId;\n }\n\n /**\n * Este método permite controlar el comportamiento con el teclado desde fuera\n * del componente.\n */\n handleKey(ev: React.KeyboardEvent) {\n const focusedId = this.state.focusedNode as TId;\n const nodeProps = this.propsStore.getFieldProps(focusedId);\n if (ev.key === '*') {\n if (this.state.focusedNode === null) return;\n const parent = this.propsStore.getFieldProps(\n this.propsStore.getFieldProps(this.state.focusedNode).parentId,\n );\n parent.children.forEach((current) =>\n this.toggleNodeExpandedState(current, true),\n );\n } else if (ev.key.match(/^\\w$/)) {\n const nextChildWithKey = getNextNodeWithKey(\n this,\n focusedId,\n ev.key,\n true,\n );\n if (nextChildWithKey !== null) {\n this.setFocusedNode(nextChildWithKey);\n this.emit('mustFocus', nextChildWithKey);\n }\n } else\n switch (ev.code) {\n case 'Home': {\n const firstChild = getFirstNonFilteredChild(this, 'root');\n if (firstChild === null) return;\n if (ev.shiftKey && ev.ctrlKey && this.state.focusedNode !== null) {\n selectAllNodesBetweenTwoNodes(\n this,\n firstChild,\n this.state.focusedNode,\n true,\n );\n }\n this.setFocusedNode(firstChild);\n this.emit('mustFocus', firstChild);\n break;\n }\n case 'End': {\n const lastVisibleChild = getLastVisibleChild(this, 'root', true);\n if (lastVisibleChild !== null) {\n if (ev.shiftKey && ev.ctrlKey && this.state.focusedNode !== null) {\n selectAllNodesBetweenTwoNodes(\n this,\n lastVisibleChild,\n this.state.focusedNode,\n true,\n );\n }\n this.setFocusedNode(lastVisibleChild);\n this.emit('mustFocus', lastVisibleChild);\n }\n break;\n }\n case 'ArrowRight': {\n if (nodeProps.isLeaf) return;\n ev.preventDefault();\n if (nodeProps.isExpanded) {\n const firstChild = getFirstNonFilteredChild(this, nodeProps.id);\n if (firstChild !== null) {\n this.setFocusedNode(firstChild);\n this.emit('mustFocus', firstChild);\n }\n } else this.toggleNodeExpandedState(nodeProps.id, true);\n break;\n }\n case 'ArrowLeft': {\n ev.preventDefault();\n if (nodeProps.isLeaf || !nodeProps.isExpanded) {\n if (\n nodeProps.parentId !== 'root' &&\n nodeProps.parentId !== undefined\n ) {\n this.setFocusedNode(nodeProps.parentId);\n this.emit('mustFocus', nodeProps.parentId);\n }\n } else this.toggleNodeExpandedState(nodeProps.id, false);\n break;\n }\n case 'ArrowUp': {\n ev.preventDefault();\n const prevChild = getPreviousChild(this, nodeProps.id, true);\n if (prevChild !== null) {\n if (ev.shiftKey) this.toggleNodeSelectedState(prevChild, true);\n this.setFocusedNode(prevChild);\n this.emit('mustFocus', prevChild);\n } else this.emit('onArrowUpOnFirstElement', true);\n break;\n }\n case 'ArrowDown': {\n ev.preventDefault();\n const nextChild = getNextChild(this, nodeProps.id, false, true);\n if (nextChild !== null) {\n if (ev.shiftKey) this.toggleNodeSelectedState(nextChild, true);\n this.setFocusedNode(nextChild);\n this.emit('mustFocus', nextChild);\n }\n break;\n }\n case 'Space': {\n if (this._configuration.current?.disableSelection) return;\n ev.preventDefault();\n this.toggleNodeSelectedState(nodeProps.id);\n break;\n }\n default:\n break;\n }\n }\n\n isNode(\n node: NodeType | TDataNodeContainer<NodeProps> | TId,\n ): node is NodeType {\n return typeof node === 'object' && 'parentId' in node;\n }\n\n isNodeContainer(\n node: NodeType | TDataNodeContainer<NodeProps> | TId,\n ): node is TDataNodeContainer<NodeProps> {\n return typeof node === 'object' && !this.isNode(node);\n }\n\n includes(searchNode: NodeType) {\n return !!this.propsStore.getFieldProps(searchNode.id);\n }\n\n initRoot() {\n this.propsStore.updateField(\n 'root',\n { children: [], id: 'root' },\n { isUrgent: true },\n );\n }\n\n move(\n moveNode: TId,\n destinationNode: TId,\n afterOrBefore?: TRequireOnlyOne<{\n after: NodeType | TId;\n before: NodeType | TId;\n position: number;\n }>,\n ) {\n const currentFather = this.propsStore.getFieldProps(\n this.propsStore.getFieldProps(moveNode).parentId,\n );\n const newFather = this.propsStore.getFieldProps(destinationNode);\n\n if (!currentFather) {\n console.warn('The current node does not belong to the tree.', moveNode);\n return;\n }\n\n if (!newFather) {\n console.warn(\n 'The destination node does not belong to the tree. No action will be made',\n destinationNode,\n );\n return;\n }\n\n currentFather.children = currentFather.children?.filter(\n (search) => search !== moveNode,\n );\n if (!newFather.children) newFather.children = [];\n if (!afterOrBefore) newFather.children.push(moveNode);\n else if (afterOrBefore.position) {\n newFather.children.splice(afterOrBefore.position - 1, 0, moveNode);\n } else {\n const key = afterOrBefore.after\n ? afterOrBefore.after\n : afterOrBefore.before;\n\n const relatedNodeKey = key && this.isNode(key) ? key.id : key;\n const relatedNodeIndex = newFather.children.findIndex(\n (search) => search === relatedNodeKey,\n );\n\n const actualIndex = addBoundary(\n afterOrBefore.before !== undefined\n ? relatedNodeIndex\n : relatedNodeIndex + 1,\n 0,\n );\n\n if (actualIndex === -1 || actualIndex === newFather.children.length)\n newFather.children.push(moveNode);\n else newFather.children.splice(actualIndex, 0, moveNode);\n }\n\n this.propsStore.updateField(currentFather.id, {\n children: [...(currentFather.children ?? [])],\n });\n this.propsStore.updateField(newFather.id, {\n children: [...newFather.children],\n });\n this.propsStore.updateField(moveNode, {\n parentId: newFather.id,\n });\n }\n\n /**\n * Borra el nodo del árbol, y dependiendo del parámetro removeChildren, borra\n * también sus hijos.\n *\n * @param removeChildren - Si se pasa en false, los nodos hijos son movidos al root\n */\n remove(removeNode: NodeType | TId, removeChildren = true) {\n const removeNodeId = this.isNode(removeNode) ? removeNode.id : removeNode;\n\n const removingNode = this.propsStore.getFieldProps(removeNodeId);\n if (!removingNode) return;\n\n const father = this.propsStore.getFieldProps(removingNode.parentId);\n if (father) {\n this.propsStore.updateField(father.id, {\n children: father.children?.filter((search) => search !== removeNodeId),\n });\n }\n\n removingNode.children?.forEach((current) => {\n if (removeChildren) {\n this.remove(current);\n } else {\n this.move(current, 'root');\n }\n });\n\n this.setState({\n selectedNodes: this.state.selectedNodes.filter(\n (current) => current !== removeNodeId,\n ),\n focusedNode:\n this.state.focusedNode === removeNodeId ? null : this.state.focusedNode,\n length: this.state.length - 1,\n });\n this.propsStore.removeField(removeNodeId);\n }\n\n removeMultiple(nodes: TId[], removeChildren = true) {\n nodes.forEach((current) => this.remove(current, removeChildren));\n }\n\n /**\n * Borra todos los nodos del árbol.\n */\n removeAll() {\n this.hasApendedFirstChild = false;\n this.setState({ focusedNode: null }, { isUrgent: true });\n this.setSelectedNodes([]);\n this.initRoot();\n Object.keys(this.propsStore.fields).forEach((current) => {\n if (!['root', this.stateKey].includes(current))\n this.propsStore.removeField(current);\n });\n }\n\n selectAll() {\n this.setState({\n selectedNodes: this.getNodesIds(),\n });\n this.state.selectedNodes.forEach((currentId) =>\n this.propsStore.updateField(currentId, { isSelected: true }),\n );\n }\n\n setFocusedNode(key: TId, avoidSelection?: boolean) {\n if (this.state.focusedNode !== null)\n this.propsStore.updateField(this.state.focusedNode, { isFocused: false });\n this.setState({\n focusedNode: key,\n });\n if (\n !this._configuration.current?.isMultiple &&\n !avoidSelection &&\n this._configuration.current?.selectionMode !== 'explicit'\n )\n this.setSelectedNodes([key]);\n this.propsStore.updateField(key, { isFocused: true });\n }\n\n setSelectedNodes(nodes: TId[], force = false) {\n if (this._configuration.current?.disableSelection && !force) return;\n this.state.selectedNodes.forEach((current) =>\n this.propsStore.updateField(current, { isSelected: false }),\n );\n this.setState({\n selectedNodes: nodes.filter((current) => {\n const { isSelectable } = this.propsStore.getFieldProps(current);\n if (isSelectable !== false)\n this.propsStore.updateField(current, { isSelected: true });\n return isSelectable !== false;\n }),\n });\n }\n\n setSelectedNodesByClickEvent(ev: React.MouseEvent) {\n if (this._configuration.current?.disableSelection) return;\n const nodeKey = getSpecificParent(\n ev.target as HTMLElement,\n (current) => current.getAttribute('role') === 'treeitem',\n )?.getAttribute('data-key');\n if (nodeKey) {\n const nodeProps = this.propsStore.getFieldProps(nodeKey);\n if (nodeProps.isDisabled || nodeProps.isSelectable === false) return;\n\n const previousSelectionKeys = [...this.state.selectedNodes];\n // eslint-disable-next-line no-nested-ternary\n const newSelection: TId[] = this._configuration.current?.isMultiple\n ? nodeProps.isSelected\n ? previousSelectionKeys.filter((current) => current !== nodeKey)\n : [...previousSelectionKeys, nodeKey]\n : [nodeKey];\n\n this.setState({\n selectedNodes: newSelection,\n });\n\n previousSelectionKeys.forEach((current) => {\n if (!newSelection.includes(current))\n this.propsStore.updateField(current, { isSelected: false });\n });\n this.propsStore.updateField(nodeKey, {\n isSelected: this._configuration.current?.isMultiple\n ? !nodeProps.isSelected\n : true,\n });\n } else console.warn('Cannot set selection, no treeitem found', ev);\n }\n\n setState(\n updateProps: Partial<TTreeDataControllerState>,\n conf?: TUpdateFieldConfiguration,\n ) {\n this.propsStore.updateField<TTreeDataControllerState>(\n this.stateKey,\n {\n ...this.state,\n ...updateProps,\n },\n conf,\n );\n }\n\n toggleNodeExpandedState(key: TId, shouldExpand?: boolean) {\n const nodeProps = this.propsStore.getFieldProps(key);\n if (nodeProps.isDisabled || nodeProps.isLeaf || nodeProps.isLoading) return;\n\n if (this._configuration.current?.onLoadData && !nodeProps.hasLoaded) {\n this.propsStore.updateField(key, { isLoading: true });\n this._configuration.current?.onLoadData(nodeProps).finally(() => {\n this.propsStore.updateField(key, {\n isLoading: false,\n isExpanded: true,\n hasLoaded: true,\n });\n\n this.setState({\n expandedNodes: [...this.state.expandedNodes, key],\n });\n this._configuration.current?.onExpand?.(\n this.propsStore.getFieldProps(key),\n );\n });\n } else {\n const { expandedNodes } = this.state;\n const shouldExpandInner =\n shouldExpand !== undefined\n ? shouldExpand\n : !expandedNodes.includes(key);\n if (this.propsStore.getFieldProps(key)?.isDisabled) return;\n\n this.setState({\n expandedNodes: shouldExpandInner\n ? [...expandedNodes, key]\n : expandedNodes.filter((current) => current !== key),\n });\n this.propsStore.updateField(key, { isExpanded: shouldExpandInner });\n this._configuration.current?.onExpand?.(\n this.propsStore.getFieldProps(key),\n );\n }\n }\n\n toggleNodeSelectedState(key: TId, isSelected?: boolean) {\n if (this._configuration.current?.disableSelection) return;\n const nodeProps = this.propsStore.getFieldProps(key);\n if (nodeProps.isDisabled || nodeProps.isSelectable === false) return;\n\n const shouldSelect =\n isSelected !== undefined\n ? isSelected\n : !this.state.selectedNodes.includes(key);\n\n if (\n shouldSelect &&\n !this._configuration.current?.isMultiple &&\n this.state.selectedNodes[0]\n )\n this.toggleNodeSelectedState(this.state.selectedNodes[0], false);\n this.propsStore.updateField(key, { isSelected: shouldSelect });\n this.setState({\n selectedNodes: shouldSelect\n ? [...this.state.selectedNodes, key]\n : this.state.selectedNodes.filter((current) => current !== key),\n });\n }\n}\n\n/**\n * Este hook permite escuchar las props de un árbol, para ello es necesario\n * pasar el handler.\n *\n * @param handler\n * @param configuration\n * @returns\n */\nexport function useTreeSelector<\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n Selected = Record<string, unknown>,\n PropsType extends Record<string, unknown> = TTreeDataControllerState,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n configuration?: TPropsConfiguration<Selected, PropsType>,\n): Selected {\n return usePropsSelector<Selected, PropsType>(\n handler?.stateKey ?? '__NO__TREE__KEY__',\n {\n propsStore: handler?.propsStore as unknown as PropsStore<PropsType>,\n ...configuration,\n },\n );\n}\n\n/**\n * Este hook permite escuchar las props de un árbol, para ello es necesario\n * pasar el handler.\n *\n * @param handler\n * @param configuration\n * @returns\n */\nexport function useTreeSelectorByName<\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n Selected = Record<string, unknown>,\n PropsType extends Record<string, unknown> = TTreeDataControllerState,\n>(\n treeName: string,\n configuration?: TPropsConfiguration<Selected, PropsType>,\n): {\n handler: TreeDataController<NodeProps, NodeType>;\n selection: Selected;\n} {\n const handler =\n useTreeDataController<TreeDataController<NodeProps, NodeType>>(treeName);\n const selection = usePropsSelector<Selected, PropsType>(\n handler?.stateKey ?? '__NO__TREE__KEY__',\n {\n propsStore: handler?.propsStore as unknown as PropsStore<PropsType>,\n ...configuration,\n },\n );\n return { selection, handler };\n}\n\nexport default TreeDataController;\n","import { BoxProps } from 'theme-ui';\nimport { TTreeProps, TDataNode, TId } from './types';\nimport TreeDataController, {\n getTreeDataController,\n} from './TreeDataController';\n\nexport type TDomProps = Omit<BoxProps, 'as'> & Record<string, unknown>;\n\nexport function getActiveDescendantName(treeName: string, nodeId: TId) {\n return `${treeName}__${nodeId}`;\n}\n\nexport function getDomProps(\n treeProps: TTreeProps,\n treeName: string,\n type: 'tree',\n node: TTreeProps,\n controller: TreeDataController,\n): BoxProps;\nexport function getDomProps(\n treeProps: TTreeProps,\n treeName: string,\n type: 'node',\n node: TDataNode,\n): BoxProps;\nexport function getDomProps(\n _: TTreeProps,\n treeName: string,\n type: 'tree' | 'node',\n par: TDataNode | TTreeProps,\n): TDomProps {\n switch (type) {\n case 'node': {\n const node = par as TDataNode;\n const tree = getTreeDataController(treeName);\n return {\n 'aria-disabled': node.isDisabled,\n 'aria-expanded': node.isLeaf ? undefined : !!node.isExpanded,\n 'aria-label': node.label,\n ...(tree.configuration.current?.disableSelection\n ? undefined\n : {\n 'aria-selected':\n node.isSelectable !== false && !node.isDisabled\n ? !!node.isSelected\n : undefined,\n }),\n className: node.className,\n color: node.color,\n 'data-key': node.id,\n id: getActiveDescendantName(treeName, node.id),\n role: 'treeitem',\n title: node.title,\n };\n }\n default: {\n const tree = par as TTreeProps;\n return {\n role: 'tree',\n 'aria-multiselectable': tree.isMultiple,\n };\n }\n }\n}\n","import { IconButton } from '@apia/components';\nimport { getVariant } from '@apia/theme';\nimport { formatMessage } from '@apia/util';\nimport { Box, Spinner } from 'theme-ui';\n\nconst SearchLabel = ({\n isLoading: isSearching,\n onDelete,\n searchString,\n}: {\n isLoading: boolean;\n onDelete?: () => unknown;\n searchString: string;\n}) => {\n if (!searchString && !isSearching) return null;\n return (\n <Box className={`tree__searchLabelBox ${isSearching ? 'isLoading' : ''}`}>\n {isSearching ? (\n <Spinner className=\"tree__loading\" />\n ) : (\n <Box as=\"label\" className=\"tree__searchLabel\">\n {formatMessage(window.LBL_FILTERING_BY, { TOK1: searchString })}\n <IconButton\n icon=\"Close\"\n aria-label={window.LBL_DELETE_FILTER}\n onClick={onDelete}\n title={window.LBL_DELETE_FILTER}\n size=\"sm\"\n {...getVariant('icon-inherit')}\n />\n </Box>\n )}\n </Box>\n );\n};\n\nexport default SearchLabel;\n","import React from 'react';\nimport TreeDataController from './TreeDataController';\nimport { TDataNode, TTreeProps } from './types';\n\nexport type TTreeContext<\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n> = {\n forceUpdate: number;\n name: string;\n handler: TreeDataController<NodeProps, NodeType>;\n treeProps: TTreeProps<NodeProps, NodeType>;\n} & Pick<TTreeProps, 'focusGetter'>;\n\nconst TreeContext = React.createContext({} as TTreeContext);\n\nexport function useTreeContext<\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>() {\n const context = React.useContext(TreeContext);\n if (!context) throw new Error('There is no tree context');\n return context as unknown as TTreeContext<NodeProps, NodeType>;\n}\n\nexport const TreeContextProvider = <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>({\n children,\n value,\n}: {\n children: React.ReactNode;\n value: TTreeContext<NodeProps, NodeType>;\n}) => {\n const Provider = React.useMemo(() => {\n return TreeContext.Provider as unknown as React.Provider<\n TTreeContext<NodeProps, NodeType>\n >;\n }, []);\n\n return <Provider value={value}>{children}</Provider>;\n};\n\nexport default TreeContext;\n","import { Icon, TIconName } from '@apia/icons';\nimport { TTreeIconRenderer } from '../types';\n\nconst DefaultIconRenderer: TTreeIconRenderer = (props) => {\n return (\n <Icon\n name={props.icon as TIconName}\n title=\"\"\n size={props.iconSize ?? 'iconsm'}\n />\n );\n};\n\nexport default DefaultIconRenderer;\n","import { Box } from 'theme-ui';\nimport { TTreeLabelRenderer } from '../types';\n\nconst DefaultLabelRenderer: TTreeLabelRenderer = (props) => {\n return <Box as=\"span\">{props.label}</Box>;\n};\n\nexport default DefaultLabelRenderer;\n","import React from 'react';\nimport { Box } from 'theme-ui';\n\nconst Spacer: React.FunctionComponent<{ level: number }> = ({ level }) => {\n return (\n <>\n {Array(level)\n .fill('')\n .map((_, i) => i)\n .map((current) => (\n <Box className=\"spacer\" key={current} />\n ))}\n </>\n );\n};\n\nexport default Spacer;\n","import React from 'react';\nimport { shallowEqual } from 'react-redux';\nimport { Box, Spinner } from 'theme-ui';\nimport DefaultIconRenderer from './renderers/DefaultIconRenderer';\nimport DefaultLabelRenderer from './renderers/DefaultLabelRenderer';\nimport Spacer from './renderers/Spacer';\nimport { useTreeContext } from './TreeContext';\nimport { TDataNode, TId } from './types';\nimport { usePropsSelector } from '@apia/util';\nimport { Icon } from '@apia/icons';\n\nconst TreeItemLabel = ({ level, treeKey }: { level: number; treeKey: TId }) => {\n const {\n handler,\n treeProps: { toggleNodesOnLabelClick },\n } = useTreeContext();\n\n const props = usePropsSelector<TDataNode, TDataNode>(treeKey, {\n selector: (current) => current,\n comparator: (prevProps, newProps) => {\n return (\n shallowEqual(prevProps, newProps) &&\n shallowEqual(prevProps?.children, newProps?.children)\n );\n },\n propsStore: handler.propsStore,\n });\n\n const Renderer = React.useMemo(\n () => props.labelRenderer ?? DefaultLabelRenderer,\n [props.labelRenderer],\n );\n\n const handleToggle = React.useCallback(() => {\n handler.toggleNodeExpandedState(treeKey);\n }, [handler, treeKey]);\n\n const IconRenderer = React.useMemo(() => {\n return typeof props.icon === 'string' ? DefaultIconRenderer : props.icon;\n }, [props.icon]);\n\n const onClick = React.useCallback(() => {\n if (props.allowToggleExpandedFromLabel !== false)\n handler.toggleNodeExpandedState(treeKey);\n }, [handler, props.allowToggleExpandedFromLabel, treeKey]);\n\n return (\n <Box\n as=\"span\"\n className={`tree__nodeItemLabel ${props.isFocused ? 'focus' : ''}`}\n >\n <Spacer level={level} />\n {(props.isLoading ||\n (props.isExpanded && props.isLeaf !== true) ||\n props.isLeaf === false ||\n (props.children?.length ?? 0) > 0 ||\n (props.isLeaf === undefined &&\n !props.hasLoaded &&\n handler.configuration.current?.onLoadData)) && (\n <Box className=\"tree__expanderWrapper\">\n {props.isLoading ? (\n <Spinner sx={{ width: 'iconSm', height: 'iconSm' }} />\n ) : (\n <Icon\n className=\"tree__expandIcon\"\n onClick={handleToggle}\n name={props.isExpanded ? 'MinusFilled' : 'PlusFilled'}\n title=\"\"\n size=\"iconSm\"\n />\n )}\n </Box>\n )}\n {props.icon && IconRenderer && <IconRenderer {...props} />}\n <Box\n as=\"span\"\n className=\"tree__nodeItemLabelRenderer\"\n onClick={toggleNodesOnLabelClick !== false ? onClick : undefined}\n >\n <Renderer {...props} level={level} />\n </Box>\n </Box>\n );\n};\n\nexport default React.memo(TreeItemLabel);\n","import React from 'react';\nimport { shallowEqual } from 'react-redux';\nimport { Box } from 'theme-ui';\nimport { getDomProps } from './getDomProps';\nimport { useTreeContext } from './TreeContext';\nimport TreeItemChildren from './TreeItemChildren';\nimport TreeItemLabel from './TreeItemLabel';\nimport { TDataNode, TId } from './types';\nimport { usePropsSelector } from '@apia/util';\n\nconst TreeItem = ({ level, treeKey }: { level: number; treeKey: TId }) => {\n const { handler, name, forceUpdate, treeProps } = useTreeContext();\n\n const props = usePropsSelector<TDataNode, TDataNode>(treeKey, {\n selector: (current) => current,\n comparator: (prevProps, newProps) => {\n return (\n shallowEqual(prevProps, newProps) &&\n shallowEqual(prevProps?.children, newProps?.children)\n );\n },\n propsStore: handler.propsStore,\n });\n\n const nodes = React.useMemo(\n () =>\n props.children?.map((current) =>\n handler.propsStore.getFieldProps(current),\n ) ?? [],\n [props.children, handler.propsStore],\n );\n\n return (\n <>\n <Box as=\"li\" {...getDomProps(treeProps, name, 'node', props)}>\n <TreeItemLabel level={level} treeKey={treeKey} />\n <TreeItemChildren\n forceUpdate={forceUpdate}\n role=\"group\"\n level={level}\n nodes={nodes}\n />\n </Box>\n </>\n );\n};\n\nexport default React.memo(TreeItem);\n","import React from 'react';\nimport { Box, BoxProps } from 'theme-ui';\nimport { useTreeContext } from './TreeContext';\nimport TreeItem from './TreeItem';\nimport { TDataNode } from './types';\n\nconst TreeItemChildren = React.forwardRef<\n HTMLDivElement,\n {\n forceUpdate: number;\n level: number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n nodes: TDataNode<any>[];\n } & BoxProps\n>(({ level, nodes, forceUpdate, ...props }, ref) => {\n const { handler } = useTreeContext();\n\n return (\n <Box ref={ref} as=\"ul\" {...props}>\n {nodes?.map((current) => {\n const currentProps = handler.propsStore.getFieldProps(current.id);\n if (!currentProps) return null;\n\n return currentProps.isFiltered ? null : (\n <TreeItem level={level + 1} key={current.id} treeKey={current.id} />\n );\n })}\n </Box>\n );\n});\n\nTreeItemChildren.displayName = 'TreeItemChildren';\n\nexport default React.memo(TreeItemChildren);\n","import { useMount } from 'ahooks';\nimport { uniqueId } from 'lodash-es';\nimport React from 'react';\nimport { shallowEqual } from 'react-redux';\nimport TreeDataController from './TreeDataController';\nimport { TTreeProps, TDataNode, TId } from './types';\nimport { selectAllNodesBetweenTwoNodes } from './util';\nimport { getSpecificParent, useLatest, usePropsSelector } from '@apia/util';\n\ninterface IUseTreeData<\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n> {\n name: string;\n treeProps: TTreeProps<NodeProps, NodeType>;\n}\n\nexport default function useTreeData<\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>({ name, treeProps }: IUseTreeData<NodeProps, NodeType>) {\n const props = useLatest(treeProps);\n const handler = React.useMemo(\n () => new TreeDataController<NodeProps, NodeType>(name, props),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n useMount(() => {\n treeProps?.initialNodes?.forEach((current) => handler.append(current));\n });\n\n const data = usePropsSelector('root', {\n comparator: shallowEqual,\n propsStore: handler.propsStore,\n selector: (current) => ({\n children: current.children ?? [],\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n forceUpdate: (current as any).forceUpdate as number,\n }),\n });\n\n const keyHandlerId = React.useMemo(() => `keyHandler${uniqueId()}`, []);\n const keyHandlerRef = React.useRef<HTMLDivElement | null>(null);\n\n const focusOnNode = React.useCallback(\n (key: TId, retry = 3) => {\n if (keyHandlerRef.current) {\n const focusElement = keyHandlerRef.current.querySelector(\n `[data-key=\"${key}\"]`,\n ) as HTMLElement;\n keyHandlerRef.current?.focus();\n\n if (focusElement) {\n const actualFocusElement = (\n treeProps.focusGetter ??\n ((liElement: HTMLElement) =>\n liElement.querySelector(\n ':scope > .tree__nodeItemLabel',\n ) as HTMLElement)\n )(focusElement);\n\n const nodeProps = handler.propsStore.getFieldProps(key);\n\n if (!treeProps.focusGetter || !nodeProps.labelRenderer)\n actualFocusElement.classList.add('focused');\n actualFocusElement.scrollIntoView({\n inline: 'nearest',\n block: 'nearest',\n });\n } else if (retry > 0) setTimeout(() => focusOnNode(key, retry - 1), 30);\n }\n },\n [handler.propsStore, treeProps.focusGetter],\n );\n\n React.useEffect(() => {\n const unsuscribe1 = handler.on('mustFocus', (node) => focusOnNode(node));\n const unsuscribe2 = handler.on('onArrowUpOnFirstElement', () =>\n treeProps.onArrowUpOnFirstElement?.(),\n );\n\n return () => {\n unsuscribe1();\n unsuscribe2();\n };\n }, [focusOnNode, handler, treeProps]);\n\n return {\n data,\n handler,\n keyHandler: {\n id: keyHandlerId,\n onKeyDown: React.useCallback(\n (ev: React.KeyboardEvent) => {\n if (ev.key === 'Enter') {\n const key = handler.state.focusedNode;\n if (key) {\n const nodeProps = handler.propsStore.getFieldProps(key);\n treeProps.onNodeClick?.(ev, nodeProps);\n }\n } else {\n handler.handleKey(ev);\n }\n },\n [handler, treeProps],\n ),\n onMouseDown: React.useCallback(\n (ev: React.MouseEvent) => {\n const previousFocused = handler.state.focusedNode;\n if (\n previousFocused !== null &&\n ev.shiftKey &&\n handler.configuration.current?.isMultiple\n )\n ev.preventDefault();\n },\n [handler.configuration, handler.state.focusedNode],\n ),\n onClick: React.useCallback(\n (ev: React.MouseEvent) => {\n if(getSpecificParent(ev.target as HTMLElement, current => current.classList.contains('tree__expandIcon'))) return;\n \n const node = getSpecificParent(\n ev.target as HTMLElement,\n (current) => !!current.getAttribute('data-key'),\n );\n if (node) {\n const previousFocused = handler.state.focusedNode;\n const key = node.getAttribute('data-key') as string;\n\n const nodeProps = handler.propsStore.getFieldProps(key);\n treeProps.onNodeClick?.(ev, nodeProps);\n\n if (\n previousFocused !== null &&\n ev.shiftKey &&\n handler.configuration.current?.isMultiple\n ) {\n selectAllNodesBetweenTwoNodes(\n handler,\n previousFocused,\n key,\n true,\n );\n } else {\n handler.setFocusedNode(key);\n handler.setSelectedNodesByClickEvent(ev);\n }\n\n if (key) focusOnNode(key);\n }\n },\n [focusOnNode, handler, treeProps],\n ),\n ref: keyHandlerRef,\n },\n };\n}\n","import { useDebounceFn, useMount, useUnmount } from 'ahooks';\nimport React, { memo } from 'react';\nimport { shallowEqual } from 'react-redux';\nimport { Box } from 'theme-ui';\nimport { getActiveDescendantName } from './getDomProps';\nimport SearchLabel from './SearchLabel';\nimport { TTreeContext, TreeContextProvider } from './TreeContext';\nimport { useTreeSelector } from './TreeDataController';\nimport TreeItemChildren from './TreeItemChildren';\nimport { TDataNode, TId, TTreeDataControllerState, TTreeProps } from './types';\nimport useTreeData from './useTreeData';\nimport { unfilterNodes, matchNodesAgainstString } from './util';\nimport { PropsStore, usePropsSelector } from '@apia/util';\nimport { getVariant } from '@apia/theme';\n\nconst Tree = <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n props: TTreeProps<NodeProps, NodeType>,\n) => {\n const { data, handler, keyHandler } = useTreeData<NodeProps, NodeType>({\n name: props.name,\n treeProps: { ...props },\n });\n\n const [isLoading, setIsLoading] = React.useState(false);\n const [currentSearchString, setCurrentSearchString] = React.useState('');\n const isTreeLoading = useTreeSelector(handler, {\n selector: (current) => current.isLoading,\n });\n React.useEffect(() => {\n setIsLoading(isTreeLoading);\n }, [isTreeLoading]);\n\n const search = useDebounceFn(\n () => {\n if (props.filterString === undefined) return;\n setIsLoading(true);\n React.startTransition(() => {\n setCurrentSearchString(props.filterString as string);\n });\n if (props.filterString !== undefined && props.filterString !== '') {\n unfilterNodes(handler);\n matchNodesAgainstString(handler, props.filterString);\n handler.forceEmitUpdate();\n } else {\n unfilterNodes(handler);\n handler.forceEmitUpdate();\n }\n setTimeout(() => setIsLoading(false), 0);\n },\n { wait: 200 },\n );\n\n React.useEffect(() => {\n search.run();\n if (!props.filterString) search.flush();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props.filterString]);\n\n usePropsSelector<TTreeDataControllerState, TTreeDataControllerState>(\n handler.stateKey,\n {\n propsStore:\n handler.propsStore as unknown as PropsStore<TTreeDataControllerState>,\n selector: (current) => current,\n comparator: (prevProps, newProps) => {\n if (\n props.onSelect &&\n !shallowEqual(prevProps?.selectedNodes, newProps?.selectedNodes)\n ) {\n props.onSelect(\n (newProps?.selectedNodes ?? []).map((currentId) =>\n handler.propsStore.getFieldProps(currentId),\n ),\n );\n }\n return true;\n },\n },\n );\n\n const { focusedNode } = usePropsSelector<\n { focusedNode: TId | null },\n TTreeDataControllerState\n >(handler.stateKey, {\n propsStore:\n handler.propsStore as unknown as PropsStore<TTreeDataControllerState>,\n selector: (current) => ({\n focusedNode: current.focusedNode,\n }),\n });\n\n useMount(() => {\n if (props.getHandler) props.getHandler(handler);\n });\n\n useUnmount(() => handler.destructor());\n\n const contextValue = React.useMemo(() => {\n const actualValue: TTreeContext<NodeProps, NodeType> = {\n handler,\n name: props.name,\n forceUpdate: data.forceUpdate,\n focusGetter: props.focusGetter,\n treeProps: props,\n };\n return actualValue;\n }, [handler, props, data.forceUpdate]);\n\n return (\n <TreeContextProvider value={contextValue}>\n <Box\n className={`tree ${props.className ?? ''}`}\n {...getVariant(props.variant ?? 'layout.common.trees.primary')}\n >\n <SearchLabel\n isLoading={props.isLoading ?? isLoading}\n onDelete={props.onDeleteFilterString}\n searchString={props.hideSearchLabel ? '' : currentSearchString}\n />\n <TreeItemChildren\n aria-activedescendant={\n focusedNode !== null\n ? getActiveDescendantName(props.name, focusedNode)\n : undefined\n }\n aria-label={props.label}\n as=\"ul\"\n forceUpdate={data.forceUpdate}\n level={-1}\n nodes={React.useMemo(\n () =>\n data.children.map((current) =>\n handler.propsStore.getFieldProps(current),\n ),\n [data.children, handler.propsStore],\n )}\n role=\"tree\"\n tabIndex={0}\n {...keyHandler}\n />\n </Box>\n </TreeContextProvider>\n );\n};\n\nexport default memo(Tree) as typeof Tree;\n"],"names":["getLastVisibleChild","handler","id","avoidFiltered","nodeProps","i","currentId","currentProps","lastChildrenLastChildren","getPreviousChild","_a","_b","fatherProps","childPosition","current","prevSibling","prevSiblingLastChild","getFirstNonFilteredChild","child","getNextChild","avoidChildren","firstNonFilteredChild","nextSibling","getNextNodeWithKey","firstKey","nextChildWithKey","positionInParent","firstChildOfTree","firstChildProps","currentNodeProps","getNodePath","nodeId","path","currentStep","getCommonAncestor","oneNodeId","anotherNodeId","oneNodePath","anotherNodePath","anotherNodeIndex","unfilterNodes","firstChild","matchNodesAgainstString","searchString","hasMatched","matchNode","hasChildrenMatched","selectAllNodesBetweenTwoNodes","commonAncestorData","anotherNodeAncestorChild","commonAncestor","oneNodeAncestorChild","ancestorProps","oneNodePosition","anotherNodePosition","lastNodeId","D","I","b","S","E","x","T","n","e","u","g","trees","treesRecordEmitter","EventEmitter","eventName","params","useTreeDataController","name","controller","setDataController","useState","useEffect","ev","getTreeDataController","TreeDataController","configuration","propsStore","PropsStore","__spreadValues","node","_c","_d","_e","_f","newNode","__spreadProps","father","currentChild","newConf","allFields","parentId","focusedId","lastVisibleChild","prevChild","nextChild","searchNode","moveNode","destinationNode","afterOrBefore","currentFather","newFather","search","key","relatedNodeKey","relatedNodeIndex","actualIndex","addBoundary","removeNode","removeChildren","removeNodeId","removingNode","nodes","avoidSelection","force","isSelectable","nodeKey","getSpecificParent","previousSelectionKeys","newSelection","updateProps","conf","shouldExpand","expandedNodes","shouldExpandInner","isSelected","shouldSelect","useTreeSelector","usePropsSelector","useTreeSelectorByName","treeName","getActiveDescendantName","getDomProps","_","type","par","tree","SearchLabel","isSearching","onDelete","jsx","Box","Spinner","jsxs","formatMessage","IconButton","getVariant","TreeContext","React","useTreeContext","context","TreeContextProvider","children","value","Provider","DefaultIconRenderer","props","Icon","DefaultLabelRenderer","Spacer","level","Fragment","R","p","C","o","a","TreeItemLabel","treeKey","toggleNodesOnLabelClick","prevProps","newProps","shallowEqual","Renderer","handleToggle","IconRenderer","onClick","d","N","r","c","TreeItem","forceUpdate","treeProps","TreeItemChildren","I$1","ref","__objRest","useTreeData","useLatest","useMount","data","keyHandlerId","uniqueId","keyHandlerRef","focusOnNode","retry","focusElement","actualFocusElement","liElement","unsuscribe1","unsuscribe2","previousFocused","Tree","keyHandler","isLoading","setIsLoading","currentSearchString","setCurrentSearchString","isTreeLoading","useDebounceFn","focusedNode","useUnmount","contextValue","memo"],"mappings":"6lBAGa,MAAAA,EAOK,CAACC,EAASC,EAAIC,IAAkB,CAChD,MAAMC,EAAYH,EAAQ,WAAW,cAAcC,CAAE,EACrD,GACGA,IAAO,SAAWE,EAAU,YAAc,CAACA,EAAU,aACtDA,EAAU,SAAS,SAAW,EAE9B,OAAO,KAET,QAASC,EAAID,EAAU,SAAS,OAAS,EAAGC,GAAK,EAAGA,IAAK,CACvD,MAAMC,EAAYF,EAAU,SAASC,CAAC,EAChCE,EAAeN,EAAQ,WAAW,cAAcK,CAAS,EAC/D,GAAI,CAACH,GAAiB,CAAC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ClB,YAAanC,EAAM,YACnB,UAAWA,CACb,GAEC,CAAChK,EAASgK,EAAOmC,EAAK,WAAW,CAAC,EAErC,OACEnD,EAACW,GAAA,CAAoB,MAAO8D,EAC1B,SAAAtE,EAACF,EAAAvD,GAAAP,EAAA,CACC,UAAW,SAAQ1E,EAAAuJ,EAAM,YAAN,KAAAvJ,EAAmB,IAClC6I,EAAAA,GAAW5I,EAAAsJ,EAAM,UAAN,KAAAtJ,EAAiB,6BAA6B,CAAA,EAF9D,CAIC,SAAAsI,CAAAA,EAACH,GAAA,CACC,WAAWxD,EAAA2E,EAAM,YAAN,KAAA3E,EAAmB4H,EAC9B,SAAUjD,EAAM,qBAChB,aAAcA,EAAM,gBAAkB,GAAKmD,CAAAA,CAC7C,EACAnE,EAAC4C,GAAAzG,EAAA,CACC,wBACEoI,IAAgB,KACZhF,EAAwByB,EAAM,KAAMuD,CAAW,EAC/C,OAEN,aAAYvD,EAAM,MAClB,GAAG,KACH,YAAamC,EAAK,YAClB,MAAO,GACP,MAAO3C,EAAM,QACX,IACE2C,EAAK,SAAS,IAAKtL,GACjBb,EAAQ,WAAW,cAAca,CAAO,CAC1C,EACF,CAACsL,EAAK,SAAUnM,EAAQ,UAAU,CACpC,EACA,KAAK,OACL,SAAU,CAAA,EACNgN,CACN,CAAA,CAAA,CAAA,CAAA,CACF,EACF,CAEJ,EAEA,IAAeU,GAAAA,GAAKX,EAAI"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/util.ts","../src/TreeDataController.ts","../src/getDomProps.ts","../../components/src/components/loaders/LoaderSpinner.tsx","../src/SearchLabel.tsx","../src/TreeContext.tsx","../src/renderers/DefaultIconRenderer.tsx","../src/renderers/DefaultLabelRenderer.tsx","../src/renderers/Spacer.tsx","../src/TreeItemLabel.tsx","../src/TreeItem.tsx","../src/TreeItemChildren.tsx","../src/useTreeData.ts","../src/Tree.tsx"],"sourcesContent":["import TreeDataController from './TreeDataController';\nimport { TDataNode, TId } from './types';\n\nexport const getLastVisibleChild: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n id: TId,\n avoidFiltered?: boolean,\n) => TId | null = (handler, id, avoidFiltered) => {\n const nodeProps = handler.propsStore.getFieldProps(id);\n if (\n (id !== 'root' && (nodeProps.isDisabled || !nodeProps.isExpanded)) ||\n nodeProps.children.length === 0\n )\n return null;\n\n for (let i = nodeProps.children.length - 1; i >= 0; i--) {\n const currentId = nodeProps.children[i];\n const currentProps = handler.propsStore.getFieldProps(currentId);\n if (!avoidFiltered || !currentProps.isFiltered) {\n const lastChildrenLastChildren = getLastVisibleChild(\n handler,\n currentId,\n avoidFiltered,\n );\n return lastChildrenLastChildren !== null\n ? lastChildrenLastChildren\n : currentId;\n }\n }\n return null;\n};\n\nexport const getPreviousChild: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n id: TId,\n avoidFiltered?: boolean,\n) => TId | null = (handler, id, avoidFiltered) => {\n const nodeProps = handler.propsStore.getFieldProps(id);\n const fatherProps = handler.propsStore.getFieldProps(nodeProps.parentId);\n let childPosition =\n fatherProps.children?.findIndex((current) => current === nodeProps.id) ??\n -1;\n\n while (childPosition > 0) {\n const prevSibling = handler.propsStore.getFieldProps(\n fatherProps.children[childPosition - 1],\n );\n const prevSiblingLastChild = getLastVisibleChild(\n handler,\n prevSibling.id,\n avoidFiltered,\n );\n if (prevSiblingLastChild !== null) return prevSiblingLastChild;\n if (!avoidFiltered || !prevSibling.isFiltered) return prevSibling.id;\n\n childPosition--;\n }\n if (nodeProps.parentId === 'root') return null;\n return nodeProps.parentId;\n};\n\nexport const getFirstNonFilteredChild: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n id: TId,\n) => null | TId = (handler, id) => {\n const nodeProps = handler.propsStore.getFieldProps(id);\n // eslint-disable-next-line no-restricted-syntax\n for (const child of nodeProps.children) {\n if (!handler.propsStore.getFieldProps(child).isFiltered) return child;\n }\n return null;\n};\n\nexport const getNextChild: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n id: TId,\n avoidChildren?: boolean,\n avoidFiltered?: boolean,\n) => TId | null = (handler, id, avoidChildren, avoidFiltered) => {\n const nodeProps = handler.propsStore.getFieldProps(id);\n const fatherProps = handler.propsStore.getFieldProps(nodeProps.parentId);\n let childPosition =\n fatherProps.children?.findIndex((current) => current === nodeProps.id) ??\n Infinity;\n if (!avoidChildren && nodeProps.isExpanded) {\n if (!avoidFiltered && nodeProps.children.length > 0)\n return nodeProps.children[0];\n\n const firstNonFilteredChild = getFirstNonFilteredChild(\n handler,\n nodeProps.id,\n );\n if (firstNonFilteredChild !== null) return firstNonFilteredChild;\n }\n while (childPosition < fatherProps.children.length - 1) {\n const nextSibling = fatherProps.children[childPosition + 1];\n if (\n !avoidFiltered ||\n !handler.propsStore.getFieldProps(nextSibling).isFiltered\n )\n return nextSibling;\n childPosition++;\n }\n if (nodeProps.parentId === 'root') return null;\n return getNextChild(handler, fatherProps.id, true, avoidFiltered);\n};\n\nexport const getNextNodeWithKey: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n id: TId,\n firstKey: string,\n avoidFiltered?: boolean,\n) => TId | null = (handler, id, firstKey, avoidFiltered) => {\n let nextChildWithKey: TId | null = id;\n do {\n nextChildWithKey = getNextChild(\n handler,\n nextChildWithKey,\n false,\n avoidFiltered,\n );\n if (nextChildWithKey !== null) {\n const nodeProps = handler.propsStore.getFieldProps(nextChildWithKey);\n if (\n (!nodeProps.isFiltered || !avoidFiltered) &&\n nodeProps.label.toUpperCase().startsWith(firstKey.toUpperCase())\n )\n return nextChildWithKey;\n }\n } while (nextChildWithKey !== null);\n\n const nodeProps = handler.propsStore.getFieldProps(id);\n const positionInParent = handler.propsStore\n .getFieldProps(nodeProps.parentId)\n .children.findIndex((current) => current === id);\n\n if (nodeProps.parentId !== 'root' || positionInParent > 0) {\n const [firstChildOfTree] =\n handler.propsStore.getFieldProps('root').children;\n const firstChildProps = handler.propsStore.getFieldProps(firstChildOfTree);\n\n if (\n firstChildOfTree &&\n (!avoidFiltered || !firstChildProps.isFiltered) &&\n firstChildProps.label.toUpperCase().startsWith(firstKey.toUpperCase())\n )\n return firstChildOfTree;\n\n nextChildWithKey = firstChildOfTree;\n do {\n nextChildWithKey = getNextChild(\n handler,\n nextChildWithKey,\n false,\n avoidFiltered,\n );\n if (nextChildWithKey) {\n const currentNodeProps =\n handler.propsStore.getFieldProps(nextChildWithKey);\n if (\n (!avoidFiltered || !currentNodeProps.isFiltered) &&\n currentNodeProps.label\n .toUpperCase()\n .startsWith(firstKey.toUpperCase())\n )\n return nextChildWithKey;\n }\n } while (nextChildWithKey !== id && nextChildWithKey !== null);\n }\n\n return null;\n};\n\nexport const getNodePath: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n nodeId: TId,\n) => TId[] = (handler, nodeId) => {\n const path: TId[] = [nodeId];\n let currentStep: TId = nodeId;\n do {\n currentStep = handler.propsStore.getFieldProps(currentStep).parentId;\n path.unshift(currentStep);\n } while (currentStep !== 'root');\n return path;\n};\n\nexport const getCommonAncestor: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n oneNodeId: TId,\n anotherNodeId: TId,\n) => {\n commonAncestor: TId;\n oneNodeAncestorChild: TId;\n anotherNodeAncestorChild: TId;\n} | null = (handler, oneNodeId, anotherNodeId) => {\n const oneNodePath = getNodePath(handler, oneNodeId);\n const anotherNodePath = getNodePath(handler, anotherNodeId);\n\n for (let i = oneNodePath.length - 1; i >= 0; i--) {\n const anotherNodeIndex = anotherNodePath.indexOf(oneNodePath[i]);\n if (anotherNodeIndex !== -1)\n return {\n commonAncestor: oneNodePath[i],\n oneNodeAncestorChild: oneNodePath[i + 1],\n anotherNodeAncestorChild: anotherNodePath[anotherNodeIndex + 1],\n };\n }\n\n console.warn(\n 'This point should have never been reached since the root node is common to all nodes',\n { oneNodeId, anotherNodeId, oneNodePath, anotherNodePath },\n );\n return null;\n};\n\nexport const unfilterNodes: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n) => void = (handler) => {\n handler.state.filteredNodes.forEach((current) => {\n handler.propsStore.updateField(\n current,\n { isFiltered: false },\n { noEmit: true },\n );\n });\n\n const firstChild = handler.propsStore.getFieldProps('root').children[0];\n if (firstChild) handler.setFocusedNode(firstChild);\n handler.setState({ filteredNodes: [] });\n};\n\nexport const matchNodesAgainstString: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n searchString: string,\n nodeId?: TId,\n) => boolean = (handler, searchString, nodeId = 'root') => {\n let hasMatched = false;\n let matchNode: TId | null = null;\n const nodeProps = handler.propsStore.getFieldProps(nodeId);\n if (\n nodeId !== 'root' &&\n nodeProps.label.match(new RegExp(searchString, 'i'))\n ) {\n handler.propsStore.updateField(nodeId, { isFiltered: false });\n hasMatched = true;\n matchNode = nodeProps.id;\n handler.setState({\n filteredNodes: handler.state.filteredNodes.filter(\n (current) => current !== nodeId,\n ),\n });\n }\n let hasChildrenMatched = false;\n nodeProps.children.forEach((current) => {\n hasChildrenMatched =\n matchNodesAgainstString(handler, searchString, current) || hasMatched;\n hasMatched = hasChildrenMatched || hasMatched;\n if (hasMatched && !matchNode) matchNode = current;\n });\n if (hasChildrenMatched) {\n handler.propsStore.updateField(nodeId, { isExpanded: true });\n if (hasMatched && !matchNode) matchNode = nodeId;\n }\n if (!hasMatched) {\n handler.propsStore.updateField(\n nodeId,\n { isFiltered: true },\n { noEmit: true },\n );\n handler.setState({\n filteredNodes: [...handler.state.filteredNodes, nodeId],\n });\n }\n if (matchNode !== null) handler.setFocusedNode(matchNode);\n return hasMatched;\n};\n\nexport const selectAllNodesBetweenTwoNodes: <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n oneNodeId: TId,\n anotherNodeId: TId,\n avoidFiltered?: boolean,\n) => void = (handler, oneNodeId, anotherNodeId, avoidFiltered) => {\n const commonAncestorData = getCommonAncestor(\n handler,\n oneNodeId,\n anotherNodeId,\n );\n if (commonAncestorData) {\n const { anotherNodeAncestorChild, commonAncestor, oneNodeAncestorChild } =\n commonAncestorData;\n const ancestorProps = handler.propsStore.getFieldProps(commonAncestor);\n const oneNodePosition = ancestorProps.children.findIndex(\n (current) => current === oneNodeAncestorChild,\n );\n const anotherNodePosition = ancestorProps.children.findIndex(\n (current) => current === anotherNodeAncestorChild,\n );\n\n let currentId: TId | null =\n oneNodePosition >= anotherNodePosition ? anotherNodeId : oneNodeId;\n const lastNodeId =\n oneNodePosition < anotherNodePosition ? anotherNodeId : oneNodeId;\n handler.toggleNodeSelectedState(currentId, true);\n do {\n currentId = getNextChild(handler, currentId, avoidFiltered);\n if (currentId !== null) handler.toggleNodeSelectedState(currentId, true);\n } while (currentId !== lastNodeId && currentId !== null);\n }\n};\n","/* eslint-disable @typescript-eslint/no-dynamic-delete */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable max-classes-per-file */\nimport React, { RefObject, useEffect, useState } from 'react';\nimport {\n TDataNode,\n TDataNodeContainer,\n TId,\n TTreeDataControllerConfig,\n TTreeDataControllerState,\n} from './types';\nimport {\n getFirstNonFilteredChild,\n getLastVisibleChild,\n getNextChild,\n getNextNodeWithKey,\n getPreviousChild,\n selectAllNodesBetweenTwoNodes,\n} from './util';\nimport {\n EventEmitter,\n PropsStore,\n TModify,\n TRequireOnlyOne,\n addBoundary,\n getSpecificParent,\n TUpdateFieldConfiguration,\n TPropsConfiguration,\n usePropsSelector,\n} from '@apia/util';\n\nconst trees: Record<string, TreeDataController> = {};\nconst treesRecordEmitter = new (class TreesRecordEmitter extends EventEmitter<{\n addController: { name: string; controller: TreeDataController };\n}> {\n emit<K extends 'addController'>(\n eventName: K,\n params: {\n addController: {\n name: string;\n controller: TreeDataController;\n };\n }[K],\n ): void {\n super.emit(eventName, params);\n\n trees[params.name] = params.controller;\n }\n})();\n\nexport function useTreeDataController<\n TreeType extends TreeDataController<any, any> = TreeDataController<any, any>,\n>(name: string) {\n const [controller, setDataController] = useState<TreeDataController>(\n trees[name],\n );\n\n useEffect(() => {\n if (trees[name] !== controller) setDataController(trees[name]);\n\n return treesRecordEmitter.on('addController', (ev) => {\n if (ev.name === name) setDataController(ev.controller);\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return controller as unknown as TreeType;\n}\n\nexport function getTreeDataController<TreeType = TreeDataController>(\n name: string,\n) {\n return trees[name] as unknown as TreeType;\n}\n\nexport function deleteTreeDataController(name: string) {\n delete trees[name];\n}\n\nclass TreeDataController<\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n> extends EventEmitter<{\n onArrowUpOnFirstElement: boolean;\n expandNode: NodeType;\n mustFocus: TId;\n}> {\n _configuration: RefObject<TTreeDataControllerConfig<NodeProps, NodeType>>;\n\n get configuration() {\n return { ...this._configuration };\n }\n\n hasApendedFirstChild = false;\n\n /**\n * Este array se usa para conocer los padres faltantes al momento de la\n * construcción del árbol, de forma de optimizar el proceso\n */\n missingParents: TId[] = [];\n\n nonEmittedUpdates: TId[] = [];\n\n get state() {\n return this.propsStore.getFieldProps<TTreeDataControllerState>(\n this.stateKey,\n );\n }\n\n stateKey = 'treeState';\n\n get stateStore() {\n return this.propsStore as unknown as PropsStore<TTreeDataControllerState>;\n }\n\n constructor(\n public name: string,\n configuration: RefObject<\n Partial<TTreeDataControllerConfig<NodeProps, NodeType>>\n >,\n public propsStore = new PropsStore<NodeType>({\n logCommands: {\n propsStore: `treeProps_${name}`,\n propsLog: `treeLog_${name}`,\n propsSuscriptors: `propsSuscriptors_${name}`,\n updateProp: `updateProp_${name}`,\n },\n }),\n ) {\n super();\n\n this._configuration = (configuration ?? {\n current: { emitUpdates: true },\n }) as RefObject<Partial<TTreeDataControllerConfig<NodeProps, NodeType>>>;\n\n (this._configuration.current as TTreeDataControllerConfig).emitUpdates =\n (this._configuration.current as TTreeDataControllerConfig).emitUpdates ??\n true;\n\n this.setState(this.getInitialState());\n treesRecordEmitter.emit('addController', {\n name,\n controller: this as unknown as TreeDataController,\n });\n this.initRoot();\n }\n\n destructor() {\n this.propsStore.destructor();\n }\n\n append(\n node: Omit<\n TModify<\n NodeType,\n { children?: NodeType['children']; parentId?: NodeType['parentId'] }\n >,\n 'nodeProps' | 'actualParentId'\n > &\n Partial<Pick<NodeType, 'nodeProps'>>,\n ) {\n const newNode = { ...(node as NodeType), nodeProps: node.nodeProps ?? {} };\n\n // Se busca el padre, si el padre no existe se agrega a la raíz\n let father: TId;\n if (\n newNode.parentId !== undefined &&\n this.propsStore.getFieldProps(newNode.parentId)?.children\n ) {\n father = newNode.parentId;\n } else {\n father = 'root';\n if (newNode.parentId) this.missingParents.push(newNode.parentId);\n newNode.actualParentId = newNode.parentId;\n newNode.parentId = 'root';\n }\n\n this.propsStore.updateField(\n newNode.id,\n {\n ...newNode,\n children: newNode.children ?? [],\n },\n { isUrgent: true },\n );\n this.setState({ length: this.state.length + 1 });\n\n // Se buscan elementos que estén en la raíz y sean hijos del nodo que se\n // está agregando. De esta forma al crear el árbol nos aseguramos que ningún\n // nodo quede afuera y evitamos iteraciones innecesarias\n if (this.missingParents.includes(newNode.id)) {\n this.propsStore.getFieldProps('root').children.forEach((currentChild) => {\n if (\n this.propsStore.getFieldProps(currentChild).actualParentId ===\n newNode.id\n ) {\n this.move(currentChild, newNode.id);\n }\n });\n this.missingParents = this.missingParents.filter(\n (current) => current !== newNode.id,\n );\n }\n\n // Se agrega el nodo a los hijos del padre\n this.propsStore.updateField(\n father,\n {\n children: [\n ...this.propsStore.getFieldProps(father).children,\n newNode.id,\n ],\n },\n { noEmit: !this._configuration.current?.emitUpdates },\n );\n\n if (!this._configuration.current?.emitUpdates)\n this.nonEmittedUpdates.push(father);\n\n if (!this.hasApendedFirstChild) {\n this.hasApendedFirstChild = true;\n this.setFocusedNode(newNode.id, true);\n }\n\n if (newNode.isExpanded) this.toggleNodeExpandedState(newNode.id, true);\n }\n\n /**\n * Cuando se quieren agregar muchos nodos, es conveniente llamar primero al\n * método batchInit y luego de finalizar, al método batchFinish()\n */\n batchInit() {\n this.config({ emitUpdates: false });\n this.setState({ isLoading: true }, { isUrgent: true });\n }\n\n /**\n * Cuando se quieren agregar muchos nodos, es conveniente llamar primero al\n * método batchInit y luego de finalizar, al método batchFinish()\n */\n batchFinish() {\n this.config({ emitUpdates: true });\n setTimeout(() => this.setState({ isLoading: false }), 0);\n\n const children = [...this.getNodesIds()];\n\n const deleteNodes = this.previousNodes.filter(\n (current) => !children.find((search) => search === current),\n );\n deleteNodes.forEach((current) => this.remove(current));\n\n this.config({ emitUpdates: true });\n setTimeout(() => this.setState({ isLoading: false }), 0);\n }\n\n config(newConf: Partial<TTreeDataControllerConfig<NodeProps, NodeType>>) {\n if (!this._configuration.current?.emitUpdates && newConf.emitUpdates) {\n this.nonEmittedUpdates.forEach((current) =>\n this.propsStore.updateField(current, {\n children: [...this.propsStore.getFieldProps(current).children],\n }),\n );\n this.nonEmittedUpdates = [];\n }\n Object.assign(\n this._configuration.current as TTreeDataControllerConfig,\n newConf,\n );\n }\n\n deselectAll() {\n this.state.selectedNodes.forEach((currentId) =>\n this.propsStore.updateField(currentId, { isSelected: false }),\n );\n this.setState({ selectedNodes: [] });\n }\n\n forceEmitUpdate() {\n this.propsStore.updateField<{ forceUpdate: number }>('root', {\n forceUpdate:\n (this.propsStore.getFieldProps<{ forceUpdate: number }>('root')\n .forceUpdate ?? 0) + 1,\n });\n }\n\n getInitialState(): TTreeDataControllerState {\n return {\n expandedNodes: [],\n filteredNodes: [],\n focusedNode: null,\n isLoading: false,\n length: 0,\n selectedNodes: [],\n };\n }\n\n getNodesAsArray() {\n const allFields = { ...this.propsStore.fields };\n delete allFields[this.stateKey];\n delete allFields.root;\n return Object.values(allFields);\n }\n\n /**\n * Devuelve un array que contiene el id de todos los nodos pertenecientes al\n * árbol\n */\n getNodesIds() {\n const allFields = { ...this.propsStore.fields };\n delete allFields[this.stateKey];\n delete allFields.root;\n return Object.keys(allFields);\n }\n\n getParentId(parentId: TId) {\n return this.propsStore.getFieldProps(parentId).parentId;\n }\n\n /**\n * Este método permite controlar el comportamiento con el teclado desde fuera\n * del componente.\n */\n handleKey(ev: React.KeyboardEvent) {\n const focusedId = this.state.focusedNode as TId;\n const nodeProps = this.propsStore.getFieldProps(focusedId);\n if (ev.key === '*') {\n if (this.state.focusedNode === null) return;\n const parent = this.propsStore.getFieldProps(\n this.propsStore.getFieldProps(this.state.focusedNode).parentId,\n );\n parent.children.forEach((current) =>\n this.toggleNodeExpandedState(current, true),\n );\n } else if (ev.key.match(/^\\w$/)) {\n const nextChildWithKey = getNextNodeWithKey(\n this,\n focusedId,\n ev.key,\n true,\n );\n if (nextChildWithKey !== null) {\n this.setFocusedNode(nextChildWithKey);\n this.emit('mustFocus', nextChildWithKey);\n }\n } else\n switch (ev.code) {\n case 'Home': {\n const firstChild = getFirstNonFilteredChild(this, 'root');\n if (firstChild === null) return;\n if (ev.shiftKey && ev.ctrlKey && this.state.focusedNode !== null) {\n selectAllNodesBetweenTwoNodes(\n this,\n firstChild,\n this.state.focusedNode,\n true,\n );\n }\n this.setFocusedNode(firstChild);\n this.emit('mustFocus', firstChild);\n break;\n }\n case 'End': {\n const lastVisibleChild = getLastVisibleChild(this, 'root', true);\n if (lastVisibleChild !== null) {\n if (ev.shiftKey && ev.ctrlKey && this.state.focusedNode !== null) {\n selectAllNodesBetweenTwoNodes(\n this,\n lastVisibleChild,\n this.state.focusedNode,\n true,\n );\n }\n this.setFocusedNode(lastVisibleChild);\n this.emit('mustFocus', lastVisibleChild);\n }\n break;\n }\n case 'ArrowRight': {\n if (nodeProps.isLeaf) return;\n ev.preventDefault();\n if (nodeProps.isExpanded) {\n const firstChild = getFirstNonFilteredChild(this, nodeProps.id);\n if (firstChild !== null) {\n this.setFocusedNode(firstChild);\n this.emit('mustFocus', firstChild);\n }\n } else this.toggleNodeExpandedState(nodeProps.id, true);\n break;\n }\n case 'ArrowLeft': {\n ev.preventDefault();\n if (nodeProps.isLeaf || !nodeProps.isExpanded) {\n if (\n nodeProps.parentId !== 'root' &&\n nodeProps.parentId !== undefined\n ) {\n this.setFocusedNode(nodeProps.parentId);\n this.emit('mustFocus', nodeProps.parentId);\n }\n } else this.toggleNodeExpandedState(nodeProps.id, false);\n break;\n }\n case 'ArrowUp': {\n ev.preventDefault();\n const prevChild = getPreviousChild(this, nodeProps.id, true);\n if (prevChild !== null) {\n if (ev.shiftKey) this.toggleNodeSelectedState(prevChild, true);\n this.setFocusedNode(prevChild);\n this.emit('mustFocus', prevChild);\n } else this.emit('onArrowUpOnFirstElement', true);\n break;\n }\n case 'ArrowDown': {\n ev.preventDefault();\n const nextChild = getNextChild(this, nodeProps.id, false, true);\n if (nextChild !== null) {\n if (ev.shiftKey) this.toggleNodeSelectedState(nextChild, true);\n this.setFocusedNode(nextChild);\n this.emit('mustFocus', nextChild);\n }\n break;\n }\n case 'Space': {\n if (this._configuration.current?.disableSelection) return;\n ev.preventDefault();\n this.toggleNodeSelectedState(nodeProps.id);\n break;\n }\n default:\n break;\n }\n }\n\n isNode(\n node: NodeType | TDataNodeContainer<NodeProps> | TId,\n ): node is NodeType {\n return typeof node === 'object' && 'parentId' in node;\n }\n\n isNodeContainer(\n node: NodeType | TDataNodeContainer<NodeProps> | TId,\n ): node is TDataNodeContainer<NodeProps> {\n return typeof node === 'object' && !this.isNode(node);\n }\n\n includes(searchNode: NodeType) {\n return !!this.propsStore.getFieldProps(searchNode.id);\n }\n\n initRoot() {\n this.propsStore.updateField(\n 'root',\n { children: [], id: 'root' },\n { isUrgent: true },\n );\n }\n\n move(\n moveNode: TId,\n destinationNode: TId,\n afterOrBefore?: TRequireOnlyOne<{\n after: NodeType | TId;\n before: NodeType | TId;\n position: number;\n }>,\n ) {\n const currentFather = this.propsStore.getFieldProps(\n this.propsStore.getFieldProps(moveNode).parentId,\n );\n const newFather = this.propsStore.getFieldProps(destinationNode);\n\n if (!currentFather) {\n console.warn('The current node does not belong to the tree.', moveNode);\n return;\n }\n\n if (!newFather) {\n console.warn(\n 'The destination node does not belong to the tree. No action will be made',\n destinationNode,\n );\n return;\n }\n\n currentFather.children = currentFather.children?.filter(\n (search) => search !== moveNode,\n );\n if (!newFather.children) newFather.children = [];\n if (!afterOrBefore) newFather.children.push(moveNode);\n else if (afterOrBefore.position) {\n newFather.children.splice(afterOrBefore.position - 1, 0, moveNode);\n } else {\n const key = afterOrBefore.after\n ? afterOrBefore.after\n : afterOrBefore.before;\n\n const relatedNodeKey = key && this.isNode(key) ? key.id : key;\n const relatedNodeIndex = newFather.children.findIndex(\n (search) => search === relatedNodeKey,\n );\n\n const actualIndex = addBoundary(\n afterOrBefore.before !== undefined\n ? relatedNodeIndex\n : relatedNodeIndex + 1,\n 0,\n );\n\n if (actualIndex === -1 || actualIndex === newFather.children.length)\n newFather.children.push(moveNode);\n else newFather.children.splice(actualIndex, 0, moveNode);\n }\n\n this.propsStore.updateField(currentFather.id, {\n children: [...(currentFather.children ?? [])],\n });\n this.propsStore.updateField(newFather.id, {\n children: [...newFather.children],\n });\n this.propsStore.updateField(moveNode, {\n parentId: newFather.id,\n });\n }\n\n /**\n * Borra el nodo del árbol, y dependiendo del parámetro removeChildren, borra\n * también sus hijos.\n *\n * @param removeChildren - Si se pasa en false, los nodos hijos son movidos al root\n */\n remove(removeNode: NodeType | TId, removeChildren = true) {\n const removeNodeId = this.isNode(removeNode) ? removeNode.id : removeNode;\n\n const removingNode = this.propsStore.getFieldProps(removeNodeId);\n if (!removingNode) return;\n\n const father = this.propsStore.getFieldProps(removingNode.parentId);\n if (father) {\n this.propsStore.updateField(father.id, {\n children: father.children?.filter((search) => search !== removeNodeId),\n });\n }\n\n removingNode.children?.forEach((current) => {\n if (removeChildren) {\n this.remove(current);\n } else {\n this.move(current, 'root');\n }\n });\n\n this.setState({\n selectedNodes: this.state.selectedNodes.filter(\n (current) => current !== removeNodeId,\n ),\n focusedNode:\n this.state.focusedNode === removeNodeId ? null : this.state.focusedNode,\n length: this.state.length - 1,\n });\n this.propsStore.removeField(removeNodeId);\n }\n\n removeMultiple(nodes: TId[], removeChildren = true) {\n nodes.forEach((current) => this.remove(current, removeChildren));\n }\n\n previousNodes: TId[] = [];\n /**\n * Borra todos los nodos del árbol.\n */\n removeAll() {\n if (this.configuration.current?.emitUpdates === false) {\n this.previousNodes = this.getNodesIds();\n this.propsStore.updateField(\n 'root',\n { children: [], id: 'root' },\n { isUrgent: true, noEmit: true },\n );\n /* Object.keys(this.propsStore.fields).forEach((current) => {\n if (!['root', this.stateKey].includes(current))\n this.propsStore.updateField(current, { children: null });\n }); */\n } else {\n this.hasApendedFirstChild = false;\n this.setState({ focusedNode: null }, { isUrgent: true });\n this.setSelectedNodes([]);\n this.initRoot();\n Object.keys(this.propsStore.fields).forEach((current) => {\n if (!['root', this.stateKey].includes(current))\n this.propsStore.removeField(current);\n });\n }\n }\n\n selectAll() {\n this.setState({\n selectedNodes: this.getNodesIds(),\n });\n this.state.selectedNodes.forEach((currentId) =>\n this.propsStore.updateField(currentId, { isSelected: true }),\n );\n }\n\n setFocusedNode(key: TId, avoidSelection?: boolean) {\n if (this.state.focusedNode !== null)\n this.propsStore.updateField(this.state.focusedNode, { isFocused: false });\n this.setState({\n focusedNode: key,\n });\n if (\n !this._configuration.current?.isMultiple &&\n !avoidSelection &&\n this._configuration.current?.selectionMode !== 'explicit'\n )\n this.setSelectedNodes([key]);\n this.propsStore.updateField(key, { isFocused: true });\n }\n\n setSelectedNodes(nodes: TId[], force = false) {\n if (this._configuration.current?.disableSelection && !force) return;\n this.state.selectedNodes.forEach((current) =>\n this.propsStore.updateField(current, { isSelected: false }),\n );\n this.setState({\n selectedNodes: nodes.filter((current) => {\n const { isSelectable } = this.propsStore.getFieldProps(current);\n if (isSelectable !== false)\n this.propsStore.updateField(current, { isSelected: true });\n return isSelectable !== false;\n }),\n });\n }\n\n setSelectedNodesByClickEvent(ev: React.MouseEvent) {\n if (this._configuration.current?.disableSelection) return;\n const nodeKey = getSpecificParent(\n ev.target as HTMLElement,\n (current) => current.getAttribute('role') === 'treeitem',\n )?.getAttribute('data-key');\n if (nodeKey) {\n const nodeProps = this.propsStore.getFieldProps(nodeKey);\n if (nodeProps.isDisabled || nodeProps.isSelectable === false) return;\n\n const previousSelectionKeys = [...this.state.selectedNodes];\n // eslint-disable-next-line no-nested-ternary\n const newSelection: TId[] = this._configuration.current?.isMultiple\n ? nodeProps.isSelected\n ? previousSelectionKeys.filter((current) => current !== nodeKey)\n : [...previousSelectionKeys, nodeKey]\n : [nodeKey];\n\n this.setState({\n selectedNodes: newSelection,\n });\n\n previousSelectionKeys.forEach((current) => {\n if (!newSelection.includes(current))\n this.propsStore.updateField(current, { isSelected: false });\n });\n this.propsStore.updateField(nodeKey, {\n isSelected: this._configuration.current?.isMultiple\n ? !nodeProps.isSelected\n : true,\n });\n } else console.warn('Cannot set selection, no treeitem found', ev);\n }\n\n setState(\n updateProps: Partial<TTreeDataControllerState>,\n conf?: TUpdateFieldConfiguration,\n ) {\n this.propsStore.updateField<TTreeDataControllerState>(\n this.stateKey,\n {\n ...this.state,\n ...updateProps,\n },\n conf,\n );\n }\n\n toggleNodeExpandedState(key: TId, shouldExpand?: boolean) {\n const nodeProps = this.propsStore.getFieldProps(key);\n if (nodeProps.isDisabled || nodeProps.isLeaf || nodeProps.isLoading) return;\n\n if (this._configuration.current?.onLoadData && !nodeProps.hasLoaded) {\n this.propsStore.updateField(key, { isLoading: true });\n this._configuration.current?.onLoadData(nodeProps).finally(() => {\n this.propsStore.updateField(key, {\n isLoading: false,\n isExpanded: true,\n hasLoaded: true,\n });\n\n this.setState({\n expandedNodes: [...this.state.expandedNodes, key],\n });\n this._configuration.current?.onExpand?.(\n this.propsStore.getFieldProps(key),\n );\n });\n } else {\n const { expandedNodes } = this.state;\n const shouldExpandInner =\n shouldExpand !== undefined\n ? shouldExpand\n : !expandedNodes.includes(key);\n if (this.propsStore.getFieldProps(key)?.isDisabled) return;\n\n this.setState({\n expandedNodes: shouldExpandInner\n ? [...expandedNodes, key]\n : expandedNodes.filter((current) => current !== key),\n });\n this.propsStore.updateField(key, { isExpanded: shouldExpandInner });\n this._configuration.current?.onExpand?.(\n this.propsStore.getFieldProps(key),\n );\n }\n }\n\n toggleNodeSelectedState(key: TId, isSelected?: boolean) {\n if (this._configuration.current?.disableSelection) return;\n const nodeProps = this.propsStore.getFieldProps(key);\n if (nodeProps.isDisabled || nodeProps.isSelectable === false) return;\n\n const shouldSelect =\n isSelected !== undefined\n ? isSelected\n : !this.state.selectedNodes.includes(key);\n\n if (\n shouldSelect &&\n !this._configuration.current?.isMultiple &&\n this.state.selectedNodes[0]\n )\n this.toggleNodeSelectedState(this.state.selectedNodes[0], false);\n this.propsStore.updateField(key, { isSelected: shouldSelect });\n this.setState({\n selectedNodes: shouldSelect\n ? [...this.state.selectedNodes, key]\n : this.state.selectedNodes.filter((current) => current !== key),\n });\n }\n}\n\n/**\n * Este hook permite escuchar las props de un árbol, para ello es necesario\n * pasar el handler.\n *\n * @param handler\n * @param configuration\n * @returns\n */\nexport function useTreeSelector<\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n Selected = Record<string, unknown>,\n PropsType extends Record<string, unknown> = TTreeDataControllerState,\n>(\n handler: TreeDataController<NodeProps, NodeType>,\n configuration?: TPropsConfiguration<Selected, PropsType>,\n): Selected {\n return usePropsSelector<Selected, PropsType>(\n handler?.stateKey ?? '__NO__TREE__KEY__',\n {\n propsStore: handler?.propsStore as unknown as PropsStore<PropsType>,\n ...configuration,\n },\n );\n}\n\n/**\n * Este hook permite escuchar las props de un árbol, para ello es necesario\n * pasar el handler.\n *\n * @param handler\n * @param configuration\n * @returns\n */\nexport function useTreeSelectorByName<\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n Selected = Record<string, unknown>,\n PropsType extends Record<string, unknown> = TTreeDataControllerState,\n>(\n treeName: string,\n configuration?: TPropsConfiguration<Selected, PropsType>,\n): {\n handler: TreeDataController<NodeProps, NodeType>;\n selection: Selected;\n} {\n const handler =\n useTreeDataController<TreeDataController<NodeProps, NodeType>>(treeName);\n const selection = usePropsSelector<Selected, PropsType>(\n handler?.stateKey ?? '__NO__TREE__KEY__',\n {\n propsStore: handler?.propsStore as unknown as PropsStore<PropsType>,\n ...configuration,\n },\n );\n return { selection, handler };\n}\n\nexport default TreeDataController;\n","import { BoxProps } from 'theme-ui';\nimport { TTreeProps, TDataNode, TId } from './types';\nimport TreeDataController, {\n getTreeDataController,\n} from './TreeDataController';\n\nexport type TDomProps = Omit<BoxProps, 'as'> & Record<string, unknown>;\n\nexport function getActiveDescendantName(treeName: string, nodeId: TId) {\n return `${treeName}__${nodeId}`;\n}\n\nexport function getDomProps(\n treeProps: TTreeProps,\n treeName: string,\n type: 'tree',\n node: TTreeProps,\n controller: TreeDataController,\n): BoxProps;\nexport function getDomProps(\n treeProps: TTreeProps,\n treeName: string,\n type: 'node',\n node: TDataNode,\n): BoxProps;\nexport function getDomProps(\n _: TTreeProps,\n treeName: string,\n type: 'tree' | 'node',\n par: TDataNode | TTreeProps,\n): TDomProps {\n switch (type) {\n case 'node': {\n const node = par as TDataNode;\n const tree = getTreeDataController(treeName);\n return {\n 'aria-disabled': node.isDisabled,\n 'aria-expanded': node.isLeaf ? undefined : !!node.isExpanded,\n 'aria-label': node.label,\n ...(tree.configuration.current?.disableSelection\n ? undefined\n : {\n 'aria-selected':\n node.isSelectable !== false && !node.isDisabled\n ? !!node.isSelected\n : undefined,\n }),\n className: node.className,\n color: node.color,\n 'data-key': node.id,\n id: getActiveDescendantName(treeName, node.id),\n role: 'treeitem',\n title: node.title,\n };\n }\n default: {\n const tree = par as TTreeProps;\n return {\n role: 'tree',\n 'aria-multiselectable': tree.isMultiple,\n };\n }\n }\n}\n","import { getVariant, makeStyledComponent } from '@apia/theme';\nimport React from 'react';\nimport { Spinner } from 'theme-ui';\nimport { ThemeUICSSObject } from 'theme-ui';\n\nexport const styles: ThemeUICSSObject = {\n height: 'iconmd',\n width: 'iconmd',\n background: 'palette.background.paper',\n};\n\nconst LoaderSpinner = makeStyledComponent(\n 'LoaderSpinner',\n 'layout.common.components.loaderSpinner',\n styles,\n ({ className }: { className?: string }) => {\n return (\n <Spinner\n {...getVariant('layout.common.components.loaderSpinner')}\n className={className}\n />\n );\n },\n);\n\nexport default LoaderSpinner;\n","import { IconButton } from '@apia/components';\nimport { getVariant } from '@apia/theme';\nimport { formatMessage } from '@apia/util';\nimport { Box } from 'theme-ui';\nimport LoaderSpinner from '../../components/src/components/loaders/LoaderSpinner';\nconst SearchLabel = ({\n isLoading: isSearching,\n onDelete,\n searchString,\n}: {\n isLoading: boolean;\n onDelete?: () => unknown;\n searchString: string;\n}) => {\n if (!searchString && !isSearching) return null;\n return (\n <Box className={`tree__searchLabelBox ${isSearching ? 'isLoading' : ''}`}>\n {isSearching ? (\n <LoaderSpinner className=\"tree__loading\" />\n ) : (\n <Box as=\"label\" className=\"tree__searchLabel\">\n {formatMessage(window.LBL_FILTERING_BY, { TOK1: searchString })}\n <IconButton\n icon=\"Close\"\n aria-label={window.LBL_DELETE_FILTER}\n onClick={onDelete}\n title={window.LBL_DELETE_FILTER}\n size=\"Sm\"\n {...getVariant('icon-inherit')}\n />\n </Box>\n )}\n </Box>\n );\n};\n\nexport default SearchLabel;\n","import React from 'react';\nimport TreeDataController from './TreeDataController';\nimport { TDataNode, TTreeProps } from './types';\n\nexport type TTreeContext<\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n> = {\n forceUpdate: number;\n name: string;\n handler: TreeDataController<NodeProps, NodeType>;\n treeProps: TTreeProps<NodeProps, NodeType>;\n} & Pick<TTreeProps, 'focusGetter'>;\n\nconst TreeContext = React.createContext({} as TTreeContext);\n\nexport function useTreeContext<\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>() {\n const context = React.useContext(TreeContext);\n if (!context) throw new Error('There is no tree context');\n return context as unknown as TTreeContext<NodeProps, NodeType>;\n}\n\nexport const TreeContextProvider = <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>({\n children,\n value,\n}: {\n children: React.ReactNode;\n value: TTreeContext<NodeProps, NodeType>;\n}) => {\n const Provider = React.useMemo(() => {\n return TreeContext.Provider as unknown as React.Provider<\n TTreeContext<NodeProps, NodeType>\n >;\n }, []);\n\n return <Provider value={value}>{children}</Provider>;\n};\n\nexport default TreeContext;\n","import { Icon, TIconName } from '@apia/icons';\nimport { TTreeIconRenderer } from '../types';\n\nconst DefaultIconRenderer: TTreeIconRenderer = (props) => {\n return (\n <Icon\n name={props.icon as TIconName}\n title=\"\"\n size={props.iconSize ?? 'iconSm'}\n />\n );\n};\n\nexport default DefaultIconRenderer;\n","import { Box } from 'theme-ui';\nimport { TTreeLabelRenderer } from '../types';\n\nconst DefaultLabelRenderer: TTreeLabelRenderer = (props) => {\n return <Box as=\"span\">{props.label}</Box>;\n};\n\nexport default DefaultLabelRenderer;\n","import React from 'react';\nimport { Box } from 'theme-ui';\n\nconst Spacer: React.FunctionComponent<{ level: number }> = ({ level }) => {\n return (\n <>\n {Array(level)\n .fill('')\n .map((_, i) => i)\n .map((current) => (\n <Box className=\"spacer\" key={current} />\n ))}\n </>\n );\n};\n\nexport default Spacer;\n","import React from 'react';\nimport { shallowEqual } from 'react-redux';\nimport { Box, Spinner } from 'theme-ui';\nimport DefaultIconRenderer from './renderers/DefaultIconRenderer';\nimport DefaultLabelRenderer from './renderers/DefaultLabelRenderer';\nimport Spacer from './renderers/Spacer';\nimport { useTreeContext } from './TreeContext';\nimport { TDataNode, TId } from './types';\nimport { usePropsSelector } from '@apia/util';\nimport { Icon } from '@apia/icons';\n\nconst TreeItemLabel = ({ level, treeKey }: { level: number; treeKey: TId }) => {\n const {\n handler,\n treeProps: { toggleNodesOnLabelClick },\n } = useTreeContext();\n\n const props = usePropsSelector<TDataNode, TDataNode>(treeKey, {\n selector: (current) => current,\n comparator: (prevProps, newProps) => {\n return (\n shallowEqual(prevProps, newProps) &&\n shallowEqual(prevProps?.children, newProps?.children)\n );\n },\n propsStore: handler.propsStore,\n });\n\n const Renderer = React.useMemo(\n () => props.labelRenderer ?? DefaultLabelRenderer,\n [props.labelRenderer],\n );\n\n const handleToggle = React.useCallback(() => {\n handler.toggleNodeExpandedState(treeKey);\n }, [handler, treeKey]);\n\n const IconRenderer = React.useMemo(() => {\n return typeof props.icon === 'string' ? DefaultIconRenderer : props.icon;\n }, [props.icon]);\n\n const onClick = React.useCallback(() => {\n if (props.allowToggleExpandedFromLabel !== false)\n handler.toggleNodeExpandedState(treeKey);\n }, [handler, props.allowToggleExpandedFromLabel, treeKey]);\n\n return (\n <Box\n as=\"span\"\n className={`tree__nodeItemLabel ${props.isFocused ? 'focus' : ''}`}\n >\n <Spacer level={level} />\n {(props.isLoading ||\n (props.isExpanded && props.isLeaf !== true) ||\n props.isLeaf === false ||\n (props.children?.length ?? 0) > 0 ||\n (props.isLeaf === undefined &&\n !props.hasLoaded &&\n handler.configuration.current?.onLoadData)) && (\n <Box className=\"tree__expanderWrapper\">\n {props.isLoading ? (\n <Spinner sx={{ width: 'iconSm', height: 'iconSm' }} />\n ) : (\n <Icon\n className=\"tree__expandIcon\"\n onClick={handleToggle}\n name={props.isExpanded ? 'MinusFilled' : 'PlusFilled'}\n title=\"\"\n size=\"iconSm\"\n />\n )}\n </Box>\n )}\n {props.icon && IconRenderer && <IconRenderer {...props} />}\n <Box\n as=\"span\"\n className=\"tree__nodeItemLabelRenderer\"\n onClick={toggleNodesOnLabelClick !== false ? onClick : undefined}\n >\n <Renderer {...props} level={level} />\n </Box>\n </Box>\n );\n};\n\nexport default React.memo(TreeItemLabel);\n","import React from 'react';\nimport { shallowEqual } from 'react-redux';\nimport { Box } from 'theme-ui';\nimport { getDomProps } from './getDomProps';\nimport { useTreeContext } from './TreeContext';\nimport TreeItemChildren from './TreeItemChildren';\nimport TreeItemLabel from './TreeItemLabel';\nimport { TDataNode, TId } from './types';\nimport { usePropsSelector } from '@apia/util';\n\nconst TreeItem = ({ level, treeKey }: { level: number; treeKey: TId }) => {\n const { handler, name, forceUpdate, treeProps } = useTreeContext();\n\n const props = usePropsSelector<TDataNode, TDataNode>(treeKey, {\n selector: (current) => current,\n comparator: (prevProps, newProps) => {\n return (\n shallowEqual(prevProps, newProps) &&\n shallowEqual(prevProps?.children, newProps?.children)\n );\n },\n propsStore: handler.propsStore,\n });\n\n const nodes = React.useMemo(\n () =>\n props.children?.map((current) =>\n handler.propsStore.getFieldProps(current),\n ) ?? [],\n [props.children, handler.propsStore],\n );\n\n return (\n <>\n <Box as=\"li\" {...getDomProps(treeProps, name, 'node', props)}>\n <TreeItemLabel level={level} treeKey={treeKey} />\n <TreeItemChildren\n forceUpdate={forceUpdate}\n role=\"group\"\n level={level}\n nodes={nodes}\n />\n </Box>\n </>\n );\n};\n\nexport default React.memo(TreeItem);\n","import React from 'react';\nimport { Box, BoxProps } from 'theme-ui';\nimport { useTreeContext } from './TreeContext';\nimport TreeItem from './TreeItem';\nimport { TDataNode } from './types';\n\nconst TreeItemChildren = React.forwardRef<\n HTMLDivElement,\n {\n forceUpdate: number;\n level: number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n nodes: TDataNode<any>[];\n } & BoxProps\n>(({ level, nodes, forceUpdate, ...props }, ref) => {\n const { handler } = useTreeContext();\n\n return (\n <Box ref={ref} as=\"ul\" {...props}>\n {nodes?.map((current) => {\n const currentProps = handler.propsStore.getFieldProps(current.id);\n if (!currentProps) return null;\n\n return currentProps.isFiltered ? null : (\n <TreeItem level={level + 1} key={current.id} treeKey={current.id} />\n );\n })}\n </Box>\n );\n});\n\nTreeItemChildren.displayName = 'TreeItemChildren';\n\nexport default React.memo(TreeItemChildren);\n","import { useMount } from 'ahooks';\nimport { uniqueId } from 'lodash-es';\nimport React from 'react';\nimport { shallowEqual } from 'react-redux';\nimport TreeDataController from './TreeDataController';\nimport { TTreeProps, TDataNode, TId } from './types';\nimport { selectAllNodesBetweenTwoNodes } from './util';\nimport { getSpecificParent, useLatest, usePropsSelector } from '@apia/util';\n\ninterface IUseTreeData<\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n> {\n name: string;\n treeProps: TTreeProps<NodeProps, NodeType>;\n}\n\nexport default function useTreeData<\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>({ name, treeProps }: IUseTreeData<NodeProps, NodeType>) {\n const props = useLatest(treeProps);\n const handler = React.useMemo(\n () => new TreeDataController<NodeProps, NodeType>(name, props),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n useMount(() => {\n treeProps?.initialNodes?.forEach((current) => handler.append(current));\n });\n\n const data = usePropsSelector('root', {\n comparator: shallowEqual,\n propsStore: handler.propsStore,\n selector: (current) => ({\n children: current.children ?? [],\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n forceUpdate: (current as any).forceUpdate as number,\n }),\n });\n\n const keyHandlerId = React.useMemo(() => `keyHandler${uniqueId()}`, []);\n const keyHandlerRef = React.useRef<HTMLDivElement | null>(null);\n\n const focusOnNode = React.useCallback(\n (key: TId, retry = 3) => {\n if (keyHandlerRef.current) {\n const focusElement = keyHandlerRef.current.querySelector(\n `[data-key=\"${key}\"]`,\n ) as HTMLElement;\n keyHandlerRef.current?.focus();\n\n if (focusElement) {\n const actualFocusElement = (\n treeProps.focusGetter ??\n ((liElement: HTMLElement) =>\n liElement.querySelector(\n ':scope > .tree__nodeItemLabel',\n ) as HTMLElement)\n )(focusElement);\n\n const nodeProps = handler.propsStore.getFieldProps(key);\n\n if (!treeProps.focusGetter || !nodeProps.labelRenderer)\n actualFocusElement.classList.add('focused');\n actualFocusElement.scrollIntoView({\n inline: 'nearest',\n block: 'nearest',\n });\n } else if (retry > 0) setTimeout(() => focusOnNode(key, retry - 1), 30);\n }\n },\n [handler.propsStore, treeProps.focusGetter],\n );\n\n React.useEffect(() => {\n const unsuscribe1 = handler.on('mustFocus', (node) => focusOnNode(node));\n const unsuscribe2 = handler.on('onArrowUpOnFirstElement', () =>\n treeProps.onArrowUpOnFirstElement?.(),\n );\n\n return () => {\n unsuscribe1();\n unsuscribe2();\n };\n }, [focusOnNode, handler, treeProps]);\n\n return {\n data,\n handler,\n keyHandler: {\n id: keyHandlerId,\n onKeyDown: React.useCallback(\n (ev: React.KeyboardEvent) => {\n if (ev.key === 'Enter') {\n const key = handler.state.focusedNode;\n if (key) {\n const nodeProps = handler.propsStore.getFieldProps(key);\n treeProps.onNodeClick?.(ev, nodeProps);\n }\n } else {\n handler.handleKey(ev);\n }\n },\n [handler, treeProps],\n ),\n onMouseDown: React.useCallback(\n (ev: React.MouseEvent) => {\n const previousFocused = handler.state.focusedNode;\n if (\n previousFocused !== null &&\n ev.shiftKey &&\n handler.configuration.current?.isMultiple\n )\n ev.preventDefault();\n },\n [handler.configuration, handler.state.focusedNode],\n ),\n onClick: React.useCallback(\n (ev: React.MouseEvent) => {\n if (\n getSpecificParent(ev.target as HTMLElement, (current) =>\n current.classList.contains('tree__expandIcon'),\n )\n )\n return;\n\n const node = getSpecificParent(\n ev.target as HTMLElement,\n (current) => !!current.getAttribute('data-key'),\n );\n if (node) {\n const previousFocused = handler.state.focusedNode;\n const key = node.getAttribute('data-key') as string;\n\n const nodeProps = handler.propsStore.getFieldProps(key);\n treeProps.onNodeClick?.(ev, nodeProps);\n\n if (\n previousFocused !== null &&\n ev.shiftKey &&\n handler.configuration.current?.isMultiple\n ) {\n selectAllNodesBetweenTwoNodes(\n handler,\n previousFocused,\n key,\n true,\n );\n } else {\n handler.setFocusedNode(key);\n handler.setSelectedNodesByClickEvent(ev);\n }\n\n if (key) focusOnNode(key);\n }\n },\n [focusOnNode, handler, treeProps],\n ),\n ref: keyHandlerRef,\n },\n };\n}\n","import { useDebounceFn, useMount, useUnmount } from 'ahooks';\nimport React, { memo } from 'react';\nimport { shallowEqual } from 'react-redux';\nimport { Box } from 'theme-ui';\nimport { getActiveDescendantName } from './getDomProps';\nimport SearchLabel from './SearchLabel';\nimport { TTreeContext, TreeContextProvider } from './TreeContext';\nimport { useTreeSelector } from './TreeDataController';\nimport TreeItemChildren from './TreeItemChildren';\nimport { TDataNode, TId, TTreeDataControllerState, TTreeProps } from './types';\nimport useTreeData from './useTreeData';\nimport { unfilterNodes, matchNodesAgainstString } from './util';\nimport { PropsStore, usePropsSelector } from '@apia/util';\nimport { getVariant } from '@apia/theme';\n\nconst Tree = <\n NodeProps extends Record<string, unknown> = Record<string, unknown>,\n NodeType extends TDataNode<NodeProps> = TDataNode<NodeProps>,\n>(\n props: TTreeProps<NodeProps, NodeType>,\n) => {\n const { data, handler, keyHandler } = useTreeData<NodeProps, NodeType>({\n name: props.name,\n treeProps: { ...props },\n });\n\n const [isLoading, setIsLoading] = React.useState(false);\n const [currentSearchString, setCurrentSearchString] = React.useState('');\n const isTreeLoading = useTreeSelector(handler, {\n selector: (current) => current.isLoading,\n });\n React.useEffect(() => {\n setIsLoading(isTreeLoading);\n }, [isTreeLoading]);\n\n const search = useDebounceFn(\n () => {\n if (props.filterString === undefined) return;\n setIsLoading(true);\n React.startTransition(() => {\n setCurrentSearchString(props.filterString as string);\n });\n if (props.filterString !== undefined && props.filterString !== '') {\n unfilterNodes(handler);\n matchNodesAgainstString(handler, props.filterString);\n handler.forceEmitUpdate();\n } else {\n unfilterNodes(handler);\n handler.forceEmitUpdate();\n }\n setTimeout(() => setIsLoading(false), 0);\n },\n { wait: 200 },\n );\n\n React.useEffect(() => {\n search.run();\n if (!props.filterString) search.flush();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props.filterString]);\n\n usePropsSelector<TTreeDataControllerState, TTreeDataControllerState>(\n handler.stateKey,\n {\n propsStore:\n handler.propsStore as unknown as PropsStore<TTreeDataControllerState>,\n selector: (current) => current,\n comparator: (prevProps, newProps) => {\n if (\n props.onSelect &&\n !shallowEqual(prevProps?.selectedNodes, newProps?.selectedNodes)\n ) {\n props.onSelect(\n (newProps?.selectedNodes ?? []).map((currentId) =>\n handler.propsStore.getFieldProps(currentId),\n ),\n );\n }\n return true;\n },\n },\n );\n\n const { focusedNode } = usePropsSelector<\n { focusedNode: TId | null },\n TTreeDataControllerState\n >(handler.stateKey, {\n propsStore:\n handler.propsStore as unknown as PropsStore<TTreeDataControllerState>,\n selector: (current) => ({\n focusedNode: current.focusedNode,\n }),\n });\n\n useMount(() => {\n if (props.getHandler) props.getHandler(handler);\n });\n\n useUnmount(() => handler.destructor());\n\n const contextValue = React.useMemo(() => {\n const actualValue: TTreeContext<NodeProps, NodeType> = {\n handler,\n name: props.name,\n forceUpdate: data.forceUpdate,\n focusGetter: props.focusGetter,\n treeProps: props,\n };\n return actualValue;\n }, [handler, props, data.forceUpdate]);\n\n return (\n <TreeContextProvider value={contextValue}>\n <Box\n className={`tree ${props.className ?? ''}`}\n {...getVariant(props.variant ?? 'layout.common.trees.primary')}\n >\n <SearchLabel\n isLoading={props.isLoading ?? isLoading}\n onDelete={props.onDeleteFilterString}\n searchString={props.hideSearchLabel ? '' : currentSearchString}\n />\n <TreeItemChildren\n aria-activedescendant={\n focusedNode !== null\n ? getActiveDescendantName(props.name, focusedNode)\n : undefined\n }\n aria-label={props.label}\n as=\"ul\"\n forceUpdate={data.forceUpdate}\n level={-1}\n nodes={React.useMemo(\n () =>\n data.children.map((current) =>\n handler.propsStore.getFieldProps(current),\n ),\n [data.children, handler.propsStore],\n )}\n role=\"tree\"\n tabIndex={0}\n {...keyHandler}\n />\n </Box>\n </TreeContextProvider>\n );\n};\n\nexport default memo(Tree) as typeof Tree;\n"],"names":["nodeProps","__spreadValues","__spreadProps","_a","_b","TreeItemLabel","TreeItemChildren","TreeItem"],"mappings":";;;;;;;;;;;AAGO,MAAM,mBAOK,GAAA,CAAC,OAAS,EAAA,EAAA,EAAI,aAAkB,KAAA;AAChD,EAAA,MAAM,SAAY,GAAA,OAAA,CAAQ,UAAW,CAAA,aAAA,CAAc,EAAE,CAAA,CAAA;AACrD,EACG,IAAA,EAAA,KAAO,WAAW,SAAU,CAAA,UAAA,IAAc,CAAC,SAAU,CAAA,UAAA,CAAA,IACtD,SAAU,CAAA,QAAA,CAAS,MAAW,KAAA,CAAA;AAE9B,IAAO,OAAA,IAAA,CAAA;AAET,EAAA,KAAA,IAAS,IAAI,SAAU,CAAA,QAAA,CAAS,SAAS,CAAG,EAAA,CAAA,IAAK,GAAG,CAAK,EAAA,EAAA;AACvD,IAAM,MAAA,SAAA,GAAY,SAAU,CAAA,QAAA,CAAS,CAAC,CAAA,CAAA;AACtC,IAAA,MAAM,YAA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F,CAAC,IAAA,CAAK,QAAU,EAAA,OAAA,CAAQ,UAAU,CAAA;AAAA,aACpC;AAAA,YACA,IAAK,EAAA,MAAA;AAAA,YACL,QAAU,EAAA,CAAA;AAAA,WACN,EAAA,UAAA,CAAA;AAAA,SACN;AAAA,OAAA;AAAA,KAAA,CAAA;AAAA,GAEJ,EAAA,CAAA,CAAA;AAEJ,CAAA,CAAA;AAEA,aAAe,KAAK,IAAI,CAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
|
-
"version": "0.1.
|
|
9
|
+
"version": "0.1.3",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "rollup -c rollup.config.esb.mjs",
|
|
12
12
|
"buildDev": "rollup -c rollup.config.esb.mjs --dev",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"directory": "packages/tree"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@apia/components": "^0.1.
|
|
45
|
-
"@apia/icons": "^0.1.
|
|
46
|
-
"@apia/theme": "^0.1.
|
|
47
|
-
"@apia/util": "^0.1.
|
|
44
|
+
"@apia/components": "^0.1.3",
|
|
45
|
+
"@apia/icons": "^0.1.3",
|
|
46
|
+
"@apia/theme": "^0.1.3",
|
|
47
|
+
"@apia/util": "^0.1.3"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "26592fdfe0290bfed776776bf9dbe5d3ac2c7341"
|
|
50
50
|
}
|