@react-aria/collections 3.0.3 → 3.1.0
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/import.mjs +7 -5
- package/dist/main.js +20 -18
- package/dist/main.js.map +1 -1
- package/dist/module.js +7 -5
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +8 -0
- package/package.json +14 -15
- package/src/index.ts +8 -7
- package/dist/BaseCollection.main.js +0 -271
- package/dist/BaseCollection.main.js.map +0 -1
- package/dist/BaseCollection.mjs +0 -260
- package/dist/BaseCollection.module.js +0 -260
- package/dist/BaseCollection.module.js.map +0 -1
- package/dist/CollectionBuilder.main.js +0 -242
- package/dist/CollectionBuilder.main.js.map +0 -1
- package/dist/CollectionBuilder.mjs +0 -230
- package/dist/CollectionBuilder.module.js +0 -230
- package/dist/CollectionBuilder.module.js.map +0 -1
- package/dist/Document.main.js +0 -369
- package/dist/Document.main.js.map +0 -1
- package/dist/Document.mjs +0 -364
- package/dist/Document.module.js +0 -364
- package/dist/Document.module.js.map +0 -1
- package/dist/Hidden.main.js +0 -90
- package/dist/Hidden.main.js.map +0 -1
- package/dist/Hidden.mjs +0 -79
- package/dist/Hidden.module.js +0 -79
- package/dist/Hidden.module.js.map +0 -1
- package/dist/types.d.ts +0 -119
- package/dist/types.d.ts.map +0 -1
- package/dist/useCachedChildren.main.js +0 -61
- package/dist/useCachedChildren.main.js.map +0 -1
- package/dist/useCachedChildren.mjs +0 -56
- package/dist/useCachedChildren.module.js +0 -56
- package/dist/useCachedChildren.module.js.map +0 -1
- package/src/BaseCollection.ts +0 -353
- package/src/CollectionBuilder.tsx +0 -265
- package/src/Document.ts +0 -569
- package/src/Hidden.tsx +0 -97
- package/src/useCachedChildren.ts +0 -70
package/dist/Document.module.js
DELETED
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/ class $681cc3c98f569e39$export$410b0c854570d131 {
|
|
12
|
-
*[Symbol.iterator]() {
|
|
13
|
-
let node = this.firstChild;
|
|
14
|
-
while(node){
|
|
15
|
-
yield node;
|
|
16
|
-
node = node.nextSibling;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
get firstChild() {
|
|
20
|
-
return this._firstChild;
|
|
21
|
-
}
|
|
22
|
-
set firstChild(firstChild) {
|
|
23
|
-
this._firstChild = firstChild;
|
|
24
|
-
this.ownerDocument.markDirty(this);
|
|
25
|
-
}
|
|
26
|
-
get lastChild() {
|
|
27
|
-
return this._lastChild;
|
|
28
|
-
}
|
|
29
|
-
set lastChild(lastChild) {
|
|
30
|
-
this._lastChild = lastChild;
|
|
31
|
-
this.ownerDocument.markDirty(this);
|
|
32
|
-
}
|
|
33
|
-
get previousSibling() {
|
|
34
|
-
return this._previousSibling;
|
|
35
|
-
}
|
|
36
|
-
set previousSibling(previousSibling) {
|
|
37
|
-
this._previousSibling = previousSibling;
|
|
38
|
-
this.ownerDocument.markDirty(this);
|
|
39
|
-
}
|
|
40
|
-
get nextSibling() {
|
|
41
|
-
return this._nextSibling;
|
|
42
|
-
}
|
|
43
|
-
set nextSibling(nextSibling) {
|
|
44
|
-
this._nextSibling = nextSibling;
|
|
45
|
-
this.ownerDocument.markDirty(this);
|
|
46
|
-
}
|
|
47
|
-
get parentNode() {
|
|
48
|
-
return this._parentNode;
|
|
49
|
-
}
|
|
50
|
-
set parentNode(parentNode) {
|
|
51
|
-
this._parentNode = parentNode;
|
|
52
|
-
this.ownerDocument.markDirty(this);
|
|
53
|
-
}
|
|
54
|
-
get isConnected() {
|
|
55
|
-
var _this_parentNode;
|
|
56
|
-
return ((_this_parentNode = this.parentNode) === null || _this_parentNode === void 0 ? void 0 : _this_parentNode.isConnected) || false;
|
|
57
|
-
}
|
|
58
|
-
invalidateChildIndices(child) {
|
|
59
|
-
if (this._minInvalidChildIndex == null || !this._minInvalidChildIndex.isConnected || child.index < this._minInvalidChildIndex.index) {
|
|
60
|
-
this._minInvalidChildIndex = child;
|
|
61
|
-
this.ownerDocument.markDirty(this);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
updateChildIndices() {
|
|
65
|
-
let node = this._minInvalidChildIndex;
|
|
66
|
-
while(node){
|
|
67
|
-
node.index = node.previousSibling ? node.previousSibling.index + 1 : 0;
|
|
68
|
-
node = node.nextSibling;
|
|
69
|
-
}
|
|
70
|
-
this._minInvalidChildIndex = null;
|
|
71
|
-
}
|
|
72
|
-
appendChild(child) {
|
|
73
|
-
if (child.parentNode) child.parentNode.removeChild(child);
|
|
74
|
-
if (this.firstChild == null) this.firstChild = child;
|
|
75
|
-
if (this.lastChild) {
|
|
76
|
-
this.lastChild.nextSibling = child;
|
|
77
|
-
child.index = this.lastChild.index + 1;
|
|
78
|
-
child.previousSibling = this.lastChild;
|
|
79
|
-
} else {
|
|
80
|
-
child.previousSibling = null;
|
|
81
|
-
child.index = 0;
|
|
82
|
-
}
|
|
83
|
-
child.parentNode = this;
|
|
84
|
-
child.nextSibling = null;
|
|
85
|
-
this.lastChild = child;
|
|
86
|
-
this.ownerDocument.markDirty(this);
|
|
87
|
-
if (this.isConnected) this.ownerDocument.queueUpdate();
|
|
88
|
-
}
|
|
89
|
-
insertBefore(newNode, referenceNode) {
|
|
90
|
-
if (referenceNode == null) return this.appendChild(newNode);
|
|
91
|
-
if (newNode.parentNode) newNode.parentNode.removeChild(newNode);
|
|
92
|
-
newNode.nextSibling = referenceNode;
|
|
93
|
-
newNode.previousSibling = referenceNode.previousSibling;
|
|
94
|
-
// Ensure that the newNode's index is less than that of the reference node so that
|
|
95
|
-
// invalidateChildIndices will properly use the newNode as the _minInvalidChildIndex, thus making sure
|
|
96
|
-
// we will properly update the indexes of all sibiling nodes after the newNode. The value here doesn't matter
|
|
97
|
-
// since updateChildIndices should calculate the proper indexes.
|
|
98
|
-
newNode.index = referenceNode.index - 1;
|
|
99
|
-
if (this.firstChild === referenceNode) this.firstChild = newNode;
|
|
100
|
-
else if (referenceNode.previousSibling) referenceNode.previousSibling.nextSibling = newNode;
|
|
101
|
-
referenceNode.previousSibling = newNode;
|
|
102
|
-
newNode.parentNode = referenceNode.parentNode;
|
|
103
|
-
this.invalidateChildIndices(newNode);
|
|
104
|
-
if (this.isConnected) this.ownerDocument.queueUpdate();
|
|
105
|
-
}
|
|
106
|
-
removeChild(child) {
|
|
107
|
-
if (child.parentNode !== this) return;
|
|
108
|
-
if (this._minInvalidChildIndex === child) this._minInvalidChildIndex = null;
|
|
109
|
-
if (child.nextSibling) {
|
|
110
|
-
this.invalidateChildIndices(child.nextSibling);
|
|
111
|
-
child.nextSibling.previousSibling = child.previousSibling;
|
|
112
|
-
}
|
|
113
|
-
if (child.previousSibling) child.previousSibling.nextSibling = child.nextSibling;
|
|
114
|
-
if (this.firstChild === child) this.firstChild = child.nextSibling;
|
|
115
|
-
if (this.lastChild === child) this.lastChild = child.previousSibling;
|
|
116
|
-
child.parentNode = null;
|
|
117
|
-
child.nextSibling = null;
|
|
118
|
-
child.previousSibling = null;
|
|
119
|
-
child.index = 0;
|
|
120
|
-
this.ownerDocument.markDirty(child);
|
|
121
|
-
if (this.isConnected) this.ownerDocument.queueUpdate();
|
|
122
|
-
}
|
|
123
|
-
addEventListener() {}
|
|
124
|
-
removeEventListener() {}
|
|
125
|
-
get previousVisibleSibling() {
|
|
126
|
-
let node = this.previousSibling;
|
|
127
|
-
while(node && node.isHidden)node = node.previousSibling;
|
|
128
|
-
return node;
|
|
129
|
-
}
|
|
130
|
-
get nextVisibleSibling() {
|
|
131
|
-
let node = this.nextSibling;
|
|
132
|
-
while(node && node.isHidden)node = node.nextSibling;
|
|
133
|
-
return node;
|
|
134
|
-
}
|
|
135
|
-
get firstVisibleChild() {
|
|
136
|
-
let node = this.firstChild;
|
|
137
|
-
while(node && node.isHidden)node = node.nextSibling;
|
|
138
|
-
return node;
|
|
139
|
-
}
|
|
140
|
-
get lastVisibleChild() {
|
|
141
|
-
let node = this.lastChild;
|
|
142
|
-
while(node && node.isHidden)node = node.previousSibling;
|
|
143
|
-
return node;
|
|
144
|
-
}
|
|
145
|
-
constructor(ownerDocument){
|
|
146
|
-
this._firstChild = null;
|
|
147
|
-
this._lastChild = null;
|
|
148
|
-
this._previousSibling = null;
|
|
149
|
-
this._nextSibling = null;
|
|
150
|
-
this._parentNode = null;
|
|
151
|
-
this._minInvalidChildIndex = null;
|
|
152
|
-
this.ownerDocument = ownerDocument;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
class $681cc3c98f569e39$export$dc064fe9e59310fd extends $681cc3c98f569e39$export$410b0c854570d131 {
|
|
156
|
-
get index() {
|
|
157
|
-
return this._index;
|
|
158
|
-
}
|
|
159
|
-
set index(index) {
|
|
160
|
-
this._index = index;
|
|
161
|
-
this.ownerDocument.markDirty(this);
|
|
162
|
-
}
|
|
163
|
-
get level() {
|
|
164
|
-
var _this_parentNode_node;
|
|
165
|
-
if (this.parentNode instanceof $681cc3c98f569e39$export$dc064fe9e59310fd) return this.parentNode.level + (((_this_parentNode_node = this.parentNode.node) === null || _this_parentNode_node === void 0 ? void 0 : _this_parentNode_node.type) === 'item' ? 1 : 0);
|
|
166
|
-
return 0;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Lazily gets a mutable instance of a Node. If the node has already
|
|
170
|
-
* been cloned during this update cycle, it just returns the existing one.
|
|
171
|
-
*/ getMutableNode() {
|
|
172
|
-
if (this.node == null) return null;
|
|
173
|
-
if (!this.isMutated) {
|
|
174
|
-
this.node = this.node.clone();
|
|
175
|
-
this.isMutated = true;
|
|
176
|
-
}
|
|
177
|
-
this.ownerDocument.markDirty(this);
|
|
178
|
-
return this.node;
|
|
179
|
-
}
|
|
180
|
-
updateNode() {
|
|
181
|
-
var _this_parentNode_node, _this_previousVisibleSibling_node, _this_previousVisibleSibling, _nextSibling_node, _this_firstVisibleChild_node, _this_firstVisibleChild, _this_lastVisibleChild_node, _this_lastVisibleChild;
|
|
182
|
-
let nextSibling = this.nextVisibleSibling;
|
|
183
|
-
let node = this.getMutableNode();
|
|
184
|
-
if (node == null) return;
|
|
185
|
-
node.index = this.index;
|
|
186
|
-
node.level = this.level;
|
|
187
|
-
var _this_parentNode_node_key;
|
|
188
|
-
node.parentKey = this.parentNode instanceof $681cc3c98f569e39$export$dc064fe9e59310fd ? (_this_parentNode_node_key = (_this_parentNode_node = this.parentNode.node) === null || _this_parentNode_node === void 0 ? void 0 : _this_parentNode_node.key) !== null && _this_parentNode_node_key !== void 0 ? _this_parentNode_node_key : null : null;
|
|
189
|
-
var _this_previousVisibleSibling_node_key;
|
|
190
|
-
node.prevKey = (_this_previousVisibleSibling_node_key = (_this_previousVisibleSibling = this.previousVisibleSibling) === null || _this_previousVisibleSibling === void 0 ? void 0 : (_this_previousVisibleSibling_node = _this_previousVisibleSibling.node) === null || _this_previousVisibleSibling_node === void 0 ? void 0 : _this_previousVisibleSibling_node.key) !== null && _this_previousVisibleSibling_node_key !== void 0 ? _this_previousVisibleSibling_node_key : null;
|
|
191
|
-
var _nextSibling_node_key;
|
|
192
|
-
node.nextKey = (_nextSibling_node_key = nextSibling === null || nextSibling === void 0 ? void 0 : (_nextSibling_node = nextSibling.node) === null || _nextSibling_node === void 0 ? void 0 : _nextSibling_node.key) !== null && _nextSibling_node_key !== void 0 ? _nextSibling_node_key : null;
|
|
193
|
-
node.hasChildNodes = !!this.firstChild;
|
|
194
|
-
var _this_firstVisibleChild_node_key;
|
|
195
|
-
node.firstChildKey = (_this_firstVisibleChild_node_key = (_this_firstVisibleChild = this.firstVisibleChild) === null || _this_firstVisibleChild === void 0 ? void 0 : (_this_firstVisibleChild_node = _this_firstVisibleChild.node) === null || _this_firstVisibleChild_node === void 0 ? void 0 : _this_firstVisibleChild_node.key) !== null && _this_firstVisibleChild_node_key !== void 0 ? _this_firstVisibleChild_node_key : null;
|
|
196
|
-
var _this_lastVisibleChild_node_key;
|
|
197
|
-
node.lastChildKey = (_this_lastVisibleChild_node_key = (_this_lastVisibleChild = this.lastVisibleChild) === null || _this_lastVisibleChild === void 0 ? void 0 : (_this_lastVisibleChild_node = _this_lastVisibleChild.node) === null || _this_lastVisibleChild_node === void 0 ? void 0 : _this_lastVisibleChild_node.key) !== null && _this_lastVisibleChild_node_key !== void 0 ? _this_lastVisibleChild_node_key : null;
|
|
198
|
-
// Update the colIndex of sibling nodes if this node has a colSpan.
|
|
199
|
-
if ((node.colSpan != null || node.colIndex != null) && nextSibling) {
|
|
200
|
-
var _node_colIndex, _node_colSpan;
|
|
201
|
-
// This queues the next sibling for update, which means this happens recursively.
|
|
202
|
-
let nextColIndex = ((_node_colIndex = node.colIndex) !== null && _node_colIndex !== void 0 ? _node_colIndex : node.index) + ((_node_colSpan = node.colSpan) !== null && _node_colSpan !== void 0 ? _node_colSpan : 1);
|
|
203
|
-
if (nextSibling.node != null && nextColIndex !== nextSibling.node.colIndex) {
|
|
204
|
-
let siblingNode = nextSibling.getMutableNode();
|
|
205
|
-
siblingNode.colIndex = nextColIndex;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
setProps(obj, ref, CollectionNodeClass, rendered, render) {
|
|
210
|
-
let node;
|
|
211
|
-
let { value: value1, textValue: textValue, id: id, ...props } = obj;
|
|
212
|
-
if (this.node == null) {
|
|
213
|
-
node = new CollectionNodeClass(id !== null && id !== void 0 ? id : `react-aria-${++this.ownerDocument.nodeId}`);
|
|
214
|
-
this.node = node;
|
|
215
|
-
} else node = this.getMutableNode();
|
|
216
|
-
props.ref = ref;
|
|
217
|
-
node.props = props;
|
|
218
|
-
node.rendered = rendered;
|
|
219
|
-
node.render = render;
|
|
220
|
-
node.value = value1;
|
|
221
|
-
if (obj['aria-label']) node['aria-label'] = obj['aria-label'];
|
|
222
|
-
node.textValue = textValue || (typeof props.children === 'string' ? props.children : '') || obj['aria-label'] || '';
|
|
223
|
-
if (id != null && id !== node.key) throw new Error('Cannot change the id of an item');
|
|
224
|
-
if (props.colSpan != null) node.colSpan = props.colSpan;
|
|
225
|
-
if (this.isConnected) this.ownerDocument.queueUpdate();
|
|
226
|
-
}
|
|
227
|
-
get style() {
|
|
228
|
-
// React sets display: none to hide elements during Suspense.
|
|
229
|
-
// We'll handle this by setting the element to hidden and invalidating
|
|
230
|
-
// its siblings/parent. Hidden elements remain in the Document, but
|
|
231
|
-
// are removed from the Collection.
|
|
232
|
-
let element = this;
|
|
233
|
-
return {
|
|
234
|
-
get display () {
|
|
235
|
-
return element.isHidden ? 'none' : '';
|
|
236
|
-
},
|
|
237
|
-
set display (value){
|
|
238
|
-
let isHidden = value === 'none';
|
|
239
|
-
if (element.isHidden !== isHidden) {
|
|
240
|
-
var _element_parentNode, _element_parentNode1;
|
|
241
|
-
// Mark parent node dirty if this element is currently the first or last visible child.
|
|
242
|
-
if (((_element_parentNode = element.parentNode) === null || _element_parentNode === void 0 ? void 0 : _element_parentNode.firstVisibleChild) === element || ((_element_parentNode1 = element.parentNode) === null || _element_parentNode1 === void 0 ? void 0 : _element_parentNode1.lastVisibleChild) === element) element.ownerDocument.markDirty(element.parentNode);
|
|
243
|
-
// Mark sibling visible elements dirty.
|
|
244
|
-
let prev = element.previousVisibleSibling;
|
|
245
|
-
let next = element.nextVisibleSibling;
|
|
246
|
-
if (prev) element.ownerDocument.markDirty(prev);
|
|
247
|
-
if (next) element.ownerDocument.markDirty(next);
|
|
248
|
-
// Mark self dirty.
|
|
249
|
-
element.isHidden = isHidden;
|
|
250
|
-
element.ownerDocument.markDirty(element);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
hasAttribute() {}
|
|
256
|
-
setAttribute() {}
|
|
257
|
-
setAttributeNS() {}
|
|
258
|
-
removeAttribute() {}
|
|
259
|
-
constructor(type, ownerDocument){
|
|
260
|
-
super(ownerDocument), this.nodeType = 8 // COMMENT_NODE (we'd use ELEMENT_NODE but React DevTools will fail to get its dimensions)
|
|
261
|
-
, this.isMutated = true, this._index = 0, this.isHidden = false;
|
|
262
|
-
this.node = null;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
class $681cc3c98f569e39$export$b34a105447964f9f extends $681cc3c98f569e39$export$410b0c854570d131 {
|
|
266
|
-
get isConnected() {
|
|
267
|
-
return true;
|
|
268
|
-
}
|
|
269
|
-
createElement(type) {
|
|
270
|
-
return new $681cc3c98f569e39$export$dc064fe9e59310fd(type, this);
|
|
271
|
-
}
|
|
272
|
-
getMutableCollection() {
|
|
273
|
-
if (!this.nextCollection) this.nextCollection = this.collection.clone();
|
|
274
|
-
return this.nextCollection;
|
|
275
|
-
}
|
|
276
|
-
markDirty(node) {
|
|
277
|
-
this.dirtyNodes.add(node);
|
|
278
|
-
}
|
|
279
|
-
addNode(element) {
|
|
280
|
-
if (element.isHidden || element.node == null) return;
|
|
281
|
-
let collection = this.getMutableCollection();
|
|
282
|
-
if (!collection.getItem(element.node.key)) for (let child of element)this.addNode(child);
|
|
283
|
-
collection.addNode(element.node);
|
|
284
|
-
}
|
|
285
|
-
removeNode(node) {
|
|
286
|
-
for (let child of node)this.removeNode(child);
|
|
287
|
-
if (node.node) {
|
|
288
|
-
let collection = this.getMutableCollection();
|
|
289
|
-
collection.removeNode(node.node.key);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
/** Finalizes the collection update, updating all nodes and freezing the collection. */ getCollection() {
|
|
293
|
-
// If in a subscription update, return return the existing collection.
|
|
294
|
-
// React will call getCollection again during render, at which point all the updates will be complete.
|
|
295
|
-
if (this.inSubscription) return this.collection;
|
|
296
|
-
// Reset queuedRender to false when getCollection is called during render.
|
|
297
|
-
this.queuedRender = false;
|
|
298
|
-
this.updateCollection();
|
|
299
|
-
return this.collection;
|
|
300
|
-
}
|
|
301
|
-
updateCollection() {
|
|
302
|
-
// First, remove disconnected nodes and update the indices of dirty element children.
|
|
303
|
-
for (let element of this.dirtyNodes)if (element instanceof $681cc3c98f569e39$export$dc064fe9e59310fd && (!element.isConnected || element.isHidden)) this.removeNode(element);
|
|
304
|
-
else element.updateChildIndices();
|
|
305
|
-
// Next, update dirty collection nodes.
|
|
306
|
-
for (let element of this.dirtyNodes)if (element instanceof $681cc3c98f569e39$export$dc064fe9e59310fd) {
|
|
307
|
-
if (element.isConnected && !element.isHidden) {
|
|
308
|
-
element.updateNode();
|
|
309
|
-
this.addNode(element);
|
|
310
|
-
}
|
|
311
|
-
if (element.node) this.dirtyNodes.delete(element);
|
|
312
|
-
element.isMutated = false;
|
|
313
|
-
} else this.dirtyNodes.delete(element);
|
|
314
|
-
// Finally, update the collection.
|
|
315
|
-
if (this.nextCollection) {
|
|
316
|
-
var _this_firstVisibleChild_node, _this_firstVisibleChild, _this_lastVisibleChild_node, _this_lastVisibleChild;
|
|
317
|
-
var _this_firstVisibleChild_node_key, _this_lastVisibleChild_node_key;
|
|
318
|
-
this.nextCollection.commit((_this_firstVisibleChild_node_key = (_this_firstVisibleChild = this.firstVisibleChild) === null || _this_firstVisibleChild === void 0 ? void 0 : (_this_firstVisibleChild_node = _this_firstVisibleChild.node) === null || _this_firstVisibleChild_node === void 0 ? void 0 : _this_firstVisibleChild_node.key) !== null && _this_firstVisibleChild_node_key !== void 0 ? _this_firstVisibleChild_node_key : null, (_this_lastVisibleChild_node_key = (_this_lastVisibleChild = this.lastVisibleChild) === null || _this_lastVisibleChild === void 0 ? void 0 : (_this_lastVisibleChild_node = _this_lastVisibleChild.node) === null || _this_lastVisibleChild_node === void 0 ? void 0 : _this_lastVisibleChild_node.key) !== null && _this_lastVisibleChild_node_key !== void 0 ? _this_lastVisibleChild_node_key : null, this.isSSR);
|
|
319
|
-
if (!this.isSSR) {
|
|
320
|
-
this.collection = this.nextCollection;
|
|
321
|
-
this.nextCollection = null;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
queueUpdate() {
|
|
326
|
-
if (this.dirtyNodes.size === 0 || this.queuedRender) return;
|
|
327
|
-
// Only trigger subscriptions once during an update, when the first item changes.
|
|
328
|
-
// React's useSyncExternalStore will call getCollection immediately, to check whether the snapshot changed.
|
|
329
|
-
// If so, React will queue a render to happen after the current commit to our fake DOM finishes.
|
|
330
|
-
// We track whether getCollection is called in a subscription, and once it is called during render,
|
|
331
|
-
// we reset queuedRender back to false.
|
|
332
|
-
this.queuedRender = true;
|
|
333
|
-
this.inSubscription = true;
|
|
334
|
-
// Clone the collection to ensure that React queues a render. It will call getCollection again
|
|
335
|
-
// during render, at which point all the updates will be complete and we can return
|
|
336
|
-
// the new collection.
|
|
337
|
-
if (!this.isSSR) this.collection = this.collection.clone();
|
|
338
|
-
for (let fn of this.subscriptions)fn();
|
|
339
|
-
this.inSubscription = false;
|
|
340
|
-
}
|
|
341
|
-
subscribe(fn) {
|
|
342
|
-
this.subscriptions.add(fn);
|
|
343
|
-
return ()=>this.subscriptions.delete(fn);
|
|
344
|
-
}
|
|
345
|
-
resetAfterSSR() {
|
|
346
|
-
if (this.isSSR) {
|
|
347
|
-
this.isSSR = false;
|
|
348
|
-
this.firstChild = null;
|
|
349
|
-
this.lastChild = null;
|
|
350
|
-
this.nodeId = 0;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
constructor(collection){
|
|
354
|
-
// @ts-ignore
|
|
355
|
-
super(null), this.nodeType = 11 // DOCUMENT_FRAGMENT_NODE
|
|
356
|
-
, this.ownerDocument = this, this.dirtyNodes = new Set(), this.isSSR = false, this.nodeId = 0, this.nodesByProps = new WeakMap(), this.nextCollection = null, this.subscriptions = new Set(), this.queuedRender = false, this.inSubscription = false;
|
|
357
|
-
this.collection = collection;
|
|
358
|
-
this.nextCollection = collection;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
export {$681cc3c98f569e39$export$410b0c854570d131 as BaseNode, $681cc3c98f569e39$export$dc064fe9e59310fd as ElementNode, $681cc3c98f569e39$export$b34a105447964f9f as Document};
|
|
364
|
-
//# sourceMappingURL=Document.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;CAUC,GAyBM,MAAM;IAaX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAA6B;QAC7C,IAAI,OAAO,IAAI,CAAC,UAAU;QAC1B,MAAO,KAAM;YACX,MAAM;YACN,OAAO,KAAK,WAAW;QACzB;IACF;IAEA,IAAI,aAAoC;QACtC,OAAO,IAAI,CAAC,WAAW;IACzB;IAEA,IAAI,WAAW,UAAiC,EAAE;QAChD,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI;IACnC;IAEA,IAAI,YAAmC;QACrC,OAAO,IAAI,CAAC,UAAU;IACxB;IAEA,IAAI,UAAU,SAAgC,EAAE;QAC9C,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI;IACnC;IAEA,IAAI,kBAAyC;QAC3C,OAAO,IAAI,CAAC,gBAAgB;IAC9B;IAEA,IAAI,gBAAgB,eAAsC,EAAE;QAC1D,IAAI,CAAC,gBAAgB,GAAG;QACxB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI;IACnC;IAEA,IAAI,cAAqC;QACvC,OAAO,IAAI,CAAC,YAAY;IAC1B;IAEA,IAAI,YAAY,WAAkC,EAAE;QAClD,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI;IACn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AAoB;QAClB,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC,YAAY,EACjD;QAGF,iFAAiF;QACjF,2GAA2G;QAC3G,gGAAgG;QAChG,mGAAmG;QACnG,uCAAuC;QACvC,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,cAAc,GAAG;QAEtB,8FAA8F;QAC9F,mFAAmF;QACnF,sBAAsB;QACtB,IAAI,CAAC,IAAI,CAAC,KAAK,EACb,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK;QAGzC,KAAK,IAAI,MAAM,IAAI,CAAC,aAAa,CAC/B;QAGF,IAAI,CAAC,cAAc,GAAG;IACxB;IAEA,UAAU,EAAc,EAAE;QACxB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;QACvB,OAAO,IAAe,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IAClD;IAEA,gBAAsB;QACpB,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,KAAK,GAAG;YACb,IAAI,CAAC,UAAU,GAAG;YAClB,IAAI,CAAC,SAAS,GAAG;YACjB,IAAI,CAAC,MAAM,GAAG;QAChB;IACF;IAjJA,YAAY,UAAa,CAAE;QACzB,aAAa;QACb,KAAK,CAAC,YAdR,WAAW,GAAI,yBAAyB;eACxC,gBAAgC,IAAI,OACpC,aAA+B,IAAI,YACnC,QAAQ,YACR,SAAS,QACT,eAAgD,IAAI,gBAE5C,iBAA2B,WAC3B,gBAAiC,IAAI,YACrC,eAAe,YACf,iBAAiB;QAKvB,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,cAAc,GAAG;IACxB;AA6IF","sources":["packages/@react-aria/collections/src/Document.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {BaseCollection, CollectionNode, Mutable} from './BaseCollection';\nimport {CollectionNodeClass} from './CollectionBuilder';\nimport {CSSProperties, ForwardedRef, ReactElement, ReactNode} from 'react';\nimport {Node} from '@react-types/shared';\n\n// This Collection implementation is perhaps a little unusual. It works by rendering the React tree into a\n// Portal to a fake DOM implementation. This gives us efficient access to the tree of rendered objects, and\n// supports React features like composition and context. We use this fake DOM to access the full set of elements\n// before we render into the real DOM, which allows us to render a subset of the elements (e.g. virtualized scrolling),\n// and compute properties like the total number of items. It also enables keyboard navigation, selection, and other features.\n// React takes care of efficiently rendering components and updating the collection for us via this fake DOM.\n//\n// The DOM is a mutable API, and React expects the node instances to remain stable over time. So the implementation is split\n// into two parts. Each mutable fake DOM node owns an instance of an immutable collection node. When a fake DOM node is updated,\n// it queues a second render for the collection. Multiple updates to a collection can be queued at once. Collection nodes are\n// lazily copied on write, so only the changed nodes need to be cloned. During the second render, the new immutable collection\n// is finalized by updating the map of Key -> Node with the new cloned nodes. Then the new collection is frozen so it can no\n// longer be mutated, and returned to the calling component to render.\n\n/**\n * A mutable node in the fake DOM tree. When mutated, it marks itself as dirty\n * and queues an update with the owner document.\n */\nexport class BaseNode<T> {\n private _firstChild: ElementNode<T> | null = null;\n private _lastChild: ElementNode<T> | null = null;\n private _previousSibling: ElementNode<T> | null = null;\n private _nextSibling: ElementNode<T> | null = null;\n private _parentNode: BaseNode<T> | null = null;\n private _minInvalidChildIndex: ElementNode<T> | null = null;\n ownerDocument: Document<T, any>;\n\n constructor(ownerDocument: Document<T, any>) {\n this.ownerDocument = ownerDocument;\n }\n\n *[Symbol.iterator](): Iterator<ElementNode<T>> {\n let node = this.firstChild;\n while (node) {\n yield node;\n node = node.nextSibling;\n }\n }\n\n get firstChild(): ElementNode<T> | null {\n return this._firstChild;\n }\n\n set firstChild(firstChild: ElementNode<T> | null) {\n this._firstChild = firstChild;\n this.ownerDocument.markDirty(this);\n }\n\n get lastChild(): ElementNode<T> | null {\n return this._lastChild;\n }\n\n set lastChild(lastChild: ElementNode<T> | null) {\n this._lastChild = lastChild;\n this.ownerDocument.markDirty(this);\n }\n\n get previousSibling(): ElementNode<T> | null {\n return this._previousSibling;\n }\n\n set previousSibling(previousSibling: ElementNode<T> | null) {\n this._previousSibling = previousSibling;\n this.ownerDocument.markDirty(this);\n }\n\n get nextSibling(): ElementNode<T> | null {\n return this._nextSibling;\n }\n\n set nextSibling(nextSibling: ElementNode<T> | null) {\n this._nextSibling = nextSibling;\n this.ownerDocument.markDirty(this);\n }\n\n get parentNode(): BaseNode<T> | null {\n return this._parentNode;\n }\n\n set parentNode(parentNode: BaseNode<T> | null) {\n this._parentNode = parentNode;\n this.ownerDocument.markDirty(this);\n }\n\n get isConnected(): boolean {\n return this.parentNode?.isConnected || false;\n }\n\n private invalidateChildIndices(child: ElementNode<T>): void {\n if (this._minInvalidChildIndex == null || !this._minInvalidChildIndex.isConnected || child.index < this._minInvalidChildIndex.index) {\n this._minInvalidChildIndex = child;\n this.ownerDocument.markDirty(this);\n }\n }\n\n updateChildIndices(): void {\n let node = this._minInvalidChildIndex;\n while (node) {\n node.index = node.previousSibling ? node.previousSibling.index + 1 : 0;\n node = node.nextSibling;\n }\n this._minInvalidChildIndex = null;\n }\n\n appendChild(child: ElementNode<T>): void {\n if (child.parentNode) {\n child.parentNode.removeChild(child);\n }\n\n if (this.firstChild == null) {\n this.firstChild = child;\n }\n\n if (this.lastChild) {\n this.lastChild.nextSibling = child;\n child.index = this.lastChild.index + 1;\n child.previousSibling = this.lastChild;\n } else {\n child.previousSibling = null;\n child.index = 0;\n }\n\n child.parentNode = this;\n child.nextSibling = null;\n this.lastChild = child;\n\n this.ownerDocument.markDirty(this);\n if (this.isConnected) {\n this.ownerDocument.queueUpdate();\n }\n }\n\n insertBefore(newNode: ElementNode<T>, referenceNode: ElementNode<T>): void {\n if (referenceNode == null) {\n return this.appendChild(newNode);\n }\n\n if (newNode.parentNode) {\n newNode.parentNode.removeChild(newNode);\n }\n\n newNode.nextSibling = referenceNode;\n newNode.previousSibling = referenceNode.previousSibling;\n // Ensure that the newNode's index is less than that of the reference node so that\n // invalidateChildIndices will properly use the newNode as the _minInvalidChildIndex, thus making sure\n // we will properly update the indexes of all sibiling nodes after the newNode. The value here doesn't matter\n // since updateChildIndices should calculate the proper indexes.\n newNode.index = referenceNode.index - 1;\n if (this.firstChild === referenceNode) {\n this.firstChild = newNode;\n } else if (referenceNode.previousSibling) {\n referenceNode.previousSibling.nextSibling = newNode;\n }\n\n referenceNode.previousSibling = newNode;\n newNode.parentNode = referenceNode.parentNode;\n\n this.invalidateChildIndices(newNode);\n if (this.isConnected) {\n this.ownerDocument.queueUpdate();\n }\n }\n\n removeChild(child: ElementNode<T>): void {\n if (child.parentNode !== this) {\n return;\n }\n\n if (this._minInvalidChildIndex === child) {\n this._minInvalidChildIndex = null;\n }\n\n if (child.nextSibling) {\n this.invalidateChildIndices(child.nextSibling);\n child.nextSibling.previousSibling = child.previousSibling;\n }\n\n if (child.previousSibling) {\n child.previousSibling.nextSibling = child.nextSibling;\n }\n\n if (this.firstChild === child) {\n this.firstChild = child.nextSibling;\n }\n\n if (this.lastChild === child) {\n this.lastChild = child.previousSibling;\n }\n\n child.parentNode = null;\n child.nextSibling = null;\n child.previousSibling = null;\n child.index = 0;\n\n this.ownerDocument.markDirty(child);\n if (this.isConnected) {\n this.ownerDocument.queueUpdate();\n }\n }\n\n addEventListener(): void {}\n removeEventListener(): void {}\n\n get previousVisibleSibling(): ElementNode<T> | null {\n let node = this.previousSibling;\n while (node && node.isHidden) {\n node = node.previousSibling;\n }\n return node;\n }\n\n get nextVisibleSibling(): ElementNode<T> | null {\n let node = this.nextSibling;\n while (node && node.isHidden) {\n node = node.nextSibling;\n }\n return node;\n }\n\n get firstVisibleChild(): ElementNode<T> | null {\n let node = this.firstChild;\n while (node && node.isHidden) {\n node = node.nextSibling;\n }\n return node;\n }\n\n get lastVisibleChild(): ElementNode<T> | null {\n let node = this.lastChild;\n while (node && node.isHidden) {\n node = node.previousSibling;\n }\n return node;\n }\n}\n\n/**\n * A mutable element node in the fake DOM tree. It owns an immutable\n * Collection Node which is copied on write.\n */\nexport class ElementNode<T> extends BaseNode<T> {\n nodeType = 8; // COMMENT_NODE (we'd use ELEMENT_NODE but React DevTools will fail to get its dimensions)\n node: CollectionNode<T> | null;\n isMutated = true;\n private _index: number = 0;\n isHidden = false;\n\n constructor(type: string, ownerDocument: Document<T, any>) {\n super(ownerDocument);\n this.node = null;\n }\n\n get index(): number {\n return this._index;\n }\n\n set index(index: number) {\n this._index = index;\n this.ownerDocument.markDirty(this);\n }\n\n get level(): number {\n if (this.parentNode instanceof ElementNode) {\n return this.parentNode.level + (this.parentNode.node?.type === 'item' ? 1 : 0);\n }\n\n return 0;\n }\n\n /**\n * Lazily gets a mutable instance of a Node. If the node has already\n * been cloned during this update cycle, it just returns the existing one.\n */\n private getMutableNode(): Mutable<CollectionNode<T>> | null {\n if (this.node == null) {\n return null;\n }\n\n if (!this.isMutated) {\n this.node = this.node.clone();\n this.isMutated = true;\n }\n\n this.ownerDocument.markDirty(this);\n return this.node;\n }\n\n updateNode(): void {\n let nextSibling = this.nextVisibleSibling;\n let node = this.getMutableNode();\n if (node == null) {\n return;\n }\n\n node.index = this.index;\n node.level = this.level;\n node.parentKey = this.parentNode instanceof ElementNode ? this.parentNode.node?.key ?? null : null;\n node.prevKey = this.previousVisibleSibling?.node?.key ?? null;\n node.nextKey = nextSibling?.node?.key ?? null;\n node.hasChildNodes = !!this.firstChild;\n node.firstChildKey = this.firstVisibleChild?.node?.key ?? null;\n node.lastChildKey = this.lastVisibleChild?.node?.key ?? null;\n\n // Update the colIndex of sibling nodes if this node has a colSpan.\n if ((node.colSpan != null || node.colIndex != null) && nextSibling) {\n // This queues the next sibling for update, which means this happens recursively.\n let nextColIndex = (node.colIndex ?? node.index) + (node.colSpan ?? 1);\n if (nextSibling.node != null && nextColIndex !== nextSibling.node.colIndex) {\n let siblingNode = nextSibling.getMutableNode();\n siblingNode!.colIndex = nextColIndex;\n }\n }\n }\n\n setProps<E extends Element>(obj: {[key: string]: any}, ref: ForwardedRef<E>, CollectionNodeClass: CollectionNodeClass<any>, rendered?: ReactNode, render?: (node: Node<T>) => ReactElement): void {\n let node;\n let {value, textValue, id, ...props} = obj;\n if (this.node == null) {\n node = new CollectionNodeClass(id ?? `react-aria-${++this.ownerDocument.nodeId}`);\n this.node = node;\n } else {\n node = this.getMutableNode();\n }\n\n props.ref = ref;\n node.props = props;\n node.rendered = rendered;\n node.render = render;\n node.value = value;\n if (obj['aria-label']) {\n node['aria-label'] = obj['aria-label'];\n }\n node.textValue = textValue || (typeof props.children === 'string' ? props.children : '') || obj['aria-label'] || '';\n if (id != null && id !== node.key) {\n throw new Error('Cannot change the id of an item');\n }\n\n if (props.colSpan != null) {\n node.colSpan = props.colSpan;\n }\n\n if (this.isConnected) {\n this.ownerDocument.queueUpdate();\n }\n }\n\n get style(): CSSProperties {\n // React sets display: none to hide elements during Suspense.\n // We'll handle this by setting the element to hidden and invalidating\n // its siblings/parent. Hidden elements remain in the Document, but\n // are removed from the Collection.\n let element = this;\n return {\n get display() {\n return element.isHidden ? 'none' : '';\n },\n set display(value) {\n let isHidden = value === 'none';\n if (element.isHidden !== isHidden) {\n // Mark parent node dirty if this element is currently the first or last visible child.\n if (element.parentNode?.firstVisibleChild === element || element.parentNode?.lastVisibleChild === element) {\n element.ownerDocument.markDirty(element.parentNode);\n }\n\n // Mark sibling visible elements dirty.\n let prev = element.previousVisibleSibling;\n let next = element.nextVisibleSibling;\n if (prev) {\n element.ownerDocument.markDirty(prev);\n }\n if (next) {\n element.ownerDocument.markDirty(next);\n }\n\n // Mark self dirty.\n element.isHidden = isHidden;\n element.ownerDocument.markDirty(element);\n }\n }\n };\n }\n\n hasAttribute(): void {}\n setAttribute(): void {}\n setAttributeNS(): void {}\n removeAttribute(): void {}\n}\n\n/**\n * A mutable Document in the fake DOM. It owns an immutable Collection instance,\n * which is lazily copied on write during updates.\n */\nexport class Document<T, C extends BaseCollection<T> = BaseCollection<T>> extends BaseNode<T> {\n nodeType = 11; // DOCUMENT_FRAGMENT_NODE\n ownerDocument: Document<T, C> = this;\n dirtyNodes: Set<BaseNode<T>> = new Set();\n isSSR = false;\n nodeId = 0;\n nodesByProps: WeakMap<object, ElementNode<T>> = new WeakMap<object, ElementNode<T>>();\n private collection: C;\n private nextCollection: C | null = null;\n private subscriptions: Set<() => void> = new Set();\n private queuedRender = false;\n private inSubscription = false;\n\n constructor(collection: C) {\n // @ts-ignore\n super(null);\n this.collection = collection;\n this.nextCollection = collection;\n }\n\n get isConnected(): boolean {\n return true;\n }\n\n createElement(type: string): ElementNode<T> {\n return new ElementNode(type, this);\n }\n\n private getMutableCollection() {\n if (!this.nextCollection) {\n this.nextCollection = this.collection.clone();\n }\n\n return this.nextCollection;\n }\n\n markDirty(node: BaseNode<T>): void {\n this.dirtyNodes.add(node);\n }\n\n private addNode(element: ElementNode<T>): void {\n if (element.isHidden || element.node == null) {\n return;\n }\n\n let collection = this.getMutableCollection();\n if (!collection.getItem(element.node.key)) {\n for (let child of element) {\n this.addNode(child);\n }\n }\n\n collection.addNode(element.node);\n }\n\n private removeNode(node: ElementNode<T>): void {\n for (let child of node) {\n this.removeNode(child);\n }\n\n if (node.node) {\n let collection = this.getMutableCollection();\n collection.removeNode(node.node.key);\n }\n }\n\n /** Finalizes the collection update, updating all nodes and freezing the collection. */\n getCollection(): C {\n // If in a subscription update, return return the existing collection.\n // React will call getCollection again during render, at which point all the updates will be complete.\n if (this.inSubscription) {\n return this.collection;\n }\n\n // Reset queuedRender to false when getCollection is called during render.\n this.queuedRender = false;\n\n this.updateCollection();\n return this.collection;\n }\n\n updateCollection(): void {\n // First, remove disconnected nodes and update the indices of dirty element children.\n for (let element of this.dirtyNodes) {\n if (element instanceof ElementNode && (!element.isConnected || element.isHidden)) {\n this.removeNode(element);\n } else {\n element.updateChildIndices();\n }\n }\n\n // Next, update dirty collection nodes.\n for (let element of this.dirtyNodes) {\n if (element instanceof ElementNode) {\n if (element.isConnected && !element.isHidden) {\n element.updateNode();\n this.addNode(element);\n }\n\n if (element.node) {\n this.dirtyNodes.delete(element);\n }\n\n element.isMutated = false;\n } else {\n this.dirtyNodes.delete(element);\n }\n }\n\n // Finally, update the collection.\n if (this.nextCollection) {\n this.nextCollection.commit(this.firstVisibleChild?.node?.key ?? null, this.lastVisibleChild?.node?.key ?? null, this.isSSR);\n if (!this.isSSR) {\n this.collection = this.nextCollection;\n this.nextCollection = null;\n }\n }\n }\n\n queueUpdate(): void {\n if (this.dirtyNodes.size === 0 || this.queuedRender) {\n return;\n }\n\n // Only trigger subscriptions once during an update, when the first item changes.\n // React's useSyncExternalStore will call getCollection immediately, to check whether the snapshot changed.\n // If so, React will queue a render to happen after the current commit to our fake DOM finishes.\n // We track whether getCollection is called in a subscription, and once it is called during render,\n // we reset queuedRender back to false.\n this.queuedRender = true;\n this.inSubscription = true;\n\n // Clone the collection to ensure that React queues a render. It will call getCollection again\n // during render, at which point all the updates will be complete and we can return\n // the new collection.\n if (!this.isSSR) {\n this.collection = this.collection.clone();\n }\n\n for (let fn of this.subscriptions) {\n fn();\n }\n\n this.inSubscription = false;\n }\n\n subscribe(fn: () => void) {\n this.subscriptions.add(fn);\n return (): boolean => this.subscriptions.delete(fn);\n }\n\n resetAfterSSR(): void {\n if (this.isSSR) {\n this.isSSR = false;\n this.firstChild = null;\n this.lastChild = null;\n this.nodeId = 0;\n }\n }\n}\n"],"names":[],"version":3,"file":"Document.module.js.map"}
|
package/dist/Hidden.main.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
var $a8uUY$react = require("react");
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function $parcel$interopDefault(a) {
|
|
5
|
-
return a && a.__esModule ? a.default : a;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function $parcel$export(e, n, v, s) {
|
|
9
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
$parcel$export(module.exports, "Hidden", () => $eaaf60978b89fc58$export$8dc98ba7eadeaa56);
|
|
13
|
-
$parcel$export(module.exports, "createHideableComponent", () => $eaaf60978b89fc58$export$86427a43e3e48ebb);
|
|
14
|
-
$parcel$export(module.exports, "useIsHidden", () => $eaaf60978b89fc58$export$b5d7cc18bb8d2b59);
|
|
15
|
-
/*
|
|
16
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
17
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
18
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
19
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
-
*
|
|
21
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
22
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
23
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
24
|
-
* governing permissions and limitations under the License.
|
|
25
|
-
*/
|
|
26
|
-
// React doesn't understand the <template> element, which doesn't have children like a normal element.
|
|
27
|
-
// It will throw an error during hydration when it expects the firstChild to contain content rendered
|
|
28
|
-
// on the server, when in reality, the browser will have placed this inside the `content` document fragment.
|
|
29
|
-
// This monkey patches the firstChild property for our special hidden template elements to work around this error.
|
|
30
|
-
// does the same for appendChild/removeChild/insertBefore as per the issue below
|
|
31
|
-
// See https://github.com/facebook/react/issues/19932
|
|
32
|
-
if (typeof HTMLTemplateElement !== 'undefined') {
|
|
33
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'firstChild', {
|
|
34
|
-
configurable: true,
|
|
35
|
-
enumerable: true,
|
|
36
|
-
get: function() {
|
|
37
|
-
return this.content.firstChild;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'appendChild', {
|
|
41
|
-
configurable: true,
|
|
42
|
-
enumerable: true,
|
|
43
|
-
value: function(node) {
|
|
44
|
-
return this.content.appendChild(node);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'removeChild', {
|
|
48
|
-
configurable: true,
|
|
49
|
-
enumerable: true,
|
|
50
|
-
value: function(node) {
|
|
51
|
-
return this.content.removeChild(node);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'insertBefore', {
|
|
55
|
-
configurable: true,
|
|
56
|
-
enumerable: true,
|
|
57
|
-
value: function(node, child) {
|
|
58
|
-
return this.content.insertBefore(node, child);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
const $eaaf60978b89fc58$export$94b6d0abf7d33e8c = /*#__PURE__*/ (0, $a8uUY$react.createContext)(false);
|
|
63
|
-
function $eaaf60978b89fc58$export$8dc98ba7eadeaa56(props) {
|
|
64
|
-
let isHidden = (0, $a8uUY$react.useContext)($eaaf60978b89fc58$export$94b6d0abf7d33e8c);
|
|
65
|
-
if (isHidden) // Don't hide again if we are already hidden.
|
|
66
|
-
return /*#__PURE__*/ (0, ($parcel$interopDefault($a8uUY$react))).createElement((0, ($parcel$interopDefault($a8uUY$react))).Fragment, null, props.children);
|
|
67
|
-
let children = /*#__PURE__*/ (0, ($parcel$interopDefault($a8uUY$react))).createElement($eaaf60978b89fc58$export$94b6d0abf7d33e8c.Provider, {
|
|
68
|
-
value: true
|
|
69
|
-
}, props.children);
|
|
70
|
-
// In SSR, portals are not supported by React. Instead, always render into a <template>
|
|
71
|
-
// element, which the browser will never display to the user. In addition, the
|
|
72
|
-
// content is not part of the accessible DOM tree, so it won't affect ids or other accessibility attributes.
|
|
73
|
-
return /*#__PURE__*/ (0, ($parcel$interopDefault($a8uUY$react))).createElement("template", null, children);
|
|
74
|
-
}
|
|
75
|
-
function $eaaf60978b89fc58$export$86427a43e3e48ebb(fn) {
|
|
76
|
-
let Wrapper = (props, ref)=>{
|
|
77
|
-
let isHidden = (0, $a8uUY$react.useContext)($eaaf60978b89fc58$export$94b6d0abf7d33e8c);
|
|
78
|
-
if (isHidden) return null;
|
|
79
|
-
return fn(props, ref);
|
|
80
|
-
};
|
|
81
|
-
// @ts-ignore - for react dev tools
|
|
82
|
-
Wrapper.displayName = fn.displayName || fn.name;
|
|
83
|
-
return (0, $a8uUY$react.forwardRef)(Wrapper);
|
|
84
|
-
}
|
|
85
|
-
function $eaaf60978b89fc58$export$b5d7cc18bb8d2b59() {
|
|
86
|
-
return (0, $a8uUY$react.useContext)($eaaf60978b89fc58$export$94b6d0abf7d33e8c);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
//# sourceMappingURL=Hidden.main.js.map
|
package/dist/Hidden.main.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAKD,sGAAsG;AACtG,qGAAqG;AACrG,4GAA4G;AAC5G,kHAAkH;AAClH,gFAAgF;AAChF,qDAAqD;AACrD,IAAI,OAAO,wBAAwB,aAAa;IAC9C,OAAO,cAAc,CAAC,oBAAoB,SAAS,EAAE,cAAc;QACjE,cAAc;QACd,YAAY;QACZ,KAAK;YACH,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU;QAChC;IACF;IAEA,OAAO,cAAc,CAAC,oBAAoB,SAAS,EAAE,eAAe;QAClE,cAAc;QACd,YAAY;QACZ,OAAO,SAAU,IAAI;YACnB,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QAClC;IACF;IAEA,OAAO,cAAc,CAAC,oBAAoB,SAAS,EAAE,eAAe;QAClE,cAAc;QACd,YAAY;QACZ,OAAO,SAAU,IAAI;YACnB,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QAClC;IACF;IAEA,OAAO,cAAc,CAAC,oBAAoB,SAAS,EAAE,gBAAgB;QACnE,cAAc;QACd,YAAY;QACZ,OAAO,SAAU,IAAI,EAAE,KAAK;YAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM;QACzC;IACF;AACF;AAEO,MAAM,0DAAkC,CAAA,GAAA,0BAAY,EAAW;AAE/D,SAAS,0CAAO,KAA4B;IACjD,IAAI,WAAW,CAAA,GAAA,uBAAS,EAAE;IAE1B,IAAI,UACF,6CAA6C;IAC7C,qBAAO,sHAAG,MAAM,QAAQ;IAG1B,IAAI,yBACF,0DAAC,0CAAc,QAAQ;QAAC,OAAA;OACrB,MAAM,QAAQ;IAInB,uFAAuF;IACvF,8EAA8E;IAC9E,4GAA4G;IAC5G,qBAAO,0DAAC,kBAAU;AACpB;AAIO,SAAS,0CAAmC,EAAwD;IACzG,IAAI,UAAU,CAAC,OAAU;QACvB,IAAI,WAAW,CAAA,GAAA,uBAAS,EAAE;QAC1B,IAAI,UACF,OAAO;QAGT,OAAO,GAAG,OAAO;IACnB;IACA,mCAAmC;IACnC,QAAQ,WAAW,GAAG,GAAG,WAAW,IAAI,GAAG,IAAI;IAC/C,OAAO,AAAC,CAAA,GAAA,uBAAS,EAAqB;AACxC;AAGO,SAAS;IACd,OAAO,CAAA,GAAA,uBAAS,EAAE;AACpB","sources":["packages/@react-aria/collections/src/Hidden.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {forwardRefType} from '@react-types/shared';\nimport React, {Context, createContext, forwardRef, JSX, ReactElement, ReactNode, useContext} from 'react';\n\n// React doesn't understand the <template> element, which doesn't have children like a normal element.\n// It will throw an error during hydration when it expects the firstChild to contain content rendered\n// on the server, when in reality, the browser will have placed this inside the `content` document fragment.\n// This monkey patches the firstChild property for our special hidden template elements to work around this error.\n// does the same for appendChild/removeChild/insertBefore as per the issue below\n// See https://github.com/facebook/react/issues/19932\nif (typeof HTMLTemplateElement !== 'undefined') {\n Object.defineProperty(HTMLTemplateElement.prototype, 'firstChild', {\n configurable: true,\n enumerable: true,\n get: function () {\n return this.content.firstChild;\n }\n });\n\n Object.defineProperty(HTMLTemplateElement.prototype, 'appendChild', {\n configurable: true,\n enumerable: true,\n value: function (node) {\n return this.content.appendChild(node);\n }\n });\n\n Object.defineProperty(HTMLTemplateElement.prototype, 'removeChild', {\n configurable: true,\n enumerable: true,\n value: function (node) {\n return this.content.removeChild(node);\n }\n });\n\n Object.defineProperty(HTMLTemplateElement.prototype, 'insertBefore', {\n configurable: true,\n enumerable: true,\n value: function (node, child) {\n return this.content.insertBefore(node, child);\n }\n });\n}\n\nexport const HiddenContext: Context<boolean> = createContext<boolean>(false);\n\nexport function Hidden(props: {children: ReactNode}): JSX.Element {\n let isHidden = useContext(HiddenContext);\n\n if (isHidden) {\n // Don't hide again if we are already hidden.\n return <>{props.children}</>;\n }\n\n let children = (\n <HiddenContext.Provider value>\n {props.children}\n </HiddenContext.Provider>\n );\n\n // In SSR, portals are not supported by React. Instead, always render into a <template>\n // element, which the browser will never display to the user. In addition, the\n // content is not part of the accessible DOM tree, so it won't affect ids or other accessibility attributes.\n return <template>{children}</template>;\n}\n\n/** Creates a component that forwards its ref and returns null if it is in a hidden subtree. */\n// Note: this function is handled specially in the documentation generator. If you change it, you'll need to update DocsTransformer as well.\nexport function createHideableComponent<T, P = {}>(fn: (props: P, ref: React.Ref<T>) => ReactElement | null): (props: P & React.RefAttributes<T>) => ReactElement | null {\n let Wrapper = (props: P, ref: React.Ref<T>) => {\n let isHidden = useContext(HiddenContext);\n if (isHidden) {\n return null;\n }\n\n return fn(props, ref);\n };\n // @ts-ignore - for react dev tools\n Wrapper.displayName = fn.displayName || fn.name;\n return (forwardRef as forwardRefType)(Wrapper);\n}\n\n/** Returns whether the component is in a hidden subtree. */\nexport function useIsHidden(): boolean {\n return useContext(HiddenContext);\n}\n"],"names":[],"version":3,"file":"Hidden.main.js.map"}
|
package/dist/Hidden.mjs
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import $8SdCi$react, {createContext as $8SdCi$createContext, useContext as $8SdCi$useContext, forwardRef as $8SdCi$forwardRef} from "react";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
5
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
-
* governing permissions and limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
// React doesn't understand the <template> element, which doesn't have children like a normal element.
|
|
15
|
-
// It will throw an error during hydration when it expects the firstChild to contain content rendered
|
|
16
|
-
// on the server, when in reality, the browser will have placed this inside the `content` document fragment.
|
|
17
|
-
// This monkey patches the firstChild property for our special hidden template elements to work around this error.
|
|
18
|
-
// does the same for appendChild/removeChild/insertBefore as per the issue below
|
|
19
|
-
// See https://github.com/facebook/react/issues/19932
|
|
20
|
-
if (typeof HTMLTemplateElement !== 'undefined') {
|
|
21
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'firstChild', {
|
|
22
|
-
configurable: true,
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function() {
|
|
25
|
-
return this.content.firstChild;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'appendChild', {
|
|
29
|
-
configurable: true,
|
|
30
|
-
enumerable: true,
|
|
31
|
-
value: function(node) {
|
|
32
|
-
return this.content.appendChild(node);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'removeChild', {
|
|
36
|
-
configurable: true,
|
|
37
|
-
enumerable: true,
|
|
38
|
-
value: function(node) {
|
|
39
|
-
return this.content.removeChild(node);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'insertBefore', {
|
|
43
|
-
configurable: true,
|
|
44
|
-
enumerable: true,
|
|
45
|
-
value: function(node, child) {
|
|
46
|
-
return this.content.insertBefore(node, child);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
const $f39a9eba43920ace$export$94b6d0abf7d33e8c = /*#__PURE__*/ (0, $8SdCi$createContext)(false);
|
|
51
|
-
function $f39a9eba43920ace$export$8dc98ba7eadeaa56(props) {
|
|
52
|
-
let isHidden = (0, $8SdCi$useContext)($f39a9eba43920ace$export$94b6d0abf7d33e8c);
|
|
53
|
-
if (isHidden) // Don't hide again if we are already hidden.
|
|
54
|
-
return /*#__PURE__*/ (0, $8SdCi$react).createElement((0, $8SdCi$react).Fragment, null, props.children);
|
|
55
|
-
let children = /*#__PURE__*/ (0, $8SdCi$react).createElement($f39a9eba43920ace$export$94b6d0abf7d33e8c.Provider, {
|
|
56
|
-
value: true
|
|
57
|
-
}, props.children);
|
|
58
|
-
// In SSR, portals are not supported by React. Instead, always render into a <template>
|
|
59
|
-
// element, which the browser will never display to the user. In addition, the
|
|
60
|
-
// content is not part of the accessible DOM tree, so it won't affect ids or other accessibility attributes.
|
|
61
|
-
return /*#__PURE__*/ (0, $8SdCi$react).createElement("template", null, children);
|
|
62
|
-
}
|
|
63
|
-
function $f39a9eba43920ace$export$86427a43e3e48ebb(fn) {
|
|
64
|
-
let Wrapper = (props, ref)=>{
|
|
65
|
-
let isHidden = (0, $8SdCi$useContext)($f39a9eba43920ace$export$94b6d0abf7d33e8c);
|
|
66
|
-
if (isHidden) return null;
|
|
67
|
-
return fn(props, ref);
|
|
68
|
-
};
|
|
69
|
-
// @ts-ignore - for react dev tools
|
|
70
|
-
Wrapper.displayName = fn.displayName || fn.name;
|
|
71
|
-
return (0, $8SdCi$forwardRef)(Wrapper);
|
|
72
|
-
}
|
|
73
|
-
function $f39a9eba43920ace$export$b5d7cc18bb8d2b59() {
|
|
74
|
-
return (0, $8SdCi$useContext)($f39a9eba43920ace$export$94b6d0abf7d33e8c);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
export {$f39a9eba43920ace$export$94b6d0abf7d33e8c as HiddenContext, $f39a9eba43920ace$export$8dc98ba7eadeaa56 as Hidden, $f39a9eba43920ace$export$86427a43e3e48ebb as createHideableComponent, $f39a9eba43920ace$export$b5d7cc18bb8d2b59 as useIsHidden};
|
|
79
|
-
//# sourceMappingURL=Hidden.module.js.map
|