@react-spectrum/color 3.1.4 → 3.1.5
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/dist/ColorWheel.main.js
CHANGED
|
@@ -7,8 +7,8 @@ var $gEgjt$react = require("react");
|
|
|
7
7
|
var $gEgjt$reactariacolor = require("@react-aria/color");
|
|
8
8
|
var $gEgjt$reactstatelycolor = require("@react-stately/color");
|
|
9
9
|
var $gEgjt$reactariafocus = require("@react-aria/focus");
|
|
10
|
-
var $gEgjt$reactspectrumprovider = require("@react-spectrum/provider");
|
|
11
10
|
var $gEgjt$reactariautils = require("@react-aria/utils");
|
|
11
|
+
var $gEgjt$reactspectrumprovider = require("@react-spectrum/provider");
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
function $parcel$interopDefault(a) {
|
|
@@ -62,7 +62,7 @@ const $63a2864687444ae1$export$f80663f808113381 = /*#__PURE__*/ (0, ($parcel$int
|
|
|
62
62
|
setWheelRadius,
|
|
63
63
|
setWheelThickness
|
|
64
64
|
]);
|
|
65
|
-
(0, $gEgjt$
|
|
65
|
+
(0, $gEgjt$reactariautils.useLayoutEffect)(()=>{
|
|
66
66
|
// the size observer's fallback to the window resize event doesn't fire on mount
|
|
67
67
|
if (wheelRadius === 0) resizeHandler();
|
|
68
68
|
}, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AAeD,MAAM,wCAAkB;AAKjB,MAAM,0DAAa,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC,SAAS,WAAW,KAA8B,EAAE,GAAiC;IAC9H,QAAQ,CAAA,GAAA,6CAAe,EAAE;IACzB,IAAI,WAAW,CAAA,GAAA,mBAAK,EAAE;IACtB,IAAI,eAAe,CAAA,GAAA,yCAAc,EAAE,KAAK;IACxC,CAAC,OAAO,aAAa,GAAG,CAAA,GAAA,0CAAc,EAAE,OAAO,cA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,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;QAC7B,GAAG,UAAU;qBACd,0DAAC;QAAO,GAAG,UAAU;QAAE,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;QAAgC,GAAG,UAAU;QAAE,KAAK;;AAIjH","sources":["packages/@react-spectrum/color/src/ColorWheel.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {classNames, dimensionValue, useFocusableRef, useStyleProps} from '@react-spectrum/utils';\nimport {ColorThumb} from './ColorThumb';\nimport {ColorWheelContext, useContextProps} from 'react-aria-components';\nimport {FocusableRef} from '@react-types/shared';\nimport React, {useCallback, useRef, useState} from 'react';\nimport {SpectrumColorWheelProps} from '@react-types/color';\nimport styles from '@adobe/spectrum-css-temp/components/colorwheel/vars.css';\nimport {useColorWheel} from '@react-aria/color';\nimport {useColorWheelState} from '@react-stately/color';\nimport {useFocusRing} from '@react-aria/focus';\nimport {useLayoutEffect, useResizeObserver} from '@react-aria/utils';\nimport {useProviderProps} from '@react-spectrum/provider';\n\nconst WHEEL_THICKNESS = 24;\n\n/**\n * ColorWheels allow users to adjust the hue of an HSL or HSB color value on a circular track.\n */\nexport const ColorWheel = React.forwardRef(function ColorWheel(props: SpectrumColorWheelProps, ref: FocusableRef<HTMLDivElement>) {\n props = useProviderProps(props);\n let inputRef = useRef(null);\n let containerRef = useFocusableRef(ref, inputRef);\n [props, containerRef] = useContextProps(props, containerRef, ColorWheelContext);\n\n let {isDisabled} = props;\n let size = props.size && dimensionValue(props.size);\n let {styleProps} = useStyleProps(props);\n\n\n let [wheelRadius, setWheelRadius] = useState<number>(0);\n let [wheelThickness, setWheelThickness] = useState(WHEEL_THICKNESS);\n\n let resizeHandler = useCallback(() => {\n if (containerRef.current) {\n setWheelRadius(containerRef.current.offsetWidth / 2);\n let thickness = window.getComputedStyle(containerRef.current)\n .getPropertyValue('--spectrum-colorwheel-track-thickness');\n if (thickness) {\n setWheelThickness(parseInt(thickness, 10));\n }\n }\n }, [containerRef, setWheelRadius, setWheelThickness]);\n\n useLayoutEffect(() => {\n // the size observer's fallback to the window resize event doesn't fire on mount\n if (wheelRadius === 0) {\n resizeHandler();\n }\n }, [wheelRadius, resizeHandler]);\n\n useResizeObserver({\n ref: containerRef,\n onResize: resizeHandler\n });\n\n let state = useColorWheelState(props);\n\n let {trackProps, inputProps, thumbProps} = useColorWheel({\n ...props,\n innerRadius: wheelRadius - wheelThickness,\n outerRadius: wheelRadius\n }, state, inputRef);\n\n let {focusProps, isFocusVisible} = useFocusRing();\n\n return (\n <div\n className={\n classNames(\n styles,\n 'spectrum-ColorWheel',\n {\n 'is-disabled': isDisabled\n },\n styleProps.className\n )\n }\n ref={containerRef}\n style={{\n ...styleProps.style,\n // Workaround around https://github.com/adobe/spectrum-css/issues/1032\n 'width': size,\n 'height': size\n }}>\n <div {...trackProps} className={classNames(styles, 'spectrum-ColorWheel-gradient')} />\n <ColorThumb\n value={state.getDisplayColor()}\n isFocused={isFocusVisible}\n isDisabled={isDisabled}\n isDragging={state.isDragging}\n containerRef={containerRef}\n className={classNames(styles, 'spectrum-ColorWheel-handle')}\n {...thumbProps}>\n <input {...focusProps} className={classNames(styles, 'spectrum-ColorWheel-slider')} {...inputProps} ref={inputRef} />\n </ColorThumb>\n </div>\n );\n});\n"],"names":[],"version":3,"file":"ColorWheel.main.js.map"}
|
package/dist/ColorWheel.mjs
CHANGED
|
@@ -3,12 +3,12 @@ import "./color.0da417e8.css";
|
|
|
3
3
|
import $bv4AR$colorwheel_vars_cssmodulejs from "./colorwheel_vars_css.mjs";
|
|
4
4
|
import {useFocusableRef as $bv4AR$useFocusableRef, dimensionValue as $bv4AR$dimensionValue, useStyleProps as $bv4AR$useStyleProps, classNames as $bv4AR$classNames} from "@react-spectrum/utils";
|
|
5
5
|
import {useContextProps as $bv4AR$useContextProps, ColorWheelContext as $bv4AR$ColorWheelContext} from "react-aria-components";
|
|
6
|
-
import $bv4AR$react, {useRef as $bv4AR$useRef, useState as $bv4AR$useState, useCallback as $bv4AR$useCallback
|
|
6
|
+
import $bv4AR$react, {useRef as $bv4AR$useRef, useState as $bv4AR$useState, useCallback as $bv4AR$useCallback} from "react";
|
|
7
7
|
import {useColorWheel as $bv4AR$useColorWheel} from "@react-aria/color";
|
|
8
8
|
import {useColorWheelState as $bv4AR$useColorWheelState} from "@react-stately/color";
|
|
9
9
|
import {useFocusRing as $bv4AR$useFocusRing} from "@react-aria/focus";
|
|
10
|
+
import {useLayoutEffect as $bv4AR$useLayoutEffect, useResizeObserver as $bv4AR$useResizeObserver} from "@react-aria/utils";
|
|
10
11
|
import {useProviderProps as $bv4AR$useProviderProps} from "@react-spectrum/provider";
|
|
11
|
-
import {useResizeObserver as $bv4AR$useResizeObserver} from "@react-aria/utils";
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
function $parcel$interopDefault(a) {
|
|
@@ -56,7 +56,7 @@ const $3aac1c27203f04b5$export$f80663f808113381 = /*#__PURE__*/ (0, $bv4AR$react
|
|
|
56
56
|
setWheelRadius,
|
|
57
57
|
setWheelThickness
|
|
58
58
|
]);
|
|
59
|
-
(0, $bv4AR$
|
|
59
|
+
(0, $bv4AR$useLayoutEffect)(()=>{
|
|
60
60
|
// the size observer's fallback to the window resize event doesn't fire on mount
|
|
61
61
|
if (wheelRadius === 0) resizeHandler();
|
|
62
62
|
}, [
|
|
@@ -3,12 +3,12 @@ import "./color.0da417e8.css";
|
|
|
3
3
|
import $bv4AR$colorwheel_vars_cssmodulejs from "./colorwheel_vars_css.module.js";
|
|
4
4
|
import {useFocusableRef as $bv4AR$useFocusableRef, dimensionValue as $bv4AR$dimensionValue, useStyleProps as $bv4AR$useStyleProps, classNames as $bv4AR$classNames} from "@react-spectrum/utils";
|
|
5
5
|
import {useContextProps as $bv4AR$useContextProps, ColorWheelContext as $bv4AR$ColorWheelContext} from "react-aria-components";
|
|
6
|
-
import $bv4AR$react, {useRef as $bv4AR$useRef, useState as $bv4AR$useState, useCallback as $bv4AR$useCallback
|
|
6
|
+
import $bv4AR$react, {useRef as $bv4AR$useRef, useState as $bv4AR$useState, useCallback as $bv4AR$useCallback} from "react";
|
|
7
7
|
import {useColorWheel as $bv4AR$useColorWheel} from "@react-aria/color";
|
|
8
8
|
import {useColorWheelState as $bv4AR$useColorWheelState} from "@react-stately/color";
|
|
9
9
|
import {useFocusRing as $bv4AR$useFocusRing} from "@react-aria/focus";
|
|
10
|
+
import {useLayoutEffect as $bv4AR$useLayoutEffect, useResizeObserver as $bv4AR$useResizeObserver} from "@react-aria/utils";
|
|
10
11
|
import {useProviderProps as $bv4AR$useProviderProps} from "@react-spectrum/provider";
|
|
11
|
-
import {useResizeObserver as $bv4AR$useResizeObserver} from "@react-aria/utils";
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
function $parcel$interopDefault(a) {
|
|
@@ -56,7 +56,7 @@ const $3aac1c27203f04b5$export$f80663f808113381 = /*#__PURE__*/ (0, $bv4AR$react
|
|
|
56
56
|
setWheelRadius,
|
|
57
57
|
setWheelThickness
|
|
58
58
|
]);
|
|
59
|
-
(0, $bv4AR$
|
|
59
|
+
(0, $bv4AR$useLayoutEffect)(()=>{
|
|
60
60
|
// the size observer's fallback to the window resize event doesn't fire on mount
|
|
61
61
|
if (wheelRadius === 0) resizeHandler();
|
|
62
62
|
}, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AAeD,MAAM,wCAAkB;AAKjB,MAAM,0DAAa,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ACtE,SAAS;YACT,UAAU;QACZ;qBACA,gCAAC;QAAK,GAAG,UAAU;QAAE,WAAW,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,4DAAK,GAAG;sBACnD,gCAAC,CAAA,GAAA,wCAAS;QACR,OAAO,MAAM,eAAe;QAC5B,WAAW;QACX,YAAY;QACZ,YAAY,MAAM,UAAU;QAC5B,cAAc;QACd,WAAW,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,4DAAK,GAAG;QAC7B,GAAG,UAAU;qBACd,gCAAC;QAAO,GAAG,UAAU;QAAE,WAAW,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,4DAAK,GAAG;QAAgC,GAAG,UAAU;QAAE,KAAK;;AAIjH","sources":["packages/@react-spectrum/color/src/ColorWheel.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {classNames, dimensionValue, useFocusableRef, useStyleProps} from '@react-spectrum/utils';\nimport {ColorThumb} from './ColorThumb';\nimport {ColorWheelContext, useContextProps} from 'react-aria-components';\nimport {FocusableRef} from '@react-types/shared';\nimport React, {useCallback, useRef, useState} from 'react';\nimport {SpectrumColorWheelProps} from '@react-types/color';\nimport styles from '@adobe/spectrum-css-temp/components/colorwheel/vars.css';\nimport {useColorWheel} from '@react-aria/color';\nimport {useColorWheelState} from '@react-stately/color';\nimport {useFocusRing} from '@react-aria/focus';\nimport {useLayoutEffect, useResizeObserver} from '@react-aria/utils';\nimport {useProviderProps} from '@react-spectrum/provider';\n\nconst WHEEL_THICKNESS = 24;\n\n/**\n * ColorWheels allow users to adjust the hue of an HSL or HSB color value on a circular track.\n */\nexport const ColorWheel = React.forwardRef(function ColorWheel(props: SpectrumColorWheelProps, ref: FocusableRef<HTMLDivElement>) {\n props = useProviderProps(props);\n let inputRef = useRef(null);\n let containerRef = useFocusableRef(ref, inputRef);\n [props, containerRef] = useContextProps(props, containerRef, ColorWheelContext);\n\n let {isDisabled} = props;\n let size = props.size && dimensionValue(props.size);\n let {styleProps} = useStyleProps(props);\n\n\n let [wheelRadius, setWheelRadius] = useState<number>(0);\n let [wheelThickness, setWheelThickness] = useState(WHEEL_THICKNESS);\n\n let resizeHandler = useCallback(() => {\n if (containerRef.current) {\n setWheelRadius(containerRef.current.offsetWidth / 2);\n let thickness = window.getComputedStyle(containerRef.current)\n .getPropertyValue('--spectrum-colorwheel-track-thickness');\n if (thickness) {\n setWheelThickness(parseInt(thickness, 10));\n }\n }\n }, [containerRef, setWheelRadius, setWheelThickness]);\n\n useLayoutEffect(() => {\n // the size observer's fallback to the window resize event doesn't fire on mount\n if (wheelRadius === 0) {\n resizeHandler();\n }\n }, [wheelRadius, resizeHandler]);\n\n useResizeObserver({\n ref: containerRef,\n onResize: resizeHandler\n });\n\n let state = useColorWheelState(props);\n\n let {trackProps, inputProps, thumbProps} = useColorWheel({\n ...props,\n innerRadius: wheelRadius - wheelThickness,\n outerRadius: wheelRadius\n }, state, inputRef);\n\n let {focusProps, isFocusVisible} = useFocusRing();\n\n return (\n <div\n className={\n classNames(\n styles,\n 'spectrum-ColorWheel',\n {\n 'is-disabled': isDisabled\n },\n styleProps.className\n )\n }\n ref={containerRef}\n style={{\n ...styleProps.style,\n // Workaround around https://github.com/adobe/spectrum-css/issues/1032\n 'width': size,\n 'height': size\n }}>\n <div {...trackProps} className={classNames(styles, 'spectrum-ColorWheel-gradient')} />\n <ColorThumb\n value={state.getDisplayColor()}\n isFocused={isFocusVisible}\n isDisabled={isDisabled}\n isDragging={state.isDragging}\n containerRef={containerRef}\n className={classNames(styles, 'spectrum-ColorWheel-handle')}\n {...thumbProps}>\n <input {...focusProps} className={classNames(styles, 'spectrum-ColorWheel-slider')} {...inputProps} ref={inputRef} />\n </ColorThumb>\n </div>\n );\n});\n"],"names":[],"version":3,"file":"ColorWheel.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/color",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -40,25 +40,25 @@
|
|
|
40
40
|
"url": "https://github.com/adobe/react-spectrum"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@react-aria/color": "^3.1.
|
|
44
|
-
"@react-aria/focus": "^3.21.
|
|
45
|
-
"@react-aria/i18n": "^3.12.
|
|
46
|
-
"@react-aria/interactions": "^3.
|
|
47
|
-
"@react-aria/utils": "^3.
|
|
48
|
-
"@react-spectrum/dialog": "^3.9.
|
|
49
|
-
"@react-spectrum/form": "^3.7.
|
|
50
|
-
"@react-spectrum/label": "^3.16.
|
|
51
|
-
"@react-spectrum/overlays": "^5.9.
|
|
52
|
-
"@react-spectrum/picker": "^3.16.
|
|
53
|
-
"@react-spectrum/textfield": "^3.14.
|
|
54
|
-
"@react-spectrum/utils": "^3.12.
|
|
55
|
-
"@react-spectrum/view": "^3.6.
|
|
56
|
-
"@react-stately/color": "^3.9.
|
|
43
|
+
"@react-aria/color": "^3.1.3",
|
|
44
|
+
"@react-aria/focus": "^3.21.3",
|
|
45
|
+
"@react-aria/i18n": "^3.12.14",
|
|
46
|
+
"@react-aria/interactions": "^3.26.0",
|
|
47
|
+
"@react-aria/utils": "^3.32.0",
|
|
48
|
+
"@react-spectrum/dialog": "^3.9.5",
|
|
49
|
+
"@react-spectrum/form": "^3.7.20",
|
|
50
|
+
"@react-spectrum/label": "^3.16.20",
|
|
51
|
+
"@react-spectrum/overlays": "^5.9.1",
|
|
52
|
+
"@react-spectrum/picker": "^3.16.5",
|
|
53
|
+
"@react-spectrum/textfield": "^3.14.3",
|
|
54
|
+
"@react-spectrum/utils": "^3.12.10",
|
|
55
|
+
"@react-spectrum/view": "^3.6.24",
|
|
56
|
+
"@react-stately/color": "^3.9.3",
|
|
57
57
|
"@react-types/color": "^3.1.2",
|
|
58
58
|
"@react-types/shared": "^3.32.1",
|
|
59
59
|
"@react-types/textfield": "^3.12.6",
|
|
60
60
|
"@swc/helpers": "^0.5.0",
|
|
61
|
-
"react-aria-components": "^1.
|
|
61
|
+
"react-aria-components": "^1.14.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@adobe/spectrum-css-temp": "3.0.0-alpha.1",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "4d838da5bfe36abb35aed166995a9ef63825370f"
|
|
76
76
|
}
|
package/src/ColorWheel.tsx
CHANGED
|
@@ -14,14 +14,14 @@ import {classNames, dimensionValue, useFocusableRef, useStyleProps} from '@react
|
|
|
14
14
|
import {ColorThumb} from './ColorThumb';
|
|
15
15
|
import {ColorWheelContext, useContextProps} from 'react-aria-components';
|
|
16
16
|
import {FocusableRef} from '@react-types/shared';
|
|
17
|
-
import React, {useCallback,
|
|
17
|
+
import React, {useCallback, useRef, useState} from 'react';
|
|
18
18
|
import {SpectrumColorWheelProps} from '@react-types/color';
|
|
19
19
|
import styles from '@adobe/spectrum-css-temp/components/colorwheel/vars.css';
|
|
20
20
|
import {useColorWheel} from '@react-aria/color';
|
|
21
21
|
import {useColorWheelState} from '@react-stately/color';
|
|
22
22
|
import {useFocusRing} from '@react-aria/focus';
|
|
23
|
+
import {useLayoutEffect, useResizeObserver} from '@react-aria/utils';
|
|
23
24
|
import {useProviderProps} from '@react-spectrum/provider';
|
|
24
|
-
import {useResizeObserver} from '@react-aria/utils';
|
|
25
25
|
|
|
26
26
|
const WHEEL_THICKNESS = 24;
|
|
27
27
|
|
|
@@ -53,7 +53,7 @@ export const ColorWheel = React.forwardRef(function ColorWheel(props: SpectrumCo
|
|
|
53
53
|
}
|
|
54
54
|
}, [containerRef, setWheelRadius, setWheelThickness]);
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
useLayoutEffect(() => {
|
|
57
57
|
// the size observer's fallback to the window resize event doesn't fire on mount
|
|
58
58
|
if (wheelRadius === 0) {
|
|
59
59
|
resizeHandler();
|