@tamagui/web 1.88.13 → 1.88.14
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/LICENSE +21 -0
- package/dist/cjs/createComponent.js +2 -2
- package/dist/cjs/createComponent.js.map +1 -1
- package/dist/cjs/createComponent.native.js +1 -1
- package/dist/cjs/createComponent.native.js.map +1 -1
- package/dist/cjs/createTamagui.js.map +1 -1
- package/dist/cjs/createTamagui.native.js.map +1 -1
- package/dist/cjs/createVariables.js.map +1 -1
- package/dist/cjs/createVariables.native.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.js +15 -19
- package/dist/cjs/helpers/getSplitStyles.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.native.js +12 -18
- package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/cjs/helpers/getStylesAtomic.js.map +1 -1
- package/dist/cjs/helpers/getThemeCSSRules.js.map +1 -1
- package/dist/cjs/helpers/insertStyleRule.js +3 -3
- package/dist/cjs/helpers/insertStyleRule.js.map +1 -1
- package/dist/cjs/helpers/insertStyleRule.native.js +3 -3
- package/dist/cjs/helpers/insertStyleRule.native.js.map +1 -1
- package/dist/cjs/helpers/propMapper.js.map +1 -1
- package/dist/cjs/helpers/propMapper.native.js.map +1 -1
- package/dist/cjs/helpers/registerCSSVariable.js.map +1 -1
- package/dist/cjs/helpers/registerCSSVariable.native.js.map +1 -1
- package/dist/cjs/hooks/getThemeProxied.js +66 -0
- package/dist/cjs/hooks/getThemeProxied.js.map +6 -0
- package/dist/cjs/hooks/getThemeProxied.native.js +100 -0
- package/dist/cjs/hooks/getThemeProxied.native.js.map +6 -0
- package/dist/cjs/hooks/useTheme.js.map +1 -1
- package/dist/cjs/hooks/useTheme.native.js.map +1 -1
- package/dist/cjs/insertFont.js.map +1 -1
- package/dist/cjs/insertFont.native.js.map +1 -1
- package/dist/cjs/setupHooks.js.map +1 -1
- package/dist/cjs/setupHooks.native.js.map +1 -1
- package/dist/cjs/views/FontLanguage.native.js.map +1 -1
- package/dist/cjs/views/Slot.js.map +1 -1
- package/dist/cjs/views/Slot.native.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.js +5 -5
- package/dist/cjs/views/TamaguiProvider.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.native.js +5 -5
- package/dist/cjs/views/TamaguiProvider.native.js.map +1 -1
- package/dist/cjs/views/Theme.js.map +1 -1
- package/dist/cjs/views/Theme.native.js.map +1 -1
- package/dist/esm/Tamagui.mjs +43 -0
- package/dist/esm/config.mjs +51 -0
- package/dist/esm/constants/accessibilityDirectMap.mjs +50 -0
- package/dist/esm/constants/constants.mjs +16 -0
- package/dist/esm/constants/isDevTools.mjs +7 -0
- package/dist/esm/contexts/ComponentContext.mjs +13 -0
- package/dist/esm/createComponent.js +2 -2
- package/dist/esm/createComponent.js.map +1 -1
- package/dist/esm/createComponent.mjs +771 -0
- package/dist/esm/createComponent.native.js +1 -1
- package/dist/esm/createComponent.native.js.map +1 -1
- package/dist/esm/createFont.mjs +18 -0
- package/dist/esm/createShorthands.mjs +4 -0
- package/dist/esm/createTamagui.js.map +1 -1
- package/dist/esm/createTamagui.mjs +206 -0
- package/dist/esm/createTamagui.native.js.map +1 -1
- package/dist/esm/createTheme.mjs +2 -0
- package/dist/esm/createTokens.mjs +5 -0
- package/dist/esm/createVariable.mjs +48 -0
- package/dist/esm/createVariables.js.map +1 -1
- package/dist/esm/createVariables.mjs +35 -0
- package/dist/esm/createVariables.native.js.map +1 -1
- package/dist/esm/defaultComponentState.mjs +16 -0
- package/dist/esm/helpers/ThemeManager.mjs +156 -0
- package/dist/esm/helpers/ThemeManagerContext.mjs +3 -0
- package/dist/esm/helpers/createMediaStyle.mjs +71 -0
- package/dist/esm/helpers/createShallowSetState.mjs +17 -0
- package/dist/esm/helpers/createStyledContext.mjs +35 -0
- package/dist/esm/helpers/defaultOffset.mjs +5 -0
- package/dist/esm/helpers/expandStyle.mjs +38 -0
- package/dist/esm/helpers/expandStyles.mjs +15 -0
- package/dist/esm/helpers/getExpandedShorthands.mjs +9 -0
- package/dist/esm/helpers/getFontLanguage.mjs +2 -0
- package/dist/esm/helpers/getGroupPropParts.mjs +13 -0
- package/dist/esm/helpers/getSplitStyles.js +15 -18
- package/dist/esm/helpers/getSplitStyles.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs +638 -0
- package/dist/esm/helpers/getSplitStyles.native.js +12 -18
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.js +1 -4
- package/dist/esm/helpers/getStylesAtomic.js.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.mjs +150 -0
- package/dist/esm/helpers/getThemeCSSRules.js.map +1 -1
- package/dist/esm/helpers/getThemeCSSRules.mjs +87 -0
- package/dist/esm/helpers/getVariantExtras.mjs +43 -0
- package/dist/esm/helpers/insertStyleRule.js +3 -3
- package/dist/esm/helpers/insertStyleRule.js.map +1 -1
- package/dist/esm/helpers/insertStyleRule.mjs +177 -0
- package/dist/esm/helpers/insertStyleRule.native.js +3 -3
- package/dist/esm/helpers/insertStyleRule.native.js.map +1 -1
- package/dist/esm/helpers/isObj.mjs +2 -0
- package/dist/esm/helpers/isTamaguiComponent.mjs +5 -0
- package/dist/esm/helpers/isTamaguiElement.mjs +4 -0
- package/dist/esm/helpers/log.mjs +4 -0
- package/dist/esm/helpers/matchMedia.mjs +11 -0
- package/dist/esm/helpers/mergeProps.mjs +21 -0
- package/dist/esm/helpers/mergeVariants.mjs +16 -0
- package/dist/esm/helpers/normalizeColor.mjs +17 -0
- package/dist/esm/helpers/normalizeShadow.mjs +23 -0
- package/dist/esm/helpers/normalizeStyle.mjs +23 -0
- package/dist/esm/helpers/normalizeStylePropKeys.mjs +2 -0
- package/dist/esm/helpers/normalizeValueWithProperty.mjs +32 -0
- package/dist/esm/helpers/objectIdentityKey.mjs +15 -0
- package/dist/esm/helpers/propMapper.js.map +1 -1
- package/dist/esm/helpers/propMapper.mjs +239 -0
- package/dist/esm/helpers/propMapper.native.js.map +1 -1
- package/dist/esm/helpers/proxyThemeToParents.mjs +36 -0
- package/dist/esm/helpers/proxyThemeVariables.mjs +12 -0
- package/dist/esm/helpers/pseudoDescriptors.mjs +34 -0
- package/dist/esm/helpers/registerCSSVariable.js.map +1 -1
- package/dist/esm/helpers/registerCSSVariable.mjs +7 -0
- package/dist/esm/helpers/registerCSSVariable.native.js.map +1 -1
- package/dist/esm/helpers/themeable.mjs +33 -0
- package/dist/esm/helpers/themes.mjs +14 -0
- package/dist/esm/helpers/timer.mjs +8 -0
- package/dist/esm/hooks/getThemeProxied.js +52 -0
- package/dist/esm/hooks/getThemeProxied.js.map +6 -0
- package/dist/esm/hooks/getThemeProxied.mjs +41 -0
- package/dist/esm/hooks/getThemeProxied.native.js +100 -0
- package/dist/esm/hooks/getThemeProxied.native.js.map +6 -0
- package/dist/esm/hooks/useConfiguration.mjs +20 -0
- package/dist/esm/hooks/useDisableSSR.mjs +5 -0
- package/dist/esm/hooks/useIsTouchDevice.mjs +4 -0
- package/dist/esm/hooks/useMedia.mjs +146 -0
- package/dist/esm/hooks/useProps.mjs +40 -0
- package/dist/esm/hooks/useTheme.js +1 -4
- package/dist/esm/hooks/useTheme.js.map +1 -1
- package/dist/esm/hooks/useTheme.mjs +222 -0
- package/dist/esm/hooks/useTheme.native.js.map +1 -1
- package/dist/esm/hooks/useThemeName.mjs +15 -0
- package/dist/esm/index.mjs +61 -0
- package/dist/esm/inject-styles.mjs +13 -0
- package/dist/esm/insertFont.js.map +1 -1
- package/dist/esm/insertFont.mjs +44 -0
- package/dist/esm/insertFont.native.js.map +1 -1
- package/dist/esm/interfaces/CSSColorNames.mjs +0 -0
- package/dist/esm/interfaces/GetRef.mjs +0 -0
- package/dist/esm/interfaces/KeyTypes.mjs +0 -0
- package/dist/esm/interfaces/RNExclusiveTypes.mjs +0 -0
- package/dist/esm/interfaces/Role.mjs +0 -0
- package/dist/esm/interfaces/TamaguiComponentEvents.mjs +0 -0
- package/dist/esm/interfaces/TamaguiComponentPropsBaseBase.mjs +0 -0
- package/dist/esm/interfaces/TamaguiComponentState.mjs +0 -0
- package/dist/esm/interfaces/WebOnlyPressEvents.mjs +0 -0
- package/dist/esm/internalWithTheme.mjs +14 -0
- package/dist/esm/setupHooks.js.map +1 -1
- package/dist/esm/setupHooks.mjs +5 -0
- package/dist/esm/setupHooks.native.js.map +1 -1
- package/dist/esm/setupReactNative.mjs +24 -0
- package/dist/esm/styled.mjs +56 -0
- package/dist/esm/type-utils.mjs +0 -0
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/views/Configuration.mjs +12 -0
- package/dist/esm/views/FontLanguage.mjs +13 -0
- package/dist/esm/views/FontLanguage.native.js.map +1 -1
- package/dist/esm/views/FontLanguage.types.mjs +0 -0
- package/dist/esm/views/Slot.js.map +1 -1
- package/dist/esm/views/Slot.mjs +53 -0
- package/dist/esm/views/Slot.native.js.map +1 -1
- package/dist/esm/views/Stack.mjs +10 -0
- package/dist/esm/views/TamaguiProvider.js +5 -5
- package/dist/esm/views/TamaguiProvider.js.map +1 -1
- package/dist/esm/views/TamaguiProvider.mjs +32 -0
- package/dist/esm/views/TamaguiProvider.native.js +5 -5
- package/dist/esm/views/TamaguiProvider.native.js.map +1 -1
- package/dist/esm/views/Text.mjs +64 -0
- package/dist/esm/views/Theme.js.map +1 -1
- package/dist/esm/views/Theme.mjs +104 -0
- package/dist/esm/views/Theme.native.js.map +1 -1
- package/dist/esm/views/ThemeDebug.mjs +57 -0
- package/dist/esm/views/ThemeProvider.mjs +20 -0
- package/dist/esm/views/View.mjs +9 -0
- package/package.json +11 -11
- package/src/config.ts +1 -1
- package/src/contexts/ComponentContext.tsx +1 -1
- package/src/createComponent.tsx +7 -5
- package/src/createFont.ts +1 -1
- package/src/createShorthands.ts +1 -1
- package/src/createTamagui.ts +4 -3
- package/src/createTokens.ts +2 -2
- package/src/createVariables.ts +2 -1
- package/src/defaultComponentState.tsx +1 -1
- package/src/helpers/ThemeManager.tsx +1 -1
- package/src/helpers/createShallowSetState.tsx +2 -2
- package/src/helpers/expandStyle.ts +1 -1
- package/src/helpers/getExpandedShorthands.ts +1 -1
- package/src/helpers/getSplitStyles.tsx +33 -26
- package/src/helpers/getStylesAtomic.ts +4 -6
- package/src/helpers/getThemeCSSRules.ts +2 -1
- package/src/helpers/getVariantExtras.tsx +2 -2
- package/src/helpers/insertStyleRule.tsx +8 -3
- package/src/helpers/isTamaguiComponent.tsx +1 -1
- package/src/helpers/isTamaguiElement.tsx +1 -1
- package/src/helpers/matchMedia.native.ts +1 -1
- package/src/helpers/matchMedia.ts +1 -1
- package/src/helpers/propMapper.ts +2 -1
- package/src/helpers/proxyThemeToParents.ts +1 -1
- package/src/helpers/registerCSSVariable.ts +3 -2
- package/src/helpers/themeable.tsx +1 -1
- package/src/hooks/useDisableSSR.tsx +1 -1
- package/src/hooks/useProps.tsx +1 -1
- package/src/hooks/useTheme.tsx +4 -6
- package/src/hooks/useThemeName.tsx +1 -1
- package/src/insertFont.ts +4 -3
- package/src/interfaces/GetRef.tsx +2 -2
- package/src/interfaces/TamaguiComponentPropsBaseBase.tsx +2 -2
- package/src/interfaces/TamaguiComponentState.tsx +1 -1
- package/src/interfaces/WebOnlyPressEvents.tsx +1 -1
- package/src/setupHooks.ts +4 -8
- package/src/setupReactNative.ts +1 -1
- package/src/styled.tsx +1 -1
- package/src/types.tsx +9 -9
- package/src/views/FontLanguage.native.tsx +0 -1
- package/src/views/FontLanguage.types.ts +2 -2
- package/src/views/Slot.tsx +2 -1
- package/src/views/TamaguiProvider.tsx +8 -5
- package/src/views/Text.tsx +1 -1
- package/src/views/Theme.tsx +2 -1
- package/src/views/ThemeDebug.native.tsx +2 -2
- package/src/views/ThemeDebug.tsx +2 -2
- package/types/config.d.ts +1 -1
- package/types/config.d.ts.map +1 -1
- package/types/contexts/ComponentContext.d.ts +1 -1
- package/types/contexts/ComponentContext.d.ts.map +1 -1
- package/types/createComponent.d.ts +1 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/createFont.d.ts +1 -1
- package/types/createFont.d.ts.map +1 -1
- package/types/createShorthands.d.ts +1 -1
- package/types/createShorthands.d.ts.map +1 -1
- package/types/createTamagui.d.ts +1 -1
- package/types/createTamagui.d.ts.map +1 -1
- package/types/createTokens.d.ts +2 -2
- package/types/createTokens.d.ts.map +1 -1
- package/types/createVariables.d.ts +1 -1
- package/types/createVariables.d.ts.map +1 -1
- package/types/defaultComponentState.d.ts +1 -1
- package/types/defaultComponentState.d.ts.map +1 -1
- package/types/helpers/ThemeManager.d.ts +1 -1
- package/types/helpers/ThemeManager.d.ts.map +1 -1
- package/types/helpers/createShallowSetState.d.ts +2 -2
- package/types/helpers/createShallowSetState.d.ts.map +1 -1
- package/types/helpers/expandStyle.d.ts +1 -1
- package/types/helpers/expandStyle.d.ts.map +1 -1
- package/types/helpers/getExpandedShorthands.d.ts +1 -1
- package/types/helpers/getExpandedShorthands.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts +2 -2
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/getThemeCSSRules.d.ts.map +1 -1
- package/types/helpers/getVariantExtras.d.ts +2 -2
- package/types/helpers/getVariantExtras.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/helpers/isTamaguiComponent.d.ts +1 -1
- package/types/helpers/isTamaguiComponent.d.ts.map +1 -1
- package/types/helpers/isTamaguiElement.d.ts +1 -1
- package/types/helpers/isTamaguiElement.d.ts.map +1 -1
- package/types/helpers/matchMedia.d.ts +1 -1
- package/types/helpers/matchMedia.d.ts.map +1 -1
- package/types/helpers/matchMedia.native.d.ts +1 -1
- package/types/helpers/matchMedia.native.d.ts.map +1 -1
- package/types/helpers/propMapper.d.ts.map +1 -1
- package/types/helpers/proxyThemeToParents.d.ts +1 -1
- package/types/helpers/proxyThemeToParents.d.ts.map +1 -1
- package/types/helpers/registerCSSVariable.d.ts +2 -2
- package/types/helpers/registerCSSVariable.d.ts.map +1 -1
- package/types/helpers/themeable.d.ts +1 -1
- package/types/helpers/themeable.d.ts.map +1 -1
- package/types/hooks/getThemeProxied.d.ts.map +1 -0
- package/types/hooks/useDisableSSR.d.ts +1 -1
- package/types/hooks/useDisableSSR.d.ts.map +1 -1
- package/types/hooks/useProps.d.ts +1 -1
- package/types/hooks/useProps.d.ts.map +1 -1
- package/types/hooks/useTheme.d.ts +3 -2
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/hooks/useThemeName.d.ts +1 -1
- package/types/hooks/useThemeName.d.ts.map +1 -1
- package/types/insertFont.d.ts +2 -2
- package/types/insertFont.d.ts.map +1 -1
- package/types/interfaces/GetRef.d.ts +2 -2
- package/types/interfaces/GetRef.d.ts.map +1 -1
- package/types/interfaces/TamaguiComponentPropsBaseBase.d.ts +2 -2
- package/types/interfaces/TamaguiComponentPropsBaseBase.d.ts.map +1 -1
- package/types/interfaces/TamaguiComponentState.d.ts +1 -1
- package/types/interfaces/TamaguiComponentState.d.ts.map +1 -1
- package/types/interfaces/WebOnlyPressEvents.d.ts +1 -1
- package/types/interfaces/WebOnlyPressEvents.d.ts.map +1 -1
- package/types/setupHooks.d.ts +3 -3
- package/types/setupHooks.d.ts.map +1 -1
- package/types/setupReactNative.d.ts +1 -1
- package/types/setupReactNative.d.ts.map +1 -1
- package/types/styled.d.ts +1 -1
- package/types/styled.d.ts.map +1 -1
- package/types/types.d.ts +9 -9
- package/types/types.d.ts.map +1 -1
- package/types/views/FontLanguage.native.d.ts.map +1 -1
- package/types/views/FontLanguage.types.d.ts +2 -2
- package/types/views/FontLanguage.types.d.ts.map +1 -1
- package/types/views/Slot.d.ts +1 -1
- package/types/views/Slot.d.ts.map +1 -1
- package/types/views/TamaguiProvider.d.ts.map +1 -1
- package/types/views/Text.d.ts +1 -1
- package/types/views/Text.d.ts.map +1 -1
- package/types/views/Theme.d.ts +1 -1
- package/types/views/Theme.d.ts.map +1 -1
- package/types/views/ThemeDebug.d.ts +2 -2
- package/types/views/ThemeDebug.d.ts.map +1 -1
- package/types/views/ThemeDebug.native.d.ts +2 -2
- package/types/views/ThemeDebug.native.d.ts.map +1 -1
|
@@ -0,0 +1,638 @@
|
|
|
1
|
+
import { currentPlatform, isClient, isServer, isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
|
+
import { stylePropsText, stylePropsTransform, validPseudoKeys, validStyles, validStylesOnBaseProps } from "@tamagui/helpers";
|
|
3
|
+
import { useInsertionEffect } from "react";
|
|
4
|
+
import { getConfig } from "../config.mjs";
|
|
5
|
+
import { accessibilityDirectMap } from "../constants/accessibilityDirectMap.mjs";
|
|
6
|
+
import { webViewFlexCompatStyles } from "../constants/constants.mjs";
|
|
7
|
+
import { isDevTools } from "../constants/isDevTools.mjs";
|
|
8
|
+
import { getMediaImportanceIfMoreImportant, mediaState as globalMediaState, isMediaKey, mediaKeyMatch, mediaQueryConfig, mergeMediaByImportance } from "../hooks/useMedia.mjs";
|
|
9
|
+
import { createMediaStyle } from "./createMediaStyle.mjs";
|
|
10
|
+
import { fixStyles } from "./expandStyles.mjs";
|
|
11
|
+
import { getGroupPropParts } from "./getGroupPropParts.mjs";
|
|
12
|
+
import { generateAtomicStyles, getStylesAtomic, styleToCSS, transformsToString } from "./getStylesAtomic.mjs";
|
|
13
|
+
import { insertStyleRules, insertedTransforms, scanAllSheets, shouldInsertStyleRules, updateRules } from "./insertStyleRule.mjs";
|
|
14
|
+
import { log } from "./log.mjs";
|
|
15
|
+
import { normalizeValueWithProperty, reverseMapClassNameToValue } from "./normalizeValueWithProperty.mjs";
|
|
16
|
+
import { getPropMappedFontFamily, propMapper } from "./propMapper.mjs";
|
|
17
|
+
import { pseudoDescriptors, pseudoPriorities } from "./pseudoDescriptors.mjs";
|
|
18
|
+
import { isObj } from "./isObj.mjs";
|
|
19
|
+
const IS_STATIC = process.env.IS_STATIC === "is_static";
|
|
20
|
+
let conf;
|
|
21
|
+
const PROP_SPLIT = "-";
|
|
22
|
+
function isValidStyleKey(key, staticConfig) {
|
|
23
|
+
return (staticConfig.validStyles || (staticConfig.isText || staticConfig.isInput ? stylePropsText : validStyles))[key] || staticConfig.acceptTokens && staticConfig.acceptTokens[key];
|
|
24
|
+
}
|
|
25
|
+
const getSplitStyles = (props, staticConfig, theme, themeName, componentState, styleProps, parentSplitStyles, context, elementType, debug) => {
|
|
26
|
+
conf = conf || getConfig(), isWeb && styleProps.isAnimated && conf.animations.isReactNative && !styleProps.noNormalize && (styleProps.noNormalize = "values");
|
|
27
|
+
const {
|
|
28
|
+
shorthands
|
|
29
|
+
} = conf,
|
|
30
|
+
{
|
|
31
|
+
isHOC,
|
|
32
|
+
isText,
|
|
33
|
+
isInput,
|
|
34
|
+
variants,
|
|
35
|
+
isReactNative,
|
|
36
|
+
inlineProps,
|
|
37
|
+
inlineWhenUnflattened,
|
|
38
|
+
parentStaticConfig,
|
|
39
|
+
acceptsClassName
|
|
40
|
+
} = staticConfig,
|
|
41
|
+
viewProps = {},
|
|
42
|
+
mediaState = styleProps.mediaState || globalMediaState,
|
|
43
|
+
usedKeys = {},
|
|
44
|
+
shouldDoClasses = acceptsClassName && isWeb && !styleProps.noClassNames,
|
|
45
|
+
rulesToInsert = [],
|
|
46
|
+
classNames = {},
|
|
47
|
+
transforms = {};
|
|
48
|
+
let pseudos = null,
|
|
49
|
+
space = props.space,
|
|
50
|
+
hasMedia = !1,
|
|
51
|
+
dynamicThemeAccess,
|
|
52
|
+
pseudoGroups,
|
|
53
|
+
mediaGroups,
|
|
54
|
+
style = {},
|
|
55
|
+
className = props.className ?? "",
|
|
56
|
+
mediaStylesSeen = 0;
|
|
57
|
+
const styleState = {
|
|
58
|
+
curProps: {
|
|
59
|
+
...props
|
|
60
|
+
},
|
|
61
|
+
classNames,
|
|
62
|
+
conf,
|
|
63
|
+
props,
|
|
64
|
+
styleProps,
|
|
65
|
+
componentState,
|
|
66
|
+
staticConfig,
|
|
67
|
+
style,
|
|
68
|
+
theme,
|
|
69
|
+
usedKeys,
|
|
70
|
+
viewProps,
|
|
71
|
+
context,
|
|
72
|
+
debug
|
|
73
|
+
};
|
|
74
|
+
process.env.NODE_ENV === "development" && debug && debug !== "profile" && isClient && (console.groupCollapsed("getSplitStyles (collapsed)"), log({
|
|
75
|
+
props,
|
|
76
|
+
staticConfig,
|
|
77
|
+
shouldDoClasses,
|
|
78
|
+
styleProps,
|
|
79
|
+
componentState,
|
|
80
|
+
styleState,
|
|
81
|
+
theme: {
|
|
82
|
+
...theme
|
|
83
|
+
}
|
|
84
|
+
}), console.groupEnd());
|
|
85
|
+
for (const keyOg in props) {
|
|
86
|
+
process.env.NODE_ENV === "development" && console.groupEnd();
|
|
87
|
+
let keyInit = keyOg,
|
|
88
|
+
valInit = props[keyOg];
|
|
89
|
+
if (styleProps.disableExpandShorthands || keyInit in shorthands && (keyInit = shorthands[keyInit]), keyInit === "className" || keyInit in usedKeys || props.asChild && webViewFlexCompatStyles[keyInit] === valInit) continue;
|
|
90
|
+
if (keyInit in skipProps && !styleProps.noSkip && !isHOC) {
|
|
91
|
+
if (keyInit === "group") {
|
|
92
|
+
const identifier = `t_group_${valInit}`,
|
|
93
|
+
containerType = conf.settings.webContainerType || "inline-size",
|
|
94
|
+
containerCSS = {
|
|
95
|
+
identifier,
|
|
96
|
+
property: "container",
|
|
97
|
+
rules: [`.${identifier} { container-name: ${valInit}; container-type: ${containerType}; }`]
|
|
98
|
+
};
|
|
99
|
+
addStyleToInsertRules(rulesToInsert, containerCSS);
|
|
100
|
+
}
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const valInitType = typeof valInit,
|
|
104
|
+
isValidStyleKeyInit = isValidStyleKey(keyInit, staticConfig);
|
|
105
|
+
if (isValidStyleKeyInit && valInitType === "string" && valInit[0] === "_") {
|
|
106
|
+
const isValidClassName = (keyInit in validStyles),
|
|
107
|
+
isMediaOrPseudo2 = !isValidClassName &&
|
|
108
|
+
// media are flattened for some reason to color-hover keys,
|
|
109
|
+
// we should probably just leave them in place to avoid extra complexity
|
|
110
|
+
keyInit.includes(PROP_SPLIT) && validStyles[keyInit.split(PROP_SPLIT)[0]];
|
|
111
|
+
if (isValidClassName || isMediaOrPseudo2) {
|
|
112
|
+
shouldDoClasses ? (mergeClassName(transforms, classNames, keyInit, valInit, isMediaOrPseudo2), delete style[keyInit]) : (style[keyInit] = reverseMapClassNameToValue(keyInit, valInit), delete classNames[keyInit]);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (styleState.curProps[keyInit] = valInit, keyInit === "dataSet") {
|
|
117
|
+
for (const keyInit2 in valInit) viewProps[`data-${hyphenate(keyInit2)}`] = valInit[keyInit2];
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (keyInit.startsWith("_style") && isObj(valInit)) {
|
|
121
|
+
Object.assign(styleState.style, valInit);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (!styleProps.noExpand) {
|
|
125
|
+
if (keyInit === "disabled" && valInit === !0 && (viewProps["aria-disabled"] = !0, (elementType === "button" || elementType === "form" || elementType === "input" || elementType === "select" || elementType === "textarea") && (viewProps.disabled = !0), !variants?.disabled)) continue;
|
|
126
|
+
if (keyInit === "testID") {
|
|
127
|
+
viewProps[isReactNative ? keyInit : "data-testid"] = valInit;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (keyInit === "id" || keyInit === "nativeID") {
|
|
131
|
+
viewProps.id = valInit;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
let didUseKeyInit = !1;
|
|
135
|
+
if (isReactNative) {
|
|
136
|
+
if (keyInit in accessibilityDirectMap || keyInit.startsWith("accessibility")) {
|
|
137
|
+
viewProps[keyInit] = valInit;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
if (didUseKeyInit = !0, keyInit in accessibilityDirectMap) {
|
|
142
|
+
viewProps[accessibilityDirectMap[keyInit]] = valInit;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
switch (keyInit) {
|
|
146
|
+
case "accessibilityRole":
|
|
147
|
+
{
|
|
148
|
+
valInit === "none" ? viewProps.role = "presentation" : viewProps.role = accessibilityRoleToWebRole[valInit] || valInit;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
case "accessibilityLabelledBy":
|
|
152
|
+
case "accessibilityFlowTo":
|
|
153
|
+
case "accessibilityControls":
|
|
154
|
+
case "accessibilityDescribedBy":
|
|
155
|
+
{
|
|
156
|
+
viewProps[`aria-${keyInit.replace("accessibility", "").toLowerCase()}`] = processIDRefList(valInit);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
case "accessibilityKeyShortcuts":
|
|
160
|
+
{
|
|
161
|
+
Array.isArray(valInit) && (viewProps["aria-keyshortcuts"] = valInit.join(" "));
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
case "accessibilityLiveRegion":
|
|
165
|
+
{
|
|
166
|
+
viewProps["aria-live"] = valInit === "none" ? "off" : valInit;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
case "accessibilityReadOnly":
|
|
170
|
+
{
|
|
171
|
+
viewProps["aria-readonly"] = valInit, (elementType === "input" || elementType === "select" || elementType === "textarea") && (viewProps.readOnly = !0);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
case "accessibilityRequired":
|
|
175
|
+
{
|
|
176
|
+
viewProps["aria-required"] = valInit, (elementType === "input" || elementType === "select" || elementType === "textarea") && (viewProps.required = valInit);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
default:
|
|
180
|
+
didUseKeyInit = !1;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (didUseKeyInit) continue;
|
|
184
|
+
}
|
|
185
|
+
const isShorthand = (keyInit in shorthands);
|
|
186
|
+
let isVariant = !isValidStyleKeyInit && variants && keyInit in variants;
|
|
187
|
+
const isStyleLikeKey = isShorthand || isValidStyleKeyInit || isVariant;
|
|
188
|
+
let isPseudo = (keyInit in validPseudoKeys),
|
|
189
|
+
isMedia = !isStyleLikeKey && !isPseudo && isMediaKey(keyInit),
|
|
190
|
+
isMediaOrPseudo = !!(isMedia || isPseudo);
|
|
191
|
+
const isStyleProp = isMediaOrPseudo || isVariant && !styleProps.noExpand || isValidStyleKeyInit || isShorthand;
|
|
192
|
+
if (isStyleProp && (props.asChild === "except-style" || props.asChild === "except-style-web")) continue;
|
|
193
|
+
const shouldPassProp = !isStyleProp ||
|
|
194
|
+
// is in parent variants
|
|
195
|
+
isHOC && parentStaticConfig?.variants && keyInit in parentStaticConfig.variants || inlineProps?.has(keyInit),
|
|
196
|
+
parentVariant = parentStaticConfig?.variants?.[keyInit],
|
|
197
|
+
isHOCShouldPassThrough = !!(isHOC && (isShorthand || isValidStyleKeyInit || isMediaOrPseudo || parentVariant || keyInit in skipProps)),
|
|
198
|
+
shouldPassThrough = shouldPassProp || isHOCShouldPassThrough;
|
|
199
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupEnd(), console.groupEnd(), console.groupCollapsed(` \u{1F511} ${keyOg}${keyInit !== keyOg ? ` (shorthand for ${keyInit})` : ""} ${shouldPassThrough ? "(pass)" : ""}`), log({
|
|
200
|
+
isVariant,
|
|
201
|
+
valInit,
|
|
202
|
+
shouldPassProp
|
|
203
|
+
}), isClient && log({
|
|
204
|
+
variants,
|
|
205
|
+
variant: variants?.[keyInit],
|
|
206
|
+
isVariant,
|
|
207
|
+
isHOCShouldPassThrough,
|
|
208
|
+
curProps: {
|
|
209
|
+
...styleState.curProps
|
|
210
|
+
},
|
|
211
|
+
parentStaticConfig
|
|
212
|
+
})), shouldPassThrough && (passDownProp(viewProps, keyInit, valInit, isMediaOrPseudo), !isVariant) || !styleProps.noSkip && keyInit in skipProps) continue;
|
|
213
|
+
(isText || isInput) && valInit && (keyInit === "fontFamily" || keyInit === shorthands.fontFamily) && valInit in conf.fontsParsed && (styleState.fontFamily = valInit);
|
|
214
|
+
const expanded = isMediaOrPseudo || !isVariant && !isValidStyleKeyInit ? [[keyInit, valInit]] : propMapper(keyInit, valInit, styleState),
|
|
215
|
+
next = getPropMappedFontFamily(expanded);
|
|
216
|
+
if (next && (styleState.fontFamily = next), process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
217
|
+
console.groupCollapsed(" \u{1F4A0} expanded", keyInit, valInit);
|
|
218
|
+
try {
|
|
219
|
+
!isServer && isDevTools && (log({
|
|
220
|
+
expanded,
|
|
221
|
+
styleProps,
|
|
222
|
+
componentState,
|
|
223
|
+
isVariant,
|
|
224
|
+
variant: variants?.[keyInit],
|
|
225
|
+
shouldPassProp,
|
|
226
|
+
isHOCShouldPassThrough,
|
|
227
|
+
theme,
|
|
228
|
+
usedKeys: {
|
|
229
|
+
...usedKeys
|
|
230
|
+
},
|
|
231
|
+
curProps: {
|
|
232
|
+
...styleState.curProps
|
|
233
|
+
}
|
|
234
|
+
}), log("expanded", expanded, `
|
|
235
|
+
usedKeys`, {
|
|
236
|
+
...usedKeys
|
|
237
|
+
}, `
|
|
238
|
+
current`, {
|
|
239
|
+
...style
|
|
240
|
+
}));
|
|
241
|
+
} catch {}
|
|
242
|
+
console.groupEnd();
|
|
243
|
+
}
|
|
244
|
+
if (expanded) {
|
|
245
|
+
for (const [key, val] of expanded) {
|
|
246
|
+
if (val == null || key in usedKeys) continue;
|
|
247
|
+
if (isPseudo = key in validPseudoKeys, isMedia = !isPseudo && !isValidStyleKeyInit && isMediaKey(key), isMediaOrPseudo = !!(isMedia || isPseudo), isVariant = variants && key in variants, (inlineProps?.has(key) || IS_STATIC && inlineWhenUnflattened?.has(key)) && (viewProps[key] = props[key] ?? val), styleProps.noExpand && isPseudo || isHOC && (isMediaOrPseudo || parentStaticConfig?.variants?.[keyInit])) {
|
|
248
|
+
passDownProp(viewProps, key, val, isMediaOrPseudo), process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed(` - passing down prop ${key}`), log({
|
|
249
|
+
val,
|
|
250
|
+
after: {
|
|
251
|
+
...viewProps[key]
|
|
252
|
+
}
|
|
253
|
+
}), console.groupEnd());
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
if (isPseudo) {
|
|
257
|
+
if (!val) continue;
|
|
258
|
+
const pseudoStyleObject = getSubStyle(styleState, key, val, styleProps.noClassNames),
|
|
259
|
+
descriptor = pseudoDescriptors[key],
|
|
260
|
+
isEnter = key === "enterStyle",
|
|
261
|
+
isExit = key === "exitStyle";
|
|
262
|
+
if (!descriptor) continue;
|
|
263
|
+
if ((!shouldDoClasses || IS_STATIC) && (pseudos ||= {}, pseudos[key] ||= {}, IS_STATIC)) {
|
|
264
|
+
Object.assign(pseudos[key], pseudoStyleObject);
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
if (shouldDoClasses && !isExit) {
|
|
268
|
+
const pseudoStyles = generateAtomicStyles(pseudoStyleObject, descriptor);
|
|
269
|
+
process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed("pseudo (classes)", key), log({
|
|
270
|
+
pseudoStyleObject,
|
|
271
|
+
pseudoStyles
|
|
272
|
+
}), console.groupEnd());
|
|
273
|
+
for (const psuedoStyle of pseudoStyles) {
|
|
274
|
+
const fullKey = `${psuedoStyle.property}${PROP_SPLIT}${descriptor.name}`;
|
|
275
|
+
fullKey in usedKeys || (addStyleToInsertRules(rulesToInsert, psuedoStyle), mergeClassName(transforms, classNames, fullKey, psuedoStyle.identifier, isMediaOrPseudo, !0));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (!shouldDoClasses || isExit || isEnter) {
|
|
279
|
+
const descriptorKey = descriptor.stateKey || descriptor.name;
|
|
280
|
+
let isDisabled = componentState[descriptorKey] === !1;
|
|
281
|
+
isExit && (isDisabled = !styleProps.isExiting), isEnter && (isDisabled = componentState.unmounted === "should-enter" ? !0 : !componentState.unmounted), process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed("pseudo", key, {
|
|
282
|
+
isDisabled
|
|
283
|
+
}), log({
|
|
284
|
+
pseudoStyleObject,
|
|
285
|
+
isDisabled,
|
|
286
|
+
descriptor,
|
|
287
|
+
componentState
|
|
288
|
+
}), console.groupEnd());
|
|
289
|
+
const importance = descriptor.priority;
|
|
290
|
+
for (const pkey in pseudoStyleObject) {
|
|
291
|
+
const val2 = pseudoStyleObject[pkey];
|
|
292
|
+
if (isDisabled) {
|
|
293
|
+
const defaultValues = animatableDefaults[pkey];
|
|
294
|
+
defaultValues != null && !(pkey in usedKeys) && mergeStyle(styleState, pkey, defaultValues);
|
|
295
|
+
} else {
|
|
296
|
+
const curImportance = usedKeys[pkey] || 0,
|
|
297
|
+
shouldMerge = importance >= curImportance;
|
|
298
|
+
shouldMerge && (pseudos ||= {}, pseudos[key] ||= {}, pseudos[key][pkey] = val2, mergeStyle(styleState, pkey, val2)), process.env.NODE_ENV === "development" && debug === "verbose" && log(" subKey", pkey, shouldMerge, {
|
|
299
|
+
importance,
|
|
300
|
+
curImportance,
|
|
301
|
+
pkey,
|
|
302
|
+
val: val2,
|
|
303
|
+
transforms: {
|
|
304
|
+
...styleState.transforms
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (!isDisabled) for (const key2 in val) {
|
|
310
|
+
const k = shorthands[key2] || key2;
|
|
311
|
+
usedKeys[k] = Math.max(importance, usedKeys[k] || 0);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
if (isMedia) {
|
|
317
|
+
if (!val) continue;
|
|
318
|
+
if (isMedia === "platform") {
|
|
319
|
+
const platform = key.slice(10);
|
|
320
|
+
if (
|
|
321
|
+
// supports web, ios, android
|
|
322
|
+
platform !== currentPlatform &&
|
|
323
|
+
// supports web, native
|
|
324
|
+
platform !== "web") continue;
|
|
325
|
+
}
|
|
326
|
+
hasMedia ||= !0;
|
|
327
|
+
const mediaStyle = getSubStyle(styleState, key, val,
|
|
328
|
+
// TODO try true like pseudo
|
|
329
|
+
!1),
|
|
330
|
+
mediaKeyShort = key.slice(1);
|
|
331
|
+
process.env.NODE_ENV === "development" && debug === "verbose" && log(` \u{1F4FA} ${key}`, {
|
|
332
|
+
key,
|
|
333
|
+
val,
|
|
334
|
+
mediaStyle,
|
|
335
|
+
props,
|
|
336
|
+
shouldDoClasses,
|
|
337
|
+
componentState
|
|
338
|
+
});
|
|
339
|
+
const hasSpace = val.space;
|
|
340
|
+
if ((hasSpace || !shouldDoClasses) && (Array.isArray(hasMedia) || (hasMedia = []), hasMedia.push(mediaKeyShort)), shouldDoClasses) {
|
|
341
|
+
if (hasSpace && (delete mediaStyle.space, mediaState[mediaKeyShort])) {
|
|
342
|
+
const importance = getMediaImportanceIfMoreImportant(mediaKeyShort, "space", usedKeys, !0);
|
|
343
|
+
importance && (space = val.space, usedKeys.space = importance, process.env.NODE_ENV === "development" && debug === "verbose" && log(`Found more important space for current media ${mediaKeyShort}: ${val} (importance: ${importance})`));
|
|
344
|
+
}
|
|
345
|
+
const mediaStyles = getStylesAtomic(mediaStyle, debug),
|
|
346
|
+
priority = mediaStylesSeen;
|
|
347
|
+
mediaStylesSeen += 1;
|
|
348
|
+
for (const style2 of mediaStyles) {
|
|
349
|
+
const out = createMediaStyle(style2, mediaKeyShort, mediaQueryConfig, isMedia, !1, priority);
|
|
350
|
+
process.env.NODE_ENV === "development" && debug === "verbose" && log("\u{1F4FA} media style:", out);
|
|
351
|
+
const fullKey = `${style2.property}${PROP_SPLIT}${mediaKeyShort}`;
|
|
352
|
+
fullKey in usedKeys || (addStyleToInsertRules(rulesToInsert, out), mergeClassName(transforms, classNames, fullKey, out.identifier, !0, !0));
|
|
353
|
+
}
|
|
354
|
+
} else {
|
|
355
|
+
const isThemeMedia = isMedia === "theme",
|
|
356
|
+
isGroupMedia = isMedia === "group";
|
|
357
|
+
if (!isThemeMedia && !(isMedia === "platform") && !isGroupMedia && !mediaState[mediaKeyShort]) continue;
|
|
358
|
+
let importanceBump = 0;
|
|
359
|
+
if (isThemeMedia) {
|
|
360
|
+
dynamicThemeAccess = !0;
|
|
361
|
+
const mediaThemeName = mediaKeyShort.slice(6);
|
|
362
|
+
if (!(themeName === mediaThemeName || themeName.startsWith(mediaThemeName))) continue;
|
|
363
|
+
} else if (isGroupMedia) {
|
|
364
|
+
const groupInfo = getGroupPropParts(mediaKeyShort),
|
|
365
|
+
groupName = groupInfo.name,
|
|
366
|
+
groupContext = context?.groups.state[groupName];
|
|
367
|
+
if (!groupContext) {
|
|
368
|
+
process.env.NODE_ENV === "development" && debug && console.warn(`No parent with group prop, skipping styles: ${groupName}`);
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
const groupPseudoKey = groupInfo.pseudo,
|
|
372
|
+
groupMediaKey = groupInfo.media,
|
|
373
|
+
componentGroupState = componentState.group?.[groupName];
|
|
374
|
+
if (groupMediaKey) {
|
|
375
|
+
mediaGroups ||= /* @__PURE__ */new Set(), mediaGroups.add(groupMediaKey);
|
|
376
|
+
const mediaState2 = componentGroupState?.media;
|
|
377
|
+
let isActive = mediaState2?.[groupMediaKey];
|
|
378
|
+
if (!mediaState2 && groupContext.layout && (isActive = mediaKeyMatch(groupMediaKey, groupContext.layout)), !isActive) continue;
|
|
379
|
+
importanceBump = 2;
|
|
380
|
+
}
|
|
381
|
+
if (groupPseudoKey) {
|
|
382
|
+
if (pseudoGroups ||= /* @__PURE__ */new Set(), pseudoGroups.add(groupName), !(componentGroupState ||
|
|
383
|
+
// fallback to context initially
|
|
384
|
+
context.groups.state[groupName]).pseudo?.[groupPseudoKey]) continue;
|
|
385
|
+
importanceBump = pseudoPriorities[groupPseudoKey];
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
for (const subKey in mediaStyle) {
|
|
389
|
+
if (subKey === "space") {
|
|
390
|
+
space = valInit.space;
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
mergeMediaByImportance(style, mediaKeyShort, subKey, mediaStyle[subKey], usedKeys, mediaState[mediaKeyShort], importanceBump), key === "fontFamily" && (styleState.fontFamily = mediaStyle.fontFamily);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
if (
|
|
399
|
+
// is HOC we can just pass through the styles as props
|
|
400
|
+
// this fixes issues where style prop got merged with wrong priority
|
|
401
|
+
!isHOC && isValidStyleKey(key, staticConfig)) {
|
|
402
|
+
mergeStyle(styleState, key, val);
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
isVariant || (viewProps[key] = val);
|
|
406
|
+
}
|
|
407
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
408
|
+
console.groupCollapsed(" \u2714\uFE0F expand complete", keyInit);
|
|
409
|
+
try {
|
|
410
|
+
log("style", {
|
|
411
|
+
...style
|
|
412
|
+
}), log("transforms", {
|
|
413
|
+
...transforms
|
|
414
|
+
}), log("viewProps", {
|
|
415
|
+
...viewProps
|
|
416
|
+
});
|
|
417
|
+
} catch {}
|
|
418
|
+
console.groupEnd();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
if (process.env.NODE_ENV === "development" && console.groupEnd(), props.style) if (isHOC) viewProps.style = props.style;else for (const style2 of [].concat(props.style)) style2 && (style2.$$css ? Object.assign(styleState.classNames, style2) : Object.assign(styleState.style, style2));
|
|
423
|
+
if (!(styleProps.noNormalize === !1) && (fixStyles(style), isWeb && !staticConfig.isReactNative && styleToCSS(style), styleState.transforms && Object.entries(styleState.transforms).sort(([a], [b]) => a.localeCompare(b)).forEach(([key, val]) => {
|
|
424
|
+
mergeTransform(style, key, val, !0);
|
|
425
|
+
}), !staticConfig.isReactNative && !staticConfig.isHOC && !(styleProps.isAnimated && !conf.animations.supportsCSSVars) && Array.isArray(style.transform) && (style.transform = transformsToString(style.transform)), parentSplitStyles)) {
|
|
426
|
+
if (shouldDoClasses) for (const key in parentSplitStyles.classNames) {
|
|
427
|
+
const val = parentSplitStyles.classNames[key];
|
|
428
|
+
key in style || key in classNames || (classNames[key] = val);
|
|
429
|
+
}
|
|
430
|
+
if (!shouldDoClasses) for (const key in parentSplitStyles.style) key in classNames || key in style || (style[key] = parentSplitStyles.style[key]);
|
|
431
|
+
}
|
|
432
|
+
if (shouldDoClasses) {
|
|
433
|
+
let retainedStyles,
|
|
434
|
+
shouldRetain = !1;
|
|
435
|
+
if (!style.$$css) {
|
|
436
|
+
const atomic = getStylesAtomic(style);
|
|
437
|
+
for (const atomicStyle of atomic) {
|
|
438
|
+
const key = atomicStyle.property,
|
|
439
|
+
isAnimatedAndAnimateOnly = styleProps.isAnimated && styleProps.noClassNames && (!props.animateOnly || props.animateOnly.includes(key)),
|
|
440
|
+
nonAnimatedAnimateOnly = !isAnimatedAndAnimateOnly && !styleProps.isAnimated && props.animateOnly?.includes(key);
|
|
441
|
+
isAnimatedAndAnimateOnly ? (retainedStyles ||= {}, retainedStyles[key] = style[key]) : nonAnimatedAnimateOnly ? (retainedStyles ||= {}, retainedStyles[key] = atomicStyle.value, shouldRetain = !0) : (addStyleToInsertRules(rulesToInsert, atomicStyle), mergeClassName(transforms, classNames, key, atomicStyle.identifier, !1, !0));
|
|
442
|
+
}
|
|
443
|
+
process.env.NODE_ENV === "development" && props.debug === "verbose" && (console.groupCollapsed("\u{1F539} getSplitStyles final style object"), console.info(style), console.groupEnd()), (shouldRetain || !IS_STATIC) && (style = retainedStyles || {});
|
|
444
|
+
}
|
|
445
|
+
if (transforms) for (const namespace in transforms) {
|
|
446
|
+
if (!transforms[namespace]) {
|
|
447
|
+
process.env.NODE_ENV === "development" && console.warn("Error no transform", transforms, namespace);
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
const [hash, val] = transforms[namespace],
|
|
451
|
+
identifier = `_transform${hash}`;
|
|
452
|
+
if (isClient && !insertedTransforms[identifier]) {
|
|
453
|
+
const rule = `.${identifier} { transform: ${val}; }`;
|
|
454
|
+
addStyleToInsertRules(rulesToInsert, {
|
|
455
|
+
identifier,
|
|
456
|
+
rules: [rule],
|
|
457
|
+
property: namespace
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
classNames[namespace] = identifier;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
if (isWeb && !isReactNative && viewProps.tabIndex == null) {
|
|
464
|
+
const isFocusable = viewProps.focusable ?? viewProps.accessible;
|
|
465
|
+
viewProps.focusable && delete viewProps.focusable;
|
|
466
|
+
const role = viewProps.role;
|
|
467
|
+
isFocusable === !1 && (viewProps.tabIndex = "-1"),
|
|
468
|
+
// These native elements are focusable by default
|
|
469
|
+
elementType === "a" || elementType === "button" || elementType === "input" || elementType === "select" || elementType === "textarea" ? (isFocusable === !1 || props.accessibilityDisabled === !0) && (viewProps.tabIndex = "-1") :
|
|
470
|
+
// These roles are made focusable by default
|
|
471
|
+
(role === "button" || role === "checkbox" || role === "link" || role === "radio" ||
|
|
472
|
+
// @ts-expect-error (consistent with RNW)
|
|
473
|
+
role === "textbox" || role === "switch") && isFocusable !== !1 && (viewProps.tabIndex = "0"), isFocusable && (viewProps.tabIndex = "0", delete viewProps.focusable);
|
|
474
|
+
}
|
|
475
|
+
const result = {
|
|
476
|
+
space,
|
|
477
|
+
hasMedia,
|
|
478
|
+
fontFamily: styleState.fontFamily,
|
|
479
|
+
viewProps,
|
|
480
|
+
// @ts-expect-error
|
|
481
|
+
style,
|
|
482
|
+
pseudos,
|
|
483
|
+
classNames,
|
|
484
|
+
rulesToInsert,
|
|
485
|
+
dynamicThemeAccess,
|
|
486
|
+
pseudoGroups,
|
|
487
|
+
mediaGroups
|
|
488
|
+
};
|
|
489
|
+
if (className && (classNames.className = className), process.env.NODE_ENV === "development" && debug === "verbose" && isDevTools) {
|
|
490
|
+
console.groupCollapsed("\u{1F539} getSplitStyles ===>");
|
|
491
|
+
try {
|
|
492
|
+
const logs = {
|
|
493
|
+
...result,
|
|
494
|
+
className,
|
|
495
|
+
componentState,
|
|
496
|
+
transforms,
|
|
497
|
+
viewProps,
|
|
498
|
+
viewPropsOrder: Object.keys(viewProps),
|
|
499
|
+
rulesToInsert,
|
|
500
|
+
parentSplitStyles
|
|
501
|
+
};
|
|
502
|
+
for (const key in logs) log(key, logs[key]);
|
|
503
|
+
} catch {}
|
|
504
|
+
console.groupEnd();
|
|
505
|
+
}
|
|
506
|
+
return result;
|
|
507
|
+
};
|
|
508
|
+
function mergeClassName(transforms, classNames, key, val, isMediaOrPseudo = !1, isInsertingNow = !1) {
|
|
509
|
+
if (val) if (!isInsertingNow && val[0] === "_" && val.startsWith("_transform-")) {
|
|
510
|
+
const ns = isMediaOrPseudo ? key : "transform";
|
|
511
|
+
let transform = insertedTransforms[val];
|
|
512
|
+
isClient && !transform && (scanAllSheets(), transform = insertedTransforms[val], !transform && isWeb && val[0] !== "_" && (transform = val)), transforms[ns] ||= ["", ""], transforms[ns][0] += val.replace("_transform", ""), transform && (transforms[ns][1] += transform);
|
|
513
|
+
} else classNames[key] = val;
|
|
514
|
+
}
|
|
515
|
+
function mergeStyle(styleState, key, val, disableNormalize = !1) {
|
|
516
|
+
const {
|
|
517
|
+
classNames,
|
|
518
|
+
viewProps,
|
|
519
|
+
style,
|
|
520
|
+
usedKeys,
|
|
521
|
+
styleProps
|
|
522
|
+
} = styleState;
|
|
523
|
+
if (isWeb && val?.[0] === "_") classNames[key] = val, usedKeys[key] ||= 1;else if (key in stylePropsTransform) styleState.transforms ||= {}, styleState.transforms[key] = val;else {
|
|
524
|
+
const out = isWeb && !disableNormalize && !styleProps.noNormalize ? normalizeValueWithProperty(val, key) : val;
|
|
525
|
+
key in validStylesOnBaseProps ? viewProps[key] = out : style[key] = out;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
const getSubStyle = (styleState, subKey, styleIn, avoidMergeTransform) => {
|
|
529
|
+
const {
|
|
530
|
+
staticConfig,
|
|
531
|
+
props,
|
|
532
|
+
conf: conf2,
|
|
533
|
+
styleProps
|
|
534
|
+
} = styleState,
|
|
535
|
+
styleOut = {};
|
|
536
|
+
for (let key in styleIn) {
|
|
537
|
+
const val = styleIn[key];
|
|
538
|
+
key = conf2.shorthands[key] || key;
|
|
539
|
+
const expanded = propMapper(key, val, styleState, {
|
|
540
|
+
...props,
|
|
541
|
+
...props[subKey]
|
|
542
|
+
});
|
|
543
|
+
if (!(!expanded || !staticConfig.isHOC && key in skipProps && !styleProps.noSkip)) for (const [skey, sval] of expanded) !avoidMergeTransform && skey in stylePropsTransform ? mergeTransform(styleOut, skey, sval) : styleOut[skey] = styleProps.noNormalize ? sval : normalizeValueWithProperty(sval, key);
|
|
544
|
+
}
|
|
545
|
+
return styleProps.noNormalize || fixStyles(styleOut), styleOut;
|
|
546
|
+
},
|
|
547
|
+
useInsertEffectCompat = isWeb ? useInsertionEffect || useIsomorphicLayoutEffect : () => {},
|
|
548
|
+
useSplitStyles = (...args) => {
|
|
549
|
+
const res = getSplitStyles(...args);
|
|
550
|
+
return useInsertEffectCompat(() => {
|
|
551
|
+
insertStyleRules(res.rulesToInsert);
|
|
552
|
+
}, [res.rulesToInsert]), res;
|
|
553
|
+
};
|
|
554
|
+
function addStyleToInsertRules(rulesToInsert, styleObject) {
|
|
555
|
+
shouldInsertStyleRules(styleObject.identifier) && (updateRules(styleObject.identifier, styleObject.rules), rulesToInsert.push(styleObject));
|
|
556
|
+
}
|
|
557
|
+
function processIDRefList(idRefList) {
|
|
558
|
+
return Array.isArray(idRefList) ? idRefList.join(" ") : idRefList;
|
|
559
|
+
}
|
|
560
|
+
const animatableDefaults = {
|
|
561
|
+
opacity: 1,
|
|
562
|
+
scale: 1,
|
|
563
|
+
rotate: "0deg",
|
|
564
|
+
rotateY: "0deg",
|
|
565
|
+
rotateX: "0deg",
|
|
566
|
+
x: 0,
|
|
567
|
+
y: 0
|
|
568
|
+
},
|
|
569
|
+
lowercaseHyphenate = match => `-${match.toLowerCase()}`,
|
|
570
|
+
hyphenate = str => str.replace(/[A-Z]/g, lowercaseHyphenate),
|
|
571
|
+
mergeTransform = (obj, key, val, backwards = !1) => {
|
|
572
|
+
typeof obj.transform != "string" && (obj.transform ||= [], obj.transform[backwards ? "unshift" : "push"]({
|
|
573
|
+
[mapTransformKeys[key] || key]: val
|
|
574
|
+
}));
|
|
575
|
+
},
|
|
576
|
+
mapTransformKeys = {
|
|
577
|
+
x: "translateX",
|
|
578
|
+
y: "translateY"
|
|
579
|
+
},
|
|
580
|
+
skipProps = {
|
|
581
|
+
untilMeasured: 1,
|
|
582
|
+
animation: 1,
|
|
583
|
+
space: 1,
|
|
584
|
+
animateOnly: 1,
|
|
585
|
+
disableClassName: 1,
|
|
586
|
+
debug: 1,
|
|
587
|
+
componentName: 1,
|
|
588
|
+
disableOptimization: 1,
|
|
589
|
+
tag: 1,
|
|
590
|
+
style: 1,
|
|
591
|
+
// handled after loop so pseudos set usedKeys and override it if necessary
|
|
592
|
+
group: 1
|
|
593
|
+
};
|
|
594
|
+
process.env.NODE_ENV === "test" && (skipProps["data-test-renders"] = 1);
|
|
595
|
+
process.env.NODE_ENV !== "production" && Object.assign(skipProps, {
|
|
596
|
+
accessibilityElementsHidden: 1,
|
|
597
|
+
accessibilityIgnoresInvertColors: 1,
|
|
598
|
+
accessibilityLanguage: 1,
|
|
599
|
+
adjustsFontSizeToFit: 1,
|
|
600
|
+
allowFontScaling: 1,
|
|
601
|
+
dataDetectorType: 1,
|
|
602
|
+
dynamicTypeRamp: 1,
|
|
603
|
+
elevationAndroid: 1,
|
|
604
|
+
hapticFeedback: 1,
|
|
605
|
+
importantForAccessibility: 1,
|
|
606
|
+
lineBreakStrategyIOS: 1,
|
|
607
|
+
maxFontSizeMultiplier: 1,
|
|
608
|
+
minimumFontScale: 1,
|
|
609
|
+
needsOffscreenAlphaCompositing: 1,
|
|
610
|
+
nextFocusDown: 1,
|
|
611
|
+
nextFocusForward: 1,
|
|
612
|
+
nextFocusLeft: 1,
|
|
613
|
+
nextFocusRight: 1,
|
|
614
|
+
nextFocusUp: 1,
|
|
615
|
+
onMagicTap: 1,
|
|
616
|
+
selectionColor: 1,
|
|
617
|
+
shouldRasterizeIOS: 1,
|
|
618
|
+
suppressHighlighting: 1,
|
|
619
|
+
textBreakStrategy: 1
|
|
620
|
+
});
|
|
621
|
+
const accessibilityRoleToWebRole = {
|
|
622
|
+
adjustable: "slider",
|
|
623
|
+
header: "heading",
|
|
624
|
+
image: "img",
|
|
625
|
+
link: "link",
|
|
626
|
+
none: "presentation",
|
|
627
|
+
summary: "region"
|
|
628
|
+
};
|
|
629
|
+
function passDownProp(viewProps, key, val, shouldMergeObject = !1) {
|
|
630
|
+
if (shouldMergeObject) {
|
|
631
|
+
const next = {
|
|
632
|
+
...viewProps[key],
|
|
633
|
+
...val
|
|
634
|
+
};
|
|
635
|
+
delete viewProps[key], viewProps[key] = next;
|
|
636
|
+
} else viewProps[key] = val;
|
|
637
|
+
}
|
|
638
|
+
export { PROP_SPLIT, getSplitStyles, getSubStyle, useSplitStyles };
|