y-design-ssr 0.2.5 → 0.2.6

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 (212) hide show
  1. package/libs/button/index.css +579 -1
  2. package/libs/button/index.mjs +111 -66
  3. package/libs/button/index.umd.js +203 -2
  4. package/libs/button/package.json +1 -1
  5. package/libs/{types/components/button → button}/src/button.d.ts +1 -1
  6. package/libs/cell/index.css +1077 -1
  7. package/libs/{types/components/cell → cell}/index.d.ts +1 -0
  8. package/libs/cell/index.mjs +168 -104
  9. package/libs/cell/index.umd.js +301 -2
  10. package/libs/cell/package.json +1 -1
  11. package/libs/{types/components/cell → cell}/src/cell.d.ts +1 -1
  12. package/libs/checkbox/index.css +1053 -1
  13. package/libs/{types/components/checkbox → checkbox}/index.d.ts +1 -0
  14. package/libs/checkbox/index.mjs +243 -127
  15. package/libs/checkbox/index.umd.js +370 -2
  16. package/libs/checkbox/package.json +1 -1
  17. package/libs/checkboxGroup/index.css +422 -1
  18. package/libs/{types/components/checkboxGroup → checkboxGroup}/index.d.ts +1 -0
  19. package/libs/checkboxGroup/index.mjs +174 -87
  20. package/libs/checkboxGroup/index.umd.js +266 -2
  21. package/libs/checkboxGroup/package.json +1 -1
  22. package/libs/col/index.css +615 -1
  23. package/libs/{types/components/col → col}/index.d.ts +1 -0
  24. package/libs/col/index.mjs +247 -81
  25. package/libs/col/index.umd.js +306 -2
  26. package/libs/col/package.json +1 -1
  27. package/libs/countdown/index.css +417 -1
  28. package/libs/{types/components/countdown → countdown}/index.d.ts +1 -0
  29. package/libs/countdown/index.mjs +180 -71
  30. package/libs/countdown/index.umd.js +232 -2
  31. package/libs/countdown/package.json +1 -1
  32. package/libs/dialog/index.css +1405 -1
  33. package/libs/{types/components/dialog → dialog}/index.d.ts +1 -0
  34. package/libs/dialog/index.mjs +647 -476
  35. package/libs/dialog/index.umd.js +1129 -2
  36. package/libs/dialog/package.json +1 -1
  37. package/libs/{types/components/dialog → dialog}/src/dialog.d.ts +1 -1
  38. package/libs/empty/index.css +457 -1
  39. package/libs/{types/components/empty → empty}/index.d.ts +1 -0
  40. package/libs/empty/index.mjs +92 -44
  41. package/libs/empty/index.umd.js +140 -2
  42. package/libs/empty/package.json +1 -1
  43. package/libs/form/index.css +477 -1
  44. package/libs/{types/components/form → form}/index.d.ts +1 -0
  45. package/libs/form/index.mjs +227 -126
  46. package/libs/form/index.umd.js +320 -2
  47. package/libs/form/package.json +1 -1
  48. package/libs/formItem/index.css +477 -1
  49. package/libs/{types/components/formItem → formItem}/index.d.ts +1 -0
  50. package/libs/formItem/index.mjs +277 -126
  51. package/libs/formItem/index.umd.js +373 -2
  52. package/libs/formItem/package.json +1 -1
  53. package/libs/icon/index.css +982 -1
  54. package/libs/{types/components/icon → icon}/index.d.ts +1 -0
  55. package/libs/icon/index.mjs +108 -58
  56. package/libs/icon/index.umd.js +187 -2
  57. package/libs/icon/package.json +1 -1
  58. package/libs/index.css +2902 -1
  59. package/libs/index.d.ts +86 -3
  60. package/libs/index.mjs +3785 -2344
  61. package/libs/index.umd.js +5509 -2
  62. package/libs/input/index.css +483 -1
  63. package/libs/{types/components/input → input}/index.d.ts +1 -0
  64. package/libs/input/index.mjs +184 -92
  65. package/libs/input/index.umd.js +275 -2
  66. package/libs/input/package.json +1 -1
  67. package/libs/layout/index.css +684 -1
  68. package/libs/layout/index.mjs +230 -130
  69. package/libs/layout/index.umd.js +318 -2
  70. package/libs/layout/package.json +1 -1
  71. package/libs/list/index.css +440 -1
  72. package/libs/{types/components/list → list}/index.d.ts +1 -0
  73. package/libs/list/index.mjs +389 -207
  74. package/libs/list/index.umd.js +572 -2
  75. package/libs/list/package.json +1 -1
  76. package/libs/loading/index.css +548 -1
  77. package/libs/{types/components/loading → loading}/index.d.ts +1 -0
  78. package/libs/loading/index.mjs +197 -118
  79. package/libs/loading/index.umd.js +322 -2
  80. package/libs/loading/package.json +1 -1
  81. package/libs/{types/components/loading → loading}/src/loading.d.ts +1 -1
  82. package/libs/mask/index.css +426 -1
  83. package/libs/{types/components/mask → mask}/index.d.ts +1 -0
  84. package/libs/mask/index.mjs +132 -70
  85. package/libs/mask/index.umd.js +202 -2
  86. package/libs/mask/package.json +1 -1
  87. package/libs/popup/index.css +465 -1
  88. package/libs/{types/components/popup → popup}/index.d.ts +1 -0
  89. package/libs/popup/index.mjs +211 -134
  90. package/libs/popup/index.umd.js +359 -2
  91. package/libs/popup/package.json +1 -1
  92. package/libs/{types/components/popup → popup}/src/popup.d.ts +1 -1
  93. package/libs/progress/index.css +488 -1
  94. package/libs/{types/components/progress → progress}/index.d.ts +1 -0
  95. package/libs/progress/index.mjs +201 -128
  96. package/libs/progress/index.umd.js +323 -2
  97. package/libs/progress/package.json +1 -1
  98. package/libs/pullrefresh/index.css +441 -1
  99. package/libs/{types/components/pullrefresh → pullrefresh}/index.d.ts +1 -0
  100. package/libs/pullrefresh/index.mjs +242 -111
  101. package/libs/pullrefresh/index.umd.js +303 -2
  102. package/libs/pullrefresh/package.json +1 -1
  103. package/libs/row/index.css +485 -1
  104. package/libs/{types/components/row → row}/index.d.ts +1 -0
  105. package/libs/row/index.mjs +182 -89
  106. package/libs/row/index.umd.js +238 -2
  107. package/libs/row/package.json +1 -1
  108. package/libs/{types/components/row → row}/src/row.d.ts +1 -1
  109. package/libs/slider/index.css +558 -1
  110. package/libs/{types/components/slider → slider}/index.d.ts +1 -0
  111. package/libs/slider/index.mjs +357 -160
  112. package/libs/slider/index.umd.js +454 -2
  113. package/libs/slider/package.json +1 -1
  114. package/libs/stepper/index.css +489 -1
  115. package/libs/{types/components/stepper → stepper}/index.d.ts +1 -0
  116. package/libs/stepper/index.mjs +182 -101
  117. package/libs/stepper/index.umd.js +270 -2
  118. package/libs/stepper/package.json +1 -1
  119. package/libs/swipe/index.css +506 -1
  120. package/libs/{types/components/swipe → swipe}/index.d.ts +1 -0
  121. package/libs/swipe/index.mjs +543 -259
  122. package/libs/swipe/index.umd.js +704 -2
  123. package/libs/swipe/package.json +1 -1
  124. package/libs/swipeItem/index.css +424 -1
  125. package/libs/{types/components/swipeItem → swipeItem}/index.d.ts +1 -0
  126. package/libs/swipeItem/index.mjs +112 -52
  127. package/libs/swipeItem/index.umd.js +155 -2
  128. package/libs/swipeItem/package.json +1 -1
  129. package/libs/switch/index.css +472 -1
  130. package/libs/{types/components/switch → switch}/index.d.ts +1 -0
  131. package/libs/switch/index.mjs +122 -62
  132. package/libs/switch/index.umd.js +201 -2
  133. package/libs/switch/package.json +1 -1
  134. package/libs/{types/components/switch → switch}/src/switch.d.ts +1 -1
  135. package/libs/{types/components/tab → tab}/index.d.ts +1 -0
  136. package/libs/tab/index.mjs +132 -68
  137. package/libs/tab/index.umd.js +191 -1
  138. package/libs/tab/package.json +1 -1
  139. package/libs/tabs/index.css +514 -1
  140. package/libs/{types/components/tabs → tabs}/index.d.ts +1 -0
  141. package/libs/tabs/index.mjs +752 -410
  142. package/libs/tabs/index.umd.js +1021 -2
  143. package/libs/tabs/package.json +1 -1
  144. package/libs/toast/index.css +1050 -1
  145. package/libs/{types/components/toast → toast}/index.d.ts +1 -0
  146. package/libs/toast/index.mjs +184 -114
  147. package/libs/toast/index.umd.js +307 -2
  148. package/libs/toast/package.json +1 -1
  149. package/libs/{types/components/toast → toast}/src/toast.d.ts +1 -1
  150. package/libs/tooltip/index.css +514 -1
  151. package/libs/{types/components/tooltip → tooltip}/index.d.ts +1 -0
  152. package/libs/tooltip/index.mjs +294 -155
  153. package/libs/tooltip/index.umd.js +417 -2
  154. package/libs/tooltip/package.json +1 -1
  155. package/libs/vue-sfc.d.ts +12 -0
  156. package/libs/vue-tsx.d.ts +42 -0
  157. package/package.json +2 -2
  158. package/libs/types/index.d.ts +0 -86
  159. /package/libs/{types/components/button → button}/index.d.ts +0 -0
  160. /package/libs/{types/components/checkbox → checkbox}/src/checkbox.d.ts +0 -0
  161. /package/libs/{types/components/checkboxGroup → checkboxGroup}/src/checkboxGroup.d.ts +0 -0
  162. /package/libs/{types/components/checkboxGroup → checkboxGroup}/src/constants.d.ts +0 -0
  163. /package/libs/{types/components/col → col}/src/col.d.ts +0 -0
  164. /package/libs/{types/context → context}/filed/constants.d.ts +0 -0
  165. /package/libs/{types/context → context}/filed/index.d.ts +0 -0
  166. /package/libs/{types/context → context}/filed/inject.d.ts +0 -0
  167. /package/libs/{types/context → context}/filed/provide.d.ts +0 -0
  168. /package/libs/{types/context → context}/relation/index.d.ts +0 -0
  169. /package/libs/{types/context → context}/relation/inject.d.ts +0 -0
  170. /package/libs/{types/context → context}/relation/provide.d.ts +0 -0
  171. /package/libs/{types/components/countdown → countdown}/src/count-down.d.ts +0 -0
  172. /package/libs/{types/components/dialog → dialog}/src/create.d.ts +0 -0
  173. /package/libs/{types/components/empty → empty}/src/empty.d.ts +0 -0
  174. /package/libs/{types/components/empty → empty}/src/utils.d.ts +0 -0
  175. /package/libs/{types/components/form → form}/src/constants.d.ts +0 -0
  176. /package/libs/{types/components/form → form}/src/form.d.ts +0 -0
  177. /package/libs/{types/components/formItem → formItem}/src/formItem.d.ts +0 -0
  178. /package/libs/{types/hooks → hooks}/touch/index.d.ts +0 -0
  179. /package/libs/{types/components/icon → icon}/src/icon.d.ts +0 -0
  180. /package/libs/{types/components/input → input}/src/input.d.ts +0 -0
  181. /package/libs/{types/components/list → list}/src/list.d.ts +0 -0
  182. /package/libs/{types/components/loading → loading}/src/create.d.ts +0 -0
  183. /package/libs/{types/components/loading → loading}/src/directive.d.ts +0 -0
  184. /package/libs/{types/locale → locale}/index.d.ts +0 -0
  185. /package/libs/{types/locale → locale}/lang/zh-CN.d.ts +0 -0
  186. /package/libs/{types/components/mask → mask}/src/mask.d.ts +0 -0
  187. /package/libs/{types/components/progress → progress}/src/progress.d.ts +0 -0
  188. /package/libs/{types/components/pullrefresh → pullrefresh}/src/pullrefresh.d.ts +0 -0
  189. /package/libs/{types/components/pullrefresh → pullrefresh}/src/utils.d.ts +0 -0
  190. /package/libs/{types/components/row → row}/src/constants.d.ts +0 -0
  191. /package/libs/{types/components/slider → slider}/src/slider.d.ts +0 -0
  192. /package/libs/{types/components/stepper → stepper}/src/stepper.d.ts +0 -0
  193. /package/libs/{types/style → style}/index.d.ts +0 -0
  194. /package/libs/{types/components/swipe → swipe}/src/constants.d.ts +0 -0
  195. /package/libs/{types/components/swipe → swipe}/src/swipe.d.ts +0 -0
  196. /package/libs/{types/components/swipeItem → swipeItem}/src/swipeItem.d.ts +0 -0
  197. /package/libs/{types/components/tab → tab}/src/tab.d.ts +0 -0
  198. /package/libs/{types/components/tabs → tabs}/src/constants.d.ts +0 -0
  199. /package/libs/{types/components/tabs → tabs}/src/tabs.d.ts +0 -0
  200. /package/libs/{types/components/tabs → tabs}/src/title.d.ts +0 -0
  201. /package/libs/{types/components/toast → toast}/src/create.d.ts +0 -0
  202. /package/libs/{types/components/tooltip → tooltip}/src/constants.d.ts +0 -0
  203. /package/libs/{types/components/tooltip → tooltip}/src/direactive.d.ts +0 -0
  204. /package/libs/{types/components/tooltip → tooltip}/src/popper.d.ts +0 -0
  205. /package/libs/{types/components/tooltip → tooltip}/src/tooltip.d.ts +0 -0
  206. /package/libs/{types/utils → utils}/create/bem.d.ts +0 -0
  207. /package/libs/{types/utils → utils}/create/index.d.ts +0 -0
  208. /package/libs/{types/utils → utils}/index.d.ts +0 -0
  209. /package/libs/{types/utils → utils}/is.d.ts +0 -0
  210. /package/libs/{types/utils → utils}/parseFlexDirection.d.ts +0 -0
  211. /package/libs/{types/utils → utils}/parseUnit.d.ts +0 -0
  212. /package/libs/{types/utils → utils}/types.d.ts +0 -0
@@ -1,11 +1,47 @@
1
- import { ref as E, reactive as U, defineComponent as x, onMounted as de, onUnmounted as fe, watch as pe, createVNode as r, Transition as te, withDirectives as P, vShow as ne, computed as F, Teleport as me, Fragment as ge, createApp as q, h as le, mergeProps as ye, resolveDirective as X, isVNode as be } from "vue";
2
- const oe = (e) => (t) => Object.prototype.toString.call(t) === `[object ${e}]`, Se = oe("Function"), ve = oe("Promise"), D = (e, t) => t ? typeof t == "string" ? ` ${e}--${t}` : Array.isArray(t) ? t.reduce((l, a) => l + D(e, a), "") : Object.keys(t).reduce(
3
- (l, a) => l + (t[a] ? D(e, a) : ""),
4
- ""
5
- ) : "", $e = (e) => (t, l) => {
6
- let a = t, s = l;
7
- return a && typeof a != "string" && (s = a, a = ""), a = a ? `${e}__${a}` : e, `${a}${D(a, s)}`;
8
- }, he = () => (e, t) => t ? `${D(`y-${e}`, t)}` : `y-${e}`, ke = {
1
+ import { ref, reactive, defineComponent, onMounted, onUnmounted, watch, createVNode, Transition, withDirectives, vShow, computed, Teleport, Fragment, createApp, h, mergeProps, resolveDirective, isVNode } from "vue";
2
+ const tagTester = (name2) => {
3
+ return (obj) => {
4
+ return Object.prototype.toString.call(obj) === `[object ${name2}]`;
5
+ };
6
+ };
7
+ const isFunction = tagTester("Function");
8
+ const isPromise = tagTester("Promise");
9
+ const getMods = (el, mods) => {
10
+ if (!mods) {
11
+ return "";
12
+ }
13
+ if (typeof mods === "string") {
14
+ return ` ${el}--${mods}`;
15
+ }
16
+ if (Array.isArray(mods)) {
17
+ return mods.reduce((acc, cur) => acc + getMods(el, cur), "");
18
+ }
19
+ return Object.keys(mods).reduce(
20
+ (acc, cur) => acc + (mods[cur] ? getMods(el, cur) : ""),
21
+ ""
22
+ );
23
+ };
24
+ const createBEM = (block) => {
25
+ return (el, mods) => {
26
+ let _el = el;
27
+ let _mods = mods;
28
+ if (_el && typeof _el !== "string") {
29
+ _mods = _el;
30
+ _el = "";
31
+ }
32
+ _el = _el ? `${block}__${_el}` : block;
33
+ return `${_el}${getMods(_el, _mods)}`;
34
+ };
35
+ };
36
+ const createGlobalBem = () => {
37
+ return (el, mods) => {
38
+ if (!mods) {
39
+ return `y-${el}`;
40
+ }
41
+ return `${getMods(`y-${el}`, mods)}`;
42
+ };
43
+ };
44
+ const defaultLang = {
9
45
  "pull-refresh": {
10
46
  pulling: "下拉刷新...",
11
47
  loosing: "释放刷新...",
@@ -17,15 +53,22 @@ const oe = (e) => (t) => Object.prototype.toString.call(t) === `[object ${e}]`,
17
53
  validateMessage: "请输入正确内容"
18
54
  }
19
55
  };
20
- E("zh-CN");
21
- U({
22
- "zh-CN": ke
56
+ ref("zh-CN");
57
+ reactive({
58
+ "zh-CN": defaultLang
23
59
  });
24
- const w = (e) => {
25
- const t = `y-${e}`;
26
- return [t, $e(t), he()];
27
- }, m = (e) => isNaN(Number(e)) && typeof e == "string" ? e : `${e}px`, Ce = (e) => {
28
- switch (e) {
60
+ const createNamespace = (name2) => {
61
+ const prefixedName = `y-${name2}`;
62
+ return [prefixedName, createBEM(prefixedName), createGlobalBem()];
63
+ };
64
+ const parseUnit = (val) => {
65
+ if (isNaN(Number(val)) && typeof val === "string") {
66
+ return val;
67
+ }
68
+ return `${val}px`;
69
+ };
70
+ const parseFlexDirection = (location) => {
71
+ switch (location) {
29
72
  case "top":
30
73
  return "column-reverse";
31
74
  case "bottom":
@@ -37,11 +80,13 @@ const w = (e) => {
37
80
  default:
38
81
  return "column";
39
82
  }
40
- }, [xe, we, Be] = w("mask"), Ne = {
83
+ };
84
+ const [name$4, bem$5, gBem$2] = createNamespace("mask");
85
+ const _props$3 = {
41
86
  // 控制显示
42
87
  modelValue: {
43
88
  type: Boolean,
44
- default: !1
89
+ default: false
45
90
  },
46
91
  // 层级
47
92
  zIndex: {
@@ -66,87 +111,118 @@ const w = (e) => {
66
111
  // 触摸滚动开关
67
112
  lockScroll: {
68
113
  type: Boolean,
69
- default: !0
114
+ default: true
70
115
  },
71
116
  onAfterLeave: {
72
117
  type: Function,
73
118
  default: null
74
119
  }
75
- }, S = U([]);
76
- let Y = 0;
77
- const I = /* @__PURE__ */ x({
78
- name: xe,
79
- props: Ne,
120
+ };
121
+ const stack = reactive([]);
122
+ let num$1 = 0;
123
+ const Mask = /* @__PURE__ */ defineComponent({
124
+ name: name$4,
125
+ props: _props$3,
80
126
  emits: ["update:modelValue"],
81
- setup(e, {
82
- slots: t
127
+ setup(props, {
128
+ slots
83
129
  }) {
84
- const l = E("");
85
- de(() => {
86
- l.value = `mask${Y}`, Y += 1, a(e.modelValue, !0);
87
- }), fe(() => {
88
- const n = S.findIndex((i) => i._id === l.value);
89
- n >= 0 && S.splice(n, 1);
90
- }), pe(() => e.modelValue, (n) => {
91
- a(n);
130
+ const id = ref("");
131
+ onMounted(() => {
132
+ id.value = `mask${num$1}`;
133
+ num$1 += 1;
134
+ stackIntercept(props.modelValue, true);
92
135
  });
93
- const a = (n, i) => {
94
- n ? (S.unshift({
95
- _id: l.value,
96
- _state: n
97
- }), S.length > 1 && (S[1]._state = !1)) : i || (S.splice(0, 1), S.length > 0 && (S[0]._state = !0));
98
- }, s = () => {
99
- let n = !1;
100
- for (let i = 0; i < S.length; i++)
101
- S[i]._id === l.value && (n = S[i]._state);
136
+ onUnmounted(() => {
137
+ const index = stack.findIndex((v) => v._id === id.value);
138
+ index >= 0 && stack.splice(index, 1);
139
+ });
140
+ watch(() => props.modelValue, (val) => {
141
+ stackIntercept(val);
142
+ });
143
+ const stackIntercept = (val, isMounted) => {
144
+ if (val) {
145
+ stack.unshift({
146
+ _id: id.value,
147
+ _state: val
148
+ });
149
+ if (stack.length > 1) {
150
+ stack[1]._state = false;
151
+ }
152
+ } else if (!isMounted) {
153
+ stack.splice(0, 1);
154
+ if (stack.length > 0) {
155
+ stack[0]._state = true;
156
+ }
157
+ }
158
+ };
159
+ const find = () => {
160
+ let _state = false;
161
+ for (let i = 0; i < stack.length; i++) {
162
+ if (stack[i]._id === id.value) {
163
+ _state = stack[i]._state;
164
+ }
165
+ }
102
166
  return {
103
- _state: n
167
+ _state
104
168
  };
105
- }, f = (n) => {
169
+ };
170
+ const onTouchMove = (payload) => {
106
171
  const {
107
- lockScroll: i
108
- } = e;
109
- i && (n.preventDefault(), n.stopPropagation());
172
+ lockScroll
173
+ } = props;
174
+ if (lockScroll) {
175
+ payload.preventDefault();
176
+ payload.stopPropagation();
177
+ }
110
178
  };
111
179
  return () => {
112
180
  const {
113
- customClass: n,
114
- duration: i,
115
- zIndex: p,
116
- customStyle: g,
117
- onAfterLeave: c
118
- } = e, {
119
- _state: d
120
- } = s();
121
- return r(te, {
122
- name: Be("animation", "fade"),
123
- onAfterLeave: c
181
+ customClass,
182
+ duration,
183
+ zIndex,
184
+ customStyle,
185
+ onAfterLeave
186
+ } = props;
187
+ const {
188
+ _state
189
+ } = find();
190
+ return createVNode(Transition, {
191
+ "name": gBem$2("animation", "fade"),
192
+ "onAfterLeave": onAfterLeave
124
193
  }, {
125
194
  default: () => {
126
- var o;
127
- return [P(r("div", {
128
- style: {
129
- animationDuration: `${i}ms`,
130
- zIndex: p,
131
- ...g
195
+ var _a;
196
+ return [withDirectives(createVNode("div", {
197
+ "style": {
198
+ animationDuration: `${duration}ms`,
199
+ zIndex,
200
+ ...customStyle
132
201
  },
133
- class: [we(), n],
134
- onTouchmove: f
135
- }, [(o = t.default) == null ? void 0 : o.call(t)]), [[ne, d]])];
202
+ "class": [bem$5(), customClass],
203
+ "onTouchmove": onTouchMove
204
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vShow, _state]])];
136
205
  }
137
206
  });
138
207
  };
139
208
  }
140
209
  });
141
- I.install = (e) => {
142
- const { name: t } = I;
143
- e.component(t, I);
210
+ const reset = "";
211
+ const libs = "";
212
+ const font = "";
213
+ const animation = "";
214
+ const theme = "";
215
+ const style$5 = "";
216
+ Mask.install = (app) => {
217
+ const { name: name2 } = Mask;
218
+ app.component(name2, Mask);
144
219
  };
145
- const [_e, Z, Ve] = w("popup"), Ae = {
220
+ const [name$3, bem$4, gBem$1] = createNamespace("popup");
221
+ const _props$2 = {
146
222
  // 控制显示
147
223
  modelValue: {
148
224
  type: Boolean,
149
- default: !1
225
+ default: false
150
226
  },
151
227
  // 位置
152
228
  position: {
@@ -181,7 +257,7 @@ const [_e, Z, Ve] = w("popup"), Ae = {
181
257
  // 点击遮罩是否关闭
182
258
  isCloseOnClickMask: {
183
259
  type: Boolean,
184
- default: !0
260
+ default: true
185
261
  },
186
262
  onAfterLeave: {
187
263
  type: Function,
@@ -189,107 +265,120 @@ const [_e, Z, Ve] = w("popup"), Ae = {
189
265
  },
190
266
  lockScroll: {
191
267
  type: Boolean,
192
- default: !0
268
+ default: true
193
269
  },
194
270
  zIndex: {
195
271
  type: Number,
196
272
  default: 101
197
273
  }
198
- }, L = /* @__PURE__ */ x({
199
- name: _e,
200
- props: Ae,
274
+ };
275
+ const Popup = /* @__PURE__ */ defineComponent({
276
+ name: name$3,
277
+ props: _props$2,
201
278
  emits: ["clickMask", "update:modelValue"],
202
- setup(e, {
203
- slots: t,
204
- emit: l
279
+ setup(props, {
280
+ slots,
281
+ emit
205
282
  }) {
206
- const a = F(() => {
283
+ const style2 = computed(() => {
207
284
  const {
208
- position: n,
209
- borderRadius: i,
210
- customStyle: p,
211
- duration: g
212
- } = e, c = m(i);
213
- let d = "0";
214
- switch (n) {
285
+ position,
286
+ borderRadius,
287
+ customStyle,
288
+ duration
289
+ } = props;
290
+ const tbR = parseUnit(borderRadius);
291
+ let br = `0`;
292
+ switch (position) {
215
293
  case "top":
216
- d = ` 0 0 ${c} ${c}`;
294
+ br = ` 0 0 ${tbR} ${tbR}`;
217
295
  break;
218
296
  case "bottom":
219
- d = `${c} ${c} 0 0`;
297
+ br = `${tbR} ${tbR} 0 0`;
220
298
  break;
221
299
  case "left":
222
- d = `0 ${c} ${c} 0`;
300
+ br = `0 ${tbR} ${tbR} 0`;
223
301
  break;
224
302
  case "right":
225
- d = `${c} 0 0 ${c}`;
303
+ br = `${tbR} 0 0 ${tbR}`;
226
304
  break;
227
305
  default:
228
- d = `${c}`;
306
+ br = `${tbR}`;
229
307
  }
230
308
  return {
231
- borderRadius: d,
232
- animationDuration: `${g}ms`,
233
- ...p
309
+ borderRadius: br,
310
+ animationDuration: `${duration}ms`,
311
+ ...customStyle
234
312
  };
235
- }), s = (n) => {
236
- l("clickMask", n), e.isCloseOnClickMask && (f.value = !1);
237
- }, f = F({
238
- get: () => e.modelValue,
239
- set: (n) => l("update:modelValue", n)
313
+ });
314
+ const onClickMask = (event) => {
315
+ emit("clickMask", event);
316
+ if (props.isCloseOnClickMask) {
317
+ visible.value = false;
318
+ }
319
+ };
320
+ const visible = computed({
321
+ get: () => props.modelValue,
322
+ set: (value) => emit("update:modelValue", value)
240
323
  });
241
324
  return () => {
242
325
  const {
243
- teleport: n,
244
- position: i,
245
- customClass: p,
246
- duration: g,
247
- onAfterLeave: c,
248
- lockScroll: d,
249
- zIndex: o
250
- } = e;
251
- return r(me, {
252
- to: n
326
+ teleport,
327
+ position,
328
+ customClass,
329
+ duration,
330
+ onAfterLeave,
331
+ lockScroll,
332
+ zIndex
333
+ } = props;
334
+ return createVNode(Teleport, {
335
+ "to": teleport
253
336
  }, {
254
- default: () => [r("div", {
255
- class: Z(),
256
- style: {
257
- zIndex: o
337
+ default: () => [createVNode("div", {
338
+ "class": bem$4(),
339
+ "style": {
340
+ zIndex
258
341
  }
259
- }, [r(I, {
260
- modelValue: f.value,
261
- "onUpdate:modelValue": (u) => f.value = u,
262
- duration: g,
263
- lockScroll: d,
264
- onClick: s,
265
- onAfterLeave: c
266
- }, null), r(te, {
267
- name: Ve("animation", `slide-${i}`)
342
+ }, [createVNode(Mask, {
343
+ "modelValue": visible.value,
344
+ "onUpdate:modelValue": ($event) => visible.value = $event,
345
+ "duration": duration,
346
+ "lockScroll": lockScroll,
347
+ "onClick": onClickMask,
348
+ "onAfterLeave": onAfterLeave
349
+ }, null), createVNode(Transition, {
350
+ "name": gBem$1("animation", `slide-${position}`)
268
351
  }, {
269
352
  default: () => {
270
- var u;
271
- return [P(r("div", {
272
- style: a.value,
273
- class: [Z("content", {
274
- [i]: i
275
- }), p]
276
- }, [((u = t.default) == null ? void 0 : u.call(t)) || null]), [[ne, f.value]])];
353
+ var _a;
354
+ return [withDirectives(createVNode("div", {
355
+ "style": style2.value,
356
+ "class": [bem$4("content", {
357
+ [position]: position
358
+ }), customClass]
359
+ }, [((_a = slots.default) == null ? void 0 : _a.call(slots)) || null]), [[vShow, visible.value]])];
277
360
  }
278
361
  })])]
279
362
  });
280
363
  };
281
364
  }
282
365
  });
283
- L.install = (e) => {
284
- const { name: t } = L;
285
- e.component(t, L);
366
+ const style$4 = "";
367
+ Popup.install = (app) => {
368
+ const { name: name2 } = Popup;
369
+ app.component(name2, Popup);
286
370
  };
287
- const [ze, z] = w("icon"), Ie = (e) => new RegExp(/\.(https|png|jpg|gif|jpeg|webp|apng)$/).test(e.toLowerCase()), M = /* @__PURE__ */ x({
288
- name: ze,
371
+ const [cname, bem$3] = createNamespace("icon");
372
+ const isImage = (name2) => {
373
+ const re = new RegExp(/\.(https|png|jpg|gif|jpeg|webp|apng)$/);
374
+ return re.test(name2.toLowerCase());
375
+ };
376
+ const Icon = /* @__PURE__ */ defineComponent({
377
+ name: cname,
289
378
  props: {
290
379
  dot: {
291
380
  type: Boolean,
292
- default: !1
381
+ default: false
293
382
  },
294
383
  name: {
295
384
  type: String,
@@ -332,62 +421,66 @@ const [ze, z] = w("icon"), Ie = (e) => new RegExp(/\.(https|png|jpg|gif|jpeg|web
332
421
  }
333
422
  },
334
423
  emits: ["click"],
335
- setup(e, {
336
- slots: t,
337
- emit: l
424
+ setup(props, {
425
+ slots,
426
+ emit
338
427
  }) {
339
- const a = Ie(e.name), s = () => ({
340
- fontSize: m(e.size),
341
- color: e.color
342
- }), f = (n) => {
343
- l("click", n);
428
+ const isImg = isImage(props.name);
429
+ const getStyle = () => ({
430
+ fontSize: parseUnit(props.size),
431
+ color: props.color
432
+ });
433
+ const onClick = (event) => {
434
+ emit("click", event);
344
435
  };
345
436
  return () => {
346
437
  const {
347
- name: n,
348
- classPrefix: i,
349
- badge: p,
350
- dot: g,
351
- subColor: c,
352
- subBg: d,
353
- tag: o
354
- } = e;
355
- return r(o, {
356
- class: `${i}${a ? "" : ` y-icon--${n}`}`,
357
- style: s(),
358
- onClick: f
438
+ name: name2,
439
+ classPrefix,
440
+ badge,
441
+ dot,
442
+ subColor,
443
+ subBg,
444
+ tag: Tag
445
+ } = props;
446
+ return createVNode(Tag, {
447
+ "class": `${classPrefix}${isImg ? "" : ` y-icon--${name2}`}`,
448
+ "style": getStyle(),
449
+ "onClick": onClick
359
450
  }, {
360
451
  default: () => {
361
- var u;
362
- return [a ? r("em", {
363
- class: z("node")
364
- }, [r("img", {
365
- class: z("image"),
366
- src: n,
367
- alt: "icon"
368
- }, null)]) : null, g ? r("em", {
369
- class: z("dot"),
370
- style: {
371
- backgroundColor: d
452
+ var _a;
453
+ return [isImg ? createVNode("em", {
454
+ "class": bem$3("node")
455
+ }, [createVNode("img", {
456
+ "class": bem$3("image"),
457
+ "src": name2,
458
+ "alt": "icon"
459
+ }, null)]) : null, dot ? createVNode("em", {
460
+ "class": bem$3("dot"),
461
+ "style": {
462
+ backgroundColor: subBg
372
463
  }
373
- }, null) : null, p ? r("em", {
374
- class: z("badge"),
375
- style: {
376
- color: c,
377
- backgroundColor: d
464
+ }, null) : null, badge ? createVNode("em", {
465
+ "class": bem$3("badge"),
466
+ "style": {
467
+ color: subColor,
468
+ backgroundColor: subBg
378
469
  }
379
- }, [p]) : null, ((u = t.default) == null ? void 0 : u.call(t)) || null];
470
+ }, [badge]) : null, ((_a = slots.default) == null ? void 0 : _a.call(slots)) || null];
380
471
  }
381
472
  });
382
473
  };
383
474
  }
384
475
  });
385
- M.install = (e) => {
386
- const { name: t } = M;
387
- e.component(t, M);
476
+ const style$3 = "";
477
+ Icon.install = (app) => {
478
+ const { name: name2 } = Icon;
479
+ app.component(name2, Icon);
388
480
  };
389
- const [Le, B, Me] = w("button"), _ = /* @__PURE__ */ x({
390
- name: Le,
481
+ const [name$2, bem$2, gBem] = createNamespace("button");
482
+ const Button = /* @__PURE__ */ defineComponent({
483
+ name: name$2,
391
484
  props: {
392
485
  // 标签
393
486
  tag: {
@@ -412,7 +505,7 @@ const [Le, B, Me] = w("button"), _ = /* @__PURE__ */ x({
412
505
  // 不可以状态
413
506
  disabled: {
414
507
  type: Boolean,
415
- default: !1
508
+ default: false
416
509
  },
417
510
  // 阴影
418
511
  shadow: {
@@ -422,12 +515,12 @@ const [Le, B, Me] = w("button"), _ = /* @__PURE__ */ x({
422
515
  // 方形
423
516
  square: {
424
517
  type: Boolean,
425
- default: !1
518
+ default: false
426
519
  },
427
520
  // 半圆弧
428
521
  semicircle: {
429
522
  type: Boolean,
430
- default: !1
523
+ default: false
431
524
  },
432
525
  // 自定义圆角
433
526
  radius: {
@@ -442,73 +535,77 @@ const [Le, B, Me] = w("button"), _ = /* @__PURE__ */ x({
442
535
  // block 自动填满父布局
443
536
  block: {
444
537
  type: Boolean,
445
- default: !1
538
+ default: false
446
539
  },
447
540
  // 危险按钮状态
448
541
  danger: {
449
542
  type: Boolean,
450
- default: !1
543
+ default: false
451
544
  }
452
545
  },
453
546
  emits: ["click"],
454
- setup(e, {
455
- slots: t,
456
- emit: l
547
+ setup(props, {
548
+ slots,
549
+ emit
457
550
  }) {
458
- const a = (s) => {
459
- l("click", s);
551
+ const onClick = (event) => {
552
+ emit("click", event);
460
553
  };
461
554
  return () => {
462
555
  let {
463
- tag: s
464
- } = e;
556
+ tag: Tag
557
+ } = props;
465
558
  const {
466
- radius: f,
467
- type: n,
468
- size: i,
469
- disabled: p,
470
- shadow: g,
471
- block: c,
472
- square: d,
473
- semicircle: o,
474
- danger: u,
475
- text: b,
476
- supplementText: y
477
- } = e, $ = t.default ? t.default() : b;
478
- return s = n === "link" ? "a" : s, r(s, {
479
- class: [B([n, i, {
480
- block: c,
481
- square: d,
482
- semicircle: o,
483
- disabled: p && s === "a"
484
- }, (n === "primary" || n === "secondary") && g ? `shadow_${g}` : "", u ? `${n}_danger` : "", p ? `${n}_disabled` : ""]), Me("el", "clickable")],
485
- style: {
486
- borderRadius: m(f)
559
+ radius,
560
+ type,
561
+ size,
562
+ disabled,
563
+ shadow,
564
+ block,
565
+ square,
566
+ semicircle,
567
+ danger,
568
+ text,
569
+ supplementText
570
+ } = props;
571
+ const showText = slots.default ? slots.default() : text;
572
+ Tag = type === "link" ? "a" : Tag;
573
+ return createVNode(Tag, {
574
+ "class": [bem$2([type, size, {
575
+ block,
576
+ square,
577
+ semicircle,
578
+ disabled: disabled && Tag === "a"
579
+ }, (type === "primary" || type === "secondary") && shadow ? `shadow_${shadow}` : "", danger ? `${type}_danger` : "", disabled ? `${type}_disabled` : ""]), gBem("el", "clickable")],
580
+ "style": {
581
+ borderRadius: parseUnit(radius)
487
582
  },
488
- disabled: p,
489
- onClick: a
583
+ "disabled": disabled,
584
+ "onClick": onClick
490
585
  }, {
491
586
  default: () => {
492
- var h, V;
493
- return [r("div", {
494
- class: B("content")
495
- }, [((h = t.leftIcon) == null ? void 0 : h.call(t)) || null, $ && r(ge, null, [y ? r("div", {
496
- class: B("text")
497
- }, [r("p", null, [$]), r("p", {
498
- class: B("subtext")
499
- }, [y])]) : r("span", {
500
- class: B("text")
501
- }, [$])]), ((V = t.rightIcon) == null ? void 0 : V.call(t)) || null])];
587
+ var _a, _b;
588
+ return [createVNode("div", {
589
+ "class": bem$2("content")
590
+ }, [((_a = slots.leftIcon) == null ? void 0 : _a.call(slots)) || null, showText && createVNode(Fragment, null, [supplementText ? createVNode("div", {
591
+ "class": bem$2("text")
592
+ }, [createVNode("p", null, [showText]), createVNode("p", {
593
+ "class": bem$2("subtext")
594
+ }, [supplementText])]) : createVNode("span", {
595
+ "class": bem$2("text")
596
+ }, [showText])]), ((_b = slots.rightIcon) == null ? void 0 : _b.call(slots)) || null])];
502
597
  }
503
598
  });
504
599
  };
505
600
  }
506
601
  });
507
- _.install = (e) => {
508
- const { name: t } = _;
509
- e.component(t, _);
602
+ const style$2 = "";
603
+ Button.install = (app) => {
604
+ const { name: name2 } = Button;
605
+ app.component(name2, Button);
510
606
  };
511
- const [Re, C] = w("loading"), Oe = {
607
+ const [name$1, bem$1] = createNamespace("loading");
608
+ const _props$1 = {
512
609
  // Loading icon 的颜色
513
610
  color: {
514
611
  type: String,
@@ -567,97 +664,107 @@ const [Re, C] = w("loading"), Oe = {
567
664
  type: String,
568
665
  default: "relative"
569
666
  }
570
- }, R = /* @__PURE__ */ x({
571
- name: Re,
572
- props: Oe,
573
- setup(e, {
574
- slots: t
667
+ };
668
+ const Loading = /* @__PURE__ */ defineComponent({
669
+ name: name$1,
670
+ props: _props$1,
671
+ setup(props, {
672
+ slots
575
673
  }) {
576
674
  return () => {
577
- var y, $;
675
+ var _a, _b;
578
676
  const {
579
- position: l,
580
- textLocation: a,
581
- bgColor: s,
582
- bgBorderRadius: f,
583
- size: n,
584
- padding: i,
585
- color: p,
586
- thick: g,
587
- direction: c,
588
- text: d,
589
- textColor: o,
590
- textSize: u
591
- } = e, b = ((y = t.default) == null ? void 0 : y.call(t)) || d;
592
- return r("div", {
593
- class: C({
594
- [l]: l !== "relative"
677
+ position,
678
+ textLocation,
679
+ bgColor,
680
+ bgBorderRadius,
681
+ size,
682
+ padding,
683
+ color,
684
+ thick,
685
+ direction,
686
+ text,
687
+ textColor,
688
+ textSize
689
+ } = props;
690
+ const showText = ((_a = slots.default) == null ? void 0 : _a.call(slots)) || text;
691
+ return createVNode("div", {
692
+ "class": bem$1({
693
+ [position]: position !== "relative"
595
694
  })
596
- }, [r("div", {
597
- class: C("bg", {
598
- [l]: l !== "relative"
695
+ }, [createVNode("div", {
696
+ "class": bem$1("bg", {
697
+ [position]: position !== "relative"
599
698
  }),
600
- style: {
601
- flexDirection: Ce(a),
602
- backgroundColor: s,
603
- borderRadius: m(f),
604
- padding: m(i)
699
+ "style": {
700
+ flexDirection: parseFlexDirection(textLocation),
701
+ backgroundColor: bgColor,
702
+ borderRadius: parseUnit(bgBorderRadius),
703
+ padding: parseUnit(padding)
605
704
  }
606
- }, [r("span", {
607
- class: C("icon-wrapper"),
608
- style: {
609
- width: m(n),
610
- height: m(n)
705
+ }, [createVNode("span", {
706
+ "class": bem$1("icon-wrapper"),
707
+ "style": {
708
+ width: parseUnit(size),
709
+ height: parseUnit(size)
611
710
  }
612
- }, [(($ = t.icon) == null ? void 0 : $.call(t)) || r("svg", {
613
- class: C("icon", {
614
- [c]: c
711
+ }, [((_b = slots.icon) == null ? void 0 : _b.call(slots)) || createVNode("svg", {
712
+ "class": bem$1("icon", {
713
+ [direction]: direction
615
714
  }),
616
- viewBox: "25 25 50 50"
617
- }, [r("circle", {
618
- class: C("icon-circle"),
619
- style: {
620
- stroke: p,
621
- strokeWidth: m(g)
715
+ "viewBox": "25 25 50 50"
716
+ }, [createVNode("circle", {
717
+ "class": bem$1("icon-circle"),
718
+ "style": {
719
+ stroke: color,
720
+ strokeWidth: parseUnit(thick)
622
721
  },
623
- cx: "50",
624
- cy: "50",
625
- r: "20",
626
- fill: "none"
627
- }, null)])]), b && r("span", {
628
- class: C("text", {
629
- [a]: a
722
+ "cx": "50",
723
+ "cy": "50",
724
+ "r": "20",
725
+ "fill": "none"
726
+ }, null)])]), showText && createVNode("span", {
727
+ "class": bem$1("text", {
728
+ [textLocation]: textLocation
630
729
  }),
631
- style: {
632
- color: o,
633
- fontSize: m(u)
730
+ "style": {
731
+ color: textColor,
732
+ fontSize: parseUnit(textSize)
634
733
  }
635
- }, [b])])]);
734
+ }, [showText])])]);
636
735
  };
637
736
  }
638
- }), Pe = {
737
+ });
738
+ const globalOptions = {
639
739
  position: "fixed"
640
740
  };
641
- let N = null;
642
- const ae = (e, t) => {
643
- const a = q({
644
- render: () => le(R, { ...e }, { ...t })
645
- }), s = document.createElement("div");
646
- return a.mount(s);
647
- }, De = {
741
+ let instance = null;
742
+ const initInstance = (customProps, customSlots) => {
743
+ const wrapper = {
744
+ render: () => {
745
+ return h(Loading, { ...customProps }, { ...customSlots });
746
+ }
747
+ };
748
+ const customApp = createApp(wrapper);
749
+ const element = document.createElement("div");
750
+ return customApp.mount(element);
751
+ };
752
+ const createLoading = {
648
753
  /**
649
754
  * @description: show
650
755
  * @param {LoadingPropsType} options
651
756
  * @return {*}
652
757
  */
653
- show: (e, t) => {
654
- N || (N = ae(
655
- {
656
- ...Pe,
657
- ...e
658
- },
659
- t
660
- )), document.body.appendChild(N.$el);
758
+ show: (customProps, customSlots) => {
759
+ if (!instance)
760
+ instance = initInstance(
761
+ {
762
+ ...globalOptions,
763
+ ...customProps
764
+ },
765
+ customSlots
766
+ );
767
+ document.body.appendChild(instance.$el);
661
768
  },
662
769
  /**
663
770
  * @description: hide
@@ -665,47 +772,73 @@ const ae = (e, t) => {
665
772
  * @return {*}
666
773
  */
667
774
  hide: () => {
668
- N && N.$el.remove();
775
+ instance && instance.$el.remove();
669
776
  }
670
- }, ee = (e, t) => {
671
- t.value ? (e.classList.add("y-loading__wrap"), e.appendChild(e.instance.$el)) : (e.classList.remove("y-loading__wrap"), e.removeChild(e.instance.$el));
672
- }, Te = {
673
- install: (e) => {
674
- e.directive("loading", re), e.directive("loading-props", je), e.directive("loading-slots", Fe);
777
+ };
778
+ const toggleLoading = (el, binding) => {
779
+ if (binding.value) {
780
+ el.classList.add("y-loading__wrap");
781
+ el.appendChild(el.instance.$el);
782
+ } else {
783
+ el.classList.remove("y-loading__wrap");
784
+ el.removeChild(el.instance.$el);
675
785
  }
676
- }, re = {
677
- getSSRProps: (e) => ({ ...e }),
678
- mounted: (e, t) => {
679
- e.instance = ae({ ...e.customProps }, { ...e.customSlots }), t.value && ee(e, t);
786
+ };
787
+ const loadingDirective = {
788
+ install: (app) => {
789
+ app.directive("loading", directive);
790
+ app.directive("loading-props", directiveProps);
791
+ app.directive("loading-slots", directiveSlots);
792
+ }
793
+ };
794
+ const directive = {
795
+ getSSRProps: (binding) => {
796
+ return { ...binding };
680
797
  },
681
- updated: (e, t) => {
682
- t.oldValue !== t.value && ee(e, t);
798
+ mounted: (el, binding) => {
799
+ el.instance = initInstance({ ...el.customProps }, { ...el.customSlots });
800
+ binding.value && toggleLoading(el, binding);
801
+ },
802
+ updated: (el, binding) => {
803
+ if (binding.oldValue !== binding.value) {
804
+ toggleLoading(el, binding);
805
+ }
683
806
  },
684
- unmounted: (e) => {
685
- e.instance && e.instance.$el.remove();
807
+ unmounted: (el) => {
808
+ el.instance && el.instance.$el.remove();
686
809
  }
687
- }, je = {
688
- getSSRProps: (e) => ({ ...e }),
689
- beforeMount: (e, t) => {
690
- e.customProps = { ...t.value };
810
+ };
811
+ const directiveProps = {
812
+ getSSRProps: (binding) => {
813
+ return { ...binding };
814
+ },
815
+ beforeMount: (el, binding) => {
816
+ el.customProps = { ...binding.value };
691
817
  }
692
- }, Fe = {
693
- getSSRProps: (e) => ({ ...e }),
694
- beforeMount: (e, t) => {
695
- e.customSlots = { ...t.value };
818
+ };
819
+ const directiveSlots = {
820
+ getSSRProps: (binding) => {
821
+ return { ...binding };
822
+ },
823
+ beforeMount: (el, binding) => {
824
+ el.customSlots = { ...binding.value };
696
825
  }
697
826
  };
698
- R.install = (e) => {
699
- e.component(R.name, R), e.provide("loading", De), e.use(Te);
827
+ const style$1 = "";
828
+ Loading.install = (app) => {
829
+ app.component(Loading.name, Loading);
830
+ app.provide("loading", createLoading);
831
+ app.use(loadingDirective);
700
832
  };
701
- function Ee(e) {
702
- return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !be(e);
833
+ function _isSlot(s) {
834
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
703
835
  }
704
- const [Ue, v] = w("dialog"), qe = {
836
+ const [name, bem] = createNamespace("dialog");
837
+ const _props = {
705
838
  // 控制显示
706
839
  modelValue: {
707
840
  type: Boolean,
708
- default: !1
841
+ default: false
709
842
  },
710
843
  width: {
711
844
  type: [Number, String],
@@ -729,15 +862,15 @@ const [Ue, v] = w("dialog"), qe = {
729
862
  },
730
863
  isCloseOnClickMask: {
731
864
  type: Boolean,
732
- default: !0
865
+ default: true
733
866
  },
734
867
  showCloseIcon: {
735
868
  type: Boolean,
736
- default: !1
869
+ default: false
737
870
  },
738
871
  showCancelBtn: {
739
872
  type: Boolean,
740
- default: !1
873
+ default: false
741
874
  },
742
875
  cancelButtonText: {
743
876
  type: String,
@@ -745,7 +878,7 @@ const [Ue, v] = w("dialog"), qe = {
745
878
  },
746
879
  showConfirmBtn: {
747
880
  type: Boolean,
748
- default: !1
881
+ default: false
749
882
  },
750
883
  confirmButtonText: {
751
884
  type: String,
@@ -765,188 +898,226 @@ const [Ue, v] = w("dialog"), qe = {
765
898
  },
766
899
  circleImg: {
767
900
  type: Boolean,
768
- default: !1
901
+ default: false
769
902
  },
770
903
  // 插入对象
771
904
  teleport: {
772
905
  type: String,
773
906
  default: "body"
774
907
  }
775
- }, O = /* @__PURE__ */ x({
776
- name: Ue,
908
+ };
909
+ const Dialog = /* @__PURE__ */ defineComponent({
910
+ name,
777
911
  directives: {
778
- loading: re
912
+ loading: directive
779
913
  },
780
- props: qe,
914
+ props: _props,
781
915
  emits: ["update:modelValue", "cancel", "confirm"],
782
- setup(e, {
783
- emit: t,
784
- slots: l
916
+ setup(props, {
917
+ emit,
918
+ slots
785
919
  }) {
786
- const a = U({
787
- cancel: !1,
788
- confirm: !1
789
- }), s = (o) => {
790
- d.value = o;
791
- }, f = (o) => {
792
- var u;
793
- s(!1), (u = e.callback) == null || u.call(e, o);
794
- }, n = (o) => {
795
- t("cancel", o, p("cancel"));
796
- }, i = (o) => {
797
- t("confirm", o, p("confirm"));
798
- }, p = (o) => {
920
+ const loading = reactive({
921
+ cancel: false,
922
+ confirm: false
923
+ });
924
+ const update = (value) => {
925
+ visible.value = value;
926
+ };
927
+ const onClose = (actionType) => {
928
+ var _a;
929
+ update(false);
930
+ (_a = props.callback) == null ? void 0 : _a.call(props, actionType);
931
+ };
932
+ const onCancel = (event) => {
933
+ emit("cancel", event, onHandler("cancel"));
934
+ };
935
+ const onConfirm = (event) => {
936
+ emit("confirm", event, onHandler("confirm"));
937
+ };
938
+ const onHandler = (actionType) => {
799
939
  const {
800
- modelValue: u,
801
- beforeClose: b
802
- } = e;
803
- if (u)
804
- if (Se(b)) {
805
- a[o] = !0;
806
- const y = b(o);
807
- ve(y) ? y.then((h) => {
808
- g(h, o);
809
- }).catch((h) => {
810
- throw new Error(h);
811
- }) : g(y, o);
812
- } else
813
- f(o);
814
- }, g = (o, u) => {
815
- o && f(u), a[u] = !1;
816
- }, c = (o, u, b) => {
817
- let y = Number(o.substring(0, o.length - 2));
818
- return y /= u || 2, b ? `${b(y)}px` : `${y}px`;
819
- }, d = F({
820
- get: () => e.modelValue,
821
- set: (o) => t("update:modelValue", o)
940
+ modelValue,
941
+ beforeClose
942
+ } = props;
943
+ if (!modelValue)
944
+ return;
945
+ if (isFunction(beforeClose)) {
946
+ loading[actionType] = true;
947
+ const fnReturn = beforeClose(actionType);
948
+ if (isPromise(fnReturn)) {
949
+ const promise = fnReturn;
950
+ promise.then((value) => {
951
+ done(value, actionType);
952
+ }).catch((e) => {
953
+ throw new Error(e);
954
+ });
955
+ } else {
956
+ done(fnReturn, actionType);
957
+ }
958
+ } else {
959
+ onClose(actionType);
960
+ }
961
+ };
962
+ const done = (value, actionType) => {
963
+ if (value) {
964
+ onClose(actionType);
965
+ loading[actionType] = false;
966
+ } else {
967
+ loading[actionType] = false;
968
+ }
969
+ };
970
+ const halfOfWidth = (val, multiple, processing) => {
971
+ let num2 = Number(val.substring(0, val.length - 2));
972
+ num2 /= multiple || 2;
973
+ return processing ? `${processing(num2)}px` : `${num2}px`;
974
+ };
975
+ const visible = computed({
976
+ get: () => props.modelValue,
977
+ set: (value) => emit("update:modelValue", value)
822
978
  });
823
979
  return () => {
824
980
  const {
825
- width: o,
826
- title: u,
827
- titleAlign: b,
828
- message: y,
829
- messageAlign: $,
830
- isCloseOnClickMask: h,
831
- showCloseIcon: V,
832
- showCancelBtn: W,
833
- cancelButtonText: T,
834
- showConfirmBtn: G,
835
- confirmButtonText: ce,
836
- imgSrc: H,
837
- circleImg: k,
838
- teleport: se
839
- } = e;
840
- return r(L, ye({
841
- modelValue: d.value,
842
- "onUpdate:modelValue": (A) => d.value = A,
843
- customClass: v(),
844
- customStyle: {
845
- width: m(o)
981
+ width,
982
+ title,
983
+ titleAlign,
984
+ message,
985
+ messageAlign,
986
+ isCloseOnClickMask,
987
+ showCloseIcon,
988
+ showCancelBtn,
989
+ cancelButtonText,
990
+ showConfirmBtn,
991
+ confirmButtonText,
992
+ imgSrc,
993
+ circleImg,
994
+ teleport
995
+ } = props;
996
+ return createVNode(Popup, mergeProps({
997
+ "modelValue": visible.value,
998
+ "onUpdate:modelValue": ($event) => visible.value = $event,
999
+ "customClass": bem(),
1000
+ "customStyle": {
1001
+ width: parseUnit(width)
846
1002
  }
847
1003
  }, {
848
- "onUpdate:modelValue": s
1004
+ "onUpdate:modelValue": update
849
1005
  }, {
850
- isCloseOnClickMask: h,
851
- teleport: se
1006
+ "isCloseOnClickMask": isCloseOnClickMask,
1007
+ "teleport": teleport
852
1008
  }), {
853
1009
  default: () => {
854
- var A, J, K, Q;
855
- return [((A = l.img) == null ? void 0 : A.call(l)) || H && r("div", {
856
- class: v("img", {
857
- circle: k
1010
+ var _a, _b, _c, _d;
1011
+ return [((_a = slots.img) == null ? void 0 : _a.call(slots)) || imgSrc && createVNode("div", {
1012
+ "class": bem("img", {
1013
+ circle: circleImg
858
1014
  }),
859
- style: {
860
- top: k ? `-${c(m(o), 4)}` : "auto",
861
- left: k ? `calc(50% - ${c(m(o), 4)})` : "auto"
1015
+ "style": {
1016
+ top: circleImg ? `-${halfOfWidth(parseUnit(width), 4)}` : "auto",
1017
+ left: circleImg ? `calc(50% - ${halfOfWidth(parseUnit(width), 4)})` : "auto"
862
1018
  }
863
- }, [r("div", {
864
- style: {
865
- width: k ? c(m(o)) : m(o),
866
- height: c(m(o)),
867
- background: `url(${H}) center`,
868
- borderRadius: k ? "50%" : "20px 20px 0 0"
1019
+ }, [createVNode("div", {
1020
+ "style": {
1021
+ width: circleImg ? halfOfWidth(parseUnit(width)) : parseUnit(width),
1022
+ height: halfOfWidth(parseUnit(width)),
1023
+ background: `url(${imgSrc}) center`,
1024
+ borderRadius: circleImg ? "50%" : "20px 20px 0 0"
869
1025
  }
870
- }, null)]), r("div", {
871
- class: v("container")
872
- }, [r("div", {
873
- style: {
874
- height: k ? c(m(o), 4, (ue) => ue + 20) : "24px"
1026
+ }, null)]), createVNode("div", {
1027
+ "class": bem("container")
1028
+ }, [createVNode("div", {
1029
+ "style": {
1030
+ height: circleImg ? halfOfWidth(parseUnit(width), 4, (num2) => {
1031
+ return num2 + 20;
1032
+ }) : "24px"
875
1033
  }
876
- }, null), ((J = l.title) == null ? void 0 : J.call(l)) || r("div", {
877
- class: v("title"),
878
- style: {
879
- textAlign: b
1034
+ }, null), ((_b = slots.title) == null ? void 0 : _b.call(slots)) || createVNode("div", {
1035
+ "class": bem("title"),
1036
+ "style": {
1037
+ textAlign: titleAlign
880
1038
  }
881
- }, [u]), r("div", {
882
- class: v("content")
883
- }, [r("div", {
884
- class: v("message"),
885
- style: {
886
- textAlign: $
1039
+ }, [title]), createVNode("div", {
1040
+ "class": bem("content")
1041
+ }, [createVNode("div", {
1042
+ "class": bem("message"),
1043
+ "style": {
1044
+ textAlign: messageAlign
887
1045
  }
888
- }, [((K = l.default) == null ? void 0 : K.call(l)) || y]), ((Q = l.footer) == null ? void 0 : Q.call(l)) || r("div", {
889
- class: v("footer"),
890
- style: {
891
- paddingTop: W || G ? "20px" : "0px"
1046
+ }, [((_c = slots.default) == null ? void 0 : _c.call(slots)) || message]), ((_d = slots.footer) == null ? void 0 : _d.call(slots)) || createVNode("div", {
1047
+ "class": bem("footer"),
1048
+ "style": {
1049
+ paddingTop: showCancelBtn || showConfirmBtn ? "20px" : "0px"
892
1050
  }
893
- }, [W && P(r(_, {
894
- type: "secondary",
895
- class: v("footer-btn"),
896
- onClick: n
897
- }, Ee(T) ? T : {
898
- default: () => [T]
899
- }), [[X("loading"), a.cancel]]), G && P(r(_, {
900
- type: "primary",
901
- class: v("footer-btn"),
902
- onClick: i
1051
+ }, [showCancelBtn && withDirectives(createVNode(Button, {
1052
+ "type": "secondary",
1053
+ "class": bem("footer-btn"),
1054
+ "onClick": onCancel
1055
+ }, _isSlot(cancelButtonText) ? cancelButtonText : {
1056
+ default: () => [cancelButtonText]
1057
+ }), [[resolveDirective("loading"), loading.cancel]]), showConfirmBtn && withDirectives(createVNode(Button, {
1058
+ "type": "primary",
1059
+ "class": bem("footer-btn"),
1060
+ "onClick": onConfirm
903
1061
  }, {
904
- default: () => [a.confirm ? "" : ce]
905
- }), [[X("loading"), a.confirm]])])]), V && r("div", {
906
- class: v("close"),
907
- onClick: () => f("close")
908
- }, [r(M, {
909
- name: "cross"
1062
+ default: () => [loading.confirm ? "" : confirmButtonText]
1063
+ }), [[resolveDirective("loading"), loading.confirm]])])]), showCloseIcon && createVNode("div", {
1064
+ "class": bem("close"),
1065
+ "onClick": () => onClose("close")
1066
+ }, [createVNode(Icon, {
1067
+ "name": "cross"
910
1068
  }, null)])])];
911
1069
  }
912
1070
  });
913
1071
  };
914
1072
  }
915
1073
  });
916
- let j = q({}), We = 0;
917
- const ie = [], Ge = (e, t) => {
918
- const l = `dialog${We += 1}`;
919
- j = q({
1074
+ let dialogApp = createApp({});
1075
+ let num = 0;
1076
+ const treasures = [];
1077
+ const createDialog = (customProps, customSlots) => {
1078
+ const id = `dialog${num += 1}`;
1079
+ const wrapper = {
920
1080
  setup() {
921
- const f = E(!0), n = (i) => {
922
- f.value = i;
1081
+ const show = ref(true);
1082
+ const toggle = (val) => {
1083
+ show.value = val;
1084
+ };
1085
+ return () => {
1086
+ return h(
1087
+ Dialog,
1088
+ {
1089
+ modelValue: show.value,
1090
+ "onUpdate:modelValue": toggle,
1091
+ ...customProps,
1092
+ onAfterLeave: () => {
1093
+ close(id);
1094
+ }
1095
+ },
1096
+ { ...customSlots }
1097
+ );
923
1098
  };
924
- return () => le(
925
- O,
926
- {
927
- modelValue: f.value,
928
- "onUpdate:modelValue": n,
929
- ...e,
930
- onAfterLeave: () => {
931
- He(l);
932
- }
933
- },
934
- { ...t }
935
- );
936
1099
  }
937
- });
938
- const s = document.createElement("div");
939
- ie.push({ id: l, app: j, el: s }), j.mount(s);
940
- }, He = (e) => {
941
- ie.forEach((t) => {
942
- e === t.id && t.app.unmount();
1100
+ };
1101
+ dialogApp = createApp(wrapper);
1102
+ const element = document.createElement("div");
1103
+ treasures.push({ id, app: dialogApp, el: element });
1104
+ dialogApp.mount(element);
1105
+ };
1106
+ const close = (id) => {
1107
+ treasures.forEach((obj) => {
1108
+ if (id === obj.id) {
1109
+ obj.app.unmount();
1110
+ }
943
1111
  });
944
1112
  };
945
- O.install = (e) => {
946
- const { name: t } = O;
947
- e.component(t, O), e.provide("dialog", Ge);
1113
+ const style = "";
1114
+ Dialog.install = (app) => {
1115
+ const { name: name2 } = Dialog;
1116
+ app.component(name2, Dialog);
1117
+ app.provide("dialog", createDialog);
948
1118
  };
949
1119
  export {
950
- Ge as createDialog,
951
- O as default
1120
+ Dialog,
1121
+ createDialog,
1122
+ Dialog as default
952
1123
  };