zova-module-a-table 5.1.38 → 5.1.39
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 +7 -1
- package/dist/component/table/controller.d.ts.map +1 -1
- package/dist/component/table/render.d.ts +1 -0
- package/dist/component/table/render.d.ts.map +1 -1
- package/dist/index.js +95 -7
- package/dist/index.js.map +1 -1
- package/dist/types/table.d.ts +3 -4
- package/dist/types/table.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/component/table/controller.tsx +50 -0
- package/src/component/table/render.tsx +60 -7
- package/src/types/table.ts +6 -4
|
@@ -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, Row } from '@tanstack/vue-table';
|
|
3
|
+
import { CellContext, OnChangeFn, Row, 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';
|
|
@@ -12,6 +12,9 @@ import { ITableCellRenderColumnOptions } from '../../types/tableColumn.js';
|
|
|
12
12
|
export interface ControllerTableProps<TData extends {} = {}> {
|
|
13
13
|
data?: TData[];
|
|
14
14
|
schema?: SchemaObject;
|
|
15
|
+
schemaOrder?: SchemaObject;
|
|
16
|
+
sorting?: SortingState;
|
|
17
|
+
onSortingChange?: OnChangeFn<SortingState>;
|
|
15
18
|
tableScope?: ITableScope;
|
|
16
19
|
getColumns?: TypeTableGetColumns<TData>;
|
|
17
20
|
slotDefault?: (table: ControllerTable<TData>) => VNode;
|
|
@@ -27,10 +30,13 @@ export declare class ControllerTable<TData extends {} = {}> extends BeanControll
|
|
|
27
30
|
protected __init__(): Promise<void>;
|
|
28
31
|
get schema(): SchemaObject | undefined;
|
|
29
32
|
get data(): TData[] | undefined;
|
|
33
|
+
get sorting(): SortingState;
|
|
30
34
|
refreshMeta(): Promise<void>;
|
|
31
35
|
private _createTable;
|
|
32
36
|
private _createColumns;
|
|
33
37
|
private _createColumnsMiddle;
|
|
38
|
+
private _getColumnPinning;
|
|
39
|
+
private _isOrderable;
|
|
34
40
|
private _createProperties;
|
|
35
41
|
private _createTableMeta;
|
|
36
42
|
getColumnJsxRenderContext(celScope: ITableColumnScope): IJsxRenderContextTableColumn;
|
|
@@ -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,
|
|
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,C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,iBAEjB;IAEY,WAAW;IAMxB,OAAO,CAAC,YAAY;YAmCN,cAAc;YA6Bd,oBAAoB;IAyBlC,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,iBAAiB;YAMX,gBAAgB;IAiCvB,yBAAyB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,4BAA4B;IAYpF,uBAAuB,CAC5B,QAAQ,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,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,5 +1,6 @@
|
|
|
1
1
|
import { BeanRenderBase } from 'zova';
|
|
2
2
|
export declare class RenderTable extends BeanRenderBase {
|
|
3
|
+
private _getColumnStyle;
|
|
3
4
|
private _renderTableDefault;
|
|
4
5
|
render(): import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
5
6
|
[key: string]: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/component/table/render.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/component/table/render.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAGtC,qBACa,WAAY,SAAQ,cAAc;IAC7C,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,mBAAmB;IA4EpB,MAAM;;;CAGd"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BeanControllerBase, BeanControllerPageBase, BeanInfo, BeanRenderBase, BeanScopeBase, appResource, beanFullNameFromOnionName, cast, createBeanDecorator, deepEqual, deepExtend, objectAssignReactive, prepareComponentOptions, useController } from "zova";
|
|
2
2
|
import { celEnvBase, isNilOrEmptyString } from "@cabloy/utils";
|
|
3
|
-
import { FlexRender, createColumnHelper, getCoreRowModel, useVueTable } from "@tanstack/vue-table";
|
|
3
|
+
import { FlexRender, createColumnHelper, functionalUpdate, getCoreRowModel, useVueTable } from "@tanstack/vue-table";
|
|
4
4
|
import { ZovaJsx, isJsxComponent } from "zova-jsx";
|
|
5
5
|
import { Controller, Render, Scope } from "zova-module-a-bean";
|
|
6
6
|
import { createVNode, defineComponent, markRaw } from "vue";
|
|
@@ -49,9 +49,13 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
49
49
|
get data() {
|
|
50
50
|
return this.$props.data;
|
|
51
51
|
}
|
|
52
|
+
get sorting() {
|
|
53
|
+
return this.$props.sorting ?? [];
|
|
54
|
+
}
|
|
52
55
|
async refreshMeta() {
|
|
53
56
|
this.tableMeta = await this._createTableMeta();
|
|
54
57
|
this.columns = await this._createColumns();
|
|
58
|
+
this.table?.setColumnPinning(this._getColumnPinning());
|
|
55
59
|
}
|
|
56
60
|
_createTable() {
|
|
57
61
|
const self = this;
|
|
@@ -60,6 +64,19 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
60
64
|
getCoreRowModel: getCoreRowModel(),
|
|
61
65
|
renderFallbackValue: this.scope.config.renderFallbackValue,
|
|
62
66
|
manualPagination: true,
|
|
67
|
+
manualSorting: true,
|
|
68
|
+
enableMultiSort: false,
|
|
69
|
+
enableSortingRemoval: false,
|
|
70
|
+
state: { get sorting() {
|
|
71
|
+
return self.sorting;
|
|
72
|
+
} },
|
|
73
|
+
onSortingChange: (updater) => {
|
|
74
|
+
const sorting = functionalUpdate(updater, self.sorting).slice(0, 1);
|
|
75
|
+
self.$props.onSortingChange?.(sorting);
|
|
76
|
+
},
|
|
77
|
+
get initialState() {
|
|
78
|
+
return { columnPinning: self._getColumnPinning() };
|
|
79
|
+
},
|
|
63
80
|
get data() {
|
|
64
81
|
return self.data || [];
|
|
65
82
|
},
|
|
@@ -68,6 +85,7 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
68
85
|
}
|
|
69
86
|
};
|
|
70
87
|
this.table = this.$useTable(tableOptions);
|
|
88
|
+
this.table.setColumnPinning(this._getColumnPinning());
|
|
71
89
|
}
|
|
72
90
|
async _createColumns() {
|
|
73
91
|
if (!this.properties) return [];
|
|
@@ -93,11 +111,37 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
93
111
|
header: (_props) => {
|
|
94
112
|
return property?.title || key;
|
|
95
113
|
},
|
|
96
|
-
cell: (props) => tableMeta.renders[key](props)
|
|
114
|
+
cell: (props) => tableMeta.renders[key](props),
|
|
115
|
+
size: property.rest?.width,
|
|
116
|
+
enableSorting: property.rest?.enableSorting === true && this._isOrderable(property),
|
|
117
|
+
sortDescFirst: property.rest?.sortDescFirst === true,
|
|
118
|
+
meta: { rest: property.rest }
|
|
97
119
|
}));
|
|
98
120
|
}
|
|
99
121
|
return columns;
|
|
100
122
|
}
|
|
123
|
+
_getColumnPinning() {
|
|
124
|
+
const left = [];
|
|
125
|
+
const right = [];
|
|
126
|
+
for (const property of this.tableMeta?.properties ?? []) {
|
|
127
|
+
const fixed = property.rest?.fixed;
|
|
128
|
+
if (fixed === "left") left.push(property.key);
|
|
129
|
+
if (fixed === "right") right.push(property.key);
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
left,
|
|
133
|
+
right
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
_isOrderable(property) {
|
|
137
|
+
const properties = this.$props.schemaOrder?.properties;
|
|
138
|
+
if (!properties) return false;
|
|
139
|
+
return [
|
|
140
|
+
property.key,
|
|
141
|
+
property.schemaKey,
|
|
142
|
+
...property.schemaKeys ?? []
|
|
143
|
+
].some((key) => key && Object.prototype.hasOwnProperty.call(properties, key));
|
|
144
|
+
}
|
|
101
145
|
_createProperties() {
|
|
102
146
|
this.properties = this.$computed(() => {
|
|
103
147
|
return this.$sdk.loadSchemaProperties(this.schema, "table");
|
|
@@ -263,17 +307,61 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
263
307
|
//#region src/component/table/render.tsx
|
|
264
308
|
var _dec$1, _dec2$1, _class$1;
|
|
265
309
|
var RenderTable = (_dec$1 = Render(), _dec2$1 = BeanInfo({ module: "a-table" }), _dec$1(_class$1 = _dec2$1(_class$1 = class RenderTable extends BeanRenderBase {
|
|
310
|
+
_getColumnStyle(column) {
|
|
311
|
+
const rest = column.columnDef.meta?.rest;
|
|
312
|
+
const fixed = column.getIsPinned();
|
|
313
|
+
const width = rest?.width ? `${rest.width}px` : void 0;
|
|
314
|
+
return {
|
|
315
|
+
width,
|
|
316
|
+
minWidth: width,
|
|
317
|
+
textAlign: rest?.align,
|
|
318
|
+
position: fixed ? "sticky" : void 0,
|
|
319
|
+
left: fixed === "left" ? `${column.getStart("left")}px` : void 0,
|
|
320
|
+
right: fixed === "right" ? `${column.getAfter("right")}px` : void 0,
|
|
321
|
+
zIndex: fixed ? 1 : void 0
|
|
322
|
+
};
|
|
323
|
+
}
|
|
266
324
|
_renderTableDefault() {
|
|
267
325
|
const table = this.table;
|
|
268
326
|
return createVNode("table", { "class": "table" }, [createVNode("thead", null, [createVNode("tr", null, [table.getFlatHeaders().map((header) => {
|
|
269
|
-
|
|
270
|
-
|
|
327
|
+
const column = header.column;
|
|
328
|
+
const canSort = column.getCanSort();
|
|
329
|
+
const sorted = column.getIsSorted();
|
|
330
|
+
const fixed = column.getIsPinned();
|
|
331
|
+
const headerDefinition = column.columnDef.header;
|
|
332
|
+
const headerContent = createVNode(FlexRender, {
|
|
333
|
+
"render": headerDefinition,
|
|
271
334
|
"props": header.getContext()
|
|
272
|
-
}, null)
|
|
335
|
+
}, null);
|
|
336
|
+
let sortAria = "none";
|
|
337
|
+
let sortIcon = "↕";
|
|
338
|
+
if (sorted === "asc") {
|
|
339
|
+
sortAria = "ascending";
|
|
340
|
+
sortIcon = "▲";
|
|
341
|
+
} else if (sorted === "desc") {
|
|
342
|
+
sortAria = "descending";
|
|
343
|
+
sortIcon = "▼";
|
|
344
|
+
}
|
|
345
|
+
return createVNode("th", {
|
|
346
|
+
"key": header.id,
|
|
347
|
+
"class": fixed ? "bg-base-100" : void 0,
|
|
348
|
+
"style": this._getColumnStyle(column),
|
|
349
|
+
"aria-sort": sortAria
|
|
350
|
+
}, [canSort ? createVNode("button", {
|
|
351
|
+
"type": "button",
|
|
352
|
+
"class": "inline-flex w-full items-center gap-1",
|
|
353
|
+
"onClick": column.getToggleSortingHandler(),
|
|
354
|
+
"aria-label": `Sort by ${column.id}`
|
|
355
|
+
}, [headerContent, createVNode("span", { "aria-hidden": "true" }, [sortIcon])]) : headerContent]);
|
|
273
356
|
})])]), createVNode("tbody", null, [table.getRowModel().rows.map((row) => {
|
|
274
357
|
return createVNode("tr", { "key": row.id }, [row.getVisibleCells().map((cell) => {
|
|
275
|
-
|
|
276
|
-
|
|
358
|
+
const column = cell.column;
|
|
359
|
+
return createVNode("td", {
|
|
360
|
+
"key": cell.id,
|
|
361
|
+
"class": column.getIsPinned() ? "bg-base-100" : void 0,
|
|
362
|
+
"style": this._getColumnStyle(column)
|
|
363
|
+
}, [createVNode(FlexRender, {
|
|
364
|
+
"render": column.columnDef.cell,
|
|
277
365
|
"props": cell.getContext()
|
|
278
366
|
}, null)]);
|
|
279
367
|
})]);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["celEnvBase","isNilOrEmptyString","createColumnHelper","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","_createTableMeta","_createColumns","self","tableOptions","getRowId","originalRow","id","renderFallbackValue","scope","config","manualPagination","table","$useTable","getColumns","_createColumnsMiddle","key","render","columnScope","getColumnScope","jsxRenderContext","getColumnJsxRenderContext","visible","columnProps","getColumnComponentPropsTop","_createColumnRender","columnHelper","property","push","accessor","header","_props","title","cell","props","renders","$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","rest","_getColumnComponentPropsTopByRest","_renderContext","evaluateExpression","Object","assign","$propsDefault","FlexRender","BeanRenderBase","Render","RenderTable","_dec","_dec2","__z_BeanInfo","module","_class","_renderTableDefault","table","_createVNode","getFlatHeaders","map","header","id","column","columnDef","getContext","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 getCoreRowModel,\n Row,\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 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 async refreshMeta() {\n this.tableMeta = await this._createTableMeta();\n this.columns = await this._createColumns();\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 get data() {\n return self.data || [];\n },\n get columns() {\n return self.columns;\n },\n };\n this.table = this.$useTable(tableOptions);\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 }),\n );\n }\n return columns;\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 { 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 _renderTableDefault() {\n const table = this.table;\n return (\n <table class=\"table\">\n <thead>\n <tr>\n {table.getFlatHeaders().map(header => {\n return (\n <th key={header.id}>\n <FlexRender\n render={header.column.columnDef.header}\n props={header.getContext()}\n ></FlexRender>\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 return (\n <td key={cell.id}>\n <FlexRender\n render={cell.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":";;;;;;;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;;;;ACwCA,IACac,mBAAeC,SAD3BH,WAAW,GAACI,UAAAC,SAAA,EAAAC,QAAA,UAAA,CAAA,GAAAH,OAAAI,WAAAH,QAAAG,YAAAC,mBAAb,MACaN,wBAA+CD,wBAA+B;CAAAQ,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,eAAerB,SAAS,OAAOsB,KAAAA,GAAW,KAAKN,YAAY;EAEpF,KAAKO,kBAAkB;EAEvB,MAAM,KAAKC,YAAY;EAEvB,KAAKC,aACG,KAAKC,OAAOC,QAClB,OAAOC,UAAUC,aAAa;GAC5B,IAAIjC,UAAUgC,UAAUC,QAAQ,GAAG;GACnC,MAAM,KAAKL,YAAY;E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ACxB,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","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":";;;;;;;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,cA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A7B,YAAA;KAAA,UAGzBU,OAAOE,UAAUoC;KAAI,SACtBA,KAAKT,WAAW;IAAC,GAAA,IAAA,CAAA,CAAA;GAIhC,CAAC,CAAC,CAAA;EAGR,CAAC,CAAC,CAAA,CAAA,CAAA;CAIV;CAEOU,SAAS;EACd,OAAO,KAAKC,eAAe,KAAKA,aAAa,IAAI,IAAI,KAAKvB,oBAAoB;CAChF;AACF,CAAC,KAAAnB,QAAA,KAAAA;;;AClGD,IAAa,SAAS,iBAAgB,WAAU;CAC9C,cAAc,iBAAiB,aAAa,KAAA,CAAS;CACrD,aAAa,CAAC;AAChB,GAAG,wBAAwB,CAAC;;;ACP5B,IAAa,UAAS,SAAQ;CAC5B,OAAO,EACL,qBAAqB,KACvB;AACF;;;;;ACJA,IAAI,MAAM,OAAO;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"}
|
package/dist/types/table.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { ColumnDef, useVueTable } from '@tanstack/vue-table';
|
|
2
|
-
import type {
|
|
3
|
-
import type { TypeTableCellRenderComponent } from 'zova-module-a-openapi';
|
|
2
|
+
import type { ISchemaObjectExtensionField, TypeTableCellRenderComponent } from 'zova-module-a-openapi';
|
|
4
3
|
import type { ControllerTable } from '../component/table/controller.jsx';
|
|
5
4
|
import type { TypeTableCellRender } from './tableColumn.js';
|
|
6
5
|
export type TypeTable<TData extends {} = {}> = ReturnType<typeof useVueTable<TData>>;
|
|
7
6
|
export type TypeColumn<TData extends {} = {}> = ColumnDef<TData, any>;
|
|
8
7
|
export interface ITableMeta<TData extends {} = {}> {
|
|
9
|
-
properties:
|
|
8
|
+
properties: ISchemaObjectExtensionField[];
|
|
10
9
|
renders: Record<string, TypeTableCellRender<TData>>;
|
|
11
10
|
}
|
|
12
|
-
export type TypeTableGetColumnsNext<TData extends {} = {}> = (properties?:
|
|
11
|
+
export type TypeTableGetColumnsNext<TData extends {} = {}> = (properties?: ISchemaObjectExtensionField[]) => Promise<TypeColumn<TData>[]>;
|
|
13
12
|
export type TypeTableCreateColumnRender<TData extends {} = {}> = (key: string, render: TypeTableCellRenderComponent) => Promise<TypeTableCellRender<TData, any> | undefined>;
|
|
14
13
|
export type TypeTableGetColumns<TData extends {} = {}> = (next: TypeTableGetColumnsNext<TData>, createColumnRender: TypeTableCreateColumnRender<TData>, table: ControllerTable<TData>) => Promise<TypeColumn<TData>[]>;
|
|
15
14
|
//# sourceMappingURL=table.d.ts.map
|
|
@@ -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,
|
|
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;A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'@cabloy/utils';
|
|
|
10
10
|
import {
|
|
11
11
|
CellContext,
|
|
12
12
|
createColumnHelper,
|
|
13
|
+
functionalUpdate,
|
|
13
14
|
getCoreRowModel,
|
|
15
|
+
OnChangeFn,
|
|
14
16
|
Row,
|
|
17
|
+
SortingState,
|
|
15
18
|
TableOptionsWithReactiveData,
|
|
16
19
|
} from '@tanstack/vue-table';
|
|
17
20
|
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
@@ -48,6 +51,9 @@ import { ITableCellRenderColumnOptions } from '../../types/tableColumn.js';
|
|
|
48
51
|
export interface ControllerTableProps<TData extends {} = {}> {
|
|
49
52
|
data?: TData[];
|
|
50
53
|
schema?: SchemaObject;
|
|
54
|
+
schemaOrder?: SchemaObject;
|
|
55
|
+
sorting?: SortingState;
|
|
56
|
+
onSortingChange?: OnChangeFn<SortingState>;
|
|
51
57
|
tableScope?: ITableScope;
|
|
52
58
|
getColumns?: TypeTableGetColumns<TData>;
|
|
53
59
|
slotDefault?: (table: ControllerTable<TData>) => VNode;
|
|
@@ -95,9 +101,14 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
95
101
|
return this.$props.data;
|
|
96
102
|
}
|
|
97
103
|
|
|
104
|
+
public get sorting() {
|
|
105
|
+
return this.$props.sorting ?? [];
|
|
106
|
+
}
|
|
107
|
+
|
|
98
108
|
public async refreshMeta() {
|
|
99
109
|
this.tableMeta = await this._createTableMeta();
|
|
100
110
|
this.columns = await this._createColumns();
|
|
111
|
+
this.table?.setColumnPinning(this._getColumnPinning());
|
|
101
112
|
}
|
|
102
113
|
|
|
103
114
|
private _createTable() {
|
|
@@ -108,6 +119,22 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
108
119
|
getCoreRowModel: getCoreRowModel(),
|
|
109
120
|
renderFallbackValue: this.scope.config.renderFallbackValue,
|
|
110
121
|
manualPagination: true,
|
|
122
|
+
manualSorting: true,
|
|
123
|
+
enableMultiSort: false,
|
|
124
|
+
enableSortingRemoval: false,
|
|
125
|
+
state: {
|
|
126
|
+
get sorting() {
|
|
127
|
+
return self.sorting;
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
onSortingChange: updater => {
|
|
131
|
+
const sorting = functionalUpdate(updater, self.sorting).slice(0, 1);
|
|
132
|
+
self.$props.onSortingChange?.(sorting);
|
|
133
|
+
},
|
|
134
|
+
get initialState() {
|
|
135
|
+
const columnPinning = self._getColumnPinning();
|
|
136
|
+
return { columnPinning };
|
|
137
|
+
},
|
|
111
138
|
get data() {
|
|
112
139
|
return self.data || [];
|
|
113
140
|
},
|
|
@@ -116,6 +143,7 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
116
143
|
},
|
|
117
144
|
};
|
|
118
145
|
this.table = this.$useTable(tableOptions);
|
|
146
|
+
this.table.setColumnPinning(this._getColumnPinning());
|
|
119
147
|
}
|
|
120
148
|
|
|
121
149
|
private async _createColumns() {
|
|
@@ -162,12 +190,34 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
162
190
|
return property?.title || key;
|
|
163
191
|
},
|
|
164
192
|
cell: props => tableMeta.renders[key](props),
|
|
193
|
+
size: property.rest?.width,
|
|
194
|
+
enableSorting: property.rest?.enableSorting === true && this._isOrderable(property),
|
|
195
|
+
sortDescFirst: property.rest?.sortDescFirst === true,
|
|
196
|
+
meta: { rest: property.rest },
|
|
165
197
|
}),
|
|
166
198
|
);
|
|
167
199
|
}
|
|
168
200
|
return columns;
|
|
169
201
|
}
|
|
170
202
|
|
|
203
|
+
private _getColumnPinning() {
|
|
204
|
+
const left: string[] = [];
|
|
205
|
+
const right: string[] = [];
|
|
206
|
+
for (const property of this.tableMeta?.properties ?? []) {
|
|
207
|
+
const fixed = property.rest?.fixed;
|
|
208
|
+
if (fixed === 'left') left.push(property.key!);
|
|
209
|
+
if (fixed === 'right') right.push(property.key!);
|
|
210
|
+
}
|
|
211
|
+
return { left, right };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private _isOrderable(property: ISchemaObjectExtensionField) {
|
|
215
|
+
const properties = this.$props.schemaOrder?.properties;
|
|
216
|
+
if (!properties) return false;
|
|
217
|
+
const keys = [property.key, property.schemaKey, ...(property.schemaKeys ?? [])];
|
|
218
|
+
return keys.some(key => key && Object.prototype.hasOwnProperty.call(properties, key));
|
|
219
|
+
}
|
|
220
|
+
|
|
171
221
|
private _createProperties() {
|
|
172
222
|
this.properties = this.$computed(() => {
|
|
173
223
|
return this.$sdk.loadSchemaProperties(this.schema, 'table');
|
|
@@ -1,9 +1,26 @@
|
|
|
1
|
+
import type { AriaAttributes, CSSProperties } from 'vue';
|
|
2
|
+
|
|
1
3
|
import { FlexRender } from '@tanstack/vue-table';
|
|
2
4
|
import { BeanRenderBase } from 'zova';
|
|
3
5
|
import { Render } from 'zova-module-a-bean';
|
|
4
6
|
|
|
5
7
|
@Render()
|
|
6
8
|
export class RenderTable extends BeanRenderBase {
|
|
9
|
+
private _getColumnStyle(column: any): CSSProperties {
|
|
10
|
+
const rest = (column.columnDef.meta as any)?.rest;
|
|
11
|
+
const fixed = column.getIsPinned();
|
|
12
|
+
const width = rest?.width ? `${rest.width}px` : undefined;
|
|
13
|
+
return {
|
|
14
|
+
width,
|
|
15
|
+
minWidth: width,
|
|
16
|
+
textAlign: rest?.align,
|
|
17
|
+
position: fixed ? ('sticky' as const) : undefined,
|
|
18
|
+
left: fixed === 'left' ? `${column.getStart('left')}px` : undefined,
|
|
19
|
+
right: fixed === 'right' ? `${column.getAfter('right')}px` : undefined,
|
|
20
|
+
zIndex: fixed ? 1 : undefined,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
7
24
|
private _renderTableDefault() {
|
|
8
25
|
const table = this.table;
|
|
9
26
|
return (
|
|
@@ -11,12 +28,43 @@ export class RenderTable extends BeanRenderBase {
|
|
|
11
28
|
<thead>
|
|
12
29
|
<tr>
|
|
13
30
|
{table.getFlatHeaders().map(header => {
|
|
31
|
+
const column = header.column;
|
|
32
|
+
const canSort = column.getCanSort();
|
|
33
|
+
const sorted = column.getIsSorted();
|
|
34
|
+
const fixed = column.getIsPinned();
|
|
35
|
+
const headerDefinition = column.columnDef.header;
|
|
36
|
+
const headerContent = (
|
|
37
|
+
<FlexRender render={headerDefinition} props={header.getContext()}></FlexRender>
|
|
38
|
+
);
|
|
39
|
+
let sortAria: AriaAttributes['aria-sort'] = 'none';
|
|
40
|
+
let sortIcon: '▲' | '▼' | '↕' = '↕';
|
|
41
|
+
if (sorted === 'asc') {
|
|
42
|
+
sortAria = 'ascending';
|
|
43
|
+
sortIcon = '▲';
|
|
44
|
+
} else if (sorted === 'desc') {
|
|
45
|
+
sortAria = 'descending';
|
|
46
|
+
sortIcon = '▼';
|
|
47
|
+
}
|
|
14
48
|
return (
|
|
15
|
-
<th
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
49
|
+
<th
|
|
50
|
+
key={header.id}
|
|
51
|
+
class={fixed ? 'bg-base-100' : undefined}
|
|
52
|
+
style={this._getColumnStyle(column)}
|
|
53
|
+
aria-sort={sortAria}
|
|
54
|
+
>
|
|
55
|
+
{canSort ? (
|
|
56
|
+
<button
|
|
57
|
+
type="button"
|
|
58
|
+
class="inline-flex w-full items-center gap-1"
|
|
59
|
+
onClick={column.getToggleSortingHandler()}
|
|
60
|
+
aria-label={`Sort by ${column.id}`}
|
|
61
|
+
>
|
|
62
|
+
{headerContent}
|
|
63
|
+
<span aria-hidden="true">{sortIcon}</span>
|
|
64
|
+
</button>
|
|
65
|
+
) : (
|
|
66
|
+
headerContent
|
|
67
|
+
)}
|
|
20
68
|
</th>
|
|
21
69
|
);
|
|
22
70
|
})}
|
|
@@ -27,10 +75,15 @@ export class RenderTable extends BeanRenderBase {
|
|
|
27
75
|
return (
|
|
28
76
|
<tr key={row.id}>
|
|
29
77
|
{row.getVisibleCells().map(cell => {
|
|
78
|
+
const column = cell.column;
|
|
30
79
|
return (
|
|
31
|
-
<td
|
|
80
|
+
<td
|
|
81
|
+
key={cell.id}
|
|
82
|
+
class={column.getIsPinned() ? 'bg-base-100' : undefined}
|
|
83
|
+
style={this._getColumnStyle(column)}
|
|
84
|
+
>
|
|
32
85
|
<FlexRender
|
|
33
|
-
render={
|
|
86
|
+
render={column.columnDef.cell}
|
|
34
87
|
props={cell.getContext()}
|
|
35
88
|
></FlexRender>
|
|
36
89
|
</td>
|
package/src/types/table.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ColumnDef, useVueTable } from '@tanstack/vue-table';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type {
|
|
3
|
+
ISchemaObjectExtensionField,
|
|
4
|
+
TypeTableCellRenderComponent,
|
|
5
|
+
} from 'zova-module-a-openapi';
|
|
4
6
|
|
|
5
7
|
import type { ControllerTable } from '../component/table/controller.jsx';
|
|
6
8
|
import type { TypeTableCellRender } from './tableColumn.js';
|
|
@@ -10,12 +12,12 @@ export type TypeTable<TData extends {} = {}> = ReturnType<typeof useVueTable<TDa
|
|
|
10
12
|
export type TypeColumn<TData extends {} = {}> = ColumnDef<TData, any>;
|
|
11
13
|
|
|
12
14
|
export interface ITableMeta<TData extends {} = {}> {
|
|
13
|
-
properties:
|
|
15
|
+
properties: ISchemaObjectExtensionField[];
|
|
14
16
|
renders: Record<string, TypeTableCellRender<TData>>;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export type TypeTableGetColumnsNext<TData extends {} = {}> = (
|
|
18
|
-
properties?:
|
|
20
|
+
properties?: ISchemaObjectExtensionField[],
|
|
19
21
|
) => Promise<TypeColumn<TData>[]>;
|
|
20
22
|
|
|
21
23
|
export type TypeTableCreateColumnRender<TData extends {} = {}> = (
|