qy-better-lib 0.0.1

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 (185) hide show
  1. package/.vscode/extensions.json +3 -0
  2. package/LICENSE +24 -0
  3. package/README.md +2 -0
  4. package/index.html +13 -0
  5. package/package.json +37 -0
  6. package/packages/core/DOCUMENTATION.md +2681 -0
  7. package/packages/core/LICENSE +24 -0
  8. package/packages/core/package.json +67 -0
  9. package/packages/core/types/index.d.ts +39 -0
  10. package/packages/core/types/json.d.ts +4 -0
  11. package/packages/core/types/vue.shim.d.ts +5 -0
  12. package/packages/core/vitest.config.ts +15 -0
  13. package/packages/core/yarn.lock +1233 -0
  14. package/packages/hooks/DOCUMENTATION.md +634 -0
  15. package/packages/hooks/LICENSE +24 -0
  16. package/packages/hooks/__tests__/use-chart/index.test.ts +287 -0
  17. package/packages/hooks/__tests__/use-emit/index.test.ts +248 -0
  18. package/packages/hooks/__tests__/use-fullscreen/index.test.ts +162 -0
  19. package/packages/hooks/__tests__/use-image/index.test.ts +230 -0
  20. package/packages/hooks/__tests__/use-layout-flow/index.test.ts +382 -0
  21. package/packages/hooks/__tests__/use-mqtt/index.test.ts +392 -0
  22. package/packages/hooks/__tests__/use-print/index.test.ts +378 -0
  23. package/packages/hooks/__tests__/use-watermark/index.test.ts +277 -0
  24. package/packages/hooks/__tests__/use-websocket/index.test.ts +402 -0
  25. package/packages/hooks/package.json +104 -0
  26. package/packages/hooks/types/index.d.ts +1 -0
  27. package/packages/hooks/types/json.d.ts +4 -0
  28. package/packages/hooks/types/vue.shim.d.ts +5 -0
  29. package/packages/hooks/yarn.lock +1832 -0
  30. package/packages/lowcode/core/package.json +60 -0
  31. package/packages/lowcode/core/types/index.d.ts +1 -0
  32. package/packages/lowcode/core/types/json.d.ts +4 -0
  33. package/packages/lowcode/core/types/vue.shim.d.ts +5 -0
  34. package/packages/lowcode/core/vite.dist.min.config.js +40 -0
  35. package/packages/lowcode/core/vite.dist.min.config.js.map +1 -0
  36. package/packages/lowcode/core/vite.lib.config.js +74 -0
  37. package/packages/lowcode/core/vite.lib.config.js.map +1 -0
  38. package/packages/lowcode/core/yarn.lock +1132 -0
  39. package/packages/lowcode/mobile/package.json +63 -0
  40. package/packages/lowcode/mobile/types/index.d.ts +1 -0
  41. package/packages/lowcode/mobile/types/json.d.ts +4 -0
  42. package/packages/lowcode/mobile/types/vue.shim.d.ts +77 -0
  43. package/packages/lowcode/mobile/vite.config.js +11 -0
  44. package/packages/lowcode/mobile/vite.config.js.map +1 -0
  45. package/packages/lowcode/mobile/vite.dist.min.config.js +71 -0
  46. package/packages/lowcode/mobile/vite.dist.min.config.js.map +1 -0
  47. package/packages/lowcode/mobile/vite.lib.config.js +137 -0
  48. package/packages/lowcode/mobile/vite.lib.config.js.map +1 -0
  49. package/packages/lowcode/mobile/yarn.lock +3888 -0
  50. package/packages/lowcode/pc/package.json +64 -0
  51. package/packages/lowcode/pc/vite.config.js +11 -0
  52. package/packages/lowcode/pc/vite.config.js.map +1 -0
  53. package/packages/lowcode/pc/vite.dist.min.config.js +71 -0
  54. package/packages/lowcode/pc/vite.dist.min.config.js.map +1 -0
  55. package/packages/lowcode/pc/vite.lib.config.js +137 -0
  56. package/packages/lowcode/pc/vite.lib.config.js.map +1 -0
  57. package/packages/lowcode/pc/yarn.lock +4026 -0
  58. package/packages/pc_components/DOCUMENTATION.md +566 -0
  59. package/packages/pc_components/LICENSE +24 -0
  60. package/packages/pc_components/lib/commDialog/index.d.ts +3 -0
  61. package/packages/pc_components/lib/commDialog/index.js +8 -0
  62. package/packages/pc_components/lib/commDialog/src/index.vue.d.ts +102 -0
  63. package/packages/pc_components/lib/commDialog/src/index.vue.js +43 -0
  64. package/packages/pc_components/lib/commDialog/src/index.vue2.js +4 -0
  65. package/packages/pc_components/lib/commDialog/src/props.d.ts +49 -0
  66. package/packages/pc_components/lib/commDialog/src/props.js +48 -0
  67. package/packages/pc_components/lib/commDialog/src/type.d.ts +39 -0
  68. package/packages/pc_components/lib/commForm/index.d.ts +3 -0
  69. package/packages/pc_components/lib/commForm/index.js +8 -0
  70. package/packages/pc_components/lib/commForm/src/index.vue.d.ts +95 -0
  71. package/packages/pc_components/lib/commForm/src/index.vue.js +50 -0
  72. package/packages/pc_components/lib/commForm/src/index.vue2.js +4 -0
  73. package/packages/pc_components/lib/commForm/src/props.d.ts +49 -0
  74. package/packages/pc_components/lib/commForm/src/props.js +47 -0
  75. package/packages/pc_components/lib/commForm/src/type.d.ts +8 -0
  76. package/packages/pc_components/lib/contextMenu/index.d.ts +5 -0
  77. package/packages/pc_components/lib/contextMenu/index.js +8 -0
  78. package/packages/pc_components/lib/contextMenu/src/index.vue.d.ts +91 -0
  79. package/packages/pc_components/lib/contextMenu/src/index.vue.js +153 -0
  80. package/packages/pc_components/lib/contextMenu/src/index.vue2.js +4 -0
  81. package/packages/pc_components/lib/contextMenu/src/props.d.ts +32 -0
  82. package/packages/pc_components/lib/contextMenu/src/props.js +27 -0
  83. package/packages/pc_components/lib/contextMenu/src/type.d.ts +11 -0
  84. package/packages/pc_components/lib/describeView/index.d.ts +2 -0
  85. package/packages/pc_components/lib/describeView/index.js +7 -0
  86. package/packages/pc_components/lib/describeView/src/index.vue.d.ts +61 -0
  87. package/packages/pc_components/lib/describeView/src/index.vue.js +84 -0
  88. package/packages/pc_components/lib/describeView/src/index.vue2.js +4 -0
  89. package/packages/pc_components/lib/describeView/src/props.d.ts +35 -0
  90. package/packages/pc_components/lib/describeView/src/props.js +33 -0
  91. package/packages/pc_components/lib/describeView/src/type.d.ts +10 -0
  92. package/packages/pc_components/lib/index.d.ts +18 -0
  93. package/packages/pc_components/lib/index.js +40 -0
  94. package/packages/pc_components/lib/simpleVirtualList/index.d.ts +2 -0
  95. package/packages/pc_components/lib/simpleVirtualList/index.js +7 -0
  96. package/packages/pc_components/lib/simpleVirtualList/src/index.vue.d.ts +28 -0
  97. package/packages/pc_components/lib/simpleVirtualList/src/index.vue.js +101 -0
  98. package/packages/pc_components/lib/simpleVirtualList/src/index.vue2.js +4 -0
  99. package/packages/pc_components/lib/simpleVirtualList/src/type.d.ts +12 -0
  100. package/packages/pc_components/lib/styles/comm-form.scss +4 -0
  101. package/packages/pc_components/lib/styles/context-menu.scss +47 -0
  102. package/packages/pc_components/lib/styles/describe-view.scss +25 -0
  103. package/packages/pc_components/lib/styles/index.scss +6 -0
  104. package/packages/pc_components/lib/styles/simple-virtual-list.scss +25 -0
  105. package/packages/pc_components/lib/styles/table-extend.scss +100 -0
  106. package/packages/pc_components/lib/styles/text-button.scss +71 -0
  107. package/packages/pc_components/lib/tableExtend/index.d.ts +3 -0
  108. package/packages/pc_components/lib/tableExtend/index.js +7 -0
  109. package/packages/pc_components/lib/tableExtend/props.d.ts +130 -0
  110. package/packages/pc_components/lib/tableExtend/props.js +128 -0
  111. package/packages/pc_components/lib/tableExtend/src/colVisible.vue.d.ts +3 -0
  112. package/packages/pc_components/lib/tableExtend/src/colVisible.vue.js +128 -0
  113. package/packages/pc_components/lib/tableExtend/src/colVisible.vue2.js +4 -0
  114. package/packages/pc_components/lib/tableExtend/src/index.vue.d.ts +186 -0
  115. package/packages/pc_components/lib/tableExtend/src/index.vue.js +234 -0
  116. package/packages/pc_components/lib/tableExtend/src/index.vue2.js +4 -0
  117. package/packages/pc_components/lib/tableExtend/src/valueCol.vue.d.ts +24 -0
  118. package/packages/pc_components/lib/tableExtend/src/valueCol.vue.js +29 -0
  119. package/packages/pc_components/lib/tableExtend/src/valueCol.vue2.js +4 -0
  120. package/packages/pc_components/lib/tableExtend/type.d.ts +165 -0
  121. package/packages/pc_components/lib/tableExtend/type.js +9 -0
  122. package/packages/pc_components/lib/tableExtend/useTable.d.ts +27 -0
  123. package/packages/pc_components/lib/tableExtend/useTable.js +115 -0
  124. package/packages/pc_components/lib/textButton/index.d.ts +2 -0
  125. package/packages/pc_components/lib/textButton/index.js +7 -0
  126. package/packages/pc_components/lib/textButton/src/index.vue.d.ts +42 -0
  127. package/packages/pc_components/lib/textButton/src/index.vue.js +44 -0
  128. package/packages/pc_components/lib/textButton/src/index.vue2.js +4 -0
  129. package/packages/pc_components/lib/textButton/src/props.d.ts +23 -0
  130. package/packages/pc_components/lib/textButton/src/props.js +30 -0
  131. package/packages/pc_components/lib/textButton/src/type.d.ts +30 -0
  132. package/packages/pc_components/lib/utils/index.d.ts +77 -0
  133. package/packages/pc_components/lib/utils/index.js +124 -0
  134. package/packages/pc_components/package.json +73 -0
  135. package/packages/pc_components/types/index.d.ts +9 -0
  136. package/packages/pc_components/types/json.d.ts +4 -0
  137. package/packages/pc_components/types/vue.shim.d.ts +5 -0
  138. package/packages/pc_components/yarn.lock +1641 -0
  139. package/postcss.config.js +19 -0
  140. package/public/vite.svg +1 -0
  141. package/src/App.vue +37 -0
  142. package/src/api/index.ts +42 -0
  143. package/src/assets/vue.svg +1 -0
  144. package/src/document/core.md +2680 -0
  145. package/src/document/hooks.md +632 -0
  146. package/src/document/pc_components.md +566 -0
  147. package/src/locales/en.json +1 -0
  148. package/src/locales/zh-cn.json +1 -0
  149. package/src/main.ts +13 -0
  150. package/src/plugins/element-plus.ts +16 -0
  151. package/src/plugins/i18n.ts +17 -0
  152. package/src/plugins/index.ts +13 -0
  153. package/src/plugins/store.ts +12 -0
  154. package/src/router/index.ts +20 -0
  155. package/src/shared/chartType.ts +279 -0
  156. package/src/shared/const.ts +160 -0
  157. package/src/shared/lib.ts +129 -0
  158. package/src/shared/request.ts +255 -0
  159. package/src/shared/type.ts +48 -0
  160. package/src/shared/utils/date.ts +83 -0
  161. package/src/shared/utils/utils.ts +85 -0
  162. package/src/store/index.ts +22 -0
  163. package/src/store/modules/app.ts +17 -0
  164. package/src/store/modules/shared.ts +21 -0
  165. package/src/styles/index.scss +169 -0
  166. package/src/types/app.d.ts +23 -0
  167. package/src/types/echarts.d.ts +5 -0
  168. package/src/types/index.d.ts +1 -0
  169. package/src/types/json.d.ts +4 -0
  170. package/src/types/scss.d.ts +9 -0
  171. package/src/types/vue.shim.d.ts +5 -0
  172. package/src/views/docs/docs-content.vue +379 -0
  173. package/src/views/docs/docs-header.vue +130 -0
  174. package/src/views/docs/docs-sidebar.vue +76 -0
  175. package/src/views/docs/hooks.ts +600 -0
  176. package/src/views/docs/index.vue +30 -0
  177. package/src/views/docs/styles/docs-content.scss +106 -0
  178. package/src/views/docs/styles/docs-header.scss +20 -0
  179. package/src/views/docs/styles/docs-sidebar.scss +182 -0
  180. package/src/views/docs/styles/index.scss +14 -0
  181. package/src/views/docs/type.ts +101 -0
  182. package/src/views/index.vue +34 -0
  183. package/tsconfig.json +37 -0
  184. package/tsconfig.node.json +8 -0
  185. package/vite.config.ts +54 -0
@@ -0,0 +1,153 @@
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({
8
+ __name: "index",
9
+ props: /* @__PURE__ */ mergeModels(props(), {
10
+ "visible": {
11
+ type: Boolean,
12
+ default: false
13
+ },
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
24
+ });
25
+ const context_menu_ref = ref(null);
26
+ const position = reactive({
27
+ left: "0px",
28
+ top: "0px"
29
+ });
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();
39
+ });
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);
70
+ }
71
+ async function show_menu(pos) {
72
+ visible.value = true;
73
+ emit("show");
74
+ await nextTick();
75
+ set_position(pos);
76
+ }
77
+ function hide() {
78
+ hide_menu();
79
+ }
80
+ function hide_menu() {
81
+ visible.value = false;
82
+ emit("hide");
83
+ }
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 };
109
+ }
110
+ function on_menu_click(item) {
111
+ if (item.disabled) return;
112
+ emit("menu_click", item);
113
+ hide_menu();
114
+ }
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", {
119
+ key: 0,
120
+ class: "contextmenu",
121
+ style: normalizeStyle({ top: position.top, left: position.left }),
122
+ ref_key: "context_menu_ref",
123
+ ref: context_menu_ref
124
+ }, [
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
130
+ }, [
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))
142
+ ])
143
+ ])
144
+ ], 4)), [
145
+ [unref(ClickOutside), hide_menu]
146
+ ]) : createCommentVNode("", true)
147
+ ]);
148
+ };
149
+ }
150
+ });
151
+ export {
152
+ _sfc_main as default
153
+ };
@@ -0,0 +1,4 @@
1
+ import _sfc_main from "./index.vue.js";
2
+ export {
3
+ _sfc_main as default
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
+ }
@@ -0,0 +1,2 @@
1
+ import { default as describeView } from './src/index.vue';
2
+ export default describeView;
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./src/index.vue.js";
2
+ _sfc_main.install = (app) => {
3
+ app.component("DescribeView", _sfc_main);
4
+ };
5
+ export {
6
+ _sfc_main as default
7
+ };
@@ -0,0 +1,61 @@
1
+ import { ViewConfig } from './type';
2
+ import { DefineComponent, ExtractPropTypes, PropType, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
+ declare function __VLS_template(): {
4
+ attrs: Partial<{}>;
5
+ slots: Partial<Record<`label_${string}`, (_: {}) => any>> & Partial<Record<`value_${string}`, (_: {
6
+ data: Record<string, any>;
7
+ }) => any>> & {
8
+ header?(_: {}): any;
9
+ footer?(_: {}): any;
10
+ };
11
+ refs: {};
12
+ rootEl: HTMLDivElement;
13
+ };
14
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
15
+ declare const __VLS_component: DefineComponent<ExtractPropTypes<{
16
+ config: {
17
+ type: PropType<Array<ViewConfig>>;
18
+ default: () => never[];
19
+ };
20
+ data: {
21
+ type: PropType<Record<string, any>>;
22
+ default: () => {};
23
+ };
24
+ column: {
25
+ type: NumberConstructor;
26
+ default: number;
27
+ };
28
+ labelWidth: {
29
+ type: (StringConstructor | NumberConstructor)[];
30
+ default: number;
31
+ };
32
+ }>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly< ExtractPropTypes<{
33
+ config: {
34
+ type: PropType<Array<ViewConfig>>;
35
+ default: () => never[];
36
+ };
37
+ data: {
38
+ type: PropType<Record<string, any>>;
39
+ default: () => {};
40
+ };
41
+ column: {
42
+ type: NumberConstructor;
43
+ default: number;
44
+ };
45
+ labelWidth: {
46
+ type: (StringConstructor | NumberConstructor)[];
47
+ default: number;
48
+ };
49
+ }>> & Readonly<{}>, {
50
+ data: Record<string, any>;
51
+ column: number;
52
+ config: ViewConfig[];
53
+ labelWidth: string | number;
54
+ }, {}, {}, {}, string, ComponentProvideOptions, true, {}, HTMLDivElement>;
55
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
56
+ export default _default;
57
+ type __VLS_WithTemplateSlots<T, S> = T & {
58
+ new (): {
59
+ $slots: S;
60
+ };
61
+ };
@@ -0,0 +1,84 @@
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({
7
+ __name: "index",
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;
25
+ }
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
+ }
40
+ }
41
+ return {
42
+ width: `${width}px`
43
+ };
44
+ }
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)
54
+ }, [
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
+ };
80
+ }
81
+ });
82
+ export {
83
+ _sfc_main as default
84
+ };
@@ -0,0 +1,4 @@
1
+ import _sfc_main from "./index.vue.js";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -0,0 +1,35 @@
1
+ import { PropType } from 'vue';
2
+ import { ViewConfig } from './type';
3
+ /**
4
+ * 描述性视图组件属性定义
5
+ */
6
+ export declare const props: () => {
7
+ /**
8
+ * 配置项列表
9
+ */
10
+ config: {
11
+ type: PropType<Array<ViewConfig>>;
12
+ default: () => never[];
13
+ };
14
+ /**
15
+ * 数据对象
16
+ */
17
+ data: {
18
+ type: PropType<Record<string, any>>;
19
+ default: () => {};
20
+ };
21
+ /**
22
+ * 展示列数
23
+ */
24
+ column: {
25
+ type: NumberConstructor;
26
+ default: number;
27
+ };
28
+ /**
29
+ * label宽度:数字或字符串;如果定义多列宽度,使用字符串格式'20,30,50'
30
+ */
31
+ labelWidth: {
32
+ type: (StringConstructor | NumberConstructor)[];
33
+ default: number;
34
+ };
35
+ };
@@ -0,0 +1,33 @@
1
+ const props = () => ({
2
+ /**
3
+ * 配置项列表
4
+ */
5
+ config: {
6
+ type: Array,
7
+ default: () => []
8
+ },
9
+ /**
10
+ * 数据对象
11
+ */
12
+ data: {
13
+ type: Object,
14
+ default: () => ({})
15
+ },
16
+ /**
17
+ * 展示列数
18
+ */
19
+ column: {
20
+ type: Number,
21
+ default: 3
22
+ },
23
+ /**
24
+ * label宽度:数字或字符串;如果定义多列宽度,使用字符串格式'20,30,50'
25
+ */
26
+ labelWidth: {
27
+ type: [Number, String],
28
+ default: 85
29
+ }
30
+ });
31
+ export {
32
+ props
33
+ };
@@ -0,0 +1,10 @@
1
+ export type ViewConfig = {
2
+ /**标签名 */
3
+ label: string;
4
+ /**属性字段 */
5
+ prop: string;
6
+ /**跨列 */
7
+ col_span?: number;
8
+ /**跨行 */
9
+ row_span?: number;
10
+ };
@@ -0,0 +1,18 @@
1
+ import { default as textButton } from './textButton';
2
+ import { default as tableExtend } from './tableExtend';
3
+ import { default as ContextMenu } from './contextMenu';
4
+ import { default as describeView } from './describeView';
5
+ import { default as simpleVirtualList } from './simpleVirtualList';
6
+ import { default as commDialog } from './commDialog';
7
+ import { default as commForm } from './commForm';
8
+ import { App } from 'vue';
9
+ import { message_alert, message_box, confirm_box, confirm_box_async, notification, close_all_messages, close_all_notifications, close_all_message_boxes } from './utils';
10
+ /**
11
+ * 安装所有组件
12
+ * 也可以手动安装所需组件
13
+ */
14
+ declare function install(app: App): void;
15
+ export type { TableProp, TableColumn } from './tableExtend';
16
+ export type { ContextMenuItem, MenuPosition } from './contextMenu';
17
+ export { install, textButton, tableExtend, ContextMenu, describeView, simpleVirtualList, commDialog, commForm, message_alert, message_box, confirm_box, confirm_box_async, notification, close_all_messages, close_all_notifications, close_all_message_boxes };
18
+ export { ContextMenu as contextMenu };
@@ -0,0 +1,40 @@
1
+ import "./textButton/index.js";
2
+ import "./tableExtend/index.js";
3
+ import "./contextMenu/index.js";
4
+ import "./describeView/index.js";
5
+ import "./simpleVirtualList/index.js";
6
+ import "./commDialog/index.js";
7
+ import "./commForm/index.js";
8
+ import { close_all_message_boxes, close_all_messages, close_all_notifications, confirm_box, confirm_box_async, message_alert, message_box, notification } from "./utils/index.js";
9
+ import _sfc_main from "./textButton/src/index.vue.js";
10
+ import _sfc_main$1 from "./tableExtend/src/index.vue.js";
11
+ import _sfc_main$2 from "./contextMenu/src/index.vue.js";
12
+ import _sfc_main$3 from "./describeView/src/index.vue.js";
13
+ import _sfc_main$4 from "./simpleVirtualList/src/index.vue.js";
14
+ import _sfc_main$5 from "./commDialog/src/index.vue.js";
15
+ import _sfc_main$6 from "./commForm/src/index.vue.js";
16
+ const components = [_sfc_main, _sfc_main$1, _sfc_main$2, _sfc_main$3, _sfc_main$4, _sfc_main$5, _sfc_main$6];
17
+ function install(app) {
18
+ components.forEach((component) => {
19
+ app.use(component);
20
+ });
21
+ }
22
+ export {
23
+ _sfc_main$2 as ContextMenu,
24
+ close_all_message_boxes,
25
+ close_all_messages,
26
+ close_all_notifications,
27
+ _sfc_main$5 as commDialog,
28
+ _sfc_main$6 as commForm,
29
+ confirm_box,
30
+ confirm_box_async,
31
+ _sfc_main$2 as contextMenu,
32
+ _sfc_main$3 as describeView,
33
+ install,
34
+ message_alert,
35
+ message_box,
36
+ notification,
37
+ _sfc_main$4 as simpleVirtualList,
38
+ _sfc_main$1 as tableExtend,
39
+ _sfc_main as textButton
40
+ };
@@ -0,0 +1,2 @@
1
+ import { default as simpleVirtualList } from './src/index.vue';
2
+ export default simpleVirtualList;
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./src/index.vue.js";
2
+ _sfc_main.install = (app) => {
3
+ app.component("SimpleVirtualList", _sfc_main);
4
+ };
5
+ export {
6
+ _sfc_main as default
7
+ };
@@ -0,0 +1,28 @@
1
+ import { VirtualListProps } from './type';
2
+ import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
+ declare function __VLS_template(): {
4
+ attrs: Partial<{}>;
5
+ slots: {
6
+ item?(_: {
7
+ item: any;
8
+ }): any;
9
+ };
10
+ refs: {
11
+ container_ref: HTMLDivElement;
12
+ };
13
+ rootEl: HTMLDivElement;
14
+ };
15
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
16
+ declare const __VLS_component: DefineComponent<VirtualListProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<VirtualListProps> & Readonly<{}>, {
17
+ buffer: number;
18
+ data_key: string;
19
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {
20
+ container_ref: HTMLDivElement;
21
+ }, HTMLDivElement>;
22
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
23
+ export default _default;
24
+ type __VLS_WithTemplateSlots<T, S> = T & {
25
+ new (): {
26
+ $slots: S;
27
+ };
28
+ };
@@ -0,0 +1,101 @@
1
+ import { defineComponent, ref, computed, watch, onMounted, openBlock, createElementBlock, unref, normalizeStyle, createElementVNode, Fragment, renderList, renderSlot, createTextVNode, toDisplayString } from "vue";
2
+ import { throttle } from "@qy_better_lib/core";
3
+ const _sfc_main = /* @__PURE__ */ defineComponent({
4
+ __name: "index",
5
+ props: {
6
+ data: {},
7
+ item_height: {},
8
+ container_height: {},
9
+ buffer: { default: 5 },
10
+ data_key: { default: "id" }
11
+ },
12
+ setup(__props) {
13
+ const props = __props;
14
+ const container_ref = ref();
15
+ const scroll_cfg = ref({
16
+ /**起始索引 */
17
+ start_index: 0,
18
+ /**结束索引 */
19
+ end_index: 0,
20
+ /**可见数量 */
21
+ visible_count: 0,
22
+ /**滚动位置 */
23
+ scroll_top: 0
24
+ });
25
+ const list_visible_height = ref(0);
26
+ const list_height = computed(() => props.data.length * props.item_height);
27
+ const content_offset_y = computed(() => scroll_cfg.value.start_index * props.item_height);
28
+ const visible_data = computed(() => {
29
+ const { start_index, end_index } = scroll_cfg.value;
30
+ return props.data.slice(start_index, end_index + 1);
31
+ });
32
+ watch(() => props.data?.length || 0, () => {
33
+ init();
34
+ });
35
+ onMounted(() => {
36
+ const container = container_ref.value;
37
+ list_visible_height.value = props.container_height || container.clientHeight;
38
+ init();
39
+ });
40
+ const throttled_scroll = throttle((e) => on_scroll(e), 80);
41
+ function init() {
42
+ if (!container_ref.value) return;
43
+ const visible_count = Math.ceil(list_visible_height.value / props.item_height);
44
+ const end_index = Math.min(visible_count + props.buffer * 2, props.data.length - 1);
45
+ scroll_cfg.value = {
46
+ start_index: 0,
47
+ end_index,
48
+ visible_count,
49
+ scroll_top: 0
50
+ };
51
+ }
52
+ function on_scroll(e) {
53
+ const target = e.target;
54
+ const scroll_top = target.scrollTop;
55
+ const { visible_count } = scroll_cfg.value;
56
+ const start_index = Math.floor(scroll_top / props.item_height);
57
+ const end_index = Math.min(start_index + visible_count + props.buffer * 2, props.data.length - 1);
58
+ scroll_cfg.value = {
59
+ start_index: Math.max(0, start_index - props.buffer),
60
+ // 起始索引减去缓冲区,确保上方有预备项
61
+ end_index,
62
+ visible_count,
63
+ scroll_top
64
+ };
65
+ }
66
+ return (_ctx, _cache) => {
67
+ return openBlock(), createElementBlock("div", {
68
+ ref_key: "container_ref",
69
+ ref: container_ref,
70
+ class: "simple-virtual-list",
71
+ style: normalizeStyle({ height: `${list_visible_height.value}px` }),
72
+ onScroll: _cache[0] || (_cache[0] = //@ts-ignore
73
+ (...args) => unref(throttled_scroll) && unref(throttled_scroll)(...args))
74
+ }, [
75
+ createElementVNode("div", {
76
+ class: "simple-virtual-list-wrap",
77
+ style: normalizeStyle({ height: `${list_height.value}px` })
78
+ }, null, 4),
79
+ createElementVNode("div", {
80
+ class: "simple-virtual-list-content",
81
+ style: normalizeStyle({ transform: `translateY(${content_offset_y.value}px)` })
82
+ }, [
83
+ (openBlock(true), createElementBlock(Fragment, null, renderList(visible_data.value, (item) => {
84
+ return openBlock(), createElementBlock("div", {
85
+ key: item[__props.data_key],
86
+ class: "simple-virtual-list-item",
87
+ style: normalizeStyle({ height: `${__props.item_height}px` })
88
+ }, [
89
+ renderSlot(_ctx.$slots, "item", { item }, () => [
90
+ createTextVNode(toDisplayString(item), 1)
91
+ ])
92
+ ], 4);
93
+ }), 128))
94
+ ], 4)
95
+ ], 36);
96
+ };
97
+ }
98
+ });
99
+ export {
100
+ _sfc_main as default
101
+ };