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AG;IAChE,IAAI,kBAAkB,CAAA,GAAA,cAAM,EAAE;QAC5B,IAAI,aAAa,MAAM,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA,IAAK,EAAE,GAAG,KAAK,SAAS,aAAa;QACpF,OAAO,iBAAiB,SAAS,gBAAgB,MAAM,CAAC,GAAG,cAAc,IAAI,CAAC,EAAE;wBAAC;QAAU,KAAK;IAClG,uDAAuD;IACvD,GAAG;QAAC;QAAe;QAAQ,MAAM,UAAU,CAAC,OAAO;KAAC;IAEpD,IAAI,mBAAmB,CAAA,GAAA,yCAAa,EAAE;IAEtC,uGAAuG;IACvG,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,iBACF,CAAA,GAAA,yCAAO,EAAE,iBAAiB,aAAa;IAE3C,GAAG;QAAC;KAAgB;IAEpB,OAAO;QACL,WAAW,CAAA,GAAA,yCAAS,EAClB,WACA,kBACA;YACE,qDAAqD;YACrD,oBAAoB;gBAAC,gBAAgB,CAAC,mBAAmB;gBAAE,SAAS,CAAC,mBAAmB;aAAC,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;QACjH;IAEJ;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  /** The layout object for the table. Computes what content is visible and how to position and style them. */\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.\n * A table displays data in rows and columns and enables a user to navigate its contents via directional navigation keys,\n * and optionally supports row selection and sorting.\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>(props: AriaTableProps, state: TableState<T> | TreeGridState<T>, ref: RefObject<HTMLElement | null>): GridAria {\n  let {\n    keyboardDelegate,\n    isVirtualized,\n    layoutDelegate,\n    layout\n  } = 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(() => keyboardDelegate || new TableKeyboardDelegate({\n    collection: state.collection,\n    disabledKeys: state.disabledKeys,\n    disabledBehavior,\n    ref,\n    direction,\n    collator,\n    layoutDelegate,\n    layout\n  }), [keyboardDelegate, state.collection, state.disabledKeys, disabledBehavior, ref, direction, collator, layoutDelegate, layout]);\n  let id = useId(props.id);\n  gridIds.set(state as TableState<T>, id);\n\n  let {gridProps} = useGrid({\n    ...props,\n    id,\n    keyboardDelegate: delegate\n  }, state, ref);\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 ? stringFormatter.format(`${sortDirection}Sort`, {columnName}) : 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(\n      gridProps,\n      descriptionProps,\n      {\n        // merge sort description with long press information\n        'aria-describedby': [descriptionProps['aria-describedby'], gridProps['aria-describedby']].filter(Boolean).join(' ')\n      }\n    )\n  };\n}\n"],"names":[],"version":3,"file":"useTable.mjs.map"}