@react-stately/tree 3.2.1 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1,7 +1,7 @@
1
- var $g0QeW$react = require("react");
2
- var $g0QeW$reactstatelyselection = require("@react-stately/selection");
3
- var $g0QeW$reactstatelycollections = require("@react-stately/collections");
4
- var $g0QeW$reactstatelyutils = require("@react-stately/utils");
1
+ var $8jMun$react = require("react");
2
+ var $8jMun$reactstatelyselection = require("@react-stately/selection");
3
+ var $8jMun$reactstatelycollections = require("@react-stately/collections");
4
+ var $8jMun$reactstatelyutils = require("@react-stately/utils");
5
5
 
6
6
  function $parcel$exportWildcard(dest, source) {
7
7
  Object.keys(source).forEach(function(key) {
@@ -22,41 +22,14 @@ function $parcel$exportWildcard(dest, source) {
22
22
  function $parcel$export(e, n, v, s) {
23
23
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
24
24
  }
25
- var $89057d8278b2b959$exports = {};
25
+ var $9fca792b9f1dbe9f$exports = {};
26
26
 
27
- $parcel$export($89057d8278b2b959$exports, "useTreeState", () => $89057d8278b2b959$export$728d6ba534403756);
27
+ $parcel$export($9fca792b9f1dbe9f$exports, "useTreeState", () => $9fca792b9f1dbe9f$export$728d6ba534403756);
28
28
 
29
29
 
30
- class $ed9110bedb94f15e$export$863faf230ee2118a {
31
- constructor(nodes, { expandedKeys: expandedKeys } = {
32
- }){
33
- this.keyMap = new Map();
34
- this.iterable = nodes;
35
- expandedKeys = expandedKeys || new Set();
36
- let visit = (node)=>{
37
- this.keyMap.set(node.key, node);
38
- if (node.childNodes && (node.type === 'section' || expandedKeys.has(node.key))) for (let child of node.childNodes)visit(child);
39
- };
40
- for (let node2 of nodes)visit(node2);
41
- let last;
42
- let index = 0;
43
- for (let [key, node1] of this.keyMap){
44
- if (last) {
45
- last.nextKey = key;
46
- node1.prevKey = last.key;
47
- } else {
48
- this.firstKey = key;
49
- node1.prevKey = undefined;
50
- }
51
- if (node1.type === 'item') node1.index = index++;
52
- last = node1;
53
- // Set nextKey as undefined since this might be the last node
54
- // If it isn't the last node, last.nextKey will properly set at start of new loop
55
- last.nextKey = undefined;
56
- }
57
- this.lastKey = last?.key;
58
- }
59
- *[Symbol.iterator]() {
30
+ var tmp = Symbol.iterator;
31
+ class $dd657f4eb6746c96$export$863faf230ee2118a {
32
+ *[tmp]() {
60
33
  yield* this.iterable;
61
34
  }
62
35
  get size() {
@@ -88,43 +61,71 @@ class $ed9110bedb94f15e$export$863faf230ee2118a {
88
61
  ];
89
62
  return this.getItem(keys[idx]);
90
63
  }
64
+ constructor(nodes, { expandedKeys: expandedKeys } = {
65
+ }){
66
+ this.keyMap = new Map();
67
+ this.iterable = nodes;
68
+ expandedKeys = expandedKeys || new Set();
69
+ let visit = (node)=>{
70
+ this.keyMap.set(node.key, node);
71
+ if (node.childNodes && (node.type === 'section' || expandedKeys.has(node.key))) for (let child of node.childNodes)visit(child);
72
+ };
73
+ for (let node2 of nodes)visit(node2);
74
+ let last;
75
+ let index = 0;
76
+ for (let [key, node1] of this.keyMap){
77
+ if (last) {
78
+ last.nextKey = key;
79
+ node1.prevKey = last.key;
80
+ } else {
81
+ this.firstKey = key;
82
+ node1.prevKey = undefined;
83
+ }
84
+ if (node1.type === 'item') node1.index = index++;
85
+ last = node1;
86
+ // Set nextKey as undefined since this might be the last node
87
+ // If it isn't the last node, last.nextKey will properly set at start of new loop
88
+ last.nextKey = undefined;
89
+ }
90
+ this.lastKey = last === null || last === void 0 ? void 0 : last.key;
91
+ }
91
92
  }
92
93
 
93
94
 
94
95
 
95
96
 
96
- function $89057d8278b2b959$export$728d6ba534403756(props) {
97
- let [expandedKeys, setExpandedKeys] = $g0QeW$reactstatelyutils.useControlledState(props.expandedKeys ? new Set(props.expandedKeys) : undefined, props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set(), props.onExpandedChange);
98
- let selectionState = $g0QeW$reactstatelyselection.useMultipleSelectionState(props);
99
- let disabledKeys = $g0QeW$react.useMemo(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set()
97
+ function $9fca792b9f1dbe9f$export$728d6ba534403756(props) {
98
+ let [expandedKeys, setExpandedKeys] = $8jMun$reactstatelyutils.useControlledState(props.expandedKeys ? new Set(props.expandedKeys) : undefined, props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set(), props.onExpandedChange);
99
+ let selectionState = $8jMun$reactstatelyselection.useMultipleSelectionState(props);
100
+ let disabledKeys = $8jMun$react.useMemo(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set()
100
101
  , [
101
102
  props.disabledKeys
102
103
  ]);
103
- let tree = $g0QeW$reactstatelycollections.useCollection(props, (nodes)=>new $ed9110bedb94f15e$export$863faf230ee2118a(nodes, {
104
+ let tree = $8jMun$reactstatelycollections.useCollection(props, (nodes)=>new $dd657f4eb6746c96$export$863faf230ee2118a(nodes, {
104
105
  expandedKeys: expandedKeys
105
106
  })
106
107
  , null, [
107
108
  expandedKeys
108
109
  ]);
109
110
  // Reset focused key if that item is deleted from the collection.
110
- $g0QeW$react.useEffect(()=>{
111
+ $8jMun$react.useEffect(()=>{
111
112
  if (selectionState.focusedKey != null && !tree.getItem(selectionState.focusedKey)) selectionState.setFocusedKey(null);
112
113
  }, [
113
114
  tree,
114
115
  selectionState.focusedKey
115
116
  ]);
116
117
  let onToggle = (key)=>{
117
- setExpandedKeys($89057d8278b2b959$var$toggleKey(expandedKeys, key));
118
+ setExpandedKeys($9fca792b9f1dbe9f$var$toggleKey(expandedKeys, key));
118
119
  };
119
120
  return {
120
121
  collection: tree,
121
122
  expandedKeys: expandedKeys,
122
123
  disabledKeys: disabledKeys,
123
124
  toggleKey: onToggle,
124
- selectionManager: new $g0QeW$reactstatelyselection.SelectionManager(tree, selectionState)
125
+ selectionManager: new $8jMun$reactstatelyselection.SelectionManager(tree, selectionState)
125
126
  };
126
127
  }
127
- function $89057d8278b2b959$var$toggleKey(set, key) {
128
+ function $9fca792b9f1dbe9f$var$toggleKey(set, key) {
128
129
  let res = new Set(set);
129
130
  if (res.has(key)) res.delete(key);
130
131
  else res.add(key);
@@ -132,7 +133,7 @@ function $89057d8278b2b959$var$toggleKey(set, key) {
132
133
  }
133
134
 
134
135
 
135
- $parcel$exportWildcard(module.exports, $89057d8278b2b959$exports);
136
+ $parcel$exportWildcard(module.exports, $9fca792b9f1dbe9f$exports);
136
137
 
137
138
 
138
139
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;MEea,yCAAc;gBAMb,KAAwB,EAAE,CAAC,eAAA,YAAY,EAA2B,CAAC,GAAG,CAAC;IAAA,CAAC,CAAE,CAAC;QANlF,IAuFN,CAtFS,MAAM,GAAsB,GAAG,CAAC,GAAG;QAMzC,IAAI,CAAC,QAAQ,GAAG,KAAK;QACrB,YAAY,GAAG,YAAY,IAAI,GAAG,CAAC,GAAG;QAEtC,GAAG,CAAC,KAAK,IAAI,IAAa,GAAK,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI;YAE9B,EAAE,EAAE,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,IAAI,KAAK,CAAS,YAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,IAC1E,GAAG,EAAE,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,CAC/B,KAAK,CAAC,KAAK;QAGjB,CAAC;QAED,GAAG,EAAE,GAAG,CAAC,KAAI,IAAI,KAAK,CACpB,KAAK,CAAC,KAAI;QAGZ,GAAG,CAAC,IAAI;QACR,GAAG,CAAC,KAAK,GAAG,CAAC;QACb,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAAI,KAAK,IAAI,CAAC,MAAM,CAAE,CAAC;YACpC,EAAE,EAAE,IAAI,EAAE,CAAC;gBACT,IA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CAAC,UAAU;IAAA,CAAC;IAEpC,GAAG,CAAC,QAAQ,IAAI,GAAQ,GAAK,CAAC;QAC5B,eAAe,CAAC,+BAAS,CAAC,YAAY,EAAE,GAAG;IAC7C,CAAC;IAED,MAAM,CAAC,CAAC;QACN,UAAU,EAAE,IAAI;sBAChB,YAAY;sBACZ,YAAY;QACZ,SAAS,EAAE,QAAQ;QACnB,gBAAgB,EAAE,GAAG,CAAC,6CAAgB,CAAC,IAAI,EAAE,cAAc;IAC7D,CAAC;AACH,CAAC;SAEQ,+BAAS,CAAC,GAAa,EAAE,GAAQ,EAAY,CAAC;IACrD,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG;IACrB,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,GACb,GAAG,CAAC,MAAM,CAAC,GAAG;SAEd,GAAG,CAAC,GAAG,CAAC,GAAG;IAGb,MAAM,CAAC,GAAG;AACZ,CAAC","sources":["packages/@react-stately/tree/src/index.ts","packages/@react-stately/tree/src/useTreeState.ts","packages/@react-stately/tree/src/TreeCollection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useTreeState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, CollectionBase, Expandable, MultipleSelection, Node} from '@react-types/shared';\nimport {Key, useEffect, useMemo} from 'react';\nimport {SelectionManager, useMultipleSelectionState} from '@react-stately/selection';\nimport {TreeCollection} from './TreeCollection';\nimport {useCollection} from '@react-stately/collections';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface TreeProps<T> extends CollectionBase<T>, Expandable, MultipleSelection {}\nexport interface TreeState<T> {\n /** A collection of items in the tree. */\n readonly collection: Collection<Node<T>>,\n\n /** A set of keys for items that are disabled. */\n readonly disabledKeys: Set<Key>,\n\n /** A set of keys for items that are expanded. */\n readonly expandedKeys: Set<Key>,\n\n /** Toggles the expanded state for an item by its key. */\n toggleKey(key: Key): void,\n\n /** A selection manager to read and update multiple selection state. */\n readonly selectionManager: SelectionManager\n}\n\n/**\n * Provides state management for tree-like components. Handles building a collection\n * of items from props, item expanded state, and manages multiple selection state.\n */\nexport function useTreeState<T extends object>(props: TreeProps<T>): TreeState<T> {\n let [expandedKeys, setExpandedKeys] = useControlledState(\n props.expandedKeys ? new Set(props.expandedKeys) : undefined,\n props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set(),\n props.onExpandedChange\n );\n\n let selectionState = useMultipleSelectionState(props);\n let disabledKeys = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n\n let tree = useCollection(props, nodes => new TreeCollection(nodes, {expandedKeys}), null, [expandedKeys]);\n\n // Reset focused key if that item is deleted from the collection.\n useEffect(() => {\n if (selectionState.focusedKey != null && !tree.getItem(selectionState.focusedKey)) {\n selectionState.setFocusedKey(null);\n }\n }, [tree, selectionState.focusedKey]);\n\n let onToggle = (key: Key) => {\n setExpandedKeys(toggleKey(expandedKeys, key));\n };\n\n return {\n collection: tree,\n expandedKeys,\n disabledKeys,\n toggleKey: onToggle,\n selectionManager: new SelectionManager(tree, selectionState)\n };\n}\n\nfunction toggleKey(set: Set<Key>, key: Key): Set<Key> {\n let res = new Set(set);\n if (res.has(key)) {\n res.delete(key);\n } else {\n res.add(key);\n }\n\n return res;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Node} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport class TreeCollection<T> implements Collection<Node<T>> {\n private keyMap: Map<Key, Node<T>> = new Map();\n private iterable: Iterable<Node<T>>;\n private firstKey: Key;\n private lastKey: Key;\n\n constructor(nodes: Iterable<Node<T>>, {expandedKeys}: {expandedKeys?: Set<Key>} = {}) {\n this.iterable = nodes;\n expandedKeys = expandedKeys || new Set();\n\n let visit = (node: Node<T>) => {\n this.keyMap.set(node.key, node);\n\n if (node.childNodes && (node.type === 'section' || expandedKeys.has(node.key))) {\n for (let child of node.childNodes) {\n visit(child);\n }\n }\n };\n\n for (let node of nodes) {\n visit(node);\n }\n\n let last: Node<T>;\n let index = 0;\n for (let [key, node] of this.keyMap) {\n if (last) {\n last.nextKey = key;\n node.prevKey = last.key;\n } else {\n this.firstKey = key;\n node.prevKey = undefined;\n }\n\n if (node.type === 'item') {\n node.index = index++;\n }\n\n last = node;\n\n // Set nextKey as undefined since this might be the last node\n // If it isn't the last node, last.nextKey will properly set at start of new loop\n last.nextKey = undefined;\n }\n\n this.lastKey = last?.key;\n }\n\n *[Symbol.iterator]() {\n yield* this.iterable;\n }\n\n get size() {\n return this.keyMap.size;\n }\n\n getKeys() {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.prevKey : null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey : null;\n }\n\n getFirstKey() {\n return this.firstKey;\n }\n\n getLastKey() {\n return this.lastKey;\n }\n\n getItem(key: Key) {\n return this.keyMap.get(key);\n }\n\n at(idx: number) {\n const keys = [...this.getKeys()];\n return this.getItem(keys[idx]);\n }\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;UEgEI,MAAM,CAAC,QAAQ;MAjDN,yCAAc;aAiDJ,CAAC;eACb,IAAI,CAAC,QAAQ;IACtB,CAAC;QAEG,IAAI,GAAG,CAAC;QACV,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB,CAAC;IAED,OAAO,GAAG,CAAC;QACT,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB,CAAC;IAED,YAAY,CAAC,GAAQ,EAAE,CAAC;QACtB,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG;QAC9B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI;IACnC,CAAC;IAED,WAAW,CAAC,GAAQ,EAAE,CAAC;QACrB,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG;QAC9B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI;IACnC,CAAC;IAED,WAAW,GAAG,CAAC;QACb,MAAM,CAAC,IAAI,CAAC,QAAQ;IACtB,CAAC;IAED,UAAU,GAAG,CAAC;QACZ,MAAM,CAAC,IAAI,CAAC,OAAO;IACrB,CAAC;IAED,OAAO,CAAC,GAAQ,EAAE,CAAC;QACjB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG;IAC5B,CAAC;IAED,EAAE,CAAC,GAAW,EAAE,CAAC;QACf,KAAK,CAAC,I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,CAAC,UAAU;IAAA,CAAC;IAEpC,GAAG,CAAC,QAAQ,IAAI,GAAQ,GAAK,CAAC;QAC5B,eAAe,CAAC,+BAAS,CAAC,YAAY,EAAE,GAAG;IAC7C,CAAC;IAED,MAAM,CAAC,CAAC;QACN,UAAU,EAAE,IAAI;sBAChB,YAAY;sBACZ,YAAY;QACZ,SAAS,EAAE,QAAQ;QACnB,gBAAgB,EAAE,GAAG,CAAC,6CAAgB,CAAC,IAAI,EAAE,cAAc;IAC7D,CAAC;AACH,CAAC;SAEQ,+BAAS,CAAC,GAAa,EAAE,GAAQ,EAAY,CAAC;IACrD,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG;IACrB,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,GACb,GAAG,CAAC,MAAM,CAAC,GAAG;SAEd,GAAG,CAAC,GAAG,CAAC,GAAG;IAGb,MAAM,CAAC,GAAG;AACZ,CAAC","sources":["packages/@react-stately/tree/src/index.ts","packages/@react-stately/tree/src/useTreeState.ts","packages/@react-stately/tree/src/TreeCollection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useTreeState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, CollectionBase, Expandable, MultipleSelection, Node} from '@react-types/shared';\nimport {Key, useEffect, useMemo} from 'react';\nimport {SelectionManager, useMultipleSelectionState} from '@react-stately/selection';\nimport {TreeCollection} from './TreeCollection';\nimport {useCollection} from '@react-stately/collections';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface TreeProps<T> extends CollectionBase<T>, Expandable, MultipleSelection {}\nexport interface TreeState<T> {\n /** A collection of items in the tree. */\n readonly collection: Collection<Node<T>>,\n\n /** A set of keys for items that are disabled. */\n readonly disabledKeys: Set<Key>,\n\n /** A set of keys for items that are expanded. */\n readonly expandedKeys: Set<Key>,\n\n /** Toggles the expanded state for an item by its key. */\n toggleKey(key: Key): void,\n\n /** A selection manager to read and update multiple selection state. */\n readonly selectionManager: SelectionManager\n}\n\n/**\n * Provides state management for tree-like components. Handles building a collection\n * of items from props, item expanded state, and manages multiple selection state.\n */\nexport function useTreeState<T extends object>(props: TreeProps<T>): TreeState<T> {\n let [expandedKeys, setExpandedKeys] = useControlledState(\n props.expandedKeys ? new Set(props.expandedKeys) : undefined,\n props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set(),\n props.onExpandedChange\n );\n\n let selectionState = useMultipleSelectionState(props);\n let disabledKeys = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n\n let tree = useCollection(props, nodes => new TreeCollection(nodes, {expandedKeys}), null, [expandedKeys]);\n\n // Reset focused key if that item is deleted from the collection.\n useEffect(() => {\n if (selectionState.focusedKey != null && !tree.getItem(selectionState.focusedKey)) {\n selectionState.setFocusedKey(null);\n }\n }, [tree, selectionState.focusedKey]);\n\n let onToggle = (key: Key) => {\n setExpandedKeys(toggleKey(expandedKeys, key));\n };\n\n return {\n collection: tree,\n expandedKeys,\n disabledKeys,\n toggleKey: onToggle,\n selectionManager: new SelectionManager(tree, selectionState)\n };\n}\n\nfunction toggleKey(set: Set<Key>, key: Key): Set<Key> {\n let res = new Set(set);\n if (res.has(key)) {\n res.delete(key);\n } else {\n res.add(key);\n }\n\n return res;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Node} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport class TreeCollection<T> implements Collection<Node<T>> {\n private keyMap: Map<Key, Node<T>> = new Map();\n private iterable: Iterable<Node<T>>;\n private firstKey: Key;\n private lastKey: Key;\n\n constructor(nodes: Iterable<Node<T>>, {expandedKeys}: {expandedKeys?: Set<Key>} = {}) {\n this.iterable = nodes;\n expandedKeys = expandedKeys || new Set();\n\n let visit = (node: Node<T>) => {\n this.keyMap.set(node.key, node);\n\n if (node.childNodes && (node.type === 'section' || expandedKeys.has(node.key))) {\n for (let child of node.childNodes) {\n visit(child);\n }\n }\n };\n\n for (let node of nodes) {\n visit(node);\n }\n\n let last: Node<T>;\n let index = 0;\n for (let [key, node] of this.keyMap) {\n if (last) {\n last.nextKey = key;\n node.prevKey = last.key;\n } else {\n this.firstKey = key;\n node.prevKey = undefined;\n }\n\n if (node.type === 'item') {\n node.index = index++;\n }\n\n last = node;\n\n // Set nextKey as undefined since this might be the last node\n // If it isn't the last node, last.nextKey will properly set at start of new loop\n last.nextKey = undefined;\n }\n\n this.lastKey = last?.key;\n }\n\n *[Symbol.iterator]() {\n yield* this.iterable;\n }\n\n get size() {\n return this.keyMap.size;\n }\n\n getKeys() {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.prevKey : null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey : null;\n }\n\n getFirstKey() {\n return this.firstKey;\n }\n\n getLastKey() {\n return this.lastKey;\n }\n\n getItem(key: Key) {\n return this.keyMap.get(key);\n }\n\n at(idx: number) {\n const keys = [...this.getKeys()];\n return this.getItem(keys[idx]);\n }\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,46 +1,19 @@
1
- import {useMemo as $l43NX$useMemo, useEffect as $l43NX$useEffect} from "react";
2
- import {useMultipleSelectionState as $l43NX$useMultipleSelectionState, SelectionManager as $l43NX$SelectionManager} from "@react-stately/selection";
3
- import {useCollection as $l43NX$useCollection} from "@react-stately/collections";
4
- import {useControlledState as $l43NX$useControlledState} from "@react-stately/utils";
1
+ import {useMemo as $9TXm6$useMemo, useEffect as $9TXm6$useEffect} from "react";
2
+ import {useMultipleSelectionState as $9TXm6$useMultipleSelectionState, SelectionManager as $9TXm6$SelectionManager} from "@react-stately/selection";
3
+ import {useCollection as $9TXm6$useCollection} from "@react-stately/collections";
4
+ import {useControlledState as $9TXm6$useControlledState} from "@react-stately/utils";
5
5
 
6
6
  function $parcel$export(e, n, v, s) {
7
7
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
8
  }
9
- var $443b2488e6fa10fb$exports = {};
9
+ var $36d99f0640511db5$exports = {};
10
10
 
11
- $parcel$export($443b2488e6fa10fb$exports, "useTreeState", () => $443b2488e6fa10fb$export$728d6ba534403756);
11
+ $parcel$export($36d99f0640511db5$exports, "useTreeState", () => $36d99f0640511db5$export$728d6ba534403756);
12
12
 
13
13
 
14
- class $62dcb9c0c42c454a$export$863faf230ee2118a {
15
- constructor(nodes, { expandedKeys: expandedKeys } = {
16
- }){
17
- this.keyMap = new Map();
18
- this.iterable = nodes;
19
- expandedKeys = expandedKeys || new Set();
20
- let visit = (node)=>{
21
- this.keyMap.set(node.key, node);
22
- if (node.childNodes && (node.type === 'section' || expandedKeys.has(node.key))) for (let child of node.childNodes)visit(child);
23
- };
24
- for (let node2 of nodes)visit(node2);
25
- let last;
26
- let index = 0;
27
- for (let [key, node1] of this.keyMap){
28
- if (last) {
29
- last.nextKey = key;
30
- node1.prevKey = last.key;
31
- } else {
32
- this.firstKey = key;
33
- node1.prevKey = undefined;
34
- }
35
- if (node1.type === 'item') node1.index = index++;
36
- last = node1;
37
- // Set nextKey as undefined since this might be the last node
38
- // If it isn't the last node, last.nextKey will properly set at start of new loop
39
- last.nextKey = undefined;
40
- }
41
- this.lastKey = last?.key;
42
- }
43
- *[Symbol.iterator]() {
14
+ var tmp = Symbol.iterator;
15
+ class $c8161626733397a0$export$863faf230ee2118a {
16
+ *[tmp]() {
44
17
  yield* this.iterable;
45
18
  }
46
19
  get size() {
@@ -72,43 +45,71 @@ class $62dcb9c0c42c454a$export$863faf230ee2118a {
72
45
  ];
73
46
  return this.getItem(keys[idx]);
74
47
  }
48
+ constructor(nodes, { expandedKeys: expandedKeys } = {
49
+ }){
50
+ this.keyMap = new Map();
51
+ this.iterable = nodes;
52
+ expandedKeys = expandedKeys || new Set();
53
+ let visit = (node)=>{
54
+ this.keyMap.set(node.key, node);
55
+ if (node.childNodes && (node.type === 'section' || expandedKeys.has(node.key))) for (let child of node.childNodes)visit(child);
56
+ };
57
+ for (let node2 of nodes)visit(node2);
58
+ let last;
59
+ let index = 0;
60
+ for (let [key, node1] of this.keyMap){
61
+ if (last) {
62
+ last.nextKey = key;
63
+ node1.prevKey = last.key;
64
+ } else {
65
+ this.firstKey = key;
66
+ node1.prevKey = undefined;
67
+ }
68
+ if (node1.type === 'item') node1.index = index++;
69
+ last = node1;
70
+ // Set nextKey as undefined since this might be the last node
71
+ // If it isn't the last node, last.nextKey will properly set at start of new loop
72
+ last.nextKey = undefined;
73
+ }
74
+ this.lastKey = last === null || last === void 0 ? void 0 : last.key;
75
+ }
75
76
  }
76
77
 
77
78
 
78
79
 
79
80
 
80
- function $443b2488e6fa10fb$export$728d6ba534403756(props) {
81
- let [expandedKeys, setExpandedKeys] = $l43NX$useControlledState(props.expandedKeys ? new Set(props.expandedKeys) : undefined, props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set(), props.onExpandedChange);
82
- let selectionState = $l43NX$useMultipleSelectionState(props);
83
- let disabledKeys = $l43NX$useMemo(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set()
81
+ function $36d99f0640511db5$export$728d6ba534403756(props) {
82
+ let [expandedKeys, setExpandedKeys] = $9TXm6$useControlledState(props.expandedKeys ? new Set(props.expandedKeys) : undefined, props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set(), props.onExpandedChange);
83
+ let selectionState = $9TXm6$useMultipleSelectionState(props);
84
+ let disabledKeys = $9TXm6$useMemo(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set()
84
85
  , [
85
86
  props.disabledKeys
86
87
  ]);
87
- let tree = $l43NX$useCollection(props, (nodes)=>new $62dcb9c0c42c454a$export$863faf230ee2118a(nodes, {
88
+ let tree = $9TXm6$useCollection(props, (nodes)=>new $c8161626733397a0$export$863faf230ee2118a(nodes, {
88
89
  expandedKeys: expandedKeys
89
90
  })
90
91
  , null, [
91
92
  expandedKeys
92
93
  ]);
93
94
  // Reset focused key if that item is deleted from the collection.
94
- $l43NX$useEffect(()=>{
95
+ $9TXm6$useEffect(()=>{
95
96
  if (selectionState.focusedKey != null && !tree.getItem(selectionState.focusedKey)) selectionState.setFocusedKey(null);
96
97
  }, [
97
98
  tree,
98
99
  selectionState.focusedKey
99
100
  ]);
100
101
  let onToggle = (key)=>{
101
- setExpandedKeys($443b2488e6fa10fb$var$toggleKey(expandedKeys, key));
102
+ setExpandedKeys($36d99f0640511db5$var$toggleKey(expandedKeys, key));
102
103
  };
103
104
  return {
104
105
  collection: tree,
105
106
  expandedKeys: expandedKeys,
106
107
  disabledKeys: disabledKeys,
107
108
  toggleKey: onToggle,
108
- selectionManager: new $l43NX$SelectionManager(tree, selectionState)
109
+ selectionManager: new $9TXm6$SelectionManager(tree, selectionState)
109
110
  };
110
111
  }
111
- function $443b2488e6fa10fb$var$toggleKey(set, key) {
112
+ function $36d99f0640511db5$var$toggleKey(set, key) {
112
113
  let res = new Set(set);
113
114
  if (res.has(key)) res.delete(key);
114
115
  else res.add(key);
@@ -118,5 +119,5 @@ function $443b2488e6fa10fb$var$toggleKey(set, key) {
118
119
 
119
120
 
120
121
 
121
- export {$443b2488e6fa10fb$export$728d6ba534403756 as useTreeState};
122
+ export {$36d99f0640511db5$export$728d6ba534403756 as useTreeState};
122
123
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;MEea,yCAAc;gBAMb,KAAwB,EAAE,CAAC,eAAA,YAAY,EAA2B,CAAC,GAAG,CAAC;IAAA,CAAC,CAAE,CAAC;QANlF,IAuFN,CAtFS,MAAM,GAAsB,GAAG,CAAC,GAAG;QAMzC,IAAI,CAAC,QAAQ,GAAG,KAAK;QACrB,YAAY,GAAG,YAAY,IAAI,GAAG,CAAC,GAAG;QAEtC,GAAG,CAAC,KAAK,IAAI,IAAa,GAAK,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI;YAE9B,EAAE,EAAE,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,IAAI,KAAK,CAAS,YAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,IAC1E,GAAG,EAAE,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,CAC/B,KAAK,CAAC,KAAK;QAGjB,CAAC;QAED,GAAG,EAAE,GAAG,CAAC,KAAI,IAAI,KAAK,CACpB,KAAK,CAAC,KAAI;QAGZ,GAAG,CAAC,IAAI;QACR,GAAG,CAAC,KAAK,GAAG,CAAC;QACb,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAAI,KAAK,IAAI,CAAC,MAAM,CAAE,CAAC;YACp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AC,EAAE,CAAC;QAAA,IAAI;QAAE,cAAc,CAAC,UAAU;IAAA,CAAC;IAEpC,GAAG,CAAC,QAAQ,IAAI,GAAQ,GAAK,CAAC;QAC5B,eAAe,CAAC,+BAAS,CAAC,YAAY,EAAE,GAAG;IAC7C,CAAC;IAED,MAAM,CAAC,CAAC;QACN,UAAU,EAAE,IAAI;sBAChB,YAAY;sBACZ,YAAY;QACZ,SAAS,EAAE,QAAQ;QACnB,gBAAgB,EAAE,GAAG,CAAC,uBAAgB,CAAC,IAAI,EAAE,cAAc;IAC7D,CAAC;AACH,CAAC;SAEQ,+BAAS,CAAC,GAAa,EAAE,GAAQ,EAAY,CAAC;IACrD,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG;IACrB,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,GACb,GAAG,CAAC,MAAM,CAAC,GAAG;SAEd,GAAG,CAAC,GAAG,CAAC,GAAG;IAGb,MAAM,CAAC,GAAG;AACZ,CAAC","sources":["packages/@react-stately/tree/src/index.ts","packages/@react-stately/tree/src/useTreeState.ts","packages/@react-stately/tree/src/TreeCollection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useTreeState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, CollectionBase, Expandable, MultipleSelection, Node} from '@react-types/shared';\nimport {Key, useEffect, useMemo} from 'react';\nimport {SelectionManager, useMultipleSelectionState} from '@react-stately/selection';\nimport {TreeCollection} from './TreeCollection';\nimport {useCollection} from '@react-stately/collections';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface TreeProps<T> extends CollectionBase<T>, Expandable, MultipleSelection {}\nexport interface TreeState<T> {\n /** A collection of items in the tree. */\n readonly collection: Collection<Node<T>>,\n\n /** A set of keys for items that are disabled. */\n readonly disabledKeys: Set<Key>,\n\n /** A set of keys for items that are expanded. */\n readonly expandedKeys: Set<Key>,\n\n /** Toggles the expanded state for an item by its key. */\n toggleKey(key: Key): void,\n\n /** A selection manager to read and update multiple selection state. */\n readonly selectionManager: SelectionManager\n}\n\n/**\n * Provides state management for tree-like components. Handles building a collection\n * of items from props, item expanded state, and manages multiple selection state.\n */\nexport function useTreeState<T extends object>(props: TreeProps<T>): TreeState<T> {\n let [expandedKeys, setExpandedKeys] = useControlledState(\n props.expandedKeys ? new Set(props.expandedKeys) : undefined,\n props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set(),\n props.onExpandedChange\n );\n\n let selectionState = useMultipleSelectionState(props);\n let disabledKeys = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n\n let tree = useCollection(props, nodes => new TreeCollection(nodes, {expandedKeys}), null, [expandedKeys]);\n\n // Reset focused key if that item is deleted from the collection.\n useEffect(() => {\n if (selectionState.focusedKey != null && !tree.getItem(selectionState.focusedKey)) {\n selectionState.setFocusedKey(null);\n }\n }, [tree, selectionState.focusedKey]);\n\n let onToggle = (key: Key) => {\n setExpandedKeys(toggleKey(expandedKeys, key));\n };\n\n return {\n collection: tree,\n expandedKeys,\n disabledKeys,\n toggleKey: onToggle,\n selectionManager: new SelectionManager(tree, selectionState)\n };\n}\n\nfunction toggleKey(set: Set<Key>, key: Key): Set<Key> {\n let res = new Set(set);\n if (res.has(key)) {\n res.delete(key);\n } else {\n res.add(key);\n }\n\n return res;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Node} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport class TreeCollection<T> implements Collection<Node<T>> {\n private keyMap: Map<Key, Node<T>> = new Map();\n private iterable: Iterable<Node<T>>;\n private firstKey: Key;\n private lastKey: Key;\n\n constructor(nodes: Iterable<Node<T>>, {expandedKeys}: {expandedKeys?: Set<Key>} = {}) {\n this.iterable = nodes;\n expandedKeys = expandedKeys || new Set();\n\n let visit = (node: Node<T>) => {\n this.keyMap.set(node.key, node);\n\n if (node.childNodes && (node.type === 'section' || expandedKeys.has(node.key))) {\n for (let child of node.childNodes) {\n visit(child);\n }\n }\n };\n\n for (let node of nodes) {\n visit(node);\n }\n\n let last: Node<T>;\n let index = 0;\n for (let [key, node] of this.keyMap) {\n if (last) {\n last.nextKey = key;\n node.prevKey = last.key;\n } else {\n this.firstKey = key;\n node.prevKey = undefined;\n }\n\n if (node.type === 'item') {\n node.index = index++;\n }\n\n last = node;\n\n // Set nextKey as undefined since this might be the last node\n // If it isn't the last node, last.nextKey will properly set at start of new loop\n last.nextKey = undefined;\n }\n\n this.lastKey = last?.key;\n }\n\n *[Symbol.iterator]() {\n yield* this.iterable;\n }\n\n get size() {\n return this.keyMap.size;\n }\n\n getKeys() {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.prevKey : null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey : null;\n }\n\n getFirstKey() {\n return this.firstKey;\n }\n\n getLastKey() {\n return this.lastKey;\n }\n\n getItem(key: Key) {\n return this.keyMap.get(key);\n }\n\n at(idx: number) {\n const keys = [...this.getKeys()];\n return this.getItem(keys[idx]);\n }\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;UEgEI,MAAM,CAAC,QAAQ;MAjDN,yCAAc;aAiDJ,CAAC;eACb,IAAI,CAAC,QAAQ;IACtB,CAAC;QAEG,IAAI,GAAG,CAAC;QACV,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB,CAAC;IAED,OAAO,GAAG,CAAC;QACT,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB,CAAC;IAED,YAAY,CAAC,GAAQ,EAAE,CAAC;QACtB,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG;QAC9B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI;IACnC,CAAC;IAED,WAAW,CAAC,GAAQ,EAAE,CAAC;QACrB,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG;QAC9B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI;IACnC,CAAC;IAED,WAAW,GAAG,CAAC;QACb,MAAM,CAAC,IAAI,CAAC,QAAQ;IACtB,CAAC;IAED,UAAU,GAAG,CAAC;QACZ,MAAM,CAAC,IAAI,CAAC,OAAO;IACrB,CAAC;IAED,OAAO,CAAC,GAAQ,EAAE,CAAC;QACjB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG;IAC5B,CAAC;IAED,EAAE,CAAC,GAAW,EAAE,CAA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A,IAAI;QAAE,cAAc,CAAC,UAAU;IAAA,CAAC;IAEpC,GAAG,CAAC,QAAQ,IAAI,GAAQ,GAAK,CAAC;QAC5B,eAAe,CAAC,+BAAS,CAAC,YAAY,EAAE,GAAG;IAC7C,CAAC;IAED,MAAM,CAAC,CAAC;QACN,UAAU,EAAE,IAAI;sBAChB,YAAY;sBACZ,YAAY;QACZ,SAAS,EAAE,QAAQ;QACnB,gBAAgB,EAAE,GAAG,CAAC,uBAAgB,CAAC,IAAI,EAAE,cAAc;IAC7D,CAAC;AACH,CAAC;SAEQ,+BAAS,CAAC,GAAa,EAAE,GAAQ,EAAY,CAAC;IACrD,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG;IACrB,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,GACb,GAAG,CAAC,MAAM,CAAC,GAAG;SAEd,GAAG,CAAC,GAAG,CAAC,GAAG;IAGb,MAAM,CAAC,GAAG;AACZ,CAAC","sources":["packages/@react-stately/tree/src/index.ts","packages/@react-stately/tree/src/useTreeState.ts","packages/@react-stately/tree/src/TreeCollection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useTreeState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, CollectionBase, Expandable, MultipleSelection, Node} from '@react-types/shared';\nimport {Key, useEffect, useMemo} from 'react';\nimport {SelectionManager, useMultipleSelectionState} from '@react-stately/selection';\nimport {TreeCollection} from './TreeCollection';\nimport {useCollection} from '@react-stately/collections';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface TreeProps<T> extends CollectionBase<T>, Expandable, MultipleSelection {}\nexport interface TreeState<T> {\n /** A collection of items in the tree. */\n readonly collection: Collection<Node<T>>,\n\n /** A set of keys for items that are disabled. */\n readonly disabledKeys: Set<Key>,\n\n /** A set of keys for items that are expanded. */\n readonly expandedKeys: Set<Key>,\n\n /** Toggles the expanded state for an item by its key. */\n toggleKey(key: Key): void,\n\n /** A selection manager to read and update multiple selection state. */\n readonly selectionManager: SelectionManager\n}\n\n/**\n * Provides state management for tree-like components. Handles building a collection\n * of items from props, item expanded state, and manages multiple selection state.\n */\nexport function useTreeState<T extends object>(props: TreeProps<T>): TreeState<T> {\n let [expandedKeys, setExpandedKeys] = useControlledState(\n props.expandedKeys ? new Set(props.expandedKeys) : undefined,\n props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set(),\n props.onExpandedChange\n );\n\n let selectionState = useMultipleSelectionState(props);\n let disabledKeys = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n\n let tree = useCollection(props, nodes => new TreeCollection(nodes, {expandedKeys}), null, [expandedKeys]);\n\n // Reset focused key if that item is deleted from the collection.\n useEffect(() => {\n if (selectionState.focusedKey != null && !tree.getItem(selectionState.focusedKey)) {\n selectionState.setFocusedKey(null);\n }\n }, [tree, selectionState.focusedKey]);\n\n let onToggle = (key: Key) => {\n setExpandedKeys(toggleKey(expandedKeys, key));\n };\n\n return {\n collection: tree,\n expandedKeys,\n disabledKeys,\n toggleKey: onToggle,\n selectionManager: new SelectionManager(tree, selectionState)\n };\n}\n\nfunction toggleKey(set: Set<Key>, key: Key): Set<Key> {\n let res = new Set(set);\n if (res.has(key)) {\n res.delete(key);\n } else {\n res.add(key);\n }\n\n return res;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Node} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport class TreeCollection<T> implements Collection<Node<T>> {\n private keyMap: Map<Key, Node<T>> = new Map();\n private iterable: Iterable<Node<T>>;\n private firstKey: Key;\n private lastKey: Key;\n\n constructor(nodes: Iterable<Node<T>>, {expandedKeys}: {expandedKeys?: Set<Key>} = {}) {\n this.iterable = nodes;\n expandedKeys = expandedKeys || new Set();\n\n let visit = (node: Node<T>) => {\n this.keyMap.set(node.key, node);\n\n if (node.childNodes && (node.type === 'section' || expandedKeys.has(node.key))) {\n for (let child of node.childNodes) {\n visit(child);\n }\n }\n };\n\n for (let node of nodes) {\n visit(node);\n }\n\n let last: Node<T>;\n let index = 0;\n for (let [key, node] of this.keyMap) {\n if (last) {\n last.nextKey = key;\n node.prevKey = last.key;\n } else {\n this.firstKey = key;\n node.prevKey = undefined;\n }\n\n if (node.type === 'item') {\n node.index = index++;\n }\n\n last = node;\n\n // Set nextKey as undefined since this might be the last node\n // If it isn't the last node, last.nextKey will properly set at start of new loop\n last.nextKey = undefined;\n }\n\n this.lastKey = last?.key;\n }\n\n *[Symbol.iterator]() {\n yield* this.iterable;\n }\n\n get size() {\n return this.keyMap.size;\n }\n\n getKeys() {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.prevKey : null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey : null;\n }\n\n getFirstKey() {\n return this.firstKey;\n }\n\n getLastKey() {\n return this.lastKey;\n }\n\n getItem(key: Key) {\n return this.keyMap.get(key);\n }\n\n at(idx: number) {\n const keys = [...this.getKeys()];\n return this.getItem(keys[idx]);\n }\n}\n"],"names":[],"version":3,"file":"module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/tree",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,10 +18,10 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@react-stately/collections": "^3.3.5",
22
- "@react-stately/selection": "^3.9.1",
23
- "@react-stately/utils": "^3.4.0",
24
- "@react-types/shared": "^3.11.0"
21
+ "@react-stately/collections": "^3.3.6",
22
+ "@react-stately/selection": "^3.9.2",
23
+ "@react-stately/utils": "^3.4.1",
24
+ "@react-types/shared": "^3.11.1"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "react": "^16.8.0 || ^17.0.0-rc.1"
@@ -29,5 +29,5 @@
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
- "gitHead": "54c2366c4f31bd4bf619126131cd583c12972acc"
32
+ "gitHead": "404d41859b7d6f56201d7fc01bd9f22ae3512937"
33
33
  }