tabula-vue 1.0.2 → 1.0.3
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/es/components/table-lite/src/display-value.d.ts +26 -0
- package/es/components/table-lite/src/display-value.mjs +82 -0
- package/es/components/table-lite/src/index.vue.d.ts +14 -14
- package/es/components/table-lite/src/index.vue2.mjs +9 -0
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/index.js +85 -2
- package/index.min.js +4 -4
- package/index.min.mjs +4 -4
- package/index.mjs +85 -2
- package/lib/components/table-lite/src/display-value.d.ts +26 -0
- package/lib/components/table-lite/src/display-value.js +86 -0
- package/lib/components/table-lite/src/index.vue.d.ts +14 -14
- package/lib/components/table-lite/src/index.vue2.js +9 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/locale/en.js +1 -1
- package/locale/en.min.js +1 -1
- package/locale/en.min.mjs +1 -1
- package/locale/en.mjs +1 -1
- package/locale/ja.js +1 -1
- package/locale/ja.min.js +1 -1
- package/locale/ja.min.mjs +1 -1
- package/locale/ja.mjs +1 -1
- package/locale/ko.js +1 -1
- package/locale/ko.min.js +1 -1
- package/locale/ko.min.mjs +1 -1
- package/locale/ko.mjs +1 -1
- package/locale/zh-cn.js +1 -1
- package/locale/zh-cn.min.js +1 -1
- package/locale/zh-cn.min.mjs +1 -1
- package/locale/zh-cn.mjs +1 -1
- package/locale/zh-hk.js +1 -1
- package/locale/zh-hk.min.js +1 -1
- package/locale/zh-hk.min.mjs +1 -1
- package/locale/zh-hk.mjs +1 -1
- package/locale/zh-tw.js +1 -1
- package/locale/zh-tw.min.js +1 -1
- package/locale/zh-tw.min.mjs +1 -1
- package/locale/zh-tw.mjs +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OptionsRow, PlusColumn } from 'tabula-vue/es/types';
|
|
2
|
+
import { VNode } from 'vue';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 同步解析 options。
|
|
6
|
+
*
|
|
7
|
+
* 支持数组 / ref / 同步函数,异步(Promise)场景直接返回空数组,
|
|
8
|
+
* 避免在纯净表格里引入每个单元格的异步副作用。
|
|
9
|
+
*/
|
|
10
|
+
export declare const resolveOptions: (options: PlusColumn['options']) => OptionsRow[];
|
|
11
|
+
/**
|
|
12
|
+
* 按列生成单元格文本格式化函数。
|
|
13
|
+
*
|
|
14
|
+
* 该函数在列级创建一次,内部持有预构建的 value → label Map,
|
|
15
|
+
* 单元格渲染时只做一次查表,不产生任何响应式依赖。
|
|
16
|
+
*
|
|
17
|
+
* @returns 无法解析(或无需解析)时返回 undefined,由调用方回退到原始值
|
|
18
|
+
*/
|
|
19
|
+
export declare const createValueTypeText: (column: PlusColumn) => ((value: unknown) => string) | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* 按列生成单元格渲染函数。
|
|
22
|
+
*
|
|
23
|
+
* 仅 tag 需要真实组件(少量使用),其余类型统一走文本,
|
|
24
|
+
* 保证纯净表格的单元格默认不创建组件实例。
|
|
25
|
+
*/
|
|
26
|
+
export declare const createValueTypeCellRender: (column: PlusColumn) => ((value: unknown) => VNode) | undefined;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { isRef, h } from 'vue';
|
|
2
|
+
import { ElTag } from 'element-plus';
|
|
3
|
+
import '../../utils/index.mjs';
|
|
4
|
+
import { isFunction } from '../../utils/is.mjs';
|
|
5
|
+
import { formatDate } from '../../utils/format.mjs';
|
|
6
|
+
|
|
7
|
+
const SELECT_TYPES = /* @__PURE__ */ new Set(["select", "radio", "checkbox"]);
|
|
8
|
+
const DATE_TYPES = /* @__PURE__ */ new Set(["date-picker"]);
|
|
9
|
+
const MONEY_TYPES = /* @__PURE__ */ new Set(["money"]);
|
|
10
|
+
const MULTIPLE_SEPARATOR = "\u3001";
|
|
11
|
+
const resolveOptions = (options) => {
|
|
12
|
+
if (!options) return [];
|
|
13
|
+
if (isRef(options)) {
|
|
14
|
+
return Array.isArray(options.value) ? options.value : [];
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(options)) return options;
|
|
17
|
+
if (isFunction(options)) {
|
|
18
|
+
const result = options();
|
|
19
|
+
return Array.isArray(result) ? result : [];
|
|
20
|
+
}
|
|
21
|
+
return [];
|
|
22
|
+
};
|
|
23
|
+
const resolveFieldProps = (column) => {
|
|
24
|
+
const fieldProps = column.fieldProps;
|
|
25
|
+
if (!fieldProps) return {};
|
|
26
|
+
if (isRef(fieldProps)) return fieldProps.value || {};
|
|
27
|
+
if (typeof fieldProps === "object") return fieldProps;
|
|
28
|
+
return {};
|
|
29
|
+
};
|
|
30
|
+
const isEmpty = (value) => value === null || value === void 0 || value === "";
|
|
31
|
+
const createValueTypeText = (column) => {
|
|
32
|
+
const valueType = column.valueType;
|
|
33
|
+
if (valueType && SELECT_TYPES.has(valueType)) {
|
|
34
|
+
const list = resolveOptions(column.options);
|
|
35
|
+
if (!list.length) return void 0;
|
|
36
|
+
const labelMap = /* @__PURE__ */ new Map();
|
|
37
|
+
list.forEach((item) => {
|
|
38
|
+
if (!isEmpty(item.value)) labelMap.set(String(item.value), item);
|
|
39
|
+
});
|
|
40
|
+
const fieldProps = resolveFieldProps(column);
|
|
41
|
+
const multiple = valueType === "checkbox" || fieldProps.multiple === true;
|
|
42
|
+
return (value) => {
|
|
43
|
+
var _a;
|
|
44
|
+
if (isEmpty(value)) return "";
|
|
45
|
+
if (multiple && Array.isArray(value)) {
|
|
46
|
+
return value.map((item) => {
|
|
47
|
+
var _a2, _b;
|
|
48
|
+
return (_b = (_a2 = labelMap.get(String(item))) == null ? void 0 : _a2.label) != null ? _b : String(item);
|
|
49
|
+
}).join(MULTIPLE_SEPARATOR);
|
|
50
|
+
}
|
|
51
|
+
const label = (_a = labelMap.get(String(value))) == null ? void 0 : _a.label;
|
|
52
|
+
return label === void 0 || label === null ? String(value) : String(label);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (valueType && DATE_TYPES.has(valueType)) {
|
|
56
|
+
const fieldProps = resolveFieldProps(column);
|
|
57
|
+
const format = fieldProps.format || "YYYY-MM-DD";
|
|
58
|
+
return (value) => isEmpty(value) ? "" : formatDate(value, format);
|
|
59
|
+
}
|
|
60
|
+
if (valueType && MONEY_TYPES.has(valueType)) {
|
|
61
|
+
const fieldProps = resolveFieldProps(column);
|
|
62
|
+
const prefix = fieldProps.format || "\uFFE5";
|
|
63
|
+
return (value) => {
|
|
64
|
+
if (isEmpty(value)) return "";
|
|
65
|
+
const num = Number(value);
|
|
66
|
+
return Number.isNaN(num) ? String(value) : `${prefix}${num.toFixed(2)}`;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return void 0;
|
|
70
|
+
};
|
|
71
|
+
const createValueTypeCellRender = (column) => {
|
|
72
|
+
if (column.valueType !== "tag") return void 0;
|
|
73
|
+
const fieldProps = resolveFieldProps(column);
|
|
74
|
+
const text = createValueTypeText(column);
|
|
75
|
+
return (value) => {
|
|
76
|
+
if (isEmpty(value)) return h("span");
|
|
77
|
+
const label = text ? text(value) : String(value);
|
|
78
|
+
return h(ElTag, { type: fieldProps.type }, () => label);
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export { createValueTypeCellRender, createValueTypeText, resolveOptions };
|
|
@@ -46,6 +46,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
46
46
|
__epPropKey: true;
|
|
47
47
|
};
|
|
48
48
|
width: (NumberConstructor | StringConstructor)[];
|
|
49
|
+
/** 内置特殊列顺序 */
|
|
49
50
|
height: (NumberConstructor | StringConstructor)[];
|
|
50
51
|
maxHeight: (NumberConstructor | StringConstructor)[];
|
|
51
52
|
fit: {
|
|
@@ -74,7 +75,6 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
74
75
|
currentRowKey: (NumberConstructor | StringConstructor)[];
|
|
75
76
|
emptyText: StringConstructor;
|
|
76
77
|
expandRowKeys: PropType<any[] | undefined>;
|
|
77
|
-
/** adaptive 计算出的高度 */
|
|
78
78
|
defaultExpandAll: BooleanConstructor;
|
|
79
79
|
defaultSort: PropType< Sort | undefined>;
|
|
80
80
|
tooltipEffect: StringConstructor;
|
|
@@ -85,7 +85,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
85
85
|
column: TableColumnCtx<any>;
|
|
86
86
|
columnIndex: number;
|
|
87
87
|
}) => number[] | {
|
|
88
|
-
rowspan: number;
|
|
88
|
+
rowspan: number; /** adaptive 计算出的高度 */
|
|
89
89
|
colspan: number;
|
|
90
90
|
} | undefined) | undefined>;
|
|
91
91
|
selectOnIndeterminate: {
|
|
@@ -148,8 +148,8 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
148
148
|
b: (blockSuffix?: string | undefined) => string;
|
|
149
149
|
e: (element?: string | undefined) => string;
|
|
150
150
|
m: (modifier?: string | undefined) => string;
|
|
151
|
-
be: (blockSuffix?: string | undefined, element?: string | undefined) => string;
|
|
152
|
-
em: (element?: string | undefined, modifier?: string | undefined) => string;
|
|
151
|
+
be: (blockSuffix?: string | undefined, element?: string | undefined) => string; /** renderHTML 单元格(可选) */
|
|
152
|
+
em: (element?: string | undefined, modifier?: string | undefined) => string; /** 纯文本单元格 */
|
|
153
153
|
bm: (blockSuffix?: string | undefined, modifier?: string | undefined) => string;
|
|
154
154
|
bem: (blockSuffix?: string | undefined, element?: string | undefined, modifier?: string | undefined) => string;
|
|
155
155
|
is: {
|
|
@@ -161,7 +161,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
161
161
|
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
|
|
162
162
|
cssVarBlockName: (name: string) => string;
|
|
163
163
|
};
|
|
164
|
-
layout: __DTS_DEFAULT_0__<any>;
|
|
164
|
+
layout: __DTS_DEFAULT_0__<any>; /** 纯文本:formatter 优先,其次 valueType 映射,最后原值;空值兜底 */
|
|
165
165
|
store: any;
|
|
166
166
|
handleHeaderFooterMousewheel: (event: any, data: any) => void;
|
|
167
167
|
handleMouseLeave: () => void;
|
|
@@ -221,7 +221,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
221
221
|
height: string;
|
|
222
222
|
maxHeight?: undefined;
|
|
223
223
|
} | {
|
|
224
|
-
maxHeight: string;
|
|
224
|
+
maxHeight: string; /** 输出所有已选行(跨页累计) */
|
|
225
225
|
height?: undefined;
|
|
226
226
|
} | {
|
|
227
227
|
height?: undefined;
|
|
@@ -243,6 +243,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
243
243
|
__epPropKey: true;
|
|
244
244
|
};
|
|
245
245
|
width: (NumberConstructor | StringConstructor)[];
|
|
246
|
+
/** 内置特殊列顺序 */
|
|
246
247
|
height: (NumberConstructor | StringConstructor)[];
|
|
247
248
|
maxHeight: (NumberConstructor | StringConstructor)[];
|
|
248
249
|
fit: {
|
|
@@ -271,7 +272,6 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
271
272
|
currentRowKey: (NumberConstructor | StringConstructor)[];
|
|
272
273
|
emptyText: StringConstructor;
|
|
273
274
|
expandRowKeys: PropType<any[] | undefined>;
|
|
274
|
-
/** adaptive 计算出的高度 */
|
|
275
275
|
defaultExpandAll: BooleanConstructor;
|
|
276
276
|
defaultSort: PropType< Sort | undefined>;
|
|
277
277
|
tooltipEffect: StringConstructor;
|
|
@@ -282,7 +282,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
282
282
|
column: TableColumnCtx<any>;
|
|
283
283
|
columnIndex: number;
|
|
284
284
|
}) => number[] | {
|
|
285
|
-
rowspan: number;
|
|
285
|
+
rowspan: number; /** adaptive 计算出的高度 */
|
|
286
286
|
colspan: number;
|
|
287
287
|
} | undefined) | undefined>;
|
|
288
288
|
selectOnIndeterminate: {
|
|
@@ -379,6 +379,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
379
379
|
__epPropKey: true;
|
|
380
380
|
};
|
|
381
381
|
width: (NumberConstructor | StringConstructor)[];
|
|
382
|
+
/** 内置特殊列顺序 */
|
|
382
383
|
height: (NumberConstructor | StringConstructor)[];
|
|
383
384
|
maxHeight: (NumberConstructor | StringConstructor)[];
|
|
384
385
|
fit: {
|
|
@@ -407,7 +408,6 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
407
408
|
currentRowKey: (NumberConstructor | StringConstructor)[];
|
|
408
409
|
emptyText: StringConstructor;
|
|
409
410
|
expandRowKeys: PropType<any[] | undefined>;
|
|
410
|
-
/** adaptive 计算出的高度 */
|
|
411
411
|
defaultExpandAll: BooleanConstructor;
|
|
412
412
|
defaultSort: PropType< Sort | undefined>;
|
|
413
413
|
tooltipEffect: StringConstructor;
|
|
@@ -418,7 +418,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
418
418
|
column: TableColumnCtx<any>;
|
|
419
419
|
columnIndex: number;
|
|
420
420
|
}) => number[] | {
|
|
421
|
-
rowspan: number;
|
|
421
|
+
rowspan: number; /** adaptive 计算出的高度 */
|
|
422
422
|
colspan: number;
|
|
423
423
|
} | undefined) | undefined>;
|
|
424
424
|
selectOnIndeterminate: {
|
|
@@ -481,8 +481,8 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
481
481
|
b: (blockSuffix?: string | undefined) => string;
|
|
482
482
|
e: (element?: string | undefined) => string;
|
|
483
483
|
m: (modifier?: string | undefined) => string;
|
|
484
|
-
be: (blockSuffix?: string | undefined, element?: string | undefined) => string;
|
|
485
|
-
em: (element?: string | undefined, modifier?: string | undefined) => string;
|
|
484
|
+
be: (blockSuffix?: string | undefined, element?: string | undefined) => string; /** renderHTML 单元格(可选) */
|
|
485
|
+
em: (element?: string | undefined, modifier?: string | undefined) => string; /** 纯文本单元格 */
|
|
486
486
|
bm: (blockSuffix?: string | undefined, modifier?: string | undefined) => string;
|
|
487
487
|
bem: (blockSuffix?: string | undefined, element?: string | undefined, modifier?: string | undefined) => string;
|
|
488
488
|
is: {
|
|
@@ -494,7 +494,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
494
494
|
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
|
|
495
495
|
cssVarBlockName: (name: string) => string;
|
|
496
496
|
};
|
|
497
|
-
layout: __DTS_DEFAULT_0__<any>;
|
|
497
|
+
layout: __DTS_DEFAULT_0__<any>; /** 纯文本:formatter 优先,其次 valueType 映射,最后原值;空值兜底 */
|
|
498
498
|
store: any;
|
|
499
499
|
handleHeaderFooterMousewheel: (event: any, data: any) => void;
|
|
500
500
|
handleMouseLeave: () => void;
|
|
@@ -554,7 +554,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
554
554
|
height: string;
|
|
555
555
|
maxHeight?: undefined;
|
|
556
556
|
} | {
|
|
557
|
-
maxHeight: string;
|
|
557
|
+
maxHeight: string; /** 输出所有已选行(跨页累计) */
|
|
558
558
|
height?: undefined;
|
|
559
559
|
} | {
|
|
560
560
|
height?: undefined;
|
|
@@ -7,6 +7,7 @@ import '../../../constants/index.mjs';
|
|
|
7
7
|
import { getLabel, getTableKey, getTableHeaderSlotName, getTableCellSlotName, getTooltip } from '../../utils/index.mjs';
|
|
8
8
|
import '../../../hooks/index.mjs';
|
|
9
9
|
import '../../table/index.mjs';
|
|
10
|
+
import { createValueTypeText, createValueTypeCellRender } from './display-value.mjs';
|
|
10
11
|
import { useLocale } from '../../../hooks/useLocale.mjs';
|
|
11
12
|
import { DefaultPageInfo } from '../../../constants/page.mjs';
|
|
12
13
|
import { useTableColumns } from '../../table/src/use-columns.mjs';
|
|
@@ -131,6 +132,8 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
131
132
|
const label = getLabel(column.label);
|
|
132
133
|
const isSimpleProp = !prop.includes(".") && !prop.includes("[");
|
|
133
134
|
const readValue = isSimpleProp ? (row) => row == null ? void 0 : row[prop] : (row) => getByPath(row, prop);
|
|
135
|
+
const valueTypeText = createValueTypeText(column);
|
|
136
|
+
const valueTypeCellRender = createValueTypeCellRender(column);
|
|
134
137
|
const cellText = (row, index) => {
|
|
135
138
|
const value = readValue(row);
|
|
136
139
|
if (isFunction(column.formatter)) {
|
|
@@ -139,6 +142,10 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
139
142
|
formatted === null || formatted === void 0 ? resolveEmptyText(column) : formatted
|
|
140
143
|
);
|
|
141
144
|
}
|
|
145
|
+
if (valueTypeText) {
|
|
146
|
+
const text = valueTypeText(value);
|
|
147
|
+
if (text !== "") return text;
|
|
148
|
+
}
|
|
142
149
|
return value === null || value === void 0 || value === "" ? String(resolveEmptyText(column)) : String(value);
|
|
143
150
|
};
|
|
144
151
|
const prepared = {
|
|
@@ -172,6 +179,8 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
172
179
|
var _a2, _b2;
|
|
173
180
|
return String((_b2 = (_a2 = column.renderHTML) == null ? void 0 : _a2.call(column, readValue(row), { row, column, index })) != null ? _b2 : "");
|
|
174
181
|
};
|
|
182
|
+
} else if (valueTypeCellRender) {
|
|
183
|
+
prepared.cellRender = ({ row }) => valueTypeCellRender(readValue(row));
|
|
175
184
|
}
|
|
176
185
|
return prepared;
|
|
177
186
|
})
|
package/es/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.0.
|
|
1
|
+
export declare const version = "1.0.3";
|
package/es/version.mjs
CHANGED
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! tabula-vue v1.0.
|
|
1
|
+
/*! tabula-vue v1.0.3 */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('element-plus')) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'element-plus'], factory) :
|
|
@@ -12345,6 +12345,81 @@
|
|
|
12345
12345
|
|
|
12346
12346
|
const PlusTable = _Table;
|
|
12347
12347
|
|
|
12348
|
+
const SELECT_TYPES = /* @__PURE__ */ new Set(["select", "radio", "checkbox"]);
|
|
12349
|
+
const DATE_TYPES = /* @__PURE__ */ new Set(["date-picker"]);
|
|
12350
|
+
const MONEY_TYPES = /* @__PURE__ */ new Set(["money"]);
|
|
12351
|
+
const MULTIPLE_SEPARATOR = "\u3001";
|
|
12352
|
+
const resolveOptions = (options) => {
|
|
12353
|
+
if (!options) return [];
|
|
12354
|
+
if (vue.isRef(options)) {
|
|
12355
|
+
return Array.isArray(options.value) ? options.value : [];
|
|
12356
|
+
}
|
|
12357
|
+
if (Array.isArray(options)) return options;
|
|
12358
|
+
if (isFunction(options)) {
|
|
12359
|
+
const result = options();
|
|
12360
|
+
return Array.isArray(result) ? result : [];
|
|
12361
|
+
}
|
|
12362
|
+
return [];
|
|
12363
|
+
};
|
|
12364
|
+
const resolveFieldProps = (column) => {
|
|
12365
|
+
const fieldProps = column.fieldProps;
|
|
12366
|
+
if (!fieldProps) return {};
|
|
12367
|
+
if (vue.isRef(fieldProps)) return fieldProps.value || {};
|
|
12368
|
+
if (typeof fieldProps === "object") return fieldProps;
|
|
12369
|
+
return {};
|
|
12370
|
+
};
|
|
12371
|
+
const isEmpty = (value) => value === null || value === void 0 || value === "";
|
|
12372
|
+
const createValueTypeText = (column) => {
|
|
12373
|
+
const valueType = column.valueType;
|
|
12374
|
+
if (valueType && SELECT_TYPES.has(valueType)) {
|
|
12375
|
+
const list = resolveOptions(column.options);
|
|
12376
|
+
if (!list.length) return void 0;
|
|
12377
|
+
const labelMap = /* @__PURE__ */ new Map();
|
|
12378
|
+
list.forEach((item) => {
|
|
12379
|
+
if (!isEmpty(item.value)) labelMap.set(String(item.value), item);
|
|
12380
|
+
});
|
|
12381
|
+
const fieldProps = resolveFieldProps(column);
|
|
12382
|
+
const multiple = valueType === "checkbox" || fieldProps.multiple === true;
|
|
12383
|
+
return (value) => {
|
|
12384
|
+
var _a;
|
|
12385
|
+
if (isEmpty(value)) return "";
|
|
12386
|
+
if (multiple && Array.isArray(value)) {
|
|
12387
|
+
return value.map((item) => {
|
|
12388
|
+
var _a2, _b;
|
|
12389
|
+
return (_b = (_a2 = labelMap.get(String(item))) == null ? void 0 : _a2.label) != null ? _b : String(item);
|
|
12390
|
+
}).join(MULTIPLE_SEPARATOR);
|
|
12391
|
+
}
|
|
12392
|
+
const label = (_a = labelMap.get(String(value))) == null ? void 0 : _a.label;
|
|
12393
|
+
return label === void 0 || label === null ? String(value) : String(label);
|
|
12394
|
+
};
|
|
12395
|
+
}
|
|
12396
|
+
if (valueType && DATE_TYPES.has(valueType)) {
|
|
12397
|
+
const fieldProps = resolveFieldProps(column);
|
|
12398
|
+
const format = fieldProps.format || "YYYY-MM-DD";
|
|
12399
|
+
return (value) => isEmpty(value) ? "" : formatDate(value, format);
|
|
12400
|
+
}
|
|
12401
|
+
if (valueType && MONEY_TYPES.has(valueType)) {
|
|
12402
|
+
const fieldProps = resolveFieldProps(column);
|
|
12403
|
+
const prefix = fieldProps.format || "\uFFE5";
|
|
12404
|
+
return (value) => {
|
|
12405
|
+
if (isEmpty(value)) return "";
|
|
12406
|
+
const num = Number(value);
|
|
12407
|
+
return Number.isNaN(num) ? String(value) : `${prefix}${num.toFixed(2)}`;
|
|
12408
|
+
};
|
|
12409
|
+
}
|
|
12410
|
+
return void 0;
|
|
12411
|
+
};
|
|
12412
|
+
const createValueTypeCellRender = (column) => {
|
|
12413
|
+
if (column.valueType !== "tag") return void 0;
|
|
12414
|
+
const fieldProps = resolveFieldProps(column);
|
|
12415
|
+
const text = createValueTypeText(column);
|
|
12416
|
+
return (value) => {
|
|
12417
|
+
if (isEmpty(value)) return vue.h("span");
|
|
12418
|
+
const label = text ? text(value) : String(value);
|
|
12419
|
+
return vue.h(elementPlus.ElTag, { type: fieldProps.type }, () => label);
|
|
12420
|
+
};
|
|
12421
|
+
};
|
|
12422
|
+
|
|
12348
12423
|
const _hoisted_1$8 = { class: "plus-table-lite__header" };
|
|
12349
12424
|
const _hoisted_2$4 = ["innerHTML"];
|
|
12350
12425
|
var _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
@@ -12461,6 +12536,8 @@
|
|
|
12461
12536
|
const label = getLabel(column.label);
|
|
12462
12537
|
const isSimpleProp = !prop.includes(".") && !prop.includes("[");
|
|
12463
12538
|
const readValue = isSimpleProp ? (row) => row == null ? void 0 : row[prop] : (row) => getByPath(row, prop);
|
|
12539
|
+
const valueTypeText = createValueTypeText(column);
|
|
12540
|
+
const valueTypeCellRender = createValueTypeCellRender(column);
|
|
12464
12541
|
const cellText = (row, index) => {
|
|
12465
12542
|
const value = readValue(row);
|
|
12466
12543
|
if (isFunction(column.formatter)) {
|
|
@@ -12469,6 +12546,10 @@
|
|
|
12469
12546
|
formatted === null || formatted === void 0 ? resolveEmptyText(column) : formatted
|
|
12470
12547
|
);
|
|
12471
12548
|
}
|
|
12549
|
+
if (valueTypeText) {
|
|
12550
|
+
const text = valueTypeText(value);
|
|
12551
|
+
if (text !== "") return text;
|
|
12552
|
+
}
|
|
12472
12553
|
return value === null || value === void 0 || value === "" ? String(resolveEmptyText(column)) : String(value);
|
|
12473
12554
|
};
|
|
12474
12555
|
const prepared = {
|
|
@@ -12502,6 +12583,8 @@
|
|
|
12502
12583
|
var _a2, _b2;
|
|
12503
12584
|
return String((_b2 = (_a2 = column.renderHTML) == null ? void 0 : _a2.call(column, readValue(row), { row, column, index })) != null ? _b2 : "");
|
|
12504
12585
|
};
|
|
12586
|
+
} else if (valueTypeCellRender) {
|
|
12587
|
+
prepared.cellRender = ({ row }) => valueTypeCellRender(readValue(row));
|
|
12505
12588
|
}
|
|
12506
12589
|
return prepared;
|
|
12507
12590
|
})
|
|
@@ -16361,7 +16444,7 @@
|
|
|
16361
16444
|
|
|
16362
16445
|
var installer = makeInstaller([...plugins]);
|
|
16363
16446
|
|
|
16364
|
-
const version = "1.0.
|
|
16447
|
+
const version = "1.0.3";
|
|
16365
16448
|
|
|
16366
16449
|
const install = installer.install;
|
|
16367
16450
|
|