@react-aria/collections 3.0.0-alpha.1 → 3.0.0-nightly.2986
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/README.md +1 -1
- package/dist/BaseCollection.main.js +157 -0
- package/dist/BaseCollection.main.js.map +1 -0
- package/dist/BaseCollection.mjs +151 -0
- package/dist/BaseCollection.module.js +151 -0
- package/dist/BaseCollection.module.js.map +1 -0
- package/dist/CollectionBuilder.main.js +233 -0
- package/dist/CollectionBuilder.main.js.map +1 -0
- package/dist/CollectionBuilder.mjs +221 -0
- package/dist/CollectionBuilder.module.js +221 -0
- package/dist/CollectionBuilder.module.js.map +1 -0
- package/dist/Document.main.js +316 -0
- package/dist/Document.main.js.map +1 -0
- package/dist/Document.mjs +311 -0
- package/dist/Document.module.js +311 -0
- package/dist/Document.module.js.map +1 -0
- package/dist/Hidden.main.js +79 -0
- package/dist/Hidden.main.js.map +1 -0
- package/dist/Hidden.mjs +68 -0
- package/dist/Hidden.module.js +68 -0
- package/dist/Hidden.module.js.map +1 -0
- package/dist/import.mjs +23 -0
- package/dist/main.js +27 -348
- package/dist/main.js.map +1 -0
- package/dist/module.js +17 -318
- package/dist/module.js.map +1 -0
- package/dist/types.d.ts +81 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/useCachedChildren.main.js +63 -0
- package/dist/useCachedChildren.main.js.map +1 -0
- package/dist/useCachedChildren.mjs +58 -0
- package/dist/useCachedChildren.module.js +58 -0
- package/dist/useCachedChildren.module.js.map +1 -0
- package/package.json +17 -10
- package/src/BaseCollection.ts +211 -0
- package/src/CollectionBuilder.tsx +237 -0
- package/src/Document.ts +453 -0
- package/src/Hidden.tsx +84 -0
- package/src/index.ts +19 -0
- package/src/useCachedChildren.ts +70 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var $a8uUY$reactdom = require("react-dom");
|
|
2
|
+
var $a8uUY$react = require("react");
|
|
3
|
+
var $a8uUY$reactariassr = require("@react-aria/ssr");
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function $parcel$interopDefault(a) {
|
|
7
|
+
return a && a.__esModule ? a.default : a;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function $parcel$export(e, n, v, s) {
|
|
11
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
$parcel$export(module.exports, "Hidden", () => $eaaf60978b89fc58$export$8dc98ba7eadeaa56);
|
|
15
|
+
$parcel$export(module.exports, "createHideableComponent", () => $eaaf60978b89fc58$export$86427a43e3e48ebb);
|
|
16
|
+
$parcel$export(module.exports, "useIsHidden", () => $eaaf60978b89fc58$export$b5d7cc18bb8d2b59);
|
|
17
|
+
/*
|
|
18
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
19
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
21
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
24
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
25
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
26
|
+
* governing permissions and limitations under the License.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// React doesn't understand the <template> element, which doesn't have children like a normal element.
|
|
31
|
+
// It will throw an error during hydration when it expects the firstChild to contain content rendered
|
|
32
|
+
// on the server, when in reality, the browser will have placed this inside the `content` document fragment.
|
|
33
|
+
// This monkey patches the firstChild property for our special hidden template elements to work around this error.
|
|
34
|
+
// See https://github.com/facebook/react/issues/19932
|
|
35
|
+
if (typeof HTMLTemplateElement !== 'undefined') {
|
|
36
|
+
const getFirstChild = Object.getOwnPropertyDescriptor(Node.prototype, 'firstChild').get;
|
|
37
|
+
Object.defineProperty(HTMLTemplateElement.prototype, 'firstChild', {
|
|
38
|
+
configurable: true,
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function() {
|
|
41
|
+
if (this.dataset.reactAriaHidden) return this.content.firstChild;
|
|
42
|
+
else return getFirstChild.call(this);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const $eaaf60978b89fc58$export$94b6d0abf7d33e8c = /*#__PURE__*/ (0, $a8uUY$react.createContext)(false);
|
|
47
|
+
// Portal to nowhere
|
|
48
|
+
const $eaaf60978b89fc58$var$hiddenFragment = typeof DocumentFragment !== 'undefined' ? new DocumentFragment() : null;
|
|
49
|
+
function $eaaf60978b89fc58$export$8dc98ba7eadeaa56(props) {
|
|
50
|
+
let isHidden = (0, $a8uUY$react.useContext)($eaaf60978b89fc58$export$94b6d0abf7d33e8c);
|
|
51
|
+
let isSSR = (0, $a8uUY$reactariassr.useIsSSR)();
|
|
52
|
+
if (isHidden) // Don't hide again if we are already hidden.
|
|
53
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($a8uUY$react))).createElement((0, ($parcel$interopDefault($a8uUY$react))).Fragment, null, props.children);
|
|
54
|
+
let children = /*#__PURE__*/ (0, ($parcel$interopDefault($a8uUY$react))).createElement($eaaf60978b89fc58$export$94b6d0abf7d33e8c.Provider, {
|
|
55
|
+
value: true
|
|
56
|
+
}, props.children);
|
|
57
|
+
// In SSR, portals are not supported by React. Instead, render into a <template>
|
|
58
|
+
// 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 isSSR ? /*#__PURE__*/ (0, ($parcel$interopDefault($a8uUY$react))).createElement("template", {
|
|
61
|
+
"data-react-aria-hidden": true
|
|
62
|
+
}, children) : /*#__PURE__*/ (0, $a8uUY$reactdom.createPortal)(children, $eaaf60978b89fc58$var$hiddenFragment);
|
|
63
|
+
}
|
|
64
|
+
function $eaaf60978b89fc58$export$86427a43e3e48ebb(fn) {
|
|
65
|
+
let Wrapper = (props, ref)=>{
|
|
66
|
+
let isHidden = (0, $a8uUY$react.useContext)($eaaf60978b89fc58$export$94b6d0abf7d33e8c);
|
|
67
|
+
if (isHidden) return null;
|
|
68
|
+
return fn(props, ref);
|
|
69
|
+
};
|
|
70
|
+
// @ts-ignore - for react dev tools
|
|
71
|
+
Wrapper.displayName = fn.displayName || fn.name;
|
|
72
|
+
return (0, $a8uUY$react.forwardRef)(Wrapper);
|
|
73
|
+
}
|
|
74
|
+
function $eaaf60978b89fc58$export$b5d7cc18bb8d2b59() {
|
|
75
|
+
return (0, $a8uUY$react.useContext)($eaaf60978b89fc58$export$94b6d0abf7d33e8c);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=Hidden.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAOD,sGAAsG;AACtG,qGAAqG;AACrG,4GAA4G;AAC5G,kHAAkH;AAClH,qDAAqD;AACrD,IAAI,OAAO,wBAAwB,aAAa;IAC9C,MAAM,gBAAgB,OAAO,wBAAwB,CAAC,KAAK,SAAS,EAAE,cAAe,GAAG;IACxF,OAAO,cAAc,CAAC,oBAAoB,SAAS,EAAE,cAAc;QACjE,cAAc;QACd,YAAY;QACZ,KAAK;YACH,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,EAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU;iBAE9B,OAAO,cAAc,IAAI,CAAC,IAAI;QAElC;IACF;AACF;AAEO,MAAM,0DAAgB,CAAA,GAAA,0BAAY,EAAW;AAEpD,oBAAoB;AACpB,MAAM,uCAAiB,OAAO,qBAAqB,cAAc,IAAI,qBAAqB;AAEnF,SAAS,0CAAO,KAA4B;IACjD,IAAI,WAAW,CAAA,GAAA,uBAAS,EAAE;IAC1B,IAAI,QAAQ,CAAA,GAAA,4BAAO;IACnB,IAAI,UACF,6CAA6C;IAC7C,qBAAO,sHAAG,MAAM,QAAQ;IAG1B,IAAI,yBACF,0DAAC,0CAAc,QAAQ;QAAC,OAAA;OACrB,MAAM,QAAQ;IAInB,gFAAgF;IAChF,8EAA8E;IAC9E,iGAAiG;IACjG,OAAO,sBACH,0DAAC;QAAS,0BAAA;OAAwB,0BAClC,CAAA,GAAA,4BAAW,EAAE,UAAU;AAC7B;AAIO,SAAS,0CAAmC,EAAqD;IACtG,IAAI,UAAU,CAAC,OAAU;QACvB,IAAI,WAAW,CAAA,GAAA,uBAAS,EAAE;QAC1B,IAAI,UACF,OAAO;QAGT,OAAO,GAAG,OAAO;IACnB;IACA,mCAAmC;IACnC,QAAQ,WAAW,GAAG,GAAG,WAAW,IAAI,GAAG,IAAI;IAC/C,OAAO,AAAC,CAAA,GAAA,uBAAS,EAAqB;AACxC;AAGO,SAAS;IACd,OAAO,CAAA,GAAA,uBAAS,EAAE;AACpB","sources":["packages/@react-aria/collections/src/Hidden.tsx"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {createPortal} from 'react-dom';\nimport {forwardRefType} from '@react-types/shared';\nimport React, {createContext, forwardRef, ReactNode, useContext} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\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\n// Portal to nowhere\nconst hiddenFragment = typeof DocumentFragment !== 'undefined' ? new DocumentFragment() : null;\n\nexport function Hidden(props: {children: ReactNode}) {\n let isHidden = useContext(HiddenContext);\n let isSSR = useIsSSR();\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, 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 DOM tree, so it won't affect ids or other accessibility attributes.\n return isSSR\n ? <template data-react-aria-hidden>{children}</template>\n : createPortal(children, hiddenFragment!);\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>) => ReactNode | null): (props: P & React.RefAttributes<T>) => ReactNode | null {\n let Wrapper = (props: P, ref: React.Ref<T>) => {\n let isHidden = useContext(HiddenContext);\n if (isHidden) {\n return null;\n }\n\n return fn(props, ref);\n };\n // @ts-ignore - for react dev tools\n Wrapper.displayName = fn.displayName || fn.name;\n return (forwardRef as forwardRefType)(Wrapper);\n}\n\n/** Returns whether the component is in a hidden subtree. */\nexport function useIsHidden(): boolean {\n return useContext(HiddenContext);\n}\n"],"names":[],"version":3,"file":"Hidden.main.js.map"}
|
package/dist/Hidden.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {createPortal as $8SdCi$createPortal} from "react-dom";
|
|
2
|
+
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
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
// React doesn't understand the <template> element, which doesn't have children like a normal element.
|
|
19
|
+
// It will throw an error during hydration when it expects the firstChild to contain content rendered
|
|
20
|
+
// on the server, when in reality, the browser will have placed this inside the `content` document fragment.
|
|
21
|
+
// This monkey patches the firstChild property for our special hidden template elements to work around this error.
|
|
22
|
+
// See https://github.com/facebook/react/issues/19932
|
|
23
|
+
if (typeof HTMLTemplateElement !== 'undefined') {
|
|
24
|
+
const getFirstChild = Object.getOwnPropertyDescriptor(Node.prototype, 'firstChild').get;
|
|
25
|
+
Object.defineProperty(HTMLTemplateElement.prototype, 'firstChild', {
|
|
26
|
+
configurable: true,
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function() {
|
|
29
|
+
if (this.dataset.reactAriaHidden) return this.content.firstChild;
|
|
30
|
+
else return getFirstChild.call(this);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
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
|
+
function $f39a9eba43920ace$export$8dc98ba7eadeaa56(props) {
|
|
38
|
+
let isHidden = (0, $8SdCi$useContext)($f39a9eba43920ace$export$94b6d0abf7d33e8c);
|
|
39
|
+
let isSSR = (0, $8SdCi$useIsSSR)();
|
|
40
|
+
if (isHidden) // Don't hide again if we are already hidden.
|
|
41
|
+
return /*#__PURE__*/ (0, $8SdCi$react).createElement((0, $8SdCi$react).Fragment, null, props.children);
|
|
42
|
+
let children = /*#__PURE__*/ (0, $8SdCi$react).createElement($f39a9eba43920ace$export$94b6d0abf7d33e8c.Provider, {
|
|
43
|
+
value: true
|
|
44
|
+
}, props.children);
|
|
45
|
+
// In SSR, portals are not supported by React. Instead, render into a <template>
|
|
46
|
+
// 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 isSSR ? /*#__PURE__*/ (0, $8SdCi$react).createElement("template", {
|
|
49
|
+
"data-react-aria-hidden": true
|
|
50
|
+
}, children) : /*#__PURE__*/ (0, $8SdCi$createPortal)(children, $f39a9eba43920ace$var$hiddenFragment);
|
|
51
|
+
}
|
|
52
|
+
function $f39a9eba43920ace$export$86427a43e3e48ebb(fn) {
|
|
53
|
+
let Wrapper = (props, ref)=>{
|
|
54
|
+
let isHidden = (0, $8SdCi$useContext)($f39a9eba43920ace$export$94b6d0abf7d33e8c);
|
|
55
|
+
if (isHidden) return null;
|
|
56
|
+
return fn(props, ref);
|
|
57
|
+
};
|
|
58
|
+
// @ts-ignore - for react dev tools
|
|
59
|
+
Wrapper.displayName = fn.displayName || fn.name;
|
|
60
|
+
return (0, $8SdCi$forwardRef)(Wrapper);
|
|
61
|
+
}
|
|
62
|
+
function $f39a9eba43920ace$export$b5d7cc18bb8d2b59() {
|
|
63
|
+
return (0, $8SdCi$useContext)($f39a9eba43920ace$export$94b6d0abf7d33e8c);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
export {$f39a9eba43920ace$export$94b6d0abf7d33e8c as HiddenContext, $f39a9eba43920ace$export$8dc98ba7eadeaa56 as Hidden, $f39a9eba43920ace$export$86427a43e3e48ebb as createHideableComponent, $f39a9eba43920ace$export$b5d7cc18bb8d2b59 as useIsHidden};
|
|
68
|
+
//# sourceMappingURL=Hidden.module.js.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {createPortal as $8SdCi$createPortal} from "react-dom";
|
|
2
|
+
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
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
// React doesn't understand the <template> element, which doesn't have children like a normal element.
|
|
19
|
+
// It will throw an error during hydration when it expects the firstChild to contain content rendered
|
|
20
|
+
// on the server, when in reality, the browser will have placed this inside the `content` document fragment.
|
|
21
|
+
// This monkey patches the firstChild property for our special hidden template elements to work around this error.
|
|
22
|
+
// See https://github.com/facebook/react/issues/19932
|
|
23
|
+
if (typeof HTMLTemplateElement !== 'undefined') {
|
|
24
|
+
const getFirstChild = Object.getOwnPropertyDescriptor(Node.prototype, 'firstChild').get;
|
|
25
|
+
Object.defineProperty(HTMLTemplateElement.prototype, 'firstChild', {
|
|
26
|
+
configurable: true,
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function() {
|
|
29
|
+
if (this.dataset.reactAriaHidden) return this.content.firstChild;
|
|
30
|
+
else return getFirstChild.call(this);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
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
|
+
function $f39a9eba43920ace$export$8dc98ba7eadeaa56(props) {
|
|
38
|
+
let isHidden = (0, $8SdCi$useContext)($f39a9eba43920ace$export$94b6d0abf7d33e8c);
|
|
39
|
+
let isSSR = (0, $8SdCi$useIsSSR)();
|
|
40
|
+
if (isHidden) // Don't hide again if we are already hidden.
|
|
41
|
+
return /*#__PURE__*/ (0, $8SdCi$react).createElement((0, $8SdCi$react).Fragment, null, props.children);
|
|
42
|
+
let children = /*#__PURE__*/ (0, $8SdCi$react).createElement($f39a9eba43920ace$export$94b6d0abf7d33e8c.Provider, {
|
|
43
|
+
value: true
|
|
44
|
+
}, props.children);
|
|
45
|
+
// In SSR, portals are not supported by React. Instead, render into a <template>
|
|
46
|
+
// 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 isSSR ? /*#__PURE__*/ (0, $8SdCi$react).createElement("template", {
|
|
49
|
+
"data-react-aria-hidden": true
|
|
50
|
+
}, children) : /*#__PURE__*/ (0, $8SdCi$createPortal)(children, $f39a9eba43920ace$var$hiddenFragment);
|
|
51
|
+
}
|
|
52
|
+
function $f39a9eba43920ace$export$86427a43e3e48ebb(fn) {
|
|
53
|
+
let Wrapper = (props, ref)=>{
|
|
54
|
+
let isHidden = (0, $8SdCi$useContext)($f39a9eba43920ace$export$94b6d0abf7d33e8c);
|
|
55
|
+
if (isHidden) return null;
|
|
56
|
+
return fn(props, ref);
|
|
57
|
+
};
|
|
58
|
+
// @ts-ignore - for react dev tools
|
|
59
|
+
Wrapper.displayName = fn.displayName || fn.name;
|
|
60
|
+
return (0, $8SdCi$forwardRef)(Wrapper);
|
|
61
|
+
}
|
|
62
|
+
function $f39a9eba43920ace$export$b5d7cc18bb8d2b59() {
|
|
63
|
+
return (0, $8SdCi$useContext)($f39a9eba43920ace$export$94b6d0abf7d33e8c);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
export {$f39a9eba43920ace$export$94b6d0abf7d33e8c as HiddenContext, $f39a9eba43920ace$export$8dc98ba7eadeaa56 as Hidden, $f39a9eba43920ace$export$86427a43e3e48ebb as createHideableComponent, $f39a9eba43920ace$export$b5d7cc18bb8d2b59 as useIsHidden};
|
|
68
|
+
//# sourceMappingURL=Hidden.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAOD,sGAAsG;AACtG,qGAAqG;AACrG,4GAA4G;AAC5G,kHAAkH;AAClH,qDAAqD;AACrD,IAAI,OAAO,wBAAwB,aAAa;IAC9C,MAAM,gBAAgB,OAAO,wBAAwB,CAAC,KAAK,SAAS,EAAE,cAAe,GAAG;IACxF,OAAO,cAAc,CAAC,oBAAoB,SAAS,EAAE,cAAc;QACjE,cAAc;QACd,YAAY;QACZ,KAAK;YACH,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,EAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU;iBAE9B,OAAO,cAAc,IAAI,CAAC,IAAI;QAElC;IACF;AACF;AAEO,MAAM,0DAAgB,CAAA,GAAA,oBAAY,EAAW;AAEpD,oBAAoB;AACpB,MAAM,uCAAiB,OAAO,qBAAqB,cAAc,IAAI,qBAAqB;AAEnF,SAAS,0CAAO,KAA4B;IACjD,IAAI,WAAW,CAAA,GAAA,iBAAS,EAAE;IAC1B,IAAI,QAAQ,CAAA,GAAA,eAAO;IACnB,IAAI,UACF,6CAA6C;IAC7C,qBAAO,kEAAG,MAAM,QAAQ;IAG1B,IAAI,yBACF,gCAAC,0CAAc,QAAQ;QAAC,OAAA;OACrB,MAAM,QAAQ;IAInB,gFAAgF;IAChF,8EAA8E;IAC9E,iGAAiG;IACjG,OAAO,sBACH,gCAAC;QAAS,0BAAA;OAAwB,0BAClC,CAAA,GAAA,mBAAW,EAAE,UAAU;AAC7B;AAIO,SAAS,0CAAmC,EAAqD;IACtG,IAAI,UAAU,CAAC,OAAU;QACvB,IAAI,WAAW,CAAA,GAAA,iBAAS,EAAE;QAC1B,IAAI,UACF,OAAO;QAGT,OAAO,GAAG,OAAO;IACnB;IACA,mCAAmC;IACnC,QAAQ,WAAW,GAAG,GAAG,WAAW,IAAI,GAAG,IAAI;IAC/C,OAAO,AAAC,CAAA,GAAA,iBAAS,EAAqB;AACxC;AAGO,SAAS;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 {createPortal} from 'react-dom';\nimport {forwardRefType} from '@react-types/shared';\nimport React, {createContext, forwardRef, ReactNode, useContext} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\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\n// Portal to nowhere\nconst hiddenFragment = typeof DocumentFragment !== 'undefined' ? new DocumentFragment() : null;\n\nexport function Hidden(props: {children: ReactNode}) {\n let isHidden = useContext(HiddenContext);\n let isSSR = useIsSSR();\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, 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 DOM tree, so it won't affect ids or other accessibility attributes.\n return isSSR\n ? <template data-react-aria-hidden>{children}</template>\n : createPortal(children, hiddenFragment!);\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>) => ReactNode | null): (props: P & React.RefAttributes<T>) => ReactNode | 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/import.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {Collection as $e1995378a142960e$export$fb8073518f34e6ec, CollectionBuilder as $e1995378a142960e$export$bf788dd355e3a401, createBranchComponent as $e1995378a142960e$export$e953bb1cd0f19726, createLeafComponent as $e1995378a142960e$export$18af5c7a9e9b3664} from "./CollectionBuilder.mjs";
|
|
2
|
+
import {createHideableComponent as $f39a9eba43920ace$export$86427a43e3e48ebb, useIsHidden as $f39a9eba43920ace$export$b5d7cc18bb8d2b59} from "./Hidden.mjs";
|
|
3
|
+
import {useCachedChildren as $e948873055cbafe4$export$727c8fc270210f13} from "./useCachedChildren.mjs";
|
|
4
|
+
import {BaseCollection as $23b9f4fcf0fe224b$export$408d25a4e12db025, NodeValue as $23b9f4fcf0fe224b$export$f5d856d854e74713} from "./BaseCollection.mjs";
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
8
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
10
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
13
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
14
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
15
|
+
* governing permissions and limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export {$e1995378a142960e$export$bf788dd355e3a401 as CollectionBuilder, $e1995378a142960e$export$fb8073518f34e6ec as Collection, $e1995378a142960e$export$18af5c7a9e9b3664 as createLeafComponent, $e1995378a142960e$export$e953bb1cd0f19726 as createBranchComponent, $f39a9eba43920ace$export$86427a43e3e48ebb as createHideableComponent, $f39a9eba43920ace$export$b5d7cc18bb8d2b59 as useIsHidden, $e948873055cbafe4$export$727c8fc270210f13 as useCachedChildren, $23b9f4fcf0fe224b$export$408d25a4e12db025 as BaseCollection, $23b9f4fcf0fe224b$export$f5d856d854e74713 as NodeValue};
|
|
23
|
+
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -1,357 +1,36 @@
|
|
|
1
|
-
var
|
|
1
|
+
var $f20386e2aa690b4a$exports = require("./CollectionBuilder.main.js");
|
|
2
|
+
var $eaaf60978b89fc58$exports = require("./Hidden.main.js");
|
|
3
|
+
var $245f3f827bea6653$exports = require("./useCachedChildren.main.js");
|
|
4
|
+
var $499e2959ba1abacc$exports = require("./BaseCollection.main.js");
|
|
2
5
|
|
|
3
|
-
var _babelRuntimeHelpersObjectWithoutProperties = $parcel$interopDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var chain = _temp.chain;
|
|
8
|
-
var focusWithoutScrolling = _temp.focusWithoutScrolling;
|
|
9
|
-
|
|
10
|
-
var _react2 = require("react");
|
|
11
|
-
|
|
12
|
-
var _react = $parcel$interopDefault(_react2);
|
|
13
|
-
|
|
14
|
-
var useRef = _react2.useRef;
|
|
15
|
-
var useCallback = _react2.useCallback;
|
|
16
|
-
var useLayoutEffect = _react2.useLayoutEffect;
|
|
17
|
-
var useEffect = _react2.useEffect;
|
|
18
|
-
var useState = _react2.useState;
|
|
19
|
-
|
|
20
|
-
var _temp2 = require("@react-stately/collections");
|
|
21
|
-
|
|
22
|
-
var Size = _temp2.Size;
|
|
23
|
-
var Rect = _temp2.Rect;
|
|
24
|
-
var useCollectionState = _temp2.useCollectionState;
|
|
25
|
-
|
|
26
|
-
var _babelRuntimeHelpersObjectSpread = $parcel$interopDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
27
|
-
|
|
28
|
-
var _babelRuntimeHelpersSlicedToArray = $parcel$interopDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
29
|
-
|
|
30
|
-
var flushSync = require("react-dom").flushSync;
|
|
31
|
-
|
|
32
|
-
function $parcel$interopDefault(a) {
|
|
33
|
-
return a && a.__esModule ? a.default : a;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function useCollectionItem(options) {
|
|
37
|
-
var _options$reusableView = options.reusableView,
|
|
38
|
-
layoutInfo = _options$reusableView.layoutInfo,
|
|
39
|
-
collectionManager = _options$reusableView.collectionManager,
|
|
40
|
-
ref = options.ref;
|
|
41
|
-
var updateSize = useCallback(function () {
|
|
42
|
-
var size = $d4b7ca346532dc68037d455bd5$var$getSize(ref.current);
|
|
43
|
-
collectionManager.updateItemSize(layoutInfo.key, size);
|
|
44
|
-
}, [collectionManager, layoutInfo.key, ref]);
|
|
45
|
-
useLayoutEffect(function () {
|
|
46
|
-
if (layoutInfo.estimatedSize) {
|
|
47
|
-
updateSize();
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
return {
|
|
51
|
-
updateSize: updateSize
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
exports.useCollectionItem = useCollectionItem;
|
|
56
|
-
|
|
57
|
-
function $d4b7ca346532dc68037d455bd5$var$getSize(node) {
|
|
58
|
-
return new Size(node.scrollWidth, node.scrollHeight);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function CollectionItem(props) {
|
|
62
|
-
var reusableView = props.reusableView,
|
|
63
|
-
parent = props.parent;
|
|
64
|
-
var ref = useRef();
|
|
65
|
-
useCollectionItem({
|
|
66
|
-
reusableView: reusableView,
|
|
67
|
-
ref: ref
|
|
68
|
-
});
|
|
69
|
-
return (/*#__PURE__*/_react.createElement("div", {
|
|
70
|
-
role: "presentation",
|
|
71
|
-
ref: ref,
|
|
72
|
-
style: layoutInfoToStyle(reusableView.layoutInfo, parent && parent.layoutInfo)
|
|
73
|
-
}, reusableView.rendered)
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
exports.CollectionItem = CollectionItem;
|
|
78
|
-
|
|
79
|
-
function layoutInfoToStyle(layoutInfo, parent) {
|
|
80
|
-
return {
|
|
81
|
-
position: 'absolute',
|
|
82
|
-
overflow: 'hidden',
|
|
83
|
-
top: layoutInfo.rect.y - (parent ? parent.rect.y : 0),
|
|
84
|
-
left: layoutInfo.rect.x - (parent ? parent.rect.x : 0),
|
|
85
|
-
transition: 'all',
|
|
86
|
-
WebkitTransition: 'all',
|
|
87
|
-
WebkitTransitionDuration: 'inherit',
|
|
88
|
-
transitionDuration: 'inherit',
|
|
89
|
-
width: layoutInfo.rect.width + 'px',
|
|
90
|
-
height: layoutInfo.rect.height + 'px',
|
|
91
|
-
opacity: layoutInfo.opacity,
|
|
92
|
-
zIndex: layoutInfo.zIndex,
|
|
93
|
-
transform: layoutInfo.transform,
|
|
94
|
-
contain: 'size layout style paint'
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
exports.layoutInfoToStyle = layoutInfoToStyle;
|
|
99
|
-
|
|
100
|
-
function $bb7f3410d6ad6d6e4b89d1b5$var$ScrollView(props, ref) {
|
|
101
|
-
var contentSize = props.contentSize,
|
|
102
|
-
visibleRect = props.visibleRect,
|
|
103
|
-
onVisibleRectChange = props.onVisibleRectChange,
|
|
104
|
-
children = props.children,
|
|
105
|
-
innerStyle = props.innerStyle,
|
|
106
|
-
sizeToFit = props.sizeToFit,
|
|
107
|
-
onScrollStart = props.onScrollStart,
|
|
108
|
-
onScrollEnd = props.onScrollEnd,
|
|
109
|
-
_props$scrollDirectio = props.scrollDirection,
|
|
110
|
-
scrollDirection = _props$scrollDirectio === void 0 ? 'both' : _props$scrollDirectio,
|
|
111
|
-
otherProps = _babelRuntimeHelpersObjectWithoutProperties(props, ["contentSize", "visibleRect", "onVisibleRectChange", "children", "innerStyle", "sizeToFit", "onScrollStart", "onScrollEnd", "scrollDirection"]);
|
|
112
|
-
|
|
113
|
-
var defaultRef = useRef();
|
|
114
|
-
ref = ref || defaultRef;
|
|
115
|
-
var state = useRef({
|
|
116
|
-
scrollTop: 0,
|
|
117
|
-
scrollLeft: 0,
|
|
118
|
-
scrollEndTime: 0,
|
|
119
|
-
scrollTimeout: null,
|
|
120
|
-
width: 0,
|
|
121
|
-
height: 0
|
|
122
|
-
}).current;
|
|
123
|
-
|
|
124
|
-
var _useState = useState(false),
|
|
125
|
-
_useState2 = _babelRuntimeHelpersSlicedToArray(_useState, 2),
|
|
126
|
-
isScrolling = _useState2[0],
|
|
127
|
-
setScrolling = _useState2[1];
|
|
128
|
-
|
|
129
|
-
var onScroll = useCallback(function (e) {
|
|
130
|
-
flushSync(function () {
|
|
131
|
-
var _e$currentTarget = e.currentTarget,
|
|
132
|
-
scrollTop = _e$currentTarget.scrollTop,
|
|
133
|
-
scrollLeft = _e$currentTarget.scrollLeft,
|
|
134
|
-
scrollHeight = _e$currentTarget.scrollHeight,
|
|
135
|
-
scrollWidth = _e$currentTarget.scrollWidth,
|
|
136
|
-
clientHeight = _e$currentTarget.clientHeight,
|
|
137
|
-
clientWidth = _e$currentTarget.clientWidth; // Prevent rubber band scrolling from shaking when scrolling out of bounds
|
|
138
|
-
|
|
139
|
-
state.scrollTop = Math.max(0, Math.min(scrollTop, scrollHeight - clientHeight));
|
|
140
|
-
state.scrollLeft = Math.max(0, Math.min(scrollLeft, scrollWidth - clientWidth));
|
|
141
|
-
onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, state.width, state.height));
|
|
142
|
-
|
|
143
|
-
if (!isScrolling) {
|
|
144
|
-
setScrolling(true);
|
|
145
|
-
|
|
146
|
-
if (onScrollStart) {
|
|
147
|
-
onScrollStart();
|
|
148
|
-
}
|
|
149
|
-
} // So we don't constantly call clearTimeout and setTimeout,
|
|
150
|
-
// keep track of the current timeout time and only reschedule
|
|
151
|
-
// the timer when it is getting close.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
var now = Date.now();
|
|
155
|
-
|
|
156
|
-
if (state.scrollEndTime <= now + 50) {
|
|
157
|
-
state.scrollEndTime = now + 300;
|
|
158
|
-
clearTimeout(state.scrollTimeout);
|
|
159
|
-
state.scrollTimeout = setTimeout(function () {
|
|
160
|
-
setScrolling(false);
|
|
161
|
-
state.scrollTimeout = null;
|
|
162
|
-
|
|
163
|
-
if (onScrollEnd) {
|
|
164
|
-
onScrollEnd();
|
|
165
|
-
}
|
|
166
|
-
}, 300);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
}, [isScrolling, onScrollEnd, onScrollStart, onVisibleRectChange, state.height, state.scrollEndTime, state.scrollLeft, state.scrollTimeout, state.scrollTop, state.width]);
|
|
170
|
-
useEffect(function () {
|
|
171
|
-
// TODO: resize observer
|
|
172
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver
|
|
173
|
-
var updateSize = function updateSize() {
|
|
174
|
-
var dom = ref.current;
|
|
175
|
-
|
|
176
|
-
if (!dom) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
var w = dom.clientWidth;
|
|
181
|
-
var h = dom.clientHeight;
|
|
182
|
-
|
|
183
|
-
if (sizeToFit && contentSize.width > 0 && contentSize.height > 0) {
|
|
184
|
-
var _style = window.getComputedStyle(dom);
|
|
185
|
-
|
|
186
|
-
if (sizeToFit === 'width') {
|
|
187
|
-
w = contentSize.width;
|
|
188
|
-
var maxWidth = parseInt(_style.maxWidth, 10);
|
|
189
|
-
|
|
190
|
-
if (!isNaN(maxWidth)) {
|
|
191
|
-
w = Math.min(maxWidth, w);
|
|
192
|
-
}
|
|
193
|
-
} else if (sizeToFit === 'height') {
|
|
194
|
-
h = contentSize.height;
|
|
195
|
-
var maxHeight = parseInt(_style.maxHeight, 10);
|
|
196
|
-
|
|
197
|
-
if (!isNaN(maxHeight)) {
|
|
198
|
-
h = Math.min(maxHeight, h);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (state.width !== w || state.height !== h) {
|
|
204
|
-
state.width = w;
|
|
205
|
-
state.height = h;
|
|
206
|
-
onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, w, h));
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
updateSize();
|
|
211
|
-
window.addEventListener('resize', updateSize, false);
|
|
212
|
-
return function () {
|
|
213
|
-
window.removeEventListener('resize', updateSize, false);
|
|
214
|
-
};
|
|
215
|
-
}, [onVisibleRectChange, ref, state.height, state.scrollLeft, state.scrollTop, state.width, sizeToFit, contentSize.width, contentSize.height]);
|
|
216
|
-
useLayoutEffect(function () {
|
|
217
|
-
var dom = ref.current;
|
|
218
|
-
|
|
219
|
-
if (!dom) {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (visibleRect.x !== state.scrollLeft) {
|
|
224
|
-
state.scrollLeft = visibleRect.x;
|
|
225
|
-
dom.scrollLeft = visibleRect.x;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (visibleRect.y !== state.scrollTop) {
|
|
229
|
-
state.scrollTop = visibleRect.y;
|
|
230
|
-
dom.scrollTop = visibleRect.y;
|
|
231
|
-
}
|
|
232
|
-
}, [ref, state.scrollLeft, state.scrollTop, visibleRect.x, visibleRect.y]);
|
|
233
|
-
|
|
234
|
-
var style = _babelRuntimeHelpersObjectSpread({}, otherProps.style, {
|
|
235
|
-
position: 'relative',
|
|
236
|
-
// Reset padding so that relative positioning works correctly. Padding will be done in JS layout.
|
|
237
|
-
padding: 0
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
if (scrollDirection === 'horizontal') {
|
|
241
|
-
style.overflowX = 'auto';
|
|
242
|
-
style.overflowY = 'hidden';
|
|
243
|
-
} else if (scrollDirection === 'vertical') {
|
|
244
|
-
style.overflowY = 'auto';
|
|
245
|
-
style.overflowX = 'hidden';
|
|
246
|
-
} else {
|
|
247
|
-
style.overflow = 'auto';
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return (/*#__PURE__*/_react.createElement("div", _babelRuntimeHelpersExtends({}, otherProps, {
|
|
251
|
-
style: style,
|
|
252
|
-
ref: ref,
|
|
253
|
-
onScroll: onScroll
|
|
254
|
-
}), /*#__PURE__*/_react.createElement("div", {
|
|
255
|
-
role: "presentation",
|
|
256
|
-
style: _babelRuntimeHelpersObjectSpread({
|
|
257
|
-
width: contentSize.width,
|
|
258
|
-
height: contentSize.height,
|
|
259
|
-
pointerEvents: isScrolling ? 'none' : 'auto'
|
|
260
|
-
}, innerStyle)
|
|
261
|
-
}, children))
|
|
262
|
-
);
|
|
7
|
+
function $parcel$export(e, n, v, s) {
|
|
8
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
263
9
|
}
|
|
264
10
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
setVisibleRect = _useCollectionState.setVisibleRect,
|
|
286
|
-
contentSize = _useCollectionState.contentSize,
|
|
287
|
-
isAnimating = _useCollectionState.isAnimating,
|
|
288
|
-
collectionManager = _useCollectionState.collectionManager,
|
|
289
|
-
startScrolling = _useCollectionState.startScrolling,
|
|
290
|
-
endScrolling = _useCollectionState.endScrolling;
|
|
291
|
-
|
|
292
|
-
var fallbackRef = useRef();
|
|
293
|
-
ref = ref || fallbackRef; // Scroll to the focusedKey when it changes. Actually focusing the focusedKey
|
|
294
|
-
// is up to the implementation using CollectionView since we don't have refs
|
|
295
|
-
// to all of the item DOM nodes.
|
|
296
|
-
|
|
297
|
-
useEffect(function () {
|
|
298
|
-
if (focusedKey) {
|
|
299
|
-
collectionManager.scrollToItem(focusedKey, 0);
|
|
300
|
-
}
|
|
301
|
-
}, [focusedKey, collectionManager]);
|
|
302
|
-
var isFocusWithin = useRef(false);
|
|
303
|
-
var onFocus = useCallback(function (e) {
|
|
304
|
-
// If the focused item is scrolled out of view and is not in the DOM, the CollectionView
|
|
305
|
-
// will have tabIndex={0}. When tabbing in from outside, scroll the focused item into view.
|
|
306
|
-
// We only want to do this if the CollectionView itself is receiving focus, not a child
|
|
307
|
-
// element, and we aren't moving focus to the CollectionView from within (see below).
|
|
308
|
-
if (e.target === ref.current && !isFocusWithin.current) {
|
|
309
|
-
collectionManager.scrollToItem(focusedKey, 0);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
isFocusWithin.current = e.target !== ref.current;
|
|
313
|
-
}, [ref, collectionManager, focusedKey]);
|
|
314
|
-
var onBlur = useCallback(function (e) {
|
|
315
|
-
isFocusWithin.current = ref.current.contains(e.relatedTarget);
|
|
316
|
-
}, [ref]); // When the focused item is scrolled out of view and is removed from the DOM,
|
|
317
|
-
// move focus to the collection view as a whole if focus was within before.
|
|
11
|
+
$parcel$export(module.exports, "CollectionBuilder", () => $f20386e2aa690b4a$exports.CollectionBuilder);
|
|
12
|
+
$parcel$export(module.exports, "Collection", () => $f20386e2aa690b4a$exports.Collection);
|
|
13
|
+
$parcel$export(module.exports, "createLeafComponent", () => $f20386e2aa690b4a$exports.createLeafComponent);
|
|
14
|
+
$parcel$export(module.exports, "createBranchComponent", () => $f20386e2aa690b4a$exports.createBranchComponent);
|
|
15
|
+
$parcel$export(module.exports, "createHideableComponent", () => $eaaf60978b89fc58$exports.createHideableComponent);
|
|
16
|
+
$parcel$export(module.exports, "useIsHidden", () => $eaaf60978b89fc58$exports.useIsHidden);
|
|
17
|
+
$parcel$export(module.exports, "useCachedChildren", () => $245f3f827bea6653$exports.useCachedChildren);
|
|
18
|
+
$parcel$export(module.exports, "BaseCollection", () => $499e2959ba1abacc$exports.BaseCollection);
|
|
19
|
+
$parcel$export(module.exports, "NodeValue", () => $499e2959ba1abacc$exports.NodeValue);
|
|
20
|
+
/*
|
|
21
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
22
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
23
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
24
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
+
*
|
|
26
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
27
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
28
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
29
|
+
* governing permissions and limitations under the License.
|
|
30
|
+
*/
|
|
318
31
|
|
|
319
|
-
var focusedView = collectionManager.getItemView(focusedKey);
|
|
320
|
-
useEffect(function () {
|
|
321
|
-
if (focusedKey && !focusedView && isFocusWithin.current && document.activeElement !== ref.current) {
|
|
322
|
-
focusWithoutScrolling(ref.current);
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
return (/*#__PURE__*/_react.createElement($bb7f3410d6ad6d6e4b89d1b5$export$ScrollView, _babelRuntimeHelpersExtends({}, otherProps, {
|
|
326
|
-
tabIndex: focusedView ? -1 : 0,
|
|
327
|
-
ref: ref,
|
|
328
|
-
onFocus: chain(otherProps.onFocus, onFocus),
|
|
329
|
-
onBlur: chain(otherProps.onBlur, onBlur),
|
|
330
|
-
innerStyle: isAnimating ? {
|
|
331
|
-
transition: "none ".concat(collectionManager.transitionDuration, "ms")
|
|
332
|
-
} : undefined,
|
|
333
|
-
contentSize: contentSize,
|
|
334
|
-
visibleRect: visibleRect,
|
|
335
|
-
onVisibleRectChange: setVisibleRect,
|
|
336
|
-
onScrollStart: startScrolling,
|
|
337
|
-
onScrollEnd: endScrolling,
|
|
338
|
-
sizeToFit: sizeToFit,
|
|
339
|
-
scrollDirection: scrollDirection
|
|
340
|
-
}), visibleViews)
|
|
341
|
-
);
|
|
342
|
-
} // forwardRef doesn't support generic parameters, so cast the result to the correct type
|
|
343
|
-
// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref
|
|
344
32
|
|
|
345
33
|
|
|
346
|
-
var CollectionView = _react.forwardRef($deafe93e304fe800e7ccd55076d5eed$var$CollectionView);
|
|
347
34
|
|
|
348
|
-
exports.CollectionView = CollectionView;
|
|
349
35
|
|
|
350
|
-
|
|
351
|
-
return (/*#__PURE__*/_react.createElement(CollectionItem, {
|
|
352
|
-
key: reusableView.key,
|
|
353
|
-
reusableView: reusableView,
|
|
354
|
-
parent: parent
|
|
355
|
-
})
|
|
356
|
-
);
|
|
357
|
-
}
|
|
36
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/collections/src/index.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {CollectionBuilder, Collection, createLeafComponent, createBranchComponent} from './CollectionBuilder';\nexport {createHideableComponent, useIsHidden} from './Hidden';\nexport {useCachedChildren} from './useCachedChildren';\nexport {BaseCollection, NodeValue} from './BaseCollection';\n\nexport type {CollectionBuilderProps, CollectionProps} from './CollectionBuilder';\nexport type {CachedChildrenOptions} from './useCachedChildren';\n"],"names":[],"version":3,"file":"main.js.map"}
|