@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.
- package/dist/BlurInput/index.d.ts +12 -0
- package/dist/BlurInput/index.js +58 -0
- package/dist/ColorsPicker/ControlBar.d.ts +8 -0
- package/dist/ColorsPicker/ControlBar.js +67 -0
- package/dist/ColorsPicker/History.d.ts +7 -0
- package/dist/ColorsPicker/History.js +53 -0
- package/dist/ColorsPicker/HistoryLinear.d.ts +6 -0
- package/dist/ColorsPicker/HistoryLinear.js +36 -0
- package/dist/ColorsPicker/HistoryPure.d.ts +5 -0
- package/dist/ColorsPicker/HistoryPure.js +28 -0
- package/dist/ColorsPicker/LinearColorPicker/LinearColorInput.d.ts +8 -0
- package/dist/ColorsPicker/LinearColorPicker/LinearColorInput.js +50 -0
- package/dist/ColorsPicker/LinearColorPicker/LinearColorPanel.d.ts +7 -0
- package/dist/ColorsPicker/LinearColorPicker/LinearColorPanel.js +77 -0
- package/dist/ColorsPicker/LinearColorPicker/LinearPointsBar.d.ts +9 -0
- package/dist/ColorsPicker/LinearColorPicker/LinearPointsBar.js +140 -0
- package/dist/ColorsPicker/LinearColorPicker/index.d.ts +2 -0
- package/dist/ColorsPicker/LinearColorPicker/index.js +2 -0
- package/dist/ColorsPicker/LinearColorPicker/useHistory.d.ts +4 -0
- package/dist/ColorsPicker/LinearColorPicker/useHistory.js +32 -0
- package/dist/ColorsPicker/MixedColorPicker/ColorTypeTab.d.ts +8 -0
- package/dist/ColorsPicker/MixedColorPicker/ColorTypeTab.js +30 -0
- package/dist/ColorsPicker/MixedColorPicker/MixedPanel.d.ts +8 -0
- package/dist/ColorsPicker/MixedColorPicker/MixedPanel.js +64 -0
- package/dist/ColorsPicker/MixedColorPicker/index.d.ts +1 -0
- package/dist/ColorsPicker/MixedColorPicker/index.js +1 -0
- package/dist/ColorsPicker/Palette.d.ts +7 -0
- package/dist/ColorsPicker/Palette.js +39 -0
- package/dist/ColorsPicker/Panel.d.ts +6 -0
- package/dist/ColorsPicker/Panel.js +224 -0
- package/dist/ColorsPicker/PanelContainer.d.ts +6 -0
- package/dist/ColorsPicker/PanelContainer.js +8 -0
- package/dist/ColorsPicker/PureColorPicker/PureColorInput.d.ts +7 -0
- package/dist/ColorsPicker/PureColorPicker/PureColorInput.js +61 -0
- package/dist/ColorsPicker/PureColorPicker/PureColorPanel.d.ts +7 -0
- package/dist/ColorsPicker/PureColorPicker/PureColorPanel.js +39 -0
- package/dist/ColorsPicker/PureColorPicker/index.d.ts +2 -0
- package/dist/ColorsPicker/PureColorPicker/index.js +2 -0
- package/dist/ColorsPicker/PureColorPicker/useHistory.d.ts +4 -0
- package/dist/ColorsPicker/PureColorPicker/useHistory.js +32 -0
- package/dist/ColorsPicker/PuresColorPicker/PuresCards.d.ts +10 -0
- package/dist/ColorsPicker/PuresColorPicker/PuresCards.js +40 -0
- package/dist/ColorsPicker/PuresColorPicker/PuresColorInput.d.ts +7 -0
- package/dist/ColorsPicker/PuresColorPicker/PuresColorInput.js +20 -0
- package/dist/ColorsPicker/PuresColorPicker/PuresColorPanel.d.ts +7 -0
- package/dist/ColorsPicker/PuresColorPicker/PuresColorPanel.js +78 -0
- package/dist/ColorsPicker/PuresColorPicker/index.d.ts +3 -0
- package/dist/ColorsPicker/PuresColorPicker/index.js +3 -0
- package/dist/ColorsPicker/PuresColorPicker/useHistory.d.ts +5 -0
- package/dist/ColorsPicker/PuresColorPicker/useHistory.js +34 -0
- package/dist/ColorsPicker/RangeColorPicker/RangeColorInput.d.ts +7 -0
- package/dist/ColorsPicker/RangeColorPicker/RangeColorInput.js +19 -0
- package/dist/ColorsPicker/RangeColorPicker/RangeColorPanel.d.ts +7 -0
- package/dist/ColorsPicker/RangeColorPicker/RangeColorPanel.js +59 -0
- package/dist/ColorsPicker/RangeColorPicker/RangePointBar.d.ts +8 -0
- package/dist/ColorsPicker/RangeColorPicker/RangePointBar.js +63 -0
- package/dist/ColorsPicker/RangeColorPicker/index.d.ts +2 -0
- package/dist/ColorsPicker/RangeColorPicker/index.js +2 -0
- package/dist/ColorsPicker/common/Preview.d.ts +11 -0
- package/dist/ColorsPicker/common/Preview.js +60 -0
- package/dist/ColorsPicker/hooks/useColorsPicker.d.ts +25 -0
- package/dist/ColorsPicker/hooks/useColorsPicker.js +78 -0
- package/dist/ColorsPicker/hooks/useControlBlock.d.ts +11 -0
- package/dist/ColorsPicker/hooks/useControlBlock.js +61 -0
- package/dist/ColorsPicker/hooks/useLocalstorageRef.d.ts +3 -0
- package/dist/ColorsPicker/hooks/useLocalstorageRef.js +11 -0
- package/dist/ColorsPicker/index.d.ts +4 -0
- package/dist/ColorsPicker/index.js +182 -0
- package/dist/ColorsPicker/interface.d.ts +58 -0
- package/dist/ColorsPicker/interface.js +1 -0
- package/dist/ColorsPicker/style/index.less +515 -0
- package/dist/ColorsPicker/utils.d.ts +29 -0
- package/dist/ColorsPicker/utils.js +233 -0
- package/dist/Watermark/index.d.ts +2 -0
- package/dist/Watermark/index.js +2 -0
- package/dist/Watermark/interface.d.ts +1 -0
- package/dist/Watermark/interface.js +1 -0
- package/dist/global.d.ts +13 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -3
- package/package.json +12 -9
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
export default function useLocalstorageRef(name) {
|
|
3
|
+
var ref = useRef();
|
|
4
|
+
useEffect(function () {
|
|
5
|
+
ref.current = JSON.parse(localStorage.getItem(name) || 'null');
|
|
6
|
+
});
|
|
7
|
+
var set = useCallback(function (value) {
|
|
8
|
+
localStorage.setItem(name, JSON.stringify(value));
|
|
9
|
+
}, []);
|
|
10
|
+
return [ref, set];
|
|
11
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
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
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
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; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import { useState } from 'react';
|
|
14
|
+
import { Trigger } from "../index";
|
|
15
|
+
import { PureColorInput, PureColorPanel } from "./PureColorPicker";
|
|
16
|
+
import { PuresColorInput, PuresColorPanel } from "./PuresColorPicker";
|
|
17
|
+
import { LinearColorInput, LinearColorPanel } from "./LinearColorPicker";
|
|
18
|
+
import PanelContainer from "./PanelContainer";
|
|
19
|
+
import { MixedPanel } from "./MixedColorPicker";
|
|
20
|
+
import { RangeColorInput, RangeColorPanel } from "./RangeColorPicker";
|
|
21
|
+
import useColorsPicker from "./hooks/useColorsPicker";
|
|
22
|
+
import "./style/index.less";
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
function ColorsPicker(props) {
|
|
25
|
+
var _useColorsPicker = useColorsPicker(props),
|
|
26
|
+
type = _useColorsPicker.type,
|
|
27
|
+
value = _useColorsPicker.value,
|
|
28
|
+
onChange = _useColorsPicker.onChange;
|
|
29
|
+
var _useState = useState(false),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
+
visible = _useState2[0],
|
|
32
|
+
setVisible = _useState2[1];
|
|
33
|
+
var renderInput = function renderInput() {
|
|
34
|
+
switch (type) {
|
|
35
|
+
case 'pure':
|
|
36
|
+
{
|
|
37
|
+
return /*#__PURE__*/_jsx(PureColorInput, {
|
|
38
|
+
value: value,
|
|
39
|
+
onChange: onChange,
|
|
40
|
+
onTrigger: function onTrigger() {
|
|
41
|
+
return setVisible(!visible);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
case 'pures':
|
|
46
|
+
{
|
|
47
|
+
return /*#__PURE__*/_jsx(PuresColorInput, {
|
|
48
|
+
value: value,
|
|
49
|
+
onTrigger: function onTrigger() {
|
|
50
|
+
return setVisible(!visible);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
case 'linear':
|
|
55
|
+
{
|
|
56
|
+
return /*#__PURE__*/_jsx(LinearColorInput, {
|
|
57
|
+
value: value,
|
|
58
|
+
onChange: onChange,
|
|
59
|
+
onTrigger: function onTrigger() {
|
|
60
|
+
return setVisible(!visible);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
case 'range':
|
|
65
|
+
{
|
|
66
|
+
return /*#__PURE__*/_jsx(RangeColorInput, {
|
|
67
|
+
value: value,
|
|
68
|
+
onTrigger: function onTrigger() {
|
|
69
|
+
return setVisible(!visible);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
default:
|
|
74
|
+
{
|
|
75
|
+
if (Array.isArray(type)) {
|
|
76
|
+
var val = value;
|
|
77
|
+
var onValueChange = onChange;
|
|
78
|
+
if (val.type === 'pure') {
|
|
79
|
+
return /*#__PURE__*/_jsx(PureColorInput, {
|
|
80
|
+
value: val.pure,
|
|
81
|
+
onChange: function onChange(newValue) {
|
|
82
|
+
return onValueChange(_objectSpread(_objectSpread({}, val), {}, {
|
|
83
|
+
pure: newValue
|
|
84
|
+
}));
|
|
85
|
+
},
|
|
86
|
+
onTrigger: function onTrigger() {
|
|
87
|
+
return setVisible(!visible);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
} else if (val.type === 'pures') {
|
|
91
|
+
return /*#__PURE__*/_jsx(PuresColorInput, {
|
|
92
|
+
value: val.pures,
|
|
93
|
+
onTrigger: function onTrigger() {
|
|
94
|
+
return setVisible(!visible);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
} else if (val.type === 'linear') {
|
|
98
|
+
return /*#__PURE__*/_jsx(LinearColorInput, {
|
|
99
|
+
value: val.linear,
|
|
100
|
+
onChange: function onChange(newValue) {
|
|
101
|
+
return onValueChange(_objectSpread(_objectSpread({}, val), {}, {
|
|
102
|
+
linear: newValue
|
|
103
|
+
}));
|
|
104
|
+
},
|
|
105
|
+
onTrigger: function onTrigger() {
|
|
106
|
+
return setVisible(!visible);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
} else if (val.type === 'range') {
|
|
110
|
+
return /*#__PURE__*/_jsx(RangeColorInput, {
|
|
111
|
+
value: val.range,
|
|
112
|
+
onTrigger: function onTrigger() {
|
|
113
|
+
return setVisible(!visible);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
console.error('unknown color picker type');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var renderPanel = function renderPanel() {
|
|
123
|
+
var renderPanelInner = function renderPanelInner() {
|
|
124
|
+
switch (type) {
|
|
125
|
+
case 'pure':
|
|
126
|
+
{
|
|
127
|
+
return /*#__PURE__*/_jsx(PureColorPanel, {
|
|
128
|
+
value: value,
|
|
129
|
+
onChange: onChange
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
case 'pures':
|
|
133
|
+
{
|
|
134
|
+
return /*#__PURE__*/_jsx(PuresColorPanel, {
|
|
135
|
+
value: value,
|
|
136
|
+
onChange: onChange
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
case 'linear':
|
|
140
|
+
{
|
|
141
|
+
return /*#__PURE__*/_jsx(LinearColorPanel, {
|
|
142
|
+
value: value,
|
|
143
|
+
onChange: onChange
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
case 'range':
|
|
147
|
+
{
|
|
148
|
+
return /*#__PURE__*/_jsx(RangeColorPanel, {
|
|
149
|
+
value: value,
|
|
150
|
+
onChange: onChange
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
default:
|
|
154
|
+
{
|
|
155
|
+
if (Array.isArray(type)) {
|
|
156
|
+
return /*#__PURE__*/_jsx(MixedPanel, {
|
|
157
|
+
type: type,
|
|
158
|
+
value: value,
|
|
159
|
+
onChange: onChange
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
console.error('unknown color picker type');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
return /*#__PURE__*/_jsx(PanelContainer, {
|
|
167
|
+
children: renderPanelInner()
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
return /*#__PURE__*/_jsx(Trigger, {
|
|
171
|
+
unmountOnExit: true,
|
|
172
|
+
trigger: "click",
|
|
173
|
+
position: "bl",
|
|
174
|
+
popupVisible: visible,
|
|
175
|
+
popup: renderPanel,
|
|
176
|
+
onClickOutside: function onClickOutside() {
|
|
177
|
+
return setVisible(false);
|
|
178
|
+
},
|
|
179
|
+
children: renderInput()
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
export default ColorsPicker;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 颜色选择器类型
|
|
3
|
+
* @description 支持纯色、线性渐变、径向渐变、多纯色集合
|
|
4
|
+
* pure - 纯色
|
|
5
|
+
* linear - 线性渐变
|
|
6
|
+
* pures - 多纯色集合
|
|
7
|
+
*/
|
|
8
|
+
export declare type ColorType = 'pure' | 'linear' | 'pures' | 'range';
|
|
9
|
+
interface StopItem {
|
|
10
|
+
/**
|
|
11
|
+
* 偏移量
|
|
12
|
+
* 0 - 100
|
|
13
|
+
*/
|
|
14
|
+
offset: number;
|
|
15
|
+
/**
|
|
16
|
+
* 颜色值
|
|
17
|
+
*/
|
|
18
|
+
color: string;
|
|
19
|
+
}
|
|
20
|
+
export interface GradientColorValue {
|
|
21
|
+
stops: StopItem[];
|
|
22
|
+
angle: number;
|
|
23
|
+
opacity: number;
|
|
24
|
+
}
|
|
25
|
+
export interface ColorValueObj {
|
|
26
|
+
type: ColorType;
|
|
27
|
+
pure?: ColorValueMap['pure'];
|
|
28
|
+
linear?: ColorValueMap['linear'];
|
|
29
|
+
pures?: ColorValueMap['pures'];
|
|
30
|
+
range?: ColorValueMap['range'];
|
|
31
|
+
}
|
|
32
|
+
export declare type ColorsPickerType = ColorType | ColorType[];
|
|
33
|
+
export interface ColorsPickerProps<T extends ColorsPickerType> {
|
|
34
|
+
type: T;
|
|
35
|
+
value: T extends ColorType ? ColorValueMap[T] : ColorValueObj;
|
|
36
|
+
onChange: (value: T extends ColorType ? ColorValueMap[T] : ColorValueObj) => void;
|
|
37
|
+
}
|
|
38
|
+
export interface ColorValueMap {
|
|
39
|
+
pure: string;
|
|
40
|
+
linear: GradientColorValue;
|
|
41
|
+
pures: string[];
|
|
42
|
+
range: [string, string];
|
|
43
|
+
}
|
|
44
|
+
export interface HSV {
|
|
45
|
+
h: number;
|
|
46
|
+
s: number;
|
|
47
|
+
v: number;
|
|
48
|
+
}
|
|
49
|
+
export interface RGB {
|
|
50
|
+
r: number;
|
|
51
|
+
g: number;
|
|
52
|
+
b: number;
|
|
53
|
+
}
|
|
54
|
+
export interface Color {
|
|
55
|
+
hsv: HSV;
|
|
56
|
+
alpha: number;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|