@ivujs/i-utils 1.1.18 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +122 -58
  2. package/dist/cjs/ID-card/index.cjs +95 -0
  3. package/dist/cjs/array/index.cjs +476 -0
  4. package/dist/cjs/clipboard/index.cjs +132 -0
  5. package/dist/cjs/color/index.cjs +207 -0
  6. package/dist/cjs/constants/date.cjs +178 -0
  7. package/dist/cjs/constants/id-card.cjs +52 -0
  8. package/dist/cjs/constants/keycode.cjs +117 -0
  9. package/dist/cjs/constants/lang.cjs +13 -0
  10. package/dist/cjs/constants/math.cjs +13 -0
  11. package/dist/cjs/constants/regexp.cjs +53 -0
  12. package/dist/cjs/constants/sort.cjs +15 -0
  13. package/dist/cjs/cookie/index.cjs +73 -0
  14. package/dist/cjs/crypto/base64/base64.cjs +540 -0
  15. package/dist/cjs/crypto/base64/index.cjs +82 -0
  16. package/dist/cjs/crypto/md5/index.cjs +49 -0
  17. package/dist/cjs/crypto/md5/md5.cjs +351 -0
  18. package/dist/cjs/crypto/sha256/index.cjs +95 -0
  19. package/dist/cjs/crypto/sha256/sha256.cjs +557 -0
  20. package/dist/cjs/crypto/sm3/index.cjs +27 -0
  21. package/dist/cjs/crypto/sm3/sm3.cjs +200 -0
  22. package/dist/cjs/crypto/sm4/index.cjs +101 -0
  23. package/dist/cjs/crypto/sm4/sm4.cjs +498 -0
  24. package/dist/cjs/date/index.cjs +1310 -0
  25. package/dist/cjs/desensitized/index.cjs +78 -0
  26. package/dist/cjs/device/index.cjs +154 -0
  27. package/dist/cjs/dom/index.cjs +132 -0
  28. package/dist/cjs/file/index.cjs +343 -0
  29. package/dist/cjs/function/index.cjs +72 -0
  30. package/dist/cjs/id/index.cjs +6 -2
  31. package/dist/cjs/index.cjs +383 -7
  32. package/dist/cjs/keycode/index.cjs +30 -0
  33. package/dist/cjs/math/index.cjs +310 -0
  34. package/dist/cjs/number/index.cjs +34 -0
  35. package/dist/cjs/object/index.cjs +319 -0
  36. package/dist/cjs/pagination/index.cjs +146 -0
  37. package/dist/cjs/random/index.cjs +27 -0
  38. package/dist/cjs/regexp/index.cjs +103 -0
  39. package/dist/cjs/storage/index.cjs +14 -0
  40. package/dist/cjs/storage/localStorage.cjs +37 -0
  41. package/dist/cjs/storage/sessionStorage.cjs +37 -0
  42. package/dist/cjs/string/index.cjs +361 -0
  43. package/dist/cjs/url/index.cjs +261 -0
  44. package/dist/cjs/validate/index.cjs +484 -0
  45. package/dist/es/ID-card/index.d.ts +36 -0
  46. package/dist/es/ID-card/index.mjs +89 -0
  47. package/dist/es/array/index.d.ts +209 -0
  48. package/dist/es/array/index.mjs +447 -0
  49. package/dist/es/clipboard/index.d.ts +32 -0
  50. package/dist/es/clipboard/index.mjs +126 -0
  51. package/dist/es/color/index.d.ts +55 -0
  52. package/dist/es/color/index.mjs +197 -0
  53. package/dist/es/constants/date.d.ts +4 -0
  54. package/dist/es/constants/date.mjs +176 -0
  55. package/dist/es/constants/id-card.d.ts +4 -0
  56. package/dist/es/constants/id-card.mjs +50 -0
  57. package/dist/es/constants/index.d.ts +11 -0
  58. package/dist/es/constants/keycode.d.ts +1 -0
  59. package/dist/es/constants/keycode.mjs +115 -0
  60. package/dist/es/constants/lang.d.ts +4 -0
  61. package/dist/es/constants/lang.mjs +11 -0
  62. package/dist/es/constants/math.d.ts +4 -0
  63. package/dist/es/constants/math.mjs +11 -0
  64. package/dist/es/constants/regexp.d.ts +4 -0
  65. package/dist/es/constants/regexp.mjs +51 -0
  66. package/dist/es/constants/sort.d.ts +4 -0
  67. package/dist/es/constants/sort.mjs +13 -0
  68. package/dist/es/cookie/index.d.ts +29 -0
  69. package/dist/es/cookie/index.mjs +67 -0
  70. package/dist/es/crypto/base64/base64.d.ts +8 -0
  71. package/dist/es/crypto/base64/base64.mjs +531 -0
  72. package/dist/es/crypto/base64/index.d.ts +53 -0
  73. package/dist/es/crypto/base64/index.mjs +73 -0
  74. package/dist/es/crypto/index.d.ts +8 -0
  75. package/dist/es/crypto/md5/index.d.ts +26 -0
  76. package/dist/es/crypto/md5/index.mjs +44 -0
  77. package/dist/es/crypto/md5/md5.d.ts +11 -0
  78. package/dist/es/crypto/md5/md5.mjs +349 -0
  79. package/dist/es/crypto/sha256/index.d.ts +52 -0
  80. package/dist/es/crypto/sha256/index.mjs +86 -0
  81. package/dist/es/crypto/sha256/sha256.d.ts +82 -0
  82. package/dist/es/crypto/sha256/sha256.mjs +548 -0
  83. package/dist/es/crypto/sm3/index.d.ts +13 -0
  84. package/dist/es/crypto/sm3/index.mjs +24 -0
  85. package/dist/es/crypto/sm3/sm3.d.ts +3 -0
  86. package/dist/es/crypto/sm3/sm3.mjs +197 -0
  87. package/dist/es/crypto/sm4/index.d.ts +56 -0
  88. package/dist/es/crypto/sm4/index.mjs +95 -0
  89. package/dist/es/crypto/sm4/sm4.d.ts +48 -0
  90. package/dist/es/crypto/sm4/sm4.mjs +490 -0
  91. package/dist/es/date/index.d.ts +608 -0
  92. package/dist/es/date/index.mjs +1222 -0
  93. package/dist/es/desensitized/index.d.ts +41 -0
  94. package/dist/es/desensitized/index.mjs +72 -0
  95. package/dist/es/device/index.d.ts +73 -0
  96. package/dist/es/device/index.mjs +140 -0
  97. package/dist/es/dom/index.d.ts +60 -0
  98. package/dist/es/dom/index.mjs +122 -0
  99. package/dist/es/file/index.d.ts +93 -0
  100. package/dist/es/file/index.mjs +327 -0
  101. package/dist/es/function/index.d.ts +26 -0
  102. package/dist/es/function/index.mjs +68 -0
  103. package/dist/es/id/index.d.ts +3 -0
  104. package/dist/es/id/index.mjs +6 -2
  105. package/dist/es/index.d.ts +26 -2
  106. package/dist/es/index.mjs +40 -4
  107. package/dist/es/keycode/index.d.ts +12 -0
  108. package/dist/es/keycode/index.mjs +27 -0
  109. package/dist/es/math/index.d.ts +66 -0
  110. package/dist/es/math/index.mjs +300 -0
  111. package/dist/es/number/index.d.ts +14 -0
  112. package/dist/es/number/index.mjs +31 -0
  113. package/dist/es/object/index.d.ts +84 -0
  114. package/dist/es/object/index.mjs +306 -0
  115. package/dist/es/pagination/index.d.ts +67 -0
  116. package/dist/es/pagination/index.mjs +140 -0
  117. package/dist/es/random/index.d.ts +18 -0
  118. package/dist/es/random/index.mjs +24 -0
  119. package/dist/es/regexp/index.d.ts +63 -0
  120. package/dist/es/regexp/index.mjs +92 -0
  121. package/dist/es/storage/index.d.ts +13 -0
  122. package/dist/es/storage/index.mjs +12 -0
  123. package/dist/es/storage/localStorage.d.ts +21 -0
  124. package/dist/es/storage/localStorage.mjs +32 -0
  125. package/dist/es/storage/sessionStorage.d.ts +21 -0
  126. package/dist/es/storage/sessionStorage.mjs +32 -0
  127. package/dist/es/string/index.d.ts +124 -0
  128. package/dist/es/string/index.mjs +342 -0
  129. package/dist/es/url/index.d.ts +118 -0
  130. package/dist/es/url/index.mjs +243 -0
  131. package/dist/es/validate/index.d.ts +231 -0
  132. package/dist/es/validate/index.mjs +447 -0
  133. package/dist/index.d.ts +2394 -2
  134. package/dist/lib/index.full.umd.js +8059 -29
  135. package/dist/lib/index.full.umd.min.js +2 -2
  136. package/dist/lib/index.full.umd.min.js.map +1 -1
  137. package/dist/resolver/auto-imports.cjs +345 -2
  138. package/dist/resolver/auto-imports.mjs +345 -2
  139. package/dist/resolver/index.cjs +1 -2
  140. package/dist/resolver/index.d.ts +1 -1
  141. package/dist/resolver/index.mjs +1 -2
  142. package/package.json +16 -7
@@ -0,0 +1,126 @@
1
+ import { blobToText } from '../file/index.mjs';
2
+
3
+ /**
4
+ * @module 浏览器Clipboard
5
+ */
6
+ /**
7
+ * 获得剪切板数据
8
+ * @description 获得的剪切板的数据是会返回多个可用的MIME类型,比如是纯文本就返回一个['text/plain'],是复制的html则会返回两个可用的['text/plain','text/html'],是复制的图片则是['image/png']
9
+ * @returns {Promise} 返回剪切板的数据,是数组形式,如果是文本则是字符串,否则是blob数据
10
+ */
11
+ function getClipboard() {
12
+ return new Promise((resolve, reject) => {
13
+ if (window.navigator.clipboard) {
14
+ window.navigator.clipboard.read().then((clipboardItems) => {
15
+ const list = [];
16
+ for (const item of clipboardItems) {
17
+ for (const type of item.types) {
18
+ item.getType(type).then(async (blob) => {
19
+ // 文本类型,可以直接输出为字符串
20
+ if (blob.type.includes("text")) {
21
+ const text = await blobToText(blob);
22
+ list.push({ type: blob.type, data: text });
23
+ }
24
+ // 图片和其他文件类型,返回blob对象
25
+ else {
26
+ list.push({ type: blob.type, data: blob });
27
+ }
28
+ });
29
+ }
30
+ }
31
+ resolve(list);
32
+ });
33
+ }
34
+ else {
35
+ console.warn("not support navigator clipboard!");
36
+ }
37
+ });
38
+ }
39
+ /**
40
+ * 获得剪切板文本
41
+ * @returns {Promise} 返回剪切板文本
42
+ */
43
+ function getClipboardText() {
44
+ return new Promise((resolve, reject) => {
45
+ if (window.navigator.clipboard) {
46
+ window.navigator.clipboard
47
+ .readText()
48
+ .then((text) => {
49
+ resolve(text);
50
+ })
51
+ .catch((error) => {
52
+ reject(error);
53
+ });
54
+ }
55
+ else {
56
+ console.warn("not support navigator clipboard!");
57
+ }
58
+ });
59
+ }
60
+ /**
61
+ * 设置剪切板数据
62
+ * @description 可以设置文本或者blob类型的数据
63
+ * @param {string|Blob} data 写入的数据,可以是文本或blob数据
64
+ * @returns {Promise} 返回结果
65
+ */
66
+ function setClipboard(data) {
67
+ return new Promise((resolve, reject) => {
68
+ // 现代浏览器
69
+ if (window.navigator.clipboard) {
70
+ let clipboardItem = null;
71
+ // 是文本类型
72
+ if (typeof data === "string") {
73
+ const blob = new Blob([data], { type: "text/plain" });
74
+ clipboardItem = new window.ClipboardItem({
75
+ ["text/plain"]: blob,
76
+ });
77
+ }
78
+ // 其他文件类型
79
+ else {
80
+ clipboardItem = new window.ClipboardItem({ [data.type]: data });
81
+ }
82
+ // 写入到剪切板中
83
+ window.navigator.clipboard.write([clipboardItem]).then((success) => {
84
+ resolve(true);
85
+ }, (failed) => {
86
+ reject(false);
87
+ });
88
+ }
89
+ else {
90
+ console.warn("not support navigator clipboard!");
91
+ }
92
+ });
93
+ }
94
+ /**
95
+ * 设置剪切板文本
96
+ * @param {string} text 写入的文本
97
+ * @returns {Promise} 返回结果
98
+ */
99
+ function setClipboardText(text) {
100
+ return new Promise((resolve, reject) => {
101
+ // 现代浏览器
102
+ if (window.navigator.clipboard) {
103
+ window.navigator.clipboard.writeText(text).then((success) => {
104
+ resolve(true);
105
+ }, (failed) => {
106
+ reject(false);
107
+ });
108
+ }
109
+ else {
110
+ console.warn("not support navigator clipboard!");
111
+ }
112
+ });
113
+ }
114
+ /**
115
+ * 清空剪切板
116
+ * @returns {Promise} 返回结果
117
+ */
118
+ function clearClipboard() {
119
+ return new Promise((resolve, reject) => {
120
+ setClipboardText("")
121
+ .then(() => resolve(true))
122
+ .catch(reject);
123
+ });
124
+ }
125
+
126
+ export { clearClipboard, getClipboard, getClipboardText, setClipboard, setClipboardText };
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @module 颜色
3
+ */
4
+ /**
5
+ * rgb颜色转hex
6
+ * @param {string} rgb rgb颜色字符串
7
+ * @returns {string} 返回生成的hex颜色
8
+ */
9
+ export declare function rgbToHex(rgb: string): string;
10
+ /**
11
+ * rgba颜色转hex
12
+ * @param {string} rgba rgba颜色字符串
13
+ * @returns {string} 返回生成的hex颜色
14
+ */
15
+ export declare function rgbaToHex(rgba: string): string;
16
+ /**
17
+ * rgba颜色转hsl
18
+ * @param {string} rgba rgb颜色字符串
19
+ * @returns {string} 返回生成的hsl颜色
20
+ */
21
+ export declare function rgbaToHsl(rgba: string): string;
22
+ /**
23
+ * hex颜色转rgb
24
+ * @param {string} hex hex颜色字符串
25
+ * @returns {string} 返回生成的rgb颜色
26
+ */
27
+ export declare function hexToRgb(hex: string): string;
28
+ /**
29
+ * hex颜色转rgba
30
+ * @param {string} hex hex颜色字符串
31
+ * @param {number} opacity 透明度
32
+ * @returns {string} 返回生成的rgba颜色
33
+ */
34
+ export declare function hexToRgba(hex: string, opacity?: number): string;
35
+ /**
36
+ * hex颜色转hsl
37
+ * @param {string} hex hex颜色字符串
38
+ * @returns {string} 返回生成的hsl颜色
39
+ */
40
+ export declare function hexToHsl(hex: string): string;
41
+ /**
42
+ * 随机生成hex颜色
43
+ * @returns {string} 返回生成的十六进制颜色
44
+ */
45
+ export declare function getDrawHex(): string;
46
+ /**
47
+ * 随机生成rgb颜色
48
+ * @returns {string} 返回生成的 rgb 颜色
49
+ */
50
+ export declare function getDrawRgb(): string;
51
+ /**
52
+ * 随机生成rgba颜色
53
+ * @returns {string} 返回生成的 rgba 颜色
54
+ */
55
+ export declare function getDrawRgba(): string;
@@ -0,0 +1,197 @@
1
+ /**
2
+ * @module 颜色
3
+ */
4
+ /**
5
+ * rgb颜色转hex
6
+ * @param {string} rgb rgb颜色字符串
7
+ * @returns {string} 返回生成的hex颜色
8
+ */
9
+ function rgbToHex(rgb) {
10
+ const arr = rgb.split(",");
11
+ const r = parseInt(arr[0].split("(")[1]);
12
+ const g = parseInt(arr[1]);
13
+ const b = parseInt(arr[2].split(")")[0]);
14
+ return "#" + _hex(r) + _hex(g) + _hex(b);
15
+ }
16
+ /**
17
+ * rgba颜色转hex
18
+ * @param {string} rgba rgba颜色字符串
19
+ * @returns {string} 返回生成的hex颜色
20
+ */
21
+ function rgbaToHex(rgba) {
22
+ const arr = rgba.split(",");
23
+ const r = parseInt(arr[0].split("(")[1]);
24
+ const g = parseInt(arr[1]);
25
+ const b = parseInt(arr[2]);
26
+ const a = parseFloat(arr[3].split(")")[0]);
27
+ return `#${_hex(Math.round(a * 256 - 1))}${_hex(r)}${_hex(g)}${_hex(b)}`;
28
+ }
29
+ /**
30
+ * rgba颜色转hsl
31
+ * @param {string} rgba rgb颜色字符串
32
+ * @returns {string} 返回生成的hsl颜色
33
+ */
34
+ function rgbaToHsl(rgba) {
35
+ const arr = rgba.split(",");
36
+ const r = parseInt(arr[0].split("(")[1]) / 255;
37
+ const g = parseInt(arr[1]) / 255;
38
+ const b = parseInt(arr[2]) / 255;
39
+ const a = parseFloat(arr[3] && arr[3].split(")")[0]);
40
+ const max = Math.max(r, g, b), min = Math.min(r, g, b);
41
+ let h = 0, s = 0;
42
+ const l = (max + min) / 2;
43
+ if (max === min) {
44
+ h = s = 0;
45
+ }
46
+ else {
47
+ const d = max - min;
48
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
49
+ switch (max) {
50
+ case r:
51
+ h = (g - b) / d + (g < b ? 6 : 0);
52
+ break;
53
+ case g:
54
+ h = (b - r) / d + 2;
55
+ break;
56
+ case b:
57
+ h = (r - g) / d + 4;
58
+ break;
59
+ }
60
+ h /= 6;
61
+ }
62
+ if (a) {
63
+ return `hsla(${Math.round(h * 360)},${Math.round(s * 100)}%,${Math.round(l * 100)}%,${a})`;
64
+ }
65
+ return `hsl(${Math.round(h * 360)},${Math.round(s * 100)}%,${Math.round(l * 100)}%)`;
66
+ }
67
+ /**
68
+ * hex颜色转rgb
69
+ * @param {string} hex hex颜色字符串
70
+ * @returns {string} 返回生成的rgb颜色
71
+ */
72
+ function hexToRgb(hex) {
73
+ const color = { r: 0, g: 0, b: 0};
74
+ const rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
75
+ const hexStr = hex.replace(rgx, function (m, r, g, b) {
76
+ return r + r + g + g + b + b;
77
+ });
78
+ const rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hexStr);
79
+ if (!rgb) {
80
+ throw new Error(`Invalid hex color: ${hex}`);
81
+ }
82
+ color.r = parseInt(rgb[1], 16);
83
+ color.g = parseInt(rgb[2], 16);
84
+ color.b = parseInt(rgb[3], 16);
85
+ return `rgb(${color.r},${color.g},${color.b})`;
86
+ }
87
+ /**
88
+ * hex颜色转rgba
89
+ * @param {string} hex hex颜色字符串
90
+ * @param {number} opacity 透明度
91
+ * @returns {string} 返回生成的rgba颜色
92
+ */
93
+ function hexToRgba(hex, opacity = 1) {
94
+ const color = { r: 0, g: 0, b: 0, o: 0 };
95
+ const rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
96
+ const hexStr = hex.replace(rgx, function (m, r, g, b) {
97
+ return r + r + g + g + b + b;
98
+ });
99
+ const rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hexStr);
100
+ if (!rgb) {
101
+ throw new Error(`Invalid hex color: ${hex}`);
102
+ }
103
+ color.r = parseInt(rgb[1], 16);
104
+ color.g = parseInt(rgb[2], 16);
105
+ color.b = parseInt(rgb[3], 16);
106
+ color.o = opacity;
107
+ return `rgba(${color.r},${color.g},${color.b},${color.o})`;
108
+ }
109
+ /**
110
+ * hex颜色转hsl
111
+ * @param {string} hex hex颜色字符串
112
+ * @returns {string} 返回生成的hsl颜色
113
+ */
114
+ function hexToHsl(hex) {
115
+ // 先解析为rgb
116
+ const rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
117
+ const hexStr = hex.replace(rgx, function (m, r, g, b) {
118
+ return r + r + g + g + b + b;
119
+ });
120
+ const rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hexStr);
121
+ if (!rgb) {
122
+ throw new Error(`Invalid hex color: ${hex}`);
123
+ }
124
+ // 再组装为hsl格式
125
+ const r = parseInt(rgb[1], 16) / 255;
126
+ const g = parseInt(rgb[2], 16) / 255;
127
+ const b = parseInt(rgb[3], 16) / 255;
128
+ const max = Math.max(r, g, b), min = Math.min(r, g, b);
129
+ let h = 0, s = 0;
130
+ const l = (max + min) / 2;
131
+ if (max === min) {
132
+ h = s = 0;
133
+ }
134
+ else {
135
+ const d = max - min;
136
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
137
+ switch (max) {
138
+ case r:
139
+ h = (g - b) / d + (g < b ? 6 : 0);
140
+ break;
141
+ case g:
142
+ h = (b - r) / d + 2;
143
+ break;
144
+ case b:
145
+ h = (r - g) / d + 4;
146
+ break;
147
+ }
148
+ h /= 6;
149
+ }
150
+ return `hsl(${Math.round(h * 360)},${Math.round(s * 100)}%,${Math.round(l * 100)}%)`;
151
+ }
152
+ /**
153
+ * 随机生成hex颜色
154
+ * @returns {string} 返回生成的十六进制颜色
155
+ */
156
+ function getDrawHex() {
157
+ return ("#" +
158
+ (function (h) {
159
+ return new Array(7 - h.length).join("0") + h;
160
+ })(((Math.random() * 0x1000000) << 0).toString(16)));
161
+ }
162
+ /**
163
+ * 随机生成rgb颜色
164
+ * @returns {string} 返回生成的 rgb 颜色
165
+ */
166
+ function getDrawRgb() {
167
+ const r = Math.floor(Math.random() * 256);
168
+ const g = Math.floor(Math.random() * 256);
169
+ const b = Math.floor(Math.random() * 256);
170
+ return `rgb(${r},${g},${b})`;
171
+ }
172
+ /**
173
+ * 随机生成rgba颜色
174
+ * @returns {string} 返回生成的 rgba 颜色
175
+ */
176
+ function getDrawRgba() {
177
+ const r = Math.floor(Math.random() * 256);
178
+ const g = Math.floor(Math.random() * 256);
179
+ const b = Math.floor(Math.random() * 256);
180
+ const a = Number(Math.random()).toFixed(2);
181
+ return `rgba(${r},${g},${b},${a})`;
182
+ }
183
+ // 内部函数
184
+ /**
185
+ * 颜色值转换
186
+ * @param {number} num 转换的值
187
+ * @returns
188
+ */
189
+ function _hex(num) {
190
+ if (num > 255) {
191
+ throw "'" + num + "'' is greater than 255(0xff);";
192
+ }
193
+ const str = Number(num).toString(16);
194
+ return ("0" + str).slice(-2);
195
+ }
196
+
197
+ export { getDrawHex, getDrawRgb, getDrawRgba, hexToHsl, hexToRgb, hexToRgba, rgbToHex, rgbaToHex, rgbaToHsl };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 日期
3
+ */
4
+ export declare const DATE: Record<string, any>;
@@ -0,0 +1,176 @@
1
+ /**
2
+ * 日期
3
+ */
4
+ const DATE = {
5
+ // 上午和下午
6
+ AM_PM: {
7
+ zh: {
8
+ AM: "上午",
9
+ PM: "下午",
10
+ },
11
+ en: {
12
+ AM: "AM",
13
+ PM: "PM",
14
+ },
15
+ },
16
+ // 周
17
+ WEEK: {
18
+ zh: {
19
+ FULL: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
20
+ SHORT: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
21
+ MINI: ["日", "一", "二", "三", "四", "五", "六"],
22
+ },
23
+ en: {
24
+ FULL: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
25
+ SHORT: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
26
+ MINI: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
27
+ },
28
+ },
29
+ // 月
30
+ MONTH: {
31
+ zh: {
32
+ FULL: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
33
+ SHORT: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"],
34
+ },
35
+ en: {
36
+ FULL: [
37
+ "January",
38
+ "February",
39
+ "March",
40
+ "April",
41
+ "May",
42
+ "June",
43
+ "July",
44
+ "August",
45
+ "September",
46
+ "October",
47
+ "November",
48
+ "December",
49
+ ],
50
+ SHORT: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
51
+ },
52
+ },
53
+ // 季度
54
+ QUARTER: {
55
+ zh: {
56
+ FULL: ["第一季度", "第二季度", "第三季度", "第四季度"],
57
+ SHORT: ["一季度", "二季度", "三季度", "四季度"],
58
+ MINI: ["一", "二", "三", "四"],
59
+ },
60
+ en: {
61
+ FULL: ["quarter 1st", "quarter 2nd", "quarter 3rd", "quarter 4th"],
62
+ SHORT: ["Q1th", "Q2nd", "Q3rd", "Q4th"],
63
+ MINI: ["Q1", "Q2", "Q3", "Q4"],
64
+ },
65
+ },
66
+ // 已过日期类型
67
+ OVER_TIME: {
68
+ zh: {
69
+ YEAR: "年",
70
+ MONTH: "月",
71
+ DATE: "日",
72
+ HOUR: "时",
73
+ MINUTE: "分",
74
+ SECOND: "秒",
75
+ MILLISECOND: "毫秒",
76
+ DAY: "天",
77
+ QUARTER: "季度",
78
+ },
79
+ en: {
80
+ YEAR: "year",
81
+ MONTH: "month",
82
+ DATE: "date",
83
+ HOUR: "hour",
84
+ MINUTE: "minute",
85
+ SECOND: "second",
86
+ MILLISECOND: "millisecond",
87
+ DAY: "day",
88
+ QUARTER: "quarter",
89
+ },
90
+ },
91
+ // 时间节点
92
+ PASS_TIME: {
93
+ zh: {
94
+ YEAR: "年前",
95
+ MONTH: "个月前",
96
+ DAY: "天前",
97
+ BEFORE_YESTERDAY: "前天",
98
+ YESTERDAY: "昨天",
99
+ TODAY: "今天",
100
+ HOUR: "小时前",
101
+ MINUTE: "分钟前",
102
+ JUST: "刚刚",
103
+ },
104
+ en: {
105
+ YEAR: " year ago",
106
+ MONTH: " month ago",
107
+ DAY: " day ago",
108
+ BEFORE_YESTERDAY: "before yesterday",
109
+ YESTERDAY: " yesterday",
110
+ TODAY: " today",
111
+ HOUR: " hour ago",
112
+ MINUTE: " minute ago",
113
+ JUST: " just",
114
+ },
115
+ },
116
+ // 节假日
117
+ HOLIDAY: {
118
+ zh: ["元旦", "春节", "清明节", "劳动节", "端午节", "中秋节", "国庆节"],
119
+ en: [
120
+ "New Year‘s Day",
121
+ "Spring Festival",
122
+ "Tomb Sweeping Day",
123
+ "Labor Day",
124
+ "Dragon Boat Festival",
125
+ "Mid-Autumn Day",
126
+ "National Day",
127
+ ],
128
+ },
129
+ // 星座
130
+ ZODIAC: {
131
+ zh: [
132
+ "摩羯座",
133
+ "水瓶座",
134
+ "双鱼座",
135
+ "白羊座",
136
+ "金牛座",
137
+ "双子座",
138
+ "巨蟹座",
139
+ "狮子座",
140
+ "处女座",
141
+ "天秤座",
142
+ "天蝎座",
143
+ "射手座",
144
+ ],
145
+ en: [
146
+ "Capricorn",
147
+ "Aquarius",
148
+ "Pisces",
149
+ "Aries",
150
+ "Taurus",
151
+ "Gemini",
152
+ "Cancer",
153
+ "Leo",
154
+ "Virgo",
155
+ "Libra",
156
+ "Scorpio",
157
+ "Sagittarius",
158
+ ],
159
+ },
160
+ // 生肖
161
+ CHINESE_ZODIAC: {
162
+ zh: ["鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"],
163
+ en: ["Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"],
164
+ },
165
+ // 天干地支
166
+ HEAVENLY_STEMS: {
167
+ zh: ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"],
168
+ en: ["Jia", "Yi", "Bing", "Ding", "Wu", "Ji", "Geng", "Xin", "Ren", "Gui"],
169
+ },
170
+ EARTHLY_BRANCHES: {
171
+ zh: ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"],
172
+ en: ["Zi", "Chou", "Yin", "Mao", "Chen", "Si", "Wu", "Wei", "Shen", "You", "Xu", "Hai"],
173
+ },
174
+ };
175
+
176
+ export { DATE };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 身份证号
3
+ */
4
+ export declare const ID_CARD: Record<string, any>;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * 身份证号
3
+ */
4
+ const ID_CARD = {
5
+ // 身份证号对应的省
6
+ PROVINCE: {
7
+ 11: "北京",
8
+ 12: "天津",
9
+ 13: "河北",
10
+ 14: "山西",
11
+ 15: "内蒙古",
12
+ 21: "辽宁",
13
+ 22: "吉林",
14
+ 23: "黑龙江",
15
+ 31: "上海",
16
+ 32: "江苏",
17
+ 33: "浙江",
18
+ 34: "安徽",
19
+ 35: "福建",
20
+ 36: "江西",
21
+ 37: "山东",
22
+ 41: "河南",
23
+ 42: "湖北",
24
+ 43: "湖南",
25
+ 44: "广东",
26
+ 45: "广西",
27
+ 46: "海南",
28
+ 50: "重庆",
29
+ 51: "四川",
30
+ 52: "贵州",
31
+ 53: "云南",
32
+ 54: "西藏",
33
+ 61: "陕西",
34
+ 62: "甘肃",
35
+ 63: "青海",
36
+ 64: "宁夏",
37
+ 65: "新疆",
38
+ 71: "台湾",
39
+ 81: "香港",
40
+ 82: "澳门",
41
+ 91: "国外",
42
+ },
43
+ // 性别
44
+ SEX: {
45
+ MAN: "男",
46
+ WOMAN: "女",
47
+ },
48
+ };
49
+
50
+ export { ID_CARD };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * 常量
3
+ * @module 常量集合
4
+ */
5
+ export * from "./sort";
6
+ export * from "./math";
7
+ export * from "./lang";
8
+ export * from "./regexp";
9
+ export * from "./date";
10
+ export * from "./keycode";
11
+ export * from "./id-card";
@@ -0,0 +1 @@
1
+ export declare const KEYCODE: Record<string, string>;