@opentiny/vue-renderless 3.21.2 → 3.23.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 (331) hide show
  1. package/amount/index.js +4 -4
  2. package/anchor/index.js +1 -1
  3. package/async-flowchart/index.js +1 -1
  4. package/autocomplete/index.js +4 -1
  5. package/autocomplete/vue.js +3 -3
  6. package/base-select/index.js +20 -21
  7. package/base-select/vue.js +2 -2
  8. package/calendar/index.js +2 -2
  9. package/calendar-bar/index.js +2 -2
  10. package/calendar-bar/vue.js +1 -1
  11. package/calendar-view/index.js +91 -25
  12. package/calendar-view/vue.js +6 -4
  13. package/card/index.js +1 -1
  14. package/card-template/index.js +1 -1
  15. package/carousel/index.js +4 -4
  16. package/carousel/vue.js +1 -1
  17. package/cascader/index.js +21 -11
  18. package/cascader/vue.js +6 -5
  19. package/cascader-menu/vue.js +2 -2
  20. package/cascader-mobile/index.js +1 -1
  21. package/cascader-node/vue.js +11 -1
  22. package/cascader-panel/index.js +4 -4
  23. package/cascader-panel/node.js +3 -4
  24. package/cascader-panel/vue.js +1 -1
  25. package/cascader-select/column-index.js +2 -2
  26. package/cascader-view/index.js +1 -1
  27. package/chart-bar/index.js +1 -1
  28. package/chart-candle/index.js +1 -1
  29. package/chart-core/deps/utils.js +6 -6
  30. package/chart-core/index.js +1 -1
  31. package/chart-funnel/index.js +1 -1
  32. package/chart-gauge/index.js +1 -1
  33. package/chart-line/index.js +1 -1
  34. package/chart-map/index.js +1 -1
  35. package/chart-pie/index.js +1 -1
  36. package/chart-radar/index.js +1 -1
  37. package/chart-sankey/index.js +1 -1
  38. package/chart-scatter/index.js +1 -1
  39. package/chart-waterfall/index.js +1 -1
  40. package/chart-wordcloud/index.js +1 -1
  41. package/checkbox/index.js +1 -1
  42. package/collapse-item/vue.js +1 -1
  43. package/column-list-item/index.js +1 -1
  44. package/common/deps/dom.js +20 -196
  45. package/common/deps/infinite-scroll.js +4 -43
  46. package/common/deps/popup-manager.js +1 -200
  47. package/container/index.js +2 -2
  48. package/crop/index.js +3 -3
  49. package/currency/index.js +2 -2
  50. package/date-panel/index.js +82 -26
  51. package/date-panel/vue.js +53 -21
  52. package/date-picker/vue.js +1 -1
  53. package/date-picker-mobile/index.js +1 -1
  54. package/date-range/index.js +74 -37
  55. package/date-range/vue.js +27 -23
  56. package/date-table/index.js +8 -5
  57. package/date-table/vue.js +1 -1
  58. package/dialog-box/index.js +3 -3
  59. package/dialog-box/vue.js +1 -1
  60. package/dialog-select/index.js +15 -4
  61. package/dialog-select/vue.js +7 -4
  62. package/drawer/index.js +2 -2
  63. package/drop-times/index.js +1 -1
  64. package/dropdown/index.js +11 -3
  65. package/dropdown/vue.js +2 -2
  66. package/dropdown-item/index.js +1 -1
  67. package/dropdown-item/mf.js +1 -1
  68. package/dropdown-menu/index.js +1 -1
  69. package/espace/vue.js +2 -2
  70. package/fall-menu/index.js +3 -3
  71. package/file-upload/index.js +16 -13
  72. package/file-upload/vue.js +2 -2
  73. package/filter/vue.js +1 -1
  74. package/filter-panel/vue.js +1 -2
  75. package/floating-button/index.js +1 -1
  76. package/flowchart/index.js +3 -3
  77. package/flowchart/vue.js +1 -1
  78. package/fluent-editor/index.js +5 -7
  79. package/fluent-editor/options.js +2 -2
  80. package/form/index.js +20 -2
  81. package/form-item/index.js +6 -6
  82. package/fullscreen/index.js +1 -1
  83. package/fullscreen/vue.js +1 -1
  84. package/grid/plugins/export.js +8 -2
  85. package/grid/plugins/exportExcel.js +3 -3
  86. package/grid/plugins/resize.js +2 -2
  87. package/grid/static/base/helperEqualCompare.js +1 -1
  88. package/grid/static/base/isPlainObject.js +1 -1
  89. package/grid/utils/common.js +2 -2
  90. package/grid/utils/dom.js +12 -7
  91. package/grid/utils/event.js +4 -4
  92. package/hrapprover/index.js +1 -1
  93. package/image/index.js +3 -3
  94. package/image-viewer/index.js +4 -6
  95. package/image-viewer/vue.js +1 -1
  96. package/input/index.js +2 -2
  97. package/input/vue.js +1 -1
  98. package/ip-address/index.js +17 -21
  99. package/ip-address/vue.js +1 -1
  100. package/link-menu/index.js +1 -1
  101. package/link-menu/vue.js +1 -1
  102. package/load-list/index.js +1 -1
  103. package/load-list/vue.js +4 -4
  104. package/loading/index.js +2 -2
  105. package/menu/vue.js +1 -1
  106. package/milestone/index.js +6 -45
  107. package/modal/index.js +5 -5
  108. package/month-range/index.js +48 -5
  109. package/month-range/vue.js +19 -15
  110. package/month-table/index.js +5 -5
  111. package/month-table/vue.js +1 -1
  112. package/nav-menu/index.js +7 -7
  113. package/notify/index.js +3 -3
  114. package/number-animation/index.js +53 -0
  115. package/number-animation/vue.js +27 -0
  116. package/numeric/index.js +5 -5
  117. package/option/index.js +1 -1
  118. package/option/vue.js +2 -1
  119. package/package.json +3 -2
  120. package/pager/index.js +28 -16
  121. package/pager/vue.js +27 -16
  122. package/panel/index.js +1 -1
  123. package/picker/index.js +28 -23
  124. package/picker/vue.js +6 -6
  125. package/picker-column/index.js +1 -1
  126. package/pop-upload/vue.js +1 -1
  127. package/popconfirm/vue.js +1 -1
  128. package/popeditor/index.js +6 -6
  129. package/popeditor/vue.js +2 -2
  130. package/popover/index.js +3 -3
  131. package/popover/vue.js +1 -1
  132. package/popup/index.js +3 -3
  133. package/pull-refresh/index.js +1 -1
  134. package/pull-refresh-mobile-first/index.js +1 -1
  135. package/pull-refresh-mobile-first/vue.js +4 -4
  136. package/quarter-panel/index.js +2 -2
  137. package/quarter-panel/vue.js +1 -1
  138. package/radio-group/index.js +1 -1
  139. package/rate/index.js +1 -1
  140. package/rate/vue.js +1 -1
  141. package/recycle-scroller/index.js +2 -2
  142. package/recycle-scroller/vue.js +1 -1
  143. package/rich-text/index.js +1 -1
  144. package/rich-text/table-module.js +2 -2
  145. package/river/river.js +1 -1
  146. package/river/vue.js +1 -1
  147. package/scrollbar/vue-bar.js +1 -1
  148. package/scrollbar/vue.js +1 -1
  149. package/search/index.js +3 -3
  150. package/select/index.js +26 -22
  151. package/select/vue.js +8 -7
  152. package/select-dropdown/vue.js +5 -5
  153. package/selected-box/index.js +1 -1
  154. package/signature/index.js +1 -1
  155. package/signature/vue.js +2 -2
  156. package/skeleton/index.js +1 -1
  157. package/slider/index.js +4 -4
  158. package/slider-button-group/slide-button.js +2 -2
  159. package/split/index.js +2 -2
  160. package/split/vue.js +1 -1
  161. package/statistic/index.js +1 -1
  162. package/steps/index.js +2 -3
  163. package/steps/slide-bar.js +2 -2
  164. package/sticky/vue.js +4 -4
  165. package/tab-bar/index.js +2 -2
  166. package/tab-item-mf/vue.js +1 -1
  167. package/tab-nav/index.js +4 -4
  168. package/tabbar/index.js +1 -1
  169. package/tabbar/vue.js +1 -1
  170. package/tabbar-item/index.js +1 -1
  171. package/tabs-mf/index.js +9 -5
  172. package/tabs-mf/vue-bar.js +5 -4
  173. package/tabs-mf/vue-swipe.js +1 -1
  174. package/tabs-mf/vue.js +2 -2
  175. package/tabs-mf/wheel.js +3 -3
  176. package/tag-group/vue.js +2 -2
  177. package/tall-storage/index.js +1 -1
  178. package/tall-storage/vue.js +1 -1
  179. package/time/index.js +1 -1
  180. package/time/vue.js +1 -1
  181. package/time-line/index.js +1 -1
  182. package/time-line-new/index.js +1 -1
  183. package/time-panel/index.js +2 -2
  184. package/time-panel/vue.js +1 -1
  185. package/time-range/index.js +1 -1
  186. package/time-range/vue.js +1 -1
  187. package/time-spinner/index.js +4 -4
  188. package/time-spinner/vue.js +1 -1
  189. package/timeline-item/index.js +1 -1
  190. package/toggle-menu/index.js +1 -1
  191. package/tooltip/index.js +2 -2
  192. package/tooltip/vue.js +2 -2
  193. package/top-box/index.js +3 -3
  194. package/transfer/index.js +42 -1
  195. package/transfer/vue.js +64 -24
  196. package/transfer-panel/index.js +6 -1
  197. package/tree/index.js +9 -9
  198. package/tree/vue.js +2 -2
  199. package/tree-node/index.js +1 -1
  200. package/tree-node/vue.js +1 -1
  201. package/tree-select/index.js +68 -22
  202. package/tree-select/vue.js +27 -3
  203. package/types/async-flowchart.type.d.ts +2 -14
  204. package/types/breadcrumb-item.type.d.ts +5 -1
  205. package/types/breadcrumb.type.d.ts +5 -1
  206. package/types/button-group.type.d.ts +5 -1
  207. package/types/button.type.d.ts +2 -2
  208. package/types/cascader.type.d.ts +6 -1
  209. package/types/date-table.type.d.ts +1 -120
  210. package/types/dropdown.type.d.ts +1 -1
  211. package/types/label.type.d.ts +1 -53
  212. package/types/loading.type.d.ts +12 -0
  213. package/types/numeric.type.d.ts +3 -22
  214. package/types/pager.type.d.ts +12 -7
  215. package/types/popconfirm.type.d.ts +2 -0
  216. package/types/steps.type.d.ts +1 -0
  217. package/types/tag-group.type.d.ts +2 -14
  218. package/types/tag.type.d.ts +4 -4
  219. package/types/tooltip.type.d.ts +3 -13
  220. package/types/transfer.type.d.ts +3 -0
  221. package/types/user-head.type.d.ts +0 -4
  222. package/upload/index.js +1 -1
  223. package/upload-list/index.js +1 -1
  224. package/upload-list/vue.js +4 -4
  225. package/user/index.js +7 -7
  226. package/user/vue.js +15 -2
  227. package/user-contact/vue.js +2 -2
  228. package/virtual-scroll-box/index.js +2 -2
  229. package/wizard/index.js +3 -3
  230. package/year-range/index.js +61 -11
  231. package/year-range/vue.js +33 -20
  232. package/year-table/index.js +10 -5
  233. package/avatar/index.js +0 -30
  234. package/avatar/vue.js +0 -22
  235. package/common/array.js +0 -115
  236. package/common/bigInt.js +0 -315
  237. package/common/browser.js +0 -81
  238. package/common/calendar/calendar.js +0 -97
  239. package/common/dataset/index.js +0 -99
  240. package/common/date.js +0 -354
  241. package/common/decimal.js +0 -155
  242. package/common/deps/ResizeObserver.js +0 -456
  243. package/common/deps/after-leave.js +0 -27
  244. package/common/deps/clickoutside.js +0 -75
  245. package/common/deps/date-util.js +0 -255
  246. package/common/deps/date.js +0 -286
  247. package/common/deps/debounce.js +0 -8
  248. package/common/deps/eSpaceCtrl.js +0 -304
  249. package/common/deps/fastdom/async.js +0 -41
  250. package/common/deps/fastdom/index.js +0 -9
  251. package/common/deps/fastdom/sandbox.js +0 -53
  252. package/common/deps/fastdom/singleton.js +0 -88
  253. package/common/deps/fullscreen/apis.js +0 -143
  254. package/common/deps/fullscreen/screenfull.js +0 -165
  255. package/common/deps/memorize.js +0 -124
  256. package/common/deps/observe-visibility.js +0 -106
  257. package/common/deps/popper.js +0 -616
  258. package/common/deps/repeat-click.js +0 -29
  259. package/common/deps/resize-event.js +0 -39
  260. package/common/deps/scroll-into-view.js +0 -29
  261. package/common/deps/scrollbar-width.js +0 -33
  262. package/common/deps/throttle.js +0 -45
  263. package/common/deps/touch-emulator.js +0 -103
  264. package/common/deps/touch.js +0 -37
  265. package/common/deps/tree-model/node.js +0 -475
  266. package/common/deps/tree-model/tree-store.js +0 -312
  267. package/common/deps/tree-model/util.js +0 -24
  268. package/common/deps/upload-ajax.js +0 -81
  269. package/common/deps/useEventListener.js +0 -54
  270. package/common/deps/useInstanceSlots.js +0 -22
  271. package/common/deps/useRect.js +0 -25
  272. package/common/deps/useRelation.js +0 -89
  273. package/common/deps/useTouch.js +0 -68
  274. package/common/deps/useUserAgent.js +0 -16
  275. package/common/deps/useWindowSize.js +0 -23
  276. package/common/deps/vue-emitter.js +0 -34
  277. package/common/deps/vue-popper.js +0 -180
  278. package/common/deps/vue-popup.js +0 -138
  279. package/common/event.js +0 -46
  280. package/common/form/const.js +0 -10
  281. package/common/function.js +0 -28
  282. package/common/global.js +0 -11
  283. package/common/index.js +0 -259
  284. package/common/object.js +0 -227
  285. package/common/prop-util.js +0 -43
  286. package/common/runtime.js +0 -79
  287. package/common/string.js +0 -417
  288. package/common/type.js +0 -66
  289. package/common/validate/index.js +0 -10
  290. package/common/validate/messages.js +0 -65
  291. package/common/validate/rules/enum.js +0 -12
  292. package/common/validate/rules/index.js +0 -18
  293. package/common/validate/rules/pattern.js +0 -20
  294. package/common/validate/rules/range.js +0 -52
  295. package/common/validate/rules/required.js +0 -11
  296. package/common/validate/rules/type.js +0 -100
  297. package/common/validate/rules/whitespace.js +0 -10
  298. package/common/validate/schema.js +0 -290
  299. package/common/validate/util.js +0 -211
  300. package/common/validate/validations/array.js +0 -22
  301. package/common/validate/validations/date.js +0 -31
  302. package/common/validate/validations/enum.js +0 -22
  303. package/common/validate/validations/float.js +0 -22
  304. package/common/validate/validations/index.js +0 -46
  305. package/common/validate/validations/integer.js +0 -22
  306. package/common/validate/validations/method.js +0 -21
  307. package/common/validate/validations/number.js +0 -25
  308. package/common/validate/validations/pattern.js +0 -21
  309. package/common/validate/validations/required.js +0 -11
  310. package/common/validate/validations/string.js +0 -33
  311. package/common/validate/validations/type.js +0 -29
  312. package/index-bar/index.js +0 -66
  313. package/index-bar/vue.js +0 -73
  314. package/index-bar-anchor/vue.js +0 -16
  315. package/label/index.js +0 -56
  316. package/label/vue.js +0 -26
  317. package/list/index.js +0 -13
  318. package/list/vue.js +0 -17
  319. package/mask/index.js +0 -13
  320. package/mask/vue.js +0 -18
  321. package/mini-picker/index.js +0 -165
  322. package/mini-picker/vue.js +0 -122
  323. package/multi-select/index.js +0 -394
  324. package/multi-select/vue.js +0 -113
  325. package/multi-select-item/index.js +0 -23
  326. package/multi-select-item/vue.js +0 -31
  327. package/toast/index.js +0 -7
  328. package/toast/vue.js +0 -19
  329. package/types/toast.type.d.ts +0 -63
  330. package/wheel/index.js +0 -165
  331. package/wheel/vue.js +0 -79
package/common/string.js DELETED
@@ -1,417 +0,0 @@
1
- import "../chunk-G2ADBYYC.js";
2
- import { isPlainObject, isNumber, isNumeric, isNull } from "./type";
3
- import { getObj, toJsonStr } from "./object";
4
- import { toFixed, Decimal } from "./decimal";
5
- import { globalEnvironment, isBrowser } from "./browser";
6
- const formatTypes = {
7
- text: "text",
8
- url: "url",
9
- html: "html",
10
- tmpl: "tmpl"
11
- };
12
- const escapeChars = {
13
- "&": "&",
14
- "<": "&#60;",
15
- ">": "&#62;",
16
- '"': "&#34;",
17
- "'": "&#x27;",
18
- "[": "&#91;",
19
- "]": "&#93;"
20
- };
21
- const isNullOrEmpty = (value) => value === null || value === void 0 || typeof value === "string" && value.trim().length === 0;
22
- function cached(fn) {
23
- let cache = /* @__PURE__ */ Object.create(null);
24
- return function cachedFn(str) {
25
- const hit = cache[str];
26
- return hit || (cache[str] = fn(str));
27
- };
28
- }
29
- const camelizeRE = /-(\w)/g;
30
- const camelize = cached((str) => str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : ""));
31
- const capitalize = cached((str) => str.charAt(0).toUpperCase() + str.slice(1));
32
- const hyphenateRE = /\B([A-Z])/g;
33
- const hyphenate = cached((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
34
- const toJson = (string) => {
35
- try {
36
- return JSON.parse(string);
37
- } catch (e) {
38
- return void 0;
39
- }
40
- };
41
- function getLengthInUtf16(string) {
42
- const len = string.length;
43
- let count = 0;
44
- for (let i = 0; i < len; i++) {
45
- let charCode = string.charCodeAt(i);
46
- if (charCode <= 65535) {
47
- count += 2;
48
- } else {
49
- count += 4;
50
- }
51
- }
52
- return count;
53
- }
54
- function getLengthInUtf8(string) {
55
- const len = string.length;
56
- let count = 0;
57
- for (let i = 0; i < len; i++) {
58
- let charCode = string.charCodeAt(i);
59
- if (charCode <= 127) {
60
- count += 1;
61
- } else if (charCode <= 2047) {
62
- count += 2;
63
- } else if (charCode <= 65535) {
64
- count += 3;
65
- } else {
66
- count += 4;
67
- }
68
- }
69
- return count;
70
- }
71
- function getLengthDefault(string) {
72
- const len = string.length;
73
- let count = 0;
74
- for (let i = 0; i < len; i++) {
75
- count++;
76
- if (string.charCodeAt(i) >> 8) {
77
- count++;
78
- }
79
- }
80
- return count;
81
- }
82
- const getLength = (string, regular) => {
83
- if (!string || typeof string !== "string") {
84
- return 0;
85
- }
86
- let count = 0;
87
- if (typeof regular === "string") {
88
- regular = regular.toLowerCase();
89
- if (regular === "utf-16" || regular === "utf16") {
90
- count = getLengthInUtf16(string);
91
- } else if (regular === "utf-8" || regular === "utf8") {
92
- count = getLengthInUtf8(string);
93
- } else {
94
- count = string.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "_").length;
95
- }
96
- } else if (typeof regular === "function") {
97
- return regular(string);
98
- } else {
99
- count = getLengthDefault(string);
100
- }
101
- return count;
102
- };
103
- const fillChar = (string, length, append, chr = "0") => {
104
- if (typeof string === "string" && typeof chr === "string" && isNumber(length)) {
105
- let len = string.length - length;
106
- if (len > 0) {
107
- return append ? string.substr(0, length) : string.substr(len, length);
108
- } else {
109
- const appendStr = [];
110
- len = Math.abs(len) / chr.length;
111
- for (; len > 0; len--) {
112
- appendStr.push(chr);
113
- }
114
- const s = appendStr.join("");
115
- return append ? string + s : s + string;
116
- }
117
- }
118
- };
119
- const random = () => {
120
- let MAX_UINT32_PLUS_ONE = 4294967296;
121
- return globalEnvironment.crypto.getRandomValues(new globalEnvironment.Uint32Array(1))[0] / MAX_UINT32_PLUS_ONE;
122
- };
123
- const guid = (prefix = "", length = 8) => prefix + random().toString().substr(2, length);
124
- const escapeHtml = (string, isReplaceSpace) => {
125
- if (!string || typeof string !== "string") {
126
- return string;
127
- }
128
- string = string.replace(/[&<>"']/g, (chr) => escapeChars[chr]);
129
- return isReplaceSpace ? string.replace(/\s/g, "&#160;") : string;
130
- };
131
- const escape = (string, escapeType, isReplaceSpace) => {
132
- if (!string || typeof string !== "string") {
133
- return string;
134
- }
135
- if (typeof escapeType === "boolean") {
136
- isReplaceSpace = !!escapeType;
137
- }
138
- if (escapeType === "uri") {
139
- return encodeURIComponent(string);
140
- } else if (escapeType === "html") {
141
- return escapeHtml(string, isReplaceSpace);
142
- } else if (escapeType === "prop") {
143
- string = escapeHtml(string, isReplaceSpace);
144
- return string.replace(/[[\]]/g, (chr) => escapeChars[chr]);
145
- }
146
- string = string.replace(/[<>"]/g, (chr) => escapeChars[chr]);
147
- return isReplaceSpace ? string.replace(/\s/g, "&#160;") : string;
148
- };
149
- const getFormat = ({ sign, format: format2, hasSign }) => {
150
- switch (sign) {
151
- case "#":
152
- format2 = formatTypes.text;
153
- break;
154
- case "@":
155
- format2 = formatTypes.url;
156
- break;
157
- case "$":
158
- format2 = formatTypes.html;
159
- break;
160
- case "%":
161
- format2 = formatTypes.tmpl;
162
- break;
163
- default:
164
- hasSign = false;
165
- break;
166
- }
167
- return { format: format2, hasSign };
168
- };
169
- const fieldFormat = (string, data, type = "html") => {
170
- if (typeof string === "string") {
171
- return string.replace(/(\/)?\{\{([\s\S]*?)}}/g, (match, slash = "", offset = "") => {
172
- const sign = offset.substr(0, 1);
173
- let hasSign = true;
174
- let format2 = formatTypes.html;
175
- let ret = getFormat({ sign, format: format2, hasSign });
176
- format2 = ret.format;
177
- hasSign = ret.hasSign;
178
- if (hasSign) {
179
- offset = (offset || "").substring(1);
180
- } else if (type) {
181
- format2 = type;
182
- }
183
- let value = getObj(data, offset);
184
- if (isNull(value)) {
185
- value = "";
186
- }
187
- if (format2 === formatTypes.tmpl) {
188
- value = `{{${value}}}`;
189
- } else {
190
- if (format2 === formatTypes.url) {
191
- value = encodeURIComponent(value);
192
- } else {
193
- value = format2 === formatTypes.html ? escapeHtml(value) : value;
194
- }
195
- }
196
- return format2 === formatTypes.url && value.length === 0 ? "" : slash + value;
197
- });
198
- }
199
- };
200
- const getFormatText = () => (str, reg, args, format2) => str.replace(reg, (m, i, j, k) => {
201
- if (!isNullOrEmpty(i) && !isNullOrEmpty(k)) {
202
- return `{${j}}`;
203
- }
204
- const value = args[j];
205
- const string = isPlainObject(value) ? toJsonStr(value) : value;
206
- if (isNullOrEmpty(value)) {
207
- return "";
208
- }
209
- return typeof value === "string" && typeof format2 === "function" ? format2(string) : string;
210
- });
211
- const getResult = ({ type, res, formatText, string, reg, args }) => {
212
- if (type === formatTypes.url) {
213
- res = formatText(string, reg, args, encodeURIComponent);
214
- } else if (type === formatTypes.html) {
215
- res = formatText(string, reg, args, escapeHtml);
216
- } else {
217
- res = formatText(string, reg, args);
218
- }
219
- return res;
220
- };
221
- const judgForFunc = (args, formatTypes2, type) => {
222
- const lastArg = args[args.length - 1];
223
- if (lastArg !== formatTypes2.text && lastArg !== formatTypes2.url && lastArg !== formatTypes2.html) {
224
- args = Array.prototype.slice.call(args, 1);
225
- } else {
226
- args = Array.prototype.slice.call(args, 1, args.length - 1);
227
- type = lastArg;
228
- }
229
- return { args, type };
230
- };
231
- const checkParam = ({ data, args, type, _arguments }) => {
232
- if (Array.isArray(data)) {
233
- args = data;
234
- } else {
235
- const judgObj = judgForFunc(_arguments, formatTypes, type);
236
- args = judgObj.args;
237
- type = judgObj.type;
238
- }
239
- return { args, type };
240
- };
241
- const format = function(string, data, type = "text") {
242
- if (typeof string !== "string" || arguments.length < 2) {
243
- return string;
244
- }
245
- let args, res;
246
- if (isPlainObject(data)) {
247
- return fieldFormat(string, data, type);
248
- }
249
- const ret = checkParam({ data, args, type, _arguments: arguments });
250
- args = ret.args;
251
- type = ret.type;
252
- const reg = /(\\)?\{(\d+)(\\)?}/g;
253
- const formatText = getFormatText();
254
- res = getResult({ type, res, formatText, string, reg, args });
255
- return res;
256
- };
257
- const getTruthyValue = ({ string, length, ellipsis }) => {
258
- const flag = typeof string === "string" && isNumber(length) && length < string.length;
259
- const truthyValue = flag && format(ellipsis, string.substr(0, length));
260
- return { flag, truthyValue };
261
- };
262
- const truncate = (string, length, ellipsis = "{0}...") => {
263
- const { flag, truthyValue } = getTruthyValue({ string, length, ellipsis });
264
- return flag ? truthyValue : string;
265
- };
266
- const tryToConvert = (convert, defaultValue, ...args) => {
267
- const result = convert.apply(null, args);
268
- return isNaN(result) ? defaultValue : result;
269
- };
270
- const toInt = (value) => isNumber(value) ? Number(value.toFixed(0)) : typeof value === "string" ? parseInt(value, 10) : NaN;
271
- const tryToInt = (value, defaultValue) => tryToConvert(toInt, defaultValue, value);
272
- const toNumber = (value) => isNumber(value) ? value : typeof value === "string" ? parseFloat(value) : NaN;
273
- const tryToNumber = (value, defaultValue) => tryToConvert(toNumber, defaultValue, value);
274
- const toDecimal = (value, fraction = 2, isTruncate = false) => {
275
- let result = NaN;
276
- if (isNumber(value)) {
277
- result = value;
278
- }
279
- if (typeof value === "string") {
280
- const val = parseFloat(value);
281
- if (!isNaN(val)) {
282
- result = val;
283
- }
284
- }
285
- if (isNumber(result)) {
286
- if (isTruncate) {
287
- result = toFixed(
288
- value.toString().split(".").slice(0, 2).map((str, index) => index ? str.slice(0, fraction) : str).join("."),
289
- fraction
290
- );
291
- } else {
292
- result = toFixed(result, fraction);
293
- }
294
- }
295
- return result;
296
- };
297
- const tryToDecimal = (value, fraction, isTruncate, defaultValue) => tryToConvert(toDecimal, defaultValue, value, fraction, isTruncate);
298
- const toCurrency = (value, fraction, placeholder, isTruncate) => {
299
- if (isNumeric(value)) {
300
- let val = toDecimal(Number(value), fraction, isTruncate);
301
- val = String(val).replace(/(^|[^\w.])(\d{4,})/g, ($0, $1, $2) => $1 + $2.replace(/\d(?=(?:\d\d\d)+(?!\d))/g, "$&,"));
302
- return placeholder ? format(placeholder, val) : val;
303
- }
304
- return NaN;
305
- };
306
- const tryToCurrency = (value, fraction, placeholder, defaultValue) => isNaN(toNumber(value)) ? defaultValue : toCurrency(value, fraction, placeholder);
307
- const toBoolValue = (value) => {
308
- if (isNumber(value)) {
309
- return value ? 1 : 0;
310
- } else if (isNull(value) || value === "false") {
311
- return false;
312
- } else if (value === "true") {
313
- return true;
314
- } else if (typeof value === "boolean") {
315
- return value;
316
- }
317
- return !!value;
318
- };
319
- const toRate = (value, total = 1, fraction = 2) => isNumber(value) && isNumber(total) ? toDecimal(Decimal(value).mul(100).div(total).toNumber(), fraction) + "%" : value;
320
- const toFileSize = (value, unit, currUnit) => {
321
- if (isNumeric(value)) {
322
- value = Number(value);
323
- if (value === 0) {
324
- return `0${currUnit || unit || "B"}`;
325
- }
326
- const fileSize = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
327
- let index = fileSize.indexOf(currUnit);
328
- if (index > -1) {
329
- for (let i = 0; i < index; i++) {
330
- value *= 1024;
331
- }
332
- }
333
- index = fileSize.indexOf(unit);
334
- if (index < 0) {
335
- index = fileSize.length - 1;
336
- }
337
- let level = 0;
338
- for (let i = 0; i < index && (value <= -1024 || value >= 1024); i++) {
339
- value /= 1024;
340
- level++;
341
- }
342
- return toDecimal(value, 2) + fileSize[level];
343
- }
344
- return value;
345
- };
346
- const formatFileSize = (size, baseUnit = "") => {
347
- if ([void 0, null].includes(size)) {
348
- return "";
349
- } else if (!isNumber(size) || size <= 0) {
350
- return size + baseUnit;
351
- }
352
- const unitArr = ["B", "K", "M", "G", "T", "P", "E", "Z", "Y"];
353
- let unitIndex = Math.max(unitArr.indexOf((baseUnit + "").toLocaleUpperCase()), 0);
354
- while (size >= 1024 && unitIndex < unitArr.length - 1) {
355
- size = size / 1024;
356
- unitIndex++;
357
- }
358
- while (size < 1 && unitIndex > 0) {
359
- size = size * 1024;
360
- unitIndex--;
361
- }
362
- return parseFloat(toDecimal(size, 2, true)) + unitArr[unitIndex];
363
- };
364
- const isKorean = (text) => /([(\uAC00-\uD7AF)|(\u3130-\u318F)])+/gi.test(text);
365
- const omitText = (text, font, w) => {
366
- let t;
367
- if (!isBrowser)
368
- return { t: text, o: false };
369
- const canvas = document.createElement("canvas");
370
- const ctx = canvas.getContext("2d");
371
- ctx.font = font;
372
- let metric = ctx.measureText(text);
373
- if (metric.width < w) {
374
- return { t: text, o: false };
375
- } else {
376
- for (let i = -1; ; i--) {
377
- t = text.slice(0, i) + "...";
378
- metric = ctx.measureText(t);
379
- if (metric.width < w) {
380
- return { t, o: true };
381
- }
382
- }
383
- }
384
- };
385
- export {
386
- camelize,
387
- capitalize,
388
- escape,
389
- escapeChars,
390
- escapeHtml,
391
- fieldFormat,
392
- fillChar,
393
- format,
394
- formatFileSize,
395
- formatTypes,
396
- getLength,
397
- guid,
398
- hyphenate,
399
- isKorean,
400
- isNullOrEmpty,
401
- omitText,
402
- random,
403
- toBoolValue,
404
- toCurrency,
405
- toDecimal,
406
- toFileSize,
407
- toInt,
408
- toJson,
409
- toNumber,
410
- toRate,
411
- truncate,
412
- tryToConvert,
413
- tryToCurrency,
414
- tryToDecimal,
415
- tryToInt,
416
- tryToNumber
417
- };
package/common/type.js DELETED
@@ -1,66 +0,0 @@
1
- import "../chunk-G2ADBYYC.js";
2
- const toString = Object.prototype.toString;
3
- const hasOwn = Object.prototype.hasOwnProperty;
4
- const getProto = Object.getPrototypeOf;
5
- const fnToString = hasOwn.toString;
6
- const ObjectFunctionString = fnToString.call(Object);
7
- const class2type = {
8
- "[object Error]": "error",
9
- "[object Object]": "object",
10
- "[object RegExp]": "regExp",
11
- "[object Date]": "date",
12
- "[object Array]": "array",
13
- "[object Function]": "function",
14
- "[object AsyncFunction]": "asyncFunction",
15
- "[object String]": "string",
16
- "[object Number]": "number",
17
- "[object Boolean]": "boolean"
18
- };
19
- const isNull = (x) => x === null || x === void 0;
20
- const typeOf = (obj) => isNull(obj) ? String(obj) : class2type[toString.call(obj)] || "object";
21
- const isObject = (obj) => typeOf(obj) === "object";
22
- const isFunction = (fn) => ["asyncFunction", "function"].includes(typeOf(fn));
23
- const isPlainObject = (obj) => {
24
- if (!obj || toString.call(obj) !== "[object Object]") {
25
- return false;
26
- }
27
- const proto = getProto(obj);
28
- if (!proto) {
29
- return true;
30
- }
31
- const Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
32
- return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString;
33
- };
34
- const isEmptyObject = (obj) => {
35
- const type = typeOf(obj);
36
- if (type === "object" || type === "array") {
37
- for (const name in obj) {
38
- if (hasOwn.call(obj, name)) {
39
- return false;
40
- }
41
- }
42
- }
43
- return true;
44
- };
45
- const isNumber = (value) => typeof value === "number" && isFinite(value);
46
- const isNumeric = (value) => value - parseFloat(value) >= 0;
47
- const isDate = (value) => typeOf(value) === "date";
48
- const isSame = (x, y) => x === y || typeof x === "number" && typeof y === "number" && isNaN(x) && isNaN(y);
49
- const isRegExp = (value) => typeOf(value) === "regExp";
50
- const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
51
- export {
52
- hasOwn,
53
- isDate,
54
- isEmptyObject,
55
- isFunction,
56
- isNull,
57
- isNumber,
58
- isNumeric,
59
- isObject,
60
- isPlainObject,
61
- isPromise,
62
- isRegExp,
63
- isSame,
64
- toString,
65
- typeOf
66
- };
@@ -1,10 +0,0 @@
1
- import "../../chunk-G2ADBYYC.js";
2
- import Schema from "./schema";
3
- import validators from "./validations/index";
4
- import getDefaultMessage from "./messages";
5
- Schema.validators = validators;
6
- Schema.getDefaultMessage = getDefaultMessage;
7
- var validate_default = Schema;
8
- export {
9
- validate_default as default
10
- };
@@ -1,65 +0,0 @@
1
- import "../../chunk-G2ADBYYC.js";
2
- const getTypesObj = (translate) => ({
3
- string: translate("validation.types.string"),
4
- method: translate("validation.types.method"),
5
- array: translate("validation.types.array"),
6
- object: translate("validation.types.object"),
7
- number: translate("validation.types.number"),
8
- date: translate("validation.types.date"),
9
- boolean: translate("validation.types.boolean"),
10
- integer: translate("validation.types.integer"),
11
- float: translate("validation.types.float"),
12
- regexp: translate("validation.types.regexp"),
13
- email: translate("validation.types.email"),
14
- url: translate("validation.types.url"),
15
- hex: translate("validation.types.hex"),
16
- digits: translate("validation.types.digits"),
17
- time: translate("validation.types.time"),
18
- dateYM: translate("validation.types.dateYM"),
19
- dateYMD: translate("validation.types.dateYMD"),
20
- dateTime: translate("validation.types.dateTime"),
21
- longDateTime: translate("validation.types.longDateTime"),
22
- version: translate("validation.types.version"),
23
- speczh: translate("validation.types.speczh"),
24
- specialch: translate("validation.types.specialch"),
25
- specialch2: translate("validation.types.hex"),
26
- acceptImg: translate("validation.types.acceptImg"),
27
- acceptFile: translate("validation.types.acceptFile"),
28
- fileSize: translate("validation.types.fileSize")
29
- });
30
- var messages_default = (translate = (value) => value) => ({
31
- default: translate("validation.default"),
32
- required: translate("validation.required"),
33
- enum: translate("validation.enum"),
34
- whitespace: translate("validation.whitespace"),
35
- date: {
36
- format: translate("validation.date.format"),
37
- parse: translate("validation.date.parse"),
38
- invalid: translate("validation.date.invalid")
39
- },
40
- types: getTypesObj(translate),
41
- string: {
42
- len: translate("validation.string.len"),
43
- min: translate("validation.string.min"),
44
- max: translate("validation.string.max"),
45
- range: translate("validation.string.range")
46
- },
47
- number: {
48
- len: translate("validation.number.len"),
49
- min: translate("validation.number.min"),
50
- max: translate("validation.number.max"),
51
- range: translate("validation.number.range")
52
- },
53
- array: {
54
- len: translate("validation.array.len"),
55
- min: translate("validation.array.min"),
56
- max: translate("validation.array.max"),
57
- range: translate("validation.array.range")
58
- },
59
- pattern: {
60
- mismatch: translate("validation.pattern.mismatch")
61
- }
62
- });
63
- export {
64
- messages_default as default
65
- };
@@ -1,12 +0,0 @@
1
- import "../../../chunk-G2ADBYYC.js";
2
- import * as util from "../util";
3
- const ENUM = "enum";
4
- function enum_default(rule, checkValue, source, errors, options) {
5
- rule[ENUM] = Array.isArray(rule[ENUM]) ? rule[ENUM] : [];
6
- if (!rule[ENUM].includes(checkValue)) {
7
- errors.push(util.format(options.messages[ENUM], "", rule[ENUM].join(", ")));
8
- }
9
- }
10
- export {
11
- enum_default as default
12
- };
@@ -1,18 +0,0 @@
1
- import "../../../chunk-G2ADBYYC.js";
2
- import type from "./type";
3
- import range from "./range";
4
- import enumRule from "./enum";
5
- import pattern from "./pattern";
6
- import required from "./required";
7
- import whitespace from "./whitespace";
8
- var rules_default = {
9
- type,
10
- range,
11
- pattern,
12
- required,
13
- whitespace,
14
- enum: enumRule
15
- };
16
- export {
17
- rules_default as default
18
- };
@@ -1,20 +0,0 @@
1
- import "../../../chunk-G2ADBYYC.js";
2
- import * as util from "../util";
3
- function pattern_default(rule, checkValue, source, errors, options) {
4
- if (rule.pattern) {
5
- if (rule.pattern instanceof RegExp) {
6
- rule.pattern.lastIndex = 0;
7
- if (!rule.pattern.test(checkValue)) {
8
- errors.push(util.format(options.messages.pattern.mismatch, "", checkValue, rule.pattern));
9
- }
10
- } else if (typeof rule.pattern === "string") {
11
- const _pattern = new RegExp(rule.pattern);
12
- if (!_pattern.test(checkValue)) {
13
- errors.push(util.format(options.messages.pattern.mismatch, "", checkValue, rule.pattern));
14
- }
15
- }
16
- }
17
- }
18
- export {
19
- pattern_default as default
20
- };
@@ -1,52 +0,0 @@
1
- import "../../../chunk-G2ADBYYC.js";
2
- import * as util from "../util";
3
- import { isNumber } from "../../type";
4
- import { getLength } from "../../string";
5
- function getErro({ min, max, val, key, rule, errors, util: util2, options }) {
6
- if (min && !max && val < rule.min) {
7
- errors.push(util2.format(options.messages[key].min, "", rule.min));
8
- } else if (max && !min && val > rule.max) {
9
- errors.push(util2.format(options.messages[key].max, "", rule.max));
10
- } else if (min && max && (val < rule.min || val > rule.max)) {
11
- errors.push(util2.format(options.messages[key].range, "", rule.min, rule.max));
12
- }
13
- }
14
- function range_default(rule, checkValue, source, errors, options) {
15
- const len = isNumber(rule.len);
16
- const min = isNumber(rule.min);
17
- const max = isNumber(rule.max);
18
- let val = checkValue;
19
- let key = null;
20
- const num = isNumber(Number(checkValue));
21
- const str = typeof checkValue === "string";
22
- const arr = Array.isArray(checkValue);
23
- if (num) {
24
- key = "number";
25
- } else if (str) {
26
- key = "string";
27
- } else if (arr) {
28
- key = "array";
29
- }
30
- if (!key) {
31
- return false;
32
- }
33
- if (arr) {
34
- val = checkValue.length;
35
- }
36
- if (str) {
37
- val = getLength(checkValue, "string");
38
- }
39
- if (rule.type === "number") {
40
- val = checkValue;
41
- }
42
- if (len) {
43
- if (val !== rule.len) {
44
- errors.push(util.format(options.messages[key].len, "", rule.len));
45
- }
46
- } else {
47
- getErro({ min, max, val, key, rule, errors, util, options });
48
- }
49
- }
50
- export {
51
- range_default as default
52
- };
@@ -1,11 +0,0 @@
1
- import "../../../chunk-G2ADBYYC.js";
2
- import * as util from "../util";
3
- import { hasOwn } from "../../type";
4
- function required_default({ rule, checkValue, source, errors, options, type }) {
5
- if (rule.required && (!hasOwn.call(source, rule.field) || util.isEmptyValue(checkValue, type || rule.type))) {
6
- errors.push(util.format(options.messages.required, ""));
7
- }
8
- }
9
- export {
10
- required_default as default
11
- };