@opentiny/vue-renderless 3.21.1 → 3.22.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 (323) 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 +1 -1
  5. package/autocomplete/vue.js +3 -3
  6. package/base-select/index.js +19 -19
  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 +66 -22
  12. package/calendar-view/vue.js +2 -3
  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-panel/index.js +4 -4
  22. package/cascader-panel/node.js +3 -4
  23. package/cascader-panel/vue.js +1 -1
  24. package/cascader-select/column-index.js +2 -2
  25. package/cascader-view/index.js +1 -1
  26. package/chart-bar/index.js +1 -1
  27. package/chart-candle/index.js +1 -1
  28. package/chart-core/deps/utils.js +6 -6
  29. package/chart-core/index.js +1 -1
  30. package/chart-funnel/index.js +1 -1
  31. package/chart-gauge/index.js +1 -1
  32. package/chart-line/index.js +1 -1
  33. package/chart-map/index.js +1 -1
  34. package/chart-pie/index.js +1 -1
  35. package/chart-radar/index.js +1 -1
  36. package/chart-sankey/index.js +1 -1
  37. package/chart-scatter/index.js +1 -1
  38. package/chart-waterfall/index.js +1 -1
  39. package/chart-wordcloud/index.js +1 -1
  40. package/checkbox/index.js +1 -1
  41. package/collapse-item/vue.js +1 -1
  42. package/column-list-item/index.js +1 -1
  43. package/common/deps/dom.js +20 -196
  44. package/common/deps/infinite-scroll.js +4 -43
  45. package/common/deps/popup-manager.js +1 -200
  46. package/container/index.js +2 -2
  47. package/crop/index.js +3 -3
  48. package/currency/index.js +2 -2
  49. package/date-panel/index.js +75 -25
  50. package/date-panel/vue.js +53 -21
  51. package/date-picker/vue.js +1 -1
  52. package/date-picker-mobile/index.js +1 -1
  53. package/date-range/index.js +71 -37
  54. package/date-range/vue.js +27 -23
  55. package/date-table/index.js +8 -5
  56. package/date-table/vue.js +1 -1
  57. package/dialog-box/index.js +3 -3
  58. package/dialog-box/vue.js +1 -1
  59. package/dialog-select/vue.js +7 -4
  60. package/drawer/index.js +2 -2
  61. package/drop-times/index.js +1 -1
  62. package/dropdown/index.js +11 -3
  63. package/dropdown/vue.js +2 -2
  64. package/dropdown-item/index.js +1 -1
  65. package/dropdown-item/mf.js +1 -1
  66. package/dropdown-menu/index.js +1 -1
  67. package/espace/vue.js +2 -2
  68. package/fall-menu/index.js +3 -3
  69. package/file-upload/index.js +16 -13
  70. package/file-upload/vue.js +2 -2
  71. package/filter/vue.js +1 -1
  72. package/filter-panel/vue.js +1 -2
  73. package/floating-button/index.js +1 -1
  74. package/flowchart/index.js +3 -3
  75. package/flowchart/vue.js +1 -1
  76. package/fluent-editor/index.js +5 -7
  77. package/fluent-editor/options.js +2 -2
  78. package/form/index.js +20 -2
  79. package/form-item/index.js +6 -6
  80. package/fullscreen/index.js +1 -1
  81. package/fullscreen/vue.js +1 -1
  82. package/grid/plugins/export.js +2 -2
  83. package/grid/plugins/exportExcel.js +3 -3
  84. package/grid/plugins/resize.js +2 -2
  85. package/grid/static/base/helperEqualCompare.js +1 -1
  86. package/grid/static/base/isPlainObject.js +1 -1
  87. package/grid/utils/common.js +2 -2
  88. package/grid/utils/dom.js +16 -8
  89. package/grid/utils/event.js +4 -4
  90. package/hrapprover/index.js +1 -1
  91. package/image/index.js +3 -3
  92. package/image-viewer/index.js +4 -6
  93. package/input/index.js +2 -2
  94. package/input/vue.js +1 -1
  95. package/ip-address/index.js +17 -21
  96. package/ip-address/vue.js +1 -1
  97. package/link-menu/index.js +1 -1
  98. package/link-menu/vue.js +1 -1
  99. package/load-list/index.js +1 -1
  100. package/load-list/vue.js +4 -4
  101. package/loading/index.js +2 -2
  102. package/menu/vue.js +1 -1
  103. package/milestone/index.js +6 -45
  104. package/modal/index.js +5 -5
  105. package/month-range/index.js +45 -5
  106. package/month-range/vue.js +19 -15
  107. package/month-table/index.js +5 -5
  108. package/month-table/vue.js +1 -1
  109. package/nav-menu/index.js +7 -7
  110. package/notify/index.js +3 -3
  111. package/numeric/index.js +5 -5
  112. package/option/index.js +1 -1
  113. package/option/vue.js +2 -1
  114. package/package.json +4 -3
  115. package/pager/index.js +28 -16
  116. package/pager/vue.js +27 -16
  117. package/panel/index.js +1 -1
  118. package/picker/index.js +11 -11
  119. package/picker/vue.js +2 -2
  120. package/picker-column/index.js +1 -1
  121. package/pop-upload/vue.js +1 -1
  122. package/popconfirm/vue.js +1 -1
  123. package/popeditor/index.js +6 -6
  124. package/popeditor/vue.js +2 -2
  125. package/popover/index.js +3 -3
  126. package/popover/vue.js +1 -1
  127. package/popup/index.js +3 -3
  128. package/pull-refresh/index.js +1 -1
  129. package/pull-refresh-mobile-first/index.js +1 -1
  130. package/pull-refresh-mobile-first/vue.js +4 -4
  131. package/quarter-panel/index.js +2 -2
  132. package/quarter-panel/vue.js +1 -1
  133. package/radio-group/index.js +1 -1
  134. package/rate/index.js +1 -1
  135. package/rate/vue.js +1 -1
  136. package/recycle-scroller/index.js +2 -2
  137. package/recycle-scroller/vue.js +1 -1
  138. package/rich-text/index.js +1 -1
  139. package/rich-text/table-module.js +2 -2
  140. package/river/river.js +1 -1
  141. package/river/vue.js +1 -1
  142. package/scrollbar/vue-bar.js +1 -1
  143. package/scrollbar/vue.js +1 -1
  144. package/search/index.js +3 -3
  145. package/select/index.js +26 -22
  146. package/select/vue.js +8 -7
  147. package/select-dropdown/vue.js +5 -5
  148. package/selected-box/index.js +1 -1
  149. package/signature/index.js +1 -1
  150. package/signature/vue.js +2 -2
  151. package/skeleton/index.js +1 -1
  152. package/slider/index.js +4 -4
  153. package/slider-button-group/slide-button.js +2 -2
  154. package/split/index.js +2 -2
  155. package/split/vue.js +1 -1
  156. package/statistic/index.js +1 -1
  157. package/steps/index.js +2 -3
  158. package/steps/slide-bar.js +2 -2
  159. package/sticky/vue.js +4 -4
  160. package/tab-bar/index.js +2 -2
  161. package/tab-item-mf/vue.js +1 -1
  162. package/tab-nav/index.js +4 -4
  163. package/tabbar/index.js +1 -1
  164. package/tabbar/vue.js +1 -1
  165. package/tabbar-item/index.js +1 -1
  166. package/tabs-mf/index.js +5 -5
  167. package/tabs-mf/vue-bar.js +1 -1
  168. package/tabs-mf/vue-swipe.js +1 -1
  169. package/tabs-mf/vue.js +2 -2
  170. package/tabs-mf/wheel.js +3 -3
  171. package/tag-group/vue.js +2 -2
  172. package/tall-storage/index.js +1 -1
  173. package/tall-storage/vue.js +1 -1
  174. package/time/index.js +1 -1
  175. package/time/vue.js +1 -1
  176. package/time-line/index.js +1 -1
  177. package/time-line-new/index.js +1 -1
  178. package/time-panel/index.js +2 -2
  179. package/time-panel/vue.js +1 -1
  180. package/time-range/index.js +1 -1
  181. package/time-range/vue.js +1 -1
  182. package/time-spinner/index.js +4 -4
  183. package/time-spinner/vue.js +1 -1
  184. package/timeline-item/index.js +1 -1
  185. package/toggle-menu/index.js +1 -1
  186. package/tooltip/index.js +2 -2
  187. package/tooltip/vue.js +2 -2
  188. package/top-box/index.js +3 -3
  189. package/transfer/index.js +1 -1
  190. package/transfer-panel/index.js +1 -1
  191. package/tree/index.js +9 -9
  192. package/tree/vue.js +2 -2
  193. package/tree-node/index.js +1 -1
  194. package/tree-node/vue.js +1 -1
  195. package/tree-select/index.js +1 -1
  196. package/types/async-flowchart.type.d.ts +2 -14
  197. package/types/breadcrumb-item.type.d.ts +5 -1
  198. package/types/breadcrumb.type.d.ts +5 -1
  199. package/types/button-group.type.d.ts +5 -1
  200. package/types/button.type.d.ts +1 -1
  201. package/types/cascader.type.d.ts +6 -1
  202. package/types/date-table.type.d.ts +1 -120
  203. package/types/dropdown.type.d.ts +1 -1
  204. package/types/label.type.d.ts +1 -53
  205. package/types/loading.type.d.ts +12 -0
  206. package/types/numeric.type.d.ts +3 -22
  207. package/types/pager.type.d.ts +12 -7
  208. package/types/popconfirm.type.d.ts +2 -0
  209. package/types/steps.type.d.ts +1 -0
  210. package/types/tag-group.type.d.ts +2 -14
  211. package/types/tag.type.d.ts +4 -4
  212. package/types/tooltip.type.d.ts +3 -13
  213. package/types/user-head.type.d.ts +0 -4
  214. package/upload/index.js +1 -1
  215. package/upload-list/index.js +1 -1
  216. package/upload-list/vue.js +4 -4
  217. package/user/index.js +7 -7
  218. package/user/vue.js +15 -2
  219. package/user-contact/vue.js +2 -2
  220. package/virtual-scroll-box/index.js +2 -2
  221. package/wizard/index.js +3 -3
  222. package/year-range/index.js +61 -11
  223. package/year-range/vue.js +33 -20
  224. package/year-table/index.js +7 -5
  225. package/avatar/index.js +0 -30
  226. package/avatar/vue.js +0 -22
  227. package/common/array.js +0 -115
  228. package/common/bigInt.js +0 -315
  229. package/common/browser.js +0 -81
  230. package/common/calendar/calendar.js +0 -97
  231. package/common/dataset/index.js +0 -99
  232. package/common/date.js +0 -354
  233. package/common/decimal.js +0 -155
  234. package/common/deps/ResizeObserver.js +0 -456
  235. package/common/deps/after-leave.js +0 -27
  236. package/common/deps/clickoutside.js +0 -75
  237. package/common/deps/date-util.js +0 -255
  238. package/common/deps/date.js +0 -286
  239. package/common/deps/debounce.js +0 -8
  240. package/common/deps/eSpaceCtrl.js +0 -304
  241. package/common/deps/fastdom/async.js +0 -41
  242. package/common/deps/fastdom/index.js +0 -9
  243. package/common/deps/fastdom/sandbox.js +0 -53
  244. package/common/deps/fastdom/singleton.js +0 -88
  245. package/common/deps/fullscreen/apis.js +0 -143
  246. package/common/deps/fullscreen/screenfull.js +0 -165
  247. package/common/deps/memorize.js +0 -124
  248. package/common/deps/observe-visibility.js +0 -106
  249. package/common/deps/popper.js +0 -613
  250. package/common/deps/repeat-click.js +0 -29
  251. package/common/deps/resize-event.js +0 -39
  252. package/common/deps/scroll-into-view.js +0 -29
  253. package/common/deps/scrollbar-width.js +0 -33
  254. package/common/deps/throttle.js +0 -45
  255. package/common/deps/touch-emulator.js +0 -103
  256. package/common/deps/touch.js +0 -37
  257. package/common/deps/tree-model/node.js +0 -475
  258. package/common/deps/tree-model/tree-store.js +0 -312
  259. package/common/deps/tree-model/util.js +0 -24
  260. package/common/deps/upload-ajax.js +0 -81
  261. package/common/deps/useEventListener.js +0 -54
  262. package/common/deps/useInstanceSlots.js +0 -22
  263. package/common/deps/useRect.js +0 -25
  264. package/common/deps/useRelation.js +0 -89
  265. package/common/deps/useTouch.js +0 -68
  266. package/common/deps/useUserAgent.js +0 -16
  267. package/common/deps/useWindowSize.js +0 -23
  268. package/common/deps/vue-emitter.js +0 -34
  269. package/common/deps/vue-popper.js +0 -177
  270. package/common/deps/vue-popup.js +0 -138
  271. package/common/event.js +0 -46
  272. package/common/form/const.js +0 -10
  273. package/common/function.js +0 -28
  274. package/common/global.js +0 -11
  275. package/common/index.js +0 -259
  276. package/common/object.js +0 -227
  277. package/common/prop-util.js +0 -43
  278. package/common/runtime.js +0 -79
  279. package/common/string.js +0 -417
  280. package/common/type.js +0 -66
  281. package/common/validate/index.js +0 -10
  282. package/common/validate/messages.js +0 -65
  283. package/common/validate/rules/enum.js +0 -12
  284. package/common/validate/rules/index.js +0 -18
  285. package/common/validate/rules/pattern.js +0 -20
  286. package/common/validate/rules/range.js +0 -52
  287. package/common/validate/rules/required.js +0 -11
  288. package/common/validate/rules/type.js +0 -100
  289. package/common/validate/rules/whitespace.js +0 -10
  290. package/common/validate/schema.js +0 -290
  291. package/common/validate/util.js +0 -211
  292. package/common/validate/validations/array.js +0 -22
  293. package/common/validate/validations/date.js +0 -31
  294. package/common/validate/validations/enum.js +0 -22
  295. package/common/validate/validations/float.js +0 -22
  296. package/common/validate/validations/index.js +0 -46
  297. package/common/validate/validations/integer.js +0 -22
  298. package/common/validate/validations/method.js +0 -21
  299. package/common/validate/validations/number.js +0 -25
  300. package/common/validate/validations/pattern.js +0 -21
  301. package/common/validate/validations/required.js +0 -11
  302. package/common/validate/validations/string.js +0 -33
  303. package/common/validate/validations/type.js +0 -29
  304. package/index-bar/index.js +0 -66
  305. package/index-bar/vue.js +0 -73
  306. package/index-bar-anchor/vue.js +0 -16
  307. package/label/index.js +0 -56
  308. package/label/vue.js +0 -26
  309. package/list/index.js +0 -13
  310. package/list/vue.js +0 -17
  311. package/mask/index.js +0 -13
  312. package/mask/vue.js +0 -18
  313. package/mini-picker/index.js +0 -165
  314. package/mini-picker/vue.js +0 -122
  315. package/multi-select/index.js +0 -394
  316. package/multi-select/vue.js +0 -113
  317. package/multi-select-item/index.js +0 -23
  318. package/multi-select-item/vue.js +0 -31
  319. package/toast/index.js +0 -7
  320. package/toast/vue.js +0 -19
  321. package/types/toast.type.d.ts +0 -63
  322. package/wheel/index.js +0 -165
  323. package/wheel/vue.js +0 -79
package/common/date.js DELETED
@@ -1,354 +0,0 @@
1
- import "../chunk-G2ADBYYC.js";
2
- import { isDate, isNumber, isNumeric } from "./type";
3
- import { fillChar } from "./string";
4
- const daysInMonths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
5
- const yyyymmddReg = new RegExp(
6
- "^(\\d{4})(/|-)(((0)?[1-9])|(1[0-2]))((/|-)(((0)?[1-9])|([1-2][0-9])|(3[0-1])))?( ((0)?[0-9]|1[0-9]|20|21|22|23):([0-5]?[0-9])((:([0-5]?[0-9]))?(.([0-9]{1,6}))?)?)?$"
7
- );
8
- const mmddyyyyReg = new RegExp(
9
- "^(((0)?[1-9])|(1[0-2]))(/|-)(((0)?[1-9])|([1-2][0-9])|(3[0-1]))?(/|-)?(\\d{4})( ((0)?[0-9]|1[0-9]|20|21|22|23):([0-5]?[0-9])((:([0-5]?[0-9]))?(.([0-9]{1,6}))?)?)?$"
10
- );
11
- const iso8601Reg = new RegExp(
12
- "^(\\d{4})-(((0)?[1-9])|(1[0-2]))-(((0)?[1-9])|([1-2][0-9])|(3[0-1]))T(((0)?[0-9]|1[0-9]|20|21|22|23):([0-5]?[0-9])((:([0-5]?[0-9]))?(.([0-9]{1,6}))?)?)?(Z|([+-])((0)?[0-9]|1[0-9]|20|21|22|23):?([0-5]?[0-9]))$"
13
- );
14
- const dateFormatRegs = {
15
- "y{1,4}": /y{1,4}/,
16
- "M{1,2}": /M{1,2}/,
17
- "d{1,2}": /d{1,2}/,
18
- "h{1,2}": /h{1,2}/,
19
- "H{1,2}": /H{1,2}/,
20
- "m{1,2}": /m{1,2}/,
21
- "s{1,2}": /s{1,2}/,
22
- "S{1,3}": /S{1,3}/,
23
- "Z{1,1}": /Z{1,1}/
24
- };
25
- const maxDateValues = {
26
- YEAR: 9999,
27
- MONTH: 11,
28
- DATE: 31,
29
- HOUR: 23,
30
- MINUTE: 59,
31
- SECOND: 59,
32
- MILLISECOND: 999
33
- };
34
- const timezone1 = "-12:00,-11:00,-10:00,-09:30,-08:00,-07:00,-06:00,-05:00,-04:30,-04:00,-03:30,-02:00,-01:00";
35
- const timezone2 = "-00:00,+00:00,+01:00,+02:00,+03:00,+03:30,+04:00,+04:30,+05:00,+05:30,+05:45,+06:00";
36
- const timezone3 = "+06:30,+07:00,+08:00,+09:00,+10:00,+10:30,+11:00,+11:30,+12:00,+12:45,+13:00,+14:00";
37
- const timezones = [].concat(timezone1.split(","), timezone2.split(","), timezone3.split(","));
38
- const getTimezone = (date) => {
39
- const timezoneoffset = 0 - date.getTimezoneOffset() / 60;
40
- let timezone;
41
- if (timezoneoffset === 0) {
42
- timezone = "Z";
43
- } else if (timezoneoffset > 0) {
44
- timezone = "+" + (timezoneoffset > 10 ? timezoneoffset : "0" + timezoneoffset) + "00";
45
- } else {
46
- timezone = (timezoneoffset < -10 ? timezoneoffset : "-0" + -timezoneoffset) + "00";
47
- }
48
- return timezone;
49
- };
50
- const isLeapYear = (year) => year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
51
- const getMilliseconds = (milliseconds) => milliseconds > maxDateValues.MILLISECOND ? Number(String(milliseconds).substring(0, 3)) : milliseconds;
52
- const getDateFromData = ({ year, month, date, hours, minutes, seconds, milliseconds }) => {
53
- let daysInMonth = daysInMonths[month];
54
- if (isLeapYear(year) && month === 1) {
55
- daysInMonth += 1;
56
- }
57
- if (date <= daysInMonth) {
58
- return new Date(year, month, date, hours, minutes, seconds, getMilliseconds(milliseconds));
59
- }
60
- };
61
- const yyyymmddDateParser = (m) => {
62
- if (m.length === 23) {
63
- const year = Number(m[1]);
64
- const month = m[3] - 1;
65
- const date = Number(m[9] || 1);
66
- const hours = m[15] || 0;
67
- const minutes = m[17] || 0;
68
- const seconds = m[20] || 0;
69
- const milliseconds = m[22] || 0;
70
- return getDateFromData({
71
- date,
72
- year,
73
- hours,
74
- month,
75
- seconds,
76
- minutes,
77
- milliseconds
78
- });
79
- }
80
- };
81
- const mmddyyyyDateParser = (m) => {
82
- if (m.length === 22) {
83
- const year = Number(m[12]);
84
- const month = m[1] - 1;
85
- const date = Number(m[6] || 1);
86
- const hours = m[14] || 0;
87
- const minutes = m[16] || 0;
88
- const seconds = m[19] || 0;
89
- const milliseconds = m[21] || 0;
90
- return getDateFromData({
91
- year,
92
- month,
93
- date,
94
- hours,
95
- minutes,
96
- seconds,
97
- milliseconds
98
- });
99
- }
100
- };
101
- const iso8601DateParser = (m) => {
102
- if (m.length !== 25) {
103
- return;
104
- }
105
- const year = Number(m[1]);
106
- const month = m[2] - 1;
107
- const date = Number(m[6]);
108
- const offset = new Date(year, month, date).getTimezoneOffset();
109
- const hours = m[12] || 0;
110
- const minutes = m[14] || 0;
111
- const seconds = m[17] || 0;
112
- const milliseconds = m[19] || 0;
113
- let timeZone = m[20];
114
- const sign = m[21];
115
- const offsetHours = m[22] || 0;
116
- const offsetMinutes = m[24] || 0;
117
- let daysInMonth = daysInMonths[month];
118
- let actHours;
119
- let actMinutes;
120
- if (isLeapYear(year) && month === 1) {
121
- daysInMonth += 1;
122
- }
123
- if (date <= daysInMonth) {
124
- if (timeZone === "Z") {
125
- actHours = hours - offset / 60;
126
- actMinutes = minutes;
127
- } else {
128
- if (!timeZone.includes(":")) {
129
- timeZone = timeZone.substr(0, 3) + ":" + timeZone.substr(3);
130
- }
131
- if (!timezones.includes(timeZone)) {
132
- return;
133
- }
134
- actHours = sign === "+" ? hours - offsetHours - offset / 60 : Number(hours) + Number(offsetHours) - offset / 60;
135
- actMinutes = sign === "+" ? minutes - offsetMinutes : Number(minutes) + Number(offsetMinutes);
136
- }
137
- return new Date(year, month, date, actHours, actMinutes, seconds, getMilliseconds(milliseconds));
138
- }
139
- };
140
- const dateParsers = [
141
- [yyyymmddReg, yyyymmddDateParser],
142
- [mmddyyyyReg, mmddyyyyDateParser],
143
- [iso8601Reg, iso8601DateParser]
144
- ];
145
- const parseDate = (str) => {
146
- for (let i = 0, len = dateParsers.length; i < len; i++) {
147
- const m = dateParsers[i][0].exec(str);
148
- if (m && m.length > 0) {
149
- return dateParsers[i][1](m);
150
- }
151
- }
152
- };
153
- const matchDateArray = (arr, value, text) => {
154
- if (text) {
155
- switch (text) {
156
- case "yyyy":
157
- case "yy":
158
- arr[0] = value;
159
- break;
160
- case "M":
161
- case "MM":
162
- arr[1] = value - 1;
163
- break;
164
- case "d":
165
- case "dd":
166
- arr[2] = value;
167
- break;
168
- case "h":
169
- case "hh":
170
- arr[3] = value;
171
- break;
172
- case "m":
173
- case "mm":
174
- arr[4] = value;
175
- break;
176
- case "s":
177
- case "ss":
178
- arr[5] = value;
179
- break;
180
- case "S":
181
- case "SS":
182
- case "SSS":
183
- arr[6] = value;
184
- break;
185
- default:
186
- break;
187
- }
188
- }
189
- };
190
- const getDateArray = (str, dateFormat) => {
191
- const arr = [0, -1, 0, 0, 0, 0];
192
- if (str.length !== dateFormat.length) {
193
- return arr;
194
- }
195
- let valuePos = 0;
196
- let textPos = 0;
197
- for (let i = 0, len = str.length; i < len; i++) {
198
- const charValue = str.substr(i, 1);
199
- const notNum = isNaN(Number(charValue)) || charValue.trim() === "";
200
- if (notNum && charValue === dateFormat.substr(i, 1) || i === len - 1) {
201
- let value;
202
- let text;
203
- if (notNum) {
204
- value = str.substring(valuePos, i);
205
- valuePos = i + 1;
206
- const end = dateFormat.indexOf(charValue, textPos);
207
- text = dateFormat.substring(textPos, end === -1 ? dateFormat.length : end);
208
- textPos = end + 1;
209
- } else {
210
- value = str.substring(valuePos, len);
211
- text = dateFormat.substring(textPos, len);
212
- }
213
- if (value.length === text.length || value) {
214
- matchDateArray(arr, value, text);
215
- }
216
- }
217
- }
218
- return arr;
219
- };
220
- const invalideTime = (time, min, max) => isNaN(time) || time < min || time > max;
221
- const invalideValue = ({ year, month, date, hours, minutes, seconds, milliseconds }) => invalideTime(year, 0, maxDateValues.YEAR) || invalideTime(month, 0, maxDateValues.MONTH) || invalideTime(date, 0, maxDateValues.DATE) || invalideTime(hours, 0, maxDateValues.HOUR) || invalideTime(minutes, 0, maxDateValues.MINUTE) || invalideTime(seconds, 0, maxDateValues.SECOND) || invalideTime(milliseconds, 0, maxDateValues.MILLISECOND);
222
- const innerParse = (value, dateFormat) => {
223
- if (typeof dateFormat === "string") {
224
- const arr = getDateArray(value, dateFormat);
225
- const year = Number(arr[0]);
226
- const month = Number(arr[1]);
227
- const date = Number(arr[2] || 1);
228
- const hours = Number(arr[3] || 0);
229
- const minutes = Number(arr[4] || 0);
230
- const seconds = Number(arr[5] || 0);
231
- const milliseconds = Number(arr[6] || 0);
232
- if (invalideValue({
233
- year,
234
- month,
235
- date,
236
- hours,
237
- minutes,
238
- seconds,
239
- milliseconds
240
- })) {
241
- return;
242
- }
243
- return getDateFromData({
244
- year,
245
- date,
246
- month,
247
- minutes,
248
- hours,
249
- milliseconds,
250
- seconds
251
- });
252
- } else {
253
- return parseDate(value);
254
- }
255
- };
256
- const toDate = (value, dateFormat, minDate) => {
257
- let date;
258
- if (isNumber(value)) {
259
- date = new Date(value);
260
- } else if (typeof value === "string") {
261
- date = innerParse(value, dateFormat);
262
- }
263
- if (minDate) {
264
- const min = minDate && toDate(minDate) || new Date(1, 1, 1, 0, 0, 0);
265
- return date && date < min ? min : date;
266
- }
267
- return date;
268
- };
269
- const format = function(date, dateFormat = "yyyy/MM/dd hh:mm:ss") {
270
- if (isDate(date)) {
271
- if (typeof dateFormat === "string") {
272
- const o = {
273
- "y{1,4}": date.getFullYear(),
274
- "M{1,2}": date.getMonth() + 1,
275
- "d{1,2}": date.getDate(),
276
- "h{1,2}": date.getHours(),
277
- "H{1,2}": date.getHours(),
278
- "m{1,2}": date.getMinutes(),
279
- "s{1,2}": date.getSeconds(),
280
- "S{1,3}": date.getMilliseconds(),
281
- "Z{1,1}": getTimezone(date)
282
- };
283
- Object.keys(o).forEach((k) => {
284
- const m = dateFormat.match(dateFormatRegs[k]);
285
- if (k && m && m.length) {
286
- dateFormat = dateFormat.replace(m[0], k === "Z{1,1}" ? o[k] : fillChar(o[k].toString(), m[0].length));
287
- }
288
- });
289
- return dateFormat;
290
- }
291
- } else if (typeof date === "string" && arguments.length >= 2) {
292
- let afterFormat = dateFormat;
293
- if (arguments.length === 2) {
294
- dateFormat = void 0;
295
- } else {
296
- afterFormat = arguments[2];
297
- }
298
- const dateValue = toDate(date, dateFormat);
299
- return dateValue ? format(dateValue, afterFormat) : "";
300
- }
301
- };
302
- const getDateWithNewTimezone = (date, otz, ntz, timezoneOffset = 0) => {
303
- if (!isDate(date) || !isNumeric(otz) || !isNumeric(ntz) || !isNumeric(timezoneOffset)) {
304
- return;
305
- }
306
- const otzOffset = -otz * 60;
307
- const ntzOffset = -ntz * 60;
308
- const dstOffeset = timezoneOffset * 60;
309
- const utc = date.getTime() + otzOffset * 6e4;
310
- return new Date(utc - (ntzOffset - dstOffeset) * 6e4);
311
- };
312
- const toDateStr = (date, dateFormat, timezone) => {
313
- if (date && isNumeric(timezone)) {
314
- timezone = parseFloat(parseFloat(timezone).toFixed(2));
315
- date = getDateWithNewTimezone(isDate(date) ? date : new Date(toDate(date)), 0, timezone);
316
- }
317
- return format(date, dateFormat);
318
- };
319
- const getWeekOfFirstDay = (date, isSunFirst) => {
320
- typeof date === "boolean" && (isSunFirst = date);
321
- isDate(date) || (date = /* @__PURE__ */ new Date());
322
- const day = date.getDay();
323
- let dayOfMonth = date.getDate();
324
- if (day === 0) {
325
- !isSunFirst && (dayOfMonth -= 6);
326
- } else {
327
- dayOfMonth = dayOfMonth - day + (!isSunFirst && 1);
328
- }
329
- return new Date(date.getFullYear(), date.getMonth(), dayOfMonth);
330
- };
331
- const TZRE = /(-|\+)(\d{2}):?(\d{2})$/;
332
- const getLocalTimezone = () => 0 - (/* @__PURE__ */ new Date()).getTimezoneOffset() / 60;
333
- const getStrTimezone = (value) => {
334
- const localTimeZone = getLocalTimezone();
335
- const match = typeof value === "string" && value.match(TZRE);
336
- if (match) {
337
- const minoffset = Number(match[2]) + Number(match[3]) / 60;
338
- value = minoffset * `${match[1]}1`;
339
- }
340
- if (isNumber(value) && value >= -12 && value <= 12) {
341
- return value;
342
- }
343
- return localTimeZone;
344
- };
345
- export {
346
- format,
347
- getDateWithNewTimezone,
348
- getLocalTimezone,
349
- getStrTimezone,
350
- getWeekOfFirstDay,
351
- isLeapYear,
352
- toDate,
353
- toDateStr
354
- };
package/common/decimal.js DELETED
@@ -1,155 +0,0 @@
1
- import "../chunk-G2ADBYYC.js";
2
- import { getMiniDecimal, toFixed as roundFixed } from "./bigInt";
3
- const DECIMAL_SEPARATOR = ".";
4
- const asInteger = (number) => {
5
- const tokens = number.split(DECIMAL_SEPARATOR);
6
- const integer = tokens[0];
7
- const fractional = tokens[1];
8
- let value;
9
- let exp;
10
- if (fractional) {
11
- value = parseInt(number.split(DECIMAL_SEPARATOR).join(""), 10);
12
- exp = fractional.length * -1;
13
- } else {
14
- const trailingZeros = integer.match(/0+$/);
15
- if (trailingZeros) {
16
- const length = trailingZeros[0].length;
17
- value = integer.substr(0, integer.length - length);
18
- exp = length;
19
- } else {
20
- value = integer;
21
- exp = 0;
22
- }
23
- }
24
- return { value, exp };
25
- };
26
- const zero = (exp) => {
27
- let result;
28
- if (exp <= 0) {
29
- result = "";
30
- } else if (String.prototype.repeat) {
31
- result = "0".repeat(exp);
32
- } else {
33
- result = ((times) => {
34
- const zeros = [];
35
- for (let i = 0; i < times; i++) {
36
- zeros.push(0);
37
- }
38
- return zeros.join("");
39
- })(exp);
40
- }
41
- return result;
42
- };
43
- const negExp = (str, position) => {
44
- position = Math.abs(position);
45
- const offset = position - str.length;
46
- let sep = DECIMAL_SEPARATOR;
47
- if (offset >= 0) {
48
- str = zero(offset) + str;
49
- sep = "0.";
50
- }
51
- const length = str.length;
52
- const dif = length - position;
53
- const head = str.substr(0, dif);
54
- const tail = str.substring(dif, length);
55
- return head + sep + tail;
56
- };
57
- const posExp = (str, exp) => String(str + zero(exp));
58
- const format = (num, exp) => (exp >= 0 ? posExp : negExp)(String(num), exp);
59
- function Decimal(num) {
60
- if (!this || this.constructor !== Decimal) {
61
- return new Decimal(num);
62
- }
63
- if (num instanceof Decimal) {
64
- return num;
65
- }
66
- this.internal = String(num);
67
- this.asInt = asInteger(this.internal);
68
- this.add = (target) => {
69
- const operands = [this, new Decimal(target)];
70
- operands.sort((x2, y2) => x2.asInt.exp - y2.asInt.exp);
71
- const smallest = operands[0].asInt.exp;
72
- const biggest = operands[1].asInt.exp;
73
- const x = Number(format(operands[1].asInt.value, biggest - smallest));
74
- const y = Number(operands[0].asInt.value);
75
- return new Decimal(format(String(x + y), smallest));
76
- };
77
- this.sub = (target) => new Decimal(this.add(target * -1));
78
- this.mul = (target) => {
79
- target = new Decimal(target);
80
- const result = String(this.asInt.value * target.asInt.value);
81
- const exp = this.asInt.exp + target.asInt.exp;
82
- return new Decimal(format(result, exp));
83
- };
84
- this.div = (target) => {
85
- target = new Decimal(target);
86
- const smallest = Math.min(this.asInt.exp, target.asInt.exp);
87
- const absSmallest = 10 ** Math.abs(smallest);
88
- const x = Decimal.mul(absSmallest, this);
89
- const y = Decimal.mul(absSmallest, target);
90
- return new Decimal(x / y);
91
- };
92
- this.toString = () => this.internal;
93
- this.toNumber = () => Number(this.internal);
94
- }
95
- Decimal.add = (a, b) => new Decimal(a).add(b);
96
- Decimal.mul = (a, b) => new Decimal(a).mul(b);
97
- Decimal.sub = (a, b) => new Decimal(a).sub(b);
98
- Decimal.div = (a, b) => new Decimal(a).div(b);
99
- const toFixed = (num, fraction = 0) => {
100
- const sign = num < 0 ? "-" : "";
101
- num = Math.abs(num);
102
- const npmPow = num.toString().length < (2 ** 53).toString().length - 1 ? 10 ** fraction : 10 ** (fraction - 1);
103
- const result = new Decimal(Math.round(new Decimal(num).mul(npmPow))).div(npmPow).toString();
104
- const numResult = Number(result);
105
- return numResult ? sign + numResult.toFixed(fraction) : numResult.toFixed(fraction);
106
- };
107
- const formatInteger = (value, { secondaryGroupSize = 3, groupSize = 0, groupSeparator = "," }) => {
108
- const negative = /^-\d+/.test(value);
109
- let result = negative ? value.slice(1) : value;
110
- const secSize = secondaryGroupSize || groupSize;
111
- if (groupSize && result.length > groupSize) {
112
- let left = result.slice(0, 0 - groupSize);
113
- const right = result.slice(0 - groupSize);
114
- left = left.replace(new RegExp(`\\B(?=(\\d{${secSize}})+(?!\\d))`, "g"), groupSeparator);
115
- result = `${left}${groupSeparator}${right}`;
116
- }
117
- return `${negative ? "-" : ""}${result}`;
118
- };
119
- const reverseString = (str) => {
120
- const arr = [];
121
- for (let i = 0; i < str.length; i++) {
122
- arr.push(str[i]);
123
- }
124
- return arr.reverse().join("");
125
- };
126
- const formatDecimal = (num, { fractionGroupSize = 0, fractionGroupSeparator = "\xA0" }) => {
127
- const RE = new RegExp(`\\B(?=(\\d{${fractionGroupSize}})+(?!\\d))`, "g");
128
- return reverseString(reverseString(num).replace(RE, fractionGroupSeparator));
129
- };
130
- const formatNumber = (value, format2 = {}) => {
131
- const { fraction, rounding, prefix = "", decimalSeparator = ".", suffix = "" } = format2;
132
- let reslut = getMiniDecimal(value);
133
- if (reslut.isNaN() || !reslut.toString()) {
134
- return value;
135
- }
136
- reslut = roundFixed(reslut.toString(), fraction, rounding);
137
- format2.zeroize === false && reslut.match(/\./) && (reslut = reslut.replace(/\.?0+$/g, ""));
138
- const number = reslut.toString().split(".").slice(0, 2).map((str, index) => index ? formatDecimal(str, format2) : formatInteger(str, format2)).join(decimalSeparator);
139
- return `${prefix}${number}${suffix}`;
140
- };
141
- const recoverNumber = (number, format2 = {}) => {
142
- const { prefix = "", suffix = "", decimalSeparator = "." } = format2;
143
- let result = number;
144
- if (typeof number === "string") {
145
- result = number.replace(new RegExp(`^${prefix}(.+)${suffix}$`), ($1, $2) => $2).split(decimalSeparator).map((s) => s.replace(/[^\d]/g, "")).join(".");
146
- }
147
- return Number(result);
148
- };
149
- export {
150
- Decimal,
151
- formatNumber,
152
- recoverNumber,
153
- roundFixed,
154
- toFixed
155
- };