@tamagui/core 1.0.1-beta.149 → 1.0.1-beta.152
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/Tamagui.js +4 -1
- package/dist/cjs/Tamagui.js.map +1 -1
- package/dist/cjs/addTheme.js.map +1 -1
- package/dist/cjs/constants/platform.js.map +2 -2
- package/dist/cjs/constants/platform.native.js.map +1 -1
- package/dist/cjs/contexts/ButtonInsideButtonContext.js.map +1 -1
- package/dist/cjs/contexts/FontLanguageContext.js.map +1 -1
- package/dist/cjs/contexts/TextAncestorContext.js +6 -7
- package/dist/cjs/contexts/TextAncestorContext.js.map +2 -2
- package/dist/cjs/contexts/ThemeContext.js.map +1 -1
- package/dist/cjs/createComponent.js +315 -123
- package/dist/cjs/createComponent.js.map +3 -3
- package/dist/cjs/createFont.js +2 -1
- package/dist/cjs/createFont.js.map +2 -2
- package/dist/cjs/createShorthands.js.map +1 -1
- package/dist/cjs/createTamagui.js +5 -3
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/createTokens.js.map +1 -1
- package/dist/cjs/createVariable.js +3 -1
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/createVariables.js.map +1 -1
- package/dist/cjs/helpers/ThemeManager.js.map +2 -2
- package/dist/cjs/helpers/assignNativePropsToWeb.js.map +1 -1
- package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +1 -1
- package/dist/cjs/helpers/calc.js.map +2 -2
- package/dist/cjs/helpers/createMediaStyle.js +10 -4
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +89 -9
- package/dist/cjs/helpers/createPropMapper.js.map +1 -1
- package/dist/cjs/helpers/createShallowUpdate.js +12 -9
- package/dist/cjs/helpers/createShallowUpdate.js.map +1 -1
- package/dist/cjs/helpers/cssHash.js.map +1 -1
- package/dist/cjs/helpers/expandStyle.js.map +2 -2
- package/dist/cjs/helpers/expandStyles.js.map +1 -1
- package/dist/cjs/helpers/extendStaticConfig.js +10 -7
- package/dist/cjs/helpers/extendStaticConfig.js.map +1 -1
- package/dist/cjs/helpers/getAnimationDriver.js.map +1 -1
- package/dist/cjs/helpers/getExpandedShorthands.js.map +1 -1
- package/dist/cjs/helpers/getFont.js.map +1 -1
- package/dist/cjs/helpers/getSize.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.js +99 -53
- package/dist/cjs/helpers/getSplitStyles.js.map +3 -3
- package/dist/cjs/helpers/getStackSize.js.map +1 -1
- package/dist/cjs/helpers/getStylesAtomic.js +8 -2
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.native.js.map +1 -1
- package/dist/cjs/helpers/getThemeCSSRules.js +7 -3
- package/dist/cjs/helpers/getThemeCSSRules.js.map +1 -1
- package/dist/cjs/helpers/getThemeCSSRules.native.js.map +1 -1
- package/dist/cjs/helpers/getVariantExtras.js +9 -7
- package/dist/cjs/helpers/getVariantExtras.js.map +1 -1
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/isTamaguiComponent.js.map +1 -1
- package/dist/cjs/helpers/isTamaguiElement.js.map +1 -1
- package/dist/cjs/helpers/matchMedia.js.map +1 -1
- package/dist/cjs/helpers/matchMedia.native.js +4 -1
- package/dist/cjs/helpers/matchMedia.native.js.map +2 -2
- package/dist/cjs/helpers/mergeProps.js.map +1 -1
- package/dist/cjs/helpers/mergeTransform.js.map +2 -2
- package/dist/cjs/helpers/normalizeColor.js +4 -1
- package/dist/cjs/helpers/normalizeColor.js.map +2 -2
- package/dist/cjs/helpers/normalizeValueWithProperty.js.map +1 -1
- package/dist/cjs/helpers/proxyThemeVariables.js.map +1 -1
- package/dist/cjs/helpers/registerCSSVariable.js.map +1 -1
- package/dist/cjs/helpers/startTransition.js +4 -1
- package/dist/cjs/helpers/startTransition.js.map +2 -2
- package/dist/cjs/helpers/themeable.js +12 -5
- package/dist/cjs/helpers/themeable.js.map +2 -2
- package/dist/cjs/helpers/themes.js.map +1 -1
- package/dist/cjs/hooks/useConstant.js.map +1 -1
- package/dist/cjs/hooks/useFeatures.js +0 -120
- package/dist/cjs/hooks/useFeatures.js.map +2 -2
- package/dist/cjs/hooks/useIsMounted.js.map +1 -1
- package/dist/cjs/hooks/useIsSSR.js.map +1 -1
- package/dist/cjs/hooks/useIsTouchDevice.js.map +1 -1
- package/dist/cjs/hooks/useMedia.js +10 -7
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/hooks/usePressable.js.map +1 -1
- package/dist/cjs/hooks/useSafeRef.js.map +1 -1
- package/dist/cjs/hooks/useServerHooks.js.map +1 -1
- package/dist/cjs/hooks/useTheme.js +6 -1
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/hooks/useUnmountEffect.js.map +1 -1
- package/dist/cjs/injectStyles.js.map +1 -1
- package/dist/cjs/insertFont.js +3 -1
- package/dist/cjs/insertFont.js.map +2 -2
- package/dist/cjs/styled.js +3 -1
- package/dist/cjs/styled.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/updateTheme.js +7 -4
- package/dist/cjs/updateTheme.js.map +1 -1
- package/dist/cjs/views/FontLanguage.js +5 -7
- package/dist/cjs/views/FontLanguage.js.map +1 -1
- package/dist/cjs/views/FontLanguage.native.js +6 -7
- package/dist/cjs/views/FontLanguage.native.js.map +1 -1
- package/dist/cjs/views/Slot.js +16 -8
- package/dist/cjs/views/Slot.js.map +1 -1
- package/dist/cjs/views/Stack.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.js +21 -12
- package/dist/cjs/views/TamaguiProvider.js.map +1 -1
- package/dist/cjs/views/Text.js.map +1 -1
- package/dist/cjs/views/Theme.js +25 -11
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/cjs/views/ThemeInverse.js +6 -7
- package/dist/cjs/views/ThemeInverse.js.map +1 -1
- package/dist/cjs/views/ThemeProvider.js +14 -8
- package/dist/cjs/views/ThemeProvider.js.map +2 -2
- package/dist/cjs/views/ThemeReset.js +9 -4
- package/dist/cjs/views/ThemeReset.js.map +2 -2
- package/dist/esm/Tamagui.js.map +1 -1
- package/dist/esm/addTheme.js.map +1 -1
- package/dist/esm/constants/constants.js.map +1 -1
- package/dist/esm/constants/platform.js.map +2 -2
- package/dist/esm/constants/platform.native.js.map +1 -1
- package/dist/esm/contexts/ButtonInsideButtonContext.js.map +1 -1
- package/dist/esm/contexts/FontLanguageContext.js.map +1 -1
- package/dist/esm/contexts/TextAncestorContext.js +6 -4
- package/dist/esm/contexts/TextAncestorContext.js.map +1 -1
- package/dist/esm/contexts/ThemeContext.js.map +1 -1
- package/dist/esm/createComponent.js +319 -125
- package/dist/esm/createComponent.js.map +3 -3
- package/dist/esm/createFont.js +2 -1
- package/dist/esm/createFont.js.map +2 -2
- package/dist/esm/createShorthands.js.map +1 -1
- package/dist/esm/createTamagui.js +5 -3
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createTokens.js.map +1 -1
- package/dist/esm/createVariable.js +3 -1
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/createVariables.js.map +1 -1
- package/dist/esm/helpers/RNComponents.js.map +1 -1
- package/dist/esm/helpers/ThemeManager.js.map +2 -2
- package/dist/esm/helpers/assignNativePropsToWeb.js.map +1 -1
- package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +1 -1
- package/dist/esm/helpers/calc.js.map +2 -2
- package/dist/esm/helpers/createMediaStyle.js +10 -4
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +89 -9
- package/dist/esm/helpers/createPropMapper.js.map +1 -1
- package/dist/esm/helpers/createShallowUpdate.js +12 -9
- package/dist/esm/helpers/createShallowUpdate.js.map +1 -1
- package/dist/esm/helpers/cssHash.js.map +1 -1
- package/dist/esm/helpers/expandStyle.js.map +2 -2
- package/dist/esm/helpers/expandStyles.js.map +1 -1
- package/dist/esm/helpers/extendStaticConfig.js +10 -7
- package/dist/esm/helpers/extendStaticConfig.js.map +1 -1
- package/dist/esm/helpers/getAnimationDriver.js.map +1 -1
- package/dist/esm/helpers/getExpandedShorthands.js.map +1 -1
- package/dist/esm/helpers/getFont.js.map +1 -1
- package/dist/esm/helpers/getSize.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.js +99 -53
- package/dist/esm/helpers/getSplitStyles.js.map +3 -3
- package/dist/esm/helpers/getStackSize.js.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.js +4 -1
- package/dist/esm/helpers/getStylesAtomic.js.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.native.js.map +1 -1
- package/dist/esm/helpers/getThemeCSSRules.js +7 -3
- package/dist/esm/helpers/getThemeCSSRules.js.map +1 -1
- package/dist/esm/helpers/getThemeCSSRules.native.js.map +1 -1
- package/dist/esm/helpers/getVariantExtras.js +9 -7
- package/dist/esm/helpers/getVariantExtras.js.map +1 -1
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/isTamaguiComponent.js.map +1 -1
- package/dist/esm/helpers/isTamaguiElement.js.map +1 -1
- package/dist/esm/helpers/matchMedia.js.map +1 -1
- package/dist/esm/helpers/matchMedia.native.js.map +1 -1
- package/dist/esm/helpers/mergeProps.js.map +1 -1
- package/dist/esm/helpers/mergeTransform.js.map +2 -2
- package/dist/esm/helpers/normalizeColor.js.map +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.js.map +1 -1
- package/dist/esm/helpers/proxyThemeVariables.js.map +1 -1
- package/dist/esm/helpers/registerCSSVariable.js.map +1 -1
- package/dist/esm/helpers/startTransition.js.map +1 -1
- package/dist/esm/helpers/themeable.js +8 -4
- package/dist/esm/helpers/themeable.js.map +1 -1
- package/dist/esm/helpers/themes.js.map +1 -1
- package/dist/esm/hooks/useConstant.js.map +1 -1
- package/dist/esm/hooks/useFeatures.js +0 -120
- package/dist/esm/hooks/useFeatures.js.map +2 -2
- package/dist/esm/hooks/useId.js.map +1 -1
- package/dist/esm/hooks/useIsMounted.js.map +1 -1
- package/dist/esm/hooks/useIsSSR.js.map +1 -1
- package/dist/esm/hooks/useIsTouchDevice.js.map +1 -1
- package/dist/esm/hooks/useMedia.js +10 -7
- package/dist/esm/hooks/useMedia.js.map +2 -2
- package/dist/esm/hooks/usePressable.js.map +1 -1
- package/dist/esm/hooks/useSafeRef.js.map +1 -1
- package/dist/esm/hooks/useServerHooks.js.map +1 -1
- package/dist/esm/hooks/useTheme.js +6 -1
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/hooks/useUnmountEffect.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/injectStyles.js.map +1 -1
- package/dist/esm/insertFont.js +3 -1
- package/dist/esm/insertFont.js.map +2 -2
- package/dist/esm/static.js.map +1 -1
- package/dist/esm/styled.js +3 -1
- package/dist/esm/styled.js.map +1 -1
- package/dist/esm/updateTheme.js +7 -4
- package/dist/esm/updateTheme.js.map +1 -1
- package/dist/esm/views/FontLanguage.js +5 -4
- package/dist/esm/views/FontLanguage.js.map +1 -1
- package/dist/esm/views/FontLanguage.native.js +6 -4
- package/dist/esm/views/FontLanguage.native.js.map +1 -1
- package/dist/esm/views/Slot.js +12 -7
- package/dist/esm/views/Slot.js.map +1 -1
- package/dist/esm/views/Stack.js.map +1 -1
- package/dist/esm/views/TamaguiProvider.js +17 -11
- package/dist/esm/views/TamaguiProvider.js.map +1 -1
- package/dist/esm/views/Text.js.map +1 -1
- package/dist/esm/views/Theme.js +21 -10
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/ThemeInverse.js +6 -4
- package/dist/esm/views/ThemeInverse.js.map +1 -1
- package/dist/esm/views/ThemeProvider.js +10 -7
- package/dist/esm/views/ThemeProvider.js.map +1 -1
- package/dist/esm/views/ThemeReset.js +5 -3
- package/dist/esm/views/ThemeReset.js.map +1 -1
- package/package.json +10 -10
- package/src/constants/platform.ts +1 -0
- package/src/createComponent.tsx +246 -57
- package/src/createFont.ts +4 -1
- package/src/createVariable.ts +2 -1
- package/src/helpers/createMediaStyle.ts +2 -2
- package/src/helpers/getSplitStyles.tsx +73 -65
- package/src/helpers/mergeTransform.ts +2 -0
- package/src/insertFont.ts +2 -1
- package/src/types.tsx +7 -5
- package/types/createVariable.d.ts +1 -1
- package/types/helpers/getSplitStyles.d.ts +1 -0
- package/types/hooks/useFeatures.d.ts +0 -1
- package/types/types.d.ts +11 -3
- package/src/helpers/cssHash.ts +0 -28
- package/src/hooks/useFeatures.tsx +0 -289
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
1
2
|
import {
|
|
2
3
|
composeEventHandlers,
|
|
3
4
|
stylePropsView,
|
|
@@ -18,7 +19,8 @@ import React, {
|
|
|
18
19
|
forwardRef,
|
|
19
20
|
memo,
|
|
20
21
|
useCallback,
|
|
21
|
-
useContext
|
|
22
|
+
useContext,
|
|
23
|
+
useEffect
|
|
22
24
|
} from "react";
|
|
23
25
|
import { StyleSheet, Text, View } from "react-native";
|
|
24
26
|
import { getConfig, onConfiguredOnce } from "./config";
|
|
@@ -30,12 +32,15 @@ import { assignNativePropsToWeb } from "./helpers/assignNativePropsToWeb";
|
|
|
30
32
|
import { getReturnVariablesAs } from "./helpers/createPropMapper";
|
|
31
33
|
import { createShallowUpdate } from "./helpers/createShallowUpdate";
|
|
32
34
|
import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
|
|
33
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
getSubStyle,
|
|
37
|
+
insertSplitStyles,
|
|
38
|
+
useSplitStyles
|
|
39
|
+
} from "./helpers/getSplitStyles";
|
|
34
40
|
import { getAllSelectors } from "./helpers/insertStyleRule";
|
|
35
41
|
import { mergeProps } from "./helpers/mergeProps";
|
|
36
42
|
import { proxyThemeVariables } from "./helpers/proxyThemeVariables";
|
|
37
|
-
import {
|
|
38
|
-
import { mediaState } from "./hooks/useMedia";
|
|
43
|
+
import { addMediaQueryListener, mediaState, removeMediaQueryListener } from "./hooks/useMedia";
|
|
39
44
|
import { usePressable } from "./hooks/usePressable";
|
|
40
45
|
import { useServerRef, useServerState } from "./hooks/useServerHooks";
|
|
41
46
|
import { getThemeManager, useTheme } from "./hooks/useTheme";
|
|
@@ -68,6 +73,7 @@ function mergeShorthands({ defaultProps }, { shorthands }) {
|
|
|
68
73
|
}
|
|
69
74
|
let initialTheme;
|
|
70
75
|
let config;
|
|
76
|
+
let mediaPropNames = [];
|
|
71
77
|
function createComponent(configIn, ParentComponent) {
|
|
72
78
|
const staticConfig = (() => {
|
|
73
79
|
const next = extendStaticConfig(configIn, ParentComponent);
|
|
@@ -87,7 +93,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
87
93
|
let tamaguiDefaultProps;
|
|
88
94
|
let initialSplitStyles;
|
|
89
95
|
const component = forwardRef((propsIn, forwardedRef) => {
|
|
90
|
-
var _a, _b, _c, _d;
|
|
96
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
91
97
|
let props;
|
|
92
98
|
if (tamaguiDefaultProps && !propsIn.asChild) {
|
|
93
99
|
props = mergeProps(tamaguiDefaultProps, propsIn)[0];
|
|
@@ -117,7 +123,15 @@ function createComponent(configIn, ParentComponent) {
|
|
|
117
123
|
resolveVariablesAs: "value"
|
|
118
124
|
};
|
|
119
125
|
const languageContext = isRSC ? null : useContext(FontLanguageContext);
|
|
120
|
-
const splitStyles = useSplitStyles(
|
|
126
|
+
const splitStyles = useSplitStyles(
|
|
127
|
+
props,
|
|
128
|
+
staticConfig,
|
|
129
|
+
theme,
|
|
130
|
+
splitStyleState,
|
|
131
|
+
props.asChild ? null : initialSplitStyles == null ? void 0 : initialSplitStyles.classNames,
|
|
132
|
+
languageContext || void 0,
|
|
133
|
+
props["debug"]
|
|
134
|
+
);
|
|
121
135
|
const hostRef = useServerRef(null);
|
|
122
136
|
const setState = states[1];
|
|
123
137
|
const setStateShallow = createShallowUpdate(setState);
|
|
@@ -136,23 +150,76 @@ function createComponent(configIn, ParentComponent) {
|
|
|
136
150
|
}
|
|
137
151
|
}
|
|
138
152
|
}
|
|
139
|
-
const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitStyles;
|
|
153
|
+
const { viewProps: viewPropsIn, pseudos, medias, style, classNames, mediaKeys } = splitStyles;
|
|
154
|
+
useIsomorphicLayoutEffect(() => {
|
|
155
|
+
for (const key of mediaKeys) {
|
|
156
|
+
addMediaQueryListener(key, forceUpdate);
|
|
157
|
+
}
|
|
158
|
+
return () => {
|
|
159
|
+
for (const key of mediaKeys) {
|
|
160
|
+
removeMediaQueryListener(key, forceUpdate);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}, [mediaKeys.join(",")]);
|
|
140
164
|
const useAnimations = (_a = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
|
|
141
165
|
const isAnimated = !!(useAnimations && props.animation);
|
|
142
166
|
const hasEnterStyle = !!props.enterStyle;
|
|
143
167
|
const animationFeatureStylesIn = props.animation ? { ...defaultNativeStyle, ...style } : null;
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
168
|
+
const propsWithAnimation = props;
|
|
169
|
+
if (!isRSC && isAnimated) {
|
|
170
|
+
const animationState = useAnimations(propsWithAnimation, {
|
|
171
|
+
state,
|
|
172
|
+
pseudos,
|
|
173
|
+
onDidAnimate: props.onDidAnimate,
|
|
174
|
+
hostRef,
|
|
175
|
+
staticConfig,
|
|
176
|
+
getStyle({ isExiting, isEntering, exitVariant, enterVariant } = {}) {
|
|
177
|
+
var _a2, _b2, _c2, _d2;
|
|
178
|
+
const style2 = animationFeatureStylesIn;
|
|
179
|
+
const enterStyle = isEntering ? enterVariant && ((_a2 = staticConfig.variants) == null ? void 0 : _a2[enterVariant]["true"]) ? getSubStyle(
|
|
180
|
+
"",
|
|
181
|
+
(_b2 = staticConfig.variants) == null ? void 0 : _b2[enterVariant]["true"],
|
|
182
|
+
staticConfig,
|
|
183
|
+
theme,
|
|
184
|
+
props,
|
|
185
|
+
state,
|
|
186
|
+
tamaguiConfig
|
|
187
|
+
) || pseudos.enterStyle : pseudos.enterStyle : null;
|
|
188
|
+
const exitStyle = isExiting ? exitVariant && ((_c2 = staticConfig.variants) == null ? void 0 : _c2[exitVariant]["true"]) ? getSubStyle(
|
|
189
|
+
"",
|
|
190
|
+
(_d2 = staticConfig.variants) == null ? void 0 : _d2[exitVariant]["true"],
|
|
191
|
+
staticConfig,
|
|
192
|
+
theme,
|
|
193
|
+
props,
|
|
194
|
+
state,
|
|
195
|
+
tamaguiConfig
|
|
196
|
+
) || pseudos.exitStyle : pseudos.exitStyle : null;
|
|
197
|
+
ensureBaseHasDefaults(
|
|
198
|
+
style2,
|
|
199
|
+
pseudos.hoverStyle,
|
|
200
|
+
pseudos.focusStyle,
|
|
201
|
+
pseudos.pressStyle,
|
|
202
|
+
pseudos.pressStyle
|
|
203
|
+
);
|
|
204
|
+
enterStyle && isEntering && merge(style2, enterStyle);
|
|
205
|
+
state.hover && pseudos.hoverStyle && merge(style2, pseudos.hoverStyle);
|
|
206
|
+
state.focus && pseudos.focusStyle && merge(style2, pseudos.focusStyle);
|
|
207
|
+
state.press && pseudos.pressStyle && merge(style2, pseudos.pressStyle);
|
|
208
|
+
exitStyle && isExiting && merge(style2, exitStyle);
|
|
209
|
+
if (process.env.NODE_ENV === "development") {
|
|
210
|
+
if (props["debug"]) {
|
|
211
|
+
console.log("animation style", style2);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return style2;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
if (animationState !== state.animation) {
|
|
218
|
+
setStateShallow({
|
|
219
|
+
animation: animationState
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
156
223
|
const {
|
|
157
224
|
tag,
|
|
158
225
|
hitSlop,
|
|
@@ -284,7 +351,21 @@ function createComponent(configIn, ParentComponent) {
|
|
|
284
351
|
onStartShouldSetResponderCapture
|
|
285
352
|
});
|
|
286
353
|
const platformMethodsRef = usePlatformMethods(viewProps);
|
|
287
|
-
const
|
|
354
|
+
const shouldSetMounted = Boolean(
|
|
355
|
+
isClient && (hasEnterStyle || props.animation) && !state.mounted
|
|
356
|
+
);
|
|
357
|
+
const setRef = useMergeRefs(
|
|
358
|
+
hostRef,
|
|
359
|
+
platformMethodsRef,
|
|
360
|
+
forwardedRef,
|
|
361
|
+
shouldSetMounted ? () => {
|
|
362
|
+
setTimeout(() => {
|
|
363
|
+
setStateShallow({
|
|
364
|
+
mounted: true
|
|
365
|
+
});
|
|
366
|
+
}, 10);
|
|
367
|
+
} : void 0
|
|
368
|
+
);
|
|
288
369
|
viewProps.ref = setRef;
|
|
289
370
|
}
|
|
290
371
|
if (props.href != void 0 && hrefAttrs != void 0) {
|
|
@@ -329,26 +410,13 @@ function createComponent(configIn, ParentComponent) {
|
|
|
329
410
|
}
|
|
330
411
|
});
|
|
331
412
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
413
|
+
if (!isRSC) {
|
|
414
|
+
useEffect(() => {
|
|
415
|
+
return () => {
|
|
416
|
+
mouseUps.delete(unPress);
|
|
417
|
+
};
|
|
418
|
+
}, []);
|
|
337
419
|
}
|
|
338
|
-
useIsomorphicLayoutEffect(() => {
|
|
339
|
-
if (isClient && (hasEnterStyle || props.animation) && !state.mounted) {
|
|
340
|
-
setStateShallow({
|
|
341
|
-
mounted: true
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
internal.current.isMounted = true;
|
|
345
|
-
return () => {
|
|
346
|
-
var _a2;
|
|
347
|
-
mouseUps.delete(unPress);
|
|
348
|
-
internal.current.isMounted = false;
|
|
349
|
-
(_a2 = internal.current.unmountEffects) == null ? void 0 : _a2.forEach((cb) => cb());
|
|
350
|
-
};
|
|
351
|
-
}, [hasEnterStyle, props.animation]);
|
|
352
420
|
let styles;
|
|
353
421
|
const animationStyles = state.animation ? state.animation.style : null;
|
|
354
422
|
if (isStringElement && shouldAvoidClasses && !shouldForcePseudo) {
|
|
@@ -365,11 +433,10 @@ function createComponent(configIn, ParentComponent) {
|
|
|
365
433
|
];
|
|
366
434
|
if (!animationStyles && initialSplitStyles) {
|
|
367
435
|
const initPseudos = initialSplitStyles.pseudos;
|
|
368
|
-
const force = shouldForcePseudo;
|
|
369
436
|
!state.mounted && addPseudoToStyles(styles, initPseudos, pseudos, "enterStyle");
|
|
370
|
-
state.hover && addPseudoToStyles(styles, initPseudos, pseudos, "hoverStyle",
|
|
371
|
-
state.focus && addPseudoToStyles(styles, initPseudos, pseudos, "focusStyle",
|
|
372
|
-
state.press && addPseudoToStyles(styles, initPseudos, pseudos, "pressStyle",
|
|
437
|
+
state.hover && addPseudoToStyles(styles, initPseudos, pseudos, "hoverStyle", shouldForcePseudo);
|
|
438
|
+
state.focus && addPseudoToStyles(styles, initPseudos, pseudos, "focusStyle", shouldForcePseudo);
|
|
439
|
+
state.press && addPseudoToStyles(styles, initPseudos, pseudos, "pressStyle", shouldForcePseudo);
|
|
373
440
|
}
|
|
374
441
|
if (shouldForcePseudo) {
|
|
375
442
|
const next = {};
|
|
@@ -413,7 +480,31 @@ function createComponent(configIn, ParentComponent) {
|
|
|
413
480
|
viewProps.className = className;
|
|
414
481
|
}
|
|
415
482
|
viewProps.style = style2;
|
|
416
|
-
}
|
|
483
|
+
}
|
|
484
|
+
if (process.env.TAMAGUI_TARGET === "native") {
|
|
485
|
+
if (splitStyles.fontFamily) {
|
|
486
|
+
const faceInfo = (_b = config.fontsParsed[splitStyles.fontFamily]) == null ? void 0 : _b.face;
|
|
487
|
+
if (faceInfo) {
|
|
488
|
+
const [weight, style2] = (() => {
|
|
489
|
+
var _a2, _b2;
|
|
490
|
+
let weight2;
|
|
491
|
+
let style3;
|
|
492
|
+
for (let i = styles.length; i >= 0; i--) {
|
|
493
|
+
weight2 ??= (_a2 = styles[i]) == null ? void 0 : _a2.fontWeight;
|
|
494
|
+
style3 ??= (_b2 = styles[i]) == null ? void 0 : _b2.fontStyle;
|
|
495
|
+
}
|
|
496
|
+
return [weight2 || "400", style3 || "normal"];
|
|
497
|
+
})();
|
|
498
|
+
const overrideFace = (_d = (_c = faceInfo[weight]) == null ? void 0 : _c[style2]) == null ? void 0 : _d.val;
|
|
499
|
+
if (overrideFace) {
|
|
500
|
+
for (const style3 of styles) {
|
|
501
|
+
if (style3 == null ? void 0 : style3.fontFamily) {
|
|
502
|
+
style3.fontFamily = overrideFace;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
417
508
|
viewProps.style = styles;
|
|
418
509
|
}
|
|
419
510
|
const initialPseudos = initialSplitStyles == null ? void 0 : initialSplitStyles.pseudos;
|
|
@@ -426,8 +517,6 @@ function createComponent(configIn, ParentComponent) {
|
|
|
426
517
|
const pressOutKey = handlesPressEvents ? "onPressOut" : "onMouseUp";
|
|
427
518
|
const shouldAttach = !asChild && (attachPress || attachHover || "pressStyle" in props || "onPress" in props || "onPressIn" in props || "onPressOut" in props || isWeb && ("hoverStyle" in props || "onHoverIn" in props || "onHoverOut" in props || "onMouseEnter" in props || "onMouseLeave" in props));
|
|
428
519
|
const unPress = useCallback(() => {
|
|
429
|
-
if (!internal.current.isMounted)
|
|
430
|
-
return;
|
|
431
520
|
setStateShallow({
|
|
432
521
|
press: false,
|
|
433
522
|
pressIn: false
|
|
@@ -490,7 +579,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
490
579
|
} : null,
|
|
491
580
|
...!isWeb && {
|
|
492
581
|
cancelable: !props.rejectResponderTermination,
|
|
493
|
-
disabled: props.disabled !== null ? props.disabled : (
|
|
582
|
+
disabled: props.disabled !== null ? props.disabled : (_e = props.accessibilityState) == null ? void 0 : _e.disabled,
|
|
494
583
|
hitSlop: props.hitSlop,
|
|
495
584
|
delayLongPress: props.delayLongPress,
|
|
496
585
|
delayPressIn: props.delayPressIn,
|
|
@@ -500,7 +589,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
500
589
|
}
|
|
501
590
|
} : null;
|
|
502
591
|
let space = spaceProp;
|
|
503
|
-
if (
|
|
592
|
+
if (mediaKeys.length) {
|
|
504
593
|
for (const key in mediaState) {
|
|
505
594
|
if (!mediaState[key])
|
|
506
595
|
continue;
|
|
@@ -510,15 +599,21 @@ function createComponent(configIn, ParentComponent) {
|
|
|
510
599
|
}
|
|
511
600
|
}
|
|
512
601
|
const themeManager = getThemeManager(theme);
|
|
513
|
-
const shouldSetChildrenThemeToParent = Boolean(
|
|
602
|
+
const shouldSetChildrenThemeToParent = Boolean(
|
|
603
|
+
themeShallow && themeManager && themeManager.didChangeTheme
|
|
604
|
+
);
|
|
514
605
|
const shouldProvideThemeManager = shouldSetChildrenThemeToParent || themeManager && themeManager.didChangeTheme;
|
|
515
|
-
const childEls = !children || asChild ? children : wrapThemeManagerContext(
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
606
|
+
const childEls = !children || asChild ? children : wrapThemeManagerContext(
|
|
607
|
+
spacedChildren({
|
|
608
|
+
separator,
|
|
609
|
+
children,
|
|
610
|
+
space,
|
|
611
|
+
direction: props.spaceDirection || "both",
|
|
612
|
+
isZStack
|
|
613
|
+
}),
|
|
614
|
+
shouldProvideThemeManager ? themeManager : void 0,
|
|
615
|
+
shouldSetChildrenThemeToParent
|
|
616
|
+
);
|
|
522
617
|
let content;
|
|
523
618
|
if (asChild) {
|
|
524
619
|
elementType = Slot;
|
|
@@ -530,17 +625,19 @@ function createComponent(configIn, ParentComponent) {
|
|
|
530
625
|
};
|
|
531
626
|
}
|
|
532
627
|
if (!isRSC && isWeb) {
|
|
533
|
-
const [pressableProps] = usePressable(
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
hitSlop
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
628
|
+
const [pressableProps] = usePressable(
|
|
629
|
+
events ? {
|
|
630
|
+
disabled,
|
|
631
|
+
...hitSlop && {
|
|
632
|
+
hitSlop
|
|
633
|
+
},
|
|
634
|
+
onPressOut: events[pressOutKey],
|
|
635
|
+
onPressIn: events[pressInKey],
|
|
636
|
+
onPress: events[pressKey]
|
|
637
|
+
} : {
|
|
638
|
+
disabled: true
|
|
639
|
+
}
|
|
640
|
+
);
|
|
544
641
|
if (events) {
|
|
545
642
|
if (handlesPressEvents) {
|
|
546
643
|
Object.assign(viewProps, pressableProps);
|
|
@@ -577,12 +674,12 @@ function createComponent(configIn, ParentComponent) {
|
|
|
577
674
|
content = createElement(elementType, viewProps, childEls);
|
|
578
675
|
if (process.env.TAMAGUI_TARGET === "web") {
|
|
579
676
|
const isAnimatedRNWView = isAnimated && typeof elementType !== "string";
|
|
580
|
-
const shouldWrapWithComponentTheme = isAnimatedRNWView && getReturnVariablesAs(props, splitStyleState) === "non-color-value";
|
|
677
|
+
const shouldWrapWithComponentTheme = !!theme.className && isAnimatedRNWView && getReturnVariablesAs(props, splitStyleState) === "non-color-value";
|
|
581
678
|
const shouldWrapWithHover = Boolean(events || isRSC) && attachHover;
|
|
582
679
|
if (shouldWrapWithHover || shouldWrapWithComponentTheme) {
|
|
583
680
|
const themeClassName = shouldWrapWithComponentTheme ? `${theme.className}` : "";
|
|
584
681
|
const hoverClassName = shouldWrapWithHover ? "t_Hoverable" : "";
|
|
585
|
-
content = /* @__PURE__ */
|
|
682
|
+
content = /* @__PURE__ */ jsx("span", {
|
|
586
683
|
className: `${hoverClassName} ${themeClassName}`,
|
|
587
684
|
style: {
|
|
588
685
|
display: "contents"
|
|
@@ -590,8 +687,9 @@ function createComponent(configIn, ParentComponent) {
|
|
|
590
687
|
...events && shouldWrapWithHover && {
|
|
591
688
|
onMouseEnter: events.onMouseEnter,
|
|
592
689
|
onMouseLeave: events.onMouseLeave
|
|
593
|
-
}
|
|
594
|
-
|
|
690
|
+
},
|
|
691
|
+
children: content
|
|
692
|
+
});
|
|
595
693
|
}
|
|
596
694
|
}
|
|
597
695
|
if (process.env.NODE_ENV === "development") {
|
|
@@ -604,12 +702,12 @@ function createComponent(configIn, ParentComponent) {
|
|
|
604
702
|
console.log("children", content);
|
|
605
703
|
console.groupEnd();
|
|
606
704
|
if (typeof window !== "undefined") {
|
|
607
|
-
console.log({ state, shouldProvideThemeManager, tamaguiDefaultProps, viewProps, splitStyles, animationStyles, handlesPressEvents, isStringElement, classNamesIn: (
|
|
705
|
+
console.log({ state, shouldProvideThemeManager, tamaguiDefaultProps, viewProps, splitStyles, animationStyles, handlesPressEvents, isStringElement, classNamesIn: (_f = props.className) == null ? void 0 : _f.split(" "), classNamesOut: (_g = viewProps.className) == null ? void 0 : _g.split(" "), events, shouldAttach, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses, animation: props.animation, style, defaultNativeStyle, initialSplitStyles, ...typeof window !== "undefined" ? { theme, themeClassName: theme.className, staticConfig, tamaguiConfig, events, shouldAvoidClasses, shouldForcePseudo, classNames: Object.fromEntries(Object.entries(classNames).map(([k, v]) => [v, getAllSelectors()[v]])) } : null });
|
|
608
706
|
}
|
|
609
707
|
console.groupEnd();
|
|
610
708
|
}
|
|
611
709
|
}
|
|
612
|
-
return
|
|
710
|
+
return content;
|
|
613
711
|
});
|
|
614
712
|
if (staticConfig.componentName) {
|
|
615
713
|
component.displayName = staticConfig.componentName;
|
|
@@ -629,23 +727,41 @@ function createComponent(configIn, ParentComponent) {
|
|
|
629
727
|
let defaultPropsIn = staticConfig.defaultProps || {};
|
|
630
728
|
const parentNames = [...staticConfig.parentNames || [], staticConfig.componentName];
|
|
631
729
|
if (config.defaultProps && parentNames && staticConfig.componentName) {
|
|
632
|
-
defaultPropsIn = mergeConfigDefaultProps(
|
|
730
|
+
defaultPropsIn = mergeConfigDefaultProps(
|
|
731
|
+
staticConfig.componentName,
|
|
732
|
+
defaultPropsIn,
|
|
733
|
+
config.defaultProps,
|
|
734
|
+
parentNames,
|
|
735
|
+
conf
|
|
736
|
+
);
|
|
633
737
|
}
|
|
634
738
|
const debug = true ? defaultPropsIn["debug"] : false;
|
|
635
739
|
if (process.env.NODE_ENV === "development" && debug === "break") {
|
|
636
740
|
debugger;
|
|
637
741
|
}
|
|
638
742
|
const [parentProps, parentClassNames] = mergeProps(defaultPropsIn, {}, true);
|
|
639
|
-
initialSplitStyles = insertSplitStyles(
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
743
|
+
initialSplitStyles = insertSplitStyles(
|
|
744
|
+
parentProps,
|
|
745
|
+
staticConfig,
|
|
746
|
+
initialTheme,
|
|
747
|
+
{
|
|
748
|
+
mounted: true,
|
|
749
|
+
hover: false,
|
|
750
|
+
press: false,
|
|
751
|
+
pressIn: false,
|
|
752
|
+
focus: false,
|
|
753
|
+
resolveVariablesAs: "both",
|
|
754
|
+
keepVariantsAsProps: true
|
|
755
|
+
},
|
|
756
|
+
void 0,
|
|
757
|
+
void 0,
|
|
758
|
+
debug
|
|
759
|
+
);
|
|
760
|
+
const [defaults2, defaultsClassnames] = mergeProps(
|
|
761
|
+
component.defaultProps,
|
|
762
|
+
initialSplitStyles.viewProps,
|
|
763
|
+
true
|
|
764
|
+
);
|
|
649
765
|
initialSplitStyles.classNames = {
|
|
650
766
|
...parentClassNames,
|
|
651
767
|
...defaultsClassnames,
|
|
@@ -659,7 +775,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
659
775
|
if (validPseudoKeys[key])
|
|
660
776
|
continue;
|
|
661
777
|
if (typeof val === "string" && val[0] === "$" || !validStyles2[key]) {
|
|
662
|
-
|
|
778
|
+
defaults2[key] = val;
|
|
663
779
|
} else {
|
|
664
780
|
defaultNativeStyle[key] = val;
|
|
665
781
|
}
|
|
@@ -668,8 +784,8 @@ function createComponent(configIn, ParentComponent) {
|
|
|
668
784
|
defaultNativeStyleSheet = StyleSheet.create({
|
|
669
785
|
base: defaultNativeStyle
|
|
670
786
|
});
|
|
671
|
-
if (Object.keys(
|
|
672
|
-
tamaguiDefaultProps =
|
|
787
|
+
if (Object.keys(defaults2).length) {
|
|
788
|
+
tamaguiDefaultProps = defaults2;
|
|
673
789
|
}
|
|
674
790
|
if (process.env.NODE_ENV === "development" && debug) {
|
|
675
791
|
if (process.env.IS_STATIC !== "is_static") {
|
|
@@ -678,7 +794,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
678
794
|
initialSplitStyles,
|
|
679
795
|
tamaguiDefaultProps,
|
|
680
796
|
defaultNativeStyle,
|
|
681
|
-
defaults,
|
|
797
|
+
defaults: defaults2,
|
|
682
798
|
defaultPropsIn
|
|
683
799
|
});
|
|
684
800
|
}
|
|
@@ -693,16 +809,19 @@ function createComponent(configIn, ParentComponent) {
|
|
|
693
809
|
...staticConfig
|
|
694
810
|
};
|
|
695
811
|
res.extractable = (Component, conf) => {
|
|
696
|
-
Component.staticConfig = extendStaticConfig(
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
812
|
+
Component.staticConfig = extendStaticConfig(
|
|
813
|
+
{
|
|
814
|
+
Component,
|
|
815
|
+
...conf,
|
|
816
|
+
neverFlatten: true,
|
|
817
|
+
isExtractable: true,
|
|
818
|
+
defaultProps: {
|
|
819
|
+
...Component.defaultProps,
|
|
820
|
+
...conf == null ? void 0 : conf.defaultProps
|
|
821
|
+
}
|
|
822
|
+
},
|
|
823
|
+
res
|
|
824
|
+
);
|
|
706
825
|
return Component;
|
|
707
826
|
};
|
|
708
827
|
return res;
|
|
@@ -777,9 +896,13 @@ function spacedChildren({
|
|
|
777
896
|
if (isEmpty || !child || child["key"] && !isZStack) {
|
|
778
897
|
final.push(child);
|
|
779
898
|
} else {
|
|
780
|
-
final.push(
|
|
781
|
-
|
|
782
|
-
|
|
899
|
+
final.push(
|
|
900
|
+
/* @__PURE__ */ jsx(Fragment, {
|
|
901
|
+
children: isZStack ? /* @__PURE__ */ jsx(AbsoluteFill, {
|
|
902
|
+
children: child
|
|
903
|
+
}) : child
|
|
904
|
+
}, index)
|
|
905
|
+
);
|
|
783
906
|
}
|
|
784
907
|
if (isUnspaced(child) && index === 0) {
|
|
785
908
|
continue;
|
|
@@ -791,53 +914,61 @@ function spacedChildren({
|
|
|
791
914
|
if (next && !isUnspaced(next)) {
|
|
792
915
|
if (separator) {
|
|
793
916
|
if (hasSpace) {
|
|
794
|
-
final.push(
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
917
|
+
final.push(
|
|
918
|
+
createSpacer({
|
|
919
|
+
key: `_${index}_before_sep_spacer`,
|
|
920
|
+
direction,
|
|
921
|
+
space,
|
|
922
|
+
spaceFlex
|
|
923
|
+
})
|
|
924
|
+
);
|
|
800
925
|
}
|
|
801
|
-
final.push(
|
|
926
|
+
final.push(
|
|
927
|
+
React.isValidElement(separator) ? React.cloneElement(separator, { key: `sep_${index}` }) : separator
|
|
928
|
+
);
|
|
802
929
|
if (hasSpace) {
|
|
803
|
-
final.push(
|
|
804
|
-
|
|
930
|
+
final.push(
|
|
931
|
+
createSpacer({
|
|
932
|
+
key: `_${index}_after_sep_spacer`,
|
|
933
|
+
direction,
|
|
934
|
+
space,
|
|
935
|
+
spaceFlex
|
|
936
|
+
})
|
|
937
|
+
);
|
|
938
|
+
}
|
|
939
|
+
} else {
|
|
940
|
+
final.push(
|
|
941
|
+
createSpacer({
|
|
942
|
+
key: `_${index}_spacer`,
|
|
805
943
|
direction,
|
|
806
944
|
space,
|
|
807
945
|
spaceFlex
|
|
808
|
-
})
|
|
809
|
-
|
|
810
|
-
} else {
|
|
811
|
-
final.push(createSpacer({
|
|
812
|
-
key: `_${index}_spacer`,
|
|
813
|
-
direction,
|
|
814
|
-
space,
|
|
815
|
-
spaceFlex
|
|
816
|
-
}));
|
|
946
|
+
})
|
|
947
|
+
);
|
|
817
948
|
}
|
|
818
949
|
}
|
|
819
950
|
}
|
|
820
951
|
return final;
|
|
821
952
|
}
|
|
822
953
|
function createSpacer({ key, direction, space, spaceFlex }) {
|
|
823
|
-
return /* @__PURE__ */
|
|
824
|
-
key,
|
|
954
|
+
return /* @__PURE__ */ jsx(Spacer, {
|
|
825
955
|
size: space,
|
|
826
956
|
direction,
|
|
827
957
|
...spaceFlex && {
|
|
828
958
|
flex: spaceFlex
|
|
829
959
|
}
|
|
830
|
-
});
|
|
960
|
+
}, key);
|
|
831
961
|
}
|
|
832
962
|
function isUnspaced(child) {
|
|
833
963
|
var _a, _b;
|
|
834
964
|
return ((_a = child == null ? void 0 : child["type"]) == null ? void 0 : _a["isVisuallyHidden"]) || ((_b = child == null ? void 0 : child["type"]) == null ? void 0 : _b["isUnspaced"]);
|
|
835
965
|
}
|
|
836
966
|
function AbsoluteFill(props) {
|
|
837
|
-
return /* @__PURE__ */
|
|
967
|
+
return /* @__PURE__ */ jsx(View, {
|
|
838
968
|
pointerEvents: "box-none",
|
|
839
|
-
style: StyleSheet.absoluteFill
|
|
840
|
-
|
|
969
|
+
style: StyleSheet.absoluteFill,
|
|
970
|
+
children: props.children
|
|
971
|
+
});
|
|
841
972
|
}
|
|
842
973
|
function processIDRefList(idRefList) {
|
|
843
974
|
return Array.isArray(idRefList) ? idRefList.join(" ") : idRefList;
|
|
@@ -893,6 +1024,69 @@ function mergeConfigDefaultProps(name, props, configDefaults, parentNames, conf)
|
|
|
893
1024
|
}
|
|
894
1025
|
return props;
|
|
895
1026
|
}
|
|
1027
|
+
const defaults = {
|
|
1028
|
+
left: 0,
|
|
1029
|
+
right: 0,
|
|
1030
|
+
top: 0,
|
|
1031
|
+
bottom: 0,
|
|
1032
|
+
opacity: 1,
|
|
1033
|
+
translateX: 0,
|
|
1034
|
+
translateY: 0,
|
|
1035
|
+
skew: 0,
|
|
1036
|
+
skewX: 0,
|
|
1037
|
+
skewY: 0,
|
|
1038
|
+
scale: 1,
|
|
1039
|
+
rotate: "0deg",
|
|
1040
|
+
rotateY: "0deg",
|
|
1041
|
+
rotateX: "0deg"
|
|
1042
|
+
};
|
|
1043
|
+
function ensureBaseHasDefaults(base, ...pseudos) {
|
|
1044
|
+
for (const pseudo of pseudos) {
|
|
1045
|
+
if (!pseudo)
|
|
1046
|
+
continue;
|
|
1047
|
+
for (const key in pseudo) {
|
|
1048
|
+
const val = pseudo[key];
|
|
1049
|
+
if (key === "transform") {
|
|
1050
|
+
if (typeof val === "string") {
|
|
1051
|
+
continue;
|
|
1052
|
+
}
|
|
1053
|
+
for (const t of val) {
|
|
1054
|
+
const tkey = Object.keys(t)[0];
|
|
1055
|
+
const defaultVal = defaults[tkey];
|
|
1056
|
+
const tDefaultVal = { [tkey]: defaultVal };
|
|
1057
|
+
if (!base.transform) {
|
|
1058
|
+
base.transform = [tDefaultVal];
|
|
1059
|
+
} else {
|
|
1060
|
+
if (!base.transform.find((x) => x[tkey])) {
|
|
1061
|
+
base.transform.push(tDefaultVal);
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
} else {
|
|
1066
|
+
if (!(key in base)) {
|
|
1067
|
+
base[key] = defaults[key];
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
function merge(base, next) {
|
|
1074
|
+
if (!next.transform || !base.transform) {
|
|
1075
|
+
Object.assign(base, next);
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
const { transform, ...rest } = next;
|
|
1079
|
+
Object.assign(base, rest);
|
|
1080
|
+
for (const t of transform) {
|
|
1081
|
+
const key = Object.keys(t)[0];
|
|
1082
|
+
const existing = base.transform.find((x) => key in x);
|
|
1083
|
+
if (existing) {
|
|
1084
|
+
existing[key] = t[key];
|
|
1085
|
+
} else {
|
|
1086
|
+
base.transform.push(t);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
896
1090
|
export {
|
|
897
1091
|
Spacer,
|
|
898
1092
|
Unspaced,
|