@react-spectrum/color 3.0.0-nightly.4567 → 3.0.0-nightly.4582
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/ColorArea.main.js +11 -10
- package/dist/ColorArea.main.js.map +1 -1
- package/dist/ColorArea.mjs +12 -11
- package/dist/ColorArea.module.js +12 -11
- package/dist/ColorArea.module.js.map +1 -1
- package/dist/ColorEditor.32e497e8.css +20 -0
- package/dist/ColorEditor.32e497e8.css.map +1 -0
- package/dist/ColorEditor.main.js +116 -0
- package/dist/ColorEditor.main.js.map +1 -0
- package/dist/ColorEditor.mjs +111 -0
- package/dist/ColorEditor.module.js +111 -0
- package/dist/ColorEditor.module.js.map +1 -0
- package/dist/ColorField.main.js +44 -6
- package/dist/ColorField.main.js.map +1 -1
- package/dist/ColorField.mjs +46 -8
- package/dist/ColorField.module.js +46 -8
- package/dist/ColorField.module.js.map +1 -1
- package/dist/ColorPicker.ab9f47c0.css +204 -0
- package/dist/ColorPicker.ab9f47c0.css.map +1 -0
- package/dist/ColorPicker.main.js +125 -0
- package/dist/ColorPicker.main.js.map +1 -0
- package/dist/ColorPicker.mjs +116 -0
- package/dist/ColorPicker.module.js +116 -0
- package/dist/ColorPicker.module.js.map +1 -0
- package/dist/ColorSlider.main.js +8 -4
- package/dist/ColorSlider.main.js.map +1 -1
- package/dist/ColorSlider.mjs +9 -5
- package/dist/ColorSlider.module.js +9 -5
- package/dist/ColorSlider.module.js.map +1 -1
- package/dist/ColorSwatch.f6e6f811.css +260 -0
- package/dist/ColorSwatch.f6e6f811.css.map +1 -0
- package/dist/ColorSwatch.main.js +94 -0
- package/dist/ColorSwatch.main.js.map +1 -0
- package/dist/ColorSwatch.mjs +84 -0
- package/dist/ColorSwatch.module.js +84 -0
- package/dist/ColorSwatch.module.js.map +1 -0
- package/dist/ColorSwatchPicker.1575be06.css +356 -0
- package/dist/ColorSwatchPicker.1575be06.css.map +1 -0
- package/dist/ColorSwatchPicker.main.js +115 -0
- package/dist/ColorSwatchPicker.main.js.map +1 -0
- package/dist/ColorSwatchPicker.mjs +106 -0
- package/dist/ColorSwatchPicker.module.js +106 -0
- package/dist/ColorSwatchPicker.module.js.map +1 -0
- package/dist/ColorThumb.main.js +57 -7
- package/dist/ColorThumb.main.js.map +1 -1
- package/dist/ColorThumb.mjs +59 -9
- package/dist/ColorThumb.module.js +59 -9
- package/dist/ColorThumb.module.js.map +1 -1
- package/dist/ColorWheel.main.js +6 -2
- package/dist/ColorWheel.main.js.map +1 -1
- package/dist/ColorWheel.mjs +7 -3
- package/dist/ColorWheel.module.js +7 -3
- package/dist/ColorWheel.module.js.map +1 -1
- package/dist/colorarea_vars_css.main.js +0 -3
- package/dist/colorarea_vars_css.main.js.map +1 -1
- package/dist/colorarea_vars_css.mjs +0 -3
- package/dist/colorarea_vars_css.module.js +0 -3
- package/dist/colorarea_vars_css.module.js.map +1 -1
- package/dist/en-US.main.js +10 -0
- package/dist/en-US.main.js.map +1 -0
- package/dist/en-US.mjs +12 -0
- package/dist/en-US.module.js +12 -0
- package/dist/en-US.module.js.map +1 -0
- package/dist/import.mjs +11 -1
- package/dist/intlStrings.main.js +9 -0
- package/dist/intlStrings.main.js.map +1 -0
- package/dist/intlStrings.mjs +11 -0
- package/dist/intlStrings.module.js +11 -0
- package/dist/intlStrings.module.js.map +1 -0
- package/dist/main.js +16 -0
- package/dist/main.js.map +1 -1
- package/dist/module.js +11 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +75 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/{vars.08ba4b4c.css → vars.53b417c1.css} +2 -3
- package/dist/vars.53b417c1.css.map +1 -0
- package/dist/{vars.6f3d3943.css → vars.6fa9fa04.css} +6 -18
- package/dist/vars.6fa9fa04.css.map +1 -0
- package/dist/{vars.571f903e.css → vars.aa07b6d2.css} +2 -2
- package/dist/{vars.571f903e.css.map → vars.aa07b6d2.css.map} +1 -1
- package/dist/{vars.ef2c01b8.css → vars.cc682729.css} +4 -4
- package/dist/{vars.ef2c01b8.css.map → vars.cc682729.css.map} +1 -1
- package/package.json +23 -17
- package/src/ColorArea.tsx +7 -6
- package/src/ColorEditor.tsx +63 -0
- package/src/ColorField.tsx +67 -14
- package/src/ColorPicker.tsx +122 -0
- package/src/ColorSlider.tsx +6 -4
- package/src/ColorSwatch.tsx +102 -0
- package/src/ColorSwatchPicker.tsx +118 -0
- package/src/ColorThumb.tsx +72 -25
- package/src/ColorWheel.tsx +5 -2
- package/src/index.ts +10 -0
- package/dist/vars.08ba4b4c.css.map +0 -1
- package/dist/vars.6f3d3943.css.map +0 -1
@@ -0,0 +1,106 @@
|
|
1
|
+
import "./ColorSwatchPicker.1575be06.css";
|
2
|
+
import {SpectrumColorSwatchContext as $d68786ae409fa722$export$8529d7908a78c058} from "./ColorSwatch.module.js";
|
3
|
+
import {ColorSwatchPicker as $1TpDU$ColorSwatchPicker, ColorSwatchPickerItem as $1TpDU$ColorSwatchPickerItem} from "react-aria-components";
|
4
|
+
import $1TpDU$react, {forwardRef as $1TpDU$forwardRef} from "react";
|
5
|
+
import {useStyleProps as $1TpDU$useStyleProps, useDOMRef as $1TpDU$useDOMRef} from "@react-spectrum/utils";
|
6
|
+
|
7
|
+
/*
|
8
|
+
* Copyright 2024 Adobe. All rights reserved.
|
9
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
10
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
11
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
14
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
15
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
16
|
+
* governing permissions and limitations under the License.
|
17
|
+
*/
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
function $4919bc07654f325c$var$ColorSwatchPicker(props, ref) {
|
22
|
+
let { density: density = "regular", size: size = "M", rounding: rounding = "none", ...otherProps } = props;
|
23
|
+
let { styleProps: styleProps } = (0, $1TpDU$useStyleProps)(props);
|
24
|
+
let domRef = (0, $1TpDU$useDOMRef)(ref);
|
25
|
+
return /*#__PURE__*/ (0, $1TpDU$react).createElement((0, $1TpDU$ColorSwatchPicker), {
|
26
|
+
...otherProps,
|
27
|
+
style: styleProps.style,
|
28
|
+
ref: domRef,
|
29
|
+
className: styleProps.className + function anonymous(props) {
|
30
|
+
let rules = "";
|
31
|
+
rules += " _Sd";
|
32
|
+
rules += " _0a";
|
33
|
+
if (props.density === "spacious") rules += " lc";
|
34
|
+
else if (props.density === "regular") rules += " lb";
|
35
|
+
else if (props.density === "compact") rules += " lF";
|
36
|
+
if (props.density === "spacious") rules += " mc";
|
37
|
+
else if (props.density === "regular") rules += " mb";
|
38
|
+
else if (props.density === "compact") rules += " mF";
|
39
|
+
return rules;
|
40
|
+
}({
|
41
|
+
density: density
|
42
|
+
})
|
43
|
+
}, /*#__PURE__*/ (0, $1TpDU$react).createElement((0, $d68786ae409fa722$export$8529d7908a78c058).Provider, {
|
44
|
+
value: {
|
45
|
+
useWrapper: $4919bc07654f325c$var$useWrapper,
|
46
|
+
size: size,
|
47
|
+
rounding: rounding
|
48
|
+
}
|
49
|
+
}, props.children));
|
50
|
+
}
|
51
|
+
/**
|
52
|
+
* A ColorSwatchPicker displays a list of color swatches and allows a user to select one of them.
|
53
|
+
*/ let $4919bc07654f325c$export$b46792416e3d8515 = /*#__PURE__*/ (0, $1TpDU$forwardRef)($4919bc07654f325c$var$ColorSwatchPicker);
|
54
|
+
function $4919bc07654f325c$var$useWrapper(swatch, color, rounding) {
|
55
|
+
return /*#__PURE__*/ (0, $1TpDU$react).createElement((0, $1TpDU$ColorSwatchPickerItem), {
|
56
|
+
color: color,
|
57
|
+
className: (renderProps)=>(function anonymous(props) {
|
58
|
+
let rules = "";
|
59
|
+
if (props.isFocusVisible) rules += " _Eb";
|
60
|
+
else rules += " _Ea";
|
61
|
+
rules += " da___D";
|
62
|
+
rules += " d___I";
|
63
|
+
rules += " _Gc";
|
64
|
+
rules += " _Fc";
|
65
|
+
rules += " Xc";
|
66
|
+
if (props.rounding === "full") rules += " _pf";
|
67
|
+
else if (props.rounding === "default") rules += " _pc";
|
68
|
+
else if (props.rounding === "none") rules += " _pa";
|
69
|
+
if (props.rounding === "full") rules += " _qf";
|
70
|
+
else if (props.rounding === "default") rules += " _qc";
|
71
|
+
else if (props.rounding === "none") rules += " _qa";
|
72
|
+
if (props.rounding === "full") rules += " _rf";
|
73
|
+
else if (props.rounding === "default") rules += " _rc";
|
74
|
+
else if (props.rounding === "none") rules += " _ra";
|
75
|
+
if (props.rounding === "full") rules += " _sf";
|
76
|
+
else if (props.rounding === "default") rules += " _sc";
|
77
|
+
else if (props.rounding === "none") rules += " _sa";
|
78
|
+
return rules;
|
79
|
+
})({
|
80
|
+
...renderProps,
|
81
|
+
rounding: rounding
|
82
|
+
})
|
83
|
+
}, ({ isSelected: isSelected })=>/*#__PURE__*/ (0, $1TpDU$react).createElement((0, $1TpDU$react).Fragment, null, swatch, isSelected && /*#__PURE__*/ (0, $1TpDU$react).createElement("div", {
|
84
|
+
"aria-hidden": true,
|
85
|
+
className: function anonymous(props) {
|
86
|
+
let rules = "";
|
87
|
+
rules += " Xa";
|
88
|
+
rules += " __ya";
|
89
|
+
rules += " _0a";
|
90
|
+
rules += " _2a";
|
91
|
+
rules += " _1a";
|
92
|
+
rules += " _3a";
|
93
|
+
rules += " _o-1icpv9v";
|
94
|
+
rules += " _tb";
|
95
|
+
rules += " _p-17zqamw";
|
96
|
+
rules += " _q-17zqamw";
|
97
|
+
rules += " _r-17zqamw";
|
98
|
+
rules += " _s-17zqamw";
|
99
|
+
return rules;
|
100
|
+
}()
|
101
|
+
})));
|
102
|
+
}
|
103
|
+
|
104
|
+
|
105
|
+
export {$4919bc07654f325c$export$b46792416e3d8515 as ColorSwatchPicker};
|
106
|
+
//# sourceMappingURL=ColorSwatchPicker.module.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;AA8BD,SAAS,wCAAkB,KAAqC,EAAE,GAA2B;IAC3F,IAAI,WACF,UAAU,iBACV,OAAO,eACP,WAAW,QACX,GAAG,YACJ,GAAG;IACJ,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE;IACjC,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IAEvB,qBACE,gCAAC,CAAA,GAAA,wBAAoB;QAClB,GAAG,UAAU;QACd,OAAO,WAAW,KAAK;QACvB,KAAK;QACL,WAAW,WAAW,SAAS,GAAG;;;;;;;;;;;UAU/B;qBAAC;QAAO;qBACX,gCAAC,CAAA,GAAA,yCAAyB,EAAE,QAAQ;QAAC,OAAO;wBAAC;kBAAY;sBAAM;QAAQ;OACpE,MAAM,QAAQ;AAIvB;AAEA;;CAEC,GACD,IAAI,0DAAqB,CAAA,GAAA,iBAAS,EAAE;AAGpC,SAAS,iCAAW,MAAoB,EAAE,KAAY,EAAE,QAA8C;IACpG,qBACE,gCAAC,CAAA,GAAA,4BAAwB;QACvB,OAAO;QACP,WAAW,CAAA,cAAe;;;;;;;;;;;;;;;;;;;;;;eAgBvB;gBAAC,GAAG,WAAW;0BAAE;YAAQ;OAC3B,CAAC,cAAC,UAAU,EAAC,iBAAM,kEACjB,QACA,4BACC,gCAAC;YACC,eAAA;YACA,WAAW;;;;;;;;;;;;;;;;;AAYvB","sources":["packages/@react-spectrum/color/src/ColorSwatchPicker.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {ColorSwatchPicker as AriaColorSwatchPicker, ColorSwatchPickerItem as AriaColorSwatchPickerItem} from 'react-aria-components';\nimport {Color} from '@react-types/color';\nimport {DOMRef, StyleProps, ValueBase} from '@react-types/shared';\nimport React, {forwardRef, ReactElement, ReactNode} from 'react';\nimport {SpectrumColorSwatchContext, SpectrumColorSwatchProps} from './ColorSwatch';\nimport {style} from '@react-spectrum/style-macro-s1' with {type: 'macro'};\nimport {useDOMRef, useStyleProps} from '@react-spectrum/utils';\n\nexport interface SpectrumColorSwatchPickerProps extends ValueBase<string | Color | null, Color>, StyleProps {\n /** The ColorSwatches within the ColorSwatchPicker. */\n children: ReactNode,\n /**\n * The amount of padding between the swatches.\n * @default \"regular\"\n */\n density?: 'compact' | 'regular' | 'spacious',\n /**\n * The size of the color swatches.\n * @default \"M\"\n */\n size?: 'XS' | 'S' | 'M' | 'L',\n /**\n * The corner rounding of the color swatches.\n * @default \"none\"\n */\n rounding?: 'none' | 'default' | 'full'\n}\n\nfunction ColorSwatchPicker(props: SpectrumColorSwatchPickerProps, ref: DOMRef<HTMLDivElement>) {\n let {\n density = 'regular',\n size = 'M',\n rounding = 'none',\n ...otherProps\n } = props;\n let {styleProps} = useStyleProps(props);\n let domRef = useDOMRef(ref);\n\n return (\n <AriaColorSwatchPicker\n {...otherProps}\n style={styleProps.style}\n ref={domRef}\n className={styleProps.className + style({\n display: 'flex',\n flexWrap: 'wrap',\n gap: {\n density: {\n compact: 0.5,\n regular: 1,\n spacious: 2\n }\n }\n })({density})}>\n <SpectrumColorSwatchContext.Provider value={{useWrapper, size, rounding}}>\n {props.children}\n </SpectrumColorSwatchContext.Provider>\n </AriaColorSwatchPicker>\n );\n}\n\n/**\n * A ColorSwatchPicker displays a list of color swatches and allows a user to select one of them.\n */\nlet _ColorSwatchPicker = forwardRef(ColorSwatchPicker);\nexport {_ColorSwatchPicker as ColorSwatchPicker};\n\nfunction useWrapper(swatch: ReactElement, color: Color, rounding: SpectrumColorSwatchProps['rounding']) {\n return (\n <AriaColorSwatchPickerItem\n color={color}\n className={renderProps => style({\n outlineStyle: {\n default: 'none',\n isFocusVisible: 'solid'\n },\n outlineColor: 'focus-ring',\n outlineWidth: 2,\n outlineOffset: 2,\n position: 'relative',\n borderRadius: {\n rounding: {\n none: 'none',\n default: 'default',\n full: 'full'\n }\n }\n })({...renderProps, rounding})}>\n {({isSelected}) => (<>\n {swatch}\n {isSelected && (\n <div\n aria-hidden\n className={style({\n position: 'absolute',\n pointerEvents: 'none',\n inset: 0,\n boxShadow: '[inset 0 0 0 2px var(--spectrum-gray-900), inset 0 0 0 4px var(--spectrum-gray-50)]',\n forcedColorAdjust: 'none',\n borderRadius: '[inherit]'\n })()} />\n )}\n </>)}\n </AriaColorSwatchPickerItem>\n );\n}\n"],"names":[],"version":3,"file":"ColorSwatchPicker.module.js.map"}
|
package/dist/ColorThumb.main.js
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
require("./vars.
|
1
|
+
require("./vars.53b417c1.css");
|
2
2
|
var $f61d632765728b2e$exports = require("./colorhandle_vars_css.main.js");
|
3
|
-
require("./vars.
|
3
|
+
require("./vars.cc682729.css");
|
4
4
|
var $f65977ae56facfaa$exports = require("./colorloupe_vars_css.main.js");
|
5
5
|
var $bRwD9$reactspectrumutils = require("@react-spectrum/utils");
|
6
|
+
var $bRwD9$reactspectrumoverlays = require("@react-spectrum/overlays");
|
6
7
|
var $bRwD9$react = require("react");
|
7
8
|
var $bRwD9$reactariautils = require("@react-aria/utils");
|
9
|
+
var $bRwD9$reactspectrumprovider = require("@react-spectrum/provider");
|
8
10
|
|
9
11
|
|
10
12
|
function $parcel$interopDefault(a) {
|
@@ -31,25 +33,73 @@ $parcel$export(module.exports, "ColorThumb", () => $2b9adc23f6c7cae1$export$a3cc
|
|
31
33
|
|
32
34
|
|
33
35
|
|
36
|
+
|
37
|
+
|
34
38
|
function $2b9adc23f6c7cae1$export$a3cc47cee1c1ccc(props) {
|
35
|
-
let { value: value, isDisabled: isDisabled, isDragging: isDragging, isFocused: isFocused, children: children, className: className = "", ...otherProps } = props;
|
36
|
-
let patternId = (0, $bRwD9$reactariautils.useId)();
|
39
|
+
let { value: value, isDisabled: isDisabled, isDragging: isDragging, isFocused: isFocused, children: children, className: className = "", style: style, containerRef: containerRef, ...otherProps } = props;
|
37
40
|
let valueCSS = value.toString("css");
|
41
|
+
let loupeRef = (0, $bRwD9$react.useRef)(null);
|
42
|
+
let provider = (0, $bRwD9$reactspectrumprovider.useProvider)();
|
38
43
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($bRwD9$react))).createElement("div", {
|
39
44
|
className: (0, $bRwD9$reactspectrumutils.classNames)((0, ($parcel$interopDefault($f61d632765728b2e$exports))), "spectrum-ColorHandle", {
|
40
45
|
"is-focused": isFocused,
|
41
46
|
"is-disabled": isDisabled
|
42
47
|
}) + " " + className,
|
48
|
+
style: style,
|
43
49
|
...otherProps
|
44
50
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($bRwD9$react))).createElement("div", {
|
45
51
|
className: (0, $bRwD9$reactspectrumutils.classNames)((0, ($parcel$interopDefault($f61d632765728b2e$exports))), "spectrum-ColorHandle-color"),
|
46
52
|
style: {
|
47
53
|
backgroundColor: valueCSS
|
48
54
|
}
|
49
|
-
}), /*#__PURE__*/ (0, ($parcel$interopDefault($bRwD9$react))).createElement(
|
55
|
+
}), /*#__PURE__*/ (0, ($parcel$interopDefault($bRwD9$react))).createElement((0, $bRwD9$reactspectrumoverlays.Overlay), {
|
56
|
+
isOpen: isDragging && provider != null,
|
57
|
+
nodeRef: loupeRef
|
58
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($bRwD9$react))).createElement($2b9adc23f6c7cae1$var$ColorLoupe, {
|
59
|
+
valueCSS: valueCSS,
|
60
|
+
containerRef: containerRef,
|
61
|
+
loupeRef: loupeRef,
|
62
|
+
style: style
|
63
|
+
})), children);
|
64
|
+
}
|
65
|
+
// ColorLoupe is rendered in a portal so that it breaks out of clipped/scrolling containers (e.g. popovers).
|
66
|
+
function $2b9adc23f6c7cae1$var$ColorLoupe({ isOpen: isOpen, valueCSS: valueCSS, containerRef: containerRef, loupeRef: loupeRef, style: style }) {
|
67
|
+
let patternId = (0, $bRwD9$reactariautils.useId)();
|
68
|
+
// Get the bounding rectangle of the container (e.g. ColorArea/ColorSlider).
|
69
|
+
let [containerRect, setContainerRect] = (0, $bRwD9$react.useState)({
|
70
|
+
top: 0,
|
71
|
+
left: 0,
|
72
|
+
width: 0,
|
73
|
+
height: 0
|
74
|
+
});
|
75
|
+
(0, $bRwD9$reactariautils.useLayoutEffect)(()=>{
|
76
|
+
var _containerRef_current;
|
77
|
+
let rect = (_containerRef_current = containerRef.current) === null || _containerRef_current === void 0 ? void 0 : _containerRef_current.getBoundingClientRect();
|
78
|
+
setContainerRect({
|
79
|
+
top: (rect === null || rect === void 0 ? void 0 : rect.top) || 0,
|
80
|
+
left: (rect === null || rect === void 0 ? void 0 : rect.left) || 0,
|
81
|
+
width: (rect === null || rect === void 0 ? void 0 : rect.width) || 0,
|
82
|
+
height: (rect === null || rect === void 0 ? void 0 : rect.height) || 0
|
83
|
+
});
|
84
|
+
}, [
|
85
|
+
containerRef
|
86
|
+
]);
|
87
|
+
// Compute the pixel position of the thumb.
|
88
|
+
let thumbTop = style.top || "50%";
|
89
|
+
if (typeof thumbTop === "string" && thumbTop.endsWith("%")) thumbTop = parseFloat(style.top || "50%") / 100 * containerRect.height;
|
90
|
+
let thumbLeft = style.left || "50%";
|
91
|
+
if (typeof thumbLeft === "string" && thumbLeft.endsWith("%")) thumbLeft = parseFloat(thumbLeft || "50%") / 100 * containerRect.width;
|
92
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($bRwD9$react))).createElement("svg", {
|
50
93
|
className: (0, $bRwD9$reactspectrumutils.classNames)((0, ($parcel$interopDefault($f65977ae56facfaa$exports))), "spectrum-ColorLoupe", {
|
51
|
-
"is-open":
|
94
|
+
"is-open": isOpen
|
52
95
|
}),
|
96
|
+
style: {
|
97
|
+
// Position relative to the viewport.
|
98
|
+
position: "fixed",
|
99
|
+
top: containerRect.top + thumbTop,
|
100
|
+
left: containerRect.left + thumbLeft
|
101
|
+
},
|
102
|
+
ref: loupeRef,
|
53
103
|
"aria-hidden": "true"
|
54
104
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($bRwD9$react))).createElement("pattern", {
|
55
105
|
id: patternId,
|
@@ -87,7 +137,7 @@ function $2b9adc23f6c7cae1$export$a3cc47cee1c1ccc(props) {
|
|
87
137
|
}), /*#__PURE__*/ (0, ($parcel$interopDefault($bRwD9$react))).createElement("path", {
|
88
138
|
className: (0, $bRwD9$reactspectrumutils.classNames)((0, ($parcel$interopDefault($f65977ae56facfaa$exports))), "spectrum-ColorLoupe-outer"),
|
89
139
|
d: "M25 3A21.98 21.98 0 003 25c0 6.2 4 14.794 11.568 24.853A144.233 144.233 0 0025 62.132a144.085 144.085 0 0010.4-12.239C42.99 39.816 47 31.209 47 25A21.98 21.98 0 0025 3m0-2a24 24 0 0124 24c0 16.255-24 40-24 40S1 41.255 1 25A24 24 0 0125 1z"
|
90
|
-
}))
|
140
|
+
}));
|
91
141
|
}
|
92
142
|
|
93
143
|
|
@@ -1 +1 @@
|
|
1
|
-
{"mappings":"
|
1
|
+
{"mappings":"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","sources":["packages/@react-spectrum/color/src/ColorThumb.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} from '@react-spectrum/utils';\nimport {Color} from '@react-types/color';\nimport {DOMProps} from '@react-types/shared';\nimport {Overlay} from '@react-spectrum/overlays';\nimport React, {CSSProperties, ReactElement, RefObject, useRef, useState} from 'react';\nimport stylesHandle from '@adobe/spectrum-css-temp/components/colorhandle/vars.css';\nimport stylesLoupe from '@adobe/spectrum-css-temp/components/colorloupe/vars.css';\nimport {useId, useLayoutEffect} from '@react-aria/utils';\nimport {useProvider} from '@react-spectrum/provider';\n\ninterface ColorThumbProps extends DOMProps {\n value: Color,\n isDisabled?: boolean,\n isDragging?: boolean, // shows the color loupe\n isFocused?: boolean, // makes the circle larger\n className?: string,\n children?: ReactElement,\n style?: CSSProperties,\n containerRef?: RefObject<HTMLElement>\n}\n\nfunction ColorThumb(props: ColorThumbProps) {\n let {value, isDisabled, isDragging, isFocused, children, className = '', style, containerRef, ...otherProps} = props;\n\n let valueCSS = value.toString('css');\n let loupeRef = useRef<HTMLElement | null>(null);\n let provider = useProvider();\n\n return (\n <div className={classNames(stylesHandle, 'spectrum-ColorHandle', {'is-focused': isFocused, 'is-disabled': isDisabled}) + ' ' + className} style={style} {...otherProps}>\n <div className={classNames(stylesHandle, 'spectrum-ColorHandle-color')} style={{backgroundColor: valueCSS}} />\n <Overlay isOpen={isDragging && provider != null} nodeRef={loupeRef}>\n <ColorLoupe valueCSS={valueCSS} containerRef={containerRef} loupeRef={loupeRef} style={style} />\n </Overlay>\n {children}\n </div>\n );\n}\n\n// ColorLoupe is rendered in a portal so that it breaks out of clipped/scrolling containers (e.g. popovers).\nfunction ColorLoupe({isOpen, valueCSS, containerRef, loupeRef, style}: any) {\n let patternId = useId();\n\n // Get the bounding rectangle of the container (e.g. ColorArea/ColorSlider).\n let [containerRect, setContainerRect] = useState({top: 0, left: 0, width: 0, height: 0});\n useLayoutEffect(() => {\n let rect = containerRef.current?.getBoundingClientRect();\n setContainerRect({\n top: rect?.top || 0,\n left: rect?.left || 0,\n width: rect?.width || 0,\n height: rect?.height || 0\n });\n }, [containerRef]);\n\n // Compute the pixel position of the thumb.\n let thumbTop = style.top || '50%';\n if (typeof thumbTop === 'string' && thumbTop.endsWith('%')) {\n thumbTop = parseFloat(style.top || '50%') / 100 * containerRect.height;\n }\n\n let thumbLeft = style.left || '50%';\n if (typeof thumbLeft === 'string' && thumbLeft.endsWith('%')) {\n thumbLeft = parseFloat(thumbLeft || '50%') / 100 * containerRect.width;\n }\n\n return (\n <svg\n className={classNames(stylesLoupe, 'spectrum-ColorLoupe', {'is-open': isOpen})}\n style={{\n // Position relative to the viewport.\n position: 'fixed',\n top: containerRect.top + thumbTop,\n left: containerRect.left + thumbLeft\n }}\n ref={loupeRef}\n aria-hidden=\"true\">\n <pattern id={patternId} x=\"0\" y=\"0\" width=\"16\" height=\"16\" patternUnits=\"userSpaceOnUse\">\n <rect className={classNames(stylesLoupe, 'spectrum-ColorLoupe-inner-background')} x=\"0\" y=\"0\" width=\"16\" height=\"16\" />\n <rect className={classNames(stylesLoupe, 'spectrum-ColorLoupe-inner-checker')} x=\"0\" y=\"0\" width=\"8\" height=\"8\" />\n <rect className={classNames(stylesLoupe, 'spectrum-ColorLoupe-inner-checker')} x=\"8\" y=\"8\" width=\"8\" height=\"8\" />\n </pattern>\n <path\n className={classNames(stylesLoupe, 'spectrum-ColorLoupe-inner')}\n d=\"M25 1a24 24 0 0124 24c0 16.255-24 40-24 40S1 41.255 1 25A24 24 0 0125 1z\"\n fill={`url(#${patternId})`} />\n <path\n className={classNames(stylesLoupe, 'spectrum-ColorLoupe-inner')}\n d=\"M25 1a24 24 0 0124 24c0 16.255-24 40-24 40S1 41.255 1 25A24 24 0 0125 1z\"\n fill={valueCSS} />\n <path\n className={classNames(stylesLoupe, 'spectrum-ColorLoupe-outer')}\n d=\"M25 3A21.98 21.98 0 003 25c0 6.2 4 14.794 11.568 24.853A144.233 144.233 0 0025 62.132a144.085 144.085 0 0010.4-12.239C42.99 39.816 47 31.209 47 25A21.98 21.98 0 0025 3m0-2a24 24 0 0124 24c0 16.255-24 40-24 40S1 41.255 1 25A24 24 0 0125 1z\" />\n </svg>\n );\n}\n\nexport {ColorThumb};\n"],"names":[],"version":3,"file":"ColorThumb.main.js.map"}
|
package/dist/ColorThumb.mjs
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
import "./vars.
|
1
|
+
import "./vars.53b417c1.css";
|
2
2
|
import $1UQoL$colorhandle_vars_cssmodulejs from "./colorhandle_vars_css.mjs";
|
3
|
-
import "./vars.
|
3
|
+
import "./vars.cc682729.css";
|
4
4
|
import $1UQoL$colorloupe_vars_cssmodulejs from "./colorloupe_vars_css.mjs";
|
5
5
|
import {classNames as $1UQoL$classNames} from "@react-spectrum/utils";
|
6
|
-
import $1UQoL$
|
7
|
-
import {
|
6
|
+
import {Overlay as $1UQoL$Overlay} from "@react-spectrum/overlays";
|
7
|
+
import $1UQoL$react, {useRef as $1UQoL$useRef, useState as $1UQoL$useState} from "react";
|
8
|
+
import {useId as $1UQoL$useId, useLayoutEffect as $1UQoL$useLayoutEffect} from "@react-aria/utils";
|
9
|
+
import {useProvider as $1UQoL$useProvider} from "@react-spectrum/provider";
|
8
10
|
|
9
11
|
|
10
12
|
function $parcel$interopDefault(a) {
|
@@ -25,25 +27,73 @@ function $parcel$interopDefault(a) {
|
|
25
27
|
|
26
28
|
|
27
29
|
|
30
|
+
|
31
|
+
|
28
32
|
function $3a90e89d07d7bbd5$export$a3cc47cee1c1ccc(props) {
|
29
|
-
let { value: value, isDisabled: isDisabled, isDragging: isDragging, isFocused: isFocused, children: children, className: className = "", ...otherProps } = props;
|
30
|
-
let patternId = (0, $1UQoL$useId)();
|
33
|
+
let { value: value, isDisabled: isDisabled, isDragging: isDragging, isFocused: isFocused, children: children, className: className = "", style: style, containerRef: containerRef, ...otherProps } = props;
|
31
34
|
let valueCSS = value.toString("css");
|
35
|
+
let loupeRef = (0, $1UQoL$useRef)(null);
|
36
|
+
let provider = (0, $1UQoL$useProvider)();
|
32
37
|
return /*#__PURE__*/ (0, $1UQoL$react).createElement("div", {
|
33
38
|
className: (0, $1UQoL$classNames)((0, ($parcel$interopDefault($1UQoL$colorhandle_vars_cssmodulejs))), "spectrum-ColorHandle", {
|
34
39
|
"is-focused": isFocused,
|
35
40
|
"is-disabled": isDisabled
|
36
41
|
}) + " " + className,
|
42
|
+
style: style,
|
37
43
|
...otherProps
|
38
44
|
}, /*#__PURE__*/ (0, $1UQoL$react).createElement("div", {
|
39
45
|
className: (0, $1UQoL$classNames)((0, ($parcel$interopDefault($1UQoL$colorhandle_vars_cssmodulejs))), "spectrum-ColorHandle-color"),
|
40
46
|
style: {
|
41
47
|
backgroundColor: valueCSS
|
42
48
|
}
|
43
|
-
}), /*#__PURE__*/ (0, $1UQoL$react).createElement(
|
49
|
+
}), /*#__PURE__*/ (0, $1UQoL$react).createElement((0, $1UQoL$Overlay), {
|
50
|
+
isOpen: isDragging && provider != null,
|
51
|
+
nodeRef: loupeRef
|
52
|
+
}, /*#__PURE__*/ (0, $1UQoL$react).createElement($3a90e89d07d7bbd5$var$ColorLoupe, {
|
53
|
+
valueCSS: valueCSS,
|
54
|
+
containerRef: containerRef,
|
55
|
+
loupeRef: loupeRef,
|
56
|
+
style: style
|
57
|
+
})), children);
|
58
|
+
}
|
59
|
+
// ColorLoupe is rendered in a portal so that it breaks out of clipped/scrolling containers (e.g. popovers).
|
60
|
+
function $3a90e89d07d7bbd5$var$ColorLoupe({ isOpen: isOpen, valueCSS: valueCSS, containerRef: containerRef, loupeRef: loupeRef, style: style }) {
|
61
|
+
let patternId = (0, $1UQoL$useId)();
|
62
|
+
// Get the bounding rectangle of the container (e.g. ColorArea/ColorSlider).
|
63
|
+
let [containerRect, setContainerRect] = (0, $1UQoL$useState)({
|
64
|
+
top: 0,
|
65
|
+
left: 0,
|
66
|
+
width: 0,
|
67
|
+
height: 0
|
68
|
+
});
|
69
|
+
(0, $1UQoL$useLayoutEffect)(()=>{
|
70
|
+
var _containerRef_current;
|
71
|
+
let rect = (_containerRef_current = containerRef.current) === null || _containerRef_current === void 0 ? void 0 : _containerRef_current.getBoundingClientRect();
|
72
|
+
setContainerRect({
|
73
|
+
top: (rect === null || rect === void 0 ? void 0 : rect.top) || 0,
|
74
|
+
left: (rect === null || rect === void 0 ? void 0 : rect.left) || 0,
|
75
|
+
width: (rect === null || rect === void 0 ? void 0 : rect.width) || 0,
|
76
|
+
height: (rect === null || rect === void 0 ? void 0 : rect.height) || 0
|
77
|
+
});
|
78
|
+
}, [
|
79
|
+
containerRef
|
80
|
+
]);
|
81
|
+
// Compute the pixel position of the thumb.
|
82
|
+
let thumbTop = style.top || "50%";
|
83
|
+
if (typeof thumbTop === "string" && thumbTop.endsWith("%")) thumbTop = parseFloat(style.top || "50%") / 100 * containerRect.height;
|
84
|
+
let thumbLeft = style.left || "50%";
|
85
|
+
if (typeof thumbLeft === "string" && thumbLeft.endsWith("%")) thumbLeft = parseFloat(thumbLeft || "50%") / 100 * containerRect.width;
|
86
|
+
return /*#__PURE__*/ (0, $1UQoL$react).createElement("svg", {
|
44
87
|
className: (0, $1UQoL$classNames)((0, ($parcel$interopDefault($1UQoL$colorloupe_vars_cssmodulejs))), "spectrum-ColorLoupe", {
|
45
|
-
"is-open":
|
88
|
+
"is-open": isOpen
|
46
89
|
}),
|
90
|
+
style: {
|
91
|
+
// Position relative to the viewport.
|
92
|
+
position: "fixed",
|
93
|
+
top: containerRect.top + thumbTop,
|
94
|
+
left: containerRect.left + thumbLeft
|
95
|
+
},
|
96
|
+
ref: loupeRef,
|
47
97
|
"aria-hidden": "true"
|
48
98
|
}, /*#__PURE__*/ (0, $1UQoL$react).createElement("pattern", {
|
49
99
|
id: patternId,
|
@@ -81,7 +131,7 @@ function $3a90e89d07d7bbd5$export$a3cc47cee1c1ccc(props) {
|
|
81
131
|
}), /*#__PURE__*/ (0, $1UQoL$react).createElement("path", {
|
82
132
|
className: (0, $1UQoL$classNames)((0, ($parcel$interopDefault($1UQoL$colorloupe_vars_cssmodulejs))), "spectrum-ColorLoupe-outer"),
|
83
133
|
d: "M25 3A21.98 21.98 0 003 25c0 6.2 4 14.794 11.568 24.853A144.233 144.233 0 0025 62.132a144.085 144.085 0 0010.4-12.239C42.99 39.816 47 31.209 47 25A21.98 21.98 0 0025 3m0-2a24 24 0 0124 24c0 16.255-24 40-24 40S1 41.255 1 25A24 24 0 0125 1z"
|
84
|
-
}))
|
134
|
+
}));
|
85
135
|
}
|
86
136
|
|
87
137
|
|
@@ -1,10 +1,12 @@
|
|
1
|
-
import "./vars.
|
1
|
+
import "./vars.53b417c1.css";
|
2
2
|
import $1UQoL$colorhandle_vars_cssmodulejs from "./colorhandle_vars_css.module.js";
|
3
|
-
import "./vars.
|
3
|
+
import "./vars.cc682729.css";
|
4
4
|
import $1UQoL$colorloupe_vars_cssmodulejs from "./colorloupe_vars_css.module.js";
|
5
5
|
import {classNames as $1UQoL$classNames} from "@react-spectrum/utils";
|
6
|
-
import $1UQoL$
|
7
|
-
import {
|
6
|
+
import {Overlay as $1UQoL$Overlay} from "@react-spectrum/overlays";
|
7
|
+
import $1UQoL$react, {useRef as $1UQoL$useRef, useState as $1UQoL$useState} from "react";
|
8
|
+
import {useId as $1UQoL$useId, useLayoutEffect as $1UQoL$useLayoutEffect} from "@react-aria/utils";
|
9
|
+
import {useProvider as $1UQoL$useProvider} from "@react-spectrum/provider";
|
8
10
|
|
9
11
|
|
10
12
|
function $parcel$interopDefault(a) {
|
@@ -25,25 +27,73 @@ function $parcel$interopDefault(a) {
|
|
25
27
|
|
26
28
|
|
27
29
|
|
30
|
+
|
31
|
+
|
28
32
|
function $3a90e89d07d7bbd5$export$a3cc47cee1c1ccc(props) {
|
29
|
-
let { value: value, isDisabled: isDisabled, isDragging: isDragging, isFocused: isFocused, children: children, className: className = "", ...otherProps } = props;
|
30
|
-
let patternId = (0, $1UQoL$useId)();
|
33
|
+
let { value: value, isDisabled: isDisabled, isDragging: isDragging, isFocused: isFocused, children: children, className: className = "", style: style, containerRef: containerRef, ...otherProps } = props;
|
31
34
|
let valueCSS = value.toString("css");
|
35
|
+
let loupeRef = (0, $1UQoL$useRef)(null);
|
36
|
+
let provider = (0, $1UQoL$useProvider)();
|
32
37
|
return /*#__PURE__*/ (0, $1UQoL$react).createElement("div", {
|
33
38
|
className: (0, $1UQoL$classNames)((0, ($parcel$interopDefault($1UQoL$colorhandle_vars_cssmodulejs))), "spectrum-ColorHandle", {
|
34
39
|
"is-focused": isFocused,
|
35
40
|
"is-disabled": isDisabled
|
36
41
|
}) + " " + className,
|
42
|
+
style: style,
|
37
43
|
...otherProps
|
38
44
|
}, /*#__PURE__*/ (0, $1UQoL$react).createElement("div", {
|
39
45
|
className: (0, $1UQoL$classNames)((0, ($parcel$interopDefault($1UQoL$colorhandle_vars_cssmodulejs))), "spectrum-ColorHandle-color"),
|
40
46
|
style: {
|
41
47
|
backgroundColor: valueCSS
|
42
48
|
}
|
43
|
-
}), /*#__PURE__*/ (0, $1UQoL$react).createElement(
|
49
|
+
}), /*#__PURE__*/ (0, $1UQoL$react).createElement((0, $1UQoL$Overlay), {
|
50
|
+
isOpen: isDragging && provider != null,
|
51
|
+
nodeRef: loupeRef
|
52
|
+
}, /*#__PURE__*/ (0, $1UQoL$react).createElement($3a90e89d07d7bbd5$var$ColorLoupe, {
|
53
|
+
valueCSS: valueCSS,
|
54
|
+
containerRef: containerRef,
|
55
|
+
loupeRef: loupeRef,
|
56
|
+
style: style
|
57
|
+
})), children);
|
58
|
+
}
|
59
|
+
// ColorLoupe is rendered in a portal so that it breaks out of clipped/scrolling containers (e.g. popovers).
|
60
|
+
function $3a90e89d07d7bbd5$var$ColorLoupe({ isOpen: isOpen, valueCSS: valueCSS, containerRef: containerRef, loupeRef: loupeRef, style: style }) {
|
61
|
+
let patternId = (0, $1UQoL$useId)();
|
62
|
+
// Get the bounding rectangle of the container (e.g. ColorArea/ColorSlider).
|
63
|
+
let [containerRect, setContainerRect] = (0, $1UQoL$useState)({
|
64
|
+
top: 0,
|
65
|
+
left: 0,
|
66
|
+
width: 0,
|
67
|
+
height: 0
|
68
|
+
});
|
69
|
+
(0, $1UQoL$useLayoutEffect)(()=>{
|
70
|
+
var _containerRef_current;
|
71
|
+
let rect = (_containerRef_current = containerRef.current) === null || _containerRef_current === void 0 ? void 0 : _containerRef_current.getBoundingClientRect();
|
72
|
+
setContainerRect({
|
73
|
+
top: (rect === null || rect === void 0 ? void 0 : rect.top) || 0,
|
74
|
+
left: (rect === null || rect === void 0 ? void 0 : rect.left) || 0,
|
75
|
+
width: (rect === null || rect === void 0 ? void 0 : rect.width) || 0,
|
76
|
+
height: (rect === null || rect === void 0 ? void 0 : rect.height) || 0
|
77
|
+
});
|
78
|
+
}, [
|
79
|
+
containerRef
|
80
|
+
]);
|
81
|
+
// Compute the pixel position of the thumb.
|
82
|
+
let thumbTop = style.top || "50%";
|
83
|
+
if (typeof thumbTop === "string" && thumbTop.endsWith("%")) thumbTop = parseFloat(style.top || "50%") / 100 * containerRect.height;
|
84
|
+
let thumbLeft = style.left || "50%";
|
85
|
+
if (typeof thumbLeft === "string" && thumbLeft.endsWith("%")) thumbLeft = parseFloat(thumbLeft || "50%") / 100 * containerRect.width;
|
86
|
+
return /*#__PURE__*/ (0, $1UQoL$react).createElement("svg", {
|
44
87
|
className: (0, $1UQoL$classNames)((0, ($parcel$interopDefault($1UQoL$colorloupe_vars_cssmodulejs))), "spectrum-ColorLoupe", {
|
45
|
-
"is-open":
|
88
|
+
"is-open": isOpen
|
46
89
|
}),
|
90
|
+
style: {
|
91
|
+
// Position relative to the viewport.
|
92
|
+
position: "fixed",
|
93
|
+
top: containerRect.top + thumbTop,
|
94
|
+
left: containerRect.left + thumbLeft
|
95
|
+
},
|
96
|
+
ref: loupeRef,
|
47
97
|
"aria-hidden": "true"
|
48
98
|
}, /*#__PURE__*/ (0, $1UQoL$react).createElement("pattern", {
|
49
99
|
id: patternId,
|
@@ -81,7 +131,7 @@ function $3a90e89d07d7bbd5$export$a3cc47cee1c1ccc(props) {
|
|
81
131
|
}), /*#__PURE__*/ (0, $1UQoL$react).createElement("path", {
|
82
132
|
className: (0, $1UQoL$classNames)((0, ($parcel$interopDefault($1UQoL$colorloupe_vars_cssmodulejs))), "spectrum-ColorLoupe-outer"),
|
83
133
|
d: "M25 3A21.98 21.98 0 003 25c0 6.2 4 14.794 11.568 24.853A144.233 144.233 0 0025 62.132a144.085 144.085 0 0010.4-12.239C42.99 39.816 47 31.209 47 25A21.98 21.98 0 0025 3m0-2a24 24 0 0124 24c0 16.255-24 40-24 40S1 41.255 1 25A24 24 0 0125 1z"
|
84
|
-
}))
|
134
|
+
}));
|
85
135
|
}
|
86
136
|
|
87
137
|
|
@@ -1 +1 @@
|
|
1
|
-
{"mappings":"
|
1
|
+
{"mappings":"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","sources":["packages/@react-spectrum/color/src/ColorThumb.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} from '@react-spectrum/utils';\nimport {Color} from '@react-types/color';\nimport {DOMProps} from '@react-types/shared';\nimport {Overlay} from '@react-spectrum/overlays';\nimport React, {CSSProperties, ReactElement, RefObject, useRef, useState} from 'react';\nimport stylesHandle from '@adobe/spectrum-css-temp/components/colorhandle/vars.css';\nimport stylesLoupe from '@adobe/spectrum-css-temp/components/colorloupe/vars.css';\nimport {useId, useLayoutEffect} from '@react-aria/utils';\nimport {useProvider} from '@react-spectrum/provider';\n\ninterface ColorThumbProps extends DOMProps {\n value: Color,\n isDisabled?: boolean,\n isDragging?: boolean, // shows the color loupe\n isFocused?: boolean, // makes the circle larger\n className?: string,\n children?: ReactElement,\n style?: CSSProperties,\n containerRef?: RefObject<HTMLElement>\n}\n\nfunction ColorThumb(props: ColorThumbProps) {\n let {value, isDisabled, isDragging, isFocused, children, className = '', style, containerRef, ...otherProps} = props;\n\n let valueCSS = value.toString('css');\n let loupeRef = useRef<HTMLElement | null>(null);\n let provider = useProvider();\n\n return (\n <div className={classNames(stylesHandle, 'spectrum-ColorHandle', {'is-focused': isFocused, 'is-disabled': isDisabled}) + ' ' + className} style={style} {...otherProps}>\n <div className={classNames(stylesHandle, 'spectrum-ColorHandle-color')} style={{backgroundColor: valueCSS}} />\n <Overlay isOpen={isDragging && provider != null} nodeRef={loupeRef}>\n <ColorLoupe valueCSS={valueCSS} containerRef={containerRef} loupeRef={loupeRef} style={style} />\n </Overlay>\n {children}\n </div>\n );\n}\n\n// ColorLoupe is rendered in a portal so that it breaks out of clipped/scrolling containers (e.g. popovers).\nfunction ColorLoupe({isOpen, valueCSS, containerRef, loupeRef, style}: any) {\n let patternId = useId();\n\n // Get the bounding rectangle of the container (e.g. ColorArea/ColorSlider).\n let [containerRect, setContainerRect] = useState({top: 0, left: 0, width: 0, height: 0});\n useLayoutEffect(() => {\n let rect = containerRef.current?.getBoundingClientRect();\n setContainerRect({\n top: rect?.top || 0,\n left: rect?.left || 0,\n width: rect?.width || 0,\n height: rect?.height || 0\n });\n }, [containerRef]);\n\n // Compute the pixel position of the thumb.\n let thumbTop = style.top || '50%';\n if (typeof thumbTop === 'string' && thumbTop.endsWith('%')) {\n thumbTop = parseFloat(style.top || '50%') / 100 * containerRect.height;\n }\n\n let thumbLeft = style.left || '50%';\n if (typeof thumbLeft === 'string' && thumbLeft.endsWith('%')) {\n thumbLeft = parseFloat(thumbLeft || '50%') / 100 * containerRect.width;\n }\n\n return (\n <svg\n className={classNames(stylesLoupe, 'spectrum-ColorLoupe', {'is-open': isOpen})}\n style={{\n // Position relative to the viewport.\n position: 'fixed',\n top: containerRect.top + thumbTop,\n left: containerRect.left + thumbLeft\n }}\n ref={loupeRef}\n aria-hidden=\"true\">\n <pattern id={patternId} x=\"0\" y=\"0\" width=\"16\" height=\"16\" patternUnits=\"userSpaceOnUse\">\n <rect className={classNames(stylesLoupe, 'spectrum-ColorLoupe-inner-background')} x=\"0\" y=\"0\" width=\"16\" height=\"16\" />\n <rect className={classNames(stylesLoupe, 'spectrum-ColorLoupe-inner-checker')} x=\"0\" y=\"0\" width=\"8\" height=\"8\" />\n <rect className={classNames(stylesLoupe, 'spectrum-ColorLoupe-inner-checker')} x=\"8\" y=\"8\" width=\"8\" height=\"8\" />\n </pattern>\n <path\n className={classNames(stylesLoupe, 'spectrum-ColorLoupe-inner')}\n d=\"M25 1a24 24 0 0124 24c0 16.255-24 40-24 40S1 41.255 1 25A24 24 0 0125 1z\"\n fill={`url(#${patternId})`} />\n <path\n className={classNames(stylesLoupe, 'spectrum-ColorLoupe-inner')}\n d=\"M25 1a24 24 0 0124 24c0 16.255-24 40-24 40S1 41.255 1 25A24 24 0 0125 1z\"\n fill={valueCSS} />\n <path\n className={classNames(stylesLoupe, 'spectrum-ColorLoupe-outer')}\n d=\"M25 3A21.98 21.98 0 003 25c0 6.2 4 14.794 11.568 24.853A144.233 144.233 0 0025 62.132a144.085 144.085 0 0010.4-12.239C42.99 39.816 47 31.209 47 25A21.98 21.98 0 0025 3m0-2a24 24 0 0124 24c0 16.255-24 40-24 40S1 41.255 1 25A24 24 0 0125 1z\" />\n </svg>\n );\n}\n\nexport {ColorThumb};\n"],"names":[],"version":3,"file":"ColorThumb.module.js.map"}
|
package/dist/ColorWheel.main.js
CHANGED
@@ -2,6 +2,7 @@ var $2b9adc23f6c7cae1$exports = require("./ColorThumb.main.js");
|
|
2
2
|
require("./vars.ac235018.css");
|
3
3
|
var $8fc6b1a2f4e7f682$exports = require("./colorwheel_vars_css.main.js");
|
4
4
|
var $gEgjt$reactspectrumutils = require("@react-spectrum/utils");
|
5
|
+
var $gEgjt$reactariacomponents = require("react-aria-components");
|
5
6
|
var $gEgjt$react = require("react");
|
6
7
|
var $gEgjt$reactariacolor = require("@react-aria/color");
|
7
8
|
var $gEgjt$reactstatelycolor = require("@react-stately/color");
|
@@ -38,14 +39,16 @@ $parcel$export(module.exports, "ColorWheel", () => $63a2864687444ae1$export$f806
|
|
38
39
|
|
39
40
|
|
40
41
|
|
42
|
+
|
41
43
|
const $63a2864687444ae1$var$WHEEL_THICKNESS = 24;
|
42
44
|
function $63a2864687444ae1$var$ColorWheel(props, ref) {
|
43
45
|
props = (0, $gEgjt$reactspectrumprovider.useProviderProps)(props);
|
46
|
+
let inputRef = (0, $gEgjt$react.useRef)(null);
|
47
|
+
let containerRef = (0, $gEgjt$reactspectrumutils.useFocusableRef)(ref, inputRef);
|
48
|
+
[props, containerRef] = (0, $gEgjt$reactariacomponents.useContextProps)(props, containerRef, (0, $gEgjt$reactariacomponents.ColorWheelContext));
|
44
49
|
let { isDisabled: isDisabled } = props;
|
45
50
|
let size = props.size && (0, $gEgjt$reactspectrumutils.dimensionValue)(props.size);
|
46
51
|
let { styleProps: styleProps } = (0, $gEgjt$reactspectrumutils.useStyleProps)(props);
|
47
|
-
let inputRef = (0, $gEgjt$react.useRef)(null);
|
48
|
-
let containerRef = (0, $gEgjt$reactspectrumutils.useFocusableRef)(ref, inputRef);
|
49
52
|
let [wheelRadius, setWheelRadius] = (0, $gEgjt$react.useState)(0);
|
50
53
|
let [wheelThickness, setWheelThickness] = (0, $gEgjt$react.useState)($63a2864687444ae1$var$WHEEL_THICKNESS);
|
51
54
|
let resizeHandler = (0, $gEgjt$react.useCallback)(()=>{
|
@@ -97,6 +100,7 @@ function $63a2864687444ae1$var$ColorWheel(props, ref) {
|
|
97
100
|
isFocused: isFocusVisible,
|
98
101
|
isDisabled: isDisabled,
|
99
102
|
isDragging: state.isDragging,
|
103
|
+
containerRef: containerRef,
|
100
104
|
className: (0, $gEgjt$reactspectrumutils.classNames)((0, ($parcel$interopDefault($8fc6b1a2f4e7f682$exports))), "spectrum-ColorWheel-handle"),
|
101
105
|
...thumbProps
|
102
106
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($gEgjt$react))).createElement("input", {
|
@@ -1 +1 @@
|
|
1
|
-
{"mappings":"
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AAeD,MAAM,wCAAkB;AAExB,SAAS,iCAAW,KAA8B,EAAE,GAAiC;IACnF,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,cAAc,CAAA,GAAA,4CAAgB;IAE7E,IAAI,cAAC,UAAU,EAAC,GAAG;IACnB,IAAI,OAAO,MAAM,IAAI,IAAI,CAAA,GAAA,wCAAa,EAAE,MAAM,IAAI;IAClD,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,uCAAY,EAAE;IAGjC,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,qBAAO,EAAU;IACrD,IAAI,CAAC,gBAAgB,kBAAkB,GAAG,CAAA,GAAA,qBAAO,EAAE;IAEnD,IAAI,gBAAgB,CAAA,GAAA,wBAAU,EAAE;QAC9B,IAAI,aAAa,OAAO,EAAE;YACxB,eAAe,aAAa,OAAO,CAAC,WAAW,GAAG;YAClD,IAAI,YAAY,OAAO,gBAAgB,CAAC,aAAa,OAAO,EACzD,gBAAgB,CAAC;YACpB,IAAI,WACF,kBAAkB,SAAS,WAAW;QAE1C;IACF,GAAG;QAAC;QAAc;QAAgB;KAAkB;IAEpD,CAAA,GAAA,sBAAQ,EAAE;QACR,gFAAgF;QAChF,IAAI,gBAAgB,GAClB;IAEJ,GAAG;QAAC;QAAa;KAAc;IAE/B,CAAA,GAAA,uCAAgB,EAAE;QAChB,KAAK;QACL,UAAU;IACZ;IAEA,IAAI,QAAQ,CAAA,GAAA,2CAAiB,EAAE;IAE/B,IAAI,cAAC,UAAU,cAAE,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,mCAAY,EAAE;QACvD,GAAG,KAAK;QACR,aAAa,cAAc;QAC3B,aAAa;IACf,GAAG,OAAO;IAEV,IAAI,cAAC,UAAU,kBAAE,cAAc,EAAC,GAAG,CAAA,GAAA,kCAAW;IAE9C,qBACE,0DAAC;QACC,WACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,mDAAK,GACL,uBACA;YACE,eAAe;QACjB,GACA,WAAW,SAAS;QAGxB,KAAK;QACL,OAAO;YACL,GAAG,WAAW,KAAK;YACnB,sEAAsE;YACtE,aAAa;YACb,SAAS;YACT,UAAU;QACZ;qBACA,0DAAC;QAAK,GAAG,UAAU;QAAE,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;sBACnD,0DAAC,CAAA,GAAA,oCAAS;QACR,OAAO,MAAM,eAAe;QAC5B,WAAW;QACX,YAAY;QACZ,YAAY,MAAM,UAAU;QAC5B,cAAc;QACd,WAAW,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;AAEA;;CAEC,GACD,IAAI,0DAAc,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","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, useEffect, 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 {useProviderProps} from '@react-spectrum/provider';\nimport {useResizeObserver} from '@react-aria/utils';\n\nconst WHEEL_THICKNESS = 24;\n\nfunction 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 useEffect(() => {\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 // @ts-ignore\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\n/**\n * ColorWheels allow users to adjust the hue of an HSL or HSB color value on a circular track.\n */\nlet _ColorWheel = React.forwardRef(ColorWheel);\nexport {_ColorWheel as ColorWheel};\n"],"names":[],"version":3,"file":"ColorWheel.main.js.map"}
|
package/dist/ColorWheel.mjs
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
import {ColorThumb as $3a90e89d07d7bbd5$export$a3cc47cee1c1ccc} from "./ColorThumb.mjs";
|
2
2
|
import "./vars.ac235018.css";
|
3
3
|
import $bv4AR$colorwheel_vars_cssmodulejs from "./colorwheel_vars_css.mjs";
|
4
|
-
import {
|
4
|
+
import {useFocusableRef as $bv4AR$useFocusableRef, dimensionValue as $bv4AR$dimensionValue, useStyleProps as $bv4AR$useStyleProps, classNames as $bv4AR$classNames} from "@react-spectrum/utils";
|
5
|
+
import {useContextProps as $bv4AR$useContextProps, ColorWheelContext as $bv4AR$ColorWheelContext} from "react-aria-components";
|
5
6
|
import $bv4AR$react, {useRef as $bv4AR$useRef, useState as $bv4AR$useState, useCallback as $bv4AR$useCallback, useEffect as $bv4AR$useEffect} from "react";
|
6
7
|
import {useColorWheel as $bv4AR$useColorWheel} from "@react-aria/color";
|
7
8
|
import {useColorWheelState as $bv4AR$useColorWheelState} from "@react-stately/color";
|
@@ -32,14 +33,16 @@ function $parcel$interopDefault(a) {
|
|
32
33
|
|
33
34
|
|
34
35
|
|
36
|
+
|
35
37
|
const $3aac1c27203f04b5$var$WHEEL_THICKNESS = 24;
|
36
38
|
function $3aac1c27203f04b5$var$ColorWheel(props, ref) {
|
37
39
|
props = (0, $bv4AR$useProviderProps)(props);
|
40
|
+
let inputRef = (0, $bv4AR$useRef)(null);
|
41
|
+
let containerRef = (0, $bv4AR$useFocusableRef)(ref, inputRef);
|
42
|
+
[props, containerRef] = (0, $bv4AR$useContextProps)(props, containerRef, (0, $bv4AR$ColorWheelContext));
|
38
43
|
let { isDisabled: isDisabled } = props;
|
39
44
|
let size = props.size && (0, $bv4AR$dimensionValue)(props.size);
|
40
45
|
let { styleProps: styleProps } = (0, $bv4AR$useStyleProps)(props);
|
41
|
-
let inputRef = (0, $bv4AR$useRef)(null);
|
42
|
-
let containerRef = (0, $bv4AR$useFocusableRef)(ref, inputRef);
|
43
46
|
let [wheelRadius, setWheelRadius] = (0, $bv4AR$useState)(0);
|
44
47
|
let [wheelThickness, setWheelThickness] = (0, $bv4AR$useState)($3aac1c27203f04b5$var$WHEEL_THICKNESS);
|
45
48
|
let resizeHandler = (0, $bv4AR$useCallback)(()=>{
|
@@ -91,6 +94,7 @@ function $3aac1c27203f04b5$var$ColorWheel(props, ref) {
|
|
91
94
|
isFocused: isFocusVisible,
|
92
95
|
isDisabled: isDisabled,
|
93
96
|
isDragging: state.isDragging,
|
97
|
+
containerRef: containerRef,
|
94
98
|
className: (0, $bv4AR$classNames)((0, ($parcel$interopDefault($bv4AR$colorwheel_vars_cssmodulejs))), "spectrum-ColorWheel-handle"),
|
95
99
|
...thumbProps
|
96
100
|
}, /*#__PURE__*/ (0, $bv4AR$react).createElement("input", {
|