@easyv/react-components 0.0.50 → 0.2.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 (82) hide show
  1. package/dist/BlurInput/index.d.ts +12 -0
  2. package/dist/BlurInput/index.js +58 -0
  3. package/dist/ColorsPicker/ControlBar.d.ts +8 -0
  4. package/dist/ColorsPicker/ControlBar.js +67 -0
  5. package/dist/ColorsPicker/History.d.ts +7 -0
  6. package/dist/ColorsPicker/History.js +53 -0
  7. package/dist/ColorsPicker/HistoryLinear.d.ts +6 -0
  8. package/dist/ColorsPicker/HistoryLinear.js +36 -0
  9. package/dist/ColorsPicker/HistoryPure.d.ts +5 -0
  10. package/dist/ColorsPicker/HistoryPure.js +28 -0
  11. package/dist/ColorsPicker/LinearColorPicker/LinearColorInput.d.ts +8 -0
  12. package/dist/ColorsPicker/LinearColorPicker/LinearColorInput.js +50 -0
  13. package/dist/ColorsPicker/LinearColorPicker/LinearColorPanel.d.ts +7 -0
  14. package/dist/ColorsPicker/LinearColorPicker/LinearColorPanel.js +77 -0
  15. package/dist/ColorsPicker/LinearColorPicker/LinearPointsBar.d.ts +9 -0
  16. package/dist/ColorsPicker/LinearColorPicker/LinearPointsBar.js +140 -0
  17. package/dist/ColorsPicker/LinearColorPicker/index.d.ts +2 -0
  18. package/dist/ColorsPicker/LinearColorPicker/index.js +2 -0
  19. package/dist/ColorsPicker/LinearColorPicker/useHistory.d.ts +4 -0
  20. package/dist/ColorsPicker/LinearColorPicker/useHistory.js +32 -0
  21. package/dist/ColorsPicker/MixedColorPicker/ColorTypeTab.d.ts +8 -0
  22. package/dist/ColorsPicker/MixedColorPicker/ColorTypeTab.js +30 -0
  23. package/dist/ColorsPicker/MixedColorPicker/MixedPanel.d.ts +8 -0
  24. package/dist/ColorsPicker/MixedColorPicker/MixedPanel.js +64 -0
  25. package/dist/ColorsPicker/MixedColorPicker/index.d.ts +1 -0
  26. package/dist/ColorsPicker/MixedColorPicker/index.js +1 -0
  27. package/dist/ColorsPicker/Palette.d.ts +7 -0
  28. package/dist/ColorsPicker/Palette.js +39 -0
  29. package/dist/ColorsPicker/Panel.d.ts +6 -0
  30. package/dist/ColorsPicker/Panel.js +224 -0
  31. package/dist/ColorsPicker/PanelContainer.d.ts +6 -0
  32. package/dist/ColorsPicker/PanelContainer.js +8 -0
  33. package/dist/ColorsPicker/PureColorPicker/PureColorInput.d.ts +7 -0
  34. package/dist/ColorsPicker/PureColorPicker/PureColorInput.js +61 -0
  35. package/dist/ColorsPicker/PureColorPicker/PureColorPanel.d.ts +7 -0
  36. package/dist/ColorsPicker/PureColorPicker/PureColorPanel.js +39 -0
  37. package/dist/ColorsPicker/PureColorPicker/index.d.ts +2 -0
  38. package/dist/ColorsPicker/PureColorPicker/index.js +2 -0
  39. package/dist/ColorsPicker/PureColorPicker/useHistory.d.ts +4 -0
  40. package/dist/ColorsPicker/PureColorPicker/useHistory.js +32 -0
  41. package/dist/ColorsPicker/PuresColorPicker/PuresCards.d.ts +10 -0
  42. package/dist/ColorsPicker/PuresColorPicker/PuresCards.js +40 -0
  43. package/dist/ColorsPicker/PuresColorPicker/PuresColorInput.d.ts +7 -0
  44. package/dist/ColorsPicker/PuresColorPicker/PuresColorInput.js +20 -0
  45. package/dist/ColorsPicker/PuresColorPicker/PuresColorPanel.d.ts +7 -0
  46. package/dist/ColorsPicker/PuresColorPicker/PuresColorPanel.js +78 -0
  47. package/dist/ColorsPicker/PuresColorPicker/index.d.ts +3 -0
  48. package/dist/ColorsPicker/PuresColorPicker/index.js +3 -0
  49. package/dist/ColorsPicker/PuresColorPicker/useHistory.d.ts +5 -0
  50. package/dist/ColorsPicker/PuresColorPicker/useHistory.js +34 -0
  51. package/dist/ColorsPicker/RangeColorPicker/RangeColorInput.d.ts +7 -0
  52. package/dist/ColorsPicker/RangeColorPicker/RangeColorInput.js +19 -0
  53. package/dist/ColorsPicker/RangeColorPicker/RangeColorPanel.d.ts +7 -0
  54. package/dist/ColorsPicker/RangeColorPicker/RangeColorPanel.js +59 -0
  55. package/dist/ColorsPicker/RangeColorPicker/RangePointBar.d.ts +8 -0
  56. package/dist/ColorsPicker/RangeColorPicker/RangePointBar.js +63 -0
  57. package/dist/ColorsPicker/RangeColorPicker/index.d.ts +2 -0
  58. package/dist/ColorsPicker/RangeColorPicker/index.js +2 -0
  59. package/dist/ColorsPicker/common/Preview.d.ts +11 -0
  60. package/dist/ColorsPicker/common/Preview.js +60 -0
  61. package/dist/ColorsPicker/hooks/useColorsPicker.d.ts +25 -0
  62. package/dist/ColorsPicker/hooks/useColorsPicker.js +78 -0
  63. package/dist/ColorsPicker/hooks/useControlBlock.d.ts +11 -0
  64. package/dist/ColorsPicker/hooks/useControlBlock.js +61 -0
  65. package/dist/ColorsPicker/hooks/useLocalstorageRef.d.ts +3 -0
  66. package/dist/ColorsPicker/hooks/useLocalstorageRef.js +11 -0
  67. package/dist/ColorsPicker/index.d.ts +4 -0
  68. package/dist/ColorsPicker/index.js +182 -0
  69. package/dist/ColorsPicker/interface.d.ts +58 -0
  70. package/dist/ColorsPicker/interface.js +1 -0
  71. package/dist/ColorsPicker/style/index.less +515 -0
  72. package/dist/ColorsPicker/utils.d.ts +29 -0
  73. package/dist/ColorsPicker/utils.js +233 -0
  74. package/dist/Watermark/index.d.ts +2 -0
  75. package/dist/Watermark/index.js +2 -0
  76. package/dist/Watermark/interface.d.ts +1 -0
  77. package/dist/Watermark/interface.js +1 -0
  78. package/dist/global.d.ts +13 -0
  79. package/dist/hooks/index.d.ts +3 -0
  80. package/dist/index.d.ts +4 -0
  81. package/dist/index.js +3 -3
  82. package/package.json +12 -9
@@ -0,0 +1,233 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ import tinycolor from 'tinycolor2';
3
+ export function toHex(x) {
4
+ return ('0' + parseInt(x).toString(16)).slice(-2);
5
+ }
6
+ export function resolveColor(colorParam) {
7
+ if (!colorParam || typeof colorParam !== 'string') {
8
+ return {};
9
+ }
10
+
11
+ // 转为小写并去除空格
12
+ var color = colorParam.toLowerCase().replace(/\s+/g, '');
13
+ var hexReg = /^#([0-9|a-f]{3}|[0-9|a-f]{6})$/;
14
+ var rgbReg = /^(rgb\(\d+,\d+,\d+\)|rgba\(\d+,\d+,\d+,(\d+)?(\.)?(\d+)?\))$/;
15
+ // const rgbReg1 = /^(rgb\(\d+,\d+,\d+\)|rgba\((\d+)?(\.)?(\d+)?,(\d+)?(\.)?(\d+)?,(\d+)?(\.)?(\d+)?,(\d+)?(\.)?(\d+)?\))$/;
16
+
17
+ var r, g, b, a;
18
+ if (hexReg.test(color)) {
19
+ if (color.length === 4) {
20
+ r = parseInt(color.slice(1, 2) + color.slice(1, 2), 16);
21
+ g = parseInt(color.slice(2, 3) + color.slice(2, 3), 16);
22
+ b = parseInt(color.slice(3, 4) + color.slice(3, 4), 16);
23
+ } else {
24
+ r = parseInt(color.slice(1, 3), 16);
25
+ g = parseInt(color.slice(3, 5), 16);
26
+ b = parseInt(color.slice(5, 7), 16);
27
+ }
28
+ a = 1;
29
+ } else if (rgbReg.test(color)) {
30
+ var colors = color.replace(/rgba|rgb|\(|\)/g, '').split(',');
31
+ r = Number(colors[0]);
32
+ g = Number(colors[1]);
33
+ b = Number(colors[2]);
34
+ a = colors.length === 4 ? Number(colors[3]) : 1;
35
+ } else {
36
+ return {};
37
+ }
38
+
39
+ // return { r: Math.floor(r), g: Math.floor(g), b: Math.floor(b), a, hex: `#${toHex(r)}${toHex(g)}${toHex(b)}` };
40
+ return {
41
+ r: r,
42
+ g: g,
43
+ b: b,
44
+ a: a,
45
+ hex: "#".concat(toHex(r)).concat(toHex(g)).concat(toHex(b))
46
+ };
47
+ }
48
+ export function transformColor(color, a) {
49
+ var _resolveColor = resolveColor(color),
50
+ r = _resolveColor.r,
51
+ g = _resolveColor.g,
52
+ b = _resolveColor.b,
53
+ hex = _resolveColor.hex;
54
+ return a === 1 ? hex : "RGBA(".concat(r, ",").concat(g, ",").concat(b, ",").concat(a, ")");
55
+ }
56
+ export function getBackgroundAccordingColor(color, fixedAngle) {
57
+ if (typeof color === 'string') {
58
+ return {
59
+ background: color
60
+ };
61
+ } else if (Array.isArray(color)) {
62
+ var rebaseStops = color.concat();
63
+ rebaseStops.sort(function (a, b) {
64
+ return a.offset - b.offset;
65
+ });
66
+ var colors = rebaseStops.map(function (item, index) {
67
+ var _resolveColor2 = resolveColor(item.color),
68
+ r = _resolveColor2.r,
69
+ g = _resolveColor2.g,
70
+ b = _resolveColor2.b,
71
+ a = _resolveColor2.a;
72
+ if (a === 1 || index === rebaseStops.length - 1) {
73
+ return "".concat(item.color, " ").concat(item.offset, "%");
74
+ } else {
75
+ var _resolveColor3 = resolveColor(rebaseStops[index + 1].color),
76
+ nextR = _resolveColor3.r,
77
+ nextG = _resolveColor3.g,
78
+ nextB = _resolveColor3.b,
79
+ nextA = _resolveColor3.a;
80
+ var stepOpacity = (nextA - a) / 5;
81
+ var stepOffset = (rebaseStops[index + 1].offset - item.offset) / 5;
82
+ var stepR = (nextR - r) / 5;
83
+ var stepG = (nextG - g) / 5;
84
+ var stepB = (nextB - b) / 5;
85
+ return Array.from({
86
+ length: 5
87
+ }).map(function (d, i) {
88
+ return "".concat(transformColor("rgb(".concat(Math.round(r + stepR * i), ",").concat(Math.round(g + stepG * i), ",").concat(Math.round(b + stepB * i), ")"), a + stepOpacity * i), " ").concat(item.offset + stepOffset * i, "%");
89
+ }).join(',');
90
+ }
91
+ });
92
+ return {
93
+ backgroundImage: "linear-gradient(".concat(fixedAngle || 0, "deg, ").concat(colors.join(','), ")")
94
+ };
95
+ } else if (_typeof(color) === 'object') {
96
+ var _color$type = color.type,
97
+ type = _color$type === void 0 ? 'pure' : _color$type,
98
+ _color$linear = color.linear,
99
+ _color$linear2 = _color$linear === void 0 ? {
100
+ stops: [{
101
+ offset: 0,
102
+ color: '#000'
103
+ }, {
104
+ offset: 100,
105
+ color: '#fff'
106
+ }],
107
+ angle: 0,
108
+ opacity: 1
109
+ } : _color$linear,
110
+ stops = _color$linear2.stops,
111
+ angle = _color$linear2.angle,
112
+ opacity = _color$linear2.opacity,
113
+ _color$pure = color.pure,
114
+ pureColor = _color$pure === void 0 ? '#000' : _color$pure;
115
+ if (type === 'linear') {
116
+ var _rebaseStops = stops.concat();
117
+ _rebaseStops.sort(function (a, b) {
118
+ return a.offset - b.offset;
119
+ });
120
+ var _colors = _rebaseStops.map(function (item, index) {
121
+ var _resolveColor4 = resolveColor(item.color),
122
+ r = _resolveColor4.r,
123
+ g = _resolveColor4.g,
124
+ b = _resolveColor4.b,
125
+ a = _resolveColor4.a;
126
+ if (a === 1 || index === _rebaseStops.length - 1) {
127
+ return "".concat(transformColor(item.color, a * opacity), " ").concat(item.offset, "%");
128
+ } else {
129
+ var _resolveColor5 = resolveColor(_rebaseStops[index + 1].color),
130
+ nextR = _resolveColor5.r,
131
+ nextG = _resolveColor5.g,
132
+ nextB = _resolveColor5.b,
133
+ nextA = _resolveColor5.a;
134
+ var stepOpacity = (nextA - a) / 5;
135
+ var stepOffset = (_rebaseStops[index + 1].offset - item.offset) / 5;
136
+ var stepR = (nextR - r) / 5;
137
+ var stepG = (nextG - g) / 5;
138
+ var stepB = (nextB - b) / 5;
139
+ return Array.from({
140
+ length: 5
141
+ }).map(function (d, i) {
142
+ return "".concat(transformColor("rgb(".concat(Math.round(r + stepR * i), ",").concat(Math.round(g + stepG * i), ",").concat(Math.round(b + stepB * i), ")"), (a + stepOpacity * i) * opacity), " ").concat(item.offset + stepOffset * i, "%");
143
+ }).join(',');
144
+ }
145
+ });
146
+ return {
147
+ backgroundImage: "linear-gradient(".concat(fixedAngle ? fixedAngle : angle, "deg, ").concat(_colors.join(','), ")")
148
+ };
149
+ } else {
150
+ return {
151
+ background: pureColor
152
+ };
153
+ }
154
+ }
155
+ }
156
+ export function getMiddleColor(colors, offset) {
157
+ var leftColor, rightColor;
158
+ var leftColors = colors.filter(function (d) {
159
+ return d.offset < offset;
160
+ });
161
+ var rightColors = colors.filter(function (d) {
162
+ return d.offset > offset;
163
+ });
164
+ if (leftColors.length) {
165
+ leftColors.sort(function (a, b) {
166
+ return b.offset - a.offset;
167
+ });
168
+ leftColor = leftColors[0];
169
+ }
170
+ if (rightColors.length) {
171
+ rightColors.sort(function (a, b) {
172
+ return a.offset - b.offset;
173
+ });
174
+ rightColor = rightColors[0];
175
+ }
176
+ if (!leftColor) {
177
+ return rightColor.color;
178
+ }
179
+ if (!rightColor) {
180
+ return leftColor.color;
181
+ }
182
+
183
+ // console.log(leftColor, rightColor, leftColors, rightColors, '计算color');
184
+
185
+ var _resolveColor6 = resolveColor(leftColor.color),
186
+ leftR = _resolveColor6.r,
187
+ leftG = _resolveColor6.g,
188
+ leftB = _resolveColor6.b,
189
+ leftA = _resolveColor6.a;
190
+ var _resolveColor7 = resolveColor(rightColor.color),
191
+ rightR = _resolveColor7.r,
192
+ rightG = _resolveColor7.g,
193
+ rightB = _resolveColor7.b,
194
+ rightA = _resolveColor7.a;
195
+
196
+ // console.log(resolveColor(leftColor.color), resolveColor(rightColor.color), '计算color');
197
+
198
+ var newR = Math.round((rightR - leftR) / (rightColor.offset - leftColor.offset) * (offset - leftColor.offset) + leftR);
199
+ var newG = Math.round((rightG - leftG) / (rightColor.offset - leftColor.offset) * (offset - leftColor.offset) + leftG);
200
+ var newB = Math.round((rightB - leftB) / (rightColor.offset - leftColor.offset) * (offset - leftColor.offset) + leftB);
201
+ var newA = (rightA - leftA) / (rightColor.offset - leftColor.offset) * (offset - leftColor.offset) + leftA;
202
+ return newA === 1 ? "#".concat(toHex(newR)).concat(toHex(newG)).concat(toHex(newB)) : "RGBA(".concat(newR, ",").concat(newG, ",").concat(newB, ",").concat(newA, ")");
203
+ }
204
+ export function getHexValue(hex) {
205
+ var result = hex.replace(/^#/, '');
206
+ if (result.length === 1) {
207
+ result = result.repeat(6);
208
+ } else if (result.length === 2) {
209
+ result = result.repeat(3);
210
+ } else if (result.length === 3) {
211
+ result = result.replace(/(\w)(\w)(\w)/, '$1$1$2$2$3$3');
212
+ } else if (result.length === 4 || result.length === 5) {
213
+ result = result.slice(0, 3).replace(/(\w)(\w)(\w)/, '$1$1$2$2$3$3');
214
+ } else if (result.length > 6) {
215
+ result = result.slice(0, 6);
216
+ }
217
+ return '#' + result;
218
+ }
219
+ export function getLinearGradientStyle(color) {
220
+ var stops = color.stops,
221
+ angle = color.angle,
222
+ opacity = color.opacity;
223
+ var sortedColors = stops.concat().sort(function (a, b) {
224
+ return a.offset - b.offset;
225
+ });
226
+ var linearString = sortedColors.map(function (d) {
227
+ return "".concat(tinycolor(d.color).toRgbString(), " ").concat(d.offset, "%");
228
+ }).join(', ');
229
+ return {
230
+ backgroundImage: "linear-gradient(".concat(angle, "deg, ").concat(linearString, ")"),
231
+ opacity: opacity
232
+ };
233
+ }
@@ -0,0 +1,2 @@
1
+ import { Watermark } from '@arco-design/web-react';
2
+ export default Watermark;
@@ -0,0 +1,2 @@
1
+ import { Watermark } from '@arco-design/web-react';
2
+ export default Watermark;
@@ -0,0 +1 @@
1
+ export { WatermarkProps } from '@arco-design/web-react';
@@ -0,0 +1 @@
1
+ export { WatermarkProps } from '@arco-design/web-react';
@@ -0,0 +1,13 @@
1
+ interface Window {
2
+ EyeDropper?: {
3
+ new (): EyeDropper;
4
+ };
5
+ }
6
+
7
+ interface EyeDropper {
8
+ open(): Promise<EyeDropperResult>;
9
+ }
10
+
11
+ interface EyeDropperResult {
12
+ sRGBHex: string;
13
+ }
@@ -0,0 +1,3 @@
1
+ export * from './useClickOutside';
2
+ export * from './useEventListener';
3
+ export * from './useTheme';
package/dist/index.d.ts CHANGED
@@ -131,5 +131,9 @@ export { default as Space } from './Space';
131
131
  export type { SpaceProps } from './Space/interface';
132
132
  export { default as Tag } from './Tag';
133
133
  export type { TagProps } from './Tag/interface';
134
+ export { default as ColorsPicker } from './ColorsPicker';
135
+ export type { ColorsPickerProps } from './ColorsPicker/interface';
134
136
  export { default as Color } from './Color';
135
137
  export { default as RangeColor } from './RangeColor';
138
+ export { default as Watermark } from './Watermark';
139
+ export type { WatermarkProps } from './Watermark/interface';
package/dist/index.js CHANGED
@@ -65,7 +65,7 @@ export { default as Radio } from "./Radio";
65
65
  export { default as Select } from "./Select";
66
66
  export { default as Space } from "./Space";
67
67
  export { default as Tag } from "./Tag";
68
- // export { default as ColorPicker } from './ColorPicker';
69
-
68
+ export { default as ColorsPicker } from "./ColorsPicker";
70
69
  export { default as Color } from "./Color";
71
- export { default as RangeColor } from "./RangeColor";
70
+ export { default as RangeColor } from "./RangeColor";
71
+ export { default as Watermark } from "./Watermark";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/react-components",
3
- "version": "0.0.50",
3
+ "version": "0.2.0",
4
4
  "description": "a react component library base on arco design",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -47,23 +47,26 @@
47
47
  ]
48
48
  },
49
49
  "dependencies": {
50
- "@easyv/react-icons": "4.14.0",
51
- "ahooks": "^3.7.8",
50
+ "@easyv/react-icons": "4.24.0",
51
+ "ahooks": "^3.7.11",
52
52
  "classnames": "^2.3.2",
53
- "rc-color-picker": "1.2.6"
53
+ "rc-color-picker": "1.2.6",
54
+ "tinycolor2": "^1.6.0"
54
55
  },
55
56
  "devDependencies": {
56
- "@arco-design/web-react": "2.57.2",
57
- "@arco-themes/react-dtable": "0.0.40",
58
- "@arco-themes/react-easytwin": "0.0.23",
57
+ "@arco-design/web-react": "2.62.0",
58
+ "@arco-themes/react-dtable": "0.0.44",
59
+ "@arco-themes/react-easytwin": "0.0.24",
59
60
  "@commitlint/cli": "^17.1.2",
60
61
  "@commitlint/config-conventional": "^17.1.0",
61
62
  "@easyv/sync-to-mirror": "^0.0.2",
63
+ "@types/color": "^3.0.6",
62
64
  "@types/lodash": "^4.14.197",
63
- "@types/react": "^18.0.0",
64
- "@types/react-dom": "^18.0.0",
65
+ "@types/react": "^18.2.66",
66
+ "@types/react-dom": "^18.2.22",
65
67
  "@types/react-resizable": "^3.0.4",
66
68
  "@types/react-sticky": "^6.0.4",
69
+ "@types/tinycolor2": "^1.4.6",
67
70
  "@umijs/lint": "^4.0.0",
68
71
  "dayjs": "^1.11.9",
69
72
  "dnd-core": "^16.0.1",