@react-aria/collections 3.0.0-alpha.1 → 3.0.0-nightly.2988

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.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/dist/BaseCollection.main.js +157 -0
  3. package/dist/BaseCollection.main.js.map +1 -0
  4. package/dist/BaseCollection.mjs +151 -0
  5. package/dist/BaseCollection.module.js +151 -0
  6. package/dist/BaseCollection.module.js.map +1 -0
  7. package/dist/CollectionBuilder.main.js +233 -0
  8. package/dist/CollectionBuilder.main.js.map +1 -0
  9. package/dist/CollectionBuilder.mjs +221 -0
  10. package/dist/CollectionBuilder.module.js +221 -0
  11. package/dist/CollectionBuilder.module.js.map +1 -0
  12. package/dist/Document.main.js +316 -0
  13. package/dist/Document.main.js.map +1 -0
  14. package/dist/Document.mjs +311 -0
  15. package/dist/Document.module.js +311 -0
  16. package/dist/Document.module.js.map +1 -0
  17. package/dist/Hidden.main.js +79 -0
  18. package/dist/Hidden.main.js.map +1 -0
  19. package/dist/Hidden.mjs +68 -0
  20. package/dist/Hidden.module.js +68 -0
  21. package/dist/Hidden.module.js.map +1 -0
  22. package/dist/import.mjs +23 -0
  23. package/dist/main.js +27 -348
  24. package/dist/main.js.map +1 -0
  25. package/dist/module.js +17 -318
  26. package/dist/module.js.map +1 -0
  27. package/dist/types.d.ts +81 -24
  28. package/dist/types.d.ts.map +1 -1
  29. package/dist/useCachedChildren.main.js +63 -0
  30. package/dist/useCachedChildren.main.js.map +1 -0
  31. package/dist/useCachedChildren.mjs +58 -0
  32. package/dist/useCachedChildren.module.js +58 -0
  33. package/dist/useCachedChildren.module.js.map +1 -0
  34. package/package.json +17 -10
  35. package/src/BaseCollection.ts +211 -0
  36. package/src/CollectionBuilder.tsx +237 -0
  37. package/src/Document.ts +453 -0
  38. package/src/Hidden.tsx +84 -0
  39. package/src/index.ts +19 -0
  40. package/src/useCachedChildren.ts +70 -0
@@ -0,0 +1,233 @@
1
+ var $499e2959ba1abacc$exports = require("./BaseCollection.main.js");
2
+ var $c20afee375f3b2d6$exports = require("./Document.main.js");
3
+ var $245f3f827bea6653$exports = require("./useCachedChildren.main.js");
4
+ var $eaaf60978b89fc58$exports = require("./Hidden.main.js");
5
+ var $4ftIM$reactdom = require("react-dom");
6
+ var $4ftIM$react = require("react");
7
+ var $4ftIM$reactariassr = require("@react-aria/ssr");
8
+ var $4ftIM$reactariautils = require("@react-aria/utils");
9
+ var $4ftIM$usesyncexternalstoreshimindexjs = require("use-sync-external-store/shim/index.js");
10
+
11
+
12
+ function $parcel$interopDefault(a) {
13
+ return a && a.__esModule ? a.default : a;
14
+ }
15
+
16
+ function $parcel$export(e, n, v, s) {
17
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
18
+ }
19
+
20
+ $parcel$export(module.exports, "CollectionBuilder", () => $f20386e2aa690b4a$export$bf788dd355e3a401);
21
+ $parcel$export(module.exports, "createLeafComponent", () => $f20386e2aa690b4a$export$18af5c7a9e9b3664);
22
+ $parcel$export(module.exports, "createBranchComponent", () => $f20386e2aa690b4a$export$e953bb1cd0f19726);
23
+ $parcel$export(module.exports, "Collection", () => $f20386e2aa690b4a$export$fb8073518f34e6ec);
24
+ /*
25
+ * Copyright 2024 Adobe. All rights reserved.
26
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
27
+ * you may not use this file except in compliance with the License. You may obtain a copy
28
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
29
+ *
30
+ * Unless required by applicable law or agreed to in writing, software distributed under
31
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
32
+ * OF ANY KIND, either express or implied. See the License for the specific language
33
+ * governing permissions and limitations under the License.
34
+ */
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+ const $f20386e2aa690b4a$var$ShallowRenderContext = /*#__PURE__*/ (0, $4ftIM$react.createContext)(false);
44
+ const $f20386e2aa690b4a$var$CollectionDocumentContext = /*#__PURE__*/ (0, $4ftIM$react.createContext)(null);
45
+ function $f20386e2aa690b4a$export$bf788dd355e3a401(props) {
46
+ // If a document was provided above us, we're already in a hidden tree. Just render the content.
47
+ let doc = (0, $4ftIM$react.useContext)($f20386e2aa690b4a$var$CollectionDocumentContext);
48
+ if (doc) return props.content;
49
+ // Otherwise, render a hidden copy of the children so that we can build the collection before constructing the state.
50
+ // This should always come before the real DOM content so we have built the collection by the time it renders during SSR.
51
+ // This is fine. CollectionDocumentContext never changes after mounting.
52
+ // eslint-disable-next-line react-hooks/rules-of-hooks
53
+ let { collection: collection, document: document } = $f20386e2aa690b4a$var$useCollectionDocument(props.createCollection);
54
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement((0, ($parcel$interopDefault($4ftIM$react))).Fragment, null, /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement((0, $eaaf60978b89fc58$exports.Hidden), null, /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement($f20386e2aa690b4a$var$CollectionDocumentContext.Provider, {
55
+ value: document
56
+ }, props.content)), /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement($f20386e2aa690b4a$var$CollectionInner, {
57
+ render: props.children,
58
+ collection: collection
59
+ }));
60
+ }
61
+ function $f20386e2aa690b4a$var$CollectionInner({ collection: collection, render: render }) {
62
+ return render(collection);
63
+ }
64
+ // React 16 and 17 don't support useSyncExternalStore natively, and the shim provided by React does not support getServerSnapshot.
65
+ // This wrapper uses the shim, but additionally calls getServerSnapshot during SSR (according to SSRProvider).
66
+ function $f20386e2aa690b4a$var$useSyncExternalStoreFallback(subscribe, getSnapshot, getServerSnapshot) {
67
+ let isSSR = (0, $4ftIM$reactariassr.useIsSSR)();
68
+ let isSSRRef = (0, $4ftIM$react.useRef)(isSSR);
69
+ // This is read immediately inside the wrapper, which also runs during render.
70
+ // We just need a ref to avoid invalidating the callback itself, which
71
+ // would cause React to re-run the callback more than necessary.
72
+ // eslint-disable-next-line rulesdir/pure-render
73
+ isSSRRef.current = isSSR;
74
+ let getSnapshotWrapper = (0, $4ftIM$react.useCallback)(()=>{
75
+ return isSSRRef.current ? getServerSnapshot() : getSnapshot();
76
+ }, [
77
+ getSnapshot,
78
+ getServerSnapshot
79
+ ]);
80
+ return (0, $4ftIM$usesyncexternalstoreshimindexjs.useSyncExternalStore)(subscribe, getSnapshotWrapper);
81
+ }
82
+ const $f20386e2aa690b4a$var$useSyncExternalStore = typeof (0, ($parcel$interopDefault($4ftIM$react)))['useSyncExternalStore'] === 'function' ? (0, ($parcel$interopDefault($4ftIM$react)))['useSyncExternalStore'] : $f20386e2aa690b4a$var$useSyncExternalStoreFallback;
83
+ function $f20386e2aa690b4a$var$useCollectionDocument(createCollection) {
84
+ // The document instance is mutable, and should never change between renders.
85
+ // useSyncExternalStore is used to subscribe to updates, which vends immutable Collection objects.
86
+ let [document] = (0, $4ftIM$react.useState)(()=>new (0, $c20afee375f3b2d6$exports.Document)((createCollection === null || createCollection === void 0 ? void 0 : createCollection()) || new (0, $499e2959ba1abacc$exports.BaseCollection)()));
87
+ let subscribe = (0, $4ftIM$react.useCallback)((fn)=>document.subscribe(fn), [
88
+ document
89
+ ]);
90
+ let getSnapshot = (0, $4ftIM$react.useCallback)(()=>{
91
+ let collection = document.getCollection();
92
+ if (document.isSSR) // After SSR is complete, reset the document to empty so it is ready for React to render the portal into.
93
+ // We do this _after_ getting the collection above so that the collection still has content in it from SSR
94
+ // during the current render, before React has finished the client render.
95
+ document.resetAfterSSR();
96
+ return collection;
97
+ }, [
98
+ document
99
+ ]);
100
+ let getServerSnapshot = (0, $4ftIM$react.useCallback)(()=>{
101
+ document.isSSR = true;
102
+ return document.getCollection();
103
+ }, [
104
+ document
105
+ ]);
106
+ let collection = $f20386e2aa690b4a$var$useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
107
+ (0, $4ftIM$reactariautils.useLayoutEffect)(()=>{
108
+ document.isMounted = true;
109
+ return ()=>{
110
+ // Mark unmounted so we can skip all of the collection updates caused by
111
+ // React calling removeChild on every item in the collection.
112
+ document.isMounted = false;
113
+ };
114
+ }, [
115
+ document
116
+ ]);
117
+ return {
118
+ collection: collection,
119
+ document: document
120
+ };
121
+ }
122
+ const $f20386e2aa690b4a$var$SSRContext = /*#__PURE__*/ (0, $4ftIM$react.createContext)(null);
123
+ function $f20386e2aa690b4a$var$useSSRCollectionNode(Type, props, ref, rendered, children, render) {
124
+ // During SSR, portals are not supported, so the collection children will be wrapped in an SSRContext.
125
+ // Since SSR occurs only once, we assume that the elements are rendered in order and never re-render.
126
+ // Therefore we can create elements in our collection document during render so that they are in the
127
+ // collection by the time we need to use the collection to render to the real DOM.
128
+ // After hydration, we switch to client rendering using the portal.
129
+ let itemRef = (0, $4ftIM$react.useCallback)((element)=>{
130
+ element === null || element === void 0 ? void 0 : element.setProps(props, ref, rendered, render);
131
+ }, [
132
+ props,
133
+ ref,
134
+ rendered,
135
+ render
136
+ ]);
137
+ let parentNode = (0, $4ftIM$react.useContext)($f20386e2aa690b4a$var$SSRContext);
138
+ if (parentNode) {
139
+ // Guard against double rendering in strict mode.
140
+ let element = parentNode.ownerDocument.nodesByProps.get(props);
141
+ if (!element) {
142
+ element = parentNode.ownerDocument.createElement(Type);
143
+ element.setProps(props, ref, rendered, render);
144
+ parentNode.appendChild(element);
145
+ parentNode.ownerDocument.updateCollection();
146
+ parentNode.ownerDocument.nodesByProps.set(props, element);
147
+ }
148
+ return children ? /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement($f20386e2aa690b4a$var$SSRContext.Provider, {
149
+ value: element
150
+ }, children) : null;
151
+ }
152
+ // @ts-ignore
153
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement(Type, {
154
+ ref: itemRef
155
+ }, children);
156
+ }
157
+ function $f20386e2aa690b4a$export$18af5c7a9e9b3664(type, render) {
158
+ let Component = ({ node: node })=>render(node.props, node.props.ref, node);
159
+ let Result = (0, $4ftIM$react.forwardRef)((props, ref)=>{
160
+ let isShallow = (0, $4ftIM$react.useContext)($f20386e2aa690b4a$var$ShallowRenderContext);
161
+ if (!isShallow) {
162
+ if (render.length >= 3) throw new Error(render.name + ' cannot be rendered outside a collection.');
163
+ return render(props, ref);
164
+ }
165
+ return $f20386e2aa690b4a$var$useSSRCollectionNode(type, props, ref, 'children' in props ? props.children : null, null, (node)=>/*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement(Component, {
166
+ node: node
167
+ }));
168
+ });
169
+ // @ts-ignore
170
+ Result.displayName = render.name;
171
+ return Result;
172
+ }
173
+ function $f20386e2aa690b4a$export$e953bb1cd0f19726(type, render, useChildren = $f20386e2aa690b4a$var$useCollectionChildren) {
174
+ let Component = ({ node: node })=>render(node.props, node.props.ref, node);
175
+ let Result = (0, $4ftIM$react.forwardRef)((props, ref)=>{
176
+ let children = useChildren(props);
177
+ var _useSSRCollectionNode;
178
+ return (_useSSRCollectionNode = $f20386e2aa690b4a$var$useSSRCollectionNode(type, props, ref, null, children, (node)=>/*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement(Component, {
179
+ node: node
180
+ }))) !== null && _useSSRCollectionNode !== void 0 ? _useSSRCollectionNode : /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement((0, ($parcel$interopDefault($4ftIM$react))).Fragment, null);
181
+ });
182
+ // @ts-ignore
183
+ Result.displayName = render.name;
184
+ return Result;
185
+ }
186
+ function $f20386e2aa690b4a$var$useCollectionChildren(options) {
187
+ return (0, $245f3f827bea6653$exports.useCachedChildren)({
188
+ ...options,
189
+ addIdAndValue: true
190
+ });
191
+ }
192
+ const $f20386e2aa690b4a$var$CollectionContext = /*#__PURE__*/ (0, $4ftIM$react.createContext)(null);
193
+ function $f20386e2aa690b4a$export$fb8073518f34e6ec(props) {
194
+ let ctx = (0, $4ftIM$react.useContext)($f20386e2aa690b4a$var$CollectionContext);
195
+ let dependencies = ((ctx === null || ctx === void 0 ? void 0 : ctx.dependencies) || []).concat(props.dependencies);
196
+ let idScope = props.idScope || (ctx === null || ctx === void 0 ? void 0 : ctx.idScope);
197
+ let children = $f20386e2aa690b4a$var$useCollectionChildren({
198
+ ...props,
199
+ idScope: idScope,
200
+ dependencies: dependencies
201
+ });
202
+ let doc = (0, $4ftIM$react.useContext)($f20386e2aa690b4a$var$CollectionDocumentContext);
203
+ if (doc) children = /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement($f20386e2aa690b4a$var$CollectionRoot, null, children);
204
+ // Propagate dependencies and idScope to child collections.
205
+ ctx = (0, $4ftIM$react.useMemo)(()=>({
206
+ dependencies: dependencies,
207
+ idScope: idScope
208
+ }), [
209
+ idScope,
210
+ ...dependencies
211
+ ]);
212
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement($f20386e2aa690b4a$var$CollectionContext.Provider, {
213
+ value: ctx
214
+ }, children);
215
+ }
216
+ function $f20386e2aa690b4a$var$CollectionRoot({ children: children }) {
217
+ let doc = (0, $4ftIM$react.useContext)($f20386e2aa690b4a$var$CollectionDocumentContext);
218
+ let wrappedChildren = (0, $4ftIM$react.useMemo)(()=>/*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement($f20386e2aa690b4a$var$CollectionDocumentContext.Provider, {
219
+ value: null
220
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement($f20386e2aa690b4a$var$ShallowRenderContext.Provider, {
221
+ value: true
222
+ }, children)), [
223
+ children
224
+ ]);
225
+ // During SSR, we render the content directly, and append nodes to the document during render.
226
+ // The collection children return null so that nothing is actually rendered into the HTML.
227
+ return (0, $4ftIM$reactariassr.useIsSSR)() ? /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement($f20386e2aa690b4a$var$SSRContext.Provider, {
228
+ value: doc
229
+ }, wrappedChildren) : /*#__PURE__*/ (0, $4ftIM$reactdom.createPortal)(w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,OAAA;WAC5B,YAGJ;QAAC;KAAS;IACb,8FAA8F;IAC9F,0FAA0F;IAC1F,OAAO,CAAA,GAAA,4BAAO,oBACV,0DAAC,iCAAW,QAAQ;QAAC,OAAO;OAAM,iCAClC,CAAA,GAAA,4BAAW,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} from './BaseCollection';\nimport {BaseNode, Document, ElementNode} from './Document';\nimport {CachedChildrenOptions, useCachedChildren} from './useCachedChildren';\nimport {createPortal} from 'react-dom';\nimport {forwardRefType, 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 {useLayoutEffect} from '@react-aria/utils';\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>) {\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 return props.content;\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 useLayoutEffect(() => {\n document.isMounted = true;\n return () => {\n // Mark unmounted so we can skip all of the collection updates caused by \n // React calling removeChild on every item in the collection.\n document.isMounted = false;\n };\n }, [document]);\n return {collection, document};\n}\n\nconst SSRContext = createContext<BaseNode<any> | null>(null);\n\nfunction useSSRCollectionNode<T extends Element>(Type: string, props: object, ref: ForwardedRef<T>, rendered?: any, children?: ReactNode, render?: (node: Node<T>) => ReactElement) {\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, rendered, render);\n }, [props, ref, rendered, render]);\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(Type);\n element.setProps(props, ref, 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 <Type ref={itemRef}>{children}</Type>;\n}\n\nexport function createLeafComponent<T extends object, P extends object, E extends Element>(type: string, render: (props: P, ref: ForwardedRef<E>) => ReactNode): (props: P & React.RefAttributes<T>) => ReactNode | null;\nexport function createLeafComponent<T extends object, P extends object, E extends Element>(type: string, render: (props: P, ref: ForwardedRef<E>, node: Node<T>) => ReactNode): (props: P & React.RefAttributes<T>) => ReactNode | null;\nexport function createLeafComponent<P extends object, E extends Element>(type: string, render: (props: P, ref: ForwardedRef<E>, node?: any) => ReactNode) {\n let Component = ({node}) => render(node.props, node.props.ref, node);\n let Result = (forwardRef as forwardRefType)((props: P, ref: ForwardedRef<E>) => {\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(type, props, ref, 'children' in props ? props.children : null, null, node => <Component node={node} />);\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>(type: string, render: (props: P, ref: ForwardedRef<E>, node: Node<T>) => ReactNode, useChildren: (props: P) => ReactNode = useCollectionChildren) {\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(type, 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.main.js.map"}
@@ -0,0 +1,221 @@
1
+ import {BaseCollection as $23b9f4fcf0fe224b$export$408d25a4e12db025} from "./BaseCollection.mjs";
2
+ import {Document as $681cc3c98f569e39$export$b34a105447964f9f} from "./Document.mjs";
3
+ import {useCachedChildren as $e948873055cbafe4$export$727c8fc270210f13} from "./useCachedChildren.mjs";
4
+ import {Hidden as $f39a9eba43920ace$export$8dc98ba7eadeaa56} from "./Hidden.mjs";
5
+ import {createPortal as $95feo$createPortal} from "react-dom";
6
+ 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";
7
+ import {useIsSSR as $95feo$useIsSSR} from "@react-aria/ssr";
8
+ import {useLayoutEffect as $95feo$useLayoutEffect} from "@react-aria/utils";
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) return props.content;
36
+ // Otherwise, render a hidden copy of the children so that we can build the collection before constructing the state.
37
+ // This should always come before the real DOM content so we have built the collection by the time it renders during SSR.
38
+ // This is fine. CollectionDocumentContext never changes after mounting.
39
+ // eslint-disable-next-line react-hooks/rules-of-hooks
40
+ let { collection: collection, document: document } = $e1995378a142960e$var$useCollectionDocument(props.createCollection);
41
+ 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, {
42
+ value: document
43
+ }, props.content)), /*#__PURE__*/ (0, $95feo$react).createElement($e1995378a142960e$var$CollectionInner, {
44
+ render: props.children,
45
+ collection: collection
46
+ }));
47
+ }
48
+ function $e1995378a142960e$var$CollectionInner({ collection: collection, render: render }) {
49
+ return render(collection);
50
+ }
51
+ // React 16 and 17 don't support useSyncExternalStore natively, and the shim provided by React does not support getServerSnapshot.
52
+ // This wrapper uses the shim, but additionally calls getServerSnapshot during SSR (according to SSRProvider).
53
+ function $e1995378a142960e$var$useSyncExternalStoreFallback(subscribe, getSnapshot, getServerSnapshot) {
54
+ let isSSR = (0, $95feo$useIsSSR)();
55
+ let isSSRRef = (0, $95feo$useRef)(isSSR);
56
+ // This is read immediately inside the wrapper, which also runs during render.
57
+ // We just need a ref to avoid invalidating the callback itself, which
58
+ // would cause React to re-run the callback more than necessary.
59
+ // eslint-disable-next-line rulesdir/pure-render
60
+ isSSRRef.current = isSSR;
61
+ let getSnapshotWrapper = (0, $95feo$useCallback)(()=>{
62
+ return isSSRRef.current ? getServerSnapshot() : getSnapshot();
63
+ }, [
64
+ getSnapshot,
65
+ getServerSnapshot
66
+ ]);
67
+ return (0, $95feo$useSyncExternalStore)(subscribe, getSnapshotWrapper);
68
+ }
69
+ const $e1995378a142960e$var$useSyncExternalStore = typeof (0, $95feo$react)['useSyncExternalStore'] === 'function' ? (0, $95feo$react)['useSyncExternalStore'] : $e1995378a142960e$var$useSyncExternalStoreFallback;
70
+ function $e1995378a142960e$var$useCollectionDocument(createCollection) {
71
+ // The document instance is mutable, and should never change between renders.
72
+ // useSyncExternalStore is used to subscribe to updates, which vends immutable Collection objects.
73
+ let [document] = (0, $95feo$useState)(()=>new (0, $681cc3c98f569e39$export$b34a105447964f9f)((createCollection === null || createCollection === void 0 ? void 0 : createCollection()) || new (0, $23b9f4fcf0fe224b$export$408d25a4e12db025)()));
74
+ let subscribe = (0, $95feo$useCallback)((fn)=>document.subscribe(fn), [
75
+ document
76
+ ]);
77
+ let getSnapshot = (0, $95feo$useCallback)(()=>{
78
+ let collection = document.getCollection();
79
+ if (document.isSSR) // After SSR is complete, reset the document to empty so it is ready for React to render the portal into.
80
+ // We do this _after_ getting the collection above so that the collection still has content in it from SSR
81
+ // during the current render, before React has finished the client render.
82
+ document.resetAfterSSR();
83
+ return collection;
84
+ }, [
85
+ document
86
+ ]);
87
+ let getServerSnapshot = (0, $95feo$useCallback)(()=>{
88
+ document.isSSR = true;
89
+ return document.getCollection();
90
+ }, [
91
+ document
92
+ ]);
93
+ let collection = $e1995378a142960e$var$useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
94
+ (0, $95feo$useLayoutEffect)(()=>{
95
+ document.isMounted = true;
96
+ return ()=>{
97
+ // Mark unmounted so we can skip all of the collection updates caused by
98
+ // React calling removeChild on every item in the collection.
99
+ document.isMounted = false;
100
+ };
101
+ }, [
102
+ document
103
+ ]);
104
+ return {
105
+ collection: collection,
106
+ document: document
107
+ };
108
+ }
109
+ const $e1995378a142960e$var$SSRContext = /*#__PURE__*/ (0, $95feo$createContext)(null);
110
+ function $e1995378a142960e$var$useSSRCollectionNode(Type, props, ref, rendered, children, render) {
111
+ // During SSR, portals are not supported, so the collection children will be wrapped in an SSRContext.
112
+ // Since SSR occurs only once, we assume that the elements are rendered in order and never re-render.
113
+ // Therefore we can create elements in our collection document during render so that they are in the
114
+ // collection by the time we need to use the collection to render to the real DOM.
115
+ // After hydration, we switch to client rendering using the portal.
116
+ let itemRef = (0, $95feo$useCallback)((element)=>{
117
+ element === null || element === void 0 ? void 0 : element.setProps(props, ref, rendered, render);
118
+ }, [
119
+ props,
120
+ ref,
121
+ rendered,
122
+ render
123
+ ]);
124
+ let parentNode = (0, $95feo$useContext)($e1995378a142960e$var$SSRContext);
125
+ if (parentNode) {
126
+ // Guard against double rendering in strict mode.
127
+ let element = parentNode.ownerDocument.nodesByProps.get(props);
128
+ if (!element) {
129
+ element = parentNode.ownerDocument.createElement(Type);
130
+ element.setProps(props, ref, rendered, render);
131
+ parentNode.appendChild(element);
132
+ parentNode.ownerDocument.updateCollection();
133
+ parentNode.ownerDocument.nodesByProps.set(props, element);
134
+ }
135
+ return children ? /*#__PURE__*/ (0, $95feo$react).createElement($e1995378a142960e$var$SSRContext.Provider, {
136
+ value: element
137
+ }, children) : null;
138
+ }
139
+ // @ts-ignore
140
+ return /*#__PURE__*/ (0, $95feo$react).createElement(Type, {
141
+ ref: itemRef
142
+ }, children);
143
+ }
144
+ function $e1995378a142960e$export$18af5c7a9e9b3664(type, render) {
145
+ let Component = ({ node: node })=>render(node.props, node.props.ref, node);
146
+ let Result = (0, $95feo$forwardRef)((props, ref)=>{
147
+ let isShallow = (0, $95feo$useContext)($e1995378a142960e$var$ShallowRenderContext);
148
+ if (!isShallow) {
149
+ if (render.length >= 3) throw new Error(render.name + ' cannot be rendered outside a collection.');
150
+ return render(props, ref);
151
+ }
152
+ return $e1995378a142960e$var$useSSRCollectionNode(type, props, ref, 'children' in props ? props.children : null, null, (node)=>/*#__PURE__*/ (0, $95feo$react).createElement(Component, {
153
+ node: node
154
+ }));
155
+ });
156
+ // @ts-ignore
157
+ Result.displayName = render.name;
158
+ return Result;
159
+ }
160
+ function $e1995378a142960e$export$e953bb1cd0f19726(type, render, useChildren = $e1995378a142960e$var$useCollectionChildren) {
161
+ let Component = ({ node: node })=>render(node.props, node.props.ref, node);
162
+ let Result = (0, $95feo$forwardRef)((props, ref)=>{
163
+ let children = useChildren(props);
164
+ var _useSSRCollectionNode;
165
+ return (_useSSRCollectionNode = $e1995378a142960e$var$useSSRCollectionNode(type, props, ref, null, children, (node)=>/*#__PURE__*/ (0, $95feo$react).createElement(Component, {
166
+ node: node
167
+ }))) !== null && _useSSRCollectionNode !== void 0 ? _useSSRCollectionNode : /*#__PURE__*/ (0, $95feo$react).createElement((0, $95feo$react).Fragment, null);
168
+ });
169
+ // @ts-ignore
170
+ Result.displayName = render.name;
171
+ return Result;
172
+ }
173
+ function $e1995378a142960e$var$useCollectionChildren(options) {
174
+ return (0, $e948873055cbafe4$export$727c8fc270210f13)({
175
+ ...options,
176
+ addIdAndValue: true
177
+ });
178
+ }
179
+ const $e1995378a142960e$var$CollectionContext = /*#__PURE__*/ (0, $95feo$createContext)(null);
180
+ function $e1995378a142960e$export$fb8073518f34e6ec(props) {
181
+ let ctx = (0, $95feo$useContext)($e1995378a142960e$var$CollectionContext);
182
+ let dependencies = ((ctx === null || ctx === void 0 ? void 0 : ctx.dependencies) || []).concat(props.dependencies);
183
+ let idScope = props.idScope || (ctx === null || ctx === void 0 ? void 0 : ctx.idScope);
184
+ let children = $e1995378a142960e$var$useCollectionChildren({
185
+ ...props,
186
+ idScope: idScope,
187
+ dependencies: dependencies
188
+ });
189
+ let doc = (0, $95feo$useContext)($e1995378a142960e$var$CollectionDocumentContext);
190
+ if (doc) children = /*#__PURE__*/ (0, $95feo$react).createElement($e1995378a142960e$var$CollectionRoot, null, children);
191
+ // Propagate dependencies and idScope to child collections.
192
+ ctx = (0, $95feo$useMemo)(()=>({
193
+ dependencies: dependencies,
194
+ idScope: idScope
195
+ }), [
196
+ idScope,
197
+ ...dependencies
198
+ ]);
199
+ return /*#__PURE__*/ (0, $95feo$react).createElement($e1995378a142960e$var$CollectionContext.Provider, {
200
+ value: ctx
201
+ }, children);
202
+ }
203
+ function $e1995378a142960e$var$CollectionRoot({ children: children }) {
204
+ let doc = (0, $95feo$useContext)($e1995378a142960e$var$CollectionDocumentContext);
205
+ let wrappedChildren = (0, $95feo$useMemo)(()=>/*#__PURE__*/ (0, $95feo$react).createElement($e1995378a142960e$var$CollectionDocumentContext.Provider, {
206
+ value: null
207
+ }, /*#__PURE__*/ (0, $95feo$react).createElement($e1995378a142960e$var$ShallowRenderContext.Provider, {
208
+ value: true
209
+ }, children)), [
210
+ children
211
+ ]);
212
+ // During SSR, we render the content directly, and append nodes to the document during render.
213
+ // The collection children return null so that nothing is actually rendered into the HTML.
214
+ return (0, $95feo$useIsSSR)() ? /*#__PURE__*/ (0, $95feo$react).createElement($e1995378a142960e$var$SSRContext.Provider, {
215
+ value: doc
216
+ }, wrappedChildren) : /*#__PURE__*/ (0, $95feo$createPortal)(wrappedChildren, doc);
217
+ }
218
+
219
+
220
+ export {$e1995378a142960e$export$bf788dd355e3a401 as CollectionBuilder, $e1995378a142960e$export$18af5c7a9e9b3664 as createLeafComponent, $e1995378a142960e$export$e953bb1cd0f19726 as createBranchComponent, $e1995378a142960e$export$fb8073518f34e6ec as Collection};
221
+ //# sourceMappingURL=CollectionBuilder.module.js.map