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xC;wBACF;;;;;AAIV","sources":["packages/@react-spectrum/s2/src/ColorWheel.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 {\n ColorWheel as AriaColorWheel,\n ColorWheelProps as AriaColorWheelProps,\n ColorWheelTrack,\n ContextValue\n} from 'react-aria-components';\nimport {ColorHandle} from './ColorHandle';\nimport {createContext, forwardRef} from 'react';\nimport {DOMRef, DOMRefValue} from '@react-types/shared';\nimport {style} from '../style' with {type: 'macro'};\nimport {StyleProps} from './style-utils';\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface ColorWheelProps extends Omit<AriaColorWheelProps, 'children' | 'className' | 'style' | 'outerRadius' | 'innerRadius'>, StyleProps {\n /**\n * @default 192\n */\n size?: number\n}\n\nexport const ColorWheelContext = createContext<ContextValue<Partial<ColorWheelProps>, DOMRefValue<HTMLDivElement>>>(null);\n\n/**\n * A ColorWheel allows users to adjust the hue of an HSL or HSB color value on a circular track.\n */\nexport const ColorWheel = forwardRef(function ColorWheel(props: ColorWheelProps, ref: DOMRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ColorWheelContext);\n let {UNSAFE_className = '', UNSAFE_style, styles = ''} = props;\n let containerRef = useDOMRef(ref);\n // TODO: how to do mobile scaling?\n let {size = 192} = props;\n let outerRadius = Math.max(size, 175) / 2;\n let thickness = 24;\n let innerRadius = outerRadius - 24;\n return (\n <AriaColorWheel \n {...props}\n outerRadius={outerRadius}\n innerRadius={innerRadius}\n ref={containerRef}\n style={UNSAFE_style}\n className={UNSAFE_className + styles}>\n {({isDisabled, state}) => (<>\n <ColorWheelTrack\n style={({defaultStyle, isDisabled}) => ({\n background: isDisabled ? undefined : defaultStyle.background\n })}\n className={style({\n // Outer border\n borderRadius: 'full',\n outlineColor: {\n default: 'gray-1000/10',\n forcedColors: 'ButtonBorder'\n },\n outlineWidth: 1,\n outlineOffset: -1,\n outlineStyle: {\n default: 'solid',\n isDisabled: 'none'\n },\n backgroundColor: {\n isDisabled: 'disabled'\n }\n })} />\n <div\n className={style({\n // Inner border\n position: 'absolute',\n inset: 24,\n pointerEvents: 'none',\n borderRadius: 'full',\n outlineColor: {\n default: 'gray-1000/10',\n forcedColors: 'ButtonBorder'\n },\n outlineWidth: 1,\n outlineStyle: {\n default: 'solid',\n isDisabled: 'none'\n }\n })({isDisabled})} />\n <ColorHandle\n containerRef={containerRef}\n getPosition={() => {\n let {x, y} = state.getThumbPosition(outerRadius - thickness / 2);\n return {\n x: (outerRadius + x) / (outerRadius * 2),\n y: (outerRadius + y) / (outerRadius * 2)\n };\n }} />\n </>)}\n </AriaColorWheel>\n );\n});\n"],"names":[],"version":3,"file":"ColorWheel.cjs.map"}