@acorex/components 20.2.26 → 20.2.27

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.
@@ -0,0 +1,337 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { TemplateRef } from '@angular/core';
3
+ import { AXEvent, AXHtmlEvent, AXValueChangedEvent } from '@acorex/cdk/common';
4
+ import { AXDropListDroppedEvent } from '@acorex/cdk/drag-drop';
5
+
6
+ /**
7
+ * Tree2 Component - Design Tokens
8
+ *
9
+ * The component supports the following CSS custom properties (design tokens):
10
+ *
11
+ * **Layout & Spacing:**
12
+ * - `--ax-comp-tree2-indent-size`: Indentation size for each tree level.
13
+ * Default: `12px`
14
+ * - `--ax-comp-tree2-node-margin`: Vertical margin between nodes.
15
+ * Default: `0.125rem`
16
+ *
17
+ * **Node Styling:**
18
+ * - `--ax-comp-tree2-node-border-radius`: Border radius for tree nodes.
19
+ * Default: `6px`
20
+ * - `--ax-comp-tree2-node-hover-bg`: Background color on node hover.
21
+ * Default: `rgba(var(--ax-sys-color-on-lightest-surface), 0.04)`
22
+ * - `--ax-comp-tree2-node-selected-bg`: Background color for selected nodes.
23
+ * Default: `rgba(var(--ax-sys-color-primary-500), 0.12)`
24
+ *
25
+ * **Tree Lines (with-line look):**
26
+ * - `--ax-comp-tree2-line-color`: Color for tree structure lines.
27
+ * Default: `rgba(var(--ax-sys-color-on-lightest-surface), 0.15)`
28
+ *
29
+ * **Drag & Drop:**
30
+ * - `--ax-comp-tree2-drag-preview-opacity`: Opacity of dragged element preview.
31
+ * Default: `0.9`
32
+ * - `--ax-comp-tree2-drag-placeholder-bg`: Background for drag placeholder.
33
+ * Default: `rgba(var(--ax-sys-color-on-lightest-surface), 0.02)`
34
+ * - `--ax-comp-tree2-drop-active-bg`: Background when hovering over valid drop zone.
35
+ * Default: `rgba(var(--ax-sys-color-primary-500), 0.08)`
36
+ * - `--ax-comp-tree2-drop-active-outline`: Outline color for active drop zones.
37
+ * Default: `rgba(var(--ax-sys-color-primary-500), 0.3)`
38
+ *
39
+ * **Dynamic Tokens (set via TypeScript):**
40
+ * - `--ax-tree-indent-size`: Dynamically set from `indentSize` input
41
+ * - `--ax-tree-line-offset`: Dynamically calculated as `indentSize / 2`
42
+ * - `--ax-tree-line-color`: Optional override for line color
43
+ *
44
+ * @example
45
+ * ```css
46
+ * // Customize tree appearance
47
+ * ax-tree2 {
48
+ * --ax-comp-tree2-indent-size: 16px;
49
+ * --ax-comp-tree2-node-selected-bg: rgba(var(--ax-sys-color-primary-600), 0.15);
50
+ * --ax-comp-tree2-line-color: rgba(var(--ax-sys-color-on-lightest-surface), 0.1);
51
+ * --ax-comp-tree2-node-hover-bg: rgba(var(--ax-sys-color-primary-500), 0.06);
52
+ * }
53
+ * ```
54
+ *
55
+ * @remarks
56
+ * All color tokens use Acorex design system variables (`--ax-sys-color-*`) for automatic
57
+ * light/dark mode support. Colors adapt based on the active theme without additional configuration.
58
+ */
59
+ interface AXTreeBeforeDropEvent extends AXEvent {
60
+ movedNode: AXTreeNode;
61
+ previousParent?: AXTreeNode;
62
+ currentParent?: AXTreeNode;
63
+ previousIndex: number;
64
+ currentIndex: number;
65
+ canceled: boolean;
66
+ }
67
+ interface AXTreeNode {
68
+ id: string;
69
+ label: string;
70
+ icon?: string;
71
+ expanded?: boolean;
72
+ selected?: boolean;
73
+ indeterminate?: boolean;
74
+ disabled?: boolean;
75
+ visible?: boolean;
76
+ children?: AXTreeNode[];
77
+ childrenCount?: number;
78
+ loading?: boolean;
79
+ data?: unknown;
80
+ }
81
+ interface AXTreeNodeToggleEvent extends AXHtmlEvent {
82
+ node: AXTreeNode;
83
+ }
84
+ interface AXTreeNodeSelectEvent extends AXHtmlEvent {
85
+ node: AXTreeNode;
86
+ }
87
+ interface AXTreeDropEvent extends AXEvent {
88
+ node: AXTreeNode;
89
+ previousParent?: AXTreeNode;
90
+ currentParent?: AXTreeNode;
91
+ previousIndex: number;
92
+ currentIndex: number;
93
+ }
94
+ interface AXTreeItemTemplateContext {
95
+ $implicit: AXTreeNode;
96
+ node: AXTreeNode;
97
+ level: number;
98
+ expanded: boolean;
99
+ childrenCount: number;
100
+ loading: boolean;
101
+ }
102
+ type AXTreeViewLook = 'default' | 'card' | 'with-line';
103
+ type AXTreeDragMode = 'none' | 'handler' | 'item';
104
+ type AXTreeDragOperationType = 'order-only' | 'move' | 'both';
105
+
106
+ declare class AXTree2Component {
107
+ #private;
108
+ private readonly ROOT_LIST_ID;
109
+ private readonly NODE_DROP_PREFIX;
110
+ private readonly LIST_PREFIX;
111
+ /** Tree data nodes */
112
+ nodes: _angular_core.ModelSignal<AXTreeNode[]>;
113
+ /** Whether to show checkboxes for selection */
114
+ showCheckbox: _angular_core.InputSignal<boolean>;
115
+ /** Drag and drop mode: 'none' (disabled), 'handler' (drag handle), 'item' (entire item) */
116
+ dragMode: _angular_core.InputSignal<AXTreeDragMode>;
117
+ /** Drag operation type: 'order-only' (reorder only), 'move' (move between parents), 'both' (allow both) */
118
+ dragOperationType: _angular_core.InputSignal<AXTreeDragOperationType>;
119
+ /** Whether to show icons */
120
+ showIcons: _angular_core.InputSignal<boolean>;
121
+ /** Whether to show children count badge */
122
+ showChildrenBadge: _angular_core.InputSignal<boolean>;
123
+ /** Custom icon for expanded nodes */
124
+ expandedIcon: _angular_core.InputSignal<string>;
125
+ /** Custom icon for collapsed nodes */
126
+ collapsedIcon: _angular_core.InputSignal<string>;
127
+ /** Indent size in pixels for each level */
128
+ indentSize: _angular_core.InputSignal<number>;
129
+ /** Node height in pixels */
130
+ nodeHeight: _angular_core.InputSignal<"compact" | "normal" | "comfortable">;
131
+ /** Visual style variant */
132
+ look: _angular_core.InputSignal<AXTreeViewLook>;
133
+ /** Custom template for tree items */
134
+ itemTemplate: _angular_core.InputSignal<TemplateRef<AXTreeItemTemplateContext>>;
135
+ /** Lazy load function for fetching children */
136
+ lazyLoad: _angular_core.InputSignal<(node: AXTreeNode) => Promise<AXTreeNode[]>>;
137
+ /** Whether to enable lazy loading */
138
+ enableLazyLoad: _angular_core.InputSignal<boolean>;
139
+ /** Emitted before a drop operation - set canceled to true to prevent drop */
140
+ onBeforeDrop: _angular_core.OutputEmitterRef<AXTreeBeforeDropEvent>;
141
+ /** Emitted when a node is toggled (expanded/collapsed) */
142
+ onNodeToggle: _angular_core.OutputEmitterRef<AXTreeNodeToggleEvent>;
143
+ /** Emitted when a node is selected/deselected */
144
+ onNodeSelect: _angular_core.OutputEmitterRef<AXTreeNodeSelectEvent>;
145
+ /** Emitted when nodes are reordered within the same parent */
146
+ onOrderChange: _angular_core.OutputEmitterRef<AXTreeDropEvent>;
147
+ /** Emitted when a node is moved to a different parent */
148
+ onMoveChange: _angular_core.OutputEmitterRef<AXTreeDropEvent>;
149
+ /** Emitted for any item change (order or move) */
150
+ onItemsChange: _angular_core.OutputEmitterRef<AXTreeDropEvent>;
151
+ /** Internal signal for tracking loading state */
152
+ protected readonly loadingNodes: _angular_core.WritableSignal<Set<string>>;
153
+ /**
154
+ * Toggle node expansion state with lazy loading support
155
+ */
156
+ toggleNode(node: AXTreeNode, event: Event): Promise<void>;
157
+ /**
158
+ * Load children for a node using lazy loading
159
+ */
160
+ private loadNodeChildren;
161
+ /**
162
+ * Update childrenCount flags for lazy loading
163
+ */
164
+ private updateHasChildrenFlags;
165
+ /**
166
+ * Toggle node selection state with indeterminate support
167
+ */
168
+ toggleSelection(node: AXTreeNode, event: AXValueChangedEvent): void;
169
+ /**
170
+ * Recursively select/deselect all children
171
+ */
172
+ private selectAllChildren;
173
+ /**
174
+ * Update parent node states based on children selection
175
+ */
176
+ private updateParentStates;
177
+ /**
178
+ * Get selection state of children
179
+ */
180
+ private getChildrenSelectionState;
181
+ /**
182
+ * Find parent node of a given node
183
+ */
184
+ private findParentNode;
185
+ /**
186
+ * Handle drop events for tree nodes
187
+ */
188
+ onDrop(event: AXDropListDroppedEvent, parentNode?: AXTreeNode): void;
189
+ /**
190
+ * Handle drop events when dropping directly onto a node (to make it a child)
191
+ */
192
+ onDropOntoNode(event: AXDropListDroppedEvent, targetNode: AXTreeNode): void;
193
+ /**
194
+ * Get array reference by drop list ID
195
+ */
196
+ private getArrayByListId;
197
+ /**
198
+ * Find parent node by list ID
199
+ */
200
+ private findParentByListId;
201
+ /**
202
+ * Find a node by ID in the tree
203
+ */
204
+ private findNodeById;
205
+ /**
206
+ * Check if targetNode is a descendant of ancestorNode (or the same node)
207
+ * Prevents circular references by checking if target exists in ancestor's children tree
208
+ */
209
+ private isNodeDescendantOf;
210
+ /**
211
+ * Generate unique list ID for each node
212
+ */
213
+ getListId(node?: AXTreeNode): string;
214
+ /**
215
+ * Expand all nodes in the tree (with lazy loading support)
216
+ */
217
+ expandAll(): Promise<void>;
218
+ /**
219
+ * Collapse all nodes in the tree
220
+ */
221
+ collapseAll(): void;
222
+ /**
223
+ * Recursively set expanded state (with lazy loading)
224
+ */
225
+ private setExpandedState;
226
+ /**
227
+ * Get count of selected nodes
228
+ */
229
+ getSelectedCount(): number;
230
+ /**
231
+ * Check if any nodes are selected
232
+ */
233
+ hasSelection(): boolean;
234
+ /**
235
+ * Recursively count selected nodes
236
+ */
237
+ private countSelected;
238
+ /**
239
+ * Get all selected nodes
240
+ */
241
+ getSelectedNodes(): AXTreeNode[];
242
+ /**
243
+ * Recursively collect selected nodes
244
+ */
245
+ private collectSelected;
246
+ /**
247
+ * Delete selected nodes from the tree
248
+ */
249
+ deleteSelected(): void;
250
+ /**
251
+ * Select all nodes in the tree
252
+ */
253
+ selectAll(): void;
254
+ /**
255
+ * Deselect all nodes in the tree
256
+ */
257
+ deselectAll(): void;
258
+ /**
259
+ * Find a node by ID in the tree
260
+ */
261
+ findNode(id: string): AXTreeNode | null;
262
+ /**
263
+ * Refresh the tree to trigger change detection
264
+ */
265
+ refresh(): void;
266
+ /**
267
+ * Recursively set selection state for all nodes
268
+ */
269
+ private setAllSelection;
270
+ /**
271
+ * Recursively remove selected nodes
272
+ */
273
+ private removeSelected;
274
+ /**
275
+ * Recursively update all parent states in the tree (used after deletion)
276
+ */
277
+ private updateAllParentStates;
278
+ /**
279
+ * Check if a node is currently loading
280
+ */
281
+ isNodeLoading(nodeId: string): boolean;
282
+ /**
283
+ * Get template context for a node
284
+ */
285
+ getTemplateContext(node: AXTreeNode, level?: number): AXTreeItemTemplateContext;
286
+ /**
287
+ * Check if node should show expand toggle
288
+ */
289
+ shouldShowExpandToggle(node: AXTreeNode): boolean;
290
+ /**
291
+ * Check if node has children
292
+ */
293
+ private hasChildren;
294
+ /**
295
+ * Check if node can be lazy loaded
296
+ */
297
+ private canLazyLoad;
298
+ /**
299
+ * Check if move operation is allowed based on dragOperationType
300
+ */
301
+ private canMoveToParent;
302
+ /**
303
+ * Check if reorder operation is allowed based on dragOperationType
304
+ */
305
+ private canReorder;
306
+ /**
307
+ * Validate if drop target is valid (prevent circular references)
308
+ */
309
+ private isValidDropTarget;
310
+ /**
311
+ * Handle reordering within the same list
312
+ */
313
+ private handleReorder;
314
+ /**
315
+ * Handle moving between different lists
316
+ */
317
+ private handleMove;
318
+ /**
319
+ * Emit beforeDrop event and return whether to continue
320
+ */
321
+ private emitBeforeDropEvent;
322
+ /**
323
+ * Emit drop events based on operation type
324
+ */
325
+ private emitDropEvents;
326
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXTree2Component, never>;
327
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXTree2Component, "ax-tree2", never, { "nodes": { "alias": "nodes"; "required": true; "isSignal": true; }; "showCheckbox": { "alias": "showCheckbox"; "required": false; "isSignal": true; }; "dragMode": { "alias": "dragMode"; "required": false; "isSignal": true; }; "dragOperationType": { "alias": "dragOperationType"; "required": false; "isSignal": true; }; "showIcons": { "alias": "showIcons"; "required": false; "isSignal": true; }; "showChildrenBadge": { "alias": "showChildrenBadge"; "required": false; "isSignal": true; }; "expandedIcon": { "alias": "expandedIcon"; "required": false; "isSignal": true; }; "collapsedIcon": { "alias": "collapsedIcon"; "required": false; "isSignal": true; }; "indentSize": { "alias": "indentSize"; "required": false; "isSignal": true; }; "nodeHeight": { "alias": "nodeHeight"; "required": false; "isSignal": true; }; "look": { "alias": "look"; "required": false; "isSignal": true; }; "itemTemplate": { "alias": "itemTemplate"; "required": false; "isSignal": true; }; "lazyLoad": { "alias": "lazyLoad"; "required": false; "isSignal": true; }; "enableLazyLoad": { "alias": "enableLazyLoad"; "required": false; "isSignal": true; }; }, { "nodes": "nodesChange"; "onBeforeDrop": "onBeforeDrop"; "onNodeToggle": "onNodeToggle"; "onNodeSelect": "onNodeSelect"; "onOrderChange": "onOrderChange"; "onMoveChange": "onMoveChange"; "onItemsChange": "onItemsChange"; }, never, never, true, never>;
328
+ }
329
+
330
+ declare class Tree2Module {
331
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<Tree2Module, never>;
332
+ static ɵmod: _angular_core.ɵɵNgModuleDeclaration<Tree2Module, never, [typeof AXTree2Component], never>;
333
+ static ɵinj: _angular_core.ɵɵInjectorDeclaration<Tree2Module>;
334
+ }
335
+
336
+ export { AXTree2Component, Tree2Module };
337
+ export type { AXTreeBeforeDropEvent, AXTreeDragMode, AXTreeDragOperationType, AXTreeDropEvent, AXTreeItemTemplateContext, AXTreeNode, AXTreeNodeSelectEvent, AXTreeNodeToggleEvent, AXTreeViewLook };