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AAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;QAEpC,MAAM,IAAI,kBACT,0DAAC;QACC,MAAK;QACL,MAAM,MAAM,IAAI;QAChB,MAAM,MAAM,IAAI;QAChB,OAAO,MAAM,MAAM,WAAW,IAAI,KAAK,MAAM,WAAW;;AAKlE;AAMA,SAAS,oCAAc,KAAyB;IAC9C,IAAI,SACF,qDAAqD;IACrD,KAAK,gBACL,YAAY,YACZ,QAAQ,gBACR,YAAY,EACZ,GAAG,YACJ,GAAG;IACJ,IAAI,QAAQ,CAAA,GAAA,wDAAiB,EAAE;IAC/B,IAAI,WAAW,CAAA,GAAA,mBAAK,EAA0C;IAC9D,IAAI,SAAS,CAAA,GAAA,2CAAY,EAAE,YAAY,OAAO;IAE9C,qBACE,0DAAC,CAAA,GAAA,uCAAY;QACV,GAAG,UAAU;QACd,KAAK;QACL,UAAU;QACT,GAAG,MAAM;QACV,gBAAgB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;;AAGzC","sources":["packages/@adobe/react-spectrum/src/color/ColorField.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 {AriaColorFieldProps, useColorChannelField, useColorField} from 'react-aria/useColorField';\n\nimport {classNames} from '../utils/classNames';\nimport {Color, ColorChannel, ColorSpace} from 'react-stately/Color';\nimport {ColorFieldContext} from 'react-aria-components/ColorField';\nimport React, {Ref, useEffect, useRef} from 'react';\nimport {\n  SpectrumFieldValidation,\n  SpectrumLabelableProps,\n  SpectrumTextInputBase,\n  StyleProps\n} from '@react-types/shared';\nimport styles from './colorfield.css';\nimport {TextFieldBase} from '../textfield/TextFieldBase';\nimport {TextFieldRef} from '../textfield/TextField';\nimport {useColorChannelFieldState, useColorFieldState} from 'react-stately/useColorFieldState';\nimport {useContextProps} from 'react-aria-components/slots';\nimport {useFormProps} from '../form/Form';\nimport {useLocale} from 'react-aria/I18nProvider';\nimport {useProviderProps} from '../provider/Provider';\n\nexport interface SpectrumColorFieldProps\n  extends\n    SpectrumTextInputBase,\n    Omit<AriaColorFieldProps, 'isInvalid' | 'validationState'>,\n    SpectrumFieldValidation<Color | null>,\n    SpectrumLabelableProps,\n    StyleProps {\n  /**\n   * The color channel that this field edits. If not provided,\n   * the color is edited as a hex value.\n   */\n  channel?: ColorChannel;\n  /**\n   * The color space that the color field operates in if a `channel` prop is provided.\n   * If no `channel` is provided, the color field always displays the color as an RGB hex value.\n   */\n  colorSpace?: ColorSpace;\n  /** Whether the ColorField should be displayed with a quiet style. */\n  isQuiet?: boolean;\n}\n\n/**\n * A color field allows users to edit a hex color or individual color channel value.\n */\nexport const ColorField = React.forwardRef(function ColorField(\n  props: SpectrumColorFieldProps,\n  ref: Ref<TextFieldRef>\n) {\n  props = useProviderProps(props);\n  props = useFormProps(props);\n  [props] = useContextProps(props, null, ColorFieldContext);\n\n  let hasWarned = useRef(false);\n  useEffect(() => {\n    if (props.placeholder && !hasWarned.current && process.env.NODE_ENV !== 'production') {\n      console.warn(\n        'Placeholders are deprecated due to accessibility issues. Please use help text instead. See the docs for details: https://react-spectrum.adobe.com/react-spectrum/ColorField.html#help-text'\n      );\n      hasWarned.current = true;\n    }\n  }, [props.placeholder]);\n\n  if (props.channel) {\n    return <ColorChannelField {...props} channel={props.channel} forwardedRef={ref} />;\n  } else {\n    return <HexColorField {...props} forwardedRef={ref} />;\n  }\n});\n\ninterface ColorChannelFieldProps extends Omit<SpectrumColorFieldProps, 'channel'> {\n  channel: ColorChannel;\n  forwardedRef: Ref<TextFieldRef>;\n}\n\nfunction ColorChannelField(props: ColorChannelFieldProps) {\n  let {\n    // These disabled props are handled by the state hook\n    value, // eslint-disable-line @typescript-eslint/no-unused-vars\n    defaultValue, // eslint-disable-line @typescript-eslint/no-unused-vars\n    onChange, // eslint-disable-line @typescript-eslint/no-unused-vars\n    validate, // eslint-disable-line @typescript-eslint/no-unused-vars\n    forwardedRef,\n    ...otherProps\n  } = props;\n  let {locale} = useLocale();\n  let state = useColorChannelFieldState({\n    ...props,\n    locale\n  });\n\n  let inputRef = useRef<HTMLInputElement & HTMLTextAreaElement>(null);\n  let result = useColorChannelField(otherProps, state, inputRef);\n\n  return (\n    <>\n      <TextFieldBase\n        {...otherProps}\n        ref={forwardedRef}\n        inputRef={inputRef}\n        {...result}\n        inputClassName={classNames(styles, 'react-spectrum-ColorField-input')}\n      />\n      {props.name && (\n        <input\n          type=\"hidden\"\n          name={props.name}\n          form={props.form}\n          value={isNaN(state.numberValue) ? '' : state.numberValue}\n        />\n      )}\n    </>\n  );\n}\n\ninterface HexColorFieldProps extends SpectrumColorFieldProps {\n  forwardedRef: Ref<TextFieldRef>;\n}\n\nfunction HexColorField(props: HexColorFieldProps) {\n  let {\n    // These disabled props are handled by the state hook\n    value, // eslint-disable-line @typescript-eslint/no-unused-vars\n    defaultValue, // eslint-disable-line @typescript-eslint/no-unused-vars\n    onChange, // eslint-disable-line @typescript-eslint/no-unused-vars\n    forwardedRef,\n    ...otherProps\n  } = props;\n  let state = useColorFieldState(props);\n  let inputRef = useRef<HTMLInputElement & HTMLTextAreaElement>(null);\n  let result = useColorField(otherProps, state, inputRef);\n\n  return (\n    <TextFieldBase\n      {...otherProps}\n      ref={forwardedRef}\n      inputRef={inputRef}\n      {...result}\n      inputClassName={classNames(styles, 'react-spectrum-ColorField-input')}\n    />\n  );\n}\n"],"names":[],"version":3,"file":"ColorField.cjs.map"}