zova-module-a-table 5.1.42 → 5.1.44
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/component/table/controller.d.ts +11 -2
- package/dist/component/table/controller.d.ts.map +1 -1
- package/dist/component/table/render.d.ts.map +1 -1
- package/dist/index.js +119 -6
- package/dist/index.js.map +1 -1
- package/dist/lib/beanControllerTableBase.d.ts +4 -0
- package/dist/lib/beanControllerTableBase.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/tableLayout.d.ts +23 -0
- package/dist/types/tableLayout.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/component/table/controller.tsx +66 -3
- package/src/component/table/render.tsx +2 -3
- package/src/lib/beanControllerTableBase.ts +10 -0
- package/src/types/index.ts +1 -0
- package/src/types/tableLayout.ts +101 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IResourceTableActionRowOptionsBase, ISchemaObjectExtensionField, TypeTableCellRenderComponent, TypeTableCellRenderComponentProvider } from 'zova-module-a-openapi';
|
|
1
|
+
import type { IResourceDetailsActionRowOptionsBase, IResourceTableActionRowOptionsBase, ISchemaObjectExtensionField, TypeTableCellRenderComponent, TypeTableCellRenderComponentProvider } from 'zova-module-a-openapi';
|
|
2
2
|
import { celEnvBase } from '@cabloy/utils';
|
|
3
3
|
import { CellContext, OnChangeFn, Row, RowSelectionState, SortingState } from '@tanstack/vue-table';
|
|
4
4
|
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
@@ -7,10 +7,12 @@ import { ZovaJsx } from 'zova-jsx';
|
|
|
7
7
|
import type { ITableMeta, TypeColumn, TypeTableGetColumns } from '../../types/table.js';
|
|
8
8
|
import type { IJsxRenderContextTableCell } from '../../types/tableCell.js';
|
|
9
9
|
import type { IJsxRenderContextTableColumn, ITableCellScope, ITableColumnScope, ITableScope } from '../../types/tableColumn.js';
|
|
10
|
+
import type { ITableLayout } from '../../types/tableLayout.js';
|
|
10
11
|
import { BeanControllerTableBase } from '../../lib/beanControllerTableBase.js';
|
|
11
12
|
import { ITableCellRenderColumnOptions } from '../../types/tableColumn.js';
|
|
12
13
|
export interface ControllerTableProps<TData extends {} = {}> {
|
|
13
14
|
data?: TData[];
|
|
15
|
+
layout?: ITableLayout;
|
|
14
16
|
schema?: SchemaObject;
|
|
15
17
|
schemaOrder?: SchemaObject;
|
|
16
18
|
sorting?: SortingState;
|
|
@@ -36,12 +38,19 @@ export declare class ControllerTable<TData extends {} = {}> extends BeanControll
|
|
|
36
38
|
get data(): TData[] | undefined;
|
|
37
39
|
get sorting(): SortingState;
|
|
38
40
|
get rowSelection(): RowSelectionState;
|
|
41
|
+
get layout(): ITableLayout;
|
|
42
|
+
get layoutProperties(): readonly ISchemaObjectExtensionField[];
|
|
39
43
|
refreshMeta(): Promise<void>;
|
|
40
44
|
private _createTable;
|
|
41
45
|
private _createColumns;
|
|
42
46
|
private _createColumnsMiddle;
|
|
43
47
|
private _getRowId;
|
|
44
48
|
private _canSelectRow;
|
|
49
|
+
private _getLayoutColumn;
|
|
50
|
+
private _getLayoutWidth;
|
|
51
|
+
private _getColumnVisibility;
|
|
52
|
+
private _getColumnOrder;
|
|
53
|
+
private _getColumnSizing;
|
|
45
54
|
private _getColumnPinning;
|
|
46
55
|
private _isOrderable;
|
|
47
56
|
private _createProperties;
|
|
@@ -50,7 +59,7 @@ export declare class ControllerTable<TData extends {} = {}> extends BeanControll
|
|
|
50
59
|
getCellJsxRenderContext(celScope: ITableCellScope, cellContext: CellContext<TData, any>): IJsxRenderContextTableCell;
|
|
51
60
|
cellRenderPrepare(renders: TypeTableCellRenderComponent | TypeTableCellRenderComponent[]): Promise<any[]>;
|
|
52
61
|
private _createColumnRender;
|
|
53
|
-
cellRender(render: TypeTableCellRenderComponent, columnProps: IResourceTableActionRowOptionsBase, renderContext: IJsxRenderContextTableCell): any;
|
|
62
|
+
cellRender(render: TypeTableCellRenderComponent, columnProps: IResourceTableActionRowOptionsBase | IResourceDetailsActionRowOptionsBase, renderContext: IJsxRenderContextTableCell): any;
|
|
54
63
|
private _cellRender;
|
|
55
64
|
private _cellRenderInner;
|
|
56
65
|
getColumnProperty(name: string): ISchemaObjectExtensionField | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/component/table/controller.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kCAAkC,EAClC,2BAA2B,EAE3B,4BAA4B,EAC5B,oCAAoC,EACrC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAsB,MAAM,eAAe,CAAC;AAC/D,OAAO,EACL,WAAW,EAIX,UAAU,EACV,GAAG,EACH,iBAAiB,EACjB,YAAY,EAEb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAS5B,OAAO,EAAkB,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,KAAK,EAEV,0BAA0B,EAE3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,4BAA4B,EAE5B,eAAe,EACf,iBAAiB,EACjB,WAAW,EAEZ,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/component/table/controller.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,kCAAkC,EAClC,2BAA2B,EAE3B,4BAA4B,EAC5B,oCAAoC,EACrC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAsB,MAAM,eAAe,CAAC;AAC/D,OAAO,EACL,WAAW,EAIX,UAAU,EACV,GAAG,EACH,iBAAiB,E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AAQ,EAAE,eAAe,EACzB,WAAW,EAAE,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,GACnC,0BAA0B;IAahB,iBAAiB,CAC5B,OAAO,EAAE,4BAA4B,GAAG,4BAA4B,EAAE;YAc1D,mBAAmB;IAwC1B,UAAU,CACf,MAAM,EAAE,4BAA4B,EACpC,WAAW,EAAE,kCAAkC,GAAG,oCAAoC,EACtF,aAAa,EAAE,0BAA0B;IA+B3C,OAAO,CAAC,WAAW;IAiCnB,OAAO,CAAC,gBAAgB;IA4DjB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,2BAA2B,GAAG,SAAS;IAK/E,OAAO,CAAC,gBAAgB;IAcjB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,EAAE,GAAG,iBAAiB;IAQhE,0BAA0B,CAC/B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,EAAE,EACZ,aAAa,EAAE,EAAE,GAChB,6BAA6B;IAMhC,OAAO,CAAC,iCAAiC;IAgBlC,iBAAiB,CACtB,MAAM,EAAE,4BAA4B,GAAG,SAAS,GAC/C,oCAAoC;CAOxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/component/table/render.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAKtC,qBACa,WAAY,SAAQ,cAAc;IAC7C,OAAO,CAAC,eAAe;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/component/table/render.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAKtC,qBACa,WAAY,SAAQ,cAAc;IAC7C,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,mBAAmB;IAqGpB,MAAM;;;CAGd"}
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,12 @@ var BeanControllerTableBase = class extends BeanControllerBase {
|
|
|
10
10
|
super(...args);
|
|
11
11
|
this.table = void 0;
|
|
12
12
|
}
|
|
13
|
+
get layout() {
|
|
14
|
+
throw new Error("should implement layout");
|
|
15
|
+
}
|
|
16
|
+
get layoutProperties() {
|
|
17
|
+
throw new Error("should implement layoutProperties");
|
|
18
|
+
}
|
|
13
19
|
$useTable(initialOptions) {
|
|
14
20
|
return this.ctx.util.instanceScope(() => {
|
|
15
21
|
return markRaw(useVueTable(initialOptions));
|
|
@@ -23,6 +29,72 @@ var BeanControllerTableBase = class extends BeanControllerBase {
|
|
|
23
29
|
//#region src/types/table.ts
|
|
24
30
|
var TableColumnIdSelection = "$$selection";
|
|
25
31
|
//#endregion
|
|
32
|
+
//#region src/types/tableLayout.ts
|
|
33
|
+
function isWidth(value) {
|
|
34
|
+
return value === "auto" || typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 2e3;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Reconciles a persisted layout with the currently eligible schema columns.
|
|
38
|
+
* Schema visibility and fixed regions always remain authoritative.
|
|
39
|
+
*/
|
|
40
|
+
function reconcileTableLayout(properties, profile) {
|
|
41
|
+
const entries = /* @__PURE__ */ new Map();
|
|
42
|
+
const profileColumns = Array.isArray(profile?.columns) ? profile.columns : [];
|
|
43
|
+
for (const item of profileColumns) {
|
|
44
|
+
if (!item || typeof item !== "object") continue;
|
|
45
|
+
const column = item;
|
|
46
|
+
const key = typeof column.key === "string" ? column.key.trim() : "";
|
|
47
|
+
if (!key || entries.has(key)) continue;
|
|
48
|
+
if (typeof column.visible !== "boolean" || !isWidth(column.width)) continue;
|
|
49
|
+
entries.set(key, {
|
|
50
|
+
key,
|
|
51
|
+
visible: column.visible,
|
|
52
|
+
width: column.width
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const eligible = properties.filter((property) => typeof property.key === "string" && property.key && property.key !== "$$selection");
|
|
56
|
+
const schemaKeys = new Set(eligible.map((property) => property.key));
|
|
57
|
+
const regions = /* @__PURE__ */ new Map();
|
|
58
|
+
regions.set("left", []);
|
|
59
|
+
regions.set("center", []);
|
|
60
|
+
regions.set("right", []);
|
|
61
|
+
for (const property of eligible) {
|
|
62
|
+
const fixed = property.rest?.fixed;
|
|
63
|
+
regions.get(fixed === "left" ? "left" : fixed === "right" ? "right" : "center").push(property);
|
|
64
|
+
}
|
|
65
|
+
const result = [];
|
|
66
|
+
for (const region of [
|
|
67
|
+
"left",
|
|
68
|
+
"center",
|
|
69
|
+
"right"
|
|
70
|
+
]) {
|
|
71
|
+
const regionProperties = regions.get(region);
|
|
72
|
+
const regionKeys = new Set(regionProperties.map((property) => property.key));
|
|
73
|
+
const ordered = profileColumns.map((item) => item && typeof item === "object" ? item : void 0).filter((item) => {
|
|
74
|
+
const key = typeof item?.key === "string" ? item.key.trim() : "";
|
|
75
|
+
return !!key && regionKeys.has(key) && schemaKeys.has(key) && entries.get(key)?.key === key;
|
|
76
|
+
}).map((item) => item.key);
|
|
77
|
+
const seen = /* @__PURE__ */ new Set();
|
|
78
|
+
for (const key of [...ordered, ...regionProperties.map((property) => property.key)]) {
|
|
79
|
+
if (seen.has(key)) continue;
|
|
80
|
+
seen.add(key);
|
|
81
|
+
const property = regionProperties.find((item) => item.key === key);
|
|
82
|
+
const entry = entries.get(key);
|
|
83
|
+
const schemaWidth = property.rest?.width;
|
|
84
|
+
result.push({
|
|
85
|
+
key,
|
|
86
|
+
visible: entry?.visible ?? true,
|
|
87
|
+
width: entry?.width ?? (typeof schemaWidth === "number" && schemaWidth > 0 ? schemaWidth : "auto")
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
version: 1,
|
|
93
|
+
...typeof profile?.schemaFingerprint === "string" ? { schemaFingerprint: profile.schemaFingerprint } : {},
|
|
94
|
+
columns: result
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
26
98
|
//#region src/component/table/controller.tsx
|
|
27
99
|
var _dec$2;
|
|
28
100
|
var _dec2$2;
|
|
@@ -51,6 +123,10 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
51
123
|
if (newValue === oldValue) return;
|
|
52
124
|
await this.refreshMeta();
|
|
53
125
|
});
|
|
126
|
+
this.$watch(() => this.$props.layout, async (newValue, oldValue) => {
|
|
127
|
+
if (deepEqual(newValue, oldValue)) return;
|
|
128
|
+
await this.refreshMeta();
|
|
129
|
+
});
|
|
54
130
|
this._createTable();
|
|
55
131
|
}
|
|
56
132
|
get schema() {
|
|
@@ -65,6 +141,12 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
65
141
|
get rowSelection() {
|
|
66
142
|
return this.$props.rowSelection ?? {};
|
|
67
143
|
}
|
|
144
|
+
get layout() {
|
|
145
|
+
return reconcileTableLayout(this.layoutProperties, this.$props.layout);
|
|
146
|
+
}
|
|
147
|
+
get layoutProperties() {
|
|
148
|
+
return this.tableMeta?.properties ?? [];
|
|
149
|
+
}
|
|
68
150
|
async refreshMeta() {
|
|
69
151
|
this.tableMeta = await this._createTableMeta();
|
|
70
152
|
this.columns = await this._createColumns();
|
|
@@ -88,6 +170,15 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
88
170
|
},
|
|
89
171
|
get rowSelection() {
|
|
90
172
|
return self.rowSelection;
|
|
173
|
+
},
|
|
174
|
+
get columnVisibility() {
|
|
175
|
+
return self._getColumnVisibility();
|
|
176
|
+
},
|
|
177
|
+
get columnOrder() {
|
|
178
|
+
return self._getColumnOrder();
|
|
179
|
+
},
|
|
180
|
+
get columnSizing() {
|
|
181
|
+
return self._getColumnSizing();
|
|
91
182
|
}
|
|
92
183
|
},
|
|
93
184
|
onSortingChange: (updater) => {
|
|
@@ -148,10 +239,13 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
148
239
|
return property?.title || key;
|
|
149
240
|
},
|
|
150
241
|
cell: (props) => tableMeta.renders[key](props),
|
|
151
|
-
size:
|
|
242
|
+
size: this._getLayoutWidth(key),
|
|
152
243
|
enableSorting: property.rest?.enableSorting === true && this._isOrderable(property),
|
|
153
244
|
sortDescFirst: property.rest?.sortDescFirst === true,
|
|
154
|
-
meta: { rest:
|
|
245
|
+
meta: { rest: {
|
|
246
|
+
...property.rest,
|
|
247
|
+
width: this._getLayoutWidth(key)
|
|
248
|
+
} }
|
|
155
249
|
}));
|
|
156
250
|
}
|
|
157
251
|
return columns;
|
|
@@ -168,6 +262,23 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
168
262
|
if (isNilOrEmptyString(originalId)) return false;
|
|
169
263
|
return typeof enableRowSelection === "function" ? enableRowSelection(row) : true;
|
|
170
264
|
}
|
|
265
|
+
_getLayoutColumn(key) {
|
|
266
|
+
return this.layout.columns.find((column) => column.key === key);
|
|
267
|
+
}
|
|
268
|
+
_getLayoutWidth(key) {
|
|
269
|
+
const width = this._getLayoutColumn(key)?.width;
|
|
270
|
+
return typeof width === "number" ? width : void 0;
|
|
271
|
+
}
|
|
272
|
+
_getColumnVisibility() {
|
|
273
|
+
return Object.fromEntries(this.layout.columns.filter((column) => column.key !== "$$selection").map((column) => [column.key, column.visible]));
|
|
274
|
+
}
|
|
275
|
+
_getColumnOrder() {
|
|
276
|
+
const keys = this.layout.columns.map((column) => column.key);
|
|
277
|
+
return this.$props.enableRowSelection ? ["$$selection", ...keys] : keys;
|
|
278
|
+
}
|
|
279
|
+
_getColumnSizing() {
|
|
280
|
+
return Object.fromEntries(this.layout.columns.filter((column) => typeof column.width === "number").map((column) => [column.key, column.width]));
|
|
281
|
+
}
|
|
171
282
|
_getColumnPinning() {
|
|
172
283
|
const left = this.$props.enableRowSelection ? ["$$selection"] : [];
|
|
173
284
|
const right = [];
|
|
@@ -360,10 +471,12 @@ var RenderTable = (_dec$1 = Render(), _dec2$1 = BeanInfo({ module: "a-table" }),
|
|
|
360
471
|
_getColumnStyle(column) {
|
|
361
472
|
const rest = column.columnDef.meta?.rest;
|
|
362
473
|
const fixed = column.getIsPinned();
|
|
363
|
-
const width =
|
|
474
|
+
const width = column.getSize();
|
|
364
475
|
return {
|
|
365
|
-
width
|
|
366
|
-
|
|
476
|
+
...typeof rest?.width === "number" ? {
|
|
477
|
+
width: `${width}px`,
|
|
478
|
+
minWidth: `${width}px`
|
|
479
|
+
} : {},
|
|
367
480
|
textAlign: rest?.align,
|
|
368
481
|
position: fixed ? "sticky" : void 0,
|
|
369
482
|
left: fixed === "left" ? `${column.getStart("left")}px` : void 0,
|
|
@@ -483,6 +596,6 @@ function TableCell(options) {
|
|
|
483
596
|
return createBeanDecorator("tableCell", "app", true, options);
|
|
484
597
|
}
|
|
485
598
|
//#endregion
|
|
486
|
-
export { BeanControllerPageTableBase, BeanControllerTableBase, ControllerTable, RenderTable, ScopeModuleATable, TableCell, TableColumnIdSelection, ZTable, components, config };
|
|
599
|
+
export { BeanControllerPageTableBase, BeanControllerTableBase, ControllerTable, RenderTable, ScopeModuleATable, TableCell, TableColumnIdSelection, ZTable, components, config, reconcileTableLayout };
|
|
487
600
|
|
|
488
601
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["celEnvBase","isNilOrEmptyString","createColumnHelper","functionalUpdate","getCoreRowModel","appResource","beanFullNameFromOnionName","cast","deepEqual","deepExtend","objectAssignReactive","isJsxComponent","ZovaJsx","Controller","BeanControllerTableBase","TableColumnIdSelection","ControllerTable","_dec","_dec2","__z_BeanInfo","module","_class","_ControllerTable","constructor","args","properties","columns","tableMeta","zovaJsx","columnCelEnv","__init__","bean","_setBean","_getColumnCelEnv","_newBeanSimple","undefined","_createProperties","refreshMeta","$watch","$props","schema","newValue","oldValue","enableRowSelection","_createTable","data","sorting","rowSelection","_createTableMeta","_createColumns","table","setColumnPinning","_getColumnPinning","self","tableOptions","getRowId","originalRow","index","parent","_getRowId","renderFallbackValue","scope","config","manualPagination","manualSorting","enableMultiSort","enableSortingRemoval","row","_canSelectRow","enableMultiRowSelection","selectionMode","state","onSortingChange","updater","slice","onRowSelectionChange","initialState","columnPinning","$useTable","getColumns","_createColumnsMiddle","key","render","columnScope","getColumnScope","jsxRenderContext","getColumnJsxRenderContext","visible","columnProps","getColumnComponentPropsTop","_createColumnRender","columnHelper","display","id","header","cell","size","enableSorting","meta","rest","fixed","width","align","property","push","accessor","_props","title","props","renders","_isOrderable","sortDescFirst","String","originalId","original","getParentRow","left","right","schemaOrder","keys","schemaKey","schemaKeys","some","Object","prototype","hasOwnProperty","call","$computed","$sdk","loadSchemaProperties","promises","res","Promise","all","filter","_item","item","forEach","celScope","app","ctx","$scene","$host","$celScope","$jsx","$$table","getCellJsxRenderContext","cellContext","cellRenderPrepare","Array","isArray","renderProviders","map","getRenderProvider","renderProvider","includes","_getBean","renderContext","beanInstance","beanOptions","getBean","onionOptions","options","checkVisible","_cellRender","cellRender","cellScope","_getBeanSyncOnly","cellProps","setTransientObject","getValue","name","_cellRenderInner","value","fallbackValue","cellProps2","renderJsxProps","class","style","$cssMerge","$style","children","length","renderJsxChildrenDirect","getColumnProperty","find","celEnv","clone","registerFunction","transientObject","defaultValue","scopeExtra","tableScope","_getColumnComponentPropsTopByRest","_renderContext","evaluateExpression","assign","$propsDefault","FlexRender","BeanRenderBase","Render","TableColumnIdSelection","RenderTable","_dec","_dec2","__z_BeanInfo","module","_class","_getColumnStyle","column","rest","columnDef","meta","fixed","getIsPinned","width","undefined","minWidth","textAlign","align","position","left","getStart","right","getAfter","zIndex","_renderTableDefault","table","selectionMode","$props","_createVNode","getFlatHeaders","map","header","canSort","getCanSort","sorted","getIsSorted","headerDefinition","selection","id","headerContent","getIsAllPageRowsSelected","getIsSomePageRowsSelected","getRowModel","rows","every","row","getCanSelect","getToggleAllPageRowsSelectedHandler","getContext","sortAria","sortIcon","getToggleSortingHandler","getIsSelected","getVisibleCells","cell","getToggleSelectedHandler","render","$slotDefault"],"sources":["../src/lib/beanControllerTableBase.ts","../src/types/table.ts","../src/component/table/controller.tsx","../src/component/table/render.tsx","../src/.metadata/component/table.ts","../src/config/config.ts","../src/.metadata/index.ts","../src/lib/beanControllerPageTableBase.ts","../src/lib/tableCell.ts"],"sourcesContent":["import { useVueTable } from '@tanstack/vue-table';\nimport { markRaw } from 'vue';\nimport { BeanControllerBase } from 'zova';\nexport class BeanControllerTableBase extends BeanControllerBase {\n constructor(...args) {\n super(...args);\n this.table = void 0;\n }\n $useTable(initialOptions) {\n return this.ctx.util.instanceScope(() => {\n return markRaw(useVueTable(initialOptions));\n });\n }\n async refreshMeta() {\n throw new Error('should implement refreshMeta');\n }\n}","export const TableColumnIdSelection = '$$selection';","import type {\n IResourceTableActionRowOptionsBase,\n ISchemaObjectExtensionField,\n ISchemaObjectExtensionFieldRest,\n TypeTableCellRenderComponent,\n TypeTableCellRenderComponentProvider,\n} from 'zova-module-a-openapi';\n\nimport { celEnvBase, isNilOrEmptyString } from '@cabloy/utils';\nimport {\n CellContext,\n createColumnHelper,\n functionalUpdate,\n getCoreRowModel,\n OnChangeFn,\n Row,\n RowSelectionState,\n SortingState,\n TableOptionsWithReactiveData,\n} from '@tanstack/vue-table';\nimport { SchemaObject } from 'openapi3-ts/oas31';\nimport { VNode } from 'vue';\nimport {\n appResource,\n beanFullNameFromOnionName,\n cast,\n deepEqual,\n deepExtend,\n objectAssignReactive,\n} from 'zova';\nimport { isJsxComponent, ZovaJsx } from 'zova-jsx';\nimport { Controller } from 'zova-module-a-bean';\n\nimport type { ITableMeta, TypeColumn, TypeTableGetColumns } from '../../types/table.js';\nimport type {\n IDecoratorTableCellOptions,\n IJsxRenderContextTableCell,\n ITableCellRender,\n} from '../../types/tableCell.js';\nimport type {\n IJsxRenderContextTableColumn,\n ITableCellRenderColumnProps,\n ITableCellScope,\n ITableColumnScope,\n ITableScope,\n TypeTableCellRender,\n} from '../../types/tableColumn.js';\n\nimport { BeanControllerTableBase } from '../../lib/beanControllerTableBase.js';\nimport { TableColumnIdSelection } from '../../types/table.js';\nimport { ITableCellRenderColumnOptions } from '../../types/tableColumn.js';\n\nexport interface ControllerTableProps<TData extends {} = {}> {\n data?: TData[];\n schema?: SchemaObject;\n schemaOrder?: SchemaObject;\n sorting?: SortingState;\n onSortingChange?: OnChangeFn<SortingState>;\n enableRowSelection?: boolean | ((row: Row<TData>) => boolean);\n selectionMode?: 'single' | 'multiple';\n rowSelection?: RowSelectionState;\n onRowSelectionChange?: OnChangeFn<RowSelectionState>;\n tableScope?: ITableScope;\n getColumns?: TypeTableGetColumns<TData>;\n slotDefault?: (table: ControllerTable<TData>) => VNode;\n getRowId?: (originalRow: TData, index: number, parent?: Row<TData>) => string;\n}\n\n@Controller()\nexport class ControllerTable<TData extends {} = {}> extends BeanControllerTableBase<TData> {\n static $propsDefault = {};\n\n // table: TypeTable<TData>; // in BeanControllerTableBase\n\n properties: ISchemaObjectExtensionField[] | undefined;\n columns: TypeColumn<TData>[];\n tableMeta: ITableMeta<TData>;\n zovaJsx: ZovaJsx;\n columnCelEnv: typeof celEnvBase;\n\n protected async __init__() {\n this.bean._setBean('$$table', this);\n // jsx\n this.columnCelEnv = this._getColumnCelEnv();\n this.zovaJsx = this.bean._newBeanSimple(ZovaJsx, false, undefined, this.columnCelEnv);\n // properties\n this._createProperties();\n // tableMeta/columns\n await this.refreshMeta();\n // watch\n this.$watch(\n () => this.$props.schema,\n async (newValue, oldValue) => {\n if (deepEqual(newValue, oldValue)) return;\n await this.refreshMeta();\n },\n );\n this.$watch(\n () => this.$props.enableRowSelection,\n async (newValue, oldValue) => {\n if (newValue === oldValue) return;\n await this.refreshMeta();\n },\n );\n // table\n this._createTable();\n }\n\n public get schema() {\n return this.$props.schema;\n }\n\n public get data() {\n return this.$props.data;\n }\n\n public get sorting() {\n return this.$props.sorting ?? [];\n }\n\n public get rowSelection() {\n return this.$props.rowSelection ?? {};\n }\n\n public async refreshMeta() {\n this.tableMeta = await this._createTableMeta();\n this.columns = await this._createColumns();\n this.table?.setColumnPinning(this._getColumnPinning());\n }\n\n private _createTable() {\n // eslint-disable-next-line\n const self = this;\n const tableOptions: TableOptionsWithReactiveData<TData> = {\n getRowId: (originalRow, index, parent) => this._getRowId(originalRow, index, parent),\n getCoreRowModel: getCoreRowModel(),\n renderFallbackValue: this.scope.config.renderFallbackValue,\n manualPagination: true,\n manualSorting: true,\n enableMultiSort: false,\n enableSortingRemoval: false,\n enableRowSelection: row => self._canSelectRow(row),\n enableMultiRowSelection: this.$props.selectionMode !== 'single',\n state: {\n get sorting() {\n return self.sorting;\n },\n get rowSelection() {\n return self.rowSelection;\n },\n },\n onSortingChange: updater => {\n const sorting = functionalUpdate(updater, self.sorting).slice(0, 1);\n self.$props.onSortingChange?.(sorting);\n },\n onRowSelectionChange: updater => {\n const rowSelection = functionalUpdate(updater, self.rowSelection);\n self.$props.onRowSelectionChange?.(rowSelection);\n },\n get initialState() {\n const columnPinning = self._getColumnPinning();\n return { columnPinning };\n },\n get data() {\n return self.data || [];\n },\n get columns() {\n return self.columns;\n },\n };\n this.table = this.$useTable(tableOptions);\n this.table.setColumnPinning(this._getColumnPinning());\n }\n\n private async _createColumns() {\n if (!this.properties) return [];\n const columns = !this.$props.getColumns\n ? await this._createColumnsMiddle(this.tableMeta.properties)\n : await this.$props.getColumns(\n async properties => {\n return await this._createColumnsMiddle(properties ?? this.tableMeta.properties);\n },\n async (\n key: string,\n render: TypeTableCellRenderComponent,\n ): Promise<TypeTableCellRender<TData, any> | undefined> => {\n // columnScope\n const columnScope = this.getColumnScope(key);\n // renderContext\n const jsxRenderContext = this.getColumnJsxRenderContext(columnScope);\n // columnProps\n const { visible, columnProps } = this.getColumnComponentPropsTop(\n key,\n columnScope,\n jsxRenderContext,\n );\n // visible\n if (visible === false) return;\n return await this._createColumnRender(\n render,\n columnProps,\n columnScope,\n jsxRenderContext,\n );\n },\n this,\n );\n if (!this.$props.enableRowSelection) return columns;\n const columnHelper = createColumnHelper<TData>();\n return [\n columnHelper.display({\n id: TableColumnIdSelection,\n header: '',\n cell: '',\n size: 48,\n enableSorting: false,\n meta: { rest: { fixed: 'left', width: 48, align: 'center' } },\n }),\n ...columns,\n ];\n }\n\n private async _createColumnsMiddle(\n properties: ISchemaObjectExtensionField[],\n ): Promise<TypeColumn<TData>[]> {\n const tableMeta = this.tableMeta;\n const columnHelper = createColumnHelper<TData>();\n const columns: TypeColumn<TData>[] = [];\n for (const property of properties) {\n const key = property.key!;\n columns.push(\n columnHelper.accessor(key as any, {\n id: key,\n header: _props => {\n return property?.title || key;\n },\n cell: props => tableMeta.renders[key](props),\n size: property.rest?.width,\n enableSorting: property.rest?.enableSorting === true && this._isOrderable(property),\n sortDescFirst: property.rest?.sortDescFirst === true,\n meta: { rest: property.rest },\n }),\n );\n }\n return columns;\n }\n\n private _getRowId(originalRow: TData, index: number, parent?: Row<TData>) {\n const id = this.$props.getRowId?.(originalRow, index, parent) ?? cast(originalRow).id;\n if (isNilOrEmptyString(id)) {\n return `__unselectable_${parent ? `${parent.id}.` : ''}${index}`;\n }\n return String(id);\n }\n\n private _canSelectRow(row: Row<TData>) {\n const enableRowSelection = this.$props.enableRowSelection;\n if (!enableRowSelection) return false;\n const originalId =\n this.$props.getRowId?.(row.original, row.index, row.getParentRow()) ?? cast(row.original).id;\n if (isNilOrEmptyString(originalId)) return false;\n return typeof enableRowSelection === 'function' ? enableRowSelection(row) : true;\n }\n\n private _getColumnPinning() {\n const left: string[] = this.$props.enableRowSelection ? [TableColumnIdSelection] : [];\n const right: string[] = [];\n for (const property of this.tableMeta?.properties ?? []) {\n const fixed = property.rest?.fixed;\n if (fixed === 'left') left.push(property.key!);\n if (fixed === 'right') right.push(property.key!);\n }\n return { left, right };\n }\n\n private _isOrderable(property: ISchemaObjectExtensionField) {\n const properties = this.$props.schemaOrder?.properties;\n if (!properties) return false;\n const keys = [property.key, property.schemaKey, ...(property.schemaKeys ?? [])];\n return keys.some(key => key && Object.prototype.hasOwnProperty.call(properties, key));\n }\n\n private _createProperties() {\n this.properties = this.$computed(() => {\n return this.$sdk.loadSchemaProperties(this.schema, 'table');\n });\n }\n\n private async _createTableMeta() {\n let properties: ISchemaObjectExtensionField[] = [];\n const renders: Record<string, TypeTableCellRender<TData>> = {};\n if (!this.properties) return { properties, renders };\n const promises: Promise<any>[] = [];\n for (const property of this.properties) {\n const key = property.key!;\n // columnScope\n const columnScope = this.getColumnScope(key);\n // renderContext\n const jsxRenderContext = this.getColumnJsxRenderContext(columnScope);\n // columnProps\n const { visible, render, columnProps } = this.getColumnComponentPropsTop(\n key,\n columnScope,\n jsxRenderContext,\n );\n // visible\n if (visible === false) continue;\n // property\n properties.push(property);\n // render\n promises.push(this._createColumnRender(render, columnProps, columnScope, jsxRenderContext));\n }\n let res = await Promise.all(promises);\n properties = properties.filter((_item, index) => !!res[index]);\n res = res.filter(item => !!item);\n properties.forEach((item, index) => {\n renders[item.key!] = res[index];\n });\n return { properties, renders };\n }\n\n public getColumnJsxRenderContext(celScope: ITableColumnScope): IJsxRenderContextTableColumn {\n return {\n app: this.app,\n ctx: this.ctx,\n $scene: 'tableColumn',\n $host: this,\n $celScope: celScope,\n $jsx: this.zovaJsx,\n $$table: this,\n };\n }\n\n public getCellJsxRenderContext(\n celScope: ITableCellScope,\n cellContext: CellContext<TData, any>,\n ): IJsxRenderContextTableCell {\n return {\n app: this.app,\n ctx: this.ctx,\n $scene: 'tableCell',\n $host: this,\n $celScope: celScope,\n $jsx: this.zovaJsx,\n $$table: this,\n cellContext,\n };\n }\n\n public async cellRenderPrepare(\n renders: TypeTableCellRenderComponent | TypeTableCellRenderComponent[],\n ) {\n if (!Array.isArray(renders)) renders = [renders];\n const renderProviders = renders.map(item => this.getRenderProvider(item));\n const promises: Promise<any>[] = renderProviders.map(renderProvider =>\n (async () => {\n if (typeof renderProvider === 'string' && renderProvider.includes('.tableCell.')) {\n return await this.app.bean._getBean(renderProvider as any, true);\n }\n })(),\n );\n return await Promise.all(promises);\n }\n\n private async _createColumnRender(\n render: TypeTableCellRenderComponent | undefined,\n columnProps: ITableCellRenderColumnProps | undefined,\n columnScope: ITableColumnScope,\n renderContext: IJsxRenderContextTableColumn,\n ): Promise<TypeTableCellRender<TData, any> | undefined> {\n // renderProvider\n const renderProvider = this.getRenderProvider(render);\n // beanInstance\n let beanInstance: ITableCellRender | undefined;\n if (typeof renderProvider === 'string' && renderProvider.includes('.tableCell.')) {\n beanInstance = await this.app.bean._getBean(renderProvider as any, true);\n const beanOptions = appResource.getBean(renderProvider as any);\n const onionOptions = beanOptions?.options as IDecoratorTableCellOptions | undefined;\n columnProps = deepExtend({}, onionOptions, columnProps);\n // should not eval jsx columnProps\n // columnProps = this.zovaJsx.renderJsxProps(columnProps as any, {}, columnScope, renderContext) as any;\n if (\n beanInstance?.checkVisible &&\n !(await beanInstance.checkVisible(columnProps as any, renderContext))\n ) {\n return;\n }\n }\n return cellContext => {\n if (!cellContext) return;\n return this._cellRender(\n render,\n columnProps,\n columnScope,\n cellContext,\n renderProvider,\n beanInstance,\n undefined,\n undefined,\n undefined,\n );\n };\n }\n\n public cellRender(\n render: TypeTableCellRenderComponent,\n columnProps: IResourceTableActionRowOptionsBase,\n renderContext: IJsxRenderContextTableCell,\n ) {\n // render\n const cellScope = renderContext.$celScope;\n // renderProvider\n const renderProvider = this.getRenderProvider(render);\n // beanInstance\n let beanInstance: ITableCellRender | undefined;\n if (typeof renderProvider === 'string' && renderProvider.includes('.tableCell.')) {\n beanInstance = this.app.bean._getBeanSyncOnly(renderProvider as any);\n const beanOptions = appResource.getBean(renderProvider as any);\n const onionOptions = beanOptions?.options as IDecoratorTableCellOptions | undefined;\n columnProps = deepExtend({}, onionOptions, columnProps);\n // should not eval jsx columnProps\n // columnProps = this.zovaJsx.renderJsxProps(columnProps as any, {}, renderContext.$celScope, renderContext) as any;\n }\n // const cellProps = isJsxComponent(render) ? Object.assign({}, columnProps, cast(render).props) : columnProps;\n const cellProps = columnProps;\n return this._cellRender(\n render,\n columnProps as ITableCellRenderColumnProps,\n undefined,\n renderContext.cellContext,\n renderProvider,\n beanInstance,\n cellProps,\n cellScope,\n renderContext,\n );\n }\n\n private _cellRender(\n render: TypeTableCellRenderComponent | undefined,\n columnProps: ITableCellRenderColumnProps | undefined,\n columnScope: ITableColumnScope | undefined,\n cellContext: CellContext<TData, any>,\n renderProvider: TypeTableCellRenderComponentProvider,\n beanInstance: ITableCellRender | undefined,\n cellProps: any | undefined,\n cellScope: ITableCellScope | undefined,\n jsxRenderContext: IJsxRenderContextTableCell | undefined,\n ) {\n return this.zovaJsx.setTransientObject(\n {\n getValue: (name: string) => {\n return cellContext.row.getValue(name);\n },\n },\n () => {\n return this._cellRenderInner(\n render,\n columnProps,\n columnScope,\n cellContext,\n renderProvider,\n beanInstance,\n cellProps,\n cellScope,\n jsxRenderContext,\n );\n },\n );\n }\n\n private _cellRenderInner(\n render: TypeTableCellRenderComponent | undefined,\n columnProps: ITableCellRenderColumnProps | undefined,\n columnScope: ITableColumnScope | undefined,\n cellContext: CellContext<TData, any>,\n renderProvider: TypeTableCellRenderComponentProvider,\n beanInstance: ITableCellRender | undefined,\n cellProps: any | undefined,\n cellScope: ITableCellScope | undefined,\n jsxRenderContext: IJsxRenderContextTableCell | undefined,\n ) {\n // value\n const value = cellContext.getValue();\n // renderFallbackValue\n const fallbackValue = this.table.options.renderFallbackValue;\n // cellScope\n if (!cellScope) {\n cellScope = objectAssignReactive({}, columnScope, { value, fallbackValue })!;\n }\n // render: text\n if (renderProvider === ('text' as TypeTableCellRenderComponent)) {\n return isNilOrEmptyString(value) ? fallbackValue : value;\n }\n // renderContext\n if (!jsxRenderContext) {\n jsxRenderContext = this.getCellJsxRenderContext(cellScope, cellContext);\n }\n // beanInstance\n if (beanInstance) {\n // jsx: props\n if (!cellProps) {\n // cellProps = isJsxComponent(render) ? Object.assign({}, columnProps, cast(render).props) : columnProps;\n cellProps = columnProps;\n }\n const cellProps2 = this.zovaJsx.renderJsxProps(\n cellProps,\n {},\n cellScope,\n jsxRenderContext,\n ) as any;\n if (cellProps2.class || cellProps2.style) {\n cellProps2.class = jsxRenderContext.$host.$cssMerge(\n cellProps2.class,\n jsxRenderContext.$host.$style(cellProps2.style),\n );\n delete cellProps2.style;\n }\n return beanInstance.render(cellProps2, jsxRenderContext, () => {\n const children = isJsxComponent(render) && cast(render).children;\n if (children && children.length > 0) {\n return this.zovaJsx.renderJsxChildrenDirect(children, cellScope, jsxRenderContext);\n } else {\n return value;\n }\n });\n }\n // general component\n return this.zovaJsx.render(render!, {}, cellScope, jsxRenderContext);\n }\n\n public getColumnProperty(name: string): ISchemaObjectExtensionField | undefined {\n if (!this.properties) return;\n return this.properties.find(item => item.key === name);\n }\n\n private _getColumnCelEnv(): typeof celEnvBase {\n const celEnv = celEnvBase.clone();\n celEnv.registerFunction('getProperty(string):dyn', name => {\n return this.getColumnProperty(name);\n });\n celEnv.registerFunction('getValue(string):dyn', name => {\n return this.zovaJsx.transientObject.getValue(name) ?? null;\n });\n celEnv.registerFunction('getValue(string, dyn):dyn', (name, defaultValue) => {\n return this.zovaJsx.transientObject.getValue(name) ?? defaultValue;\n });\n return celEnv;\n }\n\n public getColumnScope(name: string, scopeExtra?: {}): ITableColumnScope {\n return objectAssignReactive({}, this.$props.tableScope, {\n name,\n property: this.getColumnProperty(name),\n ...scopeExtra,\n });\n }\n\n public getColumnComponentPropsTop(\n name: string,\n celScope: {},\n renderContext: {},\n ): ITableCellRenderColumnOptions {\n const property = this.getColumnProperty(name);\n const rest = property?.rest;\n return this._getColumnComponentPropsTopByRest(rest, name, celScope, renderContext);\n }\n\n private _getColumnComponentPropsTopByRest(\n rest: ISchemaObjectExtensionFieldRest | undefined,\n name: string,\n celScope: {},\n _renderContext: {},\n ): ITableCellRenderColumnOptions {\n const visible = this.zovaJsx.evaluateExpression(rest?.visible, celScope);\n const render = rest?.render as TypeTableCellRenderComponent | undefined;\n const columnProps = Object.assign({ key: name }, cast(rest)?.columnProps);\n return { visible, render, columnProps };\n }\n\n // public getRenderFlattern(render: TypeTableCellRenderComponent): TypeTableCellRenderComponent {\n // return isJsxComponent(render) ? cast(render).type : render;\n // }\n\n public getRenderProvider(\n render: TypeTableCellRenderComponent | undefined,\n ): TypeTableCellRenderComponentProvider {\n if (!render) return 'text';\n if (typeof render === 'string' && render.includes(':')) {\n return beanFullNameFromOnionName(render, 'tableCell');\n }\n return render;\n }\n}\n","import type { AriaAttributes, CSSProperties } from 'vue';\n\nimport { FlexRender } from '@tanstack/vue-table';\nimport { BeanRenderBase } from 'zova';\nimport { Render } from 'zova-module-a-bean';\n\nimport { TableColumnIdSelection } from '../../types/table.js';\n\n@Render()\nexport class RenderTable extends BeanRenderBase {\n private _getColumnStyle(column: any): CSSProperties {\n const rest = (column.columnDef.meta as any)?.rest;\n const fixed = column.getIsPinned();\n const width = rest?.width ? `${rest.width}px` : undefined;\n return {\n width,\n minWidth: width,\n textAlign: rest?.align,\n position: fixed ? ('sticky' as const) : undefined,\n left: fixed === 'left' ? `${column.getStart('left')}px` : undefined,\n right: fixed === 'right' ? `${column.getAfter('right')}px` : undefined,\n zIndex: fixed ? 1 : undefined,\n };\n }\n\n private _renderTableDefault() {\n const table = this.table;\n const selectionMode = this.$props.selectionMode ?? 'multiple';\n return (\n <table class=\"table\">\n <thead>\n <tr>\n {table.getFlatHeaders().map(header => {\n const column = header.column;\n const canSort = column.getCanSort();\n const sorted = column.getIsSorted();\n const fixed = column.getIsPinned();\n const headerDefinition = column.columnDef.header;\n const selection = column.id === TableColumnIdSelection;\n const headerContent = selection ? (\n selectionMode === 'single' ? null : (\n <input\n type=\"checkbox\"\n checked={table.getIsAllPageRowsSelected()}\n indeterminate={table.getIsSomePageRowsSelected()}\n aria-checked={table.getIsSomePageRowsSelected() ? 'mixed' : undefined}\n aria-label=\"Select all rows on this page\"\n disabled={table.getRowModel().rows.every(row => !row.getCanSelect())}\n onChange={table.getToggleAllPageRowsSelectedHandler()}\n />\n )\n ) : (\n <FlexRender render={headerDefinition} props={header.getContext()}></FlexRender>\n );\n let sortAria: AriaAttributes['aria-sort'] = 'none';\n let sortIcon: '▲' | '▼' | '↕' = '↕';\n if (sorted === 'asc') {\n sortAria = 'ascending';\n sortIcon = '▲';\n } else if (sorted === 'desc') {\n sortAria = 'descending';\n sortIcon = '▼';\n }\n return (\n <th\n key={header.id}\n class={fixed ? 'bg-base-100' : undefined}\n style={this._getColumnStyle(column)}\n aria-sort={sortAria}\n >\n {canSort ? (\n <button\n type=\"button\"\n class=\"inline-flex w-full items-center gap-1\"\n onClick={column.getToggleSortingHandler()}\n aria-label={`Sort by ${column.id}`}\n >\n {headerContent}\n <span aria-hidden=\"true\">{sortIcon}</span>\n </button>\n ) : (\n headerContent\n )}\n </th>\n );\n })}\n </tr>\n </thead>\n <tbody>\n {table.getRowModel().rows.map(row => {\n return (\n <tr key={row.id} aria-selected={row.getIsSelected()}>\n {row.getVisibleCells().map(cell => {\n const column = cell.column;\n const selection = column.id === TableColumnIdSelection;\n return (\n <td\n key={cell.id}\n class={column.getIsPinned() ? 'bg-base-100' : undefined}\n style={this._getColumnStyle(column)}\n >\n {selection ? (\n <input\n type={selectionMode === 'single' ? 'radio' : 'checkbox'}\n checked={row.getIsSelected()}\n disabled={!row.getCanSelect()}\n aria-label={`Select row ${row.id}`}\n onChange={row.getToggleSelectedHandler()}\n />\n ) : (\n <FlexRender\n render={column.columnDef.cell}\n props={cell.getContext()}\n ></FlexRender>\n )}\n </td>\n );\n })}\n </tr>\n );\n })}\n </tbody>\n </table>\n );\n }\n\n public render() {\n return this.$slotDefault ? this.$slotDefault(this) : this._renderTableDefault();\n }\n}\n","import { defineComponent } from 'vue';\nimport { prepareComponentOptions, useController } from 'zova';\nimport { ControllerTable } from '../../component/table/controller.jsx';\nimport { RenderTable } from '../../component/table/render.jsx';\nexport const ZTable = defineComponent(_props => {\n useController(ControllerTable, RenderTable, undefined);\n return () => {};\n}, prepareComponentOptions());","export const config = _sys => {\n return {\n renderFallbackValue: '--'\n };\n};","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\n// eslint-disable\n/** controller: begin */\nexport * from '../component/table/controller.jsx';\nimport 'zova';\n/** controller: end */\n/** controller: begin */\nimport { ControllerTable } from '../component/table/controller.jsx';\nimport 'zova';\n/** controller: end */\n\n/** components: begin */\nexport * from './component/table.js';\nimport { ZTable } from './component/table.js';\nexport const components = {\n 'table': ZTable\n};\nimport 'zova';\n/** components: end */\n/** render: begin */\nexport * from '../component/table/render.jsx';\nimport 'zova';\n/** render: end */\n/** render: begin */\nimport { RenderTable } from '../component/table/render.jsx';\nimport 'zova';\n/** render: end */\n/** config: begin */\nexport * from '../config/config.js';\n/** config: end */\n/** scope: begin */\nimport { BeanScopeBase } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\nexport let ScopeModuleATable = (_dec = Scope(), _dec2 = __z_BeanInfo({\n module: \"a-table\"\n}), _dec(_class = _dec2(_class = class ScopeModuleATable extends BeanScopeBase {}) || _class) || _class);\nimport 'zova';\n\n/** scope: end */","import { useVueTable } from '@tanstack/vue-table';\nimport { markRaw } from 'vue';\nimport { BeanControllerPageBase } from 'zova';\nexport class BeanControllerPageTableBase extends BeanControllerPageBase {\n constructor(...args) {\n super(...args);\n this.table = void 0;\n }\n $useTable(initialOptions) {\n return this.ctx.util.instanceScope(() => {\n return markRaw(useVueTable(initialOptions));\n });\n }\n async refreshMeta() {\n throw new Error('should implement refreshMeta');\n }\n}","import { createBeanDecorator } from 'zova';\nexport function TableCell(options) {\n return createBeanDecorator('tableCell', 'app', true, options);\n}"],"mappings":";;;;;;;AAGA,IAAa,0BAAb,cAA6C,mBAAmB;CAC9D,YAAY,GAAG,MAAM;EACnB,MAAM,GAAG,IAAI;EACb,KAAK,QAAQ,KAAK;CACpB;CACA,UAAU,gBAAgB;EACxB,OAAO,KAAK,IAAI,KAAK,oBAAoB;GACvC,OAAO,QAA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D,aAAa,CAAC;AAChB,GAAG,wBAAwB,CAAC;;;ACP5B,IAAa,UAAS,SAAQ;CAC5B,OAAO,EACL,qBAAqB,KACvB;AACF;;;;;ACJA,IAAI;AAAM,IAAA;AAAO,IAAA;AAejB,IAAa,aAAa,EACxB,SAAS,OACX;AAiBA,IAAW,qBAAqB,OAAO,MAAM,GAAG,QAAQ,SAAa,EACnE,QAAQ,UACV,CAAC,GAAG,KAAK,SAAS,MAAM,SAAS,MAAM,0BAA0B,cAAc,CAAC,CAAC,KAAK,MAAM,KAAK;;;;ACjCjG,IAAa,8BAAb,cAAiD,uBAAuB;CACtE,YAAY,GAAG,MAAM;EACnB,MAAM,GAAG,IAAI;EACb,KAAK,QAAQ,KAAK;CACpB;CACA,UAAU,gBAAgB;EACxB,OAAO,KAAK,IAAI,KAAK,oBAAoB;GACvC,OAAO,QAAQ,YAAY,cAAc,CAAC;EAC5C,CAAC;CACH;CACA,MAAM,cAAc;EAClB,MAAM,IAAI,MAAM,8BAA8B;CAChD;AACF;;;ACfA,SAAgB,UAAU,SAAS;CACjC,OAAO,oBAAoB,aAAa,OAAO,MAAM,OAAO;AAC9D"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["celEnvBase","isNilOrEmptyString","createColumnHelper","functionalUpdate","getCoreRowModel","appResource","beanFullNameFromOnionName","cast","deepEqual","deepExtend","objectAssignReactive","isJsxComponent","ZovaJsx","Controller","BeanControllerTableBase","TableColumnIdSelection","reconcileTableLayout","ControllerTable","_dec","_dec2","__z_BeanInfo","module","_class","_ControllerTable","constructor","args","properties","columns","tableMeta","zovaJsx","columnCelEnv","__init__","bean","_setBean","_getColumnCelEnv","_newBeanSimple","undefined","_createProperties","refreshMeta","$watch","$props","schema","newValue","oldValue","enableRowSelection","layout","_createTable","data","sorting","rowSelection","layoutProperties","_createTableMeta","_createColumns","table","setColumnPinning","_getColumnPinning","self","tableOptions","getRowId","originalRow","index","parent","_getRowId","renderFallbackValue","scope","config","manualPagination","manualSorting","enableMultiSort","enableSortingRemoval","row","_canSelectRow","enableMultiRowSelection","selectionMode","state","columnVisibility","_getColumnVisibility","columnOrder","_getColumnOrder","columnSizing","_getColumnSizing","onSortingChange","updater","slice","onRowSelectionChange","initialState","columnPinning","$useTable","getColumns","_createColumnsMiddle","key","render","columnScope","getColumnScope","jsxRenderContext","getColumnJsxRenderContext","visible","columnProps","getColumnComponentPropsTop","_createColumnRender","columnHelper","display","id","header","cell","size","enableSorting","meta","rest","fixed","width","align","property","push","accessor","_props","title","props","renders","_getLayoutWidth","_isOrderable","sortDescFirst","String","originalId","original","getParentRow","_getLayoutColumn","find","column","Object","fromEntries","filter","map","keys","left","right","schemaOrder","schemaKey","schemaKeys","some","prototype","hasOwnProperty","call","$computed","$sdk","loadSchemaProperties","promises","res","Promise","all","_item","item","forEach","celScope","app","ctx","$scene","$host","$celScope","$jsx","$$table","getCellJsxRenderContext","cellContext","cellRenderPrepare","Array","isArray","renderProviders","getRenderProvider","renderProvider","includes","_getBean","renderContext","beanInstance","beanOptions","getBean","onionOptions","options","checkVisible","_cellRender","cellRender","cellScope","_getBeanSyncOnly","cellProps","setTransientObject","getValue","name","_cellRenderInner","value","fallbackValue","cellProps2","renderJsxProps","class","style","$cssMerge","$style","children","length","renderJsxChildrenDirect","getColumnProperty","celEnv","clone","registerFunction","transientObject","defaultValue","scopeExtra","tableScope","_getColumnComponentPropsTopByRest","_renderContext","evaluateExpression","assign","$propsDefault","FlexRender","BeanRenderBase","Render","TableColumnIdSelection","RenderTable","_dec","_dec2","__z_BeanInfo","module","_class","_getColumnStyle","column","rest","columnDef","meta","fixed","getIsPinned","width","getSize","minWidth","textAlign","align","position","undefined","left","getStart","right","getAfter","zIndex","_renderTableDefault","table","selectionMode","$props","_createVNode","getFlatHeaders","map","header","canSort","getCanSort","sorted","getIsSorted","headerDefinition","selection","id","headerContent","getIsAllPageRowsSelected","getIsSomePageRowsSelected","getRowModel","rows","every","row","getCanSelect","getToggleAllPageRowsSelectedHandler","getContext","sortAria","sortIcon","getToggleSortingHandler","getIsSelected","getVisibleCells","cell","getToggleSelectedHandler","render","$slotDefault"],"sources":["../src/lib/beanControllerTableBase.ts","../src/types/table.ts","../src/types/tableLayout.ts","../src/component/table/controller.tsx","../src/component/table/render.tsx","../src/.metadata/component/table.ts","../src/config/config.ts","../src/.metadata/index.ts","../src/lib/beanControllerPageTableBase.ts","../src/lib/tableCell.ts"],"sourcesContent":["import { useVueTable } from '@tanstack/vue-table';\nimport { markRaw } from 'vue';\nimport { BeanControllerBase } from 'zova';\nexport class BeanControllerTableBase extends BeanControllerBase {\n constructor(...args) {\n super(...args);\n this.table = void 0;\n }\n get layout() {\n throw new Error('should implement layout');\n }\n get layoutProperties() {\n throw new Error('should implement layoutProperties');\n }\n $useTable(initialOptions) {\n return this.ctx.util.instanceScope(() => {\n return markRaw(useVueTable(initialOptions));\n });\n }\n async refreshMeta() {\n throw new Error('should implement refreshMeta');\n }\n}","export const TableColumnIdSelection = '$$selection';","import { TableColumnIdSelection } from './table.js';\nfunction isWidth(value) {\n return value === 'auto' || typeof value === 'number' && Number.isInteger(value) && value >= 1 && value <= 2000;\n}\n\n/**\n * Reconciles a persisted layout with the currently eligible schema columns.\n * Schema visibility and fixed regions always remain authoritative.\n */\nexport function reconcileTableLayout(properties, profile) {\n const entries = new Map();\n const profileColumns = Array.isArray(profile?.columns) ? profile.columns : [];\n for (const item of profileColumns) {\n if (!item || typeof item !== 'object') continue;\n const column = item;\n const key = typeof column.key === 'string' ? column.key.trim() : '';\n if (!key || entries.has(key)) continue;\n if (typeof column.visible !== 'boolean' || !isWidth(column.width)) continue;\n entries.set(key, {\n key,\n visible: column.visible,\n width: column.width\n });\n }\n const eligible = properties.filter(property => typeof property.key === 'string' && property.key && property.key !== TableColumnIdSelection);\n const schemaKeys = new Set(eligible.map(property => property.key));\n const regions = new Map();\n regions.set('left', []);\n regions.set('center', []);\n regions.set('right', []);\n for (const property of eligible) {\n const fixed = property.rest?.fixed;\n regions.get(fixed === 'left' ? 'left' : fixed === 'right' ? 'right' : 'center').push(property);\n }\n const result = [];\n for (const region of ['left', 'center', 'right']) {\n const regionProperties = regions.get(region);\n const regionKeys = new Set(regionProperties.map(property => property.key));\n const ordered = profileColumns.map(item => item && typeof item === 'object' ? item : undefined).filter(item => {\n const key = typeof item?.key === 'string' ? item.key.trim() : '';\n return !!key && regionKeys.has(key) && schemaKeys.has(key) && entries.get(key)?.key === key;\n }).map(item => item.key);\n const seen = new Set();\n for (const key of [...ordered, ...regionProperties.map(property => property.key)]) {\n if (seen.has(key)) continue;\n seen.add(key);\n const property = regionProperties.find(item => item.key === key);\n const entry = entries.get(key);\n const schemaWidth = property.rest?.width;\n result.push({\n key,\n visible: entry?.visible ?? true,\n width: entry?.width ?? (typeof schemaWidth === 'number' && schemaWidth > 0 ? schemaWidth : 'auto')\n });\n }\n }\n return {\n version: 1,\n ...(typeof profile?.schemaFingerprint === 'string' ? {\n schemaFingerprint: profile.schemaFingerprint\n } : {}),\n columns: result\n };\n}","import type {\n IResourceDetailsActionRowOptionsBase,\n IResourceTableActionRowOptionsBase,\n ISchemaObjectExtensionField,\n ISchemaObjectExtensionFieldRest,\n TypeTableCellRenderComponent,\n TypeTableCellRenderComponentProvider,\n} from 'zova-module-a-openapi';\n\nimport { celEnvBase, isNilOrEmptyString } from '@cabloy/utils';\nimport {\n CellContext,\n createColumnHelper,\n functionalUpdate,\n getCoreRowModel,\n OnChangeFn,\n Row,\n RowSelectionState,\n SortingState,\n TableOptionsWithReactiveData,\n} from '@tanstack/vue-table';\nimport { SchemaObject } from 'openapi3-ts/oas31';\nimport { VNode } from 'vue';\nimport {\n appResource,\n beanFullNameFromOnionName,\n cast,\n deepEqual,\n deepExtend,\n objectAssignReactive,\n} from 'zova';\nimport { isJsxComponent, ZovaJsx } from 'zova-jsx';\nimport { Controller } from 'zova-module-a-bean';\n\nimport type { ITableMeta, TypeColumn, TypeTableGetColumns } from '../../types/table.js';\nimport type {\n IDecoratorTableCellOptions,\n IJsxRenderContextTableCell,\n ITableCellRender,\n} from '../../types/tableCell.js';\nimport type {\n IJsxRenderContextTableColumn,\n ITableCellRenderColumnProps,\n ITableCellScope,\n ITableColumnScope,\n ITableScope,\n TypeTableCellRender,\n} from '../../types/tableColumn.js';\nimport type { ITableLayout } from '../../types/tableLayout.js';\n\nimport { BeanControllerTableBase } from '../../lib/beanControllerTableBase.js';\nimport { TableColumnIdSelection } from '../../types/table.js';\nimport { ITableCellRenderColumnOptions } from '../../types/tableColumn.js';\nimport { reconcileTableLayout } from '../../types/tableLayout.js';\n\nexport interface ControllerTableProps<TData extends {} = {}> {\n data?: TData[];\n layout?: ITableLayout;\n schema?: SchemaObject;\n schemaOrder?: SchemaObject;\n sorting?: SortingState;\n onSortingChange?: OnChangeFn<SortingState>;\n enableRowSelection?: boolean | ((row: Row<TData>) => boolean);\n selectionMode?: 'single' | 'multiple';\n rowSelection?: RowSelectionState;\n onRowSelectionChange?: OnChangeFn<RowSelectionState>;\n tableScope?: ITableScope;\n getColumns?: TypeTableGetColumns<TData>;\n slotDefault?: (table: ControllerTable<TData>) => VNode;\n getRowId?: (originalRow: TData, index: number, parent?: Row<TData>) => string;\n}\n\n@Controller()\nexport class ControllerTable<TData extends {} = {}> extends BeanControllerTableBase<TData> {\n static $propsDefault = {};\n\n // table: TypeTable<TData>; // in BeanControllerTableBase\n\n properties: ISchemaObjectExtensionField[] | undefined;\n columns: TypeColumn<TData>[];\n tableMeta: ITableMeta<TData>;\n zovaJsx: ZovaJsx;\n columnCelEnv: typeof celEnvBase;\n\n protected async __init__() {\n this.bean._setBean('$$table', this);\n // jsx\n this.columnCelEnv = this._getColumnCelEnv();\n this.zovaJsx = this.bean._newBeanSimple(ZovaJsx, false, undefined, this.columnCelEnv);\n // properties\n this._createProperties();\n // tableMeta/columns\n await this.refreshMeta();\n // watch\n this.$watch(\n () => this.$props.schema,\n async (newValue, oldValue) => {\n if (deepEqual(newValue, oldValue)) return;\n await this.refreshMeta();\n },\n );\n this.$watch(\n () => this.$props.enableRowSelection,\n async (newValue, oldValue) => {\n if (newValue === oldValue) return;\n await this.refreshMeta();\n },\n );\n this.$watch(\n () => this.$props.layout,\n async (newValue, oldValue) => {\n if (deepEqual(newValue, oldValue)) return;\n await this.refreshMeta();\n },\n );\n // table\n this._createTable();\n }\n\n public get schema() {\n return this.$props.schema;\n }\n\n public get data() {\n return this.$props.data;\n }\n\n public get sorting() {\n return this.$props.sorting ?? [];\n }\n\n public get rowSelection() {\n return this.$props.rowSelection ?? {};\n }\n\n public get layout(): ITableLayout {\n return reconcileTableLayout(this.layoutProperties, this.$props.layout);\n }\n\n public get layoutProperties(): readonly ISchemaObjectExtensionField[] {\n return this.tableMeta?.properties ?? [];\n }\n\n public async refreshMeta() {\n this.tableMeta = await this._createTableMeta();\n this.columns = await this._createColumns();\n this.table?.setColumnPinning(this._getColumnPinning());\n }\n\n private _createTable() {\n // eslint-disable-next-line\n const self = this;\n const tableOptions: TableOptionsWithReactiveData<TData> = {\n getRowId: (originalRow, index, parent) => this._getRowId(originalRow, index, parent),\n getCoreRowModel: getCoreRowModel(),\n renderFallbackValue: this.scope.config.renderFallbackValue,\n manualPagination: true,\n manualSorting: true,\n enableMultiSort: false,\n enableSortingRemoval: false,\n enableRowSelection: row => self._canSelectRow(row),\n enableMultiRowSelection: this.$props.selectionMode !== 'single',\n state: {\n get sorting() {\n return self.sorting;\n },\n get rowSelection() {\n return self.rowSelection;\n },\n get columnVisibility() {\n return self._getColumnVisibility();\n },\n get columnOrder() {\n return self._getColumnOrder();\n },\n get columnSizing() {\n return self._getColumnSizing();\n },\n },\n onSortingChange: updater => {\n const sorting = functionalUpdate(updater, self.sorting).slice(0, 1);\n self.$props.onSortingChange?.(sorting);\n },\n onRowSelectionChange: updater => {\n const rowSelection = functionalUpdate(updater, self.rowSelection);\n self.$props.onRowSelectionChange?.(rowSelection);\n },\n get initialState() {\n const columnPinning = self._getColumnPinning();\n return { columnPinning };\n },\n get data() {\n return self.data || [];\n },\n get columns() {\n return self.columns;\n },\n };\n this.table = this.$useTable(tableOptions);\n this.table.setColumnPinning(this._getColumnPinning());\n }\n\n private async _createColumns() {\n if (!this.properties) return [];\n const columns = !this.$props.getColumns\n ? await this._createColumnsMiddle(this.tableMeta.properties)\n : await this.$props.getColumns(\n async properties => {\n return await this._createColumnsMiddle(properties ?? this.tableMeta.properties);\n },\n async (\n key: string,\n render: TypeTableCellRenderComponent,\n ): Promise<TypeTableCellRender<TData, any> | undefined> => {\n // columnScope\n const columnScope = this.getColumnScope(key);\n // renderContext\n const jsxRenderContext = this.getColumnJsxRenderContext(columnScope);\n // columnProps\n const { visible, columnProps } = this.getColumnComponentPropsTop(\n key,\n columnScope,\n jsxRenderContext,\n );\n // visible\n if (visible === false) return;\n return await this._createColumnRender(\n render,\n columnProps,\n columnScope,\n jsxRenderContext,\n );\n },\n this,\n );\n if (!this.$props.enableRowSelection) return columns;\n const columnHelper = createColumnHelper<TData>();\n return [\n columnHelper.display({\n id: TableColumnIdSelection,\n header: '',\n cell: '',\n size: 48,\n enableSorting: false,\n meta: { rest: { fixed: 'left', width: 48, align: 'center' } },\n }),\n ...columns,\n ];\n }\n\n private async _createColumnsMiddle(\n properties: ISchemaObjectExtensionField[],\n ): Promise<TypeColumn<TData>[]> {\n const tableMeta = this.tableMeta;\n const columnHelper = createColumnHelper<TData>();\n const columns: TypeColumn<TData>[] = [];\n for (const property of properties) {\n const key = property.key!;\n columns.push(\n columnHelper.accessor(key as any, {\n id: key,\n header: _props => {\n return property?.title || key;\n },\n cell: props => tableMeta.renders[key](props),\n size: this._getLayoutWidth(key),\n enableSorting: property.rest?.enableSorting === true && this._isOrderable(property),\n sortDescFirst: property.rest?.sortDescFirst === true,\n meta: {\n rest: {\n ...property.rest,\n width: this._getLayoutWidth(key),\n },\n },\n }),\n );\n }\n return columns;\n }\n\n private _getRowId(originalRow: TData, index: number, parent?: Row<TData>) {\n const id = this.$props.getRowId?.(originalRow, index, parent) ?? cast(originalRow).id;\n if (isNilOrEmptyString(id)) {\n return `__unselectable_${parent ? `${parent.id}.` : ''}${index}`;\n }\n return String(id);\n }\n\n private _canSelectRow(row: Row<TData>) {\n const enableRowSelection = this.$props.enableRowSelection;\n if (!enableRowSelection) return false;\n const originalId =\n this.$props.getRowId?.(row.original, row.index, row.getParentRow()) ?? cast(row.original).id;\n if (isNilOrEmptyString(originalId)) return false;\n return typeof enableRowSelection === 'function' ? enableRowSelection(row) : true;\n }\n\n private _getLayoutColumn(key: string) {\n return this.layout.columns.find(column => column.key === key);\n }\n\n private _getLayoutWidth(key: string) {\n const width = this._getLayoutColumn(key)?.width;\n return typeof width === 'number' ? width : undefined;\n }\n\n private _getColumnVisibility() {\n return Object.fromEntries(\n this.layout.columns\n .filter(column => column.key !== TableColumnIdSelection)\n .map(column => [column.key, column.visible]),\n );\n }\n\n private _getColumnOrder() {\n const keys = this.layout.columns.map(column => column.key);\n return this.$props.enableRowSelection ? [TableColumnIdSelection, ...keys] : keys;\n }\n\n private _getColumnSizing() {\n return Object.fromEntries(\n this.layout.columns\n .filter(column => typeof column.width === 'number')\n .map(column => [column.key, column.width as number]),\n );\n }\n\n private _getColumnPinning() {\n const left: string[] = this.$props.enableRowSelection ? [TableColumnIdSelection] : [];\n const right: string[] = [];\n for (const property of this.tableMeta?.properties ?? []) {\n const fixed = property.rest?.fixed;\n if (fixed === 'left') left.push(property.key!);\n if (fixed === 'right') right.push(property.key!);\n }\n return { left, right };\n }\n\n private _isOrderable(property: ISchemaObjectExtensionField) {\n const properties = this.$props.schemaOrder?.properties;\n if (!properties) return false;\n const keys = [property.key, property.schemaKey, ...(property.schemaKeys ?? [])];\n return keys.some(key => key && Object.prototype.hasOwnProperty.call(properties, key));\n }\n\n private _createProperties() {\n this.properties = this.$computed(() => {\n return this.$sdk.loadSchemaProperties(this.schema, 'table');\n });\n }\n\n private async _createTableMeta() {\n let properties: ISchemaObjectExtensionField[] = [];\n const renders: Record<string, TypeTableCellRender<TData>> = {};\n if (!this.properties) return { properties, renders };\n const promises: Promise<any>[] = [];\n for (const property of this.properties) {\n const key = property.key!;\n // columnScope\n const columnScope = this.getColumnScope(key);\n // renderContext\n const jsxRenderContext = this.getColumnJsxRenderContext(columnScope);\n // columnProps\n const { visible, render, columnProps } = this.getColumnComponentPropsTop(\n key,\n columnScope,\n jsxRenderContext,\n );\n // visible\n if (visible === false) continue;\n // property\n properties.push(property);\n // render\n promises.push(this._createColumnRender(render, columnProps, columnScope, jsxRenderContext));\n }\n let res = await Promise.all(promises);\n properties = properties.filter((_item, index) => !!res[index]);\n res = res.filter(item => !!item);\n properties.forEach((item, index) => {\n renders[item.key!] = res[index];\n });\n return { properties, renders };\n }\n\n public getColumnJsxRenderContext(celScope: ITableColumnScope): IJsxRenderContextTableColumn {\n return {\n app: this.app,\n ctx: this.ctx,\n $scene: 'tableColumn',\n $host: this,\n $celScope: celScope,\n $jsx: this.zovaJsx,\n $$table: this,\n };\n }\n\n public getCellJsxRenderContext(\n celScope: ITableCellScope,\n cellContext: CellContext<TData, any>,\n ): IJsxRenderContextTableCell {\n return {\n app: this.app,\n ctx: this.ctx,\n $scene: 'tableCell',\n $host: this,\n $celScope: celScope,\n $jsx: this.zovaJsx,\n $$table: this,\n cellContext,\n };\n }\n\n public async cellRenderPrepare(\n renders: TypeTableCellRenderComponent | TypeTableCellRenderComponent[],\n ) {\n if (!Array.isArray(renders)) renders = [renders];\n const renderProviders = renders.map(item => this.getRenderProvider(item));\n const promises: Promise<any>[] = renderProviders.map(renderProvider =>\n (async () => {\n if (typeof renderProvider === 'string' && renderProvider.includes('.tableCell.')) {\n return await this.app.bean._getBean(renderProvider as any, true);\n }\n })(),\n );\n return await Promise.all(promises);\n }\n\n private async _createColumnRender(\n render: TypeTableCellRenderComponent | undefined,\n columnProps: ITableCellRenderColumnProps | undefined,\n columnScope: ITableColumnScope,\n renderContext: IJsxRenderContextTableColumn,\n ): Promise<TypeTableCellRender<TData, any> | undefined> {\n // renderProvider\n const renderProvider = this.getRenderProvider(render);\n // beanInstance\n let beanInstance: ITableCellRender | undefined;\n if (typeof renderProvider === 'string' && renderProvider.includes('.tableCell.')) {\n beanInstance = await this.app.bean._getBean(renderProvider as any, true);\n const beanOptions = appResource.getBean(renderProvider as any);\n const onionOptions = beanOptions?.options as IDecoratorTableCellOptions | undefined;\n columnProps = deepExtend({}, onionOptions, columnProps);\n // should not eval jsx columnProps\n // columnProps = this.zovaJsx.renderJsxProps(columnProps as any, {}, columnScope, renderContext) as any;\n if (\n beanInstance?.checkVisible &&\n !(await beanInstance.checkVisible(columnProps as any, renderContext))\n ) {\n return;\n }\n }\n return cellContext => {\n if (!cellContext) return;\n return this._cellRender(\n render,\n columnProps,\n columnScope,\n cellContext,\n renderProvider,\n beanInstance,\n undefined,\n undefined,\n undefined,\n );\n };\n }\n\n public cellRender(\n render: TypeTableCellRenderComponent,\n columnProps: IResourceTableActionRowOptionsBase | IResourceDetailsActionRowOptionsBase,\n renderContext: IJsxRenderContextTableCell,\n ) {\n // render\n const cellScope = renderContext.$celScope;\n // renderProvider\n const renderProvider = this.getRenderProvider(render);\n // beanInstance\n let beanInstance: ITableCellRender | undefined;\n if (typeof renderProvider === 'string' && renderProvider.includes('.tableCell.')) {\n beanInstance = this.app.bean._getBeanSyncOnly(renderProvider as any);\n const beanOptions = appResource.getBean(renderProvider as any);\n const onionOptions = beanOptions?.options as IDecoratorTableCellOptions | undefined;\n columnProps = deepExtend({}, onionOptions, columnProps);\n // should not eval jsx columnProps\n // columnProps = this.zovaJsx.renderJsxProps(columnProps as any, {}, renderContext.$celScope, renderContext) as any;\n }\n // const cellProps = isJsxComponent(render) ? Object.assign({}, columnProps, cast(render).props) : columnProps;\n const cellProps = columnProps;\n return this._cellRender(\n render,\n columnProps as ITableCellRenderColumnProps,\n undefined,\n renderContext.cellContext,\n renderProvider,\n beanInstance,\n cellProps,\n cellScope,\n renderContext,\n );\n }\n\n private _cellRender(\n render: TypeTableCellRenderComponent | undefined,\n columnProps: ITableCellRenderColumnProps | undefined,\n columnScope: ITableColumnScope | undefined,\n cellContext: CellContext<TData, any>,\n renderProvider: TypeTableCellRenderComponentProvider,\n beanInstance: ITableCellRender | undefined,\n cellProps: any | undefined,\n cellScope: ITableCellScope | undefined,\n jsxRenderContext: IJsxRenderContextTableCell | undefined,\n ) {\n return this.zovaJsx.setTransientObject(\n {\n getValue: (name: string) => {\n return cellContext.row.getValue(name);\n },\n },\n () => {\n return this._cellRenderInner(\n render,\n columnProps,\n columnScope,\n cellContext,\n renderProvider,\n beanInstance,\n cellProps,\n cellScope,\n jsxRenderContext,\n );\n },\n );\n }\n\n private _cellRenderInner(\n render: TypeTableCellRenderComponent | undefined,\n columnProps: ITableCellRenderColumnProps | undefined,\n columnScope: ITableColumnScope | undefined,\n cellContext: CellContext<TData, any>,\n renderProvider: TypeTableCellRenderComponentProvider,\n beanInstance: ITableCellRender | undefined,\n cellProps: any | undefined,\n cellScope: ITableCellScope | undefined,\n jsxRenderContext: IJsxRenderContextTableCell | undefined,\n ) {\n // value\n const value = cellContext.getValue();\n // renderFallbackValue\n const fallbackValue = this.table.options.renderFallbackValue;\n // cellScope\n if (!cellScope) {\n cellScope = objectAssignReactive({}, columnScope, { value, fallbackValue })!;\n }\n // render: text\n if (renderProvider === ('text' as TypeTableCellRenderComponent)) {\n return isNilOrEmptyString(value) ? fallbackValue : value;\n }\n // renderContext\n if (!jsxRenderContext) {\n jsxRenderContext = this.getCellJsxRenderContext(cellScope, cellContext);\n }\n // beanInstance\n if (beanInstance) {\n // jsx: props\n if (!cellProps) {\n // cellProps = isJsxComponent(render) ? Object.assign({}, columnProps, cast(render).props) : columnProps;\n cellProps = columnProps;\n }\n const cellProps2 = this.zovaJsx.renderJsxProps(\n cellProps,\n {},\n cellScope,\n jsxRenderContext,\n ) as any;\n if (cellProps2.class || cellProps2.style) {\n cellProps2.class = jsxRenderContext.$host.$cssMerge(\n cellProps2.class,\n jsxRenderContext.$host.$style(cellProps2.style),\n );\n delete cellProps2.style;\n }\n return beanInstance.render(cellProps2, jsxRenderContext, () => {\n const children = isJsxComponent(render) && cast(render).children;\n if (children && children.length > 0) {\n return this.zovaJsx.renderJsxChildrenDirect(children, cellScope, jsxRenderContext);\n } else {\n return value;\n }\n });\n }\n // general component\n return this.zovaJsx.render(render!, {}, cellScope, jsxRenderContext);\n }\n\n public getColumnProperty(name: string): ISchemaObjectExtensionField | undefined {\n if (!this.properties) return;\n return this.properties.find(item => item.key === name);\n }\n\n private _getColumnCelEnv(): typeof celEnvBase {\n const celEnv = celEnvBase.clone();\n celEnv.registerFunction('getProperty(string):dyn', name => {\n return this.getColumnProperty(name);\n });\n celEnv.registerFunction('getValue(string):dyn', name => {\n return this.zovaJsx.transientObject.getValue(name) ?? null;\n });\n celEnv.registerFunction('getValue(string, dyn):dyn', (name, defaultValue) => {\n return this.zovaJsx.transientObject.getValue(name) ?? defaultValue;\n });\n return celEnv;\n }\n\n public getColumnScope(name: string, scopeExtra?: {}): ITableColumnScope {\n return objectAssignReactive({}, this.$props.tableScope, {\n name,\n property: this.getColumnProperty(name),\n ...scopeExtra,\n });\n }\n\n public getColumnComponentPropsTop(\n name: string,\n celScope: {},\n renderContext: {},\n ): ITableCellRenderColumnOptions {\n const property = this.getColumnProperty(name);\n const rest = property?.rest;\n return this._getColumnComponentPropsTopByRest(rest, name, celScope, renderContext);\n }\n\n private _getColumnComponentPropsTopByRest(\n rest: ISchemaObjectExtensionFieldRest | undefined,\n name: string,\n celScope: {},\n _renderContext: {},\n ): ITableCellRenderColumnOptions {\n const visible = this.zovaJsx.evaluateExpression(rest?.visible, celScope);\n const render = rest?.render as TypeTableCellRenderComponent | undefined;\n const columnProps = Object.assign({ key: name }, cast(rest)?.columnProps);\n return { visible, render, columnProps };\n }\n\n // public getRenderFlattern(render: TypeTableCellRenderComponent): TypeTableCellRenderComponent {\n // return isJsxComponent(render) ? cast(render).type : render;\n // }\n\n public getRenderProvider(\n render: TypeTableCellRenderComponent | undefined,\n ): TypeTableCellRenderComponentProvider {\n if (!render) return 'text';\n if (typeof render === 'string' && render.includes(':')) {\n return beanFullNameFromOnionName(render, 'tableCell');\n }\n return render;\n }\n}\n","import type { AriaAttributes, CSSProperties } from 'vue';\n\nimport { FlexRender } from '@tanstack/vue-table';\nimport { BeanRenderBase } from 'zova';\nimport { Render } from 'zova-module-a-bean';\n\nimport { TableColumnIdSelection } from '../../types/table.js';\n\n@Render()\nexport class RenderTable extends BeanRenderBase {\n private _getColumnStyle(column: any): CSSProperties {\n const rest = (column.columnDef.meta as any)?.rest;\n const fixed = column.getIsPinned();\n const width = column.getSize();\n return {\n ...(typeof rest?.width === 'number' ? { width: `${width}px`, minWidth: `${width}px` } : {}),\n textAlign: rest?.align,\n position: fixed ? ('sticky' as const) : undefined,\n left: fixed === 'left' ? `${column.getStart('left')}px` : undefined,\n right: fixed === 'right' ? `${column.getAfter('right')}px` : undefined,\n zIndex: fixed ? 1 : undefined,\n };\n }\n\n private _renderTableDefault() {\n const table = this.table;\n const selectionMode = this.$props.selectionMode ?? 'multiple';\n return (\n <table class=\"table\">\n <thead>\n <tr>\n {table.getFlatHeaders().map(header => {\n const column = header.column;\n const canSort = column.getCanSort();\n const sorted = column.getIsSorted();\n const fixed = column.getIsPinned();\n const headerDefinition = column.columnDef.header;\n const selection = column.id === TableColumnIdSelection;\n const headerContent = selection ? (\n selectionMode === 'single' ? null : (\n <input\n type=\"checkbox\"\n checked={table.getIsAllPageRowsSelected()}\n indeterminate={table.getIsSomePageRowsSelected()}\n aria-checked={table.getIsSomePageRowsSelected() ? 'mixed' : undefined}\n aria-label=\"Select all rows on this page\"\n disabled={table.getRowModel().rows.every(row => !row.getCanSelect())}\n onChange={table.getToggleAllPageRowsSelectedHandler()}\n />\n )\n ) : (\n <FlexRender render={headerDefinition} props={header.getContext()}></FlexRender>\n );\n let sortAria: AriaAttributes['aria-sort'] = 'none';\n let sortIcon: '▲' | '▼' | '↕' = '↕';\n if (sorted === 'asc') {\n sortAria = 'ascending';\n sortIcon = '▲';\n } else if (sorted === 'desc') {\n sortAria = 'descending';\n sortIcon = '▼';\n }\n return (\n <th\n key={header.id}\n class={fixed ? 'bg-base-100' : undefined}\n style={this._getColumnStyle(column)}\n aria-sort={sortAria}\n >\n {canSort ? (\n <button\n type=\"button\"\n class=\"inline-flex w-full items-center gap-1\"\n onClick={column.getToggleSortingHandler()}\n aria-label={`Sort by ${column.id}`}\n >\n {headerContent}\n <span aria-hidden=\"true\">{sortIcon}</span>\n </button>\n ) : (\n headerContent\n )}\n </th>\n );\n })}\n </tr>\n </thead>\n <tbody>\n {table.getRowModel().rows.map(row => {\n return (\n <tr key={row.id} aria-selected={row.getIsSelected()}>\n {row.getVisibleCells().map(cell => {\n const column = cell.column;\n const selection = column.id === TableColumnIdSelection;\n return (\n <td\n key={cell.id}\n class={column.getIsPinned() ? 'bg-base-100' : undefined}\n style={this._getColumnStyle(column)}\n >\n {selection ? (\n <input\n type={selectionMode === 'single' ? 'radio' : 'checkbox'}\n checked={row.getIsSelected()}\n disabled={!row.getCanSelect()}\n aria-label={`Select row ${row.id}`}\n onChange={row.getToggleSelectedHandler()}\n />\n ) : (\n <FlexRender\n render={column.columnDef.cell}\n props={cell.getContext()}\n ></FlexRender>\n )}\n </td>\n );\n })}\n </tr>\n );\n })}\n </tbody>\n </table>\n );\n }\n\n public render() {\n return this.$slotDefault ? this.$slotDefault(this) : this._renderTableDefault();\n }\n}\n","import { defineComponent } from 'vue';\nimport { prepareComponentOptions, useController } from 'zova';\nimport { ControllerTable } from '../../component/table/controller.jsx';\nimport { RenderTable } from '../../component/table/render.jsx';\nexport const ZTable = defineComponent(_props => {\n useController(ControllerTable, RenderTable, undefined);\n return () => {};\n}, prepareComponentOptions());","export const config = _sys => {\n return {\n renderFallbackValue: '--'\n };\n};","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\n// eslint-disable\n/** controller: begin */\nexport * from '../component/table/controller.jsx';\nimport 'zova';\n/** controller: end */\n/** controller: begin */\nimport { ControllerTable } from '../component/table/controller.jsx';\nimport 'zova';\n/** controller: end */\n\n/** components: begin */\nexport * from './component/table.js';\nimport { ZTable } from './component/table.js';\nexport const components = {\n 'table': ZTable\n};\nimport 'zova';\n/** components: end */\n/** render: begin */\nexport * from '../component/table/render.jsx';\nimport 'zova';\n/** render: end */\n/** render: begin */\nimport { RenderTable } from '../component/table/render.jsx';\nimport 'zova';\n/** render: end */\n/** config: begin */\nexport * from '../config/config.js';\n/** config: end */\n/** scope: begin */\nimport { BeanScopeBase } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\nexport let ScopeModuleATable = (_dec = Scope(), _dec2 = __z_BeanInfo({\n module: \"a-table\"\n}), _dec(_class = _dec2(_class = class ScopeModuleATable extends BeanScopeBase {}) || _class) || _class);\nimport 'zova';\n\n/** scope: end */","import { useVueTable } from '@tanstack/vue-table';\nimport { markRaw } from 'vue';\nimport { BeanControllerPageBase } from 'zova';\nexport class BeanControllerPageTableBase extends BeanControllerPageBase {\n constructor(...args) {\n super(...args);\n this.table = void 0;\n }\n $useTable(initialOptions) {\n return this.ctx.util.instanceScope(() => {\n return markRaw(useVueTable(initialOptions));\n });\n }\n async refreshMeta() {\n throw new Error('should implement refreshMeta');\n }\n}","import { createBeanDecorator } from 'zova';\nexport function TableCell(options) {\n return createBeanDecorator('tableCell', 'app', true, options);\n}"],"mappings":";;;;;;;AAGA,IAAa,0BAAb,cAA6C,mBAAmB;CAC9D,YAAY,GAAG,MAAM;EACnB,MAAM,GAAG,IAAI;EACb,KAAK,QAAQ,KAAK;CACpB;CACA,IAAI,SAAS;EACX,MAAM,IAAI,MAAM,yBAAyB;CAC3C;CACA,IAAI,mBAAmB;EACrB,MAAM,IAAI,MAAM,mCAAmC;CACrD;CACA,UAAU,gBAAgB;EACxB,OAAO,KAAK,IAAI,KAAK,oBAAoB;GACvC,OAAO,QAAQ,YAAY,cAAc,CAAC;EAC5C,CAAC;CACH;CACA,MAAM,cAAc;EAClB,MAAM,IAAI,MAAM,8BAA8B;CACh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G,QAAQ,SAAa,EACnE,QAAQ,UACV,CAAC,GAAG,KAAK,SAAS,MAAM,SAAS,MAAM,0BAA0B,cAAc,CAAC,CAAC,KAAK,MAAM,KAAK;;;;ACjCjG,IAAa,8BAAb,cAAiD,uBAAuB;CACtE,YAAY,GAAG,MAAM;EACnB,MAAM,GAAG,IAAI;EACb,KAAK,QAAQ,KAAK;CACpB;CACA,UAAU,gBAAgB;EACxB,OAAO,KAAK,IAAI,KAAK,oBAAoB;GACvC,OAAO,QAAQ,YAAY,cAAc,CAAC;EAC5C,CAAC;CACH;CACA,MAAM,cAAc;EAClB,MAAM,IAAI,MAAM,8BAA8B;CAChD;AACF;;;ACfA,SAAgB,UAAU,SAAS;CACjC,OAAO,oBAAoB,aAAa,OAAO,MAAM,OAAO;AAC9D"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Table } from '@tanstack/table-core';
|
|
2
2
|
import type { TableOptionsWithReactiveData } from '@tanstack/vue-table';
|
|
3
|
+
import type { ISchemaObjectExtensionField } from 'zova-module-a-openapi';
|
|
3
4
|
import { BeanControllerBase } from 'zova';
|
|
4
5
|
import { TypeTable } from '../types/table.js';
|
|
6
|
+
import { ITableLayout } from '../types/tableLayout.js';
|
|
5
7
|
export declare class BeanControllerTableBase<TData extends {} = {}> extends BeanControllerBase {
|
|
6
8
|
table: TypeTable<TData>;
|
|
9
|
+
get layout(): ITableLayout;
|
|
10
|
+
get layoutProperties(): readonly ISchemaObjectExtensionField[];
|
|
7
11
|
$useTable(initialOptions: TableOptionsWithReactiveData<TData>): Table<TData>;
|
|
8
12
|
refreshMeta(): Promise<void>;
|
|
9
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beanControllerTableBase.d.ts","sourceRoot":"","sources":["../../src/lib/beanControllerTableBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"beanControllerTableBase.d.ts","sourceRoot":"","sources":["../../src/lib/beanControllerTableBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAIzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qBAAa,uBAAuB,CAAC,KAAK,SAAS,EAAE,GAAG,EAAE,CAAE,SAAQ,kBAAkB;IACpF,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;IAExB,IAAW,MAAM,IAAI,YAAY,CAEhC;IAED,IAAW,gBAAgB,IAAI,SAAS,2BAA2B,EAAE,CAEpE;IAEM,SAAS,CAAC,cAAc,EAAE,4BAA4B,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;IAMtE,WAAW;CAGzB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ISchemaObjectExtensionField } from 'zova-module-a-openapi';
|
|
2
|
+
export type TypeTableLayoutWidth = number | 'auto';
|
|
3
|
+
export interface ITableLayoutColumn {
|
|
4
|
+
key: string;
|
|
5
|
+
visible: boolean;
|
|
6
|
+
width: TypeTableLayoutWidth;
|
|
7
|
+
}
|
|
8
|
+
export interface ITableLayout {
|
|
9
|
+
version: 1;
|
|
10
|
+
schemaFingerprint?: string;
|
|
11
|
+
columns: ITableLayoutColumn[];
|
|
12
|
+
}
|
|
13
|
+
export interface ITableLayoutProfileLike {
|
|
14
|
+
version?: unknown;
|
|
15
|
+
schemaFingerprint?: unknown;
|
|
16
|
+
columns?: unknown;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reconciles a persisted layout with the currently eligible schema columns.
|
|
20
|
+
* Schema visibility and fixed regions always remain authoritative.
|
|
21
|
+
*/
|
|
22
|
+
export declare function reconcileTableLayout(properties: readonly ISchemaObjectExtensionField[], profile?: ITableLayoutProfileLike | ITableLayout): ITableLayout;
|
|
23
|
+
//# sourceMappingURL=tableLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableLayout.d.ts","sourceRoot":"","sources":["../../src/types/tableLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAIzE,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,oBAAoB,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,CAAC,CAAC;IACX,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,kBAAkB,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AASD;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,SAAS,2BAA2B,EAAE,EAClD,OAAO,CAAC,EAAE,uBAAuB,GAAG,YAAY,GAC/C,YAAY,CA8Dd"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
IResourceDetailsActionRowOptionsBase,
|
|
2
3
|
IResourceTableActionRowOptionsBase,
|
|
3
4
|
ISchemaObjectExtensionField,
|
|
4
5
|
ISchemaObjectExtensionFieldRest,
|
|
@@ -45,13 +46,16 @@ import type {
|
|
|
45
46
|
ITableScope,
|
|
46
47
|
TypeTableCellRender,
|
|
47
48
|
} from '../../types/tableColumn.js';
|
|
49
|
+
import type { ITableLayout } from '../../types/tableLayout.js';
|
|
48
50
|
|
|
49
51
|
import { BeanControllerTableBase } from '../../lib/beanControllerTableBase.js';
|
|
50
52
|
import { TableColumnIdSelection } from '../../types/table.js';
|
|
51
53
|
import { ITableCellRenderColumnOptions } from '../../types/tableColumn.js';
|
|
54
|
+
import { reconcileTableLayout } from '../../types/tableLayout.js';
|
|
52
55
|
|
|
53
56
|
export interface ControllerTableProps<TData extends {} = {}> {
|
|
54
57
|
data?: TData[];
|
|
58
|
+
layout?: ITableLayout;
|
|
55
59
|
schema?: SchemaObject;
|
|
56
60
|
schemaOrder?: SchemaObject;
|
|
57
61
|
sorting?: SortingState;
|
|
@@ -102,6 +106,13 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
102
106
|
await this.refreshMeta();
|
|
103
107
|
},
|
|
104
108
|
);
|
|
109
|
+
this.$watch(
|
|
110
|
+
() => this.$props.layout,
|
|
111
|
+
async (newValue, oldValue) => {
|
|
112
|
+
if (deepEqual(newValue, oldValue)) return;
|
|
113
|
+
await this.refreshMeta();
|
|
114
|
+
},
|
|
115
|
+
);
|
|
105
116
|
// table
|
|
106
117
|
this._createTable();
|
|
107
118
|
}
|
|
@@ -122,6 +133,14 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
122
133
|
return this.$props.rowSelection ?? {};
|
|
123
134
|
}
|
|
124
135
|
|
|
136
|
+
public get layout(): ITableLayout {
|
|
137
|
+
return reconcileTableLayout(this.layoutProperties, this.$props.layout);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public get layoutProperties(): readonly ISchemaObjectExtensionField[] {
|
|
141
|
+
return this.tableMeta?.properties ?? [];
|
|
142
|
+
}
|
|
143
|
+
|
|
125
144
|
public async refreshMeta() {
|
|
126
145
|
this.tableMeta = await this._createTableMeta();
|
|
127
146
|
this.columns = await this._createColumns();
|
|
@@ -148,6 +167,15 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
148
167
|
get rowSelection() {
|
|
149
168
|
return self.rowSelection;
|
|
150
169
|
},
|
|
170
|
+
get columnVisibility() {
|
|
171
|
+
return self._getColumnVisibility();
|
|
172
|
+
},
|
|
173
|
+
get columnOrder() {
|
|
174
|
+
return self._getColumnOrder();
|
|
175
|
+
},
|
|
176
|
+
get columnSizing() {
|
|
177
|
+
return self._getColumnSizing();
|
|
178
|
+
},
|
|
151
179
|
},
|
|
152
180
|
onSortingChange: updater => {
|
|
153
181
|
const sorting = functionalUpdate(updater, self.sorting).slice(0, 1);
|
|
@@ -235,10 +263,15 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
235
263
|
return property?.title || key;
|
|
236
264
|
},
|
|
237
265
|
cell: props => tableMeta.renders[key](props),
|
|
238
|
-
size:
|
|
266
|
+
size: this._getLayoutWidth(key),
|
|
239
267
|
enableSorting: property.rest?.enableSorting === true && this._isOrderable(property),
|
|
240
268
|
sortDescFirst: property.rest?.sortDescFirst === true,
|
|
241
|
-
meta: {
|
|
269
|
+
meta: {
|
|
270
|
+
rest: {
|
|
271
|
+
...property.rest,
|
|
272
|
+
width: this._getLayoutWidth(key),
|
|
273
|
+
},
|
|
274
|
+
},
|
|
242
275
|
}),
|
|
243
276
|
);
|
|
244
277
|
}
|
|
@@ -262,6 +295,36 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
262
295
|
return typeof enableRowSelection === 'function' ? enableRowSelection(row) : true;
|
|
263
296
|
}
|
|
264
297
|
|
|
298
|
+
private _getLayoutColumn(key: string) {
|
|
299
|
+
return this.layout.columns.find(column => column.key === key);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
private _getLayoutWidth(key: string) {
|
|
303
|
+
const width = this._getLayoutColumn(key)?.width;
|
|
304
|
+
return typeof width === 'number' ? width : undefined;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
private _getColumnVisibility() {
|
|
308
|
+
return Object.fromEntries(
|
|
309
|
+
this.layout.columns
|
|
310
|
+
.filter(column => column.key !== TableColumnIdSelection)
|
|
311
|
+
.map(column => [column.key, column.visible]),
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
private _getColumnOrder() {
|
|
316
|
+
const keys = this.layout.columns.map(column => column.key);
|
|
317
|
+
return this.$props.enableRowSelection ? [TableColumnIdSelection, ...keys] : keys;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
private _getColumnSizing() {
|
|
321
|
+
return Object.fromEntries(
|
|
322
|
+
this.layout.columns
|
|
323
|
+
.filter(column => typeof column.width === 'number')
|
|
324
|
+
.map(column => [column.key, column.width as number]),
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
|
|
265
328
|
private _getColumnPinning() {
|
|
266
329
|
const left: string[] = this.$props.enableRowSelection ? [TableColumnIdSelection] : [];
|
|
267
330
|
const right: string[] = [];
|
|
@@ -404,7 +467,7 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
404
467
|
|
|
405
468
|
public cellRender(
|
|
406
469
|
render: TypeTableCellRenderComponent,
|
|
407
|
-
columnProps: IResourceTableActionRowOptionsBase,
|
|
470
|
+
columnProps: IResourceTableActionRowOptionsBase | IResourceDetailsActionRowOptionsBase,
|
|
408
471
|
renderContext: IJsxRenderContextTableCell,
|
|
409
472
|
) {
|
|
410
473
|
// render
|
|
@@ -11,10 +11,9 @@ export class RenderTable extends BeanRenderBase {
|
|
|
11
11
|
private _getColumnStyle(column: any): CSSProperties {
|
|
12
12
|
const rest = (column.columnDef.meta as any)?.rest;
|
|
13
13
|
const fixed = column.getIsPinned();
|
|
14
|
-
const width =
|
|
14
|
+
const width = column.getSize();
|
|
15
15
|
return {
|
|
16
|
-
width,
|
|
17
|
-
minWidth: width,
|
|
16
|
+
...(typeof rest?.width === 'number' ? { width: `${width}px`, minWidth: `${width}px` } : {}),
|
|
18
17
|
textAlign: rest?.align,
|
|
19
18
|
position: fixed ? ('sticky' as const) : undefined,
|
|
20
19
|
left: fixed === 'left' ? `${column.getStart('left')}px` : undefined,
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import type { Table } from '@tanstack/table-core';
|
|
2
2
|
import type { TableOptionsWithReactiveData } from '@tanstack/vue-table';
|
|
3
|
+
import type { ISchemaObjectExtensionField } from 'zova-module-a-openapi';
|
|
3
4
|
|
|
4
5
|
import { useVueTable } from '@tanstack/vue-table';
|
|
5
6
|
import { markRaw } from 'vue';
|
|
6
7
|
import { BeanControllerBase } from 'zova';
|
|
7
8
|
|
|
8
9
|
import { TypeTable } from '../types/table.js';
|
|
10
|
+
import { ITableLayout } from '../types/tableLayout.js';
|
|
9
11
|
|
|
10
12
|
export class BeanControllerTableBase<TData extends {} = {}> extends BeanControllerBase {
|
|
11
13
|
table: TypeTable<TData>;
|
|
12
14
|
|
|
15
|
+
public get layout(): ITableLayout {
|
|
16
|
+
throw new Error('should implement layout');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public get layoutProperties(): readonly ISchemaObjectExtensionField[] {
|
|
20
|
+
throw new Error('should implement layoutProperties');
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
public $useTable(initialOptions: TableOptionsWithReactiveData<TData>): Table<TData> {
|
|
14
24
|
return this.ctx.util.instanceScope(() => {
|
|
15
25
|
return markRaw(useVueTable(initialOptions));
|
package/src/types/index.ts
CHANGED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { ISchemaObjectExtensionField } from 'zova-module-a-openapi';
|
|
2
|
+
|
|
3
|
+
import { TableColumnIdSelection } from './table.js';
|
|
4
|
+
|
|
5
|
+
export type TypeTableLayoutWidth = number | 'auto';
|
|
6
|
+
|
|
7
|
+
export interface ITableLayoutColumn {
|
|
8
|
+
key: string;
|
|
9
|
+
visible: boolean;
|
|
10
|
+
width: TypeTableLayoutWidth;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ITableLayout {
|
|
14
|
+
version: 1;
|
|
15
|
+
schemaFingerprint?: string;
|
|
16
|
+
columns: ITableLayoutColumn[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ITableLayoutProfileLike {
|
|
20
|
+
version?: unknown;
|
|
21
|
+
schemaFingerprint?: unknown;
|
|
22
|
+
columns?: unknown;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isWidth(value: unknown): value is TypeTableLayoutWidth {
|
|
26
|
+
return (
|
|
27
|
+
value === 'auto' ||
|
|
28
|
+
(typeof value === 'number' && Number.isInteger(value) && value >= 1 && value <= 2000)
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Reconciles a persisted layout with the currently eligible schema columns.
|
|
34
|
+
* Schema visibility and fixed regions always remain authoritative.
|
|
35
|
+
*/
|
|
36
|
+
export function reconcileTableLayout(
|
|
37
|
+
properties: readonly ISchemaObjectExtensionField[],
|
|
38
|
+
profile?: ITableLayoutProfileLike | ITableLayout,
|
|
39
|
+
): ITableLayout {
|
|
40
|
+
const entries = new Map<string, ITableLayoutColumn>();
|
|
41
|
+
const profileColumns = Array.isArray(profile?.columns) ? profile.columns : [];
|
|
42
|
+
for (const item of profileColumns) {
|
|
43
|
+
if (!item || typeof item !== 'object') continue;
|
|
44
|
+
const column = item as Record<string, unknown>;
|
|
45
|
+
const key = typeof column.key === 'string' ? column.key.trim() : '';
|
|
46
|
+
if (!key || entries.has(key)) continue;
|
|
47
|
+
if (typeof column.visible !== 'boolean' || !isWidth(column.width)) continue;
|
|
48
|
+
entries.set(key, { key, visible: column.visible, width: column.width });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const eligible = properties.filter(
|
|
52
|
+
property =>
|
|
53
|
+
typeof property.key === 'string' && property.key && property.key !== TableColumnIdSelection,
|
|
54
|
+
);
|
|
55
|
+
const schemaKeys = new Set(eligible.map(property => property.key!));
|
|
56
|
+
const regions = new Map<'left' | 'center' | 'right', ISchemaObjectExtensionField[]>();
|
|
57
|
+
regions.set('left', []);
|
|
58
|
+
regions.set('center', []);
|
|
59
|
+
regions.set('right', []);
|
|
60
|
+
for (const property of eligible) {
|
|
61
|
+
const fixed = property.rest?.fixed;
|
|
62
|
+
regions.get(fixed === 'left' ? 'left' : fixed === 'right' ? 'right' : 'center')!.push(property);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const result: ITableLayoutColumn[] = [];
|
|
66
|
+
for (const region of ['left', 'center', 'right'] as const) {
|
|
67
|
+
const regionProperties = regions.get(region)!;
|
|
68
|
+
const regionKeys = new Set(regionProperties.map(property => property.key!));
|
|
69
|
+
const ordered = profileColumns
|
|
70
|
+
.map(item =>
|
|
71
|
+
item && typeof item === 'object' ? (item as Record<string, unknown>) : undefined,
|
|
72
|
+
)
|
|
73
|
+
.filter(item => {
|
|
74
|
+
const key = typeof item?.key === 'string' ? item.key.trim() : '';
|
|
75
|
+
return !!key && regionKeys.has(key) && schemaKeys.has(key) && entries.get(key)?.key === key;
|
|
76
|
+
})
|
|
77
|
+
.map(item => item!.key as string);
|
|
78
|
+
const seen = new Set<string>();
|
|
79
|
+
for (const key of [...ordered, ...regionProperties.map(property => property.key!)]) {
|
|
80
|
+
if (seen.has(key)) continue;
|
|
81
|
+
seen.add(key);
|
|
82
|
+
const property = regionProperties.find(item => item.key === key)!;
|
|
83
|
+
const entry = entries.get(key);
|
|
84
|
+
const schemaWidth = property.rest?.width;
|
|
85
|
+
result.push({
|
|
86
|
+
key,
|
|
87
|
+
visible: entry?.visible ?? true,
|
|
88
|
+
width:
|
|
89
|
+
entry?.width ??
|
|
90
|
+
(typeof schemaWidth === 'number' && schemaWidth > 0 ? schemaWidth : 'auto'),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
version: 1,
|
|
96
|
+
...(typeof profile?.schemaFingerprint === 'string'
|
|
97
|
+
? { schemaFingerprint: profile.schemaFingerprint }
|
|
98
|
+
: {}),
|
|
99
|
+
columns: result,
|
|
100
|
+
};
|
|
101
|
+
}
|