Files
NapCatQQ/.pnpm-store/v3/files/ec/ce63a3266260268d69b0111bc1b740c8d13e1f854eb07877615d59c56e8942a45326f91ead3bd3a44de9a3b9befbeabd330374d39dc1666320cc357003e1c4
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

60 lines
2.3 KiB
Plaintext

/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
import {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';
import {getCellId} from './utils';
import {GridNode} from '@react-types/grid';
import {TableState} from '@react-stately/table';
import {useGridCell} from '@react-aria/grid';
export interface AriaTableCellProps {
/** An object representing the table cell. Contains all the relevant information that makes up the row header. */
node: GridNode<unknown>,
/** Whether the cell is contained in a virtual scroller. */
isVirtualized?: boolean,
/** Whether selection should occur on press up instead of press down. */
shouldSelectOnPressUp?: boolean,
/**
* Handler that is called when a user performs an action on the cell.
* Please use onCellAction at the collection level instead.
* @deprecated
**/
onAction?: () => void
}
export interface TableCellAria {
/** Props for the table cell element. */
gridCellProps: DOMAttributes,
/** Whether the cell is currently in a pressed state. */
isPressed: boolean
}
/**
* Provides the behavior and accessibility implementation for a cell in a table.
* @param props - Props for the cell.
* @param state - State of the table, as returned by `useTableState`.
* @param ref - The ref attached to the cell element.
*/
export function useTableCell<T>(props: AriaTableCellProps, state: TableState<T>, ref: RefObject<FocusableElement | null>): TableCellAria {
let {gridCellProps, isPressed} = useGridCell(props, state, ref);
let columnKey = props.node.column?.key;
if (columnKey != null && state.collection.rowHeaderColumnKeys.has(columnKey)) {
gridCellProps.role = 'rowheader';
gridCellProps.id = getCellId(state, props.node.parentKey!, columnKey);
}
return {
gridCellProps,
isPressed
};
}