@tamagui/web 1.92.0 → 1.93.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/dist/cjs/createComponent.js +156 -104
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createComponent.native.js +139 -104
- package/dist/cjs/createComponent.native.js.map +2 -2
- package/dist/cjs/createVariable.js +7 -3
- package/dist/cjs/createVariable.js.map +1 -1
- package/dist/cjs/createVariable.native.js +7 -3
- package/dist/cjs/createVariable.native.js.map +2 -2
- package/dist/cjs/helpers/expandStyle.native.js +0 -5
- package/dist/cjs/helpers/expandStyle.native.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.native.js +1 -15
- package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/cjs/helpers/getThemeCSSRules.js +4 -1
- package/dist/cjs/helpers/getThemeCSSRules.js.map +1 -1
- package/dist/cjs/helpers/insertStyleRule.js +4 -1
- package/dist/cjs/helpers/insertStyleRule.js.map +1 -1
- package/dist/cjs/helpers/insertStyleRule.native.js +3 -1
- package/dist/cjs/helpers/insertStyleRule.native.js.map +2 -2
- package/dist/cjs/helpers/registerCSSVariable.js +4 -1
- package/dist/cjs/helpers/registerCSSVariable.js.map +1 -1
- package/dist/cjs/helpers/registerCSSVariable.native.js +1 -1
- package/dist/cjs/helpers/registerCSSVariable.native.js.map +2 -2
- package/dist/cjs/hooks/useProps.js +29 -5
- package/dist/cjs/hooks/useProps.js.map +1 -1
- package/dist/cjs/hooks/useProps.native.js +39 -4
- package/dist/cjs/hooks/useProps.native.js.map +2 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +2 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/createComponent.js +156 -104
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createComponent.mjs +193 -135
- package/dist/esm/createComponent.native.js +135 -103
- package/dist/esm/createComponent.native.js.map +2 -2
- package/dist/esm/createVariable.js +7 -3
- package/dist/esm/createVariable.js.map +1 -1
- package/dist/esm/createVariable.mjs +19 -16
- package/dist/esm/createVariable.native.js +7 -3
- package/dist/esm/createVariable.native.js.map +2 -2
- package/dist/esm/helpers/expandStyle.native.js +0 -5
- package/dist/esm/helpers/expandStyle.native.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.native.js +1 -15
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/helpers/getThemeCSSRules.js +4 -1
- package/dist/esm/helpers/getThemeCSSRules.js.map +1 -1
- package/dist/esm/helpers/getThemeCSSRules.mjs +1 -1
- package/dist/esm/helpers/insertStyleRule.js +4 -1
- package/dist/esm/helpers/insertStyleRule.js.map +1 -1
- package/dist/esm/helpers/insertStyleRule.mjs +4 -3
- package/dist/esm/helpers/insertStyleRule.native.js +3 -1
- package/dist/esm/helpers/insertStyleRule.native.js.map +2 -2
- package/dist/esm/helpers/registerCSSVariable.js +4 -1
- package/dist/esm/helpers/registerCSSVariable.js.map +1 -1
- package/dist/esm/helpers/registerCSSVariable.mjs +1 -1
- package/dist/esm/helpers/registerCSSVariable.native.js +1 -1
- package/dist/esm/helpers/registerCSSVariable.native.js.map +2 -2
- package/dist/esm/hooks/useProps.js +31 -6
- package/dist/esm/hooks/useProps.js.map +1 -1
- package/dist/esm/hooks/useProps.mjs +32 -5
- package/dist/esm/hooks/useProps.native.js +41 -5
- package/dist/esm/hooks/useProps.native.js.map +2 -2
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.native.js +1 -0
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/types.native.js.map +1 -1
- package/package.json +12 -12
- package/reset.css +1 -0
- package/src/createComponent.tsx +301 -229
- package/src/createVariable.ts +11 -2
- package/src/helpers/getThemeCSSRules.ts +4 -1
- package/src/helpers/insertStyleRule.tsx +4 -1
- package/src/helpers/registerCSSVariable.ts +4 -3
- package/src/hooks/useProps.tsx +46 -14
- package/src/index.ts +1 -0
- package/src/types.tsx +7 -4
- package/types/createComponent.d.ts +31 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/createVariable.d.ts.map +1 -1
- package/types/helpers/getThemeCSSRules.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/helpers/registerCSSVariable.d.ts.map +1 -1
- package/types/hooks/useProps.d.ts +7 -4
- package/types/hooks/useProps.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/types.d.ts +2 -2
- package/types/types.d.ts.map +1 -1
|
@@ -57,6 +57,115 @@ if (typeof document < "u") {
|
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
+
const useComponentState = (props, {
|
|
61
|
+
animationDriver,
|
|
62
|
+
groups
|
|
63
|
+
}, staticConfig, config) => {
|
|
64
|
+
const useAnimations = animationDriver?.useAnimations,
|
|
65
|
+
stateRef = useRef({}),
|
|
66
|
+
hasAnimationProp = !!("animation" in props || props.style && hasAnimatedStyleValue(props.style)),
|
|
67
|
+
supportsCSSVars = animationDriver?.supportsCSSVars,
|
|
68
|
+
curStateRef = stateRef.current,
|
|
69
|
+
willBeAnimatedClient = !!(!!(hasAnimationProp && !staticConfig.isHOC && useAnimations) || curStateRef.hasAnimated),
|
|
70
|
+
willBeAnimated = !isServer && willBeAnimatedClient;
|
|
71
|
+
willBeAnimated && !curStateRef.hasAnimated && (curStateRef.hasAnimated = !0);
|
|
72
|
+
const isHydrated = config?.disableSSR ? !0 : useDidFinishSSR(),
|
|
73
|
+
presence = willBeAnimated && props.animatePresence !== !1 && animationDriver?.usePresence?.() || null,
|
|
74
|
+
presenceState = presence?.[2],
|
|
75
|
+
isExiting = presenceState?.isPresent === !1,
|
|
76
|
+
isEntering = presenceState?.isPresent === !0 && presenceState.initial !== !1,
|
|
77
|
+
hasEnterStyle = !!props.enterStyle,
|
|
78
|
+
hasRNAnimation = hasAnimationProp && animationDriver?.isReactNative,
|
|
79
|
+
isReactNative = staticConfig.isReactNative;
|
|
80
|
+
let isAnimated = willBeAnimated;
|
|
81
|
+
!isReactNative && hasRNAnimation && !staticConfig.isHOC && !isHydrated && (isAnimated = !1, curStateRef.willHydrate = !0), process.env.NODE_ENV === "development" && time && time`pre-use-state`;
|
|
82
|
+
const hasEnterState = hasEnterStyle || isEntering,
|
|
83
|
+
needsToMount = !isHydrated || !curStateRef.host,
|
|
84
|
+
initialState = hasEnterState ? needsToMount ? defaultComponentStateShouldEnter : defaultComponentState : defaultComponentStateMounted,
|
|
85
|
+
disabled = isDisabled(props);
|
|
86
|
+
disabled != null && (initialState.disabled = disabled);
|
|
87
|
+
const states = useState(initialState),
|
|
88
|
+
state = props.forceStyle ? {
|
|
89
|
+
...states[0],
|
|
90
|
+
[props.forceStyle]: !0
|
|
91
|
+
} : states[0],
|
|
92
|
+
setState = states[1];
|
|
93
|
+
disabled !== state.disabled && setState({
|
|
94
|
+
...state,
|
|
95
|
+
...defaultComponentState,
|
|
96
|
+
// removes any stale press state etc
|
|
97
|
+
disabled
|
|
98
|
+
});
|
|
99
|
+
let setStateShallow = createShallowSetState(setState, disabled, props.debug);
|
|
100
|
+
if (isHydrated && state.unmounted === "should-enter" && (state.unmounted = !0), presenceState && isAnimated && isHydrated && staticConfig.variants) {
|
|
101
|
+
process.env.NODE_ENV === "development" && props.debug === "verbose" && console.warn(`has presenceState ${JSON.stringify(presenceState)}`);
|
|
102
|
+
const {
|
|
103
|
+
enterVariant,
|
|
104
|
+
exitVariant,
|
|
105
|
+
enterExitVariant,
|
|
106
|
+
custom
|
|
107
|
+
} = presenceState;
|
|
108
|
+
isObj(custom) && Object.assign(props, custom);
|
|
109
|
+
const exv = exitVariant ?? enterExitVariant,
|
|
110
|
+
env = enterVariant ?? enterExitVariant;
|
|
111
|
+
state.unmounted && env && staticConfig.variants[env] ? (process.env.NODE_ENV === "development" && props.debug === "verbose" && console.warn(`Animating presence ENTER "${env}"`), props[env] = !0) : isExiting && exv && (process.env.NODE_ENV === "development" && props.debug === "verbose" && console.warn(`Animating presence EXIT "${exv}"`), props[exv] = exitVariant !== enterExitVariant);
|
|
112
|
+
}
|
|
113
|
+
const shouldAvoidClasses = !!(!isWeb || isAnimated && !supportsCSSVars || !staticConfig.acceptsClassName ||
|
|
114
|
+
// on server for SSR and animation compat added the && isHydrated but perhaps we want
|
|
115
|
+
// disableClassName="until-hydrated" to be more straightforward
|
|
116
|
+
// see issue if not, Button sets disableClassName to true <Button animation="" /> with
|
|
117
|
+
// the react-native driver errors because it tries to animate var(--color) to rbga(..)
|
|
118
|
+
props.disableClassName && isHydrated),
|
|
119
|
+
groupName = props.group;
|
|
120
|
+
if (groupName && !curStateRef.group) {
|
|
121
|
+
const listeners = /* @__PURE__ */new Set();
|
|
122
|
+
curStateRef.group = {
|
|
123
|
+
listeners,
|
|
124
|
+
emit(name, state2) {
|
|
125
|
+
listeners.forEach(l => l(name, state2));
|
|
126
|
+
},
|
|
127
|
+
subscribe(cb) {
|
|
128
|
+
return listeners.add(cb), () => {
|
|
129
|
+
listeners.delete(cb);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
if (groupName) {
|
|
135
|
+
const groupContextState = groups.state,
|
|
136
|
+
og = setStateShallow;
|
|
137
|
+
setStateShallow = state2 => {
|
|
138
|
+
og(state2), curStateRef.group.emit(groupName, {
|
|
139
|
+
pseudo: state2
|
|
140
|
+
});
|
|
141
|
+
const next = {
|
|
142
|
+
...groupContextState[groupName],
|
|
143
|
+
...state2
|
|
144
|
+
};
|
|
145
|
+
groupContextState[groupName] = next;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
curStateRef,
|
|
150
|
+
disabled,
|
|
151
|
+
groupName,
|
|
152
|
+
hasAnimationProp,
|
|
153
|
+
hasEnterStyle,
|
|
154
|
+
isAnimated,
|
|
155
|
+
isExiting,
|
|
156
|
+
isHydrated,
|
|
157
|
+
presence,
|
|
158
|
+
presenceState,
|
|
159
|
+
setState,
|
|
160
|
+
setStateShallow,
|
|
161
|
+
shouldAvoidClasses,
|
|
162
|
+
state,
|
|
163
|
+
stateRef,
|
|
164
|
+
supportsCSSVars,
|
|
165
|
+
willBeAnimated,
|
|
166
|
+
willBeAnimatedClient
|
|
167
|
+
};
|
|
168
|
+
};
|
|
60
169
|
let BaseText, BaseView;
|
|
61
170
|
const lastInteractionWasKeyboard = {
|
|
62
171
|
value: !1
|
|
@@ -86,7 +195,6 @@ function createComponent(staticConfig) {
|
|
|
86
195
|
const {
|
|
87
196
|
Component,
|
|
88
197
|
isText,
|
|
89
|
-
isInput,
|
|
90
198
|
isZStack,
|
|
91
199
|
isHOC,
|
|
92
200
|
validStyles: validStyles2 = {},
|
|
@@ -103,7 +211,8 @@ function createComponent(staticConfig) {
|
|
|
103
211
|
const componentContext = useContext(ComponentContext);
|
|
104
212
|
let styledContextProps, overriddenContextProps, contextValue;
|
|
105
213
|
const {
|
|
106
|
-
context
|
|
214
|
+
context,
|
|
215
|
+
isReactNative
|
|
107
216
|
} = staticConfig;
|
|
108
217
|
if (context) {
|
|
109
218
|
contextValue = useContext(context);
|
|
@@ -128,7 +237,7 @@ function createComponent(staticConfig) {
|
|
|
128
237
|
process.env.NODE_ENV === "development" && isClient && useEffect(() => {
|
|
129
238
|
let overlay = null;
|
|
130
239
|
const debugVisualizerHandler = (show = !1) => {
|
|
131
|
-
const node =
|
|
240
|
+
const node = curStateRef.host;
|
|
132
241
|
if (node) if (show) {
|
|
133
242
|
overlay = document.createElement("span"), overlay.style.inset = "0px", overlay.style.zIndex = "1000000", overlay.style.position = "absolute", overlay.style.borderColor = "red", overlay.style.borderWidth = "1px", overlay.style.borderStyle = "dotted";
|
|
134
243
|
const dataAt = node.getAttribute("data-at") || "",
|
|
@@ -140,97 +249,31 @@ function createComponent(staticConfig) {
|
|
|
140
249
|
return debugKeyListeners ||= /* @__PURE__ */new Set(), debugKeyListeners.add(debugVisualizerHandler), () => {
|
|
141
250
|
debugKeyListeners?.delete(debugVisualizerHandler);
|
|
142
251
|
};
|
|
143
|
-
}, [componentName2]), !process.env.TAMAGUI_IS_CORE_NODE && process.env.NODE_ENV === "development" && debugProp === "profile" && !time && (time = require("@tamagui/timer").timer().start()), process.env.NODE_ENV === "development" && time && time`start (ignore)`, process.env.NODE_ENV === "development" && time && time`did-finish-ssr`;
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
initialState = hasEnterState ? needsToMount ? defaultComponentStateShouldEnter : defaultComponentState : defaultComponentStateMounted,
|
|
167
|
-
disabled = props.disabled || props.accessibilityState?.disabled || props["aria-disabled"] ||
|
|
168
|
-
// @ts-expect-error (comes from core)
|
|
169
|
-
props.accessibilityDisabled || !1;
|
|
170
|
-
disabled != null && (initialState.disabled = disabled);
|
|
171
|
-
const states = useState(initialState),
|
|
172
|
-
state = props.forceStyle ? {
|
|
173
|
-
...states[0],
|
|
174
|
-
[props.forceStyle]: !0
|
|
175
|
-
} : states[0],
|
|
176
|
-
setState = states[1];
|
|
177
|
-
disabled !== state.disabled && setState({
|
|
178
|
-
...state,
|
|
179
|
-
...defaultComponentState,
|
|
180
|
-
// removes any stale press state etc
|
|
181
|
-
disabled
|
|
182
|
-
});
|
|
183
|
-
let setStateShallow = createShallowSetState(setState, disabled, debugProp);
|
|
184
|
-
if (isHydrated && state.unmounted === "should-enter" && (state.unmounted = !0), presenceState && isAnimated && isHydrated && staticConfig.variants) {
|
|
185
|
-
process.env.NODE_ENV === "development" && debugProp === "verbose" && console.warn(`has presenceState ${JSON.stringify(presenceState)}`);
|
|
186
|
-
const {
|
|
187
|
-
enterVariant,
|
|
188
|
-
exitVariant,
|
|
189
|
-
enterExitVariant,
|
|
190
|
-
custom
|
|
191
|
-
} = presenceState;
|
|
192
|
-
isObj(custom) && Object.assign(props, custom);
|
|
193
|
-
const exv = exitVariant ?? enterExitVariant,
|
|
194
|
-
env = enterVariant ?? enterExitVariant;
|
|
195
|
-
state.unmounted && env && staticConfig.variants[env] ? (process.env.NODE_ENV === "development" && debugProp === "verbose" && console.warn(`Animating presence ENTER "${env}"`), props[env] = !0) : isExiting && exv && (process.env.NODE_ENV === "development" && debugProp === "verbose" && console.warn(`Animating presence EXIT "${exv}"`), props[exv] = exitVariant !== enterExitVariant);
|
|
196
|
-
}
|
|
197
|
-
const shouldAvoidClasses = !!(!isWeb || isAnimated && !supportsCSSVars || !staticConfig.acceptsClassName ||
|
|
198
|
-
// on server for SSR and animation compat added the && isHydrated but perhaps we want
|
|
199
|
-
// disableClassName="until-hydrated" to be more straightforward
|
|
200
|
-
// see issue if not, Button sets disableClassName to true <Button animation="" /> with
|
|
201
|
-
// the react-native driver errors because it tries to animate var(--color) to rbga(..)
|
|
202
|
-
propsIn.disableClassName && isHydrated),
|
|
252
|
+
}, [componentName2]), !process.env.TAMAGUI_IS_CORE_NODE && process.env.NODE_ENV === "development" && debugProp === "profile" && !time && (time = require("@tamagui/timer").timer().start()), process.env.NODE_ENV === "development" && time && time`start (ignore)`, process.env.NODE_ENV === "development" && time && time`did-finish-ssr`, process.env.NODE_ENV === "development" && time && time`stateref`;
|
|
253
|
+
const animationDriver = componentContext.animationDriver,
|
|
254
|
+
useAnimations = animationDriver?.useAnimations,
|
|
255
|
+
{
|
|
256
|
+
curStateRef,
|
|
257
|
+
disabled,
|
|
258
|
+
groupName,
|
|
259
|
+
hasAnimationProp,
|
|
260
|
+
hasEnterStyle,
|
|
261
|
+
isAnimated,
|
|
262
|
+
isExiting,
|
|
263
|
+
isHydrated,
|
|
264
|
+
presence,
|
|
265
|
+
presenceState,
|
|
266
|
+
setState,
|
|
267
|
+
setStateShallow,
|
|
268
|
+
shouldAvoidClasses,
|
|
269
|
+
state,
|
|
270
|
+
stateRef,
|
|
271
|
+
supportsCSSVars,
|
|
272
|
+
willBeAnimated,
|
|
273
|
+
willBeAnimatedClient
|
|
274
|
+
} = useComponentState(props, componentContext, staticConfig, config),
|
|
203
275
|
shouldForcePseudo = !!propsIn.forceStyle,
|
|
204
|
-
noClassNames = shouldAvoidClasses || shouldForcePseudo
|
|
205
|
-
groupName = props.group;
|
|
206
|
-
if (groupName && !curState.group) {
|
|
207
|
-
const listeners = /* @__PURE__ */new Set();
|
|
208
|
-
curState.group = {
|
|
209
|
-
listeners,
|
|
210
|
-
emit(name, state2) {
|
|
211
|
-
listeners.forEach(l => l(name, state2));
|
|
212
|
-
},
|
|
213
|
-
subscribe(cb) {
|
|
214
|
-
return listeners.add(cb), () => {
|
|
215
|
-
listeners.delete(cb);
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
if (groupName) {
|
|
221
|
-
const groupContextState = componentContext.groups.state,
|
|
222
|
-
og = setStateShallow;
|
|
223
|
-
setStateShallow = state2 => {
|
|
224
|
-
og(state2), curState.group.emit(groupName, {
|
|
225
|
-
pseudo: state2
|
|
226
|
-
});
|
|
227
|
-
const next = {
|
|
228
|
-
...groupContextState[groupName],
|
|
229
|
-
...state2
|
|
230
|
-
};
|
|
231
|
-
groupContextState[groupName] = next;
|
|
232
|
-
};
|
|
233
|
-
}
|
|
276
|
+
noClassNames = shouldAvoidClasses || shouldForcePseudo;
|
|
234
277
|
process.env.NODE_ENV === "development" && time && time`use-state`;
|
|
235
278
|
const hasTextAncestor = !!(isWeb && isText && componentContext.inText);
|
|
236
279
|
process.env.NODE_ENV === "development" && time && time`use-context`;
|
|
@@ -238,18 +281,18 @@ function createComponent(staticConfig) {
|
|
|
238
281
|
tagProp = props.tag,
|
|
239
282
|
element = isWeb && isTaggable && tagProp || Component;
|
|
240
283
|
let elementType = isText ? BaseText || element || "span" : BaseView || element || (hasTextAncestor ? "span" : "div");
|
|
241
|
-
|
|
284
|
+
animationDriver && isAnimated && (elementType = animationDriver[isText ? "Text" : "View"] || elementType);
|
|
242
285
|
const disableTheme = props["data-disable-theme"] || isHOC;
|
|
243
|
-
process.env.NODE_ENV === "development" && time && time`theme-props`, props.themeShallow && (
|
|
286
|
+
process.env.NODE_ENV === "development" && time && time`theme-props`, props.themeShallow && (curStateRef.themeShallow = !0);
|
|
244
287
|
const themeStateProps = {
|
|
245
288
|
name: props.theme,
|
|
246
289
|
componentName: componentName2,
|
|
247
290
|
disable: disableTheme,
|
|
248
|
-
shallow:
|
|
291
|
+
shallow: curStateRef.themeShallow,
|
|
249
292
|
inverse: props.themeInverse,
|
|
250
293
|
debug: debugProp
|
|
251
294
|
};
|
|
252
|
-
if (typeof
|
|
295
|
+
if (typeof curStateRef.isListeningToTheme == "boolean" && (themeStateProps.shouldUpdate = () => stateRef.current.isListeningToTheme), process.env.NODE_ENV === "development" && debugProp && debugProp !== "profile") {
|
|
253
296
|
const name = `${componentName2 || Component?.displayName || Component?.name || "[Unnamed Component]"}`,
|
|
254
297
|
type = (hasEnterStyle ? "(hasEnter)" : "") + (isAnimated ? "(animated)" : "") + (isReactNative ? "(rnw)" : "") + (presenceState?.isPresent === !1 ? "(EXIT)" : ""),
|
|
255
298
|
dataIs = propsIn["data-is"] || "",
|
|
@@ -300,7 +343,7 @@ function createComponent(staticConfig) {
|
|
|
300
343
|
isAnimated
|
|
301
344
|
},
|
|
302
345
|
splitStyles = useSplitStyles(props, staticConfig, theme, themeState?.state?.name || "", state, styleProps, null, componentContext, elementType, debugProp);
|
|
303
|
-
props.group && props.untilMeasured === "hide" && !
|
|
346
|
+
props.group && props.untilMeasured === "hide" && !curStateRef.hasMeasured && (splitStyles.style ||= {}, splitStyles.style.opacity = 0), process.env.NODE_ENV === "development" && time && time`split-styles`, curStateRef.isListeningToTheme = splitStyles.dynamicThemeAccess;
|
|
304
347
|
const isMediaArray = splitStyles.hasMedia && Array.isArray(splitStyles.hasMedia),
|
|
305
348
|
shouldListenForMedia = didGetVariableValue() || isMediaArray || noClassNames && splitStyles.hasMedia === !0,
|
|
306
349
|
mediaListeningKeys = isMediaArray ? splitStyles.hasMedia : null;
|
|
@@ -371,7 +414,7 @@ If you meant to do this, you can disable this warning - either change untilMeasu
|
|
|
371
414
|
}), !stateRef.current.hasMeasured && props.untilMeasured === "hide" && setState(prev => ({
|
|
372
415
|
...prev
|
|
373
416
|
})), stateRef.current.hasMeasured = !0;
|
|
374
|
-
})), viewProps = hooks.usePropsTransform?.(elementType, nonTamaguiProps, stateRef,
|
|
417
|
+
})), viewProps = hooks.usePropsTransform?.(elementType, nonTamaguiProps, stateRef, curStateRef.willHydrate) || nonTamaguiProps, curStateRef.composedRef || (curStateRef.composedRef = composeRefs(x => stateRef.current.host = x, forwardedRef)), viewProps.ref = curStateRef.composedRef, process.env.NODE_ENV === "development" && !isReactNative && !isText && isWeb && !isHOC && Children.toArray(props.children).forEach(item => {
|
|
375
418
|
typeof item == "string" && item !== `
|
|
376
419
|
` && console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`);
|
|
377
420
|
}), process.env.NODE_ENV === "development" && time && time`events-hooks`;
|
|
@@ -379,50 +422,31 @@ If you meant to do this, you can disable this warning - either change untilMeasu
|
|
|
379
422
|
pseudoGroups,
|
|
380
423
|
mediaGroups
|
|
381
424
|
} = splitStyles;
|
|
382
|
-
|
|
425
|
+
curStateRef.unPress || (curStateRef.unPress = () => setStateShallow({
|
|
383
426
|
press: !1,
|
|
384
427
|
pressIn: !1
|
|
385
428
|
}));
|
|
386
|
-
const unPress =
|
|
387
|
-
shouldEnter = state.unmounted;
|
|
429
|
+
const unPress = curStateRef.unPress;
|
|
388
430
|
useEffect(() => {
|
|
389
431
|
if (disabled) return;
|
|
390
|
-
if (
|
|
432
|
+
if (state.unmounted) {
|
|
391
433
|
setStateShallow({
|
|
392
434
|
unmounted: !1
|
|
393
435
|
});
|
|
394
436
|
return;
|
|
395
437
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
pseudo
|
|
405
|
-
}) => {
|
|
406
|
-
if (pseudo && pseudoGroups?.has(name)) Object.assign(current.pseudo, pseudo), persist();else if (layout && mediaGroups) {
|
|
407
|
-
const mediaState2 = getMediaState(mediaGroups, layout),
|
|
408
|
-
next = mergeIfNotShallowEqual(current.media, mediaState2);
|
|
409
|
-
next !== current.media && (Object.assign(current.media, next), persist());
|
|
410
|
-
}
|
|
411
|
-
function persist() {
|
|
412
|
-
const group = {
|
|
413
|
-
...state.group,
|
|
414
|
-
[name]: current
|
|
415
|
-
};
|
|
416
|
-
setStateShallow({
|
|
417
|
-
group
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
});
|
|
421
|
-
}
|
|
438
|
+
const dispose = subscribeToContextGroup({
|
|
439
|
+
disabled,
|
|
440
|
+
componentContext,
|
|
441
|
+
setStateShallow,
|
|
442
|
+
state,
|
|
443
|
+
mediaGroups,
|
|
444
|
+
pseudoGroups
|
|
445
|
+
});
|
|
422
446
|
return () => {
|
|
423
|
-
|
|
447
|
+
dispose?.(), mouseUps.delete(unPress);
|
|
424
448
|
};
|
|
425
|
-
}, [disabled,
|
|
449
|
+
}, [disabled, pseudoGroups ? Object.keys([...pseudoGroups]).join("") : 0, mediaGroups ? Object.keys([...mediaGroups]).join("") : 0]);
|
|
426
450
|
const runtimePressStyle = !disabled && noClassNames && pseudos?.pressStyle,
|
|
427
451
|
runtimeFocusStyle = !disabled && noClassNames && pseudos?.focusStyle,
|
|
428
452
|
runtimeFocusVisibleStyle = !disabled && noClassNames && pseudos?.focusVisibleStyle,
|
|
@@ -515,7 +539,7 @@ If you meant to do this, you can disable this warning - either change untilMeasu
|
|
|
515
539
|
ResetPresence && willBeAnimated && (hasEnterStyle || presenceState) && content && typeof content != "string" && (content = /* @__PURE__ */jsx(ResetPresence, {
|
|
516
540
|
children: content
|
|
517
541
|
})), process.env.NODE_ENV === "development" && time && time`create-element`;
|
|
518
|
-
const groupState =
|
|
542
|
+
const groupState = curStateRef.group,
|
|
519
543
|
subGroupContext = useMemo(() => {
|
|
520
544
|
if (!(!groupState || !groupName)) return groupState.listeners.clear(), {
|
|
521
545
|
...componentContext.groups,
|
|
@@ -572,7 +596,6 @@ If you meant to do this, you can disable this warning - either change untilMeasu
|
|
|
572
596
|
defaultProps,
|
|
573
597
|
elementType,
|
|
574
598
|
events,
|
|
575
|
-
initialState,
|
|
576
599
|
isAnimated,
|
|
577
600
|
isMediaArray,
|
|
578
601
|
isStringElement,
|
|
@@ -779,5 +802,40 @@ function hasAnimatedStyleValue(style) {
|
|
|
779
802
|
function getMediaState(mediaGroups, layout) {
|
|
780
803
|
return Object.fromEntries([...mediaGroups].map(mediaKey => [mediaKey, mediaKeyMatch(mediaKey, layout)]));
|
|
781
804
|
}
|
|
782
|
-
const fromPx = val => typeof val != "string" ? val : +val.replace("px", "")
|
|
783
|
-
|
|
805
|
+
const fromPx = val => typeof val != "string" ? val : +val.replace("px", ""),
|
|
806
|
+
isDisabled = props => props.disabled || props.accessibilityState?.disabled || props["aria-disabled"] || props.accessibilityDisabled || !1,
|
|
807
|
+
subscribeToContextGroup = ({
|
|
808
|
+
disabled = !1,
|
|
809
|
+
setStateShallow,
|
|
810
|
+
pseudoGroups,
|
|
811
|
+
mediaGroups,
|
|
812
|
+
componentContext,
|
|
813
|
+
state
|
|
814
|
+
}) => {
|
|
815
|
+
if (pseudoGroups || mediaGroups) {
|
|
816
|
+
const current = {
|
|
817
|
+
pseudo: {},
|
|
818
|
+
media: {}
|
|
819
|
+
};
|
|
820
|
+
return process.env.NODE_ENV === "development" && !componentContext.groups && console.debug("No context group found"), componentContext.groups?.subscribe((name, {
|
|
821
|
+
layout,
|
|
822
|
+
pseudo
|
|
823
|
+
}) => {
|
|
824
|
+
if (pseudo && pseudoGroups?.has(name)) Object.assign(current.pseudo, pseudo), persist();else if (layout && mediaGroups) {
|
|
825
|
+
const mediaState = getMediaState(mediaGroups, layout),
|
|
826
|
+
next = mergeIfNotShallowEqual(current.media, mediaState);
|
|
827
|
+
next !== current.media && (Object.assign(current.media, next), persist());
|
|
828
|
+
}
|
|
829
|
+
function persist() {
|
|
830
|
+
const group = {
|
|
831
|
+
...state.group,
|
|
832
|
+
[name]: current
|
|
833
|
+
};
|
|
834
|
+
setStateShallow({
|
|
835
|
+
group
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
export { Spacer, Unspaced, createComponent, isDisabled, mouseUps, spacedChildren, subscribeToContextGroup, useComponentState };
|