@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
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import {BaseCollection as $23b9f4fcf0fe224b$export$408d25a4e12db025, CollectionNode as $23b9f4fcf0fe224b$export$d68d59712b04d9d1} from "./BaseCollection.module.js";
|
|
2
|
-
import {Document as $681cc3c98f569e39$export$b34a105447964f9f} from "./Document.module.js";
|
|
3
|
-
import {useCachedChildren as $e948873055cbafe4$export$727c8fc270210f13} from "./useCachedChildren.module.js";
|
|
4
|
-
import {Hidden as $f39a9eba43920ace$export$8dc98ba7eadeaa56} from "./Hidden.module.js";
|
|
5
|
-
import {createPortal as $95feo$createPortal} from "react-dom";
|
|
6
|
-
import {FocusableContext as $95feo$FocusableContext} from "@react-aria/interactions";
|
|
7
|
-
import $95feo$react, {createContext as $95feo$createContext, useContext as $95feo$useContext, useRef as $95feo$useRef, useCallback as $95feo$useCallback, useState as $95feo$useState, forwardRef as $95feo$forwardRef, useMemo as $95feo$useMemo} from "react";
|
|
8
|
-
import {useIsSSR as $95feo$useIsSSR} from "@react-aria/ssr";
|
|
9
|
-
import {useSyncExternalStore as $95feo$useSyncExternalStore} from "use-sync-external-store/shim/index.js";
|
|
10
|
-
|
|
11
|
-
/*
|
|
12
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
13
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
-
* governing permissions and limitations under the License.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const $e1995378a142960e$var$ShallowRenderContext = /*#__PURE__*/ (0, $95feo$createContext)(false);
|
|
31
|
-
const $e1995378a142960e$var$CollectionDocumentContext = /*#__PURE__*/ (0, $95feo$createContext)(null);
|
|
32
|
-
function $e1995378a142960e$export$bf788dd355e3a401(props) {
|
|
33
|
-
// If a document was provided above us, we're already in a hidden tree. Just render the content.
|
|
34
|
-
let doc = (0, $95feo$useContext)($e1995378a142960e$var$CollectionDocumentContext);
|
|
35
|
-
if (doc) // The React types prior to 18 did not allow returning ReactNode from components
|
|
36
|
-
// even though the actual implementation since React 16 did.
|
|
37
|
-
// We must return ReactElement so that TS does not complain that <CollectionBuilder>
|
|
38
|
-
// is not a valid JSX element with React 16 and 17 types.
|
|
39
|
-
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20544
|
|
40
|
-
return props.content;
|
|
41
|
-
// Otherwise, render a hidden copy of the children so that we can build the collection before constructing the state.
|
|
42
|
-
// This should always come before the real DOM content so we have built the collection by the time it renders during SSR.
|
|
43
|
-
// This is fine. CollectionDocumentContext never changes after mounting.
|
|
44
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
45
|
-
let { collection: collection, document: document } = $e1995378a142960e$var$useCollectionDocument(props.createCollection);
|
|
46
|
-
return /*#__PURE__*/ (0, $95feo$react).createElement((0, $95feo$react).Fragment, null, /*#__PURE__*/ (0, $95feo$react).createElement((0, $f39a9eba43920ace$export$8dc98ba7eadeaa56), null, /*#__PURE__*/ (0, $95feo$react).createElement($e1995378a142960e$var$CollectionDocumentContext.Provider, {
|
|
47
|
-
value: document
|
|
48
|
-
}, props.content)), /*#__PURE__*/ (0, $95feo$react).createElement($e1995378a142960e$var$CollectionInner, {
|
|
49
|
-
render: props.children,
|
|
50
|
-
collection: collection
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
53
|
-
function $e1995378a142960e$var$CollectionInner({ collection: collection, render: render }) {
|
|
54
|
-
return render(collection);
|
|
55
|
-
}
|
|
56
|
-
// React 16 and 17 don't support useSyncExternalStore natively, and the shim provided by React does not support getServerSnapshot.
|
|
57
|
-
// This wrapper uses the shim, but additionally calls getServerSnapshot during SSR (according to SSRProvider).
|
|
58
|
-
function $e1995378a142960e$var$useSyncExternalStoreFallback(subscribe, getSnapshot, getServerSnapshot) {
|
|
59
|
-
let isSSR = (0, $95feo$useIsSSR)();
|
|
60
|
-
let isSSRRef = (0, $95feo$useRef)(isSSR);
|
|
61
|
-
// This is read immediately inside the wrapper, which also runs during render.
|
|
62
|
-
// We just need a ref to avoid invalidating the callback itself, which
|
|
63
|
-
// would cause React to re-run the callback more than necessary.
|
|
64
|
-
// eslint-disable-next-line rulesdir/pure-render
|
|
65
|
-
isSSRRef.current = isSSR;
|
|
66
|
-
let getSnapshotWrapper = (0, $95feo$useCallback)(()=>{
|
|
67
|
-
return isSSRRef.current ? getServerSnapshot() : getSnapshot();
|
|
68
|
-
}, [
|
|
69
|
-
getSnapshot,
|
|
70
|
-
getServerSnapshot
|
|
71
|
-
]);
|
|
72
|
-
return (0, $95feo$useSyncExternalStore)(subscribe, getSnapshotWrapper);
|
|
73
|
-
}
|
|
74
|
-
const $e1995378a142960e$var$useSyncExternalStore = typeof (0, $95feo$react)['useSyncExternalStore'] === 'function' ? (0, $95feo$react)['useSyncExternalStore'] : $e1995378a142960e$var$useSyncExternalStoreFallback;
|
|
75
|
-
function $e1995378a142960e$var$useCollectionDocument(createCollection) {
|
|
76
|
-
// The document instance is mutable, and should never change between renders.
|
|
77
|
-
// useSyncExternalStore is used to subscribe to updates, which vends immutable Collection objects.
|
|
78
|
-
let [document] = (0, $95feo$useState)(()=>new (0, $681cc3c98f569e39$export$b34a105447964f9f)((createCollection === null || createCollection === void 0 ? void 0 : createCollection()) || new (0, $23b9f4fcf0fe224b$export$408d25a4e12db025)()));
|
|
79
|
-
let subscribe = (0, $95feo$useCallback)((fn)=>document.subscribe(fn), [
|
|
80
|
-
document
|
|
81
|
-
]);
|
|
82
|
-
let getSnapshot = (0, $95feo$useCallback)(()=>{
|
|
83
|
-
let collection = document.getCollection();
|
|
84
|
-
if (document.isSSR) // After SSR is complete, reset the document to empty so it is ready for React to render the portal into.
|
|
85
|
-
// We do this _after_ getting the collection above so that the collection still has content in it from SSR
|
|
86
|
-
// during the current render, before React has finished the client render.
|
|
87
|
-
document.resetAfterSSR();
|
|
88
|
-
return collection;
|
|
89
|
-
}, [
|
|
90
|
-
document
|
|
91
|
-
]);
|
|
92
|
-
let getServerSnapshot = (0, $95feo$useCallback)(()=>{
|
|
93
|
-
document.isSSR = true;
|
|
94
|
-
return document.getCollection();
|
|
95
|
-
}, [
|
|
96
|
-
document
|
|
97
|
-
]);
|
|
98
|
-
let collection = $e1995378a142960e$var$useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
99
|
-
return {
|
|
100
|
-
collection: collection,
|
|
101
|
-
document: document
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
const $e1995378a142960e$var$SSRContext = /*#__PURE__*/ (0, $95feo$createContext)(null);
|
|
105
|
-
function $e1995378a142960e$var$createCollectionNodeClass(type) {
|
|
106
|
-
var _class;
|
|
107
|
-
let NodeClass = (_class = class extends (0, $23b9f4fcf0fe224b$export$d68d59712b04d9d1) {
|
|
108
|
-
}, _class.type = type, _class);
|
|
109
|
-
return NodeClass;
|
|
110
|
-
}
|
|
111
|
-
function $e1995378a142960e$var$useSSRCollectionNode(CollectionNodeClass, props, ref, rendered, children, render) {
|
|
112
|
-
// To prevent breaking change, if CollectionNodeClass is a string, create a CollectionNodeClass using the string as the type
|
|
113
|
-
if (typeof CollectionNodeClass === 'string') CollectionNodeClass = $e1995378a142960e$var$createCollectionNodeClass(CollectionNodeClass);
|
|
114
|
-
// During SSR, portals are not supported, so the collection children will be wrapped in an SSRContext.
|
|
115
|
-
// Since SSR occurs only once, we assume that the elements are rendered in order and never re-render.
|
|
116
|
-
// Therefore we can create elements in our collection document during render so that they are in the
|
|
117
|
-
// collection by the time we need to use the collection to render to the real DOM.
|
|
118
|
-
// After hydration, we switch to client rendering using the portal.
|
|
119
|
-
let itemRef = (0, $95feo$useCallback)((element)=>{
|
|
120
|
-
element === null || element === void 0 ? void 0 : element.setProps(props, ref, CollectionNodeClass, rendered, render);
|
|
121
|
-
}, [
|
|
122
|
-
props,
|
|
123
|
-
ref,
|
|
124
|
-
rendered,
|
|
125
|
-
render,
|
|
126
|
-
CollectionNodeClass
|
|
127
|
-
]);
|
|
128
|
-
let parentNode = (0, $95feo$useContext)($e1995378a142960e$var$SSRContext);
|
|
129
|
-
if (parentNode) {
|
|
130
|
-
// Guard against double rendering in strict mode.
|
|
131
|
-
let element = parentNode.ownerDocument.nodesByProps.get(props);
|
|
132
|
-
if (!element) {
|
|
133
|
-
element = parentNode.ownerDocument.createElement(CollectionNodeClass.type);
|
|
134
|
-
element.setProps(props, ref, CollectionNodeClass, rendered, render);
|
|
135
|
-
parentNode.appendChild(element);
|
|
136
|
-
parentNode.ownerDocument.updateCollection();
|
|
137
|
-
parentNode.ownerDocument.nodesByProps.set(props, element);
|
|
138
|
-
}
|
|
139
|
-
return children ? /*#__PURE__*/ (0, $95feo$react).createElement($e1995378a142960e$var$SSRContext.Provider, {
|
|
140
|
-
value: element
|
|
141
|
-
}, children) : null;
|
|
142
|
-
}
|
|
143
|
-
// @ts-ignore
|
|
144
|
-
return /*#__PURE__*/ (0, $95feo$react).createElement(CollectionNodeClass.type, {
|
|
145
|
-
ref: itemRef
|
|
146
|
-
}, children);
|
|
147
|
-
}
|
|
148
|
-
function $e1995378a142960e$export$18af5c7a9e9b3664(CollectionNodeClass, render) {
|
|
149
|
-
let Component = ({ node: node })=>render(node.props, node.props.ref, node);
|
|
150
|
-
let Result = (0, $95feo$forwardRef)((props, ref)=>{
|
|
151
|
-
let focusableProps = (0, $95feo$useContext)((0, $95feo$FocusableContext));
|
|
152
|
-
let isShallow = (0, $95feo$useContext)($e1995378a142960e$var$ShallowRenderContext);
|
|
153
|
-
if (!isShallow) {
|
|
154
|
-
if (render.length >= 3) throw new Error(render.name + ' cannot be rendered outside a collection.');
|
|
155
|
-
return render(props, ref);
|
|
156
|
-
}
|
|
157
|
-
return $e1995378a142960e$var$useSSRCollectionNode(CollectionNodeClass, props, ref, 'children' in props ? props.children : null, null, (node)=>// Forward FocusableContext to real DOM tree so tooltips work.
|
|
158
|
-
/*#__PURE__*/ (0, $95feo$react).createElement((0, $95feo$FocusableContext).Provider, {
|
|
159
|
-
value: focusableProps
|
|
160
|
-
}, /*#__PURE__*/ (0, $95feo$react).createElement(Component, {
|
|
161
|
-
node: node
|
|
162
|
-
})));
|
|
163
|
-
});
|
|
164
|
-
// @ts-ignore
|
|
165
|
-
Result.displayName = render.name;
|
|
166
|
-
return Result;
|
|
167
|
-
}
|
|
168
|
-
function $e1995378a142960e$export$e953bb1cd0f19726(CollectionNodeClass, render, useChildren = $e1995378a142960e$var$useCollectionChildren) {
|
|
169
|
-
let Component = ({ node: node })=>render(node.props, node.props.ref, node);
|
|
170
|
-
let Result = (0, $95feo$forwardRef)((props, ref)=>{
|
|
171
|
-
let children = useChildren(props);
|
|
172
|
-
var _useSSRCollectionNode;
|
|
173
|
-
return (_useSSRCollectionNode = $e1995378a142960e$var$useSSRCollectionNode(CollectionNodeClass, props, ref, null, children, (node)=>/*#__PURE__*/ (0, $95feo$react).createElement(Component, {
|
|
174
|
-
node: node
|
|
175
|
-
}))) !== null && _useSSRCollectionNode !== void 0 ? _useSSRCollectionNode : /*#__PURE__*/ (0, $95feo$react).createElement((0, $95feo$react).Fragment, null);
|
|
176
|
-
});
|
|
177
|
-
// @ts-ignore
|
|
178
|
-
Result.displayName = render.name;
|
|
179
|
-
return Result;
|
|
180
|
-
}
|
|
181
|
-
function $e1995378a142960e$var$useCollectionChildren(options) {
|
|
182
|
-
return (0, $e948873055cbafe4$export$727c8fc270210f13)({
|
|
183
|
-
...options,
|
|
184
|
-
addIdAndValue: true
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
const $e1995378a142960e$var$CollectionContext = /*#__PURE__*/ (0, $95feo$createContext)(null);
|
|
188
|
-
function $e1995378a142960e$export$fb8073518f34e6ec(props) {
|
|
189
|
-
let ctx = (0, $95feo$useContext)($e1995378a142960e$var$CollectionContext);
|
|
190
|
-
let dependencies = ((ctx === null || ctx === void 0 ? void 0 : ctx.dependencies) || []).concat(props.dependencies);
|
|
191
|
-
var _props_idScope;
|
|
192
|
-
let idScope = (_props_idScope = props.idScope) !== null && _props_idScope !== void 0 ? _props_idScope : ctx === null || ctx === void 0 ? void 0 : ctx.idScope;
|
|
193
|
-
let children = $e1995378a142960e$var$useCollectionChildren({
|
|
194
|
-
...props,
|
|
195
|
-
idScope: idScope,
|
|
196
|
-
dependencies: dependencies
|
|
197
|
-
});
|
|
198
|
-
let doc = (0, $95feo$useContext)($e1995378a142960e$var$CollectionDocumentContext);
|
|
199
|
-
if (doc) children = /*#__PURE__*/ (0, $95feo$react).createElement($e1995378a142960e$var$CollectionRoot, null, children);
|
|
200
|
-
// Propagate dependencies and idScope to child collections.
|
|
201
|
-
ctx = (0, $95feo$useMemo)(()=>({
|
|
202
|
-
dependencies: dependencies,
|
|
203
|
-
idScope: idScope
|
|
204
|
-
}), [
|
|
205
|
-
idScope,
|
|
206
|
-
...dependencies
|
|
207
|
-
]);
|
|
208
|
-
return /*#__PURE__*/ (0, $95feo$react).createElement($e1995378a142960e$var$CollectionContext.Provider, {
|
|
209
|
-
value: ctx
|
|
210
|
-
}, children);
|
|
211
|
-
}
|
|
212
|
-
function $e1995378a142960e$var$CollectionRoot({ children: children }) {
|
|
213
|
-
let doc = (0, $95feo$useContext)($e1995378a142960e$var$CollectionDocumentContext);
|
|
214
|
-
let wrappedChildren = (0, $95feo$useMemo)(()=>/*#__PURE__*/ (0, $95feo$react).createElement($e1995378a142960e$var$CollectionDocumentContext.Provider, {
|
|
215
|
-
value: null
|
|
216
|
-
}, /*#__PURE__*/ (0, $95feo$react).createElement($e1995378a142960e$var$ShallowRenderContext.Provider, {
|
|
217
|
-
value: true
|
|
218
|
-
}, children)), [
|
|
219
|
-
children
|
|
220
|
-
]);
|
|
221
|
-
// During SSR, we render the content directly, and append nodes to the document during render.
|
|
222
|
-
// The collection children return null so that nothing is actually rendered into the HTML.
|
|
223
|
-
return (0, $95feo$useIsSSR)() ? /*#__PURE__*/ (0, $95feo$react).createElement($e1995378a142960e$var$SSRContext.Provider, {
|
|
224
|
-
value: doc
|
|
225
|
-
}, wrappedChildren) : /*#__PURE__*/ (0, $95feo$createPortal)(wrappedChildren, doc);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
export {$e1995378a142960e$export$bf788dd355e3a401 as CollectionBuilder, $e1995378a142960e$export$18af5c7a9e9b3664 as createLeafComponent, $e1995378a142960e$export$e953bb1cd0f19726 as createBranchComponent, $e1995378a142960e$export$fb8073518f34e6ec as Collection};
|
|
230
|
-
//# sourceMappingURL=CollectionBuilder.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAaD,MAAM,2DAAuB,CAAA,GAAA,oBAAY,EAAE;AAC3C,MAAM,gEAA4B,CAAA,GAAA,oBAAY,EAA6C;AAWpF,SAAS,0CAAoD,KAAgC;IAClG,gGAAgG;IAChG,IAAI,MAAM,CAAA,GAAA,iBAAS,EAAE;IACrB,IAAI,KACF,gFAAgF;IAChF,4DAA4D;IAC5D,oFAAoF;IACpF,yDAAyD;IACzD,kEAAkE;IAClE,OAAO,MAAM,OAAO;IAGtB,qHAAqH;IACrH,yHAAyH;IAEzH,wEAAwE;IACxE,sDAAsD;IACtD,IAAI,cAAC,UAAU,YAAE,QAAQ,EAAC,GAAG,4CAAsB,MAAM,gBAAgB;IACzE,qBACE,gFACE,gCAAC,CAAA,GAAA,yCAAK,uBACJ,gCAAC,gDAA0B,QAAQ;QAAC,OAAO;OACxC,MAAM,OAAO,kBAGlB,gCAAC;QAAgB,QAAQ,MAAM,QAAQ;QAAE,YAAY;;AAG3D;AAEA,SAAS,sCAAgB,cAAC,UAAU,UAAE,MAAM,EAAC;IAC3C,OAAO,OAAO;AAChB;AAOA,kIAAkI;AAClI,8GAA8G;AAC9G,SAAS,mDAAg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A,0BAAA,IAAK,YAAY,KAAI,EAAE,AAAD,EAAG,MAAM,CAAC,MAAM,YAAY;QACxD;IAAd,IAAI,UAAU,CAAA,iBAAA,MAAM,OAAO,cAAb,4BAAA,iBAAiB,gBAAA,0BAAA,IAAK,OAAO;IAC3C,IAAI,WAAW,4CAAsB;QACnC,GAAG,KAAK;iBACR;sBACA;IACF;IAEA,IAAI,MAAM,CAAA,GAAA,iBAAS,EAAE;IACrB,IAAI,KACF,yBAAW,gCAAC,4CAAgB;IAG9B,2DAA2D;IAC3D,MAAM,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;0BACnB;qBACA;QAEF,CAAA,GAAI;QAAC;WAAY;KAAa;IAE9B,qBACE,gCAAC,wCAAkB,QAAQ;QAAC,OAAO;OAChC;AAGP;AAEA,SAAS,qCAAe,YAAC,QAAQ,EAAC;IAChC,IAAI,MAAM,CAAA,GAAA,iBAAS,EAAE;IACrB,IAAI,kBAAkB,CAAA,GAAA,cAAM,EAAE,kBAC5B,gCAAC,gDAA0B,QAAQ;YAAC,OAAO;yBACzC,gCAAC,2CAAqB,QAAQ;YAAC,OAAA;WAC5B,YAGJ;QAAC;KAAS;IACb,8FAA8F;IAC9F,0FAA0F;IAC1F,OAAO,CAAA,GAAA,eAAO,oBACV,gCAAC,iCAAW,QAAQ;QAAC,OAAO;OAAM,iCAClC,CAAA,GAAA,mBAAW,EAAE,iBAAiB;AACpC","sources":["packages/@react-aria/collections/src/CollectionBuilder.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 {BaseCollection, CollectionNode} from './BaseCollection';\nimport {BaseNode, Document, ElementNode} from './Document';\nimport {CachedChildrenOptions, useCachedChildren} from './useCachedChildren';\nimport {createPortal} from 'react-dom';\nimport {FocusableContext} from '@react-aria/interactions';\nimport {forwardRefType, Key, Node} from '@react-types/shared';\nimport {Hidden} from './Hidden';\nimport React, {createContext, ForwardedRef, forwardRef, JSX, ReactElement, ReactNode, useCallback, useContext, useMemo, useRef, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\nimport {useSyncExternalStore as useSyncExternalStoreShim} from 'use-sync-external-store/shim/index.js';\n\nconst ShallowRenderContext = createContext(false);\nconst CollectionDocumentContext = createContext<Document<any, BaseCollection<any>> | null>(null);\n\nexport interface CollectionBuilderProps<C extends BaseCollection<object>> {\n content: ReactNode,\n children: (collection: C) => ReactNode,\n createCollection?: () => C\n}\n\n/**\n * Builds a `Collection` from the children provided to the `content` prop, and passes it to the child render prop function.\n */\nexport function CollectionBuilder<C extends BaseCollection<object>>(props: CollectionBuilderProps<C>): ReactElement {\n // If a document was provided above us, we're already in a hidden tree. Just render the content.\n let doc = useContext(CollectionDocumentContext);\n if (doc) {\n // The React types prior to 18 did not allow returning ReactNode from components\n // even though the actual implementation since React 16 did.\n // We must return ReactElement so that TS does not complain that <CollectionBuilder>\n // is not a valid JSX element with React 16 and 17 types.\n // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20544\n return props.content as ReactElement;\n }\n\n // Otherwise, render a hidden copy of the children so that we can build the collection before constructing the state.\n // This should always come before the real DOM content so we have built the collection by the time it renders during SSR.\n\n // This is fine. CollectionDocumentContext never changes after mounting.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n let {collection, document} = useCollectionDocument(props.createCollection);\n return (\n <>\n <Hidden>\n <CollectionDocumentContext.Provider value={document}>\n {props.content}\n </CollectionDocumentContext.Provider>\n </Hidden>\n <CollectionInner render={props.children} collection={collection} />\n </>\n );\n}\n\nfunction CollectionInner({collection, render}) {\n return render(collection);\n}\n\ninterface CollectionDocumentResult<T, C extends BaseCollection<T>> {\n collection: C,\n document: Document<T, C>\n}\n\n// React 16 and 17 don't support useSyncExternalStore natively, and the shim provided by React does not support getServerSnapshot.\n// This wrapper uses the shim, but additionally calls getServerSnapshot during SSR (according to SSRProvider).\nfunction useSyncExternalStoreFallback<C>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => C, getServerSnapshot: () => C): C {\n let isSSR = useIsSSR();\n let isSSRRef = useRef(isSSR);\n // This is read immediately inside the wrapper, which also runs during render.\n // We just need a ref to avoid invalidating the callback itself, which\n // would cause React to re-run the callback more than necessary.\n // eslint-disable-next-line rulesdir/pure-render\n isSSRRef.current = isSSR;\n\n let getSnapshotWrapper = useCallback(() => {\n return isSSRRef.current ? getServerSnapshot() : getSnapshot();\n }, [getSnapshot, getServerSnapshot]);\n return useSyncExternalStoreShim(subscribe, getSnapshotWrapper);\n}\n\nconst useSyncExternalStore = typeof React['useSyncExternalStore'] === 'function'\n ? React['useSyncExternalStore']\n : useSyncExternalStoreFallback;\n\nfunction useCollectionDocument<T extends object, C extends BaseCollection<T>>(createCollection?: () => C): CollectionDocumentResult<T, C> {\n // The document instance is mutable, and should never change between renders.\n // useSyncExternalStore is used to subscribe to updates, which vends immutable Collection objects.\n let [document] = useState(() => new Document<T, C>(createCollection?.() || new BaseCollection() as C));\n let subscribe = useCallback((fn: () => void) => document.subscribe(fn), [document]);\n let getSnapshot = useCallback(() => {\n let collection = document.getCollection();\n if (document.isSSR) {\n // After SSR is complete, reset the document to empty so it is ready for React to render the portal into.\n // We do this _after_ getting the collection above so that the collection still has content in it from SSR\n // during the current render, before React has finished the client render.\n document.resetAfterSSR();\n }\n return collection;\n }, [document]);\n let getServerSnapshot = useCallback(() => {\n document.isSSR = true;\n return document.getCollection();\n }, [document]);\n let collection = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n return {collection, document};\n}\n\nconst SSRContext = createContext<BaseNode<any> | null>(null);\n\nexport type CollectionNodeClass<T> = {\n new (key: Key): CollectionNode<T>,\n readonly type: string\n};\n\nfunction createCollectionNodeClass(type: string): CollectionNodeClass<any> {\n let NodeClass = class extends CollectionNode<any> {\n static readonly type = type;\n };\n return NodeClass;\n}\n\nfunction useSSRCollectionNode<T extends Element>(CollectionNodeClass: CollectionNodeClass<T> | string, props: object, ref: ForwardedRef<T>, rendered?: any, children?: ReactNode, render?: (node: Node<any>) => ReactElement) {\n // To prevent breaking change, if CollectionNodeClass is a string, create a CollectionNodeClass using the string as the type\n if (typeof CollectionNodeClass === 'string') {\n CollectionNodeClass = createCollectionNodeClass(CollectionNodeClass);\n }\n\n // During SSR, portals are not supported, so the collection children will be wrapped in an SSRContext.\n // Since SSR occurs only once, we assume that the elements are rendered in order and never re-render.\n // Therefore we can create elements in our collection document during render so that they are in the\n // collection by the time we need to use the collection to render to the real DOM.\n // After hydration, we switch to client rendering using the portal.\n let itemRef = useCallback((element: ElementNode<any> | null) => {\n element?.setProps(props, ref, CollectionNodeClass, rendered, render);\n }, [props, ref, rendered, render, CollectionNodeClass]);\n let parentNode = useContext(SSRContext);\n if (parentNode) {\n // Guard against double rendering in strict mode.\n let element = parentNode.ownerDocument.nodesByProps.get(props);\n if (!element) {\n element = parentNode.ownerDocument.createElement(CollectionNodeClass.type);\n element.setProps(props, ref, CollectionNodeClass, rendered, render);\n parentNode.appendChild(element);\n parentNode.ownerDocument.updateCollection();\n parentNode.ownerDocument.nodesByProps.set(props, element);\n }\n\n return children\n ? <SSRContext.Provider value={element}>{children}</SSRContext.Provider>\n : null;\n }\n\n // @ts-ignore\n return <CollectionNodeClass.type ref={itemRef}>{children}</CollectionNodeClass.type>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function createLeafComponent<T extends object, P extends object, E extends Element>(CollectionNodeClass: CollectionNodeClass<any> | string, render: (props: P, ref: ForwardedRef<E>) => ReactElement | null): (props: P & React.RefAttributes<E>) => ReactElement | null;\nexport function createLeafComponent<T extends object, P extends object, E extends Element>(CollectionNodeClass: CollectionNodeClass<any> | string, render: (props: P, ref: ForwardedRef<E>, node: Node<T>) => ReactElement | null): (props: P & React.RefAttributes<E>) => ReactElement | null;\nexport function createLeafComponent<P extends object, E extends Element>(CollectionNodeClass: CollectionNodeClass<any> | string, render: (props: P, ref: ForwardedRef<E>, node?: any) => ReactElement | null): (props: P & React.RefAttributes<any>) => ReactElement | null {\n let Component = ({node}) => render(node.props, node.props.ref, node);\n let Result = (forwardRef as forwardRefType)((props: P, ref: ForwardedRef<E>) => {\n let focusableProps = useContext(FocusableContext);\n let isShallow = useContext(ShallowRenderContext);\n if (!isShallow) {\n if (render.length >= 3) {\n throw new Error(render.name + ' cannot be rendered outside a collection.');\n }\n return render(props, ref);\n }\n\n return useSSRCollectionNode(\n CollectionNodeClass,\n props,\n ref,\n 'children' in props ? props.children : null,\n null,\n node => (\n // Forward FocusableContext to real DOM tree so tooltips work.\n <FocusableContext.Provider value={focusableProps}>\n <Component node={node} />\n </FocusableContext.Provider>\n )\n );\n });\n // @ts-ignore\n Result.displayName = render.name;\n return Result;\n}\n\nexport function createBranchComponent<T extends object, P extends {children?: any}, E extends Element>(CollectionNodeClass: CollectionNodeClass<any> | string, render: (props: P, ref: ForwardedRef<E>, node: Node<T>) => ReactElement | null, useChildren: (props: P) => ReactNode = useCollectionChildren): (props: P & React.RefAttributes<E>) => ReactElement | null {\n let Component = ({node}) => render(node.props, node.props.ref, node);\n let Result = (forwardRef as forwardRefType)((props: P, ref: ForwardedRef<E>) => {\n let children = useChildren(props);\n return useSSRCollectionNode(CollectionNodeClass, props, ref, null, children, node => <Component node={node} />) ?? <></>;\n });\n // @ts-ignore\n Result.displayName = render.name;\n return Result;\n}\n\nfunction useCollectionChildren<T extends object>(options: CachedChildrenOptions<T>) {\n return useCachedChildren({...options, addIdAndValue: true});\n}\n\nexport interface CollectionProps<T> extends CachedChildrenOptions<T> {}\n\nconst CollectionContext = createContext<CachedChildrenOptions<unknown> | null>(null);\n\n/** A Collection renders a list of items, automatically managing caching and keys. */\nexport function Collection<T extends object>(props: CollectionProps<T>): JSX.Element {\n let ctx = useContext(CollectionContext)!;\n let dependencies = (ctx?.dependencies || []).concat(props.dependencies);\n let idScope = props.idScope ?? ctx?.idScope;\n let children = useCollectionChildren({\n ...props,\n idScope,\n dependencies\n });\n\n let doc = useContext(CollectionDocumentContext);\n if (doc) {\n children = <CollectionRoot>{children}</CollectionRoot>;\n }\n\n // Propagate dependencies and idScope to child collections.\n ctx = useMemo(() => ({\n dependencies,\n idScope\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }), [idScope, ...dependencies]);\n\n return (\n <CollectionContext.Provider value={ctx}>\n {children}\n </CollectionContext.Provider>\n );\n}\n\nfunction CollectionRoot({children}) {\n let doc = useContext(CollectionDocumentContext);\n let wrappedChildren = useMemo(() => (\n <CollectionDocumentContext.Provider value={null}>\n <ShallowRenderContext.Provider value>\n {children}\n </ShallowRenderContext.Provider>\n </CollectionDocumentContext.Provider>\n ), [children]);\n // During SSR, we render the content directly, and append nodes to the document during render.\n // The collection children return null so that nothing is actually rendered into the HTML.\n return useIsSSR()\n ? <SSRContext.Provider value={doc}>{wrappedChildren}</SSRContext.Provider>\n : createPortal(wrappedChildren, doc as unknown as Element);\n}\n"],"names":[],"version":3,"file":"CollectionBuilder.module.js.map"}
|
package/dist/Document.main.js
DELETED
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
function $parcel$export(e, n, v, s) {
|
|
3
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
$parcel$export(module.exports, "Document", () => $c20afee375f3b2d6$export$b34a105447964f9f);
|
|
7
|
-
/*
|
|
8
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
9
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
-
* governing permissions and limitations under the License.
|
|
17
|
-
*/ class $c20afee375f3b2d6$export$410b0c854570d131 {
|
|
18
|
-
*[Symbol.iterator]() {
|
|
19
|
-
let node = this.firstChild;
|
|
20
|
-
while(node){
|
|
21
|
-
yield node;
|
|
22
|
-
node = node.nextSibling;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
get firstChild() {
|
|
26
|
-
return this._firstChild;
|
|
27
|
-
}
|
|
28
|
-
set firstChild(firstChild) {
|
|
29
|
-
this._firstChild = firstChild;
|
|
30
|
-
this.ownerDocument.markDirty(this);
|
|
31
|
-
}
|
|
32
|
-
get lastChild() {
|
|
33
|
-
return this._lastChild;
|
|
34
|
-
}
|
|
35
|
-
set lastChild(lastChild) {
|
|
36
|
-
this._lastChild = lastChild;
|
|
37
|
-
this.ownerDocument.markDirty(this);
|
|
38
|
-
}
|
|
39
|
-
get previousSibling() {
|
|
40
|
-
return this._previousSibling;
|
|
41
|
-
}
|
|
42
|
-
set previousSibling(previousSibling) {
|
|
43
|
-
this._previousSibling = previousSibling;
|
|
44
|
-
this.ownerDocument.markDirty(this);
|
|
45
|
-
}
|
|
46
|
-
get nextSibling() {
|
|
47
|
-
return this._nextSibling;
|
|
48
|
-
}
|
|
49
|
-
set nextSibling(nextSibling) {
|
|
50
|
-
this._nextSibling = nextSibling;
|
|
51
|
-
this.ownerDocument.markDirty(this);
|
|
52
|
-
}
|
|
53
|
-
get parentNode() {
|
|
54
|
-
return this._parentNode;
|
|
55
|
-
}
|
|
56
|
-
set parentNode(parentNode) {
|
|
57
|
-
this._parentNode = parentNode;
|
|
58
|
-
this.ownerDocument.markDirty(this);
|
|
59
|
-
}
|
|
60
|
-
get isConnected() {
|
|
61
|
-
var _this_parentNode;
|
|
62
|
-
return ((_this_parentNode = this.parentNode) === null || _this_parentNode === void 0 ? void 0 : _this_parentNode.isConnected) || false;
|
|
63
|
-
}
|
|
64
|
-
invalidateChildIndices(child) {
|
|
65
|
-
if (this._minInvalidChildIndex == null || !this._minInvalidChildIndex.isConnected || child.index < this._minInvalidChildIndex.index) {
|
|
66
|
-
this._minInvalidChildIndex = child;
|
|
67
|
-
this.ownerDocument.markDirty(this);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
updateChildIndices() {
|
|
71
|
-
let node = this._minInvalidChildIndex;
|
|
72
|
-
while(node){
|
|
73
|
-
node.index = node.previousSibling ? node.previousSibling.index + 1 : 0;
|
|
74
|
-
node = node.nextSibling;
|
|
75
|
-
}
|
|
76
|
-
this._minInvalidChildIndex = null;
|
|
77
|
-
}
|
|
78
|
-
appendChild(child) {
|
|
79
|
-
if (child.parentNode) child.parentNode.removeChild(child);
|
|
80
|
-
if (this.firstChild == null) this.firstChild = child;
|
|
81
|
-
if (this.lastChild) {
|
|
82
|
-
this.lastChild.nextSibling = child;
|
|
83
|
-
child.index = this.lastChild.index + 1;
|
|
84
|
-
child.previousSibling = this.lastChild;
|
|
85
|
-
} else {
|
|
86
|
-
child.previousSibling = null;
|
|
87
|
-
child.index = 0;
|
|
88
|
-
}
|
|
89
|
-
child.parentNode = this;
|
|
90
|
-
child.nextSibling = null;
|
|
91
|
-
this.lastChild = child;
|
|
92
|
-
this.ownerDocument.markDirty(this);
|
|
93
|
-
if (this.isConnected) this.ownerDocument.queueUpdate();
|
|
94
|
-
}
|
|
95
|
-
insertBefore(newNode, referenceNode) {
|
|
96
|
-
if (referenceNode == null) return this.appendChild(newNode);
|
|
97
|
-
if (newNode.parentNode) newNode.parentNode.removeChild(newNode);
|
|
98
|
-
newNode.nextSibling = referenceNode;
|
|
99
|
-
newNode.previousSibling = referenceNode.previousSibling;
|
|
100
|
-
// Ensure that the newNode's index is less than that of the reference node so that
|
|
101
|
-
// invalidateChildIndices will properly use the newNode as the _minInvalidChildIndex, thus making sure
|
|
102
|
-
// we will properly update the indexes of all sibiling nodes after the newNode. The value here doesn't matter
|
|
103
|
-
// since updateChildIndices should calculate the proper indexes.
|
|
104
|
-
newNode.index = referenceNode.index - 1;
|
|
105
|
-
if (this.firstChild === referenceNode) this.firstChild = newNode;
|
|
106
|
-
else if (referenceNode.previousSibling) referenceNode.previousSibling.nextSibling = newNode;
|
|
107
|
-
referenceNode.previousSibling = newNode;
|
|
108
|
-
newNode.parentNode = referenceNode.parentNode;
|
|
109
|
-
this.invalidateChildIndices(newNode);
|
|
110
|
-
if (this.isConnected) this.ownerDocument.queueUpdate();
|
|
111
|
-
}
|
|
112
|
-
removeChild(child) {
|
|
113
|
-
if (child.parentNode !== this) return;
|
|
114
|
-
if (this._minInvalidChildIndex === child) this._minInvalidChildIndex = null;
|
|
115
|
-
if (child.nextSibling) {
|
|
116
|
-
this.invalidateChildIndices(child.nextSibling);
|
|
117
|
-
child.nextSibling.previousSibling = child.previousSibling;
|
|
118
|
-
}
|
|
119
|
-
if (child.previousSibling) child.previousSibling.nextSibling = child.nextSibling;
|
|
120
|
-
if (this.firstChild === child) this.firstChild = child.nextSibling;
|
|
121
|
-
if (this.lastChild === child) this.lastChild = child.previousSibling;
|
|
122
|
-
child.parentNode = null;
|
|
123
|
-
child.nextSibling = null;
|
|
124
|
-
child.previousSibling = null;
|
|
125
|
-
child.index = 0;
|
|
126
|
-
this.ownerDocument.markDirty(child);
|
|
127
|
-
if (this.isConnected) this.ownerDocument.queueUpdate();
|
|
128
|
-
}
|
|
129
|
-
addEventListener() {}
|
|
130
|
-
removeEventListener() {}
|
|
131
|
-
get previousVisibleSibling() {
|
|
132
|
-
let node = this.previousSibling;
|
|
133
|
-
while(node && node.isHidden)node = node.previousSibling;
|
|
134
|
-
return node;
|
|
135
|
-
}
|
|
136
|
-
get nextVisibleSibling() {
|
|
137
|
-
let node = this.nextSibling;
|
|
138
|
-
while(node && node.isHidden)node = node.nextSibling;
|
|
139
|
-
return node;
|
|
140
|
-
}
|
|
141
|
-
get firstVisibleChild() {
|
|
142
|
-
let node = this.firstChild;
|
|
143
|
-
while(node && node.isHidden)node = node.nextSibling;
|
|
144
|
-
return node;
|
|
145
|
-
}
|
|
146
|
-
get lastVisibleChild() {
|
|
147
|
-
let node = this.lastChild;
|
|
148
|
-
while(node && node.isHidden)node = node.previousSibling;
|
|
149
|
-
return node;
|
|
150
|
-
}
|
|
151
|
-
constructor(ownerDocument){
|
|
152
|
-
this._firstChild = null;
|
|
153
|
-
this._lastChild = null;
|
|
154
|
-
this._previousSibling = null;
|
|
155
|
-
this._nextSibling = null;
|
|
156
|
-
this._parentNode = null;
|
|
157
|
-
this._minInvalidChildIndex = null;
|
|
158
|
-
this.ownerDocument = ownerDocument;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
class $c20afee375f3b2d6$export$dc064fe9e59310fd extends $c20afee375f3b2d6$export$410b0c854570d131 {
|
|
162
|
-
get index() {
|
|
163
|
-
return this._index;
|
|
164
|
-
}
|
|
165
|
-
set index(index) {
|
|
166
|
-
this._index = index;
|
|
167
|
-
this.ownerDocument.markDirty(this);
|
|
168
|
-
}
|
|
169
|
-
get level() {
|
|
170
|
-
var _this_parentNode_node;
|
|
171
|
-
if (this.parentNode instanceof $c20afee375f3b2d6$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);
|
|
172
|
-
return 0;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Lazily gets a mutable instance of a Node. If the node has already
|
|
176
|
-
* been cloned during this update cycle, it just returns the existing one.
|
|
177
|
-
*/ getMutableNode() {
|
|
178
|
-
if (this.node == null) return null;
|
|
179
|
-
if (!this.isMutated) {
|
|
180
|
-
this.node = this.node.clone();
|
|
181
|
-
this.isMutated = true;
|
|
182
|
-
}
|
|
183
|
-
this.ownerDocument.markDirty(this);
|
|
184
|
-
return this.node;
|
|
185
|
-
}
|
|
186
|
-
updateNode() {
|
|
187
|
-
var _this_parentNode_node, _this_previousVisibleSibling_node, _this_previousVisibleSibling, _nextSibling_node, _this_firstVisibleChild_node, _this_firstVisibleChild, _this_lastVisibleChild_node, _this_lastVisibleChild;
|
|
188
|
-
let nextSibling = this.nextVisibleSibling;
|
|
189
|
-
let node = this.getMutableNode();
|
|
190
|
-
if (node == null) return;
|
|
191
|
-
node.index = this.index;
|
|
192
|
-
node.level = this.level;
|
|
193
|
-
var _this_parentNode_node_key;
|
|
194
|
-
node.parentKey = this.parentNode instanceof $c20afee375f3b2d6$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;
|
|
195
|
-
var _this_previousVisibleSibling_node_key;
|
|
196
|
-
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;
|
|
197
|
-
var _nextSibling_node_key;
|
|
198
|
-
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;
|
|
199
|
-
node.hasChildNodes = !!this.firstChild;
|
|
200
|
-
var _this_firstVisibleChild_node_key;
|
|
201
|
-
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;
|
|
202
|
-
var _this_lastVisibleChild_node_key;
|
|
203
|
-
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;
|
|
204
|
-
// Update the colIndex of sibling nodes if this node has a colSpan.
|
|
205
|
-
if ((node.colSpan != null || node.colIndex != null) && nextSibling) {
|
|
206
|
-
var _node_colIndex, _node_colSpan;
|
|
207
|
-
// This queues the next sibling for update, which means this happens recursively.
|
|
208
|
-
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);
|
|
209
|
-
if (nextSibling.node != null && nextColIndex !== nextSibling.node.colIndex) {
|
|
210
|
-
let siblingNode = nextSibling.getMutableNode();
|
|
211
|
-
siblingNode.colIndex = nextColIndex;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
setProps(obj, ref, CollectionNodeClass, rendered, render) {
|
|
216
|
-
let node;
|
|
217
|
-
let { value: value1, textValue: textValue, id: id, ...props } = obj;
|
|
218
|
-
if (this.node == null) {
|
|
219
|
-
node = new CollectionNodeClass(id !== null && id !== void 0 ? id : `react-aria-${++this.ownerDocument.nodeId}`);
|
|
220
|
-
this.node = node;
|
|
221
|
-
} else node = this.getMutableNode();
|
|
222
|
-
props.ref = ref;
|
|
223
|
-
node.props = props;
|
|
224
|
-
node.rendered = rendered;
|
|
225
|
-
node.render = render;
|
|
226
|
-
node.value = value1;
|
|
227
|
-
if (obj['aria-label']) node['aria-label'] = obj['aria-label'];
|
|
228
|
-
node.textValue = textValue || (typeof props.children === 'string' ? props.children : '') || obj['aria-label'] || '';
|
|
229
|
-
if (id != null && id !== node.key) throw new Error('Cannot change the id of an item');
|
|
230
|
-
if (props.colSpan != null) node.colSpan = props.colSpan;
|
|
231
|
-
if (this.isConnected) this.ownerDocument.queueUpdate();
|
|
232
|
-
}
|
|
233
|
-
get style() {
|
|
234
|
-
// React sets display: none to hide elements during Suspense.
|
|
235
|
-
// We'll handle this by setting the element to hidden and invalidating
|
|
236
|
-
// its siblings/parent. Hidden elements remain in the Document, but
|
|
237
|
-
// are removed from the Collection.
|
|
238
|
-
let element = this;
|
|
239
|
-
return {
|
|
240
|
-
get display () {
|
|
241
|
-
return element.isHidden ? 'none' : '';
|
|
242
|
-
},
|
|
243
|
-
set display (value){
|
|
244
|
-
let isHidden = value === 'none';
|
|
245
|
-
if (element.isHidden !== isHidden) {
|
|
246
|
-
var _element_parentNode, _element_parentNode1;
|
|
247
|
-
// Mark parent node dirty if this element is currently the first or last visible child.
|
|
248
|
-
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);
|
|
249
|
-
// Mark sibling visible elements dirty.
|
|
250
|
-
let prev = element.previousVisibleSibling;
|
|
251
|
-
let next = element.nextVisibleSibling;
|
|
252
|
-
if (prev) element.ownerDocument.markDirty(prev);
|
|
253
|
-
if (next) element.ownerDocument.markDirty(next);
|
|
254
|
-
// Mark self dirty.
|
|
255
|
-
element.isHidden = isHidden;
|
|
256
|
-
element.ownerDocument.markDirty(element);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
hasAttribute() {}
|
|
262
|
-
setAttribute() {}
|
|
263
|
-
setAttributeNS() {}
|
|
264
|
-
removeAttribute() {}
|
|
265
|
-
constructor(type, ownerDocument){
|
|
266
|
-
super(ownerDocument), this.nodeType = 8 // COMMENT_NODE (we'd use ELEMENT_NODE but React DevTools will fail to get its dimensions)
|
|
267
|
-
, this.isMutated = true, this._index = 0, this.isHidden = false;
|
|
268
|
-
this.node = null;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
class $c20afee375f3b2d6$export$b34a105447964f9f extends $c20afee375f3b2d6$export$410b0c854570d131 {
|
|
272
|
-
get isConnected() {
|
|
273
|
-
return true;
|
|
274
|
-
}
|
|
275
|
-
createElement(type) {
|
|
276
|
-
return new $c20afee375f3b2d6$export$dc064fe9e59310fd(type, this);
|
|
277
|
-
}
|
|
278
|
-
getMutableCollection() {
|
|
279
|
-
if (!this.nextCollection) this.nextCollection = this.collection.clone();
|
|
280
|
-
return this.nextCollection;
|
|
281
|
-
}
|
|
282
|
-
markDirty(node) {
|
|
283
|
-
this.dirtyNodes.add(node);
|
|
284
|
-
}
|
|
285
|
-
addNode(element) {
|
|
286
|
-
if (element.isHidden || element.node == null) return;
|
|
287
|
-
let collection = this.getMutableCollection();
|
|
288
|
-
if (!collection.getItem(element.node.key)) for (let child of element)this.addNode(child);
|
|
289
|
-
collection.addNode(element.node);
|
|
290
|
-
}
|
|
291
|
-
removeNode(node) {
|
|
292
|
-
for (let child of node)this.removeNode(child);
|
|
293
|
-
if (node.node) {
|
|
294
|
-
let collection = this.getMutableCollection();
|
|
295
|
-
collection.removeNode(node.node.key);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
/** Finalizes the collection update, updating all nodes and freezing the collection. */ getCollection() {
|
|
299
|
-
// If in a subscription update, return return the existing collection.
|
|
300
|
-
// React will call getCollection again during render, at which point all the updates will be complete.
|
|
301
|
-
if (this.inSubscription) return this.collection;
|
|
302
|
-
// Reset queuedRender to false when getCollection is called during render.
|
|
303
|
-
this.queuedRender = false;
|
|
304
|
-
this.updateCollection();
|
|
305
|
-
return this.collection;
|
|
306
|
-
}
|
|
307
|
-
updateCollection() {
|
|
308
|
-
// First, remove disconnected nodes and update the indices of dirty element children.
|
|
309
|
-
for (let element of this.dirtyNodes)if (element instanceof $c20afee375f3b2d6$export$dc064fe9e59310fd && (!element.isConnected || element.isHidden)) this.removeNode(element);
|
|
310
|
-
else element.updateChildIndices();
|
|
311
|
-
// Next, update dirty collection nodes.
|
|
312
|
-
for (let element of this.dirtyNodes)if (element instanceof $c20afee375f3b2d6$export$dc064fe9e59310fd) {
|
|
313
|
-
if (element.isConnected && !element.isHidden) {
|
|
314
|
-
element.updateNode();
|
|
315
|
-
this.addNode(element);
|
|
316
|
-
}
|
|
317
|
-
if (element.node) this.dirtyNodes.delete(element);
|
|
318
|
-
element.isMutated = false;
|
|
319
|
-
} else this.dirtyNodes.delete(element);
|
|
320
|
-
// Finally, update the collection.
|
|
321
|
-
if (this.nextCollection) {
|
|
322
|
-
var _this_firstVisibleChild_node, _this_firstVisibleChild, _this_lastVisibleChild_node, _this_lastVisibleChild;
|
|
323
|
-
var _this_firstVisibleChild_node_key, _this_lastVisibleChild_node_key;
|
|
324
|
-
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);
|
|
325
|
-
if (!this.isSSR) {
|
|
326
|
-
this.collection = this.nextCollection;
|
|
327
|
-
this.nextCollection = null;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
queueUpdate() {
|
|
332
|
-
if (this.dirtyNodes.size === 0 || this.queuedRender) return;
|
|
333
|
-
// Only trigger subscriptions once during an update, when the first item changes.
|
|
334
|
-
// React's useSyncExternalStore will call getCollection immediately, to check whether the snapshot changed.
|
|
335
|
-
// If so, React will queue a render to happen after the current commit to our fake DOM finishes.
|
|
336
|
-
// We track whether getCollection is called in a subscription, and once it is called during render,
|
|
337
|
-
// we reset queuedRender back to false.
|
|
338
|
-
this.queuedRender = true;
|
|
339
|
-
this.inSubscription = true;
|
|
340
|
-
// Clone the collection to ensure that React queues a render. It will call getCollection again
|
|
341
|
-
// during render, at which point all the updates will be complete and we can return
|
|
342
|
-
// the new collection.
|
|
343
|
-
if (!this.isSSR) this.collection = this.collection.clone();
|
|
344
|
-
for (let fn of this.subscriptions)fn();
|
|
345
|
-
this.inSubscription = false;
|
|
346
|
-
}
|
|
347
|
-
subscribe(fn) {
|
|
348
|
-
this.subscriptions.add(fn);
|
|
349
|
-
return ()=>this.subscriptions.delete(fn);
|
|
350
|
-
}
|
|
351
|
-
resetAfterSSR() {
|
|
352
|
-
if (this.isSSR) {
|
|
353
|
-
this.isSSR = false;
|
|
354
|
-
this.firstChild = null;
|
|
355
|
-
this.lastChild = null;
|
|
356
|
-
this.nodeId = 0;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
constructor(collection){
|
|
360
|
-
// @ts-ignore
|
|
361
|
-
super(null), this.nodeType = 11 // DOCUMENT_FRAGMENT_NODE
|
|
362
|
-
, 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;
|
|
363
|
-
this.collection = collection;
|
|
364
|
-
this.nextCollection = collection;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
//# sourceMappingURL=Document.main.js.map
|