@chayns-components/color-picker 5.0.0-beta.588 → 5.0.0-beta.589

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.
@@ -155,51 +155,72 @@ const ColorArea = () => {
155
155
  updateShouldCallOnSelect(true);
156
156
  }
157
157
  }, [updateShouldCallOnSelect, updateShouldGetCoordinates]);
158
+ const move = (0, _react.useCallback)((xCords, yCords) => {
159
+ let newXCords = xCords;
160
+ let newYCords = yCords;
161
+ switch (true) {
162
+ case xCords > 300:
163
+ newXCords = 300;
164
+ break;
165
+ case xCords < 0:
166
+ newXCords = 0;
167
+ break;
168
+ default:
169
+ break;
170
+ }
171
+ switch (true) {
172
+ case yCords > 150:
173
+ newYCords = 150;
174
+ break;
175
+ case yCords < 0:
176
+ newYCords = 0;
177
+ break;
178
+ default:
179
+ break;
180
+ }
181
+ x.set(newXCords);
182
+ y.set(newYCords);
183
+ setColor();
184
+ }, [setColor, x, y]);
158
185
  const handleMouseMove = (0, _react.useCallback)(event => {
159
186
  if (canDrag.current && pseudoRef.current) {
160
187
  const {
161
188
  left,
162
189
  top
163
190
  } = pseudoRef.current.getBoundingClientRect();
164
- let xCords = event.clientX - left - 10;
165
- let yCords = event.clientY - top - 10;
166
- switch (true) {
167
- case xCords > 300:
168
- xCords = 300;
169
- break;
170
- case xCords < 0:
171
- xCords = 0;
172
- break;
173
- default:
174
- break;
175
- }
176
- switch (true) {
177
- case yCords > 150:
178
- yCords = 150;
179
- break;
180
- case yCords < 0:
181
- yCords = 0;
182
- break;
183
- default:
184
- break;
185
- }
186
- x.set(xCords);
187
- y.set(yCords);
188
- setColor();
191
+ const xCords = event.clientX - left - 10;
192
+ const yCords = event.clientY - top - 10;
193
+ move(xCords, yCords);
189
194
  }
190
- }, [setColor, x, y]);
195
+ }, [move]);
196
+ const handleTouchMove = (0, _react.useCallback)(event => {
197
+ if (canDrag.current && pseudoRef.current) {
198
+ event.preventDefault();
199
+ const {
200
+ left,
201
+ top
202
+ } = pseudoRef.current.getBoundingClientRect();
203
+ const xCords = event.changedTouches[0] ? event.changedTouches[0].clientX - left - 10 : event.pageX;
204
+ const yCords = event.changedTouches[0] ? event.changedTouches[0].clientY - top - 10 : event.pageY;
205
+ move(xCords, yCords);
206
+ }
207
+ }, [move]);
191
208
  (0, _react.useEffect)(() => {
192
209
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
193
210
  // @ts-ignore
194
211
  window.addEventListener('mousemove', handleMouseMove);
195
212
  window.addEventListener('pointerup', handlePointerUp);
213
+ window.addEventListener('touchmove', handleTouchMove);
214
+ window.addEventListener('touchend', handlePointerUp);
196
215
  return () => {
197
216
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
198
217
  // @ts-ignore
199
218
  window.removeEventListener('mousemove', handleMouseMove);
200
219
  window.removeEventListener('pointerup', handlePointerUp);
220
+ window.removeEventListener('touchmove', handleTouchMove);
221
+ window.removeEventListener('touchend', handlePointerUp);
201
222
  };
202
- }, [handleMouseMove, handlePointerUp]);
223
+ }, [handleMouseMove, handlePointerUp, handleTouchMove]);
203
224
  return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_ColorArea.StyledColorArea, null, /*#__PURE__*/_react.default.createElement(_ColorArea.StyledColorAreaCanvas, {
204
225
  ref: canvasRef
205
226
  }), /*#__PURE__*/_react.default.createElement(_ColorArea.StyledColorAreaPseudo, {
@@ -1 +1 @@
1
- {"version":3,"file":"ColorArea.js","names":["_react","_interopRequireWildcard","require","_ColorArea","_colors","_framerMotion","_color","_ColorPickerProvider","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ColorArea","selectedColor","updateSelectedColor","updateIsPresetColor","isPresetColor","shouldGetCoordinates","updateShouldGetCoordinates","updateShouldCallOnSelect","hueColor","useContext","ColorPickerContext","opacity","setOpacity","useState","scale","setScale","scaleX","scaleY","isPresetColorRef","useRef","shouldGetCoordinatesRef","canDrag","canvasRef","pseudoRef","dragControls","useDragControls","x","useMotionValue","y","useEffect","current","extractRgbValues","canvas","rect","getBoundingClientRect","width","height","setColor","useCallback","xCord","yCord","color","getColorFromCoordinates","coordinates","_canvasRef$current","ctx","getContext","hsv","rgbToHsv","hex","hsvToHex","h","s","v","colorGradiant","createLinearGradient","addColorStop","fillStyle","fillRect","transparentGradiant","handleStartDrag","cords","getCoordinatesFromColor","tolerance","handleDrag","handleClick","event","left","top","target","clientX","clientY","handlePointerUp","handleMouseMove","xCords","yCords","window","addEventListener","removeEventListener","useMemo","createElement","StyledColorArea","StyledColorAreaCanvas","ref","StyledColorAreaPseudo","onPointerDown","onClick","StyledMotionColorAreaPointer","drag","dragConstraints","style","dragElastic","dragMomentum","onDrag","displayName","_default","exports"],"sources":["../../../../../../../src/components/color-picker/color-picker-wrapper/color-picker-popup/color-area/ColorArea.tsx"],"sourcesContent":["import React, {\n MouseEvent,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport {\n StyledColorArea,\n StyledColorAreaCanvas,\n StyledColorAreaPseudo,\n StyledMotionColorAreaPointer,\n} from './ColorArea.styles';\n\nimport { hsvToHex } from '@chayns/colors';\nimport { useDragControls, useMotionValue } from 'framer-motion';\nimport type { Scale } from '../../../../../types/colorPicker';\nimport {\n extractRgbValues,\n getColorFromCoordinates,\n getCoordinatesFromColor,\n rgbToHsv,\n} from '../../../../../utils/color';\nimport { ColorPickerContext } from '../../../../ColorPickerProvider';\n\nconst ColorArea = () => {\n const {\n selectedColor,\n updateSelectedColor,\n updateIsPresetColor,\n isPresetColor,\n shouldGetCoordinates,\n updateShouldGetCoordinates,\n updateShouldCallOnSelect,\n hueColor,\n } = useContext(ColorPickerContext);\n\n const [opacity, setOpacity] = useState<number>(1);\n const [scale, setScale] = useState<Scale>({ scaleX: 0, scaleY: 0 });\n\n const isPresetColorRef = useRef(false);\n const shouldGetCoordinatesRef = useRef(false);\n const canDrag = useRef(false);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const pseudoRef = useRef<HTMLDivElement>(null);\n\n const dragControls = useDragControls();\n\n const x = useMotionValue(0);\n const y = useMotionValue(0);\n\n useEffect(() => {\n isPresetColorRef.current = isPresetColor ?? false;\n }, [isPresetColor]);\n\n useEffect(() => {\n shouldGetCoordinatesRef.current = shouldGetCoordinates ?? true;\n }, [shouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor) {\n const { a } = extractRgbValues(selectedColor);\n\n setOpacity(a);\n }\n }, [selectedColor]);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n\n if (!canvas) {\n return;\n }\n\n const rect = canvas.getBoundingClientRect();\n\n const scaleX = canvas.width / rect.width;\n const scaleY = canvas.height / rect.height;\n\n setScale({ scaleX, scaleY });\n }, []);\n\n const setColor = useCallback(() => {\n const xCord = x.get();\n const yCord = y.get();\n\n if (typeof updateSelectedColor === 'function') {\n const color = getColorFromCoordinates({\n coordinates: {\n x: xCord,\n y: yCord,\n },\n canvas: canvasRef,\n opacity,\n scale,\n });\n\n if (color === 'transparent') {\n return;\n }\n\n updateSelectedColor(color);\n }\n }, [opacity, scale, updateSelectedColor, x, y]);\n\n useEffect(() => {\n const ctx = canvasRef.current?.getContext('2d');\n\n if (!ctx) {\n return;\n }\n\n const hsv = rgbToHsv(hueColor);\n\n const hex = hsvToHex({ h: hsv?.h ?? 1, s: 1, v: 1 });\n\n const colorGradiant = ctx.createLinearGradient(0, 0, 300, 0);\n colorGradiant.addColorStop(0, '#fff');\n colorGradiant.addColorStop(1, hex ?? 'red');\n\n ctx.fillStyle = colorGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n const transparentGradiant = ctx.createLinearGradient(0, 0, 0, 150);\n\n transparentGradiant.addColorStop(0, 'transparent');\n transparentGradiant.addColorStop(1, '#000');\n\n ctx.fillStyle = transparentGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n if (isPresetColorRef.current) {\n if (typeof updateIsPresetColor === 'function') {\n updateIsPresetColor(false);\n }\n\n return;\n }\n\n setColor();\n }, [hueColor, setColor, updateIsPresetColor]);\n\n const handleStartDrag = useCallback(() => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n canDrag.current = true;\n }, [updateShouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor && shouldGetCoordinatesRef.current) {\n const cords = getCoordinatesFromColor({\n color: selectedColor,\n canvas: canvasRef,\n tolerance: 10,\n });\n\n if (cords) {\n x.set(cords.x);\n y.set(cords.y);\n }\n }\n }, [selectedColor, x, y]);\n\n const handleDrag = useCallback(() => {\n setColor();\n }, [setColor]);\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n const { left, top } = (event.target as HTMLDivElement).getBoundingClientRect();\n\n x.set(event.clientX - left - 10);\n y.set(event.clientY - top - 10);\n\n setColor();\n },\n [setColor, updateShouldGetCoordinates, x, y],\n );\n\n const handlePointerUp = useCallback(() => {\n canDrag.current = false;\n\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(true);\n }\n\n if (typeof updateShouldCallOnSelect === 'function') {\n updateShouldCallOnSelect(true);\n }\n }, [updateShouldCallOnSelect, updateShouldGetCoordinates]);\n\n const handleMouseMove = useCallback(\n (event: MouseEvent) => {\n if (canDrag.current && pseudoRef.current) {\n const { left, top } = pseudoRef.current.getBoundingClientRect();\n\n let xCords = event.clientX - left - 10;\n let yCords = event.clientY - top - 10;\n\n switch (true) {\n case xCords > 300:\n xCords = 300;\n break;\n case xCords < 0:\n xCords = 0;\n break;\n default:\n break;\n }\n\n switch (true) {\n case yCords > 150:\n yCords = 150;\n break;\n case yCords < 0:\n yCords = 0;\n break;\n default:\n break;\n }\n\n x.set(xCords);\n y.set(yCords);\n\n setColor();\n }\n },\n [setColor, x, y],\n );\n\n useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('pointerup', handlePointerUp);\n\n return () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('pointerup', handlePointerUp);\n };\n }, [handleMouseMove, handlePointerUp]);\n\n return useMemo(\n () => (\n <StyledColorArea>\n <StyledColorAreaCanvas ref={canvasRef} />\n <StyledColorAreaPseudo\n ref={pseudoRef}\n onPointerDown={handleStartDrag}\n onClick={handleClick}\n >\n <StyledMotionColorAreaPointer\n drag\n dragConstraints={pseudoRef}\n style={{ x, y }}\n dragElastic={false}\n dragMomentum={false}\n dragControls={dragControls}\n onDrag={handleDrag}\n />\n </StyledColorAreaPseudo>\n </StyledColorArea>\n ),\n [dragControls, handleClick, handleDrag, handleStartDrag, x, y],\n );\n};\n\nColorArea.displayName = 'ColorArea';\n\nexport default ColorArea;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,UAAA,GAAAD,OAAA;AAOA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AAMA,IAAAK,oBAAA,GAAAL,OAAA;AAAqE,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAA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e,EAAED,eAAe,CAAC,CAAC;EAEtC,OAAO,IAAAO,cAAO,EACV,mBACI3G,MAAA,CAAAc,OAAA,CAAA8F,aAAA,CAACzG,UAAA,CAAA0G,eAAe,qBACZ7G,MAAA,CAAAc,OAAA,CAAA8F,aAAA,CAACzG,UAAA,CAAA2G,qBAAqB;IAACC,GAAG,EAAE7D;EAAU,CAAE,CAAC,eACzClD,MAAA,CAAAc,OAAA,CAAA8F,aAAA,CAACzG,UAAA,CAAA6G,qBAAqB;IAClBD,GAAG,EAAE5D,SAAU;IACf8D,aAAa,EAAEzB,eAAgB;IAC/B0B,OAAO,EAAErB;EAAY,gBAErB7F,MAAA,CAAAc,OAAA,CAAA8F,aAAA,CAACzG,UAAA,CAAAgH,4BAA4B;IACzBC,IAAI;IACJC,eAAe,EAAElE,SAAU;IAC3BmE,KAAK,EAAE;MAAEhE,CAAC;MAAEE;IAAE,CAAE;IAChB+D,WAAW,EAAE,KAAM;IACnBC,YAAY,EAAE,KAAM;IACpBpE,YAAY,EAAEA,YAAa;IAC3BqE,MAAM,EAAE7B;EAAW,CACtB,CACkB,CACV,CACpB,EACD,CAACxC,YAAY,EAAEyC,WAAW,EAAED,UAAU,EAAEJ,eAAe,EAAElC,CAAC,EAAEE,CAAC,CACjE,CAAC;AACL,CAAC;AAED5B,SAAS,CAAC8F,WAAW,GAAG,WAAW;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA9G,OAAA,GAErBc,SAAS","ignoreList":[]}
1
+ {"version":3,"file":"ColorArea.js","names":["_react","_interopRequireWildcard","require","_ColorArea","_colors","_framerMotion","_color","_ColorPickerProvider","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ColorArea","selectedColor","updateSelectedColor","updateIsPresetColor","isPresetColor","shouldGetCoordinates","updateShouldGetCoordinates","updateShouldCallOnSelect","hueColor","useContext","ColorPickerContext","opacity","setOpacity","useState","scale","setScale","scaleX","scaleY","isPresetColorRef","useRef","shouldGetCoordinatesRef","canDrag","canvasRef","pseudoRef","dragControls","useDragControls","x","useMotionValue","y","useEffect","current","extractRgbValues","canvas","rect","getBoundingClientRect","width","height","setColor","useCallback","xCord","yCord","color","getColorFromCoordinates","coordinates","_canvasRef$current","ctx","getContext","hsv","rgbToHsv","hex","hsvToHex","h","s","v","colorGradiant","createLinearGradient","addColorStop","fillStyle","fillRect","transparentGradiant","handleStartDrag","cords","getCoordinatesFromColor","tolerance","handleDrag","handleClick","event","left","top","target","clientX","clientY","handlePointerUp","move","xCords","yCords","newXCords","newYCords","handleMouseMove","handleTouchMove","preventDefault","changedTouches","pageX","pageY","window","addEventListener","removeEventListener","useMemo","createElement","StyledColorArea","StyledColorAreaCanvas","ref","StyledColorAreaPseudo","onPointerDown","onClick","StyledMotionColorAreaPointer","drag","dragConstraints","style","dragElastic","dragMomentum","onDrag","displayName","_default","exports"],"sources":["../../../../../../../src/components/color-picker/color-picker-wrapper/color-picker-popup/color-area/ColorArea.tsx"],"sourcesContent":["import React, {\n MouseEvent,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport {\n StyledColorArea,\n StyledColorAreaCanvas,\n StyledColorAreaPseudo,\n StyledMotionColorAreaPointer,\n} from './ColorArea.styles';\n\nimport { hsvToHex } from '@chayns/colors';\nimport { useDragControls, useMotionValue } from 'framer-motion';\nimport type { Scale } from '../../../../../types/colorPicker';\nimport {\n extractRgbValues,\n getColorFromCoordinates,\n getCoordinatesFromColor,\n rgbToHsv,\n} from '../../../../../utils/color';\nimport { ColorPickerContext } from '../../../../ColorPickerProvider';\n\nconst ColorArea = () => {\n const {\n selectedColor,\n updateSelectedColor,\n updateIsPresetColor,\n isPresetColor,\n shouldGetCoordinates,\n updateShouldGetCoordinates,\n updateShouldCallOnSelect,\n hueColor,\n } = useContext(ColorPickerContext);\n\n const [opacity, setOpacity] = useState<number>(1);\n const [scale, setScale] = useState<Scale>({ scaleX: 0, scaleY: 0 });\n\n const isPresetColorRef = useRef(false);\n const shouldGetCoordinatesRef = useRef(false);\n const canDrag = useRef(false);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const pseudoRef = useRef<HTMLDivElement>(null);\n\n const dragControls = useDragControls();\n\n const x = useMotionValue(0);\n const y = useMotionValue(0);\n\n useEffect(() => {\n isPresetColorRef.current = isPresetColor ?? false;\n }, [isPresetColor]);\n\n useEffect(() => {\n shouldGetCoordinatesRef.current = shouldGetCoordinates ?? true;\n }, [shouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor) {\n const { a } = extractRgbValues(selectedColor);\n\n setOpacity(a);\n }\n }, [selectedColor]);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n\n if (!canvas) {\n return;\n }\n\n const rect = canvas.getBoundingClientRect();\n\n const scaleX = canvas.width / rect.width;\n const scaleY = canvas.height / rect.height;\n\n setScale({ scaleX, scaleY });\n }, []);\n\n const setColor = useCallback(() => {\n const xCord = x.get();\n const yCord = y.get();\n\n if (typeof updateSelectedColor === 'function') {\n const color = getColorFromCoordinates({\n coordinates: {\n x: xCord,\n y: yCord,\n },\n canvas: canvasRef,\n opacity,\n scale,\n });\n\n if (color === 'transparent') {\n return;\n }\n\n updateSelectedColor(color);\n }\n }, [opacity, scale, updateSelectedColor, x, y]);\n\n useEffect(() => {\n const ctx = canvasRef.current?.getContext('2d');\n\n if (!ctx) {\n return;\n }\n\n const hsv = rgbToHsv(hueColor);\n\n const hex = hsvToHex({ h: hsv?.h ?? 1, s: 1, v: 1 });\n\n const colorGradiant = ctx.createLinearGradient(0, 0, 300, 0);\n colorGradiant.addColorStop(0, '#fff');\n colorGradiant.addColorStop(1, hex ?? 'red');\n\n ctx.fillStyle = colorGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n const transparentGradiant = ctx.createLinearGradient(0, 0, 0, 150);\n\n transparentGradiant.addColorStop(0, 'transparent');\n transparentGradiant.addColorStop(1, '#000');\n\n ctx.fillStyle = transparentGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n if (isPresetColorRef.current) {\n if (typeof updateIsPresetColor === 'function') {\n updateIsPresetColor(false);\n }\n\n return;\n }\n\n setColor();\n }, [hueColor, setColor, updateIsPresetColor]);\n\n const handleStartDrag = useCallback(() => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n canDrag.current = true;\n }, [updateShouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor && shouldGetCoordinatesRef.current) {\n const cords = getCoordinatesFromColor({\n color: selectedColor,\n canvas: canvasRef,\n tolerance: 10,\n });\n\n if (cords) {\n x.set(cords.x);\n y.set(cords.y);\n }\n }\n }, [selectedColor, x, y]);\n\n const handleDrag = useCallback(() => {\n setColor();\n }, [setColor]);\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n const { left, top } = (event.target as HTMLDivElement).getBoundingClientRect();\n\n x.set(event.clientX - left - 10);\n y.set(event.clientY - top - 10);\n\n setColor();\n },\n [setColor, updateShouldGetCoordinates, x, y],\n );\n\n const handlePointerUp = useCallback(() => {\n canDrag.current = false;\n\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(true);\n }\n\n if (typeof updateShouldCallOnSelect === 'function') {\n updateShouldCallOnSelect(true);\n }\n }, [updateShouldCallOnSelect, updateShouldGetCoordinates]);\n\n const move = useCallback(\n (xCords: number, yCords: number) => {\n let newXCords = xCords;\n let newYCords = yCords;\n\n switch (true) {\n case xCords > 300:\n newXCords = 300;\n break;\n case xCords < 0:\n newXCords = 0;\n break;\n default:\n break;\n }\n\n switch (true) {\n case yCords > 150:\n newYCords = 150;\n break;\n case yCords < 0:\n newYCords = 0;\n break;\n default:\n break;\n }\n\n x.set(newXCords);\n y.set(newYCords);\n\n setColor();\n },\n [setColor, x, y],\n );\n\n const handleMouseMove = useCallback(\n (event: MouseEvent) => {\n if (canDrag.current && pseudoRef.current) {\n const { left, top } = pseudoRef.current.getBoundingClientRect();\n\n const xCords = event.clientX - left - 10;\n const yCords = event.clientY - top - 10;\n\n move(xCords, yCords);\n }\n },\n [move],\n );\n\n const handleTouchMove = useCallback(\n (event: TouchEvent) => {\n if (canDrag.current && pseudoRef.current) {\n event.preventDefault();\n\n const { left, top } = pseudoRef.current.getBoundingClientRect();\n\n const xCords = event.changedTouches[0]\n ? event.changedTouches[0].clientX - left - 10\n : (event as unknown as { pageX: number }).pageX;\n const yCords = event.changedTouches[0]\n ? event.changedTouches[0].clientY - top - 10\n : (event as unknown as { pageY: number }).pageY;\n\n move(xCords, yCords);\n }\n },\n [move],\n );\n\n useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('pointerup', handlePointerUp);\n window.addEventListener('touchmove', handleTouchMove);\n window.addEventListener('touchend', handlePointerUp);\n\n return () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('pointerup', handlePointerUp);\n window.removeEventListener('touchmove', handleTouchMove);\n window.removeEventListener('touchend', handlePointerUp);\n };\n }, [handleMouseMove, handlePointerUp, handleTouchMove]);\n\n return useMemo(\n () => (\n <StyledColorArea>\n <StyledColorAreaCanvas ref={canvasRef} />\n <StyledColorAreaPseudo\n ref={pseudoRef}\n onPointerDown={handleStartDrag}\n onClick={handleClick}\n >\n <StyledMotionColorAreaPointer\n drag\n dragConstraints={pseudoRef}\n style={{ x, y }}\n dragElastic={false}\n dragMomentum={false}\n dragControls={dragControls}\n onDrag={handleDrag}\n />\n </StyledColorAreaPseudo>\n </StyledColorArea>\n ),\n [dragControls, handleClick, handleDrag, handleStartDrag, x, y],\n );\n};\n\nColorArea.displayName = 'ColorArea';\n\nexport default ColorArea;\n"],"mappings":";;;;;;AAAA,IA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CACV,CACpB,EACD,CAACxC,YAAY,EAAEyC,WAAW,EAAED,UAAU,EAAEJ,eAAe,EAAElC,CAAC,EAAEE,CAAC,CACjE,CAAC;AACL,CAAC;AAED5B,SAAS,CAACsG,WAAW,GAAG,WAAW;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAtH,OAAA,GAErBc,SAAS","ignoreList":[]}
@@ -47,6 +47,7 @@ const StyledHueSliderInput = exports.StyledHueSliderInput = _styledComponents.de
47
47
  appearance: none;
48
48
  width: 20px;
49
49
  height: 20px;
50
+ opacity: 0;
50
51
  cursor: pointer;
51
52
  border-radius: 50%;
52
53
  }
@@ -54,6 +55,7 @@ const StyledHueSliderInput = exports.StyledHueSliderInput = _styledComponents.de
54
55
  // slider thumb for firefox
55
56
  &::-moz-range-thumb {
56
57
  width: 20px;
58
+ opacity: 0;
57
59
  height: 20px;
58
60
  cursor: pointer;
59
61
  border-radius: 50%;
@@ -1 +1 @@
1
- {"version":3,"file":"HueSlider.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledHueSlider","exports","styled","div","StyledHueSliderInput","input","StyledHueSliderThumb","attrs","$position","$color","style","left","backgroundColor"],"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 height: 30px;\n cursor: pointer;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n\ntype StyledHueSliderInputProps = WithTheme<{\n $color: CSSProperties['color'];\n}>;\n\nexport const StyledHueSliderInput = styled.input<StyledHueSliderInputProps>`\n width: calc(100% - 10px);\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 cursor: pointer;\n border-radius: 50%;\n }\n\n // slider thumb for firefox\n &::-moz-range-thumb {\n width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 50%;\n }\n`;\n\ntype StyledHueSliderThumbProps = WithTheme<{ $position: number; $color: CSSProperties['color'] }>;\n\nexport const StyledHueSliderThumb = styled.div.attrs<StyledHueSliderThumbProps>(\n ({ $position, $color }) => ({\n style: {\n left: `${$position}px`,\n backgroundColor: $color,\n },\n }),\n)`\n min-width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 100px;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);\n pointer-events: none;\n z-index: 3;\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0 8px;\n white-space: nowrap;\n`;\n"],"mappings":";;;;;;AAEA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhC,MAAMG,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAGE,yBAAM,CAACC,GAAI;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAMM,MAAMC,oBAAoB,GAAAH,OAAA,CAAAG,oBAAA,GAAGF,yBAAM,CAACG,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAIM,MAAMC,oBAAoB,GAAAL,OAAA,CAAAK,oBAAA,GAAGJ,yBAAM,CAACC,GAAG,CAACI,KAAK,CAChD,CAAC;EAAEC,SAAS;EAAEC;AAAO,CAAC,MAAM;EACxBC,KAAK,EAAE;IACHC,IAAI,EAAG,GAAEH,SAAU,IAAG;IACtBI,eAAe,EAAEH;EACrB;AACJ,CAAC,CACL,CAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"HueSlider.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledHueSlider","exports","styled","div","StyledHueSliderInput","input","StyledHueSliderThumb","attrs","$position","$color","style","left","backgroundColor"],"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 height: 30px;\n cursor: pointer;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n\ntype StyledHueSliderInputProps = WithTheme<{\n $color: CSSProperties['color'];\n}>;\n\nexport const StyledHueSliderInput = styled.input<StyledHueSliderInputProps>`\n width: calc(100% - 10px);\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 opacity: 0;\n cursor: pointer;\n border-radius: 50%;\n }\n\n // slider thumb for firefox\n &::-moz-range-thumb {\n width: 20px;\n opacity: 0;\n height: 20px;\n cursor: pointer;\n border-radius: 50%;\n }\n`;\n\ntype StyledHueSliderThumbProps = WithTheme<{ $position: number; $color: CSSProperties['color'] }>;\n\nexport const StyledHueSliderThumb = styled.div.attrs<StyledHueSliderThumbProps>(\n ({ $position, $color }) => ({\n style: {\n left: `${$position}px`,\n backgroundColor: $color,\n },\n }),\n)`\n min-width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 100px;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);\n pointer-events: none;\n z-index: 3;\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0 8px;\n white-space: nowrap;\n`;\n"],"mappings":";;;;;;AAEA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhC,MAAMG,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAGE,yBAAM,CAACC,GAAI;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAMM,MAAMC,oBAAoB,GAAAH,OAAA,CAAAG,oBAAA,GAAGF,yBAAM,CAACG,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAIM,MAAMC,oBAAoB,GAAAL,OAAA,CAAAK,oBAAA,GAAGJ,yBAAM,CAACC,GAAG,CAACI,KAAK,CAChD,CAAC;EAAEC,SAAS;EAAEC;AAAO,CAAC,MAAM;EACxBC,KAAK,EAAE;IACHC,IAAI,EAAG,GAAEH,SAAU,IAAG;IACtBI,eAAe,EAAEH;EACrB;AACJ,CAAC,CACL,CAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -54,6 +54,7 @@ const StyledTransparencySliderInput = exports.StyledTransparencySliderInput = _s
54
54
  &::-webkit-slider-thumb {
55
55
  -webkit-appearance: none;
56
56
  appearance: none;
57
+ opacity: 0;
57
58
  width: 20px;
58
59
  height: 20px;
59
60
  cursor: pointer;
@@ -64,6 +65,7 @@ const StyledTransparencySliderInput = exports.StyledTransparencySliderInput = _s
64
65
  &::-moz-range-thumb {
65
66
  width: 20px;
66
67
  height: 20px;
68
+ opacity: 0;
67
69
  cursor: pointer;
68
70
  border-radius: 50%;
69
71
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TransparencySlider.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledTransparencySlider","exports","styled","div","StyledTransparencySliderBackground","StyledTransparencySliderInput","input","attrs","$color","style","background","StyledTransparencySliderThumbWrapper","$position","left","StyledTransparencySliderThumbBackground","StyledTransparencySliderThumb","backgroundColor"],"sources":["../../../../src/components/transparency-slider/TransparencySlider.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport type { CSSProperties } from 'react';\nimport styled from 'styled-components';\n\nexport const StyledTransparencySlider = styled.div`\n width: 100%;\n height: 30px;\n cursor: pointer;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n\nexport const StyledTransparencySliderBackground = styled.div`\n height: 10px;\n background-color: #fff;\n background-image: linear-gradient(45deg, #a0a0a0 25%, #0000 0),\n linear-gradient(-45deg, #a0a0a0 25%, #0000 0), linear-gradient(45deg, #0000 75%, #a0a0a0 0),\n linear-gradient(-45deg, #0000 75%, #a0a0a0 0);\n background-position:\n 0 0,\n 0 4px,\n 4px -4px,\n -4px 0;\n background-repeat: repeat;\n border-radius: 100px;\n background-size: 8px 8px;\n content: '';\n position: absolute;\n width: calc(100% - 10px);\n`;\n\ntype StyledTransparencySliderInputProps = WithTheme<{ $color?: string }>;\n\nexport const StyledTransparencySliderInput = styled.input.attrs<StyledTransparencySliderInputProps>(\n ({ $color }) => ({\n style: {\n background: `linear-gradient(90deg, ${$color ?? ''}, transparent)`,\n },\n }),\n)`\n width: calc(100% - 10px);\n border-radius: 100px;\n -webkit-appearance: none;\n height: 10px;\n outline: none;\n opacity: 0.7;\n -webkit-transition: 0.2s;\n transition: opacity 0.2s;\n z-index: 4;\n\n // Slider thumb for chrome\n &::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 50%;\n }\n\n // slider thumb for firefox\n &::-moz-range-thumb {\n width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 50%;\n }\n`;\n\ntype StyledTransparencySliderThumbWrapperProps = WithTheme<{\n $position: number;\n}>;\n\nexport const StyledTransparencySliderThumbWrapper = styled.div.attrs<StyledTransparencySliderThumbWrapperProps>(\n ({ $position }) => ({\n style: {\n left: $position,\n },\n }),\n)`\n position: absolute;\n min-width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 100px;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);\n pointer-events: none;\n z-index: 3;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n padding: 0 8px;\n white-space: nowrap;\n`;\n\nexport const StyledTransparencySliderThumbBackground = styled.div`\n position: absolute;\n background-color: #fff;\n background-image: linear-gradient(45deg, #a0a0a0 25%, #0000 0),\n linear-gradient(-45deg, #a0a0a0 25%, #0000 0), linear-gradient(45deg, #0000 75%, #a0a0a0 0),\n linear-gradient(-45deg, #0000 75%, #a0a0a0 0);\n background-position:\n 0 0,\n 0 4px,\n 4px -4px,\n -4px 0;\n background-repeat: repeat;\n background-size: 8px 8px;\n height: 100%;\n width: 100%;\n`;\n\ntype StyledTransparencySliderThumbProps = WithTheme<{\n $color: CSSProperties['color'];\n}>;\n\nexport const StyledTransparencySliderThumb = styled.div.attrs<StyledTransparencySliderThumbProps>(\n ({ $color }) => ({\n style: {\n backgroundColor: $color,\n },\n }),\n)`\n height: 100%;\n width: 100%;\n position: absolute;\n`;\n"],"mappings":";;;;;;AAEA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhC,MAAMG,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAGE,yBAAM,CAACC,GAAI;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,kCAAkC,GAAAH,OAAA,CAAAG,kCAAA,GAAGF,yBAAM,CAACC,GAAI;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAIM,MAAME,6BAA6B,GAAAJ,OAAA,CAAAI,6BAAA,GAAGH,yBAAM,CAACI,KAAK,CAACC,KAAK,CAC3D,CAAC;EAAEC;AAAO,CAAC,MAAM;EACbC,KAAK,EAAE;IACHC,UAAU,EAAG,0BAAyBF,MAAM,IAAI,EAAG;EACvD;AACJ,CAAC,CACL,CAAE;AACF;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,CAAC;AAMM,MAAMG,oCAAoC,GAAAV,OAAA,CAAAU,oCAAA,GAAGT,yBAAM,CAACC,GAAG,CAACI,KAAK,CAChE,CAAC;EAAEK;AAAU,CAAC,MAAM;EAChBH,KAAK,EAAE;IACHI,IAAI,EAAED;EACV;AACJ,CAAC,CACL,CAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAME,uCAAuC,GAAAb,OAAA,CAAAa,uCAAA,GAAGZ,yBAAM,CAACC,GAAI;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAMM,MAAMY,6BAA6B,GAAAd,OAAA,CAAAc,6BAAA,GAAGb,yBAAM,CAACC,GAAG,CAACI,KAAK,CACzD,CAAC;EAAEC;AAAO,CAAC,MAAM;EACbC,KAAK,EAAE;IACHO,eAAe,EAAER;EACrB;AACJ,CAAC,CACL,CAAE;AACF;AACA;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"TransparencySlider.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledTransparencySlider","exports","styled","div","StyledTransparencySliderBackground","StyledTransparencySliderInput","input","attrs","$color","style","background","StyledTransparencySliderThumbWrapper","$position","left","StyledTransparencySliderThumbBackground","StyledTransparencySliderThumb","backgroundColor"],"sources":["../../../../src/components/transparency-slider/TransparencySlider.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport type { CSSProperties } from 'react';\nimport styled from 'styled-components';\n\nexport const StyledTransparencySlider = styled.div`\n width: 100%;\n height: 30px;\n cursor: pointer;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n\nexport const StyledTransparencySliderBackground = styled.div`\n height: 10px;\n background-color: #fff;\n background-image: linear-gradient(45deg, #a0a0a0 25%, #0000 0),\n linear-gradient(-45deg, #a0a0a0 25%, #0000 0), linear-gradient(45deg, #0000 75%, #a0a0a0 0),\n linear-gradient(-45deg, #0000 75%, #a0a0a0 0);\n background-position:\n 0 0,\n 0 4px,\n 4px -4px,\n -4px 0;\n background-repeat: repeat;\n border-radius: 100px;\n background-size: 8px 8px;\n content: '';\n position: absolute;\n width: calc(100% - 10px);\n`;\n\ntype StyledTransparencySliderInputProps = WithTheme<{ $color?: string }>;\n\nexport const StyledTransparencySliderInput = styled.input.attrs<StyledTransparencySliderInputProps>(\n ({ $color }) => ({\n style: {\n background: `linear-gradient(90deg, ${$color ?? ''}, transparent)`,\n },\n }),\n)`\n width: calc(100% - 10px);\n border-radius: 100px;\n -webkit-appearance: none;\n height: 10px;\n outline: none;\n opacity: 0.7;\n -webkit-transition: 0.2s;\n transition: opacity 0.2s;\n z-index: 4;\n\n // Slider thumb for chrome\n &::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n opacity: 0;\n width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 50%;\n }\n\n // slider thumb for firefox\n &::-moz-range-thumb {\n width: 20px;\n height: 20px;\n opacity: 0;\n cursor: pointer;\n border-radius: 50%;\n }\n`;\n\ntype StyledTransparencySliderThumbWrapperProps = WithTheme<{\n $position: number;\n}>;\n\nexport const StyledTransparencySliderThumbWrapper = styled.div.attrs<StyledTransparencySliderThumbWrapperProps>(\n ({ $position }) => ({\n style: {\n left: $position,\n },\n }),\n)`\n position: absolute;\n min-width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 100px;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);\n pointer-events: none;\n z-index: 3;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n padding: 0 8px;\n white-space: nowrap;\n`;\n\nexport const StyledTransparencySliderThumbBackground = styled.div`\n position: absolute;\n background-color: #fff;\n background-image: linear-gradient(45deg, #a0a0a0 25%, #0000 0),\n linear-gradient(-45deg, #a0a0a0 25%, #0000 0), linear-gradient(45deg, #0000 75%, #a0a0a0 0),\n linear-gradient(-45deg, #0000 75%, #a0a0a0 0);\n background-position:\n 0 0,\n 0 4px,\n 4px -4px,\n -4px 0;\n background-repeat: repeat;\n background-size: 8px 8px;\n height: 100%;\n width: 100%;\n`;\n\ntype StyledTransparencySliderThumbProps = WithTheme<{\n $color: CSSProperties['color'];\n}>;\n\nexport const StyledTransparencySliderThumb = styled.div.attrs<StyledTransparencySliderThumbProps>(\n ({ $color }) => ({\n style: {\n backgroundColor: $color,\n },\n }),\n)`\n height: 100%;\n width: 100%;\n position: absolute;\n`;\n"],"mappings":";;;;;;AAEA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhC,MAAMG,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAGE,yBAAM,CAACC,GAAI;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,kCAAkC,GAAAH,OAAA,CAAAG,kCAAA,GAAGF,yBAAM,CAACC,GAAI;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAIM,MAAME,6BAA6B,GAAAJ,OAAA,CAAAI,6BAAA,GAAGH,yBAAM,CAACI,KAAK,CAACC,KAAK,CAC3D,CAAC;EAAEC;AAAO,CAAC,MAAM;EACbC,KAAK,EAAE;IACHC,UAAU,EAAG,0BAAyBF,MAAM,IAAI,EAAG;EACvD;AACJ,CAAC,CACL,CAAE;AACF;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,CAAC;AAMM,MAAMG,oCAAoC,GAAAV,OAAA,CAAAU,oCAAA,GAAGT,yBAAM,CAACC,GAAG,CAACI,KAAK,CAChE,CAAC;EAAEK;AAAU,CAAC,MAAM;EAChBH,KAAK,EAAE;IACHI,IAAI,EAAED;EACV;AACJ,CAAC,CACL,CAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAME,uCAAuC,GAAAb,OAAA,CAAAa,uCAAA,GAAGZ,yBAAM,CAACC,GAAI;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAMM,MAAMY,6BAA6B,GAAAd,OAAA,CAAAc,6BAAA,GAAGb,yBAAM,CAACC,GAAG,CAACI,KAAK,CACzD,CAAC;EAAEC;AAAO,CAAC,MAAM;EACbC,KAAK,EAAE;IACHO,eAAe,EAAER;EACrB;AACJ,CAAC,CACL,CAAE;AACF;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -146,51 +146,72 @@ const ColorArea = () => {
146
146
  updateShouldCallOnSelect(true);
147
147
  }
148
148
  }, [updateShouldCallOnSelect, updateShouldGetCoordinates]);
149
+ const move = useCallback((xCords, yCords) => {
150
+ let newXCords = xCords;
151
+ let newYCords = yCords;
152
+ switch (true) {
153
+ case xCords > 300:
154
+ newXCords = 300;
155
+ break;
156
+ case xCords < 0:
157
+ newXCords = 0;
158
+ break;
159
+ default:
160
+ break;
161
+ }
162
+ switch (true) {
163
+ case yCords > 150:
164
+ newYCords = 150;
165
+ break;
166
+ case yCords < 0:
167
+ newYCords = 0;
168
+ break;
169
+ default:
170
+ break;
171
+ }
172
+ x.set(newXCords);
173
+ y.set(newYCords);
174
+ setColor();
175
+ }, [setColor, x, y]);
149
176
  const handleMouseMove = useCallback(event => {
150
177
  if (canDrag.current && pseudoRef.current) {
151
178
  const {
152
179
  left,
153
180
  top
154
181
  } = pseudoRef.current.getBoundingClientRect();
155
- let xCords = event.clientX - left - 10;
156
- let yCords = event.clientY - top - 10;
157
- switch (true) {
158
- case xCords > 300:
159
- xCords = 300;
160
- break;
161
- case xCords < 0:
162
- xCords = 0;
163
- break;
164
- default:
165
- break;
166
- }
167
- switch (true) {
168
- case yCords > 150:
169
- yCords = 150;
170
- break;
171
- case yCords < 0:
172
- yCords = 0;
173
- break;
174
- default:
175
- break;
176
- }
177
- x.set(xCords);
178
- y.set(yCords);
179
- setColor();
182
+ const xCords = event.clientX - left - 10;
183
+ const yCords = event.clientY - top - 10;
184
+ move(xCords, yCords);
180
185
  }
181
- }, [setColor, x, y]);
186
+ }, [move]);
187
+ const handleTouchMove = useCallback(event => {
188
+ if (canDrag.current && pseudoRef.current) {
189
+ event.preventDefault();
190
+ const {
191
+ left,
192
+ top
193
+ } = pseudoRef.current.getBoundingClientRect();
194
+ const xCords = event.changedTouches[0] ? event.changedTouches[0].clientX - left - 10 : event.pageX;
195
+ const yCords = event.changedTouches[0] ? event.changedTouches[0].clientY - top - 10 : event.pageY;
196
+ move(xCords, yCords);
197
+ }
198
+ }, [move]);
182
199
  useEffect(() => {
183
200
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
184
201
  // @ts-ignore
185
202
  window.addEventListener('mousemove', handleMouseMove);
186
203
  window.addEventListener('pointerup', handlePointerUp);
204
+ window.addEventListener('touchmove', handleTouchMove);
205
+ window.addEventListener('touchend', handlePointerUp);
187
206
  return () => {
188
207
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
189
208
  // @ts-ignore
190
209
  window.removeEventListener('mousemove', handleMouseMove);
191
210
  window.removeEventListener('pointerup', handlePointerUp);
211
+ window.removeEventListener('touchmove', handleTouchMove);
212
+ window.removeEventListener('touchend', handlePointerUp);
192
213
  };
193
- }, [handleMouseMove, handlePointerUp]);
214
+ }, [handleMouseMove, handlePointerUp, handleTouchMove]);
194
215
  return useMemo(() => /*#__PURE__*/React.createElement(StyledColorArea, null, /*#__PURE__*/React.createElement(StyledColorAreaCanvas, {
195
216
  ref: canvasRef
196
217
  }), /*#__PURE__*/React.createElement(StyledColorAreaPseudo, {
@@ -1 +1 @@
1
- {"version":3,"file":"ColorArea.js","names":["React","useCallback","useContext","useEffect","useMemo","useRef","useState","StyledColorArea","StyledColorAreaCanvas","StyledColorAreaPseudo","StyledMotionColorAreaPointer","hsvToHex","useDragControls","useMotionValue","extractRgbValues","getColorFromCoordinates","getCoordinatesFromColor","rgbToHsv","ColorPickerContext","ColorArea","selectedColor","updateSelectedColor","updateIsPresetColor","isPresetColor","shouldGetCoordinates","updateShouldGetCoordinates","updateShouldCallOnSelect","hueColor","opacity","setOpacity","scale","setScale","scaleX","scaleY","isPresetColorRef","shouldGetCoordinatesRef","canDrag","canvasRef","pseudoRef","dragControls","x","y","current","a","canvas","rect","getBoundingClientRect","width","height","setColor","xCord","get","yCord","color","coordinates","ctx","getContext","hsv","hex","h","s","v","colorGradiant","createLinearGradient","addColorStop","fillStyle","fillRect","transparentGradiant","handleStartDrag","cords","tolerance","set","handleDrag","handleClick","event","left","top","target","clientX","clientY","handlePointerUp","handleMouseMove","xCords","yCords","window","addEventListener","removeEventListener","createElement","ref","onPointerDown","onClick","drag","dragConstraints","style","dragElastic","dragMomentum","onDrag","displayName"],"sources":["../../../../../../../src/components/color-picker/color-picker-wrapper/color-picker-popup/color-area/ColorArea.tsx"],"sourcesContent":["import React, {\n MouseEvent,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport {\n StyledColorArea,\n StyledColorAreaCanvas,\n StyledColorAreaPseudo,\n StyledMotionColorAreaPointer,\n} from './ColorArea.styles';\n\nimport { hsvToHex } from '@chayns/colors';\nimport { useDragControls, useMotionValue } from 'framer-motion';\nimport type { Scale } from '../../../../../types/colorPicker';\nimport {\n extractRgbValues,\n getColorFromCoordinates,\n getCoordinatesFromColor,\n rgbToHsv,\n} from '../../../../../utils/color';\nimport { ColorPickerContext } from '../../../../ColorPickerProvider';\n\nconst ColorArea = () => {\n const {\n selectedColor,\n updateSelectedColor,\n updateIsPresetColor,\n isPresetColor,\n shouldGetCoordinates,\n updateShouldGetCoordinates,\n updateShouldCallOnSelect,\n hueColor,\n } = useContext(ColorPickerContext);\n\n const [opacity, setOpacity] = useState<number>(1);\n const [scale, setScale] = useState<Scale>({ scaleX: 0, scaleY: 0 });\n\n const isPresetColorRef = useRef(false);\n const shouldGetCoordinatesRef = useRef(false);\n const canDrag = useRef(false);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const pseudoRef = useRef<HTMLDivElement>(null);\n\n const dragControls = useDragControls();\n\n const x = useMotionValue(0);\n const y = useMotionValue(0);\n\n useEffect(() => {\n isPresetColorRef.current = isPresetColor ?? false;\n }, [isPresetColor]);\n\n useEffect(() => {\n shouldGetCoordinatesRef.current = shouldGetCoordinates ?? true;\n }, [shouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor) {\n const { a } = extractRgbValues(selectedColor);\n\n setOpacity(a);\n }\n }, [selectedColor]);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n\n if (!canvas) {\n return;\n }\n\n const rect = canvas.getBoundingClientRect();\n\n const scaleX = canvas.width / rect.width;\n const scaleY = canvas.height / rect.height;\n\n setScale({ scaleX, scaleY });\n }, []);\n\n const setColor = useCallback(() => {\n const xCord = x.get();\n const yCord = y.get();\n\n if (typeof updateSelectedColor === 'function') {\n const color = getColorFromCoordinates({\n coordinates: {\n x: xCord,\n y: yCord,\n },\n canvas: canvasRef,\n opacity,\n scale,\n });\n\n if (color === 'transparent') {\n return;\n }\n\n updateSelectedColor(color);\n }\n }, [opacity, scale, updateSelectedColor, x, y]);\n\n useEffect(() => {\n const ctx = canvasRef.current?.getContext('2d');\n\n if (!ctx) {\n return;\n }\n\n const hsv = rgbToHsv(hueColor);\n\n const hex = hsvToHex({ h: hsv?.h ?? 1, s: 1, v: 1 });\n\n const colorGradiant = ctx.createLinearGradient(0, 0, 300, 0);\n colorGradiant.addColorStop(0, '#fff');\n colorGradiant.addColorStop(1, hex ?? 'red');\n\n ctx.fillStyle = colorGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n const transparentGradiant = ctx.createLinearGradient(0, 0, 0, 150);\n\n transparentGradiant.addColorStop(0, 'transparent');\n transparentGradiant.addColorStop(1, '#000');\n\n ctx.fillStyle = transparentGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n if (isPresetColorRef.current) {\n if (typeof updateIsPresetColor === 'function') {\n updateIsPresetColor(false);\n }\n\n return;\n }\n\n setColor();\n }, [hueColor, setColor, updateIsPresetColor]);\n\n const handleStartDrag = useCallback(() => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n canDrag.current = true;\n }, [updateShouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor && shouldGetCoordinatesRef.current) {\n const cords = getCoordinatesFromColor({\n color: selectedColor,\n canvas: canvasRef,\n tolerance: 10,\n });\n\n if (cords) {\n x.set(cords.x);\n y.set(cords.y);\n }\n }\n }, [selectedColor, x, y]);\n\n const handleDrag = useCallback(() => {\n setColor();\n }, [setColor]);\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n const { left, top } = (event.target as HTMLDivElement).getBoundingClientRect();\n\n x.set(event.clientX - left - 10);\n y.set(event.clientY - top - 10);\n\n setColor();\n },\n [setColor, updateShouldGetCoordinates, x, y],\n );\n\n const handlePointerUp = useCallback(() => {\n canDrag.current = false;\n\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(true);\n }\n\n if (typeof updateShouldCallOnSelect === 'function') {\n updateShouldCallOnSelect(true);\n }\n }, [updateShouldCallOnSelect, updateShouldGetCoordinates]);\n\n const handleMouseMove = useCallback(\n (event: MouseEvent) => {\n if (canDrag.current && pseudoRef.current) {\n const { left, top } = pseudoRef.current.getBoundingClientRect();\n\n let xCords = event.clientX - left - 10;\n let yCords = event.clientY - top - 10;\n\n switch (true) {\n case xCords > 300:\n xCords = 300;\n break;\n case xCords < 0:\n xCords = 0;\n break;\n default:\n break;\n }\n\n switch (true) {\n case yCords > 150:\n yCords = 150;\n break;\n case yCords < 0:\n yCords = 0;\n break;\n default:\n break;\n }\n\n x.set(xCords);\n y.set(yCords);\n\n setColor();\n }\n },\n [setColor, x, y],\n );\n\n useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('pointerup', handlePointerUp);\n\n return () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('pointerup', handlePointerUp);\n };\n }, [handleMouseMove, handlePointerUp]);\n\n return useMemo(\n () => (\n <StyledColorArea>\n <StyledColorAreaCanvas ref={canvasRef} />\n <StyledColorAreaPseudo\n ref={pseudoRef}\n onPointerDown={handleStartDrag}\n onClick={handleClick}\n >\n <StyledMotionColorAreaPointer\n drag\n dragConstraints={pseudoRef}\n style={{ x, y }}\n dragElastic={false}\n dragMomentum={false}\n dragControls={dragControls}\n onDrag={handleDrag}\n />\n </StyledColorAreaPseudo>\n </StyledColorArea>\n ),\n [dragControls, handleClick, handleDrag, handleStartDrag, x, y],\n );\n};\n\nColorArea.displayName = 'ColorArea';\n\nexport default ColorArea;\n"],"mappings":"AAAA,OAAOA,KAAK,IAERC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SACIC,eAAe,EACfC,qBAAqB,EACrBC,qBAAqB,EACrBC,4BAA4B,QACzB,oBAAoB;AAE3B,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,eAAe,EAAEC,cAAc,QAAQ,eAAe;AAE/D,SACIC,gBAAgB,EAChBC,uBAAuB,EACvBC,uBAAuB,EACvBC,QAAQ,QACL,4BAA4B;AACnC,SAASC,kBAAkB,QAAQ,iCAAiC;AAEpE,MAAMC,SAAS,GAAGA,CAAA,KAAM;EACpB,MAAM;IACFC,aAAa;IACbC,mBAAmB;IACnBC,mBAAmB;IACnBC,aAAa;IACbC,oBAAo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ACAI,MAAM,CAACE,mBAAmB,CAAC,WAAW,EAAEL,eAAe,CAAC;MACxDG,MAAM,CAACE,mBAAmB,CAAC,WAAW,EAAEN,eAAe,CAAC;IAC5D,CAAC;EACL,CAAC,EAAE,CAACC,eAAe,EAAED,eAAe,CAAC,CAAC;EAEtC,OAAO5E,OAAO,CACV,mBACIJ,KAAA,CAAAuF,aAAA,CAAChF,eAAe,qBACZP,KAAA,CAAAuF,aAAA,CAAC/E,qBAAqB;IAACgF,GAAG,EAAEnD;EAAU,CAAE,CAAC,eACzCrC,KAAA,CAAAuF,aAAA,CAAC9E,qBAAqB;IAClB+E,GAAG,EAAElD,SAAU;IACfmD,aAAa,EAAErB,eAAgB;IAC/BsB,OAAO,EAAEjB;EAAY,gBAErBzE,KAAA,CAAAuF,aAAA,CAAC7E,4BAA4B;IACzBiF,IAAI;IACJC,eAAe,EAAEtD,SAAU;IAC3BuD,KAAK,EAAE;MAAErD,CAAC;MAAEC;IAAE,CAAE;IAChBqD,WAAW,EAAE,KAAM;IACnBC,YAAY,EAAE,KAAM;IACpBxD,YAAY,EAAEA,YAAa;IAC3ByD,MAAM,EAAExB;EAAW,CACtB,CACkB,CACV,CACpB,EACD,CAACjC,YAAY,EAAEkC,WAAW,EAAED,UAAU,EAAEJ,eAAe,EAAE5B,CAAC,EAAEC,CAAC,CACjE,CAAC;AACL,CAAC;AAEDtB,SAAS,CAAC8E,WAAW,GAAG,WAAW;AAEnC,eAAe9E,SAAS","ignoreList":[]}
1
+ {"version":3,"file":"ColorArea.js","names":["React","useCallback","useContext","useEffect","useMemo","useRef","useState","StyledColorArea","StyledColorAreaCanvas","StyledColorAreaPseudo","StyledMotionColorAreaPointer","hsvToHex","useDragControls","useMotionValue","extractRgbValues","getColorFromCoordinates","getCoordinatesFromColor","rgbToHsv","ColorPickerContext","ColorArea","selectedColor","updateSelectedColor","updateIsPresetColor","isPresetColor","shouldGetCoordinates","updateShouldGetCoordinates","updateShouldCallOnSelect","hueColor","opacity","setOpacity","scale","setScale","scaleX","scaleY","isPresetColorRef","shouldGetCoordinatesRef","canDrag","canvasRef","pseudoRef","dragControls","x","y","current","a","canvas","rect","getBoundingClientRect","width","height","setColor","xCord","get","yCord","color","coordinates","ctx","getContext","hsv","hex","h","s","v","colorGradiant","createLinearGradient","addColorStop","fillStyle","fillRect","transparentGradiant","handleStartDrag","cords","tolerance","set","handleDrag","handleClick","event","left","top","target","clientX","clientY","handlePointerUp","move","xCords","yCords","newXCords","newYCords","handleMouseMove","handleTouchMove","preventDefault","changedTouches","pageX","pageY","window","addEventListener","removeEventListener","createElement","ref","onPointerDown","onClick","drag","dragConstraints","style","dragElastic","dragMomentum","onDrag","displayName"],"sources":["../../../../../../../src/components/color-picker/color-picker-wrapper/color-picker-popup/color-area/ColorArea.tsx"],"sourcesContent":["import React, {\n MouseEvent,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport {\n StyledColorArea,\n StyledColorAreaCanvas,\n StyledColorAreaPseudo,\n StyledMotionColorAreaPointer,\n} from './ColorArea.styles';\n\nimport { hsvToHex } from '@chayns/colors';\nimport { useDragControls, useMotionValue } from 'framer-motion';\nimport type { Scale } from '../../../../../types/colorPicker';\nimport {\n extractRgbValues,\n getColorFromCoordinates,\n getCoordinatesFromColor,\n rgbToHsv,\n} from '../../../../../utils/color';\nimport { ColorPickerContext } from '../../../../ColorPickerProvider';\n\nconst ColorArea = () => {\n const {\n selectedColor,\n updateSelectedColor,\n updateIsPresetColor,\n isPresetColor,\n shouldGetCoordinates,\n updateShouldGetCoordinates,\n updateShouldCallOnSelect,\n hueColor,\n } = useContext(ColorPickerContext);\n\n const [opacity, setOpacity] = useState<number>(1);\n const [scale, setScale] = useState<Scale>({ scaleX: 0, scaleY: 0 });\n\n const isPresetColorRef = useRef(false);\n const shouldGetCoordinatesRef = useRef(false);\n const canDrag = useRef(false);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const pseudoRef = useRef<HTMLDivElement>(null);\n\n const dragControls = useDragControls();\n\n const x = useMotionValue(0);\n const y = useMotionValue(0);\n\n useEffect(() => {\n isPresetColorRef.current = isPresetColor ?? false;\n }, [isPresetColor]);\n\n useEffect(() => {\n shouldGetCoordinatesRef.current = shouldGetCoordinates ?? true;\n }, [shouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor) {\n const { a } = extractRgbValues(selectedColor);\n\n setOpacity(a);\n }\n }, [selectedColor]);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n\n if (!canvas) {\n return;\n }\n\n const rect = canvas.getBoundingClientRect();\n\n const scaleX = canvas.width / rect.width;\n const scaleY = canvas.height / rect.height;\n\n setScale({ scaleX, scaleY });\n }, []);\n\n const setColor = useCallback(() => {\n const xCord = x.get();\n const yCord = y.get();\n\n if (typeof updateSelectedColor === 'function') {\n const color = getColorFromCoordinates({\n coordinates: {\n x: xCord,\n y: yCord,\n },\n canvas: canvasRef,\n opacity,\n scale,\n });\n\n if (color === 'transparent') {\n return;\n }\n\n updateSelectedColor(color);\n }\n }, [opacity, scale, updateSelectedColor, x, y]);\n\n useEffect(() => {\n const ctx = canvasRef.current?.getContext('2d');\n\n if (!ctx) {\n return;\n }\n\n const hsv = rgbToHsv(hueColor);\n\n const hex = hsvToHex({ h: hsv?.h ?? 1, s: 1, v: 1 });\n\n const colorGradiant = ctx.createLinearGradient(0, 0, 300, 0);\n colorGradiant.addColorStop(0, '#fff');\n colorGradiant.addColorStop(1, hex ?? 'red');\n\n ctx.fillStyle = colorGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n const transparentGradiant = ctx.createLinearGradient(0, 0, 0, 150);\n\n transparentGradiant.addColorStop(0, 'transparent');\n transparentGradiant.addColorStop(1, '#000');\n\n ctx.fillStyle = transparentGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n if (isPresetColorRef.current) {\n if (typeof updateIsPresetColor === 'function') {\n updateIsPresetColor(false);\n }\n\n return;\n }\n\n setColor();\n }, [hueColor, setColor, updateIsPresetColor]);\n\n const handleStartDrag = useCallback(() => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n canDrag.current = true;\n }, [updateShouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor && shouldGetCoordinatesRef.current) {\n const cords = getCoordinatesFromColor({\n color: selectedColor,\n canvas: canvasRef,\n tolerance: 10,\n });\n\n if (cords) {\n x.set(cords.x);\n y.set(cords.y);\n }\n }\n }, [selectedColor, x, y]);\n\n const handleDrag = useCallback(() => {\n setColor();\n }, [setColor]);\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n const { left, top } = (event.target as HTMLDivElement).getBoundingClientRect();\n\n x.set(event.clientX - left - 10);\n y.set(event.clientY - top - 10);\n\n setColor();\n },\n [setColor, updateShouldGetCoordinates, x, y],\n );\n\n const handlePointerUp = useCallback(() => {\n canDrag.current = false;\n\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(true);\n }\n\n if (typeof updateShouldCallOnSelect === 'function') {\n updateShouldCallOnSelect(true);\n }\n }, [updateShouldCallOnSelect, updateShouldGetCoordinates]);\n\n const move = useCallback(\n (xCords: number, yCords: number) => {\n let newXCords = xCords;\n let newYCords = yCords;\n\n switch (true) {\n case xCords > 300:\n newXCords = 300;\n break;\n case xCords < 0:\n newXCords = 0;\n break;\n default:\n break;\n }\n\n switch (true) {\n case yCords > 150:\n newYCords = 150;\n break;\n case yCords < 0:\n newYCords = 0;\n break;\n default:\n break;\n }\n\n x.set(newXCords);\n y.set(newYCords);\n\n setColor();\n },\n [setColor, x, y],\n );\n\n const handleMouseMove = useCallback(\n (event: MouseEvent) => {\n if (canDrag.current && pseudoRef.current) {\n const { left, top } = pseudoRef.current.getBoundingClientRect();\n\n const xCords = event.clientX - left - 10;\n const yCords = event.clientY - top - 10;\n\n move(xCords, yCords);\n }\n },\n [move],\n );\n\n const handleTouchMove = useCallback(\n (event: TouchEvent) => {\n if (canDrag.current && pseudoRef.current) {\n event.preventDefault();\n\n const { left, top } = pseudoRef.current.getBoundingClientRect();\n\n const xCords = event.changedTouches[0]\n ? event.changedTouches[0].clientX - left - 10\n : (event as unknown as { pageX: number }).pageX;\n const yCords = event.changedTouches[0]\n ? event.changedTouches[0].clientY - top - 10\n : (event as unknown as { pageY: number }).pageY;\n\n move(xCords, yCords);\n }\n },\n [move],\n );\n\n useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('pointerup', handlePointerUp);\n window.addEventListener('touchmove', handleTouchMove);\n window.addEventListener('touchend', handlePointerUp);\n\n return () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('pointerup', handlePointerUp);\n window.removeEventListener('touchmove', handleTouchMove);\n window.removeEventListener('touchend', handlePointerUp);\n };\n }, [handleMouseMove, handlePointerUp, handleTouchMove]);\n\n return useMemo(\n () => (\n <StyledColorArea>\n <StyledColorAreaCanvas ref={canvasRef} />\n <StyledColorAreaPseudo\n ref={pseudoRef}\n onPointerDown={handleStartDrag}\n onClick={handleClick}\n >\n <StyledMotionColorAreaPointer\n drag\n dragConstraints={pseudoRef}\n style={{ x, y }}\n dragElastic={false}\n dragMomentum={false}\n dragControls={dragControls}\n onDrag={handleDrag}\n />\n </StyledColorAreaPseudo>\n </StyledColorArea>\n ),\n [dragControls, handleClick, handleDrag, handleStartDrag, x, y],\n );\n};\n\nColorArea.displayName = 'ColorArea';\n\nexport default ColorArea;\n"],"mappings":"AAAA,OAAOA,KAAK,IAERC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SACIC,eAAe,EACfC,qBAAqB,EACrBC,qBAAqB,EACrBC,4BAA4B,QACzB,oB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none;
41
41
  width: 20px;
42
42
  height: 20px;
43
+ opacity: 0;
43
44
  cursor: pointer;
44
45
  border-radius: 50%;
45
46
  }
@@ -47,6 +48,7 @@ export const StyledHueSliderInput = styled.input`
47
48
  // slider thumb for firefox
48
49
  &::-moz-range-thumb {
49
50
  width: 20px;
51
+ opacity: 0;
50
52
  height: 20px;
51
53
  cursor: pointer;
52
54
  border-radius: 50%;
@@ -1 +1 @@
1
- {"version":3,"file":"HueSlider.styles.js","names":["styled","StyledHueSlider","div","StyledHueSliderInput","input","StyledHueSliderThumb","attrs","_ref","$position","$color","style","left","backgroundColor"],"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 height: 30px;\n cursor: pointer;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n\ntype StyledHueSliderInputProps = WithTheme<{\n $color: CSSProperties['color'];\n}>;\n\nexport const StyledHueSliderInput = styled.input<StyledHueSliderInputProps>`\n width: calc(100% - 10px);\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 cursor: pointer;\n border-radius: 50%;\n }\n\n // slider thumb for firefox\n &::-moz-range-thumb {\n width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 50%;\n }\n`;\n\ntype StyledHueSliderThumbProps = WithTheme<{ $position: number; $color: CSSProperties['color'] }>;\n\nexport const StyledHueSliderThumb = styled.div.attrs<StyledHueSliderThumbProps>(\n ({ $position, $color }) => ({\n style: {\n left: `${$position}px`,\n backgroundColor: $color,\n },\n }),\n)`\n min-width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 100px;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);\n pointer-events: none;\n z-index: 3;\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0 8px;\n white-space: nowrap;\n`;\n"],"mappings":"AAEA,OAAOA,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,eAAe,GAAGD,MAAM,CAACE,GAAI;AAC1C;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAID,OAAO,MAAMC,oBAAoB,GAAGL,MAAM,CAACE,GAAG,CAACI,KAAK,CAChDC,IAAA;EAAA,IAAC;IAAEC,SAAS;IAAEC;EAAO,CAAC,GAAAF,IAAA;EAAA,OAAM;IACxBG,KAAK,EAAE;MACHC,IAAI,EAAG,GAAEH,SAAU,IAAG;MACtBI,eAAe,EAAEH;IACrB;EACJ,CAAC;AAAA,CACL,CAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"HueSlider.styles.js","names":["styled","StyledHueSlider","div","StyledHueSliderInput","input","StyledHueSliderThumb","attrs","_ref","$position","$color","style","left","backgroundColor"],"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 height: 30px;\n cursor: pointer;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n\ntype StyledHueSliderInputProps = WithTheme<{\n $color: CSSProperties['color'];\n}>;\n\nexport const StyledHueSliderInput = styled.input<StyledHueSliderInputProps>`\n width: calc(100% - 10px);\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 opacity: 0;\n cursor: pointer;\n border-radius: 50%;\n }\n\n // slider thumb for firefox\n &::-moz-range-thumb {\n width: 20px;\n opacity: 0;\n height: 20px;\n cursor: pointer;\n border-radius: 50%;\n }\n`;\n\ntype StyledHueSliderThumbProps = WithTheme<{ $position: number; $color: CSSProperties['color'] }>;\n\nexport const StyledHueSliderThumb = styled.div.attrs<StyledHueSliderThumbProps>(\n ({ $position, $color }) => ({\n style: {\n left: `${$position}px`,\n backgroundColor: $color,\n },\n }),\n)`\n min-width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 100px;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);\n pointer-events: none;\n z-index: 3;\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0 8px;\n white-space: nowrap;\n`;\n"],"mappings":"AAEA,OAAOA,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,eAAe,GAAGD,MAAM,CAACE,GAAI;AAC1C;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAID,OAAO,MAAMC,oBAAoB,GAAGL,MAAM,CAACE,GAAG,CAACI,KAAK,CAChDC,IAAA;EAAA,IAAC;IAAEC,SAAS;IAAEC;EAAO,CAAC,GAAAF,IAAA;EAAA,OAAM;IACxBG,KAAK,EAAE;MACHC,IAAI,EAAG,GAAEH,SAAU,IAAG;MACtBI,eAAe,EAAEH;IACrB;EACJ,CAAC;AAAA,CACL,CAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -50,6 +50,7 @@ export const StyledTransparencySliderInput = styled.input.attrs(_ref => {
50
50
  &::-webkit-slider-thumb {
51
51
  -webkit-appearance: none;
52
52
  appearance: none;
53
+ opacity: 0;
53
54
  width: 20px;
54
55
  height: 20px;
55
56
  cursor: pointer;
@@ -60,6 +61,7 @@ export const StyledTransparencySliderInput = styled.input.attrs(_ref => {
60
61
  &::-moz-range-thumb {
61
62
  width: 20px;
62
63
  height: 20px;
64
+ opacity: 0;
63
65
  cursor: pointer;
64
66
  border-radius: 50%;
65
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TransparencySlider.styles.js","names":["styled","StyledTransparencySlider","div","StyledTransparencySliderBackground","StyledTransparencySliderInput","input","attrs","_ref","$color","style","background","StyledTransparencySliderThumbWrapper","_ref2","$position","left","StyledTransparencySliderThumbBackground","StyledTransparencySliderThumb","_ref3","backgroundColor"],"sources":["../../../../src/components/transparency-slider/TransparencySlider.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport type { CSSProperties } from 'react';\nimport styled from 'styled-components';\n\nexport const StyledTransparencySlider = styled.div`\n width: 100%;\n height: 30px;\n cursor: pointer;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n\nexport const StyledTransparencySliderBackground = styled.div`\n height: 10px;\n background-color: #fff;\n background-image: linear-gradient(45deg, #a0a0a0 25%, #0000 0),\n linear-gradient(-45deg, #a0a0a0 25%, #0000 0), linear-gradient(45deg, #0000 75%, #a0a0a0 0),\n linear-gradient(-45deg, #0000 75%, #a0a0a0 0);\n background-position:\n 0 0,\n 0 4px,\n 4px -4px,\n -4px 0;\n background-repeat: repeat;\n border-radius: 100px;\n background-size: 8px 8px;\n content: '';\n position: absolute;\n width: calc(100% - 10px);\n`;\n\ntype StyledTransparencySliderInputProps = WithTheme<{ $color?: string }>;\n\nexport const StyledTransparencySliderInput = styled.input.attrs<StyledTransparencySliderInputProps>(\n ({ $color }) => ({\n style: {\n background: `linear-gradient(90deg, ${$color ?? ''}, transparent)`,\n },\n }),\n)`\n width: calc(100% - 10px);\n border-radius: 100px;\n -webkit-appearance: none;\n height: 10px;\n outline: none;\n opacity: 0.7;\n -webkit-transition: 0.2s;\n transition: opacity 0.2s;\n z-index: 4;\n\n // Slider thumb for chrome\n &::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 50%;\n }\n\n // slider thumb for firefox\n &::-moz-range-thumb {\n width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 50%;\n }\n`;\n\ntype StyledTransparencySliderThumbWrapperProps = WithTheme<{\n $position: number;\n}>;\n\nexport const StyledTransparencySliderThumbWrapper = styled.div.attrs<StyledTransparencySliderThumbWrapperProps>(\n ({ $position }) => ({\n style: {\n left: $position,\n },\n }),\n)`\n position: absolute;\n min-width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 100px;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);\n pointer-events: none;\n z-index: 3;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n padding: 0 8px;\n white-space: nowrap;\n`;\n\nexport const StyledTransparencySliderThumbBackground = styled.div`\n position: absolute;\n background-color: #fff;\n background-image: linear-gradient(45deg, #a0a0a0 25%, #0000 0),\n linear-gradient(-45deg, #a0a0a0 25%, #0000 0), linear-gradient(45deg, #0000 75%, #a0a0a0 0),\n linear-gradient(-45deg, #0000 75%, #a0a0a0 0);\n background-position:\n 0 0,\n 0 4px,\n 4px -4px,\n -4px 0;\n background-repeat: repeat;\n background-size: 8px 8px;\n height: 100%;\n width: 100%;\n`;\n\ntype StyledTransparencySliderThumbProps = WithTheme<{\n $color: CSSProperties['color'];\n}>;\n\nexport const StyledTransparencySliderThumb = styled.div.attrs<StyledTransparencySliderThumbProps>(\n ({ $color }) => ({\n style: {\n backgroundColor: $color,\n },\n }),\n)`\n height: 100%;\n width: 100%;\n position: absolute;\n`;\n"],"mappings":"AAEA,OAAOA,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,wBAAwB,GAAGD,MAAM,CAACE,GAAI;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,kCAAkC,GAAGH,MAAM,CAACE,GAAI;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAID,OAAO,MAAME,6BAA6B,GAAGJ,MAAM,CAACK,KAAK,CAACC,KAAK,CAC3DC,IAAA;EAAA,IAAC;IAAEC;EAAO,CAAC,GAAAD,IAAA;EAAA,OAAM;IACbE,KAAK,EAAE;MACHC,UAAU,EAAG,0BAAyBF,MAAM,IAAI,EAAG;IACvD;EACJ,CAAC;AAAA,CACL,CAAE;AACF;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,CAAC;AAMD,OAAO,MAAMG,oCAAoC,GAAGX,MAAM,CAACE,GAAG,CAACI,KAAK,CAChEM,KAAA;EAAA,IAAC;IAAEC;EAAU,CAAC,GAAAD,KAAA;EAAA,OAAM;IAChBH,KAAK,EAAE;MACHK,IAAI,EAAED;IACV;EACJ,CAAC;AAAA,CACL,CAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAME,uCAAuC,GAAGf,MAAM,CAACE,GAAI;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAMD,OAAO,MAAMc,6BAA6B,GAAGhB,MAAM,CAACE,GAAG,CAACI,KAAK,CACzDW,KAAA;EAAA,IAAC;IAAET;EAAO,CAAC,GAAAS,KAAA;EAAA,OAAM;IACbR,KAAK,EAAE;MACHS,eAAe,EAAEV;IACrB;EACJ,CAAC;AAAA,CACL,CAAE;AACF;AACA;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"TransparencySlider.styles.js","names":["styled","StyledTransparencySlider","div","StyledTransparencySliderBackground","StyledTransparencySliderInput","input","attrs","_ref","$color","style","background","StyledTransparencySliderThumbWrapper","_ref2","$position","left","StyledTransparencySliderThumbBackground","StyledTransparencySliderThumb","_ref3","backgroundColor"],"sources":["../../../../src/components/transparency-slider/TransparencySlider.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport type { CSSProperties } from 'react';\nimport styled from 'styled-components';\n\nexport const StyledTransparencySlider = styled.div`\n width: 100%;\n height: 30px;\n cursor: pointer;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n\nexport const StyledTransparencySliderBackground = styled.div`\n height: 10px;\n background-color: #fff;\n background-image: linear-gradient(45deg, #a0a0a0 25%, #0000 0),\n linear-gradient(-45deg, #a0a0a0 25%, #0000 0), linear-gradient(45deg, #0000 75%, #a0a0a0 0),\n linear-gradient(-45deg, #0000 75%, #a0a0a0 0);\n background-position:\n 0 0,\n 0 4px,\n 4px -4px,\n -4px 0;\n background-repeat: repeat;\n border-radius: 100px;\n background-size: 8px 8px;\n content: '';\n position: absolute;\n width: calc(100% - 10px);\n`;\n\ntype StyledTransparencySliderInputProps = WithTheme<{ $color?: string }>;\n\nexport const StyledTransparencySliderInput = styled.input.attrs<StyledTransparencySliderInputProps>(\n ({ $color }) => ({\n style: {\n background: `linear-gradient(90deg, ${$color ?? ''}, transparent)`,\n },\n }),\n)`\n width: calc(100% - 10px);\n border-radius: 100px;\n -webkit-appearance: none;\n height: 10px;\n outline: none;\n opacity: 0.7;\n -webkit-transition: 0.2s;\n transition: opacity 0.2s;\n z-index: 4;\n\n // Slider thumb for chrome\n &::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n opacity: 0;\n width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 50%;\n }\n\n // slider thumb for firefox\n &::-moz-range-thumb {\n width: 20px;\n height: 20px;\n opacity: 0;\n cursor: pointer;\n border-radius: 50%;\n }\n`;\n\ntype StyledTransparencySliderThumbWrapperProps = WithTheme<{\n $position: number;\n}>;\n\nexport const StyledTransparencySliderThumbWrapper = styled.div.attrs<StyledTransparencySliderThumbWrapperProps>(\n ({ $position }) => ({\n style: {\n left: $position,\n },\n }),\n)`\n position: absolute;\n min-width: 20px;\n height: 20px;\n cursor: pointer;\n border-radius: 100px;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);\n pointer-events: none;\n z-index: 3;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n padding: 0 8px;\n white-space: nowrap;\n`;\n\nexport const StyledTransparencySliderThumbBackground = styled.div`\n position: absolute;\n background-color: #fff;\n background-image: linear-gradient(45deg, #a0a0a0 25%, #0000 0),\n linear-gradient(-45deg, #a0a0a0 25%, #0000 0), linear-gradient(45deg, #0000 75%, #a0a0a0 0),\n linear-gradient(-45deg, #0000 75%, #a0a0a0 0);\n background-position:\n 0 0,\n 0 4px,\n 4px -4px,\n -4px 0;\n background-repeat: repeat;\n background-size: 8px 8px;\n height: 100%;\n width: 100%;\n`;\n\ntype StyledTransparencySliderThumbProps = WithTheme<{\n $color: CSSProperties['color'];\n}>;\n\nexport const StyledTransparencySliderThumb = styled.div.attrs<StyledTransparencySliderThumbProps>(\n ({ $color }) => ({\n style: {\n backgroundColor: $color,\n },\n }),\n)`\n height: 100%;\n width: 100%;\n position: absolute;\n`;\n"],"mappings":"AAEA,OAAOA,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,wBAAwB,GAAGD,MAAM,CAACE,GAAI;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,kCAAkC,GAAGH,MAAM,CAACE,GAAI;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAID,OAAO,MAAME,6BAA6B,GAAGJ,MAAM,CAACK,KAAK,CAACC,KAAK,CAC3DC,IAAA;EAAA,IAAC;IAAEC;EAAO,CAAC,GAAAD,IAAA;EAAA,OAAM;IACbE,KAAK,EAAE;MACHC,UAAU,EAAG,0BAAyBF,MAAM,IAAI,EAAG;IACvD;EACJ,CAAC;AAAA,CACL,CAAE;AACF;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,CAAC;AAMD,OAAO,MAAMG,oCAAoC,GAAGX,MAAM,CAACE,GAAG,CAACI,KAAK,CAChEM,KAAA;EAAA,IAAC;IAAEC;EAAU,CAAC,GAAAD,KAAA;EAAA,OAAM;IAChBH,KAAK,EAAE;MACHK,IAAI,EAAED;IACV;EACJ,CAAC;AAAA,CACL,CAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAME,uCAAuC,GAAGf,MAAM,CAACE,GAAI;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAMD,OAAO,MAAMc,6BAA6B,GAAGhB,MAAM,CAACE,GAAG,CAACI,KAAK,CACzDW,KAAA;EAAA,IAAC;IAAET;EAAO,CAAC,GAAAS,KAAA;EAAA,OAAM;IACbR,KAAK,EAAE;MACHS,eAAe,EAAEV;IACrB;EACJ,CAAC;AAAA,CACL,CAAE;AACF;AACA;AACA;AACA,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-components/color-picker",
3
- "version": "5.0.0-beta.588",
3
+ "version": "5.0.0-beta.589",
4
4
  "description": "A set of beautiful React components for developing your own applications with chayns.",
5
5
  "sideEffects": false,
6
6
  "browserslist": [
@@ -67,7 +67,7 @@
67
67
  "typescript": "^5.4.5"
68
68
  },
69
69
  "dependencies": {
70
- "@chayns-components/core": "^5.0.0-beta.588",
70
+ "@chayns-components/core": "^5.0.0-beta.589",
71
71
  "@chayns/colors": "^2.0.0"
72
72
  },
73
73
  "peerDependencies": {
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "b9221aca396a2b31d289b677d5cb21b67938df02"
83
+ "gitHead": "27622e0a3cdfa133c9d2eba12153d76e87d0eb90"
84
84
  }