@synerise/ds-color-picker 0.2.0 → 0.3.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/CHANGELOG.md +12 -0
- package/dist/ColorPicker.d.ts +1 -1
- package/dist/ColorPicker.js +37 -34
- package/dist/ColorPicker.types.d.ts +4 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.3.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-color-picker@0.2.0...@synerise/ds-color-picker@0.3.0) (2023-02-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **color-picker:** copy tooltip texts object ([929c93e](https://github.com/Synerise/synerise-design/commit/929c93e53e3679e69c44e8ee655b0dbf200ad283))
|
|
12
|
+
* **color-picker:** tests for component and methods ([bafa8c6](https://github.com/Synerise/synerise-design/commit/bafa8c6bbf967983fce4a65dc9bbc71a52a72953))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
# [0.2.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-color-picker@0.1.8...@synerise/ds-color-picker@0.2.0) (2023-02-03)
|
|
7
19
|
|
|
8
20
|
|
package/dist/ColorPicker.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ColorPickerProps } from './ColorPicker.types';
|
|
3
|
-
declare const ColorPicker: ({ maxWidth, value, onChange, colors, onSaveColors, infix, placeholder, inputProps, maxSavedColors,
|
|
3
|
+
declare const ColorPicker: ({ maxWidth, value, onChange, colors, onSaveColors, infix, placeholder, inputProps, maxSavedColors, tooltip, isShownSavedColors, size, errorText, description, }: ColorPickerProps) => JSX.Element;
|
|
4
4
|
export default ColorPicker;
|
package/dist/ColorPicker.js
CHANGED
|
@@ -29,7 +29,7 @@ var ColorPicker = function ColorPicker(_ref) {
|
|
|
29
29
|
inputProps = _ref.inputProps,
|
|
30
30
|
_ref$maxSavedColors = _ref.maxSavedColors,
|
|
31
31
|
maxSavedColors = _ref$maxSavedColors === void 0 ? 9 : _ref$maxSavedColors,
|
|
32
|
-
|
|
32
|
+
tooltip = _ref.tooltip,
|
|
33
33
|
isShownSavedColors = _ref.isShownSavedColors,
|
|
34
34
|
_ref$size = _ref.size,
|
|
35
35
|
size = _ref$size === void 0 ? 'M' : _ref$size,
|
|
@@ -45,68 +45,72 @@ var ColorPicker = function ColorPicker(_ref) {
|
|
|
45
45
|
setColorHexInput = _React$useState2[1];
|
|
46
46
|
|
|
47
47
|
var _React$useState3 = React.useState(value),
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
lastValidHexColor = _React$useState3[0],
|
|
49
|
+
setLastValidHexColor = _React$useState3[1];
|
|
50
50
|
|
|
51
|
-
var _React$useState4 = React.useState(
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
var _React$useState4 = React.useState(-1),
|
|
52
|
+
pressed = _React$useState4[0],
|
|
53
|
+
setPressed = _React$useState4[1];
|
|
54
54
|
|
|
55
|
-
var _React$useState5 = React.useState(
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
var _React$useState5 = React.useState(false),
|
|
56
|
+
dropdownVisible = _React$useState5[0],
|
|
57
|
+
setDropdownVisible = _React$useState5[1];
|
|
58
58
|
|
|
59
|
-
var _React$useState6 = React.useState(
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
var _React$useState6 = React.useState(colors),
|
|
60
|
+
savedColors = _React$useState6[0],
|
|
61
|
+
setSavedColors = _React$useState6[1];
|
|
62
62
|
|
|
63
|
-
var _React$useState7 = React.useState(
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
var _React$useState7 = React.useState(tooltip == null ? void 0 : tooltip.copy),
|
|
64
|
+
tooltipText = _React$useState7[0],
|
|
65
|
+
setTooltipText = _React$useState7[1];
|
|
66
66
|
|
|
67
|
-
React.useEffect(function () {
|
|
68
|
-
if (lastValidHexColor) {
|
|
69
|
-
onChange && onChange(lastValidHexColor);
|
|
70
|
-
}
|
|
71
|
-
}, [onChange, lastValidHexColor]);
|
|
72
67
|
var onChangeTextColor = React.useCallback(function (colorValue) {
|
|
73
68
|
setColorTextInput(colorValue);
|
|
74
69
|
|
|
75
70
|
if (isValidTextColor(colorValue)) {
|
|
76
71
|
var standardizedColor = standardizeColor(colorValue);
|
|
77
|
-
setLastValidTextColor(colorValue);
|
|
78
72
|
setColorHexInput(standardizedColor);
|
|
79
73
|
setLastValidHexColor(standardizedColor);
|
|
74
|
+
onChange && onChange(standardizedColor);
|
|
80
75
|
} else if (isValidHexColor(colorValue)) {
|
|
81
76
|
var fullHexColor = convert3DigitHexTo6Digit(colorValue);
|
|
82
|
-
setLastValidTextColor(fullHexColor);
|
|
83
77
|
setColorHexInput(fullHexColor);
|
|
84
78
|
setLastValidHexColor(fullHexColor);
|
|
79
|
+
onChange && onChange(fullHexColor);
|
|
85
80
|
}
|
|
86
81
|
|
|
87
82
|
setPressed(-1);
|
|
88
|
-
}, []);
|
|
83
|
+
}, [onChange]);
|
|
89
84
|
var onChangeHexColor = React.useCallback(function (colorValue) {
|
|
90
85
|
setColorHexInput(colorValue);
|
|
91
86
|
|
|
92
87
|
if (isValidHexColor(colorValue)) {
|
|
93
88
|
var fullHexColor = convert3DigitHexTo6Digit(colorValue);
|
|
94
89
|
setColorTextInput(fullHexColor);
|
|
95
|
-
setLastValidTextColor(fullHexColor);
|
|
96
90
|
setLastValidHexColor(fullHexColor);
|
|
91
|
+
onChange && onChange(fullHexColor);
|
|
97
92
|
}
|
|
98
93
|
|
|
99
94
|
setPressed(-1);
|
|
100
|
-
}, []);
|
|
95
|
+
}, [onChange]);
|
|
101
96
|
var onBlurHandler = React.useCallback(function () {
|
|
102
|
-
setColorTextInput(
|
|
97
|
+
setColorTextInput(lastValidHexColor);
|
|
103
98
|
setColorHexInput(lastValidHexColor);
|
|
104
|
-
}, [lastValidHexColor
|
|
99
|
+
}, [lastValidHexColor]);
|
|
105
100
|
var onClickHandler = React.useCallback(function () {
|
|
106
101
|
setDropdownVisible(!dropdownVisible);
|
|
107
102
|
}, [dropdownVisible]);
|
|
103
|
+
var copyHandler = React.useCallback(function () {
|
|
104
|
+
lastValidHexColor && copy(lastValidHexColor);
|
|
105
|
+
setTooltipText(tooltip == null ? void 0 : tooltip.copied);
|
|
106
|
+
setTimeout(function () {
|
|
107
|
+
setTooltipText(tooltip == null ? void 0 : tooltip.copy);
|
|
108
|
+
}, 3000);
|
|
109
|
+
}, [lastValidHexColor, tooltip]);
|
|
108
110
|
React.useEffect(function () {
|
|
109
|
-
if (
|
|
111
|
+
if (value && (isValidHexColor(value) || isValidTextColor(value))) {
|
|
112
|
+
onChangeTextColor(value);
|
|
113
|
+
} else {
|
|
110
114
|
onChangeTextColor(DEFAULT_COLOR);
|
|
111
115
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
112
116
|
|
|
@@ -190,13 +194,11 @@ var ColorPicker = function ColorPicker(_ref) {
|
|
|
190
194
|
},
|
|
191
195
|
onBlur: onBlurHandler,
|
|
192
196
|
placeholder: placeholder,
|
|
193
|
-
icon1: /*#__PURE__*/React.createElement(ColorPickerStyles.CopyIcon, {
|
|
194
|
-
onClick:
|
|
195
|
-
lastValidHexColor && copy(lastValidHexColor);
|
|
196
|
-
},
|
|
197
|
+
icon1: tooltipText ? /*#__PURE__*/React.createElement(ColorPickerStyles.CopyIcon, {
|
|
198
|
+
onClick: copyHandler,
|
|
197
199
|
component: /*#__PURE__*/React.createElement(CopyClipboardM, null)
|
|
198
|
-
}),
|
|
199
|
-
icon1Tooltip: /*#__PURE__*/React.createElement("span", null, tooltipText
|
|
200
|
+
}) : undefined,
|
|
201
|
+
icon1Tooltip: tooltipText ? /*#__PURE__*/React.createElement("span", null, tooltipText) : undefined
|
|
200
202
|
}), isShownSavedColors && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Divider, null), swatchSection)));
|
|
201
203
|
return /*#__PURE__*/React.createElement(React.Fragment, null, maxWidth && maxWidth >= DEFAULT_MAX_WIDTH_PICKER && /*#__PURE__*/React.createElement(ColorPickerStyles.ColorPickerModalStyle, {
|
|
202
204
|
maxWidth: maxWidth
|
|
@@ -209,6 +211,7 @@ var ColorPicker = function ColorPicker(_ref) {
|
|
|
209
211
|
overlay: dropdown,
|
|
210
212
|
placement: "bottomLeft"
|
|
211
213
|
}, /*#__PURE__*/React.createElement(ColorPickerStyles.ColorPickerSelect, _extends({
|
|
214
|
+
"data-testid": "color-picker",
|
|
212
215
|
prefix: /*#__PURE__*/React.createElement(ColorPickerStyles.ColorTag, {
|
|
213
216
|
shape: TagShape.SINGLE_CHARACTER_ROUND,
|
|
214
217
|
color: lastValidHexColor,
|
|
@@ -22,7 +22,10 @@ export interface ColorPickerProps extends Partial<Pick<HTMLInputElement, 'placeh
|
|
|
22
22
|
infix?: (colorHooks?: Partial<ColorHookType>) => JSX.Element;
|
|
23
23
|
maxSavedColors?: number;
|
|
24
24
|
inputProps?: Omit<InputProps, 'value' | 'onChange' | 'defaultValue'>;
|
|
25
|
-
|
|
25
|
+
tooltip?: {
|
|
26
|
+
copy: string;
|
|
27
|
+
copied: string;
|
|
28
|
+
};
|
|
26
29
|
isShownSavedColors?: boolean;
|
|
27
30
|
size?: 'S' | 'M' | 'L';
|
|
28
31
|
errorText?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-color-picker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Color-Picker Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"@synerise/ds-core": "*",
|
|
46
46
|
"react": ">=16.9.0 < 17.0.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "2bc43ef116113283aed104339dc1a50db543b45e"
|
|
49
49
|
}
|