@react-aria/ssr 3.1.2-nightly.3111 → 3.1.2
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/main.js +23 -23
- package/dist/module.js +23 -23
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var $
|
|
1
|
+
var $8EJgg$react = require("react");
|
|
2
2
|
|
|
3
3
|
function $parcel$exportWildcard(dest, source) {
|
|
4
4
|
Object.keys(source).forEach(function(key) {
|
|
@@ -22,65 +22,65 @@ function $parcel$interopDefault(a) {
|
|
|
22
22
|
function $parcel$export(e, n, v, s) {
|
|
23
23
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
24
24
|
}
|
|
25
|
-
var $
|
|
25
|
+
var $dac019021ac61f1f$exports = {};
|
|
26
26
|
|
|
27
|
-
$parcel$export($
|
|
28
|
-
$parcel$export($
|
|
29
|
-
$parcel$export($
|
|
27
|
+
$parcel$export($dac019021ac61f1f$exports, "SSRProvider", () => $dac019021ac61f1f$export$9f8ac96af4b1b2ae);
|
|
28
|
+
$parcel$export($dac019021ac61f1f$exports, "useSSRSafeId", () => $dac019021ac61f1f$export$619500959fc48b26);
|
|
29
|
+
$parcel$export($dac019021ac61f1f$exports, "useIsSSR", () => $dac019021ac61f1f$export$535bd6ca7f90a273);
|
|
30
30
|
|
|
31
31
|
// Default context value to use in case there is no SSRProvider. This is fine for
|
|
32
32
|
// client-only apps. In order to support multiple copies of React Aria potentially
|
|
33
33
|
// being on the page at once, the prefix is set to a random number. SSRProvider
|
|
34
34
|
// will reset this to zero for consistency between server and client, so in the
|
|
35
35
|
// SSR case multiple copies of React Aria is not supported.
|
|
36
|
-
const $
|
|
36
|
+
const $dac019021ac61f1f$var$defaultContext = {
|
|
37
37
|
prefix: String(Math.round(Math.random() * 10000000000)),
|
|
38
38
|
current: 0
|
|
39
39
|
};
|
|
40
|
-
const $
|
|
41
|
-
function $
|
|
42
|
-
let cur = $
|
|
43
|
-
let value = $
|
|
40
|
+
const $dac019021ac61f1f$var$SSRContext = /*#__PURE__*/ ($parcel$interopDefault($8EJgg$react)).createContext($dac019021ac61f1f$var$defaultContext);
|
|
41
|
+
function $dac019021ac61f1f$export$9f8ac96af4b1b2ae(props) {
|
|
42
|
+
let cur = $8EJgg$react.useContext($dac019021ac61f1f$var$SSRContext);
|
|
43
|
+
let value = $8EJgg$react.useMemo(()=>({
|
|
44
44
|
// If this is the first SSRProvider, start with an empty string prefix, otherwise
|
|
45
45
|
// append and increment the counter.
|
|
46
|
-
prefix: cur === $
|
|
46
|
+
prefix: cur === $dac019021ac61f1f$var$defaultContext ? '' : `${cur.prefix}-${++cur.current}`,
|
|
47
47
|
current: 0
|
|
48
48
|
})
|
|
49
49
|
, [
|
|
50
50
|
cur
|
|
51
51
|
]);
|
|
52
|
-
return(/*#__PURE__*/ ($parcel$interopDefault($
|
|
52
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($8EJgg$react)).createElement($dac019021ac61f1f$var$SSRContext.Provider, {
|
|
53
53
|
value: value
|
|
54
54
|
}, props.children));
|
|
55
55
|
}
|
|
56
|
-
let $
|
|
57
|
-
function $
|
|
58
|
-
let ctx = $
|
|
56
|
+
let $dac019021ac61f1f$var$canUseDOM = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
57
|
+
function $dac019021ac61f1f$export$619500959fc48b26(defaultId) {
|
|
58
|
+
let ctx = $8EJgg$react.useContext($dac019021ac61f1f$var$SSRContext);
|
|
59
59
|
// If we are rendering in a non-DOM environment, and there's no SSRProvider,
|
|
60
60
|
// provide a warning to hint to the developer to add one.
|
|
61
|
-
if (ctx === $
|
|
62
|
-
return $
|
|
61
|
+
if (ctx === $dac019021ac61f1f$var$defaultContext && !$dac019021ac61f1f$var$canUseDOM) console.warn('When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.');
|
|
62
|
+
return $8EJgg$react.useMemo(()=>defaultId || `react-aria${ctx.prefix}-${++ctx.current}`
|
|
63
63
|
, [
|
|
64
64
|
defaultId
|
|
65
65
|
]);
|
|
66
66
|
}
|
|
67
|
-
function $
|
|
68
|
-
let cur = $
|
|
69
|
-
let isInSSRContext = cur !== $
|
|
70
|
-
let [isSSR, setIsSSR] = $
|
|
67
|
+
function $dac019021ac61f1f$export$535bd6ca7f90a273() {
|
|
68
|
+
let cur = $8EJgg$react.useContext($dac019021ac61f1f$var$SSRContext);
|
|
69
|
+
let isInSSRContext = cur !== $dac019021ac61f1f$var$defaultContext;
|
|
70
|
+
let [isSSR, setIsSSR] = $8EJgg$react.useState(isInSSRContext);
|
|
71
71
|
// If on the client, and the component was initially server rendered,
|
|
72
72
|
// then schedule a layout effect to update the component after hydration.
|
|
73
73
|
if (typeof window !== 'undefined' && isInSSRContext) // This if statement technically breaks the rules of hooks, but is safe
|
|
74
74
|
// because the condition never changes after mounting.
|
|
75
75
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
76
|
-
$
|
|
76
|
+
$8EJgg$react.useLayoutEffect(()=>{
|
|
77
77
|
setIsSSR(false);
|
|
78
78
|
}, []);
|
|
79
79
|
return isSSR;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
$parcel$exportWildcard(module.exports, $
|
|
83
|
+
$parcel$exportWildcard(module.exports, $dac019021ac61f1f$exports);
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
//# sourceMappingURL=main.js.map
|
package/dist/module.js
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import $
|
|
1
|
+
import $cgWTI$react, {useContext as $cgWTI$useContext, useMemo as $cgWTI$useMemo, useState as $cgWTI$useState, useLayoutEffect as $cgWTI$useLayoutEffect} from "react";
|
|
2
2
|
|
|
3
3
|
function $parcel$export(e, n, v, s) {
|
|
4
4
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
5
5
|
}
|
|
6
|
-
var $
|
|
6
|
+
var $9d939cbc98267846$exports = {};
|
|
7
7
|
|
|
8
|
-
$parcel$export($
|
|
9
|
-
$parcel$export($
|
|
10
|
-
$parcel$export($
|
|
8
|
+
$parcel$export($9d939cbc98267846$exports, "SSRProvider", () => $9d939cbc98267846$export$9f8ac96af4b1b2ae);
|
|
9
|
+
$parcel$export($9d939cbc98267846$exports, "useSSRSafeId", () => $9d939cbc98267846$export$619500959fc48b26);
|
|
10
|
+
$parcel$export($9d939cbc98267846$exports, "useIsSSR", () => $9d939cbc98267846$export$535bd6ca7f90a273);
|
|
11
11
|
|
|
12
12
|
// Default context value to use in case there is no SSRProvider. This is fine for
|
|
13
13
|
// client-only apps. In order to support multiple copies of React Aria potentially
|
|
14
14
|
// being on the page at once, the prefix is set to a random number. SSRProvider
|
|
15
15
|
// will reset this to zero for consistency between server and client, so in the
|
|
16
16
|
// SSR case multiple copies of React Aria is not supported.
|
|
17
|
-
const $
|
|
17
|
+
const $9d939cbc98267846$var$defaultContext = {
|
|
18
18
|
prefix: String(Math.round(Math.random() * 10000000000)),
|
|
19
19
|
current: 0
|
|
20
20
|
};
|
|
21
|
-
const $
|
|
22
|
-
function $
|
|
23
|
-
let cur = $
|
|
24
|
-
let value = $
|
|
21
|
+
const $9d939cbc98267846$var$SSRContext = /*#__PURE__*/ $cgWTI$react.createContext($9d939cbc98267846$var$defaultContext);
|
|
22
|
+
function $9d939cbc98267846$export$9f8ac96af4b1b2ae(props) {
|
|
23
|
+
let cur = $cgWTI$useContext($9d939cbc98267846$var$SSRContext);
|
|
24
|
+
let value = $cgWTI$useMemo(()=>({
|
|
25
25
|
// If this is the first SSRProvider, start with an empty string prefix, otherwise
|
|
26
26
|
// append and increment the counter.
|
|
27
|
-
prefix: cur === $
|
|
27
|
+
prefix: cur === $9d939cbc98267846$var$defaultContext ? '' : `${cur.prefix}-${++cur.current}`,
|
|
28
28
|
current: 0
|
|
29
29
|
})
|
|
30
30
|
, [
|
|
31
31
|
cur
|
|
32
32
|
]);
|
|
33
|
-
return(/*#__PURE__*/ $
|
|
33
|
+
return(/*#__PURE__*/ $cgWTI$react.createElement($9d939cbc98267846$var$SSRContext.Provider, {
|
|
34
34
|
value: value
|
|
35
35
|
}, props.children));
|
|
36
36
|
}
|
|
37
|
-
let $
|
|
38
|
-
function $
|
|
39
|
-
let ctx = $
|
|
37
|
+
let $9d939cbc98267846$var$canUseDOM = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
38
|
+
function $9d939cbc98267846$export$619500959fc48b26(defaultId) {
|
|
39
|
+
let ctx = $cgWTI$useContext($9d939cbc98267846$var$SSRContext);
|
|
40
40
|
// If we are rendering in a non-DOM environment, and there's no SSRProvider,
|
|
41
41
|
// provide a warning to hint to the developer to add one.
|
|
42
|
-
if (ctx === $
|
|
43
|
-
return $
|
|
42
|
+
if (ctx === $9d939cbc98267846$var$defaultContext && !$9d939cbc98267846$var$canUseDOM) console.warn('When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.');
|
|
43
|
+
return $cgWTI$useMemo(()=>defaultId || `react-aria${ctx.prefix}-${++ctx.current}`
|
|
44
44
|
, [
|
|
45
45
|
defaultId
|
|
46
46
|
]);
|
|
47
47
|
}
|
|
48
|
-
function $
|
|
49
|
-
let cur = $
|
|
50
|
-
let isInSSRContext = cur !== $
|
|
51
|
-
let [isSSR, setIsSSR] = $
|
|
48
|
+
function $9d939cbc98267846$export$535bd6ca7f90a273() {
|
|
49
|
+
let cur = $cgWTI$useContext($9d939cbc98267846$var$SSRContext);
|
|
50
|
+
let isInSSRContext = cur !== $9d939cbc98267846$var$defaultContext;
|
|
51
|
+
let [isSSR, setIsSSR] = $cgWTI$useState(isInSSRContext);
|
|
52
52
|
// If on the client, and the component was initially server rendered,
|
|
53
53
|
// then schedule a layout effect to update the component after hydration.
|
|
54
54
|
if (typeof window !== 'undefined' && isInSSRContext) // This if statement technically breaks the rules of hooks, but is safe
|
|
55
55
|
// because the condition never changes after mounting.
|
|
56
56
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
57
|
-
$
|
|
57
|
+
$cgWTI$useLayoutEffect(()=>{
|
|
58
58
|
setIsSSR(false);
|
|
59
59
|
}, []);
|
|
60
60
|
return isSSR;
|
|
@@ -63,5 +63,5 @@ function $6f523efd7517f7a2$export$535bd6ca7f90a273() {
|
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
export {$
|
|
66
|
+
export {$9d939cbc98267846$export$9f8ac96af4b1b2ae as SSRProvider, $9d939cbc98267846$export$619500959fc48b26 as useSSRSafeId, $9d939cbc98267846$export$535bd6ca7f90a273 as useIsSSR};
|
|
67
67
|
//# sourceMappingURL=module.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/ssr",
|
|
3
|
-
"version": "3.1.2
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "404d41859b7d6f56201d7fc01bd9f22ae3512937"
|
|
29
29
|
}
|