@bdsoft/element 1.1.0

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 (238) hide show
  1. package/README.md +90 -0
  2. package/global/index.ts +6 -0
  3. package/global/register-properties.ts +10 -0
  4. package/index.html +13 -0
  5. package/index.js +84 -0
  6. package/package-form/core/components/formCreate.js +274 -0
  7. package/package-form/core/components/fragment.js +12 -0
  8. package/package-form/core/factory/context.js +257 -0
  9. package/package-form/core/factory/creator.js +63 -0
  10. package/package-form/core/factory/maker.js +17 -0
  11. package/package-form/core/factory/manager.js +79 -0
  12. package/package-form/core/factory/node.js +85 -0
  13. package/package-form/core/factory/parser.js +28 -0
  14. package/package-form/core/frame/api.js +599 -0
  15. package/package-form/core/frame/attrs.js +12 -0
  16. package/package-form/core/frame/dataDriver.js +76 -0
  17. package/package-form/core/frame/fetch.js +119 -0
  18. package/package-form/core/frame/formCreate.js +274 -0
  19. package/package-form/core/frame/index.js +760 -0
  20. package/package-form/core/frame/provider.js +288 -0
  21. package/package-form/core/frame/util.js +274 -0
  22. package/package-form/core/handler/context.js +380 -0
  23. package/package-form/core/handler/effect.js +122 -0
  24. package/package-form/core/handler/index.js +111 -0
  25. package/package-form/core/handler/inject.js +145 -0
  26. package/package-form/core/handler/input.js +197 -0
  27. package/package-form/core/handler/lifecycle.js +43 -0
  28. package/package-form/core/handler/loader.js +373 -0
  29. package/package-form/core/handler/page.js +46 -0
  30. package/package-form/core/handler/render.js +29 -0
  31. package/package-form/core/index.js +12 -0
  32. package/package-form/core/package.json +15 -0
  33. package/package-form/core/parser/html.js +17 -0
  34. package/package-form/core/render/cache.js +47 -0
  35. package/package-form/core/render/index.js +31 -0
  36. package/package-form/core/render/render.js +393 -0
  37. package/package-form/element-form/components/checkbox/package.json +17 -0
  38. package/package-form/element-form/components/checkbox/src/component.jsx +110 -0
  39. package/package-form/element-form/components/checkbox/src/index.js +3 -0
  40. package/package-form/element-form/components/frame/package.json +17 -0
  41. package/package-form/element-form/components/frame/src/IconCircleClose.vue +14 -0
  42. package/package-form/element-form/components/frame/src/IconDelete.vue +12 -0
  43. package/package-form/element-form/components/frame/src/IconDocument.vue +12 -0
  44. package/package-form/element-form/components/frame/src/IconFolderOpened.vue +12 -0
  45. package/package-form/element-form/components/frame/src/IconView.vue +12 -0
  46. package/package-form/element-form/components/frame/src/component.jsx +349 -0
  47. package/package-form/element-form/components/frame/src/index.js +3 -0
  48. package/package-form/element-form/components/frame/src/style.css +66 -0
  49. package/package-form/element-form/components/group/package.json +17 -0
  50. package/package-form/element-form/components/group/src/component.jsx +314 -0
  51. package/package-form/element-form/components/group/src/index.js +3 -0
  52. package/package-form/element-form/components/group/src/style.css +125 -0
  53. package/package-form/element-form/components/index.js +22 -0
  54. package/package-form/element-form/components/radio/package.json +17 -0
  55. package/package-form/element-form/components/radio/src/component.jsx +101 -0
  56. package/package-form/element-form/components/radio/src/index.js +3 -0
  57. package/package-form/element-form/components/select/package.json +17 -0
  58. package/package-form/element-form/components/select/src/component.jsx +52 -0
  59. package/package-form/element-form/components/select/src/index.js +3 -0
  60. package/package-form/element-form/components/subform/package.json +14 -0
  61. package/package-form/element-form/components/subform/src/component.jsx +76 -0
  62. package/package-form/element-form/components/subform/src/index.js +3 -0
  63. package/package-form/element-form/components/tree/package.json +17 -0
  64. package/package-form/element-form/components/tree/src/component.jsx +62 -0
  65. package/package-form/element-form/components/tree/src/index.js +3 -0
  66. package/package-form/element-form/components/upload/package.json +17 -0
  67. package/package-form/element-form/components/upload/src/IconUpload.vue +12 -0
  68. package/package-form/element-form/components/upload/src/component.jsx +129 -0
  69. package/package-form/element-form/components/upload/src/index.js +3 -0
  70. package/package-form/element-form/components/upload/src/style.css +11 -0
  71. package/package-form/element-form/index.js +8 -0
  72. package/package-form/element-form/package.json +16 -0
  73. package/package-form/element-form/src/components/icon/IconWarning.vue +12 -0
  74. package/package-form/element-form/src/components/index.js +22 -0
  75. package/package-form/element-form/src/core/alias.js +34 -0
  76. package/package-form/element-form/src/core/api.js +208 -0
  77. package/package-form/element-form/src/core/config.js +62 -0
  78. package/package-form/element-form/src/core/index.js +60 -0
  79. package/package-form/element-form/src/core/maker.js +76 -0
  80. package/package-form/element-form/src/core/manager.js +315 -0
  81. package/package-form/element-form/src/core/provider.js +79 -0
  82. package/package-form/element-form/src/parsers/datePicker.js +31 -0
  83. package/package-form/element-form/src/parsers/hidden.js +12 -0
  84. package/package-form/element-form/src/parsers/index.js +17 -0
  85. package/package-form/element-form/src/parsers/input.js +21 -0
  86. package/package-form/element-form/src/parsers/row.js +10 -0
  87. package/package-form/element-form/src/parsers/select.js +15 -0
  88. package/package-form/element-form/src/parsers/slider.js +21 -0
  89. package/package-form/element-form/src/parsers/timePicker.js +17 -0
  90. package/package-form/element-form/src/style/index.css +52 -0
  91. package/package.json +17 -0
  92. package/src/App.vue +28 -0
  93. package/src/assets/css/element.scss +179 -0
  94. package/src/assets/css/layout.scss +215 -0
  95. package/src/assets/css/tailwind.scss +67 -0
  96. package/src/assets/images/banner.gif +0 -0
  97. package/src/assets/images/banner.png +0 -0
  98. package/src/assets/images/bg1.svg +22 -0
  99. package/src/assets/images/bg2.png +0 -0
  100. package/src/assets/images/ff.png +0 -0
  101. package/src/assets/images/home-file1.png +0 -0
  102. package/src/assets/images/ky.png +0 -0
  103. package/src/assets/images/menu/add.png +0 -0
  104. package/src/assets/images/menu/del.png +0 -0
  105. package/src/assets/images/menu/down.png +0 -0
  106. package/src/assets/images/menu/dr.png +0 -0
  107. package/src/assets/images/menu/edit.png +0 -0
  108. package/src/assets/images/menu/kx.png +0 -0
  109. package/src/assets/images/menu/mb.png +0 -0
  110. package/src/assets/images/menu/pz.png +0 -0
  111. package/src/assets/images/menu/save.png +0 -0
  112. package/src/assets/images/menu/sj.png +0 -0
  113. package/src/assets/images/menu/sjk.png +0 -0
  114. package/src/assets/images/menu/up.png +0 -0
  115. package/src/assets/images/po-i.png +0 -0
  116. package/src/assets/images/po1-i1.png +0 -0
  117. package/src/assets/images/po1-i2.png +0 -0
  118. package/src/assets/images/po1-i3.png +0 -0
  119. package/src/assets/images/po1-i4.png +0 -0
  120. package/src/assets/images/po1-i5.png +0 -0
  121. package/src/assets/images/po1-i6.png +0 -0
  122. package/src/assets/images/po1-i7.png +0 -0
  123. package/src/assets/images/po1-i8.png +0 -0
  124. package/src/assets/images/po2-i1.png +0 -0
  125. package/src/assets/images/po2-i2.png +0 -0
  126. package/src/assets/images/po3-i1.png +0 -0
  127. package/src/assets/images/po4-i1.png +0 -0
  128. package/src/assets/images/po5-i1.png +0 -0
  129. package/src/assets/images/po6-i1.png +0 -0
  130. package/src/assets/images/po6-i2.png +0 -0
  131. package/src/assets/images/po7-i1.png +0 -0
  132. package/src/assets/images/tj1.png +0 -0
  133. package/src/assets/images/tj2.png +0 -0
  134. package/src/assets/images/tj3.png +0 -0
  135. package/src/components/3dcloudwords/index.js +346 -0
  136. package/src/components/3dcloudwords/index.vue +99 -0
  137. package/src/components/3dcloudwords/readme.md +66 -0
  138. package/src/components/badge/index.js +167 -0
  139. package/src/components/badge/index.scss +166 -0
  140. package/src/components/badge/index.vue +98 -0
  141. package/src/components/badge/readme.md +18 -0
  142. package/src/components/basic/Finish.vue +107 -0
  143. package/src/components/basic/button.vue +19 -0
  144. package/src/components/basic/readme.md +7 -0
  145. package/src/components/button/index.vue +48 -0
  146. package/src/components/button/readme.md +62 -0
  147. package/src/components/carousel/index.vue +104 -0
  148. package/src/components/carousel/readme.md +12 -0
  149. package/src/components/chartconfig/index.vue +141 -0
  150. package/src/components/chartconfig/readme.md +25 -0
  151. package/src/components/contextMenu/hookContxtMenu.js +41 -0
  152. package/src/components/contextMenu/index.vue +245 -0
  153. package/src/components/contextMenu/readme.md +55 -0
  154. package/src/components/contextMenu/useElementBounding.js +40 -0
  155. package/src/components/countup/countUp.js +196 -0
  156. package/src/components/countup/index.vue +112 -0
  157. package/src/components/countup/readme.md +9 -0
  158. package/src/components/empty/assets/build.png +0 -0
  159. package/src/components/empty/assets/emptybg.gif +0 -0
  160. package/src/components/empty/assets/emptybg.png +0 -0
  161. package/src/components/empty/assets/emptybg2.jpg +0 -0
  162. package/src/components/empty/assets/emptybg3.jpg +0 -0
  163. package/src/components/empty/assets/wuxiao.png +0 -0
  164. package/src/components/empty/assets/wuxiao.webp +0 -0
  165. package/src/components/empty/building.vue +117 -0
  166. package/src/components/empty/empty.vue +120 -0
  167. package/src/components/empty/index.js +12 -0
  168. package/src/components/empty/invalid.vue +56 -0
  169. package/src/components/error/Error.vue +79 -0
  170. package/src/components/error/readme.md +20 -0
  171. package/src/components/form/Form.vue +84 -0
  172. package/src/components/form/FormItem.vue +143 -0
  173. package/src/components/form/data.js +52 -0
  174. package/src/components/form/readme.md +69 -0
  175. package/src/components/layout/banner.vue +412 -0
  176. package/src/components/layout/bar.vue +43 -0
  177. package/src/components/layout/layout1.vue +60 -0
  178. package/src/components/layout/layout2.vue +134 -0
  179. package/src/components/layout/layout3.vue +107 -0
  180. package/src/components/layout/layout4.vue +66 -0
  181. package/src/components/layout/nav.vue +333 -0
  182. package/src/components/layout/readme.md +61 -0
  183. package/src/components/loading/index.vue +122 -0
  184. package/src/components/loading/readme.md +6 -0
  185. package/src/components/notice/NoticeList.vue +198 -0
  186. package/src/components/notice/NoticeListPaging.vue +281 -0
  187. package/src/components/notice/NoticeView.vue +92 -0
  188. package/src/components/notice/readme.md +1 -0
  189. package/src/components/pagination/index.vue +100 -0
  190. package/src/components/pagination/readme.md +19 -0
  191. package/src/components/pagination/scroll-to.js +51 -0
  192. package/src/components/progress/bar.vue +72 -0
  193. package/src/components/progress/progress.vue +58 -0
  194. package/src/components/screenfull/index.js +3 -0
  195. package/src/components/screenfull/index.vue +65 -0
  196. package/src/components/screenfull/package.json +15 -0
  197. package/src/components/screenfull/readme.md +6 -0
  198. package/src/components/statisticalCount/index.vue +80 -0
  199. package/src/components/statisticalCount/readme.md +21 -0
  200. package/src/components/username/index.vue +79 -0
  201. package/src/components/username/readme.md +22 -0
  202. package/src/components/username//346/225/210/346/236/234/345/233/276.png +0 -0
  203. package/src/index.js +82 -0
  204. package/src/utils/index.js +32 -0
  205. package/src/xm_components/HeadSearch/hook/hookSearch.js +96 -0
  206. package/src/xm_components/HeadSearch/index.vue +206 -0
  207. package/src/xm_components/HeadSearch/readme.md +12 -0
  208. package/src/xm_components/HeadSearch//346/220/234/347/264/242/345/210/227/350/241/250.png +0 -0
  209. package/src/xm_components/Milestone/index.vue +212 -0
  210. package/src/xm_components/Milestone/readme.md +15 -0
  211. package/src/xm_components/readme.md +1 -0
  212. package/utils/coms/load.jsx +10 -0
  213. package/utils/func.js +32 -0
  214. package/utils/hookDialog.js +38 -0
  215. package/utils/hookPage.js +49 -0
  216. package/utils/index.js +5 -0
  217. package/utils/lib/console.js +39 -0
  218. package/utils/lib/debounce.js +19 -0
  219. package/utils/lib/deepextend.js +51 -0
  220. package/utils/lib/deepset.js +14 -0
  221. package/utils/lib/extend.js +28 -0
  222. package/utils/lib/index.js +13 -0
  223. package/utils/lib/json.js +90 -0
  224. package/utils/lib/mergeprops.js +62 -0
  225. package/utils/lib/mitt.js +43 -0
  226. package/utils/lib/modify.js +8 -0
  227. package/utils/lib/slot.js +19 -0
  228. package/utils/lib/toarray.js +5 -0
  229. package/utils/lib/tocase.js +11 -0
  230. package/utils/lib/todate.js +10 -0
  231. package/utils/lib/toline.js +10 -0
  232. package/utils/lib/tostring.js +7 -0
  233. package/utils/lib/type.js +45 -0
  234. package/utils/lib/unique.js +6 -0
  235. package/utils/message.js +166 -0
  236. package/utils/package.json +16 -0
  237. package/utils/type.js +45 -0
  238. package/vite.config.js +51 -0
@@ -0,0 +1,51 @@
1
+ import {$set} from './modify';
2
+ import is from './type';
3
+
4
+ export default function deepExtend(origin, target = {}, mode) {
5
+ let isArr = false;
6
+ for (let key in target) {
7
+ if (Object.prototype.hasOwnProperty.call(target, key)) {
8
+ let clone = target[key];
9
+ if ((isArr = Array.isArray(clone)) || is.Object(clone)) {
10
+ let nst = origin[key] === undefined;
11
+ if (isArr) {
12
+ isArr = false;
13
+ nst && $set(origin, key, []);
14
+ } else if (clone._clone && mode !== undefined) {
15
+ if (mode) {
16
+ clone = clone.getRule();
17
+ nst && $set(origin, key, {});
18
+ } else {
19
+ $set(origin, key, clone._clone());
20
+ continue;
21
+ }
22
+ } else {
23
+ nst && $set(origin, key, {});
24
+ }
25
+ origin[key] = deepExtend(origin[key], clone, mode);
26
+ } else {
27
+ $set(origin, key, clone);
28
+ if (!is.Undef(clone)) {
29
+ if (!is.Undef(clone.__json)) {
30
+ origin[key].__json = clone.__json;
31
+ }
32
+ if (!is.Undef(clone.__origin)) {
33
+ origin[key].__origin = clone.__origin;
34
+ }
35
+ }
36
+ }
37
+ }
38
+ }
39
+ return (mode !== undefined && Array.isArray(origin)) ? origin.filter(v => !v || !v.__ctrl) : origin
40
+ }
41
+
42
+ export function deepCopy(value) {
43
+ return deepExtend({}, {value}).value;
44
+ }
45
+
46
+ export function deepExtendArgs(origin, ...lst) {
47
+ lst.forEach(target => {
48
+ origin = deepExtend(origin, target);
49
+ });
50
+ return origin;
51
+ }
@@ -0,0 +1,14 @@
1
+ export default function deepSet(data, idx, val) {
2
+ let _data = data, to;
3
+ (idx || '').split('.').forEach(v => {
4
+ if (to) {
5
+ if (!_data[to] || typeof _data[to] != 'object') {
6
+ _data[to] = {}
7
+ }
8
+ _data = _data[to];
9
+ }
10
+ to = v;
11
+ })
12
+ _data[to] = val;
13
+ return _data;
14
+ }
@@ -0,0 +1,28 @@
1
+ import {$set} from './modify';
2
+
3
+ const _extends = Object.assign || function (a) {
4
+ for (let b, c = 1; c < arguments.length; c++) {
5
+ for (let d in b = arguments[c], b) {
6
+ Object.prototype.hasOwnProperty.call(b, d) && ($set(a, d, b[d]));
7
+ }
8
+ }
9
+
10
+ return a;
11
+ }
12
+ /**
13
+ * 将传入的多个对象合并成一个新的对象,并返回这个新对象。
14
+ *
15
+ * @returns {Object} - 合并后的新对象。
16
+ */
17
+ export default function extend() {
18
+ // 使用 _extends 函数将传入的所有对象合并成一个新的对象,并返回这个新对象
19
+ return _extends.apply(this, arguments);
20
+ }
21
+
22
+ export function copy(obj) {
23
+ // 如果 obj 不是对象或者为 null,则直接返回 obj
24
+ if (typeof obj !== 'object' || obj === null) return obj;
25
+ // 如果 obj 是数组,则使用扩展运算符复制数组
26
+ // 如果 obj 是对象,则使用扩展运算符复制对象
27
+ return obj instanceof Array ? [...obj] : {...obj};
28
+ }
@@ -0,0 +1,13 @@
1
+ export {default as debounce} from './debounce';
2
+ export {default as toArray} from './toarray';
3
+ export {default as toString} from './tostring';
4
+ export {default as toLine} from './toline';
5
+ export {default as toDate} from './todate';
6
+ export {default as deepExtend, deepExtendArgs, deepCopy} from './deepextend';
7
+ export {default as extend, copy} from './extend';
8
+ export {parseJson, toJson} from './json';
9
+ export {$set, $del} from './modify';
10
+ export {default as is} from './type';
11
+ export {default as uniqueId} from './unique';
12
+ export {default as getSlot} from './slot';
13
+ export {default as deepSet} from './deepset';
@@ -0,0 +1,90 @@
1
+ import deepExtend from './deepextend';
2
+ import {err} from './console';
3
+ import is from './type';
4
+
5
+ const PREFIX = '[[FORM-CREATE-PREFIX-';
6
+ const SUFFIX = '-FORM-CREATE-SUFFIX]]';
7
+
8
+ export function toJson(obj, space) {
9
+ return JSON.stringify(deepExtend(Array.isArray(obj) ? [] : {}, obj, true), function (key, val) {
10
+ if (val && val._isVue === true)
11
+ return undefined;
12
+
13
+ if (typeof val !== 'function') {
14
+ return val;
15
+ }
16
+ if (val.__json) {
17
+ return val.__json;
18
+ }
19
+ if (val.__origin)
20
+ val = val.__origin;
21
+
22
+ if (val.__emit)
23
+ return undefined;
24
+ return PREFIX + val + SUFFIX;
25
+ }, space);
26
+ }
27
+
28
+ function makeFn(fn) {
29
+ return (new Function('return ' + fn))();
30
+ }
31
+
32
+ export function parseFn(fn, mode) {
33
+ if (fn && is.String(fn) && fn.length > 4) {
34
+ let v = fn.trim();
35
+ let flag = false;
36
+ try {
37
+ if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
38
+ v = v.replace(SUFFIX, '').replace(PREFIX, '');
39
+ flag = true;
40
+ } else if (v.indexOf('$FN:') === 0) {
41
+ v = v.substring(4);
42
+ flag = true;
43
+ } else if (v.indexOf('$EXEC:') === 0) {
44
+ v = v.substring(6);
45
+ flag = true;
46
+ } else if (v.indexOf('$GLOBAL:') === 0) {
47
+ const name = v.substring(8);
48
+ v = function (...args) {
49
+ const callback = args[0].api.getGlobalEvent(name);
50
+ if (callback) {
51
+ return callback.call(this, ...args);
52
+ }
53
+ return undefined;
54
+ }
55
+ v.__json = fn;
56
+ v.__inject = true;
57
+ return v;
58
+ } else if (v.indexOf('$FNX:') === 0) {
59
+ v = makeFn('function($inject){' + v.substring(5) + '}');
60
+ v.__json = fn;
61
+ v.__inject = true;
62
+ return v;
63
+ } else if (!mode && v.indexOf('function ') === 0 && v !== 'function ') {
64
+ flag = true;
65
+ } else if (!mode && v.indexOf('function(') === 0 && v !== 'function(') {
66
+ flag = true;
67
+ }
68
+ if (!flag) return fn;
69
+ let val;
70
+ try{
71
+ val = makeFn(v);
72
+ }catch (e){
73
+ val = makeFn('function ' + v);
74
+ }
75
+ val.__json = fn;
76
+ return val;
77
+ } catch (e) {
78
+ err(`解析失败:${v}\n\nerr: ${e}`);
79
+ return undefined;
80
+ }
81
+ }
82
+ return fn;
83
+ }
84
+
85
+ export function parseJson(json, mode) {
86
+ return JSON.parse(json, function (k, v) {
87
+ if (is.Undef(v) || !v.indexOf) return v;
88
+ return parseFn(v, mode);
89
+ });
90
+ }
@@ -0,0 +1,62 @@
1
+ export const normalMerge = ['props'];
2
+ export const toArrayMerge = ['class', 'style', 'directives'];
3
+ export const functionalMerge = ['on', 'hook'];
4
+
5
+ const mergeProps = (objects, initial = {}, opt = {}) => {
6
+ const _normalMerge = [...normalMerge, ...opt['normal'] || []];
7
+ const _toArrayMerge = [...toArrayMerge, ...opt['array'] || []];
8
+ const _functionalMerge = [...functionalMerge, ...opt['functional'] || []];
9
+ const propsMerge = opt['props'] || [];
10
+
11
+ return objects.reduce((a, b) => {
12
+ for (const key in b) {
13
+ if (a[key]) {
14
+ if (propsMerge.indexOf(key) > -1) {
15
+ a[key] = mergeProps([b[key]], a[key]);
16
+ } else if (_normalMerge.indexOf(key) > -1) {
17
+ a[key] = {...a[key], ...b[key]}
18
+ } else if (_toArrayMerge.indexOf(key) > -1) {
19
+ const arrA = a[key] instanceof Array ? a[key] : [a[key]];
20
+ const arrB = b[key] instanceof Array ? b[key] : [b[key]];
21
+ a[key] = [...arrA, ...arrB]
22
+ } else if (_functionalMerge.indexOf(key) > -1) {
23
+ for (const event in b[key]) {
24
+ if (a[key][event]) {
25
+ const arrA = a[key][event] instanceof Array ? a[key][event] : [a[key][event]];
26
+ const arrB = b[key][event] instanceof Array ? b[key][event] : [b[key][event]];
27
+ a[key][event] = [...arrA, ...arrB]
28
+ } else {
29
+ a[key][event] = b[key][event]
30
+ }
31
+ }
32
+ } else if (key === 'hook') {
33
+ for (let hook in b[key]) {
34
+ if (a[key][hook]) {
35
+ a[key][hook] = mergeFn(a[key][hook], b[key][hook])
36
+ } else {
37
+ a[key][hook] = b[key][hook]
38
+ }
39
+ }
40
+ } else {
41
+ a[key] = b[key]
42
+ }
43
+ } else {
44
+ if (_normalMerge.indexOf(key) > -1 || _functionalMerge.indexOf(key) > -1 || propsMerge.indexOf(key) > -1) {
45
+ a[key] = {...b[key]}
46
+ } else if (_toArrayMerge.indexOf(key) > -1) {
47
+ a[key] = b[key] instanceof Array ? [...b[key]] : (typeof b[key] === 'object' ? {...b[key]} : b[key]);
48
+ } else
49
+ a[key] = b[key];
50
+ }
51
+ }
52
+ return a
53
+ }, initial);
54
+ }
55
+
56
+ const mergeFn = (fn1, fn2) =>
57
+ function () {
58
+ fn1 && fn1.apply(this, arguments);
59
+ fn2 && fn2.apply(this, arguments);
60
+ };
61
+
62
+ export default mergeProps;
@@ -0,0 +1,43 @@
1
+ // https://github.com/developit/mitt
2
+
3
+ export default function Mitt(all) {
4
+ all = all || new Map();
5
+
6
+ const mitt = {
7
+
8
+ $on(type, handler) {
9
+ const handlers = all.get(type);
10
+ const added = handlers && handlers.push(handler);
11
+ if (!added) {
12
+ all.set(type, [handler]);
13
+ }
14
+ },
15
+
16
+ $once(type, handler) {
17
+ handler._once = true;
18
+ mitt.$on(type, handler);
19
+ },
20
+
21
+ $off(type, handler) {
22
+ const handlers = all.get(type);
23
+ if (handlers) {
24
+ handlers.splice(handlers.indexOf(handler) >>> 0, 1);
25
+ }
26
+ },
27
+
28
+ $emit(type, ...args) {
29
+ (all.get(type) || []).slice().map((handler) => {
30
+ if (handler._once) {
31
+ mitt.$off(type, handler);
32
+ delete handler._once;
33
+ }
34
+ handler(...args);
35
+ });
36
+ (all.get('*') || []).slice().map((handler) => {
37
+ handler(type, args);
38
+ });
39
+ }
40
+ };
41
+
42
+ return mitt;
43
+ }
@@ -0,0 +1,8 @@
1
+
2
+ export function $set(target, field, value) {
3
+ target[field] = value;
4
+ }
5
+
6
+ export function $del(target, field) {
7
+ delete target[field];
8
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * 从给定的 slots 对象中筛选出不需要排除的键值对,并返回一个新的对象。
3
+ *
4
+ * @param {Object} slots - 包含键值对的对象,键是字符串,值是函数。
5
+ * @param {Array} [exclude] - 可选的数组,包含需要排除的键。
6
+ * @returns {Object} - 包含不需要排除的键值对的新对象。
7
+ */
8
+ export default function getSlot(slots, exclude) {
9
+ // 使用 reduce 方法遍历 slots 对象的所有键
10
+ return Object.keys(slots).reduce((lst, name) => {
11
+ // 检查 exclude 是否存在,并且当前键是否不在 exclude 数组中
12
+ if (!exclude || exclude.indexOf(name) === -1) {
13
+ // 如果不需要排除,则将当前键值对添加到结果对象中
14
+ lst[name] = slots[name];
15
+ }
16
+ // 返回结果对象,继续下一次迭代
17
+ return lst;
18
+ }, {}); // 初始值为空对象
19
+ }
@@ -0,0 +1,5 @@
1
+ export default function toArray(value) {
2
+ return Array.isArray(value)
3
+ ? value
4
+ : ([null, undefined, ''].indexOf(value) > -1 ? [] : [value]);
5
+ }
@@ -0,0 +1,11 @@
1
+ export default function toCase(str) {
2
+ const to = str.replace(/(-[a-z])/g, function (v) {
3
+ return v.replace('-', '').toLocaleUpperCase();
4
+ });
5
+
6
+ return lower(to);
7
+ }
8
+
9
+ export function lower(str) {
10
+ return str.replace(str[0], str[0].toLowerCase());
11
+ }
@@ -0,0 +1,10 @@
1
+ import is from './type';
2
+
3
+ export default function toDate(timeStamp) {
4
+ if (is.Date(timeStamp))
5
+ return timeStamp;
6
+ else {
7
+ let date = new Date(timeStamp);
8
+ return date.toString() === 'Invalid Date' ? timeStamp : date;
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ export default function toLine(name) {
2
+ let line = name.replace(/([A-Z])/g, '-$1').toLocaleLowerCase();
3
+ if (line.indexOf('-') === 0)
4
+ line = line.substr(1);
5
+ return line;
6
+ }
7
+
8
+ export function upper(str) {
9
+ return str.replace(str[0], str[0].toLocaleUpperCase());
10
+ }
@@ -0,0 +1,7 @@
1
+ export default function toString(val) {
2
+ return val == null
3
+ ? ''
4
+ : typeof val === 'object'
5
+ ? JSON.stringify(val, null, 2)
6
+ : String(val)
7
+ }
@@ -0,0 +1,45 @@
1
+ const is = {
2
+ type(arg, type) {
3
+ return Object.prototype.toString.call(arg) === '[object ' + type + ']'
4
+ },
5
+ Undef(v) {
6
+ return v === undefined || v === null
7
+ },
8
+ Element(arg) {
9
+ return typeof arg === 'object' && arg !== null && arg.nodeType === 1 && !is.Object(arg)
10
+ },
11
+ trueArray(data) {
12
+ return Array.isArray(data) && data.length > 0;
13
+ },
14
+ Function(v) {
15
+ const type = this.getType(v);
16
+ return type === 'Function' || type === 'AsyncFunction';
17
+ },
18
+ getType(v) {
19
+ const str = Object.prototype.toString.call(v)
20
+ return /^\[object (.*)\]$/.exec(str)[1]
21
+ },
22
+ empty(value) {
23
+ if (value === undefined || value === null) {
24
+ return true;
25
+ }
26
+
27
+ if (Array.isArray(value) && Array.isArray(value) && !value.length) {
28
+ return true;
29
+ }
30
+
31
+ return typeof value === 'string' && !value;
32
+ }
33
+ };
34
+
35
+ ['Date', 'Object', 'String', 'Boolean', 'Array', 'Number'].forEach(t => {
36
+ is[t] = function (arg) {
37
+ return is.type(arg, t);
38
+ }
39
+ })
40
+
41
+ export function hasProperty(rule, k) {
42
+ return ({}).hasOwnProperty.call(rule, k)
43
+ }
44
+
45
+ export default is;
@@ -0,0 +1,6 @@
1
+ let id = 0;
2
+
3
+ export default function uniqueId() {
4
+ const num = 370 + (++id);
5
+ return 'F' + Math.random().toString(36).substr(3, 3) + Number(`${Date.now()}`).toString(36) + num.toString(36) + 'c';
6
+ }
@@ -0,0 +1,166 @@
1
+ import { ElMessage, ElMessageBox, ElNotification, ElLoading, ElButton, ElIcon } from 'element-plus'
2
+ import { Warning } from '@element-plus/icons-vue'
3
+ import { h } from 'vue'
4
+ // !!!如果有方法报错 在执行方法外面添加nextTrick函数处理
5
+ export function showsuccess(msg, duration = 3000, showClose = true) {
6
+ ElMessage({
7
+ message: msg || '保存成功',
8
+ type: 'success',
9
+ duration: duration,
10
+ showClose: showClose
11
+ })
12
+ }
13
+
14
+ export function showerror(msg, duration = 3000, showClose = true) {
15
+ ElMessage({
16
+ message: msg || '保存失败',
17
+ type: 'error',
18
+ duration: duration,
19
+ showClose: showClose
20
+ })
21
+ }
22
+
23
+ export function showwarning(msg, duration = 3000, showClose = true, clostFn) {
24
+ ElMessage({
25
+ message: msg || '警告内容',
26
+ type: 'warning',
27
+ duration: duration,
28
+ showClose: showClose,
29
+ onClose: clostFn
30
+ })
31
+ }
32
+
33
+ export function showinfo(msg, duration = 3000, showClose = true) {
34
+ ElMessage({
35
+ message: msg || '提示信息',
36
+ duration: duration,
37
+ showClose: showClose
38
+ })
39
+ }
40
+
41
+ export function hideloading(msg) {
42
+ ElMessage.closeAll()
43
+ }
44
+
45
+ export function showconfirm(done, confirmtitle = '确认关闭?', showtext = { title: '提示', confirmButtonText: '确定', cancelButtonText: '取消' }, cancle) {
46
+ return ElMessageBox.confirm(confirmtitle, showtext.title, {
47
+ confirmButtonText: showtext.confirmButtonText,
48
+ cancelButtonText: showtext.cancelButtonText,
49
+ distinguishCancelAndClose: true,
50
+ type: 'warning'
51
+ })
52
+ .then((_) => {
53
+ done(_)
54
+ })
55
+ .catch((_) => {
56
+ console.info('showconfirm catch')
57
+ console.info(_)
58
+ cancle && cancle(_)
59
+ })
60
+ }
61
+
62
+ /**
63
+ * 信息提示框
64
+ * @param {*} msg
65
+ * @param {*} type
66
+ * @param {*} title
67
+ * @param {*} position
68
+ * @param {*} dangerouslyUseHTMLString
69
+ */
70
+ export function shownotiinfo(msg, type = 'info',title='提示',position='bottom-right',dangerouslyUseHTMLString=false) {
71
+ ElNotification({
72
+ title: title,
73
+ position: position,
74
+ message: msg,
75
+ dangerouslyUseHTMLString:dangerouslyUseHTMLString,
76
+ type: type
77
+ })
78
+ }
79
+
80
+ export function showconfirminfo(
81
+ msg = '确认删除?',
82
+ showtext = { type: '', position: 'bottom-right', title: '提示', dangerouslyUseHTMLString: true },
83
+ fn1,
84
+ fn2
85
+ ) {
86
+ // 按钮
87
+ const btn1 = h(ElButton, {
88
+ innerText: '立即刷新',
89
+ type: 'primary',
90
+ size: 'small',
91
+ style: { marginLeft: '16px', float: 'right' },
92
+ onclick: (_) => {
93
+ fn1(_)
94
+ }
95
+ })
96
+ const btn2 = h(ElButton, {
97
+ innerText: '暂不更新',
98
+ style: { float: 'right' },
99
+ size: 'small',
100
+ onclick: (_) => {
101
+ fn2(_)
102
+ }
103
+ })
104
+ // 信息div
105
+ const div = h('div', { style: { marginLeft: '8px', marginBottom: '16px', marginTop: '16px' } }, msg)
106
+ // 图标
107
+ const icon1 = h(Warning)
108
+ const icon = h(ElIcon, { style: { fontSize: '18px' } }, [icon1])
109
+ // 整体div
110
+ const msgDiv = h('div', { style: { display: 'flex', alignItems: 'center' } }, [icon, div])
111
+ ElNotification({
112
+ class: 'custom-notification',
113
+ title: showtext.title,
114
+ position: showtext.position,
115
+ dangerouslyUseHTMLString: showtext.dangerouslyUseHTMLString,
116
+ message: h('div', [msgDiv, btn1, btn2]),
117
+ type: showtext.type,
118
+ duration: 0,
119
+ showClose: false
120
+ })
121
+ }
122
+
123
+ export function showalert(done, alertMsg = 'This is a message', type = 'info', showtext = { title: '提示', confirmButtonText: '确定' }) {
124
+ return ElMessageBox.alert(alertMsg, showtext.title, {
125
+ confirmButtonText: showtext.confirmButtonText,
126
+ type: type
127
+ })
128
+ .then((_) => {
129
+ done(_)
130
+ })
131
+ .catch((_) => {
132
+ console.info('showalert catch')
133
+ console.info(_)
134
+ })
135
+ }
136
+
137
+ export function confirm(confirmtitle = '确认关闭?') {
138
+ return ElMessageBox.confirm(confirmtitle)
139
+ }
140
+
141
+
142
+ export function showloading(msg, duration = 0, showClose = true) {
143
+ ElMessage({
144
+ // <svg viewBox="0 0 1024 1024" focusable="false" data-icon="loading" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"></path></svg>
145
+ icon: 'loadsvg',
146
+ message: msg || '正在保存,请稍后...',
147
+ duration: duration,
148
+ showClose: showClose
149
+ })
150
+ }
151
+
152
+ // loading加载 closeLoading
153
+ let loadingObj = null
154
+ export function showLoading(msg) {
155
+ loadingObj = ElLoading.service({
156
+ lock: true,
157
+ text: msg || '加载中...',
158
+ spinner: 'el-icon-loading',
159
+ background: 'rgba(0, 0, 0, 0.7)'
160
+ })
161
+ }
162
+
163
+ export function closeLoading() {
164
+ loadingObj.close()
165
+ }
166
+ export { ElMessage, ElMessageBox, ElNotification, ElLoading }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@bdsoft-element/utils",
3
+ "version": "1.0.1",
4
+ "description": "",
5
+ "main": "./index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "files": [
10
+ "README.md",
11
+ "package.json"
12
+ ],
13
+ "keywords": [],
14
+ "author": "lbq",
15
+ "license": "MIT"
16
+ }
package/utils/type.js ADDED
@@ -0,0 +1,45 @@
1
+ const is = {
2
+ type(arg, type) {
3
+ return Object.prototype.toString.call(arg) === '[object ' + type + ']'
4
+ },
5
+ Undef(v) {
6
+ return v === undefined || v === null
7
+ },
8
+ Element(arg) {
9
+ return typeof arg === 'object' && arg !== null && arg.nodeType === 1 && !is.Object(arg)
10
+ },
11
+ trueArray(data) {
12
+ return Array.isArray(data) && data.length > 0;
13
+ },
14
+ Function(v) {
15
+ const type = this.getType(v);
16
+ return type === 'Function' || type === 'AsyncFunction';
17
+ },
18
+ getType(v) {
19
+ const str = Object.prototype.toString.call(v)
20
+ return /^\[object (.*)\]$/.exec(str)[1]
21
+ },
22
+ empty(value) {
23
+ if (value === undefined || value === null) {
24
+ return true;
25
+ }
26
+
27
+ if (Array.isArray(value) && Array.isArray(value) && !value.length) {
28
+ return true;
29
+ }
30
+
31
+ return typeof value === 'string' && !value;
32
+ }
33
+ };
34
+
35
+ ['Date', 'Object', 'String', 'Boolean', 'Array', 'Number'].forEach(t => {
36
+ is[t] = function (arg) {
37
+ return is.type(arg, t);
38
+ }
39
+ })
40
+
41
+ export function hasProperty(rule, k) {
42
+ return ({}).hasOwnProperty.call(rule, k)
43
+ }
44
+
45
+ export default is;