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

69 lines
2.9 KiB
Plaintext

var $fae56b53b03726ff$exports = require("./TreeCollection.main.js");
var $abPLV$reactstatelyselection = require("@react-stately/selection");
var $abPLV$react = require("react");
var $abPLV$reactstatelycollections = require("@react-stately/collections");
var $abPLV$reactstatelyutils = require("@react-stately/utils");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "useTreeState", () => $38effb299000faaf$export$728d6ba534403756);
/*
* 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 $38effb299000faaf$export$728d6ba534403756(props) {
let { onExpandedChange: onExpandedChange } = props;
let [expandedKeys, setExpandedKeys] = (0, $abPLV$reactstatelyutils.useControlledState)(props.expandedKeys ? new Set(props.expandedKeys) : undefined, props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set(), onExpandedChange);
let selectionState = (0, $abPLV$reactstatelyselection.useMultipleSelectionState)(props);
let disabledKeys = (0, $abPLV$react.useMemo)(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set(), [
props.disabledKeys
]);
let tree = (0, $abPLV$reactstatelycollections.useCollection)(props, (0, $abPLV$react.useCallback)((nodes)=>new (0, $fae56b53b03726ff$exports.TreeCollection)(nodes, {
expandedKeys: expandedKeys
}), [
expandedKeys
]), null);
// Reset focused key if that item is deleted from the collection.
(0, $abPLV$react.useEffect)(()=>{
if (selectionState.focusedKey != null && !tree.getItem(selectionState.focusedKey)) selectionState.setFocusedKey(null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
tree,
selectionState.focusedKey
]);
let onToggle = (key)=>{
setExpandedKeys($38effb299000faaf$var$toggleKey(expandedKeys, key));
};
return {
collection: tree,
expandedKeys: expandedKeys,
disabledKeys: disabledKeys,
toggleKey: onToggle,
setExpandedKeys: setExpandedKeys,
selectionManager: new (0, $abPLV$reactstatelyselection.SelectionManager)(tree, selectionState)
};
}
function $38effb299000faaf$var$toggleKey(set, key) {
let res = new Set(set);
if (res.has(key)) res.delete(key);
else res.add(key);
return res;
}
//# sourceMappingURL=useTreeState.main.js.map