@stonecrop/atable 0.3.3 → 0.3.4
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 +49 -32
- package/dist/atable.js +656 -652
- 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 +38 -32
- package/dist/src/stores/table.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +11 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/stores/table.js +12 -2
- package/package.json +3 -3
- package/src/components/ACell.vue +20 -26
- package/src/components/ATable.vue +11 -51
- package/src/index.ts +9 -1
- package/src/stores/table.ts +14 -2
- package/src/types/index.ts +13 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import ATable from './components/ATable.vue';
|
|
|
6
6
|
import ATableHeader from './components/ATableHeader.vue';
|
|
7
7
|
import ATableModal from './components/ATableModal.vue';
|
|
8
8
|
export { createTableStore } from './stores/table';
|
|
9
|
-
export type { CellContext, TableColumn, TableConfig, TableDisplay, TableRow,
|
|
9
|
+
export type { CellContext, TableColumn, TableConfig, TableDisplay, TableModal, TableModalProps, TableRow, } from './types';
|
|
10
10
|
/**
|
|
11
11
|
* Install all ATable components
|
|
12
12
|
* @param app - Vue app instance
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,OAAO,KAAK,MAAM,wBAAwB,CAAA;AAC1C,OAAO,aAAa,MAAM,gCAAgC,CAAA;AAC1D,OAAO,IAAI,MAAM,uBAAuB,CAAA;AACxC,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,YAAY,MAAM,+BAA+B,CAAA;AACxD,OAAO,WAAW,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,OAAO,KAAK,MAAM,wBAAwB,CAAA;AAC1C,OAAO,aAAa,MAAM,gCAAgC,CAAA;AAC1D,OAAO,IAAI,MAAM,uBAAuB,CAAA;AACxC,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,YAAY,MAAM,+BAA+B,CAAA;AACxD,OAAO,WAAW,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,YAAY,EACX,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,UAAU,EACV,eAAe,EACf,QAAQ,GACR,MAAM,SAAS,CAAA;AAEhB;;;;GAIG;AACH,iBAAS,OAAO,CAAC,GAAG,EAAE,GAAG,QAOxB;AAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -46,15 +46,6 @@ export declare const createTableStore: (initData: {
|
|
|
46
46
|
format?: string | ((value: any, context: CellContext) => string);
|
|
47
47
|
mask?: (value: any) => any;
|
|
48
48
|
}[]>;
|
|
49
|
-
rows: import("vue").Ref<{
|
|
50
|
-
[x: string]: any;
|
|
51
|
-
indent?: number;
|
|
52
|
-
parent?: number;
|
|
53
|
-
}[], TableRow[] | {
|
|
54
|
-
[x: string]: any;
|
|
55
|
-
indent?: number;
|
|
56
|
-
parent?: number;
|
|
57
|
-
}[]>;
|
|
58
49
|
config: import("vue").Ref<{
|
|
59
50
|
view?: "uncounted" | "list" | "list-expansion" | "tree";
|
|
60
51
|
fullWidth?: boolean;
|
|
@@ -62,7 +53,6 @@ export declare const createTableStore: (initData: {
|
|
|
62
53
|
view?: "uncounted" | "list" | "list-expansion" | "tree";
|
|
63
54
|
fullWidth?: boolean;
|
|
64
55
|
}>;
|
|
65
|
-
table: import("vue").Ref<{}, {}>;
|
|
66
56
|
display: import("vue").Ref<{
|
|
67
57
|
childrenOpen?: boolean;
|
|
68
58
|
expanded?: boolean;
|
|
@@ -107,6 +97,17 @@ export declare const createTableStore: (initData: {
|
|
|
107
97
|
component?: string;
|
|
108
98
|
componentProps?: Record<string, any>;
|
|
109
99
|
}>;
|
|
100
|
+
rows: import("vue").Ref<{
|
|
101
|
+
[x: string]: any;
|
|
102
|
+
indent?: number;
|
|
103
|
+
parent?: number;
|
|
104
|
+
}[], TableRow[] | {
|
|
105
|
+
[x: string]: any;
|
|
106
|
+
indent?: number;
|
|
107
|
+
parent?: number;
|
|
108
|
+
}[]>;
|
|
109
|
+
table: import("vue").Ref<{}, {}>;
|
|
110
|
+
updates: import("vue").Ref<Record<string, string>, Record<string, string>>;
|
|
110
111
|
hasPinnedColumns: import("vue").ComputedRef<boolean>;
|
|
111
112
|
numberedRowWidth: import("vue").ComputedRef<string>;
|
|
112
113
|
zeroColumn: import("vue").ComputedRef<boolean>;
|
|
@@ -119,8 +120,9 @@ export declare const createTableStore: (initData: {
|
|
|
119
120
|
getRowExpandSymbol: (rowIndex: number) => "" | "-" | "+";
|
|
120
121
|
isRowVisible: (rowIndex: number) => boolean;
|
|
121
122
|
setCellData: (colIndex: number, rowIndex: number, value: any) => void;
|
|
123
|
+
setCellText: (colIndex: number, rowIndex: number, value: string) => void;
|
|
122
124
|
toggleRowExpand: (rowIndex: number) => void;
|
|
123
|
-
}, "columns" | "
|
|
125
|
+
}, "columns" | "config" | "display" | "modal" | "rows" | "table" | "updates">, Pick<{
|
|
124
126
|
columns: import("vue").Ref<{
|
|
125
127
|
name: string;
|
|
126
128
|
align?: CanvasTextAlign;
|
|
@@ -150,15 +152,6 @@ export declare const createTableStore: (initData: {
|
|
|
150
152
|
format?: string | ((value: any, context: CellContext) => string);
|
|
151
153
|
mask?: (value: any) => any;
|
|
152
154
|
}[]>;
|
|
153
|
-
rows: import("vue").Ref<{
|
|
154
|
-
[x: string]: any;
|
|
155
|
-
indent?: number;
|
|
156
|
-
parent?: number;
|
|
157
|
-
}[], TableRow[] | {
|
|
158
|
-
[x: string]: any;
|
|
159
|
-
indent?: number;
|
|
160
|
-
parent?: number;
|
|
161
|
-
}[]>;
|
|
162
155
|
config: import("vue").Ref<{
|
|
163
156
|
view?: "uncounted" | "list" | "list-expansion" | "tree";
|
|
164
157
|
fullWidth?: boolean;
|
|
@@ -166,7 +159,6 @@ export declare const createTableStore: (initData: {
|
|
|
166
159
|
view?: "uncounted" | "list" | "list-expansion" | "tree";
|
|
167
160
|
fullWidth?: boolean;
|
|
168
161
|
}>;
|
|
169
|
-
table: import("vue").Ref<{}, {}>;
|
|
170
162
|
display: import("vue").Ref<{
|
|
171
163
|
childrenOpen?: boolean;
|
|
172
164
|
expanded?: boolean;
|
|
@@ -211,6 +203,17 @@ export declare const createTableStore: (initData: {
|
|
|
211
203
|
component?: string;
|
|
212
204
|
componentProps?: Record<string, any>;
|
|
213
205
|
}>;
|
|
206
|
+
rows: import("vue").Ref<{
|
|
207
|
+
[x: string]: any;
|
|
208
|
+
indent?: number;
|
|
209
|
+
parent?: number;
|
|
210
|
+
}[], TableRow[] | {
|
|
211
|
+
[x: string]: any;
|
|
212
|
+
indent?: number;
|
|
213
|
+
parent?: number;
|
|
214
|
+
}[]>;
|
|
215
|
+
table: import("vue").Ref<{}, {}>;
|
|
216
|
+
updates: import("vue").Ref<Record<string, string>, Record<string, string>>;
|
|
214
217
|
hasPinnedColumns: import("vue").ComputedRef<boolean>;
|
|
215
218
|
numberedRowWidth: import("vue").ComputedRef<string>;
|
|
216
219
|
zeroColumn: import("vue").ComputedRef<boolean>;
|
|
@@ -223,6 +226,7 @@ export declare const createTableStore: (initData: {
|
|
|
223
226
|
getRowExpandSymbol: (rowIndex: number) => "" | "-" | "+";
|
|
224
227
|
isRowVisible: (rowIndex: number) => boolean;
|
|
225
228
|
setCellData: (colIndex: number, rowIndex: number, value: any) => void;
|
|
229
|
+
setCellText: (colIndex: number, rowIndex: number, value: string) => void;
|
|
226
230
|
toggleRowExpand: (rowIndex: number) => void;
|
|
227
231
|
}, "hasPinnedColumns" | "numberedRowWidth" | "zeroColumn">, Pick<{
|
|
228
232
|
columns: import("vue").Ref<{
|
|
@@ -254,15 +258,6 @@ export declare const createTableStore: (initData: {
|
|
|
254
258
|
format?: string | ((value: any, context: CellContext) => string);
|
|
255
259
|
mask?: (value: any) => any;
|
|
256
260
|
}[]>;
|
|
257
|
-
rows: import("vue").Ref<{
|
|
258
|
-
[x: string]: any;
|
|
259
|
-
indent?: number;
|
|
260
|
-
parent?: number;
|
|
261
|
-
}[], TableRow[] | {
|
|
262
|
-
[x: string]: any;
|
|
263
|
-
indent?: number;
|
|
264
|
-
parent?: number;
|
|
265
|
-
}[]>;
|
|
266
261
|
config: import("vue").Ref<{
|
|
267
262
|
view?: "uncounted" | "list" | "list-expansion" | "tree";
|
|
268
263
|
fullWidth?: boolean;
|
|
@@ -270,7 +265,6 @@ export declare const createTableStore: (initData: {
|
|
|
270
265
|
view?: "uncounted" | "list" | "list-expansion" | "tree";
|
|
271
266
|
fullWidth?: boolean;
|
|
272
267
|
}>;
|
|
273
|
-
table: import("vue").Ref<{}, {}>;
|
|
274
268
|
display: import("vue").Ref<{
|
|
275
269
|
childrenOpen?: boolean;
|
|
276
270
|
expanded?: boolean;
|
|
@@ -315,6 +309,17 @@ export declare const createTableStore: (initData: {
|
|
|
315
309
|
component?: string;
|
|
316
310
|
componentProps?: Record<string, any>;
|
|
317
311
|
}>;
|
|
312
|
+
rows: import("vue").Ref<{
|
|
313
|
+
[x: string]: any;
|
|
314
|
+
indent?: number;
|
|
315
|
+
parent?: number;
|
|
316
|
+
}[], TableRow[] | {
|
|
317
|
+
[x: string]: any;
|
|
318
|
+
indent?: number;
|
|
319
|
+
parent?: number;
|
|
320
|
+
}[]>;
|
|
321
|
+
table: import("vue").Ref<{}, {}>;
|
|
322
|
+
updates: import("vue").Ref<Record<string, string>, Record<string, string>>;
|
|
318
323
|
hasPinnedColumns: import("vue").ComputedRef<boolean>;
|
|
319
324
|
numberedRowWidth: import("vue").ComputedRef<string>;
|
|
320
325
|
zeroColumn: import("vue").ComputedRef<boolean>;
|
|
@@ -327,6 +332,7 @@ export declare const createTableStore: (initData: {
|
|
|
327
332
|
getRowExpandSymbol: (rowIndex: number) => "" | "-" | "+";
|
|
328
333
|
isRowVisible: (rowIndex: number) => boolean;
|
|
329
334
|
setCellData: (colIndex: number, rowIndex: number, value: any) => void;
|
|
335
|
+
setCellText: (colIndex: number, rowIndex: number, value: string) => void;
|
|
330
336
|
toggleRowExpand: (rowIndex: number) => void;
|
|
331
|
-
}, "closeModal" | "getCellData" | "getCellDisplayValue" | "getFormattedValue" | "getHeaderCellStyle" | "getIndent" | "getRowExpandSymbol" | "isRowVisible" | "setCellData" | "toggleRowExpand">>;
|
|
337
|
+
}, "closeModal" | "getCellData" | "getCellDisplayValue" | "getFormattedValue" | "getHeaderCellStyle" | "getIndent" | "getRowExpandSymbol" | "isRowVisible" | "setCellData" | "setCellText" | "toggleRowExpand">>;
|
|
332
338
|
//# sourceMappingURL=table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/stores/table.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,KAAK,CAAA;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEzG;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aAAc;IAC1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CAhEnB,MAAM;6BAJZ,MAAM;4BA3BP,MAAM,YAAY,MAAM,SAAS,GAAG;4BAYpC,MAAM,YAAY,MAAM,SAAS,MAAM;gCA+BnC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0Cd,UAAU;kBAtFhB,CAAC,kBAAkB,MAAM,YAAY,MAAM,KAAG,CAAC;oCA4D7B,MAAM,YAAY,MAAM;kCAK1B,MAAM,YAAY,MAAM,SAAS,GAAG;iCA3CrC,WAAW,KAAG,aAAa;0BA0ElC,MAAM,gBAAgB,MAAM;mCAhEnB,MAAM;6BAJZ,MAAM;4BA3BP,MAAM,YAAY,MAAM,SAAS,GAAG;4BAYpC,MAAM,YAAY,MAAM,SAAS,MAAM;gCA+BnC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0Cd,UAAU;kBAtFhB,CAAC,kBAAkB,MAAM,YAAY,MAAM,KAAG,CAAC;oCA4D7B,MAAM,YAAY,MAAM;kCAK1B,MAAM,YAAY,MAAM,SAAS,GAAG;iCA3CrC,WAAW,KAAG,aAAa;0BA0ElC,MAAM,gBAAgB,MAAM;mCAhEnB,MAAM;6BAJZ,MAAM;4BA3BP,MAAM,YAAY,MAAM,SAAS,GAAG;4BAYpC,MAAM,YAAY,MAAM,SAAS,MAAM;gCA+BnC,MAAM;gNA2F1C,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createTableStore } from '../stores/table';
|
|
1
2
|
/**
|
|
2
3
|
* Table column definition.
|
|
3
4
|
* @public
|
|
@@ -97,4 +98,14 @@ export type TableModal = {
|
|
|
97
98
|
component?: string;
|
|
98
99
|
componentProps?: Record<string, any>;
|
|
99
100
|
};
|
|
101
|
+
/**
|
|
102
|
+
* Table modal props definition.
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export type TableModalProps = {
|
|
106
|
+
[key: string]: any;
|
|
107
|
+
colIndex: number;
|
|
108
|
+
rowIndex: number;
|
|
109
|
+
store: ReturnType<typeof createTableStore>;
|
|
110
|
+
};
|
|
100
111
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,MAAM,CAAA;IAEZ,KAAK,CAAC,EAAE,eAAe,CAAA;IACvB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACxC;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,WAAW,KAAK,MAAM,CAAC,CAAA;IAC5D,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAE9C,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,KAAK,MAAM,CAAC,CAAA;IAChE,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAA;CAC1B,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACzB,GAAG,EAAE,QAAQ,CAAA;IACb,MAAM,EAAE,WAAW,CAAA;IACnB,KAAK,EAAE;QAAE,C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U,CAAC,OAAO,gBAAgB,CAAC,CAAA;CAC1C,CAAA"}
|
package/dist/stores/table.js
CHANGED
|
@@ -58,6 +58,7 @@ export const createTableStore = (initData) => {
|
|
|
58
58
|
const table = ref(initData.table || createTableObject());
|
|
59
59
|
const display = ref(createDisplayObject(initData.display));
|
|
60
60
|
const modal = ref(initData.modal || { visible: false });
|
|
61
|
+
const updates = ref({});
|
|
61
62
|
// getters
|
|
62
63
|
const hasPinnedColumns = computed(() => columns.value.some(col => col.pinned));
|
|
63
64
|
const numberedRowWidth = computed(() => {
|
|
@@ -76,6 +77,13 @@ export const createTableStore = (initData) => {
|
|
|
76
77
|
table.value[index] = value;
|
|
77
78
|
rows.value[rowIndex][col.name] = value;
|
|
78
79
|
};
|
|
80
|
+
const setCellText = (colIndex, rowIndex, value) => {
|
|
81
|
+
const index = `${colIndex}:${rowIndex}`;
|
|
82
|
+
if (table.value[index] !== value) {
|
|
83
|
+
display.value[rowIndex].rowModified = true;
|
|
84
|
+
updates.value[index] = value;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
79
87
|
const getHeaderCellStyle = (column) => ({
|
|
80
88
|
minWidth: column.width || '40ch',
|
|
81
89
|
textAlign: column.align || 'center',
|
|
@@ -154,11 +162,12 @@ export const createTableStore = (initData) => {
|
|
|
154
162
|
return {
|
|
155
163
|
// state
|
|
156
164
|
columns,
|
|
157
|
-
rows,
|
|
158
165
|
config,
|
|
159
|
-
table,
|
|
160
166
|
display,
|
|
161
167
|
modal,
|
|
168
|
+
rows,
|
|
169
|
+
table,
|
|
170
|
+
updates,
|
|
162
171
|
// getters
|
|
163
172
|
hasPinnedColumns,
|
|
164
173
|
numberedRowWidth,
|
|
@@ -173,6 +182,7 @@ export const createTableStore = (initData) => {
|
|
|
173
182
|
getRowExpandSymbol,
|
|
174
183
|
isRowVisible,
|
|
175
184
|
setCellData,
|
|
185
|
+
setCellText,
|
|
176
186
|
toggleRowExpand,
|
|
177
187
|
};
|
|
178
188
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stonecrop/atable",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@vueuse/core": "^12.0.0",
|
|
39
39
|
"pinia": "^2.3.0",
|
|
40
40
|
"vue": "^3.5.11",
|
|
41
|
-
"@stonecrop/themes": "0.3.
|
|
42
|
-
"@stonecrop/utilities": "0.3.
|
|
41
|
+
"@stonecrop/themes": "0.3.4",
|
|
42
|
+
"@stonecrop/utilities": "0.3.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@microsoft/api-documenter": "^7.26.2",
|
package/src/components/ACell.vue
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
:style="cellStyle"
|
|
11
11
|
@focus="onFocus"
|
|
12
12
|
@paste="updateCellData"
|
|
13
|
-
@blur="updateCellData"
|
|
14
13
|
@input="updateCellData"
|
|
15
14
|
@click="showModal"
|
|
16
15
|
class="atable-cell"
|
|
@@ -28,7 +27,7 @@
|
|
|
28
27
|
<script setup lang="ts">
|
|
29
28
|
import { KeypressHandlers, defaultKeypressHandlers, useKeyboardNav } from '@stonecrop/utilities'
|
|
30
29
|
import { useElementBounding } from '@vueuse/core'
|
|
31
|
-
import { computed, CSSProperties, ref, useTemplateRef
|
|
30
|
+
import { computed, type CSSProperties, ref, useTemplateRef } from 'vue'
|
|
32
31
|
|
|
33
32
|
import { createTableStore } from '../stores/table'
|
|
34
33
|
import { isHtmlString } from '../utils'
|
|
@@ -48,12 +47,13 @@ const {
|
|
|
48
47
|
pinned?: boolean
|
|
49
48
|
}>()
|
|
50
49
|
|
|
50
|
+
const emit = defineEmits<{ cellInput: [colIndex: number, rowIndex: number, newValue: string, oldValue: string] }>()
|
|
51
|
+
|
|
51
52
|
const cellRef = useTemplateRef<HTMLTableCellElement>('cell')
|
|
52
53
|
const { width, height } = useElementBounding(cellRef)
|
|
53
54
|
|
|
54
55
|
// keep a shallow copy of the original cell value for comparison
|
|
55
56
|
const originalData = store.getCellData(colIndex, rowIndex)
|
|
56
|
-
const displayValue = ref(store.getCellDisplayValue(colIndex, rowIndex))
|
|
57
57
|
const currentData = ref('')
|
|
58
58
|
const cellModified = ref(false)
|
|
59
59
|
|
|
@@ -63,13 +63,7 @@ const row = store.rows[rowIndex]
|
|
|
63
63
|
const textAlign = column.align || 'center'
|
|
64
64
|
const cellWidth = column.width || '40ch'
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
() => store.getCellData(colIndex, rowIndex),
|
|
68
|
-
cellData => {
|
|
69
|
-
displayValue.value = store.getFormattedValue(colIndex, rowIndex, cellData)
|
|
70
|
-
}
|
|
71
|
-
)
|
|
72
|
-
|
|
66
|
+
const displayValue = computed(() => store.getCellDisplayValue(colIndex, rowIndex))
|
|
73
67
|
const isHtmlValue = computed(() => {
|
|
74
68
|
// TODO: check if display value is a native DOM element
|
|
75
69
|
return typeof displayValue.value === 'string' ? isHtmlString(displayValue.value) : false
|
|
@@ -156,23 +150,23 @@ const onFocus = () => {
|
|
|
156
150
|
}
|
|
157
151
|
}
|
|
158
152
|
|
|
159
|
-
const updateCellData = () => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
} else {
|
|
165
|
-
cellModified.value = cellRef.value.textContent !== originalData
|
|
166
|
-
}
|
|
153
|
+
const updateCellData = (payload: Event) => {
|
|
154
|
+
const target = payload.target as HTMLTableCellElement
|
|
155
|
+
if (target.textContent === currentData.value) {
|
|
156
|
+
return
|
|
157
|
+
}
|
|
167
158
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
159
|
+
emit('cellInput', colIndex, rowIndex, target.textContent, currentData.value)
|
|
160
|
+
currentData.value = target.textContent
|
|
161
|
+
|
|
162
|
+
// only apply changes if the cell value has changed after being mounted
|
|
163
|
+
if (column.format) {
|
|
164
|
+
cellModified.value = target.textContent !== store.getFormattedValue(colIndex, rowIndex, originalData)
|
|
165
|
+
// TODO: need to setup reverse format function?
|
|
166
|
+
store.setCellText(colIndex, rowIndex, target.textContent)
|
|
167
|
+
} else {
|
|
168
|
+
cellModified.value = target.textContent !== originalData
|
|
169
|
+
store.setCellData(colIndex, rowIndex, target.textContent)
|
|
176
170
|
}
|
|
177
171
|
}
|
|
178
172
|
</script>
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
textAlign: col?.align || 'center',
|
|
26
26
|
minWidth: col?.width || '40ch',
|
|
27
27
|
width: store.config.fullWidth ? 'auto' : null,
|
|
28
|
-
}"
|
|
28
|
+
}"
|
|
29
|
+
@cellInput="emitInput" />
|
|
29
30
|
</ARow>
|
|
30
31
|
</slot>
|
|
31
32
|
</tbody>
|
|
@@ -87,11 +88,14 @@ const tableRef = useTemplateRef<HTMLTableElement>('table')
|
|
|
87
88
|
const rowsValue = modelValue ? modelValue : rows
|
|
88
89
|
const store = createTableStore({ columns, rows: rowsValue, id, config })
|
|
89
90
|
|
|
90
|
-
store.$onAction(({ name, store, args }) => {
|
|
91
|
+
store.$onAction(({ name, store, args, after }) => {
|
|
91
92
|
if (name === 'setCellData') {
|
|
92
93
|
const [colIndex, rowIndex, newCellValue] = args
|
|
93
94
|
const prevCellValue = store.getCellData(colIndex, rowIndex)
|
|
94
|
-
|
|
95
|
+
|
|
96
|
+
after(() => {
|
|
97
|
+
emit('cellUpdate', colIndex, rowIndex, newCellValue, prevCellValue)
|
|
98
|
+
})
|
|
95
99
|
}
|
|
96
100
|
})
|
|
97
101
|
|
|
@@ -114,6 +118,10 @@ onMounted(() => {
|
|
|
114
118
|
}
|
|
115
119
|
})
|
|
116
120
|
|
|
121
|
+
const emitInput = (colIndex: number, rowIndex: number, newCellValue: any, prevCellValue: any) => {
|
|
122
|
+
emit('cellUpdate', colIndex, rowIndex, newCellValue, prevCellValue)
|
|
123
|
+
}
|
|
124
|
+
|
|
117
125
|
const assignStickyCellWidths = () => {
|
|
118
126
|
const table = tableRef.value
|
|
119
127
|
|
|
@@ -148,54 +156,6 @@ const assignStickyCellWidths = () => {
|
|
|
148
156
|
}
|
|
149
157
|
}
|
|
150
158
|
|
|
151
|
-
// const formatCell = (event?: KeyboardEvent, column?: TableColumn, cellData?: any) => {
|
|
152
|
-
// let colIndex: number
|
|
153
|
-
// const target = event?.target as HTMLTableCellElement
|
|
154
|
-
// if (event) {
|
|
155
|
-
// colIndex = target.cellIndex
|
|
156
|
-
// } else if (column && cellData) {
|
|
157
|
-
// colIndex = store.columns.indexOf(column)
|
|
158
|
-
// }
|
|
159
|
-
|
|
160
|
-
// if (!column && 'format' in store.columns[colIndex]) {
|
|
161
|
-
// // TODO: (utils) create helper to extract format from string
|
|
162
|
-
// const format = store.columns[colIndex].format
|
|
163
|
-
// if (typeof format === 'function') {
|
|
164
|
-
// return format(target.innerHTML)
|
|
165
|
-
// } else if (typeof format === 'string') {
|
|
166
|
-
// // parse format function from string
|
|
167
|
-
// // eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
168
|
-
// const formatFn: (args: any) => any = Function(`"use strict";return (${format})`)()
|
|
169
|
-
// return formatFn(target.innerHTML)
|
|
170
|
-
// } else {
|
|
171
|
-
// return target.innerHTML
|
|
172
|
-
// }
|
|
173
|
-
// } else if (cellData && 'format' in column) {
|
|
174
|
-
// const format = column.format
|
|
175
|
-
// if (typeof format === 'function') {
|
|
176
|
-
// return format(cellData)
|
|
177
|
-
// } else if (typeof format === 'string') {
|
|
178
|
-
// // parse format function from string
|
|
179
|
-
// // eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
180
|
-
// const formatFn: (args: any) => any = Function(`"use strict";return (${format})`)()
|
|
181
|
-
// return formatFn(cellData)
|
|
182
|
-
// } else {
|
|
183
|
-
// return cellData
|
|
184
|
-
// }
|
|
185
|
-
// } else if (cellData && column.type.toLowerCase() in ['int', 'decimal', 'float', 'number', 'percent']) {
|
|
186
|
-
// return cellData
|
|
187
|
-
// // TODO: number formatting
|
|
188
|
-
// } else {
|
|
189
|
-
// return cellData
|
|
190
|
-
// }
|
|
191
|
-
// }
|
|
192
|
-
|
|
193
|
-
// const moveCursorToEnd = (target: HTMLElement) => {
|
|
194
|
-
// target.focus()
|
|
195
|
-
// document.execCommand('selectAll', false, null)
|
|
196
|
-
// document.getSelection().collapseToEnd()
|
|
197
|
-
// }
|
|
198
|
-
|
|
199
159
|
window.addEventListener('keydown', (event: KeyboardEvent) => {
|
|
200
160
|
if (event.key === 'Escape') {
|
|
201
161
|
if (store.modal.visible) {
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,15 @@ import ATable from './components/ATable.vue'
|
|
|
7
7
|
import ATableHeader from './components/ATableHeader.vue'
|
|
8
8
|
import ATableModal from './components/ATableModal.vue'
|
|
9
9
|
export { createTableStore } from './stores/table'
|
|
10
|
-
export type {
|
|
10
|
+
export type {
|
|
11
|
+
CellContext,
|
|
12
|
+
TableColumn,
|
|
13
|
+
TableConfig,
|
|
14
|
+
TableDisplay,
|
|
15
|
+
TableModal,
|
|
16
|
+
TableModalProps,
|
|
17
|
+
TableRow,
|
|
18
|
+
} from './types'
|
|
11
19
|
|
|
12
20
|
/**
|
|
13
21
|
* Install all ATable components
|
package/src/stores/table.ts
CHANGED
|
@@ -75,6 +75,7 @@ export const createTableStore = (initData: {
|
|
|
75
75
|
const table = ref(initData.table || createTableObject())
|
|
76
76
|
const display = ref(createDisplayObject(initData.display))
|
|
77
77
|
const modal = ref(initData.modal || { visible: false })
|
|
78
|
+
const updates = ref<Record<string, string>>({})
|
|
78
79
|
|
|
79
80
|
// getters
|
|
80
81
|
const hasPinnedColumns = computed(() => columns.value.some(col => col.pinned))
|
|
@@ -100,6 +101,15 @@ export const createTableStore = (initData: {
|
|
|
100
101
|
rows.value[rowIndex][col.name] = value
|
|
101
102
|
}
|
|
102
103
|
|
|
104
|
+
const setCellText = (colIndex: number, rowIndex: number, value: string) => {
|
|
105
|
+
const index = `${colIndex}:${rowIndex}`
|
|
106
|
+
|
|
107
|
+
if (table.value[index] !== value) {
|
|
108
|
+
display.value[rowIndex].rowModified = true
|
|
109
|
+
updates.value[index] = value
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
103
113
|
const getHeaderCellStyle = (column: TableColumn): CSSProperties => ({
|
|
104
114
|
minWidth: column.width || '40ch',
|
|
105
115
|
textAlign: column.align || 'center',
|
|
@@ -185,11 +195,12 @@ export const createTableStore = (initData: {
|
|
|
185
195
|
return {
|
|
186
196
|
// state
|
|
187
197
|
columns,
|
|
188
|
-
rows,
|
|
189
198
|
config,
|
|
190
|
-
table,
|
|
191
199
|
display,
|
|
192
200
|
modal,
|
|
201
|
+
rows,
|
|
202
|
+
table,
|
|
203
|
+
updates,
|
|
193
204
|
|
|
194
205
|
// getters
|
|
195
206
|
hasPinnedColumns,
|
|
@@ -206,6 +217,7 @@ export const createTableStore = (initData: {
|
|
|
206
217
|
getRowExpandSymbol,
|
|
207
218
|
isRowVisible,
|
|
208
219
|
setCellData,
|
|
220
|
+
setCellText,
|
|
209
221
|
toggleRowExpand,
|
|
210
222
|
}
|
|
211
223
|
})
|
package/src/types/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createTableStore } from '../stores/table'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Table column definition.
|
|
3
5
|
* @public
|
|
@@ -104,3 +106,14 @@ export type TableModal = {
|
|
|
104
106
|
component?: string
|
|
105
107
|
componentProps?: Record<string, any>
|
|
106
108
|
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Table modal props definition.
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
export type TableModalProps = {
|
|
115
|
+
[key: string]: any
|
|
116
|
+
colIndex: number
|
|
117
|
+
rowIndex: number
|
|
118
|
+
store: ReturnType<typeof createTableStore>
|
|
119
|
+
}
|