@react-aria/collections 3.0.0-nightly-412a51816-250219 → 3.0.0-nightly-90b6fd4f7-250221
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/BaseCollection.main.js +32 -10
- package/dist/BaseCollection.main.js.map +1 -1
- package/dist/BaseCollection.mjs +32 -10
- package/dist/BaseCollection.module.js +32 -10
- package/dist/BaseCollection.module.js.map +1 -1
- package/dist/CollectionBuilder.main.js +9 -3
- package/dist/CollectionBuilder.main.js.map +1 -1
- package/dist/CollectionBuilder.mjs +9 -3
- package/dist/CollectionBuilder.module.js +9 -3
- package/dist/CollectionBuilder.module.js.map +1 -1
- package/dist/Document.main.js +12 -1
- package/dist/Document.main.js.map +1 -1
- package/dist/Document.mjs +12 -1
- package/dist/Document.module.js +12 -1
- package/dist/Document.module.js.map +1 -1
- package/dist/Hidden.main.js +4 -11
- package/dist/Hidden.main.js.map +1 -1
- package/dist/Hidden.mjs +4 -11
- package/dist/Hidden.module.js +4 -11
- package/dist/Hidden.module.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/BaseCollection.ts +40 -14
- package/src/CollectionBuilder.tsx +16 -2
- package/src/Document.ts +15 -1
- package/src/Hidden.tsx +3 -11
package/dist/Hidden.module.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {createPortal as $8SdCi$createPortal} from "react-dom";
|
|
2
1
|
import $8SdCi$react, {createContext as $8SdCi$createContext, useContext as $8SdCi$useContext, forwardRef as $8SdCi$forwardRef} from "react";
|
|
3
|
-
import {useIsSSR as $8SdCi$useIsSSR} from "@react-aria/ssr";
|
|
4
2
|
|
|
5
3
|
/*
|
|
6
4
|
* Copyright 2024 Adobe. All rights reserved.
|
|
@@ -13,8 +11,6 @@ import {useIsSSR as $8SdCi$useIsSSR} from "@react-aria/ssr";
|
|
|
13
11
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
12
|
* governing permissions and limitations under the License.
|
|
15
13
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
14
|
// React doesn't understand the <template> element, which doesn't have children like a normal element.
|
|
19
15
|
// It will throw an error during hydration when it expects the firstChild to contain content rendered
|
|
20
16
|
// on the server, when in reality, the browser will have placed this inside the `content` document fragment.
|
|
@@ -32,22 +28,19 @@ if (typeof HTMLTemplateElement !== 'undefined') {
|
|
|
32
28
|
});
|
|
33
29
|
}
|
|
34
30
|
const $f39a9eba43920ace$export$94b6d0abf7d33e8c = /*#__PURE__*/ (0, $8SdCi$createContext)(false);
|
|
35
|
-
// Portal to nowhere
|
|
36
|
-
const $f39a9eba43920ace$var$hiddenFragment = typeof DocumentFragment !== 'undefined' ? new DocumentFragment() : null;
|
|
37
31
|
function $f39a9eba43920ace$export$8dc98ba7eadeaa56(props) {
|
|
38
32
|
let isHidden = (0, $8SdCi$useContext)($f39a9eba43920ace$export$94b6d0abf7d33e8c);
|
|
39
|
-
let isSSR = (0, $8SdCi$useIsSSR)();
|
|
40
33
|
if (isHidden) // Don't hide again if we are already hidden.
|
|
41
34
|
return /*#__PURE__*/ (0, $8SdCi$react).createElement((0, $8SdCi$react).Fragment, null, props.children);
|
|
42
35
|
let children = /*#__PURE__*/ (0, $8SdCi$react).createElement($f39a9eba43920ace$export$94b6d0abf7d33e8c.Provider, {
|
|
43
36
|
value: true
|
|
44
37
|
}, props.children);
|
|
45
|
-
// In SSR, portals are not supported by React. Instead, render into a <template>
|
|
38
|
+
// In SSR, portals are not supported by React. Instead, always render into a <template>
|
|
46
39
|
// element, which the browser will never display to the user. In addition, the
|
|
47
|
-
// content is not part of the DOM tree, so it won't affect ids or other accessibility attributes.
|
|
48
|
-
return
|
|
40
|
+
// content is not part of the accessible DOM tree, so it won't affect ids or other accessibility attributes.
|
|
41
|
+
return /*#__PURE__*/ (0, $8SdCi$react).createElement("template", {
|
|
49
42
|
"data-react-aria-hidden": true
|
|
50
|
-
}, children)
|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AS;IACd,OAAO,CAAA,GAAA,iBAAS,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, {createContext, forwardRef, 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// See https://github.com/facebook/react/issues/19932\nif (typeof HTMLTemplateElement !== 'undefined') {\n const getFirstChild = Object.getOwnPropertyDescriptor(Node.prototype, 'firstChild')!.get!;\n Object.defineProperty(HTMLTemplateElement.prototype, 'firstChild', {\n configurable: true,\n enumerable: true,\n get: function () {\n if (this.dataset.reactAriaHidden) {\n return this.content.firstChild;\n } else {\n return getFirstChild.call(this);\n }\n }\n });\n}\n\nexport const HiddenContext = createContext<boolean>(false);\n\nexport function Hidden(props: {children: ReactNode}) {\n let isHidden = useContext(HiddenContext);\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 data-react-aria-hidden>{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.module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export class CollectionNode<T> implements Node<T> {
|
|
|
18
18
|
readonly lastChildKey: Key | null;
|
|
19
19
|
readonly props: any;
|
|
20
20
|
readonly render?: (node: Node<any>) => ReactElement;
|
|
21
|
+
readonly colSpan: number | null;
|
|
22
|
+
readonly colIndex: number | null;
|
|
21
23
|
constructor(type: string, key: Key);
|
|
22
24
|
get childNodes(): Iterable<Node<T>>;
|
|
23
25
|
clone(): CollectionNode<T>;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAmBA,+DAA+D;AAC/D,4BAA4B,CAAC,CAAE,YAAW,KAAK,CAAC,CAAC;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAQ;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAK;IAC3B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAS;IACxC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAQ;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAM;IAChC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,C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C,CAAC,KAAK,YAAY,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,aAAa,CAAC,CAAC,CAAC,KAAK,YAAY,GAAG,IAAI,CAAC;AAC/N,oCAAoC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,KAAK,YAAY,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,aAAa,CAAC,CAAC,CAAC,KAAK,YAAY,GAAG,IAAI,CAAC;AAgC9O,sCAAsC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS;IAAC,QAAQ,CAAC,EAAE,GAAG,CAAA;CAAC,EAAE,CAAC,SAAS,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,KAAK,YAAY,EAAE,WAAW,GAAE,CAAC,KAAK,EAAE,CAAC,KAAK,SAAiC,oEASzP;AAMD,iCAAiC,CAAC,CAAE,SAAQ,sBAAsB,CAAC,CAAC;CAAG;AAIvE,qFAAqF;AACrF,2BAA2B,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC,GAAG,IAAI,OAAO,CA2BnF","sources":["packages/@react-aria/collections/src/packages/@react-aria/collections/src/BaseCollection.ts","packages/@react-aria/collections/src/packages/@react-aria/collections/src/Document.ts","packages/@react-aria/collections/src/packages/@react-aria/collections/src/useCachedChildren.ts","packages/@react-aria/collections/src/packages/@react-aria/collections/src/Hidden.tsx","packages/@react-aria/collections/src/packages/@react-aria/collections/src/CollectionBuilder.tsx","packages/@react-aria/collections/src/packages/@react-aria/collections/src/index.ts","packages/@react-aria/collections/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,"/*\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\nexport {CollectionBuilder, Collection, createLeafComponent, createBranchComponent} from './CollectionBuilder';\nexport {createHideableComponent, useIsHidden} from './Hidden';\nexport {useCachedChildren} from './useCachedChildren';\nexport {BaseCollection, CollectionNode} from './BaseCollection';\n\nexport type {CollectionBuilderProps, CollectionProps} from './CollectionBuilder';\nexport type {CachedChildrenOptions} from './useCachedChildren';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/collections",
|
|
3
|
-
"version": "3.0.0-nightly-
|
|
3
|
+
"version": "3.0.0-nightly-90b6fd4f7-250221",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,9 +22,10 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/
|
|
26
|
-
"@react-aria/
|
|
27
|
-
"@react-
|
|
25
|
+
"@react-aria/interactions": "3.0.0-nightly-90b6fd4f7-250221",
|
|
26
|
+
"@react-aria/ssr": "3.0.0-nightly-90b6fd4f7-250221",
|
|
27
|
+
"@react-aria/utils": "3.0.0-nightly-90b6fd4f7-250221",
|
|
28
|
+
"@react-types/shared": "3.0.0-nightly-90b6fd4f7-250221",
|
|
28
29
|
"@swc/helpers": "^0.5.0",
|
|
29
30
|
"use-sync-external-store": "^1.4.0"
|
|
30
31
|
},
|
package/src/BaseCollection.ts
CHANGED
|
@@ -35,6 +35,8 @@ export class CollectionNode<T> implements Node<T> {
|
|
|
35
35
|
readonly lastChildKey: Key | null = null;
|
|
36
36
|
readonly props: any = {};
|
|
37
37
|
readonly render?: (node: Node<any>) => ReactElement;
|
|
38
|
+
readonly colSpan: number | null = null;
|
|
39
|
+
readonly colIndex: number | null = null;
|
|
38
40
|
|
|
39
41
|
constructor(type: string, key: Key) {
|
|
40
42
|
this.type = type;
|
|
@@ -61,6 +63,8 @@ export class CollectionNode<T> implements Node<T> {
|
|
|
61
63
|
node.lastChildKey = this.lastChildKey;
|
|
62
64
|
node.props = this.props;
|
|
63
65
|
node.render = this.render;
|
|
66
|
+
node.colSpan = this.colSpan;
|
|
67
|
+
node.colIndex = this.colIndex;
|
|
64
68
|
return node;
|
|
65
69
|
}
|
|
66
70
|
}
|
|
@@ -224,7 +228,7 @@ export class BaseCollection<T> implements ICollection<Node<T>> {
|
|
|
224
228
|
let clonedSection: Mutable<CollectionNode<T>> = (node as CollectionNode<T>).clone();
|
|
225
229
|
let lastChildInSection: Mutable<CollectionNode<T>> | null = null;
|
|
226
230
|
for (let child of this.getChildren(node.key)) {
|
|
227
|
-
if (
|
|
231
|
+
if (shouldKeepNode(child, filterFn, this, newCollection)) {
|
|
228
232
|
let clonedChild: Mutable<CollectionNode<T>> = (child as CollectionNode<T>).clone();
|
|
229
233
|
// eslint-disable-next-line max-depth
|
|
230
234
|
if (lastChildInSection == null) {
|
|
@@ -284,22 +288,25 @@ export class BaseCollection<T> implements ICollection<Node<T>> {
|
|
|
284
288
|
lastNode = clonedSeparator;
|
|
285
289
|
newCollection.addNode(clonedSeparator);
|
|
286
290
|
}
|
|
287
|
-
} else
|
|
291
|
+
} else {
|
|
292
|
+
// At this point, the node is either a subdialogtrigger node or a standard row/item
|
|
288
293
|
let clonedNode: Mutable<CollectionNode<T>> = (node as CollectionNode<T>).clone();
|
|
289
|
-
if (
|
|
290
|
-
newCollection.firstKey
|
|
291
|
-
|
|
294
|
+
if (shouldKeepNode(clonedNode, filterFn, this, newCollection)) {
|
|
295
|
+
if (newCollection.firstKey == null) {
|
|
296
|
+
newCollection.firstKey = clonedNode.key;
|
|
297
|
+
}
|
|
292
298
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
+
if (lastNode != null && (lastNode.type !== 'section' && lastNode.type !== 'separator') && lastNode.parentKey === clonedNode.parentKey) {
|
|
300
|
+
lastNode.nextKey = clonedNode.key;
|
|
301
|
+
clonedNode.prevKey = lastNode.key;
|
|
302
|
+
} else {
|
|
303
|
+
clonedNode.prevKey = null;
|
|
304
|
+
}
|
|
299
305
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
306
|
+
clonedNode.nextKey = null;
|
|
307
|
+
newCollection.addNode(clonedNode);
|
|
308
|
+
lastNode = clonedNode;
|
|
309
|
+
}
|
|
303
310
|
}
|
|
304
311
|
}
|
|
305
312
|
|
|
@@ -318,3 +325,22 @@ export class BaseCollection<T> implements ICollection<Node<T>> {
|
|
|
318
325
|
return newCollection;
|
|
319
326
|
}
|
|
320
327
|
}
|
|
328
|
+
|
|
329
|
+
function shouldKeepNode<T>(node: Node<T>, filterFn: (nodeValue: string) => boolean, oldCollection: BaseCollection<T>, newCollection: BaseCollection<T>): boolean {
|
|
330
|
+
if (node.type === 'subdialogtrigger' || node.type === 'submenutrigger') {
|
|
331
|
+
// Subdialog wrapper should only have one child, if it passes the filter add it to the new collection since we don't need to
|
|
332
|
+
// do any extra handling for its first/next key
|
|
333
|
+
let triggerChild = [...oldCollection.getChildren(node.key)][0];
|
|
334
|
+
if (triggerChild && filterFn(triggerChild.textValue)) {
|
|
335
|
+
let clonedChild: Mutable<CollectionNode<T>> = (triggerChild as CollectionNode<T>).clone();
|
|
336
|
+
newCollection.addNode(clonedChild);
|
|
337
|
+
return true;
|
|
338
|
+
} else {
|
|
339
|
+
return false;
|
|
340
|
+
}
|
|
341
|
+
} else if (node.type === 'header') {
|
|
342
|
+
return true;
|
|
343
|
+
} else {
|
|
344
|
+
return filterFn(node.textValue);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
@@ -14,6 +14,7 @@ import {BaseCollection} from './BaseCollection';
|
|
|
14
14
|
import {BaseNode, Document, ElementNode} from './Document';
|
|
15
15
|
import {CachedChildrenOptions, useCachedChildren} from './useCachedChildren';
|
|
16
16
|
import {createPortal} from 'react-dom';
|
|
17
|
+
import {FocusableContext} from '@react-aria/interactions';
|
|
17
18
|
import {forwardRefType, Node} from '@react-types/shared';
|
|
18
19
|
import {Hidden} from './Hidden';
|
|
19
20
|
import React, {createContext, ForwardedRef, forwardRef, JSX, ReactElement, ReactNode, useCallback, useContext, useMemo, useRef, useState} from 'react';
|
|
@@ -116,7 +117,7 @@ function useCollectionDocument<T extends object, C extends BaseCollection<T>>(cr
|
|
|
116
117
|
useLayoutEffect(() => {
|
|
117
118
|
document.isMounted = true;
|
|
118
119
|
return () => {
|
|
119
|
-
// Mark unmounted so we can skip all of the collection updates caused by
|
|
120
|
+
// Mark unmounted so we can skip all of the collection updates caused by
|
|
120
121
|
// React calling removeChild on every item in the collection.
|
|
121
122
|
document.isMounted = false;
|
|
122
123
|
};
|
|
@@ -161,6 +162,7 @@ export function createLeafComponent<T extends object, P extends object, E extend
|
|
|
161
162
|
export function createLeafComponent<P extends object, E extends Element>(type: string, render: (props: P, ref: ForwardedRef<E>, node?: any) => ReactElement) {
|
|
162
163
|
let Component = ({node}) => render(node.props, node.props.ref, node);
|
|
163
164
|
let Result = (forwardRef as forwardRefType)((props: P, ref: ForwardedRef<E>) => {
|
|
165
|
+
let focusableProps = useContext(FocusableContext);
|
|
164
166
|
let isShallow = useContext(ShallowRenderContext);
|
|
165
167
|
if (!isShallow) {
|
|
166
168
|
if (render.length >= 3) {
|
|
@@ -169,7 +171,19 @@ export function createLeafComponent<P extends object, E extends Element>(type: s
|
|
|
169
171
|
return render(props, ref);
|
|
170
172
|
}
|
|
171
173
|
|
|
172
|
-
return useSSRCollectionNode(
|
|
174
|
+
return useSSRCollectionNode(
|
|
175
|
+
type,
|
|
176
|
+
props,
|
|
177
|
+
ref,
|
|
178
|
+
'children' in props ? props.children : null,
|
|
179
|
+
null,
|
|
180
|
+
node => (
|
|
181
|
+
// Forward FocusableContext to real DOM tree so tooltips work.
|
|
182
|
+
<FocusableContext.Provider value={focusableProps}>
|
|
183
|
+
<Component node={node} />
|
|
184
|
+
</FocusableContext.Provider>
|
|
185
|
+
)
|
|
186
|
+
);
|
|
173
187
|
});
|
|
174
188
|
// @ts-ignore
|
|
175
189
|
Result.displayName = render.name;
|
package/src/Document.ts
CHANGED
|
@@ -260,6 +260,16 @@ export class ElementNode<T> extends BaseNode<T> {
|
|
|
260
260
|
node.hasChildNodes = !!this.firstChild;
|
|
261
261
|
node.firstChildKey = this.firstChild?.node.key ?? null;
|
|
262
262
|
node.lastChildKey = this.lastChild?.node.key ?? null;
|
|
263
|
+
|
|
264
|
+
// Update the colIndex of sibling nodes if this node has a colSpan.
|
|
265
|
+
if ((node.colSpan != null || node.colIndex != null) && this.nextSibling) {
|
|
266
|
+
// This queues the next sibling for update, which means this happens recursively.
|
|
267
|
+
let nextColIndex = (node.colIndex ?? node.index) + (node.colSpan ?? 1);
|
|
268
|
+
if (nextColIndex !== this.nextSibling.node.colIndex) {
|
|
269
|
+
let siblingNode = this.ownerDocument.getMutableNode(this.nextSibling);
|
|
270
|
+
siblingNode.colIndex = nextColIndex;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
263
273
|
}
|
|
264
274
|
|
|
265
275
|
setProps<E extends Element>(obj: any, ref: ForwardedRef<E>, rendered?: any, render?: (node: Node<T>) => ReactElement) {
|
|
@@ -278,6 +288,10 @@ export class ElementNode<T> extends BaseNode<T> {
|
|
|
278
288
|
node.key = id;
|
|
279
289
|
}
|
|
280
290
|
|
|
291
|
+
if (props.colSpan != null) {
|
|
292
|
+
node.colSpan = props.colSpan;
|
|
293
|
+
}
|
|
294
|
+
|
|
281
295
|
// If this is the first time props have been set, end the transaction started in the constructor
|
|
282
296
|
// so this node can be emitted.
|
|
283
297
|
if (!this.hasSetProps) {
|
|
@@ -418,8 +432,8 @@ export class Document<T, C extends BaseCollection<T> = BaseCollection<T>> extend
|
|
|
418
432
|
}
|
|
419
433
|
}
|
|
420
434
|
|
|
421
|
-
collection.commit(this.firstChild?.node.key ?? null, this.lastChild?.node.key ?? null, this.isSSR);
|
|
422
435
|
this.mutatedNodes.clear();
|
|
436
|
+
collection.commit(this.firstChild?.node.key ?? null, this.lastChild?.node.key ?? null, this.isSSR);
|
|
423
437
|
}
|
|
424
438
|
|
|
425
439
|
this.collectionMutated = false;
|
package/src/Hidden.tsx
CHANGED
|
@@ -10,10 +10,8 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {createPortal} from 'react-dom';
|
|
14
13
|
import {forwardRefType} from '@react-types/shared';
|
|
15
14
|
import React, {createContext, forwardRef, ReactElement, ReactNode, useContext} from 'react';
|
|
16
|
-
import {useIsSSR} from '@react-aria/ssr';
|
|
17
15
|
|
|
18
16
|
// React doesn't understand the <template> element, which doesn't have children like a normal element.
|
|
19
17
|
// It will throw an error during hydration when it expects the firstChild to contain content rendered
|
|
@@ -37,12 +35,8 @@ if (typeof HTMLTemplateElement !== 'undefined') {
|
|
|
37
35
|
|
|
38
36
|
export const HiddenContext = createContext<boolean>(false);
|
|
39
37
|
|
|
40
|
-
// Portal to nowhere
|
|
41
|
-
const hiddenFragment = typeof DocumentFragment !== 'undefined' ? new DocumentFragment() : null;
|
|
42
|
-
|
|
43
38
|
export function Hidden(props: {children: ReactNode}) {
|
|
44
39
|
let isHidden = useContext(HiddenContext);
|
|
45
|
-
let isSSR = useIsSSR();
|
|
46
40
|
if (isHidden) {
|
|
47
41
|
// Don't hide again if we are already hidden.
|
|
48
42
|
return <>{props.children}</>;
|
|
@@ -54,12 +48,10 @@ export function Hidden(props: {children: ReactNode}) {
|
|
|
54
48
|
</HiddenContext.Provider>
|
|
55
49
|
);
|
|
56
50
|
|
|
57
|
-
// In SSR, portals are not supported by React. Instead, render into a <template>
|
|
51
|
+
// In SSR, portals are not supported by React. Instead, always render into a <template>
|
|
58
52
|
// element, which the browser will never display to the user. In addition, the
|
|
59
|
-
// content is not part of the DOM tree, so it won't affect ids or other accessibility attributes.
|
|
60
|
-
return
|
|
61
|
-
? <template data-react-aria-hidden>{children}</template>
|
|
62
|
-
: createPortal(children, hiddenFragment!);
|
|
53
|
+
// content is not part of the accessible DOM tree, so it won't affect ids or other accessibility attributes.
|
|
54
|
+
return <template data-react-aria-hidden>{children}</template>;
|
|
63
55
|
}
|
|
64
56
|
|
|
65
57
|
/** Creates a component that forwards its ref and returns null if it is in a hidden subtree. */
|