@tamagui/web 1.4.0 → 1.5.1
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 +4 -5
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createTamagui.js +7 -6
- package/dist/cjs/createTamagui.js.map +3 -3
- package/dist/cjs/helpers/expandStyle.js +5 -14
- package/dist/cjs/helpers/expandStyle.js.map +2 -2
- package/dist/cjs/helpers/expandStyles.js +4 -42
- package/dist/cjs/helpers/expandStyles.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +22 -23
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/normalizeColor.js +13 -15
- package/dist/cjs/helpers/normalizeColor.js.map +2 -2
- package/dist/cjs/helpers/normalizeValueWithProperty.js +8 -19
- package/dist/cjs/helpers/normalizeValueWithProperty.js.map +2 -2
- package/dist/cjs/helpers/themeable.js.map +1 -1
- package/dist/cjs/views/Theme.js +2 -2
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/esm/createComponent.js +5 -10
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createComponent.mjs +5 -10
- package/dist/esm/createComponent.mjs.map +2 -2
- package/dist/esm/createTamagui.js +7 -6
- package/dist/esm/createTamagui.js.map +3 -3
- package/dist/esm/createTamagui.mjs +7 -6
- package/dist/esm/createTamagui.mjs.map +3 -3
- package/dist/esm/helpers/expandStyle.js +5 -14
- package/dist/esm/helpers/expandStyle.js.map +2 -2
- package/dist/esm/helpers/expandStyle.mjs +5 -14
- package/dist/esm/helpers/expandStyle.mjs.map +2 -2
- package/dist/esm/helpers/expandStyles.js +3 -41
- package/dist/esm/helpers/expandStyles.js.map +2 -2
- package/dist/esm/helpers/expandStyles.mjs +3 -41
- package/dist/esm/helpers/expandStyles.mjs.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +20 -21
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.mjs +20 -21
- package/dist/esm/helpers/getSplitStyles.mjs.map +2 -2
- package/dist/esm/helpers/normalizeColor.js +12 -15
- package/dist/esm/helpers/normalizeColor.js.map +2 -2
- package/dist/esm/helpers/normalizeColor.mjs +12 -15
- package/dist/esm/helpers/normalizeColor.mjs.map +2 -2
- package/dist/esm/helpers/normalizeValueWithProperty.js +9 -20
- package/dist/esm/helpers/normalizeValueWithProperty.js.map +2 -2
- package/dist/esm/helpers/normalizeValueWithProperty.mjs +9 -20
- package/dist/esm/helpers/normalizeValueWithProperty.mjs.map +2 -2
- package/dist/esm/helpers/themeable.js.map +1 -1
- package/dist/esm/helpers/themeable.mjs.map +1 -1
- package/dist/esm/views/Theme.js +2 -2
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/Theme.mjs +2 -2
- package/dist/esm/views/Theme.mjs.map +2 -2
- package/package.json +9 -9
- package/src/createComponent.tsx +7 -13
- package/src/createTamagui.ts +6 -4
- package/src/helpers/expandStyle.ts +5 -18
- package/src/helpers/expandStyles.ts +9 -46
- package/src/helpers/getSplitStyles.tsx +31 -24
- package/src/helpers/normalizeColor.ts +11 -22
- package/src/helpers/normalizeShadow.native.ts +30 -0
- package/src/helpers/normalizeShadow.ts +20 -0
- package/src/helpers/normalizeStylePropKeys.native.ts +12 -0
- package/src/helpers/normalizeStylePropKeys.ts +3 -0
- package/src/helpers/normalizeValueWithProperty.ts +9 -23
- package/src/helpers/themeable.tsx +2 -2
- package/src/views/Theme.tsx +2 -3
- package/types/createComponent.d.ts.map +1 -1
- package/types/createTamagui.d.ts.map +1 -1
- package/types/helpers/expandStyle.d.ts.map +1 -1
- package/types/helpers/expandStyles.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts +1 -2
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/normalizeColor.d.ts +5 -0
- package/types/helpers/normalizeColor.d.ts.map +1 -1
- package/types/helpers/normalizeColor.native.d.ts +16 -0
- package/types/helpers/normalizeShadow.d.ts +10 -0
- package/types/helpers/normalizeShadow.native.d.ts +10 -0
- package/types/helpers/normalizeStylePropKeys.d.ts +2 -0
- package/types/helpers/normalizeStylePropKeys.native.d.ts +13 -0
- package/types/helpers/normalizeValueWithProperty.d.ts.map +1 -1
- package/types/helpers/themeable.d.ts +2 -2
- package/types/helpers/themeable.d.ts.map +1 -1
- package/types/views/Theme.d.ts.map +1 -1
- package/src/helpers/mergeTransform.ts +0 -30
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { isWeb } from '@tamagui/constants'
|
|
2
|
-
import { normalizeCSSColor } from '@tamagui/normalize-css-color'
|
|
3
|
-
|
|
4
1
|
import { getConfig } from '../config'
|
|
5
2
|
import { expandStyle } from './expandStyle'
|
|
6
|
-
import {
|
|
3
|
+
import { normalizeShadow } from './normalizeShadow'
|
|
7
4
|
import { normalizeValueWithProperty } from './normalizeValueWithProperty.js'
|
|
8
5
|
import { pseudoDescriptors } from './pseudoDescriptors'
|
|
9
6
|
|
|
@@ -46,13 +43,19 @@ export function expandStyles(style: Record<string, any>, config = getConfig()) {
|
|
|
46
43
|
}
|
|
47
44
|
|
|
48
45
|
export function fixStyles(style: Record<string, any>) {
|
|
49
|
-
if (
|
|
46
|
+
if (
|
|
47
|
+
style.shadowRadius ||
|
|
48
|
+
style.shadowColor ||
|
|
49
|
+
style.shadowOpacity ||
|
|
50
|
+
style.shadowOffset
|
|
51
|
+
) {
|
|
50
52
|
Object.assign(style, normalizeShadow(style))
|
|
51
53
|
}
|
|
52
54
|
|
|
55
|
+
// TODO could be native-only
|
|
53
56
|
// ensure border style set by default to solid
|
|
54
57
|
for (const key in borderDefaults) {
|
|
55
|
-
if (
|
|
58
|
+
if (key in style && !style[borderDefaults[key]]) {
|
|
56
59
|
style[borderDefaults[key]] = 'solid'
|
|
57
60
|
}
|
|
58
61
|
}
|
|
@@ -65,43 +68,3 @@ const borderDefaults = {
|
|
|
65
68
|
borderLeftWidth: 'borderLeftStyle',
|
|
66
69
|
borderRightWidth: 'borderRightStyle',
|
|
67
70
|
}
|
|
68
|
-
|
|
69
|
-
function normalizeShadow({
|
|
70
|
-
shadowColor,
|
|
71
|
-
shadowOffset,
|
|
72
|
-
shadowOpacity,
|
|
73
|
-
shadowRadius,
|
|
74
|
-
}: Record<string, any>) {
|
|
75
|
-
const { height, width } = shadowOffset || defaultOffset
|
|
76
|
-
const colorStr = String(shadowColor || 'black')
|
|
77
|
-
return {
|
|
78
|
-
shadowOffset: {
|
|
79
|
-
width: normalizeValueWithProperty(width || 0),
|
|
80
|
-
height: normalizeValueWithProperty(height || 0),
|
|
81
|
-
},
|
|
82
|
-
shadowRadius: normalizeValueWithProperty(shadowRadius || 0),
|
|
83
|
-
...(isWeb && {
|
|
84
|
-
shadowColor: normalizeColor(colorStr, shadowOpacity),
|
|
85
|
-
}),
|
|
86
|
-
...(process.env.TAMAGUI_TARGET === 'native' &&
|
|
87
|
-
(() => {
|
|
88
|
-
// on native fix bug - shadows behave better if turned into non-alpha rgb() + shadowOpacity
|
|
89
|
-
const val = normalizeCSSColor(colorStr)
|
|
90
|
-
if (!val) {
|
|
91
|
-
if (process.env.NODE_ENV === 'development') {
|
|
92
|
-
// eslint-disable-next-line no-console
|
|
93
|
-
console.warn('No rgba form', colorStr)
|
|
94
|
-
}
|
|
95
|
-
return {
|
|
96
|
-
shadowColor,
|
|
97
|
-
shadowOpacity,
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const { r, g, b, a } = rgba(val)
|
|
101
|
-
return {
|
|
102
|
-
shadowColor: `rgb(${r},${g},${b})`,
|
|
103
|
-
shadowOpacity: shadowOpacity ?? a,
|
|
104
|
-
}
|
|
105
|
-
})()),
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -35,7 +35,6 @@ import type {
|
|
|
35
35
|
RulesToInsert,
|
|
36
36
|
SpaceTokens,
|
|
37
37
|
SplitStyleState,
|
|
38
|
-
StackProps,
|
|
39
38
|
StaticConfigParsed,
|
|
40
39
|
TamaguiInternalConfig,
|
|
41
40
|
ThemeParsed,
|
|
@@ -52,19 +51,16 @@ import {
|
|
|
52
51
|
shouldInsertStyleRules,
|
|
53
52
|
updateRules,
|
|
54
53
|
} from './insertStyleRule'
|
|
55
|
-
import { FlatTransforms, mergeTransform, mergeTransforms } from './mergeTransform'
|
|
56
54
|
import {
|
|
57
55
|
normalizeValueWithProperty,
|
|
58
56
|
reverseMapClassNameToValue,
|
|
59
57
|
} from './normalizeValueWithProperty.js'
|
|
60
58
|
import { pseudoDescriptors } from './pseudoDescriptors'
|
|
61
|
-
import { warnOnce } from './warnOnce'
|
|
62
59
|
|
|
63
60
|
type GetStyleState = {
|
|
64
61
|
style: ViewStyle
|
|
65
62
|
usedKeys: Record<string, number>
|
|
66
63
|
classNames: ClassNamesObject
|
|
67
|
-
flatTransforms: FlatTransforms
|
|
68
64
|
staticConfig: StaticConfigParsed
|
|
69
65
|
theme: ThemeParsed
|
|
70
66
|
props: Record<string, any>
|
|
@@ -213,15 +209,8 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
213
209
|
|
|
214
210
|
conf = conf || getConfig()
|
|
215
211
|
const { shorthands } = conf
|
|
216
|
-
const {
|
|
217
|
-
|
|
218
|
-
variants,
|
|
219
|
-
propMapper,
|
|
220
|
-
isReactNative,
|
|
221
|
-
deoptProps,
|
|
222
|
-
inlineProps,
|
|
223
|
-
inlineWhenUnflattened,
|
|
224
|
-
} = staticConfig
|
|
212
|
+
const { variants, propMapper, isReactNative, inlineProps, inlineWhenUnflattened } =
|
|
213
|
+
staticConfig
|
|
225
214
|
const validStyleProps = staticConfig.isText ? stylePropsText : validStyles
|
|
226
215
|
const viewProps: GetStyleResult['viewProps'] = {}
|
|
227
216
|
let pseudos: PseudoStyles | null = null
|
|
@@ -251,7 +240,6 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
251
240
|
const styleState: GetStyleState = {
|
|
252
241
|
classNames,
|
|
253
242
|
conf,
|
|
254
|
-
flatTransforms,
|
|
255
243
|
props,
|
|
256
244
|
state,
|
|
257
245
|
staticConfig,
|
|
@@ -262,12 +250,6 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
262
250
|
languageContext,
|
|
263
251
|
}
|
|
264
252
|
|
|
265
|
-
if (process.env.NODE_ENV === 'development') {
|
|
266
|
-
if (props.selectable) {
|
|
267
|
-
warnOnce('props.selectable', 'selectable props deprecated, use userSelect')
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
253
|
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
272
254
|
// eslint-disable-next-line no-console
|
|
273
255
|
console.groupCollapsed('getSplitStyles (looping backwards)')
|
|
@@ -668,7 +650,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
668
650
|
if (isDisabled) {
|
|
669
651
|
if (!(pkey in usedKeys) && pkey in animatableDefaults) {
|
|
670
652
|
const defaultVal = animatableDefaults[pkey]
|
|
671
|
-
mergeStyle(styleState, pkey, defaultVal, true)
|
|
653
|
+
mergeStyle(styleState, flatTransforms, pkey, defaultVal, true)
|
|
672
654
|
}
|
|
673
655
|
continue
|
|
674
656
|
}
|
|
@@ -679,7 +661,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
679
661
|
pseudos ||= {}
|
|
680
662
|
pseudos[key] ||= {}
|
|
681
663
|
pseudos[key][pkey] = val
|
|
682
|
-
mergeStyle(styleState, pkey, val)
|
|
664
|
+
mergeStyle(styleState, flatTransforms, pkey, val)
|
|
683
665
|
}
|
|
684
666
|
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
685
667
|
// prettier-ignore
|
|
@@ -793,7 +775,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
793
775
|
}
|
|
794
776
|
|
|
795
777
|
if (key in validStyleProps) {
|
|
796
|
-
mergeStyle(styleState, key, val)
|
|
778
|
+
mergeStyle(styleState, flatTransforms, key, val)
|
|
797
779
|
continue
|
|
798
780
|
}
|
|
799
781
|
|
|
@@ -1012,7 +994,8 @@ function getSubStyleProps(
|
|
|
1012
994
|
}
|
|
1013
995
|
|
|
1014
996
|
function mergeStyle(
|
|
1015
|
-
{ usedKeys, classNames,
|
|
997
|
+
{ usedKeys, classNames, viewProps, style }: GetStyleState,
|
|
998
|
+
flatTransforms: FlatTransforms,
|
|
1016
999
|
key: string,
|
|
1017
1000
|
val: any,
|
|
1018
1001
|
dontSetUsed = false
|
|
@@ -1122,3 +1105,27 @@ const animatableDefaults = {
|
|
|
1122
1105
|
|
|
1123
1106
|
const lowercaseHyphenate = (match: string) => `-${match.toLowerCase()}`
|
|
1124
1107
|
const hyphenate = (str: string) => str.replace(/[A-Z]/g, lowercaseHyphenate)
|
|
1108
|
+
|
|
1109
|
+
export type FlatTransforms = Record<string, any>
|
|
1110
|
+
|
|
1111
|
+
const mergeTransform = (obj: ViewStyle, key: string, val: any, backwards = false) => {
|
|
1112
|
+
obj.transform ||= []
|
|
1113
|
+
obj.transform[backwards ? 'unshift' : 'push']({
|
|
1114
|
+
[mapTransformKeys[key] || key]: val,
|
|
1115
|
+
} as any)
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
const mergeTransforms = (
|
|
1119
|
+
obj: ViewStyle,
|
|
1120
|
+
flatTransforms: FlatTransforms,
|
|
1121
|
+
backwards = false
|
|
1122
|
+
) => {
|
|
1123
|
+
Object.entries(flatTransforms).forEach(([key, val]) => {
|
|
1124
|
+
mergeTransform(obj, key, val, backwards)
|
|
1125
|
+
})
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
const mapTransformKeys = {
|
|
1129
|
+
x: 'translateX',
|
|
1130
|
+
y: 'translateY',
|
|
1131
|
+
}
|
|
@@ -2,37 +2,26 @@ import { isWeb } from '@tamagui/constants'
|
|
|
2
2
|
import * as NCC from '@tamagui/normalize-css-color'
|
|
3
3
|
|
|
4
4
|
export const rgba = NCC.rgba
|
|
5
|
+
export const names = NCC.names
|
|
5
6
|
|
|
6
|
-
export const normalizeColor = (color?: string | null, opacity
|
|
7
|
-
if (color
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
return `rgba(0,0,0,0)`
|
|
12
|
-
}
|
|
13
|
-
if (
|
|
14
|
-
color[0] === '$' ||
|
|
15
|
-
(isWeb && (webColors[color] || color[0] === '_' || color.startsWith('var(')))
|
|
16
|
-
) {
|
|
7
|
+
export const normalizeColor = (color?: string | null, opacity = 1) => {
|
|
8
|
+
if (!color) return
|
|
9
|
+
if (color === 'transparent') return `rgba(0,0,0,0)`
|
|
10
|
+
if (color[0] === '$') return color
|
|
11
|
+
if (isWeb && opacity === 1) {
|
|
17
12
|
return color
|
|
18
13
|
}
|
|
19
14
|
const colorProcessed = NCC.normalizeCSSColor(color)
|
|
20
|
-
if (colorProcessed
|
|
15
|
+
if (colorProcessed) {
|
|
21
16
|
const { r, g, b, a } = rgba(colorProcessed)
|
|
22
17
|
return `rgba(${r},${g},${b},${(opacity ?? a).toFixed(2)})`
|
|
23
18
|
}
|
|
24
|
-
|
|
25
|
-
if (isWeb) {
|
|
26
|
-
return color
|
|
27
|
-
} else {
|
|
19
|
+
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
28
20
|
if (process.env.NODE_ENV === 'development') {
|
|
29
21
|
console.warn(`Unknown color value: ${color}`)
|
|
30
22
|
}
|
|
23
|
+
// avoids errors
|
|
24
|
+
return
|
|
31
25
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const webColors = {
|
|
35
|
-
currentColor: true,
|
|
36
|
-
currentcolor: true,
|
|
37
|
-
inherit: true,
|
|
26
|
+
return color
|
|
38
27
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { normalizeCSSColor } from '@tamagui/normalize-css-color'
|
|
2
|
+
|
|
3
|
+
import { defaultOffset } from './expandStyles'
|
|
4
|
+
import { rgba } from './normalizeColor'
|
|
5
|
+
import { normalizeValueWithProperty } from './normalizeValueWithProperty.js'
|
|
6
|
+
|
|
7
|
+
export function normalizeShadow({
|
|
8
|
+
shadowColor,
|
|
9
|
+
shadowOffset,
|
|
10
|
+
shadowOpacity,
|
|
11
|
+
shadowRadius,
|
|
12
|
+
}: Record<string, any>) {
|
|
13
|
+
const { height, width } = shadowOffset || defaultOffset
|
|
14
|
+
const colorStr = String(shadowColor || 'black')
|
|
15
|
+
// on native fix bug - shadows behave better if turned into non-alpha rgb() + shadowOpacity
|
|
16
|
+
const val = normalizeCSSColor(colorStr)
|
|
17
|
+
if (!val) {
|
|
18
|
+
throw new Error(`invalid shadow color ${colorStr}`)
|
|
19
|
+
}
|
|
20
|
+
const { r, g, b, a } = rgba(val)
|
|
21
|
+
return {
|
|
22
|
+
shadowOffset: {
|
|
23
|
+
width: normalizeValueWithProperty(width || 0),
|
|
24
|
+
height: normalizeValueWithProperty(height || 0),
|
|
25
|
+
},
|
|
26
|
+
shadowRadius: normalizeValueWithProperty(shadowRadius || 0),
|
|
27
|
+
shadowColor: `rgb(${r},${g},${b})`,
|
|
28
|
+
shadowOpacity: shadowOpacity ?? a,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defaultOffset } from './expandStyles'
|
|
2
|
+
import { normalizeValueWithProperty } from './normalizeValueWithProperty.js'
|
|
3
|
+
|
|
4
|
+
export function normalizeShadow({
|
|
5
|
+
shadowColor,
|
|
6
|
+
shadowOffset,
|
|
7
|
+
shadowOpacity = 1,
|
|
8
|
+
shadowRadius,
|
|
9
|
+
}: Record<string, any>) {
|
|
10
|
+
const { height, width } = shadowOffset || defaultOffset
|
|
11
|
+
return {
|
|
12
|
+
shadowOffset: {
|
|
13
|
+
width: normalizeValueWithProperty(width || 0),
|
|
14
|
+
height: normalizeValueWithProperty(height || 0),
|
|
15
|
+
},
|
|
16
|
+
shadowRadius: normalizeValueWithProperty(shadowRadius || 0),
|
|
17
|
+
shadowColor,
|
|
18
|
+
shadowOpacity,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const normalizeStylePropKeys = {
|
|
2
|
+
backgroundColor: true,
|
|
3
|
+
borderColor: true,
|
|
4
|
+
borderTopColor: true,
|
|
5
|
+
borderRightColor: true,
|
|
6
|
+
borderBottomColor: true,
|
|
7
|
+
borderLeftColor: true,
|
|
8
|
+
color: true,
|
|
9
|
+
shadowColor: true,
|
|
10
|
+
textDecorationColor: true,
|
|
11
|
+
textShadowColor: true,
|
|
12
|
+
}
|
|
@@ -6,20 +6,23 @@
|
|
|
6
6
|
import { isWeb } from '@tamagui/constants'
|
|
7
7
|
|
|
8
8
|
import { getAllSelectors } from './insertStyleRule'
|
|
9
|
-
import { normalizeColor } from './normalizeColor'
|
|
9
|
+
import { names, normalizeColor } from './normalizeColor'
|
|
10
|
+
import { normalizeStylePropKeys } from './normalizeStylePropKeys'
|
|
10
11
|
|
|
11
12
|
const colorCache = {}
|
|
12
13
|
|
|
13
14
|
export function normalizeValueWithProperty(value: any, property?: string): any {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return cached
|
|
15
|
+
if (value in colorCache) {
|
|
16
|
+
return colorCache[value]
|
|
17
17
|
}
|
|
18
18
|
if (property && property in unitlessNumbers) {
|
|
19
19
|
return value
|
|
20
20
|
}
|
|
21
21
|
let res = value
|
|
22
|
-
if (
|
|
22
|
+
if (property && (property in normalizeStylePropKeys || value in names)) {
|
|
23
|
+
res = normalizeColor(value)
|
|
24
|
+
colorCache[value] = res
|
|
25
|
+
} else if (
|
|
23
26
|
process.env.TAMAGUI_TARGET === 'web' &&
|
|
24
27
|
typeof value === 'number' &&
|
|
25
28
|
(property === undefined ||
|
|
@@ -28,28 +31,10 @@ export function normalizeValueWithProperty(value: any, property?: string): any {
|
|
|
28
31
|
res = `${value}px`
|
|
29
32
|
} else if (isWeb && property !== undefined && property in stringNumbers) {
|
|
30
33
|
res = `${res}`
|
|
31
|
-
} else if (property && property in colorProps) {
|
|
32
|
-
res = normalizeColor(value)
|
|
33
|
-
colorCache[value] = res
|
|
34
34
|
}
|
|
35
35
|
return res
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// TODO react-native-web-lite
|
|
39
|
-
|
|
40
|
-
const colorProps = {
|
|
41
|
-
backgroundColor: true,
|
|
42
|
-
borderColor: true,
|
|
43
|
-
borderTopColor: true,
|
|
44
|
-
borderRightColor: true,
|
|
45
|
-
borderBottomColor: true,
|
|
46
|
-
borderLeftColor: true,
|
|
47
|
-
color: true,
|
|
48
|
-
shadowColor: true,
|
|
49
|
-
textDecorationColor: true,
|
|
50
|
-
textShadowColor: true,
|
|
51
|
-
}
|
|
52
|
-
|
|
53
38
|
const stringNumbers = {
|
|
54
39
|
zIndex: true,
|
|
55
40
|
}
|
|
@@ -64,6 +49,7 @@ const unitlessNumbers = {
|
|
|
64
49
|
columnCount: true,
|
|
65
50
|
flex: true,
|
|
66
51
|
flexGrow: true,
|
|
52
|
+
flexBasis: true,
|
|
67
53
|
flexOrder: true,
|
|
68
54
|
flexPositive: true,
|
|
69
55
|
flexShrink: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef, useId } from 'react'
|
|
2
2
|
|
|
3
|
-
import { ThemeName } from '../types'
|
|
3
|
+
import { DebugProp, ThemeName } from '../types'
|
|
4
4
|
import { Theme } from '../views/Theme'
|
|
5
5
|
|
|
6
6
|
export interface ThemeableProps {
|
|
@@ -8,7 +8,7 @@ export interface ThemeableProps {
|
|
|
8
8
|
themeInverse?: boolean
|
|
9
9
|
themeReset?: boolean
|
|
10
10
|
componentName?: string
|
|
11
|
-
debug?:
|
|
11
|
+
debug?: DebugProp
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export function themeable<Component extends (props: any) => any>(
|
package/src/views/Theme.tsx
CHANGED
|
@@ -60,14 +60,13 @@ export function useThemedChildren(
|
|
|
60
60
|
)
|
|
61
61
|
|
|
62
62
|
if (isWeb) {
|
|
63
|
-
const enableClassName =
|
|
64
|
-
forceClassName === true || (forceClassName !== false && isNewTheme)
|
|
63
|
+
const enableClassName = forceClassName ?? (forceClassName !== false && isNewTheme)
|
|
65
64
|
return (
|
|
66
65
|
<span
|
|
67
66
|
className="_dsp_contents"
|
|
68
67
|
{...(theme &&
|
|
69
68
|
enableClassName && {
|
|
70
|
-
className: `${className}
|
|
69
|
+
className: `${className} _dsp_contents`,
|
|
71
70
|
style: {
|
|
72
71
|
// in order to provide currentColor, set color by default
|
|
73
72
|
color: variableToString(theme.color),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAUN,MAAM,OAAO,CAAA;AAiBd,OAAO,EACL,SAAS,EACT,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAEhB,qBAAqB,EAErB,cAAc,EAIf,MAAM,SAAS,CAAA;AAmBhB,eAAO,MAAM,qBAAqB,EAAE,qBAMnC,CAAA;AAeD,eAAO,MAAM,QAAQ,eAAsB,CAAA;AA8B3C,wBAAgB,eAAe,CAC7B,kBAAkB,SAAS,MAAM,GAAG,EAAE,EACtC,GAAG,GAAG,cAAc,EACpB,SAAS,GAAG,KAAK,EAEjB,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,kBAAkB,EACpD,eAAe,CAAC,EAAE,iBAAiB,4DAkwBpC;AAGD,eAAO,MAAM,QAAQ;YAAW;QAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;KAAE;;CAEjD,CAAA;AAMD,eAAO,MAAM,MAAM,0DA8CjB,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAAA;IACnC,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAC5B,SAAS,CAAC,EAAE,cAAc,CAAA;IAC1B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,mBAiGxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTamagui.d.ts","sourceRoot":"","sources":["../src/createTamagui.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAGnB,MAAM,SAAS,CAAA;AAKhB,wBAAgB,aAAa,CAAC,IAAI,SAAS,kBAAkB,EAC3D,QAAQ,EAAE,IAAI,GACb,kBAAkB,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"createTamagui.d.ts","sourceRoot":"","sources":["../src/createTamagui.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAGnB,MAAM,SAAS,CAAA;AAKhB,wBAAgB,aAAa,CAAC,IAAI,SAAS,kBAAkB,EAC3D,QAAQ,EAAE,IAAI,GACb,kBAAkB,CAAC,IAAI,CAAC,CA+N1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandStyle.d.ts","sourceRoot":"","sources":["../../src/helpers/expandStyle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"expandStyle.d.ts","sourceRoot":"","sources":["../../src/helpers/expandStyle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,uBA2BlD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandStyles.d.ts","sourceRoot":"","sources":["../../src/helpers/expandStyles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"expandStyles.d.ts","sourceRoot":"","sources":["../../src/helpers/expandStyles.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,aAAa;;;CAA0B,CAAA;AAEpD;;;;;;GAMG;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;;;;;;;;;;;;6BAAc,uBAyB5E;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAiBnD"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { ViewStyle } from 'react-native';
|
|
2
2
|
import type { ClassNamesObject, DebugProp, GetStyleResult, SplitStyleState, StaticConfigParsed, TamaguiInternalConfig, ThemeParsed } from '../types';
|
|
3
3
|
import { FontLanguageProps, LanguageContextType } from '../views/FontLanguage.types';
|
|
4
|
-
import { FlatTransforms } from './mergeTransform';
|
|
5
4
|
type GetStyleState = {
|
|
6
5
|
style: ViewStyle;
|
|
7
6
|
usedKeys: Record<string, number>;
|
|
8
7
|
classNames: ClassNamesObject;
|
|
9
|
-
flatTransforms: FlatTransforms;
|
|
10
8
|
staticConfig: StaticConfigParsed;
|
|
11
9
|
theme: ThemeParsed;
|
|
12
10
|
props: Record<string, any>;
|
|
@@ -27,5 +25,6 @@ export declare const getSplitStyles: StyleSplitter;
|
|
|
27
25
|
export declare const getSubStyle: (styleState: GetStyleState, subKey: string, styleIn: Object, avoidDefaultProps?: boolean, avoidMergeTransform?: boolean) => ViewStyle;
|
|
28
26
|
export declare const insertSplitStyles: StyleSplitter;
|
|
29
27
|
export declare const useSplitStyles: StyleSplitter;
|
|
28
|
+
export type FlatTransforms = Record<string, any>;
|
|
30
29
|
export {};
|
|
31
30
|
//# sourceMappingURL=getSplitStyles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSplitStyles.d.ts","sourceRoot":"","sources":["../../src/helpers/getSplitStyles.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,cAAc,CAAA;AAWxD,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,cAAc,EAOd,eAAe,
|
|
1
|
+
{"version":3,"file":"getSplitStyles.d.ts","sourceRoot":"","sources":["../../src/helpers/getSplitStyles.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,cAAc,CAAA;AAWxD,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,cAAc,EAOd,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,WAAW,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAkBpF,KAAK,aAAa,GAAG;IACnB,KAAK,EAAE,SAAS,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,UAAU,EAAE,gBAAgB,CAAA;IAC5B,YAAY,EAAE,kBAAkB,CAAA;IAChC,KAAK,EAAE,WAAW,CAAA;IAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9B,KAAK,EAAE,eAAe,CAAA;IACtB,IAAI,EAAE,qBAAqB,CAAA;IAC3B,eAAe,CAAC,EAAE,iBAAiB,CAAA;IACnC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;AAE3D,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;AAsFhE,KAAK,aAAa,GAAG,CACnB,KAAK,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAC7B,YAAY,EAAE,kBAAkB,EAChC,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,eAAe,EACtB,iBAAiB,CAAC,EAAE,cAAc,GAAG,IAAI,EACzC,eAAe,CAAC,EAAE,mBAAmB,EAErC,WAAW,CAAC,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE,SAAS,KACd,cAAc,CAAA;AAEnB,eAAO,MAAM,UAAU,MAAM,CAAA;AAqB7B,eAAO,MAAM,cAAc,EAAE,aA+tB5B,CAAA;AA0FD,eAAO,MAAM,WAAW,eACV,aAAa,UACjB,MAAM,WACL,MAAM,sBACK,OAAO,wBACL,OAAO,KAC5B,SA6BF,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,aAI/B,CAAA;AAOD,eAAO,MAAM,cAAc,EAAE,aAU5B,CAAA;AA8BD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import * as NCC from '@tamagui/normalize-css-color';
|
|
2
2
|
export declare const rgba: typeof NCC.rgba;
|
|
3
|
+
export declare const names: {
|
|
4
|
+
transparent: number;
|
|
5
|
+
white: number;
|
|
6
|
+
black: number;
|
|
7
|
+
};
|
|
3
8
|
export declare const normalizeColor: (color?: string | null, opacity?: number) => string | undefined;
|
|
4
9
|
//# sourceMappingURL=normalizeColor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeColor.d.ts","sourceRoot":"","sources":["../../src/helpers/normalizeColor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,8BAA8B,CAAA;AAEnD,eAAO,MAAM,IAAI,iBAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"normalizeColor.d.ts","sourceRoot":"","sources":["../../src/helpers/normalizeColor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,8BAA8B,CAAA;AAEnD,eAAO,MAAM,IAAI,iBAAW,CAAA;AAC5B,eAAO,MAAM,KAAK;;;;CAAY,CAAA;AAE9B,eAAO,MAAM,cAAc,WAAY,MAAM,GAAG,IAAI,yCAoBnD,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as NCC from '@tamagui/normalize-css-color';
|
|
2
|
+
export declare const rgba: typeof NCC.rgba;
|
|
3
|
+
export declare const normalizeStylePropKeys: {
|
|
4
|
+
backgroundColor: boolean;
|
|
5
|
+
borderColor: boolean;
|
|
6
|
+
borderTopColor: boolean;
|
|
7
|
+
borderRightColor: boolean;
|
|
8
|
+
borderBottomColor: boolean;
|
|
9
|
+
borderLeftColor: boolean;
|
|
10
|
+
color: boolean;
|
|
11
|
+
shadowColor: boolean;
|
|
12
|
+
textDecorationColor: boolean;
|
|
13
|
+
textShadowColor: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare const normalizeColor: (color?: string | null, opacity?: number) => string | undefined;
|
|
16
|
+
//# sourceMappingURL=normalizeColor.native.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function normalizeShadow({ shadowColor, shadowOffset, shadowOpacity, shadowRadius, }: Record<string, any>): {
|
|
2
|
+
shadowOffset: {
|
|
3
|
+
width: any;
|
|
4
|
+
height: any;
|
|
5
|
+
};
|
|
6
|
+
shadowRadius: any;
|
|
7
|
+
shadowColor: any;
|
|
8
|
+
shadowOpacity: any;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=normalizeShadow.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function normalizeShadow({ shadowColor, shadowOffset, shadowOpacity, shadowRadius, }: Record<string, any>): {
|
|
2
|
+
shadowOffset: {
|
|
3
|
+
width: any;
|
|
4
|
+
height: any;
|
|
5
|
+
};
|
|
6
|
+
shadowRadius: any;
|
|
7
|
+
shadowColor: string;
|
|
8
|
+
shadowOpacity: any;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=normalizeShadow.native.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const normalizeStylePropKeys: {
|
|
2
|
+
backgroundColor: boolean;
|
|
3
|
+
borderColor: boolean;
|
|
4
|
+
borderTopColor: boolean;
|
|
5
|
+
borderRightColor: boolean;
|
|
6
|
+
borderBottomColor: boolean;
|
|
7
|
+
borderLeftColor: boolean;
|
|
8
|
+
color: boolean;
|
|
9
|
+
shadowColor: boolean;
|
|
10
|
+
textDecorationColor: boolean;
|
|
11
|
+
textShadowColor: boolean;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=normalizeStylePropKeys.native.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeValueWithProperty.d.ts","sourceRoot":"","sources":["../../src/helpers/normalizeValueWithProperty.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"normalizeValueWithProperty.d.ts","sourceRoot":"","sources":["../../src/helpers/normalizeValueWithProperty.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,GAAG,CAsB7E;AA+CD,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAiCxE"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ThemeName } from '../types';
|
|
1
|
+
import { DebugProp, ThemeName } from '../types';
|
|
2
2
|
export interface ThemeableProps {
|
|
3
3
|
theme?: ThemeName | null;
|
|
4
4
|
themeInverse?: boolean;
|
|
5
5
|
themeReset?: boolean;
|
|
6
6
|
componentName?: string;
|
|
7
|
-
debug?:
|
|
7
|
+
debug?: DebugProp;
|
|
8
8
|
}
|
|
9
9
|
export declare function themeable<Component extends (props: any) => any>(component: Component, opts?: {
|
|
10
10
|
componentName?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themeable.d.ts","sourceRoot":"","sources":["../../src/helpers/themeable.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"themeable.d.ts","sourceRoot":"","sources":["../../src/helpers/themeable.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAG/C,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;IACxB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAED,wBAAgB,SAAS,CAAC,SAAS,SAAS,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,EAC7D,SAAS,EAAE,SAAS,EACpB,IAAI,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,8HA4BlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Theme.d.ts","sourceRoot":"","sources":["../../src/views/Theme.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAwB,MAAM,mBAAmB,CAAA;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,OAYtC;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,oBAAoB,EAChC,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"Theme.d.ts","sourceRoot":"","sources":["../../src/views/Theme.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAwB,MAAM,mBAAmB,CAAA;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,OAYtC;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,oBAAoB,EAChC,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,OAuDzD"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { ViewStyle } from 'react-native'
|
|
2
|
-
|
|
3
|
-
export type FlatTransforms = Record<string, any>
|
|
4
|
-
|
|
5
|
-
export const mergeTransform = (
|
|
6
|
-
obj: ViewStyle,
|
|
7
|
-
key: string,
|
|
8
|
-
val: any,
|
|
9
|
-
backwards = false
|
|
10
|
-
) => {
|
|
11
|
-
obj.transform ||= []
|
|
12
|
-
obj.transform[backwards ? 'unshift' : 'push']({
|
|
13
|
-
[mapTransformKeys[key] || key]: val,
|
|
14
|
-
} as any)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const mergeTransforms = (
|
|
18
|
-
obj: ViewStyle,
|
|
19
|
-
flatTransforms: FlatTransforms,
|
|
20
|
-
backwards = false
|
|
21
|
-
) => {
|
|
22
|
-
Object.entries(flatTransforms).forEach(([key, val]) => {
|
|
23
|
-
mergeTransform(obj, key, val, backwards)
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const mapTransformKeys = {
|
|
28
|
-
x: 'translateX',
|
|
29
|
-
y: 'translateY',
|
|
30
|
-
}
|