@chayns-components/color-picker 5.0.0-beta.1003 → 5.0.0-beta.1005
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/cjs/components/color-picker-popup/color-area/ColorArea.js +4 -4
- package/lib/cjs/components/color-picker-popup/color-area/ColorArea.js.map +1 -1
- package/lib/cjs/components/color-picker-popup/color-area/ColorArea.styles.js +2 -2
- package/lib/cjs/components/color-picker-popup/color-area/ColorArea.styles.js.map +1 -1
- package/lib/esm/components/color-picker-popup/color-area/ColorArea.js +1 -1
- package/lib/esm/components/color-picker-popup/color-area/ColorArea.js.map +1 -1
- package/lib/esm/components/color-picker-popup/color-area/ColorArea.styles.js +1 -1
- package/lib/esm/components/color-picker-popup/color-area/ColorArea.styles.js.map +1 -1
- package/lib/types/components/color-picker-popup/color-area/ColorArea.styles.d.ts +2 -263
- package/package.json +4 -4
|
@@ -8,7 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _ColorArea = require("./ColorArea.styles");
|
|
9
9
|
var _colors = require("@chayns/colors");
|
|
10
10
|
var _chaynsApi = require("chayns-api");
|
|
11
|
-
var
|
|
11
|
+
var _react2 = require("motion/react");
|
|
12
12
|
var _color = require("../../../utils/color");
|
|
13
13
|
var _ColorPickerProvider = require("../../ColorPickerProvider");
|
|
14
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -35,9 +35,9 @@ const ColorArea = () => {
|
|
|
35
35
|
const canDrag = (0, _react.useRef)(false);
|
|
36
36
|
const canvasRef = (0, _react.useRef)(null);
|
|
37
37
|
const pseudoRef = (0, _react.useRef)(null);
|
|
38
|
-
const dragControls = (0,
|
|
39
|
-
const x = (0,
|
|
40
|
-
const y = (0,
|
|
38
|
+
const dragControls = (0, _react2.useDragControls)();
|
|
39
|
+
const x = (0, _react2.useMotionValue)(0);
|
|
40
|
+
const y = (0, _react2.useMotionValue)(0);
|
|
41
41
|
(0, _react.useEffect)(() => {
|
|
42
42
|
isPresetColorRef.current = isPresetColor ?? false;
|
|
43
43
|
}, [isPresetColor]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorArea.js","names":["_react","_interopRequireWildcard","require","_ColorArea","_colors","_chaynsApi","_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","canGetColorFromArea","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","cords","getCoordinatesFromColor","tolerance","handleDrag","handleClick","event","left","top","target","clientX","clientY","handlePointerUp","setRefreshScrollEnabled","move","xCords","yCords","newXCords","newYCords","handleMouseMove","handleTouchMove","preventDefault","changedTouches","pageX","pageY","handleStartDrag","window","addEventListener","endTouching","removeEventListener","useMemo","createElement","StyledColorArea","StyledColorAreaCanvas","ref","StyledColorAreaPseudo","onPointerDown","onClick","StyledMotionColorAreaPointer","drag","dragConstraints","style","dragElastic","dragMomentum","onDrag","displayName","_default","exports"],"sources":["../../../../../src/components/color-picker-popup/color-area/ColorArea.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n StyledColorArea,\n StyledColorAreaCanvas,\n StyledColorAreaPseudo,\n StyledMotionColorAreaPointer,\n} from './ColorArea.styles';\n\nimport { hsvToHex } from '@chayns/colors';\nimport { setRefreshScrollEnabled } from 'chayns-api';\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 canGetColorFromArea,\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 if (canGetColorFromArea) {\n setColor();\n }\n }, [canGetColorFromArea, hueColor, setColor, updateIsPresetColor]);\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: React.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 void setRefreshScrollEnabled(true);\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 void setRefreshScrollEnabled(false);\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 const handleStartDrag = useCallback(() => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n canDrag.current = true;\n\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('touchmove', handleTouchMove);\n\n const endTouching = () => {\n handlePointerUp();\n\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('touchmove', handleTouchMove);\n window.removeEventListener('pointerup', endTouching);\n window.removeEventListener('touchend', endTouching);\n };\n\n window.addEventListener('pointerup', endTouching);\n window.addEventListener('touchend', endTouching);\n }, [handleMouseMove, handlePointerUp, handleTouchMove, updateShouldGetCoordinates]);\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;AACA,IAAAC,UAAA,GAAAD,OAAA;AAOA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AAMA,IAAAM,oBAAA,GAAAN,OAAA;AAA+D,SAAAO,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,SAAAT,wBAAAS,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,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAA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C,CAAC;EAEnF,OAAO,IAAAmF,cAAO,EACV,mBACIvH,MAAA,CAAAe,OAAA,CAAAyG,aAAA,CAACrH,UAAA,CAAAsH,eAAe,qBACZzH,MAAA,CAAAe,OAAA,CAAAyG,aAAA,CAACrH,UAAA,CAAAuH,qBAAqB;IAACC,GAAG,EAAEvE;EAAU,CAAE,CAAC,eACzCpD,MAAA,CAAAe,OAAA,CAAAyG,aAAA,CAACrH,UAAA,CAAAyH,qBAAqB;IAClBD,GAAG,EAAEtE,SAAU;IACfwE,aAAa,EAAEX,eAAgB;IAC/BY,OAAO,EAAEhC;EAAY,gBAErB9F,MAAA,CAAAe,OAAA,CAAAyG,aAAA,CAACrH,UAAA,CAAA4H,4BAA4B;IACzBC,IAAI;IACJC,eAAe,EAAE5E,SAAU;IAC3B6E,KAAK,EAAE;MAAE1E,CAAC;MAAEE;IAAE,CAAE;IAChByE,WAAW,EAAE,KAAM;IACnBC,YAAY,EAAE,KAAM;IACpB9E,YAAY,EAAEA,YAAa;IAC3B+E,MAAM,EAAExC;EAAW,CACtB,CACkB,CACV,CACpB,EACD,CAACvC,YAAY,EAAEwC,WAAW,EAAED,UAAU,EAAEqB,eAAe,EAAE1D,CAAC,EAAEE,CAAC,CACjE,CAAC;AACL,CAAC;AAED7B,SAAS,CAACyG,WAAW,GAAG,WAAW;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAzH,OAAA,GAErBc,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ColorArea.js","names":["_react","_interopRequireWildcard","require","_ColorArea","_colors","_chaynsApi","_react2","_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","canGetColorFromArea","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","cords","getCoordinatesFromColor","tolerance","handleDrag","handleClick","event","left","top","target","clientX","clientY","handlePointerUp","setRefreshScrollEnabled","move","xCords","yCords","newXCords","newYCords","handleMouseMove","handleTouchMove","preventDefault","changedTouches","pageX","pageY","handleStartDrag","window","addEventListener","endTouching","removeEventListener","useMemo","createElement","StyledColorArea","StyledColorAreaCanvas","ref","StyledColorAreaPseudo","onPointerDown","onClick","StyledMotionColorAreaPointer","drag","dragConstraints","style","dragElastic","dragMomentum","onDrag","displayName","_default","exports"],"sources":["../../../../../src/components/color-picker-popup/color-area/ColorArea.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n StyledColorArea,\n StyledColorAreaCanvas,\n StyledColorAreaPseudo,\n StyledMotionColorAreaPointer,\n} from './ColorArea.styles';\n\nimport { hsvToHex } from '@chayns/colors';\nimport { setRefreshScrollEnabled } from 'chayns-api';\nimport { useDragControls, useMotionValue } from 'motion/react';\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 canGetColorFromArea,\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 if (canGetColorFromArea) {\n setColor();\n }\n }, [canGetColorFromArea, hueColor, setColor, updateIsPresetColor]);\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: React.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 void setRefreshScrollEnabled(true);\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 void setRefreshScrollEnabled(false);\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 const handleStartDrag = useCallback(() => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n canDrag.current = true;\n\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('touchmove', handleTouchMove);\n\n const endTouching = () => {\n handlePointerUp();\n\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('touchmove', handleTouchMove);\n window.removeEventListener('pointerup', endTouching);\n window.removeEventListener('touchend', endTouching);\n };\n\n window.addEventListener('pointerup', endTouching);\n window.addEventListener('touchend', endTouching);\n }, [handleMouseMove, handlePointerUp, handleTouchMove, updateShouldGetCoordinates]);\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,M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;MAAE1E,CAAC;MAAEE;IAAE,CAAE;IAChByE,WAAW,EAAE,KAAM;IACnBC,YAAY,EAAE,KAAM;IACpB9E,YAAY,EAAEA,YAAa;IAC3B+E,MAAM,EAAExC;EAAW,CACtB,CACkB,CACV,CACpB,EACD,CAACvC,YAAY,EAAEwC,WAAW,EAAED,UAAU,EAAEqB,eAAe,EAAE1D,CAAC,EAAEE,CAAC,CACjE,CAAC;AACL,CAAC;AAED7B,SAAS,CAACyG,WAAW,GAAG,WAAW;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAzH,OAAA,GAErBc,SAAS","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.StyledMotionColorAreaPointer = exports.StyledColorAreaPseudo = exports.StyledColorAreaCanvas = exports.StyledColorArea = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _react = require("motion/react");
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
const StyledColorArea = exports.StyledColorArea = _styledComponents.default.div`
|
|
@@ -28,7 +28,7 @@ const StyledColorAreaPseudo = exports.StyledColorAreaPseudo = _styledComponents.
|
|
|
28
28
|
height: 170px;
|
|
29
29
|
width: 320px;
|
|
30
30
|
`;
|
|
31
|
-
const StyledMotionColorAreaPointer = exports.StyledMotionColorAreaPointer = (0, _styledComponents.default)(
|
|
31
|
+
const StyledMotionColorAreaPointer = exports.StyledMotionColorAreaPointer = (0, _styledComponents.default)(_react.motion.div)`
|
|
32
32
|
position: absolute;
|
|
33
33
|
border-radius: 100%;
|
|
34
34
|
border: 2px solid white;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorArea.styles.js","names":["
|
|
1
|
+
{"version":3,"file":"ColorArea.styles.js","names":["_react","require","_styledComponents","_interopRequireDefault","e","__esModule","default","StyledColorArea","exports","styled","div","StyledColorAreaCanvas","canvas","StyledColorAreaPseudo","StyledMotionColorAreaPointer","motion"],"sources":["../../../../../src/components/color-picker-popup/color-area/ColorArea.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled from 'styled-components';\n\nexport const StyledColorArea = styled.div`\n height: 150px;\n width: 300px;\n position: relative;\n user-select: none;\n overflow: hidden;\n cursor: crosshair;\n`;\n\nexport const StyledColorAreaCanvas = styled.canvas`\n user-select: none;\n`;\n\nexport const StyledColorAreaPseudo = styled.div`\n position: absolute;\n top: -10px;\n left: -10px;\n touch-action: none;\n user-select: none;\n\n height: 170px;\n width: 320px;\n`;\n\nexport const StyledMotionColorAreaPointer = styled(motion.div)`\n position: absolute;\n border-radius: 100%;\n border: 2px solid white;\n width: 20px;\n height: 20px;\n box-shadow:\n 0 0 5px 0 rgba(0, 0, 0, 0.5),\n 0 0 3px 0 rgba(0, 0, 0, 0.5) inset;\n pointer-events: none;\n user-select: none;\n top: 0;\n left: 0;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAuC,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhC,MAAMG,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAGE,yBAAM,CAACC,GAAG;AACzC;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,qBAAqB,GAAAH,OAAA,CAAAG,qBAAA,GAAGF,yBAAM,CAACG,MAAM;AAClD;AACA,CAAC;AAEM,MAAMC,qBAAqB,GAAAL,OAAA,CAAAK,qBAAA,GAAGJ,yBAAM,CAACC,GAAG;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMI,4BAA4B,GAAAN,OAAA,CAAAM,4BAAA,GAAG,IAAAL,yBAAM,EAACM,aAAM,CAACL,GAAG,CAAC;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@ import React, { useCallback, useContext, useEffect, useMemo, useRef, useState }
|
|
|
2
2
|
import { StyledColorArea, StyledColorAreaCanvas, StyledColorAreaPseudo, StyledMotionColorAreaPointer } from './ColorArea.styles';
|
|
3
3
|
import { hsvToHex } from '@chayns/colors';
|
|
4
4
|
import { setRefreshScrollEnabled } from 'chayns-api';
|
|
5
|
-
import { useDragControls, useMotionValue } from '
|
|
5
|
+
import { useDragControls, useMotionValue } from 'motion/react';
|
|
6
6
|
import { extractRgbValues, getColorFromCoordinates, getCoordinatesFromColor, rgbToHsv } from '../../../utils/color';
|
|
7
7
|
import { ColorPickerContext } from '../../ColorPickerProvider';
|
|
8
8
|
const ColorArea = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorArea.js","names":["React","useCallback","useContext","useEffect","useMemo","useRef","useState","StyledColorArea","StyledColorAreaCanvas","StyledColorAreaPseudo","StyledMotionColorAreaPointer","hsvToHex","setRefreshScrollEnabled","useDragControls","useMotionValue","extractRgbValues","getColorFromCoordinates","getCoordinatesFromColor","rgbToHsv","ColorPickerContext","ColorArea","selectedColor","updateSelectedColor","updateIsPresetColor","isPresetColor","shouldGetCoordinates","canGetColorFromArea","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","cords","tolerance","set","handleDrag","handleClick","event","left","top","target","clientX","clientY","handlePointerUp","move","xCords","yCords","newXCords","newYCords","handleMouseMove","handleTouchMove","preventDefault","changedTouches","pageX","pageY","handleStartDrag","window","addEventListener","endTouching","removeEventListener","createElement","ref","onPointerDown","onClick","drag","dragConstraints","style","dragElastic","dragMomentum","onDrag","displayName"],"sources":["../../../../../src/components/color-picker-popup/color-area/ColorArea.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n StyledColorArea,\n StyledColorAreaCanvas,\n StyledColorAreaPseudo,\n StyledMotionColorAreaPointer,\n} from './ColorArea.styles';\n\nimport { hsvToHex } from '@chayns/colors';\nimport { setRefreshScrollEnabled } from 'chayns-api';\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 canGetColorFromArea,\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 if (canGetColorFromArea) {\n setColor();\n }\n }, [canGetColorFromArea, hueColor, setColor, updateIsPresetColor]);\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: React.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 void setRefreshScrollEnabled(true);\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 void setRefreshScrollEnabled(false);\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 const handleStartDrag = useCallback(() => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n canDrag.current = true;\n\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('touchmove', handleTouchMove);\n\n const endTouching = () => {\n handlePointerUp();\n\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('touchmove', handleTouchMove);\n window.removeEventListener('pointerup', endTouching);\n window.removeEventListener('touchend', endTouching);\n };\n\n window.addEventListener('pointerup', endTouching);\n window.addEventListener('touchend', endTouching);\n }, [handleMouseMove, handlePointerUp, handleTouchMove, updateShouldGetCoordinates]);\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,IAAIC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC5F,SACIC,eAAe,EACfC,qBAAqB,EACrBC,qBAAqB,EACrBC,4BAA4B,QACzB,oBAAoB;AAE3B,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,uBAAuB,QAAQ,YAAY;AACpD,SAASC,eAAe,EAAEC,cAAc,QAAQ,eAAe;AAE/D,SACIC,gBAAgB,EAChBC,uBAAuB,EACvBC,uBAAuB,EACvBC,QAAQ,QACL,sBAAsB;AAC7B,SAASC,kBAAkB,QAAQ,2BAA2B;AAE9D,MAAMC,SAAS,GAAGA,CAAA,KAAM;EACpB,MAAM;IACFC,aAAa;I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AED,WAAW,CAAC;MACpDF,MAAM,CAACG,mBAAmB,CAAC,UAAU,EAAED,WAAW,CAAC;IACvD,CAAC;IAEDF,MAAM,CAACC,gBAAgB,CAAC,WAAW,EAAEC,WAAW,CAAC;IACjDF,MAAM,CAACC,gBAAgB,CAAC,UAAU,EAAEC,WAAW,CAAC;EACpD,CAAC,EAAE,CAACT,eAAe,EAAEN,eAAe,EAAEO,eAAe,EAAE7D,0BAA0B,CAAC,CAAC;EAEnF,OAAOvB,OAAO,CACV,mBACIJ,KAAA,CAAAkG,aAAA,CAAC3F,eAAe,qBACZP,KAAA,CAAAkG,aAAA,CAAC1F,qBAAqB;IAAC2F,GAAG,EAAE5D;EAAU,CAAE,CAAC,eACzCvC,KAAA,CAAAkG,aAAA,CAACzF,qBAAqB;IAClB0F,GAAG,EAAE3D,SAAU;IACf4D,aAAa,EAAEP,eAAgB;IAC/BQ,OAAO,EAAE3B;EAAY,gBAErB1E,KAAA,CAAAkG,aAAA,CAACxF,4BAA4B;IACzB4F,IAAI;IACJC,eAAe,EAAE/D,SAAU;IAC3BgE,KAAK,EAAE;MAAE9D,CAAC;MAAEC;IAAE,CAAE;IAChB8D,WAAW,EAAE,KAAM;IACnBC,YAAY,EAAE,KAAM;IACpBjE,YAAY,EAAEA,YAAa;IAC3BkE,MAAM,EAAElC;EAAW,CACtB,CACkB,CACV,CACpB,EACD,CAAChC,YAAY,EAAEiC,WAAW,EAAED,UAAU,EAAEoB,eAAe,EAAEnD,CAAC,EAAEC,CAAC,CACjE,CAAC;AACL,CAAC;AAEDvB,SAAS,CAACwF,WAAW,GAAG,WAAW;AAEnC,eAAexF,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ColorArea.js","names":["React","useCallback","useContext","useEffect","useMemo","useRef","useState","StyledColorArea","StyledColorAreaCanvas","StyledColorAreaPseudo","StyledMotionColorAreaPointer","hsvToHex","setRefreshScrollEnabled","useDragControls","useMotionValue","extractRgbValues","getColorFromCoordinates","getCoordinatesFromColor","rgbToHsv","ColorPickerContext","ColorArea","selectedColor","updateSelectedColor","updateIsPresetColor","isPresetColor","shouldGetCoordinates","canGetColorFromArea","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","cords","tolerance","set","handleDrag","handleClick","event","left","top","target","clientX","clientY","handlePointerUp","move","xCords","yCords","newXCords","newYCords","handleMouseMove","handleTouchMove","preventDefault","changedTouches","pageX","pageY","handleStartDrag","window","addEventListener","endTouching","removeEventListener","createElement","ref","onPointerDown","onClick","drag","dragConstraints","style","dragElastic","dragMomentum","onDrag","displayName"],"sources":["../../../../../src/components/color-picker-popup/color-area/ColorArea.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n StyledColorArea,\n StyledColorAreaCanvas,\n StyledColorAreaPseudo,\n StyledMotionColorAreaPointer,\n} from './ColorArea.styles';\n\nimport { hsvToHex } from '@chayns/colors';\nimport { setRefreshScrollEnabled } from 'chayns-api';\nimport { useDragControls, useMotionValue } from 'motion/react';\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 canGetColorFromArea,\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 if (canGetColorFromArea) {\n setColor();\n }\n }, [canGetColorFromArea, hueColor, setColor, updateIsPresetColor]);\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: React.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 void setRefreshScrollEnabled(true);\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 void setRefreshScrollEnabled(false);\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 const handleStartDrag = useCallback(() => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n canDrag.current = true;\n\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('touchmove', handleTouchMove);\n\n const endTouching = () => {\n handlePointerUp();\n\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('touchmove', handleTouchMove);\n window.removeEventListener('pointerup', endTouching);\n window.removeEventListener('touchend', endTouching);\n };\n\n window.addEventListener('pointerup', endTouching);\n window.addEventListener('touchend', endTouching);\n }, [handleMouseMove, handlePointerUp, handleTouchMove, updateShouldGetCoordinates]);\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,IAAIC,WAAW,EAAEC,UAAU,EAAEC,SAAS,E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kE,MAAM,EAAElC;EAAW,CACtB,CACkB,CACV,CACpB,EACD,CAAChC,YAAY,EAAEiC,WAAW,EAAED,UAAU,EAAEoB,eAAe,EAAEnD,CAAC,EAAEC,CAAC,CACjE,CAAC;AACL,CAAC;AAEDvB,SAAS,CAACwF,WAAW,GAAG,WAAW;AAEnC,eAAexF,SAAS","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorArea.styles.js","names":["motion","styled","StyledColorArea","div","StyledColorAreaCanvas","canvas","StyledColorAreaPseudo","StyledMotionColorAreaPointer"],"sources":["../../../../../src/components/color-picker-popup/color-area/ColorArea.styles.ts"],"sourcesContent":["import { motion } from '
|
|
1
|
+
{"version":3,"file":"ColorArea.styles.js","names":["motion","styled","StyledColorArea","div","StyledColorAreaCanvas","canvas","StyledColorAreaPseudo","StyledMotionColorAreaPointer"],"sources":["../../../../../src/components/color-picker-popup/color-area/ColorArea.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled from 'styled-components';\n\nexport const StyledColorArea = styled.div`\n height: 150px;\n width: 300px;\n position: relative;\n user-select: none;\n overflow: hidden;\n cursor: crosshair;\n`;\n\nexport const StyledColorAreaCanvas = styled.canvas`\n user-select: none;\n`;\n\nexport const StyledColorAreaPseudo = styled.div`\n position: absolute;\n top: -10px;\n left: -10px;\n touch-action: none;\n user-select: none;\n\n height: 170px;\n width: 320px;\n`;\n\nexport const StyledMotionColorAreaPointer = styled(motion.div)`\n position: absolute;\n border-radius: 100%;\n border: 2px solid white;\n width: 20px;\n height: 20px;\n box-shadow:\n 0 0 5px 0 rgba(0, 0, 0, 0.5),\n 0 0 3px 0 rgba(0, 0, 0, 0.5) inset;\n pointer-events: none;\n user-select: none;\n top: 0;\n left: 0;\n`;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,cAAc;AACrC,OAAOC,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,eAAe,GAAGD,MAAM,CAACE,GAAG;AACzC;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,qBAAqB,GAAGH,MAAM,CAACI,MAAM;AAClD;AACA,CAAC;AAED,OAAO,MAAMC,qBAAqB,GAAGL,MAAM,CAACE,GAAG;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMI,4BAA4B,GAAGN,MAAM,CAACD,MAAM,CAACG,GAAG,CAAC;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -1,267 +1,6 @@
|
|
|
1
1
|
export declare const StyledColorArea: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
2
2
|
export declare const StyledColorAreaCanvas: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").CanvasHTMLAttributes<HTMLCanvasElement>, HTMLCanvasElement>, never>> & string;
|
|
3
3
|
export declare const StyledColorAreaPseudo: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
4
|
-
export declare const StyledMotionColorAreaPointer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<{
|
|
5
|
-
title?: string | undefined;
|
|
6
|
-
slot?: string | undefined;
|
|
7
|
-
defaultChecked?: boolean | undefined;
|
|
8
|
-
defaultValue?: string | number | readonly string[] | undefined;
|
|
9
|
-
suppressContentEditableWarning?: boolean | undefined;
|
|
10
|
-
suppressHydrationWarning?: boolean | undefined;
|
|
11
|
-
accessKey?: string | undefined;
|
|
12
|
-
autoCapitalize?: (string & {}) | "none" | "off" | "on" | "sentences" | "words" | "characters" | undefined;
|
|
13
|
-
autoFocus?: boolean | undefined;
|
|
14
|
-
className?: string | undefined;
|
|
15
|
-
contentEditable?: "inherit" | (boolean | "true" | "false") | "plaintext-only" | undefined;
|
|
16
|
-
contextMenu?: string | undefined;
|
|
17
|
-
dir?: string | undefined;
|
|
18
|
-
draggable?: (boolean | "true" | "false") | undefined;
|
|
19
|
-
enterKeyHint?: "search" | "enter" | "done" | "go" | "next" | "previous" | "send" | undefined;
|
|
20
|
-
hidden?: boolean | undefined;
|
|
21
|
-
id?: string | undefined;
|
|
22
|
-
lang?: string | undefined;
|
|
23
|
-
nonce?: string | undefined;
|
|
24
|
-
spellCheck?: (boolean | "true" | "false") | undefined;
|
|
25
|
-
tabIndex?: number | undefined;
|
|
26
|
-
translate?: "yes" | "no" | undefined;
|
|
27
|
-
radioGroup?: string | undefined;
|
|
28
|
-
role?: import("react").AriaRole | undefined;
|
|
29
|
-
about?: string | undefined;
|
|
30
|
-
content?: string | undefined;
|
|
31
|
-
datatype?: string | undefined;
|
|
32
|
-
inlist?: any;
|
|
33
|
-
prefix?: string | undefined;
|
|
34
|
-
property?: string | undefined;
|
|
35
|
-
rel?: string | undefined;
|
|
36
|
-
resource?: string | undefined;
|
|
37
|
-
rev?: string | undefined;
|
|
38
|
-
typeof?: string | undefined;
|
|
39
|
-
vocab?: string | undefined;
|
|
40
|
-
autoCorrect?: string | undefined;
|
|
41
|
-
autoSave?: string | undefined;
|
|
42
|
-
color?: string | undefined;
|
|
43
|
-
itemProp?: string | undefined;
|
|
44
|
-
itemScope?: boolean | undefined;
|
|
45
|
-
itemType?: string | undefined;
|
|
46
|
-
itemID?: string | undefined;
|
|
47
|
-
itemRef?: string | undefined;
|
|
48
|
-
results?: number | undefined;
|
|
49
|
-
security?: string | undefined;
|
|
50
|
-
unselectable?: "off" | "on" | undefined;
|
|
51
|
-
inputMode?: "none" | "text" | "search" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
|
|
52
|
-
is?: string | undefined;
|
|
53
|
-
"aria-activedescendant"?: string | undefined;
|
|
54
|
-
"aria-atomic"?: (boolean | "true" | "false") | undefined;
|
|
55
|
-
"aria-autocomplete"?: "none" | "list" | "inline" | "both" | undefined;
|
|
56
|
-
"aria-braillelabel"?: string | undefined;
|
|
57
|
-
"aria-brailleroledescription"?: string | undefined;
|
|
58
|
-
"aria-busy"?: (boolean | "true" | "false") | undefined;
|
|
59
|
-
"aria-checked"?: boolean | "true" | "false" | "mixed" | undefined;
|
|
60
|
-
"aria-colcount"?: number | undefined;
|
|
61
|
-
"aria-colindex"?: number | undefined;
|
|
62
|
-
"aria-colindextext"?: string | undefined;
|
|
63
|
-
"aria-colspan"?: number | undefined;
|
|
64
|
-
"aria-controls"?: string | undefined;
|
|
65
|
-
"aria-current"?: boolean | "time" | "true" | "false" | "step" | "page" | "date" | "location" | undefined;
|
|
66
|
-
"aria-describedby"?: string | undefined;
|
|
67
|
-
"aria-description"?: string | undefined;
|
|
68
|
-
"aria-details"?: string | undefined;
|
|
69
|
-
"aria-disabled"?: (boolean | "true" | "false") | undefined;
|
|
70
|
-
"aria-dropeffect"?: "none" | "link" | "copy" | "execute" | "move" | "popup" | undefined;
|
|
71
|
-
"aria-errormessage"?: string | undefined;
|
|
72
|
-
"aria-expanded"?: (boolean | "true" | "false") | undefined;
|
|
73
|
-
"aria-flowto"?: string | undefined;
|
|
74
|
-
"aria-grabbed"?: (boolean | "true" | "false") | undefined;
|
|
75
|
-
"aria-haspopup"?: boolean | "dialog" | "menu" | "true" | "false" | "grid" | "listbox" | "tree" | undefined;
|
|
76
|
-
"aria-hidden"?: (boolean | "true" | "false") | undefined;
|
|
77
|
-
"aria-invalid"?: boolean | "true" | "false" | "grammar" | "spelling" | undefined;
|
|
78
|
-
"aria-keyshortcuts"?: string | undefined;
|
|
79
|
-
"aria-label"?: string | undefined;
|
|
80
|
-
"aria-labelledby"?: string | undefined;
|
|
81
|
-
"aria-level"?: number | undefined;
|
|
82
|
-
"aria-live"?: "off" | "assertive" | "polite" | undefined;
|
|
83
|
-
"aria-modal"?: (boolean | "true" | "false") | undefined;
|
|
84
|
-
"aria-multiline"?: (boolean | "true" | "false") | undefined;
|
|
85
|
-
"aria-multiselectable"?: (boolean | "true" | "false") | undefined;
|
|
86
|
-
"aria-orientation"?: "horizontal" | "vertical" | undefined;
|
|
87
|
-
"aria-owns"?: string | undefined;
|
|
88
|
-
"aria-placeholder"?: string | undefined;
|
|
89
|
-
"aria-posinset"?: number | undefined;
|
|
90
|
-
"aria-pressed"?: boolean | "true" | "false" | "mixed" | undefined;
|
|
91
|
-
"aria-readonly"?: (boolean | "true" | "false") | undefined;
|
|
92
|
-
"aria-relevant"?: "text" | "all" | "additions" | "additions removals" | "additions text" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | undefined;
|
|
93
|
-
"aria-required"?: (boolean | "true" | "false") | undefined;
|
|
94
|
-
"aria-roledescription"?: string | undefined;
|
|
95
|
-
"aria-rowcount"?: number | undefined;
|
|
96
|
-
"aria-rowindex"?: number | undefined;
|
|
97
|
-
"aria-rowindextext"?: string | undefined;
|
|
98
|
-
"aria-rowspan"?: number | undefined;
|
|
99
|
-
"aria-selected"?: (boolean | "true" | "false") | undefined;
|
|
100
|
-
"aria-setsize"?: number | undefined;
|
|
101
|
-
"aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
|
|
102
|
-
"aria-valuemax"?: number | undefined;
|
|
103
|
-
"aria-valuemin"?: number | undefined;
|
|
104
|
-
"aria-valuenow"?: number | undefined;
|
|
105
|
-
"aria-valuetext"?: string | undefined;
|
|
106
|
-
dangerouslySetInnerHTML?: {
|
|
107
|
-
__html: string | TrustedHTML;
|
|
108
|
-
} | undefined;
|
|
109
|
-
onCopy?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
|
|
110
|
-
onCopyCapture?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
|
|
111
|
-
onCut?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
|
|
112
|
-
onCutCapture?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
|
|
113
|
-
onPaste?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
|
|
114
|
-
onPasteCapture?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
|
|
115
|
-
onCompositionEnd?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
|
|
116
|
-
onCompositionEndCapture?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
|
|
117
|
-
onCompositionStart?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
|
|
118
|
-
onCompositionStartCapture?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
|
|
119
|
-
onCompositionUpdate?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
|
|
120
|
-
onCompositionUpdateCapture?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
|
|
121
|
-
onFocus?: import("react").FocusEventHandler<HTMLDivElement> | undefined;
|
|
122
|
-
onFocusCapture?: import("react").FocusEventHandler<HTMLDivElement> | undefined;
|
|
123
|
-
onBlur?: import("react").FocusEventHandler<HTMLDivElement> | undefined;
|
|
124
|
-
onBlurCapture?: import("react").FocusEventHandler<HTMLDivElement> | undefined;
|
|
125
|
-
onChange?: import("react").FormEventHandler<HTMLDivElement> | undefined;
|
|
126
|
-
onChangeCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
|
|
127
|
-
onBeforeInput?: import("react").FormEventHandler<HTMLDivElement> | undefined;
|
|
128
|
-
onBeforeInputCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
|
|
129
|
-
onInput?: import("react").FormEventHandler<HTMLDivElement> | undefined;
|
|
130
|
-
onInputCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
|
|
131
|
-
onReset?: import("react").FormEventHandler<HTMLDivElement> | undefined;
|
|
132
|
-
onResetCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
|
|
133
|
-
onSubmit?: import("react").FormEventHandler<HTMLDivElement> | undefined;
|
|
134
|
-
onSubmitCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
|
|
135
|
-
onInvalid?: import("react").FormEventHandler<HTMLDivElement> | undefined;
|
|
136
|
-
onInvalidCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
|
|
137
|
-
onLoad?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
138
|
-
onLoadCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
139
|
-
onError?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
140
|
-
onErrorCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
141
|
-
onKeyDown?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
|
|
142
|
-
onKeyDownCapture?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
|
|
143
|
-
onKeyPress?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
|
|
144
|
-
onKeyPressCapture?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
|
|
145
|
-
onKeyUp?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
|
|
146
|
-
onKeyUpCapture?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
|
|
147
|
-
onAbort?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
148
|
-
onAbortCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
149
|
-
onCanPlay?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
150
|
-
onCanPlayCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
151
|
-
onCanPlayThrough?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
152
|
-
onCanPlayThroughCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
153
|
-
onDurationChange?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
154
|
-
onDurationChangeCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
155
|
-
onEmptied?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
156
|
-
onEmptiedCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
157
|
-
onEncrypted?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
158
|
-
onEncryptedCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
159
|
-
onEnded?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
160
|
-
onEndedCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
161
|
-
onLoadedData?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
162
|
-
onLoadedDataCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
163
|
-
onLoadedMetadata?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
164
|
-
onLoadedMetadataCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
165
|
-
onLoadStart?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
166
|
-
onLoadStartCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
167
|
-
onPause?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
168
|
-
onPauseCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
169
|
-
onPlay?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
170
|
-
onPlayCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
171
|
-
onPlaying?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
172
|
-
onPlayingCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
173
|
-
onProgress?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
174
|
-
onProgressCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
175
|
-
onRateChange?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
176
|
-
onRateChangeCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
177
|
-
onResize?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
178
|
-
onResizeCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
179
|
-
onSeeked?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
180
|
-
onSeekedCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
181
|
-
onSeeking?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
182
|
-
onSeekingCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
183
|
-
onStalled?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
184
|
-
onStalledCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
185
|
-
onSuspend?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
186
|
-
onSuspendCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
187
|
-
onTimeUpdate?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
188
|
-
onTimeUpdateCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
189
|
-
onVolumeChange?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
190
|
-
onVolumeChangeCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
191
|
-
onWaiting?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
192
|
-
onWaitingCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
193
|
-
onAuxClick?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
194
|
-
onAuxClickCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
195
|
-
onClick?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
196
|
-
onClickCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
197
|
-
onContextMenu?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
198
|
-
onContextMenuCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
199
|
-
onDoubleClick?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
200
|
-
onDoubleClickCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
201
|
-
onDragCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
|
|
202
|
-
onDragEndCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
|
|
203
|
-
onDragEnter?: import("react").DragEventHandler<HTMLDivElement> | undefined;
|
|
204
|
-
onDragEnterCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
|
|
205
|
-
onDragExit?: import("react").DragEventHandler<HTMLDivElement> | undefined;
|
|
206
|
-
onDragExitCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
|
|
207
|
-
onDragLeave?: import("react").DragEventHandler<HTMLDivElement> | undefined;
|
|
208
|
-
onDragLeaveCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
|
|
209
|
-
onDragOver?: import("react").DragEventHandler<HTMLDivElement> | undefined;
|
|
210
|
-
onDragOverCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
|
|
211
|
-
onDragStartCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
|
|
212
|
-
onDrop?: import("react").DragEventHandler<HTMLDivElement> | undefined;
|
|
213
|
-
onDropCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
|
|
214
|
-
onMouseDown?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
215
|
-
onMouseDownCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
216
|
-
onMouseEnter?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
217
|
-
onMouseLeave?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
218
|
-
onMouseMove?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
219
|
-
onMouseMoveCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
220
|
-
onMouseOut?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
221
|
-
onMouseOutCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
222
|
-
onMouseOver?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
223
|
-
onMouseOverCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
224
|
-
onMouseUp?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
225
|
-
onMouseUpCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
226
|
-
onSelect?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
227
|
-
onSelectCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
|
|
228
|
-
onTouchCancel?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
|
|
229
|
-
onTouchCancelCapture?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
|
|
230
|
-
onTouchEnd?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
|
|
231
|
-
onTouchEndCapture?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
|
|
232
|
-
onTouchMove?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
|
|
233
|
-
onTouchMoveCapture?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
|
|
234
|
-
onTouchStart?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
|
|
235
|
-
onTouchStartCapture?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
|
|
236
|
-
onPointerDown?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
237
|
-
onPointerDownCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
238
|
-
onPointerMove?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
239
|
-
onPointerMoveCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
240
|
-
onPointerUp?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
241
|
-
onPointerUpCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
242
|
-
onPointerCancel?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
243
|
-
onPointerCancelCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
244
|
-
onPointerEnter?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
245
|
-
onPointerLeave?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
246
|
-
onPointerOver?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
247
|
-
onPointerOverCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
248
|
-
onPointerOut?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
249
|
-
onPointerOutCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
250
|
-
onGotPointerCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
251
|
-
onGotPointerCaptureCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
252
|
-
onLostPointerCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
253
|
-
onLostPointerCaptureCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
254
|
-
onScroll?: import("react").UIEventHandler<HTMLDivElement> | undefined;
|
|
255
|
-
onScrollCapture?: import("react").UIEventHandler<HTMLDivElement> | undefined;
|
|
256
|
-
onWheel?: import("react").WheelEventHandler<HTMLDivElement> | undefined;
|
|
257
|
-
onWheelCapture?: import("react").WheelEventHandler<HTMLDivElement> | undefined;
|
|
258
|
-
onAnimationStartCapture?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
|
|
259
|
-
onAnimationEnd?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
|
|
260
|
-
onAnimationEndCapture?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
|
|
261
|
-
onAnimationIteration?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
|
|
262
|
-
onAnimationIterationCapture?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
|
|
263
|
-
onTransitionEnd?: import("react").TransitionEventHandler<HTMLDivElement> | undefined;
|
|
264
|
-
onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLDivElement> | undefined;
|
|
265
|
-
} & import("framer-motion").MotionProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
4
|
+
export declare const StyledMotionColorAreaPointer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<import("motion/react").HTMLMotionProps<"div">, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
266
5
|
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
267
|
-
}, never>> & string & Omit<import("
|
|
6
|
+
}, never>> & string & Omit<import("motion/react").ForwardRefComponent<HTMLDivElement, import("motion/react").HTMLMotionProps<"div">>, keyof import("react").Component<any, {}, any>>;
|
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.1005",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -69,12 +69,12 @@
|
|
|
69
69
|
"typescript": "^5.7.3"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@chayns-components/core": "^5.0.0-beta.
|
|
72
|
+
"@chayns-components/core": "^5.0.0-beta.1005",
|
|
73
73
|
"@chayns/colors": "^2.0.0"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"chayns-api": ">=2.0.0",
|
|
77
|
-
"
|
|
77
|
+
"motion": ">=12.4.1",
|
|
78
78
|
"react": ">=18.0.0",
|
|
79
79
|
"react-dom": ">=18.0.0",
|
|
80
80
|
"styled-components": ">=5.3.11"
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "e9addebffb5f9ef1fb0f85ddfd9611ec4b422f55"
|
|
86
86
|
}
|