@react-spectrum/s2
Version:
Spectrum 2 UI components in React
1 lines • 3.79 kB
Source Map (JSON)
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAiBM,MAAM,0DAAmB,CAAA,GAAA,0BAAY,EAAsE;AAK3G,MAAM,0DAAY,CAAA,GAAA,uBAAS,EAAE,SAAS,UAAU,KAAqB,EAAE,GAA2B;IACvG,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,iDAAsB,EAAE,OAAO,KAAK;IACnD,IAAI,oBAAC,mBAAmB,kBAAI,YAAY,UAAE,MAAM,EAAC,GAAG;IACpD,IAAI,eAAe,CAAA,GAAA,mCAAQ,EAAE;IAC7B,qBACE,gCAAC,CAAA,GAAA,oCAAY;QACV,GAAG,KAAK;QACT,KAAK;QACL,OAAO,CAAC,gBAAC,YAAY,cAAE,UAAU,EAAC,GAAM,CAAA;gBACtC,GAAG,YAAY;gBACf,YAAY,aAAa,YAAY,aAAa,UAAU;gBAC5D,kEAAkE;gBAClE,UAAU;gBACV,GAAG,YAAY;YACjB,CAAA;QACA,WAAW,CAAA,cAAe,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkBL,aAAa;kBACpD,CAAC,SAAC,KAAK,EAAC,iBACN,gCAAC,CAAA,GAAA,qCAAU;gBACV,cAAc;gBACd,aAAa,IAAM,MAAM,gBAAgB;;;AAInD","sources":["packages/@react-spectrum/s2/src/ColorArea.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 ColorArea as AriaColorArea,\n ColorAreaProps as AriaColorAreaProps,\n ContextValue\n} from 'react-aria-components';\nimport {ColorHandle} from './ColorHandle';\nimport {createContext, forwardRef} from 'react';\nimport {DOMRef, DOMRefValue} from '@react-types/shared';\nimport {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {style} from '../style' with {type: 'macro'};\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface ColorAreaProps extends Omit<AriaColorAreaProps, 'children' | 'className' | 'style'>, StyleProps {}\n\nexport const ColorAreaContext = createContext<ContextValue<Partial<ColorAreaProps>, DOMRefValue<HTMLDivElement>>>(null);\n\n/**\n * A ColorArea allows users to adjust two channels of an RGB, HSL or HSB color value against a two-dimensional gradient background.\n */\nexport const ColorArea = forwardRef(function ColorArea(props: ColorAreaProps, ref: DOMRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ColorAreaContext);\n let {UNSAFE_className = '', UNSAFE_style, styles} = props;\n let containerRef = useDOMRef(ref);\n return (\n <AriaColorArea\n {...props}\n ref={containerRef}\n style={({defaultStyle, isDisabled}) => ({\n ...defaultStyle,\n background: isDisabled ? undefined : defaultStyle.background,\n // Move position: relative to style macro so it can be overridden.\n position: undefined,\n ...UNSAFE_style\n })}\n className={renderProps => UNSAFE_className + style({\n position: 'relative',\n size: 192,\n minSize: 64,\n borderRadius: 'default',\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 }, getAllowedOverrides({height: true}))(renderProps, styles)}>\n {({state}) =>\n (<ColorHandle\n containerRef={containerRef}\n getPosition={() => state.getThumbPosition()} />)\n }\n </AriaColorArea>\n );\n});\n"],"names":[],"version":3,"file":"ColorArea.cjs.map"}