{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n\nimport { useEffect as $lS2ep$useEffect } from \"react\";\nimport { useToggle as $lS2ep$useToggle } from \"@react-aria/toggle\";\nimport { filterDOMProps as $lS2ep$filterDOMProps, mergeProps as $lS2ep$mergeProps } from \"@react-aria/utils\";\nimport { useLabel as $lS2ep$useLabel } from \"@react-aria/label\";\nimport { useToggleState as $lS2ep$useToggleState } from \"@react-stately/toggle\";\n\nfunction $parcel$export(e, n, v, s) {\n  Object.defineProperty(e, n, {\n    get: v,\n    set: s,\n    enumerable: true,\n    configurable: true\n  });\n}\n\nvar $6fc5544ca1b3ab2a$exports = {};\n$parcel$export($6fc5544ca1b3ab2a$exports, \"useCheckbox\", function () {\n  return $6fc5544ca1b3ab2a$export$e375f10ce42261c5;\n});\n\nfunction $6fc5544ca1b3ab2a$export$e375f10ce42261c5(props, state, inputRef) {\n  var _$lS2ep$useToggle = $lS2ep$useToggle(props, state, inputRef),\n      inputProps = _$lS2ep$useToggle.inputProps;\n\n  var isSelected = state.isSelected;\n  var isIndeterminate = props.isIndeterminate;\n  $lS2ep$useEffect(function () {\n    if (inputRef.current) inputRef.current.indeterminate = isIndeterminate;\n  });\n  return {\n    inputProps: _objectSpread(_objectSpread({}, inputProps), {}, {\n      checked: isSelected,\n      'aria-checked': isIndeterminate ? 'mixed' : isSelected\n    })\n  };\n}\n\nvar $9c576869c2451f7f$exports = {};\n$parcel$export($9c576869c2451f7f$exports, \"useCheckboxGroup\", function () {\n  return $9c576869c2451f7f$export$49ff6f28c54f1cbe;\n});\nvar $46cd8c3ac90d2083$export$31440636951aa68c = new WeakMap();\n\nfunction $9c576869c2451f7f$export$49ff6f28c54f1cbe(props, state) {\n  var isDisabled = props.isDisabled,\n      name = props.name;\n\n  var _$lS2ep$useLabel = $lS2ep$useLabel(_objectSpread(_objectSpread({}, props), {}, {\n    labelElementType: 'span'\n  })),\n      labelProps = _$lS2ep$useLabel.labelProps,\n      fieldProps = _$lS2ep$useLabel.fieldProps;\n\n  var domProps = $lS2ep$filterDOMProps(props, {\n    labelable: true\n  });\n  $46cd8c3ac90d2083$export$31440636951aa68c.set(state, name);\n  return {\n    groupProps: $lS2ep$mergeProps(domProps, _objectSpread({\n      role: 'group',\n      'aria-disabled': isDisabled || undefined\n    }, fieldProps)),\n    labelProps: labelProps\n  };\n}\n\nvar $1e517f900339691c$exports = {};\n$parcel$export($1e517f900339691c$exports, \"useCheckboxGroupItem\", function () {\n  return $1e517f900339691c$export$353b32fc6898d37d;\n});\n\nfunction $1e517f900339691c$export$353b32fc6898d37d(props, state, inputRef) {\n  var toggleState = $lS2ep$useToggleState({\n    isReadOnly: props.isReadOnly || state.isReadOnly,\n    isSelected: state.isSelected(props.value),\n    onChange: function onChange(isSelected) {\n      if (isSelected) state.addValue(props.value);else state.removeValue(props.value);\n      if (props.onChange) props.onChange(isSelected);\n    }\n  });\n\n  var _$6fc5544ca1b3ab2a$ex = $6fc5544ca1b3ab2a$export$e375f10ce42261c5(_objectSpread(_objectSpread({}, props), {}, {\n    isReadOnly: props.isReadOnly || state.isReadOnly,\n    isDisabled: props.isDisabled || state.isDisabled,\n    name: props.name || $46cd8c3ac90d2083$export$31440636951aa68c.get(state)\n  }), toggleState, inputRef),\n      inputProps = _$6fc5544ca1b3ab2a$ex.inputProps;\n\n  return {\n    inputProps: inputProps\n  };\n}\n\nexport { $6fc5544ca1b3ab2a$export$e375f10ce42261c5 as useCheckbox, $9c576869c2451f7f$export$49ff6f28c54f1cbe as useCheckboxGroup, $1e517f900339691c$export$353b32fc6898d37d as useCheckboxGroupItem };","map":{"version":3,"sources":["packages/@react-aria/checkbox/src/useCheckbox.ts","packages/@react-aria/checkbox/src/useCheckboxGroup.ts","packages/@react-aria/checkbox/src/utils.ts","packages/@react-aria/checkbox/src/useCheckboxGroupItem.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;SA8BgB,yC,CAAY,K,EAA0B,K,EAAoB,Q,EAAqD;AAC7H,0BAAmB,gBAAS,CAAC,KAAD,EAAQ,KAAR,EAAe,QAAf,CAA5B;AAAA,MAAK,UAAL,qBAAK,UAAL;;AACA,MAAK,UAAL,GAAmB,KAAnB,CAAK,UAAL;AAEA,MAAK,eAAL,GAAwB,KAAxB,CAAK,eAAL;AACA,EAAA,gBAAS,CAAA,YAAO;AAGd,QAAI,QAAQ,CAAC,OAAb,EACE,QAAQ,CAAC,OAAT,CAAiB,aAAjB,GAAiC,eAAjC;AAEH,GANQ,CAAT;AAQA,SAAO;AACL,IAAA,UAAU,kCACL,UADK;AAER,MAAA,OAAO,EAAE,UAFD;AAGR,sBAAgB,eAAe,GAAG,OAAH,GAAa;AAHpC;AADL,GAAP;AAOD;;;;;;AEpCM,IAAM,yCAAkB,GAAG,IAAI,OAAJ,EAA3B;;SDkBS,yC,CAAiB,K,EAA+B,K,EAA8C;AAC5G,MAAK,UAAL,GAAyB,KAAzB,CAAK,UAAL;AAAA,MAAiB,IAAjB,GAAyB,KAAzB,CAAe,IAAf;;AAEA,yBAA+B,eAAQ,iCAClC,KADkC;AAIrC,IAAA,gBAAgB,EAAE;AAJmB,KAAvC;AAAA,MAAK,UAAL,oBAAK,UAAL;AAAA,MAAiB,UAAjB,oBAAe,UAAf;;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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} from '@react-types/checkbox';\nimport {InputHTMLAttributes, RefObject, useEffect} from 'react';\nimport {ToggleState} from '@react-stately/toggle';\nimport {useToggle} from '@react-aria/toggle';\n\nexport interface CheckboxAria {\n  /** Props for the input element. */\n  inputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component.\n * Checkboxes allow users to select multiple items from a list of individual items, or\n * to mark one individual item as selected.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useToggleState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckbox(props: AriaCheckboxProps, state: ToggleState, inputRef: RefObject<HTMLInputElement>): CheckboxAria {\n  let {inputProps} = useToggle(props, state, inputRef);\n  let {isSelected} = state;\n\n  let {isIndeterminate} = props;\n  useEffect(() => {\n    // indeterminate is a property, but it can only be set via javascript\n    // https://css-tricks.com/indeterminate-checkboxes/\n    if (inputRef.current) {\n      inputRef.current.indeterminate = isIndeterminate;\n    }\n  });\n\n  return {\n    inputProps: {\n      ...inputProps,\n      checked: isSelected,\n      'aria-checked': isIndeterminate ? 'mixed' : isSelected\n    }\n  };\n}\n","/*\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 {AriaCheckboxGroupProps} from '@react-types/checkbox';\nimport {checkboxGroupNames} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {HTMLAttributes} from 'react';\nimport {useLabel} from '@react-aria/label';\n\ninterface CheckboxGroupAria {\n  /** Props for the checkbox group wrapper element. */\n  groupProps: HTMLAttributes<HTMLElement>,\n  /** Props for the checkbox group's visible label (if any). */\n  labelProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox group component.\n * Checkbox groups allow users to select multiple items from a list of options.\n * @param props - Props for the checkbox group.\n * @param state - State for the checkbox group, as returned by `useCheckboxGroupState`.\n */\nexport function useCheckboxGroup(props: AriaCheckboxGroupProps, state: CheckboxGroupState): CheckboxGroupAria {\n  let {isDisabled, name} = props;\n\n  let {labelProps, fieldProps} = useLabel({\n    ...props,\n    // Checkbox group is not an HTML input element so it\n    // shouldn't be labeled by a <label> element.\n    labelElementType: 'span'\n  });\n\n  let domProps = filterDOMProps(props, {labelable: true});\n\n  // Pass name prop from group to all items by attaching to the state.\n  checkboxGroupNames.set(state, name);\n\n  return {\n    groupProps: mergeProps(domProps, {\n      role: 'group',\n      'aria-disabled': isDisabled || undefined,\n      ...fieldProps\n    }),\n    labelProps\n  };\n}\n","/*\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 {CheckboxGroupState} from '@react-stately/checkbox';\n\nexport const checkboxGroupNames = new WeakMap<CheckboxGroupState, string>();\n","/*\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 {AriaCheckboxGroupItemProps} from '@react-types/checkbox';\nimport {CheckboxAria, useCheckbox} from './useCheckbox';\nimport {checkboxGroupNames} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {RefObject} from 'react';\nimport {useToggleState} from '@react-stately/toggle';\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component contained within a checkbox group.\n * Checkbox groups allow users to select multiple items from a list of options.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useCheckboxGroupState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckboxGroupItem(props: AriaCheckboxGroupItemProps, state: CheckboxGroupState, inputRef: RefObject<HTMLInputElement>): CheckboxAria {\n  const toggleState = useToggleState({\n    isReadOnly: props.isReadOnly || state.isReadOnly,\n    isSelected: state.isSelected(props.value),\n    onChange(isSelected) {\n      if (isSelected) {\n        state.addValue(props.value);\n      } else {\n        state.removeValue(props.value);\n      }\n\n      if (props.onChange) {\n        props.onChange(isSelected);\n      }\n    }\n  });\n\n  let {inputProps} = useCheckbox({\n    ...props,\n    isReadOnly: props.isReadOnly || state.isReadOnly,\n    isDisabled: props.isDisabled || state.isDisabled,\n    name: props.name || checkboxGroupNames.get(state)\n  }, toggleState, inputRef);\n\n  return {inputProps};\n}\n"]},"metadata":{},"sourceType":"module"}