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AAI,kBAAkB,CAAA,GAAA,oBAAM,EAAE;QAC5B,IAAI,aAAa,MAAM,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA,IAAK,EAAE,GAAG,KAAK,SAAS,aAAa;QACpF,OAAO,iBAAiB,SACpB,gBAAgB,MAAM,CAAC,GAAG,cAAc,IAAI,CAAC,EAAE;wBAAC;QAAU,KAC1D;IACJ,uDAAuD;IACzD,GAAG;QAAC;QAAe;QAAQ,MAAM,UAAU,CAAC,OAAO;KAAC;IAEpD,IAAI,mBAAmB,CAAA,GAAA,wCAAa,EAAE;IAEtC,uGAAuG;IACvG,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,iBACF,CAAA,GAAA,kCAAO,EAAE,iBAAiB,aAAa;IAE3C,GAAG;QAAC;KAAgB;IAEpB,OAAO;QACL,WAAW,CAAA,GAAA,oCAAS,EAAE,WAAW,kBAAkB;YACjD,qDAAqD;YACrD,oBAAoB;gBAAC,gBAAgB,CAAC,mBAAmB;gBAAE,SAAS,CAAC,mBAAmB;aAAC,CACtF,MAAM,CAAC,SACP,IAAI,CAAC;QACV;IACF;AACF","sources":["packages/react-aria/src/table/useTable.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 {announce} from '../live-announcer/LiveAnnouncer';\n\nimport {GridAria, GridProps, useGrid} from '../grid/useGrid';\nimport {gridIds} from './utils';\n// @ts-ignore\nimport intlMessages from '../../intl/table/*.json';\nimport {Key, LayoutDelegate, Rect, RefObject, Size} from '@react-types/shared';\nimport {mergeProps} from '../utils/mergeProps';\nimport {TableKeyboardDelegate} from './TableKeyboardDelegate';\nimport {TableState} from 'react-stately/useTableState';\nimport {TreeGridState} from 'react-stately/private/table/useTreeGridState';\nimport {useCollator} from '../i18n/useCollator';\nimport {useDescription} from '../utils/useDescription';\nimport {useId} from '../utils/useId';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMemo} from 'react';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface AriaTableProps extends GridProps {\n  /**\n   * The layout object for the table. Computes what content is visible and how to position and style\n   * them.\n   */\n  layoutDelegate?: LayoutDelegate;\n  /** @deprecated - Use layoutDelegate instead. */\n  layout?: DeprecatedLayout;\n}\n\ninterface DeprecatedLayout {\n  getLayoutInfo(key: Key): DeprecatedLayoutInfo;\n  getContentSize(): Size;\n  virtualizer: DeprecatedVirtualizer;\n}\n\ninterface DeprecatedLayoutInfo {\n  rect: Rect;\n}\n\ninterface DeprecatedVirtualizer {\n  visibleRect: Rect;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a table component. A table displays\n * data in rows and columns and enables a user to navigate its contents via directional navigation\n * keys, and optionally supports row selection and sorting.\n *\n * @param props - Props for the table.\n * @param state - State for the table, as returned by `useTableState`.\n * @param ref - The ref attached to the table element.\n */\nexport function useTable<T>(\n  props: AriaTableProps,\n  state: TableState<T> | TreeGridState<T>,\n  ref: RefObject<HTMLElement | null>\n): GridAria {\n  let {keyboardDelegate, isVirtualized, layoutDelegate, layout} = props;\n\n  // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n  // When virtualized, the layout object will be passed in as a prop and override this.\n  let collator = useCollator({usage: 'search', sensitivity: 'base'});\n  let {direction} = useLocale();\n  let disabledBehavior = state.selectionManager.disabledBehavior;\n  let delegate = useMemo(\n    () =>\n      keyboardDelegate ||\n      new TableKeyboardDelegate({\n        collection: state.collection,\n        disabledKeys: state.disabledKeys,\n        disabledBehavior,\n        ref,\n        direction,\n        collator,\n        layoutDelegate,\n        layout\n      }),\n    [\n      keyboardDelegate,\n      state.collection,\n      state.disabledKeys,\n      disabledBehavior,\n      ref,\n      direction,\n      collator,\n      layoutDelegate,\n      layout\n    ]\n  );\n  let id = useId(props.id);\n  gridIds.set(state as TableState<T>, id);\n\n  let {gridProps} = useGrid(\n    {\n      ...props,\n      id,\n      keyboardDelegate: delegate\n    },\n    state,\n    ref\n  );\n\n  // Override to include header rows\n  if (isVirtualized) {\n    gridProps['aria-rowcount'] = state.collection.size + state.collection.headerRows.length;\n  }\n\n  if (state.treeColumn != null) {\n    gridProps.role = 'treegrid';\n  }\n\n  let {column, direction: sortDirection} = state.sortDescriptor || {};\n  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/table');\n  let sortDescription = useMemo(() => {\n    let columnName = state.collection.columns.find(c => c.key === column)?.textValue ?? '';\n    return sortDirection && column\n      ? stringFormatter.format(`${sortDirection}Sort`, {columnName})\n      : undefined;\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [sortDirection, column, state.collection.columns]);\n\n  let descriptionProps = useDescription(sortDescription);\n\n  // Only announce after initial render, tabbing to the table will tell you the initial sort info already\n  useUpdateEffect(() => {\n    if (sortDescription) {\n      announce(sortDescription, 'assertive', 500);\n    }\n  }, [sortDescription]);\n\n  return {\n    gridProps: mergeProps(gridProps, descriptionProps, {\n      // merge sort description with long press information\n      'aria-describedby': [descriptionProps['aria-describedby'], gridProps['aria-describedby']]\n        .filter(Boolean)\n        .join(' ')\n    })\n  };\n}\n"],"names":[],"version":3,"file":"useTable.cjs.map"}