zova-module-a-table 5.1.38 → 5.1.40

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.
@@ -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, RowSelectionState, SortingState } from '@tanstack/vue-table';
4
4
  import { SchemaObject } from 'openapi3-ts/oas31';
5
5
  import { VNode } from 'vue';
6
6
  import { ZovaJsx } from 'zova-jsx';
@@ -12,6 +12,12 @@ 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>;
18
+ enableRowSelection?: boolean | ((row: Row<TData>) => boolean);
19
+ rowSelection?: RowSelectionState;
20
+ onRowSelectionChange?: OnChangeFn<RowSelectionState>;
15
21
  tableScope?: ITableScope;
16
22
  getColumns?: TypeTableGetColumns<TData>;
17
23
  slotDefault?: (table: ControllerTable<TData>) => VNode;
@@ -27,10 +33,16 @@ export declare class ControllerTable<TData extends {} = {}> extends BeanControll
27
33
  protected __init__(): Promise<void>;
28
34
  get schema(): SchemaObject | undefined;
29
35
  get data(): TData[] | undefined;
36
+ get sorting(): SortingState;
37
+ get rowSelection(): RowSelectionState;
30
38
  refreshMeta(): Promise<void>;
31
39
  private _createTable;
32
40
  private _createColumns;
33
41
  private _createColumnsMiddle;
42
+ private _getRowId;
43
+ private _canSelectRow;
44
+ private _getColumnPinning;
45
+ private _isOrderable;
34
46
  private _createProperties;
35
47
  private _createTableMeta;
36
48
  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,EAGX,GAAG,EAEJ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAS5B,OAAO,EAAkB,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,KAAK,EAEV,0BAA0B,EAE3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,4BAA4B,EAE5B,eAAe,EACf,iBAAiB,EACjB,WAAW,EAEZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAE3E,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,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACxC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;IACvD,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC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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":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAGtC,qBACa,WAAY,SAAQ,cAAc;IAC7C,OAAO,CAAC,mBAAmB;IAwCpB,MAAM;;;CAGd"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/component/table/render.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAKtC,qBACa,WAAY,SAAQ,cAAc;IAC7C,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,mBAAmB;IAkGpB,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";
@@ -20,6 +20,9 @@ var BeanControllerTableBase = class extends BeanControllerBase {
20
20
  }
21
21
  };
22
22
  //#endregion
23
+ //#region src/types/table.ts
24
+ var TableColumnIdSelection = "$$selection";
25
+ //#endregion
23
26
  //#region src/component/table/controller.tsx
24
27
  var _dec$2, _dec2$2, _class$2, _ControllerTable;
25
28
  var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-table" }), _dec$2(_class$2 = _dec2$2(_class$2 = (_ControllerTable = class ControllerTable extends BeanControllerTableBase {
@@ -41,6 +44,10 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
41
44
  if (deepEqual(newValue, oldValue)) return;
42
45
  await this.refreshMeta();
43
46
  });
47
+ this.$watch(() => this.$props.enableRowSelection, async (newValue, oldValue) => {
48
+ if (newValue === oldValue) return;
49
+ await this.refreshMeta();
50
+ });
44
51
  this._createTable();
45
52
  }
46
53
  get schema() {
@@ -49,17 +56,47 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
49
56
  get data() {
50
57
  return this.$props.data;
51
58
  }
59
+ get sorting() {
60
+ return this.$props.sorting ?? [];
61
+ }
62
+ get rowSelection() {
63
+ return this.$props.rowSelection ?? {};
64
+ }
52
65
  async refreshMeta() {
53
66
  this.tableMeta = await this._createTableMeta();
54
67
  this.columns = await this._createColumns();
68
+ this.table?.setColumnPinning(this._getColumnPinning());
55
69
  }
56
70
  _createTable() {
57
71
  const self = this;
58
72
  const tableOptions = {
59
- getRowId: this.$props.getRowId ?? ((originalRow) => cast(originalRow).id),
73
+ getRowId: (originalRow, index, parent) => this._getRowId(originalRow, index, parent),
60
74
  getCoreRowModel: getCoreRowModel(),
61
75
  renderFallbackValue: this.scope.config.renderFallbackValue,
62
76
  manualPagination: true,
77
+ manualSorting: true,
78
+ enableMultiSort: false,
79
+ enableSortingRemoval: false,
80
+ enableRowSelection: (row) => self._canSelectRow(row),
81
+ state: {
82
+ get sorting() {
83
+ return self.sorting;
84
+ },
85
+ get rowSelection() {
86
+ return self.rowSelection;
87
+ }
88
+ },
89
+ onSortingChange: (updater) => {
90
+ const sorting = functionalUpdate(updater, self.sorting).slice(0, 1);
91
+ self.$props.onSortingChange?.(sorting);
92
+ },
93
+ onRowSelectionChange: (updater) => {
94
+ const rowSelection = functionalUpdate(updater, self.rowSelection);
95
+ self.$props.onRowSelectionChange?.(rowSelection);
96
+ },
97
+ get initialState() {
98
+ return { columnPinning: self._getColumnPinning() };
99
+ },
63
100
  get data() {
64
101
  return self.data || [];
65
102
  },
@@ -68,11 +105,11 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
68
105
  }
69
106
  };
70
107
  this.table = this.$useTable(tableOptions);
108
+ this.table.setColumnPinning(this._getColumnPinning());
71
109
  }
72
110
  async _createColumns() {
73
111
  if (!this.properties) return [];
74
- if (!this.$props.getColumns) return await this._createColumnsMiddle(this.tableMeta.properties);
75
- return await this.$props.getColumns(async (properties) => {
112
+ const columns = !this.$props.getColumns ? await this._createColumnsMiddle(this.tableMeta.properties) : await this.$props.getColumns(async (properties) => {
76
113
  return await this._createColumnsMiddle(properties ?? this.tableMeta.properties);
77
114
  }, async (key, render) => {
78
115
  const columnScope = this.getColumnScope(key);
@@ -81,6 +118,19 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
81
118
  if (visible === false) return;
82
119
  return await this._createColumnRender(render, columnProps, columnScope, jsxRenderContext);
83
120
  }, this);
121
+ if (!this.$props.enableRowSelection) return columns;
122
+ return [createColumnHelper().display({
123
+ id: "$$selection",
124
+ header: "",
125
+ cell: "",
126
+ size: 48,
127
+ enableSorting: false,
128
+ meta: { rest: {
129
+ fixed: "left",
130
+ width: 48,
131
+ align: "center"
132
+ } }
133
+ }), ...columns];
84
134
  }
85
135
  async _createColumnsMiddle(properties) {
86
136
  const tableMeta = this.tableMeta;
@@ -93,11 +143,48 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
93
143
  header: (_props) => {
94
144
  return property?.title || key;
95
145
  },
96
- cell: (props) => tableMeta.renders[key](props)
146
+ cell: (props) => tableMeta.renders[key](props),
147
+ size: property.rest?.width,
148
+ enableSorting: property.rest?.enableSorting === true && this._isOrderable(property),
149
+ sortDescFirst: property.rest?.sortDescFirst === true,
150
+ meta: { rest: property.rest }
97
151
  }));
98
152
  }
99
153
  return columns;
100
154
  }
155
+ _getRowId(originalRow, index, parent) {
156
+ const id = this.$props.getRowId?.(originalRow, index, parent) ?? cast(originalRow).id;
157
+ if (isNilOrEmptyString(id)) return `__unselectable_${parent ? `${parent.id}.` : ""}${index}`;
158
+ return String(id);
159
+ }
160
+ _canSelectRow(row) {
161
+ const enableRowSelection = this.$props.enableRowSelection;
162
+ if (!enableRowSelection) return false;
163
+ if (isNilOrEmptyString(this.$props.getRowId?.(row.original, row.index, row.getParentRow()) ?? cast(row.original).id)) return false;
164
+ return typeof enableRowSelection === "function" ? enableRowSelection(row) : true;
165
+ }
166
+ _getColumnPinning() {
167
+ const left = this.$props.enableRowSelection ? ["$$selection"] : [];
168
+ const right = [];
169
+ for (const property of this.tableMeta?.properties ?? []) {
170
+ const fixed = property.rest?.fixed;
171
+ if (fixed === "left") left.push(property.key);
172
+ if (fixed === "right") right.push(property.key);
173
+ }
174
+ return {
175
+ left,
176
+ right
177
+ };
178
+ }
179
+ _isOrderable(property) {
180
+ const properties = this.$props.schemaOrder?.properties;
181
+ if (!properties) return false;
182
+ return [
183
+ property.key,
184
+ property.schemaKey,
185
+ ...property.schemaKeys ?? []
186
+ ].some((key) => key && Object.prototype.hasOwnProperty.call(properties, key));
187
+ }
101
188
  _createProperties() {
102
189
  this.properties = this.$computed(() => {
103
190
  return this.$sdk.loadSchemaProperties(this.schema, "table");
@@ -263,17 +350,79 @@ var ControllerTable = (_dec$2 = Controller(), _dec2$2 = BeanInfo({ module: "a-ta
263
350
  //#region src/component/table/render.tsx
264
351
  var _dec$1, _dec2$1, _class$1;
265
352
  var RenderTable = (_dec$1 = Render(), _dec2$1 = BeanInfo({ module: "a-table" }), _dec$1(_class$1 = _dec2$1(_class$1 = class RenderTable extends BeanRenderBase {
353
+ _getColumnStyle(column) {
354
+ const rest = column.columnDef.meta?.rest;
355
+ const fixed = column.getIsPinned();
356
+ const width = rest?.width ? `${rest.width}px` : void 0;
357
+ return {
358
+ width,
359
+ minWidth: width,
360
+ textAlign: rest?.align,
361
+ position: fixed ? "sticky" : void 0,
362
+ left: fixed === "left" ? `${column.getStart("left")}px` : void 0,
363
+ right: fixed === "right" ? `${column.getAfter("right")}px` : void 0,
364
+ zIndex: fixed ? 1 : void 0
365
+ };
366
+ }
266
367
  _renderTableDefault() {
267
368
  const table = this.table;
268
369
  return createVNode("table", { "class": "table" }, [createVNode("thead", null, [createVNode("tr", null, [table.getFlatHeaders().map((header) => {
269
- return createVNode("th", { "key": header.id }, [createVNode(FlexRender, {
270
- "render": header.column.columnDef.header,
370
+ const column = header.column;
371
+ const canSort = column.getCanSort();
372
+ const sorted = column.getIsSorted();
373
+ const fixed = column.getIsPinned();
374
+ const headerDefinition = column.columnDef.header;
375
+ const headerContent = column.id === "$$selection" ? createVNode("input", {
376
+ "type": "checkbox",
377
+ "checked": table.getIsAllPageRowsSelected(),
378
+ "indeterminate": table.getIsSomePageRowsSelected(),
379
+ "aria-checked": table.getIsSomePageRowsSelected() ? "mixed" : void 0,
380
+ "aria-label": "Select all rows on this page",
381
+ "disabled": table.getRowModel().rows.every((row) => !row.getCanSelect()),
382
+ "onChange": table.getToggleAllPageRowsSelectedHandler()
383
+ }, null) : createVNode(FlexRender, {
384
+ "render": headerDefinition,
271
385
  "props": header.getContext()
272
- }, null)]);
386
+ }, null);
387
+ let sortAria = "none";
388
+ let sortIcon = "↕";
389
+ if (sorted === "asc") {
390
+ sortAria = "ascending";
391
+ sortIcon = "▲";
392
+ } else if (sorted === "desc") {
393
+ sortAria = "descending";
394
+ sortIcon = "▼";
395
+ }
396
+ return createVNode("th", {
397
+ "key": header.id,
398
+ "class": fixed ? "bg-base-100" : void 0,
399
+ "style": this._getColumnStyle(column),
400
+ "aria-sort": sortAria
401
+ }, [canSort ? createVNode("button", {
402
+ "type": "button",
403
+ "class": "inline-flex w-full items-center gap-1",
404
+ "onClick": column.getToggleSortingHandler(),
405
+ "aria-label": `Sort by ${column.id}`
406
+ }, [headerContent, createVNode("span", { "aria-hidden": "true" }, [sortIcon])]) : headerContent]);
273
407
  })])]), createVNode("tbody", null, [table.getRowModel().rows.map((row) => {
274
- return createVNode("tr", { "key": row.id }, [row.getVisibleCells().map((cell) => {
275
- return createVNode("td", { "key": cell.id }, [createVNode(FlexRender, {
276
- "render": cell.column.columnDef.cell,
408
+ return createVNode("tr", {
409
+ "key": row.id,
410
+ "aria-selected": row.getIsSelected()
411
+ }, [row.getVisibleCells().map((cell) => {
412
+ const column = cell.column;
413
+ const selection = column.id === "$$selection";
414
+ return createVNode("td", {
415
+ "key": cell.id,
416
+ "class": column.getIsPinned() ? "bg-base-100" : void 0,
417
+ "style": this._getColumnStyle(column)
418
+ }, [selection ? createVNode("input", {
419
+ "type": "checkbox",
420
+ "checked": row.getIsSelected(),
421
+ "disabled": !row.getCanSelect(),
422
+ "aria-label": `Select row ${row.id}`,
423
+ "onChange": row.getToggleSelectedHandler()
424
+ }, null) : createVNode(FlexRender, {
425
+ "render": column.columnDef.cell,
277
426
  "props": cell.getContext()
278
427
  }, null)]);
279
428
  })]);
@@ -324,6 +473,6 @@ function TableCell(options) {
324
473
  return createBeanDecorator("tableCell", "app", true, options);
325
474
  }
326
475
  //#endregion
327
- export { BeanControllerPageTableBase, BeanControllerTableBase, ControllerTable, RenderTable, ScopeModuleATable, TableCell, ZTable, components, config };
476
+ export { BeanControllerPageTableBase, BeanControllerTableBase, ControllerTable, RenderTable, ScopeModuleATable, TableCell, TableColumnIdSelection, ZTable, components, config };
328
477
 
329
478
  //# sourceMappingURL=index.js.map
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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AAO,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"}
1
+ {"version":3,"file":"index.js","names":["celEnvBase","isNilOrEmptyString","createColumnHelper","functionalUpdate","getCoreRowModel","appResource","beanFullNameFromOnionName","cast","deepEqual","deepExtend","objectAssignReactive","isJsxComponent","ZovaJsx","Controller","BeanControllerTableBase","TableColumnIdSelection","ControllerTable","_dec","_dec2","__z_BeanInfo","module","_class","_ControllerTable","constructor","args","properties","columns","tableMeta","zovaJsx","columnCelEnv","__init__","bean","_setBean","_getColumnCelEnv","_newBeanSimple","undefined","_createProperties","refreshMeta","$watch","$props","schema","newValue","oldValue","enableRowSelection","_createTable","data","sorting","rowSelection","_createTableMeta","_createColumns","table","setColumnPinning","_getColumnPinning","self","tableOptions","getRowId","originalRow","index","parent","_getRowId","renderFallbackValue","scope","config","manualPagination","manualSorting","enableMultiSort","enableSortingRemoval","row","_canSelectRow","state","onSortingChange","updater","slice","onRowSelectionChange","initialState","columnPinning","$useTable","getColumns","_createColumnsMiddle","key","render","columnScope","getColumnScope","jsxRenderContext","getColumnJsxRenderContext","visible","columnProps","getColumnComponentPropsTop","_createColumnRender","columnHelper","display","id","header","cell","size","enableSorting","meta","rest","fixed","width","align","property","push","accessor","_props","title","props","renders","_isOrderable","sortDescFirst","String","originalId","original","getParentRow","left","right","schemaOrder","keys","schemaKey","schemaKeys","some","Object","prototype","hasOwnProperty","call","$computed","$sdk","loadSchemaProperties","promises","res","Promise","all","filter","_item","item","forEach","celScope","app","ctx","$scene","$host","$celScope","$jsx","$$table","getCellJsxRenderContext","cellContext","cellRenderPrepare","Array","isArray","renderProviders","map","getRenderProvider","renderProvider","includes","_getBean","renderContext","beanInstance","beanOptions","getBean","onionOptions","options","checkVisible","_cellRender","cellRender","cellScope","_getBeanSyncOnly","cellProps","setTransientObject","getValue","name","_cellRenderInner","value","fallbackValue","cellProps2","renderJsxProps","class","style","$cssMerge","$style","children","length","renderJsxChildrenDirect","getColumnProperty","find","celEnv","clone","registerFunction","transientObject","defaultValue","scopeExtra","tableScope","_getColumnComponentPropsTopByRest","_renderContext","evaluateExpression","assign","$propsDefault","FlexRender","BeanRenderBase","Render","TableColumnIdSelection","RenderTable","_dec","_dec2","__z_BeanInfo","module","_class","_getColumnStyle","column","rest","columnDef","meta","fixed","getIsPinned","width","undefined","minWidth","textAlign","align","position","left","getStart","right","getAfter","zIndex","_renderTableDefault","table","_createVNode","getFlatHeaders","map","header","canSort","getCanSort","sorted","getIsSorted","headerDefinition","selection","id","headerContent","getIsAllPageRowsSelected","getIsSomePageRowsSelected","getRowModel","rows","every","row","getCanSelect","getToggleAllPageRowsSelectedHandler","getContext","sortAria","sortIcon","getToggleSortingHandler","getIsSelected","getVisibleCells","cell","getToggleSelectedHandler","render","$slotDefault"],"sources":["../src/lib/beanControllerTableBase.ts","../src/types/table.ts","../src/component/table/controller.tsx","../src/component/table/render.tsx","../src/.metadata/component/table.ts","../src/config/config.ts","../src/.metadata/index.ts","../src/lib/beanControllerPageTableBase.ts","../src/lib/tableCell.ts"],"sourcesContent":["import { useVueTable } from '@tanstack/vue-table';\nimport { markRaw } from 'vue';\nimport { BeanControllerBase } from 'zova';\nexport class BeanControllerTableBase extends BeanControllerBase {\n constructor(...args) {\n super(...args);\n this.table = void 0;\n }\n $useTable(initialOptions) {\n return this.ctx.util.instanceScope(() => {\n return markRaw(useVueTable(initialOptions));\n });\n }\n async refreshMeta() {\n throw new Error('should implement refreshMeta');\n }\n}","export const TableColumnIdSelection = '$$selection';","import type {\n IResourceTableActionRowOptionsBase,\n ISchemaObjectExtensionField,\n ISchemaObjectExtensionFieldRest,\n TypeTableCellRenderComponent,\n TypeTableCellRenderComponentProvider,\n} from 'zova-module-a-openapi';\n\nimport { celEnvBase, isNilOrEmptyString } from '@cabloy/utils';\nimport {\n CellContext,\n createColumnHelper,\n functionalUpdate,\n getCoreRowModel,\n OnChangeFn,\n Row,\n RowSelectionState,\n SortingState,\n TableOptionsWithReactiveData,\n} from '@tanstack/vue-table';\nimport { SchemaObject } from 'openapi3-ts/oas31';\nimport { VNode } from 'vue';\nimport {\n appResource,\n beanFullNameFromOnionName,\n cast,\n deepEqual,\n deepExtend,\n objectAssignReactive,\n} from 'zova';\nimport { isJsxComponent, ZovaJsx } from 'zova-jsx';\nimport { Controller } from 'zova-module-a-bean';\n\nimport type { ITableMeta, TypeColumn, TypeTableGetColumns } from '../../types/table.js';\nimport type {\n IDecoratorTableCellOptions,\n IJsxRenderContextTableCell,\n ITableCellRender,\n} from '../../types/tableCell.js';\nimport type {\n IJsxRenderContextTableColumn,\n ITableCellRenderColumnProps,\n ITableCellScope,\n ITableColumnScope,\n ITableScope,\n TypeTableCellRender,\n} from '../../types/tableColumn.js';\n\nimport { BeanControllerTableBase } from '../../lib/beanControllerTableBase.js';\nimport { TableColumnIdSelection } from '../../types/table.js';\nimport { ITableCellRenderColumnOptions } from '../../types/tableColumn.js';\n\nexport interface ControllerTableProps<TData extends {} = {}> {\n data?: TData[];\n schema?: SchemaObject;\n schemaOrder?: SchemaObject;\n sorting?: SortingState;\n onSortingChange?: OnChangeFn<SortingState>;\n enableRowSelection?: boolean | ((row: Row<TData>) => boolean);\n rowSelection?: RowSelectionState;\n onRowSelectionChange?: OnChangeFn<RowSelectionState>;\n tableScope?: ITableScope;\n getColumns?: TypeTableGetColumns<TData>;\n slotDefault?: (table: ControllerTable<TData>) => VNode;\n getRowId?: (originalRow: TData, index: number, parent?: Row<TData>) => string;\n}\n\n@Controller()\nexport class ControllerTable<TData extends {} = {}> extends BeanControllerTableBase<TData> {\n static $propsDefault = {};\n\n // table: TypeTable<TData>; // in BeanControllerTableBase\n\n properties: ISchemaObjectExtensionField[] | undefined;\n columns: TypeColumn<TData>[];\n tableMeta: ITableMeta<TData>;\n zovaJsx: ZovaJsx;\n columnCelEnv: typeof celEnvBase;\n\n protected async __init__() {\n this.bean._setBean('$$table', this);\n // jsx\n this.columnCelEnv = this._getColumnCelEnv();\n this.zovaJsx = this.bean._newBeanSimple(ZovaJsx, false, undefined, this.columnCelEnv);\n // properties\n this._createProperties();\n // tableMeta/columns\n await this.refreshMeta();\n // watch\n this.$watch(\n () => this.$props.schema,\n async (newValue, oldValue) => {\n if (deepEqual(newValue, oldValue)) return;\n await this.refreshMeta();\n },\n );\n this.$watch(\n () => this.$props.enableRowSelection,\n async (newValue, oldValue) => {\n if (newValue === oldValue) return;\n await this.refreshMeta();\n },\n );\n // table\n this._createTable();\n }\n\n public get schema() {\n return this.$props.schema;\n }\n\n public get data() {\n return this.$props.data;\n }\n\n public get sorting() {\n return this.$props.sorting ?? [];\n }\n\n public get rowSelection() {\n return this.$props.rowSelection ?? {};\n }\n\n public async refreshMeta() {\n this.tableMeta = await this._createTableMeta();\n this.columns = await this._createColumns();\n this.table?.setColumnPinning(this._getColumnPinning());\n }\n\n private _createTable() {\n // eslint-disable-next-line\n const self = this;\n const tableOptions: TableOptionsWithReactiveData<TData> = {\n getRowId: (originalRow, index, parent) => this._getRowId(originalRow, index, parent),\n getCoreRowModel: getCoreRowModel(),\n renderFallbackValue: this.scope.config.renderFallbackValue,\n manualPagination: true,\n manualSorting: true,\n enableMultiSort: false,\n enableSortingRemoval: false,\n enableRowSelection: row => self._canSelectRow(row),\n state: {\n get sorting() {\n return self.sorting;\n },\n get rowSelection() {\n return self.rowSelection;\n },\n },\n onSortingChange: updater => {\n const sorting = functionalUpdate(updater, self.sorting).slice(0, 1);\n self.$props.onSortingChange?.(sorting);\n },\n onRowSelectionChange: updater => {\n const rowSelection = functionalUpdate(updater, self.rowSelection);\n self.$props.onRowSelectionChange?.(rowSelection);\n },\n get initialState() {\n const columnPinning = self._getColumnPinning();\n return { columnPinning };\n },\n get data() {\n return self.data || [];\n },\n get columns() {\n return self.columns;\n },\n };\n this.table = this.$useTable(tableOptions);\n this.table.setColumnPinning(this._getColumnPinning());\n }\n\n private async _createColumns() {\n if (!this.properties) return [];\n const columns = !this.$props.getColumns\n ? await this._createColumnsMiddle(this.tableMeta.properties)\n : await this.$props.getColumns(\n async properties => {\n return await this._createColumnsMiddle(properties ?? this.tableMeta.properties);\n },\n async (\n key: string,\n render: TypeTableCellRenderComponent,\n ): Promise<TypeTableCellRender<TData, any> | undefined> => {\n // columnScope\n const columnScope = this.getColumnScope(key);\n // renderContext\n const jsxRenderContext = this.getColumnJsxRenderContext(columnScope);\n // columnProps\n const { visible, columnProps } = this.getColumnComponentPropsTop(\n key,\n columnScope,\n jsxRenderContext,\n );\n // visible\n if (visible === false) return;\n return await this._createColumnRender(\n render,\n columnProps,\n columnScope,\n jsxRenderContext,\n );\n },\n this,\n );\n if (!this.$props.enableRowSelection) return columns;\n const columnHelper = createColumnHelper<TData>();\n return [\n columnHelper.display({\n id: TableColumnIdSelection,\n header: '',\n cell: '',\n size: 48,\n enableSorting: false,\n meta: { rest: { fixed: 'left', width: 48, align: 'center' } },\n }),\n ...columns,\n ];\n }\n\n private async _createColumnsMiddle(\n properties: ISchemaObjectExtensionField[],\n ): Promise<TypeColumn<TData>[]> {\n const tableMeta = this.tableMeta;\n const columnHelper = createColumnHelper<TData>();\n const columns: TypeColumn<TData>[] = [];\n for (const property of properties) {\n const key = property.key!;\n columns.push(\n columnHelper.accessor(key as any, {\n id: key,\n header: _props => {\n return property?.title || key;\n },\n cell: props => tableMeta.renders[key](props),\n size: property.rest?.width,\n enableSorting: property.rest?.enableSorting === true && this._isOrderable(property),\n sortDescFirst: property.rest?.sortDescFirst === true,\n meta: { rest: property.rest },\n }),\n );\n }\n return columns;\n }\n\n private _getRowId(originalRow: TData, index: number, parent?: Row<TData>) {\n const id = this.$props.getRowId?.(originalRow, index, parent) ?? cast(originalRow).id;\n if (isNilOrEmptyString(id)) {\n return `__unselectable_${parent ? `${parent.id}.` : ''}${index}`;\n }\n return String(id);\n }\n\n private _canSelectRow(row: Row<TData>) {\n const enableRowSelection = this.$props.enableRowSelection;\n if (!enableRowSelection) return false;\n const originalId =\n this.$props.getRowId?.(row.original, row.index, row.getParentRow()) ?? cast(row.original).id;\n if (isNilOrEmptyString(originalId)) return false;\n return typeof enableRowSelection === 'function' ? enableRowSelection(row) : true;\n }\n\n private _getColumnPinning() {\n const left: string[] = this.$props.enableRowSelection ? [TableColumnIdSelection] : [];\n const right: string[] = [];\n for (const property of this.tableMeta?.properties ?? []) {\n const fixed = property.rest?.fixed;\n if (fixed === 'left') left.push(property.key!);\n if (fixed === 'right') right.push(property.key!);\n }\n return { left, right };\n }\n\n private _isOrderable(property: ISchemaObjectExtensionField) {\n const properties = this.$props.schemaOrder?.properties;\n if (!properties) return false;\n const keys = [property.key, property.schemaKey, ...(property.schemaKeys ?? [])];\n return keys.some(key => key && Object.prototype.hasOwnProperty.call(properties, key));\n }\n\n private _createProperties() {\n this.properties = this.$computed(() => {\n return this.$sdk.loadSchemaProperties(this.schema, 'table');\n });\n }\n\n private async _createTableMeta() {\n let properties: ISchemaObjectExtensionField[] = [];\n const renders: Record<string, TypeTableCellRender<TData>> = {};\n if (!this.properties) return { properties, renders };\n const promises: Promise<any>[] = [];\n for (const property of this.properties) {\n const key = property.key!;\n // columnScope\n const columnScope = this.getColumnScope(key);\n // renderContext\n const jsxRenderContext = this.getColumnJsxRenderContext(columnScope);\n // columnProps\n const { visible, render, columnProps } = this.getColumnComponentPropsTop(\n key,\n columnScope,\n jsxRenderContext,\n );\n // visible\n if (visible === false) continue;\n // property\n properties.push(property);\n // render\n promises.push(this._createColumnRender(render, columnProps, columnScope, jsxRenderContext));\n }\n let res = await Promise.all(promises);\n properties = properties.filter((_item, index) => !!res[index]);\n res = res.filter(item => !!item);\n properties.forEach((item, index) => {\n renders[item.key!] = res[index];\n });\n return { properties, renders };\n }\n\n public getColumnJsxRenderContext(celScope: ITableColumnScope): IJsxRenderContextTableColumn {\n return {\n app: this.app,\n ctx: this.ctx,\n $scene: 'tableColumn',\n $host: this,\n $celScope: celScope,\n $jsx: this.zovaJsx,\n $$table: this,\n };\n }\n\n public getCellJsxRenderContext(\n celScope: ITableCellScope,\n cellContext: CellContext<TData, any>,\n ): IJsxRenderContextTableCell {\n return {\n app: this.app,\n ctx: this.ctx,\n $scene: 'tableCell',\n $host: this,\n $celScope: celScope,\n $jsx: this.zovaJsx,\n $$table: this,\n cellContext,\n };\n }\n\n public async cellRenderPrepare(\n renders: TypeTableCellRenderComponent | TypeTableCellRenderComponent[],\n ) {\n if (!Array.isArray(renders)) renders = [renders];\n const renderProviders = renders.map(item => this.getRenderProvider(item));\n const promises: Promise<any>[] = renderProviders.map(renderProvider =>\n (async () => {\n if (typeof renderProvider === 'string' && renderProvider.includes('.tableCell.')) {\n return await this.app.bean._getBean(renderProvider as any, true);\n }\n })(),\n );\n return await Promise.all(promises);\n }\n\n private async _createColumnRender(\n render: TypeTableCellRenderComponent | undefined,\n columnProps: ITableCellRenderColumnProps | undefined,\n columnScope: ITableColumnScope,\n renderContext: IJsxRenderContextTableColumn,\n ): Promise<TypeTableCellRender<TData, any> | undefined> {\n // renderProvider\n const renderProvider = this.getRenderProvider(render);\n // beanInstance\n let beanInstance: ITableCellRender | undefined;\n if (typeof renderProvider === 'string' && renderProvider.includes('.tableCell.')) {\n beanInstance = await this.app.bean._getBean(renderProvider as any, true);\n const beanOptions = appResource.getBean(renderProvider as any);\n const onionOptions = beanOptions?.options as IDecoratorTableCellOptions | undefined;\n columnProps = deepExtend({}, onionOptions, columnProps);\n // should not eval jsx columnProps\n // columnProps = this.zovaJsx.renderJsxProps(columnProps as any, {}, columnScope, renderContext) as any;\n if (\n beanInstance?.checkVisible &&\n !(await beanInstance.checkVisible(columnProps as any, renderContext))\n ) {\n return;\n }\n }\n return cellContext => {\n if (!cellContext) return;\n return this._cellRender(\n render,\n columnProps,\n columnScope,\n cellContext,\n renderProvider,\n beanInstance,\n undefined,\n undefined,\n undefined,\n );\n };\n }\n\n public cellRender(\n render: TypeTableCellRenderComponent,\n columnProps: IResourceTableActionRowOptionsBase,\n renderContext: IJsxRenderContextTableCell,\n ) {\n // render\n const cellScope = renderContext.$celScope;\n // renderProvider\n const renderProvider = this.getRenderProvider(render);\n // beanInstance\n let beanInstance: ITableCellRender | undefined;\n if (typeof renderProvider === 'string' && renderProvider.includes('.tableCell.')) {\n beanInstance = this.app.bean._getBeanSyncOnly(renderProvider as any);\n const beanOptions = appResource.getBean(renderProvider as any);\n const onionOptions = beanOptions?.options as IDecoratorTableCellOptions | undefined;\n columnProps = deepExtend({}, onionOptions, columnProps);\n // should not eval jsx columnProps\n // columnProps = this.zovaJsx.renderJsxProps(columnProps as any, {}, renderContext.$celScope, renderContext) as any;\n }\n // const cellProps = isJsxComponent(render) ? Object.assign({}, columnProps, cast(render).props) : columnProps;\n const cellProps = columnProps;\n return this._cellRender(\n render,\n columnProps as ITableCellRenderColumnProps,\n undefined,\n renderContext.cellContext,\n renderProvider,\n beanInstance,\n cellProps,\n cellScope,\n renderContext,\n );\n }\n\n private _cellRender(\n render: TypeTableCellRenderComponent | undefined,\n columnProps: ITableCellRenderColumnProps | undefined,\n columnScope: ITableColumnScope | undefined,\n cellContext: CellContext<TData, any>,\n renderProvider: TypeTableCellRenderComponentProvider,\n beanInstance: ITableCellRender | undefined,\n cellProps: any | undefined,\n cellScope: ITableCellScope | undefined,\n jsxRenderContext: IJsxRenderContextTableCell | undefined,\n ) {\n return this.zovaJsx.setTransientObject(\n {\n getValue: (name: string) => {\n return cellContext.row.getValue(name);\n },\n },\n () => {\n return this._cellRenderInner(\n render,\n columnProps,\n columnScope,\n cellContext,\n renderProvider,\n beanInstance,\n cellProps,\n cellScope,\n jsxRenderContext,\n );\n },\n );\n }\n\n private _cellRenderInner(\n render: TypeTableCellRenderComponent | undefined,\n columnProps: ITableCellRenderColumnProps | undefined,\n columnScope: ITableColumnScope | undefined,\n cellContext: CellContext<TData, any>,\n renderProvider: TypeTableCellRenderComponentProvider,\n beanInstance: ITableCellRender | undefined,\n cellProps: any | undefined,\n cellScope: ITableCellScope | undefined,\n jsxRenderContext: IJsxRenderContextTableCell | undefined,\n ) {\n // value\n const value = cellContext.getValue();\n // renderFallbackValue\n const fallbackValue = this.table.options.renderFallbackValue;\n // cellScope\n if (!cellScope) {\n cellScope = objectAssignReactive({}, columnScope, { value, fallbackValue })!;\n }\n // render: text\n if (renderProvider === ('text' as TypeTableCellRenderComponent)) {\n return isNilOrEmptyString(value) ? fallbackValue : value;\n }\n // renderContext\n if (!jsxRenderContext) {\n jsxRenderContext = this.getCellJsxRenderContext(cellScope, cellContext);\n }\n // beanInstance\n if (beanInstance) {\n // jsx: props\n if (!cellProps) {\n // cellProps = isJsxComponent(render) ? Object.assign({}, columnProps, cast(render).props) : columnProps;\n cellProps = columnProps;\n }\n const cellProps2 = this.zovaJsx.renderJsxProps(\n cellProps,\n {},\n cellScope,\n jsxRenderContext,\n ) as any;\n if (cellProps2.class || cellProps2.style) {\n cellProps2.class = jsxRenderContext.$host.$cssMerge(\n cellProps2.class,\n jsxRenderContext.$host.$style(cellProps2.style),\n );\n delete cellProps2.style;\n }\n return beanInstance.render(cellProps2, jsxRenderContext, () => {\n const children = isJsxComponent(render) && cast(render).children;\n if (children && children.length > 0) {\n return this.zovaJsx.renderJsxChildrenDirect(children, cellScope, jsxRenderContext);\n } else {\n return value;\n }\n });\n }\n // general component\n return this.zovaJsx.render(render!, {}, cellScope, jsxRenderContext);\n }\n\n public getColumnProperty(name: string): ISchemaObjectExtensionField | undefined {\n if (!this.properties) return;\n return this.properties.find(item => item.key === name);\n }\n\n private _getColumnCelEnv(): typeof celEnvBase {\n const celEnv = celEnvBase.clone();\n celEnv.registerFunction('getProperty(string):dyn', name => {\n return this.getColumnProperty(name);\n });\n celEnv.registerFunction('getValue(string):dyn', name => {\n return this.zovaJsx.transientObject.getValue(name) ?? null;\n });\n celEnv.registerFunction('getValue(string, dyn):dyn', (name, defaultValue) => {\n return this.zovaJsx.transientObject.getValue(name) ?? defaultValue;\n });\n return celEnv;\n }\n\n public getColumnScope(name: string, scopeExtra?: {}): ITableColumnScope {\n return objectAssignReactive({}, this.$props.tableScope, {\n name,\n property: this.getColumnProperty(name),\n ...scopeExtra,\n });\n }\n\n public getColumnComponentPropsTop(\n name: string,\n celScope: {},\n renderContext: {},\n ): ITableCellRenderColumnOptions {\n const property = this.getColumnProperty(name);\n const rest = property?.rest;\n return this._getColumnComponentPropsTopByRest(rest, name, celScope, renderContext);\n }\n\n private _getColumnComponentPropsTopByRest(\n rest: ISchemaObjectExtensionFieldRest | undefined,\n name: string,\n celScope: {},\n _renderContext: {},\n ): ITableCellRenderColumnOptions {\n const visible = this.zovaJsx.evaluateExpression(rest?.visible, celScope);\n const render = rest?.render as TypeTableCellRenderComponent | undefined;\n const columnProps = Object.assign({ key: name }, cast(rest)?.columnProps);\n return { visible, render, columnProps };\n }\n\n // public getRenderFlattern(render: TypeTableCellRenderComponent): TypeTableCellRenderComponent {\n // return isJsxComponent(render) ? cast(render).type : render;\n // }\n\n public getRenderProvider(\n render: TypeTableCellRenderComponent | undefined,\n ): TypeTableCellRenderComponentProvider {\n if (!render) return 'text';\n if (typeof render === 'string' && render.includes(':')) {\n return beanFullNameFromOnionName(render, 'tableCell');\n }\n return render;\n }\n}\n","import type { AriaAttributes, CSSProperties } from 'vue';\n\nimport { FlexRender } from '@tanstack/vue-table';\nimport { BeanRenderBase } from 'zova';\nimport { Render } from 'zova-module-a-bean';\n\nimport { TableColumnIdSelection } from '../../types/table.js';\n\n@Render()\nexport class RenderTable extends BeanRenderBase {\n private _getColumnStyle(column: any): CSSProperties {\n const rest = (column.columnDef.meta as any)?.rest;\n const fixed = column.getIsPinned();\n const width = rest?.width ? `${rest.width}px` : undefined;\n return {\n width,\n minWidth: width,\n textAlign: rest?.align,\n position: fixed ? ('sticky' as const) : undefined,\n left: fixed === 'left' ? `${column.getStart('left')}px` : undefined,\n right: fixed === 'right' ? `${column.getAfter('right')}px` : undefined,\n zIndex: fixed ? 1 : undefined,\n };\n }\n\n private _renderTableDefault() {\n const table = this.table;\n return (\n <table class=\"table\">\n <thead>\n <tr>\n {table.getFlatHeaders().map(header => {\n const column = header.column;\n const canSort = column.getCanSort();\n const sorted = column.getIsSorted();\n const fixed = column.getIsPinned();\n const headerDefinition = column.columnDef.header;\n const selection = column.id === TableColumnIdSelection;\n const headerContent = selection ? (\n <input\n type=\"checkbox\"\n checked={table.getIsAllPageRowsSelected()}\n indeterminate={table.getIsSomePageRowsSelected()}\n aria-checked={table.getIsSomePageRowsSelected() ? 'mixed' : undefined}\n aria-label=\"Select all rows on this page\"\n disabled={table.getRowModel().rows.every(row => !row.getCanSelect())}\n onChange={table.getToggleAllPageRowsSelectedHandler()}\n />\n ) : (\n <FlexRender render={headerDefinition} props={header.getContext()}></FlexRender>\n );\n let sortAria: AriaAttributes['aria-sort'] = 'none';\n let sortIcon: '▲' | '▼' | '↕' = '↕';\n if (sorted === 'asc') {\n sortAria = 'ascending';\n sortIcon = '▲';\n } else if (sorted === 'desc') {\n sortAria = 'descending';\n sortIcon = '▼';\n }\n return (\n <th\n key={header.id}\n class={fixed ? 'bg-base-100' : undefined}\n style={this._getColumnStyle(column)}\n aria-sort={sortAria}\n >\n {canSort ? (\n <button\n type=\"button\"\n class=\"inline-flex w-full items-center gap-1\"\n onClick={column.getToggleSortingHandler()}\n aria-label={`Sort by ${column.id}`}\n >\n {headerContent}\n <span aria-hidden=\"true\">{sortIcon}</span>\n </button>\n ) : (\n headerContent\n )}\n </th>\n );\n })}\n </tr>\n </thead>\n <tbody>\n {table.getRowModel().rows.map(row => {\n return (\n <tr key={row.id} aria-selected={row.getIsSelected()}>\n {row.getVisibleCells().map(cell => {\n const column = cell.column;\n const selection = column.id === TableColumnIdSelection;\n return (\n <td\n key={cell.id}\n class={column.getIsPinned() ? 'bg-base-100' : undefined}\n style={this._getColumnStyle(column)}\n >\n {selection ? (\n <input\n type=\"checkbox\"\n checked={row.getIsSelected()}\n disabled={!row.getCanSelect()}\n aria-label={`Select row ${row.id}`}\n onChange={row.getToggleSelectedHandler()}\n />\n ) : (\n <FlexRender\n render={column.columnDef.cell}\n props={cell.getContext()}\n ></FlexRender>\n )}\n </td>\n );\n })}\n </tr>\n );\n })}\n </tbody>\n </table>\n );\n }\n\n public render() {\n return this.$slotDefault ? this.$slotDefault(this) : this._renderTableDefault();\n }\n}\n","import { defineComponent } from 'vue';\nimport { prepareComponentOptions, useController } from 'zova';\nimport { ControllerTable } from '../../component/table/controller.jsx';\nimport { RenderTable } from '../../component/table/render.jsx';\nexport const ZTable = defineComponent(_props => {\n useController(ControllerTable, RenderTable, undefined);\n return () => {};\n}, prepareComponentOptions());","export const config = _sys => {\n return {\n renderFallbackValue: '--'\n };\n};","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\n// eslint-disable\n/** controller: begin */\nexport * from '../component/table/controller.jsx';\nimport 'zova';\n/** controller: end */\n/** controller: begin */\nimport { ControllerTable } from '../component/table/controller.jsx';\nimport 'zova';\n/** controller: end */\n\n/** components: begin */\nexport * from './component/table.js';\nimport { ZTable } from './component/table.js';\nexport const components = {\n 'table': ZTable\n};\nimport 'zova';\n/** components: end */\n/** render: begin */\nexport * from '../component/table/render.jsx';\nimport 'zova';\n/** render: end */\n/** render: begin */\nimport { RenderTable } from '../component/table/render.jsx';\nimport 'zova';\n/** render: end */\n/** config: begin */\nexport * from '../config/config.js';\n/** config: end */\n/** scope: begin */\nimport { BeanScopeBase } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\nexport let ScopeModuleATable = (_dec = Scope(), _dec2 = __z_BeanInfo({\n module: \"a-table\"\n}), _dec(_class = _dec2(_class = class ScopeModuleATable extends BeanScopeBase {}) || _class) || _class);\nimport 'zova';\n\n/** scope: end */","import { useVueTable } from '@tanstack/vue-table';\nimport { markRaw } from 'vue';\nimport { BeanControllerPageBase } from 'zova';\nexport class BeanControllerPageTableBase extends BeanControllerPageBase {\n constructor(...args) {\n super(...args);\n this.table = void 0;\n }\n $useTable(initialOptions) {\n return this.ctx.util.instanceScope(() => {\n return markRaw(useVueTable(initialOptions));\n });\n }\n async refreshMeta() {\n throw new Error('should implement refreshMeta');\n }\n}","import { createBeanDecorator } from 'zova';\nexport function TableCell(options) {\n return createBeanDecorator('tableCell', 'app', true, options);\n}"],"mappings":";;;;;;;AAGA,IAAa,0BAAb,cAA6C,mBAAmB;CAC9D,YAAY,GAAG,MAAM;EACnB,MAAM,GAAG,IAAI;EACb,KAAK,QAAQ,KAAK;CACpB;CACA,UAAU,gBAAgB;EACxB,OAAO,KAAK,IAAI,KAAK,oBAAoB;GACvC,OAAO,QAAQ,YAAY,cAAc,CAAC;EAC5C,CAAC;CACH;CACA,MAAM,cAAc;EAClB,MAAM,IAAI,MAAM,8BAA8B;CAChD;AACF;;;AChBA,IAAa,yBAAyB;;;;ACmEtC,IACagB,mBAAeC,SAD3BJ,WAAW,GAACK,UAAAC,SAAA,EAAAC,QAAA,UAAA,CAAA,GAAAH,OAAAI,WAAAH,QAAAG,YAAAC,mBAAb,MACaN,wBAA+CF,wBAA+B;CAAAS,YAAA,GAAAC,MAAA;EAAA,MAAA,GAAAA,IAAA;EAGzF,KAEAC,aAAU,KAAA;EAAA,KACVC,UAAO,KAAA;EAAA,KACPC,Y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;CACA,MAAM,cAAc;EAClB,MAAM,IAAI,MAAM,8BAA8B;CAChD;AACF;;;ACfA,SAAgB,UAAU,SAAS;CACjC,OAAO,oBAAoB,aAAa,OAAO,MAAM,OAAO;AAC9D"}
@@ -1,15 +1,15 @@
1
1
  import type { ColumnDef, useVueTable } from '@tanstack/vue-table';
2
- import type { SchemaObject } from 'openapi3-ts/oas31';
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>;
7
+ export declare const TableColumnIdSelection = "$$selection";
8
8
  export interface ITableMeta<TData extends {} = {}> {
9
- properties: SchemaObject[];
9
+ properties: ISchemaObjectExtensionField[];
10
10
  renders: Record<string, TypeTableCellRender<TData>>;
11
11
  }
12
- export type TypeTableGetColumnsNext<TData extends {} = {}> = (properties?: SchemaObject[]) => Promise<TypeColumn<TData>[]>;
12
+ export type TypeTableGetColumnsNext<TData extends {} = {}> = (properties?: ISchemaObjectExtensionField[]) => Promise<TypeColumn<TData>[]>;
13
13
  export type TypeTableCreateColumnRender<TData extends {} = {}> = (key: string, render: TypeTableCellRenderComponent) => Promise<TypeTableCellRender<TData, any> | undefined>;
14
14
  export type TypeTableGetColumns<TData extends {} = {}> = (next: TypeTableGetColumnsNext<TData>, createColumnRender: TypeTableCreateColumnRender<TData>, table: ControllerTable<TData>) => Promise<TypeColumn<TData>[]>;
15
15
  //# 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,C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AmB,CAAC,KAAK,SAAS,EAAE,GAAG,EAAE,IAAI,CACvD,IAAI,EAAE,uBAAuB,CAAC,KAAK,CAAC,EACpC,kBAAkB,EAAE,2BAA2B,CAAC,KAAK,CAAC,EACtD,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,KAC1B,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zova-module-a-table",
3
- "version": "5.1.38",
4
- "gitHead": "eb85d771ef75776a439e56df3af8be6a3a36c1c2",
3
+ "version": "5.1.40",
4
+ "gitHead": "8ecb407bf2c0bb2e28592206ca1a39f37ab50902",
5
5
  "description": "",
6
6
  "keywords": [
7
7
  "Zova Module"
@@ -10,8 +10,12 @@ import { celEnvBase, isNilOrEmptyString } from '@cabloy/utils';
10
10
  import {
11
11
  CellContext,
12
12
  createColumnHelper,
13
+ functionalUpdate,
13
14
  getCoreRowModel,
15
+ OnChangeFn,
14
16
  Row,
17
+ RowSelectionState,
18
+ SortingState,
15
19
  TableOptionsWithReactiveData,
16
20
  } from '@tanstack/vue-table';
17
21
  import { SchemaObject } from 'openapi3-ts/oas31';
@@ -43,11 +47,18 @@ import type {
43
47
  } from '../../types/tableColumn.js';
44
48
 
45
49
  import { BeanControllerTableBase } from '../../lib/beanControllerTableBase.js';
50
+ import { TableColumnIdSelection } from '../../types/table.js';
46
51
  import { ITableCellRenderColumnOptions } from '../../types/tableColumn.js';
47
52
 
48
53
  export interface ControllerTableProps<TData extends {} = {}> {
49
54
  data?: TData[];
50
55
  schema?: SchemaObject;
56
+ schemaOrder?: SchemaObject;
57
+ sorting?: SortingState;
58
+ onSortingChange?: OnChangeFn<SortingState>;
59
+ enableRowSelection?: boolean | ((row: Row<TData>) => boolean);
60
+ rowSelection?: RowSelectionState;
61
+ onRowSelectionChange?: OnChangeFn<RowSelectionState>;
51
62
  tableScope?: ITableScope;
52
63
  getColumns?: TypeTableGetColumns<TData>;
53
64
  slotDefault?: (table: ControllerTable<TData>) => VNode;
@@ -83,6 +94,13 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
83
94
  await this.refreshMeta();
84
95
  },
85
96
  );
97
+ this.$watch(
98
+ () => this.$props.enableRowSelection,
99
+ async (newValue, oldValue) => {
100
+ if (newValue === oldValue) return;
101
+ await this.refreshMeta();
102
+ },
103
+ );
86
104
  // table
87
105
  this._createTable();
88
106
  }
@@ -95,19 +113,52 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
95
113
  return this.$props.data;
96
114
  }
97
115
 
116
+ public get sorting() {
117
+ return this.$props.sorting ?? [];
118
+ }
119
+
120
+ public get rowSelection() {
121
+ return this.$props.rowSelection ?? {};
122
+ }
123
+
98
124
  public async refreshMeta() {
99
125
  this.tableMeta = await this._createTableMeta();
100
126
  this.columns = await this._createColumns();
127
+ this.table?.setColumnPinning(this._getColumnPinning());
101
128
  }
102
129
 
103
130
  private _createTable() {
104
131
  // eslint-disable-next-line
105
132
  const self = this;
106
133
  const tableOptions: TableOptionsWithReactiveData<TData> = {
107
- getRowId: this.$props.getRowId ?? ((originalRow: TData) => cast(originalRow).id),
134
+ getRowId: (originalRow, index, parent) => this._getRowId(originalRow, index, parent),
108
135
  getCoreRowModel: getCoreRowModel(),
109
136
  renderFallbackValue: this.scope.config.renderFallbackValue,
110
137
  manualPagination: true,
138
+ manualSorting: true,
139
+ enableMultiSort: false,
140
+ enableSortingRemoval: false,
141
+ enableRowSelection: row => self._canSelectRow(row),
142
+ state: {
143
+ get sorting() {
144
+ return self.sorting;
145
+ },
146
+ get rowSelection() {
147
+ return self.rowSelection;
148
+ },
149
+ },
150
+ onSortingChange: updater => {
151
+ const sorting = functionalUpdate(updater, self.sorting).slice(0, 1);
152
+ self.$props.onSortingChange?.(sorting);
153
+ },
154
+ onRowSelectionChange: updater => {
155
+ const rowSelection = functionalUpdate(updater, self.rowSelection);
156
+ self.$props.onRowSelectionChange?.(rowSelection);
157
+ },
158
+ get initialState() {
159
+ const columnPinning = self._getColumnPinning();
160
+ return { columnPinning };
161
+ },
111
162
  get data() {
112
163
  return self.data || [];
113
164
  },
@@ -116,35 +167,55 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
116
167
  },
117
168
  };
118
169
  this.table = this.$useTable(tableOptions);
170
+ this.table.setColumnPinning(this._getColumnPinning());
119
171
  }
120
172
 
121
173
  private async _createColumns() {
122
174
  if (!this.properties) return [];
123
- if (!this.$props.getColumns) return await this._createColumnsMiddle(this.tableMeta.properties);
124
- return await this.$props.getColumns(
125
- async properties => {
126
- return await this._createColumnsMiddle(properties ?? this.tableMeta.properties);
127
- },
128
- async (
129
- key: string,
130
- render: TypeTableCellRenderComponent,
131
- ): Promise<TypeTableCellRender<TData, any> | undefined> => {
132
- // columnScope
133
- const columnScope = this.getColumnScope(key);
134
- // renderContext
135
- const jsxRenderContext = this.getColumnJsxRenderContext(columnScope);
136
- // columnProps
137
- const { visible, columnProps } = this.getColumnComponentPropsTop(
138
- key,
139
- columnScope,
140
- jsxRenderContext,
175
+ const columns = !this.$props.getColumns
176
+ ? await this._createColumnsMiddle(this.tableMeta.properties)
177
+ : await this.$props.getColumns(
178
+ async properties => {
179
+ return await this._createColumnsMiddle(properties ?? this.tableMeta.properties);
180
+ },
181
+ async (
182
+ key: string,
183
+ render: TypeTableCellRenderComponent,
184
+ ): Promise<TypeTableCellRender<TData, any> | undefined> => {
185
+ // columnScope
186
+ const columnScope = this.getColumnScope(key);
187
+ // renderContext
188
+ const jsxRenderContext = this.getColumnJsxRenderContext(columnScope);
189
+ // columnProps
190
+ const { visible, columnProps } = this.getColumnComponentPropsTop(
191
+ key,
192
+ columnScope,
193
+ jsxRenderContext,
194
+ );
195
+ // visible
196
+ if (visible === false) return;
197
+ return await this._createColumnRender(
198
+ render,
199
+ columnProps,
200
+ columnScope,
201
+ jsxRenderContext,
202
+ );
203
+ },
204
+ this,
141
205
  );
142
- // visible
143
- if (visible === false) return;
144
- return await this._createColumnRender(render, columnProps, columnScope, jsxRenderContext);
145
- },
146
- this,
147
- );
206
+ if (!this.$props.enableRowSelection) return columns;
207
+ const columnHelper = createColumnHelper<TData>();
208
+ return [
209
+ columnHelper.display({
210
+ id: TableColumnIdSelection,
211
+ header: '',
212
+ cell: '',
213
+ size: 48,
214
+ enableSorting: false,
215
+ meta: { rest: { fixed: 'left', width: 48, align: 'center' } },
216
+ }),
217
+ ...columns,
218
+ ];
148
219
  }
149
220
 
150
221
  private async _createColumnsMiddle(
@@ -162,12 +233,51 @@ export class ControllerTable<TData extends {} = {}> extends BeanControllerTableB
162
233
  return property?.title || key;
163
234
  },
164
235
  cell: props => tableMeta.renders[key](props),
236
+ size: property.rest?.width,
237
+ enableSorting: property.rest?.enableSorting === true && this._isOrderable(property),
238
+ sortDescFirst: property.rest?.sortDescFirst === true,
239
+ meta: { rest: property.rest },
165
240
  }),
166
241
  );
167
242
  }
168
243
  return columns;
169
244
  }
170
245
 
246
+ private _getRowId(originalRow: TData, index: number, parent?: Row<TData>) {
247
+ const id = this.$props.getRowId?.(originalRow, index, parent) ?? cast(originalRow).id;
248
+ if (isNilOrEmptyString(id)) {
249
+ return `__unselectable_${parent ? `${parent.id}.` : ''}${index}`;
250
+ }
251
+ return String(id);
252
+ }
253
+
254
+ private _canSelectRow(row: Row<TData>) {
255
+ const enableRowSelection = this.$props.enableRowSelection;
256
+ if (!enableRowSelection) return false;
257
+ const originalId =
258
+ this.$props.getRowId?.(row.original, row.index, row.getParentRow()) ?? cast(row.original).id;
259
+ if (isNilOrEmptyString(originalId)) return false;
260
+ return typeof enableRowSelection === 'function' ? enableRowSelection(row) : true;
261
+ }
262
+
263
+ private _getColumnPinning() {
264
+ const left: string[] = this.$props.enableRowSelection ? [TableColumnIdSelection] : [];
265
+ const right: string[] = [];
266
+ for (const property of this.tableMeta?.properties ?? []) {
267
+ const fixed = property.rest?.fixed;
268
+ if (fixed === 'left') left.push(property.key!);
269
+ if (fixed === 'right') right.push(property.key!);
270
+ }
271
+ return { left, right };
272
+ }
273
+
274
+ private _isOrderable(property: ISchemaObjectExtensionField) {
275
+ const properties = this.$props.schemaOrder?.properties;
276
+ if (!properties) return false;
277
+ const keys = [property.key, property.schemaKey, ...(property.schemaKeys ?? [])];
278
+ return keys.some(key => key && Object.prototype.hasOwnProperty.call(properties, key));
279
+ }
280
+
171
281
  private _createProperties() {
172
282
  this.properties = this.$computed(() => {
173
283
  return this.$sdk.loadSchemaProperties(this.schema, 'table');
@@ -1,9 +1,28 @@
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
 
7
+ import { TableColumnIdSelection } from '../../types/table.js';
8
+
5
9
  @Render()
6
10
  export class RenderTable extends BeanRenderBase {
11
+ private _getColumnStyle(column: any): CSSProperties {
12
+ const rest = (column.columnDef.meta as any)?.rest;
13
+ const fixed = column.getIsPinned();
14
+ const width = rest?.width ? `${rest.width}px` : undefined;
15
+ return {
16
+ width,
17
+ minWidth: width,
18
+ textAlign: rest?.align,
19
+ position: fixed ? ('sticky' as const) : undefined,
20
+ left: fixed === 'left' ? `${column.getStart('left')}px` : undefined,
21
+ right: fixed === 'right' ? `${column.getAfter('right')}px` : undefined,
22
+ zIndex: fixed ? 1 : undefined,
23
+ };
24
+ }
25
+
7
26
  private _renderTableDefault() {
8
27
  const table = this.table;
9
28
  return (
@@ -11,12 +30,54 @@ export class RenderTable extends BeanRenderBase {
11
30
  <thead>
12
31
  <tr>
13
32
  {table.getFlatHeaders().map(header => {
33
+ const column = header.column;
34
+ const canSort = column.getCanSort();
35
+ const sorted = column.getIsSorted();
36
+ const fixed = column.getIsPinned();
37
+ const headerDefinition = column.columnDef.header;
38
+ const selection = column.id === TableColumnIdSelection;
39
+ const headerContent = selection ? (
40
+ <input
41
+ type="checkbox"
42
+ checked={table.getIsAllPageRowsSelected()}
43
+ indeterminate={table.getIsSomePageRowsSelected()}
44
+ aria-checked={table.getIsSomePageRowsSelected() ? 'mixed' : undefined}
45
+ aria-label="Select all rows on this page"
46
+ disabled={table.getRowModel().rows.every(row => !row.getCanSelect())}
47
+ onChange={table.getToggleAllPageRowsSelectedHandler()}
48
+ />
49
+ ) : (
50
+ <FlexRender render={headerDefinition} props={header.getContext()}></FlexRender>
51
+ );
52
+ let sortAria: AriaAttributes['aria-sort'] = 'none';
53
+ let sortIcon: '▲' | '▼' | '↕' = '↕';
54
+ if (sorted === 'asc') {
55
+ sortAria = 'ascending';
56
+ sortIcon = '▲';
57
+ } else if (sorted === 'desc') {
58
+ sortAria = 'descending';
59
+ sortIcon = '▼';
60
+ }
14
61
  return (
15
- <th key={header.id}>
16
- <FlexRender
17
- render={header.column.columnDef.header}
18
- props={header.getContext()}
19
- ></FlexRender>
62
+ <th
63
+ key={header.id}
64
+ class={fixed ? 'bg-base-100' : undefined}
65
+ style={this._getColumnStyle(column)}
66
+ aria-sort={sortAria}
67
+ >
68
+ {canSort ? (
69
+ <button
70
+ type="button"
71
+ class="inline-flex w-full items-center gap-1"
72
+ onClick={column.getToggleSortingHandler()}
73
+ aria-label={`Sort by ${column.id}`}
74
+ >
75
+ {headerContent}
76
+ <span aria-hidden="true">{sortIcon}</span>
77
+ </button>
78
+ ) : (
79
+ headerContent
80
+ )}
20
81
  </th>
21
82
  );
22
83
  })}
@@ -25,14 +86,30 @@ export class RenderTable extends BeanRenderBase {
25
86
  <tbody>
26
87
  {table.getRowModel().rows.map(row => {
27
88
  return (
28
- <tr key={row.id}>
89
+ <tr key={row.id} aria-selected={row.getIsSelected()}>
29
90
  {row.getVisibleCells().map(cell => {
91
+ const column = cell.column;
92
+ const selection = column.id === TableColumnIdSelection;
30
93
  return (
31
- <td key={cell.id}>
32
- <FlexRender
33
- render={cell.column.columnDef.cell}
34
- props={cell.getContext()}
35
- ></FlexRender>
94
+ <td
95
+ key={cell.id}
96
+ class={column.getIsPinned() ? 'bg-base-100' : undefined}
97
+ style={this._getColumnStyle(column)}
98
+ >
99
+ {selection ? (
100
+ <input
101
+ type="checkbox"
102
+ checked={row.getIsSelected()}
103
+ disabled={!row.getCanSelect()}
104
+ aria-label={`Select row ${row.id}`}
105
+ onChange={row.getToggleSelectedHandler()}
106
+ />
107
+ ) : (
108
+ <FlexRender
109
+ render={column.columnDef.cell}
110
+ props={cell.getContext()}
111
+ ></FlexRender>
112
+ )}
36
113
  </td>
37
114
  );
38
115
  })}
@@ -1,6 +1,8 @@
1
1
  import type { ColumnDef, useVueTable } from '@tanstack/vue-table';
2
- import type { SchemaObject } from 'openapi3-ts/oas31';
3
- import type { TypeTableCellRenderComponent } from 'zova-module-a-openapi';
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';
@@ -9,13 +11,15 @@ export type TypeTable<TData extends {} = {}> = ReturnType<typeof useVueTable<TDa
9
11
 
10
12
  export type TypeColumn<TData extends {} = {}> = ColumnDef<TData, any>;
11
13
 
14
+ export const TableColumnIdSelection = '$$selection';
15
+
12
16
  export interface ITableMeta<TData extends {} = {}> {
13
- properties: SchemaObject[];
17
+ properties: ISchemaObjectExtensionField[];
14
18
  renders: Record<string, TypeTableCellRender<TData>>;
15
19
  }
16
20
 
17
21
  export type TypeTableGetColumnsNext<TData extends {} = {}> = (
18
- properties?: SchemaObject[],
22
+ properties?: ISchemaObjectExtensionField[],
19
23
  ) => Promise<TypeColumn<TData>[]>;
20
24
 
21
25
  export type TypeTableCreateColumnRender<TData extends {} = {}> = (