zartui 3.0.3 → 3.0.4

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 (219) hide show
  1. package/es/action-sheet/index.css +1 -1
  2. package/es/avatar/Avatar.d.ts +5 -1
  3. package/es/avatar/Avatar.mjs +9 -4
  4. package/es/avatar/index.css +1 -1
  5. package/es/avatar/index.d.ts +4 -1
  6. package/es/badge/Badge.d.ts +1 -1
  7. package/es/badge/index.d.ts +1 -1
  8. package/es/button/index.css +1 -1
  9. package/es/calendar/Calendar.mjs +2 -2
  10. package/es/calendar/index.css +1 -1
  11. package/es/cascader/index.css +1 -1
  12. package/es/cell/index.css +1 -1
  13. package/es/cell-group/CellGroup.d.ts +1 -1
  14. package/es/cell-group/index.d.ts +1 -1
  15. package/es/checkbox/index.css +1 -1
  16. package/es/col/Col.d.ts +1 -1
  17. package/es/col/index.d.ts +1 -1
  18. package/es/collapse-item/CollapseItem.d.ts +1 -1
  19. package/es/collapse-item/index.d.ts +1 -1
  20. package/es/config-provider/ConfigProvider.d.ts +1 -1
  21. package/es/config-provider/index.d.ts +2 -2
  22. package/es/dialog/index.css +1 -1
  23. package/es/divider/Divider.d.ts +1 -1
  24. package/es/divider/index.d.ts +1 -1
  25. package/es/dropdown-menu/DropdownMenu.d.ts +1 -1
  26. package/es/dropdown-menu/index.d.ts +1 -1
  27. package/es/empty/Empty.d.ts +1 -1
  28. package/es/empty/index.d.ts +1 -1
  29. package/es/field/index.css +1 -1
  30. package/es/grid/Grid.d.ts +1 -1
  31. package/es/grid/index.d.ts +1 -1
  32. package/es/grid-item/GridItem.d.ts +1 -1
  33. package/es/grid-item/index.css +1 -1
  34. package/es/grid-item/index.d.ts +1 -1
  35. package/es/icon/Icon.d.ts +1 -1
  36. package/es/icon/config.mjs +3 -2
  37. package/es/icon/index.css +1 -1
  38. package/es/icon/index.d.ts +1 -1
  39. package/es/image-preview/ImagePreview.d.ts +2 -1
  40. package/es/image-preview/ImagePreview.mjs +9 -4
  41. package/es/image-preview/ImagePreviewItem.d.ts +2 -1
  42. package/es/image-preview/ImagePreviewItem.mjs +22 -13
  43. package/es/image-preview/index.css +1 -1
  44. package/es/image-preview/index.d.ts +2 -1
  45. package/es/index.d.ts +1 -1
  46. package/es/index.mjs +1 -1
  47. package/es/lazyload/vue-lazyload/lazy-image.mjs +5 -5
  48. package/es/loading/Loading.d.ts +1 -1
  49. package/es/loading/index.d.ts +1 -1
  50. package/es/media-picker/MediaPicker.mjs +1 -1
  51. package/es/media-picker/image/DefaultAudioIcon.d.ts +1 -1
  52. package/es/media-picker/image/DefaultFileIcon.d.ts +1 -1
  53. package/es/media-picker/image/DefaultVideoIcon.d.ts +1 -1
  54. package/es/media-picker/image/DeleteIcon.d.ts +1 -1
  55. package/es/media-picker/image/PickFileIcon.d.ts +1 -1
  56. package/es/media-picker/image/PickPhotoIcon.d.ts +1 -1
  57. package/es/media-picker/image/TakeAudioIcon.d.ts +1 -1
  58. package/es/media-picker/image/TakePhotoIcon.d.ts +1 -1
  59. package/es/media-picker/image/TakeVideoIcon.d.ts +1 -1
  60. package/es/media-picker/util/media-util.d.ts +17 -2
  61. package/es/media-picker/util/media-util.mjs +137 -10
  62. package/es/media-picker/watermark/image-processor.mjs +28 -3
  63. package/es/media-picker/watermark/watermark.mjs +3 -3
  64. package/es/multiple-picker/MultiplePicker.mjs +1 -2
  65. package/es/multiple-picker/index.css +1 -1
  66. package/es/multiple-picker/types.d.ts +2 -1
  67. package/es/nav-bar/index.css +1 -1
  68. package/es/overlay/Overlay.d.ts +1 -1
  69. package/es/overlay/index.d.ts +1 -1
  70. package/es/picker/PickerColumn.mjs +5 -4
  71. package/es/picker/index.css +1 -1
  72. package/es/popup/Popup.d.ts +26 -0
  73. package/es/popup/Popup.mjs +12 -10
  74. package/es/popup/index.css +1 -1
  75. package/es/popup/index.d.ts +18 -0
  76. package/es/radio/index.css +1 -1
  77. package/es/row/Row.d.ts +1 -1
  78. package/es/row/index.d.ts +1 -1
  79. package/es/search/index.css +1 -1
  80. package/es/skeleton/Skeleton.d.ts +1 -1
  81. package/es/skeleton/index.d.ts +1 -1
  82. package/es/step/Step.d.ts +1 -1
  83. package/es/step/index.d.ts +1 -1
  84. package/es/stepper/Stepper.d.ts +1 -1
  85. package/es/stepper/Stepper.mjs +1 -2
  86. package/es/stepper/index.d.ts +1 -1
  87. package/es/style/base.css +1 -1
  88. package/es/style/css-variables.css +1 -1
  89. package/es/swipe/Swipe.mjs +1 -3
  90. package/es/swipe-item/SwipeItem.d.ts +1 -1
  91. package/es/swipe-item/index.d.ts +1 -1
  92. package/es/tab/Tab.d.ts +1 -1
  93. package/es/tab/index.d.ts +1 -1
  94. package/es/tabbar-item/index.css +1 -1
  95. package/es/tabs/TabsTitle.d.ts +1 -1
  96. package/es/tabs/index.css +1 -1
  97. package/es/time-picker/index.css +1 -1
  98. package/es/toast/index.css +1 -1
  99. package/es/utils/constant.d.ts +1 -0
  100. package/es/utils/constant.mjs +3 -1
  101. package/es/utils/mount-component.d.ts +1 -1
  102. package/lib/action-sheet/index.css +1 -1
  103. package/lib/avatar/Avatar.d.ts +5 -1
  104. package/lib/avatar/Avatar.js +9 -4
  105. package/lib/avatar/index.css +1 -1
  106. package/lib/avatar/index.d.ts +4 -1
  107. package/lib/badge/Badge.d.ts +1 -1
  108. package/lib/badge/index.d.ts +1 -1
  109. package/lib/button/index.css +1 -1
  110. package/lib/calendar/Calendar.js +2 -2
  111. package/lib/calendar/index.css +1 -1
  112. package/lib/cascader/index.css +1 -1
  113. package/lib/cell/index.css +1 -1
  114. package/lib/cell-group/CellGroup.d.ts +1 -1
  115. package/lib/cell-group/index.d.ts +1 -1
  116. package/lib/checkbox/index.css +1 -1
  117. package/lib/col/Col.d.ts +1 -1
  118. package/lib/col/index.d.ts +1 -1
  119. package/lib/collapse-item/CollapseItem.d.ts +1 -1
  120. package/lib/collapse-item/index.d.ts +1 -1
  121. package/lib/config-provider/ConfigProvider.d.ts +1 -1
  122. package/lib/config-provider/index.d.ts +2 -2
  123. package/lib/dialog/index.css +1 -1
  124. package/lib/divider/Divider.d.ts +1 -1
  125. package/lib/divider/index.d.ts +1 -1
  126. package/lib/dropdown-menu/DropdownMenu.d.ts +1 -1
  127. package/lib/dropdown-menu/index.d.ts +1 -1
  128. package/lib/empty/Empty.d.ts +1 -1
  129. package/lib/empty/index.d.ts +1 -1
  130. package/lib/field/index.css +1 -1
  131. package/lib/grid/Grid.d.ts +1 -1
  132. package/lib/grid/index.d.ts +1 -1
  133. package/lib/grid-item/GridItem.d.ts +1 -1
  134. package/lib/grid-item/index.css +1 -1
  135. package/lib/grid-item/index.d.ts +1 -1
  136. package/lib/icon/Icon.d.ts +1 -1
  137. package/lib/icon/config.js +3 -2
  138. package/lib/icon/index.css +1 -1
  139. package/lib/icon/index.d.ts +1 -1
  140. package/lib/image-preview/ImagePreview.d.ts +2 -1
  141. package/lib/image-preview/ImagePreview.js +9 -4
  142. package/lib/image-preview/ImagePreviewItem.d.ts +2 -1
  143. package/lib/image-preview/ImagePreviewItem.js +21 -12
  144. package/lib/image-preview/index.css +1 -1
  145. package/lib/image-preview/index.d.ts +2 -1
  146. package/lib/index.css +1 -1
  147. package/lib/index.d.ts +1 -1
  148. package/lib/index.js +1 -1
  149. package/lib/lazyload/vue-lazyload/lazy-image.js +6 -6
  150. package/lib/loading/Loading.d.ts +1 -1
  151. package/lib/loading/index.d.ts +1 -1
  152. package/lib/media-picker/MediaPicker.js +1 -1
  153. package/lib/media-picker/image/DefaultAudioIcon.d.ts +1 -1
  154. package/lib/media-picker/image/DefaultFileIcon.d.ts +1 -1
  155. package/lib/media-picker/image/DefaultVideoIcon.d.ts +1 -1
  156. package/lib/media-picker/image/DeleteIcon.d.ts +1 -1
  157. package/lib/media-picker/image/PickFileIcon.d.ts +1 -1
  158. package/lib/media-picker/image/PickPhotoIcon.d.ts +1 -1
  159. package/lib/media-picker/image/TakeAudioIcon.d.ts +1 -1
  160. package/lib/media-picker/image/TakePhotoIcon.d.ts +1 -1
  161. package/lib/media-picker/image/TakeVideoIcon.d.ts +1 -1
  162. package/lib/media-picker/util/media-util.d.ts +17 -2
  163. package/lib/media-picker/util/media-util.js +137 -10
  164. package/lib/media-picker/watermark/image-processor.js +22 -2
  165. package/lib/media-picker/watermark/watermark.js +5 -5
  166. package/lib/multiple-picker/MultiplePicker.js +1 -2
  167. package/lib/multiple-picker/index.css +1 -1
  168. package/lib/multiple-picker/types.d.ts +2 -1
  169. package/lib/nav-bar/index.css +1 -1
  170. package/lib/overlay/Overlay.d.ts +1 -1
  171. package/lib/overlay/index.d.ts +1 -1
  172. package/lib/picker/PickerColumn.js +5 -4
  173. package/lib/picker/index.css +1 -1
  174. package/lib/popup/Popup.d.ts +26 -0
  175. package/lib/popup/Popup.js +11 -9
  176. package/lib/popup/index.css +1 -1
  177. package/lib/popup/index.d.ts +18 -0
  178. package/lib/radio/index.css +1 -1
  179. package/lib/row/Row.d.ts +1 -1
  180. package/lib/row/index.d.ts +1 -1
  181. package/lib/search/index.css +1 -1
  182. package/lib/skeleton/Skeleton.d.ts +1 -1
  183. package/lib/skeleton/index.d.ts +1 -1
  184. package/lib/step/Step.d.ts +1 -1
  185. package/lib/step/index.d.ts +1 -1
  186. package/lib/stepper/Stepper.d.ts +1 -1
  187. package/lib/stepper/Stepper.js +1 -2
  188. package/lib/stepper/index.d.ts +1 -1
  189. package/lib/style/base.css +1 -1
  190. package/lib/style/css-variables.css +1 -1
  191. package/lib/swipe/Swipe.js +1 -3
  192. package/lib/swipe-item/SwipeItem.d.ts +1 -1
  193. package/lib/swipe-item/index.d.ts +1 -1
  194. package/lib/tab/Tab.d.ts +1 -1
  195. package/lib/tab/index.d.ts +1 -1
  196. package/lib/tabbar-item/index.css +1 -1
  197. package/lib/tabs/TabsTitle.d.ts +1 -1
  198. package/lib/tabs/index.css +1 -1
  199. package/lib/time-picker/index.css +1 -1
  200. package/lib/toast/index.css +1 -1
  201. package/lib/utils/constant.d.ts +1 -0
  202. package/lib/utils/constant.js +3 -1
  203. package/lib/utils/mount-component.d.ts +1 -1
  204. package/lib/web-types.json +1 -1
  205. package/lib/zartui.cjs.js +251 -112
  206. package/lib/zartui.es.js +251 -112
  207. package/lib/zartui.js +251 -112
  208. package/lib/zartui.min.js +1 -1
  209. package/package.json +21 -20
  210. package/es/media-picker/util/orientation-util.d.ts +0 -37
  211. package/es/media-picker/util/orientation-util.mjs +0 -118
  212. package/es/tabbar/image/common-normal.png +0 -0
  213. package/es/utils/date.d.ts +0 -29
  214. package/es/utils/date.mjs +0 -96
  215. package/lib/media-picker/util/orientation-util.d.ts +0 -37
  216. package/lib/media-picker/util/orientation-util.js +0 -137
  217. package/lib/tabbar/image/common-normal.png +0 -0
  218. package/lib/utils/date.d.ts +0 -29
  219. package/lib/utils/date.js +0 -115
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zartui",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "面向政务场景的移动端组件库",
5
5
  "main": "lib/zartui.cjs.js",
6
6
  "module": "es/index.mjs",
@@ -12,17 +12,6 @@
12
12
  "es",
13
13
  "lib"
14
14
  ],
15
- "scripts": {
16
- "dev": "zartui-cli dev",
17
- "lint": "zartui-cli lint",
18
- "test": "zartui-cli test",
19
- "build": "zartui-cli build",
20
- "build:site": "zartui-cli build-site",
21
- "release": "cp ../../README.md ./ && zartui-cli release && rm ./README.md",
22
- "release:site": "pnpm build:site && npx gh-pages -d site-dist --add",
23
- "test:watch": "zartui-cli test --watch",
24
- "test:coverage": "open test/coverage/index.html"
25
- },
26
15
  "publishConfig": {
27
16
  "registry": "https://registry.npmjs.org/"
28
17
  },
@@ -47,19 +36,31 @@
47
36
  "devDependencies": {
48
37
  "@types/node": "^16.11.56",
49
38
  "@types/jest": "^29.1.1",
50
- "@zartui/cli": "workspace:^",
51
- "@zartui/eslint-config": "workspace:^",
52
- "@zartui/icons": "workspace:^",
53
- "@vue/runtime-core": "^3.2.28",
39
+ "@vue/runtime-core": "^3.2.44",
54
40
  "@vue/test-utils": "^2.0.2",
55
41
  "typescript": "^4.8.2",
56
- "vue": "^3.2.28",
57
- "vue-router": "^4.1.5"
42
+ "vue": "^3.2.44",
43
+ "vue-router": "^4.1.5",
44
+ "@zartui/date-utils": "^0.0.2",
45
+ "@zartui/icons": "^0.0.2",
46
+ "@zartui/eslint-config": "^3.5.2",
47
+ "@zartui/cli": "^5.0.0"
58
48
  },
59
49
  "sideEffects": [
60
50
  "es/**/style/*",
61
51
  "lib/**/style/*",
62
52
  "*.css"
63
53
  ],
64
- "web-types": "lib/web-types.json"
65
- }
54
+ "web-types": "lib/web-types.json",
55
+ "scripts": {
56
+ "dev": "zartui-cli dev",
57
+ "lint": "zartui-cli lint",
58
+ "test": "zartui-cli test",
59
+ "build": "zartui-cli build",
60
+ "build:site": "zartui-cli build-site",
61
+ "release": "cp ../../README.md ./ && zartui-cli release && rm ./README.md",
62
+ "release:site": "pnpm build:site && npx gh-pages -d site-dist --add",
63
+ "test:watch": "zartui-cli test --watch",
64
+ "test:coverage": "open test/coverage/index.html"
65
+ }
66
+ }
@@ -1,37 +0,0 @@
1
- /**
2
- * Get string from char code in data view.
3
- * @param {DataView} dataView - The data view for read.
4
- * @param {number} start - The start index.
5
- * @param {number} length - The read length.
6
- * @returns {string} The read result.
7
- */
8
- export declare function getStringFromCharCode(dataView: DataView, start: number, length: number): string;
9
- /**
10
- * Get orientation value from given array buffer.
11
- * @param {ArrayBuffer} arrayBuffer - The array buffer to read.
12
- * @returns {number} The read orientation value.
13
- */
14
- export declare function resetAndGetOrientation(arrayBuffer: ArrayBufferLike): number;
15
- /**
16
- * Convert array-like or iterable object to an array.
17
- * @param {*} value - The value to convert.
18
- * @returns {Array} Returns a new array.
19
- */
20
- export declare function toArray(value: ArrayLike<unknown>): any[];
21
- /**
22
- * Transform array buffer to Data URL.
23
- * @param {ArrayBuffer} arrayBuffer - The array buffer to transform.
24
- * @param {string} mimeType - The mime type of the Data URL.
25
- * @returns {string} The result Data URL.
26
- */
27
- export declare function arrayBufferToDataURL(arrayBuffer: ArrayBuffer, mimeType: string): string;
28
- /**
29
- * Parse Exif Orientation value.
30
- * @param {number} orientation - The orientation to parse.
31
- * @returns {Object} The parsed result.
32
- */
33
- export declare function parseOrientation(orientation: number): {
34
- rotate: number;
35
- scaleX: number;
36
- scaleY: number;
37
- };
@@ -1,118 +0,0 @@
1
- function getStringFromCharCode(dataView, start, length) {
2
- let str = "";
3
- let i;
4
- length += start;
5
- for (i = start; i < length; i += 1) {
6
- str += String.fromCharCode(dataView.getUint8(i));
7
- }
8
- return str;
9
- }
10
- function resetAndGetOrientation(arrayBuffer) {
11
- const dataView = new DataView(arrayBuffer);
12
- let orientation = 0;
13
- try {
14
- let littleEndian;
15
- let app1Start;
16
- let ifdStart;
17
- if (dataView.getUint8(0) === 255 && dataView.getUint8(1) === 216) {
18
- const length = dataView.byteLength;
19
- let offset = 2;
20
- while (offset + 1 < length) {
21
- if (dataView.getUint8(offset) === 255 && dataView.getUint8(offset + 1) === 225) {
22
- app1Start = offset;
23
- break;
24
- }
25
- offset += 1;
26
- }
27
- }
28
- if (app1Start) {
29
- const exifIDCode = app1Start + 4;
30
- const tiffOffset = app1Start + 10;
31
- if (getStringFromCharCode(dataView, exifIDCode, 4) === "Exif") {
32
- const endianness = dataView.getUint16(tiffOffset);
33
- littleEndian = endianness === 18761;
34
- if (littleEndian || endianness === 19789) {
35
- if (dataView.getUint16(tiffOffset + 2, littleEndian) === 42) {
36
- const firstIFDOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
37
- if (firstIFDOffset >= 8) {
38
- ifdStart = tiffOffset + firstIFDOffset;
39
- }
40
- }
41
- }
42
- }
43
- }
44
- if (ifdStart) {
45
- const length = dataView.getUint16(ifdStart, littleEndian);
46
- let offset;
47
- let i;
48
- for (i = 0; i < length; i += 1) {
49
- offset = ifdStart + i * 12 + 2;
50
- if (dataView.getUint16(offset, littleEndian) === 274) {
51
- offset += 8;
52
- orientation = dataView.getUint16(offset, littleEndian);
53
- dataView.setUint16(offset, 1, littleEndian);
54
- break;
55
- }
56
- }
57
- }
58
- } catch (e) {
59
- orientation = 1;
60
- }
61
- return orientation;
62
- }
63
- function toArray(value) {
64
- return Array.from ? Array.from(value) : Array.prototype.slice.call(value);
65
- }
66
- function arrayBufferToDataURL(arrayBuffer, mimeType) {
67
- const chunks = [];
68
- const chunkSize = 8192;
69
- let uint8 = new Uint8Array(arrayBuffer);
70
- while (uint8.length > 0) {
71
- chunks.push(String.fromCharCode.apply(null, toArray(uint8.subarray(0, chunkSize))));
72
- uint8 = uint8.subarray(chunkSize);
73
- }
74
- return `data:${mimeType};base64,${btoa(chunks.join(""))}`;
75
- }
76
- function parseOrientation(orientation) {
77
- let rotate = 0;
78
- let scaleX = 1;
79
- let scaleY = 1;
80
- switch (orientation) {
81
- case 2:
82
- scaleX = -1;
83
- break;
84
- case 3:
85
- rotate = -180;
86
- break;
87
- case 4:
88
- scaleY = -1;
89
- break;
90
- case 5:
91
- rotate = 90;
92
- scaleY = -1;
93
- break;
94
- case 6:
95
- rotate = 90;
96
- break;
97
- case 7:
98
- rotate = 90;
99
- scaleX = -1;
100
- break;
101
- case 8:
102
- rotate = -90;
103
- break;
104
- default:
105
- }
106
- return {
107
- rotate,
108
- scaleX,
109
- scaleY
110
- };
111
- }
112
- export {
113
- arrayBufferToDataURL,
114
- getStringFromCharCode,
115
- parseOrientation,
116
- resetAndGetOrientation,
117
- toArray
118
- };
Binary file
@@ -1,29 +0,0 @@
1
- export declare const weekList: string[];
2
- export declare const FORMAT: {
3
- FORMAT_HM: string;
4
- FORMAT_MDHM: string;
5
- FORMAT_MD_CN: string;
6
- FORMAT_MD: string;
7
- FORMAT_YMD: string;
8
- FORMAT_YMD_SLASH: string;
9
- FORMAT_YM: string;
10
- FORMAT_YMDHM: string;
11
- FORMAT_YMDHMS: string;
12
- FORMAT_YMDHMSMS: string;
13
- FORMAT_YM_CN: string;
14
- FORMAT_YMD_CN: string;
15
- FORMAT_YMDH_CN: string;
16
- FORMAT_MDH_CN: string;
17
- FORMAT_YMDHM_CN: string;
18
- FORMAT_YMDHMS_CN: string;
19
- };
20
- /**
21
- * 创建 Date对象
22
- * @param dateObj 可传入:
23
- * 1. number格式的timestamp;
24
- * 2. string格式的日期字符串
25
- * 3. Date对象将原封不动的返回
26
- * @returns {null|Date|*}
27
- */
28
- export declare function createDate(dateObj: string | number | Date): Date | null;
29
- export declare function formatDate(dateObj: number | string | Date, formatType?: string): string | null;
package/es/utils/date.mjs DELETED
@@ -1,96 +0,0 @@
1
- import { isDate, isDef } from "./validate.mjs";
2
- const weekList = [
3
- "\u5468\u65E5",
4
- "\u5468\u4E00",
5
- "\u5468\u4E8C",
6
- "\u5468\u4E09",
7
- "\u5468\u56DB",
8
- "\u5468\u4E94",
9
- "\u5468\u516D"
10
- ];
11
- const FORMAT = {
12
- FORMAT_HM: "HH:mm",
13
- FORMAT_MDHM: "MM-dd HH:mm",
14
- FORMAT_MD_CN: "MM\u6708dd\u65E5",
15
- FORMAT_MD: "MM-dd",
16
- FORMAT_YMD: "yyyy-MM-dd",
17
- FORMAT_YMD_SLASH: "yyyy/MM/dd",
18
- FORMAT_YM: "yyyy-MM",
19
- FORMAT_YMDHM: "yyyy-MM-dd HH:mm",
20
- FORMAT_YMDHMS: "yyyy-MM-dd HH:mm:ss",
21
- FORMAT_YMDHMSMS: "yyyy-MM-dd HH:mm:ss msms",
22
- FORMAT_YM_CN: "yyyy\u5E74MM\u6708",
23
- FORMAT_YMD_CN: "yyyy\u5E74MM\u6708dd\u65E5",
24
- FORMAT_YMDH_CN: "yyyy\u5E74MM\u6708dd\u65E5 HH\u65F6",
25
- FORMAT_MDH_CN: "MM\u6708dd\u65E5 HH\u65F6",
26
- FORMAT_YMDHM_CN: "yyyy\u5E74MM\u6708dd\u65E5 HH\u65F6mm\u5206",
27
- FORMAT_YMDHMS_CN: "yyyy\u5E74MM\u6708dd\u65E5 HH\u65F6mm\u5206ss\u79D2"
28
- };
29
- const __formatNumber__ = function(number) {
30
- if (number < 10) {
31
- return "0" + number;
32
- }
33
- return number + "";
34
- };
35
- function createDate(dateObj) {
36
- if (!isDef(dateObj)) {
37
- return null;
38
- }
39
- if (typeof dateObj === "number") {
40
- return new Date(dateObj);
41
- }
42
- if (typeof dateObj === "string") {
43
- dateObj = dateObj.replace(/-/g, "/");
44
- if (dateObj.length === 7) {
45
- dateObj += "/01";
46
- }
47
- return new Date(dateObj);
48
- }
49
- if (isDate(dateObj)) {
50
- return dateObj;
51
- }
52
- return null;
53
- }
54
- function formatDate(dateObj, formatType = FORMAT.FORMAT_YMDHMS) {
55
- const date = createDate(dateObj);
56
- if (date) {
57
- date.getFullYear();
58
- let formatResult = formatType.replace(
59
- "yyyy",
60
- __formatNumber__(date.getFullYear())
61
- );
62
- formatResult = formatResult.replace(
63
- "yy",
64
- String(date.getFullYear()).substring(2)
65
- );
66
- formatResult = formatResult.replace(
67
- "MM",
68
- __formatNumber__(date.getMonth() + 1)
69
- );
70
- formatResult = formatResult.replace("dd", __formatNumber__(date.getDate()));
71
- formatResult = formatResult.replace(
72
- "HH",
73
- __formatNumber__(date.getHours())
74
- );
75
- formatResult = formatResult.replace(
76
- "mm",
77
- __formatNumber__(date.getMinutes())
78
- );
79
- formatResult = formatResult.replace(
80
- "ss",
81
- __formatNumber__(date.getSeconds())
82
- );
83
- formatResult = formatResult.replace(
84
- "msms",
85
- __formatNumber__(date.getMilliseconds())
86
- );
87
- return formatResult;
88
- }
89
- return null;
90
- }
91
- export {
92
- FORMAT,
93
- createDate,
94
- formatDate,
95
- weekList
96
- };
@@ -1,37 +0,0 @@
1
- /**
2
- * Get string from char code in data view.
3
- * @param {DataView} dataView - The data view for read.
4
- * @param {number} start - The start index.
5
- * @param {number} length - The read length.
6
- * @returns {string} The read result.
7
- */
8
- export declare function getStringFromCharCode(dataView: DataView, start: number, length: number): string;
9
- /**
10
- * Get orientation value from given array buffer.
11
- * @param {ArrayBuffer} arrayBuffer - The array buffer to read.
12
- * @returns {number} The read orientation value.
13
- */
14
- export declare function resetAndGetOrientation(arrayBuffer: ArrayBufferLike): number;
15
- /**
16
- * Convert array-like or iterable object to an array.
17
- * @param {*} value - The value to convert.
18
- * @returns {Array} Returns a new array.
19
- */
20
- export declare function toArray(value: ArrayLike<unknown>): any[];
21
- /**
22
- * Transform array buffer to Data URL.
23
- * @param {ArrayBuffer} arrayBuffer - The array buffer to transform.
24
- * @param {string} mimeType - The mime type of the Data URL.
25
- * @returns {string} The result Data URL.
26
- */
27
- export declare function arrayBufferToDataURL(arrayBuffer: ArrayBuffer, mimeType: string): string;
28
- /**
29
- * Parse Exif Orientation value.
30
- * @param {number} orientation - The orientation to parse.
31
- * @returns {Object} The parsed result.
32
- */
33
- export declare function parseOrientation(orientation: number): {
34
- rotate: number;
35
- scaleX: number;
36
- scaleY: number;
37
- };
@@ -1,137 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var stdin_exports = {};
19
- __export(stdin_exports, {
20
- arrayBufferToDataURL: () => arrayBufferToDataURL,
21
- getStringFromCharCode: () => getStringFromCharCode,
22
- parseOrientation: () => parseOrientation,
23
- resetAndGetOrientation: () => resetAndGetOrientation,
24
- toArray: () => toArray
25
- });
26
- module.exports = __toCommonJS(stdin_exports);
27
- function getStringFromCharCode(dataView, start, length) {
28
- let str = "";
29
- let i;
30
- length += start;
31
- for (i = start; i < length; i += 1) {
32
- str += String.fromCharCode(dataView.getUint8(i));
33
- }
34
- return str;
35
- }
36
- function resetAndGetOrientation(arrayBuffer) {
37
- const dataView = new DataView(arrayBuffer);
38
- let orientation = 0;
39
- try {
40
- let littleEndian;
41
- let app1Start;
42
- let ifdStart;
43
- if (dataView.getUint8(0) === 255 && dataView.getUint8(1) === 216) {
44
- const length = dataView.byteLength;
45
- let offset = 2;
46
- while (offset + 1 < length) {
47
- if (dataView.getUint8(offset) === 255 && dataView.getUint8(offset + 1) === 225) {
48
- app1Start = offset;
49
- break;
50
- }
51
- offset += 1;
52
- }
53
- }
54
- if (app1Start) {
55
- const exifIDCode = app1Start + 4;
56
- const tiffOffset = app1Start + 10;
57
- if (getStringFromCharCode(dataView, exifIDCode, 4) === "Exif") {
58
- const endianness = dataView.getUint16(tiffOffset);
59
- littleEndian = endianness === 18761;
60
- if (littleEndian || endianness === 19789) {
61
- if (dataView.getUint16(tiffOffset + 2, littleEndian) === 42) {
62
- const firstIFDOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
63
- if (firstIFDOffset >= 8) {
64
- ifdStart = tiffOffset + firstIFDOffset;
65
- }
66
- }
67
- }
68
- }
69
- }
70
- if (ifdStart) {
71
- const length = dataView.getUint16(ifdStart, littleEndian);
72
- let offset;
73
- let i;
74
- for (i = 0; i < length; i += 1) {
75
- offset = ifdStart + i * 12 + 2;
76
- if (dataView.getUint16(offset, littleEndian) === 274) {
77
- offset += 8;
78
- orientation = dataView.getUint16(offset, littleEndian);
79
- dataView.setUint16(offset, 1, littleEndian);
80
- break;
81
- }
82
- }
83
- }
84
- } catch (e) {
85
- orientation = 1;
86
- }
87
- return orientation;
88
- }
89
- function toArray(value) {
90
- return Array.from ? Array.from(value) : Array.prototype.slice.call(value);
91
- }
92
- function arrayBufferToDataURL(arrayBuffer, mimeType) {
93
- const chunks = [];
94
- const chunkSize = 8192;
95
- let uint8 = new Uint8Array(arrayBuffer);
96
- while (uint8.length > 0) {
97
- chunks.push(String.fromCharCode.apply(null, toArray(uint8.subarray(0, chunkSize))));
98
- uint8 = uint8.subarray(chunkSize);
99
- }
100
- return `data:${mimeType};base64,${btoa(chunks.join(""))}`;
101
- }
102
- function parseOrientation(orientation) {
103
- let rotate = 0;
104
- let scaleX = 1;
105
- let scaleY = 1;
106
- switch (orientation) {
107
- case 2:
108
- scaleX = -1;
109
- break;
110
- case 3:
111
- rotate = -180;
112
- break;
113
- case 4:
114
- scaleY = -1;
115
- break;
116
- case 5:
117
- rotate = 90;
118
- scaleY = -1;
119
- break;
120
- case 6:
121
- rotate = 90;
122
- break;
123
- case 7:
124
- rotate = 90;
125
- scaleX = -1;
126
- break;
127
- case 8:
128
- rotate = -90;
129
- break;
130
- default:
131
- }
132
- return {
133
- rotate,
134
- scaleX,
135
- scaleY
136
- };
137
- }
Binary file
@@ -1,29 +0,0 @@
1
- export declare const weekList: string[];
2
- export declare const FORMAT: {
3
- FORMAT_HM: string;
4
- FORMAT_MDHM: string;
5
- FORMAT_MD_CN: string;
6
- FORMAT_MD: string;
7
- FORMAT_YMD: string;
8
- FORMAT_YMD_SLASH: string;
9
- FORMAT_YM: string;
10
- FORMAT_YMDHM: string;
11
- FORMAT_YMDHMS: string;
12
- FORMAT_YMDHMSMS: string;
13
- FORMAT_YM_CN: string;
14
- FORMAT_YMD_CN: string;
15
- FORMAT_YMDH_CN: string;
16
- FORMAT_MDH_CN: string;
17
- FORMAT_YMDHM_CN: string;
18
- FORMAT_YMDHMS_CN: string;
19
- };
20
- /**
21
- * 创建 Date对象
22
- * @param dateObj 可传入:
23
- * 1. number格式的timestamp;
24
- * 2. string格式的日期字符串
25
- * 3. Date对象将原封不动的返回
26
- * @returns {null|Date|*}
27
- */
28
- export declare function createDate(dateObj: string | number | Date): Date | null;
29
- export declare function formatDate(dateObj: number | string | Date, formatType?: string): string | null;
package/lib/utils/date.js DELETED
@@ -1,115 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var stdin_exports = {};
19
- __export(stdin_exports, {
20
- FORMAT: () => FORMAT,
21
- createDate: () => createDate,
22
- formatDate: () => formatDate,
23
- weekList: () => weekList
24
- });
25
- module.exports = __toCommonJS(stdin_exports);
26
- var import_validate = require("./validate");
27
- const weekList = [
28
- "\u5468\u65E5",
29
- "\u5468\u4E00",
30
- "\u5468\u4E8C",
31
- "\u5468\u4E09",
32
- "\u5468\u56DB",
33
- "\u5468\u4E94",
34
- "\u5468\u516D"
35
- ];
36
- const FORMAT = {
37
- FORMAT_HM: "HH:mm",
38
- FORMAT_MDHM: "MM-dd HH:mm",
39
- FORMAT_MD_CN: "MM\u6708dd\u65E5",
40
- FORMAT_MD: "MM-dd",
41
- FORMAT_YMD: "yyyy-MM-dd",
42
- FORMAT_YMD_SLASH: "yyyy/MM/dd",
43
- FORMAT_YM: "yyyy-MM",
44
- FORMAT_YMDHM: "yyyy-MM-dd HH:mm",
45
- FORMAT_YMDHMS: "yyyy-MM-dd HH:mm:ss",
46
- FORMAT_YMDHMSMS: "yyyy-MM-dd HH:mm:ss msms",
47
- FORMAT_YM_CN: "yyyy\u5E74MM\u6708",
48
- FORMAT_YMD_CN: "yyyy\u5E74MM\u6708dd\u65E5",
49
- FORMAT_YMDH_CN: "yyyy\u5E74MM\u6708dd\u65E5 HH\u65F6",
50
- FORMAT_MDH_CN: "MM\u6708dd\u65E5 HH\u65F6",
51
- FORMAT_YMDHM_CN: "yyyy\u5E74MM\u6708dd\u65E5 HH\u65F6mm\u5206",
52
- FORMAT_YMDHMS_CN: "yyyy\u5E74MM\u6708dd\u65E5 HH\u65F6mm\u5206ss\u79D2"
53
- };
54
- const __formatNumber__ = function(number) {
55
- if (number < 10) {
56
- return "0" + number;
57
- }
58
- return number + "";
59
- };
60
- function createDate(dateObj) {
61
- if (!(0, import_validate.isDef)(dateObj)) {
62
- return null;
63
- }
64
- if (typeof dateObj === "number") {
65
- return new Date(dateObj);
66
- }
67
- if (typeof dateObj === "string") {
68
- dateObj = dateObj.replace(/-/g, "/");
69
- if (dateObj.length === 7) {
70
- dateObj += "/01";
71
- }
72
- return new Date(dateObj);
73
- }
74
- if ((0, import_validate.isDate)(dateObj)) {
75
- return dateObj;
76
- }
77
- return null;
78
- }
79
- function formatDate(dateObj, formatType = FORMAT.FORMAT_YMDHMS) {
80
- const date = createDate(dateObj);
81
- if (date) {
82
- date.getFullYear();
83
- let formatResult = formatType.replace(
84
- "yyyy",
85
- __formatNumber__(date.getFullYear())
86
- );
87
- formatResult = formatResult.replace(
88
- "yy",
89
- String(date.getFullYear()).substring(2)
90
- );
91
- formatResult = formatResult.replace(
92
- "MM",
93
- __formatNumber__(date.getMonth() + 1)
94
- );
95
- formatResult = formatResult.replace("dd", __formatNumber__(date.getDate()));
96
- formatResult = formatResult.replace(
97
- "HH",
98
- __formatNumber__(date.getHours())
99
- );
100
- formatResult = formatResult.replace(
101
- "mm",
102
- __formatNumber__(date.getMinutes())
103
- );
104
- formatResult = formatResult.replace(
105
- "ss",
106
- __formatNumber__(date.getSeconds())
107
- );
108
- formatResult = formatResult.replace(
109
- "msms",
110
- __formatNumber__(date.getMilliseconds())
111
- );
112
- return formatResult;
113
- }
114
- return null;
115
- }