805 lines
37 KiB
JavaScript
805 lines
37 KiB
JavaScript
import $ce3de3ff2fd66848$exports from "./ar-AE.mjs";
|
|
import $cb80dcce530985b9$exports from "./bg-BG.mjs";
|
|
import $68ac86749db4c0fb$exports from "./cs-CZ.mjs";
|
|
import $9a6cbac08487e661$exports from "./da-DK.mjs";
|
|
import $c963661d89486e72$exports from "./de-DE.mjs";
|
|
import $ac03861c6e8605f4$exports from "./el-GR.mjs";
|
|
import $09e6b82e0d6e466a$exports from "./en-US.mjs";
|
|
import $8cc39eb66c2bf220$exports from "./es-ES.mjs";
|
|
import $4e11db3c25a38112$exports from "./et-EE.mjs";
|
|
import $da1e751a92575e02$exports from "./fi-FI.mjs";
|
|
import $1b5d6c6c47d55106$exports from "./fr-FR.mjs";
|
|
import $7c18ba27b86d3308$exports from "./he-IL.mjs";
|
|
import $2cb40998e20e8a46$exports from "./hr-HR.mjs";
|
|
import $189e23eec1d6aa3a$exports from "./hu-HU.mjs";
|
|
import $3c5ec8e4f015dfd0$exports from "./it-IT.mjs";
|
|
import $d021d50e6b315ebb$exports from "./ja-JP.mjs";
|
|
import $52535c35c24ec937$exports from "./ko-KR.mjs";
|
|
import $b37ee03672edfd1d$exports from "./lt-LT.mjs";
|
|
import $c7df6686b4189d56$exports from "./lv-LV.mjs";
|
|
import $da07fe8ec87e6b68$exports from "./nb-NO.mjs";
|
|
import $64b7e390f5791490$exports from "./nl-NL.mjs";
|
|
import $2a03621e773f1678$exports from "./pl-PL.mjs";
|
|
import $0a79c0aba9e5ecc6$exports from "./pt-BR.mjs";
|
|
import $de7b4d0f7dc86fc8$exports from "./pt-PT.mjs";
|
|
import $28ea7e849d77bd1c$exports from "./ro-RO.mjs";
|
|
import $9a09321cf046b187$exports from "./ru-RU.mjs";
|
|
import $5afe469a63fcac7b$exports from "./sk-SK.mjs";
|
|
import $2956757ac31a7ce2$exports from "./sl-SI.mjs";
|
|
import $cedee0e66b175529$exports from "./sr-SP.mjs";
|
|
import $6db19998ba4427da$exports from "./sv-SE.mjs";
|
|
import $166b7c9cc1adb1a1$exports from "./tr-TR.mjs";
|
|
import $c7ab180b401e49ff$exports from "./uk-UA.mjs";
|
|
import $1648ec00941567f3$exports from "./zh-CN.mjs";
|
|
import $b26f22384b3c1526$exports from "./zh-TW.mjs";
|
|
import {useGridRowGroup as $lJcFS$useGridRowGroup, useGrid as $lJcFS$useGrid, GridKeyboardDelegate as $lJcFS$GridKeyboardDelegate, useGridCell as $lJcFS$useGridCell, useGridRow as $lJcFS$useGridRow, useGridSelectionCheckbox as $lJcFS$useGridSelectionCheckbox} from "@react-aria/grid";
|
|
import {announce as $lJcFS$announce} from "@react-aria/live-announcer";
|
|
import {useId as $lJcFS$useId, useDescription as $lJcFS$useDescription, useUpdateEffect as $lJcFS$useUpdateEffect, mergeProps as $lJcFS$mergeProps, isAndroid as $lJcFS$isAndroid, getSyntheticLinkProps as $lJcFS$getSyntheticLinkProps, useEffectEvent as $lJcFS$useEffectEvent} from "@react-aria/utils";
|
|
import {useMemo as $lJcFS$useMemo, useEffect as $lJcFS$useEffect, useRef as $lJcFS$useRef, useCallback as $lJcFS$useCallback} from "react";
|
|
import {tableNestedRows as $lJcFS$tableNestedRows} from "@react-stately/flags";
|
|
import {useCollator as $lJcFS$useCollator, useLocale as $lJcFS$useLocale, useLocalizedStringFormatter as $lJcFS$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
import {getFirstItem as $lJcFS$getFirstItem, getChildNodes as $lJcFS$getChildNodes, getNthItem as $lJcFS$getNthItem, getLastItem as $lJcFS$getLastItem} from "@react-stately/collections";
|
|
import {useFocusable as $lJcFS$useFocusable, focusSafely as $lJcFS$focusSafely} from "@react-aria/focus";
|
|
import {usePress as $lJcFS$usePress, useKeyboard as $lJcFS$useKeyboard, useMove as $lJcFS$useMove, useInteractionModality as $lJcFS$useInteractionModality} from "@react-aria/interactions";
|
|
import {useVisuallyHidden as $lJcFS$useVisuallyHidden} from "@react-aria/visually-hidden";
|
|
|
|
|
|
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.
|
|
*/ /*
|
|
* 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.
|
|
*/
|
|
|
|
/*
|
|
* 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.
|
|
*/ const $2140fb2337097f2d$export$552312adfd451dab = new WeakMap();
|
|
function $2140fb2337097f2d$var$normalizeKey(key) {
|
|
if (typeof key === "string") return key.replace(/\s*/g, "");
|
|
return "" + key;
|
|
}
|
|
function $2140fb2337097f2d$export$37cd4213f2ad742e(state, columnKey) {
|
|
let gridId = $2140fb2337097f2d$export$552312adfd451dab.get(state);
|
|
if (!gridId) throw new Error("Unknown grid");
|
|
return `${gridId}-${$2140fb2337097f2d$var$normalizeKey(columnKey)}`;
|
|
}
|
|
function $2140fb2337097f2d$export$19baff3266315d44(state, rowKey, columnKey) {
|
|
let gridId = $2140fb2337097f2d$export$552312adfd451dab.get(state);
|
|
if (!gridId) throw new Error("Unknown grid");
|
|
return `${gridId}-${$2140fb2337097f2d$var$normalizeKey(rowKey)}-${$2140fb2337097f2d$var$normalizeKey(columnKey)}`;
|
|
}
|
|
function $2140fb2337097f2d$export$85069b70317f543(state, rowKey) {
|
|
// A row is labelled by it's row headers.
|
|
return [
|
|
...state.collection.rowHeaderColumnKeys
|
|
].map((columnKey)=>$2140fb2337097f2d$export$19baff3266315d44(state, rowKey, columnKey)).join(" ");
|
|
}
|
|
|
|
|
|
var $7476b46781682bf5$exports = {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$7476b46781682bf5$exports = {
|
|
"ar-AE": $ce3de3ff2fd66848$exports,
|
|
"bg-BG": $cb80dcce530985b9$exports,
|
|
"cs-CZ": $68ac86749db4c0fb$exports,
|
|
"da-DK": $9a6cbac08487e661$exports,
|
|
"de-DE": $c963661d89486e72$exports,
|
|
"el-GR": $ac03861c6e8605f4$exports,
|
|
"en-US": $09e6b82e0d6e466a$exports,
|
|
"es-ES": $8cc39eb66c2bf220$exports,
|
|
"et-EE": $4e11db3c25a38112$exports,
|
|
"fi-FI": $da1e751a92575e02$exports,
|
|
"fr-FR": $1b5d6c6c47d55106$exports,
|
|
"he-IL": $7c18ba27b86d3308$exports,
|
|
"hr-HR": $2cb40998e20e8a46$exports,
|
|
"hu-HU": $189e23eec1d6aa3a$exports,
|
|
"it-IT": $3c5ec8e4f015dfd0$exports,
|
|
"ja-JP": $d021d50e6b315ebb$exports,
|
|
"ko-KR": $52535c35c24ec937$exports,
|
|
"lt-LT": $b37ee03672edfd1d$exports,
|
|
"lv-LV": $c7df6686b4189d56$exports,
|
|
"nb-NO": $da07fe8ec87e6b68$exports,
|
|
"nl-NL": $64b7e390f5791490$exports,
|
|
"pl-PL": $2a03621e773f1678$exports,
|
|
"pt-BR": $0a79c0aba9e5ecc6$exports,
|
|
"pt-PT": $de7b4d0f7dc86fc8$exports,
|
|
"ro-RO": $28ea7e849d77bd1c$exports,
|
|
"ru-RU": $9a09321cf046b187$exports,
|
|
"sk-SK": $5afe469a63fcac7b$exports,
|
|
"sl-SI": $2956757ac31a7ce2$exports,
|
|
"sr-SP": $cedee0e66b175529$exports,
|
|
"sv-SE": $6db19998ba4427da$exports,
|
|
"tr-TR": $166b7c9cc1adb1a1$exports,
|
|
"uk-UA": $c7ab180b401e49ff$exports,
|
|
"zh-CN": $1648ec00941567f3$exports,
|
|
"zh-TW": $b26f22384b3c1526$exports
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
* Copyright 2022 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.
|
|
*/
|
|
|
|
class $0ba3c81c7f1caedd$export$da43f8f5cb04028d extends (0, $lJcFS$GridKeyboardDelegate) {
|
|
isCell(node) {
|
|
return node.type === "cell" || node.type === "rowheader" || node.type === "column";
|
|
}
|
|
getKeyBelow(key) {
|
|
let startItem = this.collection.getItem(key);
|
|
if (!startItem) return;
|
|
// If focus was on a column, then focus the first child column if any,
|
|
// or find the corresponding cell in the first row.
|
|
if (startItem.type === "column") {
|
|
let child = (0, $lJcFS$getFirstItem)((0, $lJcFS$getChildNodes)(startItem, this.collection));
|
|
if (child) return child.key;
|
|
let firstKey = this.getFirstKey();
|
|
if (firstKey == null) return;
|
|
let firstItem = this.collection.getItem(firstKey);
|
|
return (0, $lJcFS$getNthItem)((0, $lJcFS$getChildNodes)(firstItem, this.collection), startItem.index).key;
|
|
}
|
|
return super.getKeyBelow(key);
|
|
}
|
|
getKeyAbove(key) {
|
|
let startItem = this.collection.getItem(key);
|
|
if (!startItem) return;
|
|
// If focus was on a column, focus the parent column if any
|
|
if (startItem.type === "column") {
|
|
let parent = this.collection.getItem(startItem.parentKey);
|
|
if (parent && parent.type === "column") return parent.key;
|
|
return;
|
|
}
|
|
// only return above row key if not header row
|
|
let superKey = super.getKeyAbove(key);
|
|
if (superKey != null && this.collection.getItem(superKey).type !== "headerrow") return superKey;
|
|
// If no item was found, and focus was on a cell, then focus the
|
|
// corresponding column header.
|
|
if (this.isCell(startItem)) return this.collection.columns[startItem.index].key;
|
|
// If focus was on a row, then focus the first column header.
|
|
return this.collection.columns[0].key;
|
|
}
|
|
findNextColumnKey(column) {
|
|
// Search following columns
|
|
let key = this.findNextKey(column.key, (item)=>item.type === "column");
|
|
if (key != null) return key;
|
|
// Wrap around to the first column
|
|
let row = this.collection.headerRows[column.level];
|
|
for (let item of (0, $lJcFS$getChildNodes)(row, this.collection)){
|
|
if (item.type === "column") return item.key;
|
|
}
|
|
}
|
|
findPreviousColumnKey(column) {
|
|
// Search previous columns
|
|
let key = this.findPreviousKey(column.key, (item)=>item.type === "column");
|
|
if (key != null) return key;
|
|
// Wrap around to the last column
|
|
let row = this.collection.headerRows[column.level];
|
|
let childNodes = [
|
|
...(0, $lJcFS$getChildNodes)(row, this.collection)
|
|
];
|
|
for(let i = childNodes.length - 1; i >= 0; i--){
|
|
let item = childNodes[i];
|
|
if (item.type === "column") return item.key;
|
|
}
|
|
}
|
|
getKeyRightOf(key) {
|
|
let item = this.collection.getItem(key);
|
|
if (!item) return;
|
|
// If focus was on a column, then focus the next column
|
|
if (item.type === "column") return this.direction === "rtl" ? this.findPreviousColumnKey(item) : this.findNextColumnKey(item);
|
|
return super.getKeyRightOf(key);
|
|
}
|
|
getKeyLeftOf(key) {
|
|
let item = this.collection.getItem(key);
|
|
if (!item) return;
|
|
// If focus was on a column, then focus the previous column
|
|
if (item.type === "column") return this.direction === "rtl" ? this.findNextColumnKey(item) : this.findPreviousColumnKey(item);
|
|
return super.getKeyLeftOf(key);
|
|
}
|
|
getKeyForSearch(search, fromKey) {
|
|
if (!this.collator) return null;
|
|
let collection = this.collection;
|
|
let key = fromKey !== null && fromKey !== void 0 ? fromKey : this.getFirstKey();
|
|
if (key == null) return null;
|
|
// If the starting key is a cell, search from its parent row.
|
|
let startItem = collection.getItem(key);
|
|
if (startItem.type === "cell") key = startItem.parentKey;
|
|
let hasWrapped = false;
|
|
while(key != null){
|
|
let item = collection.getItem(key);
|
|
// Check each of the row header cells in this row for a match
|
|
for (let cell of (0, $lJcFS$getChildNodes)(item, this.collection)){
|
|
let column = collection.columns[cell.index];
|
|
if (collection.rowHeaderColumnKeys.has(column.key) && cell.textValue) {
|
|
let substring = cell.textValue.slice(0, search.length);
|
|
if (this.collator.compare(substring, search) === 0) {
|
|
// If we started on a cell, end on the matching cell. Otherwise, end on the row.
|
|
let fromItem = fromKey != null ? collection.getItem(fromKey) : startItem;
|
|
return fromItem.type === "cell" ? cell.key : item.key;
|
|
}
|
|
}
|
|
}
|
|
key = this.getKeyBelow(key);
|
|
// Wrap around when reaching the end of the collection
|
|
if (key == null && !hasWrapped) {
|
|
key = this.getFirstKey();
|
|
hasWrapped = true;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
function $6e31608fbba75bab$export$25bceaac3c7e4dc7(props, state, ref) {
|
|
let { keyboardDelegate: keyboardDelegate, isVirtualized: isVirtualized, layout: layout } = props;
|
|
// By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
|
|
// When virtualized, the layout object will be passed in as a prop and override this.
|
|
let collator = (0, $lJcFS$useCollator)({
|
|
usage: "search",
|
|
sensitivity: "base"
|
|
});
|
|
let { direction: direction } = (0, $lJcFS$useLocale)();
|
|
let disabledBehavior = state.selectionManager.disabledBehavior;
|
|
let delegate = (0, $lJcFS$useMemo)(()=>keyboardDelegate || new (0, $0ba3c81c7f1caedd$export$da43f8f5cb04028d)({
|
|
collection: state.collection,
|
|
disabledKeys: disabledBehavior === "selection" ? new Set() : state.disabledKeys,
|
|
ref: ref,
|
|
direction: direction,
|
|
collator: collator,
|
|
layout: layout
|
|
}), [
|
|
keyboardDelegate,
|
|
state.collection,
|
|
state.disabledKeys,
|
|
disabledBehavior,
|
|
ref,
|
|
direction,
|
|
collator,
|
|
layout
|
|
]);
|
|
let id = (0, $lJcFS$useId)(props.id);
|
|
(0, $2140fb2337097f2d$export$552312adfd451dab).set(state, id);
|
|
let { gridProps: gridProps } = (0, $lJcFS$useGrid)({
|
|
...props,
|
|
id: id,
|
|
keyboardDelegate: delegate
|
|
}, state, ref);
|
|
// Override to include header rows
|
|
if (isVirtualized) gridProps["aria-rowcount"] = state.collection.size + state.collection.headerRows.length;
|
|
if ((0, $lJcFS$tableNestedRows)() && "expandedKeys" in state) gridProps.role = "treegrid";
|
|
let { column: column, direction: sortDirection } = state.sortDescriptor || {};
|
|
let stringFormatter = (0, $lJcFS$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($7476b46781682bf5$exports))), "@react-aria/table");
|
|
let sortDescription = (0, $lJcFS$useMemo)(()=>{
|
|
var _state_collection_columns_find;
|
|
let columnName = (_state_collection_columns_find = state.collection.columns.find((c)=>c.key === column)) === null || _state_collection_columns_find === void 0 ? void 0 : _state_collection_columns_find.textValue;
|
|
return sortDirection && column ? stringFormatter.format(`${sortDirection}Sort`, {
|
|
columnName: columnName
|
|
}) : undefined;
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, [
|
|
sortDirection,
|
|
column,
|
|
state.collection.columns
|
|
]);
|
|
let descriptionProps = (0, $lJcFS$useDescription)(sortDescription);
|
|
// Only announce after initial render, tabbing to the table will tell you the initial sort info already
|
|
(0, $lJcFS$useUpdateEffect)(()=>{
|
|
(0, $lJcFS$announce)(sortDescription, "assertive", 500);
|
|
}, [
|
|
sortDescription
|
|
]);
|
|
return {
|
|
gridProps: (0, $lJcFS$mergeProps)(gridProps, descriptionProps, {
|
|
// merge sort description with long press information
|
|
"aria-describedby": [
|
|
descriptionProps["aria-describedby"],
|
|
gridProps["aria-describedby"]
|
|
].filter(Boolean).join(" ")
|
|
})
|
|
};
|
|
}
|
|
|
|
|
|
/*
|
|
* 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, $lJcFS$useGridCell)({
|
|
...props,
|
|
focusMode: "child"
|
|
}, state, ref);
|
|
let isSelectionCellDisabled = node.props.isSelectionCell && state.selectionManager.selectionMode === "single";
|
|
let { pressProps: pressProps } = (0, $lJcFS$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, $lJcFS$useFocusable)({}, ref);
|
|
let ariaSort = null;
|
|
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, $lJcFS$isAndroid)()) ariaSort = isSortedColumn ? sortDirection : "none";
|
|
let stringFormatter = (0, $lJcFS$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($7476b46781682bf5$exports))), "@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, $lJcFS$isAndroid)()) sortDescription = `${sortDescription}, ${stringFormatter.format(sortDirection)}`;
|
|
}
|
|
let descriptionProps = (0, $lJcFS$useDescription)(sortDescription);
|
|
let shouldDisableFocus = state.collection.size === 0;
|
|
(0, $lJcFS$useEffect)(()=>{
|
|
if (shouldDisableFocus && state.selectionManager.focusedKey === node.key) state.selectionManager.setFocusedKey(null);
|
|
}, [
|
|
shouldDisableFocus,
|
|
state.selectionManager,
|
|
node.key
|
|
]);
|
|
return {
|
|
columnHeaderProps: {
|
|
...(0, $lJcFS$mergeProps)(gridCellProps, pressProps, focusableProps, descriptionProps, // If the table is empty, make all column headers untabbable
|
|
shouldDisableFocus && {
|
|
tabIndex: -1
|
|
}),
|
|
role: "columnheader",
|
|
id: (0, $2140fb2337097f2d$export$37cd4213f2ad742e)(state, node.key),
|
|
"aria-colspan": node.colspan && node.colspan > 1 ? node.colspan : null,
|
|
"aria-sort": ariaSort
|
|
}
|
|
};
|
|
}
|
|
|
|
|
|
/*
|
|
* 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.
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
const $b2db214c022798eb$var$EXPANSION_KEYS = {
|
|
expand: {
|
|
ltr: "ArrowRight",
|
|
rtl: "ArrowLeft"
|
|
},
|
|
"collapse": {
|
|
ltr: "ArrowLeft",
|
|
rtl: "ArrowRight"
|
|
}
|
|
};
|
|
function $b2db214c022798eb$export$7f2f6ae19e707aa5(props, state, ref) {
|
|
let { node: node, isVirtualized: isVirtualized } = props;
|
|
let { rowProps: rowProps, ...states } = (0, $lJcFS$useGridRow)(props, state, ref);
|
|
let { direction: direction } = (0, $lJcFS$useLocale)();
|
|
if (isVirtualized && !((0, $lJcFS$tableNestedRows)() && "expandedKeys" in state)) rowProps["aria-rowindex"] = node.index + 1 + state.collection.headerRows.length; // aria-rowindex is 1 based
|
|
else delete rowProps["aria-rowindex"];
|
|
let treeGridRowProps = {};
|
|
if ((0, $lJcFS$tableNestedRows)() && "expandedKeys" in state) {
|
|
let treeNode = state.keyMap.get(node.key);
|
|
if (treeNode != null) {
|
|
var _treeNode_props, _treeNode_props_children, _treeNode_props1;
|
|
let hasChildRows = ((_treeNode_props = treeNode.props) === null || _treeNode_props === void 0 ? void 0 : _treeNode_props.UNSTABLE_childItems) || ((_treeNode_props1 = treeNode.props) === null || _treeNode_props1 === void 0 ? void 0 : (_treeNode_props_children = _treeNode_props1.children) === null || _treeNode_props_children === void 0 ? void 0 : _treeNode_props_children.length) > state.userColumnCount;
|
|
treeGridRowProps = {
|
|
onKeyDown: (e)=>{
|
|
if (e.key === $b2db214c022798eb$var$EXPANSION_KEYS["expand"][direction] && state.selectionManager.focusedKey === treeNode.key && hasChildRows && state.expandedKeys !== "all" && !state.expandedKeys.has(treeNode.key)) {
|
|
state.toggleKey(treeNode.key);
|
|
e.stopPropagation();
|
|
} else if (e.key === $b2db214c022798eb$var$EXPANSION_KEYS["collapse"][direction] && state.selectionManager.focusedKey === treeNode.key && hasChildRows && (state.expandedKeys === "all" || state.expandedKeys.has(treeNode.key))) {
|
|
state.toggleKey(treeNode.key);
|
|
e.stopPropagation();
|
|
}
|
|
},
|
|
"aria-expanded": hasChildRows ? state.expandedKeys === "all" || state.expandedKeys.has(node.key) : undefined,
|
|
"aria-level": treeNode.level,
|
|
"aria-posinset": treeNode.indexOfType + 1,
|
|
"aria-setsize": treeNode.level > 1 ? (0, $lJcFS$getLastItem)(state.keyMap.get(treeNode === null || treeNode === void 0 ? void 0 : treeNode.parentKey).childNodes).indexOfType + 1 : (0, $lJcFS$getLastItem)(state.keyMap.get(state.collection.body.key).childNodes).indexOfType + 1
|
|
};
|
|
}
|
|
}
|
|
let linkProps = states.hasAction ? (0, $lJcFS$getSyntheticLinkProps)(node.props) : {};
|
|
return {
|
|
rowProps: {
|
|
...(0, $lJcFS$mergeProps)(rowProps, treeGridRowProps, linkProps),
|
|
"aria-labelledby": (0, $2140fb2337097f2d$export$85069b70317f543)(state, node.key)
|
|
},
|
|
...states
|
|
};
|
|
}
|
|
|
|
|
|
/*
|
|
* 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 $f917ee10f4c32dab$export$1b95a7d2d517b841(props, state, ref) {
|
|
let { node: node, isVirtualized: isVirtualized } = props;
|
|
let rowProps = {
|
|
role: "row"
|
|
};
|
|
if (isVirtualized && !((0, $lJcFS$tableNestedRows)() && "expandedKeys" in state)) rowProps["aria-rowindex"] = node.index + 1; // aria-rowindex is 1 based
|
|
return {
|
|
rowProps: rowProps
|
|
};
|
|
}
|
|
|
|
|
|
/*
|
|
* 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 $7713593715703b24$export$49571c903d73624c(props, state, ref) {
|
|
let { gridCellProps: gridCellProps, isPressed: isPressed } = (0, $lJcFS$useGridCell)(props, state, ref);
|
|
let columnKey = props.node.column.key;
|
|
if (state.collection.rowHeaderColumnKeys.has(columnKey)) {
|
|
gridCellProps.role = "rowheader";
|
|
gridCellProps.id = (0, $2140fb2337097f2d$export$19baff3266315d44)(state, props.node.parentKey, columnKey);
|
|
}
|
|
return {
|
|
gridCellProps: gridCellProps,
|
|
isPressed: isPressed
|
|
};
|
|
}
|
|
|
|
|
|
/*
|
|
* 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 $2a795c53a101c542$export$16ea7f650bd7c1bb(props, state) {
|
|
let { key: key } = props;
|
|
const { checkboxProps: checkboxProps } = (0, $lJcFS$useGridSelectionCheckbox)(props, state);
|
|
return {
|
|
checkboxProps: {
|
|
...checkboxProps,
|
|
"aria-labelledby": `${checkboxProps.id} ${(0, $2140fb2337097f2d$export$85069b70317f543)(state, key)}`
|
|
}
|
|
};
|
|
}
|
|
function $2a795c53a101c542$export$1003db6a7e384b99(state) {
|
|
let { isEmpty: isEmpty, isSelectAll: isSelectAll, selectionMode: selectionMode } = state.selectionManager;
|
|
const stringFormatter = (0, $lJcFS$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($7476b46781682bf5$exports))), "@react-aria/table");
|
|
return {
|
|
checkboxProps: {
|
|
"aria-label": stringFormatter.format(selectionMode === "single" ? "select" : "selectAll"),
|
|
isSelected: isSelectAll,
|
|
isDisabled: selectionMode !== "multiple" || state.collection.size === 0,
|
|
isIndeterminate: !isEmpty && !isSelectAll,
|
|
onChange: ()=>state.selectionManager.toggleSelectAll()
|
|
}
|
|
};
|
|
}
|
|
|
|
|
|
/*
|
|
* 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 $e91ef4e5004e3774$export$52994e973806c219(props, state, ref) {
|
|
let { column: item, triggerRef: triggerRef, isDisabled: isDisabled, onResizeStart: onResizeStart, onResize: onResize, onResizeEnd: onResizeEnd, "aria-label": ariaLabel } = props;
|
|
const stringFormatter = (0, $lJcFS$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($7476b46781682bf5$exports))), "@react-aria/table");
|
|
let id = (0, $lJcFS$useId)();
|
|
let isResizing = state.resizingColumn === item.key;
|
|
let isResizingRef = (0, $lJcFS$useRef)(isResizing);
|
|
let lastSize = (0, $lJcFS$useRef)(null);
|
|
let wasFocusedOnResizeStart = (0, $lJcFS$useRef)(false);
|
|
let editModeEnabled = state.tableState.isKeyboardNavigationDisabled;
|
|
let { direction: direction } = (0, $lJcFS$useLocale)();
|
|
let { keyboardProps: keyboardProps } = (0, $lJcFS$useKeyboard)({
|
|
onKeyDown: (e)=>{
|
|
if (editModeEnabled) {
|
|
if (e.key === "Escape" || e.key === "Enter" || e.key === " " || e.key === "Tab") {
|
|
e.preventDefault();
|
|
endResize(item);
|
|
}
|
|
} else {
|
|
// Continue propagation on keydown events so they still bubbles to useSelectableCollection and are handled there
|
|
e.continuePropagation();
|
|
if (e.key === "Enter") startResize(item);
|
|
}
|
|
}
|
|
});
|
|
let startResize = (0, $lJcFS$useEffectEvent)((item)=>{
|
|
if (!isResizingRef.current) {
|
|
lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
|
|
state.startResize(item.key);
|
|
state.tableState.setKeyboardNavigationDisabled(true);
|
|
onResizeStart === null || onResizeStart === void 0 ? void 0 : onResizeStart(lastSize.current);
|
|
}
|
|
isResizingRef.current = true;
|
|
});
|
|
let resize = (0, $lJcFS$useEffectEvent)((item, newWidth)=>{
|
|
let sizes = state.updateResizedColumns(item.key, newWidth);
|
|
onResize === null || onResize === void 0 ? void 0 : onResize(sizes);
|
|
lastSize.current = sizes;
|
|
});
|
|
let endResize = (0, $lJcFS$useEffectEvent)((item)=>{
|
|
if (isResizingRef.current) {
|
|
if (lastSize.current == null) lastSize.current = state.updateResizedColumns(item.key, state.getColumnWidth(item.key));
|
|
state.endResize();
|
|
state.tableState.setKeyboardNavigationDisabled(false);
|
|
onResizeEnd === null || onResizeEnd === void 0 ? void 0 : onResizeEnd(lastSize.current);
|
|
isResizingRef.current = false;
|
|
if ((triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) && !wasFocusedOnResizeStart.current) // switch focus back to the column header unless the resizer was already focused when resizing started.
|
|
(0, $lJcFS$focusSafely)(triggerRef.current);
|
|
}
|
|
lastSize.current = null;
|
|
});
|
|
const columnResizeWidthRef = (0, $lJcFS$useRef)(0);
|
|
const { moveProps: moveProps } = (0, $lJcFS$useMove)({
|
|
onMoveStart () {
|
|
columnResizeWidthRef.current = state.getColumnWidth(item.key);
|
|
startResize(item);
|
|
},
|
|
onMove (e) {
|
|
let { deltaX: deltaX, deltaY: deltaY, pointerType: pointerType } = e;
|
|
if (direction === "rtl") deltaX *= -1;
|
|
if (pointerType === "keyboard") {
|
|
if (deltaY !== 0 && deltaX === 0) deltaX = deltaY * -1;
|
|
deltaX *= 10;
|
|
}
|
|
// if moving up/down only, no need to resize
|
|
if (deltaX !== 0) {
|
|
columnResizeWidthRef.current += deltaX;
|
|
resize(item, columnResizeWidthRef.current);
|
|
}
|
|
},
|
|
onMoveEnd (e) {
|
|
let { pointerType: pointerType } = e;
|
|
columnResizeWidthRef.current = 0;
|
|
if (pointerType === "mouse" || pointerType === "touch" && wasFocusedOnResizeStart.current) endResize(item);
|
|
}
|
|
});
|
|
let onKeyDown = (0, $lJcFS$useCallback)((e)=>{
|
|
if (editModeEnabled) moveProps.onKeyDown(e);
|
|
}, [
|
|
editModeEnabled,
|
|
moveProps
|
|
]);
|
|
let min = Math.floor(state.getColumnMinWidth(item.key));
|
|
let max = Math.floor(state.getColumnMaxWidth(item.key));
|
|
if (max === Infinity) max = Number.MAX_SAFE_INTEGER;
|
|
let value = Math.floor(state.getColumnWidth(item.key));
|
|
let modality = (0, $lJcFS$useInteractionModality)();
|
|
if (modality === "virtual" && typeof window !== "undefined" && "ontouchstart" in window) modality = "touch";
|
|
let description = (triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) == null && (modality === "keyboard" || modality === "virtual") && !isResizing ? stringFormatter.format("resizerDescription") : undefined;
|
|
let descriptionProps = (0, $lJcFS$useDescription)(description);
|
|
let ariaProps = {
|
|
"aria-label": ariaLabel,
|
|
"aria-orientation": "horizontal",
|
|
"aria-labelledby": `${id} ${(0, $2140fb2337097f2d$export$37cd4213f2ad742e)(state.tableState, item.key)}`,
|
|
"aria-valuetext": stringFormatter.format("columnSize", {
|
|
value: value
|
|
}),
|
|
"type": "range",
|
|
min: min,
|
|
max: max,
|
|
value: value,
|
|
...descriptionProps
|
|
};
|
|
const focusInput = (0, $lJcFS$useCallback)(()=>{
|
|
if (ref.current) (0, $lJcFS$focusSafely)(ref.current);
|
|
}, [
|
|
ref
|
|
]);
|
|
let resizingColumn = state.resizingColumn;
|
|
let prevResizingColumn = (0, $lJcFS$useRef)(null);
|
|
(0, $lJcFS$useEffect)(()=>{
|
|
if (prevResizingColumn.current !== resizingColumn && resizingColumn != null && resizingColumn === item.key) {
|
|
wasFocusedOnResizeStart.current = document.activeElement === ref.current;
|
|
startResize(item);
|
|
// Delay focusing input until Android Chrome's delayed click after touchend happens: https://bugs.chromium.org/p/chromium/issues/detail?id=1150073
|
|
let timeout = setTimeout(()=>focusInput(), 0);
|
|
// VoiceOver on iOS has problems focusing the input from a menu.
|
|
let VOTimeout = setTimeout(focusInput, 400);
|
|
return ()=>{
|
|
clearTimeout(timeout);
|
|
clearTimeout(VOTimeout);
|
|
};
|
|
}
|
|
prevResizingColumn.current = resizingColumn;
|
|
}, [
|
|
resizingColumn,
|
|
item,
|
|
focusInput,
|
|
ref,
|
|
startResize
|
|
]);
|
|
let onChange = (e)=>{
|
|
let currentWidth = state.getColumnWidth(item.key);
|
|
let nextValue = parseFloat(e.target.value);
|
|
if (nextValue > currentWidth) nextValue = currentWidth + 10;
|
|
else nextValue = currentWidth - 10;
|
|
resize(item, nextValue);
|
|
};
|
|
let { pressProps: pressProps } = (0, $lJcFS$usePress)({
|
|
onPressStart: (e)=>{
|
|
if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey || e.pointerType === "keyboard") return;
|
|
if (e.pointerType === "virtual" && state.resizingColumn != null) {
|
|
endResize(item);
|
|
return;
|
|
}
|
|
// Sometimes onPress won't trigger for quick taps on mobile so we want to focus the input so blurring away
|
|
// can cancel resize mode for us.
|
|
focusInput();
|
|
// If resizer is always visible, mobile screenreader user can access the visually hidden resizer directly and thus we don't need
|
|
// to handle a virtual click to start the resizer.
|
|
if (e.pointerType !== "virtual") startResize(item);
|
|
},
|
|
onPress: (e)=>{
|
|
if ((e.pointerType === "touch" && wasFocusedOnResizeStart.current || e.pointerType === "mouse") && state.resizingColumn != null) endResize(item);
|
|
}
|
|
});
|
|
let { visuallyHiddenProps: visuallyHiddenProps } = (0, $lJcFS$useVisuallyHidden)();
|
|
return {
|
|
resizerProps: (0, $lJcFS$mergeProps)(keyboardProps, {
|
|
...moveProps,
|
|
onKeyDown: onKeyDown
|
|
}, pressProps, {
|
|
style: {
|
|
touchAction: "none"
|
|
}
|
|
}),
|
|
inputProps: (0, $lJcFS$mergeProps)(visuallyHiddenProps, {
|
|
id: id,
|
|
onBlur: ()=>{
|
|
endResize(item);
|
|
},
|
|
onChange: onChange,
|
|
disabled: isDisabled
|
|
}, ariaProps),
|
|
isResizing: isResizing
|
|
};
|
|
}
|
|
|
|
|
|
|
|
function $0047e6c294ea075f$export$6fb1613bd7b28198() {
|
|
return (0, $lJcFS$useGridRowGroup)();
|
|
}
|
|
|
|
|
|
export {$0047e6c294ea075f$export$6fb1613bd7b28198 as useTableRowGroup, $6e31608fbba75bab$export$25bceaac3c7e4dc7 as useTable, $f329116d8ad0aba0$export$9514819a8c81e960 as useTableColumnHeader, $b2db214c022798eb$export$7f2f6ae19e707aa5 as useTableRow, $f917ee10f4c32dab$export$1b95a7d2d517b841 as useTableHeaderRow, $7713593715703b24$export$49571c903d73624c as useTableCell, $2a795c53a101c542$export$16ea7f650bd7c1bb as useTableSelectionCheckbox, $2a795c53a101c542$export$1003db6a7e384b99 as useTableSelectAllCheckbox, $e91ef4e5004e3774$export$52994e973806c219 as useTableColumnResize};
|
|
//# sourceMappingURL=module.js.map
|