@easyv/react-components 0.0.15 → 0.0.17
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.
- package/dist/Color/Preview.js +1 -1
- package/dist/Color/index.js +2 -2
- package/dist/ColorPicker/Panel.js +12 -16
- package/dist/ColorPicker/index.js +3 -4
- package/dist/ColorPicker/utils.d.ts +2 -2
- package/dist/ColorPicker/utils.js +7 -7
- package/dist/Modal/index.less +15 -0
- package/dist/RangeColor/Panel.js +4 -4
- package/dist/RangeColor/Points.js +2 -0
- package/dist/hooks/useEventListener.js +3 -2
- package/package.json +1 -1
package/dist/Color/Preview.js
CHANGED
|
@@ -29,7 +29,7 @@ export default function Preview(_ref) {
|
|
|
29
29
|
var previewRef = useRef(null);
|
|
30
30
|
var pickerRef = useRef(null);
|
|
31
31
|
var deferedShow = useDeferredValue(show);
|
|
32
|
-
var handleClick = function handleClick(
|
|
32
|
+
var handleClick = function handleClick() {
|
|
33
33
|
setShow(true);
|
|
34
34
|
};
|
|
35
35
|
var handleHide = function handleHide() {
|
package/dist/Color/index.js
CHANGED
|
@@ -23,8 +23,8 @@ export default function Color(_ref) {
|
|
|
23
23
|
onChange(newValue);
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
var handleHexChange = function handleHexChange(
|
|
27
|
-
hex =
|
|
26
|
+
var handleHexChange = function handleHexChange(hexParam) {
|
|
27
|
+
var hex = hexParam.startsWith('#') ? hexParam : '#' + hexParam;
|
|
28
28
|
hex = hex.toUpperCase();
|
|
29
29
|
var hexReg = /^#([0-9|A-F]{3}|[0-9|A-F]{6})$/;
|
|
30
30
|
if (!hexReg.test(hex)) {
|
|
@@ -6,27 +6,27 @@ import 'rc-color-picker/assets/index.css';
|
|
|
6
6
|
import "./Panel.less";
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
export default /*#__PURE__*/memo(function ColorPickerPanel(_ref) {
|
|
9
|
-
var _ref$
|
|
10
|
-
record = _ref$record === void 0 ? null : _ref$record,
|
|
11
|
-
_ref$color = _ref.color,
|
|
9
|
+
var _ref$color = _ref.color,
|
|
12
10
|
color = _ref$color === void 0 ? 'rgba(255,0,255,0.5)' : _ref$color,
|
|
13
|
-
active = _ref.active,
|
|
14
11
|
onChange = _ref.onChange;
|
|
15
|
-
var
|
|
12
|
+
var lastColor = useRef(color);
|
|
16
13
|
var colorObj = new Color(color);
|
|
17
14
|
useMemo(function () {
|
|
18
|
-
|
|
19
|
-
}, [
|
|
15
|
+
lastColor.current = color;
|
|
16
|
+
}, [color]);
|
|
20
17
|
var _useDebounceFn = useDebounceFn(function (_ref2) {
|
|
21
|
-
var
|
|
18
|
+
var changedColor = _ref2.color,
|
|
22
19
|
alpha = _ref2.alpha;
|
|
23
|
-
|
|
20
|
+
var isSameColor = new Color(changedColor).hex === new Color(lastColor.current).hex && new Color(changedColor).alpha === new Color(lastColor.current).alpha;
|
|
21
|
+
if (isSameColor) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
24
|
var newColor;
|
|
25
25
|
var rgbColor;
|
|
26
26
|
if (alpha === 100) {
|
|
27
|
-
newColor =
|
|
27
|
+
newColor = changedColor;
|
|
28
28
|
} else {
|
|
29
|
-
rgbColor = new Color(
|
|
29
|
+
rgbColor = new Color(changedColor).RGB;
|
|
30
30
|
newColor = "RGBA(".concat(rgbColor[0], ",").concat(rgbColor[1], ",").concat(rgbColor[2], ",").concat(alpha / 100, ")");
|
|
31
31
|
}
|
|
32
32
|
onChange(newColor);
|
|
@@ -36,15 +36,11 @@ export default /*#__PURE__*/memo(function ColorPickerPanel(_ref) {
|
|
|
36
36
|
trailing: false
|
|
37
37
|
}),
|
|
38
38
|
run = _useDebounceFn.run;
|
|
39
|
-
return
|
|
39
|
+
return /*#__PURE__*/_jsx(Panel, {
|
|
40
40
|
className: 'arco-color-picker-panel',
|
|
41
41
|
color: colorObj.toHexString(),
|
|
42
42
|
alpha: colorObj.alpha,
|
|
43
43
|
mode: "RGB",
|
|
44
44
|
onChange: run
|
|
45
|
-
}) : /*#__PURE__*/_jsx(Panel, {
|
|
46
|
-
className: 'arco-color-picker-panel',
|
|
47
|
-
mode: "RGB",
|
|
48
|
-
onChange: run
|
|
49
45
|
});
|
|
50
46
|
});
|
|
@@ -70,8 +70,7 @@ function CustomColorPicker(_ref, ref) {
|
|
|
70
70
|
useEffect(function () {
|
|
71
71
|
return function () {
|
|
72
72
|
var lastColor = lastColorRef.current;
|
|
73
|
-
|
|
74
|
-
if (lastColor != null) {
|
|
73
|
+
if (lastColor) {
|
|
75
74
|
if (typeof lastColor === 'string') {
|
|
76
75
|
var newColors = [lastColor].concat(usedPureColors || []);
|
|
77
76
|
newColors = Array.from(new Set(newColors)).slice(0, 16);
|
|
@@ -190,12 +189,12 @@ function CustomColorPicker(_ref, ref) {
|
|
|
190
189
|
className: 'arco-color-picker-type',
|
|
191
190
|
children: [/*#__PURE__*/_jsx("span", {
|
|
192
191
|
className: classNames('arco-color-picker-circle', 'arco-color-picker-pure', _defineProperty({}, 'arco-color-picker-active', color.type === 'pure')),
|
|
193
|
-
onClick: function onClick(
|
|
192
|
+
onClick: function onClick() {
|
|
194
193
|
return handleTypeChange('pure');
|
|
195
194
|
}
|
|
196
195
|
}), /*#__PURE__*/_jsx("span", {
|
|
197
196
|
className: classNames('arco-color-picker-circle', 'arco-color-picker-linear', _defineProperty({}, 'arco-color-picker-active', color.type === 'linear')),
|
|
198
|
-
onClick: function onClick(
|
|
197
|
+
onClick: function onClick() {
|
|
199
198
|
return handleTypeChange('linear');
|
|
200
199
|
}
|
|
201
200
|
})]
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function toHex(x: any): string;
|
|
2
|
+
export declare function resolveColor(colorParam: string): {
|
|
2
3
|
r?: undefined;
|
|
3
4
|
g?: undefined;
|
|
4
5
|
b?: undefined;
|
|
@@ -11,7 +12,6 @@ export declare function resolveColor(color: string): {
|
|
|
11
12
|
a: any;
|
|
12
13
|
hex: string;
|
|
13
14
|
};
|
|
14
|
-
export declare function toHex(x: any): string;
|
|
15
15
|
export declare function transformColor(color: any, a: any): string | undefined;
|
|
16
16
|
export declare function getBackgroundAccordingColor(color: any, fixedAngle?: number): {
|
|
17
17
|
backgroundImage: string;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
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
|
-
export function
|
|
3
|
-
|
|
2
|
+
export function toHex(x) {
|
|
3
|
+
return ('0' + parseInt(x).toString(16)).slice(-2);
|
|
4
|
+
}
|
|
5
|
+
export function resolveColor(colorParam) {
|
|
6
|
+
if (!colorParam || typeof colorParam !== 'string') {
|
|
4
7
|
return {};
|
|
5
8
|
}
|
|
6
9
|
|
|
7
10
|
// 转为小写并去除空格
|
|
8
|
-
color =
|
|
11
|
+
var color = colorParam.toLowerCase().replace(/\s+/g, '');
|
|
9
12
|
var hexReg = /^#([0-9|a-f]{3}|[0-9|a-f]{6})$/;
|
|
10
13
|
var rgbReg = /^(rgb\(\d+,\d+,\d+\)|rgba\(\d+,\d+,\d+,(\d+)?(\.)?(\d+)?\))$/;
|
|
11
14
|
// const rgbReg1 = /^(rgb\(\d+,\d+,\d+\)|rgba\((\d+)?(\.)?(\d+)?,(\d+)?(\.)?(\d+)?,(\d+)?(\.)?(\d+)?,(\d+)?(\.)?(\d+)?\))$/;
|
|
@@ -41,9 +44,6 @@ export function resolveColor(color) {
|
|
|
41
44
|
hex: "#".concat(toHex(r)).concat(toHex(g)).concat(toHex(b))
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
|
-
export function toHex(x) {
|
|
45
|
-
return ('0' + parseInt(x).toString(16)).slice(-2);
|
|
46
|
-
}
|
|
47
47
|
export function transformColor(color, a) {
|
|
48
48
|
var _resolveColor = resolveColor(color),
|
|
49
49
|
r = _resolveColor.r,
|
|
@@ -143,7 +143,7 @@ export function getBackgroundAccordingColor(color, fixedAngle) {
|
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
145
|
return {
|
|
146
|
-
backgroundImage: "linear-gradient(".concat(fixedAngle
|
|
146
|
+
backgroundImage: "linear-gradient(".concat(fixedAngle ? fixedAngle : angle, "deg, ").concat(_colors.join(','), ")")
|
|
147
147
|
};
|
|
148
148
|
} else {
|
|
149
149
|
return {
|
package/dist/Modal/index.less
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
.arco-modal {
|
|
2
2
|
.arco-modal-header {
|
|
3
|
+
height: 56px;
|
|
4
|
+
padding: 0 24px;
|
|
5
|
+
|
|
3
6
|
.arco-modal-title {
|
|
4
7
|
text-align: left;
|
|
5
8
|
}
|
|
6
9
|
}
|
|
10
|
+
|
|
11
|
+
.arco-modal-close-icon {
|
|
12
|
+
font-size: 14px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.arco-modal-content {
|
|
16
|
+
padding: 24px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.arco-modal-footer {
|
|
20
|
+
padding: 12px 24px;
|
|
21
|
+
}
|
|
7
22
|
}
|
|
8
23
|
|
|
9
24
|
.arco-modal-simple {
|
package/dist/RangeColor/Panel.js
CHANGED
|
@@ -54,7 +54,7 @@ function CustomColorPicker(_ref, ref) {
|
|
|
54
54
|
useEffect(function () {
|
|
55
55
|
return function () {
|
|
56
56
|
var lastColor = lastColorRef.current;
|
|
57
|
-
if (lastColor
|
|
57
|
+
if (lastColor) {
|
|
58
58
|
if (typeof lastColor === 'string') {
|
|
59
59
|
var newColors = [lastColor].concat(usedPureColors || []);
|
|
60
60
|
newColors = Array.from(new Set(newColors)).slice(0, 16);
|
|
@@ -72,11 +72,11 @@ function CustomColorPicker(_ref, ref) {
|
|
|
72
72
|
e.stopPropagation();
|
|
73
73
|
if (e.key === 'Backspace') {
|
|
74
74
|
if (color.length > 2) {
|
|
75
|
-
|
|
75
|
+
var resultColor = color.filter(function (d, i) {
|
|
76
76
|
return i !== active;
|
|
77
77
|
});
|
|
78
78
|
setActive(active > 0 ? active - 1 : 0);
|
|
79
|
-
onChange(
|
|
79
|
+
onChange(resultColor);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
};
|
|
@@ -116,7 +116,7 @@ function CustomColorPicker(_ref, ref) {
|
|
|
116
116
|
// 切换dot的排列方向
|
|
117
117
|
var handleReverseColor = function handleReverseColor() {
|
|
118
118
|
var copyStops = color.slice();
|
|
119
|
-
var newStops = copyStops.reduce(function (all, item
|
|
119
|
+
var newStops = copyStops.reduce(function (all, item) {
|
|
120
120
|
var obj = {};
|
|
121
121
|
obj['offset'] = 100 - item.offset;
|
|
122
122
|
obj['color'] = item.color;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
export function useEventListener(eventName, handler) {
|
|
3
3
|
var element = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window;
|
|
4
|
-
var savedHandler = useRef(
|
|
4
|
+
var savedHandler = useRef(null);
|
|
5
5
|
useEffect(function () {
|
|
6
6
|
savedHandler.current = handler;
|
|
7
7
|
}, [handler]);
|
|
8
8
|
useEffect(function () {
|
|
9
9
|
var eventListener = function eventListener(event) {
|
|
10
|
-
|
|
10
|
+
var _savedHandler$current;
|
|
11
|
+
return (_savedHandler$current = savedHandler.current) === null || _savedHandler$current === void 0 ? void 0 : _savedHandler$current.call(savedHandler, event);
|
|
11
12
|
};
|
|
12
13
|
element.addEventListener(eventName, eventListener);
|
|
13
14
|
return function () {
|