@fangzhongya/fang-ui 0.1.55 → 0.1.56

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 (232) hide show
  1. package/dist/components/audios/src/index2.cjs +16 -10
  2. package/dist/components/audios/src/index2.js +16 -10
  3. package/dist/components/box-adjust/src/index2.cjs +6 -4
  4. package/dist/components/box-adjust/src/index2.js +6 -4
  5. package/dist/components/box-title/src/index2.cjs +3 -2
  6. package/dist/components/box-title/src/index2.js +3 -2
  7. package/dist/components/buttons/src/data.d.ts +5 -5
  8. package/dist/components/buttons/src/index2.cjs +2 -2
  9. package/dist/components/buttons/src/index2.js +2 -2
  10. package/dist/components/cascaders/src/data.d.ts +5 -5
  11. package/dist/components/checks/src/data.d.ts +5 -5
  12. package/dist/components/common/list.d.ts +1 -1
  13. package/dist/components/common/use.cjs +1 -1
  14. package/dist/components/common/use.js +1 -1
  15. package/dist/components/dates/src/data.d.ts +5 -5
  16. package/dist/components/dates2/src/data.d.ts +5 -5
  17. package/dist/components/double/src/index2.cjs +3 -2
  18. package/dist/components/double/src/index2.js +3 -2
  19. package/dist/components/edit/src/index2.cjs +3 -2
  20. package/dist/components/edit/src/index2.js +3 -2
  21. package/dist/components/edit-data/src/area/array-json2.cjs +8 -4
  22. package/dist/components/edit-data/src/area/array-json2.js +8 -4
  23. package/dist/components/edit-data/src/area/array2.cjs +46 -8
  24. package/dist/components/edit-data/src/area/array2.js +47 -9
  25. package/dist/components/edit-data/src/area/editor2.cjs +22 -4
  26. package/dist/components/edit-data/src/area/editor2.js +22 -4
  27. package/dist/components/edit-data/src/area/general2.cjs +8 -1
  28. package/dist/components/edit-data/src/area/general2.js +8 -1
  29. package/dist/components/edit-data/src/area/object-json2.cjs +5 -1
  30. package/dist/components/edit-data/src/area/object-json2.js +5 -1
  31. package/dist/components/edit-data/src/area/object2.cjs +48 -11
  32. package/dist/components/edit-data/src/area/object2.js +49 -12
  33. package/dist/components/edit-data/src/data/array2.cjs +9 -5
  34. package/dist/components/edit-data/src/data/array2.js +9 -5
  35. package/dist/components/edit-data/src/data/bigint2.cjs +7 -3
  36. package/dist/components/edit-data/src/data/bigint2.js +7 -3
  37. package/dist/components/edit-data/src/data/boolean2.cjs +7 -3
  38. package/dist/components/edit-data/src/data/boolean2.js +7 -3
  39. package/dist/components/edit-data/src/data/date.cjs +4 -0
  40. package/dist/components/edit-data/src/data/date.js +4 -0
  41. package/dist/components/edit-data/src/data/date2.cjs +48 -0
  42. package/dist/components/edit-data/src/data/date2.js +48 -0
  43. package/dist/components/edit-data/src/data/function2.cjs +16 -7
  44. package/dist/components/edit-data/src/data/function2.js +17 -8
  45. package/dist/components/edit-data/src/data/null2.cjs +3 -1
  46. package/dist/components/edit-data/src/data/null2.js +4 -2
  47. package/dist/components/edit-data/src/data/number2.cjs +7 -3
  48. package/dist/components/edit-data/src/data/number2.js +7 -3
  49. package/dist/components/edit-data/src/data/object2.cjs +9 -5
  50. package/dist/components/edit-data/src/data/object2.js +9 -5
  51. package/dist/components/edit-data/src/data/other2.cjs +13 -5
  52. package/dist/components/edit-data/src/data/other2.js +14 -6
  53. package/dist/components/edit-data/src/data/string2.cjs +7 -3
  54. package/dist/components/edit-data/src/data/string2.js +7 -3
  55. package/dist/components/edit-data/src/data/symbol2.cjs +7 -3
  56. package/dist/components/edit-data/src/data/symbol2.js +7 -3
  57. package/dist/components/edit-data/src/data/undefined2.cjs +3 -1
  58. package/dist/components/edit-data/src/data/undefined2.js +4 -2
  59. package/dist/components/edit-data/src/data.cjs +10 -0
  60. package/dist/components/edit-data/src/data.d.ts +20 -0
  61. package/dist/components/edit-data/src/data.js +10 -0
  62. package/dist/components/edit-data/src/index2.cjs +31 -2
  63. package/dist/components/edit-data/src/index2.js +45 -16
  64. package/dist/components/edit-data-add/src/index2.cjs +2 -0
  65. package/dist/components/edit-data-add/src/index2.js +2 -0
  66. package/dist/components/edit-float/src/index2.cjs +3 -2
  67. package/dist/components/edit-float/src/index2.js +3 -2
  68. package/dist/components/history/src/index2.cjs +6 -4
  69. package/dist/components/history/src/index2.js +6 -4
  70. package/dist/components/input-array/src/index2.cjs +3 -2
  71. package/dist/components/input-array/src/index2.js +3 -2
  72. package/dist/components/input-history/src/index2.cjs +3 -2
  73. package/dist/components/input-history/src/index2.js +3 -2
  74. package/dist/components/input-select/src/index2.cjs +6 -4
  75. package/dist/components/input-select/src/index2.js +6 -4
  76. package/dist/components/labels/src/data.d.ts +5 -5
  77. package/dist/components/message/index.d.ts +11 -4
  78. package/dist/components/message/src/function.d.ts +11 -4
  79. package/dist/components/message-box/index.d.ts +2 -3
  80. package/dist/components/message-box/src/function.d.ts +2 -3
  81. package/dist/components/retract/index.css +23 -20
  82. package/dist/components/retract/index.scss +39 -20
  83. package/dist/components/retract/src/data.cjs +4 -1
  84. package/dist/components/retract/src/data.d.ts +4 -1
  85. package/dist/components/retract/src/data.js +4 -1
  86. package/dist/components/retract/src/index2.cjs +12 -10
  87. package/dist/components/retract/src/index2.js +9 -7
  88. package/dist/components/right-key/index.css +2 -1
  89. package/dist/components/right-key/index.scss +2 -1
  90. package/dist/components/right-key/src/data.cjs +7 -2
  91. package/dist/components/right-key/src/data.d.ts +5 -0
  92. package/dist/components/right-key/src/data.js +7 -2
  93. package/dist/components/right-key/src/index2.cjs +134 -60
  94. package/dist/components/right-key/src/index2.js +135 -61
  95. package/dist/components/selects/src/data.d.ts +5 -5
  96. package/dist/components/stick-window/src/index2.cjs +3 -2
  97. package/dist/components/stick-window/src/index2.js +3 -2
  98. package/dist/components/switchs/src/data.d.ts +5 -4
  99. package/dist/components/uploads/src/data.d.ts +5 -5
  100. package/dist/components/uploads/src/index2.cjs +26 -21
  101. package/dist/components/uploads/src/index2.js +15 -10
  102. package/dist/components/videos/src/index2.cjs +30 -19
  103. package/dist/components/videos/src/index2.js +30 -19
  104. package/dist/components/window/src/index2.cjs +9 -6
  105. package/dist/components/window/src/index2.js +9 -6
  106. package/dist/css/index.css +25 -21
  107. package/dist/css/retract.css +23 -20
  108. package/dist/css/right-key.css +2 -1
  109. package/dist/hooks/model/index.cjs +25 -0
  110. package/dist/hooks/model/index.d.ts +2 -0
  111. package/dist/hooks/model/index.js +25 -0
  112. package/dist/icons/index.json +1 -1
  113. package/dist/icons/vue/bar.cjs +2 -18
  114. package/dist/icons/vue/bar.js +1 -17
  115. package/dist/icons/vue/bar2.cjs +21 -2
  116. package/dist/icons/vue/bar2.js +21 -2
  117. package/dist/icons/vue/below.cjs +2 -18
  118. package/dist/icons/vue/below.js +1 -17
  119. package/dist/icons/vue/below2.cjs +21 -2
  120. package/dist/icons/vue/below2.js +21 -2
  121. package/dist/icons/vue/bicycle.cjs +2 -15
  122. package/dist/icons/vue/bicycle.js +1 -14
  123. package/dist/icons/vue/bicycle2.cjs +18 -2
  124. package/dist/icons/vue/bicycle2.js +18 -2
  125. package/dist/icons/vue/bottom-left.cjs +2 -22
  126. package/dist/icons/vue/bottom-left.js +1 -21
  127. package/dist/icons/vue/bottom-left2.cjs +25 -2
  128. package/dist/icons/vue/bottom-left2.js +25 -2
  129. package/dist/icons/vue/bottom-right.cjs +2 -22
  130. package/dist/icons/vue/bottom-right.js +1 -21
  131. package/dist/icons/vue/bottom-right2.cjs +25 -2
  132. package/dist/icons/vue/bottom-right2.js +25 -2
  133. package/dist/icons/vue/bottom.cjs +2 -18
  134. package/dist/icons/vue/bottom.js +1 -17
  135. package/dist/icons/vue/bottom2.cjs +21 -2
  136. package/dist/icons/vue/bottom2.js +21 -2
  137. package/dist/icons/vue/catalogue.cjs +2 -23
  138. package/dist/icons/vue/catalogue.js +1 -22
  139. package/dist/icons/vue/catalogue2.cjs +26 -2
  140. package/dist/icons/vue/catalogue2.js +26 -2
  141. package/dist/icons/vue/clear.cjs +2 -23
  142. package/dist/icons/vue/clear.js +1 -22
  143. package/dist/icons/vue/clear2.cjs +26 -2
  144. package/dist/icons/vue/clear2.js +26 -2
  145. package/dist/icons/vue/close.cjs +2 -18
  146. package/dist/icons/vue/close.js +1 -17
  147. package/dist/icons/vue/close2.cjs +21 -2
  148. package/dist/icons/vue/close2.js +21 -2
  149. package/dist/icons/vue/delete.cjs +2 -18
  150. package/dist/icons/vue/delete.js +1 -17
  151. package/dist/icons/vue/delete2.cjs +21 -2
  152. package/dist/icons/vue/delete2.js +21 -2
  153. package/dist/icons/vue/document.cjs +2 -23
  154. package/dist/icons/vue/document.js +1 -22
  155. package/dist/icons/vue/document2.cjs +26 -2
  156. package/dist/icons/vue/document2.js +26 -2
  157. package/dist/icons/vue/down.cjs +2 -18
  158. package/dist/icons/vue/down.js +1 -17
  159. package/dist/icons/vue/down2.cjs +21 -2
  160. package/dist/icons/vue/down2.js +21 -2
  161. package/dist/icons/vue/download.cjs +2 -18
  162. package/dist/icons/vue/download.js +1 -17
  163. package/dist/icons/vue/download2.cjs +21 -2
  164. package/dist/icons/vue/download2.js +21 -2
  165. package/dist/icons/vue/edit.cjs +2 -23
  166. package/dist/icons/vue/edit.js +1 -22
  167. package/dist/icons/vue/edit2.cjs +26 -2
  168. package/dist/icons/vue/edit2.js +26 -2
  169. package/dist/icons/vue/enter.cjs +2 -19
  170. package/dist/icons/vue/enter.js +1 -18
  171. package/dist/icons/vue/enter2.cjs +22 -2
  172. package/dist/icons/vue/enter2.js +22 -2
  173. package/dist/icons/vue/frame.cjs +2 -15
  174. package/dist/icons/vue/frame.js +1 -14
  175. package/dist/icons/vue/frame2.cjs +18 -2
  176. package/dist/icons/vue/frame2.js +18 -2
  177. package/dist/icons/vue/index.cjs +81 -54
  178. package/dist/icons/vue/index.js +54 -27
  179. package/dist/icons/vue/left.cjs +2 -18
  180. package/dist/icons/vue/left.js +1 -17
  181. package/dist/icons/vue/left2.cjs +21 -2
  182. package/dist/icons/vue/left2.js +21 -2
  183. package/dist/icons/vue/mute.cjs +2 -18
  184. package/dist/icons/vue/mute.js +1 -17
  185. package/dist/icons/vue/mute2.cjs +21 -2
  186. package/dist/icons/vue/mute2.js +21 -2
  187. package/dist/icons/vue/pause.cjs +2 -24
  188. package/dist/icons/vue/pause.js +1 -23
  189. package/dist/icons/vue/pause2.cjs +27 -2
  190. package/dist/icons/vue/pause2.js +27 -2
  191. package/dist/icons/vue/play.cjs +2 -19
  192. package/dist/icons/vue/play.js +1 -18
  193. package/dist/icons/vue/play2.cjs +22 -2
  194. package/dist/icons/vue/play2.js +22 -2
  195. package/dist/icons/vue/plus.cjs +2 -18
  196. package/dist/icons/vue/plus.js +1 -17
  197. package/dist/icons/vue/plus2.cjs +21 -2
  198. package/dist/icons/vue/plus2.js +21 -2
  199. package/dist/icons/vue/retreat.cjs +2 -19
  200. package/dist/icons/vue/retreat.js +1 -18
  201. package/dist/icons/vue/retreat2.cjs +22 -2
  202. package/dist/icons/vue/retreat2.js +22 -2
  203. package/dist/icons/vue/right.cjs +2 -18
  204. package/dist/icons/vue/right.js +1 -17
  205. package/dist/icons/vue/right2.cjs +21 -2
  206. package/dist/icons/vue/right2.js +21 -2
  207. package/dist/icons/vue/sound.cjs +2 -22
  208. package/dist/icons/vue/sound.js +1 -21
  209. package/dist/icons/vue/sound2.cjs +25 -2
  210. package/dist/icons/vue/sound2.js +25 -2
  211. package/dist/icons/vue/star.cjs +2 -22
  212. package/dist/icons/vue/star.js +1 -21
  213. package/dist/icons/vue/star2.cjs +25 -2
  214. package/dist/icons/vue/star2.js +25 -2
  215. package/dist/icons/vue/up.cjs +2 -18
  216. package/dist/icons/vue/up.js +1 -17
  217. package/dist/icons/vue/up2.cjs +21 -2
  218. package/dist/icons/vue/up2.js +21 -2
  219. package/dist/icons/vue/views.cjs +2 -18
  220. package/dist/icons/vue/views.js +1 -17
  221. package/dist/icons/vue/views2.cjs +21 -2
  222. package/dist/icons/vue/views2.js +21 -2
  223. package/dist/index.css +25 -21
  224. package/dist/utils/vues/index.d.ts +1 -0
  225. package/dist/utils/vues/shared.cjs +19 -0
  226. package/dist/utils/vues/shared.d.ts +5 -0
  227. package/dist/utils/vues/shared.js +19 -0
  228. package/package.json +12 -13
  229. package/dist/_virtual/_plugin-vue_export-helper.cjs +0 -10
  230. package/dist/_virtual/_plugin-vue_export-helper.js +0 -10
  231. /package/dist/components/{box-fun → box}/index.css +0 -0
  232. /package/dist/css/{box-fun.css → box.css} +0 -0
@@ -8,6 +8,7 @@ const index$3 = require("../../box-teleport/index.cjs");
8
8
  const data = require("./data.cjs");
9
9
  const index$1 = require("../../../hooks/cssname/index.cjs");
10
10
  const index = require("../../../hooks/locale/index.cjs");
11
+ const getBoxDom = require("../../../utils/vues/getBoxDom.cjs");
11
12
  const index$2 = require("../../../hooks/props-default/index.cjs");
12
13
  const _hoisted_1 = ["onClick"];
13
14
  const _sfc_main = /* @__PURE__ */ vue.defineComponent({
@@ -23,73 +24,145 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
23
24
  const flag = vue.ref(false);
24
25
  const refRightKey = vue.ref();
25
26
  const refRightKeyBox = vue.ref();
26
- const topx = vue.ref("");
27
- const lefty = vue.ref("");
27
+ const position = vue.ref({ x: 0, y: 0 });
28
28
  const dom = vue.ref();
29
- vue.onMounted(() => {
30
- globalThis.addEventListener("mousedown", watchContextmenu);
31
- });
32
- vue.onUnmounted(() => {
33
- globalThis.removeEventListener("mousedown", watchContextmenu);
29
+ const boxStyle = vue.computed(() => {
30
+ if (!refRightKeyBox.value) return {};
31
+ const rect = refRightKeyBox.value.getBoundingClientRect();
32
+ const { innerWidth, innerHeight } = window;
33
+ let x = position.value.x;
34
+ let y = position.value.y;
35
+ if (x + rect.width > innerWidth) {
36
+ x = x - rect.width;
37
+ }
38
+ if (y + rect.height > innerHeight) {
39
+ y = y - rect.height;
40
+ }
41
+ return {
42
+ top: `${y}px`,
43
+ left: `${x}px`
44
+ };
34
45
  });
35
- function watchContextmenu(event) {
36
- if (refRightKeyBox.value.contains(event.target)) {
46
+ function handleGlobalMousedown(event) {
47
+ var _a;
48
+ if ((_a = refRightKeyBox.value) == null ? void 0 : _a.contains(event.target)) {
37
49
  return;
38
50
  }
39
- if (!refRightKey.value.contains(event.target) || event.button !== 2) {
51
+ flag.value = false;
52
+ }
53
+ function handleGlobalClick(event) {
54
+ var _a;
55
+ if (event.button === 2) return;
56
+ if (!((_a = refRightKeyBox.value) == null ? void 0 : _a.contains(event.target))) {
57
+ flag.value = false;
58
+ }
59
+ }
60
+ function handleKeydown(event) {
61
+ if (event.key === "Escape" && flag.value) {
40
62
  flag.value = false;
41
63
  }
42
64
  }
43
65
  function isDomClass(dom2) {
44
- if (dom2) {
45
- if (props.domClass) {
46
- const v = getPrentClass.getPrentClass(
47
- dom2,
48
- props.domClass,
49
- props.level
50
- );
51
- if (v && refRightKey.value.contains(v)) {
52
- return v;
53
- }
54
- } else {
55
- return dom2;
66
+ var _a, _b;
67
+ if (!dom2) return null;
68
+ if (props.domClass) {
69
+ const element = getPrentClass.getPrentClass(
70
+ dom2,
71
+ props.domClass,
72
+ props.level
73
+ );
74
+ if (element && ((_a = refRightKey.value) == null ? void 0 : _a.contains(element))) {
75
+ return element;
56
76
  }
77
+ } else if ((_b = refRightKey.value) == null ? void 0 : _b.contains(dom2)) {
78
+ return dom2;
57
79
  }
80
+ return null;
58
81
  }
59
82
  function handleContextmenu(event) {
60
- let target = event.target;
61
- target = isDomClass(target);
62
- if (target) {
63
- dom.value = target;
64
- let x = 0, y = 0;
65
- if (event.x || event.y) {
66
- x = event.x;
67
- y = event.y;
68
- } else if (event.pageX || event.pageY) {
69
- x = event.pageX - 1;
70
- y = event.pageY - 1;
71
- }
72
- let ww = globalThis ? globalThis.innerWidth : 0;
73
- let kw = 0;
74
- if (ww != 0 && x + 120 > ww) {
75
- kw = 0 - (x + 120 - ww);
76
- }
77
- topx.value = x + kw + "px";
78
- lefty.value = y + "px";
79
- flag.value = true;
80
- event.preventDefault();
81
- event.stopPropagation();
82
- emit("click-right", target);
83
- } else {
83
+ const target = isDomClass(event.target);
84
+ if (!target) {
84
85
  flag.value = false;
86
+ return;
85
87
  }
88
+ dom.value = target;
89
+ let x = event.clientX;
90
+ let y = event.clientY;
91
+ flag.value = true;
92
+ event.preventDefault();
93
+ event.stopPropagation();
94
+ emit("click-right", target);
95
+ vue.nextTick(() => {
96
+ position.value = { x, y };
97
+ });
86
98
  }
87
99
  function onClick(v) {
88
100
  flag.value = false;
89
101
  emit("click-key", v, dom.value);
90
102
  }
103
+ const toDom = vue.ref();
104
+ vue.watch(
105
+ () => flag.value,
106
+ () => {
107
+ if (props.isSingle) {
108
+ if (flag.value) {
109
+ if (toDom.value) {
110
+ toDom.value.querySelectorAll("." + cs.z("box")).forEach((v) => {
111
+ v.style.display = "none";
112
+ });
113
+ }
114
+ vue.nextTick(() => {
115
+ refRightKeyBox.value.style.display = "block";
116
+ });
117
+ } else {
118
+ refRightKeyBox.value.style.display = "none";
119
+ }
120
+ } else {
121
+ refRightKeyBox.value.style.display = flag.value ? "block" : "none";
122
+ }
123
+ }
124
+ );
125
+ vue.onMounted(() => {
126
+ toDom.value = getBoxDom.getBoxDom();
127
+ document.addEventListener("mousedown", handleGlobalMousedown, true);
128
+ document.addEventListener("click", handleGlobalClick, true);
129
+ document.addEventListener("keydown", handleKeydown);
130
+ window.addEventListener("resize", () => {
131
+ if (flag.value) {
132
+ flag.value = false;
133
+ }
134
+ });
135
+ window.addEventListener(
136
+ "scroll",
137
+ () => {
138
+ if (flag.value) {
139
+ flag.value = false;
140
+ }
141
+ },
142
+ true
143
+ );
144
+ });
145
+ vue.onUnmounted(() => {
146
+ document.removeEventListener("mousedown", handleGlobalMousedown, true);
147
+ document.removeEventListener("click", handleGlobalClick, true);
148
+ document.removeEventListener("keydown", handleKeydown);
149
+ window.removeEventListener("resize", () => {
150
+ });
151
+ window.removeEventListener("scroll", () => {
152
+ }, true);
153
+ });
91
154
  __expose({
92
- ...data.dataExpose
155
+ ...data.dataExpose,
156
+ // 提供关闭菜单的方法
157
+ close: () => {
158
+ flag.value = false;
159
+ },
160
+ // 提供打开菜单的方法
161
+ open: (x, y, target) => {
162
+ position.value = { x, y };
163
+ dom.value = target;
164
+ flag.value = true;
165
+ }
93
166
  });
94
167
  return (_ctx, _cache) => {
95
168
  return vue.openBlock(), vue.createElementBlock("div", {
@@ -108,11 +181,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
108
181
  class: vue.normalizeClass([vue.unref(cs).z("box"), vue.unref(props).boxClass]),
109
182
  ref_key: "refRightKeyBox",
110
183
  ref: refRightKeyBox,
111
- style: vue.normalizeStyle({
112
- position: "fixed",
113
- top: lefty.value,
114
- left: topx.value
115
- })
184
+ style: vue.normalizeStyle(boxStyle.value)
116
185
  }, [
117
186
  vue.createElementVNode("div", {
118
187
  class: vue.normalizeClass(vue.unref(cs).z("box-list"))
@@ -123,13 +192,18 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
123
192
  onClick: vue.withModifiers(($event) => onClick(v), ["stop"]),
124
193
  class: vue.normalizeClass(vue.unref(cs).z("box-list-li"))
125
194
  }, [
126
- v.icon ? (vue.openBlock(), vue.createBlock(vue.unref(index$4.Icon), { key: 0 }, {
127
- default: vue.withCtx(() => [
128
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(v.icon)))
129
- ]),
130
- _: 2
131
- }, 1024)) : vue.createCommentVNode("", true),
132
- vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(use.useVueValue)(v, vue.unref(props).label)), 1)
195
+ vue.renderSlot(_ctx.$slots, vue.unref(data.dataSlot).list, {
196
+ value: v,
197
+ index: k
198
+ }, () => [
199
+ v.icon ? (vue.openBlock(), vue.createBlock(vue.unref(index$4.Icon), { key: 0 }, {
200
+ default: vue.withCtx(() => [
201
+ (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(v.icon)))
202
+ ]),
203
+ _: 2
204
+ }, 1024)) : vue.createCommentVNode("", true),
205
+ vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(use.useVueValue)(v, vue.unref(props).label)), 1)
206
+ ])
133
207
  ], 10, _hoisted_1);
134
208
  }), 128))
135
209
  ], 2)
@@ -137,7 +211,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
137
211
  [vue.vShow, flag.value]
138
212
  ])
139
213
  ]),
140
- _: 1
214
+ _: 3
141
215
  }, 8, ["disabled", "to"])
142
216
  ], 34);
143
217
  };
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, onMounted, onUnmounted, createElementBlock, openBlock, normalizeClass, unref, renderSlot, createVNode, withCtx, withDirectives, createElementVNode, normalizeStyle, Fragment, renderList, withModifiers, createBlock, createCommentVNode, resolveDynamicComponent, toDisplayString, vShow } from "vue";
1
+ import { defineComponent, ref, computed, nextTick, watch, onMounted, onUnmounted, createElementBlock, openBlock, normalizeClass, unref, renderSlot, createVNode, withCtx, withDirectives, createElementVNode, normalizeStyle, Fragment, renderList, withModifiers, createBlock, createCommentVNode, resolveDynamicComponent, toDisplayString, vShow } from "vue";
2
2
  import { getPrentClass } from "@fangzhongya/utils/css/getPrentClass";
3
3
  import { useVueValue } from "../../common/use.js";
4
4
  import { Icon } from "../../icon/index.js";
@@ -6,6 +6,7 @@ import { BoxTeleport } from "../../box-teleport/index.js";
6
6
  import { name, dataProps, dataExpose, dataSlot, dataEmits } from "./data.js";
7
7
  import { useCssName } from "../../../hooks/cssname/index.js";
8
8
  import { useLocale } from "../../../hooks/locale/index.js";
9
+ import { getBoxDom } from "../../../utils/vues/getBoxDom.js";
9
10
  import { usePropsDefault, getProps } from "../../../hooks/props-default/index.js";
10
11
  const _hoisted_1 = ["onClick"];
11
12
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -21,73 +22,145 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
21
22
  const flag = ref(false);
22
23
  const refRightKey = ref();
23
24
  const refRightKeyBox = ref();
24
- const topx = ref("");
25
- const lefty = ref("");
25
+ const position = ref({ x: 0, y: 0 });
26
26
  const dom = ref();
27
- onMounted(() => {
28
- globalThis.addEventListener("mousedown", watchContextmenu);
29
- });
30
- onUnmounted(() => {
31
- globalThis.removeEventListener("mousedown", watchContextmenu);
27
+ const boxStyle = computed(() => {
28
+ if (!refRightKeyBox.value) return {};
29
+ const rect = refRightKeyBox.value.getBoundingClientRect();
30
+ const { innerWidth, innerHeight } = window;
31
+ let x = position.value.x;
32
+ let y = position.value.y;
33
+ if (x + rect.width > innerWidth) {
34
+ x = x - rect.width;
35
+ }
36
+ if (y + rect.height > innerHeight) {
37
+ y = y - rect.height;
38
+ }
39
+ return {
40
+ top: `${y}px`,
41
+ left: `${x}px`
42
+ };
32
43
  });
33
- function watchContextmenu(event) {
34
- if (refRightKeyBox.value.contains(event.target)) {
44
+ function handleGlobalMousedown(event) {
45
+ var _a;
46
+ if ((_a = refRightKeyBox.value) == null ? void 0 : _a.contains(event.target)) {
35
47
  return;
36
48
  }
37
- if (!refRightKey.value.contains(event.target) || event.button !== 2) {
49
+ flag.value = false;
50
+ }
51
+ function handleGlobalClick(event) {
52
+ var _a;
53
+ if (event.button === 2) return;
54
+ if (!((_a = refRightKeyBox.value) == null ? void 0 : _a.contains(event.target))) {
55
+ flag.value = false;
56
+ }
57
+ }
58
+ function handleKeydown(event) {
59
+ if (event.key === "Escape" && flag.value) {
38
60
  flag.value = false;
39
61
  }
40
62
  }
41
63
  function isDomClass(dom2) {
42
- if (dom2) {
43
- if (props.domClass) {
44
- const v = getPrentClass(
45
- dom2,
46
- props.domClass,
47
- props.level
48
- );
49
- if (v && refRightKey.value.contains(v)) {
50
- return v;
51
- }
52
- } else {
53
- return dom2;
64
+ var _a, _b;
65
+ if (!dom2) return null;
66
+ if (props.domClass) {
67
+ const element = getPrentClass(
68
+ dom2,
69
+ props.domClass,
70
+ props.level
71
+ );
72
+ if (element && ((_a = refRightKey.value) == null ? void 0 : _a.contains(element))) {
73
+ return element;
54
74
  }
75
+ } else if ((_b = refRightKey.value) == null ? void 0 : _b.contains(dom2)) {
76
+ return dom2;
55
77
  }
78
+ return null;
56
79
  }
57
80
  function handleContextmenu(event) {
58
- let target = event.target;
59
- target = isDomClass(target);
60
- if (target) {
61
- dom.value = target;
62
- let x = 0, y = 0;
63
- if (event.x || event.y) {
64
- x = event.x;
65
- y = event.y;
66
- } else if (event.pageX || event.pageY) {
67
- x = event.pageX - 1;
68
- y = event.pageY - 1;
69
- }
70
- let ww = globalThis ? globalThis.innerWidth : 0;
71
- let kw = 0;
72
- if (ww != 0 && x + 120 > ww) {
73
- kw = 0 - (x + 120 - ww);
74
- }
75
- topx.value = x + kw + "px";
76
- lefty.value = y + "px";
77
- flag.value = true;
78
- event.preventDefault();
79
- event.stopPropagation();
80
- emit("click-right", target);
81
- } else {
81
+ const target = isDomClass(event.target);
82
+ if (!target) {
82
83
  flag.value = false;
84
+ return;
83
85
  }
86
+ dom.value = target;
87
+ let x = event.clientX;
88
+ let y = event.clientY;
89
+ flag.value = true;
90
+ event.preventDefault();
91
+ event.stopPropagation();
92
+ emit("click-right", target);
93
+ nextTick(() => {
94
+ position.value = { x, y };
95
+ });
84
96
  }
85
97
  function onClick(v) {
86
98
  flag.value = false;
87
99
  emit("click-key", v, dom.value);
88
100
  }
101
+ const toDom = ref();
102
+ watch(
103
+ () => flag.value,
104
+ () => {
105
+ if (props.isSingle) {
106
+ if (flag.value) {
107
+ if (toDom.value) {
108
+ toDom.value.querySelectorAll("." + cs.z("box")).forEach((v) => {
109
+ v.style.display = "none";
110
+ });
111
+ }
112
+ nextTick(() => {
113
+ refRightKeyBox.value.style.display = "block";
114
+ });
115
+ } else {
116
+ refRightKeyBox.value.style.display = "none";
117
+ }
118
+ } else {
119
+ refRightKeyBox.value.style.display = flag.value ? "block" : "none";
120
+ }
121
+ }
122
+ );
123
+ onMounted(() => {
124
+ toDom.value = getBoxDom();
125
+ document.addEventListener("mousedown", handleGlobalMousedown, true);
126
+ document.addEventListener("click", handleGlobalClick, true);
127
+ document.addEventListener("keydown", handleKeydown);
128
+ window.addEventListener("resize", () => {
129
+ if (flag.value) {
130
+ flag.value = false;
131
+ }
132
+ });
133
+ window.addEventListener(
134
+ "scroll",
135
+ () => {
136
+ if (flag.value) {
137
+ flag.value = false;
138
+ }
139
+ },
140
+ true
141
+ );
142
+ });
143
+ onUnmounted(() => {
144
+ document.removeEventListener("mousedown", handleGlobalMousedown, true);
145
+ document.removeEventListener("click", handleGlobalClick, true);
146
+ document.removeEventListener("keydown", handleKeydown);
147
+ window.removeEventListener("resize", () => {
148
+ });
149
+ window.removeEventListener("scroll", () => {
150
+ }, true);
151
+ });
89
152
  __expose({
90
- ...dataExpose
153
+ ...dataExpose,
154
+ // 提供关闭菜单的方法
155
+ close: () => {
156
+ flag.value = false;
157
+ },
158
+ // 提供打开菜单的方法
159
+ open: (x, y, target) => {
160
+ position.value = { x, y };
161
+ dom.value = target;
162
+ flag.value = true;
163
+ }
91
164
  });
92
165
  return (_ctx, _cache) => {
93
166
  return openBlock(), createElementBlock("div", {
@@ -106,11 +179,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
106
179
  class: normalizeClass([unref(cs).z("box"), unref(props).boxClass]),
107
180
  ref_key: "refRightKeyBox",
108
181
  ref: refRightKeyBox,
109
- style: normalizeStyle({
110
- position: "fixed",
111
- top: lefty.value,
112
- left: topx.value
113
- })
182
+ style: normalizeStyle(boxStyle.value)
114
183
  }, [
115
184
  createElementVNode("div", {
116
185
  class: normalizeClass(unref(cs).z("box-list"))
@@ -121,13 +190,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
121
190
  onClick: withModifiers(($event) => onClick(v), ["stop"]),
122
191
  class: normalizeClass(unref(cs).z("box-list-li"))
123
192
  }, [
124
- v.icon ? (openBlock(), createBlock(unref(Icon), { key: 0 }, {
125
- default: withCtx(() => [
126
- (openBlock(), createBlock(resolveDynamicComponent(v.icon)))
127
- ]),
128
- _: 2
129
- }, 1024)) : createCommentVNode("", true),
130
- createElementVNode("span", null, toDisplayString(unref(useVueValue)(v, unref(props).label)), 1)
193
+ renderSlot(_ctx.$slots, unref(dataSlot).list, {
194
+ value: v,
195
+ index: k
196
+ }, () => [
197
+ v.icon ? (openBlock(), createBlock(unref(Icon), { key: 0 }, {
198
+ default: withCtx(() => [
199
+ (openBlock(), createBlock(resolveDynamicComponent(v.icon)))
200
+ ]),
201
+ _: 2
202
+ }, 1024)) : createCommentVNode("", true),
203
+ createElementVNode("span", null, toDisplayString(unref(useVueValue)(v, unref(props).label)), 1)
204
+ ])
131
205
  ], 10, _hoisted_1);
132
206
  }), 128))
133
207
  ], 2)
@@ -135,7 +209,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
135
209
  [vShow, flag.value]
136
210
  ])
137
211
  ]),
138
- _: 1
212
+ _: 3
139
213
  }, 8, ["disabled", "to"])
140
214
  ], 34);
141
215
  };
@@ -1,5 +1,5 @@
1
1
  import { ExtractPropTypes } from 'vue';
2
- import { comHandle } from '../../common/list';
2
+ import { comHandle, Options } from '../../common/list';
3
3
  /**
4
4
  * @title {h3}
5
5
  */
@@ -18,10 +18,10 @@ export declare const dataProps: {
18
18
  };
19
19
  options: {
20
20
  type: {
21
- (arrayLength: number): (string | number | boolean | ObjAny)[];
22
- (...items: (string | number | boolean | ObjAny)[]): (string | number | boolean | ObjAny)[];
23
- new (arrayLength: number): (string | number | boolean | ObjAny)[];
24
- new (...items: (string | number | boolean | ObjAny)[]): (string | number | boolean | ObjAny)[];
21
+ (arrayLength: number): Options[];
22
+ (...items: Options[]): Options[];
23
+ new (arrayLength: number): Options[];
24
+ new (...items: Options[]): Options[];
25
25
  isArray(arg: any): arg is any[];
26
26
  readonly prototype: any[];
27
27
  from<T>(arrayLike: ArrayLike<T>): T[];
@@ -4,11 +4,12 @@ const vue = require("vue");
4
4
  const index$3 = require("../../box-teleport/index.cjs");
5
5
  const data = require("./data.cjs");
6
6
  const index$4 = require("../../icon/index.cjs");
7
- const close = require("../../../icons/vue/close.cjs");
7
+ require("../../../icons/vue/close.cjs");
8
8
  const index$1 = require("../../../hooks/cssname/index.cjs");
9
9
  const index = require("../../../hooks/locale/index.cjs");
10
10
  const index$5 = require("../../../directives/stick/index.cjs");
11
11
  const index$2 = require("../../../hooks/props-default/index.cjs");
12
+ const close_vue_vue_type_script_setup_true_lang = require("../../../icons/vue/close2.cjs");
12
13
  const _hoisted_1 = ["onClick"];
13
14
  const _sfc_main = /* @__PURE__ */ vue.defineComponent({
14
15
  __name: "index",
@@ -87,7 +88,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
87
88
  title: vue.unref(getLocale)("close")
88
89
  }, {
89
90
  default: vue.withCtx(() => [
90
- vue.createVNode(close.default)
91
+ vue.createVNode(close_vue_vue_type_script_setup_true_lang.default)
91
92
  ]),
92
93
  _: 1
93
94
  }, 8, ["onClick", "class", "title"])
@@ -2,11 +2,12 @@ import { defineComponent, ref, createBlock, openBlock, unref, withCtx, withDirec
2
2
  import { BoxTeleport } from "../../box-teleport/index.js";
3
3
  import { name, dataProps, dataExpose, dataSlot, dataEmits } from "./data.js";
4
4
  import { Icon } from "../../icon/index.js";
5
- import Close from "../../../icons/vue/close.js";
5
+ import "../../../icons/vue/close.js";
6
6
  import { useCssName } from "../../../hooks/cssname/index.js";
7
7
  import { useLocale } from "../../../hooks/locale/index.js";
8
8
  import vStick from "../../../directives/stick/index.js";
9
9
  import { usePropsDefault, getProps } from "../../../hooks/props-default/index.js";
10
+ import _sfc_main$1 from "../../../icons/vue/close2.js";
10
11
  const _hoisted_1 = ["onClick"];
11
12
  const _sfc_main = /* @__PURE__ */ defineComponent({
12
13
  __name: "index",
@@ -85,7 +86,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
85
86
  title: unref(getLocale)("close")
86
87
  }, {
87
88
  default: withCtx(() => [
88
- createVNode(Close)
89
+ createVNode(_sfc_main$1)
89
90
  ]),
90
91
  _: 1
91
92
  }, 8, ["onClick", "class", "title"])
@@ -1,4 +1,5 @@
1
1
  import { ExtractPropTypes } from 'vue';
2
+ import { Options } from '../../common/list';
2
3
  /**
3
4
  * @title {h3} switchs 开关列表
4
5
  * @text value: '' 在@change中会返回 true
@@ -14,10 +15,10 @@ export declare const dataProps: {
14
15
  };
15
16
  options: {
16
17
  type: {
17
- (arrayLength: number): (string | number | boolean | ObjAny)[];
18
- (...items: (string | number | boolean | ObjAny)[]): (string | number | boolean | ObjAny)[];
19
- new (arrayLength: number): (string | number | boolean | ObjAny)[];
20
- new (...items: (string | number | boolean | ObjAny)[]): (string | number | boolean | ObjAny)[];
18
+ (arrayLength: number): Options[];
19
+ (...items: Options[]): Options[];
20
+ new (arrayLength: number): Options[];
21
+ new (...items: Options[]): Options[];
21
22
  isArray(arg: any): arg is any[];
22
23
  readonly prototype: any[];
23
24
  from<T>(arrayLike: ArrayLike<T>): T[];
@@ -1,5 +1,5 @@
1
1
  import { ExtractPublicPropTypes } from 'vue';
2
- import { comHandle } from '../../common/list';
2
+ import { comHandle, Options } from '../../common/list';
3
3
  /**
4
4
  * @title {h3} uploads
5
5
  */
@@ -78,10 +78,10 @@ export declare const dataProps: {
78
78
  };
79
79
  options: {
80
80
  type: {
81
- (arrayLength: number): (string | number | boolean | ObjAny)[];
82
- (...items: (string | number | boolean | ObjAny)[]): (string | number | boolean | ObjAny)[];
83
- new (arrayLength: number): (string | number | boolean | ObjAny)[];
84
- new (...items: (string | number | boolean | ObjAny)[]): (string | number | boolean | ObjAny)[];
81
+ (arrayLength: number): Options[];
82
+ (...items: Options[]): Options[];
83
+ new (arrayLength: number): Options[];
84
+ new (...items: Options[]): Options[];
85
85
  isArray(arg: any): arg is any[];
86
86
  readonly prototype: any[];
87
87
  from<T>(arrayLike: ArrayLike<T>): T[];