@easyv/react-components 0.2.3 → 0.2.5
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/ColorsPicker/LinearColorPicker/LinearColorInput.d.ts +2 -1
- package/dist/ColorsPicker/LinearColorPicker/LinearColorInput.js +5 -2
- package/dist/ColorsPicker/LinearColorPicker/LinearColorPanel.js +10 -3
- package/dist/ColorsPicker/index.js +3 -0
- package/dist/ColorsPicker/interface.d.ts +3 -2
- package/dist/ColorsPicker/utils.js +4 -2
- package/package.json +1 -1
- package/dist/ColorsPicker/LinearColorPicker/LinearPointsBar.d.ts +0 -10
- package/dist/ColorsPicker/PanelContainer.d.ts +0 -6
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ColorValueMap } from '../interface';
|
|
2
2
|
interface LinearColorInputProps {
|
|
3
3
|
value: ColorValueMap['linear'];
|
|
4
|
+
disabledOutAlpha?: boolean;
|
|
4
5
|
onTrigger: () => void;
|
|
5
6
|
onChange: (val: ColorValueMap['linear']) => void;
|
|
6
7
|
}
|
|
7
|
-
export default function LinearColorInput({ value, onChange, onTrigger, }: LinearColorInputProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default function LinearColorInput({ value, disabledOutAlpha, onChange, onTrigger, }: LinearColorInputProps): import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -11,8 +11,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
11
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
12
|
export default function LinearColorInput(_ref) {
|
|
13
13
|
var value = _ref.value,
|
|
14
|
+
disabledOutAlpha = _ref.disabledOutAlpha,
|
|
14
15
|
onChange = _ref.onChange,
|
|
15
16
|
onTrigger = _ref.onTrigger;
|
|
17
|
+
var _value$opacity = value.opacity,
|
|
18
|
+
opacity = _value$opacity === void 0 ? 1 : _value$opacity;
|
|
16
19
|
var handleAlphaChange = function handleAlphaChange(val) {
|
|
17
20
|
onChange(_objectSpread(_objectSpread({}, value), {}, {
|
|
18
21
|
opacity: val
|
|
@@ -34,11 +37,11 @@ export default function LinearColorInput(_ref) {
|
|
|
34
37
|
prefix: "#",
|
|
35
38
|
value: '线性渐变',
|
|
36
39
|
disabled: true
|
|
37
|
-
}), /*#__PURE__*/_jsx(BlurInput, {
|
|
40
|
+
}), !disabledOutAlpha && /*#__PURE__*/_jsx(BlurInput, {
|
|
38
41
|
size: "small",
|
|
39
42
|
suffix: "%",
|
|
40
43
|
className: 'pure-color-picker-alpha',
|
|
41
|
-
value: (
|
|
44
|
+
value: (opacity * 100).toFixed(0),
|
|
42
45
|
validate: function validate(val) {
|
|
43
46
|
return +val >= 0 && +val <= 100;
|
|
44
47
|
},
|
|
@@ -14,13 +14,12 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
14
14
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
15
15
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
16
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
-
import { useState } from 'react';
|
|
17
|
+
import { useEffect, useRef, useState } from 'react';
|
|
18
18
|
import Panel from "../Panel";
|
|
19
19
|
import History from "../History";
|
|
20
20
|
import LinearPointsBar from "./LinearPointsBar";
|
|
21
21
|
import useHistory from "./useHistory";
|
|
22
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
24
23
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
24
|
export default function LinearColorPanel(_ref) {
|
|
26
25
|
var _value$stops$currentI;
|
|
@@ -38,6 +37,11 @@ export default function LinearColorPanel(_ref) {
|
|
|
38
37
|
useHistory({
|
|
39
38
|
value: value
|
|
40
39
|
});
|
|
40
|
+
var panelRef = useRef(null);
|
|
41
|
+
useEffect(function () {
|
|
42
|
+
var _panelRef$current;
|
|
43
|
+
(_panelRef$current = panelRef.current) === null || _panelRef$current === void 0 ? void 0 : _panelRef$current.focus();
|
|
44
|
+
}, []);
|
|
41
45
|
var handleChange = function handleChange(color, complete) {
|
|
42
46
|
var newStops = _toConsumableArray(value.stops);
|
|
43
47
|
newStops[currentIndex].color = color;
|
|
@@ -68,7 +72,10 @@ export default function LinearColorPanel(_ref) {
|
|
|
68
72
|
return prev + 1;
|
|
69
73
|
});
|
|
70
74
|
};
|
|
71
|
-
return /*#__PURE__*/_jsxs(
|
|
75
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
76
|
+
tabIndex: 0,
|
|
77
|
+
id: "linear-colors-panel",
|
|
78
|
+
ref: panelRef,
|
|
72
79
|
children: [/*#__PURE__*/_jsx(LinearPointsBar, {
|
|
73
80
|
active: currentIndex,
|
|
74
81
|
value: value,
|
|
@@ -25,6 +25,7 @@ function ColorsPicker(props) {
|
|
|
25
25
|
var _useColorsPicker = useColorsPicker(props),
|
|
26
26
|
type = _useColorsPicker.type,
|
|
27
27
|
value = _useColorsPicker.value,
|
|
28
|
+
disabledOutAlpha = _useColorsPicker.disabledOutAlpha,
|
|
28
29
|
onChange = _useColorsPicker.onChange,
|
|
29
30
|
onChangeComplete = _useColorsPicker.onChangeComplete;
|
|
30
31
|
var _useState = useState(false),
|
|
@@ -63,6 +64,7 @@ function ColorsPicker(props) {
|
|
|
63
64
|
onChangeComplete === null || onChangeComplete === void 0 ? void 0 : onChangeComplete(val);
|
|
64
65
|
};
|
|
65
66
|
return /*#__PURE__*/_jsx(LinearColorInput, {
|
|
67
|
+
disabledOutAlpha: disabledOutAlpha,
|
|
66
68
|
value: value,
|
|
67
69
|
onChange: _handleChange,
|
|
68
70
|
onTrigger: function onTrigger() {
|
|
@@ -108,6 +110,7 @@ function ColorsPicker(props) {
|
|
|
108
110
|
});
|
|
109
111
|
} else if (val.type === 'linear') {
|
|
110
112
|
return /*#__PURE__*/_jsx(LinearColorInput, {
|
|
113
|
+
disabledOutAlpha: disabledOutAlpha,
|
|
111
114
|
value: val.linear,
|
|
112
115
|
onChange: function onChange(newValue) {
|
|
113
116
|
return onValueChange(_objectSpread(_objectSpread({}, val), {}, {
|
|
@@ -19,8 +19,8 @@ interface StopItem {
|
|
|
19
19
|
}
|
|
20
20
|
export interface GradientColorValue {
|
|
21
21
|
stops: StopItem[];
|
|
22
|
-
angle
|
|
23
|
-
opacity
|
|
22
|
+
angle?: number;
|
|
23
|
+
opacity?: number;
|
|
24
24
|
}
|
|
25
25
|
export interface ColorValueObj {
|
|
26
26
|
type: ColorType;
|
|
@@ -33,6 +33,7 @@ export declare type ColorsPickerType = ColorType | ColorType[];
|
|
|
33
33
|
export interface ColorsPickerProps<T extends ColorsPickerType> {
|
|
34
34
|
type: T;
|
|
35
35
|
value: T extends ColorType ? ColorValueMap[T] : ColorValueObj;
|
|
36
|
+
disabledOutAlpha?: boolean;
|
|
36
37
|
onChange?: (value: T extends ColorType ? ColorValueMap[T] : ColorValueObj) => void;
|
|
37
38
|
onChangeComplete?: (value: T extends ColorType ? ColorValueMap[T] : ColorValueObj) => void;
|
|
38
39
|
}
|
|
@@ -218,8 +218,10 @@ export function getHexValue(hex) {
|
|
|
218
218
|
}
|
|
219
219
|
export function getLinearGradientStyle(color) {
|
|
220
220
|
var stops = color.stops,
|
|
221
|
-
angle = color.angle,
|
|
222
|
-
|
|
221
|
+
_color$angle = color.angle,
|
|
222
|
+
angle = _color$angle === void 0 ? 0 : _color$angle,
|
|
223
|
+
_color$opacity = color.opacity,
|
|
224
|
+
opacity = _color$opacity === void 0 ? 1 : _color$opacity;
|
|
223
225
|
var sortedColors = stops.concat().sort(function (a, b) {
|
|
224
226
|
return a.offset - b.offset;
|
|
225
227
|
});
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ColorValueMap } from '../interface';
|
|
2
|
-
interface LinearPointsBarProps {
|
|
3
|
-
active: number;
|
|
4
|
-
value: ColorValueMap['linear'];
|
|
5
|
-
onSelect: (current: number) => void;
|
|
6
|
-
onChange?: (value: ColorValueMap['linear']) => void;
|
|
7
|
-
onChangeComplete?: (value: ColorValueMap['linear']) => void;
|
|
8
|
-
}
|
|
9
|
-
export default function LinearPointsBar({ active, value, onSelect, onChange, onChangeComplete, }: LinearPointsBarProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export {};
|