@tamagui/web 1.130.2 → 1.130.4
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.cjs +8 -6
- package/dist/cjs/createComponent.js +6 -6
- package/dist/cjs/createComponent.js.map +1 -1
- package/dist/cjs/createComponent.native.js +4 -4
- package/dist/cjs/createComponent.native.js.map +2 -2
- package/dist/cjs/views/Theme.cjs +44 -35
- package/dist/cjs/views/Theme.js +16 -12
- package/dist/cjs/views/Theme.js.map +1 -1
- package/dist/cjs/views/Theme.native.js +22 -14
- package/dist/cjs/views/Theme.native.js.map +2 -2
- package/dist/esm/createComponent.js +6 -6
- package/dist/esm/createComponent.js.map +1 -1
- package/dist/esm/createComponent.mjs +8 -6
- package/dist/esm/createComponent.mjs.map +1 -1
- package/dist/esm/createComponent.native.js +4 -4
- package/dist/esm/createComponent.native.js.map +1 -1
- package/dist/esm/views/Theme.js +16 -12
- package/dist/esm/views/Theme.js.map +1 -1
- package/dist/esm/views/Theme.mjs +44 -35
- package/dist/esm/views/Theme.mjs.map +1 -1
- package/dist/esm/views/Theme.native.js +46 -37
- package/dist/esm/views/Theme.native.js.map +1 -1
- package/package.json +12 -12
- package/src/createComponent.tsx +8 -8
- package/src/views/Theme.tsx +29 -22
- package/types/views/Theme.d.ts +7 -1
- package/types/views/Theme.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/web",
|
|
3
|
-
"version": "1.130.
|
|
3
|
+
"version": "1.130.4",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -27,16 +27,16 @@
|
|
|
27
27
|
"reset.css"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tamagui/compose-refs": "1.130.
|
|
31
|
-
"@tamagui/constants": "1.130.
|
|
32
|
-
"@tamagui/helpers": "1.130.
|
|
33
|
-
"@tamagui/is-equal-shallow": "1.130.
|
|
34
|
-
"@tamagui/normalize-css-color": "1.130.
|
|
35
|
-
"@tamagui/timer": "1.130.
|
|
36
|
-
"@tamagui/types": "1.130.
|
|
37
|
-
"@tamagui/use-did-finish-ssr": "1.130.
|
|
38
|
-
"@tamagui/use-event": "1.130.
|
|
39
|
-
"@tamagui/use-force-update": "1.130.
|
|
30
|
+
"@tamagui/compose-refs": "1.130.4",
|
|
31
|
+
"@tamagui/constants": "1.130.4",
|
|
32
|
+
"@tamagui/helpers": "1.130.4",
|
|
33
|
+
"@tamagui/is-equal-shallow": "1.130.4",
|
|
34
|
+
"@tamagui/normalize-css-color": "1.130.4",
|
|
35
|
+
"@tamagui/timer": "1.130.4",
|
|
36
|
+
"@tamagui/types": "1.130.4",
|
|
37
|
+
"@tamagui/use-did-finish-ssr": "1.130.4",
|
|
38
|
+
"@tamagui/use-event": "1.130.4",
|
|
39
|
+
"@tamagui/use-force-update": "1.130.4"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": "*",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"react-native": "*"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@tamagui/build": "1.130.
|
|
47
|
+
"@tamagui/build": "1.130.4",
|
|
48
48
|
"@testing-library/react": "^16.1.0",
|
|
49
49
|
"csstype": "^3.0.10",
|
|
50
50
|
"react": "*",
|
package/src/createComponent.tsx
CHANGED
|
@@ -1268,17 +1268,10 @@ export function createComponent<
|
|
|
1268
1268
|
|
|
1269
1269
|
if (process.env.NODE_ENV === 'development' && time) time`spaced-as-child`
|
|
1270
1270
|
|
|
1271
|
-
let useChildrenResult: any
|
|
1272
|
-
if (hooks.useChildren) {
|
|
1273
|
-
useChildrenResult = hooks.useChildren(elementType, content, viewProps)
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
if (process.env.NODE_ENV === 'development' && time) time`use-children`
|
|
1277
|
-
|
|
1278
1271
|
// passthrough mode - only pass style display contents, nothing else
|
|
1279
1272
|
if (!splitStyles) {
|
|
1280
|
-
elementType = 'span'
|
|
1281
1273
|
content = propsIn.children
|
|
1274
|
+
elementType = BaseViewComponent
|
|
1282
1275
|
viewProps = {
|
|
1283
1276
|
style: {
|
|
1284
1277
|
display: 'contents',
|
|
@@ -1286,6 +1279,13 @@ export function createComponent<
|
|
|
1286
1279
|
}
|
|
1287
1280
|
}
|
|
1288
1281
|
|
|
1282
|
+
let useChildrenResult: any
|
|
1283
|
+
if (hooks.useChildren) {
|
|
1284
|
+
useChildrenResult = hooks.useChildren(elementType, content, viewProps)
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
if (process.env.NODE_ENV === 'development' && time) time`use-children`
|
|
1288
|
+
|
|
1289
1289
|
if (useChildrenResult) {
|
|
1290
1290
|
content = useChildrenResult
|
|
1291
1291
|
} else {
|
package/src/views/Theme.tsx
CHANGED
|
@@ -13,12 +13,9 @@ import {
|
|
|
13
13
|
import type { ThemeProps } from '../types'
|
|
14
14
|
import { ThemeDebug } from './ThemeDebug'
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
type ThemeComponentPropsOnly = ThemeProps & { passThrough?: boolean; contain?: boolean }
|
|
17
17
|
|
|
18
|
-
export const Theme = forwardRef(function Theme(
|
|
19
|
-
props: ThemeProps & { passThrough?: boolean },
|
|
20
|
-
ref
|
|
21
|
-
) {
|
|
18
|
+
export const Theme = forwardRef(function Theme(props: ThemeComponentPropsOnly, ref) {
|
|
22
19
|
// @ts-expect-error only for internal views
|
|
23
20
|
if (props.disable) {
|
|
24
21
|
return props.children
|
|
@@ -67,7 +64,7 @@ Theme['avoidForwardRef'] = true
|
|
|
67
64
|
export function getThemedChildren(
|
|
68
65
|
themeState: ThemeState,
|
|
69
66
|
children: any,
|
|
70
|
-
props:
|
|
67
|
+
props: ThemeComponentPropsOnly,
|
|
71
68
|
isRoot = false,
|
|
72
69
|
stateRef: MutableRefObject<{ hasEverThemed?: boolean | 'wrapped' }>,
|
|
73
70
|
passThrough = false
|
|
@@ -147,7 +144,7 @@ export function getThemedChildren(
|
|
|
147
144
|
forceClassName,
|
|
148
145
|
themeState,
|
|
149
146
|
state,
|
|
150
|
-
|
|
147
|
+
themeSpanProps: getThemeClassNameAndColor(themeState, props, isRoot),
|
|
151
148
|
})
|
|
152
149
|
}
|
|
153
150
|
}
|
|
@@ -157,14 +154,15 @@ export function getThemedChildren(
|
|
|
157
154
|
}
|
|
158
155
|
|
|
159
156
|
if (isWeb) {
|
|
160
|
-
const
|
|
157
|
+
const baseStyle = props.contain ? inertContainedStyle : inertStyle
|
|
158
|
+
const { className = '', color } = passThrough
|
|
161
159
|
? {}
|
|
162
|
-
:
|
|
160
|
+
: getThemeClassNameAndColor(themeState, props, isRoot)
|
|
163
161
|
|
|
164
162
|
children = (
|
|
165
163
|
<span
|
|
166
|
-
className={`${className}
|
|
167
|
-
style={passThrough ?
|
|
164
|
+
className={`${className} is_Theme`}
|
|
165
|
+
style={passThrough ? baseStyle : { color, ...baseStyle }}
|
|
168
166
|
>
|
|
169
167
|
{children}
|
|
170
168
|
</span>
|
|
@@ -183,9 +181,13 @@ export function getThemedChildren(
|
|
|
183
181
|
? 't_dark is_inversed'
|
|
184
182
|
: ''
|
|
185
183
|
: ''
|
|
186
|
-
}
|
|
187
|
-
:
|
|
188
|
-
children =
|
|
184
|
+
} `
|
|
185
|
+
: ``
|
|
186
|
+
children = (
|
|
187
|
+
<span style={baseStyle} className={className}>
|
|
188
|
+
{children}
|
|
189
|
+
</span>
|
|
190
|
+
)
|
|
189
191
|
}
|
|
190
192
|
|
|
191
193
|
return children
|
|
@@ -194,7 +196,18 @@ export function getThemedChildren(
|
|
|
194
196
|
return children
|
|
195
197
|
}
|
|
196
198
|
|
|
197
|
-
|
|
199
|
+
const inertStyle = {
|
|
200
|
+
display: 'contents',
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const inertContainedStyle = {
|
|
204
|
+
display: 'contents',
|
|
205
|
+
contain: 'strict',
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const empty = { className: '', color: undefined }
|
|
209
|
+
|
|
210
|
+
function getThemeClassNameAndColor(
|
|
198
211
|
themeState: ThemeState,
|
|
199
212
|
props: ThemeProps,
|
|
200
213
|
isRoot = false
|
|
@@ -207,12 +220,6 @@ function getThemeClassNameAndStyle(
|
|
|
207
220
|
const themeColor =
|
|
208
221
|
themeState?.theme && themeState.isNew ? variableToString(themeState.theme.color) : ''
|
|
209
222
|
|
|
210
|
-
const style = themeColor
|
|
211
|
-
? {
|
|
212
|
-
color: themeColor,
|
|
213
|
-
}
|
|
214
|
-
: undefined
|
|
215
|
-
|
|
216
223
|
const maxInverses = getSetting('maxDarkLightNesting') || 3
|
|
217
224
|
const themeClassName =
|
|
218
225
|
themeState.inverses >= maxInverses
|
|
@@ -221,7 +228,7 @@ function getThemeClassNameAndStyle(
|
|
|
221
228
|
|
|
222
229
|
const className = `${isRoot ? '' : 't_sub_theme'} t_${themeClassName}`
|
|
223
230
|
|
|
224
|
-
return {
|
|
231
|
+
return { color: themeColor, className }
|
|
225
232
|
}
|
|
226
233
|
|
|
227
234
|
const schemePrefix = /^(dark|light)_/
|
package/types/views/Theme.d.ts
CHANGED
|
@@ -2,10 +2,16 @@ import type { MutableRefObject } from 'react';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { type ThemeState } from '../hooks/useThemeState';
|
|
4
4
|
import type { ThemeProps } from '../types';
|
|
5
|
+
type ThemeComponentPropsOnly = ThemeProps & {
|
|
6
|
+
passThrough?: boolean;
|
|
7
|
+
contain?: boolean;
|
|
8
|
+
};
|
|
5
9
|
export declare const Theme: React.ForwardRefExoticComponent<ThemeProps & {
|
|
6
10
|
passThrough?: boolean;
|
|
11
|
+
contain?: boolean;
|
|
7
12
|
} & React.RefAttributes<unknown>>;
|
|
8
|
-
export declare function getThemedChildren(themeState: ThemeState, children: any, props:
|
|
13
|
+
export declare function getThemedChildren(themeState: ThemeState, children: any, props: ThemeComponentPropsOnly, isRoot: boolean | undefined, stateRef: MutableRefObject<{
|
|
9
14
|
hasEverThemed?: boolean | 'wrapped';
|
|
10
15
|
}>, passThrough?: boolean): any;
|
|
16
|
+
export {};
|
|
11
17
|
//# sourceMappingURL=Theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Theme.d.ts","sourceRoot":"","sources":["../../src/views/Theme.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAC7C,OAAO,KAAqE,MAAM,OAAO,CAAA;AAIzF,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"Theme.d.ts","sourceRoot":"","sources":["../../src/views/Theme.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAC7C,OAAO,KAAqE,MAAM,OAAO,CAAA;AAIzF,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAG1C,KAAK,uBAAuB,GAAG,UAAU,GAAG;IAAE,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAExF,eAAO,MAAM,KAAK;kBAF0C,OAAO;cAAY,OAAO;iCA4CpF,CAAA;AAIF,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,GAAG,EACb,KAAK,EAAE,uBAAuB,EAC9B,MAAM,qBAAQ,EACd,QAAQ,EAAE,gBAAgB,CAAC;IAAE,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAAE,CAAC,EACnE,WAAW,UAAQ,OA+HpB"}
|