@synerise/ds-color-picker 0.3.98 → 0.3.100

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 CHANGED
@@ -3,6 +3,22 @@
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.100](https://github.com/Synerise/synerise-design/compare/@synerise/ds-color-picker@0.3.99...@synerise/ds-color-picker@0.3.100) (2024-11-28)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-color-picker
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.3.99](https://github.com/Synerise/synerise-design/compare/@synerise/ds-color-picker@0.3.98...@synerise/ds-color-picker@0.3.99) (2024-11-21)
15
+
16
+ **Note:** Version bump only for package @synerise/ds-color-picker
17
+
18
+
19
+
20
+
21
+
6
22
  ## [0.3.98](https://github.com/Synerise/synerise-design/compare/@synerise/ds-color-picker@0.3.97...@synerise/ds-color-picker@0.3.98) (2024-11-12)
7
23
 
8
24
  **Note:** Version bump only for package @synerise/ds-color-picker
@@ -1,5 +1,4 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
2
  import React from 'react';
4
3
  import { HexColorPicker as ReactColorful } from 'react-colorful';
5
4
  import Divider from '@synerise/ds-divider';
@@ -13,60 +12,50 @@ import { isValidHexColor, isValidTextColor, convert3DigitHexTo6Digit, filterAlph
13
12
  import ColorPickerStyles from './ColorPicker.styles';
14
13
  var DEFAULT_MAX_WIDTH_PICKER = 228;
15
14
  var DEFAULT_COLOR = '#ffffff';
16
-
17
15
  var ColorPicker = function ColorPicker(_ref) {
18
16
  var maxWidth = _ref.maxWidth,
19
- value = _ref.value,
20
- onChange = _ref.onChange,
21
- _ref$colors = _ref.colors,
22
- colors = _ref$colors === void 0 ? [] : _ref$colors,
23
- onSaveColors = _ref.onSaveColors,
24
- _ref$infix = _ref.infix,
25
- infix = _ref$infix === void 0 ? function () {
26
- return /*#__PURE__*/React.createElement(React.Fragment, null);
27
- } : _ref$infix,
28
- placeholder = _ref.placeholder,
29
- inputProps = _ref.inputProps,
30
- _ref$maxSavedColors = _ref.maxSavedColors,
31
- maxSavedColors = _ref$maxSavedColors === void 0 ? 9 : _ref$maxSavedColors,
32
- tooltip = _ref.tooltip,
33
- isShownSavedColors = _ref.isShownSavedColors,
34
- _ref$size = _ref.size,
35
- size = _ref$size === void 0 ? 'M' : _ref$size,
36
- errorText = _ref.errorText,
37
- description = _ref.description;
38
-
17
+ value = _ref.value,
18
+ onChange = _ref.onChange,
19
+ _ref$colors = _ref.colors,
20
+ colors = _ref$colors === void 0 ? [] : _ref$colors,
21
+ onSaveColors = _ref.onSaveColors,
22
+ _ref$infix = _ref.infix,
23
+ infix = _ref$infix === void 0 ? function () {
24
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
25
+ } : _ref$infix,
26
+ placeholder = _ref.placeholder,
27
+ inputProps = _ref.inputProps,
28
+ _ref$maxSavedColors = _ref.maxSavedColors,
29
+ maxSavedColors = _ref$maxSavedColors === void 0 ? 9 : _ref$maxSavedColors,
30
+ tooltip = _ref.tooltip,
31
+ isShownSavedColors = _ref.isShownSavedColors,
32
+ _ref$size = _ref.size,
33
+ size = _ref$size === void 0 ? 'M' : _ref$size,
34
+ errorText = _ref.errorText,
35
+ description = _ref.description;
39
36
  var _React$useState = React.useState(value),
40
- colorTextInput = _React$useState[0],
41
- setColorTextInput = _React$useState[1];
42
-
37
+ colorTextInput = _React$useState[0],
38
+ setColorTextInput = _React$useState[1];
43
39
  var _React$useState2 = React.useState(value),
44
- colorHexInput = _React$useState2[0],
45
- setColorHexInput = _React$useState2[1];
46
-
40
+ colorHexInput = _React$useState2[0],
41
+ setColorHexInput = _React$useState2[1];
47
42
  var _React$useState3 = React.useState(value),
48
- lastValidHexColor = _React$useState3[0],
49
- setLastValidHexColor = _React$useState3[1];
50
-
43
+ lastValidHexColor = _React$useState3[0],
44
+ setLastValidHexColor = _React$useState3[1];
51
45
  var _React$useState4 = React.useState(-1),
52
- pressed = _React$useState4[0],
53
- setPressed = _React$useState4[1];
54
-
46
+ pressed = _React$useState4[0],
47
+ setPressed = _React$useState4[1];
55
48
  var _React$useState5 = React.useState(false),
56
- dropdownVisible = _React$useState5[0],
57
- setDropdownVisible = _React$useState5[1];
58
-
49
+ dropdownVisible = _React$useState5[0],
50
+ setDropdownVisible = _React$useState5[1];
59
51
  var _React$useState6 = React.useState(colors),
60
- savedColors = _React$useState6[0],
61
- setSavedColors = _React$useState6[1];
62
-
52
+ savedColors = _React$useState6[0],
53
+ setSavedColors = _React$useState6[1];
63
54
  var _React$useState7 = React.useState(tooltip == null ? void 0 : tooltip.copy),
64
- tooltipText = _React$useState7[0],
65
- setTooltipText = _React$useState7[1];
66
-
55
+ tooltipText = _React$useState7[0],
56
+ setTooltipText = _React$useState7[1];
67
57
  var onChangeTextColor = React.useCallback(function (colorValue) {
68
58
  setColorTextInput(colorValue);
69
-
70
59
  if (isValidTextColor(colorValue)) {
71
60
  var standardizedColor = standardizeColor(colorValue);
72
61
  setColorHexInput(standardizedColor);
@@ -78,19 +67,16 @@ var ColorPicker = function ColorPicker(_ref) {
78
67
  setLastValidHexColor(fullHexColor);
79
68
  onChange && onChange(fullHexColor);
80
69
  }
81
-
82
70
  setPressed(-1);
83
71
  }, [onChange]);
84
72
  var onChangeHexColor = React.useCallback(function (colorValue) {
85
73
  setColorHexInput(colorValue);
86
-
87
74
  if (isValidHexColor(colorValue)) {
88
75
  var fullHexColor = convert3DigitHexTo6Digit(colorValue);
89
76
  setColorTextInput(fullHexColor);
90
77
  setLastValidHexColor(fullHexColor);
91
78
  onChange && onChange(fullHexColor);
92
79
  }
93
-
94
80
  setPressed(-1);
95
81
  }, [onChange]);
96
82
  var onBlurHandler = React.useCallback(function () {
@@ -112,25 +98,22 @@ var ColorPicker = function ColorPicker(_ref) {
112
98
  onChangeTextColor(value);
113
99
  } else {
114
100
  onChangeTextColor(DEFAULT_COLOR);
115
- } // eslint-disable-next-line react-hooks/exhaustive-deps
116
-
101
+ }
102
+ // eslint-disable-next-line react-hooks/exhaustive-deps
117
103
  }, []);
118
104
  var heightOfDropdown = React.useCallback(function () {
119
105
  if (errorText || description) {
120
106
  if (errorText && description) {
121
107
  return -40;
122
108
  }
123
-
124
109
  return -20;
125
110
  }
126
-
127
111
  return 4;
128
112
  }, [errorText, description]);
129
113
  var ref = React.useRef(null);
130
114
  useOnClickOutside(ref, function () {
131
115
  setDropdownVisible(false);
132
116
  });
133
-
134
117
  var saveColor = function saveColor() {
135
118
  setSavedColors(function (ar) {
136
119
  var colorsArray = (lastValidHexColor ? [lastValidHexColor].concat(ar) : ar).slice(0, maxSavedColors);
@@ -138,7 +121,6 @@ var ColorPicker = function ColorPicker(_ref) {
138
121
  return colorsArray;
139
122
  });
140
123
  };
141
-
142
124
  var swatchSection = /*#__PURE__*/React.createElement(ColorPickerStyles.SwatchSectionWrapper, null, /*#__PURE__*/React.createElement(Tooltip, {
143
125
  title: "Save color swatch"
144
126
  }, /*#__PURE__*/React.createElement(ColorPickerStyles.AddColorButton, {
@@ -152,7 +134,8 @@ var ColorPicker = function ColorPicker(_ref) {
152
134
  color: colorTextInput,
153
135
  setColor: onChangeTextColor
154
136
  }), savedColors.length > 0 && /*#__PURE__*/React.createElement(Tags, {
155
- tagShape: TagShape.SINGLE_CHARACTER_SQUARE // @ts-ignore
137
+ tagShape: TagShape.SINGLE_CHARACTER_SQUARE
138
+ // @ts-ignore
156
139
  ,
157
140
  selected: savedColors.map(function (colorEntry, i) {
158
141
  return {
@@ -228,5 +211,4 @@ var ColorPicker = function ColorPicker(_ref) {
228
211
  errorText: errorText
229
212
  }, inputProps))));
230
213
  };
231
-
232
214
  export default ColorPicker;
@@ -10,7 +10,7 @@ export declare const ColorTag: import("styled-components").StyledComponent<{
10
10
  };
11
11
  }, any, {}, never>;
12
12
  export declare const AddColorButton: import("styled-components").StyledComponent<typeof Button, any, {}, never>;
13
- export declare const CopyIcon: import("styled-components").StyledComponent<import("react").FC<import("@synerise/ds-icon").IconProps>, any, {}, never>;
13
+ export declare const CopyIcon: import("styled-components").StyledComponent<({ name, component, className, ...rest }: import("@synerise/ds-icon").IconProps) => import("react").JSX.Element, any, {}, never>;
14
14
  export declare const ColorPickerInput: import("styled-components").StyledComponent<import("react").ComponentType<import("@synerise/ds-input").BaseProps<HTMLInputElement> & import("antd/lib/input").InputProps>, any, {}, never>;
15
15
  export declare const ColorPickerSelect: import("styled-components").StyledComponent<import("react").ComponentType<import("@synerise/ds-input").BaseProps<HTMLInputElement> & import("antd/lib/input").InputProps>, any, {}, never>;
16
16
  export declare const PrefixTag: import("styled-components").StyledComponent<"div", any, {
@@ -44,7 +44,7 @@ declare const _default: {
44
44
  SwatchSectionWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
45
45
  PreffixWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
46
46
  ValueWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
47
- CopyIcon: import("styled-components").StyledComponent<import("react").FC<import("@synerise/ds-icon").IconProps>, any, {}, never>;
47
+ CopyIcon: import("styled-components").StyledComponent<({ name, component, className, ...rest }: import("@synerise/ds-icon").IconProps) => import("react").JSX.Element, any, {}, never>;
48
48
  ColorPickerInput: import("styled-components").StyledComponent<import("react").ComponentType<import("@synerise/ds-input").BaseProps<HTMLInputElement> & import("antd/lib/input").InputProps>, any, {}, never>;
49
49
  TagDot: import("styled-components").StyledComponent<"div", any, {
50
50
  pressed?: boolean | undefined;
@@ -1,9 +1,7 @@
1
1
  var _templateObject;
2
-
3
2
  function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
4
-
5
- import styled, { createGlobalStyle } from 'styled-components'; // @ts-ignore
6
-
3
+ import styled, { createGlobalStyle } from 'styled-components';
4
+ // @ts-ignore
7
5
  import { TagsStyles, Tag } from '@synerise/ds-tags';
8
6
  import Button from '@synerise/ds-button';
9
7
  import Icon from '@synerise/ds-icon';
@@ -1,5 +1,4 @@
1
1
  export var ColorPickerSize;
2
-
3
2
  (function (ColorPickerSize) {
4
3
  ColorPickerSize[ColorPickerSize["S"] = 136] = "S";
5
4
  ColorPickerSize[ColorPickerSize["M"] = 168] = "M";
package/dist/utils.js CHANGED
@@ -6,6 +6,7 @@ export var filterAlphanumeric = function filterAlphanumeric(colorValue) {
6
6
  export var isValidHexColor = function isValidHexColor(hex) {
7
7
  return hexColorRegex.test(hex);
8
8
  };
9
+
9
10
  /**
10
11
  *
11
12
  * Method that creates an option element and then assigns a colour to its styles.
@@ -14,14 +15,14 @@ export var isValidHexColor = function isValidHexColor(hex) {
14
15
  * @param {string} strColor
15
16
  * @returns {boolean}
16
17
  */
17
-
18
18
  export var isValidTextColor = function isValidTextColor(strColor) {
19
- if (!strColor) return false; // eslint-disable-next-line no-undef
20
-
19
+ if (!strColor) return false;
20
+ // eslint-disable-next-line no-undef
21
21
  var s = new Option().style;
22
22
  s.color = strColor;
23
23
  return s.color === strColor;
24
24
  };
25
+
25
26
  /**
26
27
  *
27
28
  * A method that converts color in user-understandable notation to HEX notation.
@@ -30,29 +31,23 @@ export var isValidTextColor = function isValidTextColor(strColor) {
30
31
  * @param {string} color
31
32
  * @returns {string}
32
33
  */
33
-
34
34
  export var standardizeColor = function standardizeColor(color) {
35
35
  var ctx = document.createElement('canvas').getContext('2d');
36
-
37
36
  if (ctx) {
38
37
  ctx.fillStyle = color;
39
38
  return ctx.fillStyle;
40
39
  }
41
-
42
40
  return '';
43
41
  };
44
42
  export var convert3DigitHexTo6Digit = function convert3DigitHexTo6Digit(hexColor) {
45
43
  var alphaHexColor = filterAlphanumeric(hexColor);
46
-
47
44
  if (alphaHexColor.length === 3) {
48
- var newAlphaHexColor = ''; // eslint-disable-next-line no-plusplus
49
-
45
+ var newAlphaHexColor = '';
46
+ // eslint-disable-next-line no-plusplus
50
47
  for (var i = 0; i < alphaHexColor.length; i++) {
51
48
  newAlphaHexColor += alphaHexColor[i] + alphaHexColor[i];
52
49
  }
53
-
54
50
  return "#" + newAlphaHexColor;
55
51
  }
56
-
57
52
  return hexColor;
58
53
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-color-picker",
3
- "version": "0.3.98",
3
+ "version": "0.3.100",
4
4
  "description": "Color-Picker Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -34,14 +34,14 @@
34
34
  ],
35
35
  "types": "dist/index.d.ts",
36
36
  "dependencies": {
37
- "@synerise/ds-button": "^0.21.18",
38
- "@synerise/ds-divider": "^0.7.14",
39
- "@synerise/ds-dropdown": "^0.18.23",
40
- "@synerise/ds-icon": "^0.66.4",
41
- "@synerise/ds-input": "^0.24.13",
42
- "@synerise/ds-tags": "^0.10.17",
43
- "@synerise/ds-tooltip": "^0.14.48",
44
- "@synerise/ds-utils": "^0.31.1",
37
+ "@synerise/ds-button": "^0.21.20",
38
+ "@synerise/ds-divider": "^0.7.16",
39
+ "@synerise/ds-dropdown": "^0.18.25",
40
+ "@synerise/ds-icon": "^0.67.1",
41
+ "@synerise/ds-input": "^0.24.15",
42
+ "@synerise/ds-tags": "^0.10.19",
43
+ "@synerise/ds-tooltip": "^0.14.50",
44
+ "@synerise/ds-utils": "^0.31.2",
45
45
  "copy-to-clipboard": "^3.3.1",
46
46
  "react-colorful": "^5.2.0"
47
47
  },
@@ -51,5 +51,5 @@
51
51
  "react": ">=16.9.0 <= 17.0.2",
52
52
  "styled-components": "5.0.1"
53
53
  },
54
- "gitHead": "8d26191fc0475407e0691b9b183761ad3cd7c87d"
54
+ "gitHead": "4a56ee7ef816c22341ce704154dc7aa65b7d1dcc"
55
55
  }