@tamagui/core 1.0.1-beta.60 → 1.0.1-beta.63
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 +15 -5
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/helpers/createMediaStyle.js +1 -1
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +34 -15
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/createTamaguiProvider.js +3 -3
- package/dist/cjs/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/cjs/helpers/extendStaticConfig.js +2 -1
- package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
- package/dist/cjs/helpers/generateAtomicStyles.js +65 -122
- package/dist/cjs/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +29 -14
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.js +8 -22
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/insertStyleRule.js +2 -1
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/mergeProps.js +40 -0
- package/dist/cjs/helpers/mergeProps.js.map +7 -0
- package/dist/cjs/helpers/pseudos.js +41 -0
- package/dist/cjs/helpers/pseudos.js.map +7 -0
- package/dist/cjs/helpers/themeable.js +2 -2
- package/dist/cjs/helpers/themeable.js.map +2 -2
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/static.js +2 -0
- package/dist/cjs/static.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/createComponent.js +15 -8
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/helpers/createMediaStyle.js +1 -1
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +34 -15
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/createTamaguiProvider.js +2 -2
- package/dist/esm/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/esm/helpers/extendStaticConfig.js +5 -3
- package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
- package/dist/esm/helpers/generateAtomicStyles.js +65 -121
- package/dist/esm/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +29 -14
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +7 -20
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +2 -1
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/mergeProps.js +18 -0
- package/dist/esm/helpers/mergeProps.js.map +7 -0
- package/dist/esm/helpers/pseudos.js +18 -0
- package/dist/esm/helpers/pseudos.js.map +7 -0
- package/dist/esm/helpers/themeable.js +2 -1
- package/dist/esm/helpers/themeable.js.map +2 -2
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/static.js +2 -0
- package/dist/esm/static.js.map +2 -2
- package/dist/jsx/createComponent.js +15 -8
- package/dist/jsx/helpers/createMediaStyle.js +1 -1
- package/dist/jsx/helpers/createPropMapper.js +34 -15
- package/dist/jsx/helpers/createTamaguiProvider.js +2 -2
- package/dist/jsx/helpers/extendStaticConfig.js +5 -3
- package/dist/jsx/helpers/generateAtomicStyles.js +65 -121
- package/dist/jsx/helpers/getSplitStyles.js +29 -14
- package/dist/jsx/helpers/getStylesAtomic.js +7 -20
- package/dist/jsx/helpers/insertStyleRule.js +2 -1
- package/dist/jsx/helpers/mergeProps.js +17 -0
- package/dist/jsx/helpers/pseudos.js +17 -0
- package/dist/jsx/helpers/themeable.js +2 -1
- package/dist/jsx/index.js +4 -0
- package/dist/jsx/static.js +2 -0
- package/package.json +5 -6
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/createPropMapper.d.ts +1 -1
- package/types/helpers/createPropMapper.d.ts.map +1 -1
- package/types/helpers/createTamaguiProvider.d.ts +1 -1
- package/types/helpers/createTamaguiProvider.d.ts.map +1 -1
- package/types/helpers/extendStaticConfig.d.ts.map +1 -1
- package/types/helpers/generateAtomicStyles.d.ts +5 -6
- package/types/helpers/generateAtomicStyles.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts +2 -2
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts +0 -14
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/helpers/mergeProps.d.ts +2 -0
- package/types/helpers/mergeProps.d.ts.map +1 -0
- package/types/helpers/pseudos.d.ts +15 -0
- package/types/helpers/pseudos.d.ts.map +1 -0
- package/types/helpers/themeable.d.ts.map +1 -1
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +1 -1
- package/types/static.d.ts +2 -0
- package/types/static.d.ts.map +1 -1
- package/types/types.d.ts +4 -3
- package/types/types.d.ts.map +1 -1
|
@@ -4,7 +4,8 @@ import React, { forwardRef } from "react";
|
|
|
4
4
|
import { Theme } from "../views/Theme";
|
|
5
5
|
import { ThemeInverse } from "../views/ThemeInverse";
|
|
6
6
|
function themeable(component, opts) {
|
|
7
|
-
const withThemeComponent = forwardRef(/* @__PURE__ */ __name(function WithTheme(
|
|
7
|
+
const withThemeComponent = forwardRef(/* @__PURE__ */ __name(function WithTheme(props, ref) {
|
|
8
|
+
const { themeInverse, theme, ...rest } = props;
|
|
8
9
|
const element = React.createElement(component, { ...rest, ref });
|
|
9
10
|
if (themeInverse) {
|
|
10
11
|
return /* @__PURE__ */ React.createElement(ThemeInverse, null, element);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/themeable.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { forwardRef } from 'react'\n\nimport { ThemeName } from '../types'\nimport { Theme } from '../views/Theme'\nimport { ThemeInverse } from '../views/ThemeInverse'\n\nexport type ThemeableProps = {\n theme?: ThemeName | string | null\n themeInverse?: boolean\n}\n\nexport function themeable<Component extends (props: any) => any>(\n component: Component,\n opts?: { componentName?: string }\n) {\n const withThemeComponent = forwardRef(function WithTheme(\n { themeInverse, theme, ...rest }
|
|
5
|
-
"mappings": ";;AAAA;AAGA;AACA;AAOO,mBACL,WACA,MACA;AACA,QAAM,qBAAqB,WAAW,
|
|
4
|
+
"sourcesContent": ["import React, { forwardRef } from 'react'\n\nimport { ThemeName } from '../types'\nimport { Theme } from '../views/Theme'\nimport { ThemeInverse } from '../views/ThemeInverse'\n\nexport type ThemeableProps = {\n theme?: ThemeName | string | null\n themeInverse?: boolean\n}\n\nexport function themeable<Component extends (props: any) => any>(\n component: Component,\n opts?: { componentName?: string }\n) {\n const withThemeComponent = forwardRef(function WithTheme(props: any, ref) {\n const { themeInverse, theme, ...rest } = props\n const element = React.createElement(component, { ...rest, ref } as any)\n if (themeInverse) {\n return <ThemeInverse>{element}</ThemeInverse>\n }\n if (theme || opts) {\n return (\n <Theme componentName={opts?.componentName} name={(theme as any) || null}>\n {element}\n </Theme>\n )\n }\n return element\n })\n\n const withTheme: any = withThemeComponent\n withTheme.displayName = `Themed(${\n (component as any)?.displayName || (component as any)?.name || 'Anonymous'\n })`\n\n return withTheme as Component extends (props: infer P) => infer R\n ? (\n props: Omit<P, 'theme' | 'themeInverse'> & {\n theme?: ThemeName | null\n themeInverse?: boolean\n }\n ) => R\n : unknown\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAGA;AACA;AAOO,mBACL,WACA,MACA;AACA,QAAM,qBAAqB,WAAW,0CAAmB,OAAY,KAAK;AACxE,UAAM,EAAE,cAAc,UAAU,SAAS;AACzC,UAAM,UAAU,MAAM,cAAc,WAAW,EAAE,GAAG,MAAM,IAAI,CAAQ;AACtE,QAAI,cAAc;AAChB,aAAO,oCAAC,oBAAc,OAAQ;AAAA,IAChC;AACA,QAAI,SAAS,MAAM;AACjB,aACE,oCAAC;AAAA,QAAM,eAAe,6BAAM;AAAA,QAAe,MAAO,SAAiB;AAAA,SAChE,OACH;AAAA,IAEJ;AACA,WAAO;AAAA,EACT,GAdsC,YAcrC;AAED,QAAM,YAAiB;AACvB,YAAU,cAAc,UACrB,wCAAmB,gBAAgB,wCAAmB,SAAQ;AAGjE,SAAO;AAQT;AAjCgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -23,6 +23,9 @@ export * from "./helpers/getExpandedShorthands";
|
|
|
23
23
|
export * from "./helpers/getSize";
|
|
24
24
|
export * from "./helpers/getSplitStyles";
|
|
25
25
|
export * from "./helpers/getStylesAtomic";
|
|
26
|
+
export * from "./helpers/pseudos";
|
|
27
|
+
export * from "./helpers/mergeProps";
|
|
28
|
+
import { expandStyles } from "./helpers/generateAtomicStyles";
|
|
26
29
|
export * from "./helpers/getTextSize";
|
|
27
30
|
export * from "./helpers/isObj";
|
|
28
31
|
export * from "./helpers/isTamaguiElement";
|
|
@@ -52,6 +55,7 @@ export * from "@tamagui/helpers";
|
|
|
52
55
|
export {
|
|
53
56
|
RNWTextProps,
|
|
54
57
|
RNWViewProps,
|
|
58
|
+
expandStyles,
|
|
55
59
|
getConfig,
|
|
56
60
|
getHasConfigured,
|
|
57
61
|
getThemes,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './insertFont'\nexport * from './styled'\nexport * from './types'\n// for type portability\nexport { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './conf'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport * from './constants/rnw'\n\nexport * from './helpers/calc'\nexport * from './helpers/createShallowUpdate'\nexport * from './helpers/getStackSize'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/getTextSize'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/isTamaguiComponent'\nexport * from './helpers/matchMedia'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\nexport * from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useUnmountEffect'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport * from './views/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/ThemeReset'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/helpers'\n"],
|
|
5
|
-
"mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;",
|
|
4
|
+
"sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './insertFont'\nexport * from './styled'\nexport * from './types'\n// for type portability\nexport { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './conf'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport * from './constants/rnw'\n\nexport * from './helpers/calc'\nexport * from './helpers/createShallowUpdate'\nexport * from './helpers/getStackSize'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/pseudos'\nexport * from './helpers/mergeProps'\nexport { expandStyles } from './helpers/generateAtomicStyles'\nexport * from './helpers/getTextSize'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/isTamaguiComponent'\nexport * from './helpers/matchMedia'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\nexport * from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useUnmountEffect'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport * from './views/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/ThemeReset'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/helpers'\n"],
|
|
5
|
+
"mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/static.js
CHANGED
|
@@ -9,6 +9,8 @@ export * from "./hooks/useMedia";
|
|
|
9
9
|
export * from "./hooks/useTheme";
|
|
10
10
|
export * from "./helpers/isObj";
|
|
11
11
|
export * from "./helpers/getStylesAtomic";
|
|
12
|
+
export * from "./helpers/generateAtomicStyles";
|
|
13
|
+
export * from "./helpers/pseudos";
|
|
12
14
|
export * from "./helpers/proxyThemeVariables";
|
|
13
15
|
export * from "./helpers/getSplitStyles";
|
|
14
16
|
export * from "@tamagui/helpers";
|
package/dist/esm/static.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/static.ts"],
|
|
4
|
-
"sourcesContent": ["// only stuff that gets extracted or needed by tamagui-static\n\nexport * from './styled'\nexport * from './createComponent'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createTamagui'\nexport * from './createVariable'\nexport * from './constants/constants'\n\nexport * from './hooks/useMedia'\nexport * from './hooks/useTheme'\n\nexport * from './helpers/isObj'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/proxyThemeVariables'\nexport * from './helpers/getSplitStyles'\nexport * from '@tamagui/helpers'\n\nexport * from './constants/rnw'\n\nexport * from './types'\n"],
|
|
5
|
-
"mappings": "AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;",
|
|
4
|
+
"sourcesContent": ["// only stuff that gets extracted or needed by tamagui-static\n\nexport * from './styled'\nexport * from './createComponent'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createTamagui'\nexport * from './createVariable'\nexport * from './constants/constants'\n\nexport * from './hooks/useMedia'\nexport * from './hooks/useTheme'\n\nexport * from './helpers/isObj'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/generateAtomicStyles'\nexport * from './helpers/pseudos'\nexport * from './helpers/proxyThemeVariables'\nexport * from './helpers/getSplitStyles'\nexport * from '@tamagui/helpers'\n\nexport * from './constants/rnw'\n\nexport * from './types'\n"],
|
|
5
|
+
"mappings": "AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -23,6 +23,7 @@ import { createShallowUpdate } from "./helpers/createShallowUpdate";
|
|
|
23
23
|
import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
|
|
24
24
|
import { insertSplitStyles, useSplitStyles } from "./helpers/getSplitStyles";
|
|
25
25
|
import { getAllSelectors } from "./helpers/insertStyleRule";
|
|
26
|
+
import { mergeProps } from "./helpers/mergeProps";
|
|
26
27
|
import { proxyThemeVariables } from "./helpers/proxyThemeVariables";
|
|
27
28
|
import { wrapThemeManagerContext } from "./helpers/wrapThemeManagerContext";
|
|
28
29
|
import { useFeatures } from "./hooks/useFeatures";
|
|
@@ -96,14 +97,23 @@ function createComponent(configIn, ParentComponent) {
|
|
|
96
97
|
__name(addPseudoToStyles, "addPseudoToStyles");
|
|
97
98
|
const component = forwardRef((propsIn, forwardedRef) => {
|
|
98
99
|
var _a, _b, _c, _d, _e;
|
|
99
|
-
|
|
100
|
+
let props;
|
|
101
|
+
if (tamaguiDefaultProps && !propsIn.asChild) {
|
|
102
|
+
props = mergeProps(tamaguiDefaultProps, propsIn);
|
|
103
|
+
} else {
|
|
104
|
+
props = propsIn;
|
|
105
|
+
}
|
|
100
106
|
const { Component, isText, isZStack } = staticConfig;
|
|
101
107
|
const componentName = props.componentName || staticConfig.componentName;
|
|
102
108
|
const componentClassName = props.asChild ? "" : props.componentName ? `is_${props.componentName}` : defaultComponentClassName;
|
|
103
109
|
if (process.env.NODE_ENV === "development") {
|
|
104
110
|
if (props["debug"]) {
|
|
105
111
|
console.log("\u26A0\uFE0F", componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "debug on");
|
|
106
|
-
console.log("props in:", {
|
|
112
|
+
console.log("props in:", {
|
|
113
|
+
propsIn,
|
|
114
|
+
props,
|
|
115
|
+
ordered: Object.keys(props)
|
|
116
|
+
});
|
|
107
117
|
if (props["debug"] === "break")
|
|
108
118
|
debugger;
|
|
109
119
|
}
|
|
@@ -121,7 +131,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
121
131
|
noClassNames: true,
|
|
122
132
|
dynamicStylesInline: true,
|
|
123
133
|
resolveVariablesAs: "value"
|
|
124
|
-
}, shouldAvoidClasses || props.asChild ? null : initialSplitStyles.classNames);
|
|
134
|
+
}, shouldAvoidClasses || props.asChild ? null : initialSplitStyles.classNames, props["debug"]);
|
|
125
135
|
const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitStyles;
|
|
126
136
|
const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
|
|
127
137
|
const isAnimated = !!(useAnimations && props.animation);
|
|
@@ -597,11 +607,8 @@ function createComponent(configIn, ParentComponent) {
|
|
|
597
607
|
focus: false,
|
|
598
608
|
resolveVariablesAs: "both",
|
|
599
609
|
keepVariantsAsProps: true
|
|
600
|
-
});
|
|
601
|
-
const defaults =
|
|
602
|
-
...component.defaultProps,
|
|
603
|
-
...initialSplitStyles.viewProps
|
|
604
|
-
};
|
|
610
|
+
}, void 0, staticConfig.defaultProps["debug"]);
|
|
611
|
+
const defaults = mergeProps(component.defaultProps, initialSplitStyles.viewProps);
|
|
605
612
|
defaultNativeStyle = {};
|
|
606
613
|
const validStyles2 = staticConfig.validStyles || stylePropsView;
|
|
607
614
|
for (const key in staticConfig.defaultProps) {
|
|
@@ -12,7 +12,7 @@ const createMediaStyle = /* @__PURE__ */ __name(({ identifier, rules }, mediaKey
|
|
|
12
12
|
const screenStr = negate ? "not all" : "screen";
|
|
13
13
|
const mediaSelector = mediaObjectToString(mediaQueries[mediaKey]);
|
|
14
14
|
const mediaQuery = `${screenStr} and ${mediaSelector}`;
|
|
15
|
-
const styleInner = rules
|
|
15
|
+
const styleInner = rules.map((rule) => rule.replace(identifier, nextIdentifier)).join(";");
|
|
16
16
|
let styleRule = "";
|
|
17
17
|
if (styleInner.includes("@media")) {
|
|
18
18
|
styleRule = styleInner.replace("{", ` and ${mediaQuery} {`);
|
|
@@ -9,14 +9,14 @@ import { isObj } from "./isObj";
|
|
|
9
9
|
const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
10
10
|
const variants = staticConfig.variants || {};
|
|
11
11
|
const defaultProps = staticConfig.defaultProps || {};
|
|
12
|
-
const mapper = /* @__PURE__ */ __name((key, value, theme, propsIn, state, avoidDefaultProps = false) => {
|
|
12
|
+
const mapper = /* @__PURE__ */ __name((key, value, theme, propsIn, state, avoidDefaultProps = false, debug) => {
|
|
13
13
|
const conf = getConfig();
|
|
14
14
|
if (!conf) {
|
|
15
15
|
console.trace("no conf! err");
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
const props = state.fallbackProps || propsIn;
|
|
19
|
-
const returnVariablesAs = state.resolveVariablesAs === "value" || !!props.animation ? "value" : "auto";
|
|
19
|
+
const returnVariablesAs = state.resolveVariablesAs === "value" || !!props.animation ? "non-color-value" : "auto";
|
|
20
20
|
const fontFamily = props.fontFamily || defaultProps.fontFamily || "$body";
|
|
21
21
|
const variantValue = resolveVariants(key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, "", avoidDefaultProps);
|
|
22
22
|
if (variantValue) {
|
|
@@ -29,9 +29,9 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
|
29
29
|
}
|
|
30
30
|
if (value) {
|
|
31
31
|
if (value[0] === "$") {
|
|
32
|
-
value = getToken(key, value, conf, theme, fontFamily, returnVariablesAs);
|
|
32
|
+
value = getToken(key, value, conf, theme, fontFamily, returnVariablesAs, debug);
|
|
33
33
|
} else if (isVariable(value)) {
|
|
34
|
-
value = getVariableValue(value, returnVariablesAs);
|
|
34
|
+
value = getVariableValue(key, value, returnVariablesAs);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
if (shouldReturn) {
|
|
@@ -40,7 +40,7 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
|
40
40
|
}, "mapper");
|
|
41
41
|
return mapper;
|
|
42
42
|
}, "createPropMapper");
|
|
43
|
-
const resolveVariants = /* @__PURE__ */ __name((key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps = false) => {
|
|
43
|
+
const resolveVariants = /* @__PURE__ */ __name((key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps = false, debug) => {
|
|
44
44
|
var _a;
|
|
45
45
|
const variant = variants && variants[key];
|
|
46
46
|
if (variant && value !== void 0) {
|
|
@@ -51,7 +51,7 @@ const resolveVariants = /* @__PURE__ */ __name((key, value, props, defaultProps,
|
|
|
51
51
|
variantValue = fn(value, getVariantExtras(props, theme, defaultProps, avoidDefaultProps));
|
|
52
52
|
}
|
|
53
53
|
if (isObj(variantValue)) {
|
|
54
|
-
variantValue = resolveTokensAndVariants(key, variantValue, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps);
|
|
54
|
+
variantValue = resolveTokensAndVariants(key, variantValue, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps, debug);
|
|
55
55
|
}
|
|
56
56
|
return Object.entries(expandStyles(variantValue));
|
|
57
57
|
} else {
|
|
@@ -59,13 +59,14 @@ const resolveVariants = /* @__PURE__ */ __name((key, value, props, defaultProps,
|
|
|
59
59
|
if ((_a = staticConfig.validStyles) == null ? void 0 : _a[key]) {
|
|
60
60
|
return null;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
const name = staticConfig.componentName || "[UnnamedComponent]";
|
|
63
|
+
console.warn(`No variant found: ${name} has variant "${key}", but no matching value "${value}"`);
|
|
63
64
|
}
|
|
64
65
|
return null;
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
}, "resolveVariants");
|
|
68
|
-
const resolveTokensAndVariants = /* @__PURE__ */ __name((key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps) => {
|
|
69
|
+
const resolveTokensAndVariants = /* @__PURE__ */ __name((key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps, debug) => {
|
|
69
70
|
var _a;
|
|
70
71
|
let res = {};
|
|
71
72
|
for (const rKey in value) {
|
|
@@ -79,15 +80,15 @@ const resolveTokensAndVariants = /* @__PURE__ */ __name((key, value, props, defa
|
|
|
79
80
|
} else {
|
|
80
81
|
res = {
|
|
81
82
|
...res,
|
|
82
|
-
...Object.fromEntries(resolveVariants(fKey, val, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, key, avoidDefaultProps))
|
|
83
|
+
...Object.fromEntries(resolveVariants(fKey, val, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, key, avoidDefaultProps, debug))
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
86
|
} else if (typeof val === "string") {
|
|
86
|
-
const fVal = val[0] === "$" ? getToken(fKey, val, conf, theme, fontFamily, returnVariablesAs) : val;
|
|
87
|
+
const fVal = val[0] === "$" ? getToken(fKey, val, conf, theme, fontFamily, returnVariablesAs, debug) : val;
|
|
87
88
|
res[fKey] = fVal;
|
|
88
89
|
} else {
|
|
89
90
|
if (isObj(val)) {
|
|
90
|
-
res[fKey] = resolveTokensAndVariants(fKey, val, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, key, avoidDefaultProps);
|
|
91
|
+
res[fKey] = resolveTokensAndVariants(fKey, val, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, key, avoidDefaultProps, debug);
|
|
91
92
|
} else {
|
|
92
93
|
res[fKey] = value[fKey];
|
|
93
94
|
}
|
|
@@ -128,7 +129,7 @@ const fontShorthand = {
|
|
|
128
129
|
fontSize: "size",
|
|
129
130
|
fontWeight: "weight"
|
|
130
131
|
};
|
|
131
|
-
const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed, fontsParsed }, theme, fontFamily = "$body", resolveAs) => {
|
|
132
|
+
const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed, fontsParsed }, theme, fontFamily = "$body", resolveAs, debug) => {
|
|
132
133
|
var _a, _b, _c;
|
|
133
134
|
let valOrVar;
|
|
134
135
|
let hasSet = false;
|
|
@@ -167,21 +168,39 @@ const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed, fontsParsed
|
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
170
|
if (hasSet) {
|
|
170
|
-
return getVariableValue(valOrVar, resolveAs);
|
|
171
|
+
return getVariableValue(key, valOrVar, resolveAs);
|
|
171
172
|
}
|
|
172
173
|
if (process.env.NODE_ENV === "development") {
|
|
173
174
|
if (value && value[0] === "$") {
|
|
174
|
-
console.warn(`\u26A0\uFE0F
|
|
175
|
+
console.warn(`\u26A0\uFE0F You've passed the value "${value}" to the style property "${key}", but there's no theme or token with the key "${value}". Using theme "${theme.name}".
|
|
176
|
+
|
|
177
|
+
Set the debug prop to true to see more detailed debug information.`);
|
|
178
|
+
if (debug) {
|
|
179
|
+
if (typeof window !== "undefined") {
|
|
180
|
+
console.log("Looked in:");
|
|
181
|
+
console.log("Theme:", theme);
|
|
182
|
+
console.log("Tokens:", tokensParsed);
|
|
183
|
+
console.log("Fonts:", fontsParsed);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
175
186
|
return null;
|
|
176
187
|
}
|
|
177
188
|
}
|
|
178
189
|
return value;
|
|
179
190
|
}, "getToken");
|
|
180
|
-
function getVariableValue(valOrVar, resolveAs = "auto") {
|
|
191
|
+
function getVariableValue(key, valOrVar, resolveAs = "auto") {
|
|
181
192
|
if (isVariable(valOrVar)) {
|
|
182
193
|
if (resolveAs === "variable") {
|
|
183
194
|
return valOrVar;
|
|
184
195
|
}
|
|
196
|
+
if (resolveAs === "non-color-value") {
|
|
197
|
+
if (isWeb) {
|
|
198
|
+
if (key in tokenCategories.color) {
|
|
199
|
+
return valOrVar.variable;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return valOrVar.val;
|
|
203
|
+
}
|
|
185
204
|
if (!isWeb || resolveAs === "value") {
|
|
186
205
|
return valOrVar.val;
|
|
187
206
|
}
|
|
@@ -9,13 +9,13 @@ function createTamaguiProvider({
|
|
|
9
9
|
...themeProps
|
|
10
10
|
}) {
|
|
11
11
|
return /* @__PURE__ */ __name(function TamaguiProvider({
|
|
12
|
-
|
|
12
|
+
disableInjectCSS,
|
|
13
13
|
children,
|
|
14
14
|
...themePropsProvider
|
|
15
15
|
}) {
|
|
16
16
|
if (typeof document !== "undefined") {
|
|
17
17
|
React.useLayoutEffect(() => {
|
|
18
|
-
if (
|
|
18
|
+
if (disableInjectCSS)
|
|
19
19
|
return;
|
|
20
20
|
const style = document.createElement("style");
|
|
21
21
|
style.appendChild(document.createTextNode(getCSS()));
|
|
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { stylePropsView } from "@tamagui/helpers";
|
|
4
4
|
import { createPropMapper } from "./createPropMapper";
|
|
5
|
+
import { mergeProps } from "./mergeProps";
|
|
5
6
|
function extendStaticConfig(config, parent) {
|
|
6
7
|
var _a;
|
|
7
8
|
if (!parent || !("staticConfig" in parent)) {
|
|
@@ -35,12 +36,13 @@ function extendStaticConfig(config, parent) {
|
|
|
35
36
|
...parent.staticConfig.validStyles,
|
|
36
37
|
...config.validStyles
|
|
37
38
|
} : parent.staticConfig.validStyles || stylePropsView,
|
|
38
|
-
defaultProps: {
|
|
39
|
+
defaultProps: mergeProps({
|
|
39
40
|
...parent.staticConfig.defaultProps,
|
|
40
|
-
...parent.staticConfig.defaultVariants
|
|
41
|
+
...parent.staticConfig.defaultVariants
|
|
42
|
+
}, {
|
|
41
43
|
...config.defaultProps,
|
|
42
44
|
...config.defaultVariants
|
|
43
|
-
}
|
|
45
|
+
})
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
48
|
__name(extendStaticConfig, "extendStaticConfig");
|
|
@@ -4,55 +4,44 @@ import { simpleHash } from "@tamagui/helpers";
|
|
|
4
4
|
import hyphenateStyleName from "hyphenate-style-name";
|
|
5
5
|
import normalizeCSSColor from "normalize-css-color";
|
|
6
6
|
import { isWeb } from "../constants/platform";
|
|
7
|
-
import {
|
|
7
|
+
import { pseudos } from "./pseudos";
|
|
8
|
+
const reducedStyleKeys = {
|
|
9
|
+
shadowColor: true,
|
|
10
|
+
shadowOffset: true,
|
|
11
|
+
shadowOpacity: true,
|
|
12
|
+
shadowRadius: true,
|
|
13
|
+
textShadowColor: true,
|
|
14
|
+
textShadowOffset: true,
|
|
15
|
+
textShadowRadius: true
|
|
16
|
+
};
|
|
8
17
|
function expandStyles(style) {
|
|
9
18
|
const res = {};
|
|
19
|
+
boxShadowReducer(res, style);
|
|
20
|
+
textShadowReducer(res, style);
|
|
10
21
|
for (const key in style) {
|
|
11
|
-
|
|
22
|
+
if (reducedStyleKeys[key])
|
|
23
|
+
continue;
|
|
24
|
+
if (key in pseudos) {
|
|
25
|
+
res[key] = expandStyles(style[key]);
|
|
26
|
+
} else {
|
|
27
|
+
updateReactDOMStyle(res, key, style[key]);
|
|
28
|
+
}
|
|
12
29
|
}
|
|
13
30
|
return res;
|
|
14
31
|
}
|
|
15
32
|
__name(expandStyles, "expandStyles");
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"borderTopLeftRadius",
|
|
24
|
-
"borderTopRightRadius",
|
|
25
|
-
"borderBottomRightRadius",
|
|
26
|
-
"borderBottomLeftRadius"
|
|
27
|
-
],
|
|
28
|
-
borderStyle: ["borderTopStyle", "borderRightStyle", "borderBottomStyle", "borderLeftStyle"],
|
|
29
|
-
borderWidth: ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"],
|
|
30
|
-
margin: ["marginTop", "marginRight", "marginBottom", "marginLeft"],
|
|
31
|
-
marginHorizontal: ["marginRight", "marginLeft"],
|
|
32
|
-
marginVertical: ["marginTop", "marginBottom"],
|
|
33
|
-
overscrollBehavior: ["overscrollBehaviorX", "overscrollBehaviorY"],
|
|
34
|
-
padding: ["paddingTop", "paddingRight", "paddingBottom", "paddingLeft"],
|
|
35
|
-
paddingHorizontal: ["paddingRight", "paddingLeft"],
|
|
36
|
-
paddingVertical: ["paddingTop", "paddingBottom"],
|
|
37
|
-
...isWeb && {
|
|
38
|
-
overflow: ["overflowX", "overflowY"]
|
|
33
|
+
function updateReactDOMStyle(style, key, value) {
|
|
34
|
+
value = normalizeValueWithProperty(value, key);
|
|
35
|
+
const out = expandStyle(key, value);
|
|
36
|
+
if (out) {
|
|
37
|
+
Object.assign(style, Object.fromEntries(out));
|
|
38
|
+
} else {
|
|
39
|
+
style[key] = value;
|
|
39
40
|
}
|
|
40
|
-
}
|
|
41
|
+
}
|
|
42
|
+
__name(updateReactDOMStyle, "updateReactDOMStyle");
|
|
41
43
|
const generateAtomicStyles = /* @__PURE__ */ __name((style) => {
|
|
42
44
|
const res = expandStyles(style);
|
|
43
|
-
if (style.shadowColor != null || style.shadowOffset != null || style.shadowOpacity != null || style.shadowRadius != null) {
|
|
44
|
-
boxShadowReducer(res, style);
|
|
45
|
-
delete res["shadowColor"];
|
|
46
|
-
delete res["shadowOffset"];
|
|
47
|
-
delete res["shadowOpacity"];
|
|
48
|
-
delete res["shadowRadius"];
|
|
49
|
-
}
|
|
50
|
-
if (style.textShadowColor != null || style.textShadowOffset != null || style.textShadowRadius != null) {
|
|
51
|
-
textShadowReducer(res, style);
|
|
52
|
-
delete res["textShadowColor"];
|
|
53
|
-
delete res["textShadowOffset"];
|
|
54
|
-
delete res["textShadowRadius"];
|
|
55
|
-
}
|
|
56
45
|
const out = {};
|
|
57
46
|
for (const key in res) {
|
|
58
47
|
const value = res[key];
|
|
@@ -63,11 +52,11 @@ const generateAtomicStyles = /* @__PURE__ */ __name((style) => {
|
|
|
63
52
|
const { identifier } = cachedResult;
|
|
64
53
|
out[identifier] = cachedResult;
|
|
65
54
|
} else {
|
|
66
|
-
const identifier =
|
|
67
|
-
const rules = createAtomicRules(identifier, key,
|
|
55
|
+
const identifier = simpleHash(key + valueString);
|
|
56
|
+
const rules = createAtomicRules(identifier, key, valueString);
|
|
68
57
|
const cachedResult2 = cache.set(key, valueString, {
|
|
69
58
|
property: key,
|
|
70
|
-
value:
|
|
59
|
+
value: valueString,
|
|
71
60
|
identifier,
|
|
72
61
|
rules
|
|
73
62
|
});
|
|
@@ -77,16 +66,6 @@ const generateAtomicStyles = /* @__PURE__ */ __name((style) => {
|
|
|
77
66
|
}
|
|
78
67
|
return out;
|
|
79
68
|
}, "generateAtomicStyles");
|
|
80
|
-
function updateReactDOMStyle(style, key, value) {
|
|
81
|
-
value = normalizeValueWithProperty(value, key);
|
|
82
|
-
const out = expandStyle(key, value);
|
|
83
|
-
if (out) {
|
|
84
|
-
Object.assign(style, Object.fromEntries(out));
|
|
85
|
-
} else {
|
|
86
|
-
style[key] = value;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
__name(updateReactDOMStyle, "updateReactDOMStyle");
|
|
90
69
|
function expandStyle(key, value) {
|
|
91
70
|
if (key === "flex") {
|
|
92
71
|
if (value <= -1) {
|
|
@@ -155,15 +134,9 @@ function createAtomicRules(identifier, property, value) {
|
|
|
155
134
|
const rules = [];
|
|
156
135
|
const selector = `.${identifier}`;
|
|
157
136
|
switch (property) {
|
|
158
|
-
case "animationKeyframes": {
|
|
159
|
-
const { animationNames, rules: keyframesRules } = processKeyframesValue(value);
|
|
160
|
-
const block = createDeclarationBlock({ animationName: animationNames.join(",") });
|
|
161
|
-
rules.push(`${selector}${block}`, ...keyframesRules);
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
137
|
case "placeholderTextColor": {
|
|
165
138
|
const block = createDeclarationBlock({ color: value, opacity: 1 });
|
|
166
|
-
rules.push(`${selector}
|
|
139
|
+
rules.push(`${selector}::placeholder${block}`);
|
|
167
140
|
break;
|
|
168
141
|
}
|
|
169
142
|
case "pointerEvents": {
|
|
@@ -202,58 +175,16 @@ function createAtomicRules(identifier, property, value) {
|
|
|
202
175
|
return rules;
|
|
203
176
|
}
|
|
204
177
|
__name(createAtomicRules, "createAtomicRules");
|
|
205
|
-
function processKeyframesValue(keyframesValue) {
|
|
206
|
-
if (typeof keyframesValue === "number") {
|
|
207
|
-
throw new Error(`Invalid CSS keyframes type: ${typeof keyframesValue}`);
|
|
208
|
-
}
|
|
209
|
-
const animationNames = [];
|
|
210
|
-
const rules = [];
|
|
211
|
-
const value = Array.isArray(keyframesValue) ? keyframesValue : [keyframesValue];
|
|
212
|
-
for (const keyframes of value) {
|
|
213
|
-
if (typeof keyframes === "string") {
|
|
214
|
-
animationNames.push(keyframes);
|
|
215
|
-
} else {
|
|
216
|
-
const { identifier, rules: keyframesRules } = createKeyframes(keyframes);
|
|
217
|
-
animationNames.push(identifier);
|
|
218
|
-
rules.push(...keyframesRules);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return { animationNames, rules };
|
|
222
|
-
}
|
|
223
|
-
__name(processKeyframesValue, "processKeyframesValue");
|
|
224
|
-
function createKeyframes(keyframes) {
|
|
225
|
-
const prefixes2 = ["-webkit-", ""];
|
|
226
|
-
const identifier = createIdentifier("r", "animation", keyframes);
|
|
227
|
-
const steps = "{" + Object.keys(keyframes).map((stepName) => {
|
|
228
|
-
const rule = keyframes[stepName];
|
|
229
|
-
const block = createDeclarationBlock(rule);
|
|
230
|
-
return `${stepName}${block}`;
|
|
231
|
-
}).join("") + "}";
|
|
232
|
-
const rules = prefixes2.map((prefix) => {
|
|
233
|
-
return `@${prefix}keyframes ${identifier}${steps}`;
|
|
234
|
-
});
|
|
235
|
-
return { identifier, rules };
|
|
236
|
-
}
|
|
237
|
-
__name(createKeyframes, "createKeyframes");
|
|
238
178
|
function createDeclarationBlock(style) {
|
|
239
|
-
const domStyle =
|
|
179
|
+
const domStyle = expandStyles(style);
|
|
240
180
|
const declarationsString = Object.keys(domStyle).map((property) => {
|
|
241
181
|
const value = domStyle[property];
|
|
242
182
|
const prop = hyphenateStyleName(property);
|
|
243
|
-
|
|
244
|
-
return value.map((v) => `${prop}:${v}`).join(";");
|
|
245
|
-
} else {
|
|
246
|
-
return `${prop}:${value}`;
|
|
247
|
-
}
|
|
183
|
+
return `${prop}:${value}`;
|
|
248
184
|
}).sort().join(";");
|
|
249
185
|
return `{${declarationsString};}`;
|
|
250
186
|
}
|
|
251
187
|
__name(createDeclarationBlock, "createDeclarationBlock");
|
|
252
|
-
function createIdentifier(prefix, name, value) {
|
|
253
|
-
const hashedString = simpleHash(name + stringifyValueWithProperty(value, name));
|
|
254
|
-
return `${prefix}-${hashedString}`;
|
|
255
|
-
}
|
|
256
|
-
__name(createIdentifier, "createIdentifier");
|
|
257
188
|
const cache = {
|
|
258
189
|
get(property, value) {
|
|
259
190
|
if (cache[property] != null && cache[property].hasOwnProperty(value) && cache[property][value] != null) {
|
|
@@ -268,8 +199,7 @@ const cache = {
|
|
|
268
199
|
}
|
|
269
200
|
};
|
|
270
201
|
function stringifyValueWithProperty(value, property) {
|
|
271
|
-
|
|
272
|
-
return typeof normalizedValue !== "string" ? JSON.stringify(normalizedValue || "") : normalizedValue;
|
|
202
|
+
return normalizeValueWithProperty(value, property);
|
|
273
203
|
}
|
|
274
204
|
__name(stringifyValueWithProperty, "stringifyValueWithProperty");
|
|
275
205
|
const mapTransform = /* @__PURE__ */ __name((transform) => {
|
|
@@ -296,7 +226,8 @@ const colorProps = {
|
|
|
296
226
|
};
|
|
297
227
|
function normalizeValueWithProperty(value, property) {
|
|
298
228
|
if (process.env.TAMAGUI_TARGET === "web") {
|
|
299
|
-
|
|
229
|
+
const shouldCoerceToPx = typeof value === "number" && (property === void 0 || property === null || !unitlessNumbers[property]);
|
|
230
|
+
if (shouldCoerceToPx) {
|
|
300
231
|
return `${value}px`;
|
|
301
232
|
}
|
|
302
233
|
}
|
|
@@ -324,6 +255,7 @@ const normalizeColor = /* @__PURE__ */ __name((color, opacity = 1) => {
|
|
|
324
255
|
const alpha = (a * opacity).toFixed(2);
|
|
325
256
|
return `rgba(${r},${g},${b},${alpha})`;
|
|
326
257
|
}
|
|
258
|
+
return `${color}`;
|
|
327
259
|
}, "normalizeColor");
|
|
328
260
|
const isWebColor = /* @__PURE__ */ __name((color) => color === "currentcolor" || color === "currentColor" || color === "inherit" || color.indexOf("var(") === 0, "isWebColor");
|
|
329
261
|
const processColor = /* @__PURE__ */ __name((color) => {
|
|
@@ -383,25 +315,17 @@ const unitlessNumbers = {
|
|
|
383
315
|
scaleZ: true,
|
|
384
316
|
shadowOpacity: true
|
|
385
317
|
};
|
|
386
|
-
const prefixes = ["ms", "Moz", "O", "Webkit"];
|
|
387
|
-
const prefixKey = /* @__PURE__ */ __name((prefix, key) => {
|
|
388
|
-
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
|
389
|
-
}, "prefixKey");
|
|
390
|
-
Object.keys(unitlessNumbers).forEach((prop) => {
|
|
391
|
-
prefixes.forEach((prefix) => {
|
|
392
|
-
unitlessNumbers[prefixKey(prefix, prop)] = unitlessNumbers[prop];
|
|
393
|
-
});
|
|
394
|
-
});
|
|
395
318
|
const resolveShadowValue = /* @__PURE__ */ __name((style) => {
|
|
396
319
|
const { shadowColor, shadowOffset, shadowOpacity, shadowRadius } = style;
|
|
320
|
+
if (shadowRadius === void 0) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
397
323
|
const { height, width } = shadowOffset || defaultOffset;
|
|
398
324
|
const offsetX = normalizeValueWithProperty(width);
|
|
399
325
|
const offsetY = normalizeValueWithProperty(height);
|
|
400
326
|
const blurRadius = normalizeValueWithProperty(shadowRadius || 0);
|
|
401
|
-
const color = normalizeColor(shadowColor || "black", shadowOpacity);
|
|
402
|
-
|
|
403
|
-
return `${offsetX} ${offsetY} ${blurRadius} ${color}`;
|
|
404
|
-
}
|
|
327
|
+
const color = normalizeColor(String(shadowColor || "black"), shadowOpacity);
|
|
328
|
+
return `${offsetX} ${offsetY} ${blurRadius} ${color}`;
|
|
405
329
|
}, "resolveShadowValue");
|
|
406
330
|
function boxShadowReducer(resolvedStyle, style) {
|
|
407
331
|
const { boxShadow } = style;
|
|
@@ -425,9 +349,29 @@ function textShadowReducer(resolvedStyle, style) {
|
|
|
425
349
|
}
|
|
426
350
|
}
|
|
427
351
|
__name(textShadowReducer, "textShadowReducer");
|
|
352
|
+
const STYLE_SHORT_FORM_EXPANSIONS = {
|
|
353
|
+
borderColor: ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"],
|
|
354
|
+
borderRadius: [
|
|
355
|
+
"borderTopLeftRadius",
|
|
356
|
+
"borderTopRightRadius",
|
|
357
|
+
"borderBottomRightRadius",
|
|
358
|
+
"borderBottomLeftRadius"
|
|
359
|
+
],
|
|
360
|
+
borderStyle: ["borderTopStyle", "borderRightStyle", "borderBottomStyle", "borderLeftStyle"],
|
|
361
|
+
borderWidth: ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"],
|
|
362
|
+
margin: ["marginTop", "marginRight", "marginBottom", "marginLeft"],
|
|
363
|
+
marginHorizontal: ["marginRight", "marginLeft"],
|
|
364
|
+
marginVertical: ["marginTop", "marginBottom"],
|
|
365
|
+
overscrollBehavior: ["overscrollBehaviorX", "overscrollBehaviorY"],
|
|
366
|
+
padding: ["paddingTop", "paddingRight", "paddingBottom", "paddingLeft"],
|
|
367
|
+
paddingHorizontal: ["paddingRight", "paddingLeft"],
|
|
368
|
+
paddingVertical: ["paddingTop", "paddingBottom"],
|
|
369
|
+
...isWeb && {
|
|
370
|
+
overflow: ["overflowX", "overflowY"]
|
|
371
|
+
}
|
|
372
|
+
};
|
|
428
373
|
export {
|
|
429
374
|
expandStyle,
|
|
430
375
|
expandStyles,
|
|
431
|
-
generateAtomicStyles
|
|
432
|
-
inline
|
|
376
|
+
generateAtomicStyles
|
|
433
377
|
};
|