@vrojs/element-plus 0.0.16 → 0.0.18

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.
@@ -10,6 +10,10 @@ export declare const VroElTableActionsColumn: import('@vrojs/base').WithInstall<
10
10
  type: import('vue').PropType<"hover" | "click" | "contextmenu">;
11
11
  default: string;
12
12
  };
13
+ moreButtonProps: {
14
+ type: import('vue').PropType<import('./types').VroElTableActionsColumnButtonProps>;
15
+ default: () => {};
16
+ };
13
17
  moreText: StringConstructor;
14
18
  moreActions: {
15
19
  type: import('vue').PropType<import('./types').VroElTableActionsColumnActions>;
@@ -81,6 +85,7 @@ export declare const VroElTableActionsColumn: import('@vrojs/base').WithInstall<
81
85
  filterMultiple: boolean;
82
86
  actions: import('./types').VroElTableActionsColumnActions<any>;
83
87
  moreTrigger: "click" | "contextmenu" | "hover";
88
+ moreButtonProps: Partial<import('element-plus').ButtonProps>;
84
89
  moreActions: import('./types').VroElTableActionsColumnActions<any>;
85
90
  }, true, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
86
91
  P: {};
@@ -99,6 +104,10 @@ export declare const VroElTableActionsColumn: import('@vrojs/base').WithInstall<
99
104
  type: import('vue').PropType<"hover" | "click" | "contextmenu">;
100
105
  default: string;
101
106
  };
107
+ moreButtonProps: {
108
+ type: import('vue').PropType<import('./types').VroElTableActionsColumnButtonProps>;
109
+ default: () => {};
110
+ };
102
111
  moreText: StringConstructor;
103
112
  moreActions: {
104
113
  type: import('vue').PropType<import('./types').VroElTableActionsColumnActions>;
@@ -170,6 +179,7 @@ export declare const VroElTableActionsColumn: import('@vrojs/base').WithInstall<
170
179
  filterMultiple: boolean;
171
180
  actions: import('./types').VroElTableActionsColumnActions<any>;
172
181
  moreTrigger: "click" | "contextmenu" | "hover";
182
+ moreButtonProps: Partial<import('element-plus').ButtonProps>;
173
183
  moreActions: import('./types').VroElTableActionsColumnActions<any>;
174
184
  }>;
175
185
  __isFragment?: never;
@@ -185,6 +195,10 @@ export declare const VroElTableActionsColumn: import('@vrojs/base').WithInstall<
185
195
  type: import('vue').PropType<"hover" | "click" | "contextmenu">;
186
196
  default: string;
187
197
  };
198
+ moreButtonProps: {
199
+ type: import('vue').PropType<import('./types').VroElTableActionsColumnButtonProps>;
200
+ default: () => {};
201
+ };
188
202
  moreText: StringConstructor;
189
203
  moreActions: {
190
204
  type: import('vue').PropType<import('./types').VroElTableActionsColumnActions>;
@@ -256,6 +270,7 @@ export declare const VroElTableActionsColumn: import('@vrojs/base').WithInstall<
256
270
  filterMultiple: boolean;
257
271
  actions: import('./types').VroElTableActionsColumnActions<any>;
258
272
  moreTrigger: "click" | "contextmenu" | "hover";
273
+ moreButtonProps: Partial<import('element-plus').ButtonProps>;
259
274
  moreActions: import('./types').VroElTableActionsColumnActions<any>;
260
275
  }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
261
276
  $slots: Readonly<import('./types').VroElTableActionsColumnSlots<any>> & import('./types').VroElTableActionsColumnSlots<any>;
@@ -1,5 +1,10 @@
1
- import { Component, ExtractPropTypes, PropType } from 'vue';
1
+ import { ButtonProps } from 'element-plus';
2
+ import { ExtractPropTypes, PropType } from 'vue';
2
3
  import { VroElTableColumnScope } from '../vro-el-table-column/types';
4
+ /**
5
+ * 操作按钮属性,透传给 ElButton,其中 loading、onClick 由组件内部管理。
6
+ */
7
+ export type VroElTableActionsColumnButtonProps = Partial<ButtonProps>;
3
8
  export interface VroElTableActionsColumnAction<T = any> {
4
9
  /**
5
10
  * 操作唯一标识,用于优化列表渲染。
@@ -9,18 +14,6 @@ export interface VroElTableActionsColumnAction<T = any> {
9
14
  * 操作文本。
10
15
  */
11
16
  label: string;
12
- /**
13
- * 操作图标。
14
- */
15
- icon?: string | Component;
16
- /**
17
- * 按钮类型。
18
- */
19
- type?: 'primary' | 'success' | 'warning' | 'danger' | 'info';
20
- /**
21
- * 是否禁用。
22
- */
23
- disabled?: boolean;
24
17
  /**
25
18
  * 是否隐藏,返回 true 时隐藏当前操作。
26
19
  */
@@ -29,6 +22,10 @@ export interface VroElTableActionsColumnAction<T = any> {
29
22
  * 点击操作时触发。
30
23
  */
31
24
  onAction?: (row: T, index: number) => any;
25
+ /**
26
+ * 按钮属性,直接展示的操作项透传给 ElButton;收纳到更多下拉菜单中的操作项,取其中的 icon、disabled、type。
27
+ */
28
+ buttonProps?: VroElTableActionsColumnButtonProps;
32
29
  }
33
30
  export type VroElTableActionsColumnActions<T = any> = VroElTableActionsColumnAction<T>[] | ((row: T, index: number) => VroElTableActionsColumnAction<T>[]);
34
31
  export declare const vroElTableActionsColumnProps: {
@@ -50,6 +47,13 @@ export declare const vroElTableActionsColumnProps: {
50
47
  type: PropType<"hover" | "click" | "contextmenu">;
51
48
  default: string;
52
49
  };
50
+ /**
51
+ * 更多操作按钮属性,默认 { type: 'primary', link: true }。
52
+ */
53
+ moreButtonProps: {
54
+ type: PropType<VroElTableActionsColumnButtonProps>;
55
+ default: () => {};
56
+ };
53
57
  /**
54
58
  * 更多操作按钮文本。
55
59
  */
@@ -1,7 +1,7 @@
1
- import { elTableColumnProps as r } from "../utils/elTableColumnProps.js";
1
+ import { elTableColumnProps as t } from "../utils/elTableColumnProps.js";
2
2
  import "@vrojs/base";
3
3
  const e = {
4
- ...r,
4
+ ...t,
5
5
  /**
6
6
  * 列标题。
7
7
  */
@@ -20,6 +20,13 @@ const e = {
20
20
  type: String,
21
21
  default: "hover"
22
22
  },
23
+ /**
24
+ * 更多操作按钮属性,默认 { type: 'primary', link: true }。
25
+ */
26
+ moreButtonProps: {
27
+ type: Object,
28
+ default: () => ({})
29
+ },
23
30
  /**
24
31
  * 更多操作按钮文本。
25
32
  */
@@ -16,6 +16,10 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
16
16
  type: import('vue').PropType<"hover" | "click" | "contextmenu">;
17
17
  default: string;
18
18
  };
19
+ moreButtonProps: {
20
+ type: import('vue').PropType<import('./types').VroElTableActionsColumnButtonProps>;
21
+ default: () => {};
22
+ };
19
23
  moreText: StringConstructor;
20
24
  moreActions: {
21
25
  type: import('vue').PropType<VroElTableActionsColumnActions>;
@@ -85,6 +89,10 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
85
89
  type: import('vue').PropType<"hover" | "click" | "contextmenu">;
86
90
  default: string;
87
91
  };
92
+ moreButtonProps: {
93
+ type: import('vue').PropType<import('./types').VroElTableActionsColumnButtonProps>;
94
+ default: () => {};
95
+ };
88
96
  moreText: StringConstructor;
89
97
  moreActions: {
90
98
  type: import('vue').PropType<VroElTableActionsColumnActions>;
@@ -156,6 +164,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
156
164
  filterMultiple: boolean;
157
165
  actions: VroElTableActionsColumnActions<any>;
158
166
  moreTrigger: "click" | "contextmenu" | "hover";
167
+ moreButtonProps: Partial<import('element-plus').ButtonProps>;
159
168
  moreActions: VroElTableActionsColumnActions<any>;
160
169
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
161
170
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
@@ -1,74 +1,71 @@
1
- import { defineComponent as V, computed as A, reactive as D, createBlock as c, openBlock as a, unref as i, mergeProps as m, withCtx as r, renderSlot as f, normalizeProps as M, guardReactiveProps as z, createElementBlock as v, createCommentVNode as F, Fragment as w, renderList as T, withModifiers as h, createTextVNode as p, toDisplayString as b, createVNode as E, normalizeClass as K } from "vue";
1
+ import { defineComponent as V, computed as A, reactive as D, createBlock as c, openBlock as a, unref as i, mergeProps as s, withCtx as l, renderSlot as p, normalizeProps as M, guardReactiveProps as z, createElementBlock as P, createCommentVNode as F, Fragment as v, renderList as w, withModifiers as T, createTextVNode as f, toDisplayString as b, createVNode as h, normalizeClass as K } from "vue";
2
2
  import { pick as S, typedKeys as j, isFunction as R, isPromiseLike as q } from "@daysnap/utils";
3
- import { ElTableColumn as G, ElButton as L, ElDropdown as H, ElDropdownMenu as J, ElDropdownItem as O } from "element-plus";
3
+ import { ElTableColumn as G, ElButton as E, ElDropdown as H, ElDropdownMenu as J, ElDropdownItem as O } from "element-plus";
4
4
  import { useLocale as Q } from "../locale/useLocale.js";
5
5
  import { elTableColumnProps as U } from "../utils/elTableColumnProps.js";
6
6
  import "@vrojs/base";
7
7
  import { vroElTableActionsColumnProps as W } from "./types.js";
8
- const ne = /* @__PURE__ */ V({
8
+ const to = /* @__PURE__ */ V({
9
9
  name: "VroElTableActionsColumn",
10
10
  __name: "vro-el-table-actions-column",
11
11
  props: W,
12
- setup(P) {
13
- const u = P, { t: g } = Q(), _ = A(() => {
14
- const e = S(u, j(U));
12
+ setup(L) {
13
+ const d = L, { t: g } = Q(), _ = A(() => {
14
+ const o = S(d, j(U));
15
15
  return {
16
- ...e,
17
- label: u.label ?? g("tableActionsColumn.label"),
18
- className: ["vro-el-table-actions-column-cell", e.className].filter(Boolean).join(" ")
16
+ ...o,
17
+ label: d.label ?? g("tableActionsColumn.label"),
18
+ className: ["vro-el-table-actions-column-cell", o.className].filter(Boolean).join(" ")
19
19
  };
20
- }), B = A(() => u.moreText ?? g("tableActionsColumn.moreText")), y = D(/* @__PURE__ */ new Map()), d = (e, l, o) => (typeof e == "function" ? e(l, o) : e).filter((t) => !(R(t.hidden) ? t.hidden(l, o) : t.hidden)), s = (e, l) => e.key ?? `${l}-${e.label}`, $ = (e, l, o) => !!y.get(`${l}-${s(e, o)}`), k = (e, l, o, n) => {
21
- y.set(`${l}-${s(e, o)}`, n);
22
- }, C = async (e, l, o, n) => {
23
- const t = e.onAction?.(l, o);
24
- if (!(!e.icon || !q(t))) {
25
- k(e, o, n, !0);
20
+ }), B = A(() => d.moreText ?? g("tableActionsColumn.moreText")), $ = D(/* @__PURE__ */ new Map()), m = (o, n, e) => (typeof o == "function" ? o(n, e) : o).filter((r) => !(R(r.hidden) ? r.hidden(n, e) : r.hidden)), u = (o, n) => o.key ?? `${n}-${o.label}`, y = (o, n, e) => !!$.get(`${n}-${u(o, e)}`), k = (o, n, e, t) => {
21
+ $.set(`${n}-${u(o, e)}`, t);
22
+ }, C = async (o, n, e, t) => {
23
+ const r = o.onAction?.(n, e);
24
+ if (!(!o.buttonProps?.icon || !q(r))) {
25
+ k(o, e, t, !0);
26
26
  try {
27
- await t;
27
+ await r;
28
28
  } finally {
29
- k(e, o, n, !1);
29
+ k(o, e, t, !1);
30
30
  }
31
31
  }
32
32
  };
33
- return (e, l) => (a(), c(i(G), m(_.value, { class: "vro-el-table-actions-column" }), {
34
- default: r((o) => [
35
- f(e.$slots, "default", M(z(o)), () => [
36
- (a(!0), v(w, null, T(d(e.actions, o.row, o.$index), (n, t) => (a(), c(i(L), {
37
- key: s(n, t),
38
- link: "",
39
- type: n.type || "primary",
40
- icon: n.icon,
41
- loading: $(n, o.$index, t),
42
- disabled: n.disabled,
43
- onClick: h((N) => C(n, o.row, o.$index, t), ["stop"])
44
- }, {
45
- default: r(() => [
46
- f(e.$slots, "action", m({ ref_for: !0 }, { ...o, action: n }), () => [
47
- p(b(n.label), 1)
33
+ return (o, n) => (a(), c(i(G), s(_.value, { class: "vro-el-table-actions-column" }), {
34
+ default: l((e) => [
35
+ p(o.$slots, "default", M(z(e)), () => [
36
+ (a(!0), P(v, null, w(m(o.actions, e.row, e.$index), (t, r) => (a(), c(i(E), s({
37
+ key: u(t, r)
38
+ }, { ref_for: !0 }, { link: !0, type: "primary", ...t.buttonProps }, {
39
+ loading: y(t, e.$index, r),
40
+ onClick: T((N) => C(t, e.row, e.$index, r), ["stop"])
41
+ }), {
42
+ default: l(() => [
43
+ p(o.$slots, "action", s({ ref_for: !0 }, { ...e, action: t }), () => [
44
+ f(b(t.label), 1)
48
45
  ])
49
46
  ]),
50
47
  _: 2
51
- }, 1032, ["type", "icon", "loading", "disabled", "onClick"]))), 128)),
52
- d(e.moreActions, o.row, o.$index).length ? (a(), c(i(H), {
48
+ }, 1040, ["loading", "onClick"]))), 128)),
49
+ m(o.moreActions, e.row, e.$index).length ? (a(), c(i(H), {
53
50
  key: 0,
54
- trigger: e.moreTrigger
51
+ trigger: o.moreTrigger
55
52
  }, {
56
- dropdown: r(() => [
57
- E(i(J), null, {
58
- default: r(() => [
59
- (a(!0), v(w, null, T(d(e.moreActions, o.row, o.$index), (n, t) => (a(), c(i(O), {
60
- key: s(n, t),
53
+ dropdown: l(() => [
54
+ h(i(J), null, {
55
+ default: l(() => [
56
+ (a(!0), P(v, null, w(m(o.moreActions, e.row, e.$index), (t, r) => (a(), c(i(O), {
57
+ key: u(t, r),
61
58
  class: K([
62
59
  "vro-el-table-actions-column-dropdown-action",
63
- n.type && `is-${n.type}`
60
+ t.buttonProps?.type && `is-${t.buttonProps.type}`
64
61
  ]),
65
- icon: n.icon,
66
- disabled: n.disabled || $(n, o.$index, t),
67
- onClick: h((N) => C(n, o.row, o.$index, t), ["stop"])
62
+ icon: t.buttonProps?.icon,
63
+ disabled: t.buttonProps?.disabled || y(t, e.$index, r),
64
+ onClick: T((N) => C(t, e.row, e.$index, r), ["stop"])
68
65
  }, {
69
- default: r(() => [
70
- f(e.$slots, "more-action", m({ ref_for: !0 }, { ...o, action: n }), () => [
71
- p(b(n.label), 1)
66
+ default: l(() => [
67
+ p(o.$slots, "more-action", s({ ref_for: !0 }, { ...e, action: t }), () => [
68
+ f(b(t.label), 1)
72
69
  ])
73
70
  ]),
74
71
  _: 2
@@ -77,16 +74,16 @@ const ne = /* @__PURE__ */ V({
77
74
  _: 2
78
75
  }, 1024)
79
76
  ]),
80
- default: r(() => [
81
- E(i(L), {
77
+ default: l(() => [
78
+ h(i(E), s({
82
79
  type: "primary",
83
80
  link: ""
84
- }, {
85
- default: r(() => [
86
- p(b(B.value), 1)
81
+ }, o.moreButtonProps), {
82
+ default: l(() => [
83
+ f(b(B.value), 1)
87
84
  ]),
88
85
  _: 1
89
- })
86
+ }, 16)
90
87
  ]),
91
88
  _: 2
92
89
  }, 1032, ["trigger"])) : F("", !0)
@@ -97,5 +94,5 @@ const ne = /* @__PURE__ */ V({
97
94
  }
98
95
  });
99
96
  export {
100
- ne as default
97
+ to as default
101
98
  };
@@ -7,8 +7,8 @@ export declare const VroElTableColumn: import('@vrojs/base').WithInstall<{
7
7
  };
8
8
  unit: StringConstructor;
9
9
  lineClamp: NumberConstructor;
10
- map: import('vue').PropType<Record<PropertyKey, any>>;
11
- renderDefault: import('vue').PropType<import('./types').VroElTableColumnRender>;
10
+ map: import('vue').PropType<import('./types').VroElTableColumnMap>;
11
+ render: import('vue').PropType<import('./types').VroElTableColumnRender>;
12
12
  renderContent: import('vue').PropType<import('./types').VroElTableColumnRender>;
13
13
  prefixIcon: import('vue').PropType<import('./types').VroElTableColumnIcon>;
14
14
  suffixIcon: import('vue').PropType<import('./types').VroElTableColumnIcon>;
@@ -92,8 +92,8 @@ export declare const VroElTableColumn: import('@vrojs/base').WithInstall<{
92
92
  };
93
93
  unit: StringConstructor;
94
94
  lineClamp: NumberConstructor;
95
- map: import('vue').PropType<Record<PropertyKey, any>>;
96
- renderDefault: import('vue').PropType<import('./types').VroElTableColumnRender>;
95
+ map: import('vue').PropType<import('./types').VroElTableColumnMap>;
96
+ render: import('vue').PropType<import('./types').VroElTableColumnRender>;
97
97
  renderContent: import('vue').PropType<import('./types').VroElTableColumnRender>;
98
98
  prefixIcon: import('vue').PropType<import('./types').VroElTableColumnIcon>;
99
99
  suffixIcon: import('vue').PropType<import('./types').VroElTableColumnIcon>;
@@ -174,8 +174,8 @@ export declare const VroElTableColumn: import('@vrojs/base').WithInstall<{
174
174
  };
175
175
  unit: StringConstructor;
176
176
  lineClamp: NumberConstructor;
177
- map: import('vue').PropType<Record<PropertyKey, any>>;
178
- renderDefault: import('vue').PropType<import('./types').VroElTableColumnRender>;
177
+ map: import('vue').PropType<import('./types').VroElTableColumnMap>;
178
+ render: import('vue').PropType<import('./types').VroElTableColumnRender>;
179
179
  renderContent: import('vue').PropType<import('./types').VroElTableColumnRender>;
180
180
  prefixIcon: import('vue').PropType<import('./types').VroElTableColumnIcon>;
181
181
  suffixIcon: import('vue').PropType<import('./types').VroElTableColumnIcon>;
@@ -1 +1 @@
1
- :root,:host{--vro-el-table-column-gap: 4px;--vro-el-table-column-icon-size: 14px;--vro-el-table-column-line-clamp: 1}.vro-el-table-column-content{display:inline-flex;width:100%;max-width:100%;min-width:0;align-items:center;gap:var(--vro-el-table-column-gap);vertical-align:middle}.vro-el-table-column-content.is-center{justify-content:center}.vro-el-table-column-content.is-right{justify-content:flex-end}.vro-el-table-column-content .vro-el-icon{flex:none;font-size:var(--vro-el-table-column-icon-size)}.vro-el-table-column-prefix,.vro-el-table-column-suffix{display:inline-flex;flex:none;min-width:0;align-items:center}.vro-el-table-column-text{flex:0 1 auto;max-width:100%;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vro-el-table-column-text.is-line-clamp{display:-webkit-box;white-space:normal;-webkit-box-orient:vertical;-webkit-line-clamp:var(--vro-el-table-column-line-clamp)}
1
+ :root,:host{--vro-el-table-column-gap: 4px;--vro-el-table-column-icon-size: 14px;--vro-el-table-column-line-clamp: 1}.vro-el-table-column-content{display:inline-flex;width:100%;max-width:100%;min-width:0;align-items:center;gap:var(--vro-el-table-column-gap);vertical-align:middle}.vro-el-table-column-content.is-left{justify-content:flex-start}.vro-el-table-column-content.is-center{justify-content:center}.vro-el-table-column-content.is-right{justify-content:flex-end}.vro-el-table-column-content .vro-el-icon{flex:none;font-size:var(--vro-el-table-column-icon-size)}.vro-el-table-column-prefix,.vro-el-table-column-suffix{display:inline-flex;flex:none;min-width:0;align-items:center}.vro-el-table-column-text{flex:0 1 auto;max-width:100%;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vro-el-table-column-text.is-line-clamp{display:-webkit-box;white-space:normal;-webkit-box-orient:vertical;-webkit-line-clamp:var(--vro-el-table-column-line-clamp)}
@@ -1,8 +1,9 @@
1
1
  import { TableColumnCtx } from 'element-plus';
2
2
  import { ExtractPropTypes, PropType, VNodeChild } from 'vue';
3
3
  import { VroElIconProps } from '../vro-el-icon';
4
- export type VroElTableColumnFormatter = TableColumnCtx<any>['formatter'];
4
+ export type VroElTableColumnFormatter<T extends Record<string, any> = any> = (row: T, column: TableColumnCtx<T>, cellValue: any, index: number) => any;
5
5
  export type VroElTableColumnIcon = string | Partial<VroElIconProps>;
6
+ export type VroElTableColumnMap<T extends Record<string, any> = any> = Record<PropertyKey, any> | ((row: T, index: number) => Record<PropertyKey, any>);
6
7
  export interface VroElTableColumnScope<T extends Record<string, any> = any> {
7
8
  row: T;
8
9
  column: TableColumnCtx<T>;
@@ -19,7 +20,17 @@ export interface VroElTableColumnExpandScope {
19
20
  export interface VroElTableColumnFilterIconScope {
20
21
  filterOpened: boolean;
21
22
  }
22
- export type VroElTableColumnRender<T extends Record<string, any> = any> = (scope: VroElTableColumnScope<T>) => VNodeChild;
23
+ export interface VroElTableColumnRenderScope<T extends Record<string, any> = any> extends VroElTableColumnScope<T> {
24
+ /**
25
+ * 单元格原始值,即 prop 对应的值。
26
+ */
27
+ rawValue?: any;
28
+ /**
29
+ * 单元格格式化后的值,已应用 formatter、map、unit。
30
+ */
31
+ value?: any;
32
+ }
33
+ export type VroElTableColumnRender<T extends Record<string, any> = any> = (scope: VroElTableColumnRenderScope<T>) => VNodeChild;
23
34
  export declare const vroElTableColumnProps: {
24
35
  /**
25
36
  * 空值占位内容。
@@ -29,7 +40,7 @@ export declare const vroElTableColumnProps: {
29
40
  default: string;
30
41
  };
31
42
  /**
32
- * 非空值后缀单位。
43
+ * 非空值后缀单位,仅对字符串、数字生效。
33
44
  */
34
45
  unit: StringConstructor;
35
46
  /**
@@ -37,15 +48,15 @@ export declare const vroElTableColumnProps: {
37
48
  */
38
49
  lineClamp: NumberConstructor;
39
50
  /**
40
- * 枚举值映射表。
51
+ * 枚举值映射表,支持传入函数按行生成。
41
52
  */
42
- map: PropType<Record<PropertyKey, any>>;
53
+ map: PropType<VroElTableColumnMap>;
43
54
  /**
44
- * 自定义整格内容渲染函数,优先级高于 renderContent、formatter、map。
55
+ * 自定义整格内容渲染函数,优先级高于 renderContent、formatter、map,低于默认插槽。
45
56
  */
46
- renderDefault: PropType<VroElTableColumnRender>;
57
+ render: PropType<VroElTableColumnRender>;
47
58
  /**
48
- * 自定义中间主体内容渲染函数。
59
+ * 自定义中间主体内容渲染函数,前后缀图标、对齐、单位仍然生效,空值占位由自定义内容自行处理。
49
60
  */
50
61
  renderContent: PropType<VroElTableColumnRender>;
51
62
  /**
@@ -133,9 +144,9 @@ export interface VroElTableColumnSlots<T extends Record<string, any> = any> {
133
144
  /**
134
145
  * 自定义默认内容前缀。
135
146
  */
136
- prefix?: (props: VroElTableColumnScope<T>) => any;
147
+ prefix?: (props: VroElTableColumnRenderScope<T>) => any;
137
148
  /**
138
149
  * 自定义默认内容后缀。
139
150
  */
140
- suffix?: (props: VroElTableColumnScope<T>) => any;
151
+ suffix?: (props: VroElTableColumnRenderScope<T>) => any;
141
152
  }
@@ -1,7 +1,7 @@
1
- import { elTableColumnProps as e } from "../utils/elTableColumnProps.js";
1
+ import { elTableColumnProps as n } from "../utils/elTableColumnProps.js";
2
2
  import "@vrojs/base";
3
3
  const r = {
4
- ...e,
4
+ ...n,
5
5
  /**
6
6
  * 空值占位内容。
7
7
  */
@@ -10,7 +10,7 @@ const r = {
10
10
  default: "-"
11
11
  },
12
12
  /**
13
- * 非空值后缀单位。
13
+ * 非空值后缀单位,仅对字符串、数字生效。
14
14
  */
15
15
  unit: String,
16
16
  /**
@@ -18,15 +18,15 @@ const r = {
18
18
  */
19
19
  lineClamp: Number,
20
20
  /**
21
- * 枚举值映射表。
21
+ * 枚举值映射表,支持传入函数按行生成。
22
22
  */
23
- map: Object,
23
+ map: [Object, Function],
24
24
  /**
25
- * 自定义整格内容渲染函数,优先级高于 renderContent、formatter、map。
25
+ * 自定义整格内容渲染函数,优先级高于 renderContent、formatter、map,低于默认插槽。
26
26
  */
27
- renderDefault: Function,
27
+ render: Function,
28
28
  /**
29
- * 自定义中间主体内容渲染函数。
29
+ * 自定义中间主体内容渲染函数,前后缀图标、对齐、单位仍然生效,空值占位由自定义内容自行处理。
30
30
  */
31
31
  renderContent: Function,
32
32
  /**
@@ -13,8 +13,8 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
13
13
  };
14
14
  unit: StringConstructor;
15
15
  lineClamp: NumberConstructor;
16
- map: import('vue').PropType<Record<PropertyKey, any>>;
17
- renderDefault: import('vue').PropType<import('./types').VroElTableColumnRender>;
16
+ map: import('vue').PropType<import('./types').VroElTableColumnMap>;
17
+ render: import('vue').PropType<import('./types').VroElTableColumnRender>;
18
18
  renderContent: import('vue').PropType<import('./types').VroElTableColumnRender>;
19
19
  prefixIcon: import('vue').PropType<VroElTableColumnIcon>;
20
20
  suffixIcon: import('vue').PropType<VroElTableColumnIcon>;
@@ -80,8 +80,8 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
80
80
  };
81
81
  unit: StringConstructor;
82
82
  lineClamp: NumberConstructor;
83
- map: import('vue').PropType<Record<PropertyKey, any>>;
84
- renderDefault: import('vue').PropType<import('./types').VroElTableColumnRender>;
83
+ map: import('vue').PropType<import('./types').VroElTableColumnMap>;
84
+ render: import('vue').PropType<import('./types').VroElTableColumnRender>;
85
85
  renderContent: import('vue').PropType<import('./types').VroElTableColumnRender>;
86
86
  prefixIcon: import('vue').PropType<VroElTableColumnIcon>;
87
87
  suffixIcon: import('vue').PropType<VroElTableColumnIcon>;
@@ -1,66 +1,68 @@
1
- import { defineComponent as T, useSlots as w, computed as y, createBlock as D, openBlock as I, unref as S, mergeProps as A, createSlots as B, withCtx as o, createVNode as O, renderSlot as u, normalizeProps as i, guardReactiveProps as p, h as a } from "vue";
2
- import { pick as R, typedKeys as j } from "@daysnap/utils";
3
- import { ElTableColumn as z } from "element-plus";
4
- import { getProp as K } from "element-plus/es/utils/objects";
5
- import { elTableColumnProps as M } from "../utils/elTableColumnProps.js";
1
+ import { defineComponent as B, useSlots as N, computed as s, createBlock as K, openBlock as O, unref as R, normalizeProps as p, guardReactiveProps as i, createSlots as j, withCtx as c, renderList as z, renderSlot as C, createVNode as D, h as a } from "vue";
2
+ import { typedKeys as y, pick as F, getByPath as L, isFunction as M } from "@daysnap/utils";
3
+ import { ElTableColumn as U } from "element-plus";
4
+ import { elTableColumnProps as W } from "../utils/elTableColumnProps.js";
6
5
  import "@vrojs/base";
7
- import { VroElIcon as N } from "../vro-el-icon/index.js";
8
- import { vroElTableColumnProps as _ } from "./types.js";
9
- const W = /* @__PURE__ */ T({
6
+ import { VroElIcon as q } from "../vro-el-icon/index.js";
7
+ import { vroElTableColumnProps as G } from "./types.js";
8
+ const re = /* @__PURE__ */ B({
10
9
  name: "VroElTableColumn",
11
10
  __name: "vro-el-table-column",
12
- props: _,
13
- setup(b) {
14
- const r = b, l = w(), v = ["selection", "index", "expand"], x = y(() => R(r, j(M))), $ = y(() => !v.includes(r.type) || !!l.default || !!r.renderDefault), h = ({ scope: e }) => e.$index < 0 ? null : l.default ? l.default(e) : r.renderDefault ? r.renderDefault(e) : a("div", { class: ["vro-el-table-column-content", `is-${r.align || "left"}`] }, [
15
- m("prefix", l.prefix?.(e) ?? f(r.prefixIcon)),
16
- V(e),
17
- m("suffix", l.suffix?.(e) ?? f(r.suffixIcon))
18
- ]), m = (e, n) => n == null ? null : a("span", { class: `vro-el-table-column-${e}` }, n), f = (e) => e ? a(N, typeof e == "string" ? { name: e } : e) : null, V = (e) => r.renderContent ? r.renderContent(e) : a(
11
+ props: G,
12
+ setup(x) {
13
+ const r = x, l = N(), b = ["selection", "index", "expand"], h = ["default", "prefix", "suffix"], g = y(W).filter((e) => e !== "formatter"), S = s(() => F(r, g)), $ = s(() => r.type === "expand"), v = s(() => y(l).filter((e) => !h.includes(e) && !String(e).startsWith("_"))), P = s(() => !b.includes(r.type) || !!l.default || !!r.render), V = ({ scope: e }) => e.$index < 0 ? null : l.default ? l.default(e) : w(e), w = (e) => {
14
+ const t = {
15
+ ...e,
16
+ ..._(e)
17
+ };
18
+ return r.render ? r.render(t) : a("div", { class: ["vro-el-table-column-content", `is-${r.align || "left"}`] }, [
19
+ f("prefix", l.prefix?.(t) ?? m(r.prefixIcon)),
20
+ E(t),
21
+ f("suffix", l.suffix?.(t) ?? m(r.suffixIcon))
22
+ ]);
23
+ }, f = (e, t) => t == null ? null : a("span", { class: `vro-el-table-column-${e}` }, t), m = (e) => e ? a(q, typeof e == "string" ? { name: e } : e) : null, E = (e) => r.renderContent ? r.renderContent(e) : a(
19
24
  "span",
20
25
  {
21
26
  class: ["vro-el-table-column-text", { "is-line-clamp": !!r.lineClamp }],
22
27
  style: r.lineClamp ? { "--vro-el-table-column-line-clamp": r.lineClamp } : void 0
23
28
  },
24
- P(e)
25
- ), P = (e) => {
26
- const n = g(e);
27
- return c(n) ? r.placeholder : n;
28
- }, g = (e) => {
29
- const { row: n, column: t, $index: E } = e, d = r.prop || r.property, C = d ? K(n, d).value : void 0, s = r.formatter ? r.formatter(n, t, C, E) : k(C);
30
- return c(s) || !r.unit ? s : `${s}${r.unit}`;
31
- }, k = (e) => !r.map || e == null ? e : Object.prototype.hasOwnProperty.call(r.map, e) ? r.map[e] : e, c = (e) => e == null || e === "" || Array.isArray(e) && !e.length;
32
- return (e, n) => (I(), D(S(z), A(x.value, { class: "vro-el-table-column" }), B({ _: 2 }, [
29
+ d(e.value) ? r.placeholder : e.value
30
+ ), _ = (e) => {
31
+ const { row: t, column: n, $index: o } = e, A = r.prop || r.property, u = L(t, A), I = r.formatter ? r.formatter(t, n, u, o) : T(u, t, o);
32
+ return {
33
+ rawValue: u,
34
+ value: k(I)
35
+ };
36
+ }, k = (e) => {
37
+ const t = typeof e == "string" || typeof e == "number";
38
+ return r.unit && t && !d(e) ? `${e}${r.unit}` : e;
39
+ }, T = (e, t, n) => {
40
+ const o = M(r.map) ? r.map(t, n) : r.map;
41
+ return !o || e == null ? e : Object.prototype.hasOwnProperty.call(o, e) ? o[e] : e;
42
+ }, d = (e) => e == null || e === "" || Array.isArray(e) && !e.length;
43
+ return (e, t) => (O(), K(R(U), p(i(S.value)), j({ _: 2 }, [
33
44
  $.value ? {
34
45
  name: "default",
35
- fn: o((t) => [
36
- O(h, { scope: t }, null, 8, ["scope"])
46
+ fn: c((n) => [
47
+ C(e.$slots, "default", p(i(n)))
37
48
  ]),
38
49
  key: "0"
39
- } : void 0,
40
- e.$slots.header ? {
41
- name: "header",
42
- fn: o((t) => [
43
- u(e.$slots, "header", i(p(t)))
50
+ } : P.value ? {
51
+ name: "default",
52
+ fn: c((n) => [
53
+ D(V, { scope: n }, null, 8, ["scope"])
44
54
  ]),
45
55
  key: "1"
46
56
  } : void 0,
47
- e.$slots.expand ? {
48
- name: "expand",
49
- fn: o((t) => [
50
- u(e.$slots, "expand", i(p(t)))
51
- ]),
52
- key: "2"
53
- } : void 0,
54
- e.$slots["filter-icon"] ? {
55
- name: "filter-icon",
56
- fn: o((t) => [
57
- u(e.$slots, "filter-icon", i(p(t)))
58
- ]),
59
- key: "3"
60
- } : void 0
57
+ z(v.value, (n) => ({
58
+ name: n,
59
+ fn: c((o) => [
60
+ C(e.$slots, n, p(i(o)))
61
+ ])
62
+ }))
61
63
  ]), 1040));
62
64
  }
63
65
  });
64
66
  export {
65
- W as default
67
+ re as default
66
68
  };
@@ -1,17 +1,16 @@
1
- import { TableColumnCtx } from 'element-plus';
2
1
  import { Component, ExtractPropTypes, PropType, Raw } from 'vue';
3
2
  import { VroElTableActionsColumnActions, VroElTableActionsColumnProps } from '../vro-el-table-actions-column';
4
- import { VroElTableColumnProps, VroElTableColumnRender } from '../vro-el-table-column';
5
- export type VroElTableColumnGroupFormatter<T extends Record<string, any> = any> = (row: T, column: TableColumnCtx<T>, cellValue: any, index: number) => any;
6
- export type VroElTableColumnGroupTableColumnProps<T extends Record<string, any> = any> = Partial<Omit<VroElTableColumnProps, 'formatter' | 'renderDefault' | 'renderContent'>> & {
3
+ import { VroElTableColumnFormatter, VroElTableColumnProps, VroElTableColumnRender } from '../vro-el-table-column';
4
+ export type VroElTableColumnGroupFormatter<T extends Record<string, any> = any> = VroElTableColumnFormatter<T>;
5
+ export type VroElTableColumnGroupTableColumnProps<T extends Record<string, any> = any> = Partial<Omit<VroElTableColumnProps, 'formatter' | 'render' | 'renderContent'>> & {
7
6
  /**
8
7
  * 单元格格式化函数。
9
8
  */
10
- formatter?: VroElTableColumnGroupFormatter<T>;
9
+ formatter?: VroElTableColumnFormatter<T>;
11
10
  /**
12
11
  * 自定义整格内容渲染函数,优先级高于 renderContent、formatter、map。
13
12
  */
14
- renderDefault?: VroElTableColumnRender<T>;
13
+ render?: VroElTableColumnRender<T>;
15
14
  /**
16
15
  * 自定义中间主体内容渲染函数。
17
16
  */