@tamagui/web 3.0.0-beta.807.1 → 3.0.0-beta.831.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/config.cjs +1 -1
- package/dist/cjs/config.native.cjs +1 -1
- package/dist/cjs/config.native.js +1 -1
- package/dist/cjs/config.native.js.map +1 -1
- package/dist/cjs/createComponent.cjs +28 -18
- package/dist/cjs/createComponent.native.cjs +30 -20
- package/dist/cjs/createComponent.native.js +30 -20
- package/dist/cjs/createComponent.native.js.map +1 -1
- package/dist/cjs/createStyledHOC.cjs +54 -4
- package/dist/cjs/createStyledHOC.native.cjs +55 -4
- package/dist/cjs/createStyledHOC.native.js +55 -4
- package/dist/cjs/createStyledHOC.native.js.map +1 -1
- package/dist/cjs/createTokens.cjs +1 -1
- package/dist/cjs/createTokens.native.cjs +1 -1
- package/dist/cjs/createTokens.native.js +1 -1
- package/dist/cjs/createTokens.native.js.map +1 -1
- package/dist/cjs/dom/html.cjs +147 -99
- package/dist/cjs/dom/htmlRuntime.native.cjs +6 -2
- package/dist/cjs/dom/htmlRuntime.native.js +6 -2
- package/dist/cjs/dom/htmlRuntime.native.js.map +1 -1
- package/dist/cjs/dom/primitives.native.cjs +16 -13
- package/dist/cjs/dom/primitives.native.js +16 -13
- package/dist/cjs/dom/primitives.native.js.map +1 -1
- package/dist/cjs/helpers/componentDisplayName.cjs +1 -11
- package/dist/cjs/helpers/componentDisplayName.native.cjs +1 -11
- package/dist/cjs/helpers/componentDisplayName.native.js +1 -11
- package/dist/cjs/helpers/componentDisplayName.native.js.map +1 -1
- package/dist/cjs/helpers/directStyleCSS.cjs +101 -104
- package/dist/cjs/helpers/formatDiagnostic.cjs +2 -4
- package/dist/cjs/helpers/formatDiagnostic.native.cjs +2 -4
- package/dist/cjs/helpers/formatDiagnostic.native.js +2 -4
- package/dist/cjs/helpers/formatDiagnostic.native.js.map +1 -1
- package/dist/cjs/helpers/getCSSStylesAtomic.cjs +10 -10
- package/dist/cjs/helpers/getSplitStyles.cjs +168 -600
- package/dist/cjs/helpers/getSplitStyles.native.cjs +168 -762
- package/dist/cjs/helpers/getSplitStyles.native.js +168 -762
- package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/cjs/helpers/splitStyleProps.cjs +46 -0
- package/dist/cjs/helpers/splitStyleProps.native.cjs +49 -0
- package/dist/cjs/helpers/splitStyleProps.native.js +51 -0
- package/dist/cjs/helpers/splitStyleProps.native.js.map +1 -0
- package/dist/cjs/helpers/styleStaticConfig.cjs +76 -0
- package/dist/cjs/helpers/styleStaticConfig.native.cjs +79 -0
- package/dist/cjs/helpers/styleStaticConfig.native.js +81 -0
- package/dist/cjs/helpers/styleStaticConfig.native.js.map +1 -0
- package/dist/cjs/helpers/tokenCategories.cjs +32 -71
- package/dist/cjs/helpers/tokenCategories.native.cjs +34 -73
- package/dist/cjs/helpers/tokenCategories.native.js +34 -73
- package/dist/cjs/helpers/tokenCategories.native.js.map +1 -1
- package/dist/cjs/helpers/variantResolvers.cjs +87 -0
- package/dist/cjs/helpers/variantResolvers.native.cjs +140 -0
- package/dist/cjs/helpers/variantResolvers.native.js +142 -0
- package/dist/cjs/helpers/variantResolvers.native.js.map +1 -0
- package/dist/cjs/hooks/useSplitStyles.cjs +2 -2
- package/dist/cjs/hooks/useSplitStyles.native.cjs +2 -2
- package/dist/cjs/hooks/useSplitStyles.native.js +2 -2
- package/dist/cjs/hooks/useSplitStyles.native.js.map +1 -1
- package/dist/cjs/index.cjs +3 -9
- package/dist/cjs/index.native.cjs +3 -9
- package/dist/cjs/index.native.js +3 -9
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/internal-runtime.cjs +8 -7
- package/dist/cjs/internal-runtime.native.cjs +8 -7
- package/dist/cjs/internal-runtime.native.js +8 -7
- package/dist/cjs/internal-runtime.native.js.map +1 -1
- package/dist/cjs/static-resolve.cjs +6 -5
- package/dist/cjs/static-resolve.native.cjs +6 -5
- package/dist/cjs/static-resolve.native.js +6 -5
- package/dist/cjs/static-resolve.native.js.map +1 -1
- package/dist/cjs/styled.cjs +4 -56
- package/dist/cjs/styled.native.cjs +4 -58
- package/dist/cjs/styled.native.js +4 -58
- package/dist/cjs/styled.native.js.map +1 -1
- package/dist/cjs/types.cjs +1 -21
- package/dist/cjs/types.native.cjs +1 -21
- package/dist/cjs/types.native.js +1 -21
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/views/Text.cjs +4 -2
- package/dist/cjs/views/Text.native.cjs +4 -2
- package/dist/cjs/views/Text.native.js +4 -2
- package/dist/cjs/views/Text.native.js.map +1 -1
- package/dist/cjs/views/View.cjs +4 -2
- package/dist/cjs/views/View.native.cjs +4 -2
- package/dist/cjs/views/View.native.js +4 -2
- package/dist/cjs/views/View.native.js.map +1 -1
- package/dist/esm/config.mjs +1 -1
- package/dist/esm/config.mjs.map +1 -1
- package/dist/esm/config.native.js +1 -1
- package/dist/esm/config.native.js.map +1 -1
- package/dist/esm/createComponent.mjs +29 -19
- package/dist/esm/createComponent.mjs.map +1 -1
- package/dist/esm/createComponent.native.js +31 -21
- package/dist/esm/createComponent.native.js.map +1 -1
- package/dist/esm/createStyledHOC.mjs +55 -5
- package/dist/esm/createStyledHOC.mjs.map +1 -1
- package/dist/esm/createStyledHOC.native.js +56 -5
- package/dist/esm/createStyledHOC.native.js.map +1 -1
- package/dist/esm/createTokens.mjs +1 -1
- package/dist/esm/createTokens.mjs.map +1 -1
- package/dist/esm/createTokens.native.js +1 -1
- package/dist/esm/createTokens.native.js.map +1 -1
- package/dist/esm/dom/html.mjs +147 -99
- package/dist/esm/dom/html.mjs.map +1 -1
- package/dist/esm/dom/htmlRuntime.native.js +7 -3
- package/dist/esm/dom/htmlRuntime.native.js.map +1 -1
- package/dist/esm/dom/primitives.native.js +16 -13
- package/dist/esm/dom/primitives.native.js.map +1 -1
- package/dist/esm/helpers/componentDisplayName.mjs +1 -8
- package/dist/esm/helpers/componentDisplayName.mjs.map +1 -1
- package/dist/esm/helpers/componentDisplayName.native.js +1 -8
- package/dist/esm/helpers/componentDisplayName.native.js.map +1 -1
- package/dist/esm/helpers/directStyleCSS.mjs +101 -104
- package/dist/esm/helpers/directStyleCSS.mjs.map +1 -1
- package/dist/esm/helpers/formatDiagnostic.mjs +2 -4
- package/dist/esm/helpers/formatDiagnostic.mjs.map +1 -1
- package/dist/esm/helpers/formatDiagnostic.native.js +2 -4
- package/dist/esm/helpers/formatDiagnostic.native.js.map +1 -1
- package/dist/esm/helpers/getCSSStylesAtomic.mjs +10 -10
- package/dist/esm/helpers/getCSSStylesAtomic.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs +166 -594
- package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.native.js +166 -757
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/helpers/splitStyleProps.mjs +27 -0
- package/dist/esm/helpers/splitStyleProps.mjs.map +1 -0
- package/dist/esm/helpers/splitStyleProps.native.js +28 -0
- package/dist/esm/helpers/splitStyleProps.native.js.map +1 -0
- package/dist/esm/helpers/styleStaticConfig.mjs +57 -0
- package/dist/esm/helpers/styleStaticConfig.mjs.map +1 -0
- package/dist/esm/helpers/styleStaticConfig.native.js +58 -0
- package/dist/esm/helpers/styleStaticConfig.native.js.map +1 -0
- package/dist/esm/helpers/tokenCategories.mjs +33 -72
- package/dist/esm/helpers/tokenCategories.mjs.map +1 -1
- package/dist/esm/helpers/tokenCategories.native.js +35 -74
- package/dist/esm/helpers/tokenCategories.native.js.map +1 -1
- package/dist/esm/helpers/variantResolvers.mjs +65 -0
- package/dist/esm/helpers/variantResolvers.mjs.map +1 -0
- package/dist/esm/helpers/variantResolvers.native.js +116 -0
- package/dist/esm/helpers/variantResolvers.native.js.map +1 -0
- package/dist/esm/hooks/useSplitStyles.mjs +2 -2
- package/dist/esm/hooks/useSplitStyles.mjs.map +1 -1
- package/dist/esm/hooks/useSplitStyles.native.js +2 -2
- package/dist/esm/hooks/useSplitStyles.native.js.map +1 -1
- package/dist/esm/index.js +3 -5
- package/dist/esm/index.mjs +3 -5
- package/dist/esm/index.native.js +3 -5
- package/dist/esm/internal-runtime.mjs +8 -7
- package/dist/esm/internal-runtime.mjs.map +1 -1
- package/dist/esm/internal-runtime.native.js +8 -7
- package/dist/esm/internal-runtime.native.js.map +1 -1
- package/dist/esm/static-resolve.mjs +8 -6
- package/dist/esm/static-resolve.mjs.map +1 -1
- package/dist/esm/static-resolve.native.js +8 -6
- package/dist/esm/static-resolve.native.js.map +1 -1
- package/dist/esm/styled.mjs +6 -57
- package/dist/esm/styled.mjs.map +1 -1
- package/dist/esm/styled.native.js +6 -59
- package/dist/esm/styled.native.js.map +1 -1
- package/dist/esm/types.mjs +1 -18
- package/dist/esm/types.mjs.map +1 -1
- package/dist/esm/types.native.js +1 -18
- package/dist/esm/types.native.js.map +1 -1
- package/dist/esm/views/Text.mjs +4 -2
- package/dist/esm/views/Text.mjs.map +1 -1
- package/dist/esm/views/Text.native.js +4 -2
- package/dist/esm/views/Text.native.js.map +1 -1
- package/dist/esm/views/View.mjs +4 -2
- package/dist/esm/views/View.mjs.map +1 -1
- package/dist/esm/views/View.native.js +4 -2
- package/dist/esm/views/View.native.js.map +1 -1
- package/package.json +15 -15
- package/src/config.ts +1 -1
- package/src/createComponent.tsx +41 -30
- package/src/createStyledHOC.tsx +56 -9
- package/src/createTokens.ts +1 -1
- package/src/dom/html.tsx +778 -877
- package/src/dom/htmlRuntime.native.tsx +7 -3
- package/src/dom/primitives.native.tsx +30 -39
- package/src/helpers/componentDisplayName.ts +0 -11
- package/src/helpers/directStyleCSS.ts +91 -112
- package/src/helpers/formatDiagnostic.ts +2 -4
- package/src/helpers/getCSSStylesAtomic.ts +32 -26
- package/src/helpers/getSplitStyles.tsx +315 -1119
- package/src/helpers/getVariantExtras.tsx +3 -3
- package/src/helpers/splitStyleProps.ts +166 -0
- package/src/helpers/styleFrontend.ts +8 -4
- package/src/helpers/styleStaticConfig.ts +88 -0
- package/src/helpers/tokenCategories.ts +62 -93
- package/src/helpers/variantResolvers.ts +121 -0
- package/src/hooks/useSplitStyles.tsx +17 -2
- package/src/hooks/useTheme.tsx +1 -1
- package/src/index.ts +8 -4
- package/src/internal-runtime.ts +10 -9
- package/src/static-resolve.ts +18 -14
- package/src/styled.tsx +7 -264
- package/src/types.tsx +19 -40
- package/src/views/Text.tsx +6 -7
- package/src/views/View.tsx +6 -7
- package/types/createComponent.d.ts.map +1 -1
- package/types/createStyledHOC.d.ts.map +1 -1
- package/types/dom/html.d.ts.map +1 -1
- package/types/dom/htmlRuntime.native.d.ts.map +1 -1
- package/types/dom/primitives.native.d.ts.map +1 -1
- package/types/helpers/componentDisplayName.d.ts +0 -3
- package/types/helpers/componentDisplayName.d.ts.map +1 -1
- package/types/helpers/directStyleCSS.d.ts.map +1 -1
- package/types/helpers/formatDiagnostic.d.ts.map +1 -1
- package/types/helpers/getCSSStylesAtomic.d.ts +17 -15
- package/types/helpers/getCSSStylesAtomic.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts +6 -6
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/splitStyleProps.d.ts +44 -0
- package/types/helpers/splitStyleProps.d.ts.map +1 -0
- package/types/helpers/styleFrontend.d.ts +4 -4
- package/types/helpers/styleFrontend.d.ts.map +1 -1
- package/types/helpers/styleStaticConfig.d.ts +19 -0
- package/types/helpers/styleStaticConfig.d.ts.map +1 -0
- package/types/helpers/tokenCategories.d.ts +1 -1
- package/types/helpers/tokenCategories.d.ts.map +1 -1
- package/types/helpers/variantResolvers.d.ts +9 -0
- package/types/helpers/variantResolvers.d.ts.map +1 -0
- package/types/hooks/useSplitStyles.d.ts.map +1 -1
- package/types/index.d.ts +2 -4
- package/types/index.d.ts.map +1 -1
- package/types/internal-runtime.d.ts.map +1 -1
- package/types/static-resolve.d.ts +2 -2
- package/types/static-resolve.d.ts.map +1 -1
- package/types/styled.d.ts +3 -39
- package/types/styled.d.ts.map +1 -1
- package/types/types.d.ts +2 -12
- package/types/types.d.ts.map +1 -1
- package/types/views/Text.d.ts.map +1 -1
- package/types/views/View.d.ts.map +1 -1
- package/dist/cjs/helpers/getDefaultProps.cjs +0 -24
- package/dist/cjs/helpers/getDefaultProps.native.cjs +0 -28
- package/dist/cjs/helpers/getDefaultProps.native.js +0 -30
- package/dist/cjs/helpers/getDefaultProps.native.js.map +0 -1
- package/dist/cjs/helpers/themeable.cjs +0 -92
- package/dist/cjs/helpers/themeable.native.cjs +0 -95
- package/dist/cjs/helpers/themeable.native.js +0 -97
- package/dist/cjs/helpers/themeable.native.js.map +0 -1
- package/dist/cjs/hooks/useProps.cjs +0 -129
- package/dist/cjs/hooks/useProps.native.cjs +0 -135
- package/dist/cjs/hooks/useProps.native.js +0 -137
- package/dist/cjs/hooks/useProps.native.js.map +0 -1
- package/dist/esm/helpers/getDefaultProps.mjs +0 -4
- package/dist/esm/helpers/getDefaultProps.mjs.map +0 -1
- package/dist/esm/helpers/getDefaultProps.native.js +0 -6
- package/dist/esm/helpers/getDefaultProps.native.js.map +0 -1
- package/dist/esm/helpers/themeable.mjs +0 -67
- package/dist/esm/helpers/themeable.mjs.map +0 -1
- package/dist/esm/helpers/themeable.native.js +0 -68
- package/dist/esm/helpers/themeable.native.js.map +0 -1
- package/dist/esm/hooks/useProps.mjs +0 -100
- package/dist/esm/hooks/useProps.mjs.map +0 -1
- package/dist/esm/hooks/useProps.native.js +0 -104
- package/dist/esm/hooks/useProps.native.js.map +0 -1
- package/src/helpers/getDefaultProps.ts +0 -3
- package/src/helpers/themeable.tsx +0 -96
- package/src/hooks/useProps.tsx +0 -186
- package/types/helpers/getDefaultProps.d.ts +0 -3
- package/types/helpers/getDefaultProps.d.ts.map +0 -1
- package/types/helpers/themeable.d.ts +0 -3
- package/types/helpers/themeable.d.ts.map +0 -1
- package/types/hooks/useProps.d.ts +0 -39
- package/types/hooks/useProps.d.ts.map +0 -1
package/src/config.ts
CHANGED
|
@@ -169,7 +169,7 @@ export const getThemes = () => getConfigFromGlobalOrLocal()!.themes
|
|
|
169
169
|
export const updateConfig = (key: string, value: any) => {
|
|
170
170
|
// for usage internally only
|
|
171
171
|
const config = getConfigFromGlobalOrLocal()
|
|
172
|
-
if (!config || !
|
|
172
|
+
if (!config || key === '__proto__' || !(key in config)) {
|
|
173
173
|
return
|
|
174
174
|
}
|
|
175
175
|
Object.assign(config[key], value)
|
package/src/createComponent.tsx
CHANGED
|
@@ -19,9 +19,10 @@ import { GroupContext } from './contexts/GroupContext'
|
|
|
19
19
|
import { didGetVariableValue, setDidGetVariableValue } from './createVariable'
|
|
20
20
|
import { defaultComponentStateMounted } from './defaultComponentState'
|
|
21
21
|
import { getWebEvents, useEvents, wrapWithGestureDetector } from './eventHandling'
|
|
22
|
-
import { getDefaultProps } from './helpers/getDefaultProps'
|
|
23
22
|
import { componentDisplayName } from './helpers/componentDisplayName'
|
|
24
|
-
import { getSplitStyles
|
|
23
|
+
import { getSplitStyles } from './helpers/getSplitStyles'
|
|
24
|
+
import { getConfigRevisionState } from './helpers/grammarConfig'
|
|
25
|
+
import { getStyleStaticConfig, type StyleStaticConfig } from './helpers/styleStaticConfig'
|
|
25
26
|
import {
|
|
26
27
|
getNativeStyleEngine,
|
|
27
28
|
queueNativeViewState,
|
|
@@ -267,16 +268,10 @@ export function createComponent<
|
|
|
267
268
|
)
|
|
268
269
|
}
|
|
269
270
|
|
|
270
|
-
prepareStyleStaticConfig(staticConfig)
|
|
271
|
-
|
|
272
271
|
let config: TamaguiInternalConfig | null = null
|
|
273
272
|
let resolvedDefaultProps: Record<string, any> | undefined
|
|
274
|
-
let
|
|
275
|
-
|
|
276
|
-
staticConfig.contextProps || staticConfig.context?.propKeys
|
|
277
|
-
const styledContextKeys = styledContextPropKeys
|
|
278
|
-
? new Set(styledContextPropKeys)
|
|
279
|
-
: undefined
|
|
273
|
+
let resolvedStyleRevision = -1
|
|
274
|
+
let resolvedStyleStaticConfig: StyleStaticConfig | undefined
|
|
280
275
|
|
|
281
276
|
const { Component, isText, isHOC } = staticConfig
|
|
282
277
|
|
|
@@ -290,11 +285,11 @@ export function createComponent<
|
|
|
290
285
|
|
|
291
286
|
let res: ComponentType
|
|
292
287
|
|
|
288
|
+
const { displayName } = staticConfig
|
|
289
|
+
|
|
293
290
|
const component = (propsInWithRef: ComponentPropTypes & { ref?: React.Ref<Ref> }) => {
|
|
294
291
|
'use no memo'
|
|
295
292
|
|
|
296
|
-
const displayName = (res as any)[componentDisplayName] as string | undefined
|
|
297
|
-
|
|
298
293
|
// read the forwarded ref directly off the incoming props — do NOT clone the
|
|
299
294
|
// whole object every render just to strip `ref`. the original props object is
|
|
300
295
|
// passed straight through; `ref` is skipped in the getSplitStyles pass (so it
|
|
@@ -305,6 +300,29 @@ export function createComponent<
|
|
|
305
300
|
|
|
306
301
|
config = config || getConfig()
|
|
307
302
|
|
|
303
|
+
const styleRevision = getConfigRevisionState(config).revision
|
|
304
|
+
if (resolvedStyleRevision !== styleRevision) {
|
|
305
|
+
resolvedStyleRevision = styleRevision
|
|
306
|
+
const nextStyleStaticConfig = getStyleStaticConfig(staticConfig, config)
|
|
307
|
+
resolvedStyleStaticConfig = nextStyleStaticConfig
|
|
308
|
+
resolvedDefaultProps = nextStyleStaticConfig.defaultProps
|
|
309
|
+
// the relative-position default is a style, so it joins the base layer
|
|
310
|
+
// under everything the call site writes
|
|
311
|
+
if (
|
|
312
|
+
isWeb &&
|
|
313
|
+
!staticConfig.isText &&
|
|
314
|
+
config.settings.defaultPosition === 'relative' &&
|
|
315
|
+
nextStyleStaticConfig.baseStyle?.position === undefined
|
|
316
|
+
) {
|
|
317
|
+
resolvedStyleStaticConfig = {
|
|
318
|
+
...nextStyleStaticConfig,
|
|
319
|
+
baseStyle: { position: 'relative', ...nextStyleStaticConfig.baseStyle },
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const styleStaticConfig = resolvedStyleStaticConfig!
|
|
324
|
+
const styledContextKeys = styleStaticConfig.styledContextKeys
|
|
325
|
+
|
|
308
326
|
const internalID = process.env.NODE_ENV === 'development' ? React.useId() : ''
|
|
309
327
|
|
|
310
328
|
if (process.env.NODE_ENV === 'development') {
|
|
@@ -386,20 +404,6 @@ export function createComponent<
|
|
|
386
404
|
let props: ViewProps | TextProps = propsIn
|
|
387
405
|
|
|
388
406
|
// merge both default props and styled context props - ensure order is preserved
|
|
389
|
-
if (!didResolveDefaultProps) {
|
|
390
|
-
didResolveDefaultProps = true
|
|
391
|
-
const staticDefaultProps = getDefaultProps(staticConfig)
|
|
392
|
-
resolvedDefaultProps =
|
|
393
|
-
isWeb &&
|
|
394
|
-
!isText &&
|
|
395
|
-
config.settings.defaultPosition === 'relative' &&
|
|
396
|
-
staticDefaultProps?.position === undefined
|
|
397
|
-
? staticDefaultProps
|
|
398
|
-
? { position: 'relative', ...staticDefaultProps }
|
|
399
|
-
: { position: 'relative' }
|
|
400
|
-
: staticDefaultProps
|
|
401
|
-
}
|
|
402
|
-
|
|
403
407
|
// merge styled context props over defaults, ensure order is preserved
|
|
404
408
|
const [nextProps, overrides] = mergeComponentProps(
|
|
405
409
|
resolvedDefaultProps,
|
|
@@ -763,7 +767,6 @@ export function createComponent<
|
|
|
763
767
|
canPlatformPseudo: componentState.platformPseudo,
|
|
764
768
|
displayName,
|
|
765
769
|
styledContext: styledContextValue,
|
|
766
|
-
styledContextKeys,
|
|
767
770
|
} as const
|
|
768
771
|
|
|
769
772
|
const themeName = themeState?.name || ''
|
|
@@ -783,7 +786,8 @@ export function createComponent<
|
|
|
783
786
|
elementType,
|
|
784
787
|
startedUnhydrated,
|
|
785
788
|
debugProp,
|
|
786
|
-
animationDriver
|
|
789
|
+
animationDriver,
|
|
790
|
+
styleStaticConfig
|
|
787
791
|
)
|
|
788
792
|
|
|
789
793
|
const finalizedComponentState = componentState.finalizeStyleFlags(
|
|
@@ -957,7 +961,8 @@ export function createComponent<
|
|
|
957
961
|
elementType,
|
|
958
962
|
startedUnhydrated,
|
|
959
963
|
debugProp,
|
|
960
|
-
animationDriver
|
|
964
|
+
animationDriver,
|
|
965
|
+
styleStaticConfig
|
|
961
966
|
)
|
|
962
967
|
if (!nextStyles?.style) return false
|
|
963
968
|
|
|
@@ -1117,7 +1122,8 @@ export function createComponent<
|
|
|
1117
1122
|
elementType,
|
|
1118
1123
|
startedUnhydrated,
|
|
1119
1124
|
debugProp,
|
|
1120
|
-
animationDriver
|
|
1125
|
+
animationDriver,
|
|
1126
|
+
styleStaticConfig
|
|
1121
1127
|
)
|
|
1122
1128
|
|
|
1123
1129
|
const effectiveTransition =
|
|
@@ -2221,6 +2227,11 @@ export function createComponent<
|
|
|
2221
2227
|
|
|
2222
2228
|
res.staticConfig = staticConfig
|
|
2223
2229
|
|
|
2230
|
+
if (displayName) {
|
|
2231
|
+
res.displayName = displayName
|
|
2232
|
+
;(res as any)[componentDisplayName] = displayName
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2224
2235
|
return res
|
|
2225
2236
|
}
|
|
2226
2237
|
|
package/src/createStyledHOC.tsx
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import React, { type ReactNode, type Ref as ReactRef } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
setComponentDisplayName,
|
|
5
|
-
} from './helpers/componentDisplayName'
|
|
6
|
-
import { themeable } from './helpers/themeable'
|
|
2
|
+
import { componentDisplayName } from './helpers/componentDisplayName'
|
|
3
|
+
import { Theme } from './views/Theme'
|
|
7
4
|
import type {
|
|
8
5
|
GetFinalProps,
|
|
9
6
|
StaticConfig,
|
|
@@ -11,6 +8,7 @@ import type {
|
|
|
11
8
|
StyledHOCOptions,
|
|
12
9
|
TamaguiComponent,
|
|
13
10
|
TamaDefer,
|
|
11
|
+
ThemeProps,
|
|
14
12
|
} from './types'
|
|
15
13
|
|
|
16
14
|
export function createStyledHOC<
|
|
@@ -70,18 +68,67 @@ export function createStyledHOC<
|
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
let out: any = function StyledHOCComponent(props: any) {
|
|
71
|
+
'use no memo'
|
|
72
|
+
|
|
73
73
|
const { ref, ...rest } = props
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
if (options?.disableTheme) {
|
|
75
|
+
return render(rest, ref)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const defaultTheme = extendedConfig.defaultProps?.theme
|
|
79
|
+
const { theme: _, ...themedRest } = rest
|
|
80
|
+
const element = render({ ...themedRest, 'data-disable-theme': true }, ref)
|
|
81
|
+
|
|
82
|
+
let themeProps: Partial<ThemeProps> | null = null
|
|
83
|
+
if ('debug' in props) {
|
|
84
|
+
themeProps = { debug: props.debug }
|
|
85
|
+
}
|
|
86
|
+
if ('theme' in props || defaultTheme) {
|
|
87
|
+
;(themeProps ||= {}).name = 'theme' in props ? props.theme : defaultTheme
|
|
88
|
+
}
|
|
76
89
|
|
|
77
|
-
|
|
90
|
+
// keeping the theme key present with a null value keeps the tree stable
|
|
91
|
+
// across theme changes, while an entirely absent key avoids mounting Theme.
|
|
92
|
+
if (!themeProps) {
|
|
93
|
+
return element
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const context = extendedConfig.context
|
|
97
|
+
if (!context) {
|
|
98
|
+
return (
|
|
99
|
+
<Theme disable-child-theme {...themeProps}>
|
|
100
|
+
{element}
|
|
101
|
+
</Theme>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const contextValue = React.useContext(context)
|
|
106
|
+
let overriddenContextProps: object | undefined
|
|
107
|
+
for (const key in context.props) {
|
|
108
|
+
const value = props[key]
|
|
109
|
+
if (value !== undefined) {
|
|
110
|
+
;(overriddenContextProps ||= {})[key] = value
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const Provider = context.Provider
|
|
114
|
+
return (
|
|
115
|
+
<Provider {...contextValue} {...overriddenContextProps}>
|
|
116
|
+
<Theme disable-child-theme {...themeProps}>
|
|
117
|
+
{element}
|
|
118
|
+
</Theme>
|
|
119
|
+
</Provider>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
78
122
|
|
|
79
123
|
if (extendedConfig.memo || process.env.TAMAGUI_MEMOIZE_STYLED_HOC) {
|
|
80
124
|
out = React.memo(out)
|
|
81
125
|
}
|
|
82
126
|
|
|
83
127
|
const displayName = options?.displayName || (component as any)[componentDisplayName]
|
|
84
|
-
|
|
128
|
+
if (displayName) {
|
|
129
|
+
out.displayName = displayName
|
|
130
|
+
out[componentDisplayName] = displayName
|
|
131
|
+
}
|
|
85
132
|
|
|
86
133
|
out.staticConfig = extendedConfig
|
|
87
134
|
return out
|
package/src/createTokens.ts
CHANGED
|
@@ -13,7 +13,7 @@ function validateNoTrueTokenKeys(tokens: CreateTokens) {
|
|
|
13
13
|
const tokenSet = tokens[category]
|
|
14
14
|
if (!tokenSet || typeof tokenSet !== 'object') continue
|
|
15
15
|
|
|
16
|
-
if (
|
|
16
|
+
if ('true' in tokenSet) {
|
|
17
17
|
throw new Error(
|
|
18
18
|
`tokens.${category}.true is reserved because boolean values select component defaults. Use an explicit token name instead.`
|
|
19
19
|
)
|