@unicom-cloud/utils 0.1.11 → 0.1.12

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 (107) hide show
  1. package/date/index.js +22 -0
  2. package/date.js +9 -0
  3. package/index.js +56 -54
  4. package/lunar/index.js +36 -0
  5. package/lunar/lib/Holiday.js +42 -0
  6. package/lunar/lib/HolidayUtil.js +128 -0
  7. package/lunar/lib/I18n.js +1005 -0
  8. package/lunar/lib/JieQi.js +40 -0
  9. package/lunar/lib/Lunar.js +1035 -0
  10. package/lunar/lib/LunarMonth.js +150 -0
  11. package/lunar/lib/LunarTime.js +138 -0
  12. package/lunar/lib/LunarUtil.js +1752 -0
  13. package/lunar/lib/LunarYear.js +616 -0
  14. package/lunar/lib/ShouXingUtil.js +6915 -0
  15. package/lunar/lib/Solar.js +311 -0
  16. package/lunar/lib/SolarHalfYear.js +45 -0
  17. package/lunar/lib/SolarMonth.js +55 -0
  18. package/lunar/lib/SolarSeason.js +42 -0
  19. package/lunar/lib/SolarUtil.js +256 -0
  20. package/lunar/lib/SolarWeek.js +153 -0
  21. package/lunar/lib/SolarYear.js +35 -0
  22. package/lunar/lib/index.js +35 -0
  23. package/lunar.js +36 -0
  24. package/package.json +1 -1
  25. package/snapdom/src/api/preCache.js +26 -36
  26. package/snapdom/src/api/snapdom.js +78 -61
  27. package/snapdom/src/core/capture.js +54 -54
  28. package/snapdom/src/core/prepare.js +46 -37
  29. package/snapdom/src/modules/fonts.js +90 -92
  30. package/snapdom/src/modules/iconFonts.js +28 -0
  31. package/snapdom/src/modules/images.js +6 -6
  32. package/snapdom/src/modules/pseudo.js +51 -49
  33. package/snapdom/src/modules/styles.js +27 -7
  34. package/snapdom/src/modules/svgDefs.js +26 -0
  35. package/snapdom/src/utils/helpers.js +150 -103
  36. package/tinycolor/index.js +46 -0
  37. package/tinycolor/src/conversion.js +143 -0
  38. package/tinycolor/src/css-color-names.js +153 -0
  39. package/tinycolor/src/format-input.js +77 -0
  40. package/tinycolor/src/from-ratio.js +21 -0
  41. package/tinycolor/src/index.js +404 -0
  42. package/tinycolor/src/random.js +221 -0
  43. package/tinycolor/src/readability.js +37 -0
  44. package/tinycolor/src/to-ms-filter.js +15 -0
  45. package/tinycolor/src/util.js +32 -0
  46. package/tinycolor.js +46 -0
  47. package/tree/index.js +10 -8
  48. package/tree.js +9 -7
  49. package/types/date/index.d.ts +4 -0
  50. package/types/index.d.ts +4 -3
  51. package/types/lunar/index.d.ts +3 -0
  52. package/types/lunar/lib/Holiday.d.ts +17 -0
  53. package/types/lunar/lib/HolidayUtil.d.ts +23 -0
  54. package/types/lunar/lib/I18n.d.ts +23 -0
  55. package/types/lunar/lib/JieQi.d.ts +15 -0
  56. package/types/lunar/lib/Lunar.d.ts +245 -0
  57. package/types/lunar/lib/LunarMonth.d.ts +35 -0
  58. package/types/lunar/lib/LunarTime.d.ts +40 -0
  59. package/types/lunar/lib/LunarUtil.d.ts +128 -0
  60. package/types/lunar/lib/LunarYear.d.ts +61 -0
  61. package/types/lunar/lib/ShouXingUtil.d.ts +38 -0
  62. package/types/lunar/lib/Solar.d.ts +51 -0
  63. package/types/lunar/lib/SolarHalfYear.d.ts +15 -0
  64. package/types/lunar/lib/SolarMonth.d.ts +16 -0
  65. package/types/lunar/lib/SolarSeason.d.ts +15 -0
  66. package/types/lunar/lib/SolarUtil.d.ts +20 -0
  67. package/types/lunar/lib/SolarWeek.d.ts +23 -0
  68. package/types/lunar/lib/SolarYear.d.ts +12 -0
  69. package/types/lunar/lib/index.d.ts +17 -0
  70. package/types/snapdom/src/core/prepare.d.ts +1 -1
  71. package/types/snapdom/src/modules/fonts.d.ts +1 -3
  72. package/types/snapdom/src/modules/iconFonts.d.ts +2 -0
  73. package/types/snapdom/src/modules/pseudo.d.ts +1 -1
  74. package/types/snapdom/src/modules/styles.d.ts +1 -10
  75. package/types/snapdom/src/modules/svgDefs.d.ts +19 -0
  76. package/types/snapdom/src/utils/helpers.d.ts +1 -1
  77. package/types/tinycolor/index.d.ts +2 -0
  78. package/types/tinycolor/src/conversion.d.ts +79 -0
  79. package/types/tinycolor/src/css-color-names.d.ts +4 -0
  80. package/types/tinycolor/src/format-input.d.ts +38 -0
  81. package/types/tinycolor/src/from-ratio.d.ts +14 -0
  82. package/types/tinycolor/src/index.d.ts +214 -0
  83. package/types/tinycolor/src/interfaces.d.ts +57 -0
  84. package/types/tinycolor/src/public_api.d.ts +10 -0
  85. package/types/tinycolor/src/random.d.ts +24 -0
  86. package/types/tinycolor/src/readability.d.ts +46 -0
  87. package/types/tinycolor/src/to-ms-filter.d.ts +5 -0
  88. package/types/tinycolor/src/umd_api.d.ts +22 -0
  89. package/types/tinycolor/src/util.d.ts +36 -0
  90. package/types/tree/index.d.ts +1 -0
  91. package/types/ui-color/compareColorByRange.d.ts +2 -0
  92. package/types/ui-color/index.d.ts +183 -0
  93. package/ui-color/compareColorByRange.js +9 -0
  94. package/ui-color/index.js +155 -0
  95. package/uiColor.js +28 -0
  96. package/convertTime.js +0 -4
  97. package/dayjs/index.js +0 -15
  98. package/dayjs.js +0 -5
  99. package/lunar-converter/index.js +0 -641
  100. package/lunarConverter.js +0 -4
  101. package/searchTree.js +0 -4
  102. package/types/dayjs/index.d.ts +0 -1
  103. package/types/lunar-converter/index.d.ts +0 -113
  104. /package/{convert-time/index.js → date/convertTime.js} +0 -0
  105. /package/{search-tree/index.js → tree/searchTree.js} +0 -0
  106. /package/types/{convert-time/index.d.ts → date/convertTime.d.ts} +0 -0
  107. /package/types/{search-tree/index.d.ts → tree/searchTree.d.ts} +0 -0
@@ -6,3 +6,4 @@ export function getLabelFromDictionaryByValue(a: any, value: any, 保底?: boole
6
6
  export function getChildWithParentBy(root: any, key: any, value: any, childrenKey?: string): null | undefined;
7
7
  export function getItemBy2(root: any, key: any, value: any, childrenKey?: string): any;
8
8
  export default getItemBy;
9
+ export { default as searchTree } from "./searchTree";
@@ -0,0 +1,2 @@
1
+ export default compareColorByRange;
2
+ declare function compareColorByRange(range?: number[]): (percentage?: number) => string;
@@ -0,0 +1,183 @@
1
+ export { default as compareColorByRange } from "./compareColorByRange";
2
+ export namespace blue {
3
+ namespace name {
4
+ let zh: string;
5
+ let en: string;
6
+ }
7
+ let value: string;
8
+ }
9
+ export const colorPresets: {
10
+ key: string;
11
+ name: {
12
+ zh: string;
13
+ en: string;
14
+ };
15
+ primary: string;
16
+ light: TinyColor[];
17
+ dark: TinyColor[];
18
+ }[];
19
+ export const colors: {
20
+ name: {
21
+ zh: string;
22
+ en: string;
23
+ };
24
+ value: string;
25
+ }[];
26
+ export namespace cyan {
27
+ export namespace name_1 {
28
+ let zh_1: string;
29
+ export { zh_1 as zh };
30
+ let en_1: string;
31
+ export { en_1 as en };
32
+ }
33
+ export { name_1 as name };
34
+ let value_1: string;
35
+ export { value_1 as value };
36
+ }
37
+ export function generate(options?: {}): TinyColor[];
38
+ export function generateDark(options?: {}): TinyColor[];
39
+ export namespace gold {
40
+ export namespace name_2 {
41
+ let zh_2: string;
42
+ export { zh_2 as zh };
43
+ let en_2: string;
44
+ export { en_2 as en };
45
+ }
46
+ export { name_2 as name };
47
+ let value_2: string;
48
+ export { value_2 as value };
49
+ }
50
+ export namespace gray {
51
+ export namespace name_3 {
52
+ let zh_3: string;
53
+ export { zh_3 as zh };
54
+ let en_3: string;
55
+ export { en_3 as en };
56
+ }
57
+ export { name_3 as name };
58
+ let value_3: string;
59
+ export { value_3 as value };
60
+ }
61
+ export namespace grayPresets {
62
+ export let key: string;
63
+ import name_4 = gray.name;
64
+ export { name_4 as name };
65
+ import primary = gray.value;
66
+ export { primary };
67
+ export let light: TinyColor[];
68
+ export let dark: TinyColor[];
69
+ }
70
+ export namespace green {
71
+ export namespace name_5 {
72
+ let zh_4: string;
73
+ export { zh_4 as zh };
74
+ let en_4: string;
75
+ export { en_4 as en };
76
+ }
77
+ export { name_5 as name };
78
+ let value_4: string;
79
+ export { value_4 as value };
80
+ }
81
+ export const LENGTH: 10;
82
+ export namespace lime {
83
+ export namespace name_6 {
84
+ let zh_5: string;
85
+ export { zh_5 as zh };
86
+ let en_5: string;
87
+ export { en_5 as en };
88
+ }
89
+ export { name_6 as name };
90
+ let value_5: string;
91
+ export { value_5 as value };
92
+ }
93
+ export namespace magenta {
94
+ export namespace name_7 {
95
+ let zh_6: string;
96
+ export { zh_6 as zh };
97
+ let en_6: string;
98
+ export { en_6 as en };
99
+ }
100
+ export { name_7 as name };
101
+ let value_6: string;
102
+ export { value_6 as value };
103
+ }
104
+ export namespace orange {
105
+ export namespace name_8 {
106
+ let zh_7: string;
107
+ export { zh_7 as zh };
108
+ let en_7: string;
109
+ export { en_7 as en };
110
+ }
111
+ export { name_8 as name };
112
+ let value_7: string;
113
+ export { value_7 as value };
114
+ }
115
+ export namespace orangered {
116
+ export namespace name_9 {
117
+ let zh_8: string;
118
+ export { zh_8 as zh };
119
+ let en_8: string;
120
+ export { en_8 as en };
121
+ }
122
+ export { name_9 as name };
123
+ let value_8: string;
124
+ export { value_8 as value };
125
+ }
126
+ export function palette(options?: {}): TinyColor;
127
+ export function paletteDark(options?: {}): TinyColor;
128
+ export namespace pinkpurple {
129
+ export namespace name_10 {
130
+ let zh_9: string;
131
+ export { zh_9 as zh };
132
+ let en_9: string;
133
+ export { en_9 as en };
134
+ }
135
+ export { name_10 as name };
136
+ let value_9: string;
137
+ export { value_9 as value };
138
+ }
139
+ export namespace primary {
140
+ export namespace name_11 {
141
+ let zh_10: string;
142
+ export { zh_10 as zh };
143
+ let en_10: string;
144
+ export { en_10 as en };
145
+ }
146
+ export { name_11 as name };
147
+ let value_10: string;
148
+ export { value_10 as value };
149
+ }
150
+ export namespace purple {
151
+ export namespace name_12 {
152
+ let zh_11: string;
153
+ export { zh_11 as zh };
154
+ let en_11: string;
155
+ export { en_11 as en };
156
+ }
157
+ export { name_12 as name };
158
+ let value_11: string;
159
+ export { value_11 as value };
160
+ }
161
+ export namespace red {
162
+ export namespace name_13 {
163
+ let zh_12: string;
164
+ export { zh_12 as zh };
165
+ let en_12: string;
166
+ export { en_12 as en };
167
+ }
168
+ export { name_13 as name };
169
+ let value_12: string;
170
+ export { value_12 as value };
171
+ }
172
+ export namespace yellow {
173
+ export namespace name_14 {
174
+ let zh_13: string;
175
+ export { zh_13 as zh };
176
+ let en_13: string;
177
+ export { en_13 as en };
178
+ }
179
+ export { name_14 as name };
180
+ let value_13: string;
181
+ export { value_13 as value };
182
+ }
183
+ import TinyColor from '../tinycolor';
@@ -0,0 +1,9 @@
1
+ function i(r = [34797, 15747172]) {
2
+ return (n = 1) => {
3
+ const o = r, t = Math.log(256) / Math.log(2), e = o[0] >>> t * 2 & 255, g = o[0] >>> t * 1 & 255, l = o[0] >>> t * 0 & 255, c = o[1] >>> t * 2 & 255, s = o[1] >>> t * 1 & 255, f = o[1] >>> t * 0 & 255, a = c - (c - e) * n, b = s - (s - g) * n, h = f - (f - l) * n;
4
+ return `rgb(${a},${b},${h})`;
5
+ };
6
+ }
7
+ export {
8
+ i as default
9
+ };
@@ -0,0 +1,155 @@
1
+ import { TinyColor as e } from "../tinycolor/src/index.js";
2
+ import { default as Q } from "./compareColorByRange.js";
3
+ const c = 10, A = {
4
+ name: { zh: "浪漫红", en: "red" },
5
+ value: "#F53F3F"
6
+ }, d = {
7
+ name: { zh: "晚秋红", en: "orangered" },
8
+ value: "#FF702E"
9
+ }, k = {
10
+ name: { zh: "活力橙", en: "orange" },
11
+ value: "#FFA500"
12
+ }, C = {
13
+ name: { zh: "黄昏", en: "gold" },
14
+ value: "#FFBD14"
15
+ }, b = {
16
+ name: { zh: "柠檬黄", en: "yellow" },
17
+ value: "#FFE014"
18
+ }, _ = {
19
+ name: { zh: "新生绿", en: "lime" },
20
+ value: "#A1E619"
21
+ }, M = {
22
+ name: { zh: "仙野绿", en: "green" },
23
+ value: "#00B82B"
24
+ }, x = {
25
+ name: { zh: "碧涛青", en: "cyan" },
26
+ value: "#0BD0D0"
27
+ }, G = {
28
+ name: { zh: "海蔚蓝", en: "blue" },
29
+ value: "#2E8FFF"
30
+ }, H = {
31
+ name: { zh: "主题色(极致蓝)", en: "primary" },
32
+ value: "#1A5EFF"
33
+ }, L = {
34
+ name: { zh: "暗夜紫", en: "purple" },
35
+ value: "#7126D9"
36
+ }, P = {
37
+ name: { zh: "青春紫", en: "pinkpurple" },
38
+ value: "#D91AD9"
39
+ }, T = {
40
+ name: { zh: "品红", en: "magenta" },
41
+ value: "#FF299F"
42
+ }, s = {
43
+ name: { zh: "中性灰", en: "gray" },
44
+ value: "#6B6C6D"
45
+ }, N = [
46
+ A,
47
+ d,
48
+ k,
49
+ C,
50
+ b,
51
+ _,
52
+ M,
53
+ x,
54
+ G,
55
+ H,
56
+ L,
57
+ P,
58
+ T
59
+ ], R = {
60
+ key: s.name?.en ?? s.name?.zh ?? s.name,
61
+ name: s.name,
62
+ primary: s.value,
63
+ light: [
64
+ new e("#F7F8F9"),
65
+ new e("#F2F3F4"),
66
+ new e("#E5E6E7"),
67
+ new e("#C9CACB"),
68
+ new e("#A9ABAC"),
69
+ new e("#868788"),
70
+ new e(s.value),
71
+ new e("#4D4E4F"),
72
+ new e("#28292A"),
73
+ new e("#1E1F20")
74
+ ],
75
+ dark: [
76
+ new e("#121213"),
77
+ new e("#1C1C1D"),
78
+ new e("#404142"),
79
+ new e("#5E5F60"),
80
+ new e("#797A7B"),
81
+ new e("#9C9E9F"),
82
+ new e("#BCBDBE"),
83
+ new e("#D8D9DB"),
84
+ new e("#E4E6E8"),
85
+ new e("#E8EBEE")
86
+ ]
87
+ }, J = N.map((n, l, i) => {
88
+ const r = n.name, a = r?.en ?? r?.zh ?? r, t = n.value;
89
+ return {
90
+ key: a,
91
+ name: r,
92
+ primary: t,
93
+ light: j({ color: t, length: c }),
94
+ dark: q({ color: t, length: c })
95
+ };
96
+ }).concat([R]);
97
+ function f(n = {}) {
98
+ const { length: l, color: i, level: r } = n, a = (l ?? c) / 2 + 1, t = r ?? a;
99
+ let u = new e(i);
100
+ const w = u.toHsv(), g = w.h, o = w.s, m = w.v, y = g === 0 && o === 0, E = t < a, v = Math.abs(a - t), B = 1, p = 0.1;
101
+ let h = o;
102
+ h > p && (E ? h = o - (o - p) / (a - 1) * v : h = o + (B - o) / (a - 1) * v), y && (h = o);
103
+ const D = y ? 0.97 : 1, z = 0.1;
104
+ let F = m;
105
+ return F > z && (E ? F = m + (D - m) / (a - 1) * v : F = m - (m - z) / (a - 1) * v), u = new e({
106
+ h: g,
107
+ s: h,
108
+ v: F
109
+ }), n.dark && (u = u.darken(n.amount ?? 10)), u;
110
+ }
111
+ function S(n = {}) {
112
+ return f({ ...n, dark: !0 });
113
+ }
114
+ function j(n = {}) {
115
+ const { length: l } = n;
116
+ return Array.from(new Array(l ?? c), (r, a) => {
117
+ const t = a + 1;
118
+ return f({ ...n, level: t });
119
+ });
120
+ }
121
+ function q(n = {}) {
122
+ const { length: l } = n;
123
+ return Array.from(new Array(l ?? c), (r, a) => {
124
+ const t = a + 1;
125
+ return S({
126
+ ...n,
127
+ level: c - t + 1
128
+ });
129
+ });
130
+ }
131
+ export {
132
+ c as LENGTH,
133
+ G as blue,
134
+ J as colorPresets,
135
+ N as colors,
136
+ Q as compareColorByRange,
137
+ x as cyan,
138
+ j as generate,
139
+ q as generateDark,
140
+ C as gold,
141
+ s as gray,
142
+ R as grayPresets,
143
+ M as green,
144
+ _ as lime,
145
+ T as magenta,
146
+ k as orange,
147
+ d as orangered,
148
+ f as palette,
149
+ S as paletteDark,
150
+ P as pinkpurple,
151
+ H as primary,
152
+ L as purple,
153
+ A as red,
154
+ b as yellow
155
+ };
package/uiColor.js ADDED
@@ -0,0 +1,28 @@
1
+ import "./tinycolor/src/index.js";
2
+ import { default as o } from "./ui-color/compareColorByRange.js";
3
+ import { LENGTH as t, blue as p, colorPresets as g, colors as n, cyan as m, generate as s, generateDark as y, gold as c, gray as d, grayPresets as i, green as u, lime as f, magenta as k, orange as x, orangered as D, palette as P, paletteDark as b, pinkpurple as w, primary as B, purple as C, red as E, yellow as G } from "./ui-color/index.js";
4
+ export {
5
+ t as LENGTH,
6
+ p as blue,
7
+ g as colorPresets,
8
+ n as colors,
9
+ o as compareColorByRange,
10
+ m as cyan,
11
+ s as generate,
12
+ y as generateDark,
13
+ c as gold,
14
+ d as gray,
15
+ i as grayPresets,
16
+ u as green,
17
+ f as lime,
18
+ k as magenta,
19
+ x as orange,
20
+ D as orangered,
21
+ P as palette,
22
+ b as paletteDark,
23
+ w as pinkpurple,
24
+ B as primary,
25
+ C as purple,
26
+ E as red,
27
+ G as yellow
28
+ };
package/convertTime.js DELETED
@@ -1,4 +0,0 @@
1
- import { default as o } from "./convert-time/index.js";
2
- export {
3
- o as default
4
- };
package/dayjs/index.js DELETED
@@ -1,15 +0,0 @@
1
- import a from "dayjs";
2
- function s(e, n) {
3
- let t = a.duration(e, n || "minutes");
4
- return [
5
- { value: t.years(), unit: "年" },
6
- { value: t.months(), unit: "个月" },
7
- { value: t.days(), unit: "天" },
8
- { value: t.hours(), unit: "小时" },
9
- { value: t.minutes(), unit: "分钟" },
10
- { value: t.seconds(), unit: "秒" }
11
- ].filter((u) => u.value > 0).map((u, o, r) => Math.floor(u.value) + u.unit).join("");
12
- }
13
- export {
14
- s as convertToDurationBasedOnTimeUnits
15
- };
package/dayjs.js DELETED
@@ -1,5 +0,0 @@
1
- import "dayjs";
2
- import { convertToDurationBasedOnTimeUnits as e } from "./dayjs/index.js";
3
- export {
4
- e as convertToDurationBasedOnTimeUnits
5
- };