@stonecrop/atable 0.4.11 → 0.4.13
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/assets/index.css +1 -1
- package/dist/atable.d.ts +420 -110
- package/dist/atable.js +916 -886
- package/dist/atable.js.map +1 -1
- package/dist/atable.umd.cjs +2 -2
- package/dist/atable.umd.cjs.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/stores/table.d.ts +113 -83
- package/dist/src/stores/table.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +305 -27
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/stores/table.js +24 -0
- package/package.json +3 -3
- package/src/components/AGanttCell.vue +27 -21
- package/src/components/ATable.vue +42 -17
- package/src/index.ts +2 -0
- package/src/stores/table.ts +33 -1
- package/src/types/index.ts +333 -23
|
@@ -4,20 +4,67 @@ import { createTableStore } from '../stores/table';
|
|
|
4
4
|
* Table column definition.
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export interface TableColumn {
|
|
8
|
+
/**
|
|
9
|
+
* The key of the column. This is used to identify the column in the table.
|
|
10
|
+
*/
|
|
8
11
|
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* The alignment of the column. Possible values:
|
|
14
|
+
* - `left` - left aligned
|
|
15
|
+
* - `center` - center aligned
|
|
16
|
+
* - `right` - right aligned
|
|
17
|
+
* - `start` - aligned to the start of the column
|
|
18
|
+
* - `end` - aligned to the end of the column
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue 'center'
|
|
21
|
+
*/
|
|
9
22
|
align?: CanvasTextAlign;
|
|
23
|
+
/**
|
|
24
|
+
* Control whether cells for the column is editable.
|
|
25
|
+
*
|
|
26
|
+
* @defaultValue false
|
|
27
|
+
*/
|
|
10
28
|
edit?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The label of the column. This is displayed in the table header.
|
|
31
|
+
*
|
|
32
|
+
* @defaultValue If no label is provided, a character will be assigned alphabetically,
|
|
33
|
+
* starting from 'A' for the first column, 'B' for the second column, and so on.
|
|
34
|
+
*/
|
|
11
35
|
label?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The data-type of the column. Possible values:
|
|
38
|
+
* - `Data` - the column contains text data
|
|
39
|
+
* - `Select` - the column contains a select input
|
|
40
|
+
* - `Date` - the column contains a date input
|
|
41
|
+
* - `component` - the column contains a custom component
|
|
42
|
+
*
|
|
43
|
+
* @beta
|
|
44
|
+
*/
|
|
12
45
|
type?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The width of the column. This can be a number (in pixels) or a string (in CSS units).
|
|
48
|
+
*
|
|
49
|
+
* @defaultValue '40ch'
|
|
50
|
+
*/
|
|
13
51
|
width?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Control whether the column should be pinned to the table.
|
|
54
|
+
*
|
|
55
|
+
* @defaultValue false
|
|
56
|
+
*/
|
|
14
57
|
pinned?: boolean;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
originalIndex?: number;
|
|
58
|
+
/**
|
|
59
|
+
* The component to use to render the cell for the column. If not provided, the table will
|
|
60
|
+
* render the default `<td>` element.
|
|
61
|
+
*/
|
|
20
62
|
cellComponent?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Additional properties to pass to the table's cell component.
|
|
65
|
+
*
|
|
66
|
+
* Only applicable if the `cellComponent` property is set for the column.
|
|
67
|
+
*/
|
|
21
68
|
cellComponentProps?: Record<string, any>;
|
|
22
69
|
/**
|
|
23
70
|
* The component to use for the modal. If a function is provided, it will be called with the cell context.
|
|
@@ -34,26 +81,82 @@ export type TableColumn = {
|
|
|
34
81
|
* - `store` - the table data store
|
|
35
82
|
*/
|
|
36
83
|
modalComponent?: string | ((context: CellContext) => string);
|
|
84
|
+
/**
|
|
85
|
+
* Additional properties to pass to the modal component.
|
|
86
|
+
*
|
|
87
|
+
* Only applicable if the `modalComponent` property is set for the column.
|
|
88
|
+
*/
|
|
37
89
|
modalComponentExtraProps?: Record<string, any>;
|
|
90
|
+
/**
|
|
91
|
+
* The format function to use to format the value of the cell. This can either be a normal or stringified
|
|
92
|
+
* function that takes the value and the cell context and returns a string.
|
|
93
|
+
*/
|
|
38
94
|
format?: string | ((value: any, context: CellContext) => string);
|
|
95
|
+
/**
|
|
96
|
+
* The masking function to use to apply an input mask to the cell. This will accept an input value and
|
|
97
|
+
* return the masked value.
|
|
98
|
+
*/
|
|
39
99
|
mask?: (value: any) => any;
|
|
40
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Whether the column is a Gantt column.
|
|
102
|
+
*
|
|
103
|
+
* Only applicable for Gantt tables.
|
|
104
|
+
*
|
|
105
|
+
* @defaultValue false
|
|
106
|
+
*/
|
|
107
|
+
isGantt?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* The component to use to render the Gantt bar for the column.
|
|
110
|
+
*
|
|
111
|
+
* Only applicable for Gantt tables.
|
|
112
|
+
*
|
|
113
|
+
* @defaultValue 'AGanttCell'
|
|
114
|
+
*/
|
|
115
|
+
ganttComponent?: string;
|
|
116
|
+
/**
|
|
117
|
+
* The colspan of the Gantt-bar for the column. This is used to determine how many columns
|
|
118
|
+
* the Gantt-bar should span.
|
|
119
|
+
*
|
|
120
|
+
* Only applicable for Gantt tables.
|
|
121
|
+
*
|
|
122
|
+
* @defaultValue The number of columns in the table, excluding any pinned columns.
|
|
123
|
+
*/
|
|
124
|
+
colspan?: number;
|
|
125
|
+
/**
|
|
126
|
+
* The starting column index for the Gantt-bar, excluding any pinned columns. This is
|
|
127
|
+
* evaluated automatically while rendering the table.
|
|
128
|
+
*
|
|
129
|
+
* Only applicable for Gantt tables.
|
|
130
|
+
*
|
|
131
|
+
* @defaultValue 0
|
|
132
|
+
*/
|
|
133
|
+
originalIndex?: number;
|
|
134
|
+
}
|
|
41
135
|
/**
|
|
42
136
|
* Table cell context definition.
|
|
43
137
|
* @public
|
|
44
138
|
*/
|
|
45
|
-
export
|
|
139
|
+
export interface CellContext {
|
|
140
|
+
/**
|
|
141
|
+
* The row object for the current cell.
|
|
142
|
+
*/
|
|
46
143
|
row: TableRow;
|
|
144
|
+
/**
|
|
145
|
+
* The column object for the current cell.
|
|
146
|
+
*/
|
|
47
147
|
column: TableColumn;
|
|
148
|
+
/**
|
|
149
|
+
* The table object for the current cell.
|
|
150
|
+
*/
|
|
48
151
|
table: {
|
|
49
152
|
[key: string]: any;
|
|
50
153
|
};
|
|
51
|
-
}
|
|
154
|
+
}
|
|
52
155
|
/**
|
|
53
156
|
* Table configuration definition.
|
|
54
157
|
* @public
|
|
55
158
|
*/
|
|
56
|
-
export
|
|
159
|
+
export interface TableConfig {
|
|
57
160
|
/**
|
|
58
161
|
* The type of view to display the table in. Possible values:
|
|
59
162
|
* - `uncounted` - row numbers are not displayed in the table
|
|
@@ -62,57 +165,232 @@ export type TableConfig = {
|
|
|
62
165
|
* - `tree` - carets are displayed in the number column that expand/collapse grouped rows
|
|
63
166
|
*/
|
|
64
167
|
view?: 'uncounted' | 'list' | 'list-expansion' | 'tree' | 'gantt';
|
|
168
|
+
/**
|
|
169
|
+
* Control whether the table should be allowed to use the full width of its container.
|
|
170
|
+
*
|
|
171
|
+
* @defaultValue false
|
|
172
|
+
*/
|
|
65
173
|
fullWidth?: boolean;
|
|
66
|
-
}
|
|
174
|
+
}
|
|
67
175
|
/**
|
|
68
176
|
* Table display definition.
|
|
69
177
|
* @public
|
|
70
178
|
*/
|
|
71
|
-
export
|
|
72
|
-
|
|
179
|
+
export interface TableDisplay {
|
|
180
|
+
/**
|
|
181
|
+
* Indicates whether a row node is expanded or collapsed.
|
|
182
|
+
*
|
|
183
|
+
* Only applicable for list-expansion views.
|
|
184
|
+
*
|
|
185
|
+
* @defaultValue false
|
|
186
|
+
*/
|
|
73
187
|
expanded?: boolean;
|
|
74
|
-
|
|
188
|
+
/**
|
|
189
|
+
* Indicates whether a row node's child nodes are open or closed.
|
|
190
|
+
*
|
|
191
|
+
* Only applicable for tree views.
|
|
192
|
+
*
|
|
193
|
+
* @defaultValue false
|
|
194
|
+
*/
|
|
195
|
+
childrenOpen?: boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Indicates whether a row node is a parent node. This is evaluated automatically
|
|
198
|
+
* while rendering the table.
|
|
199
|
+
*
|
|
200
|
+
* Only applicable for tree views.
|
|
201
|
+
*/
|
|
75
202
|
isParent?: boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Indicates whether a row node is a root node. This is evaluated automatically
|
|
205
|
+
* while rendering the table.
|
|
206
|
+
*
|
|
207
|
+
* Only applicable for tree views.
|
|
208
|
+
*/
|
|
76
209
|
isRoot?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Indicates whether a row node is visible. This is evaluated automatically
|
|
212
|
+
* while rendering the table.
|
|
213
|
+
*
|
|
214
|
+
* Only applicable for tree views.
|
|
215
|
+
*/
|
|
77
216
|
open?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* The indentation level of the row node.
|
|
219
|
+
*
|
|
220
|
+
* Only applicable for tree and gantt views.
|
|
221
|
+
*
|
|
222
|
+
* @defaultValue 0
|
|
223
|
+
*/
|
|
224
|
+
indent?: number;
|
|
225
|
+
/**
|
|
226
|
+
* The HTML parent element for the row node. This is evaluated automatically while rendering
|
|
227
|
+
* the table.
|
|
228
|
+
*
|
|
229
|
+
* Only applicable for tree and gantt views.
|
|
230
|
+
*/
|
|
78
231
|
parent?: number;
|
|
232
|
+
/**
|
|
233
|
+
* Indicates whether a row node has been modified. This is evaluated automatically when a cell
|
|
234
|
+
* is edited.
|
|
235
|
+
*
|
|
236
|
+
* @defaultValue false
|
|
237
|
+
*/
|
|
79
238
|
rowModified?: boolean;
|
|
80
|
-
}
|
|
239
|
+
}
|
|
81
240
|
/**
|
|
82
241
|
* Table row definition.
|
|
83
242
|
* @public
|
|
84
243
|
*/
|
|
85
|
-
export
|
|
244
|
+
export interface TableRow {
|
|
245
|
+
/**
|
|
246
|
+
* Additional arbitrary properties that can be passed to the row object.
|
|
247
|
+
*/
|
|
86
248
|
[key: string]: any;
|
|
249
|
+
/**
|
|
250
|
+
* The indentation level of the row node.
|
|
251
|
+
*
|
|
252
|
+
* Only applicable for tree and gantt views.
|
|
253
|
+
*
|
|
254
|
+
* @defaultValue 0
|
|
255
|
+
*/
|
|
87
256
|
indent?: number;
|
|
257
|
+
/**
|
|
258
|
+
* The HTML parent element for the row node. This is evaluated automatically while rendering
|
|
259
|
+
* the table.
|
|
260
|
+
*
|
|
261
|
+
* Only applicable for tree and gantt views.
|
|
262
|
+
*/
|
|
88
263
|
parent?: number;
|
|
264
|
+
/**
|
|
265
|
+
* The options to use when rendering the row as a Gantt table.
|
|
266
|
+
*/
|
|
267
|
+
gantt?: GanttOptions;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* This interface defines the options for a row when it is being viewed as a Gantt chart.
|
|
271
|
+
* @public
|
|
272
|
+
*/
|
|
273
|
+
export interface GanttOptions {
|
|
274
|
+
/**
|
|
275
|
+
* The colour to be applied to the row's gantt bar.
|
|
276
|
+
*/
|
|
277
|
+
color?: string;
|
|
278
|
+
/**
|
|
279
|
+
* The starting column index for the gantt bar.
|
|
280
|
+
*/
|
|
281
|
+
startIndex?: number;
|
|
282
|
+
/**
|
|
283
|
+
* The ending column index for the gantt bar. If the endIndex and colspan are not provided,
|
|
284
|
+
* the bar will stretch to the end of the table.
|
|
285
|
+
*/
|
|
286
|
+
endIndex?: number;
|
|
287
|
+
/**
|
|
288
|
+
* The length of the gantt bar. Useful when only the start index is provided. If the
|
|
289
|
+
* colspan and endIndex are not provided, the bar will stretch to the end of the table.
|
|
290
|
+
*/
|
|
291
|
+
colspan?: number;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Gantt table drag event definition.
|
|
295
|
+
* @public
|
|
296
|
+
*/
|
|
297
|
+
export type GanttDragEvent = {
|
|
298
|
+
rowIndex: number;
|
|
299
|
+
colIndex: number;
|
|
300
|
+
type: 'bar';
|
|
301
|
+
start: number;
|
|
302
|
+
end: number;
|
|
303
|
+
} | {
|
|
304
|
+
rowIndex: number;
|
|
305
|
+
colIndex: number;
|
|
306
|
+
type: 'resize';
|
|
307
|
+
edge: 'start' | 'end';
|
|
308
|
+
value: number;
|
|
89
309
|
};
|
|
90
310
|
/**
|
|
91
311
|
* Table modal definition.
|
|
92
312
|
* @public
|
|
93
313
|
*/
|
|
94
|
-
export
|
|
95
|
-
|
|
314
|
+
export interface TableModal {
|
|
315
|
+
/**
|
|
316
|
+
* Indicates whether the table modal is currently visible.
|
|
317
|
+
*
|
|
318
|
+
* @defaultValue false
|
|
319
|
+
*/
|
|
320
|
+
visible?: boolean;
|
|
321
|
+
/**
|
|
322
|
+
* The HTML cell element that the modal is currently being displayed for. The field is unset
|
|
323
|
+
* when the modal is not being displayed.
|
|
324
|
+
*/
|
|
96
325
|
cell?: HTMLTableCellElement | null;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
326
|
+
/**
|
|
327
|
+
* The HTML parent element that the modal is currently being displayed for. The field is unset
|
|
328
|
+
* when the modal is not being displayed.
|
|
329
|
+
*/
|
|
101
330
|
parent?: HTMLElement;
|
|
331
|
+
/**
|
|
332
|
+
* The index of the column that the modal is currently being displayed for. The field is
|
|
333
|
+
* unset when the modal is not being displayed.
|
|
334
|
+
*/
|
|
335
|
+
colIndex?: number;
|
|
336
|
+
/**
|
|
337
|
+
* The index of the row that the modal is currently being displayed for. The field is
|
|
338
|
+
* unset when the modal is not being displayed.
|
|
339
|
+
*/
|
|
102
340
|
rowIndex?: number;
|
|
103
|
-
|
|
104
|
-
|
|
341
|
+
/**
|
|
342
|
+
* The component to use to render the modal. If not provided, the table will
|
|
343
|
+
* try to use the column's `modalComponent` property, if set. If that is not set,
|
|
344
|
+
* the table will not display a modal.
|
|
345
|
+
*
|
|
346
|
+
* @see {@link TableColumn.modalComponent}
|
|
347
|
+
*/
|
|
105
348
|
component?: string;
|
|
349
|
+
/**
|
|
350
|
+
* Additional properties to pass to the table's modal component.
|
|
351
|
+
*/
|
|
106
352
|
componentProps?: Record<string, any>;
|
|
107
|
-
|
|
353
|
+
/**
|
|
354
|
+
* Reactive bottom value for the modal's bounding box. The field is unset when the modal
|
|
355
|
+
* is not being displayed.
|
|
356
|
+
*/
|
|
357
|
+
bottom?: ReturnType<typeof useElementBounding>['bottom'];
|
|
358
|
+
/**
|
|
359
|
+
* Reactive height value for the modal's bounding box. The field is unset when the modal
|
|
360
|
+
* is not being displayed.
|
|
361
|
+
*/
|
|
362
|
+
height?: ReturnType<typeof useElementBounding>['height'];
|
|
363
|
+
/**
|
|
364
|
+
* Reactive left value for the modal's bounding box. The field is unset when the modal
|
|
365
|
+
* is not being displayed.
|
|
366
|
+
*/
|
|
367
|
+
left?: ReturnType<typeof useElementBounding>['left'];
|
|
368
|
+
/**
|
|
369
|
+
* Reactive width value for the modal's bounding box. The field is unset when the modal
|
|
370
|
+
* is not being displayed.
|
|
371
|
+
*/
|
|
372
|
+
width?: ReturnType<typeof useElementBounding>['width'];
|
|
373
|
+
}
|
|
108
374
|
/**
|
|
109
375
|
* Table modal component props definition.
|
|
110
376
|
* @public
|
|
111
377
|
*/
|
|
112
|
-
export
|
|
378
|
+
export interface TableModalProps {
|
|
379
|
+
/**
|
|
380
|
+
* Additional arbitrary properties that can be passed to the modal component.
|
|
381
|
+
*/
|
|
113
382
|
[key: string]: any;
|
|
383
|
+
/**
|
|
384
|
+
* The index of the column that the modal is currently being displayed for.
|
|
385
|
+
*/
|
|
114
386
|
colIndex: number;
|
|
387
|
+
/**
|
|
388
|
+
* The index of the row that the modal is currently being displayed for.
|
|
389
|
+
*/
|
|
115
390
|
rowIndex: number;
|
|
391
|
+
/**
|
|
392
|
+
* The store for managing the current table's state.
|
|
393
|
+
*/
|
|
116
394
|
store: ReturnType<typeof createTableStore>;
|
|
117
|
-
}
|
|
395
|
+
}
|
|
118
396
|
//# 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;;;GAGG;AACH,MAAM,
|
|
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;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,eAAe,CAAA;IAEvB;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAExC;;;;;;;;;;;;;OAaG;IAEH,cAAc,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,WAAW,KAAK,MAAM,CAAC,CAAA;IAE5D;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAE9C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,E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H,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAEpC;;;OAGG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,QAAQ,CAAC,CAAA;IAExD;;;OAGG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,QAAQ,CAAC,CAAA;IAExD;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAA;IAEpD;;;OAGG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAA;CACtD;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;IAElB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,KAAK,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAA;CAC1C"}
|
package/dist/stores/table.js
CHANGED
|
@@ -90,6 +90,10 @@ export const createTableStore = (initData) => {
|
|
|
90
90
|
textAlign: column.align || 'center',
|
|
91
91
|
width: config.value.fullWidth ? 'auto' : undefined,
|
|
92
92
|
});
|
|
93
|
+
const isRowGantt = (rowIndex) => {
|
|
94
|
+
const row = rows.value[rowIndex];
|
|
95
|
+
return config.value.view === 'gantt' && row.indent === 0;
|
|
96
|
+
};
|
|
93
97
|
const isRowVisible = (rowIndex) => {
|
|
94
98
|
return config.value.view !== 'tree' || display.value[rowIndex].isRoot || display.value[rowIndex].open;
|
|
95
99
|
};
|
|
@@ -160,6 +164,24 @@ export const createTableStore = (initData) => {
|
|
|
160
164
|
return 'inherit';
|
|
161
165
|
}
|
|
162
166
|
};
|
|
167
|
+
const updateGanttBar = (event) => {
|
|
168
|
+
// update the local gantt bar cache
|
|
169
|
+
const ganttBar = rows.value[event.rowIndex]?.gantt;
|
|
170
|
+
if (ganttBar) {
|
|
171
|
+
if (event.type === 'resize') {
|
|
172
|
+
if (event.edge === 'start') {
|
|
173
|
+
ganttBar.startIndex = event.value;
|
|
174
|
+
}
|
|
175
|
+
else if (event.edge === 'end') {
|
|
176
|
+
ganttBar.endIndex = event.value;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else if (event.type === 'bar') {
|
|
180
|
+
ganttBar.startIndex = event.start;
|
|
181
|
+
ganttBar.endIndex = event.end;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
163
185
|
return {
|
|
164
186
|
// state
|
|
165
187
|
columns,
|
|
@@ -181,10 +203,12 @@ export const createTableStore = (initData) => {
|
|
|
181
203
|
getHeaderCellStyle,
|
|
182
204
|
getIndent,
|
|
183
205
|
getRowExpandSymbol,
|
|
206
|
+
isRowGantt,
|
|
184
207
|
isRowVisible,
|
|
185
208
|
setCellData,
|
|
186
209
|
setCellText,
|
|
187
210
|
toggleRowExpand,
|
|
211
|
+
updateGanttBar,
|
|
188
212
|
};
|
|
189
213
|
});
|
|
190
214
|
return createStore();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stonecrop/atable",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@vueuse/core": "^12.7.0",
|
|
39
39
|
"pinia": "^3.0.1",
|
|
40
40
|
"vue": "^3.5.13",
|
|
41
|
-
"@stonecrop/themes": "0.4.
|
|
42
|
-
"@stonecrop/utilities": "0.4.
|
|
41
|
+
"@stonecrop/themes": "0.4.13",
|
|
42
|
+
"@stonecrop/utilities": "0.4.13"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@microsoft/api-documenter": "^7.26.10",
|
|
@@ -26,16 +26,26 @@
|
|
|
26
26
|
</template>
|
|
27
27
|
|
|
28
28
|
<script setup lang="ts">
|
|
29
|
-
import { ref, computed, onMounted, useTemplateRef } from 'vue'
|
|
30
29
|
import { useDraggable, useElementBounding } from '@vueuse/core'
|
|
30
|
+
import { ref, computed, onMounted, useTemplateRef } from 'vue'
|
|
31
|
+
|
|
32
|
+
import { createTableStore } from '../stores/table'
|
|
31
33
|
|
|
32
34
|
const {
|
|
35
|
+
store,
|
|
36
|
+
columnsCount,
|
|
37
|
+
rowIndex,
|
|
38
|
+
colIndex,
|
|
33
39
|
start,
|
|
34
40
|
end,
|
|
35
41
|
colspan = 1,
|
|
36
42
|
label,
|
|
37
43
|
color,
|
|
38
44
|
} = defineProps<{
|
|
45
|
+
store: ReturnType<typeof createTableStore>
|
|
46
|
+
columnsCount: number
|
|
47
|
+
rowIndex: number
|
|
48
|
+
colIndex: number
|
|
39
49
|
start?: number
|
|
40
50
|
end?: number
|
|
41
51
|
colspan?: number
|
|
@@ -53,12 +63,6 @@ onMounted(() => {
|
|
|
53
63
|
}
|
|
54
64
|
})
|
|
55
65
|
|
|
56
|
-
const emit = defineEmits<{
|
|
57
|
-
'update:start': [value: number]
|
|
58
|
-
'update:end': [value: number]
|
|
59
|
-
drag: [{ type: 'bar'; start: number; end: number } | { type: 'resize'; edge: 'start' | 'end'; value: number }]
|
|
60
|
-
}>()
|
|
61
|
-
|
|
62
66
|
const containerRef = useTemplateRef('container')
|
|
63
67
|
const barRef = useTemplateRef('bar')
|
|
64
68
|
const leftHandleRef = useTemplateRef('leftHandle')
|
|
@@ -66,8 +70,8 @@ const rightHandleRef = useTemplateRef('rightHandle')
|
|
|
66
70
|
|
|
67
71
|
const { width: totalBarWidth } = useElementBounding(containerRef)
|
|
68
72
|
const { left: barLeft, right: barRight } = useElementBounding(barRef)
|
|
69
|
-
const currentStart = ref(start ||
|
|
70
|
-
const currentEnd = ref(end ||
|
|
73
|
+
const currentStart = ref(start || 0)
|
|
74
|
+
const currentEnd = ref(end || currentStart.value + colspan)
|
|
71
75
|
const dragStartData = ref({ startX: 0, startPos: 0 })
|
|
72
76
|
|
|
73
77
|
const pixelsPerColumn = computed(() => (colspan > 0 ? totalBarWidth.value / colspan : 0))
|
|
@@ -108,8 +112,7 @@ const { isDragging: isLeftDragging } = useDraggable(leftHandleRef, {
|
|
|
108
112
|
const newStart = Math.max(0, Math.min(currentEnd.value - 1, dragStartData.value.startPos + deltaColumns))
|
|
109
113
|
currentStart.value = newStart
|
|
110
114
|
|
|
111
|
-
|
|
112
|
-
emit('drag', { type: 'resize', edge: 'start', value: newStart })
|
|
115
|
+
store.updateGanttBar({ rowIndex, colIndex, type: 'resize', edge: 'start', value: newStart })
|
|
113
116
|
}
|
|
114
117
|
},
|
|
115
118
|
})
|
|
@@ -127,7 +130,10 @@ const { isDragging: isRightDragging } = useDraggable(rightHandleRef, {
|
|
|
127
130
|
if (isRightDragging.value && barRef.value) {
|
|
128
131
|
const deltaX = x - dragStartData.value.startX
|
|
129
132
|
const deltaColumns = deltaX / pixelsPerColumn.value
|
|
130
|
-
const newEnd = Math.max(
|
|
133
|
+
const newEnd = Math.max(
|
|
134
|
+
currentStart.value + 1,
|
|
135
|
+
Math.min(columnsCount, dragStartData.value.startPos + deltaColumns)
|
|
136
|
+
)
|
|
131
137
|
barRef.value.style.width = `${((newEnd - currentStart.value) / colspan) * 100}%`
|
|
132
138
|
}
|
|
133
139
|
},
|
|
@@ -135,11 +141,13 @@ const { isDragging: isRightDragging } = useDraggable(rightHandleRef, {
|
|
|
135
141
|
if (barRef.value) {
|
|
136
142
|
const deltaX = x - dragStartData.value.startX
|
|
137
143
|
const deltaColumns = Math.round(deltaX / pixelsPerColumn.value)
|
|
138
|
-
const newEnd = Math.max(
|
|
144
|
+
const newEnd = Math.max(
|
|
145
|
+
currentStart.value + 1,
|
|
146
|
+
Math.min(columnsCount, dragStartData.value.startPos + deltaColumns)
|
|
147
|
+
)
|
|
139
148
|
currentEnd.value = newEnd
|
|
140
149
|
|
|
141
|
-
|
|
142
|
-
emit('drag', { type: 'resize', edge: 'end', value: newEnd })
|
|
150
|
+
store.updateGanttBar({ rowIndex, colIndex, type: 'resize', edge: 'end', value: newEnd })
|
|
143
151
|
}
|
|
144
152
|
},
|
|
145
153
|
})
|
|
@@ -159,7 +167,7 @@ const { isDragging: isBarDragging } = useDraggable(barRef, {
|
|
|
159
167
|
const deltaX = x - dragStartData.value.startX
|
|
160
168
|
const deltaColumns = deltaX / pixelsPerColumn.value
|
|
161
169
|
const barWidth = currentEnd.value - currentStart.value
|
|
162
|
-
const newStart = Math.max(0, Math.min(dragStartData.value.startPos + deltaColumns,
|
|
170
|
+
const newStart = Math.max(0, Math.min(dragStartData.value.startPos + deltaColumns, columnsCount - barWidth))
|
|
163
171
|
barRef.value.style.left = `${(newStart / colspan) * 100}%`
|
|
164
172
|
}
|
|
165
173
|
},
|
|
@@ -174,17 +182,15 @@ const { isDragging: isBarDragging } = useDraggable(barRef, {
|
|
|
174
182
|
if (newStart < 0) {
|
|
175
183
|
newStart = 0
|
|
176
184
|
newEnd = barWidth
|
|
177
|
-
} else if (newEnd >
|
|
178
|
-
newEnd =
|
|
185
|
+
} else if (newEnd > columnsCount) {
|
|
186
|
+
newEnd = columnsCount
|
|
179
187
|
newStart = newEnd - barWidth
|
|
180
188
|
}
|
|
181
189
|
|
|
182
190
|
currentStart.value = newStart
|
|
183
191
|
currentEnd.value = newEnd
|
|
184
192
|
|
|
185
|
-
|
|
186
|
-
emit('update:end', newEnd)
|
|
187
|
-
emit('drag', { type: 'bar', start: newStart, end: newEnd })
|
|
193
|
+
store.updateGanttBar({ rowIndex, colIndex, type: 'bar', start: newStart, end: newEnd })
|
|
188
194
|
}
|
|
189
195
|
},
|
|
190
196
|
})
|