@qy_better_lib/pc 0.2.34 → 0.3.2

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.
Files changed (69) hide show
  1. package/DOCUMENTATION.md +559 -0
  2. package/dist/@qy_better_lib/pc.min.js +1 -1
  3. package/lib/commDialog/index.d.ts +3 -0
  4. package/lib/commDialog/index.js +8 -0
  5. package/lib/commDialog/src/index.vue.d.ts +102 -0
  6. package/lib/commDialog/src/index.vue.js +49 -0
  7. package/lib/commDialog/src/index.vue2.js +4 -0
  8. package/lib/commDialog/src/props.d.ts +49 -0
  9. package/lib/commDialog/src/props.js +48 -0
  10. package/lib/commDialog/src/type.d.ts +39 -0
  11. package/lib/commForm/index.d.ts +3 -0
  12. package/lib/commForm/index.js +8 -0
  13. package/lib/commForm/src/index.vue.d.ts +95 -0
  14. package/lib/commForm/src/index.vue.js +51 -0
  15. package/lib/commForm/src/index.vue2.js +4 -0
  16. package/lib/commForm/src/props.d.ts +49 -0
  17. package/lib/commForm/src/props.js +47 -0
  18. package/lib/commForm/src/type.d.ts +8 -0
  19. package/lib/contextMenu/index.d.ts +5 -2
  20. package/lib/contextMenu/index.js +5 -4
  21. package/lib/contextMenu/src/index.vue.d.ts +48 -36
  22. package/lib/contextMenu/src/index.vue.js +128 -79
  23. package/lib/contextMenu/src/index.vue2.js +2 -2
  24. package/lib/contextMenu/src/props.d.ts +32 -0
  25. package/lib/contextMenu/src/props.js +27 -0
  26. package/lib/contextMenu/src/type.d.ts +11 -0
  27. package/lib/describeView/index.js +4 -4
  28. package/lib/describeView/src/index.vue.d.ts +6 -9
  29. package/lib/describeView/src/index.vue.js +73 -70
  30. package/lib/describeView/src/index.vue2.js +2 -2
  31. package/lib/describeView/src/props.d.ts +35 -0
  32. package/lib/describeView/src/props.js +33 -0
  33. package/lib/index.d.ts +7 -3
  34. package/lib/index.js +31 -21
  35. package/lib/simpleVirtualList/index.js +4 -4
  36. package/lib/simpleVirtualList/src/index.vue.js +70 -53
  37. package/lib/simpleVirtualList/src/index.vue2.js +2 -2
  38. package/lib/styles/comm-form.scss +4 -0
  39. package/lib/styles/index.scss +6 -5
  40. package/lib/tableExtend/index.js +4 -4
  41. package/lib/tableExtend/props.d.ts +74 -15
  42. package/lib/tableExtend/props.js +82 -24
  43. package/lib/tableExtend/src/colVisible.vue.js +95 -70
  44. package/lib/tableExtend/src/colVisible.vue2.js +2 -2
  45. package/lib/tableExtend/src/index.vue.d.ts +18 -10
  46. package/lib/tableExtend/src/index.vue.js +171 -142
  47. package/lib/tableExtend/src/index.vue2.js +2 -2
  48. package/lib/tableExtend/src/valueCol.vue.js +11 -8
  49. package/lib/tableExtend/src/valueCol.vue2.js +2 -2
  50. package/lib/tableExtend/type.d.ts +9 -14
  51. package/lib/tableExtend/type.js +7 -2
  52. package/lib/tableExtend/useTable.d.ts +19 -50
  53. package/lib/tableExtend/useTable.js +95 -56
  54. package/lib/textButton/index.js +4 -4
  55. package/lib/textButton/src/index.vue.d.ts +7 -6
  56. package/lib/textButton/src/index.vue.js +25 -37
  57. package/lib/textButton/src/index.vue2.js +2 -2
  58. package/lib/textButton/src/props.d.ts +23 -0
  59. package/lib/textButton/src/props.js +30 -0
  60. package/lib/textButton/src/type.d.ts +30 -0
  61. package/lib/utils/index.d.ts +55 -13
  62. package/lib/utils/index.js +98 -54
  63. package/package.json +25 -8
  64. package/types/index.d.ts +9 -1
  65. /package/lib/styles/{contextMenu.scss → context-menu.scss} +0 -0
  66. /package/lib/styles/{describeView.scss → describe-view.scss} +0 -0
  67. /package/lib/styles/{simpleVirtualList.scss → simple-virtual-list.scss} +0 -0
  68. /package/lib/styles/{tableExtend.scss → table-extend.scss} +0 -0
  69. /package/lib/styles/{textButton.scss → text-button.scss} +0 -0
@@ -1,74 +1,86 @@
1
- import { PropType, DefineComponent, ExtractPropTypes, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
1
+ import { ContextMenuItem, MenuPosition } from './type';
2
+ import { DefineComponent, ExtractPropTypes, PropType, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
2
3
  /**
3
- * 右键菜单显示
4
+ * 显示菜单
5
+ * @param event 鼠标事件或位置对象
6
+ */
7
+ declare function show(event: MouseEvent | MenuPosition): Promise<void>;
8
+ /**
9
+ * 隐藏菜单
4
10
  */
5
- declare function show(e: any): Promise<void>;
6
11
  declare function hide(): void;
7
12
  declare function __VLS_template(): {
8
13
  attrs: Partial<{}>;
9
14
  slots: {
10
15
  item?(_: {
11
- data: any;
16
+ data: ContextMenuItem;
12
17
  }): any;
13
18
  };
14
19
  refs: {
15
- contextMenuRef: HTMLDivElement;
20
+ context_menu_ref: HTMLDivElement;
16
21
  };
17
22
  rootEl: any;
18
23
  };
19
24
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
20
25
  declare const __VLS_component: DefineComponent<ExtractPropTypes<{
21
- visible: {
22
- type: BooleanConstructor;
23
- default: () => boolean;
24
- };
25
26
  position: {
26
- type: PropType<{
27
+ type: PropType<MenuPosition>;
28
+ default: () => {
27
29
  x: number;
28
30
  y: number;
29
- }>;
30
- default: () => void;
31
+ };
31
32
  };
32
33
  options: {
33
- type: PropType<Record<string, any>>;
34
- default: never[];
35
- required: true;
34
+ type: PropType<ContextMenuItem[]>;
35
+ default: () => never[];
36
+ required: boolean;
37
+ };
38
+ disabled: {
39
+ type: BooleanConstructor;
40
+ default: boolean;
41
+ };
42
+ visible: {
43
+ type: PropType<boolean>;
36
44
  };
37
45
  }>, {
38
46
  hide: typeof hide;
39
47
  show: typeof show;
40
48
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
41
- menuClick: (...args: any[]) => void;
42
- "update:visible": (...args: any[]) => void;
49
+ show: () => any;
50
+ menu_click: (item: ContextMenuItem) => any;
51
+ hide: () => any;
52
+ "update:visible": (value: boolean) => any;
43
53
  }, string, PublicProps, Readonly< ExtractPropTypes<{
44
- visible: {
45
- type: BooleanConstructor;
46
- default: () => boolean;
47
- };
48
54
  position: {
49
- type: PropType<{
55
+ type: PropType<MenuPosition>;
56
+ default: () => {
50
57
  x: number;
51
58
  y: number;
52
- }>;
53
- default: () => void;
59
+ };
54
60
  };
55
61
  options: {
56
- type: PropType<Record<string, any>>;
57
- default: never[];
58
- required: true;
62
+ type: PropType<ContextMenuItem[]>;
63
+ default: () => never[];
64
+ required: boolean;
65
+ };
66
+ disabled: {
67
+ type: BooleanConstructor;
68
+ default: boolean;
69
+ };
70
+ visible: {
71
+ type: PropType<boolean>;
59
72
  };
60
73
  }>> & Readonly<{
61
- onMenuClick?: ((...args: any[]) => any) | undefined;
62
- "onUpdate:visible"?: ((...args: any[]) => any) | undefined;
74
+ onShow?: (() => any) | undefined;
75
+ onMenu_click?: ((item: ContextMenuItem) => any) | undefined;
76
+ onHide?: (() => any) | undefined;
77
+ "onUpdate:visible"?: ((value: boolean) => any) | undefined;
63
78
  }>, {
64
- options: Record<string, any>;
65
- visible: boolean;
66
- position: {
67
- x: number;
68
- y: number;
69
- };
79
+ disabled: boolean;
80
+ options: ContextMenuItem[];
81
+ position: MenuPosition;
70
82
  }, {}, {}, {}, string, ComponentProvideOptions, true, {
71
- contextMenuRef: HTMLDivElement;
83
+ context_menu_ref: HTMLDivElement;
72
84
  }, any>;
73
85
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
74
86
  export default _default;
@@ -1,104 +1,153 @@
1
- import { defineComponent as M, ref as _, reactive as X, watch as $, nextTick as p, onMounted as D, onBeforeUnmount as L, resolveComponent as N, openBlock as i, createBlock as h, Teleport as P, withDirectives as S, createElementBlock as a, normalizeStyle as T, createElementVNode as b, Fragment as C, renderList as V, normalizeClass as Y, renderSlot as z, createTextVNode as H, toDisplayString as O, unref as R, createCommentVNode as W } from "vue";
2
- import { ClickOutside as j } from "@qy_better_lib/core";
3
- const q = { class: "contextmenu-wrap" }, A = { class: "contextmenu-items" }, F = ["onClick"], I = /* @__PURE__ */ M({
1
+ import { defineComponent, useModel, ref, reactive, watch, onMounted, onBeforeUnmount, nextTick, resolveComponent, openBlock, createBlock, Teleport, withDirectives, createElementBlock, normalizeStyle, createElementVNode, Fragment, renderList, normalizeClass, renderSlot, createTextVNode, toDisplayString, unref, createCommentVNode, mergeModels } from "vue";
2
+ import { ClickOutside } from "@qy_better_lib/core";
3
+ import { props } from "./props.js";
4
+ const _hoisted_1 = { class: "contextmenu-wrap" };
5
+ const _hoisted_2 = { class: "contextmenu-items" };
6
+ const _hoisted_3 = ["onClick"];
7
+ const _sfc_main = /* @__PURE__ */ defineComponent({
4
8
  __name: "index",
5
- props: {
6
- visible: {
9
+ props: /* @__PURE__ */ mergeModels(props(), {
10
+ "visible": {
7
11
  type: Boolean,
8
- default: () => !1
12
+ default: false
9
13
  },
10
- position: {
11
- type: Object,
12
- default: () => {
13
- }
14
- },
15
- options: {
16
- type: Array,
17
- default: [],
18
- required: !0
19
- }
20
- },
21
- emits: ["menuClick", "update:visible"],
22
- setup(m, { expose: g, emit: B }) {
23
- const v = m, y = B;
24
- g({
25
- hide: d,
26
- show: u
14
+ "visibleModifiers": {}
15
+ }),
16
+ emits: /* @__PURE__ */ mergeModels(["menu_click", "show", "hide"], ["update:visible"]),
17
+ setup(__props, { expose: __expose, emit: __emit }) {
18
+ const props2 = __props;
19
+ const visible = useModel(__props, "visible");
20
+ const emit = __emit;
21
+ __expose({
22
+ hide,
23
+ show
27
24
  });
28
- const l = _(!1), s = _(null), r = X({
29
- left: 0,
30
- top: 0
25
+ const context_menu_ref = ref(null);
26
+ const position = reactive({
27
+ left: "0px",
28
+ top: "0px"
31
29
  });
32
- $(() => v.visible, (e) => {
33
- e && (l.value = !0, p(() => {
34
- k(v.position);
35
- }));
36
- }, {
37
- immediate: !0
38
- }), D(() => {
39
- s.value?.addEventListener("contextmenu", u);
40
- }), L(() => {
41
- x();
30
+ watch(() => visible.value, (val) => {
31
+ if (val) {
32
+ show_menu(props2.position);
33
+ } else {
34
+ hide_menu();
35
+ }
36
+ }, { immediate: true });
37
+ onMounted(() => {
38
+ add_context_menu_event();
42
39
  });
43
- function x() {
44
- s.value?.removeEventListener("contextmenu", u);
40
+ onBeforeUnmount(() => {
41
+ remove_context_menu_event();
42
+ });
43
+ function add_context_menu_event() {
44
+ if (context_menu_ref.value && !props2.disabled) {
45
+ context_menu_ref.value.addEventListener("contextmenu", handle_context_menu);
46
+ }
47
+ }
48
+ function remove_context_menu_event() {
49
+ if (context_menu_ref.value) {
50
+ context_menu_ref.value.removeEventListener("contextmenu", handle_context_menu);
51
+ }
52
+ }
53
+ async function handle_context_menu(e) {
54
+ if (props2.disabled) return;
55
+ e.preventDefault();
56
+ e.stopPropagation();
57
+ await show_menu({ x: e.pageX, y: e.pageY });
58
+ }
59
+ async function show(event) {
60
+ if (props2.disabled) return;
61
+ let position2;
62
+ if ("pageX" in event && "pageY" in event) {
63
+ event.preventDefault();
64
+ event.stopPropagation();
65
+ position2 = { x: event.pageX, y: event.pageY };
66
+ } else {
67
+ position2 = event;
68
+ }
69
+ await show_menu(position2);
45
70
  }
46
- function E(e) {
47
- e.disabled || (y("menuClick", e), d());
71
+ async function show_menu(pos) {
72
+ visible.value = true;
73
+ emit("show");
74
+ await nextTick();
75
+ set_position(pos);
48
76
  }
49
- async function u(e) {
50
- e.preventDefault(), l.value = !0, await p();
51
- const { pageX: o, pageY: t } = e;
52
- k({ x: o, y: t });
77
+ function hide() {
78
+ hide_menu();
53
79
  }
54
- function k(e) {
55
- const { clientWidth: o, clientHeight: t } = s.value;
56
- !o || !t || (r.top = `${w("Y", e.y || 0, t)}px`, r.left = `${w("X", e.x || 0, o)}px`);
80
+ function hide_menu() {
81
+ visible.value = false;
82
+ emit("hide");
57
83
  }
58
- function d() {
59
- x(), l.value = !1, p(() => {
60
- y("update:visible", !1);
61
- });
84
+ function set_position(pos) {
85
+ if (!context_menu_ref.value) return;
86
+ const menu_rect = context_menu_ref.value.getBoundingClientRect();
87
+ const { width, height } = menu_rect;
88
+ if (!width || !height) return;
89
+ const { top, left } = calculate_menu_position(pos, { width, height });
90
+ position.top = `${top}px`;
91
+ position.left = `${left}px`;
92
+ }
93
+ function calculate_menu_position(pos, size) {
94
+ const window_height = window.innerHeight;
95
+ const scroll_top = window.scrollY;
96
+ let top = pos.y - scroll_top;
97
+ if (top + size.height > window_height) {
98
+ top = Math.max(0, top - size.height);
99
+ }
100
+ top += scroll_top;
101
+ const window_width = window.innerWidth;
102
+ const scroll_left = window.scrollX;
103
+ let left = pos.x - scroll_left;
104
+ if (left + size.width > window_width) {
105
+ left = Math.max(0, left - size.width);
106
+ }
107
+ left += scroll_left;
108
+ return { top, left };
62
109
  }
63
- function w(e, o, t) {
64
- const n = e === "X" ? window.innerWidth : window.innerHeight, f = e === "X" ? window.scrollX : window.scrollY;
65
- let c = o - f;
66
- return c + t > n && (c = Math.max(0, c - t)), c + f;
110
+ function on_menu_click(item) {
111
+ if (item.disabled) return;
112
+ emit("menu_click", item);
113
+ hide_menu();
67
114
  }
68
- return (e, o) => {
69
- const t = N("el-divider");
70
- return i(), h(P, { to: "body" }, [
71
- l.value ? S((i(), a("div", {
115
+ return (_ctx, _cache) => {
116
+ const _component_el_divider = resolveComponent("el-divider");
117
+ return openBlock(), createBlock(Teleport, { to: "body" }, [
118
+ visible.value ? withDirectives((openBlock(), createElementBlock("div", {
72
119
  key: 0,
73
120
  class: "contextmenu",
74
- style: T({ top: r.top, left: r.left }),
75
- ref_key: "contextMenuRef",
76
- ref: s
121
+ style: normalizeStyle({ top: position.top, left: position.left }),
122
+ ref_key: "context_menu_ref",
123
+ ref: context_menu_ref
77
124
  }, [
78
- b("div", q, [
79
- b("ul", A, [
80
- (i(!0), a(C, null, V(m.options, (n) => (i(), a(C, {
81
- key: n.key
82
- }, [
83
- n?.type == "divider" ? (i(), h(t, { key: 0 })) : (i(), a("li", {
84
- key: 1,
85
- class: Y(["contextmenu-item", { disabled: n.disabled }]),
86
- onClick: (f) => E(n)
125
+ createElementVNode("div", _hoisted_1, [
126
+ createElementVNode("ul", _hoisted_2, [
127
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.options, (item) => {
128
+ return openBlock(), createElementBlock(Fragment, {
129
+ key: item.key
87
130
  }, [
88
- z(e.$slots, "item", { data: n }, () => [
89
- H(O(n.label), 1)
90
- ])
91
- ], 10, F))
92
- ], 64))), 128))
131
+ item.type === "divider" ? (openBlock(), createBlock(_component_el_divider, { key: 0 })) : (openBlock(), createElementBlock("li", {
132
+ key: 1,
133
+ class: normalizeClass(["contextmenu-item", { "disabled": item.disabled }]),
134
+ onClick: ($event) => on_menu_click(item)
135
+ }, [
136
+ renderSlot(_ctx.$slots, "item", { data: item }, () => [
137
+ createTextVNode(toDisplayString(item.label), 1)
138
+ ])
139
+ ], 10, _hoisted_3))
140
+ ], 64);
141
+ }), 128))
93
142
  ])
94
143
  ])
95
144
  ], 4)), [
96
- [R(j), d]
97
- ]) : W("", !0)
145
+ [unref(ClickOutside), hide_menu]
146
+ ]) : createCommentVNode("", true)
98
147
  ]);
99
148
  };
100
149
  }
101
150
  });
102
151
  export {
103
- I as default
152
+ _sfc_main as default
104
153
  };
@@ -1,4 +1,4 @@
1
- import f from "./index.vue.js";
1
+ import _sfc_main from "./index.vue.js";
2
2
  export {
3
- f as default
3
+ _sfc_main as default
4
4
  };
@@ -0,0 +1,32 @@
1
+ import { PropType } from 'vue';
2
+ import { ContextMenuItem, MenuPosition } from './type';
3
+ /**
4
+ * 右键菜单组件属性定义
5
+ */
6
+ export declare const props: () => {
7
+ /**
8
+ * 菜单显示位置
9
+ */
10
+ position: {
11
+ type: PropType<MenuPosition>;
12
+ default: () => {
13
+ x: number;
14
+ y: number;
15
+ };
16
+ };
17
+ /**
18
+ * 菜单项配置
19
+ */
20
+ options: {
21
+ type: PropType<ContextMenuItem[]>;
22
+ default: () => never[];
23
+ required: boolean;
24
+ };
25
+ /**
26
+ * 是否禁用右键菜单
27
+ */
28
+ disabled: {
29
+ type: BooleanConstructor;
30
+ default: boolean;
31
+ };
32
+ };
@@ -0,0 +1,27 @@
1
+ const props = () => ({
2
+ /**
3
+ * 菜单显示位置
4
+ */
5
+ position: {
6
+ type: Object,
7
+ default: () => ({ x: 0, y: 0 })
8
+ },
9
+ /**
10
+ * 菜单项配置
11
+ */
12
+ options: {
13
+ type: Array,
14
+ default: () => [],
15
+ required: true
16
+ },
17
+ /**
18
+ * 是否禁用右键菜单
19
+ */
20
+ disabled: {
21
+ type: Boolean,
22
+ default: false
23
+ }
24
+ });
25
+ export {
26
+ props
27
+ };
@@ -0,0 +1,11 @@
1
+ export interface ContextMenuItem {
2
+ key: string;
3
+ label: string;
4
+ disabled?: boolean;
5
+ type?: 'divider';
6
+ [key: string]: any;
7
+ }
8
+ export interface MenuPosition {
9
+ x: number;
10
+ y: number;
11
+ }
@@ -1,7 +1,7 @@
1
- import e from "./src/index.vue.js";
2
- e.install = (i) => {
3
- i.component("DescribeView", e);
1
+ import _sfc_main from "./src/index.vue.js";
2
+ _sfc_main.install = (app) => {
3
+ app.component("DescribeView", _sfc_main);
4
4
  };
5
5
  export {
6
- e as default
6
+ _sfc_main as default
7
7
  };
@@ -1,5 +1,5 @@
1
- import { PropType, DefineComponent, ExtractPropTypes, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
2
1
  import { ViewConfig } from './type';
2
+ import { DefineComponent, ExtractPropTypes, PropType, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
3
  declare function __VLS_template(): {
4
4
  attrs: Partial<{}>;
5
5
  slots: Partial<Record<`label_${string}`, (_: {}) => any>> & Partial<Record<`value_${string}`, (_: {
@@ -13,39 +13,35 @@ declare function __VLS_template(): {
13
13
  };
14
14
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
15
15
  declare const __VLS_component: DefineComponent<ExtractPropTypes<{
16
- /**配置 */
17
16
  config: {
18
17
  type: PropType<Array<ViewConfig>>;
18
+ default: () => never[];
19
19
  };
20
- /**数据 */
21
20
  data: {
22
21
  type: PropType<Record<string, any>>;
23
- default: {};
22
+ default: () => {};
24
23
  };
25
24
  column: {
26
25
  type: NumberConstructor;
27
26
  default: number;
28
27
  };
29
- /**label宽度:数字或字符串;如果定义多列宽度,使用字符串格式'20,30,50' */
30
28
  labelWidth: {
31
29
  type: (StringConstructor | NumberConstructor)[];
32
30
  default: number;
33
31
  };
34
32
  }>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly< ExtractPropTypes<{
35
- /**配置 */
36
33
  config: {
37
34
  type: PropType<Array<ViewConfig>>;
35
+ default: () => never[];
38
36
  };
39
- /**数据 */
40
37
  data: {
41
38
  type: PropType<Record<string, any>>;
42
- default: {};
39
+ default: () => {};
43
40
  };
44
41
  column: {
45
42
  type: NumberConstructor;
46
43
  default: number;
47
44
  };
48
- /**label宽度:数字或字符串;如果定义多列宽度,使用字符串格式'20,30,50' */
49
45
  labelWidth: {
50
46
  type: (StringConstructor | NumberConstructor)[];
51
47
  default: number;
@@ -53,6 +49,7 @@ declare const __VLS_component: DefineComponent<ExtractPropTypes<{
53
49
  }>> & Readonly<{}>, {
54
50
  data: Record<string, any>;
55
51
  column: number;
52
+ config: ViewConfig[];
56
53
  labelWidth: string | number;
57
54
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, HTMLDivElement>;
58
55
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
@@ -1,81 +1,84 @@
1
- import { defineComponent as y, computed as h, openBlock as s, createElementBlock as i, renderSlot as r, createElementVNode as d, normalizeStyle as c, Fragment as v, renderList as $, createTextVNode as u, toDisplayString as p } from "vue";
2
- import { isNumber as g } from "@qy_better_lib/core";
3
- const w = { class: "describe-view-container" }, _ = { class: "value" }, N = /* @__PURE__ */ y({
1
+ import { defineComponent, computed, openBlock, createElementBlock, renderSlot, createElementVNode, normalizeStyle, Fragment, renderList, createTextVNode, toDisplayString } from "vue";
2
+ import { is_number } from "@qy_better_lib/core";
3
+ import { props } from "./props.js";
4
+ const _hoisted_1 = { class: "describe-view-container" };
5
+ const _hoisted_2 = { class: "value" };
6
+ const _sfc_main = /* @__PURE__ */ defineComponent({
4
7
  __name: "index",
5
- props: {
6
- /**配置 */
7
- config: {
8
- type: Object
9
- },
10
- /**数据 */
11
- data: {
12
- type: Object,
13
- default: {}
14
- },
15
- // 展示列数
16
- column: {
17
- type: Number,
18
- default: 3
19
- },
20
- /**label宽度:数字或字符串;如果定义多列宽度,使用字符串格式'20,30,50' */
21
- labelWidth: {
22
- type: [Number, String],
23
- default: 85
24
- }
25
- },
26
- setup(n) {
27
- const a = n, f = h(() => ({
28
- "grid-template-columns": `repeat(${a.column}, minmax(1px, 1fr))`
29
- }));
30
- function m(t) {
31
- const l = {};
32
- return t.col_span && (l.gridColumnStart = `span ${t.col_span}`), t.row_span && (l.gridRowStart = `span ${t.row_span}`), l;
8
+ props: props(),
9
+ setup(__props) {
10
+ const props2 = __props;
11
+ const container_style = computed(() => {
12
+ return {
13
+ "grid-template-columns": `repeat(${props2.column}, minmax(1px, 1fr))`
14
+ };
15
+ });
16
+ function item_style(item) {
17
+ const style = {};
18
+ if (item.col_span) {
19
+ style.gridColumnStart = `span ${item.col_span}`;
20
+ }
21
+ if (item.row_span) {
22
+ style.gridRowStart = `span ${item.row_span}`;
23
+ }
24
+ return style;
33
25
  }
34
- function b(t) {
35
- let l = (t + 1) % a.column;
36
- l = l === 0 ? a.column : l;
37
- let e = 0;
38
- if (g(a.labelWidth))
39
- e = a.labelWidth;
40
- else {
41
- if (a.labelWidth === "auto") return {};
42
- const o = a.labelWidth.split(",");
43
- o.length === 1 ? e = a.labelWidth : e = o[l - 1];
26
+ function label_style(index) {
27
+ let col_number = (index + 1) % props2.column;
28
+ col_number = col_number === 0 ? props2.column : col_number;
29
+ let width = 0;
30
+ if (is_number(props2.labelWidth)) {
31
+ width = props2.labelWidth;
32
+ } else {
33
+ if (props2.labelWidth === "auto") return {};
34
+ const w_list = props2.labelWidth.split(",");
35
+ if (w_list.length === 1) {
36
+ width = props2.labelWidth;
37
+ } else {
38
+ width = w_list[col_number - 1] || w_list[0];
39
+ }
44
40
  }
45
41
  return {
46
- width: `${e}px`
42
+ width: `${width}px`
47
43
  };
48
44
  }
49
- return (t, l) => (s(), i("div", w, [
50
- r(t.$slots, "header"),
51
- d("div", {
52
- class: "view-content",
53
- style: c(f.value)
54
- }, [
55
- (s(!0), i(v, null, $(n.config, (e, o) => (s(), i("div", {
56
- class: "view-item",
57
- key: e.prop,
58
- style: c(m(e))
45
+ function get_item_value(item) {
46
+ return props2.data[item.prop] !== void 0 ? props2.data[item.prop] : "--";
47
+ }
48
+ return (_ctx, _cache) => {
49
+ return openBlock(), createElementBlock("div", _hoisted_1, [
50
+ renderSlot(_ctx.$slots, "header"),
51
+ createElementVNode("div", {
52
+ class: "view-content",
53
+ style: normalizeStyle(container_style.value)
59
54
  }, [
60
- d("div", {
61
- class: "label",
62
- style: c(b(o))
63
- }, [
64
- r(t.$slots, `label_${e.prop}`, {}, () => [
65
- u(p(`${e.label}:`), 1)
66
- ])
67
- ], 4),
68
- d("div", _, [
69
- r(t.$slots, `value_${e.prop}`, { data: n.data }, () => [
70
- u(p(n.data[e.prop] != null ? n.data[e.prop] : "--"), 1)
71
- ])
72
- ])
73
- ], 4))), 128))
74
- ], 4),
75
- r(t.$slots, "footer")
76
- ]));
55
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.config, (item, index) => {
56
+ return openBlock(), createElementBlock("div", {
57
+ key: item.prop,
58
+ class: "view-item",
59
+ style: normalizeStyle(item_style(item))
60
+ }, [
61
+ createElementVNode("div", {
62
+ class: "label",
63
+ style: normalizeStyle(label_style(index))
64
+ }, [
65
+ renderSlot(_ctx.$slots, `label_${item.prop}`, {}, () => [
66
+ createTextVNode(toDisplayString(`${item.label}:`), 1)
67
+ ])
68
+ ], 4),
69
+ createElementVNode("div", _hoisted_2, [
70
+ renderSlot(_ctx.$slots, `value_${item.prop}`, { data: _ctx.data }, () => [
71
+ createTextVNode(toDisplayString(get_item_value(item)), 1)
72
+ ])
73
+ ])
74
+ ], 4);
75
+ }), 128))
76
+ ], 4),
77
+ renderSlot(_ctx.$slots, "footer")
78
+ ]);
79
+ };
77
80
  }
78
81
  });
79
82
  export {
80
- N as default
83
+ _sfc_main as default
81
84
  };