@tamagui/helpers 2.7.7 → 3.0.0-beta.1097.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/clamp.cjs +15 -19
- package/dist/cjs/clamp.native.cjs +29 -0
- package/dist/cjs/clamp.native.js +16 -19
- package/dist/cjs/clamp.native.js.map +1 -1
- package/dist/cjs/composeEventHandlers.cjs +25 -32
- package/dist/cjs/composeEventHandlers.native.cjs +38 -0
- package/dist/cjs/composeEventHandlers.native.js +25 -36
- package/dist/cjs/composeEventHandlers.native.js.map +1 -1
- package/dist/cjs/index.cjs +12 -11
- package/dist/cjs/index.native.cjs +30 -0
- package/dist/cjs/index.native.js +12 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/reservedThemeProps.cjs +40 -0
- package/dist/cjs/reservedThemeProps.native.cjs +42 -0
- package/dist/cjs/reservedThemeProps.native.js +44 -0
- package/dist/cjs/reservedThemeProps.native.js.map +1 -0
- package/dist/cjs/shouldRenderNativePlatform.cjs +37 -37
- package/dist/cjs/shouldRenderNativePlatform.native.cjs +70 -0
- package/dist/cjs/shouldRenderNativePlatform.native.js +54 -59
- package/dist/cjs/shouldRenderNativePlatform.native.js.map +1 -1
- package/dist/cjs/themeClassNames.cjs +44 -0
- package/dist/cjs/themeClassNames.native.cjs +64 -0
- package/dist/cjs/themeClassNames.native.js +66 -0
- package/dist/cjs/themeClassNames.native.js.map +1 -0
- package/dist/cjs/toStylePropsObject.cjs +33 -0
- package/dist/cjs/toStylePropsObject.native.cjs +72 -0
- package/dist/cjs/toStylePropsObject.native.js +74 -0
- package/dist/cjs/toStylePropsObject.native.js.map +1 -0
- package/dist/cjs/tokenCategories.cjs +47 -0
- package/dist/cjs/tokenCategories.native.cjs +51 -0
- package/dist/cjs/tokenCategories.native.js +53 -0
- package/dist/cjs/tokenCategories.native.js.map +1 -0
- package/dist/cjs/types.cjs +18 -20
- package/dist/cjs/types.native.cjs +36 -0
- package/dist/cjs/types.native.js +18 -19
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/validStyleProps.cjs +44 -323
- package/dist/cjs/validStyleProps.native.cjs +60 -0
- package/dist/cjs/validStyleProps.native.js +45 -316
- package/dist/cjs/validStyleProps.native.js.map +1 -1
- package/dist/cjs/webOnlyStyleProps.cjs +21 -93
- package/dist/cjs/webOnlyStyleProps.native.cjs +35 -0
- package/dist/cjs/webOnlyStyleProps.native.js +22 -93
- package/dist/cjs/webOnlyStyleProps.native.js.map +1 -1
- package/dist/cjs/withStaticProperties.cjs +24 -30
- package/dist/cjs/withStaticProperties.native.cjs +37 -0
- package/dist/cjs/withStaticProperties.native.js +25 -30
- package/dist/cjs/withStaticProperties.native.js.map +1 -1
- package/dist/esm/clamp.mjs +2 -1
- package/dist/esm/clamp.mjs.map +1 -1
- package/dist/esm/clamp.native.js +3 -2
- package/dist/esm/clamp.native.js.map +1 -1
- package/dist/esm/composeEventHandlers.mjs +12 -14
- package/dist/esm/composeEventHandlers.mjs.map +1 -1
- package/dist/esm/composeEventHandlers.native.js +12 -19
- package/dist/esm/composeEventHandlers.native.js.map +1 -1
- package/dist/esm/index.js +21 -9
- package/dist/esm/index.mjs +21 -9
- package/dist/esm/index.native.js +21 -9
- package/dist/esm/reservedThemeProps.mjs +20 -0
- package/dist/esm/reservedThemeProps.mjs.map +1 -0
- package/dist/esm/reservedThemeProps.native.js +20 -0
- package/dist/esm/reservedThemeProps.native.js.map +1 -0
- package/dist/esm/shouldRenderNativePlatform.mjs +25 -19
- package/dist/esm/shouldRenderNativePlatform.mjs.map +1 -1
- package/dist/esm/shouldRenderNativePlatform.native.js +42 -42
- package/dist/esm/shouldRenderNativePlatform.native.js.map +1 -1
- package/dist/esm/themeClassNames.mjs +21 -0
- package/dist/esm/themeClassNames.mjs.map +1 -0
- package/dist/esm/themeClassNames.native.js +39 -0
- package/dist/esm/themeClassNames.native.js.map +1 -0
- package/dist/esm/toStylePropsObject.mjs +13 -0
- package/dist/esm/toStylePropsObject.mjs.map +1 -0
- package/dist/esm/toStylePropsObject.native.js +50 -0
- package/dist/esm/toStylePropsObject.native.js.map +1 -0
- package/dist/esm/tokenCategories.mjs +28 -0
- package/dist/esm/tokenCategories.mjs.map +1 -0
- package/dist/esm/tokenCategories.native.js +30 -0
- package/dist/esm/tokenCategories.native.js.map +1 -0
- package/dist/esm/types.mjs +1 -0
- package/dist/esm/types.mjs.map +1 -1
- package/dist/esm/types.native.js +1 -0
- package/dist/esm/types.native.js.map +1 -1
- package/dist/esm/validStyleProps.mjs +21 -297
- package/dist/esm/validStyleProps.mjs.map +1 -1
- package/dist/esm/validStyleProps.native.js +22 -291
- package/dist/esm/validStyleProps.native.js.map +1 -1
- package/dist/esm/webOnlyStyleProps.mjs +7 -75
- package/dist/esm/webOnlyStyleProps.mjs.map +1 -1
- package/dist/esm/webOnlyStyleProps.native.js +7 -75
- package/dist/esm/webOnlyStyleProps.native.js.map +1 -1
- package/dist/esm/withStaticProperties.mjs +11 -12
- package/dist/esm/withStaticProperties.mjs.map +1 -1
- package/dist/esm/withStaticProperties.native.js +12 -13
- package/dist/esm/withStaticProperties.native.js.map +1 -1
- package/package.json +16 -5
- package/src/composeEventHandlers.ts +6 -10
- package/src/index.ts +3 -0
- package/src/reservedThemeProps.ts +26 -0
- package/src/themeClassNames.ts +26 -0
- package/src/toStylePropsObject.ts +29 -0
- package/src/tokenCategories.ts +29 -0
- package/src/validStyleProps.ts +89 -349
- package/src/webOnlyStyleProps.ts +16 -80
- package/types/composeEventHandlers.d.ts.map +1 -1
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +1 -1
- package/types/reservedThemeProps.d.ts +11 -0
- package/types/reservedThemeProps.d.ts.map +1 -0
- package/types/themeClassNames.d.ts +3 -0
- package/types/themeClassNames.d.ts.map +1 -0
- package/types/toStylePropsObject.d.ts +6 -0
- package/types/toStylePropsObject.d.ts.map +1 -0
- package/types/tokenCategories.d.ts +4 -0
- package/types/tokenCategories.d.ts.map +1 -0
- package/types/validStyleProps.d.ts +1533 -1242
- package/types/validStyleProps.d.ts.map +1 -1
- package/types/webOnlyStyleProps.d.ts +106 -99
- package/types/webOnlyStyleProps.d.ts.map +1 -1
- package/types/withStaticProperties.d.ts.map +1 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"withStaticProperties.native.js","names":[],"sources":["esm/withStaticProperties.native.js"],"sourcesContent":["var Decorated = /* @__PURE__ */ Symbol();\nvar withStaticProperties = function(component, staticProps) {\n var out = (function() {\n if (component[Decorated]) {\n return typeof component === \"function\" ? Object.assign(component.bind(null), component) : {\n ...component\n };\n }\n return component;\n })();\n Object.assign(out, staticProps);\n out[Decorated] = true;\n return out;\n};\nexport {\n withStaticProperties\n};\n//# sourceMappingURL=withStaticProperties.js.map\n"],"mappings":";AAAA,IAAI,YAA4B,uBAAO;AACvC,IAAI,uBAAuB,SAAS,WAAW,aAAa;CAC1D,IAAI,OAAO,WAAW;EACpB,IAAI,UAAU,YAAY;GACxB,OAAO,OAAO,cAAc,aAAa,OAAO,OAAO,UAAU,KAAK,IAAI,GAAG,SAAS,IAAI,EACxF,GAAG,UACL;EACF;EACA,OAAO;CACT,EAAC,CAAE;CACH,OAAO,OAAO,KAAK,WAAW;CAC9B,IAAI,aAAa;CACjB,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/helpers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.1097.1",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
6
|
"source": "src/index.ts",
|
|
6
7
|
"files": [
|
|
@@ -15,6 +16,15 @@
|
|
|
15
16
|
"types": "./types/index.d.ts",
|
|
16
17
|
"exports": {
|
|
17
18
|
"./package.json": "./package.json",
|
|
19
|
+
"./tokenCategories": {
|
|
20
|
+
"types": "./types/tokenCategories.d.ts",
|
|
21
|
+
"react-native": "./dist/esm/tokenCategories.mjs",
|
|
22
|
+
"browser": "./dist/esm/tokenCategories.mjs",
|
|
23
|
+
"module": "./dist/esm/tokenCategories.mjs",
|
|
24
|
+
"import": "./dist/esm/tokenCategories.mjs",
|
|
25
|
+
"require": "./dist/cjs/tokenCategories.cjs",
|
|
26
|
+
"default": "./dist/esm/tokenCategories.mjs"
|
|
27
|
+
},
|
|
18
28
|
".": {
|
|
19
29
|
"types": "./types/index.d.ts",
|
|
20
30
|
"react-native": "./dist/esm/index.native.js",
|
|
@@ -35,12 +45,13 @@
|
|
|
35
45
|
"clean:build": "tamagui-build clean:build"
|
|
36
46
|
},
|
|
37
47
|
"dependencies": {
|
|
38
|
-
"@tamagui/constants": "
|
|
39
|
-
"@tamagui/simple-hash": "
|
|
48
|
+
"@tamagui/constants": "3.0.0-beta.1097.1",
|
|
49
|
+
"@tamagui/simple-hash": "3.0.0-beta.1097.1",
|
|
50
|
+
"@tamagui/style-grammar": "3.0.0-beta.1097.1"
|
|
40
51
|
},
|
|
41
52
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "
|
|
43
|
-
"react": "
|
|
53
|
+
"@tamagui/build": "3.0.0-beta.1097.1",
|
|
54
|
+
"react": "19.2.3"
|
|
44
55
|
},
|
|
45
56
|
"peerDependencies": {
|
|
46
57
|
"react": ">=19"
|
|
@@ -12,16 +12,12 @@ export function composeEventHandlers<E extends Events>(
|
|
|
12
12
|
}
|
|
13
13
|
return (event: E) => {
|
|
14
14
|
og?.(event)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
) ||
|
|
22
|
-
// @ts-ignore
|
|
23
|
-
('defaultPrevented' in event && !event.defaultPrevented)
|
|
24
|
-
) {
|
|
15
|
+
const isPrevented =
|
|
16
|
+
!!event &&
|
|
17
|
+
typeof event === 'object' &&
|
|
18
|
+
(('defaultPrevented' in event && Boolean(event.defaultPrevented)) ||
|
|
19
|
+
('isCanceled' in event && Boolean(event.isCanceled)))
|
|
20
|
+
if (!event || !checkDefaultPrevented || !isPrevented) {
|
|
25
21
|
return next?.(event)
|
|
26
22
|
}
|
|
27
23
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export * from '@tamagui/simple-hash'
|
|
2
2
|
export * from './clamp'
|
|
3
|
+
export * from './reservedThemeProps'
|
|
4
|
+
export * from './themeClassNames'
|
|
3
5
|
export * from './composeEventHandlers'
|
|
4
6
|
export * from './types'
|
|
5
7
|
export * from './shouldRenderNativePlatform'
|
|
8
|
+
export * from './tokenCategories'
|
|
6
9
|
export * from './validStyleProps'
|
|
7
10
|
export * from './withStaticProperties'
|
|
8
11
|
export * from './webOnlyStyleProps'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The props `<Theme>` owns. Inline theme values live on `<ThemeUpdate>`, so an
|
|
3
|
+
* unknown `<Theme>` prop is always invalid.
|
|
4
|
+
*
|
|
5
|
+
* It lives here, in a side-effect-free package, because the compiler classifies
|
|
6
|
+
* static `<Theme>` props with the same table the runtime uses. One table, so a
|
|
7
|
+
* new reserved prop can never mean one thing at build time and another at
|
|
8
|
+
* runtime.
|
|
9
|
+
*/
|
|
10
|
+
export const reservedThemeProps: Record<string, true> = {
|
|
11
|
+
_isRoot: true,
|
|
12
|
+
children: true,
|
|
13
|
+
className: true,
|
|
14
|
+
contain: true,
|
|
15
|
+
debug: true,
|
|
16
|
+
deopt: true,
|
|
17
|
+
disable: true,
|
|
18
|
+
'disable-child-theme': true,
|
|
19
|
+
forceClassName: true,
|
|
20
|
+
_themeUpdate: true,
|
|
21
|
+
name: true,
|
|
22
|
+
nativeUpdate: true,
|
|
23
|
+
needsUpdate: true,
|
|
24
|
+
passThrough: true,
|
|
25
|
+
shallow: true,
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// read a complete scheme segment so names such as "lightsaber" stay distinct.
|
|
2
|
+
const schemePrefix = /^(light|dark)(?=_|$)/
|
|
3
|
+
export function getThemeScheme(name: string): 'light' | 'dark' | undefined {
|
|
4
|
+
return schemePrefix.exec(name)?.[0] as 'light' | 'dark' | undefined
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// runtime and zero output share this hierarchy. inherited schemes follow the
|
|
8
|
+
// document class; only authored schemes emit the more specific full-name class.
|
|
9
|
+
export function getThemeClassNames(
|
|
10
|
+
name: string,
|
|
11
|
+
isRoot?: boolean,
|
|
12
|
+
schemeAuthored?: boolean
|
|
13
|
+
): string {
|
|
14
|
+
const scheme = getThemeScheme(name)
|
|
15
|
+
const relativeName = scheme ? name.slice(scheme.length + 1) : name
|
|
16
|
+
let classes = isRoot ? '' : 't_sub_theme'
|
|
17
|
+
if (relativeName) {
|
|
18
|
+
let prefix = 't'
|
|
19
|
+
for (const part of relativeName.split('_')) {
|
|
20
|
+
prefix += `_${part}`
|
|
21
|
+
classes += ` ${prefix}`
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (schemeAuthored && scheme) classes += ` t_${name}`
|
|
25
|
+
return classes
|
|
26
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type StylePropSource = string | Readonly<Record<string, boolean>> | undefined
|
|
2
|
+
type StylePropWords<Value extends string> =
|
|
3
|
+
Value extends `${infer A} ${infer B} ${infer C} ${infer D} ${infer E} ${infer F} ${infer G} ${infer H} ${infer Tail}`
|
|
4
|
+
? A | B | C | D | E | F | G | H | StylePropWords<Tail>
|
|
5
|
+
: Value extends `${infer Head} ${infer Tail}`
|
|
6
|
+
? Head | StylePropWords<Tail>
|
|
7
|
+
: Value
|
|
8
|
+
type StylePropKeys<Source> = Source extends string
|
|
9
|
+
? StylePropWords<Source>
|
|
10
|
+
: Source extends Readonly<Record<string, boolean>>
|
|
11
|
+
? keyof Source
|
|
12
|
+
: never
|
|
13
|
+
|
|
14
|
+
export const toStylePropsObject = <const Sources extends readonly StylePropSource[]>(
|
|
15
|
+
...sources: Sources
|
|
16
|
+
): { [Key in Exclude<Extract<StylePropKeys<Sources[number]>, string>, ''>]: true } => {
|
|
17
|
+
const out: Record<string, boolean> = {}
|
|
18
|
+
for (const source of sources) {
|
|
19
|
+
if (!source) continue
|
|
20
|
+
for (const key of typeof source === 'string'
|
|
21
|
+
? source.split(' ')
|
|
22
|
+
: Object.keys(source)) {
|
|
23
|
+
if (key) out[key] = true
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return out as {
|
|
27
|
+
[Key in Exclude<Extract<StylePropKeys<Sources[number]>, string>, ''>]: true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export * from '@tamagui/style-grammar/token-categories'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
propToTokenCategoryCode,
|
|
5
|
+
tokenCategoryNames,
|
|
6
|
+
} from '@tamagui/style-grammar/token-categories'
|
|
7
|
+
|
|
8
|
+
type TokenCategories = Record<
|
|
9
|
+
'radius' | 'size' | 'zIndex' | 'color',
|
|
10
|
+
Record<string, true>
|
|
11
|
+
>
|
|
12
|
+
|
|
13
|
+
// public compatibility view. each category materializes only when a caller reads it
|
|
14
|
+
export const tokenCategories = {} as TokenCategories
|
|
15
|
+
for (const category of ['radius', 'size', 'zIndex', 'color'] as const) {
|
|
16
|
+
let view: Record<string, true> | undefined
|
|
17
|
+
Object.defineProperty(tokenCategories, category, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get() {
|
|
20
|
+
if (view) return view
|
|
21
|
+
view = {}
|
|
22
|
+
const code = tokenCategoryNames.indexOf(category)
|
|
23
|
+
for (const property in propToTokenCategoryCode) {
|
|
24
|
+
if (propToTokenCategoryCode[property] === code) view[property] = true
|
|
25
|
+
}
|
|
26
|
+
return view
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
}
|
package/src/validStyleProps.ts
CHANGED
|
@@ -5,354 +5,94 @@ import {
|
|
|
5
5
|
webOnlyStylePropsText,
|
|
6
6
|
webOnlyStylePropsView,
|
|
7
7
|
} from './webOnlyStyleProps'
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
caretColor: true,
|
|
98
|
-
}),
|
|
99
|
-
},
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// discrete (non-animatable) view style properties - keyword-based, no interpolation
|
|
103
|
-
// defined above stylePropsView so it can be spread in without duplication
|
|
104
|
-
const nonAnimatableViewProps = {
|
|
105
|
-
alignContent: true,
|
|
106
|
-
alignItems: true,
|
|
107
|
-
alignSelf: true,
|
|
108
|
-
backfaceVisibility: true,
|
|
109
|
-
borderCurve: true,
|
|
110
|
-
borderStyle: true,
|
|
111
|
-
borderBlockStyle: true,
|
|
112
|
-
borderBlockEndStyle: true,
|
|
113
|
-
borderBlockStartStyle: true,
|
|
114
|
-
borderInlineStyle: true,
|
|
115
|
-
borderInlineEndStyle: true,
|
|
116
|
-
borderInlineStartStyle: true,
|
|
117
|
-
boxSizing: true,
|
|
118
|
-
cursor: true,
|
|
119
|
-
direction: true,
|
|
120
|
-
display: true,
|
|
121
|
-
flexDirection: true,
|
|
122
|
-
flexWrap: true,
|
|
123
|
-
isolation: true,
|
|
124
|
-
justifyContent: true,
|
|
125
|
-
mixBlendMode: true,
|
|
126
|
-
outlineStyle: true,
|
|
127
|
-
overflow: true,
|
|
128
|
-
position: true,
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// discrete (non-animatable) font properties
|
|
132
|
-
const nonAnimatableFontProps = {
|
|
133
|
-
fontFamily: true,
|
|
134
|
-
fontStyle: true,
|
|
135
|
-
fontVariant: true,
|
|
136
|
-
textTransform: true,
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// discrete (non-animatable) text-only properties
|
|
140
|
-
const nonAnimatableTextOnlyProps = {
|
|
141
|
-
textAlign: true,
|
|
142
|
-
textDecorationLine: true,
|
|
143
|
-
textDecorationStyle: true,
|
|
144
|
-
userSelect: true,
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// discrete (non-animatable) unitless properties
|
|
148
|
-
const nonAnimatableUnitlessProps = {
|
|
149
|
-
WebkitLineClamp: true,
|
|
150
|
-
lineClamp: true,
|
|
151
|
-
gridTemplateColumns: true,
|
|
152
|
-
gridTemplateAreas: true,
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// all non-animatable style props combined, used by getSplitStyles to keep
|
|
156
|
-
// these as atomic CSS classNames even for components with animation drivers
|
|
157
|
-
export const nonAnimatableStyleProps = {
|
|
158
|
-
...nonAnimatableViewProps,
|
|
159
|
-
...nonAnimatableFontProps,
|
|
160
|
-
...nonAnimatableTextOnlyProps,
|
|
161
|
-
...nonAnimatableUnitlessProps,
|
|
162
|
-
// web-only discrete properties (defined in webOnlyStyleProps.ts)
|
|
163
|
-
...(process.env.TAMAGUI_TARGET === 'web' && {
|
|
164
|
-
...nonAnimatableWebViewProps,
|
|
165
|
-
...nonAnimatableWebTextProps,
|
|
166
|
-
}),
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export const stylePropsUnitless = {
|
|
170
|
-
...nonAnimatableUnitlessProps,
|
|
171
|
-
animationIterationCount: true,
|
|
172
|
-
aspectRatio: true,
|
|
173
|
-
borderImageOutset: true,
|
|
174
|
-
borderImageSlice: true,
|
|
175
|
-
borderImageWidth: true,
|
|
176
|
-
columnCount: true,
|
|
177
|
-
flex: true,
|
|
178
|
-
flexGrow: true,
|
|
179
|
-
flexOrder: true,
|
|
180
|
-
flexPositive: true,
|
|
181
|
-
flexShrink: true,
|
|
182
|
-
flexNegative: true,
|
|
183
|
-
fontWeight: true,
|
|
184
|
-
gridRow: true,
|
|
185
|
-
gridRowEnd: true,
|
|
186
|
-
gridRowGap: true,
|
|
187
|
-
gridRowStart: true,
|
|
188
|
-
gridColumn: true,
|
|
189
|
-
gridColumnEnd: true,
|
|
190
|
-
gridColumnGap: true,
|
|
191
|
-
gridColumnStart: true,
|
|
192
|
-
opacity: true,
|
|
193
|
-
order: true,
|
|
194
|
-
orphans: true,
|
|
195
|
-
tabSize: true,
|
|
196
|
-
widows: true,
|
|
197
|
-
zIndex: true,
|
|
198
|
-
zoom: true,
|
|
199
|
-
scale: true,
|
|
200
|
-
scaleX: true,
|
|
201
|
-
scaleY: true,
|
|
202
|
-
scaleZ: true,
|
|
203
|
-
shadowOpacity: true,
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export const stylePropsTransform = {
|
|
207
|
-
x: true,
|
|
208
|
-
y: true,
|
|
209
|
-
scale: true,
|
|
210
|
-
perspective: true,
|
|
211
|
-
scaleX: true,
|
|
212
|
-
scaleY: true,
|
|
213
|
-
skewX: true,
|
|
214
|
-
skewY: true,
|
|
215
|
-
matrix: true,
|
|
216
|
-
rotate: true,
|
|
217
|
-
rotateY: true,
|
|
218
|
-
rotateX: true,
|
|
219
|
-
rotateZ: true,
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export const stylePropsView = {
|
|
223
|
-
...nonAnimatableViewProps,
|
|
224
|
-
borderBottomEndRadius: true,
|
|
225
|
-
borderBottomStartRadius: true,
|
|
226
|
-
borderBottomWidth: true,
|
|
227
|
-
borderLeftWidth: true,
|
|
228
|
-
borderRightWidth: true,
|
|
229
|
-
borderBlockWidth: true,
|
|
230
|
-
borderBlockEndWidth: true,
|
|
231
|
-
borderBlockStartWidth: true,
|
|
232
|
-
borderInlineWidth: true,
|
|
233
|
-
borderInlineEndWidth: true,
|
|
234
|
-
borderInlineStartWidth: true,
|
|
235
|
-
borderTopEndRadius: true,
|
|
236
|
-
borderTopStartRadius: true,
|
|
237
|
-
borderTopWidth: true,
|
|
238
|
-
borderWidth: true,
|
|
239
|
-
transform: true,
|
|
240
|
-
transformOrigin: true,
|
|
241
|
-
borderEndWidth: true,
|
|
242
|
-
borderStartWidth: true,
|
|
243
|
-
bottom: true,
|
|
244
|
-
end: true,
|
|
245
|
-
flexBasis: true,
|
|
246
|
-
gap: true,
|
|
247
|
-
columnGap: true,
|
|
248
|
-
rowGap: true,
|
|
249
|
-
left: true,
|
|
250
|
-
margin: true,
|
|
251
|
-
marginBlock: true,
|
|
252
|
-
marginBlockEnd: true,
|
|
253
|
-
marginBlockStart: true,
|
|
254
|
-
marginInline: true,
|
|
255
|
-
marginInlineStart: true,
|
|
256
|
-
marginInlineEnd: true,
|
|
257
|
-
marginBottom: true,
|
|
258
|
-
marginEnd: true,
|
|
259
|
-
marginHorizontal: true,
|
|
260
|
-
marginLeft: true,
|
|
261
|
-
marginRight: true,
|
|
262
|
-
marginStart: true,
|
|
263
|
-
marginTop: true,
|
|
264
|
-
marginVertical: true,
|
|
265
|
-
padding: true,
|
|
266
|
-
paddingBottom: true,
|
|
267
|
-
paddingInline: true,
|
|
268
|
-
paddingBlock: true,
|
|
269
|
-
paddingBlockStart: true,
|
|
270
|
-
paddingInlineEnd: true,
|
|
271
|
-
paddingInlineStart: true,
|
|
272
|
-
paddingEnd: true,
|
|
273
|
-
paddingHorizontal: true,
|
|
274
|
-
paddingLeft: true,
|
|
275
|
-
paddingRight: true,
|
|
276
|
-
paddingStart: true,
|
|
277
|
-
paddingTop: true,
|
|
278
|
-
paddingVertical: true,
|
|
279
|
-
right: true,
|
|
280
|
-
start: true,
|
|
281
|
-
top: true,
|
|
282
|
-
inset: true,
|
|
283
|
-
insetBlock: true,
|
|
284
|
-
insetBlockEnd: true,
|
|
285
|
-
insetBlockStart: true,
|
|
286
|
-
insetInline: true,
|
|
287
|
-
insetInlineEnd: true,
|
|
288
|
-
insetInlineStart: true,
|
|
289
|
-
shadowOffset: true,
|
|
290
|
-
shadowRadius: true,
|
|
291
|
-
...tokenCategories.color,
|
|
292
|
-
...tokenCategories.radius,
|
|
293
|
-
...tokenCategories.size,
|
|
294
|
-
...stylePropsTransform,
|
|
295
|
-
...stylePropsUnitless,
|
|
296
|
-
...(isAndroid ? { elevationAndroid: true } : {}),
|
|
297
|
-
|
|
298
|
-
boxShadow: true,
|
|
299
|
-
border: true,
|
|
300
|
-
filter: true,
|
|
301
|
-
// RN 0.76+ supports linear-gradient via backgroundImage
|
|
302
|
-
backgroundImage: true,
|
|
303
|
-
// the actual RN 0.76+ prop name (backgroundImage expands to this on native)
|
|
304
|
-
experimental_backgroundImage: true,
|
|
305
|
-
// RN 0.76/0.77+ style props (New Architecture)
|
|
306
|
-
outline: true,
|
|
307
|
-
outlineColor: true,
|
|
308
|
-
outlineOffset: true,
|
|
309
|
-
outlineWidth: true,
|
|
310
|
-
|
|
311
|
-
// web-only for convenience - tree-shaken on native
|
|
312
|
-
...(process.env.TAMAGUI_TARGET === 'web' ? webOnlyStylePropsView : {}),
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
const stylePropsFont = {
|
|
316
|
-
...nonAnimatableFontProps,
|
|
317
|
-
fontSize: true,
|
|
318
|
-
fontWeight: true,
|
|
319
|
-
letterSpacing: true,
|
|
320
|
-
lineHeight: true,
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
export const stylePropsTextOnly = {
|
|
324
|
-
...stylePropsFont,
|
|
325
|
-
...nonAnimatableTextOnlyProps,
|
|
326
|
-
...textColors,
|
|
327
|
-
textShadow: true,
|
|
328
|
-
textShadowOffset: true,
|
|
329
|
-
textShadowRadius: true,
|
|
330
|
-
verticalAlign: true,
|
|
331
|
-
|
|
332
|
-
// web-only text props - tree-shaken on native
|
|
333
|
-
...(process.env.TAMAGUI_TARGET === 'web' ? webOnlyStylePropsText : {}),
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
export const stylePropsText = {
|
|
337
|
-
...stylePropsView,
|
|
338
|
-
...stylePropsTextOnly,
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
export const stylePropsAll = stylePropsText
|
|
342
|
-
|
|
343
|
-
export const validPseudoKeys = {
|
|
344
|
-
enterStyle: true,
|
|
345
|
-
exitStyle: true,
|
|
346
|
-
hoverStyle: true,
|
|
347
|
-
pressStyle: true,
|
|
348
|
-
focusStyle: true,
|
|
349
|
-
disabledStyle: true,
|
|
350
|
-
focusWithinStyle: true,
|
|
351
|
-
|
|
352
|
-
// allow some web only ones
|
|
353
|
-
...(process.env.TAMAGUI_TARGET === 'web' && {
|
|
354
|
-
focusVisibleStyle: true,
|
|
355
|
-
}),
|
|
356
|
-
}
|
|
8
|
+
import { toStylePropsObject as toObj } from './toStylePropsObject'
|
|
9
|
+
export { tokenCategories } from './tokenCategories'
|
|
10
|
+
|
|
11
|
+
export const cssShorthandLonghands = toObj(
|
|
12
|
+
'borderWidth borderStyle borderColor borderTopWidth borderTopStyle borderTopColor borderRightWidth borderRightStyle borderRightColor borderBottomWidth borderBottomStyle borderBottomColor borderLeftWidth borderLeftStyle borderLeftColor outlineWidth outlineStyle outlineColor outlineOffset'
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
const textColors = toObj('color textDecorationColor textShadowColor')
|
|
16
|
+
|
|
17
|
+
const inputColors = toObj(
|
|
18
|
+
'placeholderTextColor selectionColor cursorColor selectionHandleColor'
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
const nonAnimatableViewProps = toObj(
|
|
22
|
+
'alignContent alignItems alignSelf backfaceVisibility borderCurve borderStyle borderBlockStyle borderBlockEndStyle borderBlockStartStyle borderInlineStyle borderInlineEndStyle borderInlineStartStyle boxSizing cursor direction display flexDirection flexWrap isolation justifyContent mixBlendMode outlineStyle overflow pointerEvents position visibility'
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const nonAnimatableFontProps = toObj('fontFamily fontStyle fontVariant textTransform')
|
|
26
|
+
|
|
27
|
+
const nonAnimatableTextOnlyProps = toObj(
|
|
28
|
+
'textAlign textDecorationLine textDecorationStyle userSelect writingDirection'
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
const nonAnimatableUnitlessProps = toObj('WebkitLineClamp lineClamp')
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* CSS Grid layout props. Web-only by default — Yoga (React Native's layout
|
|
35
|
+
* engine) has no stable CSS Grid support (see facebook/yoga#1865).
|
|
36
|
+
*
|
|
37
|
+
* To enable on native with an experimental Yoga build, set the
|
|
38
|
+
* `TAMAGUI_CSS_GRID` environment variable to `"1"`.
|
|
39
|
+
*/
|
|
40
|
+
const cssGridProps = toObj(
|
|
41
|
+
'gridTemplateColumns gridTemplateAreas gridRow gridRowEnd gridRowGap gridRowStart gridColumn gridColumnEnd gridColumnGap gridColumnStart'
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
const enableCSSGrid =
|
|
45
|
+
process.env.TAMAGUI_TARGET === 'web' || process.env.TAMAGUI_CSS_GRID === '1'
|
|
46
|
+
|
|
47
|
+
export const nonAnimatableStyleProps = toObj(
|
|
48
|
+
nonAnimatableViewProps,
|
|
49
|
+
nonAnimatableFontProps,
|
|
50
|
+
nonAnimatableTextOnlyProps,
|
|
51
|
+
nonAnimatableUnitlessProps,
|
|
52
|
+
enableCSSGrid ? cssGridProps : undefined,
|
|
53
|
+
process.env.TAMAGUI_TARGET === 'web' ? nonAnimatableWebViewProps : undefined,
|
|
54
|
+
process.env.TAMAGUI_TARGET === 'web' ? nonAnimatableWebTextProps : undefined
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
export const stylePropsUnitless = toObj(
|
|
58
|
+
nonAnimatableUnitlessProps,
|
|
59
|
+
enableCSSGrid ? cssGridProps : undefined,
|
|
60
|
+
'animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth columnCount flex flexGrow flexOrder flexPositive flexShrink flexNegative fontWeight opacity order orphans tabSize widows zIndex zoom scale scaleX scaleY scaleZ shadowOpacity'
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
export const stylePropsTransform = toObj(
|
|
64
|
+
'x y scale perspective scaleX scaleY skewX skewY matrix rotate rotateY rotateX rotateZ'
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
export const stylePropsView = toObj(
|
|
68
|
+
nonAnimatableViewProps,
|
|
69
|
+
'borderBottomWidth borderLeftWidth borderRightWidth borderBlockWidth borderBlockEndWidth borderBlockStartWidth borderInlineWidth borderInlineEndWidth borderInlineStartWidth borderTopWidth borderWidth transform transformOrigin borderEndWidth borderStartWidth bottom end flexBasis gap columnGap rowGap left margin marginBlock marginBlockEnd marginBlockStart marginInline marginInlineStart marginInlineEnd marginBottom marginEnd marginHorizontal marginLeft marginRight marginStart marginTop marginVertical padding paddingBottom paddingInline paddingBlock paddingBlockEnd paddingBlockStart paddingInlineEnd paddingInlineStart paddingEnd paddingHorizontal paddingLeft paddingRight paddingStart paddingTop paddingVertical right start top inset insetBlock insetBlockEnd insetBlockStart insetInline insetInlineEnd insetInlineStart shadowOffset backgroundColor borderColor borderBlockStartColor borderBlockEndColor borderBlockColor borderBottomColor borderInlineColor borderInlineStartColor borderInlineEndColor borderTopColor borderLeftColor borderRightColor borderEndColor borderStartColor shadowColor outlineColor',
|
|
70
|
+
process.env.TAMAGUI_TARGET === 'web' ? 'caretColor' : undefined,
|
|
71
|
+
'borderRadius borderTopLeftRadius borderTopRightRadius borderBottomLeftRadius borderBottomRightRadius borderTopStartRadius borderTopEndRadius borderBottomStartRadius borderBottomEndRadius borderStartStartRadius borderStartEndRadius borderEndStartRadius borderEndEndRadius width height minWidth minHeight maxWidth maxHeight blockSize minBlockSize maxBlockSize inlineSize minInlineSize maxInlineSize shadowRadius',
|
|
72
|
+
stylePropsTransform,
|
|
73
|
+
stylePropsUnitless,
|
|
74
|
+
isAndroid ? { elevationAndroid: true } : undefined,
|
|
75
|
+
'boxShadow border borderBlock borderInline filter background backgroundImage experimental_backgroundImage outline outlineOffset outlineWidth',
|
|
76
|
+
process.env.TAMAGUI_TARGET === 'web' ? webOnlyStylePropsView : undefined
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
const stylePropsFont = toObj(
|
|
80
|
+
nonAnimatableFontProps,
|
|
81
|
+
'fontSize fontWeight letterSpacing lineHeight'
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
export const stylePropsTextOnly = toObj(
|
|
85
|
+
stylePropsFont,
|
|
86
|
+
nonAnimatableTextOnlyProps,
|
|
87
|
+
textColors,
|
|
88
|
+
'textShadow textShadowOffset textShadowRadius textDecoration font verticalAlign',
|
|
89
|
+
process.env.TAMAGUI_TARGET === 'web' ? webOnlyStylePropsText : undefined
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
export const stylePropsText = toObj(stylePropsView, stylePropsTextOnly)
|
|
93
|
+
|
|
94
|
+
export const stylePropsInput = toObj(stylePropsText, inputColors)
|
|
95
|
+
|
|
96
|
+
export const stylePropsAll = stylePropsInput
|
|
357
97
|
|
|
358
98
|
export const validStyles = stylePropsView
|