{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAiDM,SAAS,0CACd,KAAsB,EACtB,KAAkB,EAClB,GAAuC;IAEvC,IAAI,cAAC,UAAU,cAAE,UAAU,cAAE,UAAU,EAAE,GAAG,QAAO,GAAG,CAAA,GAAA,mCAAQ,EAAE,OAAO,OAAO;IAE9E,OAAO;oBACL;QACA,YAAY;YACV,GAAG,UAAU;YACb,MAAM;YACN,SAAS;QACX;oBACA;QACA,GAAG,MAAM;IACX;AACF","sources":["packages/react-aria/src/switch/useSwitch.ts"],"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 {AriaToggleProps, useToggle} from '../toggle/useToggle';\nimport {\n  DOMAttributesWithRef,\n  InputDOMProps,\n  RefObject,\n  ValidationResult\n} from '@react-types/shared';\nimport {InputHTMLAttributes, LabelHTMLAttributes} from 'react';\nimport {ToggleProps, ToggleState} from 'react-stately/useToggleState';\n\nexport interface SwitchProps extends ToggleProps {}\n\nexport interface AriaSwitchProps extends SwitchProps, InputDOMProps, AriaToggleProps {\n  /**\n   * Identifies the element (or elements) whose contents or presence are controlled by the current\n   * element.\n   */\n  'aria-controls'?: string;\n}\n\nexport interface SwitchAria extends ValidationResult {\n  /** Props for the label wrapper element. */\n  labelProps: LabelHTMLAttributes<HTMLLabelElement>;\n  /** Props for the input element. */\n  inputProps: InputHTMLAttributes<HTMLInputElement>;\n  /** Props for the switch description element, if any. */\n  descriptionProps: DOMAttributesWithRef<HTMLElement>;\n  /** Props for the switch error message element, if any. */\n  errorMessageProps: DOMAttributesWithRef<HTMLElement>;\n  /** Whether the switch is selected. */\n  isSelected: boolean;\n  /** Whether the switch is in a pressed state. */\n  isPressed: boolean;\n  /** Whether the switch is disabled. */\n  isDisabled: boolean;\n  /** Whether the switch is read only. */\n  isReadOnly: boolean;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a switch component.\n * A switch is similar to a checkbox, but represents on/off values as opposed to selection.\n *\n * @param props - Props for the switch.\n * @param state - State for the switch, as returned by `useToggleState`.\n * @param ref - Ref to the HTML input element.\n */\nexport function useSwitch(\n  props: AriaSwitchProps,\n  state: ToggleState,\n  ref: RefObject<HTMLInputElement | null>\n): SwitchAria {\n  let {labelProps, inputProps, isSelected, ...states} = useToggle(props, state, ref);\n\n  return {\n    labelProps,\n    inputProps: {\n      ...inputProps,\n      role: 'switch',\n      checked: isSelected\n    },\n    isSelected,\n    ...states\n  };\n}\n"],"names":[],"version":3,"file":"useSwitch.cjs.map"}