@chayns-components/color-picker 5.0.0-beta.456 → 5.0.0-beta.458
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/lib/components/hue-slider/HueSlider.js +1 -1
- package/lib/components/hue-slider/HueSlider.js.map +1 -1
- package/lib/components/hue-slider/HueSlider.styles.d.ts +1 -1
- package/lib/components/hue-slider/HueSlider.styles.js +4 -4
- package/lib/components/hue-slider/HueSlider.styles.js.map +1 -1
- package/package.json +3 -3
|
@@ -48,7 +48,7 @@ const HueSlider = _ref => {
|
|
|
48
48
|
}
|
|
49
49
|
}, [onChange]);
|
|
50
50
|
return useMemo(() => /*#__PURE__*/React.createElement(StyledHueSlider, null, /*#__PURE__*/React.createElement(StyledHueSliderInput, {
|
|
51
|
-
color: hslColor,
|
|
51
|
+
$color: hslColor,
|
|
52
52
|
type: "range",
|
|
53
53
|
min: 0,
|
|
54
54
|
max: 360,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HueSlider.js","names":["hslToRgb255","React","useCallback","useEffect","useMemo","useState","convertColorToHsl","splitRgb","StyledHueSlider","StyledHueSliderInput","HueSlider","_ref","onChange","color","editedValue","setEditedValue","hslColor","setHslColor","rgb","hsl","r","g","b","match","toString","parseInt","handleInputChange","event","Number","target","value","percentage","hue","saturation","lightness","h","s","l","createElement","type","min","max","displayName"],"sources":["../../../src/components/hue-slider/HueSlider.tsx"],"sourcesContent":["import { hslToRgb255 } from '@chayns/colors';\nimport React, {\n ChangeEvent,\n CSSProperties,\n FC,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport { convertColorToHsl, splitRgb } from '../../utils/color';\nimport { StyledHueSlider, StyledHueSliderInput } from './HueSlider.styles';\n\nexport type HueSliderProps = {\n /**\n * The color that should be selected.\n */\n color?: CSSProperties['color'];\n /**\n * Function that will be executed when the color is changed.\n */\n onChange?: (color: CSSProperties['color']) => void;\n};\n\nconst HueSlider: FC<HueSliderProps> = ({ onChange, color = 'rgba(255, 0, 0, 1)' }) => {\n const [editedValue, setEditedValue] = useState(0);\n const [hslColor, setHslColor] = useState<CSSProperties['color']>('hsl(0, 0, 100)');\n\n useEffect(() => {\n if (color) {\n const rgb = splitRgb(color);\n\n if (!rgb) {\n return;\n }\n\n const hsl = convertColorToHsl(`rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, 1)`);\n const match = hsl?.toString().match(/hsl\\((\\d+),\\s*([\\d.]+)%,\\s*([\\d.]+)%\\)/);\n\n if (!match || !match[1]) {\n return;\n }\n\n setHslColor(`hsl(${match[1]}, 100%, 50%)`);\n setEditedValue(parseInt(match[1], 10));\n\n if (typeof onChange === 'function') {\n onChange(hsl);\n }\n }\n }, [color, onChange]);\n\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setEditedValue(Number(event.target.value));\n\n const percentage = (Number(event.target.value) / 360) * 100;\n const hue = (percentage / 100) * 360;\n const saturation = 100;\n const lightness = 50;\n\n const hsl = `hsl(${hue}, ${saturation}%, ${lightness}%)`;\n setHslColor(hsl);\n\n if (typeof onChange === 'function') {\n const rgb = hslToRgb255({ h: hue, s: 1, l: 0.5 });\n\n if (!rgb) {\n return;\n }\n\n onChange(`rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${1})`);\n }\n },\n [onChange]
|
|
1
|
+
{"version":3,"file":"HueSlider.js","names":["hslToRgb255","React","useCallback","useEffect","useMemo","useState","convertColorToHsl","splitRgb","StyledHueSlider","StyledHueSliderInput","HueSlider","_ref","onChange","color","editedValue","setEditedValue","hslColor","setHslColor","rgb","hsl","r","g","b","match","toString","parseInt","handleInputChange","event","Number","target","value","percentage","hue","saturation","lightness","h","s","l","createElement","$color","type","min","max","displayName"],"sources":["../../../src/components/hue-slider/HueSlider.tsx"],"sourcesContent":["import { hslToRgb255 } from '@chayns/colors';\nimport React, {\n ChangeEvent,\n CSSProperties,\n FC,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport { convertColorToHsl, splitRgb } from '../../utils/color';\nimport { StyledHueSlider, StyledHueSliderInput } from './HueSlider.styles';\n\nexport type HueSliderProps = {\n /**\n * The color that should be selected.\n */\n color?: CSSProperties['color'];\n /**\n * Function that will be executed when the color is changed.\n */\n onChange?: (color: CSSProperties['color']) => void;\n};\n\nconst HueSlider: FC<HueSliderProps> = ({ onChange, color = 'rgba(255, 0, 0, 1)' }) => {\n const [editedValue, setEditedValue] = useState(0);\n const [hslColor, setHslColor] = useState<CSSProperties['color']>('hsl(0, 0, 100)');\n\n useEffect(() => {\n if (color) {\n const rgb = splitRgb(color);\n\n if (!rgb) {\n return;\n }\n\n const hsl = convertColorToHsl(`rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, 1)`);\n const match = hsl?.toString().match(/hsl\\((\\d+),\\s*([\\d.]+)%,\\s*([\\d.]+)%\\)/);\n\n if (!match || !match[1]) {\n return;\n }\n\n setHslColor(`hsl(${match[1]}, 100%, 50%)`);\n setEditedValue(parseInt(match[1], 10));\n\n if (typeof onChange === 'function') {\n onChange(hsl);\n }\n }\n }, [color, onChange]);\n\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setEditedValue(Number(event.target.value));\n\n const percentage = (Number(event.target.value) / 360) * 100;\n const hue = (percentage / 100) * 360;\n const saturation = 100;\n const lightness = 50;\n\n const hsl = `hsl(${hue}, ${saturation}%, ${lightness}%)`;\n setHslColor(hsl);\n\n if (typeof onChange === 'function') {\n const rgb = hslToRgb255({ h: hue, s: 1, l: 0.5 });\n\n if (!rgb) {\n return;\n }\n\n onChange(`rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${1})`);\n }\n },\n [onChange],\n );\n\n return useMemo(\n () => (\n <StyledHueSlider>\n <StyledHueSliderInput\n $color={hslColor}\n type=\"range\"\n min={0}\n max={360}\n value={editedValue}\n onChange={handleInputChange}\n />\n </StyledHueSlider>\n ),\n [editedValue, handleInputChange, hslColor],\n );\n};\n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AACL,CAAC;AAEDN,SAAS,CAACiC,WAAW,GAAG,WAAW;AAEnC,eAAejC,SAAS"}
|
|
@@ -2,7 +2,7 @@ import type { WithTheme } from '@chayns-components/core';
|
|
|
2
2
|
import type { CSSProperties } from 'react';
|
|
3
3
|
export declare const StyledHueSlider: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
4
4
|
type StyledHueSliderInputProps = WithTheme<{
|
|
5
|
-
color: CSSProperties['color'];
|
|
5
|
+
$color: CSSProperties['color'];
|
|
6
6
|
}>;
|
|
7
7
|
export declare const StyledHueSliderInput: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, StyledHueSliderInputProps>>;
|
|
8
8
|
export {};
|
|
@@ -37,9 +37,9 @@ export const StyledHueSliderInput = styled.input`
|
|
|
37
37
|
height: 20px;
|
|
38
38
|
background-color: ${_ref => {
|
|
39
39
|
let {
|
|
40
|
-
color
|
|
40
|
+
$color
|
|
41
41
|
} = _ref;
|
|
42
|
-
return color;
|
|
42
|
+
return $color;
|
|
43
43
|
}};
|
|
44
44
|
cursor: pointer;
|
|
45
45
|
border-radius: 50%;
|
|
@@ -52,9 +52,9 @@ export const StyledHueSliderInput = styled.input`
|
|
|
52
52
|
height: 20px;
|
|
53
53
|
background-color: ${_ref2 => {
|
|
54
54
|
let {
|
|
55
|
-
color
|
|
55
|
+
$color
|
|
56
56
|
} = _ref2;
|
|
57
|
-
return color;
|
|
57
|
+
return $color;
|
|
58
58
|
}};
|
|
59
59
|
cursor: pointer;
|
|
60
60
|
border-radius: 50%;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HueSlider.styles.js","names":["styled","StyledHueSlider","div","StyledHueSliderInput","input","_ref","color","_ref2"],"sources":["../../../src/components/hue-slider/HueSlider.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport type { CSSProperties } from 'react';\nimport styled from 'styled-components';\n\nexport const StyledHueSlider = styled.div`\n width: 100%;\n cursor: pointer;\n`;\n\ntype StyledHueSliderInputProps = WithTheme<{\n color: CSSProperties['color'];\n}>;\n\nexport const StyledHueSliderInput = styled.input<StyledHueSliderInputProps>`\n width: 100%;\n border-radius: 100px;\n -webkit-appearance: none;\n height: 10px;\n background: linear-gradient(\n to right,\n hsl(0, 100%, 50%),\n hsl(30, 100%, 50%),\n hsl(60, 100%, 50%),\n hsl(90, 100%, 50%),\n hsl(120, 100%, 50%),\n hsl(150, 100%, 50%),\n hsl(180, 100%, 50%),\n hsl(210, 100%, 50%),\n hsl(240, 100%, 50%),\n hsl(270, 100%, 50%),\n hsl(300, 100%, 50%),\n hsl(330, 100%, 50%),\n hsl(360, 100%, 50%)\n );\n outline: none;\n opacity: 0.7;\n -webkit-transition: 0.2s;\n transition: opacity 0.2s;\n\n // Slider thumb for chrome\n &::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 20px;\n height: 20px;\n background-color: ${({ color }) => color};\n cursor: pointer;\n border-radius: 50%;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);\n }\n\n // slider thumb for firefox\n &::-moz-range-thumb {\n width: 20px;\n height: 20px;\n background-color: ${({ color }) => color};\n cursor: pointer;\n border-radius: 50%;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);\n }\n`;\n"],"mappings":"AAEA,OAAOA,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,eAAe,GAAGD,MAAM,CAACE,GAAI;AAC1C;AACA;AACA,CAAC;AAMD,OAAO,MAAMC,oBAAoB,GAAGH,MAAM,CAACI,KAAiC;AAC5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4BC,IAAA;EAAA,IAAC;IAAEC;
|
|
1
|
+
{"version":3,"file":"HueSlider.styles.js","names":["styled","StyledHueSlider","div","StyledHueSliderInput","input","_ref","$color","_ref2"],"sources":["../../../src/components/hue-slider/HueSlider.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport type { CSSProperties } from 'react';\nimport styled from 'styled-components';\n\nexport const StyledHueSlider = styled.div`\n width: 100%;\n cursor: pointer;\n`;\n\ntype StyledHueSliderInputProps = WithTheme<{\n $color: CSSProperties['color'];\n}>;\n\nexport const StyledHueSliderInput = styled.input<StyledHueSliderInputProps>`\n width: 100%;\n border-radius: 100px;\n -webkit-appearance: none;\n height: 10px;\n background: linear-gradient(\n to right,\n hsl(0, 100%, 50%),\n hsl(30, 100%, 50%),\n hsl(60, 100%, 50%),\n hsl(90, 100%, 50%),\n hsl(120, 100%, 50%),\n hsl(150, 100%, 50%),\n hsl(180, 100%, 50%),\n hsl(210, 100%, 50%),\n hsl(240, 100%, 50%),\n hsl(270, 100%, 50%),\n hsl(300, 100%, 50%),\n hsl(330, 100%, 50%),\n hsl(360, 100%, 50%)\n );\n outline: none;\n opacity: 0.7;\n -webkit-transition: 0.2s;\n transition: opacity 0.2s;\n\n // Slider thumb for chrome\n &::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 20px;\n height: 20px;\n background-color: ${({ $color }) => $color};\n cursor: pointer;\n border-radius: 50%;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);\n }\n\n // slider thumb for firefox\n &::-moz-range-thumb {\n width: 20px;\n height: 20px;\n background-color: ${({ $color }) => $color};\n cursor: pointer;\n border-radius: 50%;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);\n }\n`;\n"],"mappings":"AAEA,OAAOA,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,eAAe,GAAGD,MAAM,CAACE,GAAI;AAC1C;AACA;AACA,CAAC;AAMD,OAAO,MAAMC,oBAAoB,GAAGH,MAAM,CAACI,KAAiC;AAC5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4BC,IAAA;EAAA,IAAC;IAAEC;EAAO,CAAC,GAAAD,IAAA;EAAA,OAAKC,MAAM;AAAA,CAAC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4BC,KAAA;EAAA,IAAC;IAAED;EAAO,CAAC,GAAAC,KAAA;EAAA,OAAKD,MAAM;AAAA,CAAC;AACnD;AACA;AACA;AACA;AACA,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/color-picker",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.458",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"typescript": "^5.3.3"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@chayns-components/core": "^5.0.0-beta.
|
|
60
|
+
"@chayns-components/core": "^5.0.0-beta.458",
|
|
61
61
|
"@chayns/colors": "^2.0.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "1d73583ba75b4129c0b79b08a51c5c07d1d74a6c"
|
|
74
74
|
}
|