@tamagui/core 1.0.1-beta.165 → 1.0.1-beta.166

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.
@@ -80,6 +80,9 @@ function styled(Component, options, staticExtractionOptions) {
80
80
  isText,
81
81
  isImage
82
82
  };
83
+ if (defaultProps.children) {
84
+ conf.neverFlatten = true;
85
+ }
83
86
  return conf;
84
87
  }
85
88
  return {};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/styled.tsx"],
4
- "sourcesContent": ["import { Image, Text, TextInput } from 'react-native'\n\nimport { createComponent } from './createComponent'\nimport { RNComponents } from './helpers/RNComponents'\nimport {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n TamaguiElement,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types'\n\n// TODO may be able to use this in the options?: arg below directly\nexport type StyledOptions<ParentComponent extends StylableComponent> = GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n Component: ParentComponent,\n // this should be Partial<GetProps<ParentComponent>> but causes excessively deep type issues\n options?: GetProps<ParentComponent> & {\n name?: string\n variants?: Variants | undefined\n // thought i had this typed, but can't get it linked\n defaultVariants?: { [key: string]: any }\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n const staticConfigProps = (() => {\n const parentStaticConfig =\n 'staticConfig' in Component ? (Component.staticConfig as StaticConfig) : null\n\n if (process.env.NODE_ENV === 'development') {\n if (parentStaticConfig?.isHOC) {\n // eslint-disable-next-line no-console\n console.warn(\n `Warning: Parent component is a functional component, not a Tamagui styled() component. Extending with styled() will break and lead to incorrect styles.`\n )\n }\n }\n\n if (options) {\n const { variants, name, defaultVariants, ...defaultProps } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n let isReactNativeWeb = parentStaticConfig?.isReactNativeWeb || RNComponents.has(Component)\n // this can happen due to smart-ness in fake-react-native, rough heuristic here to ensure we match (could be better..)\n if (!('staticConfig' in Component) && !isReactNativeWeb) {\n if (RNComponents.has(Component['displayName'])) {\n RNComponents.add(Component)\n isReactNativeWeb = true\n } else {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn(\n `Invalid styled() component: Tamagui only accepts react-native Text, View, Image, TextInput, or another styled Tamagui view`\n )\n }\n }\n }\n const reactNativeWebComponent = isReactNativeWeb\n ? parentStaticConfig?.reactNativeWebComponent || Component\n : null\n const isTamagui = !isReactNativeWeb && !!parentStaticConfig\n const Comp = reactNativeWebComponent || (Component as any)\n const isImage = Boolean(\n staticExtractionOptions?.isImage || parentStaticConfig?.isImage || Comp === Image\n )\n const isInput = Boolean(\n staticExtractionOptions?.isInput || parentStaticConfig?.isInput || Comp === TextInput\n )\n const isText = Boolean(\n isInput || staticExtractionOptions?.isText || parentStaticConfig?.isText || Comp === Text\n )\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\n }),\n isTamagui,\n // this type gets messed up by options?: Partial<GetProps<ParentComponent>> above\n // take away the Partial<> and it's fine\n variants,\n defaultProps,\n defaultVariants,\n componentName: name,\n isReactNativeWeb,\n // for nesting multiple levels of rnw styled() need keep use the OG component\n reactNativeWebComponent,\n isInput,\n isText,\n isImage,\n }\n\n return conf\n }\n return {}\n })()\n\n const component = createComponent(staticConfigProps, Component)\n\n // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = ParentComponent extends TamaguiComponent<any, any, infer P>\n ? P\n : GetProps<ParentComponent>\n type ParentVariants = ParentComponent extends TamaguiComponent<any, any, any, infer V> ? V : {}\n\n type OurVariants = Variants extends void\n ? {}\n : {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n }\n\n type VariantProps = Omit<ParentVariants, keyof OurVariants> & OurVariants\n type OurPropsBase = ParentPropsBase & VariantProps\n\n type Props = Variants extends void\n ? GetProps<ParentComponent>\n : // start with base props\n OurPropsBase &\n // add in media (+ pseudos nested)\n MediaProps<Partial<OurPropsBase>> &\n // add in pseudos\n PseudoProps<Partial<OurPropsBase>>\n\n return component as TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n}\n\n// import { Stack } from './views/Stack'\n// const X = styled(Stack, {\n// variants: {\n// size: {\n// '...size': (val) => {\n// return {}\n// }\n// },\n// disabled: {\n// true: {\n// opacity: 0.5,\n// pointerEvents: 'none',\n// },\n// },\n// } as const\n// })\n// type variants = GetStyledVariants<typeof X>\n// const y = <X disabled size=\"$10\" />\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAuC;AAEvC,6BAAgC;AAChC,0BAA6B;AAqBtB,SAAS,OAId,WAEA,SAMA,yBACA;AACA,QAAM,qBAAqB,MAAM;AAC/B,UAAM,qBACJ,kBAAkB,YAAa,UAAU,eAAgC;AAE3E,QAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,UAAI,yDAAoB,OAAO;AAE7B,gBAAQ;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,QAAI,SAAS;AACX,YAAM,EAAE,UAAU,MAAM,oBAAoB,aAAa,IAAI;AAC7D,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AACA,UAAI,oBAAmB,yDAAoB,qBAAoB,iCAAa,IAAI,SAAS;AAEzF,UAAI,EAAE,kBAAkB,cAAc,CAAC,kBAAkB;AACvD,YAAI,iCAAa,IAAI,UAAU,cAAc,GAAG;AAC9C,2CAAa,IAAI,SAAS;AAC1B,6BAAmB;AAAA,QACrB,OAAO;AACL,cAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,oBAAQ;AAAA,cACN;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,YAAM,0BAA0B,oBAC5B,yDAAoB,4BAA2B,YAC/C;AACJ,YAAM,YAAY,CAAC,oBAAoB,CAAC,CAAC;AACzC,YAAM,OAAO,2BAA4B;AACzC,YAAM,UAAU;AAAA,SACd,mEAAyB,aAAW,yDAAoB,YAAW,SAAS;AAAA,MAC9E;AACA,YAAM,UAAU;AAAA,SACd,mEAAyB,aAAW,yDAAoB,YAAW,SAAS;AAAA,MAC9E;AACA,YAAM,SAAS;AAAA,QACb,YAAW,mEAAyB,YAAU,yDAAoB,WAAU,SAAS;AAAA,MACvF;AAEA,YAAM,OAA8B;AAAA,QAClC,GAAG;AAAA,QACH,GAAI,CAAC,aAAa;AAAA,UAChB,WAAW;AAAA,QACb;AAAA,QACA;AAAA,QAGA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QAEA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,GAAG;AAEH,QAAM,gBAAY,wCAAgB,mBAAmB,SAAS;AA4B9D,SAAO;AAMT;",
4
+ "sourcesContent": ["import { Image, Text, TextInput } from 'react-native'\n\nimport { createComponent } from './createComponent'\nimport { RNComponents } from './helpers/RNComponents'\nimport {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n TamaguiElement,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types'\n\n// TODO may be able to use this in the options?: arg below directly\nexport type StyledOptions<ParentComponent extends StylableComponent> = GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n Component: ParentComponent,\n // this should be Partial<GetProps<ParentComponent>> but causes excessively deep type issues\n options?: GetProps<ParentComponent> & {\n name?: string\n variants?: Variants | undefined\n // thought i had this typed, but can't get it linked\n defaultVariants?: { [key: string]: any }\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n const staticConfigProps = (() => {\n const parentStaticConfig =\n 'staticConfig' in Component ? (Component.staticConfig as StaticConfig) : null\n\n if (process.env.NODE_ENV === 'development') {\n if (parentStaticConfig?.isHOC) {\n // eslint-disable-next-line no-console\n console.warn(\n `Warning: Parent component is a functional component, not a Tamagui styled() component. Extending with styled() will break and lead to incorrect styles.`\n )\n }\n }\n\n if (options) {\n const { variants, name, defaultVariants, ...defaultProps } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n let isReactNativeWeb = parentStaticConfig?.isReactNativeWeb || RNComponents.has(Component)\n // this can happen due to smart-ness in fake-react-native, rough heuristic here to ensure we match (could be better..)\n if (!('staticConfig' in Component) && !isReactNativeWeb) {\n if (RNComponents.has(Component['displayName'])) {\n RNComponents.add(Component)\n isReactNativeWeb = true\n } else {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn(\n `Invalid styled() component: Tamagui only accepts react-native Text, View, Image, TextInput, or another styled Tamagui view`\n )\n }\n }\n }\n const reactNativeWebComponent = isReactNativeWeb\n ? parentStaticConfig?.reactNativeWebComponent || Component\n : null\n const isTamagui = !isReactNativeWeb && !!parentStaticConfig\n const Comp = reactNativeWebComponent || (Component as any)\n const isImage = Boolean(\n staticExtractionOptions?.isImage || parentStaticConfig?.isImage || Comp === Image\n )\n const isInput = Boolean(\n staticExtractionOptions?.isInput || parentStaticConfig?.isInput || Comp === TextInput\n )\n const isText = Boolean(\n isInput || staticExtractionOptions?.isText || parentStaticConfig?.isText || Comp === Text\n )\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\n }),\n isTamagui,\n // this type gets messed up by options?: Partial<GetProps<ParentComponent>> above\n // take away the Partial<> and it's fine\n variants,\n defaultProps,\n defaultVariants,\n componentName: name,\n isReactNativeWeb,\n // for nesting multiple levels of rnw styled() need keep use the OG component\n reactNativeWebComponent,\n isInput,\n isText,\n isImage,\n }\n\n // TODO compiler doesn't have logic to include children, de-opt (see EnsureFlexed for test usage)\n if (defaultProps.children) {\n conf.neverFlatten = true\n }\n\n return conf\n }\n return {}\n })()\n\n const component = createComponent(staticConfigProps, Component)\n\n // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = ParentComponent extends TamaguiComponent<any, any, infer P>\n ? P\n : GetProps<ParentComponent>\n type ParentVariants = ParentComponent extends TamaguiComponent<any, any, any, infer V> ? V : {}\n\n type OurVariants = Variants extends void\n ? {}\n : {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n }\n\n type VariantProps = Omit<ParentVariants, keyof OurVariants> & OurVariants\n type OurPropsBase = ParentPropsBase & VariantProps\n\n type Props = Variants extends void\n ? GetProps<ParentComponent>\n : // start with base props\n OurPropsBase &\n // add in media (+ pseudos nested)\n MediaProps<Partial<OurPropsBase>> &\n // add in pseudos\n PseudoProps<Partial<OurPropsBase>>\n\n return component as TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n}\n\n// import { Stack } from './views/Stack'\n// const X = styled(Stack, {\n// variants: {\n// size: {\n// '...size': (val) => {\n// return {}\n// }\n// },\n// disabled: {\n// true: {\n// opacity: 0.5,\n// pointerEvents: 'none',\n// },\n// },\n// } as const\n// })\n// type variants = GetStyledVariants<typeof X>\n// const y = <X disabled size=\"$10\" />\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAuC;AAEvC,6BAAgC;AAChC,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ACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAGA,UAAI,aAAa,UAAU;AACzB,aAAK,eAAe;AAAA,MACtB;AAEA,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,GAAG;AAEH,QAAM,gBAAY,wCAAgB,mBAAmB,SAAS;AA4B9D,SAAO;AAMT;",
6
6
  "names": []
7
7
  }
@@ -57,6 +57,9 @@ function styled(Component, options, staticExtractionOptions) {
57
57
  isText,
58
58
  isImage
59
59
  };
60
+ if (defaultProps.children) {
61
+ conf.neverFlatten = true;
62
+ }
60
63
  return conf;
61
64
  }
62
65
  return {};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/styled.tsx"],
4
- "sourcesContent": ["import { Image, Text, TextInput } from 'react-native'\n\nimport { createComponent } from './createComponent'\nimport { RNComponents } from './helpers/RNComponents'\nimport {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n TamaguiElement,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types'\n\n// TODO may be able to use this in the options?: arg below directly\nexport type StyledOptions<ParentComponent extends StylableComponent> = GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n Component: ParentComponent,\n // this should be Partial<GetProps<ParentComponent>> but causes excessively deep type issues\n options?: GetProps<ParentComponent> & {\n name?: string\n variants?: Variants | undefined\n // thought i had this typed, but can't get it linked\n defaultVariants?: { [key: string]: any }\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n const staticConfigProps = (() => {\n const parentStaticConfig =\n 'staticConfig' in Component ? (Component.staticConfig as StaticConfig) : null\n\n if (process.env.NODE_ENV === 'development') {\n if (parentStaticConfig?.isHOC) {\n // eslint-disable-next-line no-console\n console.warn(\n `Warning: Parent component is a functional component, not a Tamagui styled() component. Extending with styled() will break and lead to incorrect styles.`\n )\n }\n }\n\n if (options) {\n const { variants, name, defaultVariants, ...defaultProps } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n let isReactNativeWeb = parentStaticConfig?.isReactNativeWeb || RNComponents.has(Component)\n // this can happen due to smart-ness in fake-react-native, rough heuristic here to ensure we match (could be better..)\n if (!('staticConfig' in Component) && !isReactNativeWeb) {\n if (RNComponents.has(Component['displayName'])) {\n RNComponents.add(Component)\n isReactNativeWeb = true\n } else {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn(\n `Invalid styled() component: Tamagui only accepts react-native Text, View, Image, TextInput, or another styled Tamagui view`\n )\n }\n }\n }\n const reactNativeWebComponent = isReactNativeWeb\n ? parentStaticConfig?.reactNativeWebComponent || Component\n : null\n const isTamagui = !isReactNativeWeb && !!parentStaticConfig\n const Comp = reactNativeWebComponent || (Component as any)\n const isImage = Boolean(\n staticExtractionOptions?.isImage || parentStaticConfig?.isImage || Comp === Image\n )\n const isInput = Boolean(\n staticExtractionOptions?.isInput || parentStaticConfig?.isInput || Comp === TextInput\n )\n const isText = Boolean(\n isInput || staticExtractionOptions?.isText || parentStaticConfig?.isText || Comp === Text\n )\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\n }),\n isTamagui,\n // this type gets messed up by options?: Partial<GetProps<ParentComponent>> above\n // take away the Partial<> and it's fine\n variants,\n defaultProps,\n defaultVariants,\n componentName: name,\n isReactNativeWeb,\n // for nesting multiple levels of rnw styled() need keep use the OG component\n reactNativeWebComponent,\n isInput,\n isText,\n isImage,\n }\n\n return conf\n }\n return {}\n })()\n\n const component = createComponent(staticConfigProps, Component)\n\n // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = ParentComponent extends TamaguiComponent<any, any, infer P>\n ? P\n : GetProps<ParentComponent>\n type ParentVariants = ParentComponent extends TamaguiComponent<any, any, any, infer V> ? V : {}\n\n type OurVariants = Variants extends void\n ? {}\n : {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n }\n\n type VariantProps = Omit<ParentVariants, keyof OurVariants> & OurVariants\n type OurPropsBase = ParentPropsBase & VariantProps\n\n type Props = Variants extends void\n ? GetProps<ParentComponent>\n : // start with base props\n OurPropsBase &\n // add in media (+ pseudos nested)\n MediaProps<Partial<OurPropsBase>> &\n // add in pseudos\n PseudoProps<Partial<OurPropsBase>>\n\n return component as TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n}\n\n// import { Stack } from './views/Stack'\n// const X = styled(Stack, {\n// variants: {\n// size: {\n// '...size': (val) => {\n// return {}\n// }\n// },\n// disabled: {\n// true: {\n// opacity: 0.5,\n// pointerEvents: 'none',\n// },\n// },\n// } as const\n// })\n// type variants = GetStyledVariants<typeof X>\n// const y = <X disabled size=\"$10\" />\n"],
5
- "mappings": "AAAA,SAAS,OAAO,MAAM,iBAAiB;AAEvC,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAqBtB,SAAS,OAId,WAEA,SAMA,yBACA;AACA,QAAM,qBAAqB,MAAM;AAC/B,UAAM,qBACJ,kBAAkB,YAAa,UAAU,eAAgC;AAE3E,QAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,UAAI,yDAAoB,OAAO;AAE7B,gBAAQ;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,QAAI,SAAS;AACX,YAAM,EAAE,UAAU,MAAM,oBAAoB,aAAa,IAAI;AAC7D,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AACA,UAAI,oBAAmB,yDAAoB,qBAAoB,aAAa,IAAI,SAAS;AAEzF,UAAI,EAAE,kBAAkB,cAAc,CAAC,kBAAkB;AACvD,YAAI,aAAa,IAAI,UAAU,cAAc,GAAG;AAC9C,uBAAa,IAAI,SAAS;AAC1B,6BAAmB;AAAA,QACrB,OAAO;AACL,cAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,oBAAQ;AAAA,cACN;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,YAAM,0BAA0B,oBAC5B,yDAAoB,4BAA2B,YAC/C;AACJ,YAAM,YAAY,CAAC,oBAAoB,CAAC,CAAC;AACzC,YAAM,OAAO,2BAA4B;AACzC,YAAM,UAAU;AAAA,SACd,mEAAyB,aAAW,yDAAoB,YAAW,SAAS;AAAA,MAC9E;AACA,YAAM,UAAU;AAAA,SACd,mEAAyB,aAAW,yDAAoB,YAAW,SAAS;AAAA,MAC9E;AACA,YAAM,SAAS;AAAA,QACb,YAAW,mEAAyB,YAAU,yDAAoB,WAAU,SAAS;AAAA,MACvF;AAEA,YAAM,OAA8B;AAAA,QAClC,GAAG;AAAA,QACH,GAAI,CAAC,aAAa;AAAA,UAChB,WAAW;AAAA,QACb;AAAA,QACA;AAAA,QAGA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QAEA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,GAAG;AAEH,QAAM,YAAY,gBAAgB,mBAAmB,SAAS;AA4B9D,SAAO;AAMT;",
4
+ "sourcesContent": ["import { Image, Text, TextInput } from 'react-native'\n\nimport { createComponent } from './createComponent'\nimport { RNComponents } from './helpers/RNComponents'\nimport {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n TamaguiElement,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types'\n\n// TODO may be able to use this in the options?: arg below directly\nexport type StyledOptions<ParentComponent extends StylableComponent> = GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n Component: ParentComponent,\n // this should be Partial<GetProps<ParentComponent>> but causes excessively deep type issues\n options?: GetProps<ParentComponent> & {\n name?: string\n variants?: Variants | undefined\n // thought i had this typed, but can't get it linked\n defaultVariants?: { [key: string]: any }\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n const staticConfigProps = (() => {\n const parentStaticConfig =\n 'staticConfig' in Component ? (Component.staticConfig as StaticConfig) : null\n\n if (process.env.NODE_ENV === 'development') {\n if (parentStaticConfig?.isHOC) {\n // eslint-disable-next-line no-console\n console.warn(\n `Warning: Parent component is a functional component, not a Tamagui styled() component. Extending with styled() will break and lead to incorrect styles.`\n )\n }\n }\n\n if (options) {\n const { variants, name, defaultVariants, ...defaultProps } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n let isReactNativeWeb = parentStaticConfig?.isReactNativeWeb || RNComponents.has(Component)\n // this can happen due to smart-ness in fake-react-native, rough heuristic here to ensure we match (could be better..)\n if (!('staticConfig' in Component) && !isReactNativeWeb) {\n if (RNComponents.has(Component['displayName'])) {\n RNComponents.add(Component)\n isReactNativeWeb = true\n } else {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn(\n `Invalid styled() component: Tamagui only accepts react-native Text, View, Image, TextInput, or another styled Tamagui view`\n )\n }\n }\n }\n const reactNativeWebComponent = isReactNativeWeb\n ? parentStaticConfig?.reactNativeWebComponent || Component\n : null\n const isTamagui = !isReactNativeWeb && !!parentStaticConfig\n const Comp = reactNativeWebComponent || (Component as any)\n const isImage = Boolean(\n staticExtractionOptions?.isImage || parentStaticConfig?.isImage || Comp === Image\n )\n const isInput = Boolean(\n staticExtractionOptions?.isInput || parentStaticConfig?.isInput || Comp === TextInput\n )\n const isText = Boolean(\n isInput || staticExtractionOptions?.isText || parentStaticConfig?.isText || Comp === Text\n )\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\n }),\n isTamagui,\n // this type gets messed up by options?: Partial<GetProps<ParentComponent>> above\n // take away the Partial<> and it's fine\n variants,\n defaultProps,\n defaultVariants,\n componentName: name,\n isReactNativeWeb,\n // for nesting multiple levels of rnw styled() need keep use the OG component\n reactNativeWebComponent,\n isInput,\n isText,\n isImage,\n }\n\n // TODO compiler doesn't have logic to include children, de-opt (see EnsureFlexed for test usage)\n if (defaultProps.children) {\n conf.neverFlatten = true\n }\n\n return conf\n }\n return {}\n })()\n\n const component = createComponent(staticConfigProps, Component)\n\n // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = ParentComponent extends TamaguiComponent<any, any, infer P>\n ? P\n : GetProps<ParentComponent>\n type ParentVariants = ParentComponent extends TamaguiComponent<any, any, any, infer V> ? V : {}\n\n type OurVariants = Variants extends void\n ? {}\n : {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n }\n\n type VariantProps = Omit<ParentVariants, keyof OurVariants> & OurVariants\n type OurPropsBase = ParentPropsBase & VariantProps\n\n type Props = Variants extends void\n ? GetProps<ParentComponent>\n : // start with base props\n OurPropsBase &\n // add in media (+ pseudos nested)\n MediaProps<Partial<OurPropsBase>> &\n // add in pseudos\n PseudoProps<Partial<OurPropsBase>>\n\n return component as TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n}\n\n// import { Stack } from './views/Stack'\n// const X = styled(Stack, {\n// variants: {\n// size: {\n// '...size': (val) => {\n// return {}\n// }\n// },\n// disabled: {\n// true: {\n// opacity: 0.5,\n// pointerEvents: 'none',\n// },\n// },\n// } as const\n// })\n// type variants = GetStyledVariants<typeof X>\n// const y = <X disabled size=\"$10\" />\n"],
5
+ "mappings": "AA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ACA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QAEA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAGA,UAAI,aAAa,UAAU;AACzB,aAAK,eAAe;AAAA,MACtB;AAEA,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,GAAG;AAEH,QAAM,YAAY,gBAAgB,mBAAmB,SAAS;AA4B9D,SAAO;AAMT;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/core",
3
- "version": "1.0.1-beta.165",
3
+ "version": "1.0.1-beta.166",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -15,6 +15,7 @@
15
15
  "scripts": {
16
16
  "build": "tamagui-build",
17
17
  "watch": "tamagui-build --watch",
18
+ "lint": "eslint",
18
19
  "clean": "tamagui-build clean",
19
20
  "clean:build": "tamagui-build clean:build",
20
21
  "test": "vitest --run --config ../vite-plugin-internal/src/vite.config.ts"
@@ -27,14 +28,14 @@
27
28
  ],
28
29
  "dependencies": {
29
30
  "@expo/match-media": "^0.3.0",
30
- "@tamagui/compose-refs": "^1.0.1-beta.165",
31
- "@tamagui/helpers": "^1.0.1-beta.165",
32
- "@tamagui/normalize-css-color-lite": "^1.0.1-beta.165",
33
- "@tamagui/rnw": "^1.0.1-beta.165",
34
- "@tamagui/rnw-lite": "^1.0.1-beta.165",
35
- "@tamagui/use-debounce": "^1.0.1-beta.165",
36
- "@tamagui/use-event": "^1.0.1-beta.165",
37
- "@tamagui/use-force-update": "^1.0.1-beta.165",
31
+ "@tamagui/compose-refs": "^1.0.1-beta.166",
32
+ "@tamagui/helpers": "^1.0.1-beta.166",
33
+ "@tamagui/normalize-css-color-lite": "^1.0.1-beta.166",
34
+ "@tamagui/rnw": "^1.0.1-beta.166",
35
+ "@tamagui/rnw-lite": "^1.0.1-beta.166",
36
+ "@tamagui/use-debounce": "^1.0.1-beta.166",
37
+ "@tamagui/use-event": "^1.0.1-beta.166",
38
+ "@tamagui/use-force-update": "^1.0.1-beta.166",
38
39
  "expo-screen-orientation": "^4.3.0",
39
40
  "hyphenate-style-name": "^1.0.4"
40
41
  },
@@ -43,7 +44,7 @@
43
44
  "react-dom": "*"
44
45
  },
45
46
  "devDependencies": {
46
- "@tamagui/build": "^1.0.1-beta.165",
47
+ "@tamagui/build": "^1.0.1-beta.166",
47
48
  "@types/react": "^18.0.15",
48
49
  "csstype": "^3.0.10",
49
50
  "esbuild": "^0.15.6",
package/src/styled.tsx CHANGED
@@ -104,6 +104,11 @@ export function styled<
104
104
  isImage,
105
105
  }
106
106
 
107
+ // TODO compiler doesn't have logic to include children, de-opt (see EnsureFlexed for test usage)
108
+ if (defaultProps.children) {
109
+ conf.neverFlatten = true
110
+ }
111
+
107
112
  return conf
108
113
  }
109
114
  return {}