zova-module-a-table 5.1.39 → 5.1.41
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 +8 -1
- package/dist/component/table/controller.d.ts.map +1 -1
- package/dist/component/table/render.d.ts.map +1 -1
- package/dist/index.js +85 -14
- package/dist/index.js.map +1 -1
- package/dist/types/table.d.ts +1 -0
- package/dist/types/table.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/component/table/controller.tsx +88 -26
- package/src/component/table/render.tsx +33 -6
- package/src/types/table.ts +2 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IResourceTableActionRowOptionsBase, ISchemaObjectExtensionField, TypeTableCellRenderComponent, TypeTableCellRenderComponentProvider } from 'zova-module-a-openapi';
|
|
2
2
|
import { celEnvBase } from '@cabloy/utils';
|
|
3
|
-
import { CellContext, OnChangeFn, Row, SortingState } from '@tanstack/vue-table';
|
|
3
|
+
import { CellContext, OnChangeFn, Row, RowSelectionState, SortingState } from '@tanstack/vue-table';
|
|
4
4
|
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
5
5
|
import { VNode } from 'vue';
|
|
6
6
|
import { ZovaJsx } from 'zova-jsx';
|
|
@@ -15,6 +15,10 @@ export interface ControllerTableProps<TData extends {} = {}> {
|
|
|
15
15
|
schemaOrder?: SchemaObject;
|
|
16
16
|
sorting?: SortingState;
|
|
17
17
|
onSortingChange?: OnChangeFn<SortingState>;
|
|
18
|
+
enableRowSelection?: boolean | ((row: Row<TData>) => boolean);
|
|
19
|
+
selectionMode?: 'single' | 'multiple';
|
|
20
|
+
rowSelection?: RowSelectionState;
|
|
21
|
+
onRowSelectionChange?: OnChangeFn<RowSelectionState>;
|
|
18
22
|
tableScope?: ITableScope;
|
|
19
23
|
getColumns?: TypeTableGetColumns<TData>;
|
|
20
24
|
slotDefault?: (table: ControllerTable<TData>) => VNode;
|
|
@@ -31,10 +35,13 @@ export declare class ControllerTable<TData extends {} = {}> extends BeanControll
|
|
|
31
35
|
get schema(): SchemaObject | undefined;
|
|
32
36
|
get data(): TData[] | undefined;
|
|
33
37
|
get sorting(): SortingState;
|
|
38
|
+
get rowSelection(): RowSelectionState;
|
|
34
39
|
refreshMeta(): Promise<void>;
|
|
35
40
|
private _createTable;
|
|
36
41
|
private _createColumns;
|
|
37
42
|
private _createColumnsMiddle;
|
|
43
|
+
private _getRowId;
|
|
44
|
+
private _canSelectRow;
|
|
38
45
|
private _getColumnPinning;
|
|
39
46
|
private _isOrderable;
|
|
40
47
|
private _createProperties;
|
|
@@ -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,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;AAEpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/component/table/controller.tsx"],"names":[],"mappings":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,CAC5B,OAAO,EAAE,4BAA4B,GAAG,4BAA4B,EAAE;YAc1D,mBAAmB;IAwC1B,UAAU,CACf,MAAM,EAAE,4BAA4B,EACpC,WAAW,EAAE,kCAAkC,EAC/C,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;
|
|
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;IAevB,OAAO,CAAC,mBAAmB;IAqGpB,MAAM;;;CAGd"}
|
package/dist/index.js
CHANGED
|
@@ -20,8 +20,14 @@ var BeanControllerTableBase = class extends BeanControllerBase {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
//#endregion
|
|
23
|
+
//#region src/types/table.ts
|
|
24
|
+
var TableColumnIdSelection = "$$selection";
|
|
25
|
+
//#endregion
|
|
23
26
|
//#region src/component/table/controller.tsx
|
|
24
|
-
var _dec$2
|
|
27
|
+
var _dec$2;
|
|
28
|
+
var _dec2$2;
|
|
29
|
+
var _class$2;
|
|
30
|
+
var _ControllerTable;
|
|
25
31
|
var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-table" }), _dec$2(_class$2 = _dec2$2(_class$2 = (_ControllerTable = class ControllerTable extends BeanControllerTableBase {
|
|
26
32
|
constructor(...args) {
|
|
27
33
|
super(...args);
|
|
@@ -41,6 +47,10 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
41
47
|
if (deepEqual(newValue, oldValue)) return;
|
|
42
48
|
await this.refreshMeta();
|
|
43
49
|
});
|
|
50
|
+
this.$watch(() => this.$props.enableRowSelection, async (newValue, oldValue) => {
|
|
51
|
+
if (newValue === oldValue) return;
|
|
52
|
+
await this.refreshMeta();
|
|
53
|
+
});
|
|
44
54
|
this._createTable();
|
|
45
55
|
}
|
|
46
56
|
get schema() {
|
|
@@ -52,6 +62,9 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
52
62
|
get sorting() {
|
|
53
63
|
return this.$props.sorting ?? [];
|
|
54
64
|
}
|
|
65
|
+
get rowSelection() {
|
|
66
|
+
return this.$props.rowSelection ?? {};
|
|
67
|
+
}
|
|
55
68
|
async refreshMeta() {
|
|
56
69
|
this.tableMeta = await this._createTableMeta();
|
|
57
70
|
this.columns = await this._createColumns();
|
|
@@ -60,20 +73,31 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
60
73
|
_createTable() {
|
|
61
74
|
const self = this;
|
|
62
75
|
const tableOptions = {
|
|
63
|
-
getRowId:
|
|
76
|
+
getRowId: (originalRow, index, parent) => this._getRowId(originalRow, index, parent),
|
|
64
77
|
getCoreRowModel: getCoreRowModel(),
|
|
65
78
|
renderFallbackValue: this.scope.config.renderFallbackValue,
|
|
66
79
|
manualPagination: true,
|
|
67
80
|
manualSorting: true,
|
|
68
81
|
enableMultiSort: false,
|
|
69
82
|
enableSortingRemoval: false,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
83
|
+
enableRowSelection: (row) => self._canSelectRow(row),
|
|
84
|
+
enableMultiRowSelection: this.$props.selectionMode !== "single",
|
|
85
|
+
state: {
|
|
86
|
+
get sorting() {
|
|
87
|
+
return self.sorting;
|
|
88
|
+
},
|
|
89
|
+
get rowSelection() {
|
|
90
|
+
return self.rowSelection;
|
|
91
|
+
}
|
|
92
|
+
},
|
|
73
93
|
onSortingChange: (updater) => {
|
|
74
94
|
const sorting = functionalUpdate(updater, self.sorting).slice(0, 1);
|
|
75
95
|
self.$props.onSortingChange?.(sorting);
|
|
76
96
|
},
|
|
97
|
+
onRowSelectionChange: (updater) => {
|
|
98
|
+
const rowSelection = functionalUpdate(updater, self.rowSelection);
|
|
99
|
+
self.$props.onRowSelectionChange?.(rowSelection);
|
|
100
|
+
},
|
|
77
101
|
get initialState() {
|
|
78
102
|
return { columnPinning: self._getColumnPinning() };
|
|
79
103
|
},
|
|
@@ -89,8 +113,7 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
89
113
|
}
|
|
90
114
|
async _createColumns() {
|
|
91
115
|
if (!this.properties) return [];
|
|
92
|
-
|
|
93
|
-
return await this.$props.getColumns(async (properties) => {
|
|
116
|
+
const columns = !this.$props.getColumns ? await this._createColumnsMiddle(this.tableMeta.properties) : await this.$props.getColumns(async (properties) => {
|
|
94
117
|
return await this._createColumnsMiddle(properties ?? this.tableMeta.properties);
|
|
95
118
|
}, async (key, render) => {
|
|
96
119
|
const columnScope = this.getColumnScope(key);
|
|
@@ -99,6 +122,19 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
99
122
|
if (visible === false) return;
|
|
100
123
|
return await this._createColumnRender(render, columnProps, columnScope, jsxRenderContext);
|
|
101
124
|
}, this);
|
|
125
|
+
if (!this.$props.enableRowSelection) return columns;
|
|
126
|
+
return [createColumnHelper().display({
|
|
127
|
+
id: "$$selection",
|
|
128
|
+
header: "",
|
|
129
|
+
cell: "",
|
|
130
|
+
size: 48,
|
|
131
|
+
enableSorting: false,
|
|
132
|
+
meta: { rest: {
|
|
133
|
+
fixed: "left",
|
|
134
|
+
width: 48,
|
|
135
|
+
align: "center"
|
|
136
|
+
} }
|
|
137
|
+
}), ...columns];
|
|
102
138
|
}
|
|
103
139
|
async _createColumnsMiddle(properties) {
|
|
104
140
|
const tableMeta = this.tableMeta;
|
|
@@ -120,8 +156,20 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
120
156
|
}
|
|
121
157
|
return columns;
|
|
122
158
|
}
|
|
159
|
+
_getRowId(originalRow, index, parent) {
|
|
160
|
+
const id = this.$props.getRowId?.(originalRow, index, parent) ?? cast(originalRow).id;
|
|
161
|
+
if (isNilOrEmptyString(id)) return `__unselectable_${parent ? `${parent.id}.` : ""}${index}`;
|
|
162
|
+
return String(id);
|
|
163
|
+
}
|
|
164
|
+
_canSelectRow(row) {
|
|
165
|
+
const enableRowSelection = this.$props.enableRowSelection;
|
|
166
|
+
if (!enableRowSelection) return false;
|
|
167
|
+
const originalId = this.$props.getRowId?.(row.original, row.index, row.getParentRow()) ?? cast(row.original).id;
|
|
168
|
+
if (isNilOrEmptyString(originalId)) return false;
|
|
169
|
+
return typeof enableRowSelection === "function" ? enableRowSelection(row) : true;
|
|
170
|
+
}
|
|
123
171
|
_getColumnPinning() {
|
|
124
|
-
const left = [];
|
|
172
|
+
const left = this.$props.enableRowSelection ? ["$$selection"] : [];
|
|
125
173
|
const right = [];
|
|
126
174
|
for (const property of this.tableMeta?.properties ?? []) {
|
|
127
175
|
const fixed = property.rest?.fixed;
|
|
@@ -305,7 +353,9 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
305
353
|
}, _ControllerTable.$propsDefault = {}, _ControllerTable)) || _class$2) || _class$2);
|
|
306
354
|
//#endregion
|
|
307
355
|
//#region src/component/table/render.tsx
|
|
308
|
-
var _dec$1
|
|
356
|
+
var _dec$1;
|
|
357
|
+
var _dec2$1;
|
|
358
|
+
var _class$1;
|
|
309
359
|
var RenderTable = (_dec$1 = Render(), _dec2$1 = BeanInfo({ module: "a-table" }), _dec$1(_class$1 = _dec2$1(_class$1 = class RenderTable extends BeanRenderBase {
|
|
310
360
|
_getColumnStyle(column) {
|
|
311
361
|
const rest = column.columnDef.meta?.rest;
|
|
@@ -323,13 +373,22 @@ var RenderTable = (_dec$1 = Render(), _dec2$1 = BeanInfo({ module: "a-table" }),
|
|
|
323
373
|
}
|
|
324
374
|
_renderTableDefault() {
|
|
325
375
|
const table = this.table;
|
|
376
|
+
const selectionMode = this.$props.selectionMode ?? "multiple";
|
|
326
377
|
return createVNode("table", { "class": "table" }, [createVNode("thead", null, [createVNode("tr", null, [table.getFlatHeaders().map((header) => {
|
|
327
378
|
const column = header.column;
|
|
328
379
|
const canSort = column.getCanSort();
|
|
329
380
|
const sorted = column.getIsSorted();
|
|
330
381
|
const fixed = column.getIsPinned();
|
|
331
382
|
const headerDefinition = column.columnDef.header;
|
|
332
|
-
const headerContent = createVNode(
|
|
383
|
+
const headerContent = column.id === "$$selection" ? selectionMode === "single" ? null : createVNode("input", {
|
|
384
|
+
"type": "checkbox",
|
|
385
|
+
"checked": table.getIsAllPageRowsSelected(),
|
|
386
|
+
"indeterminate": table.getIsSomePageRowsSelected(),
|
|
387
|
+
"aria-checked": table.getIsSomePageRowsSelected() ? "mixed" : void 0,
|
|
388
|
+
"aria-label": "Select all rows on this page",
|
|
389
|
+
"disabled": table.getRowModel().rows.every((row) => !row.getCanSelect()),
|
|
390
|
+
"onChange": table.getToggleAllPageRowsSelectedHandler()
|
|
391
|
+
}, null) : createVNode(FlexRender, {
|
|
333
392
|
"render": headerDefinition,
|
|
334
393
|
"props": header.getContext()
|
|
335
394
|
}, null);
|
|
@@ -354,13 +413,23 @@ var RenderTable = (_dec$1 = Render(), _dec2$1 = BeanInfo({ module: "a-table" }),
|
|
|
354
413
|
"aria-label": `Sort by ${column.id}`
|
|
355
414
|
}, [headerContent, createVNode("span", { "aria-hidden": "true" }, [sortIcon])]) : headerContent]);
|
|
356
415
|
})])]), createVNode("tbody", null, [table.getRowModel().rows.map((row) => {
|
|
357
|
-
return createVNode("tr", {
|
|
416
|
+
return createVNode("tr", {
|
|
417
|
+
"key": row.id,
|
|
418
|
+
"aria-selected": row.getIsSelected()
|
|
419
|
+
}, [row.getVisibleCells().map((cell) => {
|
|
358
420
|
const column = cell.column;
|
|
421
|
+
const selection = column.id === "$$selection";
|
|
359
422
|
return createVNode("td", {
|
|
360
423
|
"key": cell.id,
|
|
361
424
|
"class": column.getIsPinned() ? "bg-base-100" : void 0,
|
|
362
425
|
"style": this._getColumnStyle(column)
|
|
363
|
-
}, [createVNode(
|
|
426
|
+
}, [selection ? createVNode("input", {
|
|
427
|
+
"type": selectionMode === "single" ? "radio" : "checkbox",
|
|
428
|
+
"checked": row.getIsSelected(),
|
|
429
|
+
"disabled": !row.getCanSelect(),
|
|
430
|
+
"aria-label": `Select row ${row.id}`,
|
|
431
|
+
"onChange": row.getToggleSelectedHandler()
|
|
432
|
+
}, null) : createVNode(FlexRender, {
|
|
364
433
|
"render": column.columnDef.cell,
|
|
365
434
|
"props": cell.getContext()
|
|
366
435
|
}, null)]);
|
|
@@ -386,7 +455,9 @@ var config = (_sys) => {
|
|
|
386
455
|
//#region src/.metadata/index.ts
|
|
387
456
|
/** config: end */
|
|
388
457
|
/** scope: begin */
|
|
389
|
-
var _dec
|
|
458
|
+
var _dec;
|
|
459
|
+
var _dec2;
|
|
460
|
+
var _class;
|
|
390
461
|
var components = { "table": ZTable };
|
|
391
462
|
var ScopeModuleATable = (_dec = Scope(), _dec2 = BeanInfo({ module: "a-table" }), _dec(_class = _dec2(_class = class ScopeModuleATable extends BeanScopeBase {}) || _class) || _class);
|
|
392
463
|
/** scope: end */
|
|
@@ -412,6 +483,6 @@ function TableCell(options) {
|
|
|
412
483
|
return createBeanDecorator("tableCell", "app", true, options);
|
|
413
484
|
}
|
|
414
485
|
//#endregion
|
|
415
|
-
export { BeanControllerPageTableBase, BeanControllerTableBase, ControllerTable, RenderTable, ScopeModuleATable, TableCell, ZTable, components, config };
|
|
486
|
+
export { BeanControllerPageTableBase, BeanControllerTableBase, ControllerTable, RenderTable, ScopeModuleATable, TableCell, TableColumnIdSelection, ZTable, components, config };
|
|
416
487
|
|
|
417
488
|
//# 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","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","_createTable","data","sorting","_createTableMeta","_createColumns","table","setColumnPinning","_getColumnPinning","self","tableOptions","getRowId","originalRow","id","renderFallbackValue","scope","config","manualPagination","manualSorting","enableMultiSort","enableSortingRemoval","state","onSortingChange","updater","slice","initialState","columnPinning","$useTable","getColumns","_createColumnsMiddle","key","render","columnScope","getColumnScope","jsxRenderContext","getColumnJsxRenderContext","visible","columnProps","getColumnComponentPropsTop","_createColumnRender","columnHelper","property","push","accessor","header","_props","title","cell","props","renders","size","rest","width","enableSorting","_isOrderable","sortDescFirst","meta","left","right","fixed","schemaOrder","keys","schemaKey","schemaKeys","some","Object","prototype","hasOwnProperty","call","$computed","$sdk","loadSchemaProperties","promises","res","Promise","all","filter","_item","index","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","row","_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","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","_createVNode","getFlatHeaders","map","header","canSort","getCanSort","sorted","getIsSorted","headerDefinition","headerContent","getContext","sortAria","sortIcon","id","getToggleSortingHandler","getRowModel","rows","row","getVisibleCells","cell","render","$slotDefault"],"sources":["../src/lib/beanControllerTableBase.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}","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 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 { 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 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 // 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 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: this.$props.getRowId ?? ((originalRow: TData) => cast(originalRow).id),\n getCoreRowModel: getCoreRowModel(),\n renderFallbackValue: this.scope.config.renderFallbackValue,\n manualPagination: true,\n manualSorting: true,\n enableMultiSort: false,\n enableSortingRemoval: false,\n state: {\n get sorting() {\n return self.sorting;\n },\n },\n onSortingChange: updater => {\n const sorting = functionalUpdate(updater, self.sorting).slice(0, 1);\n self.$props.onSortingChange?.(sorting);\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 if (!this.$props.getColumns) return await this._createColumnsMiddle(this.tableMeta.properties);\n return 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(render, columnProps, columnScope, jsxRenderContext);\n },\n this,\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 _getColumnPinning() {\n const left: string[] = [];\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\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 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 headerContent = (\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}>\n {row.getVisibleCells().map(cell => {\n const column = cell.column;\n return (\n <td\n key={cell.id}\n class={column.getIsPinned() ? 'bg-base-100' : undefined}\n style={this._getColumnStyle(column)}\n >\n <FlexRender\n render={column.columnDef.cell}\n props={cell.getContext()}\n ></FlexRender>\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":";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AoB,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","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,QAAQ,YAAY,cAAc,CAAC;EAC5C,CAAC;CACH;CACA,MAAM,cAAc;EAClB,MAAM,IAAI,MAAM,8BAA8B;CAChD;AACF;;;AChBA,IAAa,yBAAyB;;;;;;;ACoEtC,IACagB,mBAAeC,SAD3BJ,WAAW,GAACK,UAAAC,SAAA,EAAAC,QAAA,UAAA,CAAA,GAAAH,OAAAI,WAAAH,QAAAG,YAAAC,mBAAb,MACaN,wBAA+CF,wBAA+B;CAAAS,YAAA,GAAAC,MAAA;EAAA,MAAA,GAAAA,IAAA;EAGzF,KAEAC,aAAU,KAAA;EAAA,KACVC,UAAO,KAAA;EAAA,KACPC,YAAS,KAAA;EAAA,KACTC,UAAO,KAAA;EAAA,KACPC,eAAY,KAAA;CAAA;CAEZ,MAAgBC,WAAW;EACzB,KAAKC,KAAKC,SAAS,WAAW,IAAI;EAElC,KAAKH,eAAe,KAAKI,iBAAiB;EAC1C,KAAKL,UAAU,KAAKG,KAAKG,eAAetB,SAAS,OAAOuB,KAAAA,GAAW,KAAKN,YAAY;EAEpF,KAAKO,kBAAkB;EAEvB,MAAM,KAAKC,YAAY;EAEvB,KAAKC,aACG,KAAKC,OAAOC,QAClB,OAAOC,UAAUC,aAAa;GAC5B,IAAIlC,UAAUiC,UAAUC,QAAQ,GAAG;GACnC,MA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
4
|
import type { TypeTableCellRender } from './tableColumn.js';
|
|
5
5
|
export type TypeTable<TData extends {} = {}> = ReturnType<typeof useVueTable<TData>>;
|
|
6
6
|
export type TypeColumn<TData extends {} = {}> = ColumnDef<TData, any>;
|
|
7
|
+
export declare const TableColumnIdSelection = "$$selection";
|
|
7
8
|
export interface ITableMeta<TData extends {} = {}> {
|
|
8
9
|
properties: ISchemaObjectExtensionField[];
|
|
9
10
|
renders: Record<string, TypeTableCellRender<TData>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/types/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EACV,2BAA2B,EAC3B,4BAA4B,EAC7B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,MAAM,MAAM,SAAS,CAAC,KAAK,SAAS,EAAE,GAAG,EAAE,IAAI,UAAU,CAAC,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;AAErF,MAAM,MAAM,UAAU,CAAC,KAAK,SAAS,EAAE,GAAG,EAAE,IAAI,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAEtE,MAAM,WAAW,UAAU,CAAC,KAAK,SAAS,EAAE,GAAG,EAAE;IAC/C,UAAU,EAAE,2BAA2B,EAAE,CAAC;IAC1C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;CACrD;AAED,MAAM,MAAM,uBAAuB,CAAC,KAAK,SAAS,EAAE,GAAG,EAAE,IAAI,CAC3D,UAAU,CAAC,EAAE,2BAA2B,EAAE,KACvC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,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BAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;CACrD;AAED,MAAM,MAAM,uBAAuB,CAAC,KAAK,SAAS,EAAE,GAAG,EAAE,IAAI,CAC3D,UAAU,CAAC,EAAE,2BAA2B,EAAE,KACvC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAElC,MAAM,MAAM,2BAA2B,CAAC,KAAK,SAAS,EAAE,GAAG,EAAE,IAAI,CAC/D,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,4BAA4B,KACjC,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC;AAE1D,MAAM,MAAM,mBAAmB,CAAC,KAAK,SAAS,EAAE,GAAG,EAAE,IAAI,CACvD,IAAI,EAAE,uBAAuB,CAAC,KAAK,CAAC,EACpC,kBAAkB,EAAE,2BAA2B,CAAC,KAAK,CAAC,EACtD,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,KAC1B,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
getCoreRowModel,
|
|
15
15
|
OnChangeFn,
|
|
16
16
|
Row,
|
|
17
|
+
RowSelectionState,
|
|
17
18
|
SortingState,
|
|
18
19
|
TableOptionsWithReactiveData,
|
|
19
20
|
} from '@tanstack/vue-table';
|
|
@@ -46,6 +47,7 @@ import type {
|
|
|
46
47
|
} from '../../types/tableColumn.js';
|
|
47
48
|
|
|
48
49
|
import { BeanControllerTableBase } from '../../lib/beanControllerTableBase.js';
|
|
50
|
+
import { TableColumnIdSelection } from '../../types/table.js';
|
|
49
51
|
import { ITableCellRenderColumnOptions } from '../../types/tableColumn.js';
|
|
50
52
|
|
|
51
53
|
export interface ControllerTableProps<TData extends {} = {}> {
|
|
@@ -54,6 +56,10 @@ export interface ControllerTableProps<TData extends {} = {}> {
|
|
|
54
56
|
schemaOrder?: SchemaObject;
|
|
55
57
|
sorting?: SortingState;
|
|
56
58
|
onSortingChange?: OnChangeFn<SortingState>;
|
|
59
|
+
enableRowSelection?: boolean | ((row: Row<TData>) => boolean);
|
|
60
|
+
selectionMode?: 'single' | 'multiple';
|
|
61
|
+
rowSelection?: RowSelectionState;
|
|
62
|
+
onRowSelectionChange?: OnChangeFn<RowSelectionState>;
|
|
57
63
|
tableScope?: ITableScope;
|
|
58
64
|
getColumns?: TypeTableGetColumns<TData>;
|
|
59
65
|
slotDefault?: (table: ControllerTable<TData>) => VNode;
|
|
@@ -89,6 +95,13 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
89
95
|
await this.refreshMeta();
|
|
90
96
|
},
|
|
91
97
|
);
|
|
98
|
+
this.$watch(
|
|
99
|
+
() => this.$props.enableRowSelection,
|
|
100
|
+
async (newValue, oldValue) => {
|
|
101
|
+
if (newValue === oldValue) return;
|
|
102
|
+
await this.refreshMeta();
|
|
103
|
+
},
|
|
104
|
+
);
|
|
92
105
|
// table
|
|
93
106
|
this._createTable();
|
|
94
107
|
}
|
|
@@ -105,6 +118,10 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
105
118
|
return this.$props.sorting ?? [];
|
|
106
119
|
}
|
|
107
120
|
|
|
121
|
+
public get rowSelection() {
|
|
122
|
+
return this.$props.rowSelection ?? {};
|
|
123
|
+
}
|
|
124
|
+
|
|
108
125
|
public async refreshMeta() {
|
|
109
126
|
this.tableMeta = await this._createTableMeta();
|
|
110
127
|
this.columns = await this._createColumns();
|
|
@@ -115,22 +132,31 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
115
132
|
// eslint-disable-next-line
|
|
116
133
|
const self = this;
|
|
117
134
|
const tableOptions: TableOptionsWithReactiveData<TData> = {
|
|
118
|
-
getRowId:
|
|
135
|
+
getRowId: (originalRow, index, parent) => this._getRowId(originalRow, index, parent),
|
|
119
136
|
getCoreRowModel: getCoreRowModel(),
|
|
120
137
|
renderFallbackValue: this.scope.config.renderFallbackValue,
|
|
121
138
|
manualPagination: true,
|
|
122
139
|
manualSorting: true,
|
|
123
140
|
enableMultiSort: false,
|
|
124
141
|
enableSortingRemoval: false,
|
|
142
|
+
enableRowSelection: row => self._canSelectRow(row),
|
|
143
|
+
enableMultiRowSelection: this.$props.selectionMode !== 'single',
|
|
125
144
|
state: {
|
|
126
145
|
get sorting() {
|
|
127
146
|
return self.sorting;
|
|
128
147
|
},
|
|
148
|
+
get rowSelection() {
|
|
149
|
+
return self.rowSelection;
|
|
150
|
+
},
|
|
129
151
|
},
|
|
130
152
|
onSortingChange: updater => {
|
|
131
153
|
const sorting = functionalUpdate(updater, self.sorting).slice(0, 1);
|
|
132
154
|
self.$props.onSortingChange?.(sorting);
|
|
133
155
|
},
|
|
156
|
+
onRowSelectionChange: updater => {
|
|
157
|
+
const rowSelection = functionalUpdate(updater, self.rowSelection);
|
|
158
|
+
self.$props.onRowSelectionChange?.(rowSelection);
|
|
159
|
+
},
|
|
134
160
|
get initialState() {
|
|
135
161
|
const columnPinning = self._getColumnPinning();
|
|
136
162
|
return { columnPinning };
|
|
@@ -148,31 +174,50 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
148
174
|
|
|
149
175
|
private async _createColumns() {
|
|
150
176
|
if (!this.properties) return [];
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
177
|
+
const columns = !this.$props.getColumns
|
|
178
|
+
? await this._createColumnsMiddle(this.tableMeta.properties)
|
|
179
|
+
: await this.$props.getColumns(
|
|
180
|
+
async properties => {
|
|
181
|
+
return await this._createColumnsMiddle(properties ?? this.tableMeta.properties);
|
|
182
|
+
},
|
|
183
|
+
async (
|
|
184
|
+
key: string,
|
|
185
|
+
render: TypeTableCellRenderComponent,
|
|
186
|
+
): Promise<TypeTableCellRender<TData, any> | undefined> => {
|
|
187
|
+
// columnScope
|
|
188
|
+
const columnScope = this.getColumnScope(key);
|
|
189
|
+
// renderContext
|
|
190
|
+
const jsxRenderContext = this.getColumnJsxRenderContext(columnScope);
|
|
191
|
+
// columnProps
|
|
192
|
+
const { visible, columnProps } = this.getColumnComponentPropsTop(
|
|
193
|
+
key,
|
|
194
|
+
columnScope,
|
|
195
|
+
jsxRenderContext,
|
|
196
|
+
);
|
|
197
|
+
// visible
|
|
198
|
+
if (visible === false) return;
|
|
199
|
+
return await this._createColumnRender(
|
|
200
|
+
render,
|
|
201
|
+
columnProps,
|
|
202
|
+
columnScope,
|
|
203
|
+
jsxRenderContext,
|
|
204
|
+
);
|
|
205
|
+
},
|
|
206
|
+
this,
|
|
169
207
|
);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
208
|
+
if (!this.$props.enableRowSelection) return columns;
|
|
209
|
+
const columnHelper = createColumnHelper<TData>();
|
|
210
|
+
return [
|
|
211
|
+
columnHelper.display({
|
|
212
|
+
id: TableColumnIdSelection,
|
|
213
|
+
header: '',
|
|
214
|
+
cell: '',
|
|
215
|
+
size: 48,
|
|
216
|
+
enableSorting: false,
|
|
217
|
+
meta: { rest: { fixed: 'left', width: 48, align: 'center' } },
|
|
218
|
+
}),
|
|
219
|
+
...columns,
|
|
220
|
+
];
|
|
176
221
|
}
|
|
177
222
|
|
|
178
223
|
private async _createColumnsMiddle(
|
|
@@ -200,8 +245,25 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
200
245
|
return columns;
|
|
201
246
|
}
|
|
202
247
|
|
|
248
|
+
private _getRowId(originalRow: TData, index: number, parent?: Row<TData>) {
|
|
249
|
+
const id = this.$props.getRowId?.(originalRow, index, parent) ?? cast(originalRow).id;
|
|
250
|
+
if (isNilOrEmptyString(id)) {
|
|
251
|
+
return `__unselectable_${parent ? `${parent.id}.` : ''}${index}`;
|
|
252
|
+
}
|
|
253
|
+
return String(id);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
private _canSelectRow(row: Row<TData>) {
|
|
257
|
+
const enableRowSelection = this.$props.enableRowSelection;
|
|
258
|
+
if (!enableRowSelection) return false;
|
|
259
|
+
const originalId =
|
|
260
|
+
this.$props.getRowId?.(row.original, row.index, row.getParentRow()) ?? cast(row.original).id;
|
|
261
|
+
if (isNilOrEmptyString(originalId)) return false;
|
|
262
|
+
return typeof enableRowSelection === 'function' ? enableRowSelection(row) : true;
|
|
263
|
+
}
|
|
264
|
+
|
|
203
265
|
private _getColumnPinning() {
|
|
204
|
-
const left: string[] = [];
|
|
266
|
+
const left: string[] = this.$props.enableRowSelection ? [TableColumnIdSelection] : [];
|
|
205
267
|
const right: string[] = [];
|
|
206
268
|
for (const property of this.tableMeta?.properties ?? []) {
|
|
207
269
|
const fixed = property.rest?.fixed;
|
|
@@ -4,6 +4,8 @@ import { FlexRender } from '@tanstack/vue-table';
|
|
|
4
4
|
import { BeanRenderBase } from 'zova';
|
|
5
5
|
import { Render } from 'zova-module-a-bean';
|
|
6
6
|
|
|
7
|
+
import { TableColumnIdSelection } from '../../types/table.js';
|
|
8
|
+
|
|
7
9
|
@Render()
|
|
8
10
|
export class RenderTable extends BeanRenderBase {
|
|
9
11
|
private _getColumnStyle(column: any): CSSProperties {
|
|
@@ -23,6 +25,7 @@ export class RenderTable extends BeanRenderBase {
|
|
|
23
25
|
|
|
24
26
|
private _renderTableDefault() {
|
|
25
27
|
const table = this.table;
|
|
28
|
+
const selectionMode = this.$props.selectionMode ?? 'multiple';
|
|
26
29
|
return (
|
|
27
30
|
<table class="table">
|
|
28
31
|
<thead>
|
|
@@ -33,7 +36,20 @@ export class RenderTable extends BeanRenderBase {
|
|
|
33
36
|
const sorted = column.getIsSorted();
|
|
34
37
|
const fixed = column.getIsPinned();
|
|
35
38
|
const headerDefinition = column.columnDef.header;
|
|
36
|
-
const
|
|
39
|
+
const selection = column.id === TableColumnIdSelection;
|
|
40
|
+
const headerContent = selection ? (
|
|
41
|
+
selectionMode === 'single' ? null : (
|
|
42
|
+
<input
|
|
43
|
+
type="checkbox"
|
|
44
|
+
checked={table.getIsAllPageRowsSelected()}
|
|
45
|
+
indeterminate={table.getIsSomePageRowsSelected()}
|
|
46
|
+
aria-checked={table.getIsSomePageRowsSelected() ? 'mixed' : undefined}
|
|
47
|
+
aria-label="Select all rows on this page"
|
|
48
|
+
disabled={table.getRowModel().rows.every(row => !row.getCanSelect())}
|
|
49
|
+
onChange={table.getToggleAllPageRowsSelectedHandler()}
|
|
50
|
+
/>
|
|
51
|
+
)
|
|
52
|
+
) : (
|
|
37
53
|
<FlexRender render={headerDefinition} props={header.getContext()}></FlexRender>
|
|
38
54
|
);
|
|
39
55
|
let sortAria: AriaAttributes['aria-sort'] = 'none';
|
|
@@ -73,19 +89,30 @@ export class RenderTable extends BeanRenderBase {
|
|
|
73
89
|
<tbody>
|
|
74
90
|
{table.getRowModel().rows.map(row => {
|
|
75
91
|
return (
|
|
76
|
-
<tr key={row.id}>
|
|
92
|
+
<tr key={row.id} aria-selected={row.getIsSelected()}>
|
|
77
93
|
{row.getVisibleCells().map(cell => {
|
|
78
94
|
const column = cell.column;
|
|
95
|
+
const selection = column.id === TableColumnIdSelection;
|
|
79
96
|
return (
|
|
80
97
|
<td
|
|
81
98
|
key={cell.id}
|
|
82
99
|
class={column.getIsPinned() ? 'bg-base-100' : undefined}
|
|
83
100
|
style={this._getColumnStyle(column)}
|
|
84
101
|
>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
102
|
+
{selection ? (
|
|
103
|
+
<input
|
|
104
|
+
type={selectionMode === 'single' ? 'radio' : 'checkbox'}
|
|
105
|
+
checked={row.getIsSelected()}
|
|
106
|
+
disabled={!row.getCanSelect()}
|
|
107
|
+
aria-label={`Select row ${row.id}`}
|
|
108
|
+
onChange={row.getToggleSelectedHandler()}
|
|
109
|
+
/>
|
|
110
|
+
) : (
|
|
111
|
+
<FlexRender
|
|
112
|
+
render={column.columnDef.cell}
|
|
113
|
+
props={cell.getContext()}
|
|
114
|
+
></FlexRender>
|
|
115
|
+
)}
|
|
89
116
|
</td>
|
|
90
117
|
);
|
|
91
118
|
})}
|
package/src/types/table.ts
CHANGED
|
@@ -11,6 +11,8 @@ export type TypeTable<TData extends {} = {}> = ReturnType<typeof useVueTable<TDa
|
|
|
11
11
|
|
|
12
12
|
export type TypeColumn<TData extends {} = {}> = ColumnDef<TData, any>;
|
|
13
13
|
|
|
14
|
+
export const TableColumnIdSelection = '$$selection';
|
|
15
|
+
|
|
14
16
|
export interface ITableMeta<TData extends {} = {}> {
|
|
15
17
|
properties: ISchemaObjectExtensionField[];
|
|
16
18
|
renders: Record<string, TypeTableCellRender<TData>>;
|