@tamagui/web 1.121.1 → 1.121.3
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/cjs/defaultComponentState.cjs +6 -1
- package/dist/cjs/defaultComponentState.js +5 -1
- package/dist/cjs/defaultComponentState.js.map +1 -1
- package/dist/cjs/defaultComponentState.native.js +7 -2
- package/dist/cjs/defaultComponentState.native.js.map +2 -2
- package/dist/cjs/hooks/useComponentState.cjs +10 -8
- package/dist/cjs/hooks/useComponentState.js +6 -6
- package/dist/cjs/hooks/useComponentState.js.map +1 -1
- package/dist/cjs/hooks/useComponentState.native.js +6 -6
- package/dist/cjs/hooks/useComponentState.native.js.map +2 -2
- package/dist/cjs/hooks/useIsHydrated.cjs +28 -0
- package/dist/cjs/hooks/useIsHydrated.js +27 -0
- package/dist/cjs/hooks/useIsHydrated.js.map +6 -0
- package/dist/cjs/hooks/useIsHydrated.native.js +35 -0
- package/dist/cjs/hooks/useIsHydrated.native.js.map +6 -0
- package/dist/esm/defaultComponentState.js +5 -1
- package/dist/esm/defaultComponentState.js.map +1 -1
- package/dist/esm/defaultComponentState.mjs +5 -1
- package/dist/esm/defaultComponentState.mjs.map +1 -1
- package/dist/esm/defaultComponentState.native.js +5 -1
- package/dist/esm/defaultComponentState.native.js.map +2 -2
- package/dist/esm/hooks/useComponentState.js +8 -6
- package/dist/esm/hooks/useComponentState.js.map +1 -1
- package/dist/esm/hooks/useComponentState.mjs +10 -8
- package/dist/esm/hooks/useComponentState.mjs.map +1 -1
- package/dist/esm/hooks/useComponentState.native.js +7 -6
- package/dist/esm/hooks/useComponentState.native.js.map +2 -2
- package/dist/esm/hooks/useIsHydrated.js +11 -0
- package/dist/esm/hooks/useIsHydrated.js.map +6 -0
- package/dist/esm/hooks/useIsHydrated.mjs +5 -0
- package/dist/esm/hooks/useIsHydrated.mjs.map +1 -0
- package/dist/esm/hooks/useIsHydrated.native.js +15 -0
- package/dist/esm/hooks/useIsHydrated.native.js.map +6 -0
- package/package.json +11 -11
- package/src/defaultComponentState.tsx +5 -0
- package/src/hooks/useComponentState.ts +10 -10
- package/src/hooks/useIsHydrated.ts +13 -0
- package/types/defaultComponentState.d.ts +1 -0
- package/types/defaultComponentState.d.ts.map +1 -1
- package/types/hooks/useComponentState.d.ts.map +1 -1
- package/types/hooks/useIsHydrated.d.ts +2 -0
- package/types/hooks/useIsHydrated.d.ts.map +1 -0
|
@@ -21,7 +21,8 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
21
21
|
var defaultComponentState_exports = {};
|
|
22
22
|
__export(defaultComponentState_exports, {
|
|
23
23
|
defaultComponentState: () => defaultComponentState,
|
|
24
|
-
defaultComponentStateMounted: () => defaultComponentStateMounted
|
|
24
|
+
defaultComponentStateMounted: () => defaultComponentStateMounted,
|
|
25
|
+
defaultComponentStateShouldEnter: () => defaultComponentStateShouldEnter
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(defaultComponentState_exports);
|
|
27
28
|
const defaultComponentState = {
|
|
@@ -36,4 +37,8 @@ const defaultComponentState = {
|
|
|
36
37
|
defaultComponentStateMounted = {
|
|
37
38
|
...defaultComponentState,
|
|
38
39
|
unmounted: !1
|
|
40
|
+
},
|
|
41
|
+
defaultComponentStateShouldEnter = {
|
|
42
|
+
...defaultComponentState,
|
|
43
|
+
unmounted: "should-enter"
|
|
39
44
|
};
|
|
@@ -15,7 +15,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0
|
|
|
15
15
|
var defaultComponentState_exports = {};
|
|
16
16
|
__export(defaultComponentState_exports, {
|
|
17
17
|
defaultComponentState: () => defaultComponentState,
|
|
18
|
-
defaultComponentStateMounted: () => defaultComponentStateMounted
|
|
18
|
+
defaultComponentStateMounted: () => defaultComponentStateMounted,
|
|
19
|
+
defaultComponentStateShouldEnter: () => defaultComponentStateShouldEnter
|
|
19
20
|
});
|
|
20
21
|
module.exports = __toCommonJS(defaultComponentState_exports);
|
|
21
22
|
const defaultComponentState = {
|
|
@@ -29,5 +30,8 @@ const defaultComponentState = {
|
|
|
29
30
|
}, defaultComponentStateMounted = {
|
|
30
31
|
...defaultComponentState,
|
|
31
32
|
unmounted: !1
|
|
33
|
+
}, defaultComponentStateShouldEnter = {
|
|
34
|
+
...defaultComponentState,
|
|
35
|
+
unmounted: "should-enter"
|
|
32
36
|
};
|
|
33
37
|
//# sourceMappingURL=defaultComponentState.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/defaultComponentState.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,wBAA+C;AAAA,EAC1D,OAAO;AAAA,EACP,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO;AAAA,EACP,cAAc;AAAA,EACd,WAAW;AAAA,EACX,UAAU;AACZ,GAEa,+BAAsD;AAAA,EACjE,GAAG;AAAA,EACH,WAAW;AACb;",
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,wBAA+C;AAAA,EAC1D,OAAO;AAAA,EACP,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO;AAAA,EACP,cAAc;AAAA,EACd,WAAW;AAAA,EACX,UAAU;AACZ,GAEa,+BAAsD;AAAA,EACjE,GAAG;AAAA,EACH,WAAW;AACb,GAEa,mCAA0D;AAAA,EACrE,GAAG;AAAA,EACH,WAAW;AACb;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -16,7 +16,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0
|
|
|
16
16
|
var defaultComponentState_exports = {};
|
|
17
17
|
__export(defaultComponentState_exports, {
|
|
18
18
|
defaultComponentState: () => defaultComponentState,
|
|
19
|
-
defaultComponentStateMounted: () => defaultComponentStateMounted
|
|
19
|
+
defaultComponentStateMounted: () => defaultComponentStateMounted,
|
|
20
|
+
defaultComponentStateShouldEnter: () => defaultComponentStateShouldEnter
|
|
20
21
|
});
|
|
21
22
|
module.exports = __toCommonJS(defaultComponentState_exports);
|
|
22
23
|
var defaultComponentState = {
|
|
@@ -30,10 +31,14 @@ var defaultComponentState = {
|
|
|
30
31
|
}, defaultComponentStateMounted = {
|
|
31
32
|
...defaultComponentState,
|
|
32
33
|
unmounted: !1
|
|
34
|
+
}, defaultComponentStateShouldEnter = {
|
|
35
|
+
...defaultComponentState,
|
|
36
|
+
unmounted: "should-enter"
|
|
33
37
|
};
|
|
34
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
35
39
|
0 && (module.exports = {
|
|
36
40
|
defaultComponentState,
|
|
37
|
-
defaultComponentStateMounted
|
|
41
|
+
defaultComponentStateMounted,
|
|
42
|
+
defaultComponentStateShouldEnter
|
|
38
43
|
});
|
|
39
44
|
//# sourceMappingURL=defaultComponentState.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/web/src/defaultComponentState.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;AAEA
|
|
5
|
-
"names": ["defaultComponentState", "hover", "press", "pressIn", "focus", "focusVisible", "unmounted", "disabled", "defaultComponentStateMounted"]
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAEA;;;;;;;AAAO,IAAMA,wBAA+C;EAC1DC,OAAO;EACPC,OAAO;EACPC,SAAS;EACTC,OAAO;EACPC,cAAc;EACdC,WAAW;EACXC,UAAU;AACZ,GAEaC,+BAAsD;EACjE,GAAGR;EACHM,WAAW;AACb,GAEaG,mCAA0D;EACrE,GAAGT;EACHM,WAAW;AACb;",
|
|
5
|
+
"names": ["defaultComponentState", "hover", "press", "pressIn", "focus", "focusVisible", "unmounted", "disabled", "defaultComponentStateMounted", "defaultComponentStateShouldEnter"]
|
|
6
6
|
}
|
|
@@ -28,12 +28,14 @@ var import_constants = require("@tamagui/constants"),
|
|
|
28
28
|
import_defaultComponentState = require("../defaultComponentState.cjs"),
|
|
29
29
|
import_createShallowSetState = require("../helpers/createShallowSetState.cjs"),
|
|
30
30
|
import_isObj = require("../helpers/isObj.cjs"),
|
|
31
|
-
import_log = require("../helpers/log.cjs")
|
|
31
|
+
import_log = require("../helpers/log.cjs"),
|
|
32
|
+
import_useIsHydrated = require("./useIsHydrated.cjs");
|
|
32
33
|
const useComponentState = (props, {
|
|
33
34
|
animationDriver,
|
|
34
35
|
groups
|
|
35
36
|
}, staticConfig, config) => {
|
|
36
|
-
const
|
|
37
|
+
const isHydrated = (0, import_useIsHydrated.useIsHydrated)(),
|
|
38
|
+
useAnimations = animationDriver?.useAnimations,
|
|
37
39
|
stateRef = (0, import_react.useRef)(void 0);
|
|
38
40
|
stateRef.current || (stateRef.current = {});
|
|
39
41
|
const hasAnimationProp = !!("animation" in props || props.style && hasAnimatedStyleValue(props.style)),
|
|
@@ -50,8 +52,9 @@ const useComponentState = (props, {
|
|
|
50
52
|
isExiting = presenceState?.isPresent === !1,
|
|
51
53
|
isEntering = presenceState?.isPresent === !0 && presenceState.initial !== !1,
|
|
52
54
|
hasEnterStyle = !!props.enterStyle,
|
|
53
|
-
hasAnimationThatNeedsHydrate = hasAnimationProp && (animationDriver?.isReactNative || !supportsCSSVars),
|
|
54
|
-
|
|
55
|
+
hasAnimationThatNeedsHydrate = hasAnimationProp && !isHydrated && (animationDriver?.isReactNative || !supportsCSSVars),
|
|
56
|
+
hasEnterState = hasEnterStyle || isEntering,
|
|
57
|
+
initialState = hasEnterState || hasAnimationThatNeedsHydrate ||
|
|
55
58
|
// disableClassName doesnt work server side, only client, so needs hydrate
|
|
56
59
|
// this is just for a better ux, supports css variables for light/dark, media queries, etc
|
|
57
60
|
disableClassName ?
|
|
@@ -60,7 +63,7 @@ const useComponentState = (props, {
|
|
|
60
63
|
// without flickers of the wrong colors.
|
|
61
64
|
// but once we do that initial hydration and we are in client side rendering mode,
|
|
62
65
|
// we can avoid the extra re-render on mount
|
|
63
|
-
import_defaultComponentState.defaultComponentState : import_defaultComponentState.defaultComponentStateMounted,
|
|
66
|
+
hasEnterState ? import_defaultComponentState.defaultComponentStateShouldEnter : import_defaultComponentState.defaultComponentState : import_defaultComponentState.defaultComponentStateMounted,
|
|
64
67
|
disabled = isDisabled(props);
|
|
65
68
|
disabled != null && (initialState.disabled = disabled);
|
|
66
69
|
const states = (0, import_react.useState)(initialState),
|
|
@@ -68,10 +71,9 @@ const useComponentState = (props, {
|
|
|
68
71
|
...states[0],
|
|
69
72
|
[props.forceStyle]: !0
|
|
70
73
|
} : states[0],
|
|
71
|
-
setState = states[1]
|
|
72
|
-
isHydrated = state.unmounted === !1;
|
|
74
|
+
setState = states[1];
|
|
73
75
|
let isAnimated = willBeAnimated;
|
|
74
|
-
import_constants.isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC &&
|
|
76
|
+
import_constants.isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated && (isAnimated = !1, curStateRef.willHydrate = !0), disabled !== state.disabled && (state.disabled = disabled, disabled && Object.assign(state, import_defaultComponentState.defaultComponentStateMounted), setState({
|
|
75
77
|
...state
|
|
76
78
|
}));
|
|
77
79
|
let setStateShallow = (0, import_createShallowSetState.createShallowSetState)(setState, disabled, !1, props.debug);
|
|
@@ -17,15 +17,15 @@ __export(useComponentState_exports, {
|
|
|
17
17
|
useComponentState: () => useComponentState
|
|
18
18
|
});
|
|
19
19
|
module.exports = __toCommonJS(useComponentState_exports);
|
|
20
|
-
var import_constants = require("@tamagui/constants"), import_react = require("react"), import_defaultComponentState = require("../defaultComponentState"), import_createShallowSetState = require("../helpers/createShallowSetState"), import_isObj = require("../helpers/isObj"), import_log = require("../helpers/log");
|
|
20
|
+
var import_constants = require("@tamagui/constants"), import_react = require("react"), import_defaultComponentState = require("../defaultComponentState"), import_createShallowSetState = require("../helpers/createShallowSetState"), import_isObj = require("../helpers/isObj"), import_log = require("../helpers/log"), import_useIsHydrated = require("./useIsHydrated");
|
|
21
21
|
const useComponentState = (props, { animationDriver, groups }, staticConfig, config) => {
|
|
22
|
-
const useAnimations = animationDriver?.useAnimations, stateRef = (0, import_react.useRef)(
|
|
22
|
+
const isHydrated = (0, import_useIsHydrated.useIsHydrated)(), useAnimations = animationDriver?.useAnimations, stateRef = (0, import_react.useRef)(
|
|
23
23
|
void 0
|
|
24
24
|
);
|
|
25
25
|
stateRef.current || (stateRef.current = {});
|
|
26
26
|
const hasAnimationProp = !!("animation" in props || props.style && hasAnimatedStyleValue(props.style)), supportsCSSVars = animationDriver?.supportsCSSVars, curStateRef = stateRef.current, willBeAnimatedClient = !!(!!(hasAnimationProp && !staticConfig.isHOC && useAnimations) || curStateRef.hasAnimated), willBeAnimated = !import_constants.isServer && willBeAnimatedClient;
|
|
27
27
|
willBeAnimated && !curStateRef.hasAnimated && (curStateRef.hasAnimated = !0);
|
|
28
|
-
const { disableClassName } = props, presence = willBeAnimated && props.animatePresence !== !1 && animationDriver?.usePresence?.() || null, presenceState = presence?.[2], isExiting = presenceState?.isPresent === !1, isEntering = presenceState?.isPresent === !0 && presenceState.initial !== !1, hasEnterStyle = !!props.enterStyle, hasAnimationThatNeedsHydrate = hasAnimationProp && (animationDriver?.isReactNative || !supportsCSSVars),
|
|
28
|
+
const { disableClassName } = props, presence = willBeAnimated && props.animatePresence !== !1 && animationDriver?.usePresence?.() || null, presenceState = presence?.[2], isExiting = presenceState?.isPresent === !1, isEntering = presenceState?.isPresent === !0 && presenceState.initial !== !1, hasEnterStyle = !!props.enterStyle, hasAnimationThatNeedsHydrate = hasAnimationProp && !isHydrated && (animationDriver?.isReactNative || !supportsCSSVars), hasEnterState = hasEnterStyle || isEntering, initialState = hasEnterState || hasAnimationThatNeedsHydrate || // disableClassName doesnt work server side, only client, so needs hydrate
|
|
29
29
|
// this is just for a better ux, supports css variables for light/dark, media queries, etc
|
|
30
30
|
disableClassName ? (
|
|
31
31
|
// on the very first render we switch all spring animation drivers to css rendering
|
|
@@ -33,12 +33,12 @@ const useComponentState = (props, { animationDriver, groups }, staticConfig, con
|
|
|
33
33
|
// without flickers of the wrong colors.
|
|
34
34
|
// but once we do that initial hydration and we are in client side rendering mode,
|
|
35
35
|
// we can avoid the extra re-render on mount
|
|
36
|
-
import_defaultComponentState.defaultComponentState
|
|
36
|
+
hasEnterState ? import_defaultComponentState.defaultComponentStateShouldEnter : import_defaultComponentState.defaultComponentState
|
|
37
37
|
) : import_defaultComponentState.defaultComponentStateMounted, disabled = isDisabled(props);
|
|
38
38
|
disabled != null && (initialState.disabled = disabled);
|
|
39
|
-
const states = (0, import_react.useState)(initialState), state = props.forceStyle ? { ...states[0], [props.forceStyle]: !0 } : states[0], setState = states[1]
|
|
39
|
+
const states = (0, import_react.useState)(initialState), state = props.forceStyle ? { ...states[0], [props.forceStyle]: !0 } : states[0], setState = states[1];
|
|
40
40
|
let isAnimated = willBeAnimated;
|
|
41
|
-
import_constants.isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC &&
|
|
41
|
+
import_constants.isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated && (isAnimated = !1, curStateRef.willHydrate = !0), disabled !== state.disabled && (state.disabled = disabled, disabled && Object.assign(state, import_defaultComponentState.defaultComponentStateMounted), setState({ ...state }));
|
|
42
42
|
let setStateShallow = (0, import_createShallowSetState.createShallowSetState)(setState, disabled, !1, props.debug);
|
|
43
43
|
if (presenceState && isAnimated && isHydrated && staticConfig.variants) {
|
|
44
44
|
process.env.NODE_ENV === "development" && props.debug === "verbose" && console.warn(`has presenceState ${JSON.stringify(presenceState)}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useComponentState.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;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AAM,oBAAoB,YAC1B,MAAM,eAAe,KACrB,MAAM,yBACN;",
|
|
5
5
|
"names": ["state"]
|
|
6
6
|
}
|
|
@@ -18,15 +18,15 @@ __export(useComponentState_exports, {
|
|
|
18
18
|
useComponentState: () => useComponentState
|
|
19
19
|
});
|
|
20
20
|
module.exports = __toCommonJS(useComponentState_exports);
|
|
21
|
-
var import_constants = require("@tamagui/constants"), import_react = require("react"), import_defaultComponentState = require("../defaultComponentState"), import_createShallowSetState = require("../helpers/createShallowSetState"), import_isObj = require("../helpers/isObj"), import_log = require("../helpers/log"), useComponentState = function(props, param, staticConfig, config) {
|
|
22
|
-
var { animationDriver, groups } = param, _animationDriver_usePresence, useAnimations = animationDriver == null ? void 0 : animationDriver.useAnimations, stateRef = (0, import_react.useRef)(void 0);
|
|
21
|
+
var import_constants = require("@tamagui/constants"), import_react = require("react"), import_defaultComponentState = require("../defaultComponentState"), import_createShallowSetState = require("../helpers/createShallowSetState"), import_isObj = require("../helpers/isObj"), import_log = require("../helpers/log"), import_useIsHydrated = require("./useIsHydrated"), useComponentState = function(props, param, staticConfig, config) {
|
|
22
|
+
var { animationDriver, groups } = param, _animationDriver_usePresence, isHydrated = (0, import_useIsHydrated.useIsHydrated)(), useAnimations = animationDriver == null ? void 0 : animationDriver.useAnimations, stateRef = (0, import_react.useRef)(void 0);
|
|
23
23
|
stateRef.current || (stateRef.current = {});
|
|
24
24
|
var hasAnimationProp = !!("animation" in props || props.style && hasAnimatedStyleValue(props.style)), supportsCSSVars = animationDriver == null ? void 0 : animationDriver.supportsCSSVars, curStateRef = stateRef.current, willBeAnimatedClient = function() {
|
|
25
25
|
var next = !!(hasAnimationProp && !staticConfig.isHOC && useAnimations);
|
|
26
26
|
return !!(next || curStateRef.hasAnimated);
|
|
27
27
|
}(), willBeAnimated = !import_constants.isServer && willBeAnimatedClient;
|
|
28
28
|
willBeAnimated && !curStateRef.hasAnimated && (curStateRef.hasAnimated = !0);
|
|
29
|
-
var { disableClassName } = props, presence = willBeAnimated && props.animatePresence !== !1 && (animationDriver == null || (_animationDriver_usePresence = animationDriver.usePresence) === null || _animationDriver_usePresence === void 0 ? void 0 : _animationDriver_usePresence.call(animationDriver)) || null, presenceState = presence == null ? void 0 : presence[2], isExiting = (presenceState == null ? void 0 : presenceState.isPresent) === !1, isEntering = (presenceState == null ? void 0 : presenceState.isPresent) === !0 && presenceState.initial !== !1, hasEnterStyle = !!props.enterStyle, hasAnimationThatNeedsHydrate = hasAnimationProp && ((animationDriver == null ? void 0 : animationDriver.isReactNative) || !supportsCSSVars), hasEnterState = hasEnterStyle || isEntering, shouldEnter = hasEnterState || hasAnimationThatNeedsHydrate || // disableClassName doesnt work server side, only client, so needs hydrate
|
|
29
|
+
var { disableClassName } = props, presence = willBeAnimated && props.animatePresence !== !1 && (animationDriver == null || (_animationDriver_usePresence = animationDriver.usePresence) === null || _animationDriver_usePresence === void 0 ? void 0 : _animationDriver_usePresence.call(animationDriver)) || null, presenceState = presence == null ? void 0 : presence[2], isExiting = (presenceState == null ? void 0 : presenceState.isPresent) === !1, isEntering = (presenceState == null ? void 0 : presenceState.isPresent) === !0 && presenceState.initial !== !1, hasEnterStyle = !!props.enterStyle, hasAnimationThatNeedsHydrate = hasAnimationProp && !isHydrated && ((animationDriver == null ? void 0 : animationDriver.isReactNative) || !supportsCSSVars), hasEnterState = hasEnterStyle || isEntering, shouldEnter = hasEnterState || hasAnimationThatNeedsHydrate || // disableClassName doesnt work server side, only client, so needs hydrate
|
|
30
30
|
// this is just for a better ux, supports css variables for light/dark, media queries, etc
|
|
31
31
|
disableClassName, initialState = shouldEnter ? (
|
|
32
32
|
// on the very first render we switch all spring animation drivers to css rendering
|
|
@@ -34,14 +34,14 @@ var import_constants = require("@tamagui/constants"), import_react = require("re
|
|
|
34
34
|
// without flickers of the wrong colors.
|
|
35
35
|
// but once we do that initial hydration and we are in client side rendering mode,
|
|
36
36
|
// we can avoid the extra re-render on mount
|
|
37
|
-
import_defaultComponentState.defaultComponentState
|
|
37
|
+
hasEnterState ? import_defaultComponentState.defaultComponentStateShouldEnter : import_defaultComponentState.defaultComponentState
|
|
38
38
|
) : import_defaultComponentState.defaultComponentStateMounted, disabled = isDisabled(props);
|
|
39
39
|
disabled != null && (initialState.disabled = disabled);
|
|
40
40
|
var states = (0, import_react.useState)(initialState), state = props.forceStyle ? {
|
|
41
41
|
...states[0],
|
|
42
42
|
[props.forceStyle]: !0
|
|
43
|
-
} : states[0], setState = states[1],
|
|
44
|
-
import_constants.isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC &&
|
|
43
|
+
} : states[0], setState = states[1], isAnimated = willBeAnimated;
|
|
44
|
+
import_constants.isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated && (isAnimated = !1, curStateRef.willHydrate = !0), disabled !== state.disabled && (state.disabled = disabled, disabled && Object.assign(state, import_defaultComponentState.defaultComponentStateMounted), setState({
|
|
45
45
|
...state
|
|
46
46
|
}));
|
|
47
47
|
var setStateShallow = (0, import_createShallowSetState.createShallowSetState)(setState, disabled, !1, props.debug);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/Users/n8/tamagui/code/core/web/src/hooks/useComponentState.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;;;;;uBAAgC,+BAChC,eAAiC,kBACjC,+
|
|
5
|
-
"names": ["useComponentState", "props", "staticConfig", "config", "animationDriver", "groups", "useAnimations", "stateRef", "useRef", "undefined", "current", "hasAnimationProp", "Boolean", "style", "hasAnimatedStyleValue", "supportsCSSVars", "curStateRef", "willBeAnimatedClient", "next", "isHOC", "hasAnimated", "willBeAnimated", "isServer", "disableClassName", "presence", "usePresence", "presenceState", "isExiting", "isPresent", "isEntering", "initial", "hasEnterStyle", "enterStyle", "hasAnimationThatNeedsHydrate", "isReactNative", "hasEnterState", "shouldEnter", "initialState", "defaultComponentState", "defaultComponentStateMounted",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;QACrB,GAAGjC;MACL;AACA6C,wBAAkBZ,SAAAA,IAAa5D;IACjC;EACF;AAEA,SAAO;IACLF;IACAyB;IACAqC;IACAnE;IACAoB;IACAiB;IACArB;IACAvB;IACAoB;IACAE;IACAqB;IACAM;IACAkB;IACA1B;IACAtC;IACAQ;IACAM;IACAJ;EACF;AACF;AAEA,SAASH,sBAAsBD,OAAa;AAC1C,SAAOsC,OAAO0C,KAAKhF,KAAAA,EAAOiF,KAAK,SAACC,GAAAA;AAC9B,QAAMC,MAAMnF,MAAMkF,CAAAA;AAClB,WAAOC,OAAO,OAAOA,OAAQ,YAAY,gBAAgBA;EAC3D,CAAA;AACF;AAEA,IAAMtD,aAAa,SAAC3C,OAAAA;MAGhBA;AAFF,SACEA,MAAM0C,cACN1C,4BAAAA,MAAMkG,wBAAkB,QAAxBlG,8BAAAA,SAAAA,SAAAA,0BAA0B0C,aAC1B1C,MAAM,eAAA,KACNA,MAAMmG,yBACN;AAEJ;",
|
|
5
|
+
"names": ["useComponentState", "props", "staticConfig", "config", "animationDriver", "groups", "isHydrated", "useIsHydrated", "useAnimations", "stateRef", "useRef", "undefined", "current", "hasAnimationProp", "Boolean", "style", "hasAnimatedStyleValue", "supportsCSSVars", "curStateRef", "willBeAnimatedClient", "next", "isHOC", "hasAnimated", "willBeAnimated", "isServer", "disableClassName", "presence", "usePresence", "presenceState", "isExiting", "isPresent", "isEntering", "initial", "hasEnterStyle", "enterStyle", "hasAnimationThatNeedsHydrate", "isReactNative", "hasEnterState", "shouldEnter", "initialState", "defaultComponentStateShouldEnter", "defaultComponentState", "defaultComponentStateMounted", "disabled", "isDisabled", "states", "useState", "state", "forceStyle", "setState", "isAnimated", "isWeb", "willHydrate", "Object", "assign", "setStateShallow", "createShallowSetState", "debug", "variants", "process", "env", "NODE_ENV", "console", "warn", "JSON", "stringify", "enterVariant", "exitVariant", "enterExitVariant", "custom", "isObj", "exv", "unmounted", "noClass", "isAnimatedAndHydrated", "isClassNameDisabled", "acceptsClassName", "disableSSR", "isDisabledManually", "log", "groupName", "group", "listeners", "Set", "emit", "name", "forEach", "l", "subscribe", "cb", "add", "delete", "groupContextState", "og", "pseudo", "keys", "some", "k", "val", "accessibilityState", "accessibilityDisabled"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var useIsHydrated_exports = {};
|
|
22
|
+
__export(useIsHydrated_exports, {
|
|
23
|
+
useIsHydrated: () => useIsHydrated
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useIsHydrated_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
const nullSubscribe = () => () => {},
|
|
28
|
+
useIsHydrated = () => (0, import_react.useSyncExternalStore)(nullSubscribe, () => !0, () => !1);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var useIsHydrated_exports = {};
|
|
16
|
+
__export(useIsHydrated_exports, {
|
|
17
|
+
useIsHydrated: () => useIsHydrated
|
|
18
|
+
});
|
|
19
|
+
module.exports = __toCommonJS(useIsHydrated_exports);
|
|
20
|
+
var import_react = require("react");
|
|
21
|
+
const nullSubscribe = () => () => {
|
|
22
|
+
}, useIsHydrated = () => (0, import_react.useSyncExternalStore)(
|
|
23
|
+
nullSubscribe,
|
|
24
|
+
() => !0,
|
|
25
|
+
() => !1
|
|
26
|
+
);
|
|
27
|
+
//# sourceMappingURL=useIsHydrated.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
+
var useIsHydrated_exports = {};
|
|
17
|
+
__export(useIsHydrated_exports, {
|
|
18
|
+
useIsHydrated: () => useIsHydrated
|
|
19
|
+
});
|
|
20
|
+
module.exports = __toCommonJS(useIsHydrated_exports);
|
|
21
|
+
var import_react = require("react"), nullSubscribe = function() {
|
|
22
|
+
return function() {
|
|
23
|
+
};
|
|
24
|
+
}, useIsHydrated = function() {
|
|
25
|
+
return (0, import_react.useSyncExternalStore)(nullSubscribe, function() {
|
|
26
|
+
return !0;
|
|
27
|
+
}, function() {
|
|
28
|
+
return !1;
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
useIsHydrated
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=useIsHydrated.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/Users/n8/tamagui/code/core/web/src/hooks/useIsHydrated.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;;;;;mBAAqC,kBAE/BA,gBAAgB,WAAA;AACpB,SAAO,WAAA;EAAO;AAChB,GAEaC,gBAAgB,WAAA;AAC3B,aAAOC,mCACLF,eACA,WAAA;WAAM;KACN,WAAA;WAAM;;AAEV;",
|
|
5
|
+
"names": ["nullSubscribe", "useIsHydrated", "useSyncExternalStore"]
|
|
6
|
+
}
|
|
@@ -9,9 +9,13 @@ const defaultComponentState = {
|
|
|
9
9
|
}, defaultComponentStateMounted = {
|
|
10
10
|
...defaultComponentState,
|
|
11
11
|
unmounted: !1
|
|
12
|
+
}, defaultComponentStateShouldEnter = {
|
|
13
|
+
...defaultComponentState,
|
|
14
|
+
unmounted: "should-enter"
|
|
12
15
|
};
|
|
13
16
|
export {
|
|
14
17
|
defaultComponentState,
|
|
15
|
-
defaultComponentStateMounted
|
|
18
|
+
defaultComponentStateMounted,
|
|
19
|
+
defaultComponentStateShouldEnter
|
|
16
20
|
};
|
|
17
21
|
//# sourceMappingURL=defaultComponentState.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/defaultComponentState.tsx"],
|
|
4
|
-
"mappings": "AAEO,MAAM,wBAA+C;AAAA,EAC1D,OAAO;AAAA,EACP,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO;AAAA,EACP,cAAc;AAAA,EACd,WAAW;AAAA,EACX,UAAU;AACZ,GAEa,+BAAsD;AAAA,EACjE,GAAG;AAAA,EACH,WAAW;AACb;",
|
|
4
|
+
"mappings": "AAEO,MAAM,wBAA+C;AAAA,EAC1D,OAAO;AAAA,EACP,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO;AAAA,EACP,cAAc;AAAA,EACd,WAAW;AAAA,EACX,UAAU;AACZ,GAEa,+BAAsD;AAAA,EACjE,GAAG;AAAA,EACH,WAAW;AACb,GAEa,mCAA0D;AAAA,EACrE,GAAG;AAAA,EACH,WAAW;AACb;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -10,6 +10,10 @@ const defaultComponentState = {
|
|
|
10
10
|
defaultComponentStateMounted = {
|
|
11
11
|
...defaultComponentState,
|
|
12
12
|
unmounted: !1
|
|
13
|
+
},
|
|
14
|
+
defaultComponentStateShouldEnter = {
|
|
15
|
+
...defaultComponentState,
|
|
16
|
+
unmounted: "should-enter"
|
|
13
17
|
};
|
|
14
|
-
export { defaultComponentState, defaultComponentStateMounted };
|
|
18
|
+
export { defaultComponentState, defaultComponentStateMounted, defaultComponentStateShouldEnter };
|
|
15
19
|
//# sourceMappingURL=defaultComponentState.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defaultComponentState","hover","press","pressIn","focus","focusVisible","unmounted","disabled","defaultComponentStateMounted"],"sources":["../../src/defaultComponentState.tsx"],"sourcesContent":[null],"mappings":"AAEO,MAAMA,qBAAA,GAA+C;IAC1DC,KAAA,EAAO;IACPC,KAAA,EAAO;IACPC,OAAA,EAAS;IACTC,KAAA,EAAO;IACPC,YAAA,EAAc;IACdC,SAAA,EAAW;IACXC,QAAA,EAAU;EACZ;EAEaC,4BAAA,GAAsD;IACjE,GAAGR,qBAAA;IACHM,SAAA,EAAW;EACb","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["defaultComponentState","hover","press","pressIn","focus","focusVisible","unmounted","disabled","defaultComponentStateMounted","defaultComponentStateShouldEnter"],"sources":["../../src/defaultComponentState.tsx"],"sourcesContent":[null],"mappings":"AAEO,MAAMA,qBAAA,GAA+C;IAC1DC,KAAA,EAAO;IACPC,KAAA,EAAO;IACPC,OAAA,EAAS;IACTC,KAAA,EAAO;IACPC,YAAA,EAAc;IACdC,SAAA,EAAW;IACXC,QAAA,EAAU;EACZ;EAEaC,4BAAA,GAAsD;IACjE,GAAGR,qBAAA;IACHM,SAAA,EAAW;EACb;EAEaG,gCAAA,GAA0D;IACrE,GAAGT,qBAAA;IACHM,SAAA,EAAW;EACb","ignoreList":[]}
|
|
@@ -9,9 +9,13 @@ var defaultComponentState = {
|
|
|
9
9
|
}, defaultComponentStateMounted = {
|
|
10
10
|
...defaultComponentState,
|
|
11
11
|
unmounted: !1
|
|
12
|
+
}, defaultComponentStateShouldEnter = {
|
|
13
|
+
...defaultComponentState,
|
|
14
|
+
unmounted: "should-enter"
|
|
12
15
|
};
|
|
13
16
|
export {
|
|
14
17
|
defaultComponentState,
|
|
15
|
-
defaultComponentStateMounted
|
|
18
|
+
defaultComponentStateMounted,
|
|
19
|
+
defaultComponentStateShouldEnter
|
|
16
20
|
};
|
|
17
21
|
//# sourceMappingURL=defaultComponentState.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/web/src/defaultComponentState.tsx"],
|
|
4
|
-
"mappings": "AAEO,IAAMA,wBAA+C;EAC1DC,OAAO;EACPC,OAAO;EACPC,SAAS;EACTC,OAAO;EACPC,cAAc;EACdC,WAAW;EACXC,UAAU;AACZ,GAEaC,+BAAsD;EACjE,GAAGR;EACHM,WAAW;AACb;",
|
|
5
|
-
"names": ["defaultComponentState", "hover", "press", "pressIn", "focus", "focusVisible", "unmounted", "disabled", "defaultComponentStateMounted"]
|
|
4
|
+
"mappings": "AAEO,IAAMA,wBAA+C;EAC1DC,OAAO;EACPC,OAAO;EACPC,SAAS;EACTC,OAAO;EACPC,cAAc;EACdC,WAAW;EACXC,UAAU;AACZ,GAEaC,+BAAsD;EACjE,GAAGR;EACHM,WAAW;AACb,GAEaG,mCAA0D;EACrE,GAAGT;EACHM,WAAW;AACb;",
|
|
5
|
+
"names": ["defaultComponentState", "hover", "press", "pressIn", "focus", "focusVisible", "unmounted", "disabled", "defaultComponentStateMounted", "defaultComponentStateShouldEnter"]
|
|
6
6
|
}
|
|
@@ -2,19 +2,21 @@ import { isServer, isWeb } from "@tamagui/constants";
|
|
|
2
2
|
import { useRef, useState } from "react";
|
|
3
3
|
import {
|
|
4
4
|
defaultComponentState,
|
|
5
|
-
defaultComponentStateMounted
|
|
5
|
+
defaultComponentStateMounted,
|
|
6
|
+
defaultComponentStateShouldEnter
|
|
6
7
|
} from "../defaultComponentState";
|
|
7
8
|
import { createShallowSetState } from "../helpers/createShallowSetState";
|
|
8
9
|
import { isObj } from "../helpers/isObj";
|
|
9
10
|
import { log } from "../helpers/log";
|
|
11
|
+
import { useIsHydrated } from "./useIsHydrated";
|
|
10
12
|
const useComponentState = (props, { animationDriver, groups }, staticConfig, config) => {
|
|
11
|
-
const useAnimations = animationDriver?.useAnimations, stateRef = useRef(
|
|
13
|
+
const isHydrated = useIsHydrated(), useAnimations = animationDriver?.useAnimations, stateRef = useRef(
|
|
12
14
|
void 0
|
|
13
15
|
);
|
|
14
16
|
stateRef.current || (stateRef.current = {});
|
|
15
17
|
const hasAnimationProp = !!("animation" in props || props.style && hasAnimatedStyleValue(props.style)), supportsCSSVars = animationDriver?.supportsCSSVars, curStateRef = stateRef.current, willBeAnimatedClient = !!(!!(hasAnimationProp && !staticConfig.isHOC && useAnimations) || curStateRef.hasAnimated), willBeAnimated = !isServer && willBeAnimatedClient;
|
|
16
18
|
willBeAnimated && !curStateRef.hasAnimated && (curStateRef.hasAnimated = !0);
|
|
17
|
-
const { disableClassName } = props, presence = willBeAnimated && props.animatePresence !== !1 && animationDriver?.usePresence?.() || null, presenceState = presence?.[2], isExiting = presenceState?.isPresent === !1, isEntering = presenceState?.isPresent === !0 && presenceState.initial !== !1, hasEnterStyle = !!props.enterStyle, hasAnimationThatNeedsHydrate = hasAnimationProp && (animationDriver?.isReactNative || !supportsCSSVars),
|
|
19
|
+
const { disableClassName } = props, presence = willBeAnimated && props.animatePresence !== !1 && animationDriver?.usePresence?.() || null, presenceState = presence?.[2], isExiting = presenceState?.isPresent === !1, isEntering = presenceState?.isPresent === !0 && presenceState.initial !== !1, hasEnterStyle = !!props.enterStyle, hasAnimationThatNeedsHydrate = hasAnimationProp && !isHydrated && (animationDriver?.isReactNative || !supportsCSSVars), hasEnterState = hasEnterStyle || isEntering, initialState = hasEnterState || hasAnimationThatNeedsHydrate || // disableClassName doesnt work server side, only client, so needs hydrate
|
|
18
20
|
// this is just for a better ux, supports css variables for light/dark, media queries, etc
|
|
19
21
|
disableClassName ? (
|
|
20
22
|
// on the very first render we switch all spring animation drivers to css rendering
|
|
@@ -22,12 +24,12 @@ const useComponentState = (props, { animationDriver, groups }, staticConfig, con
|
|
|
22
24
|
// without flickers of the wrong colors.
|
|
23
25
|
// but once we do that initial hydration and we are in client side rendering mode,
|
|
24
26
|
// we can avoid the extra re-render on mount
|
|
25
|
-
defaultComponentState
|
|
27
|
+
hasEnterState ? defaultComponentStateShouldEnter : defaultComponentState
|
|
26
28
|
) : defaultComponentStateMounted, disabled = isDisabled(props);
|
|
27
29
|
disabled != null && (initialState.disabled = disabled);
|
|
28
|
-
const states = useState(initialState), state = props.forceStyle ? { ...states[0], [props.forceStyle]: !0 } : states[0], setState = states[1]
|
|
30
|
+
const states = useState(initialState), state = props.forceStyle ? { ...states[0], [props.forceStyle]: !0 } : states[0], setState = states[1];
|
|
29
31
|
let isAnimated = willBeAnimated;
|
|
30
|
-
isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC &&
|
|
32
|
+
isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated && (isAnimated = !1, curStateRef.willHydrate = !0), disabled !== state.disabled && (state.disabled = disabled, disabled && Object.assign(state, defaultComponentStateMounted), setState({ ...state }));
|
|
31
33
|
let setStateShallow = createShallowSetState(setState, disabled, !1, props.debug);
|
|
32
34
|
if (presenceState && isAnimated && isHydrated && staticConfig.variants) {
|
|
33
35
|
process.env.NODE_ENV === "development" && props.debug === "verbose" && console.warn(`has presenceState ${JSON.stringify(presenceState)}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useComponentState.ts"],
|
|
4
|
-
"mappings": "AAAA,SAAS,UAAU,aAAa;AAChC,SAAS,QAAQ,gBAAgB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC,SAAS,aAAa;AACtB,SAAS,WAAW;
|
|
4
|
+
"mappings": "AAAA,SAAS,UAAU,aAAa;AAChC,SAAS,QAAQ,gBAAgB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC,SAAS,aAAa;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Y,oBAAI,IAAwB;AAC9C,gBAAY,QAAQ;AAAA,MAClB;AAAA,MACA,KAAK,MAAMA,QAAO;AAChB,kBAAU,QAAQ,CAAC,MAAM,EAAE,MAAMA,MAAK,CAAC;AAAA,MACzC;AAAA,MACA,UAAU,IAAI;AACZ,yBAAU,IAAI,EAAE,GACT,MAAM;AACX,oBAAU,OAAO,EAAE;AAAA,QACrB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,MAAI,WAAW;AAEb,UAAM,oBAAoB,OAAO,OAC3B,KAAK;AACX,sBAAkB,CAACA,WAAU;AAC3B,SAAGA,MAAK,GACR,YAAY,MAAO,KAAK,WAAW;AAAA,QACjC,QAAQA;AAAA,MACV,CAAC;AAED,YAAM,OAAO;AAAA,QACX,GAAG,kBAAkB,SAAS;AAAA,QAC9B,GAAGA;AAAA,MACL;AACA,wBAAkB,SAAS,IAAI;AAAA,IACjC;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,SAAS,sBAAsB,OAAe;AAC5C,SAAO,OAAO,KAAK,KAAK,EAAE,KAAK,CAAC,MAAM;AACpC,UAAM,MAAM,MAAM,CAAC;AACnB,WAAO,OAAO,OAAO,OAAQ,YAAY,gBAAgB;AAAA,EAC3D,CAAC;AACH;AAEA,MAAM,aAAa,CAAC,UAEhB,MAAM,YACN,MAAM,oBAAoB,YAC1B,MAAM,eAAe,KACrB,MAAM,yBACN;",
|
|
5
5
|
"names": ["state"]
|
|
6
6
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { isServer, isWeb } from "@tamagui/constants";
|
|
2
2
|
import { useRef, useState } from "react";
|
|
3
|
-
import { defaultComponentState, defaultComponentStateMounted } from "../defaultComponentState.mjs";
|
|
3
|
+
import { defaultComponentState, defaultComponentStateMounted, defaultComponentStateShouldEnter } from "../defaultComponentState.mjs";
|
|
4
4
|
import { createShallowSetState } from "../helpers/createShallowSetState.mjs";
|
|
5
5
|
import { isObj } from "../helpers/isObj.mjs";
|
|
6
6
|
import { log } from "../helpers/log.mjs";
|
|
7
|
+
import { useIsHydrated } from "./useIsHydrated.mjs";
|
|
7
8
|
const useComponentState = (props, {
|
|
8
9
|
animationDriver,
|
|
9
10
|
groups
|
|
10
11
|
}, staticConfig, config) => {
|
|
11
|
-
const
|
|
12
|
+
const isHydrated = useIsHydrated(),
|
|
13
|
+
useAnimations = animationDriver?.useAnimations,
|
|
12
14
|
stateRef = useRef(void 0);
|
|
13
15
|
stateRef.current || (stateRef.current = {});
|
|
14
16
|
const hasAnimationProp = !!("animation" in props || props.style && hasAnimatedStyleValue(props.style)),
|
|
@@ -25,8 +27,9 @@ const useComponentState = (props, {
|
|
|
25
27
|
isExiting = presenceState?.isPresent === !1,
|
|
26
28
|
isEntering = presenceState?.isPresent === !0 && presenceState.initial !== !1,
|
|
27
29
|
hasEnterStyle = !!props.enterStyle,
|
|
28
|
-
hasAnimationThatNeedsHydrate = hasAnimationProp && (animationDriver?.isReactNative || !supportsCSSVars),
|
|
29
|
-
|
|
30
|
+
hasAnimationThatNeedsHydrate = hasAnimationProp && !isHydrated && (animationDriver?.isReactNative || !supportsCSSVars),
|
|
31
|
+
hasEnterState = hasEnterStyle || isEntering,
|
|
32
|
+
initialState = hasEnterState || hasAnimationThatNeedsHydrate ||
|
|
30
33
|
// disableClassName doesnt work server side, only client, so needs hydrate
|
|
31
34
|
// this is just for a better ux, supports css variables for light/dark, media queries, etc
|
|
32
35
|
disableClassName ?
|
|
@@ -35,7 +38,7 @@ const useComponentState = (props, {
|
|
|
35
38
|
// without flickers of the wrong colors.
|
|
36
39
|
// but once we do that initial hydration and we are in client side rendering mode,
|
|
37
40
|
// we can avoid the extra re-render on mount
|
|
38
|
-
defaultComponentState : defaultComponentStateMounted,
|
|
41
|
+
hasEnterState ? defaultComponentStateShouldEnter : defaultComponentState : defaultComponentStateMounted,
|
|
39
42
|
disabled = isDisabled(props);
|
|
40
43
|
disabled != null && (initialState.disabled = disabled);
|
|
41
44
|
const states = useState(initialState),
|
|
@@ -43,10 +46,9 @@ const useComponentState = (props, {
|
|
|
43
46
|
...states[0],
|
|
44
47
|
[props.forceStyle]: !0
|
|
45
48
|
} : states[0],
|
|
46
|
-
setState = states[1]
|
|
47
|
-
isHydrated = state.unmounted === !1;
|
|
49
|
+
setState = states[1];
|
|
48
50
|
let isAnimated = willBeAnimated;
|
|
49
|
-
isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC &&
|
|
51
|
+
isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated && (isAnimated = !1, curStateRef.willHydrate = !0), disabled !== state.disabled && (state.disabled = disabled, disabled && Object.assign(state, defaultComponentStateMounted), setState({
|
|
50
52
|
...state
|
|
51
53
|
}));
|
|
52
54
|
let setStateShallow = createShallowSetState(setState, disabled, !1, props.debug);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isServer","isWeb","useRef","useState","defaultComponentState","defaultComponentStateMounted","createShallowSetState","isObj","log","useComponentState","props","animationDriver","groups","staticConfig","config","useAnimations","stateRef","current","hasAnimationProp","style","hasAnimatedStyleValue","supportsCSSVars","curStateRef","willBeAnimatedClient","isHOC","hasAnimated","willBeAnimated","disableClassName","presence","animatePresence","usePresence","presenceState","isExiting","isPresent","isEntering","initial","hasEnterStyle","enterStyle","hasAnimationThatNeedsHydrate","isReactNative","initialState","disabled","isDisabled","states","state","forceStyle","setState","
|
|
1
|
+
{"version":3,"names":["isServer","isWeb","useRef","useState","defaultComponentState","defaultComponentStateMounted","defaultComponentStateShouldEnter","createShallowSetState","isObj","log","useIsHydrated","useComponentState","props","animationDriver","groups","staticConfig","config","isHydrated","useAnimations","stateRef","current","hasAnimationProp","style","hasAnimatedStyleValue","supportsCSSVars","curStateRef","willBeAnimatedClient","isHOC","hasAnimated","willBeAnimated","disableClassName","presence","animatePresence","usePresence","presenceState","isExiting","isPresent","isEntering","initial","hasEnterStyle","enterStyle","hasAnimationThatNeedsHydrate","isReactNative","hasEnterState","initialState","disabled","isDisabled","states","state","forceStyle","setState","isAnimated","willHydrate","Object","assign","setStateShallow","debug","variants","process","env","NODE_ENV","console","warn","JSON","stringify","enterVariant","exitVariant","enterExitVariant","custom","exv","unmounted","noClass","isAnimatedAndHydrated","isClassNameDisabled","acceptsClassName","disableSSR","isDisabledManually","groupName","group","listeners","Set","emit","name","state2","forEach","l","subscribe","cb","add","delete","groupContextState","og","pseudo","next","keys","some","k","val","accessibilityState","accessibilityDisabled"],"sources":["../../../src/hooks/useComponentState.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,EAAUC,KAAA,QAAa;AAChC,SAASC,MAAA,EAAQC,QAAA,QAAgB;AACjC,SACEC,qBAAA,EACAC,4BAAA,EACAC,gCAAA,QACK;AACP,SAASC,qBAAA,QAA6B;AACtC,SAASC,KAAA,QAAa;AACtB,SAASC,GAAA,QAAW;AAYpB,SAASC,aAAA,QAAqB;AAEvB,MAAMC,iBAAA,GAAoBA,CAC/BC,KAAA,EACA;EAAEC,eAAA;EAAiBC;AAAO,GAC1BC,YAAA,EACAC,MAAA,KACG;EACH,MAAMC,UAAA,GAAaP,aAAA,CAAc;IAC3BQ,aAAA,GAAgBL,eAAA,EAAiBK,aAAA;IAEjCC,QAAA,GAAWjB,MAAA,CACf,MACF;EACKiB,QAAA,CAASC,OAAA,KACZD,QAAA,CAASC,OAAA,GAAU,CAAC;EAItB,MAAMC,gBAAA,GAAmB,GACvB,eAAeT,KAAA,IAAUA,KAAA,CAAMU,KAAA,IAASC,qBAAA,CAAsBX,KAAA,CAAMU,KAAK;IAIrEE,eAAA,GAAkBX,eAAA,EAAiBW,eAAA;IACnCC,WAAA,GAAcN,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er, isWeb } from "@tamagui/constants";
|
|
2
2
|
import { useRef, useState } from "react";
|
|
3
|
-
import { defaultComponentState, defaultComponentStateMounted } from "../defaultComponentState";
|
|
3
|
+
import { defaultComponentState, defaultComponentStateMounted, defaultComponentStateShouldEnter } from "../defaultComponentState";
|
|
4
4
|
import { createShallowSetState } from "../helpers/createShallowSetState";
|
|
5
5
|
import { isObj } from "../helpers/isObj";
|
|
6
6
|
import { log } from "../helpers/log";
|
|
7
|
+
import { useIsHydrated } from "./useIsHydrated";
|
|
7
8
|
var useComponentState = function(props, param, staticConfig, config) {
|
|
8
|
-
var { animationDriver, groups } = param, _animationDriver_usePresence, useAnimations = animationDriver?.useAnimations, stateRef = useRef(void 0);
|
|
9
|
+
var { animationDriver, groups } = param, _animationDriver_usePresence, isHydrated = useIsHydrated(), useAnimations = animationDriver?.useAnimations, stateRef = useRef(void 0);
|
|
9
10
|
stateRef.current || (stateRef.current = {});
|
|
10
11
|
var hasAnimationProp = !!("animation" in props || props.style && hasAnimatedStyleValue(props.style)), supportsCSSVars = animationDriver?.supportsCSSVars, curStateRef = stateRef.current, willBeAnimatedClient = function() {
|
|
11
12
|
var next = !!(hasAnimationProp && !staticConfig.isHOC && useAnimations);
|
|
12
13
|
return !!(next || curStateRef.hasAnimated);
|
|
13
14
|
}(), willBeAnimated = !isServer && willBeAnimatedClient;
|
|
14
15
|
willBeAnimated && !curStateRef.hasAnimated && (curStateRef.hasAnimated = !0);
|
|
15
|
-
var { disableClassName } = props, presence = willBeAnimated && props.animatePresence !== !1 && (animationDriver == null || (_animationDriver_usePresence = animationDriver.usePresence) === null || _animationDriver_usePresence === void 0 ? void 0 : _animationDriver_usePresence.call(animationDriver)) || null, presenceState = presence?.[2], isExiting = presenceState?.isPresent === !1, isEntering = presenceState?.isPresent === !0 && presenceState.initial !== !1, hasEnterStyle = !!props.enterStyle, hasAnimationThatNeedsHydrate = hasAnimationProp && (animationDriver?.isReactNative || !supportsCSSVars), hasEnterState = hasEnterStyle || isEntering, shouldEnter = hasEnterState || hasAnimationThatNeedsHydrate || // disableClassName doesnt work server side, only client, so needs hydrate
|
|
16
|
+
var { disableClassName } = props, presence = willBeAnimated && props.animatePresence !== !1 && (animationDriver == null || (_animationDriver_usePresence = animationDriver.usePresence) === null || _animationDriver_usePresence === void 0 ? void 0 : _animationDriver_usePresence.call(animationDriver)) || null, presenceState = presence?.[2], isExiting = presenceState?.isPresent === !1, isEntering = presenceState?.isPresent === !0 && presenceState.initial !== !1, hasEnterStyle = !!props.enterStyle, hasAnimationThatNeedsHydrate = hasAnimationProp && !isHydrated && (animationDriver?.isReactNative || !supportsCSSVars), hasEnterState = hasEnterStyle || isEntering, shouldEnter = hasEnterState || hasAnimationThatNeedsHydrate || // disableClassName doesnt work server side, only client, so needs hydrate
|
|
16
17
|
// this is just for a better ux, supports css variables for light/dark, media queries, etc
|
|
17
18
|
disableClassName, initialState = shouldEnter ? (
|
|
18
19
|
// on the very first render we switch all spring animation drivers to css rendering
|
|
@@ -20,14 +21,14 @@ var useComponentState = function(props, param, staticConfig, config) {
|
|
|
20
21
|
// without flickers of the wrong colors.
|
|
21
22
|
// but once we do that initial hydration and we are in client side rendering mode,
|
|
22
23
|
// we can avoid the extra re-render on mount
|
|
23
|
-
defaultComponentState
|
|
24
|
+
hasEnterState ? defaultComponentStateShouldEnter : defaultComponentState
|
|
24
25
|
) : defaultComponentStateMounted, disabled = isDisabled(props);
|
|
25
26
|
disabled != null && (initialState.disabled = disabled);
|
|
26
27
|
var states = useState(initialState), state = props.forceStyle ? {
|
|
27
28
|
...states[0],
|
|
28
29
|
[props.forceStyle]: !0
|
|
29
|
-
} : states[0], setState = states[1],
|
|
30
|
-
isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC &&
|
|
30
|
+
} : states[0], setState = states[1], isAnimated = willBeAnimated;
|
|
31
|
+
isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated && (isAnimated = !1, curStateRef.willHydrate = !0), disabled !== state.disabled && (state.disabled = disabled, disabled && Object.assign(state, defaultComponentStateMounted), setState({
|
|
31
32
|
...state
|
|
32
33
|
}));
|
|
33
34
|
var setStateShallow = createShallowSetState(setState, disabled, !1, props.debug);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/Users/n8/tamagui/code/core/web/src/hooks/useComponentState.ts"],
|
|
4
|
-
"mappings": "AAAA,SAASA,UAAUC,aAAa;AAChC,SAASC,QAAQC,gBAAgB;AACjC,SACEC,uBACAC,
|
|
5
|
-
"names": ["isServer", "isWeb", "useRef", "useState", "defaultComponentState", "defaultComponentStateMounted", "createShallowSetState", "isObj", "log", "useComponentState", "props", "staticConfig", "config", "animationDriver", "groups", "useAnimations", "stateRef", "undefined", "current", "hasAnimationProp", "Boolean", "style", "hasAnimatedStyleValue", "supportsCSSVars", "curStateRef", "willBeAnimatedClient", "next", "isHOC", "hasAnimated", "willBeAnimated", "disableClassName", "presence", "usePresence", "presenceState", "isExiting", "isPresent", "isEntering", "initial", "hasEnterStyle", "enterStyle", "hasAnimationThatNeedsHydrate", "isReactNative", "hasEnterState", "shouldEnter", "initialState", "disabled", "isDisabled", "states", "state", "forceStyle", "setState", "
|
|
4
|
+
"mappings": "AAAA,SAASA,UAAUC,aAAa;AAChC,SAASC,QAAQC,gBAAgB;AACjC,SACEC,uBACAC,8BACAC,wCACK;AACP,SAASC,6BAA6B;AACtC,SAASC,aAAa;AACtB,SAASC,WAAW;AAYpB,SAASC,qBAAqB;AAEvB,IAAMC,oBAAoB,SAC/BC,OAAAA,OAEAC,cACAC,QAAAA;MAFA,EAAEC,iBAAiBC,OAAM,IAAqB,OAyC1CD,8BArCEE,aAAaP,cAAAA,GACbQ,gBAAgBH,iBAAiBG,eAEjCC,WAAWjB,OACfkB,MAAAA;AAEF,EAAKD,SAASE,YACZF,SAASE,UAAU,CAAC;AAItB,MAAMC,mBAAmBC,GACvB,eAAeX,SAAUA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
|
5
|
+
"names": ["isServer", "isWeb", "useRef", "useState", "defaultComponentState", "defaultComponentStateMounted", "defaultComponentStateShouldEnter", "createShallowSetState", "isObj", "log", "useIsHydrated", "useComponentState", "props", "staticConfig", "config", "animationDriver", "groups", "isHydrated", "useAnimations", "stateRef", "undefined", "current", "hasAnimationProp", "Boolean", "style", "hasAnimatedStyleValue", "supportsCSSVars", "curStateRef", "willBeAnimatedClient", "next", "isHOC", "hasAnimated", "willBeAnimated", "disableClassName", "presence", "usePresence", "presenceState", "isExiting", "isPresent", "isEntering", "initial", "hasEnterStyle", "enterStyle", "hasAnimationThatNeedsHydrate", "isReactNative", "hasEnterState", "shouldEnter", "initialState", "disabled", "isDisabled", "states", "state", "forceStyle", "setState", "isAnimated", "willHydrate", "Object", "assign", "setStateShallow", "debug", "variants", "process", "env", "NODE_ENV", "console", "warn", "JSON", "stringify", "enterVariant", "exitVariant", "enterExitVariant", "custom", "exv", "unmounted", "noClass", "isAnimatedAndHydrated", "isClassNameDisabled", "acceptsClassName", "disableSSR", "isDisabledManually", "groupName", "group", "listeners", "Set", "emit", "name", "forEach", "l", "subscribe", "cb", "add", "delete", "groupContextState", "og", "pseudo", "keys", "some", "k", "val", "accessibilityState", "accessibilityDisabled"]
|
|
6
6
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useSyncExternalStore","nullSubscribe","useIsHydrated"],"sources":["../../../src/hooks/useIsHydrated.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,oBAAA,QAA4B;AAErC,MAAMC,aAAA,GAAgBA,CAAA,KACb,MAAM,CAAC;EAGHC,aAAA,GAAgBA,CAAA,KACpBF,oBAAA,CACLC,aAAA,EACA,MAAM,IACN,MAAM,EACR","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
var nullSubscribe = function() {
|
|
3
|
+
return function() {
|
|
4
|
+
};
|
|
5
|
+
}, useIsHydrated = function() {
|
|
6
|
+
return useSyncExternalStore(nullSubscribe, function() {
|
|
7
|
+
return !0;
|
|
8
|
+
}, function() {
|
|
9
|
+
return !1;
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
useIsHydrated
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useIsHydrated.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/Users/n8/tamagui/code/core/web/src/hooks/useIsHydrated.ts"],
|
|
4
|
+
"mappings": "AAAA,SAASA,4BAA4B;AAErC,IAAMC,gBAAgB,WAAA;AACpB,SAAO,WAAA;EAAO;AAChB,GAEaC,gBAAgB,WAAA;AAC3B,SAAOF,qBACLC,eACA,WAAA;WAAM;KACN,WAAA;WAAM;;AAEV;",
|
|
5
|
+
"names": ["useSyncExternalStore", "nullSubscribe", "useIsHydrated"]
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/web",
|
|
3
|
-
"version": "1.121.
|
|
3
|
+
"version": "1.121.3",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -27,22 +27,22 @@
|
|
|
27
27
|
"reset.css"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tamagui/compose-refs": "1.121.
|
|
31
|
-
"@tamagui/constants": "1.121.
|
|
32
|
-
"@tamagui/helpers": "1.121.
|
|
33
|
-
"@tamagui/normalize-css-color": "1.121.
|
|
34
|
-
"@tamagui/timer": "1.121.
|
|
35
|
-
"@tamagui/types": "1.121.
|
|
36
|
-
"@tamagui/use-did-finish-ssr": "1.121.
|
|
37
|
-
"@tamagui/use-event": "1.121.
|
|
38
|
-
"@tamagui/use-force-update": "1.121.
|
|
30
|
+
"@tamagui/compose-refs": "1.121.3",
|
|
31
|
+
"@tamagui/constants": "1.121.3",
|
|
32
|
+
"@tamagui/helpers": "1.121.3",
|
|
33
|
+
"@tamagui/normalize-css-color": "1.121.3",
|
|
34
|
+
"@tamagui/timer": "1.121.3",
|
|
35
|
+
"@tamagui/types": "1.121.3",
|
|
36
|
+
"@tamagui/use-did-finish-ssr": "1.121.3",
|
|
37
|
+
"@tamagui/use-event": "1.121.3",
|
|
38
|
+
"@tamagui/use-force-update": "1.121.3"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": "*",
|
|
42
42
|
"react-dom": "*"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@tamagui/build": "1.121.
|
|
45
|
+
"@tamagui/build": "1.121.3",
|
|
46
46
|
"@testing-library/react": "^16.1.0",
|
|
47
47
|
"csstype": "^3.0.10",
|
|
48
48
|
"react": "*",
|
|
@@ -14,3 +14,8 @@ export const defaultComponentStateMounted: TamaguiComponentState = {
|
|
|
14
14
|
...defaultComponentState,
|
|
15
15
|
unmounted: false,
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
export const defaultComponentStateShouldEnter: TamaguiComponentState = {
|
|
19
|
+
...defaultComponentState,
|
|
20
|
+
unmounted: 'should-enter',
|
|
21
|
+
}
|
|
@@ -3,6 +3,7 @@ import { useRef, useState } from 'react'
|
|
|
3
3
|
import {
|
|
4
4
|
defaultComponentState,
|
|
5
5
|
defaultComponentStateMounted,
|
|
6
|
+
defaultComponentStateShouldEnter,
|
|
6
7
|
} from '../defaultComponentState'
|
|
7
8
|
import { createShallowSetState } from '../helpers/createShallowSetState'
|
|
8
9
|
import { isObj } from '../helpers/isObj'
|
|
@@ -18,6 +19,7 @@ import type {
|
|
|
18
19
|
TextProps,
|
|
19
20
|
UseAnimationHook,
|
|
20
21
|
} from '../types'
|
|
22
|
+
import { useIsHydrated } from './useIsHydrated'
|
|
21
23
|
|
|
22
24
|
export const useComponentState = (
|
|
23
25
|
props: StackProps | TextProps | Record<string, any>,
|
|
@@ -25,6 +27,7 @@ export const useComponentState = (
|
|
|
25
27
|
staticConfig: StaticConfig,
|
|
26
28
|
config: TamaguiInternalConfig
|
|
27
29
|
) => {
|
|
30
|
+
const isHydrated = useIsHydrated()
|
|
28
31
|
const useAnimations = animationDriver?.useAnimations as UseAnimationHook | undefined
|
|
29
32
|
|
|
30
33
|
const stateRef = useRef<TamaguiComponentStateRef>(
|
|
@@ -70,7 +73,9 @@ export const useComponentState = (
|
|
|
70
73
|
const hasEnterStyle = !!props.enterStyle
|
|
71
74
|
|
|
72
75
|
const hasAnimationThatNeedsHydrate =
|
|
73
|
-
hasAnimationProp &&
|
|
76
|
+
hasAnimationProp &&
|
|
77
|
+
!isHydrated &&
|
|
78
|
+
(animationDriver?.isReactNative || !supportsCSSVars)
|
|
74
79
|
|
|
75
80
|
const hasEnterState = hasEnterStyle || isEntering
|
|
76
81
|
|
|
@@ -93,7 +98,9 @@ export const useComponentState = (
|
|
|
93
98
|
// without flickers of the wrong colors.
|
|
94
99
|
// but once we do that initial hydration and we are in client side rendering mode,
|
|
95
100
|
// we can avoid the extra re-render on mount
|
|
96
|
-
|
|
101
|
+
hasEnterState
|
|
102
|
+
? defaultComponentStateShouldEnter
|
|
103
|
+
: defaultComponentState
|
|
97
104
|
: defaultComponentStateMounted
|
|
98
105
|
|
|
99
106
|
// will be nice to deprecate half of these:
|
|
@@ -109,16 +116,9 @@ export const useComponentState = (
|
|
|
109
116
|
const state = props.forceStyle ? { ...states[0], [props.forceStyle]: true } : states[0]
|
|
110
117
|
const setState = states[1]
|
|
111
118
|
|
|
112
|
-
const isHydrated = state.unmounted === false
|
|
113
|
-
|
|
114
119
|
// only web server + initial client render run this when not hydrated:
|
|
115
120
|
let isAnimated = willBeAnimated
|
|
116
|
-
if (
|
|
117
|
-
isWeb &&
|
|
118
|
-
hasAnimationThatNeedsHydrate &&
|
|
119
|
-
!staticConfig.isHOC &&
|
|
120
|
-
state.unmounted === true
|
|
121
|
-
) {
|
|
121
|
+
if (isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated) {
|
|
122
122
|
isAnimated = false
|
|
123
123
|
curStateRef.willHydrate = true
|
|
124
124
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TamaguiComponentState } from './interfaces/TamaguiComponentState';
|
|
2
2
|
export declare const defaultComponentState: TamaguiComponentState;
|
|
3
3
|
export declare const defaultComponentStateMounted: TamaguiComponentState;
|
|
4
|
+
export declare const defaultComponentStateShouldEnter: TamaguiComponentState;
|
|
4
5
|
//# sourceMappingURL=defaultComponentState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultComponentState.d.ts","sourceRoot":"","sources":["../src/defaultComponentState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAE/E,eAAO,MAAM,qBAAqB,EAAE,qBAQnC,CAAA;AAED,eAAO,MAAM,4BAA4B,EAAE,qBAG1C,CAAA"}
|
|
1
|
+
{"version":3,"file":"defaultComponentState.d.ts","sourceRoot":"","sources":["../src/defaultComponentState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAE/E,eAAO,MAAM,qBAAqB,EAAE,qBAQnC,CAAA;AAED,eAAO,MAAM,4BAA4B,EAAE,qBAG1C,CAAA;AAED,eAAO,MAAM,gCAAgC,EAAE,qBAG9C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useComponentState.d.ts","sourceRoot":"","sources":["../../src/hooks/useComponentState.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useComponentState.d.ts","sourceRoot":"","sources":["../../src/hooks/useComponentState.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,iBAAiB,EAEjB,UAAU,EACV,YAAY,EACZ,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,SAAS,EAEV,MAAM,UAAU,CAAA;AAGjB,eAAO,MAAM,iBAAiB,UACrB,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,+BACtB,iBAAiB,gBAChC,YAAY,UAClB,qBAAqB;;;;;;;;;;;;;;;;;;;CA6N9B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsHydrated.d.ts","sourceRoot":"","sources":["../../src/hooks/useIsHydrated.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,eAMzB,CAAA"}
|