{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\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; }\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; }\nimport { filterDOMProps, mergeProps } from '@react-aria/utils';\nimport { listIds } from \"./utils\";\nimport { useId } from '@react-aria/utils';\nimport { useLabel } from '@react-aria/label';\nimport { useSelectableList } from '@react-aria/selection';\nimport { mapDomPropsToRN, useMapDomPropsToRN } from '@react-native-aria/utils';\nexport function useListBox(props, state, ref) {\n  var domProps = filterDOMProps(props, {\n    labelable: true\n  });\n  var _useSelectableList = useSelectableList(_objectSpread(_objectSpread({}, props), {}, {\n      ref: ref,\n      selectionManager: state.selectionManager,\n      collection: state.collection,\n      disabledKeys: state.disabledKeys\n    })),\n    listProps = _useSelectableList.listProps;\n  var id = useId(props.id);\n  listIds.set(state, id);\n  var _useLabel = useLabel(_objectSpread(_objectSpread({}, props), {}, {\n      id: id,\n      labelElementType: 'span'\n    })),\n    _labelProps = _useLabel.labelProps,\n    fieldProps = _useLabel.fieldProps;\n  var labelProps = mapDomPropsToRN(_labelProps);\n  var _listBoxProps = mergeProps(domProps, state.selectionManager.selectionMode === 'multiple' ? {\n    'aria-multiselectable': 'true'\n  } : {}, _objectSpread({\n    role: 'listbox'\n  }, mergeProps(fieldProps, listProps)));\n  var listBoxProps = useMapDomPropsToRN(_listBoxProps, ref);\n  return {\n    labelProps: labelProps,\n    listBoxProps: listBoxProps\n  };\n}","map":{"version":3,"sources":["useListBox.web.ts"],"names":["filterDOMProps","mergeProps","listIds","useId","useLabel","useSelectableList","mapDomPropsToRN","useMapDomPropsToRN","useListBox","props","state","ref","domProps","labelable","listProps","selectionManager","collection","disabledKeys","id","set","labelProps","_labelProps","fieldProps","labelElementType","_listBoxProps","selectionMode","role","listBoxProps"],"mappings":";;;AAaA,SAASA,cAAT,EAAyBC,UAAzB,QAA2C,mBAA3C;AAGA,SAASC,OAAT;AAEA,SAASC,KAAT,QAAsB,mBAAtB;AACA,SAASC,QAAT,QAAyB,mBAAzB;AACA,SAASC,iBAAT,QAAkC,uBAAlC;AACA,SAASC,eAAT,EAA0BC,kBAA1B,QAAoD,0BAApD;AA+BA,OAAO,SAASC,UAAT,CACLC,KADK,EAELC,KAFK,EAGLC,GAHK,EAIQ;EACb,IAAIC,QAAQ,GAAGZ,cAAc,CAACS,KAAD,EAAQ;IAAEI,SAAS,EAAE;EAAb,CAAR,CAA7B;EACA,IAAA,kBAAA,GAAoBR,iBAAiB,CAAA,aAAA,CAAA,aAAA,KAChCI,KADiC;MAEpCE,GAFoC,EAEpCA,GAFoC;MAGpCI,gBAAgB,EAAEL,KAAK,CAACK,gBAHY;MAIpCC,UAAU,EAAEN,KAAK,CAACM,UAJkB;MAKpCC,YAAY,EAAEP,KAAK,CAACO;IAAAA,EALe,CAArC;IAAMH,SAAAA,GAAAA,kBAAAA,CAAAA,SAAAA;EAQN,IAAII,EAAE,GAAGf,KAAK,CAACM,KAAK,CAACS,EAAP,CAAd;EACAhB,OAAO,CAACiB,GAARjB,CAAYQ,KAAZR,EAAmBgB,EAAnBhB,CAAAA;EAEA,IAAA,SAAA,GAA8CE,QAAQ,CAAA,aAAA,CAAA,aAAA,KACjDK,KADkD;MAErDS,EAFqD,EAErDA,EAFqD;MAKrDK,gBAAgB,EAAE;IAAA,EALkC,CAAtD;IAAkBF,WAAd,GAAA,SAAA,CAAED,UAAU;IAAeE,UAAAA,GAAAA,SAAAA,CAAAA,UAAAA;EAQ/B,IAAMF,UAAU,GAAGd,eAAe,CAACe,WAAD,CAAlC;EAEA,IAAMG,aAAa,GAAGvB,UAAU,CAC9BW,QAD8B,EAE9B,KAAK,CAACG,gBAAN,CAAuBU,aAAvB,KAAyC,UAAzC,GACI;IACE,sBAAA,EAAwB;EAD1B,CADJ,GAII,CAAA,CAN0B,EAAA,aAAA;IAQ5BC,IAAI,EAAE;EADR,GAEKzB,UAAU,CAACqB,UAAD,EAAaR,SAAb,CAAA,CATe,CAAhC;EAaA,IAAMa,YAAY,GAAGpB,kBAAkB,CAACiB,aAAD,EAAgBb,GAAhB,CAAvC;EAEA,OAAO;IACLS,UADK,EACLA,UADK;IAELO,YAAAA,EAAAA;EAFK,CAAP;AAID","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 { AriaListBoxProps } from '@react-types/listbox';\nimport { filterDOMProps, mergeProps } from '@react-aria/utils';\nimport { HTMLAttributes, ReactNode, RefObject } from 'react';\nimport { KeyboardDelegate } from '@react-types/shared';\nimport { listIds } from './utils';\nimport { ListState } from '@react-stately/list';\nimport { useId } from '@react-aria/utils';\nimport { useLabel } from '@react-aria/label';\nimport { useSelectableList } from '@react-aria/selection';\nimport { mapDomPropsToRN, useMapDomPropsToRN } from '@react-native-aria/utils';\n\ninterface ListBoxAria {\n  /** Props for the listbox element. */\n  listBoxProps: HTMLAttributes<HTMLElement>;\n  /** Props for the listbox's visual label element (if any). */\n  labelProps: HTMLAttributes<HTMLElement>;\n}\n\ninterface AriaListBoxOptions<T> extends Omit<AriaListBoxProps<T>, 'children'> {\n  /** Whether the listbox uses virtual scrolling. */\n  isVirtualized?: boolean;\n\n  /**\n   * An optional keyboard delegate implementation for type to select,\n   * to override the default.\n   */\n  keyboardDelegate?: KeyboardDelegate;\n\n  /**\n   * An optional visual label for the listbox.\n   */\n  label?: ReactNode;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a listbox component.\n * A listbox displays a list of options and allows a user to select one or more of them.\n * @param props - Props for the listbox.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useListBox<T>(\n  props: AriaListBoxOptions<T>,\n  state: ListState<T>,\n  ref: RefObject<HTMLElement>\n): ListBoxAria {\n  let domProps = filterDOMProps(props, { labelable: true });\n  let { listProps } = useSelectableList({\n    ...props,\n    ref,\n    selectionManager: state.selectionManager,\n    collection: state.collection,\n    disabledKeys: state.disabledKeys,\n  });\n\n  let id = useId(props.id);\n  listIds.set(state, id);\n\n  let { labelProps: _labelProps, fieldProps } = useLabel({\n    ...props,\n    id,\n    // listbox is not an HTML input element so it\n    // shouldn't be labeled by a <label> element.\n    labelElementType: 'span',\n  });\n\n  const labelProps = mapDomPropsToRN(_labelProps);\n\n  const _listBoxProps = mergeProps(\n    domProps,\n    state.selectionManager.selectionMode === 'multiple'\n      ? {\n          'aria-multiselectable': 'true',\n        }\n      : {},\n    {\n      role: 'listbox',\n      ...mergeProps(fieldProps, listProps),\n    }\n  );\n\n  const listBoxProps = useMapDomPropsToRN(_listBoxProps, ref);\n\n  return {\n    labelProps,\n    listBoxProps,\n  };\n}\n"]},"metadata":{},"sourceType":"module"}