Files
NapCatQQ/.pnpm-store/v3/files/ac/98888ebc0422e004762fbc6125f4387594648d3b8fe5a0826f3f9d0d5770b878e1136716745c376c47e4de6be01a2e5b366f88f72e932ab1d9f9212079156b
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

118 lines
6.4 KiB
Plaintext

var $c9aa5a224613c979$exports = require("./ListCollection.main.js");
var $5RsKl$reactstatelyselection = require("@react-stately/selection");
var $5RsKl$react = require("react");
var $5RsKl$reactstatelycollections = require("@react-stately/collections");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "useListState", () => $5450691d3629f6ea$export$2f645645f7bca764);
$parcel$export(module.exports, "UNSTABLE_useFilteredListState", () => $5450691d3629f6ea$export$ba9d38c0f1bf2b36);
/*
* 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 $5450691d3629f6ea$export$2f645645f7bca764(props) {
let { filter: filter, layoutDelegate: layoutDelegate } = props;
let selectionState = (0, $5RsKl$reactstatelyselection.useMultipleSelectionState)(props);
let disabledKeys = (0, $5RsKl$react.useMemo)(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set(), [
props.disabledKeys
]);
let factory = (0, $5RsKl$react.useCallback)((nodes)=>filter ? new (0, $c9aa5a224613c979$exports.ListCollection)(filter(nodes)) : new (0, $c9aa5a224613c979$exports.ListCollection)(nodes), [
filter
]);
let context = (0, $5RsKl$react.useMemo)(()=>({
suppressTextValueWarning: props.suppressTextValueWarning
}), [
props.suppressTextValueWarning
]);
let collection = (0, $5RsKl$reactstatelycollections.useCollection)(props, factory, context);
let selectionManager = (0, $5RsKl$react.useMemo)(()=>new (0, $5RsKl$reactstatelyselection.SelectionManager)(collection, selectionState, {
layoutDelegate: layoutDelegate
}), [
collection,
selectionState,
layoutDelegate
]);
$5450691d3629f6ea$var$useFocusedKeyReset(collection, selectionManager);
return {
collection: collection,
disabledKeys: disabledKeys,
selectionManager: selectionManager
};
}
function $5450691d3629f6ea$export$ba9d38c0f1bf2b36(state, filterFn) {
let collection = (0, $5RsKl$react.useMemo)(()=>filterFn ? state.collection.filter(filterFn) : state.collection, [
state.collection,
filterFn
]);
let selectionManager = state.selectionManager.withCollection(collection);
$5450691d3629f6ea$var$useFocusedKeyReset(collection, selectionManager);
return {
collection: collection,
selectionManager: selectionManager,
disabledKeys: state.disabledKeys
};
}
function $5450691d3629f6ea$var$useFocusedKeyReset(collection, selectionManager) {
// Reset focused key if that item is deleted from the collection.
const cachedCollection = (0, $5RsKl$react.useRef)(null);
(0, $5RsKl$react.useEffect)(()=>{
if (selectionManager.focusedKey != null && !collection.getItem(selectionManager.focusedKey) && cachedCollection.current) {
const startItem = cachedCollection.current.getItem(selectionManager.focusedKey);
const cachedItemNodes = [
...cachedCollection.current.getKeys()
].map((key)=>{
const itemNode = cachedCollection.current.getItem(key);
return (itemNode === null || itemNode === void 0 ? void 0 : itemNode.type) === 'item' ? itemNode : null;
}).filter((node)=>node !== null);
const itemNodes = [
...collection.getKeys()
].map((key)=>{
const itemNode = collection.getItem(key);
return (itemNode === null || itemNode === void 0 ? void 0 : itemNode.type) === 'item' ? itemNode : null;
}).filter((node)=>node !== null);
var _cachedItemNodes_length, _itemNodes_length;
const diff = ((_cachedItemNodes_length = cachedItemNodes === null || cachedItemNodes === void 0 ? void 0 : cachedItemNodes.length) !== null && _cachedItemNodes_length !== void 0 ? _cachedItemNodes_length : 0) - ((_itemNodes_length = itemNodes === null || itemNodes === void 0 ? void 0 : itemNodes.length) !== null && _itemNodes_length !== void 0 ? _itemNodes_length : 0);
var _startItem_index, _startItem_index1, _itemNodes_length1;
let index = Math.min(diff > 1 ? Math.max(((_startItem_index = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0) - diff + 1, 0) : (_startItem_index1 = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index1 !== void 0 ? _startItem_index1 : 0, ((_itemNodes_length1 = itemNodes === null || itemNodes === void 0 ? void 0 : itemNodes.length) !== null && _itemNodes_length1 !== void 0 ? _itemNodes_length1 : 0) - 1);
let newNode = null;
let isReverseSearching = false;
while(index >= 0){
if (!selectionManager.isDisabled(itemNodes[index].key)) {
newNode = itemNodes[index];
break;
}
// Find next, not disabled item.
if (index < itemNodes.length - 1 && !isReverseSearching) index++;
else {
isReverseSearching = true;
var _startItem_index2, _startItem_index3;
if (index > ((_startItem_index2 = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index2 !== void 0 ? _startItem_index2 : 0)) index = (_startItem_index3 = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index3 !== void 0 ? _startItem_index3 : 0;
index--;
}
}
selectionManager.setFocusedKey(newNode ? newNode.key : null);
}
cachedCollection.current = collection;
}, [
collection,
selectionManager
]);
}
//# sourceMappingURL=useListState.main.js.map