zova-module-a-table 5.1.12 → 5.1.16
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/cli/tableCell/boilerplate/{{sceneName}}.{{beanName}}.tsx_ +7 -6
- package/cli/tableCellActionRow/boilerplate/{{sceneName}}.{{beanName}}.tsx_ +19 -0
- package/dist/component/table/controller.d.ts +3 -7
- package/dist/component/table/controller.d.ts.map +1 -1
- package/dist/index.js +14 -43
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
- package/src/component/table/controller.tsx +25 -36
- package/cli/tableCell/metadata/generate.ts +0 -63
- package/cli/tableCell/metadata/utils.ts +0 -15
- package/cli/tsconfig.json +0 -8
- package/dist-cli/tableCell/metadata/generate.js +0 -55
- package/dist-cli/tableCell/metadata/utils.js +0 -14
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { IResourceTableCellOptionsBase } from 'zova-module-a-openapi';
|
|
2
2
|
|
|
3
3
|
import { BeanBase } from 'zova';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
4
|
+
import { TableCell, type IJsxRenderContextTableCell, type ITableCellRender, type NextTableCellRender } from 'zova-module-a-table';
|
|
5
|
+
|
|
6
|
+
declare module 'zova-module-a-openapi' {
|
|
7
|
+
export interface IResourceTableCellRecord {
|
|
8
|
+
'<%=argv.module%>:<%=argv.beanName%>'?: ITableCellOptions<%=argv.beanNameCapitalize%>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
10
11
|
|
|
11
12
|
export interface ITableCellOptions<%=argv.beanNameCapitalize%> extends IResourceTableCellOptionsBase {}
|
|
12
13
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IResourceTableActionRowOptionsBase } from 'zova-module-a-openapi';
|
|
2
|
+
|
|
3
|
+
import { BeanBase } from 'zova';
|
|
4
|
+
import { type IJsxRenderContextTableCell, type ITableCellRender, type NextTableCellRender, TableCell } from 'zova-module-a-table';
|
|
5
|
+
|
|
6
|
+
declare module 'zova-module-a-openapi' {
|
|
7
|
+
export interface IResourceTableActionRowRecord {
|
|
8
|
+
'<%=argv.module%>:<%=argv.beanName%>'?: ITableCellOptions<%=argv.beanNameCapitalize%>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ITableCellOptions<%=argv.beanNameCapitalize%> extends IResourceTableActionRowOptionsBase {}
|
|
13
|
+
|
|
14
|
+
@TableCell<ITableCellOptions<%=argv.beanNameCapitalize%>>()
|
|
15
|
+
export class TableCell<%=argv.beanNameCapitalize%> extends BeanBase implements ITableCellRender {
|
|
16
|
+
render(_options: ITableCellOptions<%=argv.beanNameCapitalize%>, _renderContext: IJsxRenderContextTableCell, next: NextTableCellRender) {
|
|
17
|
+
return next();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IResourceTableActionRowOptionsBase, TypeTableCellRenderComponent } from 'zova-module-a-openapi';
|
|
2
2
|
import { celEnvBase } from '@cabloy/utils';
|
|
3
3
|
import { CellContext } 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';
|
|
7
|
-
import { BeanResourceProviders } from 'zova-module-a-openapi';
|
|
8
7
|
import type { ITableMeta, TypeColumn, TypeTable, TypeTableGetColumns } from '../../types/table.js';
|
|
9
8
|
import type { IJsxRenderContextTableCell } from '../../types/tableCell.js';
|
|
10
9
|
import { BeanControllerTableBase } from '../../lib/beanControllerTableBase.js';
|
|
@@ -12,7 +11,6 @@ import { ITableCellRenderColumnOptions, type IJsxRenderContextTableColumn, type
|
|
|
12
11
|
export interface ControllerTableProps<TData extends {} = {}> {
|
|
13
12
|
data?: TData[];
|
|
14
13
|
schema?: SchemaObject;
|
|
15
|
-
tableProvider?: ITableProvider;
|
|
16
14
|
tableScope?: ITableScope;
|
|
17
15
|
getColumns?: TypeTableGetColumns<TData>;
|
|
18
16
|
slotDefault?: (table: ControllerTable<TData>) => VNode;
|
|
@@ -22,11 +20,9 @@ export declare class ControllerTable<TData extends {} = {}> extends BeanControll
|
|
|
22
20
|
properties: SchemaObject[] | undefined;
|
|
23
21
|
columns: TypeColumn<TData>[];
|
|
24
22
|
table: TypeTable<TData>;
|
|
25
|
-
tableProvider: ITableProvider;
|
|
26
23
|
tableMeta: ITableMeta<TData>;
|
|
27
24
|
zovaJsx: ZovaJsx;
|
|
28
25
|
columnCelEnv: typeof celEnvBase;
|
|
29
|
-
$$beanResourceProviders: BeanResourceProviders;
|
|
30
26
|
protected __init__(): Promise<void>;
|
|
31
27
|
get schema(): SchemaObject | undefined;
|
|
32
28
|
get data(): TData[] | undefined;
|
|
@@ -40,7 +36,7 @@ export declare class ControllerTable<TData extends {} = {}> extends BeanControll
|
|
|
40
36
|
getCellJsxRenderContext(celScope: ITableCellScope, cellContext: CellContext<TData, any>): IJsxRenderContextTableCell;
|
|
41
37
|
cellRenderPrepare(renders: TypeTableCellRenderComponent | TypeTableCellRenderComponent[]): Promise<any[]>;
|
|
42
38
|
private _createColumnRender;
|
|
43
|
-
cellRender(render: TypeTableCellRenderComponent, columnProps:
|
|
39
|
+
cellRender(render: TypeTableCellRenderComponent, columnProps: IResourceTableActionRowOptionsBase, renderContext: IJsxRenderContextTableCell): any;
|
|
44
40
|
private _cellRender;
|
|
45
41
|
private _cellRenderInner;
|
|
46
42
|
getColumnProperty(name: string): SchemaObject | undefined;
|
|
@@ -48,6 +44,6 @@ export declare class ControllerTable<TData extends {} = {}> extends BeanControll
|
|
|
48
44
|
getColumnScope(name: string, scopeExtra?: {}): ITableColumnScope;
|
|
49
45
|
getColumnComponentPropsTop(name: string, celScope: {}, renderContext: {}): ITableCellRenderColumnOptions;
|
|
50
46
|
private _getColumnComponentPropsTopByRest;
|
|
51
|
-
getRenderProvider(render: TypeTableCellRenderComponent | undefined):
|
|
47
|
+
getRenderProvider(render: TypeTableCellRenderComponent | undefined): TypeTableCellRenderComponent;
|
|
52
48
|
}
|
|
53
49
|
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/component/table/controller.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/component/table/controller.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kCAAkC,EAAmC,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAE/I,OAAO,EAAE,UAAU,EAAsB,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAqE,MAAM,qBAAqB,CAAC;AACrH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAE5B,OAAO,EAAkB,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,KAAK,EAA8B,0BAA0B,EAAoB,MAAM,0BAA0B,CAAC;AAEzH,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EACL,6BAA6B,EAC7B,KAAK,4BAA4B,EAEjC,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEjB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,oBAAoB,CAAC,KAAK,SAAS,EAAE,GAAG,EAAE;IACzD,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,UAAU,CAAC,EAAE,mB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AiB;IAQhE,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,GAAG,6BAA6B;IAM/G,OAAO,CAAC,iCAAiC;IAgBlC,iBAAiB,CAAC,MAAM,EAAE,4BAA4B,GAAG,SAAS,GAAG,4BAA4B;CAGzG"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { BeanControllerBase, BeanControllerPageBase, BeanInfo, BeanRenderBase, BeanScopeBase,
|
|
1
|
+
import { BeanControllerBase, BeanControllerPageBase, BeanInfo, BeanRenderBase, BeanScopeBase, appResource, cast, createBeanDecorator, deepEqual, deepExtend, objectAssignReactive, prepareComponentOptions, useController } from "zova";
|
|
2
2
|
import { celEnvBase, isNilOrEmptyString } from "@cabloy/utils";
|
|
3
3
|
import { FlexRender, createColumnHelper, getCoreRowModel, useVueTable } from "@tanstack/vue-table";
|
|
4
|
+
import { classes } from "typestyle";
|
|
4
5
|
import { ZovaJsx, isJsxComponent } from "zova-jsx";
|
|
5
6
|
import { Controller, Render, Scope } from "zova-module-a-bean";
|
|
6
7
|
import { createVNode, defineComponent, markRaw } from "vue";
|
|
@@ -17,43 +18,21 @@ var BeanControllerTableBase = class extends BeanControllerBase {
|
|
|
17
18
|
};
|
|
18
19
|
//#endregion
|
|
19
20
|
//#region src/component/table/controller.tsx
|
|
20
|
-
var _dec$2, _dec2$2,
|
|
21
|
-
|
|
22
|
-
r && Object.defineProperty(e, i, {
|
|
23
|
-
enumerable: r.enumerable,
|
|
24
|
-
configurable: r.configurable,
|
|
25
|
-
writable: r.writable,
|
|
26
|
-
value: r.initializer ? r.initializer.call(l) : void 0
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
function _applyDecoratedDescriptor(i, e, r, n, l) {
|
|
30
|
-
var a = {};
|
|
31
|
-
return Object.keys(n).forEach(function(i) {
|
|
32
|
-
a[i] = n[i];
|
|
33
|
-
}), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = !0), a = r.slice().reverse().reduce(function(r, n) {
|
|
34
|
-
return n(i, e, r) || r;
|
|
35
|
-
}, a), l && void 0 !== a.initializer && (a.value = a.initializer ? a.initializer.call(l) : void 0, a.initializer = void 0), void 0 === a.initializer ? (Object.defineProperty(i, e, a), null) : a;
|
|
36
|
-
}
|
|
37
|
-
var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-table" }), _dec3 = Use("a-openapi.bean.resourceProviders"), _dec4 = Reflect.metadata("design:type", typeof BeanResourceProviders === "undefined" ? Object : BeanResourceProviders), _dec$2(_class$2 = _dec2$2(_class$2 = (_class2 = (_ControllerTable = class ControllerTable extends BeanControllerTableBase {
|
|
21
|
+
var _dec$2, _dec2$2, _class$2, _ControllerTable;
|
|
22
|
+
var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-table" }), _dec$2(_class$2 = _dec2$2(_class$2 = (_ControllerTable = class ControllerTable extends BeanControllerTableBase {
|
|
38
23
|
constructor(...args) {
|
|
39
24
|
super(...args);
|
|
40
25
|
this.properties = void 0;
|
|
41
26
|
this.columns = void 0;
|
|
42
27
|
this.table = void 0;
|
|
43
|
-
this.tableProvider = void 0;
|
|
44
28
|
this.tableMeta = void 0;
|
|
45
29
|
this.zovaJsx = void 0;
|
|
46
30
|
this.columnCelEnv = void 0;
|
|
47
|
-
_initializerDefineProperty(this, "$$beanResourceProviders", _descriptor, this);
|
|
48
31
|
}
|
|
49
32
|
async __init__() {
|
|
50
33
|
this.bean._setBean("$$table", this);
|
|
51
|
-
this.tableProvider = this.$useComputed(() => {
|
|
52
|
-
const tableProvider = this.$$beanResourceProviders.tableProvider;
|
|
53
|
-
return this.$props.tableProvider ? deepExtend({}, tableProvider, this.$props.tableProvider) : tableProvider;
|
|
54
|
-
});
|
|
55
34
|
this.columnCelEnv = this._getColumnCelEnv();
|
|
56
|
-
this.zovaJsx = this.
|
|
35
|
+
this.zovaJsx = this.bean._newBeanSimple(ZovaJsx, false, void 0, this.columnCelEnv);
|
|
57
36
|
this._createProperties();
|
|
58
37
|
await this.refreshMeta();
|
|
59
38
|
this.$watch(() => this.$props.schema, async (newValue, oldValue) => {
|
|
@@ -118,7 +97,7 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
118
97
|
return columns;
|
|
119
98
|
}
|
|
120
99
|
_createProperties() {
|
|
121
|
-
this.properties = this.$
|
|
100
|
+
this.properties = this.$computed(() => {
|
|
122
101
|
return this.$sdk.loadSchemaProperties(this.schema, "table");
|
|
123
102
|
});
|
|
124
103
|
}
|
|
@@ -187,7 +166,6 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
187
166
|
beanInstance = await this.sys.bean._getBean(renderProvider, true);
|
|
188
167
|
const onionOptions = appResource.getBean(renderProvider)?.options;
|
|
189
168
|
columnProps = deepExtend({}, onionOptions, columnProps);
|
|
190
|
-
columnProps = this.zovaJsx.renderJsxProps(columnProps, {}, columnScope, renderContext);
|
|
191
169
|
if (beanInstance?.checkVisible && !await beanInstance.checkVisible(columnProps, renderContext)) return;
|
|
192
170
|
}
|
|
193
171
|
return (cellContext) => {
|
|
@@ -203,7 +181,6 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
203
181
|
beanInstance = this.sys.bean._getBeanSyncOnly(renderProvider);
|
|
204
182
|
const onionOptions = appResource.getBean(renderProvider)?.options;
|
|
205
183
|
columnProps = deepExtend({}, onionOptions, columnProps);
|
|
206
|
-
columnProps = this.zovaJsx.renderJsxProps(columnProps, {}, renderContext.$celScope, renderContext);
|
|
207
184
|
}
|
|
208
185
|
const cellProps = columnProps;
|
|
209
186
|
return this._cellRender(render, columnProps, void 0, renderContext.cellContext, renderProvider, beanInstance, cellProps, cellScope, renderContext);
|
|
@@ -226,7 +203,12 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
226
203
|
if (!jsxRenderContext) jsxRenderContext = this.getCellJsxRenderContext(cellScope, cellContext);
|
|
227
204
|
if (beanInstance) {
|
|
228
205
|
if (!cellProps) cellProps = columnProps;
|
|
229
|
-
|
|
206
|
+
const cellProps2 = this.zovaJsx.renderJsxProps(cellProps, {}, cellScope, jsxRenderContext);
|
|
207
|
+
if (cellProps2.class || cellProps2.style) {
|
|
208
|
+
cellProps2.class = classes(cellProps2.class, jsxRenderContext.$host.$style(cellProps2.style));
|
|
209
|
+
delete cellProps2.style;
|
|
210
|
+
}
|
|
211
|
+
return beanInstance.render(cellProps2, jsxRenderContext, () => {
|
|
230
212
|
const children = isJsxComponent(render) && cast(render).children;
|
|
231
213
|
if (children && children.length > 0) return this.zovaJsx.renderJsxChildrenDirect(children, cellScope, jsxRenderContext);
|
|
232
214
|
else return value;
|
|
@@ -267,20 +249,9 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
|
|
|
267
249
|
};
|
|
268
250
|
}
|
|
269
251
|
getRenderProvider(render) {
|
|
270
|
-
|
|
271
|
-
if (typeof render === "string") {
|
|
272
|
-
const render2 = this.tableProvider.components?.[render];
|
|
273
|
-
if (!render2) throw new Error(`not found table cell component of: ${render}`);
|
|
274
|
-
return render2;
|
|
275
|
-
}
|
|
276
|
-
return render;
|
|
252
|
+
return render || "text";
|
|
277
253
|
}
|
|
278
|
-
}, _ControllerTable.$propsDefault = {}, _ControllerTable)
|
|
279
|
-
configurable: true,
|
|
280
|
-
enumerable: true,
|
|
281
|
-
writable: true,
|
|
282
|
-
initializer: null
|
|
283
|
-
}), _class2)) || _class$2) || _class$2);
|
|
254
|
+
}, _ControllerTable.$propsDefault = {}, _ControllerTable)) || _class$2) || _class$2);
|
|
284
255
|
//#endregion
|
|
285
256
|
//#region src/component/table/render.tsx
|
|
286
257
|
var _dec$1, _dec2$1, _class$1;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["celEnvBase","isNilOrEmptyString","createColumnHelper","getCoreRowModel","appResource","cast","deepEqual","deepExtend","objectAssignReactive","Use","isJsxComponent","ZovaJsx","Controller","BeanControllerTableBase","ControllerTable","_dec","_dec2","__z_BeanInfo","module","_dec3","_dec4","Reflect","metadata","BeanResourceProviders","Object","_class","_class2","_ControllerTable","constructor","args","properties","columns","table","tableProvider","tableMeta","zovaJsx","columnCelEnv","_initializerDefineProperty","_descriptor","__init__","bean","_setBean","$useComputed","$$beanResourceProviders","$props","_getColumnCelEnv","app","_newBeanSimple","components","_createProperties","refreshMeta","$watch","schema","newValue","oldValue","_createTable","data","_createTableMeta","_createColumns","self","tableOptions","getRowId","row","id","renderFallbackValue","scope","config","manualPagination","$useTable","getColumns","_createColumnsMiddle","key","render","columnScope","getColumnScope","jsxRenderContext","getColumnJsxRenderContext","visible","columnProps","getColumnComponentPropsTop","_createColumnRender","columnHelper","property","push","accessor","header","_props","title","cell","props","renders","$sdk","loadSchemaProperties","promises","res","Promise","all","filter","_item","index","item","forEach","celScope","ctx","$scene","$host","$celScope","$jsx","$$table","getCellJsxRenderContext","cellContext","cellRenderPrepare","Array","isArray","renderProviders","map","getRenderProvider","renderProvider","includes","sys","_getBean","renderContext","beanInstance","beanOptions","getBean","onionOptions","options","renderJsxProps","checkVisible","_cellRender","undefined","cellRender","cellScope","_getBeanSyncOnly","cellProps","setTransientObject","getValue","name","_cellRenderInner","value","fallbackValue","children","length","renderJsxChildrenDirect","getColumnProperty","find","celEnv","clone","registerFunction","transientObject","scopeExtra","tableScope","rest","_getColumnComponentPropsTopByRest","_renderContext","evaluateExpression","assign","render2","Error","$propsDefault","_applyDecoratedDescriptor","prototype","configurable","enumerable","writable","initializer","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 type { RowData, Table } from '@tanstack/table-core';\nimport type { TableOptionsWithReactiveData } from '@tanstack/vue-table';\n\nimport { useVueTable } from '@tanstack/vue-table';\nimport { markRaw } from 'vue';\nimport { BeanControllerBase } from 'zova';\n\nexport class BeanControllerTableBase extends BeanControllerBase {\n public $useTable<TData extends RowData>(initialOptions: TableOptionsWithReactiveData<TData>): Table<TData> {\n return this.ctx.util.instanceScope(() => {\n return markRaw(useVueTable(initialOptions));\n });\n }\n\n public async refreshMeta() {\n throw new Error('should implement refreshMeta');\n }\n}\n","import type {\n IResourceActionRowOptionsBase,\n ISchemaObjectExtensionFieldRest,\n ITableProvider,\n TypeTableCellRenderComponent,\n TypeTableCellRenderComponentProvider,\n} from 'zova-module-a-openapi';\n\nimport { celEnvBase, isNilOrEmptyString } from '@cabloy/utils';\nimport { CellContext, createColumnHelper, getCoreRowModel, TableOptionsWithReactiveData } from '@tanstack/vue-table';\nimport { SchemaObject } from 'openapi3-ts/oas31';\nimport { VNode } from 'vue';\nimport { appResource, cast, deepEqual, deepExtend, objectAssignReactive, Use } from 'zova';\nimport { isJsxComponent, ZovaJsx } from 'zova-jsx';\nimport { Controller } from 'zova-module-a-bean';\nimport { BeanResourceProviders } from 'zova-module-a-openapi';\n\nimport type { ITableMeta, TypeColumn, TypeTable, TypeTableGetColumns } from '../../types/table.js';\nimport type { IDecoratorTableCellOptions, IJsxRenderContextTableCell, ITableCellRender } from '../../types/tableCell.js';\n\nimport { BeanControllerTableBase } from '../../lib/beanControllerTableBase.js';\nimport {\n ITableCellRenderColumnOptions,\n type IJsxRenderContextTableColumn,\n type ITableCellRenderColumnProps,\n type ITableCellScope,\n type ITableColumnScope,\n type ITableScope,\n type TypeTableCellRender,\n} from '../../types/tableColumn.js';\n\nexport interface ControllerTableProps<TData extends {} = {}> {\n data?: TData[];\n schema?: SchemaObject;\n tableProvider?: ITableProvider;\n tableScope?: ITableScope;\n getColumns?: TypeTableGetColumns<TData>;\n slotDefault?: (table: ControllerTable<TData>) => VNode;\n}\n\n@Controller()\nexport class ControllerTable<TData extends {} = {}> extends BeanControllerTableBase {\n static $propsDefault = {};\n\n properties: SchemaObject[] | undefined;\n columns: TypeColumn<TData>[];\n table: TypeTable<TData>;\n tableProvider: ITableProvider;\n tableMeta: ITableMeta<TData>;\n zovaJsx: ZovaJsx;\n columnCelEnv: typeof celEnvBase;\n\n @Use()\n $$beanResourceProviders: BeanResourceProviders;\n\n protected async __init__() {\n this.bean._setBean('$$table', this);\n this.tableProvider = this.$useComputed(() => {\n const tableProvider = this.$$beanResourceProviders.tableProvider;\n return this.$props.tableProvider ? deepExtend({}, tableProvider, this.$props.tableProvider) : tableProvider;\n });\n // jsx\n this.columnCelEnv = this._getColumnCelEnv();\n this.zovaJsx = this.app.bean._newBeanSimple(ZovaJsx, false, this.tableProvider.components, 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 get schema() {\n return this.$props.schema;\n }\n\n 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: (row: TData) => cast(row).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 (key: string, render: TypeTableCellRenderComponent): 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(key, columnScope, jsxRenderContext);\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(properties: SchemaObject[]): 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.$useComputed(() => {\n return this.$sdk.loadSchemaProperties(this.schema, 'table');\n });\n }\n\n private async _createTableMeta() {\n let properties: SchemaObject[] = [];\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(key, columnScope, jsxRenderContext);\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(celScope: ITableCellScope, cellContext: CellContext<TData, any>): 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(renders: TypeTableCellRenderComponent | TypeTableCellRenderComponent[]) {\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.sys.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.sys.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 columnProps = this.zovaJsx.renderJsxProps(columnProps as any, {}, columnScope, renderContext) as any;\n if (beanInstance?.checkVisible && !(await beanInstance.checkVisible(columnProps as any, renderContext))) return;\n }\n return cellContext => {\n if (!cellContext) return;\n return this._cellRender(render, columnProps, columnScope, cellContext, renderProvider, beanInstance, undefined, undefined, undefined);\n };\n }\n\n public cellRender(render: TypeTableCellRenderComponent, columnProps: IResourceActionRowOptionsBase, renderContext: IJsxRenderContextTableCell) {\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.sys.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 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') {\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(cellProps, {}, cellScope, jsxRenderContext);\n return beanInstance.render(cellProps, 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): SchemaObject | 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);\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(name: string, celScope: {}, renderContext: {}): 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(render: TypeTableCellRenderComponent | undefined): TypeTableCellRenderComponentProvider {\n if (!render) return 'text';\n if (typeof render === 'string') {\n const render2 = this.tableProvider.components?.[render];\n if (!render2) throw new Error(`not found table cell component of: ${render}`);\n return render2;\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 type { TypeControllerInnerProps } from 'zova';\n\nimport { defineComponent } from 'vue';\nimport { prepareComponentOptions, useController } from 'zova';\n\nimport type { ControllerTableProps } from '../../component/table/controller.jsx';\n\nimport { ControllerTable } from '../../component/table/controller.jsx';\nimport { RenderTable } from '../../component/table/render.jsx';\nexport type TypeControllerTablePublicProps<TData extends {} = {}> = {\n controllerRef?: (ref: ControllerTable<TData>) => void;\n} & ControllerTableProps<TData>;\n\ntype ControllerInnerProps<TData extends {} = {}> = TypeControllerInnerProps<\n ControllerTableProps<TData>,\n keyof typeof ControllerTable.$propsDefault\n>;\ndeclare module 'zova-module-a-table' {\n export interface ControllerTable<TData extends {} = {}> {\n $props: ControllerInnerProps<TData>;\n }\n}\ndeclare module 'zova-module-a-table' {\n export interface RenderTable<TData extends {} = {}> extends ControllerTable<TData> {}\n}\nexport const ZTable = defineComponent(\n <TData extends {} = {}>(_props: TypeControllerTablePublicProps<TData>) => {\n useController(ControllerTable, RenderTable, undefined);\n return () => {};\n },\n prepareComponentOptions(),\n);\ndeclare module 'zova-module-a-bean' {\n export interface IVonaComponentRecord {\n 'a-table:table': ControllerTableProps;\n }\n}\n","import type { ZovaSys } from 'zova';\n\nexport const config = (_sys: ZovaSys) => {\n return {\n renderFallbackValue: '--',\n };\n};\n","// eslint-disable\n/** controller: begin */\nexport * from '../component/table/controller.jsx';\n\nimport 'zova';\ndeclare module 'zova' {\n \n \n}\ndeclare module 'zova-module-a-table' {\n \n export interface ControllerTable {\n /** @internal */\n get scope(): ScopeModuleATable;\n } \n}\n/** controller: end */\n/** controller: begin */\nimport { ControllerTable } from '../component/table/controller.jsx';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordLocal {\n 'a-table.controller.table': ControllerTable;\n }\n}\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';\ndeclare module 'zova' {\nexport interface IComponentRecord {\n 'a-table:table': ControllerTable;\n}\nexport interface IZovaComponentRecord {\n 'a-table:table': typeof ZTable;\n}\n}\n/** components: end */\n/** render: begin */\nexport * from '../component/table/render.jsx';\n\nimport 'zova';\ndeclare module 'zova' {\n \n \n}\ndeclare module 'zova-module-a-table' {\n \n export interface RenderTable {\n /** @internal */\n get scope(): ScopeModuleATable;\n } \n}\n/** render: end */\n/** render: begin */\nimport { RenderTable } from '../component/table/render.jsx';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordLocal {\n 'a-table.render.table': RenderTable;\n }\n}\n/** render: end */\n/** config: begin */\nexport * from '../config/config.js';\nimport { config } from '../config/config.js';\n/** config: end */\n/** scope: begin */\nimport { BeanScopeBase, type BeanScopeUtil, TypeModuleConfig } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\n\n@Scope()\nexport class ScopeModuleATable extends BeanScopeBase {}\n\nexport interface ScopeModuleATable {\n util: BeanScopeUtil;\nconfig: TypeModuleConfig<typeof config>;\n}\n\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanScopeRecord {\n 'a-table': ScopeModuleATable;\n }\n \n export interface IBeanScopeConfig {\n 'a-table': ReturnType<typeof config>;\n }\n\n \n\n \n}\n \n/** scope: end */\n","import type { RowData, Table } from '@tanstack/table-core';\nimport type { TableOptionsWithReactiveData } from '@tanstack/vue-table';\n\nimport { useVueTable } from '@tanstack/vue-table';\nimport { markRaw } from 'vue';\nimport { BeanControllerPageBase } from 'zova';\n\nexport class BeanControllerPageTableBase extends BeanControllerPageBase {\n public $useTable<TData extends RowData>(initialOptions: TableOptionsWithReactiveData<TData>): Table<TData> {\n return this.ctx.util.instanceScope(() => {\n return markRaw(useVueTable(initialOptions));\n });\n }\n\n public async refreshMeta() {\n throw new Error('should implement refreshMeta');\n }\n}\n","import { createBeanDecorator } from 'zova';\n\nimport type { IDecoratorTableCellOptions } from '../types/tableCell.js';\n\nexport function TableCell<T extends IDecoratorTableCellOptions>(options?: T): ClassDecorator {\n return createBeanDecorator('tableCell', 'sys', true, options);\n}\n"],"mappings":";;;;;;;AAGA,IAAS,0BAAT,cAA2C,mBAAM;CACjD,UAAS,gBAAmB;AAC5B,SAAS,KAAA,IAAA,KAAA,oBAAgC;;IAEn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SAAQ;AACjC,WAAAZ,YAAA,MAAA,EAAA,OACWY,KAAKR,IAAE,EAAA,CAAAJ,YAAAX,YAAA;KAAA,UAEJuB,KAAKP,OAAOC,UAAUM;KAAI,SAC3BA,KAAKL,YAAW;KAAC,EAAA,KAAA,CAAA,CAAA;KAI9B,CAAA,CAAA;IAGN,CAAA,CAAA,CAAA,CAAA;;CAMHM,SAAS;AACd,SAAO,KAAKC,eAAe,KAAKA,aAAa,KAAK,GAAG,KAAKhB,qBAAqB;;EAElF,IAAAD,SAAA,IAAAA;;;;AC5CD,eAAc,iBAAA,aAAgC,KAAA,EAAG;;GAEjD,yBAA2B,CAAA;;;ACP3B,IAAa,UAAS,SAAQ;UAE9B,qBAAuB,MACrB;;;;;;ACHF,IAAG,MAAO,OAAA;AAeV,IAAA,aAAA,EACE,SAAE,QACH;AAiBD,IAAQ,qBAAc,OAAA,OAAA,EAAA,QAAA,SAAA,EACtB,QAAO,WACN,CAAC,EAAE,KAAC,SAAa,MAAC,SAAA,MAAe,0BAAA,cAAA,GAAA,IAAA,OAAA,IAAA;;;;ACjClC,IAAS,8BAAT,cAAiD,uBAAA;CACjD,UAAS,gBAAmB;AAC5B,SAAS,KAAA,IAAA,KAAA,oBAAoC;;IAEvC;;CAEJ,MAAE,cAAgB;AAChB,QAAE,IAAO,MAAO,+BAA6B;;;;;;ACRjD,QAAO,oBAAO,aAA4B,OAAO,MAAG,QAAM"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["celEnvBase","isNilOrEmptyString","createColumnHelper","getCoreRowModel","classes","appResource","cast","deepEqual","deepExtend","objectAssignReactive","isJsxComponent","ZovaJsx","Controller","BeanControllerTableBase","ControllerTable","_dec","_dec2","__z_BeanInfo","module","_class","_ControllerTable","constructor","args","properties","columns","table","tableMeta","zovaJsx","columnCelEnv","__init__","bean","_setBean","_getColumnCelEnv","_newBeanSimple","undefined","_createProperties","refreshMeta","$watch","$props","schema","newValue","oldValue","_createTable","data","_createTableMeta","_createColumns","self","tableOptions","getRowId","row","id","renderFallbackValue","scope","config","manualPagination","$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","sys","_getBean","renderContext","beanInstance","beanOptions","getBean","onionOptions","options","checkVisible","_cellRender","cellRender","cellScope","_getBeanSyncOnly","cellProps","setTransientObject","getValue","name","_cellRenderInner","value","fallbackValue","cellProps2","renderJsxProps","class","style","$style","children","length","renderJsxChildrenDirect","getColumnProperty","find","celEnv","clone","registerFunction","transientObject","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 type { RowData, Table } from '@tanstack/table-core';\nimport type { TableOptionsWithReactiveData } from '@tanstack/vue-table';\n\nimport { useVueTable } from '@tanstack/vue-table';\nimport { markRaw } from 'vue';\nimport { BeanControllerBase } from 'zova';\n\nexport class BeanControllerTableBase extends BeanControllerBase {\n public $useTable<TData extends RowData>(initialOptions: TableOptionsWithReactiveData<TData>): Table<TData> {\n return this.ctx.util.instanceScope(() => {\n return markRaw(useVueTable(initialOptions));\n });\n }\n\n public async refreshMeta() {\n throw new Error('should implement refreshMeta');\n }\n}\n","import type { IResourceTableActionRowOptionsBase, ISchemaObjectExtensionFieldRest, TypeTableCellRenderComponent } from 'zova-module-a-openapi';\n\nimport { celEnvBase, isNilOrEmptyString } from '@cabloy/utils';\nimport { CellContext, createColumnHelper, getCoreRowModel, TableOptionsWithReactiveData } from '@tanstack/vue-table';\nimport { SchemaObject } from 'openapi3-ts/oas31';\nimport { classes } from 'typestyle';\nimport { VNode } from 'vue';\nimport { appResource, cast, deepEqual, deepExtend, objectAssignReactive } from 'zova';\nimport { isJsxComponent, ZovaJsx } from 'zova-jsx';\nimport { Controller } from 'zova-module-a-bean';\n\nimport type { ITableMeta, TypeColumn, TypeTable, TypeTableGetColumns } from '../../types/table.js';\nimport type { IDecoratorTableCellOptions, IJsxRenderContextTableCell, ITableCellRender } from '../../types/tableCell.js';\n\nimport { BeanControllerTableBase } from '../../lib/beanControllerTableBase.js';\nimport {\n ITableCellRenderColumnOptions,\n type IJsxRenderContextTableColumn,\n type ITableCellRenderColumnProps,\n type ITableCellScope,\n type ITableColumnScope,\n type ITableScope,\n type TypeTableCellRender,\n} 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}\n\n@Controller()\nexport class ControllerTable<TData extends {} = {}> extends BeanControllerTableBase {\n static $propsDefault = {};\n\n properties: SchemaObject[] | undefined;\n columns: TypeColumn<TData>[];\n table: TypeTable<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 get schema() {\n return this.$props.schema;\n }\n\n 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: (row: TData) => cast(row).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 (key: string, render: TypeTableCellRenderComponent): 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(key, columnScope, jsxRenderContext);\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(properties: SchemaObject[]): 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: SchemaObject[] = [];\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(key, columnScope, jsxRenderContext);\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(celScope: ITableCellScope, cellContext: CellContext<TData, any>): 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(renders: TypeTableCellRenderComponent | TypeTableCellRenderComponent[]) {\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.sys.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.sys.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 (beanInstance?.checkVisible && !(await beanInstance.checkVisible(columnProps as any, renderContext))) return;\n }\n return cellContext => {\n if (!cellContext) return;\n return this._cellRender(render, columnProps, columnScope, cellContext, renderProvider, beanInstance, undefined, undefined, undefined);\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.sys.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: TypeTableCellRenderComponent,\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: TypeTableCellRenderComponent,\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(cellProps, {}, cellScope, jsxRenderContext) as any;\n if (cellProps2.class || cellProps2.style) {\n cellProps2.class = classes(cellProps2.class, jsxRenderContext.$host.$style(cellProps2.style));\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): SchemaObject | 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);\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(name: string, celScope: {}, renderContext: {}): 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(render: TypeTableCellRenderComponent | undefined): TypeTableCellRenderComponent {\n return render || ('text' as TypeTableCellRenderComponent);\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 type { TypeControllerInnerProps } from 'zova';\n\nimport { defineComponent } from 'vue';\nimport { prepareComponentOptions, useController } from 'zova';\n\nimport type { ControllerTableProps } from '../../component/table/controller.jsx';\n\nimport { ControllerTable } from '../../component/table/controller.jsx';\nimport { RenderTable } from '../../component/table/render.jsx';\nexport type TypeControllerTablePublicProps<TData extends {} = {}> = {\n controllerRef?: (ref: ControllerTable<TData>) => void;\n} & ControllerTableProps<TData>;\n\ntype ControllerInnerProps<TData extends {} = {}> = TypeControllerInnerProps<\n ControllerTableProps<TData>,\n keyof typeof ControllerTable.$propsDefault\n>;\ndeclare module 'zova-module-a-table' {\n export interface ControllerTable<TData extends {} = {}> {\n $props: ControllerInnerProps<TData>;\n }\n}\ndeclare module 'zova-module-a-table' {\n export interface RenderTable<TData extends {} = {}> extends ControllerTable<TData> {}\n}\nexport const ZTable = defineComponent(\n <TData extends {} = {}>(_props: TypeControllerTablePublicProps<TData>) => {\n useController(ControllerTable, RenderTable, undefined);\n return () => {};\n },\n prepareComponentOptions(),\n);\ndeclare module 'zova-module-a-bean' {\n export interface IVonaComponentRecord {\n 'a-table:table': ControllerTableProps;\n }\n}\n","import type { ZovaSys } from 'zova';\n\nexport const config = (_sys: ZovaSys) => {\n return {\n renderFallbackValue: '--',\n };\n};\n","// eslint-disable\n/** controller: begin */\nexport * from '../component/table/controller.jsx';\n\nimport 'zova';\ndeclare module 'zova' {\n \n \n}\ndeclare module 'zova-module-a-table' {\n \n export interface ControllerTable {\n /** @internal */\n get scope(): ScopeModuleATable;\n } \n}\n/** controller: end */\n/** controller: begin */\nimport { ControllerTable } from '../component/table/controller.jsx';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordLocal {\n 'a-table.controller.table': ControllerTable;\n }\n}\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';\ndeclare module 'zova' {\nexport interface IComponentRecord {\n 'a-table:table': ControllerTable;\n}\nexport interface IZovaComponentRecord {\n 'a-table:table': typeof ZTable;\n}\n}\n/** components: end */\n/** render: begin */\nexport * from '../component/table/render.jsx';\n\nimport 'zova';\ndeclare module 'zova' {\n \n \n}\ndeclare module 'zova-module-a-table' {\n \n export interface RenderTable {\n /** @internal */\n get scope(): ScopeModuleATable;\n } \n}\n/** render: end */\n/** render: begin */\nimport { RenderTable } from '../component/table/render.jsx';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordLocal {\n 'a-table.render.table': RenderTable;\n }\n}\n/** render: end */\n/** config: begin */\nexport * from '../config/config.js';\nimport { config } from '../config/config.js';\n/** config: end */\n/** scope: begin */\nimport { BeanScopeBase, type BeanScopeUtil, TypeModuleConfig } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\n\n@Scope()\nexport class ScopeModuleATable extends BeanScopeBase {}\n\nexport interface ScopeModuleATable {\n util: BeanScopeUtil;\nconfig: TypeModuleConfig<typeof config>;\n}\n\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanScopeRecord {\n 'a-table': ScopeModuleATable;\n }\n \n export interface IBeanScopeConfig {\n 'a-table': ReturnType<typeof config>;\n }\n\n \n\n \n}\n \n/** scope: end */\n","import type { RowData, Table } from '@tanstack/table-core';\nimport type { TableOptionsWithReactiveData } from '@tanstack/vue-table';\n\nimport { useVueTable } from '@tanstack/vue-table';\nimport { markRaw } from 'vue';\nimport { BeanControllerPageBase } from 'zova';\n\nexport class BeanControllerPageTableBase extends BeanControllerPageBase {\n public $useTable<TData extends RowData>(initialOptions: TableOptionsWithReactiveData<TData>): Table<TData> {\n return this.ctx.util.instanceScope(() => {\n return markRaw(useVueTable(initialOptions));\n });\n }\n\n public async refreshMeta() {\n throw new Error('should implement refreshMeta');\n }\n}\n","import { createBeanDecorator } from 'zova';\n\nimport type { IDecoratorTableCellOptions } from '../types/tableCell.js';\n\nexport function TableCell<T extends IDecoratorTableCellOptions>(options?: T): ClassDecorator {\n return createBeanDecorator('tableCell', 'sys', true, options);\n}\n"],"mappings":";;;;;;;;AAGA,IAAS,0BAAT,cAA2C,mBAAM;CACjD,UAAS,gBAAmB;AAC5B,SAAS,KAAA,IAAA,KAAA,oBAAgC;;IAEnC;;CAEJ,MAAE,cAAgB;AAChB,QAAE,IAAO,MAAO,+BAA6B;;;;;;ACuBjD,IACac,mBAAeC,SAD3BH,YAAY,EAAAI,UAAAC,SAAA,EAAAC,QAAA,WAAA,CAAA,EAAAH,OAAAI,WAAAH,QAAAG,YAAAC,mBAAb,MACaN,wBAA+CD,wBAAwB;CAAAQ,YAAA,GAAAC,MAAA;AAAA,QAAA,GAAAA,KAAA;AAAA,OAGlFC,aAAU,KAAA;AAAA,OACVC,UAAO,KAAA;AAAA,OACPC,QAAK,KAAA;AAAA,OACLC,YAAS,KAAA;AAAA,OACTC,UAAO,KAAA;AAAA,OACPC,eAAY,KAAA;;CAEZ,MAAgBC,WAAW;AACzB,OAAKC,KAAKC,SAAS,WAAW,KAAK;AAEnC,OAAKH,eAAe,KAAKI,kBAAkB;AAC3C,OAAKL,UAAU,KAAKG,KAAKG,eAAetB,SAAS,OAAOuB,KAAAA,GAAW,KAAKN,aAAa;AAErF,OAAKO,mBAAmB;AAExB,QAAM,KAAKC,aAAa;AAExB,OAAKC,aACG,KAAKC,OAAOC,QAClB,OAAOC,UAAUC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AA;KAAA,UAEJuB,KAAKP,OAAOC,UAAUM;KAAI,SAC3BA,KAAKL,YAAW;KAAC,EAAA,KAAA,CAAA,CAAA;KAI9B,CAAA,CAAA;IAGN,CAAA,CAAA,CAAA,CAAA;;CAMHM,SAAS;AACd,SAAO,KAAKC,eAAe,KAAKA,aAAa,KAAK,GAAG,KAAKhB,qBAAqB;;EAElF,IAAAD,SAAA,IAAAA;;;;AC5CD,eAAc,iBAAA,aAAgC,KAAA,EAAG;;GAEjD,yBAA2B,CAAA;;;ACP3B,IAAa,UAAS,SAAQ;UAE9B,qBAAuB,MACrB;;;;;;ACHF,IAAG,MAAO,OAAA;AAeV,IAAA,aAAA,EACE,SAAE,QACH;AAiBD,IAAQ,qBAAc,OAAA,OAAA,EAAA,QAAA,SAAA,EACtB,QAAO,WACN,CAAC,EAAE,KAAC,SAAa,MAAC,SAAA,MAAe,0BAAA,cAAA,GAAA,IAAA,OAAA,IAAA;;;;ACjClC,IAAS,8BAAT,cAAiD,uBAAA;CACjD,UAAS,gBAAmB;AAC5B,SAAS,KAAA,IAAA,KAAA,oBAAoC;;IAEvC;;CAEJ,MAAE,cAAgB;AAChB,QAAE,IAAO,MAAO,+BAA6B;;;;;;ACRjD,QAAO,oBAAO,aAA4B,OAAO,MAAG,QAAM"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zova-module-a-table",
|
|
3
|
-
"version": "5.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "5.1.16",
|
|
4
|
+
"gitHead": "f5fbd410ec433943070bb60839f1e762f98593c6",
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Zova Module"
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
"rest",
|
|
15
15
|
"src",
|
|
16
16
|
"icons",
|
|
17
|
-
"assets"
|
|
18
|
-
"dist-cli"
|
|
17
|
+
"assets"
|
|
19
18
|
],
|
|
20
19
|
"type": "module",
|
|
21
20
|
"exports": {
|
|
@@ -26,8 +25,8 @@
|
|
|
26
25
|
"./*": "./*"
|
|
27
26
|
},
|
|
28
27
|
"scripts": {
|
|
29
|
-
"clean": "rimraf dist
|
|
30
|
-
"tsc:publish": "npm run clean && zova :bin:buildModule --sourcemap && tsc -p tsconfig.build.json
|
|
28
|
+
"clean": "rimraf dist tsconfig.build.tsbuildinfo",
|
|
29
|
+
"tsc:publish": "npm run clean && zova :bin:buildModule --sourcemap && tsc -p tsconfig.build.json",
|
|
31
30
|
"prepublishOnly": "npm run tsc:publish",
|
|
32
31
|
"prepack": "clean-package",
|
|
33
32
|
"postpack": "clean-package restore && npm run clean"
|
|
@@ -59,7 +58,7 @@
|
|
|
59
58
|
"optionsGlobalInterfaceName": "IDecoratorTableCellOptions",
|
|
60
59
|
"optionsGlobalInterfaceFrom": "zova-module-a-table",
|
|
61
60
|
"boilerplate": "tableCell/boilerplate",
|
|
62
|
-
"
|
|
61
|
+
"boilerplateActionRow": "tableCellActionRow/boilerplate"
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
IResourceActionRowOptionsBase,
|
|
3
|
-
ISchemaObjectExtensionFieldRest,
|
|
4
|
-
ITableProvider,
|
|
5
|
-
TypeTableCellRenderComponent,
|
|
6
|
-
TypeTableCellRenderComponentProvider,
|
|
7
|
-
} from 'zova-module-a-openapi';
|
|
1
|
+
import type { IResourceTableActionRowOptionsBase, ISchemaObjectExtensionFieldRest, TypeTableCellRenderComponent } from 'zova-module-a-openapi';
|
|
8
2
|
|
|
9
3
|
import { celEnvBase, isNilOrEmptyString } from '@cabloy/utils';
|
|
10
4
|
import { CellContext, createColumnHelper, getCoreRowModel, TableOptionsWithReactiveData } from '@tanstack/vue-table';
|
|
11
5
|
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
6
|
+
import { classes } from 'typestyle';
|
|
12
7
|
import { VNode } from 'vue';
|
|
13
|
-
import { appResource, cast, deepEqual, deepExtend, objectAssignReactive
|
|
8
|
+
import { appResource, cast, deepEqual, deepExtend, objectAssignReactive } from 'zova';
|
|
14
9
|
import { isJsxComponent, ZovaJsx } from 'zova-jsx';
|
|
15
10
|
import { Controller } from 'zova-module-a-bean';
|
|
16
|
-
import { BeanResourceProviders } from 'zova-module-a-openapi';
|
|
17
11
|
|
|
18
12
|
import type { ITableMeta, TypeColumn, TypeTable, TypeTableGetColumns } from '../../types/table.js';
|
|
19
13
|
import type { IDecoratorTableCellOptions, IJsxRenderContextTableCell, ITableCellRender } from '../../types/tableCell.js';
|
|
@@ -32,7 +26,6 @@ import {
|
|
|
32
26
|
export interface ControllerTableProps<TData extends {} = {}> {
|
|
33
27
|
data?: TData[];
|
|
34
28
|
schema?: SchemaObject;
|
|
35
|
-
tableProvider?: ITableProvider;
|
|
36
29
|
tableScope?: ITableScope;
|
|
37
30
|
getColumns?: TypeTableGetColumns<TData>;
|
|
38
31
|
slotDefault?: (table: ControllerTable<TData>) => VNode;
|
|
@@ -45,23 +38,15 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
45
38
|
properties: SchemaObject[] | undefined;
|
|
46
39
|
columns: TypeColumn<TData>[];
|
|
47
40
|
table: TypeTable<TData>;
|
|
48
|
-
tableProvider: ITableProvider;
|
|
49
41
|
tableMeta: ITableMeta<TData>;
|
|
50
42
|
zovaJsx: ZovaJsx;
|
|
51
43
|
columnCelEnv: typeof celEnvBase;
|
|
52
44
|
|
|
53
|
-
@Use()
|
|
54
|
-
$$beanResourceProviders: BeanResourceProviders;
|
|
55
|
-
|
|
56
45
|
protected async __init__() {
|
|
57
46
|
this.bean._setBean('$$table', this);
|
|
58
|
-
this.tableProvider = this.$useComputed(() => {
|
|
59
|
-
const tableProvider = this.$$beanResourceProviders.tableProvider;
|
|
60
|
-
return this.$props.tableProvider ? deepExtend({}, tableProvider, this.$props.tableProvider) : tableProvider;
|
|
61
|
-
});
|
|
62
47
|
// jsx
|
|
63
48
|
this.columnCelEnv = this._getColumnCelEnv();
|
|
64
|
-
this.zovaJsx = this.
|
|
49
|
+
this.zovaJsx = this.bean._newBeanSimple(ZovaJsx, false, undefined, this.columnCelEnv);
|
|
65
50
|
// properties
|
|
66
51
|
this._createProperties();
|
|
67
52
|
// tableMeta/columns
|
|
@@ -151,7 +136,7 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
151
136
|
}
|
|
152
137
|
|
|
153
138
|
private _createProperties() {
|
|
154
|
-
this.properties = this.$
|
|
139
|
+
this.properties = this.$computed(() => {
|
|
155
140
|
return this.$sdk.loadSchemaProperties(this.schema, 'table');
|
|
156
141
|
});
|
|
157
142
|
}
|
|
@@ -238,7 +223,8 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
238
223
|
const beanOptions = appResource.getBean(renderProvider as any);
|
|
239
224
|
const onionOptions = beanOptions?.options as IDecoratorTableCellOptions | undefined;
|
|
240
225
|
columnProps = deepExtend({}, onionOptions, columnProps);
|
|
241
|
-
|
|
226
|
+
// should not eval jsx columnProps
|
|
227
|
+
// columnProps = this.zovaJsx.renderJsxProps(columnProps as any, {}, columnScope, renderContext) as any;
|
|
242
228
|
if (beanInstance?.checkVisible && !(await beanInstance.checkVisible(columnProps as any, renderContext))) return;
|
|
243
229
|
}
|
|
244
230
|
return cellContext => {
|
|
@@ -247,7 +233,11 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
247
233
|
};
|
|
248
234
|
}
|
|
249
235
|
|
|
250
|
-
public cellRender(
|
|
236
|
+
public cellRender(
|
|
237
|
+
render: TypeTableCellRenderComponent,
|
|
238
|
+
columnProps: IResourceTableActionRowOptionsBase,
|
|
239
|
+
renderContext: IJsxRenderContextTableCell,
|
|
240
|
+
) {
|
|
251
241
|
// render
|
|
252
242
|
const cellScope = renderContext.$celScope;
|
|
253
243
|
// renderProvider
|
|
@@ -259,7 +249,8 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
259
249
|
const beanOptions = appResource.getBean(renderProvider as any);
|
|
260
250
|
const onionOptions = beanOptions?.options as IDecoratorTableCellOptions | undefined;
|
|
261
251
|
columnProps = deepExtend({}, onionOptions, columnProps);
|
|
262
|
-
|
|
252
|
+
// should not eval jsx columnProps
|
|
253
|
+
// columnProps = this.zovaJsx.renderJsxProps(columnProps as any, {}, renderContext.$celScope, renderContext) as any;
|
|
263
254
|
}
|
|
264
255
|
// const cellProps = isJsxComponent(render) ? Object.assign({}, columnProps, cast(render).props) : columnProps;
|
|
265
256
|
const cellProps = columnProps;
|
|
@@ -281,7 +272,7 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
281
272
|
columnProps: ITableCellRenderColumnProps | undefined,
|
|
282
273
|
columnScope: ITableColumnScope | undefined,
|
|
283
274
|
cellContext: CellContext<TData, any>,
|
|
284
|
-
renderProvider:
|
|
275
|
+
renderProvider: TypeTableCellRenderComponent,
|
|
285
276
|
beanInstance: ITableCellRender | undefined,
|
|
286
277
|
cellProps: any | undefined,
|
|
287
278
|
cellScope: ITableCellScope | undefined,
|
|
@@ -314,7 +305,7 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
314
305
|
columnProps: ITableCellRenderColumnProps | undefined,
|
|
315
306
|
columnScope: ITableColumnScope | undefined,
|
|
316
307
|
cellContext: CellContext<TData, any>,
|
|
317
|
-
renderProvider:
|
|
308
|
+
renderProvider: TypeTableCellRenderComponent,
|
|
318
309
|
beanInstance: ITableCellRender | undefined,
|
|
319
310
|
cellProps: any | undefined,
|
|
320
311
|
cellScope: ITableCellScope | undefined,
|
|
@@ -329,7 +320,7 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
329
320
|
cellScope = objectAssignReactive({}, columnScope, { value, fallbackValue })!;
|
|
330
321
|
}
|
|
331
322
|
// render: text
|
|
332
|
-
if (renderProvider === 'text') {
|
|
323
|
+
if (renderProvider === ('text' as TypeTableCellRenderComponent)) {
|
|
333
324
|
return isNilOrEmptyString(value) ? fallbackValue : value;
|
|
334
325
|
}
|
|
335
326
|
// renderContext
|
|
@@ -343,8 +334,12 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
343
334
|
// cellProps = isJsxComponent(render) ? Object.assign({}, columnProps, cast(render).props) : columnProps;
|
|
344
335
|
cellProps = columnProps;
|
|
345
336
|
}
|
|
346
|
-
|
|
347
|
-
|
|
337
|
+
const cellProps2 = this.zovaJsx.renderJsxProps(cellProps, {}, cellScope, jsxRenderContext) as any;
|
|
338
|
+
if (cellProps2.class || cellProps2.style) {
|
|
339
|
+
cellProps2.class = classes(cellProps2.class, jsxRenderContext.$host.$style(cellProps2.style));
|
|
340
|
+
delete cellProps2.style;
|
|
341
|
+
}
|
|
342
|
+
return beanInstance.render(cellProps2, jsxRenderContext, () => {
|
|
348
343
|
const children = isJsxComponent(render) && cast(render).children;
|
|
349
344
|
if (children && children.length > 0) {
|
|
350
345
|
return this.zovaJsx.renderJsxChildrenDirect(children, cellScope, jsxRenderContext);
|
|
@@ -403,13 +398,7 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
|
|
|
403
398
|
// return isJsxComponent(render) ? cast(render).type : render;
|
|
404
399
|
// }
|
|
405
400
|
|
|
406
|
-
public getRenderProvider(render: TypeTableCellRenderComponent | undefined):
|
|
407
|
-
|
|
408
|
-
if (typeof render === 'string') {
|
|
409
|
-
const render2 = this.tableProvider.components?.[render];
|
|
410
|
-
if (!render2) throw new Error(`not found table cell component of: ${render}`);
|
|
411
|
-
return render2;
|
|
412
|
-
}
|
|
413
|
-
return render;
|
|
401
|
+
public getRenderProvider(render: TypeTableCellRenderComponent | undefined): TypeTableCellRenderComponent {
|
|
402
|
+
return render || ('text' as TypeTableCellRenderComponent);
|
|
414
403
|
}
|
|
415
404
|
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { IMetadataCustomGenerateOptions } from '@cabloy/cli';
|
|
2
|
-
import type { IGlobBeanFile } from '@cabloy/module-info';
|
|
3
|
-
|
|
4
|
-
import { combineResourceName } from '@cabloy/utils';
|
|
5
|
-
import { toUpperCaseFirstChar } from '@cabloy/word-utils';
|
|
6
|
-
import fse from 'fs-extra';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
|
|
9
|
-
import { generateRestIndex } from './utils.ts';
|
|
10
|
-
|
|
11
|
-
export default async function (options: IMetadataCustomGenerateOptions): Promise<string> {
|
|
12
|
-
const { globFiles } = options;
|
|
13
|
-
for (const globFile of globFiles) {
|
|
14
|
-
if (globFile.isIgnore) continue;
|
|
15
|
-
// restComponent
|
|
16
|
-
await generateRestTableCell(options, globFile);
|
|
17
|
-
}
|
|
18
|
-
return '';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async function generateRestTableCell(
|
|
22
|
-
options: IMetadataCustomGenerateOptions,
|
|
23
|
-
globFile: IGlobBeanFile,
|
|
24
|
-
) {
|
|
25
|
-
const { moduleName, modulePath } = options;
|
|
26
|
-
const { beanName, beanNameCapitalize, sceneName } = globFile;
|
|
27
|
-
// options
|
|
28
|
-
const typeOptionsName = `ITableCellOptions${beanNameCapitalize}`;
|
|
29
|
-
// import
|
|
30
|
-
const contentImports: string[] = [];
|
|
31
|
-
contentImports.push(`import type { ${typeOptionsName} } from 'zova-module-${moduleName}';`);
|
|
32
|
-
// component
|
|
33
|
-
const componentNamePrefix = 'BBT';
|
|
34
|
-
const componentName = beanName;
|
|
35
|
-
const componentNameFull = `${componentNamePrefix}${toUpperCaseFirstChar(combineResourceName(componentName, moduleName, true, true))}`;
|
|
36
|
-
const contentComponent = `export function ${componentNameFull}(
|
|
37
|
-
_props: ${typeOptionsName},
|
|
38
|
-
) {
|
|
39
|
-
return '${moduleName}.${sceneName}.${beanName}';
|
|
40
|
-
}`;
|
|
41
|
-
// content
|
|
42
|
-
const content = `${contentImports.join('\n')}
|
|
43
|
-
|
|
44
|
-
${contentComponent}
|
|
45
|
-
`;
|
|
46
|
-
// output
|
|
47
|
-
const fileDest = path.join(modulePath, `rest/tableCell/${beanName}.ts`);
|
|
48
|
-
await fse.outputFile(fileDest, content);
|
|
49
|
-
// tableCells
|
|
50
|
-
const fileComponents = path.join(modulePath, 'rest/tableCells.ts');
|
|
51
|
-
let contentComponents = '';
|
|
52
|
-
if (fse.existsSync(fileComponents)) {
|
|
53
|
-
contentComponents = (await fse.readFile(fileComponents)).toString();
|
|
54
|
-
}
|
|
55
|
-
const exportContent = `export * from './tableCell/${beanName}.js';`;
|
|
56
|
-
if (!contentComponents.includes(exportContent)) {
|
|
57
|
-
contentComponents = `${contentComponents}${exportContent}\n`;
|
|
58
|
-
await fse.outputFile(fileComponents, contentComponents);
|
|
59
|
-
}
|
|
60
|
-
// index
|
|
61
|
-
const exportIndexContent = "export * from './tableCells.js';";
|
|
62
|
-
await generateRestIndex(modulePath, exportIndexContent);
|
|
63
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import fse from 'fs-extra';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
|
|
4
|
-
export async function generateRestIndex(modulePath: string, append: string) {
|
|
5
|
-
// index
|
|
6
|
-
const fileIndex = path.join(modulePath, 'rest/index.ts');
|
|
7
|
-
let contentIndex = '';
|
|
8
|
-
if (fse.existsSync(fileIndex)) {
|
|
9
|
-
contentIndex = (await fse.readFile(fileIndex)).toString();
|
|
10
|
-
}
|
|
11
|
-
if (!contentIndex.includes(append)) {
|
|
12
|
-
contentIndex = `${contentIndex}${append}\n`;
|
|
13
|
-
await fse.outputFile(fileIndex, contentIndex);
|
|
14
|
-
}
|
|
15
|
-
}
|
package/cli/tsconfig.json
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { combineResourceName } from '@cabloy/utils';
|
|
2
|
-
import { toUpperCaseFirstChar } from '@cabloy/word-utils';
|
|
3
|
-
import fse from 'fs-extra';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { generateRestIndex } from "./utils.js";
|
|
6
|
-
export default async function (options) {
|
|
7
|
-
const { globFiles } = options;
|
|
8
|
-
for (const globFile of globFiles) {
|
|
9
|
-
if (globFile.isIgnore)
|
|
10
|
-
continue;
|
|
11
|
-
// restComponent
|
|
12
|
-
await generateRestTableCell(options, globFile);
|
|
13
|
-
}
|
|
14
|
-
return '';
|
|
15
|
-
}
|
|
16
|
-
async function generateRestTableCell(options, globFile) {
|
|
17
|
-
const { moduleName, modulePath } = options;
|
|
18
|
-
const { beanName, beanNameCapitalize, sceneName } = globFile;
|
|
19
|
-
// options
|
|
20
|
-
const typeOptionsName = `ITableCellOptions${beanNameCapitalize}`;
|
|
21
|
-
// import
|
|
22
|
-
const contentImports = [];
|
|
23
|
-
contentImports.push(`import type { ${typeOptionsName} } from 'zova-module-${moduleName}';`);
|
|
24
|
-
// component
|
|
25
|
-
const componentNamePrefix = 'BBT';
|
|
26
|
-
const componentName = beanName;
|
|
27
|
-
const componentNameFull = `${componentNamePrefix}${toUpperCaseFirstChar(combineResourceName(componentName, moduleName, true, true))}`;
|
|
28
|
-
const contentComponent = `export function ${componentNameFull}(
|
|
29
|
-
_props: ${typeOptionsName},
|
|
30
|
-
) {
|
|
31
|
-
return '${moduleName}.${sceneName}.${beanName}';
|
|
32
|
-
}`;
|
|
33
|
-
// content
|
|
34
|
-
const content = `${contentImports.join('\n')}
|
|
35
|
-
|
|
36
|
-
${contentComponent}
|
|
37
|
-
`;
|
|
38
|
-
// output
|
|
39
|
-
const fileDest = path.join(modulePath, `rest/tableCell/${beanName}.ts`);
|
|
40
|
-
await fse.outputFile(fileDest, content);
|
|
41
|
-
// tableCells
|
|
42
|
-
const fileComponents = path.join(modulePath, 'rest/tableCells.ts');
|
|
43
|
-
let contentComponents = '';
|
|
44
|
-
if (fse.existsSync(fileComponents)) {
|
|
45
|
-
contentComponents = (await fse.readFile(fileComponents)).toString();
|
|
46
|
-
}
|
|
47
|
-
const exportContent = `export * from './tableCell/${beanName}.js';`;
|
|
48
|
-
if (!contentComponents.includes(exportContent)) {
|
|
49
|
-
contentComponents = `${contentComponents}${exportContent}\n`;
|
|
50
|
-
await fse.outputFile(fileComponents, contentComponents);
|
|
51
|
-
}
|
|
52
|
-
// index
|
|
53
|
-
const exportIndexContent = "export * from './tableCells.js';";
|
|
54
|
-
await generateRestIndex(modulePath, exportIndexContent);
|
|
55
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import fse from 'fs-extra';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
export async function generateRestIndex(modulePath, append) {
|
|
4
|
-
// index
|
|
5
|
-
const fileIndex = path.join(modulePath, 'rest/index.ts');
|
|
6
|
-
let contentIndex = '';
|
|
7
|
-
if (fse.existsSync(fileIndex)) {
|
|
8
|
-
contentIndex = (await fse.readFile(fileIndex)).toString();
|
|
9
|
-
}
|
|
10
|
-
if (!contentIndex.includes(append)) {
|
|
11
|
-
contentIndex = `${contentIndex}${append}\n`;
|
|
12
|
-
await fse.outputFile(fileIndex, contentIndex);
|
|
13
|
-
}
|
|
14
|
-
}
|