@apia/tree2-controller 4.0.20
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 +367 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +755 -0
- package/dist/index.js.map +1 -0
- package/package.json +40 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { MouseEvent, KeyboardEvent } from 'react';
|
|
2
|
+
|
|
3
|
+
type TLabelIcon = {
|
|
4
|
+
className?: string;
|
|
5
|
+
icon: string;
|
|
6
|
+
label: string;
|
|
7
|
+
onClick?: (node: MobXTreeNode, ev: MouseEvent) => unknown;
|
|
8
|
+
onKeyDown?: (node: MobXTreeNode, ev: MouseEvent) => unknown;
|
|
9
|
+
title?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* RENDERERS
|
|
13
|
+
*/
|
|
14
|
+
type TTreeIconRenderer = React.FunctionComponent<{
|
|
15
|
+
node: MobXTreeNode;
|
|
16
|
+
}>;
|
|
17
|
+
type TTreeLabelRenderer = React.FunctionComponent<{
|
|
18
|
+
node: MobXTreeNode;
|
|
19
|
+
}>;
|
|
20
|
+
type MobXTreeNodeState = {
|
|
21
|
+
'aria-label': string;
|
|
22
|
+
/**
|
|
23
|
+
* Si se pasa asyncNode=true, el nodo recargará cada vez que sea expandido mediante el método onLoadData.
|
|
24
|
+
*/
|
|
25
|
+
asyncNode: boolean;
|
|
26
|
+
canCollapse: boolean;
|
|
27
|
+
children: Map<string, MobXTreeNode>;
|
|
28
|
+
className: string;
|
|
29
|
+
color: string;
|
|
30
|
+
/**
|
|
31
|
+
* Esta prop marca que ya se pidieron los datos mediante onLoadData para este
|
|
32
|
+
* nodo.
|
|
33
|
+
*/
|
|
34
|
+
hasLoaded: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* El icon puede ser el nombre de uno de los elementos del mapa de íconos de
|
|
37
|
+
* Icon.tsx o un TTreeIconRenderer que permite utilizar un componente para
|
|
38
|
+
* renderizar el ícono.*/
|
|
39
|
+
icon: string | TTreeIconRenderer | null;
|
|
40
|
+
/**
|
|
41
|
+
* Este string se usa como height y width del ícono, de modo que se puede
|
|
42
|
+
* pasar cualquier expresión válida de ThemeUI.
|
|
43
|
+
*/
|
|
44
|
+
iconSize: string;
|
|
45
|
+
/**
|
|
46
|
+
* Cuando un nodo está deshabilitado, no se pondrá foco en él, ni podrá ser seleccionado.
|
|
47
|
+
*/
|
|
48
|
+
isDisabled: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Indica si un nodo está o no expandido, en caso de que se establezca en
|
|
51
|
+
* true, el mismo será expandido. Esto puede ser útil para controlar el árbol
|
|
52
|
+
* desde fuera, en cuyo caso se deben modificar las propiedades mediante
|
|
53
|
+
* handler.propsStore.updateField(node.id, { newProps }).
|
|
54
|
+
*/
|
|
55
|
+
isExpanded: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Indica que el nodo no coincide con los criterios de búsqueda y por lo tanto debe ser ocultado. Se diferencia de isHidden en que esta propiedad se establece automáticamente cuando cambian los criterios de búsqueda del árbol.
|
|
58
|
+
*/
|
|
59
|
+
isFiltered: boolean;
|
|
60
|
+
isHidden: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Esta prop se usa para decir que un nodo es un sub-árbol, aún cuando no
|
|
63
|
+
* tiene hijos. Esto es especialmente útil cuando se quiere hacer carga
|
|
64
|
+
* asíncrona de datos, ya que al expandirse, se llamará al método onLoadData
|
|
65
|
+
* del tree.
|
|
66
|
+
*/
|
|
67
|
+
isLeaf?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Se setea en true al momento de llamar a onLoadData y en false al finalizar
|
|
70
|
+
* la carga de datos.
|
|
71
|
+
*/
|
|
72
|
+
isLoading: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Define si un nodo puede ser seleccionado o no. Por defecto es true.
|
|
75
|
+
*/
|
|
76
|
+
isSelectable: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Es la etiqueta que será mostrada en el nodo. Además, se utiliza para la búsqueda.
|
|
79
|
+
*/
|
|
80
|
+
label: string;
|
|
81
|
+
/**
|
|
82
|
+
* Permite definir botones personalizados que serán mostrados en el árbol.
|
|
83
|
+
*/
|
|
84
|
+
labelIcons: TLabelIcon[];
|
|
85
|
+
/**
|
|
86
|
+
* Si se pasa un labelRenderer se utilizará en lugar de
|
|
87
|
+
* DefaultLabelRenderer.tsx. El labelRenderer es el responsable de hacer caso
|
|
88
|
+
* de los eventos de click para la selección del nodo.
|
|
89
|
+
*/
|
|
90
|
+
labelRenderer: TTreeLabelRenderer | null;
|
|
91
|
+
nodeProps?: any;
|
|
92
|
+
/**
|
|
93
|
+
* Es llamado cuando se hace click o cuando se presiona Enter en el ícono.
|
|
94
|
+
*/
|
|
95
|
+
onClick?: (ev: MouseEvent) => unknown;
|
|
96
|
+
onKeyDown?: (ev: KeyboardEvent) => unknown;
|
|
97
|
+
title: string;
|
|
98
|
+
};
|
|
99
|
+
type MobXTreeState = {
|
|
100
|
+
disableSelection: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Si se pasa un filterString !== undefined => los nodos del árbol cuyo label
|
|
103
|
+
* no coincida serán ocultados, a menos que alguno de sus hijos si coincida.
|
|
104
|
+
*/
|
|
105
|
+
filterString: string;
|
|
106
|
+
/**
|
|
107
|
+
* Permite ocultar todos los nodos de tipo folder que no tengan hijos.
|
|
108
|
+
*/
|
|
109
|
+
hideEmptyFolders: boolean;
|
|
110
|
+
id: string;
|
|
111
|
+
/**
|
|
112
|
+
* Pone el mismo spinner que mientras está en modo batch.
|
|
113
|
+
*/
|
|
114
|
+
isLoading: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Habilita la selección múltiple, por defecto está deshabilitada.
|
|
117
|
+
*/
|
|
118
|
+
isMultiple: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Esta función debe devolver una promesa. Cuando se expande un nodo que no
|
|
121
|
+
* tiene hijos, esta función es llamada y el nodo es puesto en estado de carga
|
|
122
|
+
* hasta que la promesa se resuelve.
|
|
123
|
+
*/
|
|
124
|
+
onLoadData?: (node: MobXTreeNode) => Promise<void>;
|
|
125
|
+
onNodeClick?: (ev: MouseEvent, node: MobXTreeNode) => unknown;
|
|
126
|
+
onNodeDoubleClick?: (ev: MouseEvent, node: MobXTreeNode) => unknown;
|
|
127
|
+
onNodeExpanderClick?: (ev: MouseEvent, node: MobXTreeNode) => unknown;
|
|
128
|
+
onNodeKeyDown?: (ev: KeyboardEvent, node: MobXTreeNode) => unknown;
|
|
129
|
+
onSelect?: (ev: Set<MobXTreeNode>) => Promise<boolean> | boolean | void;
|
|
130
|
+
/**
|
|
131
|
+
* Si se pasa **onFocus**, el nodo será seleccionado al recibir foco (por
|
|
132
|
+
* ejemplo, al navegarlo con las flechas).
|
|
133
|
+
*
|
|
134
|
+
* Si se pasa **explicit**, solamente se
|
|
135
|
+
* hará seleccionará al hacerle click (o presionar enter o espacio).
|
|
136
|
+
*
|
|
137
|
+
* Si se pasa **explicitMultiple**, solamente se hará selección al hacer
|
|
138
|
+
* click o presionar enter o espacio, y además la selección múltiple solamente
|
|
139
|
+
* funcionará si las teclas Shift o Ctrl están presionadas.
|
|
140
|
+
*
|
|
141
|
+
* @default "onFocus"
|
|
142
|
+
*/
|
|
143
|
+
selectionMode: 'onFocus' | 'explicit' | 'explicitMultiple';
|
|
144
|
+
/**
|
|
145
|
+
* Si se pasa en false, los nodos padre solamente se podrán expandir/colapsar
|
|
146
|
+
* al hacer click en los íconos.
|
|
147
|
+
*/
|
|
148
|
+
toggleNodesOnLabelClick: boolean;
|
|
149
|
+
variant: string;
|
|
150
|
+
} & Pick<MobXTreeNodeState, 'aria-label' | 'children' | 'className' | 'title'>;
|
|
151
|
+
type TCreateNode = {
|
|
152
|
+
id?: string;
|
|
153
|
+
initialState?: Partial<MobXTreeNodeState> & {
|
|
154
|
+
isSelected?: boolean;
|
|
155
|
+
};
|
|
156
|
+
parentId?: string;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
interface IMobXTreeEventsHandler {
|
|
160
|
+
handleSelectionEvent(this: MobXTree, node: MobXTreeNode, mods?: {
|
|
161
|
+
ctrlKey?: boolean;
|
|
162
|
+
shiftKey?: boolean;
|
|
163
|
+
type: string;
|
|
164
|
+
}): void;
|
|
165
|
+
handleNodeDoubleClick(this: MobXTree, node: MobXTreeNode, ev: MouseEvent): void;
|
|
166
|
+
handleNodeExpanderClick(this: MobXTree, node: MobXTreeNode, ev: MouseEvent): void;
|
|
167
|
+
handleNodeClick(this: MobXTree, node: MobXTreeNode, ev: MouseEvent): void;
|
|
168
|
+
handleNodeKeyDown(this: MobXTree, node: MobXTreeNode, ev: KeyboardEvent): void;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
declare class MobXTree implements IMobXChildKeeper, IMobXTreeEventsHandler {
|
|
172
|
+
focusedNode: MobXTreeNode | null;
|
|
173
|
+
get id(): string;
|
|
174
|
+
indexedChildren: Map<string, MobXTreeNode>;
|
|
175
|
+
readonly parent: null;
|
|
176
|
+
get tree(): this;
|
|
177
|
+
selectedItems: Set<MobXTreeNode>;
|
|
178
|
+
state: MobXTreeState;
|
|
179
|
+
constructor(initialTreeState?: Omit<Partial<MobXTreeState>, 'children'>);
|
|
180
|
+
/**
|
|
181
|
+
*
|
|
182
|
+
*
|
|
183
|
+
* OWN METHODS
|
|
184
|
+
*
|
|
185
|
+
*
|
|
186
|
+
*/
|
|
187
|
+
clearSelection(): void;
|
|
188
|
+
focusNode(node: MobXTreeNode): void;
|
|
189
|
+
/**
|
|
190
|
+
* Devuelve el nodo con el id especificado o undefined si no existe.
|
|
191
|
+
*/
|
|
192
|
+
getNodeById(id: string): MobXTreeNode | this | undefined;
|
|
193
|
+
/**
|
|
194
|
+
* Actúa si el nodo que está en foco ya no existe en el árbol y restaura el foco en el primer nodo visible.
|
|
195
|
+
*/
|
|
196
|
+
reviewFocus(): void;
|
|
197
|
+
setSelectedNodes(newSelection: Set<string>): void;
|
|
198
|
+
setSelectedNodes(newSelection: Set<MobXTreeNode>): void;
|
|
199
|
+
toggleNodeSelection(node: MobXTreeNode, isSelected?: boolean): void;
|
|
200
|
+
/**
|
|
201
|
+
*
|
|
202
|
+
*
|
|
203
|
+
* MobXChildKeeper
|
|
204
|
+
*
|
|
205
|
+
*
|
|
206
|
+
*/
|
|
207
|
+
append(node: MobXTreeNode): void;
|
|
208
|
+
create(props: TCreateNode): MobXTreeNode;
|
|
209
|
+
getChild(id: string): MobXTreeNode | undefined;
|
|
210
|
+
getChildren(): MobXTreeNode[];
|
|
211
|
+
getFirstChildren(omitFiltered?: boolean | undefined): MobXTreeNode | null;
|
|
212
|
+
getLastChildren(omitFiltered?: boolean | undefined): MobXTreeNode | null;
|
|
213
|
+
getFollowingSibling(omitFiltered?: boolean | undefined): MobXTreeNode | null;
|
|
214
|
+
getPreviousSibling(omitFiltered?: boolean | undefined): MobXTreeNode | null;
|
|
215
|
+
getSibling(): MobXTreeNode[];
|
|
216
|
+
removeAllChildren(): void;
|
|
217
|
+
removeChild(param: string | MobXTreeNode): void;
|
|
218
|
+
/**
|
|
219
|
+
*
|
|
220
|
+
*
|
|
221
|
+
* MobXTreeEventsHandler
|
|
222
|
+
*
|
|
223
|
+
*
|
|
224
|
+
*/
|
|
225
|
+
handleNodeClick(node: MobXTreeNode, ev: MouseEvent): void;
|
|
226
|
+
handleNodeDoubleClick(node: MobXTreeNode, ev: MouseEvent<Element, globalThis.MouseEvent>): void;
|
|
227
|
+
handleNodeExpanderClick(node: MobXTreeNode, ev: MouseEvent<Element, globalThis.MouseEvent>): void;
|
|
228
|
+
handleNodeKeyDown(node: MobXTreeNode, ev: KeyboardEvent<Element>): void;
|
|
229
|
+
handleSelectionEvent(node: MobXTreeNode, mods?: {
|
|
230
|
+
ctrlKey?: boolean;
|
|
231
|
+
shiftKey?: boolean;
|
|
232
|
+
type: string;
|
|
233
|
+
}): void;
|
|
234
|
+
static fromNodes(nodes: MobxTreeStaticBuilderNode[]): MobXTree;
|
|
235
|
+
}
|
|
236
|
+
type MobxTreeStaticBuilderNode = Omit<Partial<MobXTreeNodeState>, 'children'> & {
|
|
237
|
+
parentId?: string;
|
|
238
|
+
id: string;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
declare class MobXTreeNode implements IMobXChildKeeper {
|
|
242
|
+
readonly id: string;
|
|
243
|
+
parent: MobXTreeNode | MobXTree | null;
|
|
244
|
+
state: MobXTreeNodeState;
|
|
245
|
+
constructor(id: string, parent: MobXTreeNode | MobXTree | null, initialState?: Omit<Partial<MobXTreeNodeState>, 'children'>);
|
|
246
|
+
/**
|
|
247
|
+
*
|
|
248
|
+
*
|
|
249
|
+
* GETTERS
|
|
250
|
+
*
|
|
251
|
+
*
|
|
252
|
+
*/
|
|
253
|
+
get isFocused(): boolean;
|
|
254
|
+
get isSelected(): boolean;
|
|
255
|
+
get showExpander(): boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Da acceso al árbol raíz de cada nodo
|
|
258
|
+
*/
|
|
259
|
+
get tree(): MobXTree;
|
|
260
|
+
/**
|
|
261
|
+
*
|
|
262
|
+
*
|
|
263
|
+
* OWN METHODS
|
|
264
|
+
*
|
|
265
|
+
*
|
|
266
|
+
*/
|
|
267
|
+
toggleExpansion(isExpanded?: boolean): Promise<void>;
|
|
268
|
+
getNodeProps<T>(): T;
|
|
269
|
+
remove(): void;
|
|
270
|
+
/**
|
|
271
|
+
*
|
|
272
|
+
*
|
|
273
|
+
* MobXChildKeeper
|
|
274
|
+
*
|
|
275
|
+
*
|
|
276
|
+
*/
|
|
277
|
+
append(node: MobXTreeNode): void;
|
|
278
|
+
create(props: TCreateNode): MobXTreeNode;
|
|
279
|
+
getChild(id: string): MobXTreeNode | undefined;
|
|
280
|
+
getChildren(): MobXTreeNode[];
|
|
281
|
+
getFirstChildren(omitFiltered?: boolean | undefined): MobXTreeNode | null;
|
|
282
|
+
getLastChildren(omitFiltered?: boolean | undefined): MobXTreeNode | null;
|
|
283
|
+
getFollowingSibling(omitFiltered?: boolean | undefined): MobXTreeNode | null;
|
|
284
|
+
getPreviousSibling(omitFiltered?: boolean | undefined): MobXTreeNode | null;
|
|
285
|
+
getSibling(): MobXTreeNode[];
|
|
286
|
+
removeAllChildren(): void;
|
|
287
|
+
removeChild(param: string | MobXTreeNode): void;
|
|
288
|
+
/**
|
|
289
|
+
*
|
|
290
|
+
*
|
|
291
|
+
* MobXTreeEventsHandler
|
|
292
|
+
*
|
|
293
|
+
*
|
|
294
|
+
*/
|
|
295
|
+
handleClick(ev: MouseEvent): void;
|
|
296
|
+
handleDoubleClick(ev: MouseEvent<Element, globalThis.MouseEvent>): void;
|
|
297
|
+
handleExpanderClick(ev: MouseEvent<Element, globalThis.MouseEvent>): void;
|
|
298
|
+
handleKeyDown(ev: KeyboardEvent<Element>): void;
|
|
299
|
+
handleSelectionEvent(mods?: {
|
|
300
|
+
ctrlKey?: boolean;
|
|
301
|
+
shiftKey?: boolean;
|
|
302
|
+
type: string;
|
|
303
|
+
}): void;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
interface IMobXChildKeeper {
|
|
307
|
+
/**
|
|
308
|
+
* Permite añadir un nodo como hijo del nodo actual.
|
|
309
|
+
*
|
|
310
|
+
* Si el nodo que se está insertando era hijo de otro, se realiza una operación de movimiento, quitando al nodo del padre anterior.
|
|
311
|
+
*
|
|
312
|
+
* Si se inserta un nuevo nodo, con un id igual a otro que ya existía previamente en el árbol, se lanza **DuplicatedNodeInsertionError**.
|
|
313
|
+
*/
|
|
314
|
+
append(node: MobXTreeNode): void;
|
|
315
|
+
/**
|
|
316
|
+
* Crea un nodo nuevo y lo devuelve. El nodo será agregado al nodo con id=parentId pasado o al nodo actual si no se pasa ninguno.
|
|
317
|
+
*/
|
|
318
|
+
create(props: TCreateNode): MobXTreeNode;
|
|
319
|
+
/**
|
|
320
|
+
* Devuelve un hijo directo del elemento actual con el id especificado.
|
|
321
|
+
*/
|
|
322
|
+
getChild(id: string): MobXTreeNode | undefined;
|
|
323
|
+
/**
|
|
324
|
+
* Devuelve todos los hijos del nodo actual.
|
|
325
|
+
*/
|
|
326
|
+
getChildren(): MobXTreeNode[];
|
|
327
|
+
/**
|
|
328
|
+
* Devuelve el primer hijo que cumpla con las condiciones.
|
|
329
|
+
*
|
|
330
|
+
* Si se pasa omitFiltered=true, no toma en cuenta nodos que tengan la propiedad isFiltered=true
|
|
331
|
+
*/
|
|
332
|
+
getFirstChildren(omitFiltered?: boolean): MobXTreeNode | null;
|
|
333
|
+
/**
|
|
334
|
+
* Devuelve el primer hijo que cumpla con las condiciones.
|
|
335
|
+
*
|
|
336
|
+
* Si se pasa omitFiltered=true, no toma en cuenta nodos que tengan la propiedad isFiltered=true
|
|
337
|
+
*/
|
|
338
|
+
getLastChildren(omitFiltered?: boolean): MobXTreeNode | null;
|
|
339
|
+
/**
|
|
340
|
+
* Devuelve el hermano siguiente que cumpla con las condiciones.
|
|
341
|
+
*
|
|
342
|
+
* Si se pasa omitFiltered=true, no toma en cuenta nodos que tengan la propiedad isFiltered=true
|
|
343
|
+
*/
|
|
344
|
+
getFollowingSibling(omitFiltered?: boolean): MobXTreeNode | null;
|
|
345
|
+
/**
|
|
346
|
+
* Devuelve el hermano anterior que cumpla con las condiciones.
|
|
347
|
+
*
|
|
348
|
+
* Si se pasa omitFiltered=true, no toma en cuenta nodos que tengan la propiedad isFiltered=true
|
|
349
|
+
*/
|
|
350
|
+
getPreviousSibling(omitFiltered?: boolean): MobXTreeNode | null;
|
|
351
|
+
/**
|
|
352
|
+
* Devuelve todos los hermanos del nodo actual.
|
|
353
|
+
*/
|
|
354
|
+
getSibling(): MobXTreeNode[];
|
|
355
|
+
/**
|
|
356
|
+
* Elimina todos los hijos
|
|
357
|
+
*/
|
|
358
|
+
removeAllChildren(): void;
|
|
359
|
+
/**
|
|
360
|
+
* Elimina el hijo indicado. El parámetro puede ser el id o el nodo a eliminar.
|
|
361
|
+
* Si el nodo no es hijo del elemento, no se hace nada con él.
|
|
362
|
+
*/
|
|
363
|
+
removeChild(param: string | MobXTreeNode): void;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export { type IMobXChildKeeper, MobXTree, MobXTreeNode, type MobXTreeNodeState, type MobXTreeState, type TCreateNode, type TLabelIcon, type TTreeIconRenderer, type TTreeLabelRenderer };
|
|
367
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,755 @@
|
|
|
1
|
+
import { makeAutoObservable, observable, action, computed, reaction } from 'mobx';
|
|
2
|
+
import { v4 } from 'uuid';
|
|
3
|
+
|
|
4
|
+
class DuplicatedNodeInsertionError extends Error {
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const MobXChildKeeper = {
|
|
8
|
+
append(node) {
|
|
9
|
+
const existingNode = this.tree.indexedChildren.get(node.id);
|
|
10
|
+
if (existingNode && existingNode !== node) {
|
|
11
|
+
console.error(
|
|
12
|
+
new DuplicatedNodeInsertionError("Duplicated node insertion")
|
|
13
|
+
);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (existingNode?.parent && existingNode.parent !== this) {
|
|
17
|
+
existingNode.parent.removeChild(node.id);
|
|
18
|
+
}
|
|
19
|
+
this.state.children.set(node.id, node);
|
|
20
|
+
this.tree.indexedChildren.set(node.id, node);
|
|
21
|
+
node.parent = this;
|
|
22
|
+
},
|
|
23
|
+
create({ id, initialState, parentId = this.id }) {
|
|
24
|
+
let parentNode = parentId ? this.tree.getNodeById(parentId) : this;
|
|
25
|
+
if (!parentNode) {
|
|
26
|
+
console.warn("Cannot find parent node with id = ", parentId);
|
|
27
|
+
parentNode = this;
|
|
28
|
+
}
|
|
29
|
+
const newNode = new MobXTreeNode(id ?? v4(), parentNode, initialState);
|
|
30
|
+
parentNode.append(newNode);
|
|
31
|
+
if (initialState?.isSelected) {
|
|
32
|
+
this.tree.toggleNodeSelection(newNode, true);
|
|
33
|
+
}
|
|
34
|
+
return newNode;
|
|
35
|
+
},
|
|
36
|
+
getChild(id) {
|
|
37
|
+
return this.state.children.get(id);
|
|
38
|
+
},
|
|
39
|
+
getChildren() {
|
|
40
|
+
return [...this.state.children.values()];
|
|
41
|
+
},
|
|
42
|
+
getFirstChildren(omitFiltered) {
|
|
43
|
+
return this.getChildren().find((c) => !c.state.isFiltered || !omitFiltered) || null;
|
|
44
|
+
},
|
|
45
|
+
getLastChildren(omitFiltered) {
|
|
46
|
+
return this.getChildren().findLast(
|
|
47
|
+
(c) => !c.state.isFiltered || !omitFiltered
|
|
48
|
+
) || null;
|
|
49
|
+
},
|
|
50
|
+
getFollowingSibling(omitFiltered) {
|
|
51
|
+
const sibling = this.getSibling();
|
|
52
|
+
const thisIndex = sibling.indexOf(this);
|
|
53
|
+
for (let i = thisIndex + 1; i < sibling.length; i++) {
|
|
54
|
+
if (!omitFiltered || !sibling[i].state.isFiltered) {
|
|
55
|
+
return sibling[i];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
},
|
|
60
|
+
getPreviousSibling(omitFiltered) {
|
|
61
|
+
const sibling = this.getSibling();
|
|
62
|
+
const thisIndex = sibling.indexOf(this);
|
|
63
|
+
for (let i = thisIndex - 1; i >= 0; i--) {
|
|
64
|
+
if (!omitFiltered || !sibling[i].state.isFiltered) {
|
|
65
|
+
return sibling[i];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
},
|
|
70
|
+
getSibling() {
|
|
71
|
+
return this.parent?.getChildren() ?? [];
|
|
72
|
+
},
|
|
73
|
+
removeAllChildren() {
|
|
74
|
+
this.getChildren().forEach(this.removeChild.bind(this));
|
|
75
|
+
},
|
|
76
|
+
removeChild(param) {
|
|
77
|
+
const id = param instanceof MobXTreeNode ? param.id : param;
|
|
78
|
+
this.state.children.get(id)?.getChildren().forEach((c) => c.remove());
|
|
79
|
+
this.state.children.delete(id);
|
|
80
|
+
this.tree.indexedChildren.delete(id);
|
|
81
|
+
this.tree.reviewFocus();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
var __defProp$1 = Object.defineProperty;
|
|
86
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
87
|
+
var __publicField$1 = (obj, key, value) => {
|
|
88
|
+
__defNormalProp$1(obj, key + "" , value);
|
|
89
|
+
return value;
|
|
90
|
+
};
|
|
91
|
+
class MobXTreeNode {
|
|
92
|
+
constructor(id, parent, initialState) {
|
|
93
|
+
this.id = id;
|
|
94
|
+
this.parent = parent;
|
|
95
|
+
__publicField$1(this, "state", {
|
|
96
|
+
"aria-label": "",
|
|
97
|
+
asyncNode: false,
|
|
98
|
+
canCollapse: true,
|
|
99
|
+
children: /* @__PURE__ */ new Map(),
|
|
100
|
+
className: "",
|
|
101
|
+
color: "",
|
|
102
|
+
hasLoaded: true,
|
|
103
|
+
icon: null,
|
|
104
|
+
iconSize: "Md",
|
|
105
|
+
isDisabled: false,
|
|
106
|
+
isFiltered: false,
|
|
107
|
+
isExpanded: false,
|
|
108
|
+
isHidden: false,
|
|
109
|
+
isLoading: false,
|
|
110
|
+
isSelectable: true,
|
|
111
|
+
label: "",
|
|
112
|
+
labelIcons: [],
|
|
113
|
+
labelRenderer: null,
|
|
114
|
+
nodeProps: {},
|
|
115
|
+
title: ""
|
|
116
|
+
});
|
|
117
|
+
Object.assign(this.state, initialState);
|
|
118
|
+
makeAutoObservable(this, {
|
|
119
|
+
append: false,
|
|
120
|
+
id: false,
|
|
121
|
+
getChild: false,
|
|
122
|
+
getChildren: false,
|
|
123
|
+
getFirstChildren: false,
|
|
124
|
+
getFollowingSibling: false,
|
|
125
|
+
getLastChildren: false,
|
|
126
|
+
getNodeProps: false,
|
|
127
|
+
getPreviousSibling: false,
|
|
128
|
+
getSibling: false,
|
|
129
|
+
parent: false,
|
|
130
|
+
tree: false,
|
|
131
|
+
isFocused: computed,
|
|
132
|
+
isSelected: computed,
|
|
133
|
+
showExpander: computed,
|
|
134
|
+
create: action,
|
|
135
|
+
handleClick: action,
|
|
136
|
+
handleDoubleClick: action,
|
|
137
|
+
handleExpanderClick: action,
|
|
138
|
+
handleKeyDown: action,
|
|
139
|
+
handleSelectionEvent: action,
|
|
140
|
+
remove: action,
|
|
141
|
+
removeAllChildren: action,
|
|
142
|
+
removeChild: action,
|
|
143
|
+
toggleExpansion: action,
|
|
144
|
+
state: observable
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
*
|
|
149
|
+
*
|
|
150
|
+
* GETTERS
|
|
151
|
+
*
|
|
152
|
+
*
|
|
153
|
+
*/
|
|
154
|
+
get isFocused() {
|
|
155
|
+
return this.tree.focusedNode === this;
|
|
156
|
+
}
|
|
157
|
+
get isSelected() {
|
|
158
|
+
return this.tree.selectedItems.has(this);
|
|
159
|
+
}
|
|
160
|
+
get showExpander() {
|
|
161
|
+
return this.state.canCollapse !== false && (this.state.asyncNode || this.state.isLeaf === false || this.state.isLeaf !== true && this.state.children.size > 0);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Da acceso al árbol raíz de cada nodo
|
|
165
|
+
*/
|
|
166
|
+
get tree() {
|
|
167
|
+
let parent = this;
|
|
168
|
+
while (parent.parent !== null) {
|
|
169
|
+
parent = parent.parent;
|
|
170
|
+
}
|
|
171
|
+
if (!(parent instanceof MobXTree))
|
|
172
|
+
throw new Error("The node is not inside the tree");
|
|
173
|
+
return parent;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
*
|
|
177
|
+
*
|
|
178
|
+
* OWN METHODS
|
|
179
|
+
*
|
|
180
|
+
*
|
|
181
|
+
*/
|
|
182
|
+
async toggleExpansion(isExpanded = !this.state.isExpanded) {
|
|
183
|
+
if (this.state.canCollapse === false) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (!this.state.isExpanded && isExpanded && (this.state.asyncNode || !this.state.hasLoaded && this.tree.state.onLoadData && !this.getChildren().length)) {
|
|
187
|
+
if (!this.state.asyncNode) {
|
|
188
|
+
this.state.hasLoaded = true;
|
|
189
|
+
}
|
|
190
|
+
let cancelIsLoading = false;
|
|
191
|
+
setTimeout(() => {
|
|
192
|
+
if (!cancelIsLoading) {
|
|
193
|
+
this.state.isLoading = true;
|
|
194
|
+
}
|
|
195
|
+
}, 50);
|
|
196
|
+
if (this.tree.state.onLoadData) {
|
|
197
|
+
try {
|
|
198
|
+
await this.tree.state.onLoadData?.(this);
|
|
199
|
+
} catch (e) {
|
|
200
|
+
console.error(e);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
this.state.isExpanded = true;
|
|
204
|
+
cancelIsLoading = true;
|
|
205
|
+
this.state.isLoading = false;
|
|
206
|
+
} else {
|
|
207
|
+
this.state.isExpanded = isExpanded;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
getNodeProps() {
|
|
211
|
+
return this.state.nodeProps;
|
|
212
|
+
}
|
|
213
|
+
remove() {
|
|
214
|
+
this.parent?.removeChild(this.id);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
*
|
|
218
|
+
*
|
|
219
|
+
* MobXChildKeeper
|
|
220
|
+
*
|
|
221
|
+
*
|
|
222
|
+
*/
|
|
223
|
+
append(node) {
|
|
224
|
+
return MobXChildKeeper.append.call(this, node);
|
|
225
|
+
}
|
|
226
|
+
create(props) {
|
|
227
|
+
return MobXChildKeeper.create.call(this, props);
|
|
228
|
+
}
|
|
229
|
+
getChild(id) {
|
|
230
|
+
return MobXChildKeeper.getChild.call(this, id);
|
|
231
|
+
}
|
|
232
|
+
getChildren() {
|
|
233
|
+
return MobXChildKeeper.getChildren.call(this);
|
|
234
|
+
}
|
|
235
|
+
getFirstChildren(omitFiltered) {
|
|
236
|
+
return MobXChildKeeper.getFirstChildren.call(this, omitFiltered);
|
|
237
|
+
}
|
|
238
|
+
getLastChildren(omitFiltered) {
|
|
239
|
+
return MobXChildKeeper.getLastChildren.call(this, omitFiltered);
|
|
240
|
+
}
|
|
241
|
+
getFollowingSibling(omitFiltered) {
|
|
242
|
+
return MobXChildKeeper.getFollowingSibling.call(this, omitFiltered);
|
|
243
|
+
}
|
|
244
|
+
getPreviousSibling(omitFiltered) {
|
|
245
|
+
return MobXChildKeeper.getPreviousSibling.call(this, omitFiltered);
|
|
246
|
+
}
|
|
247
|
+
getSibling() {
|
|
248
|
+
return MobXChildKeeper.getSibling.call(this);
|
|
249
|
+
}
|
|
250
|
+
removeAllChildren() {
|
|
251
|
+
return MobXChildKeeper.removeAllChildren.call(this);
|
|
252
|
+
}
|
|
253
|
+
removeChild(param) {
|
|
254
|
+
return MobXChildKeeper.removeChild.call(this, param);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
*
|
|
258
|
+
*
|
|
259
|
+
* MobXTreeEventsHandler
|
|
260
|
+
*
|
|
261
|
+
*
|
|
262
|
+
*/
|
|
263
|
+
handleClick(ev) {
|
|
264
|
+
return this.tree.handleNodeClick.call(this.tree, this, ev);
|
|
265
|
+
}
|
|
266
|
+
handleDoubleClick(ev) {
|
|
267
|
+
return this.tree.handleNodeDoubleClick.call(this.tree, this, ev);
|
|
268
|
+
}
|
|
269
|
+
handleExpanderClick(ev) {
|
|
270
|
+
return this.tree.handleNodeExpanderClick.call(this.tree, this, ev);
|
|
271
|
+
}
|
|
272
|
+
handleKeyDown(ev) {
|
|
273
|
+
return this.tree.handleNodeKeyDown.call(this.tree, this, ev);
|
|
274
|
+
}
|
|
275
|
+
handleSelectionEvent(mods) {
|
|
276
|
+
return this.tree.handleSelectionEvent.call(this.tree, this, mods);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function getNodePath(node) {
|
|
281
|
+
const path = [node];
|
|
282
|
+
let current = node;
|
|
283
|
+
while (current.parent) {
|
|
284
|
+
current = current.parent;
|
|
285
|
+
path.unshift(current);
|
|
286
|
+
}
|
|
287
|
+
return path;
|
|
288
|
+
}
|
|
289
|
+
function findCommonAncestor(nodeA, nodeB) {
|
|
290
|
+
const pathA = getNodePath(nodeA);
|
|
291
|
+
const pathB = getNodePath(nodeB);
|
|
292
|
+
let commonAncestor = pathA[0];
|
|
293
|
+
let i = 0;
|
|
294
|
+
for (i; i < Math.min(pathA.length, pathB.length); i++) {
|
|
295
|
+
if (pathA[i] === pathB[i]) {
|
|
296
|
+
commonAncestor = pathA[i];
|
|
297
|
+
} else {
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
const indexA = commonAncestor.getChildren().indexOf(pathA[i]);
|
|
302
|
+
const indexB = commonAncestor.getChildren().indexOf(pathB[i]);
|
|
303
|
+
return [
|
|
304
|
+
commonAncestor,
|
|
305
|
+
indexA < indexB ? nodeA : nodeB,
|
|
306
|
+
indexA > indexB ? nodeA : nodeB,
|
|
307
|
+
indexA < indexB ? indexA : indexB,
|
|
308
|
+
indexA > indexB ? indexA : indexB
|
|
309
|
+
];
|
|
310
|
+
}
|
|
311
|
+
function getLastDescendant(node, conf) {
|
|
312
|
+
if (conf?.omitChildren) {
|
|
313
|
+
return node;
|
|
314
|
+
}
|
|
315
|
+
if (!conf?.omitCollapsed || node.state.isExpanded) {
|
|
316
|
+
const lastChild = node.getLastChildren(conf?.omitFiltered);
|
|
317
|
+
if (lastChild) {
|
|
318
|
+
return getLastDescendant(lastChild, conf);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return node;
|
|
322
|
+
}
|
|
323
|
+
function getPreviousNode(node, conf) {
|
|
324
|
+
const previousSibling = node.getPreviousSibling(conf?.omitFiltered);
|
|
325
|
+
if (previousSibling) {
|
|
326
|
+
return getLastDescendant(previousSibling, conf);
|
|
327
|
+
}
|
|
328
|
+
if (node.parent instanceof MobXTreeNode) {
|
|
329
|
+
return node.parent;
|
|
330
|
+
}
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
function getNextNode(node, conf) {
|
|
334
|
+
if (!conf?.omitChildren && (!conf?.omitCollapsed || node.state.isExpanded) && node.getChildren().length > 0) {
|
|
335
|
+
const firstChild = node.getChildren().find((c) => !conf?.omitFiltered || !c.state.isFiltered);
|
|
336
|
+
if (firstChild) {
|
|
337
|
+
return firstChild;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
const nextSibling = node.getFollowingSibling(conf?.omitFiltered);
|
|
341
|
+
if (nextSibling) {
|
|
342
|
+
return nextSibling;
|
|
343
|
+
}
|
|
344
|
+
if (node.parent instanceof MobXTreeNode) {
|
|
345
|
+
return getNextNode(node.parent, {
|
|
346
|
+
...conf,
|
|
347
|
+
omitChildren: true
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
function findAllNodesBetweenTwoNodes(nodeA, nodeB) {
|
|
353
|
+
const [, actualA, actualB] = findCommonAncestor(nodeA, nodeB);
|
|
354
|
+
const selectedNodes = [actualA];
|
|
355
|
+
if (nodeA !== nodeB) {
|
|
356
|
+
let node = getNextNode(actualA);
|
|
357
|
+
while (node !== null && node !== actualB) {
|
|
358
|
+
selectedNodes.push(node);
|
|
359
|
+
node = getNextNode(node);
|
|
360
|
+
}
|
|
361
|
+
if (node === null) {
|
|
362
|
+
throw new Error("Error on findAllNodesBetweenTwoNodes");
|
|
363
|
+
} else {
|
|
364
|
+
selectedNodes.push(node);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return selectedNodes;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
async function handleSelectionEvent(node, mods) {
|
|
371
|
+
const focused = this.focusedNode || this.getFirstChildren(true) || node;
|
|
372
|
+
let newSelection = /* @__PURE__ */ new Set();
|
|
373
|
+
if (mods?.shiftKey) {
|
|
374
|
+
newSelection = new Set(this.selectedItems);
|
|
375
|
+
findAllNodesBetweenTwoNodes(focused, node).forEach(
|
|
376
|
+
(c) => newSelection.add(c)
|
|
377
|
+
);
|
|
378
|
+
} else if (mods?.ctrlKey) {
|
|
379
|
+
newSelection = this.selectedItems;
|
|
380
|
+
if (newSelection.has(node)) {
|
|
381
|
+
newSelection.delete(node);
|
|
382
|
+
} else {
|
|
383
|
+
newSelection.add(node);
|
|
384
|
+
}
|
|
385
|
+
} else {
|
|
386
|
+
newSelection.add(node);
|
|
387
|
+
}
|
|
388
|
+
const res = await this.state.onSelect?.(new Set(newSelection));
|
|
389
|
+
if (res !== false) {
|
|
390
|
+
this.setSelectedNodes(new Set(newSelection));
|
|
391
|
+
}
|
|
392
|
+
this.focusNode(node);
|
|
393
|
+
}
|
|
394
|
+
function handleNodeDoubleClick(node, ev) {
|
|
395
|
+
this.state.onNodeDoubleClick?.(ev, node);
|
|
396
|
+
}
|
|
397
|
+
function handleNodeExpanderClick(node, ev) {
|
|
398
|
+
this.state.onNodeExpanderClick?.(ev, node);
|
|
399
|
+
if (!ev.isDefaultPrevented()) {
|
|
400
|
+
ev.stopPropagation();
|
|
401
|
+
node.toggleExpansion();
|
|
402
|
+
this.handleSelectionEvent(node, ev);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function handleNodeClick(node, ev) {
|
|
406
|
+
node.state.onClick?.(ev);
|
|
407
|
+
this.state.onNodeClick?.(ev, node);
|
|
408
|
+
if (!ev.isDefaultPrevented()) {
|
|
409
|
+
ev.preventDefault();
|
|
410
|
+
if (this.state.toggleNodesOnLabelClick !== false) {
|
|
411
|
+
node.toggleExpansion();
|
|
412
|
+
}
|
|
413
|
+
this.handleSelectionEvent(node, ev);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
function handleNodeKeyDown(node, ev) {
|
|
417
|
+
node.state.onKeyDown?.(ev);
|
|
418
|
+
if (ev.key === "Enter") {
|
|
419
|
+
node.state.onClick?.(ev);
|
|
420
|
+
}
|
|
421
|
+
this.state.onNodeKeyDown?.(ev, node);
|
|
422
|
+
const assignSelection = (newFocusedNode, innerEvent = ev) => {
|
|
423
|
+
ev.preventDefault();
|
|
424
|
+
this.handleSelectionEvent(newFocusedNode, innerEvent);
|
|
425
|
+
};
|
|
426
|
+
if (!ev.isDefaultPrevented()) {
|
|
427
|
+
switch (ev.code) {
|
|
428
|
+
case "ArrowDown": {
|
|
429
|
+
const nextFocused = getNextNode(node, {
|
|
430
|
+
omitFiltered: true,
|
|
431
|
+
omitCollapsed: true
|
|
432
|
+
});
|
|
433
|
+
if (nextFocused) {
|
|
434
|
+
assignSelection(nextFocused);
|
|
435
|
+
}
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
case "ArrowLeft":
|
|
439
|
+
if (!node.state.isDisabled) {
|
|
440
|
+
if (!node.state.isLeaf && node.state.isExpanded) {
|
|
441
|
+
node.toggleExpansion(false);
|
|
442
|
+
} else if (node.parent instanceof MobXTreeNode) {
|
|
443
|
+
assignSelection(node.parent);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
break;
|
|
447
|
+
case "ArrowRight":
|
|
448
|
+
if (!node.state.isDisabled && !node.state.isLeaf) {
|
|
449
|
+
if (!node.state.isExpanded) {
|
|
450
|
+
node.toggleExpansion(true);
|
|
451
|
+
} else {
|
|
452
|
+
const child = node.getFirstChildren(true);
|
|
453
|
+
if (child) {
|
|
454
|
+
assignSelection(child);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
break;
|
|
459
|
+
case "ArrowUp": {
|
|
460
|
+
const previousFocused = getPreviousNode(node, {
|
|
461
|
+
omitFiltered: true,
|
|
462
|
+
omitCollapsed: true
|
|
463
|
+
});
|
|
464
|
+
if (previousFocused) {
|
|
465
|
+
assignSelection(previousFocused);
|
|
466
|
+
}
|
|
467
|
+
break;
|
|
468
|
+
}
|
|
469
|
+
case "End": {
|
|
470
|
+
const lastChild = this.getLastChildren(true);
|
|
471
|
+
if (lastChild) {
|
|
472
|
+
const nextFocused = getLastDescendant(lastChild, {
|
|
473
|
+
omitCollapsed: true,
|
|
474
|
+
omitFiltered: true
|
|
475
|
+
});
|
|
476
|
+
assignSelection(nextFocused);
|
|
477
|
+
}
|
|
478
|
+
break;
|
|
479
|
+
}
|
|
480
|
+
case "Home": {
|
|
481
|
+
const nextFocused = this.getFirstChildren(true);
|
|
482
|
+
if (nextFocused) {
|
|
483
|
+
assignSelection(nextFocused);
|
|
484
|
+
}
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
case "PageDown": {
|
|
488
|
+
ev.preventDefault();
|
|
489
|
+
let nextFocused = getNextNode(node, {
|
|
490
|
+
omitFiltered: true,
|
|
491
|
+
omitCollapsed: true
|
|
492
|
+
});
|
|
493
|
+
if (nextFocused) {
|
|
494
|
+
for (let i = 0; i <= 10; i++) {
|
|
495
|
+
const newPrevious = getNextNode(nextFocused, {
|
|
496
|
+
omitFiltered: true,
|
|
497
|
+
omitCollapsed: true
|
|
498
|
+
});
|
|
499
|
+
if (newPrevious) {
|
|
500
|
+
nextFocused = newPrevious;
|
|
501
|
+
} else {
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
assignSelection(nextFocused);
|
|
506
|
+
}
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
case "PageUp": {
|
|
510
|
+
ev.preventDefault();
|
|
511
|
+
let previousFocused = getPreviousNode(node, {
|
|
512
|
+
omitFiltered: true,
|
|
513
|
+
omitCollapsed: true
|
|
514
|
+
});
|
|
515
|
+
if (previousFocused) {
|
|
516
|
+
for (let i = 0; i <= 10; i++) {
|
|
517
|
+
const newPrevious = getPreviousNode(previousFocused, {
|
|
518
|
+
omitFiltered: true,
|
|
519
|
+
omitCollapsed: true
|
|
520
|
+
});
|
|
521
|
+
if (newPrevious) {
|
|
522
|
+
previousFocused = newPrevious;
|
|
523
|
+
} else {
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
assignSelection(previousFocused);
|
|
528
|
+
}
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
case "Space": {
|
|
532
|
+
assignSelection(
|
|
533
|
+
this.focusedNode || this.getFirstChildren(true) || node,
|
|
534
|
+
Object.assign(ev, { type: "click" })
|
|
535
|
+
);
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
const MobXTreeEventsHandler = {
|
|
542
|
+
handleNodeClick,
|
|
543
|
+
handleNodeDoubleClick,
|
|
544
|
+
handleNodeExpanderClick,
|
|
545
|
+
handleNodeKeyDown,
|
|
546
|
+
handleSelectionEvent
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
var __defProp = Object.defineProperty;
|
|
550
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
551
|
+
var __publicField = (obj, key, value) => {
|
|
552
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
553
|
+
return value;
|
|
554
|
+
};
|
|
555
|
+
class MobXTree {
|
|
556
|
+
constructor(initialTreeState) {
|
|
557
|
+
__publicField(this, "focusedNode", null);
|
|
558
|
+
__publicField(this, "indexedChildren", /* @__PURE__ */ new Map());
|
|
559
|
+
__publicField(this, "parent", null);
|
|
560
|
+
__publicField(this, "selectedItems", /* @__PURE__ */ new Set());
|
|
561
|
+
__publicField(this, "state", {
|
|
562
|
+
"aria-label": "",
|
|
563
|
+
children: /* @__PURE__ */ new Map(),
|
|
564
|
+
className: "",
|
|
565
|
+
disableSelection: false,
|
|
566
|
+
filterString: "",
|
|
567
|
+
hideEmptyFolders: false,
|
|
568
|
+
id: v4(),
|
|
569
|
+
isLoading: false,
|
|
570
|
+
isMultiple: true,
|
|
571
|
+
selectionMode: "explicit",
|
|
572
|
+
title: "",
|
|
573
|
+
toggleNodesOnLabelClick: true,
|
|
574
|
+
variant: ""
|
|
575
|
+
});
|
|
576
|
+
Object.assign(this.state, initialTreeState ?? {});
|
|
577
|
+
makeAutoObservable(this, {
|
|
578
|
+
getChild: false,
|
|
579
|
+
getChildren: false,
|
|
580
|
+
getFirstChildren: false,
|
|
581
|
+
getFollowingSibling: false,
|
|
582
|
+
getLastChildren: false,
|
|
583
|
+
getPreviousSibling: false,
|
|
584
|
+
getSibling: false,
|
|
585
|
+
handleNodeDoubleClick: false,
|
|
586
|
+
parent: false,
|
|
587
|
+
getNodeById: false,
|
|
588
|
+
id: false,
|
|
589
|
+
tree: false,
|
|
590
|
+
focusedNode: observable,
|
|
591
|
+
indexedChildren: observable,
|
|
592
|
+
selectedItems: observable,
|
|
593
|
+
state: observable,
|
|
594
|
+
append: action,
|
|
595
|
+
clearSelection: action,
|
|
596
|
+
create: action,
|
|
597
|
+
focusNode: action,
|
|
598
|
+
handleNodeClick: action,
|
|
599
|
+
handleNodeExpanderClick: action,
|
|
600
|
+
handleNodeKeyDown: action,
|
|
601
|
+
handleSelectionEvent: action,
|
|
602
|
+
removeAllChildren: action,
|
|
603
|
+
removeChild: action,
|
|
604
|
+
reviewFocus: action,
|
|
605
|
+
setSelectedNodes: action,
|
|
606
|
+
toggleNodeSelection: action
|
|
607
|
+
});
|
|
608
|
+
reaction(
|
|
609
|
+
() => this.state.toggleNodesOnLabelClick,
|
|
610
|
+
() => {
|
|
611
|
+
console.log(this.state.toggleNodesOnLabelClick);
|
|
612
|
+
}
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
get id() {
|
|
616
|
+
return this.state.id;
|
|
617
|
+
}
|
|
618
|
+
get tree() {
|
|
619
|
+
return this;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
*
|
|
623
|
+
*
|
|
624
|
+
* OWN METHODS
|
|
625
|
+
*
|
|
626
|
+
*
|
|
627
|
+
*/
|
|
628
|
+
clearSelection() {
|
|
629
|
+
[...this.selectedItems.values()].forEach(
|
|
630
|
+
(c) => this.toggleNodeSelection(c, false)
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
focusNode(node) {
|
|
634
|
+
const storedNode = this.getNodeById(node.id);
|
|
635
|
+
if (!node.state.isDisabled && storedNode instanceof MobXTreeNode) {
|
|
636
|
+
this.focusedNode = storedNode;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Devuelve el nodo con el id especificado o undefined si no existe.
|
|
641
|
+
*/
|
|
642
|
+
getNodeById(id) {
|
|
643
|
+
if (id === "root" || id === this.id)
|
|
644
|
+
return this;
|
|
645
|
+
return this.indexedChildren.get(id);
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Actúa si el nodo que está en foco ya no existe en el árbol y restaura el foco en el primer nodo visible.
|
|
649
|
+
*/
|
|
650
|
+
reviewFocus() {
|
|
651
|
+
if (!this.getNodeById(this.focusedNode?.id ?? "")) {
|
|
652
|
+
const firstChild = this.getFirstChildren(true);
|
|
653
|
+
if (firstChild) {
|
|
654
|
+
this.focusNode(firstChild);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
setSelectedNodes(newSelection) {
|
|
659
|
+
this.clearSelection();
|
|
660
|
+
newSelection.forEach((value) => {
|
|
661
|
+
const node = typeof value === "string" ? this.getNodeById(value) : value;
|
|
662
|
+
if (node) {
|
|
663
|
+
this.toggleNodeSelection(node, true);
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
toggleNodeSelection(node, isSelected) {
|
|
668
|
+
if (!this.state.disableSelection && node.state.isSelectable && !node.state.isDisabled) {
|
|
669
|
+
const actualSelected = isSelected ?? !node.isSelected;
|
|
670
|
+
if (actualSelected) {
|
|
671
|
+
if (!this.state.isMultiple) {
|
|
672
|
+
this.selectedItems.clear();
|
|
673
|
+
}
|
|
674
|
+
this.selectedItems.add(node);
|
|
675
|
+
} else {
|
|
676
|
+
this.selectedItems.delete(node);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
*
|
|
682
|
+
*
|
|
683
|
+
* MobXChildKeeper
|
|
684
|
+
*
|
|
685
|
+
*
|
|
686
|
+
*/
|
|
687
|
+
append(node) {
|
|
688
|
+
MobXChildKeeper.append.call(this, node);
|
|
689
|
+
}
|
|
690
|
+
create(props) {
|
|
691
|
+
return MobXChildKeeper.create.call(this, props);
|
|
692
|
+
}
|
|
693
|
+
getChild(id) {
|
|
694
|
+
return MobXChildKeeper.getChild.call(this, id);
|
|
695
|
+
}
|
|
696
|
+
getChildren() {
|
|
697
|
+
return MobXChildKeeper.getChildren.call(this);
|
|
698
|
+
}
|
|
699
|
+
getFirstChildren(omitFiltered) {
|
|
700
|
+
return MobXChildKeeper.getFirstChildren.call(this, omitFiltered);
|
|
701
|
+
}
|
|
702
|
+
getLastChildren(omitFiltered) {
|
|
703
|
+
return MobXChildKeeper.getLastChildren.call(this, omitFiltered);
|
|
704
|
+
}
|
|
705
|
+
getFollowingSibling(omitFiltered) {
|
|
706
|
+
return MobXChildKeeper.getFollowingSibling.call(this, omitFiltered);
|
|
707
|
+
}
|
|
708
|
+
getPreviousSibling(omitFiltered) {
|
|
709
|
+
return MobXChildKeeper.getPreviousSibling.call(this, omitFiltered);
|
|
710
|
+
}
|
|
711
|
+
getSibling() {
|
|
712
|
+
return MobXChildKeeper.getSibling.call(this);
|
|
713
|
+
}
|
|
714
|
+
removeAllChildren() {
|
|
715
|
+
return MobXChildKeeper.removeAllChildren.call(this);
|
|
716
|
+
}
|
|
717
|
+
removeChild(param) {
|
|
718
|
+
return MobXChildKeeper.removeChild.call(this, param);
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
*
|
|
722
|
+
*
|
|
723
|
+
* MobXTreeEventsHandler
|
|
724
|
+
*
|
|
725
|
+
*
|
|
726
|
+
*/
|
|
727
|
+
handleNodeClick(node, ev) {
|
|
728
|
+
return MobXTreeEventsHandler.handleNodeClick.call(this, node, ev);
|
|
729
|
+
}
|
|
730
|
+
handleNodeDoubleClick(node, ev) {
|
|
731
|
+
return MobXTreeEventsHandler.handleNodeDoubleClick.call(this, node, ev);
|
|
732
|
+
}
|
|
733
|
+
handleNodeExpanderClick(node, ev) {
|
|
734
|
+
return MobXTreeEventsHandler.handleNodeExpanderClick.call(this, node, ev);
|
|
735
|
+
}
|
|
736
|
+
handleNodeKeyDown(node, ev) {
|
|
737
|
+
return MobXTreeEventsHandler.handleNodeKeyDown.call(this, node, ev);
|
|
738
|
+
}
|
|
739
|
+
handleSelectionEvent(node, mods) {
|
|
740
|
+
return MobXTreeEventsHandler.handleSelectionEvent.call(this, node, mods);
|
|
741
|
+
}
|
|
742
|
+
static fromNodes(nodes) {
|
|
743
|
+
const controller = new MobXTree({});
|
|
744
|
+
nodes.forEach((current) => {
|
|
745
|
+
const parent = current.parentId ? controller.getNodeById(current.parentId) : controller;
|
|
746
|
+
if (parent) {
|
|
747
|
+
parent.create(current);
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
return controller;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
export { MobXTree, MobXTreeNode };
|
|
755
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/store/error.ts","../src/store/MobXChildKeeper/MobXChildKeeper.ts","../src/store/MobXTreeNode.ts","../src/store/traversal.ts","../src/store/MobXTreeEventsHandler/MobXTreeEventsHandler.ts","../src/store/MobXTree.ts"],"sourcesContent":["export class DuplicatedNodeInsertionError extends Error {}\r\n","import { v4 } from 'uuid';\r\nimport { MobXTree } from '../MobXTree';\r\nimport { MobXTreeNode } from '../MobXTreeNode';\r\nimport { DuplicatedNodeInsertionError } from '../error';\r\nimport { TCreateNode } from '../types';\r\nimport { IMobXChildKeeper } from './types';\r\n\r\nexport const MobXChildKeeper: IMobXChildKeeper = {\r\n append(this: MobXTreeNode | MobXTree, node: MobXTreeNode) {\r\n const existingNode = this.tree.indexedChildren.get(node.id);\r\n\r\n if (existingNode && existingNode !== node) {\r\n console.error(\r\n new DuplicatedNodeInsertionError('Duplicated node insertion'),\r\n );\r\n return;\r\n }\r\n\r\n if (existingNode?.parent && existingNode.parent !== this) {\r\n existingNode.parent.removeChild(node.id);\r\n }\r\n\r\n this.state.children.set(node.id, node);\r\n this.tree.indexedChildren.set(node.id, node);\r\n\r\n node.parent = this;\r\n },\r\n create(\r\n this: MobXTreeNode | MobXTree,\r\n { id, initialState, parentId = this.id }: TCreateNode,\r\n ): MobXTreeNode {\r\n let parentNode = parentId ? this.tree.getNodeById(parentId) : this;\r\n\r\n if (!parentNode) {\r\n console.warn('Cannot find parent node with id = ', parentId);\r\n parentNode = this;\r\n }\r\n\r\n const newNode = new MobXTreeNode(id ?? v4(), parentNode, initialState);\r\n parentNode.append(newNode);\r\n\r\n if (initialState?.isSelected) {\r\n this.tree.toggleNodeSelection(newNode, true);\r\n }\r\n\r\n return newNode;\r\n },\r\n getChild(this: MobXTreeNode | MobXTree, id) {\r\n return this.state.children.get(id);\r\n },\r\n getChildren(this: MobXTreeNode | MobXTree): MobXTreeNode[] {\r\n return [...this.state.children.values()];\r\n },\r\n getFirstChildren(\r\n this: MobXTreeNode | MobXTree,\r\n omitFiltered?: boolean | undefined,\r\n ): MobXTreeNode | null {\r\n return (\r\n this.getChildren().find((c) => !c.state.isFiltered || !omitFiltered) ||\r\n null\r\n );\r\n },\r\n getLastChildren(\r\n this: MobXTreeNode | MobXTree,\r\n omitFiltered?: boolean | undefined,\r\n ): MobXTreeNode | null {\r\n return (\r\n this.getChildren().findLast(\r\n (c) => !c.state.isFiltered || !omitFiltered,\r\n ) || null\r\n );\r\n },\r\n getFollowingSibling(\r\n this: MobXTreeNode | MobXTree,\r\n omitFiltered?: boolean | undefined,\r\n ): MobXTreeNode | null {\r\n const sibling = this.getSibling();\r\n const thisIndex = sibling.indexOf(this as MobXTreeNode);\r\n\r\n for (let i = thisIndex + 1; i < sibling.length; i++) {\r\n if (!omitFiltered || !sibling[i].state.isFiltered) {\r\n return sibling[i];\r\n }\r\n }\r\n\r\n return null;\r\n },\r\n getPreviousSibling(\r\n this: MobXTreeNode | MobXTree,\r\n omitFiltered?: boolean | undefined,\r\n ): MobXTreeNode | null {\r\n const sibling = this.getSibling();\r\n const thisIndex = sibling.indexOf(this as MobXTreeNode);\r\n\r\n for (let i = thisIndex - 1; i >= 0; i--) {\r\n if (!omitFiltered || !sibling[i].state.isFiltered) {\r\n return sibling[i];\r\n }\r\n }\r\n\r\n return null;\r\n },\r\n getSibling(this: MobXTreeNode | MobXTree): MobXTreeNode[] {\r\n return this.parent?.getChildren() ?? [];\r\n },\r\n removeAllChildren(this: MobXTreeNode | MobXTree): void {\r\n this.getChildren().forEach(this.removeChild.bind(this));\r\n },\r\n removeChild(\r\n this: MobXTreeNode | MobXTree,\r\n param: string | MobXTreeNode,\r\n ): void {\r\n const id = param instanceof MobXTreeNode ? param.id : param;\r\n\r\n this.state.children\r\n .get(id)\r\n ?.getChildren()\r\n .forEach((c) => c.remove());\r\n\r\n this.state.children.delete(id);\r\n this.tree.indexedChildren.delete(id);\r\n\r\n this.tree.reviewFocus();\r\n },\r\n};\r\n","import { makeAutoObservable, action, observable, computed } from 'mobx';\r\nimport { MobXTree } from './MobXTree';\r\nimport { MobXTreeNodeState, TCreateNode } from './types';\r\nimport { IMobXChildKeeper } from './MobXChildKeeper/types';\r\nimport { MobXChildKeeper } from './MobXChildKeeper/MobXChildKeeper';\r\nimport { KeyboardEvent, MouseEvent } from 'react';\r\n\r\nexport class MobXTreeNode implements IMobXChildKeeper {\r\n state: MobXTreeNodeState = {\r\n 'aria-label': '',\r\n asyncNode: false,\r\n canCollapse: true,\r\n children: new Map(),\r\n className: '',\r\n color: '',\r\n hasLoaded: true,\r\n icon: null,\r\n iconSize: 'Md',\r\n isDisabled: false,\r\n isFiltered: false,\r\n isExpanded: false,\r\n isHidden: false,\r\n isLoading: false,\r\n isSelectable: true,\r\n label: '',\r\n labelIcons: [],\r\n labelRenderer: null,\r\n nodeProps: {},\r\n title: '',\r\n };\r\n\r\n constructor(\r\n public readonly id: string,\r\n public parent: MobXTreeNode | MobXTree | null,\r\n initialState?: Omit<Partial<MobXTreeNodeState>, 'children'>,\r\n ) {\r\n Object.assign(this.state, initialState);\r\n\r\n makeAutoObservable(this, {\r\n append: false,\r\n id: false,\r\n getChild: false,\r\n getChildren: false,\r\n getFirstChildren: false,\r\n getFollowingSibling: false,\r\n getLastChildren: false,\r\n getNodeProps: false,\r\n getPreviousSibling: false,\r\n getSibling: false,\r\n parent: false,\r\n tree: false,\r\n\r\n isFocused: computed,\r\n isSelected: computed,\r\n showExpander: computed,\r\n\r\n create: action,\r\n handleClick: action,\r\n handleDoubleClick: action,\r\n handleExpanderClick: action,\r\n handleKeyDown: action,\r\n handleSelectionEvent: action,\r\n remove: action,\r\n removeAllChildren: action,\r\n removeChild: action,\r\n toggleExpansion: action,\r\n\r\n state: observable,\r\n });\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * GETTERS\r\n *\r\n *\r\n */\r\n get isFocused() {\r\n return this.tree.focusedNode === this;\r\n }\r\n\r\n get isSelected() {\r\n return this.tree.selectedItems.has(this);\r\n }\r\n\r\n get showExpander() {\r\n return (\r\n this.state.canCollapse !== false &&\r\n (this.state.asyncNode ||\r\n this.state.isLeaf === false ||\r\n (this.state.isLeaf !== true && this.state.children.size > 0))\r\n );\r\n }\r\n\r\n /**\r\n * Da acceso al árbol raíz de cada nodo\r\n */\r\n get tree(): MobXTree {\r\n let parent: MobXTreeNode | MobXTree = this;\r\n while (parent.parent !== null) {\r\n parent = parent.parent;\r\n }\r\n\r\n if (!(parent instanceof MobXTree))\r\n throw new Error('The node is not inside the tree');\r\n\r\n return parent;\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * OWN METHODS\r\n *\r\n *\r\n */\r\n async toggleExpansion(isExpanded = !this.state.isExpanded) {\r\n if (this.state.canCollapse === false) {\r\n return;\r\n }\r\n\r\n if (\r\n !this.state.isExpanded &&\r\n isExpanded &&\r\n (this.state.asyncNode ||\r\n (!this.state.hasLoaded &&\r\n this.tree.state.onLoadData &&\r\n !this.getChildren().length))\r\n ) {\r\n if (!this.state.asyncNode) {\r\n this.state.hasLoaded = true;\r\n }\r\n let cancelIsLoading = false;\r\n setTimeout(() => {\r\n if (!cancelIsLoading) {\r\n this.state.isLoading = true;\r\n }\r\n }, 50);\r\n\r\n if (this.tree.state.onLoadData) {\r\n try {\r\n await this.tree.state.onLoadData?.(this);\r\n } catch (e) {\r\n console.error(e);\r\n }\r\n }\r\n\r\n this.state.isExpanded = true;\r\n cancelIsLoading = true;\r\n this.state.isLoading = false;\r\n } else {\r\n this.state.isExpanded = isExpanded;\r\n }\r\n }\r\n\r\n getNodeProps<T>() {\r\n return this.state.nodeProps as T;\r\n }\r\n\r\n remove() {\r\n this.parent?.removeChild(this.id);\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * MobXChildKeeper\r\n *\r\n *\r\n */\r\n append(node: MobXTreeNode) {\r\n return MobXChildKeeper.append.call(this, node);\r\n }\r\n create(props: TCreateNode): MobXTreeNode {\r\n return MobXChildKeeper.create.call(this, props);\r\n }\r\n getChild(id: string): MobXTreeNode | undefined {\r\n return MobXChildKeeper.getChild.call(this, id);\r\n }\r\n getChildren(): MobXTreeNode[] {\r\n return MobXChildKeeper.getChildren.call(this);\r\n }\r\n getFirstChildren(omitFiltered?: boolean | undefined): MobXTreeNode | null {\r\n return MobXChildKeeper.getFirstChildren.call(this, omitFiltered);\r\n }\r\n getLastChildren(omitFiltered?: boolean | undefined): MobXTreeNode | null {\r\n return MobXChildKeeper.getLastChildren.call(this, omitFiltered);\r\n }\r\n getFollowingSibling(omitFiltered?: boolean | undefined): MobXTreeNode | null {\r\n return MobXChildKeeper.getFollowingSibling.call(this, omitFiltered);\r\n }\r\n getPreviousSibling(omitFiltered?: boolean | undefined): MobXTreeNode | null {\r\n return MobXChildKeeper.getPreviousSibling.call(this, omitFiltered);\r\n }\r\n getSibling(): MobXTreeNode[] {\r\n return MobXChildKeeper.getSibling.call(this);\r\n }\r\n removeAllChildren(): void {\r\n return MobXChildKeeper.removeAllChildren.call(this);\r\n }\r\n removeChild(param: string | MobXTreeNode): void {\r\n return MobXChildKeeper.removeChild.call(this, param);\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * MobXTreeEventsHandler\r\n *\r\n *\r\n */\r\n handleClick(ev: MouseEvent) {\r\n return this.tree.handleNodeClick.call(this.tree, this, ev);\r\n }\r\n handleDoubleClick(ev: MouseEvent<Element, globalThis.MouseEvent>): void {\r\n return this.tree.handleNodeDoubleClick.call(this.tree, this, ev);\r\n }\r\n handleExpanderClick(ev: MouseEvent<Element, globalThis.MouseEvent>): void {\r\n return this.tree.handleNodeExpanderClick.call(this.tree, this, ev);\r\n }\r\n handleKeyDown(ev: KeyboardEvent<Element>): void {\r\n return this.tree.handleNodeKeyDown.call(this.tree, this, ev);\r\n }\r\n handleSelectionEvent(mods?: {\r\n ctrlKey?: boolean;\r\n shiftKey?: boolean;\r\n type: string;\r\n }) {\r\n return this.tree.handleSelectionEvent.call(this.tree, this, mods);\r\n }\r\n}\r\n","import { MobXTree } from './MobXTree';\r\nimport { MobXTreeNode } from './MobXTreeNode';\r\n\r\nexport function getNodePath(node: MobXTreeNode) {\r\n const path: (MobXTreeNode | MobXTree)[] = [node];\r\n let current: MobXTreeNode | MobXTree = node;\r\n while (current.parent) {\r\n current = current.parent;\r\n path.unshift(current);\r\n }\r\n return path;\r\n}\r\n\r\n/**\r\n * Resuelve el problema de saber cuál nodo va primero en el árbol para facilitar el algoritmo de búsqueda de nodos pertenecientes a la selección\r\n *\r\n * @returns [commonAncestor, firstSelected, lastSelected, indexAonCommon, indexBonCommon]\r\n */\r\nexport function findCommonAncestor(\r\n nodeA: MobXTreeNode,\r\n nodeB: MobXTreeNode,\r\n): [MobXTreeNode | MobXTree, MobXTreeNode, MobXTreeNode, number, number] {\r\n const pathA = getNodePath(nodeA);\r\n const pathB = getNodePath(nodeB);\r\n\r\n let commonAncestor: ReturnType<typeof getNodePath>[0] = pathA[0];\r\n\r\n let i = 0;\r\n for (i; i < Math.min(pathA.length, pathB.length); i++) {\r\n if (pathA[i] === pathB[i]) {\r\n commonAncestor = pathA[i];\r\n } else {\r\n break;\r\n }\r\n }\r\n\r\n const indexA = commonAncestor.getChildren().indexOf(pathA[i] as MobXTreeNode);\r\n const indexB = commonAncestor.getChildren().indexOf(pathB[i] as MobXTreeNode);\r\n\r\n return [\r\n commonAncestor,\r\n indexA < indexB ? nodeA : nodeB,\r\n indexA > indexB ? nodeA : nodeB,\r\n indexA < indexB ? indexA : indexB,\r\n indexA > indexB ? indexA : indexB,\r\n ];\r\n}\r\n\r\nexport function getAllDescendants(node: MobXTreeNode) {\r\n const descendants: MobXTreeNode[] = node.getChildren();\r\n\r\n descendants.forEach((current) => {\r\n descendants.push(...getAllDescendants(current));\r\n });\r\n\r\n return descendants;\r\n}\r\n\r\nexport type TTraverseTreeConf = {\r\n omitChildren?: boolean;\r\n /**\r\n * Elementos que no están a la vista porque su padre está colapsado\r\n */\r\n omitCollapsed?: boolean;\r\n omitFiltered?: boolean;\r\n};\r\n\r\n/**\r\n *\r\n * @param node\r\n * @returns\r\n */\r\nexport function getLastDescendant(\r\n node: MobXTreeNode,\r\n conf?: TTraverseTreeConf,\r\n): MobXTreeNode {\r\n if (conf?.omitChildren) {\r\n return node;\r\n }\r\n\r\n if (!conf?.omitCollapsed || node.state.isExpanded) {\r\n const lastChild = node.getLastChildren(conf?.omitFiltered);\r\n\r\n if (lastChild) {\r\n return getLastDescendant(lastChild, conf);\r\n }\r\n }\r\n\r\n return node;\r\n}\r\n\r\nexport function getPreviousNode(\r\n node: MobXTreeNode,\r\n conf?: TTraverseTreeConf,\r\n): MobXTreeNode | null {\r\n const previousSibling = node.getPreviousSibling(conf?.omitFiltered);\r\n if (previousSibling) {\r\n return getLastDescendant(previousSibling, conf);\r\n }\r\n if (node.parent instanceof MobXTreeNode) {\r\n return node.parent;\r\n }\r\n return null;\r\n}\r\n\r\nexport function getNextNode(\r\n node: MobXTreeNode,\r\n conf?: TTraverseTreeConf,\r\n): MobXTreeNode | null {\r\n if (\r\n !conf?.omitChildren &&\r\n (!conf?.omitCollapsed || node.state.isExpanded) &&\r\n node.getChildren().length > 0\r\n ) {\r\n const firstChild = node\r\n .getChildren()\r\n .find((c) => !conf?.omitFiltered || !c.state.isFiltered);\r\n\r\n if (firstChild) {\r\n return firstChild;\r\n }\r\n }\r\n\r\n const nextSibling = node.getFollowingSibling(conf?.omitFiltered);\r\n if (nextSibling) {\r\n return nextSibling;\r\n }\r\n\r\n if (node.parent instanceof MobXTreeNode) {\r\n return getNextNode(node.parent as MobXTreeNode, {\r\n ...conf,\r\n omitChildren: true,\r\n });\r\n }\r\n\r\n return null;\r\n}\r\n\r\nexport function findAllNodesBetweenTwoNodes(\r\n nodeA: MobXTreeNode,\r\n nodeB: MobXTreeNode,\r\n) {\r\n const [, actualA, actualB] = findCommonAncestor(nodeA, nodeB);\r\n const selectedNodes = [actualA];\r\n\r\n if (nodeA !== nodeB) {\r\n let node = getNextNode(actualA);\r\n while (node !== null && node !== actualB) {\r\n selectedNodes.push(node);\r\n node = getNextNode(node);\r\n }\r\n\r\n if (node === null) {\r\n throw new Error('Error on findAllNodesBetweenTwoNodes');\r\n } else {\r\n selectedNodes.push(node); // actualB\r\n }\r\n }\r\n\r\n return selectedNodes;\r\n}\r\n","import { KeyboardEvent, MouseEvent } from 'react';\r\nimport { MobXTree } from '../MobXTree';\r\nimport { MobXTreeNode } from '../MobXTreeNode';\r\nimport {\r\n findAllNodesBetweenTwoNodes,\r\n getLastDescendant,\r\n getNextNode,\r\n getPreviousNode,\r\n} from '../traversal';\r\nimport { IMobXTreeEventsHandler } from './types';\r\n\r\nexport async function handleSelectionEvent(\r\n this: MobXTree,\r\n node: MobXTreeNode,\r\n mods?: {\r\n ctrlKey?: boolean;\r\n shiftKey?: boolean;\r\n type: string;\r\n },\r\n) {\r\n const focused = this.focusedNode || this.getFirstChildren(true) || node;\r\n\r\n let newSelection: Set<MobXTreeNode> = new Set();\r\n\r\n if (mods?.shiftKey) {\r\n newSelection = new Set<MobXTreeNode>(this.selectedItems);\r\n findAllNodesBetweenTwoNodes(focused, node).forEach((c) =>\r\n newSelection.add(c),\r\n );\r\n } else if (mods?.ctrlKey) {\r\n newSelection = this.selectedItems;\r\n\r\n if (newSelection.has(node)) {\r\n newSelection.delete(node);\r\n } else {\r\n newSelection.add(node);\r\n }\r\n } else {\r\n newSelection.add(node);\r\n }\r\n\r\n const res = await this.state.onSelect?.(new Set(newSelection));\r\n if (res !== false) {\r\n this.setSelectedNodes(new Set(newSelection));\r\n }\r\n\r\n this.focusNode(node);\r\n}\r\n\r\nexport function handleNodeDoubleClick(\r\n this: MobXTree,\r\n node: MobXTreeNode,\r\n ev: MouseEvent,\r\n) {\r\n this.state.onNodeDoubleClick?.(ev, node);\r\n}\r\n\r\nexport function handleNodeExpanderClick(\r\n this: MobXTree,\r\n node: MobXTreeNode,\r\n ev: MouseEvent,\r\n) {\r\n this.state.onNodeExpanderClick?.(ev, node);\r\n\r\n if (!ev.isDefaultPrevented()) {\r\n ev.stopPropagation();\r\n node.toggleExpansion();\r\n this.handleSelectionEvent(node, ev);\r\n }\r\n}\r\n\r\nexport function handleNodeClick(\r\n this: MobXTree,\r\n node: MobXTreeNode,\r\n ev: MouseEvent,\r\n) {\r\n node.state.onClick?.(ev);\r\n this.state.onNodeClick?.(ev, node);\r\n\r\n if (!ev.isDefaultPrevented()) {\r\n ev.preventDefault();\r\n\r\n if (this.state.toggleNodesOnLabelClick !== false) {\r\n node.toggleExpansion();\r\n }\r\n\r\n this.handleSelectionEvent(node, ev);\r\n }\r\n}\r\n\r\nexport function handleNodeKeyDown(\r\n this: MobXTree,\r\n node: MobXTreeNode,\r\n ev: KeyboardEvent,\r\n) {\r\n node.state.onKeyDown?.(ev);\r\n if (ev.key === 'Enter') {\r\n node.state.onClick?.(ev as any);\r\n }\r\n this.state.onNodeKeyDown?.(ev, node);\r\n\r\n const assignSelection = (\r\n newFocusedNode: MobXTreeNode,\r\n innerEvent: KeyboardEvent = ev,\r\n ) => {\r\n ev.preventDefault();\r\n this.handleSelectionEvent(newFocusedNode, innerEvent);\r\n };\r\n\r\n if (!ev.isDefaultPrevented()) {\r\n switch (ev.code) {\r\n case 'ArrowDown': {\r\n const nextFocused = getNextNode(node, {\r\n omitFiltered: true,\r\n omitCollapsed: true,\r\n });\r\n\r\n if (nextFocused) {\r\n assignSelection(nextFocused);\r\n }\r\n break;\r\n }\r\n case 'ArrowLeft':\r\n if (!node.state.isDisabled) {\r\n if (!node.state.isLeaf && node.state.isExpanded) {\r\n node.toggleExpansion(false);\r\n } else if (node.parent instanceof MobXTreeNode) {\r\n assignSelection(node.parent);\r\n }\r\n }\r\n break;\r\n case 'ArrowRight':\r\n if (!node.state.isDisabled && !node.state.isLeaf) {\r\n if (!node.state.isExpanded) {\r\n node.toggleExpansion(true);\r\n } else {\r\n const child = node.getFirstChildren(true);\r\n if (child) {\r\n assignSelection(child);\r\n }\r\n }\r\n }\r\n break;\r\n case 'ArrowUp': {\r\n const previousFocused = getPreviousNode(node, {\r\n omitFiltered: true,\r\n omitCollapsed: true,\r\n });\r\n\r\n if (previousFocused) {\r\n assignSelection(previousFocused);\r\n }\r\n break;\r\n }\r\n case 'End': {\r\n const lastChild = this.getLastChildren(true);\r\n\r\n if (lastChild) {\r\n const nextFocused = getLastDescendant(lastChild, {\r\n omitCollapsed: true,\r\n omitFiltered: true,\r\n });\r\n\r\n assignSelection(nextFocused);\r\n }\r\n break;\r\n }\r\n case 'Home': {\r\n const nextFocused = this.getFirstChildren(true);\r\n\r\n if (nextFocused) {\r\n assignSelection(nextFocused);\r\n }\r\n break;\r\n }\r\n case 'PageDown': {\r\n ev.preventDefault();\r\n\r\n let nextFocused = getNextNode(node, {\r\n omitFiltered: true,\r\n omitCollapsed: true,\r\n });\r\n\r\n if (nextFocused) {\r\n for (let i = 0; i <= 10; i++) {\r\n const newPrevious = getNextNode(nextFocused, {\r\n omitFiltered: true,\r\n omitCollapsed: true,\r\n });\r\n if (newPrevious) {\r\n nextFocused = newPrevious;\r\n } else {\r\n break;\r\n }\r\n }\r\n\r\n assignSelection(nextFocused);\r\n }\r\n break;\r\n }\r\n case 'PageUp': {\r\n ev.preventDefault();\r\n\r\n let previousFocused = getPreviousNode(node, {\r\n omitFiltered: true,\r\n omitCollapsed: true,\r\n });\r\n\r\n if (previousFocused) {\r\n for (let i = 0; i <= 10; i++) {\r\n const newPrevious = getPreviousNode(previousFocused, {\r\n omitFiltered: true,\r\n omitCollapsed: true,\r\n });\r\n if (newPrevious) {\r\n previousFocused = newPrevious;\r\n } else {\r\n break;\r\n }\r\n }\r\n\r\n assignSelection(previousFocused);\r\n }\r\n break;\r\n }\r\n case 'Space': {\r\n assignSelection(\r\n this.focusedNode || this.getFirstChildren(true) || node,\r\n Object.assign(ev, { type: 'click' }) as any,\r\n );\r\n break;\r\n }\r\n }\r\n }\r\n}\r\n\r\nexport const MobXTreeEventsHandler: IMobXTreeEventsHandler = {\r\n handleNodeClick,\r\n handleNodeDoubleClick,\r\n handleNodeExpanderClick,\r\n handleNodeKeyDown,\r\n handleSelectionEvent,\r\n};\r\n","import { action, makeAutoObservable, observable, reaction } from 'mobx';\r\nimport type { MobXTreeNodeState, MobXTreeState, TCreateNode } from './types';\r\nimport { MobXTreeNode } from './MobXTreeNode';\r\nimport { v4 } from 'uuid';\r\nimport { MobXTreeEventsHandler } from './MobXTreeEventsHandler/MobXTreeEventsHandler';\r\nimport { IMobXChildKeeper } from './MobXChildKeeper/types';\r\nimport { MobXChildKeeper } from './MobXChildKeeper/MobXChildKeeper';\r\nimport { IMobXTreeEventsHandler } from './MobXTreeEventsHandler/types';\r\nimport { MouseEvent, KeyboardEvent } from 'react';\r\n\r\nexport class MobXTree implements IMobXChildKeeper, IMobXTreeEventsHandler {\r\n focusedNode: MobXTreeNode | null = null;\r\n get id() {\r\n return this.state.id;\r\n }\r\n indexedChildren: Map<string, MobXTreeNode> = new Map();\r\n public readonly parent = null;\r\n get tree() {\r\n return this;\r\n }\r\n selectedItems: Set<MobXTreeNode> = new Set();\r\n state: MobXTreeState = {\r\n 'aria-label': '',\r\n children: new Map(),\r\n className: '',\r\n disableSelection: false,\r\n filterString: '',\r\n hideEmptyFolders: false,\r\n id: v4(),\r\n isLoading: false,\r\n isMultiple: true,\r\n selectionMode: 'explicit',\r\n title: '',\r\n toggleNodesOnLabelClick: true,\r\n variant: '',\r\n };\r\n\r\n constructor(initialTreeState?: Omit<Partial<MobXTreeState>, 'children'>) {\r\n Object.assign(this.state, initialTreeState ?? {});\r\n\r\n makeAutoObservable(this, {\r\n getChild: false,\r\n getChildren: false,\r\n getFirstChildren: false,\r\n getFollowingSibling: false,\r\n getLastChildren: false,\r\n getPreviousSibling: false,\r\n getSibling: false,\r\n handleNodeDoubleClick: false,\r\n parent: false,\r\n getNodeById: false,\r\n id: false,\r\n tree: false,\r\n\r\n focusedNode: observable,\r\n indexedChildren: observable,\r\n selectedItems: observable,\r\n state: observable,\r\n\r\n append: action,\r\n clearSelection: action,\r\n create: action,\r\n focusNode: action,\r\n handleNodeClick: action,\r\n handleNodeExpanderClick: action,\r\n handleNodeKeyDown: action,\r\n handleSelectionEvent: action,\r\n removeAllChildren: action,\r\n removeChild: action,\r\n reviewFocus: action,\r\n setSelectedNodes: action,\r\n toggleNodeSelection: action,\r\n });\r\n\r\n reaction(\r\n () => this.state.toggleNodesOnLabelClick,\r\n () => {\r\n console.log(this.state.toggleNodesOnLabelClick);\r\n },\r\n );\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * OWN METHODS\r\n *\r\n *\r\n */\r\n clearSelection() {\r\n [...this.selectedItems.values()].forEach((c) =>\r\n this.toggleNodeSelection(c, false),\r\n );\r\n }\r\n\r\n focusNode(node: MobXTreeNode) {\r\n const storedNode = this.getNodeById(node.id);\r\n if (!node.state.isDisabled && storedNode instanceof MobXTreeNode) {\r\n this.focusedNode = storedNode;\r\n }\r\n }\r\n\r\n /**\r\n * Devuelve el nodo con el id especificado o undefined si no existe.\r\n */\r\n getNodeById(id: string) {\r\n if (id === 'root' || id === this.id) return this;\r\n\r\n return this.indexedChildren.get(id);\r\n }\r\n\r\n /**\r\n * Actúa si el nodo que está en foco ya no existe en el árbol y restaura el foco en el primer nodo visible.\r\n */\r\n reviewFocus() {\r\n if (!this.getNodeById(this.focusedNode?.id ?? '')) {\r\n const firstChild = this.getFirstChildren(true);\r\n if (firstChild) {\r\n this.focusNode(firstChild);\r\n }\r\n }\r\n }\r\n\r\n setSelectedNodes(newSelection: Set<string>): void;\r\n setSelectedNodes(newSelection: Set<MobXTreeNode>): void;\r\n setSelectedNodes(newSelection: Set<string> | Set<MobXTreeNode>): void {\r\n this.clearSelection();\r\n newSelection.forEach((value) => {\r\n const node: MobXTreeNode = (\r\n typeof value === 'string' ? this.getNodeById(value) : value\r\n ) as MobXTreeNode;\r\n\r\n if (node) {\r\n this.toggleNodeSelection(node, true);\r\n }\r\n });\r\n }\r\n\r\n toggleNodeSelection(node: MobXTreeNode, isSelected?: boolean) {\r\n if (\r\n !this.state.disableSelection &&\r\n node.state.isSelectable &&\r\n !node.state.isDisabled\r\n ) {\r\n const actualSelected = isSelected ?? !node.isSelected;\r\n\r\n if (actualSelected) {\r\n if (!this.state.isMultiple) {\r\n this.selectedItems.clear();\r\n }\r\n this.selectedItems.add(node);\r\n } else {\r\n this.selectedItems.delete(node);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * MobXChildKeeper\r\n *\r\n *\r\n */\r\n append(node: MobXTreeNode) {\r\n MobXChildKeeper.append.call(this, node);\r\n }\r\n create(props: TCreateNode): MobXTreeNode {\r\n return MobXChildKeeper.create.call(this, props);\r\n }\r\n getChild(id: string): MobXTreeNode | undefined {\r\n return MobXChildKeeper.getChild.call(this, id);\r\n }\r\n getChildren(): MobXTreeNode[] {\r\n return MobXChildKeeper.getChildren.call(this);\r\n }\r\n getFirstChildren(omitFiltered?: boolean | undefined): MobXTreeNode | null {\r\n return MobXChildKeeper.getFirstChildren.call(this, omitFiltered);\r\n }\r\n getLastChildren(omitFiltered?: boolean | undefined): MobXTreeNode | null {\r\n return MobXChildKeeper.getLastChildren.call(this, omitFiltered);\r\n }\r\n getFollowingSibling(omitFiltered?: boolean | undefined): MobXTreeNode | null {\r\n return MobXChildKeeper.getFollowingSibling.call(this, omitFiltered);\r\n }\r\n getPreviousSibling(omitFiltered?: boolean | undefined): MobXTreeNode | null {\r\n return MobXChildKeeper.getPreviousSibling.call(this, omitFiltered);\r\n }\r\n getSibling(): MobXTreeNode[] {\r\n return MobXChildKeeper.getSibling.call(this);\r\n }\r\n removeAllChildren(): void {\r\n return MobXChildKeeper.removeAllChildren.call(this);\r\n }\r\n removeChild(param: string | MobXTreeNode): void {\r\n return MobXChildKeeper.removeChild.call(this, param);\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * MobXTreeEventsHandler\r\n *\r\n *\r\n */\r\n handleNodeClick(node: MobXTreeNode, ev: MouseEvent) {\r\n return MobXTreeEventsHandler.handleNodeClick.call(this, node, ev);\r\n }\r\n handleNodeDoubleClick(\r\n node: MobXTreeNode,\r\n ev: MouseEvent<Element, globalThis.MouseEvent>,\r\n ): void {\r\n return MobXTreeEventsHandler.handleNodeDoubleClick.call(this, node, ev);\r\n }\r\n handleNodeExpanderClick(\r\n node: MobXTreeNode,\r\n ev: MouseEvent<Element, globalThis.MouseEvent>,\r\n ): void {\r\n return MobXTreeEventsHandler.handleNodeExpanderClick.call(this, node, ev);\r\n }\r\n handleNodeKeyDown(node: MobXTreeNode, ev: KeyboardEvent<Element>): void {\r\n return MobXTreeEventsHandler.handleNodeKeyDown.call(this, node, ev);\r\n }\r\n handleSelectionEvent(\r\n node: MobXTreeNode,\r\n mods?: { ctrlKey?: boolean; shiftKey?: boolean; type: string },\r\n ) {\r\n return MobXTreeEventsHandler.handleSelectionEvent.call(this, node, mods);\r\n }\r\n\r\n public static fromNodes(nodes: MobxTreeStaticBuilderNode[]) {\r\n const controller = new MobXTree({});\r\n\r\n nodes.forEach((current) => {\r\n const parent = current.parentId\r\n ? controller.getNodeById(current.parentId)\r\n : controller;\r\n\r\n if (parent) {\r\n parent.create(current);\r\n }\r\n });\r\n\r\n return controller;\r\n }\r\n}\r\n\r\nexport type MobxTreeStaticBuilderNode = Omit<\r\n Partial<MobXTreeNodeState>,\r\n 'children'\r\n> & {\r\n parentId?: string;\r\n id: string;\r\n};\r\n"],"names":["__publicField"],"mappings":";;;AAAO,MAAM,qCAAqC,KAAA,CAAM;AAAC;;ACOlD,MAAM,eAAA,GAAoC;AAAA,EAC/C,OAAsC,IAAA,EAAoB;AACxD,IAAA,MAAM,eAAe,IAAA,CAAK,IAAA,CAAK,eAAA,CAAgB,GAAA,CAAI,KAAK,EAAE,CAAA;AAE1D,IAAA,IAAI,YAAA,IAAgB,iBAAiB,IAAA,EAAM;AACzC,MAAA,OAAA,CAAQ,KAAA;AAAA,QACN,IAAI,6BAA6B,2BAA2B;AAAA,OAC9D;AACA,MAAA;AAAA;AAGF,IAAA,IAAI,YAAA,EAAc,MAAA,IAAU,YAAA,CAAa,MAAA,KAAW,IAAA,EAAM;AACxD,MAAA,YAAA,CAAa,MAAA,CAAO,WAAA,CAAY,IAAA,CAAK,EAAE,CAAA;AAAA;AAGzC,IAAA,IAAA,CAAK,KAAA,CAAM,QAAA,CAAS,GAAA,CAAI,IAAA,CAAK,IAAI,IAAI,CAAA;AACrC,IAAA,IAAA,CAAK,IAAA,CAAK,eAAA,CAAgB,GAAA,CAAI,IAAA,CAAK,IAAI,IAAI,CAAA;AAE3C,IAAA,IAAA,CAAK,MAAA,GAAS,IAAA;AAAA,GAChB;AAAA,EACA,OAEE,EAAE,EAAA,EAAI,cAAc,QAAA,GAAW,IAAA,CAAK,IAAG,EACzB;AACd,IAA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IAAA,OAAO,qBAAA,CAAsB,iBAAA,CAAkB,IAAA,CAAK,IAAA,EAAM,MAAM,EAAE,CAAA;AAAA;AACpE,EACA,oBAAA,CACE,MACA,IAAA,EACA;AACA,IAAA,OAAO,qBAAA,CAAsB,oBAAA,CAAqB,IAAA,CAAK,IAAA,EAAM,MAAM,IAAI,CAAA;AAAA;AACzE,EAEA,OAAc,UAAU,KAAA,EAAoC;AAC1D,IAAA,MAAM,UAAA,GAAa,IAAI,QAAA,CAAS,EAAE,CAAA;AAElC,IAAA,KAAA,CAAM,OAAA,CAAQ,CAAC,OAAA,KAAY;AACzB,MAAA,MAAM,SAAS,OAAA,CAAQ,QAAA,GACnB,WAAW,WAAA,CAAY,OAAA,CAAQ,QAAQ,CAAA,GACvC,UAAA;AAEJ,MAAA,IAAI,MAAA,EAAQ;AACV,QAAA,MAAA,CAAO,OAAO,OAAO,CAAA;AAAA;AACvB,KACD,CAAA;AAED,IAAA,OAAO,UAAA;AAAA;AAEX;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apia/tree2-controller",
|
|
3
|
+
"version": "4.0.20",
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"author": "Alexis Leite <alexisleite@live.com>",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"typings": "dist/index.d.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"libDev": "rollup --config ../../config/rollup.common.mjs --environment MODE:development,ENTRY:index.ts",
|
|
12
|
+
"libBuild": "rollup --config ../../config/rollup.common.mjs --environment MODE:production,ENTRY:index.ts",
|
|
13
|
+
"libWatch": "rollup --watch --config ../../config/rollup.common.mjs --environment MODE:development,ENTRY:index.ts,WATCH:true",
|
|
14
|
+
"libWatchDevExecution": "rollup --watch --config ../../config/rollup.common.mjs --environment MODE:development,ENTRY:index.ts,WATCH:true,DEV_SERVER_MODULE:execution",
|
|
15
|
+
"libWatchDevDashboards": "rollup --watch --config ../../config/rollup.common.mjs --environment MODE:development,ENTRY:index.ts,WATCH:true,DEV_SERVER_MODULE:dashboards"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@types/uuid": "^9.0.8",
|
|
19
|
+
"ahooks": "^3.7.10",
|
|
20
|
+
"mobx": "^6.12.3",
|
|
21
|
+
"mobx-react-lite": "^4.0.7",
|
|
22
|
+
"uuid": "^9.0.1"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/react": "^18.2.43",
|
|
26
|
+
"@types/react-dom": "^18.2.17",
|
|
27
|
+
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
|
28
|
+
"axios": "^1.3.5",
|
|
29
|
+
"typescript": "5.4.2"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": "^18.2.0",
|
|
33
|
+
"react-dom": "^18.2.0"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public",
|
|
37
|
+
"registry": "https://registry.npmjs.org/"
|
|
38
|
+
},
|
|
39
|
+
"gitHead": "dabff9ca7bf9d14298fe7a661d73607a35a4df2a"
|
|
40
|
+
}
|