@tamagui/web 2.2.0 → 2.3.0
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/.turbo/turbo-build.log +1 -1
- package/dist/cjs/createComponent.cjs +26 -5
- package/dist/cjs/createComponent.native.js +30 -5
- package/dist/cjs/createComponent.native.js.map +1 -1
- package/dist/cjs/helpers/mainThreadPressEvents.native.js +14 -3
- package/dist/cjs/helpers/mainThreadPressEvents.native.js.map +1 -1
- package/dist/cjs/hooks/useComponentState.cjs +4 -2
- package/dist/cjs/hooks/useComponentState.native.js +5 -3
- package/dist/cjs/hooks/useComponentState.native.js.map +1 -1
- package/dist/cjs/opacityModifier.test-d.cjs +24 -0
- package/dist/cjs/opacityModifier.test-d.native.js +27 -0
- package/dist/cjs/opacityModifier.test-d.native.js.map +1 -0
- package/dist/esm/createComponent.mjs +23 -6
- package/dist/esm/createComponent.mjs.map +1 -1
- package/dist/esm/createComponent.native.js +31 -6
- package/dist/esm/createComponent.native.js.map +1 -1
- package/dist/esm/helpers/mainThreadPressEvents.native.js +14 -3
- package/dist/esm/helpers/mainThreadPressEvents.native.js.map +1 -1
- package/dist/esm/hooks/useComponentState.mjs +5 -3
- package/dist/esm/hooks/useComponentState.mjs.map +1 -1
- package/dist/esm/hooks/useComponentState.native.js +6 -4
- package/dist/esm/hooks/useComponentState.native.js.map +1 -1
- package/dist/esm/opacityModifier.test-d.mjs +25 -0
- package/dist/esm/opacityModifier.test-d.mjs.map +1 -0
- package/dist/esm/opacityModifier.test-d.native.js +25 -0
- package/dist/esm/opacityModifier.test-d.native.js.map +1 -0
- package/package.json +13 -13
- package/src/createComponent.tsx +67 -5
- package/src/helpers/mainThreadPressEvents.native.ts +20 -2
- package/src/hooks/useComponentState.ts +17 -2
- package/src/opacityModifier.test-d.ts +57 -0
- package/src/types.tsx +18 -3
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/mainThreadPressEvents.native.d.ts.map +1 -1
- package/types/hooks/useComponentState.d.ts +1 -0
- package/types/hooks/useComponentState.d.ts.map +1 -1
- package/types/types.d.ts +5 -3
- package/types/types.d.ts.map +1 -1
|
@@ -50,10 +50,17 @@ function useMainThreadPressEvents(events, viewProps) {
|
|
|
50
50
|
ref.current.pressOutTimer = null;
|
|
51
51
|
ref.current.longPressTimer = null;
|
|
52
52
|
}
|
|
53
|
-
viewProps.onStartShouldSetResponder
|
|
54
|
-
|
|
53
|
+
var userStartShouldSet = viewProps.onStartShouldSetResponder;
|
|
54
|
+
var userGrant = viewProps.onResponderGrant;
|
|
55
|
+
var userRelease = viewProps.onResponderRelease;
|
|
56
|
+
var userTerminate = viewProps.onResponderTerminate;
|
|
57
|
+
var userTerminationRequest = viewProps.onResponderTerminationRequest;
|
|
58
|
+
var userMove = viewProps.onResponderMove;
|
|
59
|
+
viewProps.onStartShouldSetResponder = function (e) {
|
|
60
|
+
return Boolean(userStartShouldSet === null || userStartShouldSet === void 0 ? void 0 : userStartShouldSet(e)) || !events.disabled;
|
|
55
61
|
};
|
|
56
62
|
viewProps.onResponderGrant = function (e) {
|
|
63
|
+
userGrant === null || userGrant === void 0 ? void 0 : userGrant(e);
|
|
57
64
|
cleanup();
|
|
58
65
|
ref.current.state = "pressing";
|
|
59
66
|
if (delayPressIn > 0) {
|
|
@@ -74,6 +81,7 @@ function useMainThreadPressEvents(events, viewProps) {
|
|
|
74
81
|
}
|
|
75
82
|
};
|
|
76
83
|
viewProps.onResponderRelease = function (e) {
|
|
84
|
+
userRelease === null || userRelease === void 0 ? void 0 : userRelease(e);
|
|
77
85
|
var wasLongPressed = ref.current.state === "longPressed";
|
|
78
86
|
cleanup();
|
|
79
87
|
if (ref.current.state === "pressing") {
|
|
@@ -87,17 +95,20 @@ function useMainThreadPressEvents(events, viewProps) {
|
|
|
87
95
|
ref.current.state = "idle";
|
|
88
96
|
};
|
|
89
97
|
viewProps.onResponderTerminate = function (e) {
|
|
98
|
+
userTerminate === null || userTerminate === void 0 ? void 0 : userTerminate(e);
|
|
90
99
|
cleanup();
|
|
91
100
|
if (ref.current.state === "active" || ref.current.state === "longPressed") {
|
|
92
101
|
deactivate(e);
|
|
93
102
|
}
|
|
94
103
|
ref.current.state = "idle";
|
|
95
104
|
};
|
|
96
|
-
viewProps.onResponderTerminationRequest = function () {
|
|
105
|
+
viewProps.onResponderTerminationRequest = function (e) {
|
|
106
|
+
if (userTerminationRequest) return userTerminationRequest(e);
|
|
97
107
|
return events.cancelable !== false;
|
|
98
108
|
};
|
|
99
109
|
viewProps.onResponderMove = function (e) {
|
|
100
110
|
var _events_onPressMove;
|
|
111
|
+
userMove === null || userMove === void 0 ? void 0 : userMove(e);
|
|
101
112
|
(_events_onPressMove = events.onPressMove) === null || _events_onPressMove === void 0 ? void 0 : _events_onPressMove.call(events, e);
|
|
102
113
|
};
|
|
103
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRef","DEFAULT_LONG_PRESS_DELAY","DEFAULT_MIN_PRESS_DURATION","useMainThreadPressEvents","events","viewProps","enabled","arguments","length","debugName","ref","current","state","pressInTimer","pressOutTimer","longPressTimer","activateTime","_events_delayPressIn","delayPressIn","Math","max","_events_delayPressOut","delayPressOut","_events_delayLongPress","delayLongPress","_events_minPressDuration","minPressDuration","activate","e","_events_onPressIn","Date","now","onPressIn","call","deactivate","pressDuration","remaining","setTimeout","_events_onPressOut2","onPressOut","_events_onPressOut","cleanup","clearTimeout","onStartShouldSetResponder","
|
|
1
|
+
{"version":3,"names":["useRef","DEFAULT_LONG_PRESS_DELAY","DEFAULT_MIN_PRESS_DURATION","useMainThreadPressEvents","events","viewProps","enabled","arguments","length","debugName","ref","current","state","pressInTimer","pressOutTimer","longPressTimer","activateTime","_events_delayPressIn","delayPressIn","Math","max","_events_delayPressOut","delayPressOut","_events_delayLongPress","delayLongPress","_events_minPressDuration","minPressDuration","activate","e","_events_onPressIn","Date","now","onPressIn","call","deactivate","pressDuration","remaining","setTimeout","_events_onPressOut2","onPressOut","_events_onPressOut","cleanup","clearTimeout","userStartShouldSet","onStartShouldSetResponder","userGrant","onResponderGrant","userRelease","onResponderRelease","userTerminate","onResponderTerminate","userTerminationRequest","onResponderTerminationRequest","userMove","onResponderMove","Boolean","disabled","onLongPress","_events_onLongPress","wasLongPressed","_events_onPress","onPress","cancelable","_events_onPressMove","onPressMove"],"sources":["../../../src/helpers/mainThreadPressEvents.native.ts"],"sourcesContent":[null],"mappings":"AAMI,SAASA,MAAA,QAAc;AAI3B,IAAIC,wBAAA,GAA2B;AAC/B,IAAIC,0BAAA,GAA6B;AAC1B,SAASC,yBAAyBC,MAAA,EAAQC,SAAA,EAAW;EACxD,IAAIC,OAAA,GAAUC,SAAA,CAAUC,MAAA,GAAS,KAAKD,SAAA,CAAU,CAAC,MAAM,SAASA,SAAA,CAAU,CAAC,IAAI;IAAME,SAAA,GAAYF,SAAA,CAAUC,MAAA,GAAS,IAAID,SAAA,CAAU,CAAC,IAAI;EACvI,IAAIG,GAAA,GAAMV,MAAA,CAAO,IAAI;EACrB,IAAI,CAACU,GAAA,CAAIC,OAAA,EAAS;IACdD,GAAA,CAAIC,OAAA,GAAU;MACVC,KAAA,EAAO;MACPC,YAAA,EAAc;MACdC,aAAA,EAAe;MACfC,cAAA,EAAgB;MAChBC,YAAA,EAAc;IAClB;EACJ;EACA,IAAI,CAACV,OAAA,IAAW,CAACF,MAAA,EAAQ;EACzB,IAAIa,oBAAA;EACJ,IAAIC,YAAA,GAAeC,IAAA,CAAKC,GAAA,CAAI,IAAIH,oBAAA,GAAuBb,MAAA,CAAOc,YAAA,MAAkB,QAAQD,oBAAA,KAAyB,SAASA,oBAAA,GAAuB,CAAC;EAClJ,IAAII,qBAAA;EACJ,IAAIC,aAAA,GAAgBH,IAAA,CAAKC,GAAA,CAAI,IAAIC,qBAAA,GAAwBjB,MAAA,CAAOkB,aAAA,MAAmB,QAAQD,qBAAA,KAA0B,SAASA,qBAAA,GAAwB,CAAC;EACvJ,IAAIE,sBAAA;EAC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,KAAA,GAAQ;EACxB;EACAP,SAAA,CAAU6C,oBAAA,GAAuB,UAAStB,CAAA,EAAG;IACzCqB,aAAA,KAAkB,QAAQA,aAAA,KAAkB,SAAS,SAASA,aAAA,CAAcrB,CAAC;IAC7Ea,OAAA,CAAQ;IACR,IAAI/B,GAAA,CAAIC,OAAA,CAAQC,KAAA,KAAU,YAAYF,GAAA,CAAIC,OAAA,CAAQC,KAAA,KAAU,eAAe;MACvEsB,UAAA,CAAWN,CAAC;IAChB;IACAlB,GAAA,CAAIC,OAAA,CAAQC,KAAA,GAAQ;EACxB;EACAP,SAAA,CAAU+C,6BAAA,GAAgC,UAASxB,CAAA,EAAG;IAClD,IAAIuB,sBAAA,EAAwB,OAAOA,sBAAA,CAAuBvB,CAAC;IAC3D,OAAOxB,MAAA,CAAO0D,UAAA,KAAe;EACjC;EACAzD,SAAA,CAAUiD,eAAA,GAAkB,UAAS1B,CAAA,EAAG;IACpC,IAAImC,mBAAA;IACJV,QAAA,KAAa,QAAQA,QAAA,KAAa,SAAS,SAASA,QAAA,CAASzB,CAAC;IAC9D,CAACmC,mBAAA,GAAsB3D,MAAA,CAAO4D,WAAA,MAAiB,QAAQD,mBAAA,KAAwB,SAAS,SAASA,mBAAA,CAAoB9B,IAAA,CAAK7B,MAAA,EAAQwB,CAAC;EACvI;AACJ","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isServer, isWeb } from "@tamagui/constants";
|
|
1
|
+
import { getPlatformDriver, isServer, isWeb } from "@tamagui/constants";
|
|
2
2
|
import { useCreateShallowSetState } from "@tamagui/is-equal-shallow";
|
|
3
3
|
import { useDidFinishSSR, useIsClientOnly } from "@tamagui/use-did-finish-ssr";
|
|
4
4
|
import { useRef, useState } from "react";
|
|
@@ -30,8 +30,9 @@ const useComponentState = (props, animationDriver, staticConfig, config) => {
|
|
|
30
30
|
if (!needsHydration && hasAnimationProp) {
|
|
31
31
|
curStateRef.hasAnimated = true;
|
|
32
32
|
}
|
|
33
|
+
const platformPseudo = Boolean(!isHOC && useAnimations && animationDriver?.avoidReRenders && getPlatformDriver()?.pseudo && ("hoverStyle" in props || "pressStyle" in props || "focusStyle" in props));
|
|
33
34
|
const willBeAnimatedClient = (() => {
|
|
34
|
-
const next = !!(hasAnimationProp && !isHOC && useAnimations);
|
|
35
|
+
const next = !!((hasAnimationProp || platformPseudo) && !isHOC && useAnimations);
|
|
35
36
|
return Boolean(next || curStateRef.hasAnimated);
|
|
36
37
|
})();
|
|
37
38
|
const willBeAnimated = !isServer && willBeAnimatedClient;
|
|
@@ -154,7 +155,8 @@ const useComponentState = (props, animationDriver, staticConfig, config) => {
|
|
|
154
155
|
inputStyle,
|
|
155
156
|
outputStyle,
|
|
156
157
|
willBeAnimated,
|
|
157
|
-
willBeAnimatedClient
|
|
158
|
+
willBeAnimatedClient,
|
|
159
|
+
platformPseudo
|
|
158
160
|
};
|
|
159
161
|
};
|
|
160
162
|
function hasAnimatedStyleValue(style) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isServer","isWeb","useCreateShallowSetState","useDidFinishSSR","useIsClientOnly","useRef","useState","getSetting","defaultComponentState","defaultComponentStateMounted","defaultComponentStateShouldEnter","isObj","log","useComponentState","props","animationDriver","staticConfig","config","isHydrated","needsHydration","useAnimations","isStub","isHOC","stateRef","current","startedUnhydrated","hasAnimationProp","Boolean","style","hasAnimatedStyleValue","inputStyle","outputStyle","curStateRef","hasAnimated","willBeAnimatedClient","next","willBeAnimated","disableClassName","presence","usePresence","presenceState","isExiting","isPresent","isEntering","initial","hasEnterStyle","enterStyle","hasAnimationThatNeedsHydrate","isReactNative","canImmediatelyEnter","shouldEnter","initialState","disabled","isDisabled","states","state","forceStyle","setState","isAnimated","willHydrate","Object","assign","_","groupName","group","setStateShallow","debug","variants","process","env","NODE_ENV","console","warn","JSON","stringify","enterVariant","exitVariant","enterExitVariant","custom","exv","unmounted","noClass","isAnimatedAndHydrated","isClassNameDisabled","acceptsClassName","isDisabledManually","keys","some","k","val","passThrough","accessibilityState","accessibilityDisabled"],"sources":["../../../src/hooks/useComponentState.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,EAAUC,KAAA,QAAa;
|
|
1
|
+
{"version":3,"names":["getPlatformDriver","isServer","isWeb","useCreateShallowSetState","useDidFinishSSR","useIsClientOnly","useRef","useState","getSetting","defaultComponentState","defaultComponentStateMounted","defaultComponentStateShouldEnter","isObj","log","useComponentState","props","animationDriver","staticConfig","config","isHydrated","needsHydration","useAnimations","isStub","isHOC","stateRef","current","startedUnhydrated","hasAnimationProp","Boolean","style","hasAnimatedStyleValue","inputStyle","outputStyle","curStateRef","hasAnimated","platformPseudo","avoidReRenders","pseudo","willBeAnimatedClient","next","willBeAnimated","disableClassName","presence","usePresence","presenceState","isExiting","isPresent","isEntering","initial","hasEnterStyle","enterStyle","hasAnimationThatNeedsHydrate","isReactNative","canImmediatelyEnter","shouldEnter","initialState","disabled","isDisabled","states","state","forceStyle","setState","isAnimated","willHydrate","Object","assign","_","groupName","group","setStateShallow","debug","variants","process","env","NODE_ENV","console","warn","JSON","stringify","enterVariant","exitVariant","enterExitVariant","custom","exv","unmounted","noClass","isAnimatedAndHydrated","isClassNameDisabled","acceptsClassName","isDisabledManually","keys","some","k","val","passThrough","accessibilityState","accessibilityDisabled"],"sources":["../../../src/hooks/useComponentState.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,iBAAA,EAAmBC,QAAA,EAAUC,KAAA,QAAa;AACnD,SAASC,wBAAA,QAAgC;AACzC,SAASC,eAAA,EAAiBC,eAAA,QAAuB;AACjD,SAASC,MAAA,EAAQC,QAAA,QAAgB;AACjC,SAASC,UAAA,QAAkB;AAC3B,SACEC,qBAAA,EACAC,4BAAA,EACAC,gCAAA,QACK;AACP,SAASC,KAAA,QAAa;AACtB,SAASC,GAAA,QAAW;AAYb,MAAMC,iBAAA,GAAoBA,CAC/BC,KAAA,EACAC,eAAA,EACAC,YAAA,EACAC,MA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A,CAAYP,iBAAA;IAC/BO,WAAA;IACAuB,QAAA;IACAW,SAAA;IACAxC,gBAAA;IACAsB,aAAA;IACAa,UAAA;IACAjB,SAAA;IACA1B,UAAA;IACAuB,QAAA;IACAE,aAAA;IACAiB,QAAA;IACAQ,eAAA;IACAgB,OAAA;IACA1B,KAAA;IACAnC,QAAA;IACAO,UAAA;IACAC,WAAA;IACAQ,cAAA;IACAF,oBAAA;IACAH;EACF;AACF;AAEA,SAASL,sBAAsBD,KAAA,EAAe;EAC5C,OAAOmC,MAAA,CAAO0B,IAAA,CAAK7D,KAAK,EAAE8D,IAAA,CAAMC,CAAA,IAAM;IACpC,MAAMC,GAAA,GAAMhE,KAAA,CAAM+D,CAAC;IACnB,OAAOC,GAAA,IAAO,OAAOA,GAAA,KAAQ,YAAY,gBAAgBA,GAAA;EAC3D,CAAC;AACH;AAEA,MAAMpC,UAAA,GAAc1C,KAAA,IAAe;EACjC,OACEA,KAAA,CAAMyC,QAAA,IACNzC,KAAA,CAAM+E,WAAA,IACN/E,KAAA,CAAMgF,kBAAA,EAAoBvC,QAAA,IAC1BzC,KAAA,CAAM,eAAe,KACrBA,KAAA,CAAMiF,qBAAA,IACN;AAEJ","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isServer, isWeb } from "@tamagui/constants";
|
|
1
|
+
import { getPlatformDriver, isServer, isWeb } from "@tamagui/constants";
|
|
2
2
|
import { useCreateShallowSetState } from "@tamagui/is-equal-shallow";
|
|
3
3
|
import { useDidFinishSSR, useIsClientOnly } from "@tamagui/use-did-finish-ssr";
|
|
4
4
|
import { useRef, useState } from "react";
|
|
@@ -14,7 +14,7 @@ function _type_of(obj) {
|
|
|
14
14
|
var useComponentState = function (props, animationDriver, staticConfig, config) {
|
|
15
15
|
"use no memo";
|
|
16
16
|
|
|
17
|
-
var _animationDriver_usePresence;
|
|
17
|
+
var _getPlatformDriver, _animationDriver_usePresence;
|
|
18
18
|
var isHydrated = useDidFinishSSR();
|
|
19
19
|
var needsHydration = !useIsClientOnly();
|
|
20
20
|
var useAnimations = (animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.isStub) ? void 0 : animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.useAnimations;
|
|
@@ -38,8 +38,9 @@ var useComponentState = function (props, animationDriver, staticConfig, config)
|
|
|
38
38
|
if (!needsHydration && hasAnimationProp) {
|
|
39
39
|
curStateRef.hasAnimated = true;
|
|
40
40
|
}
|
|
41
|
+
var platformPseudo = Boolean(!isHOC && useAnimations && (animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.avoidReRenders) && ((_getPlatformDriver = getPlatformDriver()) === null || _getPlatformDriver === void 0 ? void 0 : _getPlatformDriver.pseudo) && ("hoverStyle" in props || "pressStyle" in props || "focusStyle" in props));
|
|
41
42
|
var willBeAnimatedClient = function () {
|
|
42
|
-
var next = !!(hasAnimationProp && !isHOC && useAnimations);
|
|
43
|
+
var next = !!((hasAnimationProp || platformPseudo) && !isHOC && useAnimations);
|
|
43
44
|
return Boolean(next || curStateRef.hasAnimated);
|
|
44
45
|
}();
|
|
45
46
|
var willBeAnimated = !isServer && willBeAnimatedClient;
|
|
@@ -164,7 +165,8 @@ var useComponentState = function (props, animationDriver, staticConfig, config)
|
|
|
164
165
|
inputStyle,
|
|
165
166
|
outputStyle,
|
|
166
167
|
willBeAnimated,
|
|
167
|
-
willBeAnimatedClient
|
|
168
|
+
willBeAnimatedClient,
|
|
169
|
+
platformPseudo
|
|
168
170
|
};
|
|
169
171
|
};
|
|
170
172
|
function hasAnimatedStyleValue(style) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isServer","isWeb","useCreateShallowSetState","useDidFinishSSR","useIsClientOnly","useRef","useState","getSetting","defaultComponentState","defaultComponentStateMounted","defaultComponentStateShouldEnter","isObj","log","_type_of","obj","Symbol","constructor","useComponentState","props","animationDriver","staticConfig","config","_animationDriver_usePresence","isHydrated","needsHydration","useAnimations","isStub","isHOC","stateRef","current","startedUnhydrated","hasAnimationProp","Boolean","style","hasAnimatedStyleValue","_animationDriver_inputStyle","inputStyle","_animationDriver_outputStyle","outputStyle","curStateRef","hasAnimated","willBeAnimatedClient","next","willBeAnimated","disableClassName","presence","usePresence","call","presenceState","isExiting","isPresent","isEntering","initial","hasEnterStyle","enterStyle","hasAnimationThatNeedsHydrate","isReactNative","canImmediatelyEnter","shouldEnter","initialState","disabled","isDisabled","states","state","forceStyle","setState","isAnimated","willHydrate","Object","assign","_","groupName","group","setStateShallow","debug","variants","process","env","NODE_ENV","console","warn","JSON","stringify","enterVariant","exitVariant","enterExitVariant","custom","exv","unmounted","noClass","isAnimatedAndHydrated","isClassNameDisabled","acceptsClassName","isDisabledManually"],"sources":["../../../src/hooks/useComponentState.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,EAAUC,KAAA,QAAa;
|
|
1
|
+
{"version":3,"names":["getPlatformDriver","isServer","isWeb","useCreateShallowSetState","useDidFinishSSR","useIsClientOnly","useRef","useState","getSetting","defaultComponentState","defaultComponentStateMounted","defaultComponentStateShouldEnter","isObj","log","_type_of","obj","Symbol","constructor","useComponentState","props","animationDriver","staticConfig","config","_getPlatformDriver","_animationDriver_usePresence","isHydrated","needsHydration","useAnimations","isStub","isHOC","stateRef","current","startedUnhydrated","hasAnimationProp","Boolean","style","hasAnimatedStyleValue","_animationDriver_inputStyle","inputStyle","_animationDriver_outputStyle","outputStyle","curStateRef","hasAnimated","platformPseudo","avoidReRenders","pseudo","willBeAnimatedClient","next","willBeAnimated","disableClassName","presence","usePresence","call","presenceState","isExiting","isPresent","isEntering","initial","hasEnterStyle","enterStyle","hasAnimationThatNeedsHydrate","isReactNative","canImmediatelyEnter","shouldEnter","initialState","disabled","isDisabled","states","state","forceStyle","setState","isAnimated","willHydrate","Object","assign","_","groupName","group","setStateShallow","debug","variants","process","env","NODE_ENV","console","warn","JSON","stringify","enterVariant","exitVariant","enterExitVariant","custom","exv","unmounted","noClass","isAnimatedAndHydrated","isClassNameDisabled","acceptsClassName","isDisabledManually","keys","some","k","val"],"sources":["../../../src/hooks/useComponentState.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,iBAAA,EAAmBC,QAAA,EAAUC,KAAA,QAAa;AACnD,SAASC,wBAAA,QAAgC;AACzC,SAASC,eAAA,EAAiBC,eAAA,QAAuB;AACjD,SAASC,MAAA,EAAQC,QAAA,QAAgB;AACjC,SAASC,UAAA,QAAkB;AAC3B,SAAAC,qBAAA,EAAAC,4BAAA,EAAAC,gCAAA;AAAA,SACEC,KAAA;AAAA,SACAC,GAAA;AAAA,SACAC,SAAAC,GAAA;EAAA,uBACK;;EACP,OAASA,GAAA,WAAaC,MAAA,oBAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AACtB;AAYO,IAAAG,iBAAM,YAAAA,CACXC,KACA,EAAAC,eACA,EAAAC,YACA,EAAAC,MACG;EACH;;EAEA,IAAAC,kBAAmB,EAAAC,4BAAgB;EACnC,IAAAC,UAAM,GAAArB,eAAkB;EAExB,IAAAsB,cAAM,IAAgBrB,eAAA,EAAiB;EAIvC,IAAAsB,aAAc,GAAI,CAAAP,eAAA,aAAAA,eAAA,uBAAAA,eAAA,CAAAQ,MAAA,aAAAR,eAAA,aAAAA,eAAA,uBAAAA,eAAA,CAAAO,aAAA;EAElB;IAAME;EAAA,IAAAR,YAAW;EAAA,IAAAS,QAAA,GAAAxB,MAAA;EAEf;EACF,MAEA;EACE,KAAAwB,QAAS,CAAAC,OAAU;IAAAD,QACjB,CAAAC,OAAA;MACFC,iBAAA,EAAAN,cAAA,KAAAD;IACF;EAGA;EAAyB,IACrBQ,gBAAS,GAAAC,OAAgB,EAAAL,KAC1B,gBAAe,IAAAV,KAAA,IAAAA,KAAA,CAAAgB,KAAsB,IAAMC,qBAAK,CAAAjB,KAAA,CAAAgB,KAAA;EACnD,IAAAE,2BAAA;EAEA,IAAAC,UAAM,IAAAD,2BAA8B,GAAAjB,eA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AAH,WAAA,KAAAC,gBAAA;IAOL;EACE;EAEA,IAAAI,OAAM,IAAA5F,KAAA,MAAAiB,KAAA,CACJkD,UAAC;EAEH,KAAA5C,UAAM;IAENqE,OAAA;EAAA;IAAA,IAEG5F,KAAA,IAAAuB,UAAA;MAED,IACAsE,qBAAA,GAAAxB,UAAA,IAAA9C,UAAA;MACA,IAAAuE,mBAAU,IAAA3E,YAAA,CAAA4E,gBAAA,KAAAzF,UAAA,mBAAA4D,KAAA,CAAAyB,SAAA;MAEV,IAAAK,kBAAgB,GAAAjD,gBAAa,KAAAmB,KAAiB,CAAAyB,SAAM;MAClD;MAA0B;MACxBE,qBACA,IAAAvD,WAAA,cAAA0D,kBAAA,IAAAF,mBAAA;QACAF,OACD;QACH,IAAAb,OAAA,CAAAC,GAAA,CAAAC,QAAA,sBAAAhE,KAAA,CAAA4D,KAAA;UACFlE,GAAA;YACFkF,qBAAA;YACFG,kBAAA;YAEOF;UACL;QACA;MACA;IACA;EAAA;EACA,OACA;IACAhE,iBAAA,EAAAS,WAAA,CAAAT,iBAAA;IACAS,WAAA;IACAwB,QAAA;IACAW,SAAA;IACA3C,gBAAA;IACAyB,aAAA;IACAa,UAAA;IACAjB,SAAA;IACA7B,UAAA;IACAyB,QAAA;IACAG,aAAA;IACAiB,QAAA;IACAQ,eAAA;IACAgB,OAAA;IACA1B,KAAA;IACFtC,QAAA;IACFQ,UAAA;IAEAE,WAAS;IACPQ,cAAc;IACZF,oBAAmB;IACnBH;EACF,CAAC;AACH;AAEA,SAAMP,qBAA6BA,CAAAD,KAAA;EACjC,OACEsC,MAAM,CAAA0B,IAAA,CAAAhE,KAAA,CACN,CAAAiE,IAAA,CAAM,UAAAC,CAAA;IAMV,IAAAC,GAAA,GAAAnE,KAAA,CAAAkE,CAAA","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { expectTypeOf, describe, test } from "vitest";
|
|
2
|
+
describe("opacity modifier types", () => {
|
|
3
|
+
test("ColorTokens accepts opacity modifier syntax", () => {
|
|
4
|
+
const colorWithOpacity = "$color/50";
|
|
5
|
+
const colorWithFullOpacity = "$color/100";
|
|
6
|
+
const colorWithLowOpacity = "$color/10";
|
|
7
|
+
const regularToken = "$color";
|
|
8
|
+
const colorName = "red";
|
|
9
|
+
expectTypeOf(colorWithOpacity).toMatchTypeOf();
|
|
10
|
+
expectTypeOf(colorWithFullOpacity).toMatchTypeOf();
|
|
11
|
+
expectTypeOf(colorWithLowOpacity).toMatchTypeOf();
|
|
12
|
+
expectTypeOf(regularToken).toMatchTypeOf();
|
|
13
|
+
expectTypeOf(colorName).toMatchTypeOf();
|
|
14
|
+
});
|
|
15
|
+
test("FontColorTokens is type-safe (no font color tokens in default config)", () => {
|
|
16
|
+
const fontColorNumber = 42;
|
|
17
|
+
expectTypeOf(fontColorNumber).toMatchTypeOf();
|
|
18
|
+
expectTypeOf().toMatchTypeOf();
|
|
19
|
+
});
|
|
20
|
+
test("opacity modifier rejects invalid formats", () => {
|
|
21
|
+
const validOpacity = "$color/75";
|
|
22
|
+
expectTypeOf(validOpacity).toMatchTypeOf();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=opacityModifier.test-d.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["expectTypeOf","describe","test","colorWithOpacity","colorWithFullOpacity","colorWithLowOpacity","regularToken","colorName","toMatchTypeOf","fontColorNumber","validOpacity"],"sources":["../../src/opacityModifier.test-d.ts"],"sourcesContent":[null],"mappings":"AAQA,SAASA,YAAA,EAAcC,QAAA,EAAUC,IAAA,QAAY;AAG7CD,QAAA,CAAS,0BAA0B,MAAM;EACvCC,IAAA,CAAK,+CAA+C,MAAM;IAExD,MAAMC,gBAAA,GAAgC;IACtC,MAAMC,oBAAA,GAAoC;IAC1C,MAAMC,mBAAA,GAAmC;IAGzC,MAAMC,YAAA,GAA4B;IAClC,MAAMC,SAAA,GAAyB;IAG/BP,YAAA,CAAaG,gBAAgB,EAAEK,aAAA,CAA2B;IAC1DR,YAAA,CAAaI,oBAAoB,EAAEI,aAAA,CAA2B;IAC9DR,YAAA,CAAaK,mBAAmB,EAAEG,aAAA,CAA2B;IAC7DR,YAAA,CAAaM,YAAY,EAAEE,aAAA,CAA2B;IACtDR,YAAA,CAAaO,SAAS,EAAEC,aAAA,CAA2B;EACrD,CAAC;EAEDN,IAAA,CAAK,yEAAyE,MAAM;IAMlF,MAAMO,eAAA,GAAmC;IAEzCT,YAAA,CAAaS,eAAe,EAAED,aAAA,CAA+B;IAC7DR,YAAA,CAAqB,EAAEQ,aAAA,CAA+B;EACxD,CAAC;EAEDN,IAAA,CAAK,4CAA4C,MAAM;IAKrD,MAAMQ,YAAA,GAA4B;IAClCV,YAAA,CAAaU,YAAY,EAAEF,aAAA,CAA2B;EAOxD,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { expectTypeOf, describe, test } from "vitest";
|
|
2
|
+
describe("opacity modifier types", function () {
|
|
3
|
+
test("ColorTokens accepts opacity modifier syntax", function () {
|
|
4
|
+
var colorWithOpacity = "$color/50";
|
|
5
|
+
var colorWithFullOpacity = "$color/100";
|
|
6
|
+
var colorWithLowOpacity = "$color/10";
|
|
7
|
+
var regularToken = "$color";
|
|
8
|
+
var colorName = "red";
|
|
9
|
+
expectTypeOf(colorWithOpacity).toMatchTypeOf();
|
|
10
|
+
expectTypeOf(colorWithFullOpacity).toMatchTypeOf();
|
|
11
|
+
expectTypeOf(colorWithLowOpacity).toMatchTypeOf();
|
|
12
|
+
expectTypeOf(regularToken).toMatchTypeOf();
|
|
13
|
+
expectTypeOf(colorName).toMatchTypeOf();
|
|
14
|
+
});
|
|
15
|
+
test("FontColorTokens is type-safe (no font color tokens in default config)", function () {
|
|
16
|
+
var fontColorNumber = 42;
|
|
17
|
+
expectTypeOf(fontColorNumber).toMatchTypeOf();
|
|
18
|
+
expectTypeOf().toMatchTypeOf();
|
|
19
|
+
});
|
|
20
|
+
test("opacity modifier rejects invalid formats", function () {
|
|
21
|
+
var validOpacity = "$color/75";
|
|
22
|
+
expectTypeOf(validOpacity).toMatchTypeOf();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=opacityModifier.test-d.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["expectTypeOf","describe","test","colorWithOpacity","colorWithFullOpacity","colorWithLowOpacity","regularToken","colorName","toMatchTypeOf","fontColorNumber","validOpacity"],"sources":["../../src/opacityModifier.test-d.ts"],"sourcesContent":[null],"mappings":"AAQA,SAASA,YAAA,EAAcC,QAAA,EAAUC,IAAA,QAAY;AAG7CD,QAAA,CAAS,0BAA0B,YAAM;EACvCC,IAAA,CAAK,+CAA+C,YAAM;IAExD,IAAAC,gBAAM,cAAgC;IACtC,IAAAC,oBAAM,eAAoC;IAC1C,IAAAC,mBAAM,cAAmC;IAGzC,IAAAC,YAAM,WAA4B;IAClC,IAAAC,SAAM,QAAyB;IAG/BP,YAAA,CAAaG,gBAAgB,EAAEK,aAAA,CAA2B;IAC1DR,YAAA,CAAaI,oBAAoB,EAAEI,aAAA,CAA2B;IAC9DR,YAAA,CAAaK,mBAAmB,EAAEG,aAAA,CAA2B;IAC7DR,YAAA,CAAaM,YAAY,EAAEE,aAAA,CAA2B;IACtDR,YAAA,CAAaO,SAAS,EAAEC,aAAA,CAA2B;EACrD,CAAC;EAEDN,IAAA,CAAK,yEAAyE,YAAM;IAMlF,IAAAO,eAAM,KAAmC;IAEzCT,YAAA,CAAaS,eAAe,EAAED,aAAA,CAA+B;IAC7DR,YAAA,CAAqB,EAAEQ,aAAA,CAA+B;EACxD,CAAC;EAEDN,IAAA,CAAK,4CAA4C,YAAM;IAKrD,IAAAQ,YAAM,cAA4B;IAClCV,YAAA,CAAaU,YAAY,EAAEF,aAAA,CAA2B;EAOxD,CAAC;AACH,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/web",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Nate Wienert"
|
|
@@ -51,20 +51,20 @@
|
|
|
51
51
|
"test:web": "vitest --typecheck --run"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@tamagui/compose-refs": "2.
|
|
55
|
-
"@tamagui/constants": "2.
|
|
56
|
-
"@tamagui/helpers": "2.
|
|
57
|
-
"@tamagui/is-equal-shallow": "2.
|
|
58
|
-
"@tamagui/native": "2.
|
|
59
|
-
"@tamagui/normalize-css-color": "2.
|
|
60
|
-
"@tamagui/timer": "2.
|
|
61
|
-
"@tamagui/types": "2.
|
|
62
|
-
"@tamagui/use-did-finish-ssr": "2.
|
|
63
|
-
"@tamagui/use-event": "2.
|
|
64
|
-
"@tamagui/use-force-update": "2.
|
|
54
|
+
"@tamagui/compose-refs": "2.3.0",
|
|
55
|
+
"@tamagui/constants": "2.3.0",
|
|
56
|
+
"@tamagui/helpers": "2.3.0",
|
|
57
|
+
"@tamagui/is-equal-shallow": "2.3.0",
|
|
58
|
+
"@tamagui/native": "2.3.0",
|
|
59
|
+
"@tamagui/normalize-css-color": "2.3.0",
|
|
60
|
+
"@tamagui/timer": "2.3.0",
|
|
61
|
+
"@tamagui/types": "2.3.0",
|
|
62
|
+
"@tamagui/use-did-finish-ssr": "2.3.0",
|
|
63
|
+
"@tamagui/use-event": "2.3.0",
|
|
64
|
+
"@tamagui/use-force-update": "2.3.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@tamagui/build": "2.
|
|
67
|
+
"@tamagui/build": "2.3.0",
|
|
68
68
|
"@testing-library/react": "^16.1.0",
|
|
69
69
|
"csstype": "^3.0.10",
|
|
70
70
|
"react": ">=19",
|
package/src/createComponent.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { composeRefs } from '@tamagui/compose-refs'
|
|
2
2
|
import {
|
|
3
|
+
getPlatformDriver,
|
|
3
4
|
isClient,
|
|
4
5
|
isNativeDesktop,
|
|
5
6
|
isServer,
|
|
@@ -445,6 +446,7 @@ export function createComponent<
|
|
|
445
446
|
outputStyle,
|
|
446
447
|
willBeAnimated,
|
|
447
448
|
willBeAnimatedClient,
|
|
449
|
+
platformPseudo,
|
|
448
450
|
startedUnhydrated,
|
|
449
451
|
} = componentState
|
|
450
452
|
|
|
@@ -457,6 +459,25 @@ export function createComponent<
|
|
|
457
459
|
// `nextState`, clear it. if they diverge (animated components' fast path never
|
|
458
460
|
// calls into React), flush via componentState.setStateShallow here.
|
|
459
461
|
useIsomorphicLayoutEffect(() => {
|
|
462
|
+
// first: refresh the emitter latch while a self pseudo is active. the driver
|
|
463
|
+
// keeps the last-emitted snapshot latched across re-renders (so an unrelated
|
|
464
|
+
// render doesn't snap a hovered style back to base), but a render can change
|
|
465
|
+
// the styles that FEED the pseudo merge — e.g. a row becoming active removes
|
|
466
|
+
// its hoverStyle while still hovered — and the stale snapshot would keep
|
|
467
|
+
// painting over the new base (hover-beats-active-during-scrub).
|
|
468
|
+
// `updateStyleListener` is rebuilt each render over fresh props/state and
|
|
469
|
+
// reads `nextState || state`, so re-invoking it re-emits the correct merged
|
|
470
|
+
// style: identical values when the render was truly unrelated (no visual
|
|
471
|
+
// change), fresh values when it wasn't. gate on the last-EMITTED pseudo state
|
|
472
|
+
// (prevPseudoState), not React state — React state can lag the emitter by a
|
|
473
|
+
// commit, and a stale-true `state.hover` here would resurrect a hover the
|
|
474
|
+
// emitter already cleared. this must run BEFORE the nextState flush below so
|
|
475
|
+
// the re-emit still sees the freshest pseudo state.
|
|
476
|
+
const emitted = stateRef.current.prevPseudoState
|
|
477
|
+
if (emitted && (emitted.hover || emitted.press || emitted.focus)) {
|
|
478
|
+
stateRef.current.updateStyleListener?.()
|
|
479
|
+
}
|
|
480
|
+
|
|
460
481
|
const pendingState = stateRef.current.nextState
|
|
461
482
|
if (!pendingState) return
|
|
462
483
|
stateRef.current.nextState = undefined
|
|
@@ -466,6 +487,24 @@ export function createComponent<
|
|
|
466
487
|
})
|
|
467
488
|
}
|
|
468
489
|
|
|
490
|
+
// renderer-driven pseudo states (setupPlatformDriver): the platform resolves
|
|
491
|
+
// hover natively per hitbox and pushes flips here, replacing the
|
|
492
|
+
// mouseEnter/mouseLeave lane on such renderers. the flip applies through the
|
|
493
|
+
// same setStateShallow the event handlers use — under the (driver-opened)
|
|
494
|
+
// avoidReRenders gate that's the emitter path: zero React commits, animated
|
|
495
|
+
// per the declared transition or instant by default. press stays on the
|
|
496
|
+
// responder event path (it must fire onPress anyway); the driver only owns
|
|
497
|
+
// the hover trigger for now.
|
|
498
|
+
useIsomorphicLayoutEffect(() => {
|
|
499
|
+
if (!platformPseudo || props.disabled) return
|
|
500
|
+
const pseudoDriver = getPlatformDriver()?.pseudo
|
|
501
|
+
const host = stateRef.current.host
|
|
502
|
+
if (!pseudoDriver || !host) return
|
|
503
|
+
return pseudoDriver.subscribe(host, ({ hovered }) => {
|
|
504
|
+
stateRef.current.setStateShallow?.({ hover: hovered })
|
|
505
|
+
})
|
|
506
|
+
}, [platformPseudo, props.disabled])
|
|
507
|
+
|
|
469
508
|
// create new context with groups, or else sublings will grab the same one
|
|
470
509
|
const allGroupContexts = useMemo((): AllGroupContexts | null => {
|
|
471
510
|
if (!groupName || props.passThrough) {
|
|
@@ -742,7 +781,7 @@ export function createComponent<
|
|
|
742
781
|
|
|
743
782
|
if (
|
|
744
783
|
!isPassthrough &&
|
|
745
|
-
(hasAnimationProp || groupName) &&
|
|
784
|
+
(hasAnimationProp || groupName || platformPseudo) &&
|
|
746
785
|
animationDriver?.avoidReRenders &&
|
|
747
786
|
!hasEnterExitTransition
|
|
748
787
|
) {
|
|
@@ -790,13 +829,30 @@ export function createComponent<
|
|
|
790
829
|
stateRef.current.prevPseudoState,
|
|
791
830
|
updatedState,
|
|
792
831
|
nextStyles?.pseudoTransitions,
|
|
793
|
-
|
|
832
|
+
// platform-pseudo with no declared transition = instant (CSS :hover semantics)
|
|
833
|
+
props.transition ?? (platformPseudo ? '0ms' : undefined)
|
|
794
834
|
)
|
|
795
835
|
|
|
796
836
|
// update prev state for next comparison (includes group states)
|
|
797
837
|
stateRef.current.prevPseudoState = extractPseudoState(updatedState)
|
|
798
838
|
|
|
799
|
-
|
|
839
|
+
// a self pseudo being active means the emitted style is a transient hover/press/focus
|
|
840
|
+
// override (it's not in React state under avoidReRenders), so the worklet must keep it
|
|
841
|
+
// latched across incidental re-renders; when none is active this is the base and renders
|
|
842
|
+
// own it again.
|
|
843
|
+
const hasActivePseudo = Boolean(
|
|
844
|
+
updatedState.hover ||
|
|
845
|
+
updatedState.press ||
|
|
846
|
+
updatedState.pressIn ||
|
|
847
|
+
updatedState.focus ||
|
|
848
|
+
updatedState.focusWithin
|
|
849
|
+
)
|
|
850
|
+
|
|
851
|
+
useStyleListener(
|
|
852
|
+
(nextStyles?.style || {}) as any,
|
|
853
|
+
effectiveTransition,
|
|
854
|
+
hasActivePseudo
|
|
855
|
+
)
|
|
800
856
|
}
|
|
801
857
|
|
|
802
858
|
function updateGroupListeners() {
|
|
@@ -1011,7 +1067,8 @@ export function createComponent<
|
|
|
1011
1067
|
stateRef.current.prevPseudoState,
|
|
1012
1068
|
state,
|
|
1013
1069
|
splitStyles?.pseudoTransitions,
|
|
1014
|
-
|
|
1070
|
+
// platform-pseudo with no declared transition = instant (CSS :hover semantics)
|
|
1071
|
+
props.transition ?? (platformPseudo ? '0ms' : undefined)
|
|
1015
1072
|
)
|
|
1016
1073
|
|
|
1017
1074
|
// add effectiveTransition to splitStyles for drivers to consume
|
|
@@ -1254,7 +1311,12 @@ export function createComponent<
|
|
|
1254
1311
|
)
|
|
1255
1312
|
|
|
1256
1313
|
const runtimeHoverStyle = !disabled && noClass && pseudos?.hoverStyle
|
|
1257
|
-
|
|
1314
|
+
// with a platform pseudo driver the hover STATE is driver-sourced; only keep
|
|
1315
|
+
// the JS hover listeners when something else needs them (dynamic group
|
|
1316
|
+
// children, or the user's own onMouseEnter/Leave handlers below).
|
|
1317
|
+
const needsHoverState = Boolean(
|
|
1318
|
+
hasDynamicGroupChildren || (runtimeHoverStyle && !platformPseudo)
|
|
1319
|
+
)
|
|
1258
1320
|
const attachHover =
|
|
1259
1321
|
(isWeb || isNativeDesktop) &&
|
|
1260
1322
|
!!(hasDynamicGroupChildren || needsHoverState || onMouseEnter || onMouseLeave)
|
|
@@ -80,9 +80,23 @@ export function useMainThreadPressEvents(
|
|
|
80
80
|
ref.current.longPressTimer = null
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
// user-supplied responder props (the View's raw RN gesture API) must keep
|
|
84
|
+
// working: blindly overwriting them here silently killed any press-hold-drag
|
|
85
|
+
// gesture built on onResponderMove/onResponderRelease whenever the element
|
|
86
|
+
// also had hover/press events. compose instead — user handler first, then
|
|
87
|
+
// the press synthesis.
|
|
88
|
+
const userStartShouldSet = viewProps.onStartShouldSetResponder
|
|
89
|
+
const userGrant = viewProps.onResponderGrant
|
|
90
|
+
const userRelease = viewProps.onResponderRelease
|
|
91
|
+
const userTerminate = viewProps.onResponderTerminate
|
|
92
|
+
const userTerminationRequest = viewProps.onResponderTerminationRequest
|
|
93
|
+
const userMove = viewProps.onResponderMove
|
|
94
|
+
|
|
95
|
+
viewProps.onStartShouldSetResponder = (e: any) =>
|
|
96
|
+
Boolean(userStartShouldSet?.(e)) || !events.disabled
|
|
84
97
|
|
|
85
98
|
viewProps.onResponderGrant = (e: any) => {
|
|
99
|
+
userGrant?.(e)
|
|
86
100
|
cleanup()
|
|
87
101
|
ref.current.state = 'pressing'
|
|
88
102
|
|
|
@@ -103,6 +117,7 @@ export function useMainThreadPressEvents(
|
|
|
103
117
|
}
|
|
104
118
|
|
|
105
119
|
viewProps.onResponderRelease = (e: any) => {
|
|
120
|
+
userRelease?.(e)
|
|
106
121
|
const wasLongPressed = ref.current.state === 'longPressed'
|
|
107
122
|
cleanup()
|
|
108
123
|
|
|
@@ -120,6 +135,7 @@ export function useMainThreadPressEvents(
|
|
|
120
135
|
}
|
|
121
136
|
|
|
122
137
|
viewProps.onResponderTerminate = (e: any) => {
|
|
138
|
+
userTerminate?.(e)
|
|
123
139
|
cleanup()
|
|
124
140
|
if (ref.current.state === 'active' || ref.current.state === 'longPressed') {
|
|
125
141
|
deactivate(e)
|
|
@@ -127,11 +143,13 @@ export function useMainThreadPressEvents(
|
|
|
127
143
|
ref.current.state = 'idle'
|
|
128
144
|
}
|
|
129
145
|
|
|
130
|
-
viewProps.onResponderTerminationRequest = () => {
|
|
146
|
+
viewProps.onResponderTerminationRequest = (e: any) => {
|
|
147
|
+
if (userTerminationRequest) return userTerminationRequest(e)
|
|
131
148
|
return events.cancelable !== false
|
|
132
149
|
}
|
|
133
150
|
|
|
134
151
|
viewProps.onResponderMove = (e: any) => {
|
|
152
|
+
userMove?.(e)
|
|
135
153
|
events.onPressMove?.(e)
|
|
136
154
|
}
|
|
137
155
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isServer, isWeb } from '@tamagui/constants'
|
|
1
|
+
import { getPlatformDriver, isServer, isWeb } from '@tamagui/constants'
|
|
2
2
|
import { useCreateShallowSetState } from '@tamagui/is-equal-shallow'
|
|
3
3
|
import { useDidFinishSSR, useIsClientOnly } from '@tamagui/use-did-finish-ssr'
|
|
4
4
|
import { useRef, useState } from 'react'
|
|
@@ -63,8 +63,22 @@ export const useComponentState = (
|
|
|
63
63
|
curStateRef.hasAnimated = true
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
// a renderer platform driver with native pseudo states (react-native-gpui)
|
|
67
|
+
// makes ANY component with runtime pseudo styles ride the animation-driver
|
|
68
|
+
// emitter path — no per-site transition/animation prop required. the flip is
|
|
69
|
+
// driver-sourced (hover) or event-sourced (press/focus) but either way applies
|
|
70
|
+
// through the emitter with zero React commits; with no transition declared it
|
|
71
|
+
// resolves instant (see createComponent's effectiveTransition default).
|
|
72
|
+
const platformPseudo = Boolean(
|
|
73
|
+
!isHOC &&
|
|
74
|
+
useAnimations &&
|
|
75
|
+
animationDriver?.avoidReRenders &&
|
|
76
|
+
getPlatformDriver()?.pseudo &&
|
|
77
|
+
('hoverStyle' in props || 'pressStyle' in props || 'focusStyle' in props)
|
|
78
|
+
)
|
|
79
|
+
|
|
66
80
|
const willBeAnimatedClient = (() => {
|
|
67
|
-
const next = !!(hasAnimationProp && !isHOC && useAnimations)
|
|
81
|
+
const next = !!((hasAnimationProp || platformPseudo) && !isHOC && useAnimations)
|
|
68
82
|
return Boolean(next || curStateRef.hasAnimated)
|
|
69
83
|
})()
|
|
70
84
|
|
|
@@ -247,6 +261,7 @@ export const useComponentState = (
|
|
|
247
261
|
outputStyle,
|
|
248
262
|
willBeAnimated,
|
|
249
263
|
willBeAnimatedClient,
|
|
264
|
+
platformPseudo,
|
|
250
265
|
}
|
|
251
266
|
}
|
|
252
267
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type tests for the opacity modifier syntax (e.g., $color/50)
|
|
3
|
+
*
|
|
4
|
+
* The runtime already supports this syntax in getTokenForKey, but the types
|
|
5
|
+
* were not accepting it. These tests verify that color tokens with opacity
|
|
6
|
+
* modifiers are now type-safe.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { expectTypeOf, describe, test } from 'vitest'
|
|
10
|
+
import type { ColorTokens, FontColorTokens } from './types'
|
|
11
|
+
|
|
12
|
+
describe('opacity modifier types', () => {
|
|
13
|
+
test('ColorTokens accepts opacity modifier syntax', () => {
|
|
14
|
+
// Should accept token with opacity modifier
|
|
15
|
+
const colorWithOpacity: ColorTokens = '$color/50'
|
|
16
|
+
const colorWithFullOpacity: ColorTokens = '$color/100'
|
|
17
|
+
const colorWithLowOpacity: ColorTokens = '$color/10'
|
|
18
|
+
|
|
19
|
+
// Should still accept regular tokens
|
|
20
|
+
const regularToken: ColorTokens = '$color'
|
|
21
|
+
const colorName: ColorTokens = 'red'
|
|
22
|
+
|
|
23
|
+
// These should all be valid
|
|
24
|
+
expectTypeOf(colorWithOpacity).toMatchTypeOf<ColorTokens>()
|
|
25
|
+
expectTypeOf(colorWithFullOpacity).toMatchTypeOf<ColorTokens>()
|
|
26
|
+
expectTypeOf(colorWithLowOpacity).toMatchTypeOf<ColorTokens>()
|
|
27
|
+
expectTypeOf(regularToken).toMatchTypeOf<ColorTokens>()
|
|
28
|
+
expectTypeOf(colorName).toMatchTypeOf<ColorTokens>()
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
test('FontColorTokens is type-safe (no font color tokens in default config)', () => {
|
|
32
|
+
// The default config defines no font `color` sub-tokens, so FontColorTokens
|
|
33
|
+
// resolves to `number` here — there is no `$fontColor` token to assign. The
|
|
34
|
+
// user-facing opacity path (`color="$token/50"`) is covered by the ColorTokens
|
|
35
|
+
// test above. FontColorTokens carries the same `${Base}/${number}` branch, so
|
|
36
|
+
// once a font config defines `color` tokens, `$myFontColor/50` is type-safe too.
|
|
37
|
+
const fontColorNumber: FontColorTokens = 42
|
|
38
|
+
|
|
39
|
+
expectTypeOf(fontColorNumber).toMatchTypeOf<FontColorTokens>()
|
|
40
|
+
expectTypeOf<number>().toMatchTypeOf<FontColorTokens>()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test('opacity modifier rejects invalid formats', () => {
|
|
44
|
+
// These should NOT be valid (but TypeScript will still accept them as strings)
|
|
45
|
+
// The runtime parsing handles validation
|
|
46
|
+
|
|
47
|
+
// Valid opacity numbers (0-100)
|
|
48
|
+
const validOpacity: ColorTokens = '$color/75'
|
|
49
|
+
expectTypeOf(validOpacity).toMatchTypeOf<ColorTokens>()
|
|
50
|
+
|
|
51
|
+
// Note: TypeScript template literal types are permissive with numbers
|
|
52
|
+
// The runtime validation in getTokenForKey handles edge cases like:
|
|
53
|
+
// - Negative numbers
|
|
54
|
+
// - Numbers > 100
|
|
55
|
+
// - Non-numeric strings after /
|
|
56
|
+
})
|
|
57
|
+
})
|