{"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAuCM,MAAM,0DAA6B,CAAA,GAAA,0BAAY,EACpD;AAMK,MAAM,0DAAc,CAAA,GAAA,uBAAS,EAAE,SAAS,YAC7C,KAA+B,EAC/B,GAA2B;IAE3B,IAAI,SAAS,CAAA,GAAA,mCAAQ,EAAE;IACvB,CAAC,OAAO,OAAO,GAAG,CAAA,GAAA,+CAAc,EAAE,OAAO,QAAQ,CAAA,GAAA,wDAAiB;IAClE,IAAI,oBAAC,gBAAgB,SAAE,KAAK,EAAC,GAAG,CAAA,GAAA,6CAAa,EAAE;IAC/C,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,uCAAY,EAAE;IACjC,IAAI,MAAM,CAAA,GAAA,uBAAS,EAAE;IACrB,IAAI,QAAC,OAAO,KAAK,QAAQ,eAAK,WAAW,KAAK,YAAY,WAAU,GAAG;IAEvE,IAAI,uBACF,0DAAC;QACE,GAAG,gBAAgB;QACnB,GAAG,UAAU;QACd,KAAK;QACL,OAAO;YACL,GAAG,WAAW,KAAK;YACnB,oFAAoF;YACpF,YACE,MAAM,eAAe,CAAC,WAAW,IAC7B,CAAC,gBAAgB,EAAE,MAAM,EAAE,EAAE,MAAM,4EAA4E,CAAC,GAEhH;QACR;QACA,WACE,WAAW,SAAS,GACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAuBG;kBAAC;sBAAM;QAAQ;;IAKxB,+DAA+D;IAC/D,IAAI,KACF,OAAO,IAAI,UAAU,CAAC,QAAQ,OAAO;IAGvC,OAAO;AACT","sources":["packages/@adobe/react-spectrum/src/color/ColorSwatch.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 {AriaColorSwatchProps, useColorSwatch} from 'react-aria/useColorSwatch';\n\nimport {Color} from 'react-stately/Color';\nimport {ColorSwatchContext} from 'react-aria-components/ColorSwatch';\nimport {DOMRef, StyleProps} from '@react-types/shared';\nimport React, {createContext, forwardRef, JSX, ReactElement, useContext} from 'react';\nimport {style} from '@react-spectrum/style-macro-s1' with {type: 'macro'};\nimport {useContextProps} from 'react-aria-components/slots';\nimport {useDOMRef} from '../utils/useDOMRef';\nimport {useStyleProps} from '../utils/styleProps';\n\nexport interface SpectrumColorSwatchProps extends AriaColorSwatchProps, StyleProps {\n  /**\n   * The size of the ColorSwatch.\n   *\n   * @default 'M'\n   */\n  size?: 'XS' | 'S' | 'M' | 'L';\n  /**\n   * The corner rounding of the ColorSwatch.\n   *\n   * @default 'default'\n   */\n  rounding?: 'default' | 'none' | 'full';\n}\n\ninterface SpectrumColorSwatchContextValue extends Pick<\n  SpectrumColorSwatchProps,\n  'size' | 'rounding'\n> {\n  useWrapper: (\n    swatch: ReactElement,\n    color: Color,\n    rounding: SpectrumColorSwatchProps['rounding']\n  ) => JSX.Element;\n}\n\nexport const SpectrumColorSwatchContext = createContext<SpectrumColorSwatchContextValue | null>(\n  null\n);\n\n/**\n * A ColorSwatch displays a preview of a selected color.\n */\nexport const ColorSwatch = forwardRef(function ColorSwatch(\n  props: SpectrumColorSwatchProps,\n  ref: DOMRef<HTMLDivElement>\n): JSX.Element {\n  let domRef = useDOMRef(ref);\n  [props, domRef] = useContextProps(props, domRef, ColorSwatchContext);\n  let {colorSwatchProps, color} = useColorSwatch(props);\n  let {styleProps} = useStyleProps(props);\n  let ctx = useContext(SpectrumColorSwatchContext);\n  let {size = ctx?.size || 'M', rounding = ctx?.rounding || 'default'} = props;\n\n  let swatch = (\n    <div\n      {...colorSwatchProps}\n      {...styleProps}\n      ref={domRef}\n      style={{\n        ...styleProps.style,\n        // TODO: should there be a distinction between transparent and no value (e.g. null)?\n        background:\n          color.getChannelValue('alpha') > 0\n            ? `linear-gradient(${color}, ${color}), repeating-conic-gradient(#e6e6e6 0% 25%, white 0% 50%) 0% 50% / 16px 16px`\n            : // Red slash to indicate there is no selected color.\n              'linear-gradient(to bottom right, transparent calc(50% - 2px), var(--spectrum-red-900) calc(50% - 2px) calc(50% + 2px), transparent calc(50% + 2px)) no-repeat'\n      }}\n      className={\n        styleProps.className +\n        style({\n          size: {\n            size: {\n              XS: 4,\n              S: 6,\n              M: 8,\n              L: 10\n            }\n          },\n          borderRadius: {\n            rounding: {\n              default: 'default',\n              none: 'none',\n              full: 'full'\n            }\n          },\n          // Trick to create a partially transparent color from a variable.\n          // Ideally we'd use relative color syntax for this but it's not in Firefox yet.\n          borderColor: '[color-mix(in srgb, var(--spectrum-gray-900), transparent 49%)]',\n          borderWidth: 1,\n          borderStyle: 'solid',\n          boxSizing: 'border-box',\n          forcedColorAdjust: 'none'\n        })({size, rounding})\n      }\n    />\n  );\n\n  // ColorSwatchPicker needs to wrap the swatch in a ListBoxItem.\n  if (ctx) {\n    return ctx.useWrapper(swatch, color, rounding);\n  }\n\n  return swatch;\n});\n"],"names":[],"version":3,"file":"ColorSwatch.cjs.map"}