{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAiBD,MAAM,qCAAe;IACnB,QAAQ;IACR,UAAU;IACV,YAAY;AACd;AAGO,SAAS,0CAAsB,KAA+B,EAAE,KAAmB,EAAE,GAAwC;IAClI,IAAI,gBAAgB,MAAM,gBAAgB,CAAC,aAAa;IACxD,IAAI,cAAc;QAChB,MAAM,kCAAY,CAAC,cAAc;IACnC;IAEA,IAAI,kBAAkB,QAAQ;QAC5B,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC,MAAM,GAAG;QAC5D,WAAW,CAAC,eAAe,GAAG;IAChC;IAEA,IAAI,YAAY,MAAM,GAAG,KAAK,MAAM,gBAAgB,CAAC,UAAU;IAC/D,IAAI,qBAAqB,CAAA,GAAA,yCAAa,EAAE;QACtC,IAAI,WACF,MAAM,gBAAgB,CAAC,aAAa,CAAC;IAEzC;IAEA,8EAA8E;IAC9E,CAAA,GAAA,gBAAQ,EAAE;QACR,OAAO;YACL;QACF;IACF,GAAG,EAAE;IAEL,OAAO;QACL,aAAa,CAAA,GAAA,yCAAS,EAAE,aAAa;YACnC,UAAU,aAAa,MAAM,gBAAgB,CAAC,UAAU,IAAI,OAAO,IAAI;YACvE;gBACE,MAAM,gBAAgB,CAAC,aAAa,CAAC,MAAM,GAAG;YAChD;YACA;gBACE,MAAM,gBAAgB,CAAC,MAAM,CAAC,MAAM,GAAG;YACzC;QACF;IACF;AACF","sources":["packages/react-aria/src/actiongroup/useActionGroupItem.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 {DOMAttributes, FocusableElement, Key, RefObject} from '@react-types/shared';\nimport {ListState} from 'react-stately/useListState';\nimport {mergeProps} from '../utils/mergeProps';\nimport {PressProps} from '../interactions/usePress';\nimport {useEffect} from 'react';\nimport {useEffectEvent} from '../utils/useEffectEvent';\n\nexport interface AriaActionGroupItemProps {\n  key: Key\n}\n\nexport interface ActionGroupItemAria {\n  buttonProps: DOMAttributes & PressProps\n}\n\nconst BUTTON_ROLES = {\n  'none': undefined,\n  'single': 'radio',\n  'multiple': 'checkbox'\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useActionGroupItem<T>(props: AriaActionGroupItemProps, state: ListState<T>, ref?: RefObject<FocusableElement | null>): ActionGroupItemAria {\n  let selectionMode = state.selectionManager.selectionMode;\n  let buttonProps = {\n    role: BUTTON_ROLES[selectionMode]\n  };\n\n  if (selectionMode !== 'none') {\n    let isSelected = state.selectionManager.isSelected(props.key);\n    buttonProps['aria-checked'] = isSelected;\n  }\n\n  let isFocused = props.key === state.selectionManager.focusedKey;\n  let onRemovedWithFocus = useEffectEvent(() => {\n    if (isFocused) {\n      state.selectionManager.setFocusedKey(null);\n    }\n  });\n\n  // If the focused item is removed from the DOM, reset the focused key to null.\n  useEffect(() => {\n    return () => {\n      onRemovedWithFocus();\n    };\n  }, []);\n\n  return {\n    buttonProps: mergeProps(buttonProps, {\n      tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,\n      onFocus() {\n        state.selectionManager.setFocusedKey(props.key);\n      },\n      onPress() {\n        state.selectionManager.select(props.key);\n      }\n    })\n  };\n}\n"],"names":[],"version":3,"file":"useActionGroupItem.mjs.map"}