@stonecrop/atable 0.4.23 → 0.4.25

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.
@@ -1,4 +1,5 @@
1
1
  import { useElementBounding } from '@vueuse/core';
2
+ import type { Ref, ShallowRef } from 'vue';
2
3
  import { createTableStore } from '../stores/table';
3
4
  /**
4
5
  * Table column definition.
@@ -115,8 +116,8 @@ export interface TableColumn {
115
116
  */
116
117
  ganttComponent?: string;
117
118
  /**
118
- * The colspan of the Gantt-bar for the column. This is used to determine how many columns
119
- * the Gantt-bar should span.
119
+ * The colspan of the Gantt bar for the column. This determines how many columns
120
+ * the Gantt bar should span across.
120
121
  *
121
122
  * Only applicable for Gantt tables.
122
123
  *
@@ -124,8 +125,8 @@ export interface TableColumn {
124
125
  */
125
126
  colspan?: number;
126
127
  /**
127
- * The starting column index for the Gantt-bar, excluding any pinned columns. This is
128
- * evaluated automatically while rendering the table.
128
+ * The original column index for the Gantt bar, excluding any pinned columns.
129
+ * This is evaluated automatically while rendering the table.
129
130
  *
130
131
  * Only applicable for Gantt tables.
131
132
  *
@@ -164,8 +165,10 @@ export interface TableConfig {
164
165
  * - `list` - row numbers are displayed in the table
165
166
  * - `list-expansion` - carets are displayed in the number column that expand/collapse the row inline
166
167
  * - `tree` - carets are displayed in the number column that expand/collapse grouped rows
168
+ * - `gantt` - view that allows specific rows to be displayed with Gantt functionality
169
+ * - `tree-gantt` - similar to `gantt`, but allows for tree functionality as well
167
170
  */
168
- view?: 'uncounted' | 'list' | 'list-expansion' | 'tree' | 'gantt';
171
+ view?: 'uncounted' | 'list' | 'list-expansion' | 'tree' | 'gantt' | 'tree-gantt';
169
172
  /**
170
173
  * Control whether the table should be allowed to use the full width of its container.
171
174
  *
@@ -268,26 +271,30 @@ export interface TableRow {
268
271
  gantt?: GanttOptions;
269
272
  }
270
273
  /**
271
- * This interface defines the options for a row when it is being viewed as a Gantt chart.
274
+ * Gantt chart options for table rows.
272
275
  * @public
273
276
  */
274
277
  export interface GanttOptions {
275
278
  /**
276
- * The colour to be applied to the row's gantt bar.
279
+ * The color to be applied to the row's gantt bar.
280
+ *
281
+ * @defaultValue '#cccccc'
277
282
  */
278
283
  color?: string;
279
284
  /**
280
285
  * The starting column index for the gantt bar.
286
+ *
287
+ * @defaultValue 0
281
288
  */
282
289
  startIndex?: number;
283
290
  /**
284
- * The ending column index for the gantt bar. If the endIndex and colspan are not provided,
291
+ * The ending column index for the gantt bar. If endIndex and colspan are not provided,
285
292
  * the bar will stretch to the end of the table.
286
293
  */
287
294
  endIndex?: number;
288
295
  /**
289
- * The length of the gantt bar. Useful when only the start index is provided. If the
290
- * colspan and endIndex are not provided, the bar will stretch to the end of the table.
296
+ * The length of the gantt bar in columns. Useful when only the start index is provided.
297
+ * If colspan and endIndex are not provided, the bar will stretch to the end of the table.
291
298
  */
292
299
  colspan?: number;
293
300
  }
@@ -409,4 +416,125 @@ export interface TableModalProps {
409
416
  */
410
417
  store: ReturnType<typeof createTableStore>;
411
418
  }
419
+ /**
420
+ * Gantt bar information for VueFlow integration.
421
+ * @public
422
+ */
423
+ export interface GanttBarInfo {
424
+ /**
425
+ * Unique identifier for the gantt bar.
426
+ */
427
+ id: string;
428
+ /**
429
+ * The row index of the gantt bar.
430
+ */
431
+ rowIndex: number;
432
+ /**
433
+ * The primary column index of the gantt bar (typically the start index).
434
+ */
435
+ colIndex: number;
436
+ /**
437
+ * Starting column index of the gantt bar.
438
+ */
439
+ startIndex: Ref<number>;
440
+ /**
441
+ * Ending column index of the gantt bar.
442
+ */
443
+ endIndex: Ref<number>;
444
+ /**
445
+ * Color of the gantt bar.
446
+ */
447
+ color: Ref<string>;
448
+ /**
449
+ * The position of the gantt bar in the ATable component.
450
+ */
451
+ position: {
452
+ x: ShallowRef<number>;
453
+ y: ShallowRef<number>;
454
+ };
455
+ /**
456
+ * Display label for the gantt bar.
457
+ */
458
+ label?: string;
459
+ }
460
+ /**
461
+ * Connection handle information for gantt bar connections.
462
+ * @public
463
+ */
464
+ export interface ConnectionHandle {
465
+ /**
466
+ * Unique identifier for the connection handle.
467
+ */
468
+ id: string;
469
+ /**
470
+ * The row index of the gantt bar this handle belongs to.
471
+ */
472
+ rowIndex: number;
473
+ /**
474
+ * The column index of the gantt bar this handle belongs to.
475
+ */
476
+ colIndex: number;
477
+ /**
478
+ * The side of the gantt bar where this handle is located.
479
+ */
480
+ side: 'left' | 'right';
481
+ /**
482
+ * The position of the connection handle.
483
+ */
484
+ position: {
485
+ x: ShallowRef<number>;
486
+ y: ShallowRef<number>;
487
+ };
488
+ /**
489
+ * Whether the handle is currently visible (on hover).
490
+ */
491
+ visible: Ref<boolean>;
492
+ /**
493
+ * Reference to the gantt bar this handle belongs to.
494
+ */
495
+ barId: string;
496
+ }
497
+ /**
498
+ * Connection path between two gantt bars.
499
+ * @public
500
+ */
501
+ export interface ConnectionPath {
502
+ /**
503
+ * Unique identifier for the connection path.
504
+ */
505
+ id: string;
506
+ /**
507
+ * The source connection handle.
508
+ */
509
+ from: {
510
+ barId: string;
511
+ side: 'left' | 'right';
512
+ };
513
+ /**
514
+ * The target connection handle.
515
+ */
516
+ to: {
517
+ barId: string;
518
+ side: 'left' | 'right';
519
+ };
520
+ /**
521
+ * Optional styling for the connection path.
522
+ */
523
+ style?: {
524
+ color?: string;
525
+ width?: number;
526
+ };
527
+ /**
528
+ * Optional label for the connection.
529
+ */
530
+ label?: string;
531
+ }
532
+ /**
533
+ * Connection event for handling connection creation/deletion.
534
+ * @public
535
+ */
536
+ export type ConnectionEvent = {
537
+ type: 'create' | 'delete';
538
+ connection: ConnectionPath;
539
+ };
412
540
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD;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,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IAEtB;;OAEG;IACH,QAAQ,EAAE;QACT,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;QACrB,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;KACrB,CAAA;IAED;;OAEG;IACH,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAErB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IAEV;;OAEG;IACH,IAAI,EAAE;QACL,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;KACtB,CAAA;IAED;;OAEG;IACH,EAAE,EAAE;QACH,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;KACtB,CAAA;IAED;;OAEG;IACH,KAAK,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,KAAK,CAAC,EAAE,MAAM,CAAA;KACd,CAAA;IAED;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAA;IACzB,UAAU,EAAE,cAAc,CAAA;CAC1B,CAAA"}
@@ -10,35 +10,18 @@ import { generateHash } from '../utils';
10
10
  export const createTableStore = (initData) => {
11
11
  const id = initData.id || generateHash();
12
12
  const createStore = defineStore(`table-${id}`, () => {
13
- // util functions
14
- const createTableObject = () => {
15
- const table = {};
16
- for (const [colIndex, column] of columns.value.entries()) {
17
- for (const [rowIndex, row] of rows.value.entries()) {
18
- table[`${colIndex}:${rowIndex}`] = row[column.name];
19
- }
20
- }
21
- return table;
22
- };
23
- const createDisplayObject = (display) => {
13
+ const createDisplayObject = () => {
24
14
  const defaultDisplay = [Object.assign({}, { rowModified: false })];
25
- // TODO: (typing) what is the type of `display` here?
26
- if (display) {
27
- if ('0:0' in display) {
28
- return display;
29
- }
30
- // else if ('default' in display) {
31
- // // TODO: (typing) what is the possible input here for 'default'?
32
- // defaultDisplay = display.default
33
- // }
34
- }
35
15
  // TODO: (typing) is this type correct for the parent set?
36
16
  const parents = new Set();
37
- for (let rowIndex = rows.value.length - 1; rowIndex >= 0; rowIndex--) {
17
+ for (let rowIndex = 0; rowIndex < rows.value.length; rowIndex++) {
38
18
  const row = rows.value[rowIndex];
39
- if (row.parent) {
19
+ if (row.parent !== null && row.parent !== undefined) {
40
20
  parents.add(row.parent);
41
21
  }
22
+ }
23
+ for (let rowIndex = 0; rowIndex < rows.value.length; rowIndex++) {
24
+ const row = rows.value[rowIndex];
42
25
  defaultDisplay[rowIndex] = {
43
26
  childrenOpen: false,
44
27
  expanded: false,
@@ -56,24 +39,78 @@ export const createTableStore = (initData) => {
56
39
  const columns = ref(initData.columns);
57
40
  const rows = ref(initData.rows);
58
41
  const config = ref(initData.config || {});
59
- const table = ref(initData.table || createTableObject());
60
- const display = ref(createDisplayObject(initData.display));
42
+ // Track row modifications and expand states separately from the computed display
43
+ const rowModifications = ref({});
44
+ const rowExpandStates = ref({});
45
+ const table = computed(() => {
46
+ const table = {};
47
+ for (const [colIndex, column] of columns.value.entries()) {
48
+ for (const [rowIndex, row] of rows.value.entries()) {
49
+ table[`${colIndex}:${rowIndex}`] = row[column.name];
50
+ }
51
+ }
52
+ return table;
53
+ });
54
+ const display = computed({
55
+ get: () => {
56
+ const baseDisplay = createDisplayObject();
57
+ // Apply persistent modifications and expand states
58
+ for (let i = 0; i < baseDisplay.length; i++) {
59
+ if (rowModifications.value[i]) {
60
+ baseDisplay[i].rowModified = rowModifications.value[i];
61
+ }
62
+ if (rowExpandStates.value[i]) {
63
+ if (rowExpandStates.value[i].childrenOpen !== undefined) {
64
+ baseDisplay[i].childrenOpen = rowExpandStates.value[i].childrenOpen;
65
+ }
66
+ if (rowExpandStates.value[i].expanded !== undefined) {
67
+ baseDisplay[i].expanded = rowExpandStates.value[i].expanded;
68
+ }
69
+ }
70
+ }
71
+ // Calculate 'open' property for tree view based on parent's childrenOpen state
72
+ if (isTreeView.value) {
73
+ for (let i = 0; i < baseDisplay.length; i++) {
74
+ const row = baseDisplay[i];
75
+ if (!row.isRoot && row.parent !== null && row.parent !== undefined) {
76
+ // Child row is 'open' if its parent's childrenOpen is true
77
+ const parentIndex = row.parent;
78
+ if (parentIndex >= 0 && parentIndex < baseDisplay.length) {
79
+ baseDisplay[i].open = baseDisplay[parentIndex].childrenOpen || false;
80
+ }
81
+ }
82
+ }
83
+ }
84
+ return baseDisplay;
85
+ },
86
+ set: (newDisplay) => {
87
+ // Only update if the new display is different from the current one; also avoids recursive updates
88
+ if (JSON.stringify(newDisplay) !== JSON.stringify(display.value)) {
89
+ display.value = newDisplay;
90
+ }
91
+ },
92
+ });
61
93
  const modal = ref(initData.modal || { visible: false });
62
94
  const updates = ref({});
95
+ const ganttBars = ref([]);
96
+ const connectionHandles = ref([]);
97
+ const connectionPaths = ref([]);
63
98
  // getters
64
99
  const hasPinnedColumns = computed(() => columns.value.some(col => col.pinned));
100
+ const isGanttView = computed(() => config.value.view === 'gantt' || config.value.view === 'tree-gantt');
101
+ const isTreeView = computed(() => config.value.view === 'tree' || config.value.view === 'tree-gantt');
65
102
  const numberedRowWidth = computed(() => {
66
103
  const indent = Math.ceil(rows.value.length / 100 + 1);
67
104
  return `${indent}ch`;
68
105
  });
69
- const zeroColumn = computed(() => config.value.view ? ['list', 'tree', 'list-expansion'].includes(config.value.view) : false);
106
+ const zeroColumn = computed(() => config.value.view ? ['list', 'tree', 'tree-gantt', 'list-expansion'].includes(config.value.view) : false);
70
107
  // actions
71
108
  const getCellData = (colIndex, rowIndex) => table.value[`${colIndex}:${rowIndex}`];
72
109
  const setCellData = (colIndex, rowIndex, value) => {
73
110
  const index = `${colIndex}:${rowIndex}`;
74
111
  const col = columns.value[colIndex];
75
112
  if (table.value[index] !== value) {
76
- display.value[rowIndex].rowModified = true;
113
+ rowModifications.value[rowIndex] = true;
77
114
  }
78
115
  table.value[index] = value;
79
116
  // Create a new row object to ensure reactivity
@@ -82,10 +119,13 @@ export const createTableStore = (initData) => {
82
119
  [col.name]: value,
83
120
  };
84
121
  };
122
+ const updateRows = (newRows) => {
123
+ rows.value = newRows;
124
+ };
85
125
  const setCellText = (colIndex, rowIndex, value) => {
86
126
  const index = `${colIndex}:${rowIndex}`;
87
127
  if (table.value[index] !== value) {
88
- display.value[rowIndex].rowModified = true;
128
+ rowModifications.value[rowIndex] = true;
89
129
  updates.value[index] = value;
90
130
  }
91
131
  };
@@ -116,34 +156,53 @@ export const createTableStore = (initData) => {
116
156
  };
117
157
  const isRowGantt = (rowIndex) => {
118
158
  const row = rows.value[rowIndex];
119
- return config.value.view === 'gantt' && row.indent === 0;
159
+ return isGanttView.value && row.gantt !== undefined;
120
160
  };
121
161
  const isRowVisible = (rowIndex) => {
122
- return config.value.view !== 'tree' || display.value[rowIndex].isRoot || display.value[rowIndex].open;
162
+ return !isTreeView.value || display.value[rowIndex].isRoot || display.value[rowIndex].open;
123
163
  };
124
164
  const getRowExpandSymbol = (rowIndex) => {
125
- if (config.value.view !== 'tree') {
165
+ if (!isTreeView.value && config.value.view !== 'list-expansion') {
126
166
  return '';
127
167
  }
128
- if (display.value[rowIndex].isRoot || display.value[rowIndex].isParent) {
129
- return display.value[rowIndex].childrenOpen ? '-' : '+';
168
+ if (isTreeView.value && (display.value[rowIndex].isRoot || display.value[rowIndex].isParent)) {
169
+ return display.value[rowIndex].childrenOpen ? '' : '';
170
+ }
171
+ if (config.value.view === 'list-expansion') {
172
+ return display.value[rowIndex].expanded ? '▼' : '►';
130
173
  }
131
174
  return '';
132
175
  };
133
176
  const toggleRowExpand = (rowIndex) => {
134
- if (config.value.view === 'tree') {
135
- display.value[rowIndex].childrenOpen = !display.value[rowIndex].childrenOpen;
136
- for (let index = rows.value.length - 1; index >= 0; index--) {
137
- if (display.value[index].parent === rowIndex) {
138
- display.value[index].open = !display.value[index].open;
139
- if (display.value[index].childrenOpen) {
177
+ if (isTreeView.value) {
178
+ const currentState = rowExpandStates.value[rowIndex] || {};
179
+ const currentChildrenOpen = currentState.childrenOpen ?? display.value[rowIndex].childrenOpen;
180
+ const newChildrenOpen = !currentChildrenOpen;
181
+ rowExpandStates.value[rowIndex] = {
182
+ ...currentState,
183
+ childrenOpen: newChildrenOpen,
184
+ };
185
+ // If we're closing, recursively close all descendant nodes
186
+ if (!newChildrenOpen) {
187
+ for (let index = 0; index < rows.value.length; index++) {
188
+ if (display.value[index].parent === rowIndex) {
189
+ const childState = rowExpandStates.value[index] || {};
190
+ rowExpandStates.value[index] = {
191
+ ...childState,
192
+ childrenOpen: false,
193
+ };
140
194
  toggleRowExpand(index);
141
195
  }
142
196
  }
143
197
  }
144
198
  }
145
199
  else if (config.value.view === 'list-expansion') {
146
- display.value[rowIndex].expanded = !display.value[rowIndex].expanded;
200
+ const currentState = rowExpandStates.value[rowIndex] || {};
201
+ const currentExpanded = currentState.expanded ?? display.value[rowIndex].expanded;
202
+ rowExpandStates.value[rowIndex] = {
203
+ ...currentState,
204
+ expanded: !currentExpanded,
205
+ };
147
206
  }
148
207
  };
149
208
  const getCellDisplayValue = (colIndex, rowIndex) => {
@@ -211,34 +270,120 @@ export const createTableStore = (initData) => {
211
270
  }
212
271
  }
213
272
  };
273
+ const registerGanttBar = (barInfo) => {
274
+ const existingIndex = ganttBars.value.findIndex(bar => bar.id === barInfo.id);
275
+ if (existingIndex >= 0) {
276
+ // @ts-expect-error TODO: for some reason, the IDE is expecting an unref'd value
277
+ ganttBars.value[existingIndex] = barInfo;
278
+ }
279
+ else {
280
+ // @ts-expect-error TODO: for some reason, the IDE is expecting an unref'd value
281
+ ganttBars.value.push(barInfo);
282
+ }
283
+ };
284
+ const unregisterGanttBar = (barId) => {
285
+ const index = ganttBars.value.findIndex(bar => bar.id === barId);
286
+ if (index >= 0) {
287
+ ganttBars.value.splice(index, 1);
288
+ }
289
+ };
290
+ const registerConnectionHandle = (handleInfo) => {
291
+ const existingIndex = connectionHandles.value.findIndex(handle => handle.id === handleInfo.id);
292
+ if (existingIndex >= 0) {
293
+ // @ts-expect-error TODO: for some reason, the IDE is expecting an unref'd value
294
+ connectionHandles.value[existingIndex] = handleInfo;
295
+ }
296
+ else {
297
+ // @ts-expect-error TODO: for some reason, the IDE is expecting an unref'd value
298
+ connectionHandles.value.push(handleInfo);
299
+ }
300
+ };
301
+ const unregisterConnectionHandle = (handleId) => {
302
+ const index = connectionHandles.value.findIndex(handle => handle.id === handleId);
303
+ if (index >= 0) {
304
+ connectionHandles.value.splice(index, 1);
305
+ }
306
+ };
307
+ const createConnection = (fromHandleId, toHandleId, options) => {
308
+ const fromHandle = connectionHandles.value.find(h => h.id === fromHandleId);
309
+ const toHandle = connectionHandles.value.find(h => h.id === toHandleId);
310
+ if (!fromHandle || !toHandle) {
311
+ // eslint-disable-next-line no-console
312
+ console.warn('Cannot create connection: handle not found');
313
+ return null;
314
+ }
315
+ const connection = {
316
+ id: `connection-${fromHandleId}-${toHandleId}`,
317
+ from: {
318
+ barId: fromHandle.barId,
319
+ side: fromHandle.side,
320
+ },
321
+ to: {
322
+ barId: toHandle.barId,
323
+ side: toHandle.side,
324
+ },
325
+ style: options?.style,
326
+ label: options?.label,
327
+ };
328
+ connectionPaths.value.push(connection);
329
+ return connection;
330
+ };
331
+ const deleteConnection = (connectionId) => {
332
+ const index = connectionPaths.value.findIndex(conn => conn.id === connectionId);
333
+ if (index >= 0) {
334
+ connectionPaths.value.splice(index, 1);
335
+ return true;
336
+ }
337
+ return false;
338
+ };
339
+ const getConnectionsForBar = (barId) => {
340
+ return connectionPaths.value.filter(conn => conn.from.barId === barId || conn.to.barId === barId);
341
+ };
342
+ const getHandlesForBar = (barId) => {
343
+ return connectionHandles.value.filter(handle => handle.barId === barId);
344
+ };
214
345
  return {
215
346
  // state
216
347
  columns,
217
348
  config,
349
+ connectionHandles,
350
+ connectionPaths,
218
351
  display,
352
+ ganttBars,
219
353
  modal,
220
354
  rows,
221
355
  table,
222
356
  updates,
223
357
  // getters
224
358
  hasPinnedColumns,
359
+ isGanttView,
360
+ isTreeView,
225
361
  numberedRowWidth,
226
362
  zeroColumn,
227
363
  // actions
228
364
  closeModal,
365
+ createConnection,
366
+ deleteConnection,
229
367
  getCellData,
230
368
  getCellDisplayValue,
369
+ getConnectionsForBar,
231
370
  getFormattedValue,
371
+ getHandlesForBar,
232
372
  getHeaderCellStyle,
233
- resizeColumn,
234
373
  getIndent,
235
374
  getRowExpandSymbol,
236
375
  isRowGantt,
237
376
  isRowVisible,
377
+ registerConnectionHandle,
378
+ registerGanttBar,
379
+ resizeColumn,
238
380
  setCellData,
239
381
  setCellText,
240
382
  toggleRowExpand,
383
+ unregisterConnectionHandle,
384
+ unregisterGanttBar,
241
385
  updateGanttBar,
386
+ updateRows,
242
387
  };
243
388
  });
244
389
  return createStore();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/atable",
3
- "version": "0.4.23",
3
+ "version": "0.4.25",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "author": {
@@ -38,8 +38,8 @@
38
38
  "@vueuse/core": "^13.4.0",
39
39
  "pinia": "^3.0.3",
40
40
  "vue": "^3.5.17",
41
- "@stonecrop/themes": "0.4.23",
42
- "@stonecrop/utilities": "0.4.23"
41
+ "@stonecrop/utilities": "0.4.25",
42
+ "@stonecrop/themes": "0.4.25"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@microsoft/api-documenter": "^7.26.29",