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,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;uBAChD,0DAAC,CAAA,GAAA,8DAAa;QAAE,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;;IAEzD,IAAI,cAAc,QAAQ,GAAG,CAAC,QAAQ,KAAK,cAAc;QACvD,KAAK,IAAI,OAAO;YAAC;YAAc;YAAmB;SAAe,CAC/D,IAAI,aAAa,CAAC,IAAI,IAAI,MACxB,QAAQ,IAAI,CAAC,GAAG,IAAI,0HAA0H,CAAC;QAGnJ,IAAI,MAAM,KAAK,IAAI,MACjB,QAAQ,IAAI,CAAC;IAEjB;IAEA,qBACE,0DAAC;QACE,GAAG,UAAU;QACb,GAAG,UAAU;QACd,KAAK;QACL,WACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,mDAAK,GACL,qBACA;YACE,cAAc,WAAW,OAAO;YAChC,oBAAoB;YACpB,4BAA4B,CAAC;YAC7B,cAAc;YACd,eAAe;YACf,cAAc;QAChB,GACA,WAAW,SAAS;qBAGxB,0DAAC,CAAA,GAAA,mCAAQ;QAAE,gBAAgB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;QAAe,WAAW;qBACtE,0DAAC;QACE,GAAG,UAAU;QACd,KAAK;QACL,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;uBAElC,0DAAC;QAAK,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;OAA2B,WAC9D,0BACC,0DAAC;QAAK,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;OACjC;AAKX","sources":["packages/@adobe/react-spectrum/src/checkbox/Checkbox.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 {AriaCheckboxProps, useCheckbox} from 'react-aria/useCheckbox';\n\nimport {CheckboxContext} from 'react-aria-components/Checkbox';\nimport {CheckboxGroupContext} from './context';\nimport CheckmarkSmall from '@spectrum-icons/ui/CheckmarkSmall';\nimport {classNames} from '../utils/classNames';\nimport DashSmall from '@spectrum-icons/ui/DashSmall';\nimport {FocusableRef, StyleProps} from '@react-types/shared';\nimport {FocusRing} from 'react-aria/FocusRing';\nimport React, {forwardRef, useContext, useRef} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/checkbox/vars.css';\nimport {useCheckboxGroupItem} from 'react-aria/useCheckboxGroup';\nimport {useContextProps} from 'react-aria-components/slots';\nimport {useFocusableRef} from '../utils/useDOMRef';\nimport {useFormProps} from '../form/Form';\nimport {useHover} from 'react-aria/useHover';\nimport {useProviderProps} from '../provider/Provider';\nimport {useStyleProps} from '../utils/styleProps';\nimport {useToggleState} from 'react-stately/useToggleState';\n\nexport interface SpectrumCheckboxProps extends Omit<AriaCheckboxProps, 'onClick'>, StyleProps {\n  /**\n   * This prop sets the emphasized style which provides visual prominence.\n   */\n  isEmphasized?: boolean,\n  /**\n   * A slot name for the component. Slots allow the component to receive props from a parent component.\n   * An explicit `null` value indicates that the local props completely override all props received from a parent.\n   * @private\n   */\n  slot?: string | null\n}\n\n/**\n * Checkboxes allow users to select multiple items from a list of individual items,\n * or to mark one individual item as selected.\n */\nexport const Checkbox = forwardRef(function Checkbox(props: SpectrumCheckboxProps, ref: FocusableRef<HTMLLabelElement>) {\n  let originalProps = props;\n  let inputRef = useRef<HTMLInputElement>(null);\n  let domRef = useFocusableRef(ref, inputRef);\n\n  [props, domRef] = useContextProps(props, domRef, CheckboxContext);\n  props = useProviderProps(props);\n  props = useFormProps(props);\n  let {\n    isIndeterminate = false,\n    isEmphasized = false,\n    autoFocus,\n    children,\n    ...otherProps\n  } = props;\n  let {styleProps} = useStyleProps(otherProps);\n\n  // Swap hooks depending on whether this checkbox is inside a CheckboxGroup.\n  // This is a bit unorthodox. Typically, hooks cannot be called in a conditional,\n  // but since the checkbox won't move in and out of a group, it should be safe.\n  let groupState = useContext(CheckboxGroupContext);\n  let {inputProps, isInvalid, isDisabled} = groupState\n    // eslint-disable-next-line react-hooks/rules-of-hooks\n    ? useCheckboxGroupItem({\n      ...props,\n      // Value is optional for standalone checkboxes, but required for CheckboxGroup items;\n      // it's passed explicitly here to avoid typescript error (requires ignore).\n      // @ts-ignore\n      value: props.value,\n      // Only pass isRequired and validationState to react-aria if they came from\n      // the props for this individual checkbox, and not from the group via context.\n      isRequired: originalProps.isRequired,\n      validationState: originalProps.validationState,\n      isInvalid: originalProps.isInvalid\n    }, groupState, inputRef)\n    // eslint-disable-next-line react-hooks/rules-of-hooks\n    : useCheckbox(props, useToggleState(props), inputRef);\n\n  let {hoverProps, isHovered} = useHover({isDisabled});\n\n  let markIcon = isIndeterminate\n    ? <DashSmall UNSAFE_className={classNames(styles, 'spectrum-Checkbox-partialCheckmark')} />\n    : <CheckmarkSmall UNSAFE_className={classNames(styles, 'spectrum-Checkbox-checkmark')} />;\n\n  if (groupState && process.env.NODE_ENV !== 'production') {\n    for (let key of ['isSelected', 'defaultSelected', 'isEmphasized']) {\n      if (originalProps[key] != null) {\n        console.warn(`${key} is unsupported on individual <Checkbox> elements within a <CheckboxGroup>. Please apply these props to the group instead.`);\n      }\n    }\n    if (props.value == null) {\n      console.warn('A <Checkbox> element within a <CheckboxGroup> requires a `value` property.');\n    }\n  }\n\n  return (\n    <label\n      {...styleProps}\n      {...hoverProps}\n      ref={domRef}\n      className={\n        classNames(\n          styles,\n          'spectrum-Checkbox',\n          {\n            'is-checked': inputProps.checked,\n            'is-indeterminate': isIndeterminate,\n            'spectrum-Checkbox--quiet': !isEmphasized,\n            'is-invalid': isInvalid,\n            'is-disabled': isDisabled,\n            'is-hovered': isHovered\n          },\n          styleProps.className\n        )\n      }>\n      <FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>\n        <input\n          {...inputProps}\n          ref={inputRef}\n          className={classNames(styles, 'spectrum-Checkbox-input')} />\n      </FocusRing>\n      <span className={classNames(styles, 'spectrum-Checkbox-box')}>{markIcon}</span>\n      {children && (\n        <span className={classNames(styles, 'spectrum-Checkbox-label')}>\n          {children}\n        </span>\n      )}\n    </label>\n  );\n});\n"],"names":[],"version":3,"file":"Checkbox.cjs.map"}