@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.
- package/DOCUMENTATION.md +559 -0
- package/dist/@qy_better_lib/pc.min.js +1 -1
- package/lib/commDialog/index.d.ts +3 -0
- package/lib/commDialog/index.js +8 -0
- package/lib/commDialog/src/index.vue.d.ts +102 -0
- package/lib/commDialog/src/index.vue.js +49 -0
- package/lib/commDialog/src/index.vue2.js +4 -0
- package/lib/commDialog/src/props.d.ts +49 -0
- package/lib/commDialog/src/props.js +48 -0
- package/lib/commDialog/src/type.d.ts +39 -0
- package/lib/commForm/index.d.ts +3 -0
- package/lib/commForm/index.js +8 -0
- package/lib/commForm/src/index.vue.d.ts +95 -0
- package/lib/commForm/src/index.vue.js +51 -0
- package/lib/commForm/src/index.vue2.js +4 -0
- package/lib/commForm/src/props.d.ts +49 -0
- package/lib/commForm/src/props.js +47 -0
- package/lib/commForm/src/type.d.ts +8 -0
- package/lib/contextMenu/index.d.ts +5 -2
- package/lib/contextMenu/index.js +5 -4
- package/lib/contextMenu/src/index.vue.d.ts +48 -36
- package/lib/contextMenu/src/index.vue.js +128 -79
- package/lib/contextMenu/src/index.vue2.js +2 -2
- package/lib/contextMenu/src/props.d.ts +32 -0
- package/lib/contextMenu/src/props.js +27 -0
- package/lib/contextMenu/src/type.d.ts +11 -0
- package/lib/describeView/index.js +4 -4
- package/lib/describeView/src/index.vue.d.ts +6 -9
- package/lib/describeView/src/index.vue.js +73 -70
- package/lib/describeView/src/index.vue2.js +2 -2
- package/lib/describeView/src/props.d.ts +35 -0
- package/lib/describeView/src/props.js +33 -0
- package/lib/index.d.ts +7 -3
- package/lib/index.js +31 -21
- package/lib/simpleVirtualList/index.js +4 -4
- package/lib/simpleVirtualList/src/index.vue.js +70 -53
- package/lib/simpleVirtualList/src/index.vue2.js +2 -2
- package/lib/styles/comm-form.scss +4 -0
- package/lib/styles/index.scss +6 -5
- package/lib/tableExtend/index.js +4 -4
- package/lib/tableExtend/props.d.ts +74 -15
- package/lib/tableExtend/props.js +82 -24
- package/lib/tableExtend/src/colVisible.vue.js +95 -70
- package/lib/tableExtend/src/colVisible.vue2.js +2 -2
- package/lib/tableExtend/src/index.vue.d.ts +18 -10
- package/lib/tableExtend/src/index.vue.js +171 -142
- package/lib/tableExtend/src/index.vue2.js +2 -2
- package/lib/tableExtend/src/valueCol.vue.js +11 -8
- package/lib/tableExtend/src/valueCol.vue2.js +2 -2
- package/lib/tableExtend/type.d.ts +9 -14
- package/lib/tableExtend/type.js +7 -2
- package/lib/tableExtend/useTable.d.ts +19 -50
- package/lib/tableExtend/useTable.js +95 -56
- package/lib/textButton/index.js +4 -4
- package/lib/textButton/src/index.vue.d.ts +7 -6
- package/lib/textButton/src/index.vue.js +25 -37
- package/lib/textButton/src/index.vue2.js +2 -2
- package/lib/textButton/src/props.d.ts +23 -0
- package/lib/textButton/src/props.js +30 -0
- package/lib/textButton/src/type.d.ts +30 -0
- package/lib/utils/index.d.ts +55 -13
- package/lib/utils/index.js +98 -54
- package/package.json +25 -8
- package/types/index.d.ts +9 -1
- /package/lib/styles/{contextMenu.scss → context-menu.scss} +0 -0
- /package/lib/styles/{describeView.scss → describe-view.scss} +0 -0
- /package/lib/styles/{simpleVirtualList.scss → simple-virtual-list.scss} +0 -0
- /package/lib/styles/{tableExtend.scss → table-extend.scss} +0 -0
- /package/lib/styles/{textButton.scss → text-button.scss} +0 -0
|
@@ -1,74 +1,86 @@
|
|
|
1
|
-
import {
|
|
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:
|
|
16
|
+
data: ContextMenuItem;
|
|
12
17
|
}): any;
|
|
13
18
|
};
|
|
14
19
|
refs: {
|
|
15
|
-
|
|
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<
|
|
34
|
-
default: never[];
|
|
35
|
-
required:
|
|
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
|
-
|
|
42
|
-
|
|
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<
|
|
57
|
-
default: never[];
|
|
58
|
-
required:
|
|
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
|
-
|
|
62
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
position:
|
|
67
|
-
x: number;
|
|
68
|
-
y: number;
|
|
69
|
-
};
|
|
79
|
+
disabled: boolean;
|
|
80
|
+
options: ContextMenuItem[];
|
|
81
|
+
position: MenuPosition;
|
|
70
82
|
}, {}, {}, {}, string, ComponentProvideOptions, true, {
|
|
71
|
-
|
|
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
|
|
2
|
-
import { ClickOutside
|
|
3
|
-
|
|
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:
|
|
12
|
+
default: false
|
|
9
13
|
},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
const context_menu_ref = ref(null);
|
|
26
|
+
const position = reactive({
|
|
27
|
+
left: "0px",
|
|
28
|
+
top: "0px"
|
|
31
29
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
44
|
-
|
|
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
|
|
47
|
-
|
|
71
|
+
async function show_menu(pos) {
|
|
72
|
+
visible.value = true;
|
|
73
|
+
emit("show");
|
|
74
|
+
await nextTick();
|
|
75
|
+
set_position(pos);
|
|
48
76
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const { pageX: o, pageY: t } = e;
|
|
52
|
-
k({ x: o, y: t });
|
|
77
|
+
function hide() {
|
|
78
|
+
hide_menu();
|
|
53
79
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
|
|
80
|
+
function hide_menu() {
|
|
81
|
+
visible.value = false;
|
|
82
|
+
emit("hide");
|
|
57
83
|
}
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
|
|
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
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
110
|
+
function on_menu_click(item) {
|
|
111
|
+
if (item.disabled) return;
|
|
112
|
+
emit("menu_click", item);
|
|
113
|
+
hide_menu();
|
|
67
114
|
}
|
|
68
|
-
return (
|
|
69
|
-
const
|
|
70
|
-
return
|
|
71
|
-
|
|
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:
|
|
75
|
-
ref_key: "
|
|
76
|
-
ref:
|
|
121
|
+
style: normalizeStyle({ top: position.top, left: position.left }),
|
|
122
|
+
ref_key: "context_menu_ref",
|
|
123
|
+
ref: context_menu_ref
|
|
77
124
|
}, [
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
(
|
|
81
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
[
|
|
97
|
-
]) :
|
|
145
|
+
[unref(ClickOutside), hide_menu]
|
|
146
|
+
]) : createCommentVNode("", true)
|
|
98
147
|
]);
|
|
99
148
|
};
|
|
100
149
|
}
|
|
101
150
|
});
|
|
102
151
|
export {
|
|
103
|
-
|
|
152
|
+
_sfc_main as default
|
|
104
153
|
};
|
|
@@ -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
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
35
|
-
let
|
|
36
|
-
|
|
37
|
-
let
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
else {
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
|
|
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: `${
|
|
42
|
+
width: `${width}px`
|
|
47
43
|
};
|
|
48
44
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
(
|
|
56
|
-
class: "view-
|
|
57
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
83
|
+
_sfc_main as default
|
|
81
84
|
};
|