Files
NapCatQQ/.pnpm-store/v3/files/73/1f9e0f3859bc9a9ed1a5699a119fb6a2be5af2f05a6bf1736a1f5a434cad3fada09a272fd5653d1d27353bbba5ceb1c2bbde66efc35f777ff47260be198efe
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

87 lines
4.3 KiB
Plaintext

import {getColumnHeaderId as $2140fb2337097f2d$export$37cd4213f2ad742e} from "./utils.mjs";
import $cjB6b$intlStringsmodulejs from "./intlStrings.mjs";
import {isAndroid as $cjB6b$isAndroid, useDescription as $cjB6b$useDescription, mergeProps as $cjB6b$mergeProps} from "@react-aria/utils";
import {useEffect as $cjB6b$useEffect} from "react";
import {usePress as $cjB6b$usePress, useFocusable as $cjB6b$useFocusable} from "@react-aria/interactions";
import {useGridCell as $cjB6b$useGridCell} from "@react-aria/grid";
import {useLocalizedStringFormatter as $cjB6b$useLocalizedStringFormatter} from "@react-aria/i18n";
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
/*
* 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.
*/
function $f329116d8ad0aba0$export$9514819a8c81e960(props, state, ref) {
var _state_sortDescriptor, _state_sortDescriptor1;
let { node: node } = props;
let allowsSorting = node.props.allowsSorting;
// if there are no focusable children, the column header will focus the cell
let { gridCellProps: gridCellProps } = (0, $cjB6b$useGridCell)({
...props,
focusMode: 'child'
}, state, ref);
let isSelectionCellDisabled = node.props.isSelectionCell && state.selectionManager.selectionMode === 'single';
let { pressProps: pressProps } = (0, $cjB6b$usePress)({
isDisabled: !allowsSorting || isSelectionCellDisabled,
onPress () {
state.sort(node.key);
},
ref: ref
});
// Needed to pick up the focusable context, enabling things like Tooltips for example
let { focusableProps: focusableProps } = (0, $cjB6b$useFocusable)({}, ref);
let ariaSort = undefined;
let isSortedColumn = ((_state_sortDescriptor = state.sortDescriptor) === null || _state_sortDescriptor === void 0 ? void 0 : _state_sortDescriptor.column) === node.key;
let sortDirection = (_state_sortDescriptor1 = state.sortDescriptor) === null || _state_sortDescriptor1 === void 0 ? void 0 : _state_sortDescriptor1.direction;
// aria-sort not supported in Android Talkback
if (node.props.allowsSorting && !(0, $cjB6b$isAndroid)()) ariaSort = isSortedColumn ? sortDirection : 'none';
let stringFormatter = (0, $cjB6b$useLocalizedStringFormatter)((0, ($parcel$interopDefault($cjB6b$intlStringsmodulejs))), '@react-aria/table');
let sortDescription;
if (allowsSorting) {
sortDescription = `${stringFormatter.format('sortable')}`;
// Android Talkback doesn't support aria-sort so we add sort order details to the aria-described by here
if (isSortedColumn && sortDirection && (0, $cjB6b$isAndroid)()) sortDescription = `${sortDescription}, ${stringFormatter.format(sortDirection)}`;
}
let descriptionProps = (0, $cjB6b$useDescription)(sortDescription);
let shouldDisableFocus = state.collection.size === 0;
(0, $cjB6b$useEffect)(()=>{
if (shouldDisableFocus && state.selectionManager.focusedKey === node.key) state.selectionManager.setFocusedKey(null);
}, [
shouldDisableFocus,
state.selectionManager,
node.key
]);
return {
columnHeaderProps: {
...(0, $cjB6b$mergeProps)(focusableProps, gridCellProps, pressProps, descriptionProps, // If the table is empty, make all column headers untabbable
shouldDisableFocus ? {
tabIndex: -1
} : null),
role: 'columnheader',
id: (0, $2140fb2337097f2d$export$37cd4213f2ad742e)(state, node.key),
'aria-colspan': node.colSpan && node.colSpan > 1 ? node.colSpan : undefined,
'aria-sort': ariaSort
}
};
}
export {$f329116d8ad0aba0$export$9514819a8c81e960 as useTableColumnHeader};
//# sourceMappingURL=useTableColumnHeader.module.js.map