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G,UAAU;oBAAE,KAAK;gBAAQ;aAAE;YAC9C;gBAAC,CAAA,GAAA,yCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAQ;aAAE;YAC9C;gBAAC,CAAA,GAAA,yCAAW;gBAAG;oBAAC,MAAM;oBAAgB,WAAW,WAAW,SAAS;oBAAE,YAAY,MAAM,UAAU,IAAI;gBAAK;aAAE;YAC9G;gBAAC,CAAA,GAAA,yCAAU;gBAAG;oBACZ,OAAO;wBACL,aAAa;wBACb,cAAc;oBAChB;gBACF;aAAE;YACF;gBAAC,CAAA,GAAA,yCAAgB;gBAAG;aAAW;SAChC;qBACD,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;QACpB,gBAAc,MAAM,OAAO,IAAI;QAC/B,iBAAe,MAAM,UAAU,IAAI;QACnC,gBAAc,WAAW,SAAS,IAAI;QACtC,iBAAe,MAAM,UAAU,IAAI;QACnC,iBAAe,MAAM,UAAU,IAAI;;AAG3C","sources":["packages/react-aria-components/src/ColorField.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 {\n  ClassNameOrFunction,\n  ContextValue,\n  dom,\n  Provider,\n  RACValidation,\n  removeDataAttributes,\n  RenderProps,\n  SlotProps,\n  useContextProps,\n  useRenderProps,\n  useSlot\n} from './utils';\nimport {ColorChannel, ColorSpace} from 'react-stately/Color';\nimport {ColorFieldState, useColorChannelFieldState, useColorFieldState} from 'react-stately/useColorFieldState';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {GlobalDOMAttributes, InputDOMProps, ValidationResult} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport React, {createContext, ForwardedRef, forwardRef, HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, Ref, useRef} from 'react';\nimport {TextContext} from './Text';\nimport {useLocale} from 'react-aria/I18nProvider';\n\nexport interface ColorFieldRenderProps {\n  /**\n   * Whether the color field is disabled.\n   * @selector [data-disabled]\n   */\n  isDisabled: boolean,\n  /**\n   * Whether the color field is invalid.\n   * @selector [data-invalid]\n   */\n  isInvalid: boolean,\n  /**\n   * Whether the color field is read only.\n   * @selector [data-readonly]\n   */\n   isReadOnly: boolean,\n   /**\n    * Whether the color field is required.\n    * @selector [data-required]\n    */\n   isRequired: boolean,\n  /**\n   * The color channel that this field edits, or \"hex\" if no `channel` prop is set.\n   * @selector [data-channel=\"hex | hue | saturation | ...\"]\n   */\n  channel: ColorChannel | 'hex',\n  /**\n   * State of the color field.\n   */\n  state: ColorFieldState\n}\n\nexport interface ColorFieldProps extends Omit<AriaColorFieldProps, 'label' | 'placeholder' | 'description' | 'errorMessage' | 'validationState' | 'validationBehavior'>, RACValidation, InputDOMProps, RenderProps<ColorFieldRenderProps>, SlotProps, GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n   * @default 'react-aria-ColorField'\n   */\n  className?: ClassNameOrFunction<ColorFieldRenderProps>,\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}\n\nexport const ColorFieldContext = createContext<ContextValue<ColorFieldProps, HTMLDivElement>>(null);\nexport const ColorFieldStateContext = createContext<ColorFieldState | null>(null);\n\n/**\n * A color field allows users to edit a hex color or individual color channel value.\n */\nexport const ColorField = forwardRef(function ColorField(props: ColorFieldProps, ref: ForwardedRef<HTMLDivElement>) {\n  [props, ref] = useContextProps(props, ref, ColorFieldContext);\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<ColorFieldProps, 'channel'> {\n  channel: ColorChannel,\n  forwardedRef: ForwardedRef<HTMLDivElement>\n}\n\nfunction ColorChannelField(props: ColorChannelFieldProps) {\n  let {locale} = useLocale();\n  let state = useColorChannelFieldState({\n    ...props,\n    locale\n  });\n\n  let inputRef = useRef<HTMLInputElement>(null);\n  let [labelRef, label] = useSlot(\n    !props['aria-label'] && !props['aria-labelledby']\n  );\n  let {\n    labelProps,\n    inputProps,\n    descriptionProps,\n    errorMessageProps,\n    ...validation\n  } = useColorChannelField({\n    ...removeDataAttributes(props),\n    label,\n    validationBehavior: props.validationBehavior ?? 'native'\n  }, state, inputRef);\n\n  return (\n    <>\n      {useChildren(\n        props,\n        state,\n        props.forwardedRef,\n        inputProps,\n        inputRef,\n        labelProps,\n        labelRef,\n        descriptionProps,\n        errorMessageProps,\n        validation\n      )}\n      {props.name && <input type=\"hidden\" name={props.name} form={props.form} value={isNaN(state.numberValue) ? '' : state.numberValue} />}\n    </>\n  );\n}\n\ninterface HexColorFieldProps extends ColorFieldProps {\n  forwardedRef: ForwardedRef<HTMLDivElement>\n}\n\nfunction HexColorField(props: HexColorFieldProps) {\n  let state = useColorFieldState({\n    ...props,\n    validationBehavior: props.validationBehavior ?? 'native'\n  });\n\n  let inputRef = useRef<HTMLInputElement>(null);\n  let [labelRef, label] = useSlot(\n    !props['aria-label'] && !props['aria-labelledby']\n  );\n  let {\n    labelProps,\n    inputProps,\n    descriptionProps,\n    errorMessageProps,\n    ...validation\n  } = useColorField({\n    ...removeDataAttributes(props),\n    label,\n    validationBehavior: props.validationBehavior ?? 'native'\n  }, state, inputRef);\n\n  return useChildren(\n    props,\n    state,\n    props.forwardedRef,\n    inputProps,\n    inputRef,\n    labelProps,\n    labelRef,\n    descriptionProps,\n    errorMessageProps,\n    validation\n  );\n}\n\nfunction useChildren(\n  props: ColorFieldProps,\n  state: ColorFieldState,\n  ref: ForwardedRef<HTMLDivElement>,\n  inputProps: InputHTMLAttributes<HTMLElement>,\n  inputRef: Ref<HTMLInputElement>,\n  labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n  labelRef: Ref<HTMLLabelElement>,\n  descriptionProps: HTMLAttributes<HTMLElement>,\n  errorMessageProps: HTMLAttributes<HTMLElement>,\n  validation: ValidationResult\n) {\n  let renderProps = useRenderProps({\n    ...props,\n    values: {\n      state,\n      channel: props.channel || 'hex',\n      isDisabled: props.isDisabled || false,\n      isInvalid: validation.isInvalid || false,\n      isReadOnly: props.isReadOnly || false,\n      isRequired: props.isRequired || false\n    },\n    defaultClassName: 'react-aria-ColorField'\n  });\n\n  let DOMProps = filterDOMProps(props, {global: true});\n  delete DOMProps.id;\n\n  return (\n    <Provider\n      values={[\n        [ColorFieldStateContext, state],\n        [InputContext, {...inputProps, ref: inputRef}],\n        [LabelContext, {...labelProps, ref: labelRef}],\n        [GroupContext, {role: 'presentation', isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}],\n        [TextContext, {\n          slots: {\n            description: descriptionProps,\n            errorMessage: errorMessageProps\n          }\n        }],\n        [FieldErrorContext, validation]\n      ]}>\n      <dom.div\n        {...DOMProps}\n        {...renderProps}\n        ref={ref}\n        slot={props.slot || undefined}\n        data-channel={props.channel || 'hex'}\n        data-disabled={props.isDisabled || undefined}\n        data-invalid={validation.isInvalid || undefined}\n        data-readonly={props.isReadOnly || undefined}\n        data-required={props.isRequired || undefined} />\n    </Provider>\n  );\n}\n"],"names":[],"version":3,"file":"ColorField.mjs.map"}