@tamagui/web 1.129.19 → 1.130.1
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/createComponent.cjs +43 -32
- package/dist/cjs/createComponent.js +36 -23
- package/dist/cjs/createComponent.js.map +1 -1
- package/dist/cjs/createComponent.native.js +30 -21
- package/dist/cjs/createComponent.native.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.cjs +3 -2
- package/dist/cjs/helpers/getSplitStyles.js +4 -2
- package/dist/cjs/helpers/getSplitStyles.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.native.js +2 -0
- package/dist/cjs/helpers/getSplitStyles.native.js.map +2 -2
- package/dist/cjs/helpers/mergeProps.cjs +13 -9
- package/dist/cjs/helpers/mergeProps.js +17 -9
- package/dist/cjs/helpers/mergeProps.js.map +1 -1
- package/dist/cjs/helpers/mergeProps.native.js +20 -9
- package/dist/cjs/helpers/mergeProps.native.js.map +2 -2
- package/dist/cjs/hooks/useComponentState.cjs +1 -1
- package/dist/cjs/hooks/useComponentState.js +1 -1
- package/dist/cjs/hooks/useComponentState.js.map +1 -1
- package/dist/cjs/hooks/useComponentState.native.js +1 -1
- package/dist/cjs/hooks/useComponentState.native.js.map +2 -2
- package/dist/cjs/hooks/useProps.cjs +2 -2
- package/dist/cjs/hooks/useProps.js +7 -2
- package/dist/cjs/hooks/useProps.js.map +1 -1
- package/dist/cjs/hooks/useProps.native.js +3 -3
- package/dist/cjs/hooks/useProps.native.js.map +1 -1
- package/dist/cjs/hooks/useThemeState.cjs +2 -1
- package/dist/cjs/hooks/useThemeState.js +3 -1
- package/dist/cjs/hooks/useThemeState.js.map +1 -1
- package/dist/cjs/hooks/useThemeState.native.js +6 -1
- package/dist/cjs/hooks/useThemeState.native.js.map +2 -2
- package/dist/cjs/views/Theme.cjs +10 -7
- package/dist/cjs/views/Theme.js +21 -7
- package/dist/cjs/views/Theme.js.map +1 -1
- package/dist/cjs/views/Theme.native.js +7 -7
- package/dist/cjs/views/Theme.native.js.map +2 -2
- package/dist/esm/createComponent.js +36 -23
- package/dist/esm/createComponent.js.map +1 -1
- package/dist/esm/createComponent.mjs +43 -32
- package/dist/esm/createComponent.mjs.map +1 -1
- package/dist/esm/createComponent.native.js +42 -32
- package/dist/esm/createComponent.native.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.js +4 -2
- package/dist/esm/helpers/getSplitStyles.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs +3 -2
- package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.native.js +1 -0
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/helpers/mergeProps.js +17 -9
- package/dist/esm/helpers/mergeProps.js.map +1 -1
- package/dist/esm/helpers/mergeProps.mjs +13 -9
- package/dist/esm/helpers/mergeProps.mjs.map +1 -1
- package/dist/esm/helpers/mergeProps.native.js +18 -9
- package/dist/esm/helpers/mergeProps.native.js.map +1 -1
- package/dist/esm/hooks/useComponentState.js +1 -1
- package/dist/esm/hooks/useComponentState.js.map +1 -1
- package/dist/esm/hooks/useComponentState.mjs +1 -1
- package/dist/esm/hooks/useComponentState.mjs.map +1 -1
- package/dist/esm/hooks/useComponentState.native.js +1 -1
- package/dist/esm/hooks/useProps.js +7 -2
- package/dist/esm/hooks/useProps.js.map +1 -1
- package/dist/esm/hooks/useProps.mjs +2 -2
- package/dist/esm/hooks/useProps.mjs.map +1 -1
- package/dist/esm/hooks/useProps.native.js +2 -2
- package/dist/esm/hooks/useProps.native.js.map +1 -1
- package/dist/esm/hooks/useThemeState.js +3 -1
- package/dist/esm/hooks/useThemeState.js.map +1 -1
- package/dist/esm/hooks/useThemeState.mjs +2 -1
- package/dist/esm/hooks/useThemeState.mjs.map +1 -1
- package/dist/esm/hooks/useThemeState.native.js +2 -1
- package/dist/esm/hooks/useThemeState.native.js.map +1 -1
- package/dist/esm/views/Theme.js +21 -7
- package/dist/esm/views/Theme.js.map +1 -1
- package/dist/esm/views/Theme.mjs +10 -7
- package/dist/esm/views/Theme.mjs.map +1 -1
- package/dist/esm/views/Theme.native.js +10 -6
- package/dist/esm/views/Theme.native.js.map +1 -1
- package/package.json +12 -12
- package/src/createComponent.tsx +135 -106
- package/src/helpers/getSplitStyles.tsx +9 -3
- package/src/helpers/mergeProps.ts +53 -4
- package/src/hooks/useComponentState.ts +1 -0
- package/src/hooks/useProps.tsx +7 -2
- package/src/hooks/useThemeState.ts +7 -2
- package/src/setupHooks.ts +1 -1
- package/src/types.tsx +10 -1
- package/src/views/Theme.tsx +40 -21
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/mergeProps.d.ts +19 -0
- package/types/helpers/mergeProps.d.ts.map +1 -1
- package/types/hooks/useProps.d.ts.map +1 -1
- package/types/hooks/useThemeState.d.ts.map +1 -1
- package/types/setupHooks.d.ts +1 -1
- package/types/setupHooks.d.ts.map +1 -1
- package/types/types.d.ts +7 -1
- package/types/types.d.ts.map +1 -1
- package/types/views/Theme.d.ts +4 -2
- package/types/views/Theme.d.ts.map +1 -1
|
@@ -12,11 +12,14 @@ var empty = {
|
|
|
12
12
|
},
|
|
13
13
|
Theme = /* @__PURE__ */forwardRef(function (props, ref) {
|
|
14
14
|
if (props.disable) return props.children;
|
|
15
|
-
var
|
|
15
|
+
var {
|
|
16
|
+
passThrough
|
|
17
|
+
} = props,
|
|
18
|
+
isRoot = !!props._isRoot,
|
|
16
19
|
[_, themeState] = useThemeWithState(props, isRoot),
|
|
17
20
|
disableDirectChildTheme = props["disable-child-theme"],
|
|
18
21
|
finalChildren = disableDirectChildTheme ? Children.map(props.children, function (child) {
|
|
19
|
-
return /* @__PURE__ */cloneElement(child, {
|
|
22
|
+
return passThrough ? child : /* @__PURE__ */cloneElement(child, {
|
|
20
23
|
"data-disable-theme": !0
|
|
21
24
|
});
|
|
22
25
|
}) : props.children;
|
|
@@ -28,12 +31,13 @@ var empty = {
|
|
|
28
31
|
var stateRef = useRef({
|
|
29
32
|
hasEverThemed: !1
|
|
30
33
|
});
|
|
31
|
-
return getThemedChildren(themeState, finalChildren, props, isRoot, stateRef);
|
|
34
|
+
return getThemedChildren(themeState, finalChildren, props, isRoot, stateRef, passThrough);
|
|
32
35
|
});
|
|
33
36
|
Theme.avoidForwardRef = !0;
|
|
34
37
|
function getThemedChildren(themeState, children, props) {
|
|
35
38
|
var isRoot = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1,
|
|
36
39
|
stateRef = arguments.length > 4 ? arguments[4] : void 0,
|
|
40
|
+
passThrough = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : !1,
|
|
37
41
|
{
|
|
38
42
|
shallow,
|
|
39
43
|
forceClassName
|
|
@@ -62,7 +66,7 @@ function getThemedChildren(themeState, children, props) {
|
|
|
62
66
|
var parentState = getThemeState(themeState.isNew ? themeState.id : themeState.parentId);
|
|
63
67
|
if (!parentState) throw new Error("\u203C\uFE0F010");
|
|
64
68
|
children = Children.toArray(children).map(function (child) {
|
|
65
|
-
return /* @__PURE__ */isValidElement(child) ? /* @__PURE__ */cloneElement(child, void 0, /* @__PURE__ */_jsx(Theme, {
|
|
69
|
+
return /* @__PURE__ */isValidElement(child) ? passThrough ? child : /* @__PURE__ */cloneElement(child, void 0, /* @__PURE__ */_jsx(Theme, {
|
|
66
70
|
name: parentState.name,
|
|
67
71
|
children: child.props.children
|
|
68
72
|
})) : child;
|
|
@@ -82,10 +86,10 @@ function getThemedChildren(themeState, children, props) {
|
|
|
82
86
|
} = getThemeClassNameAndStyle(themeState, props, isRoot);
|
|
83
87
|
if (children = /* @__PURE__ */_jsx("span", {
|
|
84
88
|
className: `${className} _dsp_contents is_Theme`,
|
|
85
|
-
style,
|
|
89
|
+
style: passThrough ? void 0 : style,
|
|
86
90
|
children
|
|
87
91
|
}), state.hasEverThemed === "wrapped") {
|
|
88
|
-
var className1 = requiresExtraWrapper ? `${isInverse ? name.startsWith("light") ? "t_light is_inversed" : name.startsWith("dark") ? "t_dark is_inversed" : "" : ""} _dsp_contents` : "_dsp_contents";
|
|
92
|
+
var className1 = !passThrough && requiresExtraWrapper ? `${isInverse ? name.startsWith("light") ? "t_light is_inversed" : name.startsWith("dark") ? "t_dark is_inversed" : "" : ""} _dsp_contents` : "_dsp_contents";
|
|
89
93
|
children = /* @__PURE__ */_jsx("span", {
|
|
90
94
|
className: className1,
|
|
91
95
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["jsx","_jsx","isWeb","React","Children","cloneElement","forwardRef","isValidElement","useRef","getSetting","variableToString","useThemeWithState","getThemeState","hasThemeUpdatingProps","ThemeStateContext","ThemeDebug","empty","className","style","Theme","props","ref","disable","children","isRoot","_isRoot","_","themeState","disableDirectChildTheme","finalChildren","map","child","only","stateRef","hasEverThemed","getThemedChildren","avoidForwardRef","arguments","length","shallow","forceClassName","state","current","shouldRenderChildrenWithTheme","isNew","process","env","NODE_ENV","debug","themeProps","Provider","value","id","isInverse","name","requiresExtraWrapper","parentId","parentState","Error","toArray","console","warn","getThemeClassNameAndStyle","className1","startsWith"],"sources":["../../../src/views/Theme.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,GAAA,IAAAC,IAAA,QAAa;AAEtB,SAAOC,KAAA,QAAS,oBAAwB;AACxC,OAAAC,KAAS,IAAAC,QAAA,EAAAC,YAAkB,EAAAC,UAAA,EAAAC,cAAA,EAAAC,MAAA;AAC3B,SAASC,UAAA,6BAAwB;AACjC,SAASC,gBAAA,qCAAyB;AAClC,SAAAC,iBAAA;AAAA,SACEC,aAAA,EAAAC,qBAAA,EAAAC,iBAAA;AAAA,SACAC,UAAA;AAAA,IACAC,KAAA;IAAAC,SAEK;IAEPC,KAAA,EAAS;
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","isWeb","React","Children","cloneElement","forwardRef","isValidElement","useRef","getSetting","variableToString","useThemeWithState","getThemeState","hasThemeUpdatingProps","ThemeStateContext","ThemeDebug","empty","className","style","Theme","props","ref","disable","children","passThrough","isRoot","_isRoot","_","themeState","disableDirectChildTheme","finalChildren","map","child","only","stateRef","hasEverThemed","getThemedChildren","avoidForwardRef","arguments","length","shallow","forceClassName","state","current","shouldRenderChildrenWithTheme","isNew","process","env","NODE_ENV","debug","themeProps","Provider","value","id","isInverse","name","requiresExtraWrapper","parentId","parentState","Error","toArray","console","warn","getThemeClassNameAndStyle","className1","startsWith","themeColor","theme","color","maxInverses","themeClassName","inverses","replace","schemePrefix"],"sources":["../../../src/views/Theme.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,GAAA,IAAAC,IAAA,QAAa;AAEtB,SAAOC,KAAA,QAAS,oBAAwB;AACxC,OAAAC,KAAS,IAAAC,QAAA,EAAAC,YAAkB,EAAAC,UAAA,EAAAC,cAAA,EAAAC,MAAA;AAC3B,SAASC,UAAA,6BAAwB;AACjC,SAASC,gBAAA,qCAAyB;AAClC,SAAAC,iBAAA;AAAA,SACEC,aAAA,EAAAC,qBAAA,EAAAC,iBAAA;AAAA,SACAC,UAAA;AAAA,IACAC,KAAA;IAAAC,SAEK;IAEPC,KAAA,EAAS;EAwEH;EAAAC,KAAA,kBAAAb,UAAA,WAAAc,KAAA,EAAAC,GAAA;IAtEN,IAAMD,KAAA,CAAAE,OAAU,EAOd,OAAIF,KAAM,CAAAG,QAAA;IACR;QAAAC;MAAa,IAAAJ,KAAA;MAAAK,MAAA,KAAAL,KAAA,CAAAM,OAAA;MAAA,CAAAC,CAAA,EAAAC,UAAA,IAAAjB,iBAAA,CAAAS,KAAA,EAAAK,MAAA;MAAAI,uBAAA,GAAAT,KAAA;MAAAU,aAAA,GAAAD,uBAAA,GAAAzB,QAAA,CAAA2B,GAAA,CAAAX,KAAA,CAAAG,QAAA,YAAAS,KAAA;QAGf,OAAQR,WAAY,GAAAQ,KAAI,GAElB,eAAW3B,YAEV,CAAA2B,KAA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|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -27,16 +27,16 @@
|
|
|
27
27
|
"reset.css"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tamagui/compose-refs": "1.
|
|
31
|
-
"@tamagui/constants": "1.
|
|
32
|
-
"@tamagui/helpers": "1.
|
|
33
|
-
"@tamagui/is-equal-shallow": "1.
|
|
34
|
-
"@tamagui/normalize-css-color": "1.
|
|
35
|
-
"@tamagui/timer": "1.
|
|
36
|
-
"@tamagui/types": "1.
|
|
37
|
-
"@tamagui/use-did-finish-ssr": "1.
|
|
38
|
-
"@tamagui/use-event": "1.
|
|
39
|
-
"@tamagui/use-force-update": "1.
|
|
30
|
+
"@tamagui/compose-refs": "1.130.1",
|
|
31
|
+
"@tamagui/constants": "1.130.1",
|
|
32
|
+
"@tamagui/helpers": "1.130.1",
|
|
33
|
+
"@tamagui/is-equal-shallow": "1.130.1",
|
|
34
|
+
"@tamagui/normalize-css-color": "1.130.1",
|
|
35
|
+
"@tamagui/timer": "1.130.1",
|
|
36
|
+
"@tamagui/types": "1.130.1",
|
|
37
|
+
"@tamagui/use-did-finish-ssr": "1.130.1",
|
|
38
|
+
"@tamagui/use-event": "1.130.1",
|
|
39
|
+
"@tamagui/use-force-update": "1.130.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": "*",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"react-native": "*"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@tamagui/build": "1.
|
|
47
|
+
"@tamagui/build": "1.130.1",
|
|
48
48
|
"@testing-library/react": "^16.1.0",
|
|
49
49
|
"csstype": "^3.0.10",
|
|
50
50
|
"react": "*",
|
package/src/createComponent.tsx
CHANGED
|
@@ -418,7 +418,7 @@ export function createComponent<
|
|
|
418
418
|
|
|
419
419
|
// create new context with groups, or else sublings will grab the same one
|
|
420
420
|
const allGroupContexts = useMemo((): AllGroupContexts | null => {
|
|
421
|
-
if (!groupName) {
|
|
421
|
+
if (!groupName || props.passThrough) {
|
|
422
422
|
return groupContextParent
|
|
423
423
|
}
|
|
424
424
|
|
|
@@ -632,11 +632,13 @@ export function createComponent<
|
|
|
632
632
|
debugProp
|
|
633
633
|
)
|
|
634
634
|
|
|
635
|
+
// splitStyles === null === passThrough
|
|
636
|
+
|
|
635
637
|
const groupContext = groupName ? allGroupContexts?.[groupName] || null : null
|
|
636
638
|
|
|
637
639
|
// one tiny mutation 🙏 get width/height optimistically from raw values if possible
|
|
638
640
|
// if set hardcoded it avoids extra renders
|
|
639
|
-
if (groupContext) {
|
|
641
|
+
if (splitStyles && groupContext) {
|
|
640
642
|
const groupState = groupContext?.state
|
|
641
643
|
if (groupState && groupState.layout === undefined) {
|
|
642
644
|
if (splitStyles.style?.width || splitStyles.style?.height) {
|
|
@@ -650,116 +652,124 @@ export function createComponent<
|
|
|
650
652
|
|
|
651
653
|
// avoids re-rendering if animation driver supports it
|
|
652
654
|
// TODO believe we need to set some sort of "pendingState" in case it re-renders
|
|
653
|
-
if (
|
|
654
|
-
|
|
655
|
-
|
|
655
|
+
if (splitStyles) {
|
|
656
|
+
if ((!hasAnimationProp || groupName) && animationDriver?.avoidReRenders) {
|
|
657
|
+
const useStyleListener = stateRef.current.useStyleListener
|
|
658
|
+
const ogSetStateShallow = setStateShallow
|
|
656
659
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
660
|
+
stateRef.current.setStateShallow = (nextOrGetNext) => {
|
|
661
|
+
const prev = NextState.get(stateRef) || state
|
|
662
|
+
const next =
|
|
663
|
+
typeof nextOrGetNext === 'function' ? nextOrGetNext(prev) : nextOrGetNext
|
|
661
664
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
+
if (next === prev || isEqualShallow(prev, next)) {
|
|
666
|
+
return
|
|
667
|
+
}
|
|
665
668
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
669
|
+
// one thing we have to handle here and where it gets a bit more complex is group styles
|
|
670
|
+
const canAvoidReRender = Object.keys(next).every((key) =>
|
|
671
|
+
avoidReRenderKeys.has(key)
|
|
672
|
+
)
|
|
670
673
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
674
|
+
if (canAvoidReRender) {
|
|
675
|
+
const updatedState = {
|
|
676
|
+
...prev,
|
|
677
|
+
...next,
|
|
678
|
+
}
|
|
679
|
+
NextState.set(stateRef, updatedState)
|
|
680
|
+
|
|
681
|
+
if (
|
|
682
|
+
process.env.NODE_ENV === 'development' &&
|
|
683
|
+
debugProp &&
|
|
684
|
+
debugProp !== 'profile'
|
|
685
|
+
) {
|
|
686
|
+
console.groupCollapsed(`[⚡️] avoid setState`, next, { updatedState, props })
|
|
687
|
+
console.info(stateRef.current.host)
|
|
688
|
+
console.groupEnd()
|
|
689
|
+
}
|
|
687
690
|
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
691
|
+
const {
|
|
692
|
+
group,
|
|
693
|
+
hasDynGroupChildren,
|
|
694
|
+
unmounted,
|
|
695
|
+
animation,
|
|
696
|
+
...childrenGroupState
|
|
697
|
+
} = updatedState
|
|
698
|
+
|
|
699
|
+
// update before getting styles
|
|
700
|
+
if (groupContext) {
|
|
701
|
+
notifyGroupSubscribers(
|
|
702
|
+
groupContext,
|
|
703
|
+
stateRef.current.group || null,
|
|
704
|
+
childrenGroupState
|
|
705
|
+
)
|
|
706
|
+
}
|
|
704
707
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
708
|
+
// we just emit and return for group without animation ^
|
|
709
|
+
if (!hasAnimationProp || !useStyleListener) {
|
|
710
|
+
return
|
|
711
|
+
}
|
|
709
712
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
713
|
+
const nextStyles = getSplitStyles(
|
|
714
|
+
props,
|
|
715
|
+
staticConfig,
|
|
716
|
+
theme,
|
|
717
|
+
themeName,
|
|
718
|
+
updatedState,
|
|
719
|
+
styleProps,
|
|
720
|
+
null,
|
|
721
|
+
componentContext,
|
|
722
|
+
allGroupContexts,
|
|
723
|
+
elementType,
|
|
724
|
+
startedUnhydrated,
|
|
725
|
+
debugProp
|
|
726
|
+
)
|
|
724
727
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
728
|
+
useStyleListener((nextStyles?.style || {}) as any)
|
|
729
|
+
} else {
|
|
730
|
+
if (
|
|
731
|
+
process.env.NODE_ENV === 'development' &&
|
|
732
|
+
debugProp &&
|
|
733
|
+
debugProp !== 'profile'
|
|
734
|
+
) {
|
|
735
|
+
console.info(`[🐌] re-render`, { canAvoidReRender, next })
|
|
736
|
+
}
|
|
737
|
+
ogSetStateShallow(next)
|
|
733
738
|
}
|
|
734
|
-
ogSetStateShallow(next)
|
|
735
739
|
}
|
|
736
|
-
}
|
|
737
740
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
+
// needs to capture latest props (it's called from memoized `events`)
|
|
742
|
+
setStateShallow = (state) => {
|
|
743
|
+
stateRef.current.setStateShallow?.(state)
|
|
744
|
+
}
|
|
741
745
|
}
|
|
742
746
|
}
|
|
743
747
|
|
|
744
748
|
if (process.env.NODE_ENV === 'development' && time) time`split-styles`
|
|
745
749
|
|
|
746
750
|
// hide strategy will set this opacity = 0 until measured
|
|
747
|
-
if (
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
+
if (splitStyles) {
|
|
752
|
+
if (
|
|
753
|
+
props.group &&
|
|
754
|
+
props.untilMeasured === 'hide' &&
|
|
755
|
+
!stateRef.current.hasMeasured
|
|
756
|
+
) {
|
|
757
|
+
splitStyles.style ||= {}
|
|
758
|
+
splitStyles.style.opacity = 0
|
|
759
|
+
}
|
|
751
760
|
|
|
752
|
-
|
|
753
|
-
|
|
761
|
+
if (splitStyles.dynamicThemeAccess != null) {
|
|
762
|
+
stateRef.current.isListeningToTheme = splitStyles.dynamicThemeAccess
|
|
763
|
+
}
|
|
754
764
|
}
|
|
755
765
|
|
|
756
766
|
// only listen for changes if we are using raw theme values or media space, or dynamic media (native)
|
|
757
767
|
// array = space media breakpoints
|
|
758
|
-
const hasRuntimeMediaKeys = splitStyles
|
|
768
|
+
const hasRuntimeMediaKeys = splitStyles?.hasMedia && splitStyles.hasMedia !== true
|
|
759
769
|
const shouldListenForMedia =
|
|
760
770
|
didGetVariableValue() ||
|
|
761
771
|
hasRuntimeMediaKeys ||
|
|
762
|
-
(noClass && splitStyles
|
|
772
|
+
(noClass && splitStyles?.hasMedia === true)
|
|
763
773
|
|
|
764
774
|
const mediaListeningKeys = hasRuntimeMediaKeys
|
|
765
775
|
? (splitStyles.hasMedia as Set<string>)
|
|
@@ -776,7 +786,9 @@ export function createComponent<
|
|
|
776
786
|
style: splitStylesStyle,
|
|
777
787
|
classNames,
|
|
778
788
|
space,
|
|
779
|
-
|
|
789
|
+
pseudoGroups,
|
|
790
|
+
mediaGroups,
|
|
791
|
+
} = splitStyles || {}
|
|
780
792
|
|
|
781
793
|
const propsWithAnimation = props as UseAnimationProps
|
|
782
794
|
|
|
@@ -804,7 +816,7 @@ export function createComponent<
|
|
|
804
816
|
onClick,
|
|
805
817
|
theme: _themeProp,
|
|
806
818
|
...nonTamaguiProps
|
|
807
|
-
} = viewPropsIn
|
|
819
|
+
} = viewPropsIn || {}
|
|
808
820
|
|
|
809
821
|
// these can ultimately be for DOM, react-native-web views, or animated views
|
|
810
822
|
// so the type is pretty loose
|
|
@@ -880,7 +892,7 @@ export function createComponent<
|
|
|
880
892
|
|
|
881
893
|
if (process.env.NODE_ENV === 'development' && time) time`destructure`
|
|
882
894
|
|
|
883
|
-
if (groupContext) {
|
|
895
|
+
if (splitStyles && groupContext) {
|
|
884
896
|
nonTamaguiProps.onLayout = composeEventHandlers(
|
|
885
897
|
nonTamaguiProps.onLayout,
|
|
886
898
|
(e: LayoutEvent) => {
|
|
@@ -935,12 +947,6 @@ export function createComponent<
|
|
|
935
947
|
|
|
936
948
|
if (process.env.NODE_ENV === 'development' && time) time`events-hooks`
|
|
937
949
|
|
|
938
|
-
// combined multiple effects into one for performance so be careful with logic
|
|
939
|
-
// should not be a layout effect because otherwise it wont render the initial state
|
|
940
|
-
// for example css driver needs to render once with the first styles, then again with the next
|
|
941
|
-
// if its a layout effect it will just skip that first <render >output
|
|
942
|
-
const { pseudoGroups, mediaGroups } = splitStyles
|
|
943
|
-
|
|
944
950
|
const unPress = () => {
|
|
945
951
|
setStateShallow({ press: false, pressIn: false })
|
|
946
952
|
}
|
|
@@ -956,9 +962,11 @@ export function createComponent<
|
|
|
956
962
|
}
|
|
957
963
|
return styleObject
|
|
958
964
|
}
|
|
959
|
-
const computed =
|
|
960
|
-
|
|
961
|
-
|
|
965
|
+
const computed = stateRef.current.host
|
|
966
|
+
? cssStyleDeclarationToObject(
|
|
967
|
+
getComputedStyle(stateRef.current.host as Element)
|
|
968
|
+
)
|
|
969
|
+
: {}
|
|
962
970
|
console.groupCollapsed(`Rendered > (opacity: ${computed.opacity})`)
|
|
963
971
|
console.warn(stateRef.current.host)
|
|
964
972
|
console.warn(computed)
|
|
@@ -1226,7 +1234,7 @@ export function createComponent<
|
|
|
1226
1234
|
if (process.env.NODE_ENV === 'development' && time) time`hooks`
|
|
1227
1235
|
|
|
1228
1236
|
let content =
|
|
1229
|
-
!children || asChild
|
|
1237
|
+
!children || asChild || !splitStyles
|
|
1230
1238
|
? children
|
|
1231
1239
|
: spacedChildren({
|
|
1232
1240
|
separator,
|
|
@@ -1270,6 +1278,17 @@ export function createComponent<
|
|
|
1270
1278
|
|
|
1271
1279
|
if (process.env.NODE_ENV === 'development' && time) time`use-children`
|
|
1272
1280
|
|
|
1281
|
+
// passthrough mode - only pass style display contents, nothing else
|
|
1282
|
+
if (!splitStyles) {
|
|
1283
|
+
elementType = 'span'
|
|
1284
|
+
content = propsIn.children
|
|
1285
|
+
viewProps = {
|
|
1286
|
+
style: {
|
|
1287
|
+
display: 'contents',
|
|
1288
|
+
},
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1273
1292
|
if (useChildrenResult) {
|
|
1274
1293
|
content = useChildrenResult
|
|
1275
1294
|
} else {
|
|
@@ -1279,7 +1298,15 @@ export function createComponent<
|
|
|
1279
1298
|
// needs to reset the presence state for nested children
|
|
1280
1299
|
const ResetPresence = config?.animations?.ResetPresence
|
|
1281
1300
|
const needsReset = Boolean(
|
|
1282
|
-
|
|
1301
|
+
// not when passing down to child
|
|
1302
|
+
!asChild &&
|
|
1303
|
+
// not when passThrough
|
|
1304
|
+
splitStyles &&
|
|
1305
|
+
// not when HOC
|
|
1306
|
+
!isHOC &&
|
|
1307
|
+
ResetPresence &&
|
|
1308
|
+
willBeAnimated &&
|
|
1309
|
+
(hasEnterStyle || presenceState)
|
|
1283
1310
|
)
|
|
1284
1311
|
// avoid re-parenting
|
|
1285
1312
|
const hasEverReset = stateRef.current.hasEverResetPresence
|
|
@@ -1312,9 +1339,10 @@ export function createComponent<
|
|
|
1312
1339
|
|
|
1313
1340
|
if (process.env.NODE_ENV === 'development' && time) time`group-context`
|
|
1314
1341
|
|
|
1315
|
-
content =
|
|
1316
|
-
|
|
1317
|
-
|
|
1342
|
+
content =
|
|
1343
|
+
disableTheme || !splitStyles
|
|
1344
|
+
? content
|
|
1345
|
+
: getThemedChildren(themeState, content, themeStateProps, false, stateRef)
|
|
1318
1346
|
|
|
1319
1347
|
if (process.env.NODE_ENV === 'development' && time) time`themed-children`
|
|
1320
1348
|
|
|
@@ -1323,7 +1351,7 @@ export function createComponent<
|
|
|
1323
1351
|
content = (
|
|
1324
1352
|
<span
|
|
1325
1353
|
className="_dsp_contents"
|
|
1326
|
-
{...(isHydrated && events && getWebEvents(events))}
|
|
1354
|
+
{...(splitStyles && isHydrated && events && getWebEvents(events))}
|
|
1327
1355
|
>
|
|
1328
1356
|
{content}
|
|
1329
1357
|
</span>
|
|
@@ -1357,6 +1385,7 @@ export function createComponent<
|
|
|
1357
1385
|
if (process.env.TAMAGUI_TARGET === 'web' && startedUnhydrated) {
|
|
1358
1386
|
// breaking rules of hooks but startedUnhydrated NEVER changes
|
|
1359
1387
|
const styleTags = useMemo(() => {
|
|
1388
|
+
if (!splitStyles) return
|
|
1360
1389
|
return getStyleTags(Object.values(splitStyles.rulesToInsert))
|
|
1361
1390
|
}, [])
|
|
1362
1391
|
// this is only to appease react hydration really
|
|
@@ -1509,7 +1538,7 @@ export function createComponent<
|
|
|
1509
1538
|
|
|
1510
1539
|
out = options?.disableTheme ? out : themeable(out, extendedConfig, true)
|
|
1511
1540
|
|
|
1512
|
-
if (process.env.TAMAGUI_MEMOIZE_STYLEABLE) {
|
|
1541
|
+
if (extendedConfig.memo || process.env.TAMAGUI_MEMOIZE_STYLEABLE) {
|
|
1513
1542
|
out = React.memo(out)
|
|
1514
1543
|
}
|
|
1515
1544
|
|
|
@@ -97,7 +97,7 @@ type StyleSplitter = (
|
|
|
97
97
|
elementType?: string,
|
|
98
98
|
startedUnhydrated?: boolean,
|
|
99
99
|
debug?: DebugProp
|
|
100
|
-
) => GetStyleResult
|
|
100
|
+
) => null | GetStyleResult
|
|
101
101
|
|
|
102
102
|
export const PROP_SPLIT = '-'
|
|
103
103
|
|
|
@@ -147,6 +147,10 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
147
147
|
conf = conf || getConfig()
|
|
148
148
|
const animationDriver = componentContext?.animationDriver || conf.animations
|
|
149
149
|
|
|
150
|
+
if (props.passThrough) {
|
|
151
|
+
return null
|
|
152
|
+
}
|
|
153
|
+
|
|
150
154
|
// a bit icky, we need no normalize but not fully
|
|
151
155
|
if (
|
|
152
156
|
isWeb &&
|
|
@@ -1524,8 +1528,10 @@ export const useSplitStyles: StyleSplitter = (a, b, c, d, e, f, g, h, i, j, k, l
|
|
|
1524
1528
|
|
|
1525
1529
|
if (process.env.TAMAGUI_TARGET !== 'native') {
|
|
1526
1530
|
useInsertEffectCompat(() => {
|
|
1527
|
-
|
|
1528
|
-
|
|
1531
|
+
if (res) {
|
|
1532
|
+
insertStyleRules(res.rulesToInsert)
|
|
1533
|
+
}
|
|
1534
|
+
}, [res?.rulesToInsert])
|
|
1529
1535
|
}
|
|
1530
1536
|
|
|
1531
1537
|
return res
|
|
@@ -10,6 +10,25 @@
|
|
|
10
10
|
* Handles a couple special tamagui cases
|
|
11
11
|
* - classNames can be extracted out separately
|
|
12
12
|
* - shorthands can be expanded before merging
|
|
13
|
+
* - pseudo props and variants maintain runtime order for proper priority
|
|
14
|
+
*
|
|
15
|
+
* Example of variant/pseudo prop ordering importance:
|
|
16
|
+
* const StyledButton = styled(Button, {
|
|
17
|
+
* pressStyle: { bg: '$blue10' },
|
|
18
|
+
* variants: {
|
|
19
|
+
* variant: {
|
|
20
|
+
* default: { pressStyle: { bg: 'red', scale: 1.05 } }
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* })
|
|
24
|
+
*
|
|
25
|
+
* case 1: variant first, then pressStyle
|
|
26
|
+
* <StyledButton variant='default' pressStyle={{ bg: 'orange' }} />
|
|
27
|
+
* output: {variant: 'default', pressStyle: {bg: 'orange'}}
|
|
28
|
+
*
|
|
29
|
+
* case 2: pressStyle first, then variant
|
|
30
|
+
* <StyledButton pressStyle={{ bg: 'orange' }} variant='default' />
|
|
31
|
+
* output: {pressStyle: {bg: 'orange'}, variant: 'default'}
|
|
13
32
|
*/
|
|
14
33
|
|
|
15
34
|
import { mediaKeys } from '../hooks/useMedia'
|
|
@@ -27,6 +46,35 @@ export const mergeProps = (a: Object, b?: Object, inverseShorthands?: AnyRecord)
|
|
|
27
46
|
mergeProp(out, b, undefined, key, inverseShorthands)
|
|
28
47
|
}
|
|
29
48
|
}
|
|
49
|
+
|
|
50
|
+
// Targeted reordering: only reorder pseudo props and variants that need runtime order
|
|
51
|
+
if (b && Object.keys(b).length > 0) {
|
|
52
|
+
// Check if we have any pseudo props or variants that need reordering
|
|
53
|
+
const hasPropsNeedingReorder = Object.keys(b).some(
|
|
54
|
+
(key) => (key in pseudoDescriptors || key === 'variant') && key in a && key in out
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
if (hasPropsNeedingReorder) {
|
|
58
|
+
const reordered: AnyRecord = {}
|
|
59
|
+
|
|
60
|
+
// First: Add pseudo props and variants that need specific ordering from runtime props (b)
|
|
61
|
+
for (const key in b) {
|
|
62
|
+
if ((key in pseudoDescriptors || key === 'variant') && key in out) {
|
|
63
|
+
reordered[key] = out[key]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Second: Add all other props in their original order
|
|
68
|
+
for (const key in out) {
|
|
69
|
+
if (!(key in reordered)) {
|
|
70
|
+
reordered[key] = out[key]
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return reordered
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
30
78
|
return out
|
|
31
79
|
}
|
|
32
80
|
|
|
@@ -40,10 +88,7 @@ function mergeProp(
|
|
|
40
88
|
const longhand = inverseShorthands?.[key] || null
|
|
41
89
|
const val = a[key]
|
|
42
90
|
|
|
43
|
-
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
|
|
91
|
+
// This ensures styled definition and runtime props are always merged
|
|
47
92
|
if (key in pseudoDescriptors || mediaKeys.has(key)) {
|
|
48
93
|
out[key] = {
|
|
49
94
|
...out[key],
|
|
@@ -52,5 +97,9 @@ function mergeProp(
|
|
|
52
97
|
return
|
|
53
98
|
}
|
|
54
99
|
|
|
100
|
+
if (b && (key in b || (longhand && longhand in b))) {
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
55
104
|
out[longhand || key] = val
|
|
56
105
|
}
|
|
@@ -237,6 +237,7 @@ function hasAnimatedStyleValue(style: Object) {
|
|
|
237
237
|
const isDisabled = (props: any) => {
|
|
238
238
|
return (
|
|
239
239
|
props.disabled ||
|
|
240
|
+
props.passThrough ||
|
|
240
241
|
props.accessibilityState?.disabled ||
|
|
241
242
|
props['aria-disabled'] ||
|
|
242
243
|
props.accessibilityDisabled ||
|
package/src/hooks/useProps.tsx
CHANGED
|
@@ -122,7 +122,7 @@ export function usePropsAndStyle<A extends PropsLikeObject>(
|
|
|
122
122
|
groupContext
|
|
123
123
|
)
|
|
124
124
|
|
|
125
|
-
const { mediaGroups, pseudoGroups } = splitStyles
|
|
125
|
+
const { mediaGroups, pseudoGroups } = splitStyles || {}
|
|
126
126
|
|
|
127
127
|
useIsomorphicLayoutEffect(() => {
|
|
128
128
|
if (disabled) {
|
|
@@ -149,5 +149,10 @@ export function usePropsAndStyle<A extends PropsLikeObject>(
|
|
|
149
149
|
mediaGroups ? Object.keys([...mediaGroups]).join('') : 0,
|
|
150
150
|
])
|
|
151
151
|
|
|
152
|
-
return [
|
|
152
|
+
return [
|
|
153
|
+
splitStyles?.viewProps || {},
|
|
154
|
+
splitStyles?.style || {},
|
|
155
|
+
theme,
|
|
156
|
+
mediaState,
|
|
157
|
+
] as any
|
|
153
158
|
}
|