cosey 0.2.14 → 0.2.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.
@@ -95,6 +95,9 @@ function exportRenderer(row, column, cellValue, index) {
95
95
  if (column.formatter) {
96
96
  return column.formatter(row, column, cellValue, index);
97
97
  }
98
+ if (column.format) {
99
+ return column.format(cellValue, row, column, index);
100
+ }
98
101
  if (isEmpty(cellValue)) {
99
102
  return "";
100
103
  }
@@ -1,4 +1,5 @@
1
- import { type ExtractPropTypes, type PropType } from 'vue';
1
+ import { type VNode, type ExtractPropTypes, type PropType } from 'vue';
2
+ import { type TableColumnCtx } from 'element-plus';
2
3
  import elTableColumnProps from 'element-plus/es/components/table/src/table-column/defaults.mjs';
3
4
  import { type RendererType } from './renderer';
4
5
  export type TableColumnPropsSlots = string | ((props: {
@@ -29,6 +30,7 @@ export type TableColumnProps<T = any> = Partial<Omit<ExtractPropTypes<typeof elT
29
30
  [prop: string]: any;
30
31
  };
31
32
  tooltip?: string;
33
+ format?: (cellValue: any, row: any, column: TableColumnCtx<any>, index: number) => VNode;
32
34
  };
33
35
  export declare const tableColumnProps: {
34
36
  slots: {
@@ -54,6 +56,9 @@ export declare const tableColumnProps: {
54
56
  tooltip: {
55
57
  type: StringConstructor;
56
58
  };
59
+ format: {
60
+ type: FunctionConstructor;
61
+ };
57
62
  type: {
58
63
  type: StringConstructor;
59
64
  default: string;
@@ -3,7 +3,7 @@ import elTableColumnProps from 'element-plus/es/components/table/src/table-colum
3
3
  const tableColumnProps = {
4
4
  ...elTableColumnProps,
5
5
  slots: {
6
- type: [String, Object]
6
+ type: [String, Object, Function]
7
7
  },
8
8
  renderer: {
9
9
  type: [String, Object],
@@ -24,6 +24,9 @@ const tableColumnProps = {
24
24
  },
25
25
  tooltip: {
26
26
  type: String
27
+ },
28
+ format: {
29
+ type: Function
27
30
  }
28
31
  };
29
32
 
@@ -42,6 +42,7 @@ declare const TableColumn: import("vue").DefineComponent<{
42
42
  [prop: string]: any;
43
43
  } | undefined;
44
44
  tooltip?: string | undefined;
45
+ format?: ((cellValue: any, row: any, column: import("element-plus").TableColumnCtx<any>, index: number) => import("vue").VNode) | undefined;
45
46
  }, () => import("vue/jsx-runtime").JSX.Element | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
46
47
  label?: string | undefined;
47
48
  minWidth?: string | number | undefined;
@@ -85,6 +86,7 @@ declare const TableColumn: import("vue").DefineComponent<{
85
86
  [prop: string]: any;
86
87
  } | undefined;
87
88
  tooltip?: string | undefined;
89
+ format?: ((cellValue: any, row: any, column: import("element-plus").TableColumnCtx<any>, index: number) => import("vue").VNode) | undefined;
88
90
  }> & Readonly<{}>, {
89
91
  minWidth: string | number;
90
92
  width: string | number;
@@ -38,17 +38,23 @@ const TableColumn = defineComponent({
38
38
  }
39
39
  }
40
40
  if (!obj.formatter) {
41
- obj.formatter = (row, column, cellValue, index) => {
42
- return renderer({
43
- cellValue,
44
- row}, obj.renderer, t);
45
- };
46
- const renderType = typeof obj.renderer === "object" ? obj.renderer.type : obj.renderer;
47
- const renderProps = mapRendererColumnProps[renderType];
48
- if (renderProps) {
49
- cls.push(renderProps.className);
50
- if (renderProps.minWidth && !obj.minWidth) {
51
- obj.minWidth = renderProps.minWidth;
41
+ if (obj.format) {
42
+ obj.formatter = (row, column, cellValue, index) => {
43
+ return obj.format(cellValue, row, column, index);
44
+ };
45
+ } else {
46
+ obj.formatter = (row, column, cellValue, index) => {
47
+ return renderer({
48
+ cellValue,
49
+ row}, obj.renderer, t);
50
+ };
51
+ const renderType = typeof obj.renderer === "object" ? obj.renderer.type : obj.renderer;
52
+ const renderProps = mapRendererColumnProps[renderType];
53
+ if (renderProps) {
54
+ cls.push(renderProps.className);
55
+ if (renderProps.minWidth && !obj.minWidth) {
56
+ obj.minWidth = renderProps.minWidth;
57
+ }
52
58
  }
53
59
  }
54
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosey",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "description": "基于 Vue3 + vite 的后台管理系统框架",
5
5
  "type": "module",
6
6
  "main": "index.js",