@tamagui/web 3.0.0-beta.1432.1 → 3.0.0-beta.1444.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.cjs +3 -3
- package/dist/cjs/createComponent.native.cjs +5 -3
- package/dist/cjs/createComponent.native.js +5 -3
- package/dist/cjs/createComponent.native.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.cjs +8 -0
- package/dist/cjs/helpers/getSplitStyles.native.cjs +8 -0
- package/dist/cjs/helpers/getSplitStyles.native.js +8 -0
- package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/createComponent.mjs +3 -3
- package/dist/esm/createComponent.mjs.map +1 -1
- package/dist/esm/createComponent.native.js +5 -3
- package/dist/esm/createComponent.native.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs +8 -0
- package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.native.js +8 -0
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/package.json +16 -16
- package/src/createComponent.tsx +9 -3
- package/src/helpers/getSplitStyles.tsx +28 -0
- package/src/styled.tsx +11 -1
- package/src/types.tsx +45 -21
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/styled.d.ts +2 -2
- package/types/styled.d.ts.map +1 -1
- package/types/types.d.ts +16 -10
- package/types/types.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/web",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.1444.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Nate Wienert"
|
|
@@ -100,23 +100,23 @@
|
|
|
100
100
|
"test:web": "vitest --typecheck --run"
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@tamagui/animation-helpers": "3.0.0-beta.
|
|
104
|
-
"@tamagui/compose-refs": "3.0.0-beta.
|
|
105
|
-
"@tamagui/constants": "3.0.0-beta.
|
|
106
|
-
"@tamagui/dom": "3.0.0-beta.
|
|
107
|
-
"@tamagui/helpers": "3.0.0-beta.
|
|
108
|
-
"@tamagui/is-equal-shallow": "3.0.0-beta.
|
|
109
|
-
"@tamagui/native": "3.0.0-beta.
|
|
110
|
-
"@tamagui/normalize-css-color": "3.0.0-beta.
|
|
111
|
-
"@tamagui/react-native-types": "3.0.0-beta.
|
|
112
|
-
"@tamagui/style-grammar": "3.0.0-beta.
|
|
113
|
-
"@tamagui/types": "3.0.0-beta.
|
|
114
|
-
"@tamagui/use-did-finish-ssr": "3.0.0-beta.
|
|
115
|
-
"@tamagui/use-event": "3.0.0-beta.
|
|
116
|
-
"@tamagui/use-force-update": "3.0.0-beta.
|
|
103
|
+
"@tamagui/animation-helpers": "3.0.0-beta.1444.1",
|
|
104
|
+
"@tamagui/compose-refs": "3.0.0-beta.1444.1",
|
|
105
|
+
"@tamagui/constants": "3.0.0-beta.1444.1",
|
|
106
|
+
"@tamagui/dom": "3.0.0-beta.1444.1",
|
|
107
|
+
"@tamagui/helpers": "3.0.0-beta.1444.1",
|
|
108
|
+
"@tamagui/is-equal-shallow": "3.0.0-beta.1444.1",
|
|
109
|
+
"@tamagui/native": "3.0.0-beta.1444.1",
|
|
110
|
+
"@tamagui/normalize-css-color": "3.0.0-beta.1444.1",
|
|
111
|
+
"@tamagui/react-native-types": "3.0.0-beta.1444.1",
|
|
112
|
+
"@tamagui/style-grammar": "3.0.0-beta.1444.1",
|
|
113
|
+
"@tamagui/types": "3.0.0-beta.1444.1",
|
|
114
|
+
"@tamagui/use-did-finish-ssr": "3.0.0-beta.1444.1",
|
|
115
|
+
"@tamagui/use-event": "3.0.0-beta.1444.1",
|
|
116
|
+
"@tamagui/use-force-update": "3.0.0-beta.1444.1"
|
|
117
117
|
},
|
|
118
118
|
"devDependencies": {
|
|
119
|
-
"@tamagui/build": "3.0.0-beta.
|
|
119
|
+
"@tamagui/build": "3.0.0-beta.1444.1",
|
|
120
120
|
"@testing-library/react": "^16.1.0",
|
|
121
121
|
"csstype": "^3.0.10",
|
|
122
122
|
"react": "19.2.3",
|
package/src/createComponent.tsx
CHANGED
|
@@ -644,7 +644,14 @@ export function createComponent<
|
|
|
644
644
|
? false
|
|
645
645
|
: props['data-disable-theme'] && !('theme' in props)
|
|
646
646
|
|
|
647
|
-
|
|
647
|
+
// a styled HOC leaves theming to the component it wraps and hands it the
|
|
648
|
+
// theme prop. on native the HOC's own styles resolve to values here, before
|
|
649
|
+
// that, so an HOC given a theme themes itself and the wrapped component
|
|
650
|
+
// inherits it instead of applying it a second time. keyed on presence, like
|
|
651
|
+
// disableThemeProp, so hook order never changes across renders
|
|
652
|
+
const hocThemesSelf =
|
|
653
|
+
process.env.TAMAGUI_TARGET === 'native' && isHOC && 'theme' in props
|
|
654
|
+
const disableTheme = disableThemeProp || (isHOC && !hocThemesSelf)
|
|
648
655
|
|
|
649
656
|
if (process.env.NODE_ENV === 'development' && time) time`theme-props`
|
|
650
657
|
|
|
@@ -1323,7 +1330,6 @@ export function createComponent<
|
|
|
1323
1330
|
asChild,
|
|
1324
1331
|
children,
|
|
1325
1332
|
themeShallow,
|
|
1326
|
-
spaceDirection: _spaceDirection,
|
|
1327
1333
|
onPress,
|
|
1328
1334
|
onLongPress,
|
|
1329
1335
|
onPressIn,
|
|
@@ -1355,7 +1361,7 @@ export function createComponent<
|
|
|
1355
1361
|
}
|
|
1356
1362
|
|
|
1357
1363
|
if (isHOC) {
|
|
1358
|
-
if (typeof _themeProp !== 'undefined') {
|
|
1364
|
+
if (typeof _themeProp !== 'undefined' && !hocThemesSelf) {
|
|
1359
1365
|
viewProps.theme = _themeProp
|
|
1360
1366
|
}
|
|
1361
1367
|
if (typeof passThrough !== 'undefined') {
|
|
@@ -449,6 +449,7 @@ const passFrontendContainerType = 27
|
|
|
449
449
|
const passSourceLayer = 28
|
|
450
450
|
const passParentCursor = 29
|
|
451
451
|
const passMapSourceKey = 30
|
|
452
|
+
const passVariantOutput = 31
|
|
452
453
|
|
|
453
454
|
const passFlags = 13
|
|
454
455
|
|
|
@@ -919,6 +920,30 @@ function contributeProp(
|
|
|
919
920
|
}
|
|
920
921
|
}
|
|
921
922
|
|
|
923
|
+
// variants hold styles and aria/data attributes (data- is handled above),
|
|
924
|
+
// which flatten to the same attribute. anything else a variant sets (a
|
|
925
|
+
// theme, a handler, a prop for the wrapped component) is dropped, so a
|
|
926
|
+
// variant means the same flattened or not
|
|
927
|
+
if (
|
|
928
|
+
pass[passVariantOutput] &&
|
|
929
|
+
!isValidStyleKeyInit &&
|
|
930
|
+
!keyInit.startsWith('aria-') &&
|
|
931
|
+
!(keyInit in stylePropsAll) &&
|
|
932
|
+
!(keyInit in skipProps) &&
|
|
933
|
+
!(variants && keyInit in variants) &&
|
|
934
|
+
!(parentVariants && keyInit in parentVariants) &&
|
|
935
|
+
!styledContextKeys?.has(keyInit) &&
|
|
936
|
+
!(styledContext && keyInit in styledContext)
|
|
937
|
+
) {
|
|
938
|
+
if (process.env.NODE_ENV === 'development') {
|
|
939
|
+
warnOnce(
|
|
940
|
+
`variant-non-style:${keyInit}`,
|
|
941
|
+
`a variant set "${keyInit}", which is not a style. Variants hold styles and aria/data attributes only: set "${keyInit}" on the component one level up.`
|
|
942
|
+
)
|
|
943
|
+
}
|
|
944
|
+
return
|
|
945
|
+
}
|
|
946
|
+
|
|
922
947
|
if (process.env.TAMAGUI_TARGET === 'web') {
|
|
923
948
|
if (!noExpand) {
|
|
924
949
|
// map the React Native-shaped public prop surface onto DOM attributes in
|
|
@@ -4064,9 +4089,12 @@ export function emitVariantStyle(
|
|
|
4064
4089
|
{})[key] = original
|
|
4065
4090
|
}
|
|
4066
4091
|
const parent = pass[passParentCursor]
|
|
4092
|
+
const parentVariantOutput = pass[passVariantOutput]
|
|
4067
4093
|
pass[passParentCursor] = condition
|
|
4094
|
+
pass[passVariantOutput] = true
|
|
4068
4095
|
contributeProp(pass, key, value, original, disabled)
|
|
4069
4096
|
pass[passParentCursor] = parent
|
|
4097
|
+
pass[passVariantOutput] = parentVariantOutput
|
|
4070
4098
|
}
|
|
4071
4099
|
|
|
4072
4100
|
// handles finding and resolving the fontFamily to the token name
|
package/src/styled.tsx
CHANGED
|
@@ -19,6 +19,7 @@ import type {
|
|
|
19
19
|
StaticConfig,
|
|
20
20
|
StaticConfigPublic,
|
|
21
21
|
StylableComponent,
|
|
22
|
+
StyleOnlyVariants,
|
|
22
23
|
StyledContext,
|
|
23
24
|
StyledDynamicFn,
|
|
24
25
|
StyledDynamicProp,
|
|
@@ -26,6 +27,7 @@ import type {
|
|
|
26
27
|
TamaguiComponent,
|
|
27
28
|
ThemeValueGet,
|
|
28
29
|
VariantDefinitions,
|
|
30
|
+
VariantStyleProps,
|
|
29
31
|
} from './types'
|
|
30
32
|
|
|
31
33
|
type AreVariantsUndefined<Variants> =
|
|
@@ -78,7 +80,15 @@ export type StyledOptions<
|
|
|
78
80
|
ContextPropKeys
|
|
79
81
|
> & {
|
|
80
82
|
displayName?: string
|
|
81
|
-
variants?:
|
|
83
|
+
variants?:
|
|
84
|
+
| (Variants &
|
|
85
|
+
NoInferLocal<
|
|
86
|
+
StyleOnlyVariants<
|
|
87
|
+
Variants,
|
|
88
|
+
keyof VariantStyleProps<ParentComponent, StyledConfig>
|
|
89
|
+
>
|
|
90
|
+
>)
|
|
91
|
+
| undefined
|
|
82
92
|
defaultVariants?: NoInferLocal<GetVariantAcceptedValues<NonNullable<Variants>>>
|
|
83
93
|
context?: Context
|
|
84
94
|
contextProps?: readonly Extract<
|
package/src/types.tsx
CHANGED
|
@@ -3443,39 +3443,63 @@ export type VariantDefinitions<
|
|
|
3443
3443
|
}
|
|
3444
3444
|
? S
|
|
3445
3445
|
: {},
|
|
3446
|
-
MyProps extends object =
|
|
3447
|
-
GetVariantProps<
|
|
3448
|
-
Parent,
|
|
3449
|
-
StaticConfig['isText'] extends true
|
|
3450
|
-
? true
|
|
3451
|
-
: StaticConfig['isInput'] extends true
|
|
3452
|
-
? true
|
|
3453
|
-
: false
|
|
3454
|
-
>
|
|
3455
|
-
>,
|
|
3446
|
+
MyProps extends object = VariantStyleProps<Parent, StaticConfig>,
|
|
3456
3447
|
Val = any,
|
|
3457
3448
|
> = VariantDefinitionFromProps<MyProps, Val> & {
|
|
3458
3449
|
_isEmpty?: 1
|
|
3459
3450
|
}
|
|
3460
3451
|
|
|
3452
|
+
export type VariantStyleProps<
|
|
3453
|
+
Parent extends StylableComponent,
|
|
3454
|
+
StaticConfig extends StaticConfigPublic,
|
|
3455
|
+
> = Partial<
|
|
3456
|
+
GetVariantProps<
|
|
3457
|
+
Parent,
|
|
3458
|
+
StaticConfig['isText'] extends true
|
|
3459
|
+
? true
|
|
3460
|
+
: StaticConfig['isInput'] extends true
|
|
3461
|
+
? true
|
|
3462
|
+
: false
|
|
3463
|
+
>
|
|
3464
|
+
>
|
|
3465
|
+
|
|
3466
|
+
/**
|
|
3467
|
+
* the exact-key check styled() runs on the variants it infers: a key that is
|
|
3468
|
+
* not a style, shorthand, aria/data attribute, or variant of the component is
|
|
3469
|
+
* `never`, since inference alone never flags extra keys.
|
|
3470
|
+
*/
|
|
3471
|
+
export type StyleOnlyVariants<Variants, AllowedKeys extends PropertyKey> = {
|
|
3472
|
+
[Name in keyof Variants]: Variants[Name] extends StyledDynamic<any, any>
|
|
3473
|
+
? Variants[Name]
|
|
3474
|
+
: {
|
|
3475
|
+
[Value in keyof Variants[Name]]: Variants[Name][Value] extends object
|
|
3476
|
+
? {
|
|
3477
|
+
[Key in keyof Variants[Name][Value]]: Key extends
|
|
3478
|
+
| AllowedKeys
|
|
3479
|
+
| keyof Variants
|
|
3480
|
+
| `aria-${string}`
|
|
3481
|
+
| `data-${string}`
|
|
3482
|
+
? Variants[Name][Value][Key]
|
|
3483
|
+
: never
|
|
3484
|
+
}
|
|
3485
|
+
: Variants[Name][Value]
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
|
|
3461
3489
|
export type StaticStyleInput = string
|
|
3462
3490
|
|
|
3491
|
+
// variants are styles only: a variant value holds style props and the parent's
|
|
3492
|
+
// variants, never a non-style prop such as theme. a component that changes
|
|
3493
|
+
// theme with a variant does it one level up, as a theme prop.
|
|
3463
3494
|
export type GetVariantProps<
|
|
3464
3495
|
A extends StylableComponent,
|
|
3465
3496
|
IsText extends boolean | undefined,
|
|
3466
3497
|
> = A extends {
|
|
3467
|
-
__tama: [
|
|
3468
|
-
infer Props,
|
|
3469
|
-
any,
|
|
3470
|
-
infer NonStyledProps,
|
|
3471
|
-
infer BaseStyles,
|
|
3472
|
-
infer VariantProps,
|
|
3473
|
-
any,
|
|
3474
|
-
]
|
|
3498
|
+
__tama: [any, any, any, infer BaseStyles, infer VariantProps, any]
|
|
3475
3499
|
}
|
|
3476
|
-
?
|
|
3477
|
-
?
|
|
3478
|
-
:
|
|
3500
|
+
? BaseStyles extends object
|
|
3501
|
+
? WithThemeAndShorthands<BaseStyles, VariantProps>
|
|
3502
|
+
: {}
|
|
3479
3503
|
: WithThemeAndShorthands<IsText extends true ? TextStylePropsBase : StackStyleBase>
|
|
3480
3504
|
|
|
3481
3505
|
export type VariantDefinitionFromProps<MyProps, Val> = MyProps extends object
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAuC/D,OAAO,KAAK,EASV,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EAOf,MAAM,SAAS,CAAA;AAahB,KAAK,iBAAiB,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC,CAAA;AAEpF,eAAO,MAAM,kBAAkB,wBAA+B,CAAA;AAuK9D,wBAAgB,eAAe,CAC7B,kBAAkB,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,EACnD,GAAG,SAAS,cAAc,GAAG,cAAc,EAC3C,SAAS,GAAG,KAAK,EACjB,UAAU,SAAS,MAAM,GAAG,KAAK,EACjC,YAAY,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAuC/D,OAAO,KAAK,EASV,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EAOf,MAAM,SAAS,CAAA;AAahB,KAAK,iBAAiB,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC,CAAA;AAEpF,eAAO,MAAM,kBAAkB,wBAA+B,CAAA;AAuK9D,wBAAgB,eAAe,CAC7B,kBAAkB,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,EACnD,GAAG,SAAS,cAAc,GAAG,cAAc,EAC3C,SAAS,GAAG,KAAK,EACjB,UAAU,SAAS,MAAM,GAAG,KAAK,EACjC,YAAY,EAAE,YAAY,wEAolE3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSplitStyles.d.ts","sourceRoot":"","sources":["../../src/helpers/getSplitStyles.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EACV,gBAAgB,EAEhB,mBAAmB,EAEnB,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,aAAa,EAGb,eAAe,EACf,YAAY,EAGZ,qBAAqB,EACrB,qBAAqB,EAErB,WAAW,EAGZ,MAAM,UAAU,CAAA;AAkBjB,OAAO,EAAE,oBAAoB,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAKlF,OAAO,EAAE,oBAAoB,EAAE,CAAA;AAqB/B,OAAO,EAAE,mB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AAG,CACvB,KAAK,EAAE,aAAa,EACpB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,GAAG,EACV,gBAAgB,CAAC,EAAE,OAAO,EAC1B,aAAa,CAAC,EAAE,GAAG,KAChB,IAAI,CAAA;AAs3CT,KAAK,oBAAoB,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI,CAAA;AAgCnF,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,oBAAoB,GAAG,IAAI,EACjC,QAAQ,SAAI,EACZ,WAAW,UAAQ,WA4OpB;AA6HD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EACpB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,GAAG,EACb,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,OAAO,QAyBlB;AAID,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,qBAAqB,sBAgBtF;AAMD,cAAc,mBAAmB,CAAA"}
|
package/types/styled.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { styledDynamic } from './helpers/styledDynamic';
|
|
2
2
|
import type { FrontendComponent, StyleFrontend } from './helpers/styleFrontend';
|
|
3
3
|
import type { GetRef } from './interfaces/GetRef';
|
|
4
|
-
import type { GetBaseStyles, GetNonStyledProps, GetProps, GetStaticConfig, GetStyledVariants, InferStyledProps, StaticConfigPublic, StylableComponent, StyledContext, StyledDynamicFn, StyledDynamicProp, TamaDefer, TamaguiComponent, VariantDefinitions } from './types';
|
|
4
|
+
import type { GetBaseStyles, GetNonStyledProps, GetProps, GetStaticConfig, GetStyledVariants, InferStyledProps, StaticConfigPublic, StylableComponent, StyleOnlyVariants, StyledContext, StyledDynamicFn, StyledDynamicProp, TamaDefer, TamaguiComponent, VariantDefinitions, VariantStyleProps } from './types';
|
|
5
5
|
type AreVariantsUndefined<Variants> = Required<Variants> extends {
|
|
6
6
|
_isEmpty: 1;
|
|
7
7
|
} ? true : false;
|
|
@@ -14,7 +14,7 @@ type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
|
14
14
|
type GetStyledOptionsAcceptedProps<ParentComponent extends StylableComponent, StyledConfig extends StaticConfigPublic, Variants extends VariantDefinitions<ParentComponent, StyledConfig>, Context, ContextPropKeys extends string> = Partial<InferStyledProps<ParentComponent, StyledConfig>> & (AreVariantsUndefined<Variants> extends true ? {} : Partial<GetVariantAcceptedValues<Variants>>) & GetStyledContextProps<Context, ContextPropKeys>;
|
|
15
15
|
export type StyledOptions<ParentComponent extends StylableComponent, StyledConfig extends StaticConfigPublic, Variants extends VariantDefinitions<ParentComponent, StyledConfig>, Context extends StyledContext<any> | undefined = undefined, ContextPropKeys extends string = GetStyledContextDefaultKeys<Context>> = GetStyledOptionsAcceptedProps<ParentComponent, StyledConfig, Variants, Context, ContextPropKeys> & {
|
|
16
16
|
displayName?: string;
|
|
17
|
-
variants?: Variants | undefined;
|
|
17
|
+
variants?: (Variants & NoInferLocal<StyleOnlyVariants<Variants, keyof VariantStyleProps<ParentComponent, StyledConfig>>>) | undefined;
|
|
18
18
|
defaultVariants?: NoInferLocal<GetVariantAcceptedValues<NonNullable<Variants>>>;
|
|
19
19
|
context?: Context;
|
|
20
20
|
contextProps?: readonly Extract<ContextPropKeys, keyof GetStyledContextAllProps<Context> & string>[];
|
package/types/styled.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAE/E,OAA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
|
@@ -2044,20 +2044,26 @@ export type StyledDynamic<Val = any, Output extends object = Record<string, any>
|
|
|
2044
2044
|
export type StyledResolver<Props = Record<string, any>, Output extends object = Record<string, any>> = (props: Props, env: StyledDynamicEnv) => Partial<Output> | null | undefined;
|
|
2045
2045
|
export type VariantDefinitions<Parent extends StylableComponent = TamaguiComponent, StaticConfig extends StaticConfigPublic = Parent extends {
|
|
2046
2046
|
__tama: [any, any, any, any, any, infer S];
|
|
2047
|
-
} ? S : {}, MyProps extends object =
|
|
2047
|
+
} ? S : {}, MyProps extends object = VariantStyleProps<Parent, StaticConfig>, Val = any> = VariantDefinitionFromProps<MyProps, Val> & {
|
|
2048
2048
|
_isEmpty?: 1;
|
|
2049
2049
|
};
|
|
2050
|
+
export type VariantStyleProps<Parent extends StylableComponent, StaticConfig extends StaticConfigPublic> = Partial<GetVariantProps<Parent, StaticConfig['isText'] extends true ? true : StaticConfig['isInput'] extends true ? true : false>>;
|
|
2051
|
+
/**
|
|
2052
|
+
* the exact-key check styled() runs on the variants it infers: a key that is
|
|
2053
|
+
* not a style, shorthand, aria/data attribute, or variant of the component is
|
|
2054
|
+
* `never`, since inference alone never flags extra keys.
|
|
2055
|
+
*/
|
|
2056
|
+
export type StyleOnlyVariants<Variants, AllowedKeys extends PropertyKey> = {
|
|
2057
|
+
[Name in keyof Variants]: Variants[Name] extends StyledDynamic<any, any> ? Variants[Name] : {
|
|
2058
|
+
[Value in keyof Variants[Name]]: Variants[Name][Value] extends object ? {
|
|
2059
|
+
[Key in keyof Variants[Name][Value]]: Key extends AllowedKeys | keyof Variants | `aria-${string}` | `data-${string}` ? Variants[Name][Value][Key] : never;
|
|
2060
|
+
} : Variants[Name][Value];
|
|
2061
|
+
};
|
|
2062
|
+
};
|
|
2050
2063
|
export type StaticStyleInput = string;
|
|
2051
2064
|
export type GetVariantProps<A extends StylableComponent, IsText extends boolean | undefined> = A extends {
|
|
2052
|
-
__tama: [
|
|
2053
|
-
|
|
2054
|
-
any,
|
|
2055
|
-
infer NonStyledProps,
|
|
2056
|
-
infer BaseStyles,
|
|
2057
|
-
infer VariantProps,
|
|
2058
|
-
any
|
|
2059
|
-
];
|
|
2060
|
-
} ? Props extends TamaDefer ? GetFinalProps<NonStyledProps, BaseStyles, VariantProps> : Props : WithThemeAndShorthands<IsText extends true ? TextStylePropsBase : StackStyleBase>;
|
|
2065
|
+
__tama: [any, any, any, infer BaseStyles, infer VariantProps, any];
|
|
2066
|
+
} ? BaseStyles extends object ? WithThemeAndShorthands<BaseStyles, VariantProps> : {} : WithThemeAndShorthands<IsText extends true ? TextStylePropsBase : StackStyleBase>;
|
|
2061
2067
|
export type VariantDefinitionFromProps<MyProps, Val> = MyProps extends object ? {
|
|
2062
2068
|
[propName: string]: StyledDynamic<any, MyProps> | {
|
|
2063
2069
|
[Key in string | number | 'true' | 'false']?: MyProps | StaticStyleInput;
|