@tamagui/web 1.22.3 → 1.22.5
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 +6 -15
- package/dist/cjs/createComponent.js.map +1 -1
- package/dist/cjs/helpers/extendStaticConfig.js +25 -22
- package/dist/cjs/helpers/extendStaticConfig.js.map +1 -1
- package/dist/cjs/helpers/getStylesAtomic.js +4 -4
- package/dist/cjs/helpers/getStylesAtomic.js.map +1 -1
- package/dist/cjs/helpers/mergeProps.js +4 -2
- package/dist/cjs/helpers/mergeProps.js.map +1 -1
- package/dist/cjs/styled.js +5 -1
- package/dist/cjs/styled.js.map +1 -1
- package/dist/esm/createComponent.js +6 -15
- package/dist/esm/createComponent.js.map +1 -1
- package/dist/esm/createComponent.mjs +6 -15
- package/dist/esm/createComponent.mjs.map +1 -1
- package/dist/esm/helpers/extendStaticConfig.js +24 -22
- package/dist/esm/helpers/extendStaticConfig.js.map +1 -1
- package/dist/esm/helpers/extendStaticConfig.mjs +24 -22
- package/dist/esm/helpers/extendStaticConfig.mjs.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.js +4 -4
- package/dist/esm/helpers/getStylesAtomic.js.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.mjs +4 -4
- package/dist/esm/helpers/getStylesAtomic.mjs.map +1 -1
- package/dist/esm/helpers/mergeProps.js +4 -2
- package/dist/esm/helpers/mergeProps.js.map +1 -1
- package/dist/esm/helpers/mergeProps.mjs +4 -2
- package/dist/esm/helpers/mergeProps.mjs.map +1 -1
- package/dist/esm/styled.js +5 -1
- package/dist/esm/styled.js.map +1 -1
- package/dist/esm/styled.mjs +5 -1
- package/dist/esm/styled.mjs.map +1 -1
- package/package.json +9 -9
- package/src/createComponent.tsx +6 -26
- package/src/helpers/extendStaticConfig.ts +35 -26
- package/src/helpers/getStylesAtomic.ts +4 -8
- package/src/helpers/mergeProps.ts +5 -3
- package/src/styled.tsx +17 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/extendStaticConfig.d.ts +8 -1
- package/types/helpers/extendStaticConfig.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/mergeProps.d.ts +1 -1
- package/types/helpers/mergeProps.d.ts.map +1 -1
- package/types/styled.d.ts.map +1 -1
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { stylePropsView } from '@tamagui/helpers'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
GenericVariantDefinitions,
|
|
5
|
+
StaticConfig,
|
|
6
|
+
StaticConfigParsed,
|
|
7
|
+
StylableComponent,
|
|
8
|
+
} from '../types.js'
|
|
4
9
|
import { createPropMapper } from './createPropMapper.js'
|
|
5
10
|
import { mergeProps } from './mergeProps.js'
|
|
6
11
|
|
|
@@ -13,25 +18,9 @@ export function extendStaticConfig(
|
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
const parentStaticConfig = parent.staticConfig as StaticConfig
|
|
16
|
-
const variants = {
|
|
17
|
-
...parentStaticConfig.variants,
|
|
18
|
-
}
|
|
19
21
|
|
|
20
22
|
// merge variants... can we type this?
|
|
21
|
-
|
|
22
|
-
for (const key in config.variants) {
|
|
23
|
-
if (variants[key]) {
|
|
24
|
-
variants[key] = {
|
|
25
|
-
...variants[key],
|
|
26
|
-
...config.variants[key],
|
|
27
|
-
}
|
|
28
|
-
} else {
|
|
29
|
-
variants[key] = config.variants[key]
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// console.log('variants', variants)
|
|
23
|
+
const variants = mergeVariants(parentStaticConfig.variants, config.variants)
|
|
35
24
|
|
|
36
25
|
// include our own
|
|
37
26
|
const parentNames = [...(parentStaticConfig.parentNames || [])]
|
|
@@ -40,15 +29,11 @@ export function extendStaticConfig(
|
|
|
40
29
|
}
|
|
41
30
|
|
|
42
31
|
const deoptProps = config.deoptProps || new Set<string>()
|
|
43
|
-
// deoptProps.add('style')
|
|
44
32
|
|
|
45
|
-
const defaultProps = mergeProps(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
...config.defaultProps,
|
|
50
|
-
}
|
|
51
|
-
)[0]
|
|
33
|
+
const defaultProps = mergeProps(parentStaticConfig.defaultProps, {
|
|
34
|
+
...config.defaultProps,
|
|
35
|
+
...config.defaultVariants,
|
|
36
|
+
})[0]
|
|
52
37
|
|
|
53
38
|
return parseStaticConfig({
|
|
54
39
|
...parentStaticConfig,
|
|
@@ -67,6 +52,30 @@ export function extendStaticConfig(
|
|
|
67
52
|
})
|
|
68
53
|
}
|
|
69
54
|
|
|
55
|
+
export const mergeVariants = (
|
|
56
|
+
parentVariants?: GenericVariantDefinitions,
|
|
57
|
+
ourVariants?: GenericVariantDefinitions
|
|
58
|
+
) => {
|
|
59
|
+
const variants = {
|
|
60
|
+
...parentVariants,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (ourVariants) {
|
|
64
|
+
for (const key in ourVariants) {
|
|
65
|
+
if (key in variants) {
|
|
66
|
+
variants[key] = {
|
|
67
|
+
...variants[key],
|
|
68
|
+
...ourVariants[key],
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
variants[key] = ourVariants[key]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return variants
|
|
77
|
+
}
|
|
78
|
+
|
|
70
79
|
export const parseStaticConfig = (config: Partial<StaticConfig>): StaticConfigParsed => {
|
|
71
80
|
const parsed = {
|
|
72
81
|
defaultProps: {},
|
|
@@ -103,8 +103,8 @@ const presetHashes = {
|
|
|
103
103
|
|
|
104
104
|
export function styleToCSS(style: Record<string, any>) {
|
|
105
105
|
// box-shadow
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
const { shadowOffset, shadowRadius, shadowColor } = style
|
|
107
|
+
if (style.shadowRadius) {
|
|
108
108
|
const offset = shadowOffset || defaultOffset
|
|
109
109
|
const shadow = `${normalizeValueWithProperty(
|
|
110
110
|
offset.width
|
|
@@ -118,12 +118,8 @@ export function styleToCSS(style: Record<string, any>) {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
// text-shadow
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
'textShadowOffset' in style ||
|
|
124
|
-
'textShadowRadius' in style
|
|
125
|
-
) {
|
|
126
|
-
const { textShadowColor, textShadowOffset, textShadowRadius } = style
|
|
121
|
+
const { textShadowColor, textShadowOffset, textShadowRadius } = style
|
|
122
|
+
if (textShadowColor || textShadowOffset || textShadowRadius) {
|
|
127
123
|
const { height, width } = textShadowOffset || defaultOffset
|
|
128
124
|
const radius = textShadowRadius || 0
|
|
129
125
|
const color = normalizeValueWithProperty(textShadowColor, 'textShadowColor')
|
|
@@ -18,7 +18,7 @@ type AnyRecord = Record<string, any>
|
|
|
18
18
|
|
|
19
19
|
export const mergeProps = (
|
|
20
20
|
a: Object,
|
|
21
|
-
b
|
|
21
|
+
b?: Object,
|
|
22
22
|
leaveOutClassNames = false,
|
|
23
23
|
inverseShorthands?: AnyRecord
|
|
24
24
|
) => {
|
|
@@ -27,8 +27,10 @@ export const mergeProps = (
|
|
|
27
27
|
for (const key in a) {
|
|
28
28
|
mergeProp(out, outCns, a, b, key, leaveOutClassNames, inverseShorthands)
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
if (b) {
|
|
31
|
+
for (const key in b) {
|
|
32
|
+
mergeProp(out, outCns, b, undefined, key, leaveOutClassNames, inverseShorthands)
|
|
33
|
+
}
|
|
32
34
|
}
|
|
33
35
|
return [out, outCns] as const
|
|
34
36
|
}
|
package/src/styled.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { stylePropsAll } from '@tamagui/helpers'
|
|
2
2
|
|
|
3
3
|
import { createComponent } from './createComponent.js'
|
|
4
|
+
import { mergeVariants } from './helpers/extendStaticConfig.js'
|
|
4
5
|
import { ReactNativeStaticConfigs } from './setupReactNative.js'
|
|
5
6
|
import type {
|
|
6
7
|
GetProps,
|
|
@@ -77,7 +78,7 @@ export function styled<
|
|
|
77
78
|
!!parentStaticConfig &&
|
|
78
79
|
!(parentStaticConfig.isReactNative || parentStaticConfig.isHOC)
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
let Component: any = isPlainStyledComponent
|
|
81
82
|
? ComponentIn
|
|
82
83
|
: parentStaticConfig?.Component || ComponentIn
|
|
83
84
|
|
|
@@ -98,6 +99,17 @@ export function styled<
|
|
|
98
99
|
...defaultProps
|
|
99
100
|
} = options
|
|
100
101
|
|
|
102
|
+
// TODO why is this breaking native but fixing web
|
|
103
|
+
// if (process.env.TAMAGUI_TARGET === 'web') {
|
|
104
|
+
// if (parentStaticConfig) {
|
|
105
|
+
// defaultProps = {
|
|
106
|
+
// ...parentStaticConfig.defaultProps,
|
|
107
|
+
// ...defaultProps,
|
|
108
|
+
// ...defaultVariants,
|
|
109
|
+
// }
|
|
110
|
+
// }
|
|
111
|
+
// }
|
|
112
|
+
|
|
101
113
|
if (defaultVariants) {
|
|
102
114
|
defaultProps = {
|
|
103
115
|
...defaultVariants,
|
|
@@ -105,6 +117,10 @@ export function styled<
|
|
|
105
117
|
}
|
|
106
118
|
}
|
|
107
119
|
|
|
120
|
+
if (parentStaticConfig?.isHOC) {
|
|
121
|
+
variants = mergeVariants(parentStaticConfig.variants, variants)
|
|
122
|
+
}
|
|
123
|
+
|
|
108
124
|
const nativeConf =
|
|
109
125
|
(isReactNative && ReactNativeStaticConfigs.get(Component)) || null
|
|
110
126
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AASA,OAAO,KAWN,MAAM,OAAO,CAAA;AAkBd,OAAO,EACL,SAAS,EACT,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EAC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,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,mBAkGxD"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import type { StaticConfig, StaticConfigParsed, StylableComponent } from '../types.js';
|
|
1
|
+
import type { GenericVariantDefinitions, StaticConfig, StaticConfigParsed, StylableComponent } from '../types.js';
|
|
2
2
|
export declare function extendStaticConfig(config: Partial<StaticConfig>, parent?: StylableComponent): StaticConfigParsed;
|
|
3
|
+
export declare const mergeVariants: (parentVariants?: GenericVariantDefinitions, ourVariants?: GenericVariantDefinitions) => {
|
|
4
|
+
[x: string]: {
|
|
5
|
+
[key: string]: ((a: any, b: any) => any) | {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
};
|
|
3
10
|
export declare const parseStaticConfig: (config: Partial<StaticConfig>) => StaticConfigParsed;
|
|
4
11
|
//# sourceMappingURL=extendStaticConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extendStaticConfig.d.ts","sourceRoot":"","sources":["../../src/helpers/extendStaticConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"extendStaticConfig.d.ts","sourceRoot":"","sources":["../../src/helpers/extendStaticConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,yBAAyB,EACzB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,aAAa,CAAA;AAIpB,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,EAC7B,MAAM,CAAC,EAAE,iBAAiB,sBAuC3B;AAED,eAAO,MAAM,aAAa,oBACP,yBAAyB,gBAC5B,yBAAyB;;;;;;CAoBxC,CAAA;AAED,eAAO,MAAM,iBAAiB,WAAY,QAAQ,YAAY,CAAC,KAAG,kBAUjE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStylesAtomic.d.ts","sourceRoot":"","sources":["../../src/helpers/getStylesAtomic.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAc,MAAM,kBAAkB,CAAA;AAG1D,OAAO,KAAK,EAAyB,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAG9E,OAAO,EAAE,gBAAgB,EAAqB,MAAM,wBAAwB,CAAA;AAW5E,wBAAgB,eAAe,CAAC,QAAQ,EAAE,oBAAoB,iBAgB7D;AAID,eAAO,MAAM,oBAAoB,YACtB,oBAAoB,WACpB,gBAAgB,KACxB,WAAW,EAoDb,CAAA;AAMD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"getStylesAtomic.d.ts","sourceRoot":"","sources":["../../src/helpers/getStylesAtomic.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAc,MAAM,kBAAkB,CAAA;AAG1D,OAAO,KAAK,EAAyB,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAG9E,OAAO,EAAE,gBAAgB,EAAqB,MAAM,wBAAwB,CAAA;AAW5E,wBAAgB,eAAe,CAAC,QAAQ,EAAE,oBAAoB,iBAgB7D;AAID,eAAO,MAAM,oBAAoB,YACtB,oBAAoB,WACpB,gBAAgB,KACxB,WAAW,EAoDb,CAAA;AAMD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAgCpD"}
|
|
@@ -12,6 +12,6 @@
|
|
|
12
12
|
* - shorthands can be expanded before merging
|
|
13
13
|
*/
|
|
14
14
|
type AnyRecord = Record<string, any>;
|
|
15
|
-
export declare const mergeProps: (a: Object, b
|
|
15
|
+
export declare const mergeProps: (a: Object, b?: Object, leaveOutClassNames?: boolean, inverseShorthands?: AnyRecord) => readonly [AnyRecord, AnyRecord];
|
|
16
16
|
export {};
|
|
17
17
|
//# sourceMappingURL=mergeProps.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeProps.d.ts","sourceRoot":"","sources":["../../src/helpers/mergeProps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAEpC,eAAO,MAAM,UAAU,MAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"mergeProps.d.ts","sourceRoot":"","sources":["../../src/helpers/mergeProps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAEpC,eAAO,MAAM,UAAU,MAClB,MAAM,MACL,MAAM,oDAEU,SAAS,oCAa9B,CAAA"}
|
package/types/styled.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,YAAY,CAAA;AAEnB,KAAK,YAAY,CAAC,CAAC,SAAS,iBAAiB,IAAI,CAAC,SAAS,gBAAgB,CACzE,GAAG,EACH,GAAG,EACH,MAAM,CAAC,CACR,GACG,CAAC,GACD,QAAQ,CAAC,CAAC,CAAC,CAAA;AAEf,KAAK,eAAe,CAAC,CAAC,SAAS,iBAAiB,IAAI,CAAC,SAAS,gBAAgB,CAC5E,GAAG,EACH,GAAG,EACH,GAAG,EACH,MAAM,CAAC,CACR,GACG,CAAC,GACD,EAAE,CAAA;AAEN,KAAK,wBAAwB,CAAC,CAAC,IAAI,CAA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