@stonecrop/atable 0.4.32 → 0.4.34

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/README.md CHANGED
@@ -19,6 +19,50 @@
19
19
 
20
20
  </details>
21
21
 
22
+ ## Tree View Configuration
23
+
24
+ ATable supports tree views with configurable default expansion states for hierarchical data. Use the `defaultTreeExpansion` option in your table configuration to control initial expansion behavior:
25
+
26
+ ```js
27
+ // Default behavior (no defaultTreeExpansion specified) - all nodes expanded
28
+ const config = {
29
+ view: 'tree'
30
+ }
31
+
32
+ // Only show root nodes (fully collapsed)
33
+ const config = {
34
+ view: 'tree',
35
+ defaultTreeExpansion: 'root'
36
+ }
37
+
38
+ // Show only nodes with gantt data and their paths (branch mode)
39
+ const config = {
40
+ view: 'tree',
41
+ defaultTreeExpansion: 'branch'
42
+ }
43
+
44
+ // Show all nodes (fully expanded) - same as default
45
+ const config = {
46
+ view: 'tree',
47
+ defaultTreeExpansion: 'leaf'
48
+ }
49
+ ```
50
+
51
+ **Expansion Modes:**
52
+ - `root`: Only top-level nodes are visible (fully collapsed)
53
+ - `branch`: Shows the minimal tree to display all nodes with gantt data. Only expands nodes that lead to gantt-enabled nodes, stops expanding at gantt nodes that have no gantt descendants
54
+ - `leaf`: All nodes are visible (fully expanded)
55
+ - `undefined` (default): All nodes start expanded (same as 'leaf' mode)
56
+
57
+ **Example Usage:**
58
+ ```vue
59
+ <ATable
60
+ v-model:rows="treeData"
61
+ v-model:columns="columns"
62
+ :config="{ view: 'tree', defaultTreeExpansion: 'branch' }"
63
+ />
64
+ ```
65
+
22
66
  ## Column API
23
67
 
24
68
  The primary API for ATable is the column object.
package/dist/atable.d.ts CHANGED
@@ -34,6 +34,30 @@ export { ATableLoadingBar }
34
34
 
35
35
  export { ATableModal }
36
36
 
37
+ /**
38
+ * Base table configuration properties shared across all view types.
39
+ * @public
40
+ */
41
+ export declare interface BaseTableConfig {
42
+ /**
43
+ * Control whether the table should be allowed to use the full width of its container.
44
+ *
45
+ * @defaultValue false
46
+ */
47
+ fullWidth?: boolean;
48
+ }
49
+
50
+ /**
51
+ * Table configuration for basic view types (uncounted, list, list-expansion).
52
+ * @public
53
+ */
54
+ export declare interface BasicTableConfig extends BaseTableConfig {
55
+ /**
56
+ * The type of view to display the table in.
57
+ */
58
+ view?: 'uncounted' | 'list' | 'list-expansion';
59
+ }
60
+
37
61
  /**
38
62
  * Table cell context definition.
39
63
  * @public
@@ -191,13 +215,37 @@ colspan?: number | undefined;
191
215
  originalIndex?: number | undefined;
192
216
  }[]>;
193
217
  config: Ref< {
194
- view?: "uncounted" | "list" | "list-expansion" | "tree" | "gantt" | "tree-gantt" | undefined;
218
+ view?: "uncounted" | "list" | "list-expansion" | undefined;
219
+ fullWidth?: boolean | undefined;
220
+ } | {
221
+ view: "tree";
222
+ defaultTreeExpansion?: "root" | "branch" | "leaf" | undefined;
195
223
  fullWidth?: boolean | undefined;
224
+ } | {
225
+ view: "gantt";
196
226
  dependencyGraph?: boolean | undefined;
227
+ fullWidth?: boolean | undefined;
228
+ } | {
229
+ view: "tree-gantt";
230
+ defaultTreeExpansion?: "root" | "branch" | "leaf" | undefined;
231
+ dependencyGraph?: boolean | undefined;
232
+ fullWidth?: boolean | undefined;
197
233
  }, TableConfig | {
198
- view?: "uncounted" | "list" | "list-expansion" | "tree" | "gantt" | "tree-gantt" | undefined;
234
+ view?: "uncounted" | "list" | "list-expansion" | undefined;
235
+ fullWidth?: boolean | undefined;
236
+ } | {
237
+ view: "tree";
238
+ defaultTreeExpansion?: "root" | "branch" | "leaf" | undefined;
199
239
  fullWidth?: boolean | undefined;
240
+ } | {
241
+ view: "gantt";
200
242
  dependencyGraph?: boolean | undefined;
243
+ fullWidth?: boolean | undefined;
244
+ } | {
245
+ view: "tree-gantt";
246
+ defaultTreeExpansion?: "root" | "branch" | "leaf" | undefined;
247
+ dependencyGraph?: boolean | undefined;
248
+ fullWidth?: boolean | undefined;
201
249
  }>;
202
250
  connectionHandles: Ref< {
203
251
  id: string;
@@ -426,13 +474,37 @@ colspan?: number | undefined;
426
474
  originalIndex?: number | undefined;
427
475
  }[]>;
428
476
  config: Ref< {
429
- view?: "uncounted" | "list" | "list-expansion" | "tree" | "gantt" | "tree-gantt" | undefined;
477
+ view?: "uncounted" | "list" | "list-expansion" | undefined;
478
+ fullWidth?: boolean | undefined;
479
+ } | {
480
+ view: "tree";
481
+ defaultTreeExpansion?: "root" | "branch" | "leaf" | undefined;
430
482
  fullWidth?: boolean | undefined;
483
+ } | {
484
+ view: "gantt";
485
+ dependencyGraph?: boolean | undefined;
486
+ fullWidth?: boolean | undefined;
487
+ } | {
488
+ view: "tree-gantt";
489
+ defaultTreeExpansion?: "root" | "branch" | "leaf" | undefined;
431
490
  dependencyGraph?: boolean | undefined;
491
+ fullWidth?: boolean | undefined;
432
492
  }, TableConfig | {
433
- view?: "uncounted" | "list" | "list-expansion" | "tree" | "gantt" | "tree-gantt" | undefined;
493
+ view?: "uncounted" | "list" | "list-expansion" | undefined;
494
+ fullWidth?: boolean | undefined;
495
+ } | {
496
+ view: "tree";
497
+ defaultTreeExpansion?: "root" | "branch" | "leaf" | undefined;
434
498
  fullWidth?: boolean | undefined;
499
+ } | {
500
+ view: "gantt";
501
+ dependencyGraph?: boolean | undefined;
502
+ fullWidth?: boolean | undefined;
503
+ } | {
504
+ view: "tree-gantt";
505
+ defaultTreeExpansion?: "root" | "branch" | "leaf" | undefined;
435
506
  dependencyGraph?: boolean | undefined;
507
+ fullWidth?: boolean | undefined;
436
508
  }>;
437
509
  connectionHandles: Ref< {
438
510
  id: string;
@@ -661,13 +733,37 @@ colspan?: number | undefined;
661
733
  originalIndex?: number | undefined;
662
734
  }[]>;
663
735
  config: Ref< {
664
- view?: "uncounted" | "list" | "list-expansion" | "tree" | "gantt" | "tree-gantt" | undefined;
736
+ view?: "uncounted" | "list" | "list-expansion" | undefined;
737
+ fullWidth?: boolean | undefined;
738
+ } | {
739
+ view: "tree";
740
+ defaultTreeExpansion?: "root" | "branch" | "leaf" | undefined;
665
741
  fullWidth?: boolean | undefined;
742
+ } | {
743
+ view: "gantt";
744
+ dependencyGraph?: boolean | undefined;
745
+ fullWidth?: boolean | undefined;
746
+ } | {
747
+ view: "tree-gantt";
748
+ defaultTreeExpansion?: "root" | "branch" | "leaf" | undefined;
666
749
  dependencyGraph?: boolean | undefined;
750
+ fullWidth?: boolean | undefined;
667
751
  }, TableConfig | {
668
- view?: "uncounted" | "list" | "list-expansion" | "tree" | "gantt" | "tree-gantt" | undefined;
752
+ view?: "uncounted" | "list" | "list-expansion" | undefined;
753
+ fullWidth?: boolean | undefined;
754
+ } | {
755
+ view: "tree";
756
+ defaultTreeExpansion?: "root" | "branch" | "leaf" | undefined;
669
757
  fullWidth?: boolean | undefined;
758
+ } | {
759
+ view: "gantt";
760
+ dependencyGraph?: boolean | undefined;
761
+ fullWidth?: boolean | undefined;
762
+ } | {
763
+ view: "tree-gantt";
764
+ defaultTreeExpansion?: "root" | "branch" | "leaf" | undefined;
670
765
  dependencyGraph?: boolean | undefined;
766
+ fullWidth?: boolean | undefined;
671
767
  }>;
672
768
  connectionHandles: Ref< {
673
769
  id: string;
@@ -961,6 +1057,24 @@ export declare interface GanttOptions {
961
1057
  colspan?: number;
962
1058
  }
963
1059
 
1060
+ /**
1061
+ * Table configuration for gantt view types.
1062
+ * @public
1063
+ */
1064
+ export declare interface GanttTableConfig extends BaseTableConfig {
1065
+ /**
1066
+ * The type of view to display the table in.
1067
+ */
1068
+ view: 'gantt';
1069
+ /**
1070
+ * Control whether dependency graph connections should be enabled for Gantt views.
1071
+ * When false, connection handles and dependency lines will be hidden.
1072
+ *
1073
+ * @defaultValue true
1074
+ */
1075
+ dependencyGraph?: boolean;
1076
+ }
1077
+
964
1078
  /**
965
1079
  * Install all ATable components
966
1080
  * @param app - Vue app instance
@@ -1103,34 +1217,10 @@ export declare interface TableColumn {
1103
1217
  }
1104
1218
 
1105
1219
  /**
1106
- * Table configuration definition.
1220
+ * Table configuration definition using discriminated unions for type safety.
1107
1221
  * @public
1108
1222
  */
1109
- export declare interface TableConfig {
1110
- /**
1111
- * The type of view to display the table in. Possible values:
1112
- * - `uncounted` - row numbers are not displayed in the table
1113
- * - `list` - row numbers are displayed in the table
1114
- * - `list-expansion` - carets are displayed in the number column that expand/collapse the row inline
1115
- * - `tree` - carets are displayed in the number column that expand/collapse grouped rows
1116
- * - `gantt` - view that allows specific rows to be displayed with Gantt functionality
1117
- * - `tree-gantt` - similar to `gantt`, but allows for tree functionality as well
1118
- */
1119
- view?: 'uncounted' | 'list' | 'list-expansion' | 'tree' | 'gantt' | 'tree-gantt';
1120
- /**
1121
- * Control whether the table should be allowed to use the full width of its container.
1122
- *
1123
- * @defaultValue false
1124
- */
1125
- fullWidth?: boolean;
1126
- /**
1127
- * Control whether dependency graph connections should be enabled for Gantt views.
1128
- * When false, connection handles and dependency lines will be hidden.
1129
- *
1130
- * @defaultValue true
1131
- */
1132
- dependencyGraph?: boolean;
1133
- }
1223
+ export declare type TableConfig = BasicTableConfig | TreeTableConfig | GanttTableConfig | TreeGanttTableConfig;
1134
1224
 
1135
1225
  /**
1136
1226
  * Table display definition.
@@ -1316,4 +1406,51 @@ export declare interface TableRow {
1316
1406
  gantt?: GanttOptions;
1317
1407
  }
1318
1408
 
1409
+ /**
1410
+ * Table configuration for tree-gantt view types.
1411
+ * @public
1412
+ */
1413
+ export declare interface TreeGanttTableConfig extends BaseTableConfig {
1414
+ /**
1415
+ * The type of view to display the table in.
1416
+ */
1417
+ view: 'tree-gantt';
1418
+ /**
1419
+ * Default expansion state for tree views. Possible values:
1420
+ * - `root` - Only top-level nodes are visible (fully collapsed)
1421
+ * - `branch` - Shows minimal tree to display all gantt nodes. Expands only the necessary paths to gantt nodes, stops at gantt nodes with no gantt descendants
1422
+ * - `leaf` - All nodes are visible (fully expanded)
1423
+ *
1424
+ * @defaultValue undefined (default behavior is 'leaf' mode)
1425
+ */
1426
+ defaultTreeExpansion?: 'root' | 'branch' | 'leaf';
1427
+ /**
1428
+ * Control whether dependency graph connections should be enabled for Gantt views.
1429
+ * When false, connection handles and dependency lines will be hidden.
1430
+ *
1431
+ * @defaultValue true
1432
+ */
1433
+ dependencyGraph?: boolean;
1434
+ }
1435
+
1436
+ /**
1437
+ * Table configuration for tree view types.
1438
+ * @public
1439
+ */
1440
+ export declare interface TreeTableConfig extends BaseTableConfig {
1441
+ /**
1442
+ * The type of view to display the table in.
1443
+ */
1444
+ view: 'tree';
1445
+ /**
1446
+ * Default expansion state for tree views. Possible values:
1447
+ * - `root` - Only top-level nodes are visible (fully collapsed)
1448
+ * - `branch` - Shows minimal tree to display all gantt nodes. Expands only the necessary paths to gantt nodes, stops at gantt nodes with no gantt descendants
1449
+ * - `leaf` - All nodes are visible (fully expanded)
1450
+ *
1451
+ * @defaultValue undefined (default behavior is 'leaf' mode)
1452
+ */
1453
+ defaultTreeExpansion?: 'root' | 'branch' | 'leaf';
1454
+ }
1455
+
1319
1456
  export { }