@tamagui/web 1.15.4 → 1.15.6

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/styled.tsx"],
4
- "sourcesContent": ["import { stylePropsAll } from '@tamagui/helpers'\nimport { forwardRef } from 'react'\n\nimport { createComponent } from './createComponent.js'\nimport { ReactNativeStaticConfigs } from './setupReactNative.js'\nimport type {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n TamaguiElement,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types.js'\n\n// TODO may be able to use this in the options?: arg below directly\nexport type StyledOptions<ParentComponent extends StylableComponent> =\n GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n }\n\ntype GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n infer P\n>\n ? P\n : GetProps<A>\n\ntype GetVariantProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n any,\n infer V\n>\n ? V\n : {}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n ComponentIn: 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 acceptsClassName?: boolean\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n // validate not using a variant over an existing valid style\n if (process.env.NODE_ENV !== 'production') {\n if (!ComponentIn) {\n throw new Error(`No component given to styled()`)\n }\n if (options?.variants) {\n for (const key in options.variants) {\n if (key in stylePropsAll) {\n console.error(\n `Invalid variant key overlaps with style key: ${key}. Tamagui prevents defining variants that use valid style keys to reduce complexity and confusion.`\n )\n }\n }\n }\n }\n\n const parentStaticConfig =\n 'staticConfig' in ComponentIn ? (ComponentIn.staticConfig as StaticConfig) : null\n\n const isPlainStyledComponent =\n !!parentStaticConfig &&\n !(parentStaticConfig.isReactNative || parentStaticConfig.isHOC)\n\n const Component: any = isPlainStyledComponent\n ? ComponentIn\n : parentStaticConfig?.Component || ComponentIn\n\n const isReactNative = Boolean(\n ReactNativeStaticConfigs.has(Component) ||\n staticExtractionOptions?.isReactNative ||\n ReactNativeStaticConfigs.has(parentStaticConfig?.Component) ||\n parentStaticConfig?.isReactNative\n )\n\n const staticConfigProps = (() => {\n if (options) {\n const {\n variants,\n name,\n defaultVariants,\n acceptsClassName: acceptsClassNameProp,\n ...defaultProps\n } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n\n const nativeConf =\n (isReactNative && ReactNativeStaticConfigs.get(Component)) || null\n\n const isText = Boolean(\n staticExtractionOptions?.isText || parentStaticConfig?.isText\n )\n const acceptsClassName =\n acceptsClassNameProp ??\n (isPlainStyledComponent ||\n isReactNative ||\n (parentStaticConfig?.isHOC && parentStaticConfig?.acceptsClassName))\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isPlainStyledComponent && {\n Component,\n }),\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 || parentStaticConfig?.componentName,\n isReactNative,\n isText,\n acceptsClassName,\n ...nativeConf,\n }\n\n // bail on non className views as well\n if (defaultProps.children || !acceptsClassName) {\n conf.neverFlatten = true\n }\n\n return conf\n }\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 // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = GetBaseProps<ParentComponent>\n type ParentVariants = GetVariantProps<ParentComponent>\n\n type OurVariants = Variants extends void\n ? {}\n : {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<\n any,\n infer Val\n >\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 type ParentStaticProperties = {\n [Key in Exclude<\n keyof ParentComponent,\n 'defaultProps' | 'propTypes' | '$$typeof' | 'staticConfig' | 'extractable'\n >]: ParentComponent[Key]\n }\n\n type StyledComponent = TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariants,\n ParentStaticProperties\n >\n\n for (const key in ComponentIn) {\n if (key in component) continue\n // @ts-expect-error assigning static properties over\n component[key] = ComponentIn[key]\n }\n\n return component as any as StyledComponent\n}\n\n// sanity check types\n// import { Stack } from './views/Stack'\n// const X = styled(Stack, {\n// variants: {\n// size: {\n// '...size': (val) => {\n// return {\n// pointerEvents: 'auto'\n// }\n// }\n// },\n// disabled: {\n// true: {\n// alignContent: 'center',\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,qBAA8B;AAG9B,6BAAgC;AAChC,8BAAyC;AAuClC,SAAS,OAId,aAEA,SAOA,yBACA;AAEA,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QAAI,CAAC,aAAa;AAChB,YAAM,IAAI,MAAM,gCAAgC;AAAA,IAClD;AACA,QAAI,mCAAS,UAAU;AACrB,iBAAW,OAAO,QAAQ,UAAU;AAClC,YAAI,OAAO,8BAAe;AACxB,kBAAQ;AAAA,YACN,gDAAg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ClC;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { stylePropsAll } from '@tamagui/helpers'\nimport { forwardRef } from 'react'\n\nimport { createComponent } from './createComponent.js'\nimport { ReactNativeStaticConfigs } from './setupReactNative.js'\nimport type {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n TamaguiElement,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types.js'\n\ntype GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n infer P\n>\n ? P\n : GetProps<A>\n\ntype GetVariantProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n any,\n infer V\n>\n ? V\n : {}\n\ntype GetVariantAcceptedValues<V> = V extends Object\n ? {\n [Key in keyof V]?: V[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof V[Key]>\n }\n : undefined\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n ComponentIn: 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?: GetVariantAcceptedValues<Variants>\n acceptsClassName?: boolean\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n // validate not using a variant over an existing valid style\n if (process.env.NODE_ENV !== 'production') {\n if (!ComponentIn) {\n throw new Error(`No component given to styled()`)\n }\n if (options?.variants) {\n for (const key in options.variants) {\n if (key in stylePropsAll) {\n console.error(\n `Invalid variant key overlaps with style key: ${key}. Tamagui prevents defining variants that use valid style keys to reduce complexity and confusion.`\n )\n }\n }\n }\n }\n\n const parentStaticConfig =\n 'staticConfig' in ComponentIn ? (ComponentIn.staticConfig as StaticConfig) : null\n\n const isPlainStyledComponent =\n !!parentStaticConfig &&\n !(parentStaticConfig.isReactNative || parentStaticConfig.isHOC)\n\n const Component: any = isPlainStyledComponent\n ? ComponentIn\n : parentStaticConfig?.Component || ComponentIn\n\n const isReactNative = Boolean(\n ReactNativeStaticConfigs.has(Component) ||\n staticExtractionOptions?.isReactNative ||\n ReactNativeStaticConfigs.has(parentStaticConfig?.Component) ||\n parentStaticConfig?.isReactNative\n )\n\n const staticConfigProps = (() => {\n if (options) {\n const {\n variants,\n name,\n defaultVariants,\n acceptsClassName: acceptsClassNameProp,\n ...defaultProps\n } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n\n const nativeConf =\n (isReactNative && ReactNativeStaticConfigs.get(Component)) || null\n\n const isText = Boolean(\n staticExtractionOptions?.isText || parentStaticConfig?.isText\n )\n const acceptsClassName =\n acceptsClassNameProp ??\n (isPlainStyledComponent ||\n isReactNative ||\n (parentStaticConfig?.isHOC && parentStaticConfig?.acceptsClassName))\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isPlainStyledComponent && {\n Component,\n }),\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 || parentStaticConfig?.componentName,\n isReactNative,\n isText,\n acceptsClassName,\n ...nativeConf,\n }\n\n // bail on non className views as well\n if (defaultProps.children || !acceptsClassName) {\n conf.neverFlatten = true\n }\n\n return conf\n }\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 // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = GetBaseProps<ParentComponent>\n type ParentVariants = GetVariantProps<ParentComponent>\n\n type OurVariantProps = GetVariantAcceptedValues<Variants>\n\n type VariantProps = Omit<ParentVariants, keyof OurVariantProps> & OurVariantProps\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 type ParentStaticProperties = {\n [Key in Exclude<\n keyof ParentComponent,\n 'defaultProps' | 'propTypes' | '$$typeof' | 'staticConfig' | 'extractable'\n >]: ParentComponent[Key]\n }\n\n type StyledComponent = TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariantProps,\n ParentStaticProperties\n >\n\n for (const key in ComponentIn) {\n if (key in component) continue\n // @ts-expect-error assigning static properties over\n component[key] = ComponentIn[key]\n }\n\n return component as any as StyledComponent\n}\n\n// sanity check types\n// import { Stack } from './views/Stack'\n// const X = styled(Stack, {\n// variants: {\n// size: {\n// '...size': (val) => {\n// return {\n// pointerEvents: 'auto'\n// }\n// }\n// },\n// disabled: {\n// true: {\n// alignContent: 'center',\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,qBAA8B;AAG9B,6BAAgC;AAChC,8BAAyC;AAuClC,SAAS,OAId,aAEA,SAOA,yBACA;AAEA,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QAAI,CAAC,aAAa;AAChB,YAAM,IAAI,MAAM,gCAAgC;AAAA,IAClD;AACA,QAAI,mCAAS,UAAU;AACrB,iBAAW,OAAO,QAAQ,UAAU;AAClC,YAAI,OAAO,8BAAe;AACxB,kBAAQ;AAAA,YACN,gDAAgD;AAAA,UAClD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,qBACJ,kBAAkB,cAAe,YAAY,eAAgC;AAE/E,QAAM,yBACJ,CAAC,CAAC,sBACF,EAAE,mBAAmB,iBAAiB,mBAAmB;AAE3D,QAAM,YAAiB,yBACnB,eACA,yDAAoB,cAAa;AAErC,QAAM,gBAAgB;AAAA,IACpB,iDAAyB,IAAI,SAAS,MACpC,mEAAyB,kBACzB,iDAAyB,IAAI,yDAAoB,SAAS,MAC1D,yDAAoB;AAAA,EACxB;AAEA,QAAM,qBAAqB,MAAM;AAC/B,QAAI,SAAS;AACX,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA,kBAAkB;AAAA,QAClB,GAAG;AAAA,MACL,IAAI;AACJ,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AAEA,YAAM,aACH,iBAAiB,iDAAyB,IAAI,SAAS,KAAM;AAEhE,YAAM,SAAS;AAAA,SACb,mEAAyB,YAAU,yDAAoB;AAAA,MACzD;AACA,YAAM,mBACJ,yBACC,0BACC,kBACC,yDAAoB,WAAS,yDAAoB;AAEtD,YAAM,OAA8B;AAAA,QAClC,GAAG;AAAA,QACH,GAAI,CAAC,0BAA0B;AAAA,UAC7B;AAAA,QACF;AAAA;AAAA;AAAA,QAGA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe,SAAQ,yDAAoB;AAAA,QAC3C;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MACL;AAGA,UAAI,aAAa,YAAY,CAAC,kBAAkB;AAC9C,aAAK,eAAe;AAAA,MACtB;AAEA,aAAO;AAAA,IACT;AAAA,EACF,GAAG;AAEH,QAAM,gBAAY,wCAAgB,qBAAqB,CAAC,GAAG,SAAS;AAoCpE,aAAW,OAAO,aAAa;AAC7B,QAAI,OAAO;AAAW;AAEtB,cAAU,GAAG,IAAI,YAAY,GAAG;AAAA,EAClC;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/styled.tsx"],
4
- "sourcesContent": ["import { stylePropsAll } from '@tamagui/helpers'\nimport { forwardRef } from 'react'\n\nimport { createComponent } from './createComponent.js'\nimport { ReactNativeStaticConfigs } from './setupReactNative.js'\nimport type {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n TamaguiElement,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types.js'\n\n// TODO may be able to use this in the options?: arg below directly\nexport type StyledOptions<ParentComponent extends StylableComponent> =\n GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n }\n\ntype GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n infer P\n>\n ? P\n : GetProps<A>\n\ntype GetVariantProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n any,\n infer V\n>\n ? V\n : {}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n ComponentIn: 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 acceptsClassName?: boolean\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n // validate not using a variant over an existing valid style\n if (process.env.NODE_ENV !== 'production') {\n if (!ComponentIn) {\n throw new Error(`No component given to styled()`)\n }\n if (options?.variants) {\n for (const key in options.variants) {\n if (key in stylePropsAll) {\n console.error(\n `Invalid variant key overlaps with style key: ${key}. Tamagui prevents defining variants that use valid style keys to reduce complexity and confusion.`\n )\n }\n }\n }\n }\n\n const parentStaticConfig =\n 'staticConfig' in ComponentIn ? (ComponentIn.staticConfig as StaticConfig) : null\n\n const isPlainStyledComponent =\n !!parentStaticConfig &&\n !(parentStaticConfig.isReactNative || parentStaticConfig.isHOC)\n\n const Component: any = isPlainStyledComponent\n ? ComponentIn\n : parentStaticConfig?.Component || ComponentIn\n\n const isReactNative = Boolean(\n ReactNativeStaticConfigs.has(Component) ||\n staticExtractionOptions?.isReactNative ||\n ReactNativeStaticConfigs.has(parentStaticConfig?.Component) ||\n parentStaticConfig?.isReactNative\n )\n\n const staticConfigProps = (() => {\n if (options) {\n const {\n variants,\n name,\n defaultVariants,\n acceptsClassName: acceptsClassNameProp,\n ...defaultProps\n } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n\n const nativeConf =\n (isReactNative && ReactNativeStaticConfigs.get(Component)) || null\n\n const isText = Boolean(\n staticExtractionOptions?.isText || parentStaticConfig?.isText\n )\n const acceptsClassName =\n acceptsClassNameProp ??\n (isPlainStyledComponent ||\n isReactNative ||\n (parentStaticConfig?.isHOC && parentStaticConfig?.acceptsClassName))\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isPlainStyledComponent && {\n Component,\n }),\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 || parentStaticConfig?.componentName,\n isReactNative,\n isText,\n acceptsClassName,\n ...nativeConf,\n }\n\n // bail on non className views as well\n if (defaultProps.children || !acceptsClassName) {\n conf.neverFlatten = true\n }\n\n return conf\n }\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 // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = GetBaseProps<ParentComponent>\n type ParentVariants = GetVariantProps<ParentComponent>\n\n type OurVariants = Variants extends void\n ? {}\n : {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<\n any,\n infer Val\n >\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 type ParentStaticProperties = {\n [Key in Exclude<\n keyof ParentComponent,\n 'defaultProps' | 'propTypes' | '$$typeof' | 'staticConfig' | 'extractable'\n >]: ParentComponent[Key]\n }\n\n type StyledComponent = TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariants,\n ParentStaticProperties\n >\n\n for (const key in ComponentIn) {\n if (key in component) continue\n // @ts-expect-error assigning static properties over\n component[key] = ComponentIn[key]\n }\n\n return component as any as StyledComponent\n}\n\n// sanity check types\n// import { Stack } from './views/Stack'\n// const X = styled(Stack, {\n// variants: {\n// size: {\n// '...size': (val) => {\n// return {\n// pointerEvents: 'auto'\n// }\n// }\n// },\n// disabled: {\n// true: {\n// alignContent: 'center',\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,qBAAqB;AAG9B,SAAS,uBAAuB;AAChC,SAAS,gCAAgC;AAuClC,SAAS,OAId,aAEA,SAOA,yBACA;AAEA,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QAAI,CAAC,aAAa;AAChB,YAAM,IAAI,MAAM,gCAAgC;AAAA,IAClD;AACA,QAAI,mCAAS,UAAU;AACrB,iBAAW,OAAO,QAAQ,UAAU;AAClC,YAAI,OAAO,eAAe;AACxB,kBAAQ;AAAA,YACN,gDAAgD;AAAA,UAClD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,qBACJ,kBAAkB,cAAe,YAAY,eAAgC;AAE/E,QAAM,yBACJ,CAAC,CAAC,sBACF,EAAE,mBAAmB,iBAAiB,mBAAmB;AAE3D,QAAM,YAAiB,yBACnB,eACA,yDAAoB,cAAa;AAErC,QAAM,gBAAgB;AAAA,IACpB,yBAAyB,IAAI,SAAS,MACpC,mEAAyB,kBACzB,yBAAyB,IAAI,yDAAoB,SAAS,MAC1D,yDAAoB;AAAA,EACxB;AAEA,QAAM,qBAAqB,MAAM;AAC/B,QAAI,SAAS;AACX,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA,kBAAkB;AAAA,QAClB,GAAG;AAAA,MACL,IAAI;AACJ,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AAEA,YAAM,aACH,iBAAiB,yBAAyB,IAAI,SAAS,KAAM;AAEhE,YAAM,SAAS;AAAA,SACb,mEAAyB,YAAU,yDAAoB;AAAA,MACzD;AACA,YAAM,mBACJ,yBACC,0BACC,kBACC,yDAAoB,WAAS,yDAAoB;AAEtD,YAAM,OAA8B;AAAA,QAClC,GAAG;AAAA,QACH,GAAI,CAAC,0BAA0B;AAAA,UAC7B;AAAA,QACF;AAAA;AAAA;AAAA,QAGA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe,SAAQ,yDAAoB;AAAA,QAC3C;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MACL;AAGA,UAAI,aAAa,YAAY,CAAC,kBAAkB;AAC9C,aAAK,eAAe;AAAA,MACtB;AAEA,aAAO;AAAA,IACT;AAAA,EACF,GAAG;AAEH,QAAM,YAAY,gBAAgB,qBAAqB,CAAC,GAAG,SAAS;AA6CpE,aAAW,OAAO,aAAa;AAC7B,QAAI,OAAO;AAAW;AAEtB,cAAU,GAAG,IAAI,YAAY,GAAG;AAAA,EAClC;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { stylePropsAll } from '@tamagui/helpers'\nimport { forwardRef } from 'react'\n\nimport { createComponent } from './createComponent.js'\nimport { ReactNativeStaticConfigs } from './setupReactNative.js'\nimport type {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n TamaguiElement,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types.js'\n\ntype GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n infer P\n>\n ? P\n : GetProps<A>\n\ntype GetVariantProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n any,\n infer V\n>\n ? V\n : {}\n\ntype GetVariantAcceptedValues<V> = V extends Object\n ? {\n [Key in keyof V]?: V[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof V[Key]>\n }\n : undefined\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n ComponentIn: 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?: GetVariantAcceptedValues<Variants>\n acceptsClassName?: boolean\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n // validate not using a variant over an existing valid style\n if (process.env.NODE_ENV !== 'production') {\n if (!ComponentIn) {\n throw new Error(`No component given to styled()`)\n }\n if (options?.variants) {\n for (const key in options.variants) {\n if (key in stylePropsAll) {\n console.error(\n `Invalid variant key overlaps with style key: ${key}. Tamagui prevents defining variants that use valid style keys to reduce complexity and confusion.`\n )\n }\n }\n }\n }\n\n const parentStaticConfig =\n 'staticConfig' in ComponentIn ? (ComponentIn.staticConfig as StaticConfig) : null\n\n const isPlainStyledComponent =\n !!parentStaticConfig &&\n !(parentStaticConfig.isReactNative || parentStaticConfig.isHOC)\n\n const Component: any = isPlainStyledComponent\n ? ComponentIn\n : parentStaticConfig?.Component || ComponentIn\n\n const isReactNative = Boolean(\n ReactNativeStaticConfigs.has(Component) ||\n staticExtractionOptions?.isReactNative ||\n ReactNativeStaticConfigs.has(parentStaticConfig?.Component) ||\n parentStaticConfig?.isReactNative\n )\n\n const staticConfigProps = (() => {\n if (options) {\n const {\n variants,\n name,\n defaultVariants,\n acceptsClassName: acceptsClassNameProp,\n ...defaultProps\n } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n\n const nativeConf =\n (isReactNative && ReactNativeStaticConfigs.get(Component)) || null\n\n const isText = Boolean(\n staticExtractionOptions?.isText || parentStaticConfig?.isText\n )\n const acceptsClassName =\n acceptsClassNameProp ??\n (isPlainStyledComponent ||\n isReactNative ||\n (parentStaticConfig?.isHOC && parentStaticConfig?.acceptsClassName))\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isPlainStyledComponent && {\n Component,\n }),\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 || parentStaticConfig?.componentName,\n isReactNative,\n isText,\n acceptsClassName,\n ...nativeConf,\n }\n\n // bail on non className views as well\n if (defaultProps.children || !acceptsClassName) {\n conf.neverFlatten = true\n }\n\n return conf\n }\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 // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = GetBaseProps<ParentComponent>\n type ParentVariants = GetVariantProps<ParentComponent>\n\n type OurVariantProps = GetVariantAcceptedValues<Variants>\n\n type VariantProps = Omit<ParentVariants, keyof OurVariantProps> & OurVariantProps\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 type ParentStaticProperties = {\n [Key in Exclude<\n keyof ParentComponent,\n 'defaultProps' | 'propTypes' | '$$typeof' | 'staticConfig' | 'extractable'\n >]: ParentComponent[Key]\n }\n\n type StyledComponent = TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariantProps,\n ParentStaticProperties\n >\n\n for (const key in ComponentIn) {\n if (key in component) continue\n // @ts-expect-error assigning static properties over\n component[key] = ComponentIn[key]\n }\n\n return component as any as StyledComponent\n}\n\n// sanity check types\n// import { Stack } from './views/Stack'\n// const X = styled(Stack, {\n// variants: {\n// size: {\n// '...size': (val) => {\n// return {\n// pointerEvents: 'auto'\n// }\n// }\n// },\n// disabled: {\n// true: {\n// alignContent: 'center',\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,qBAAqB;AAG9B,SAAS,uBAAuB;AAChC,SAAS,gCAAgC;AAuClC,SAAS,OAId,aAEA,SAOA,yBACA;AAEA,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QAAI,CAAC,aAAa;AAChB,YAAM,IAAI,MAAM,gCAAgC;AAAA,IAClD;AACA,QAAI,mCAAS,UAAU;AACrB,iBAAW,OAAO,QAAQ,UAAU;AAClC,YAAI,OAAO,eAAe;AACxB,kBAAQ;AAAA,YACN,gDAAgD;AAAA,UAClD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,qBACJ,kBAAkB,cAAe,YAAY,eAAgC;AAE/E,QAAM,yBACJ,CAAC,CAAC,sBACF,EAAE,mBAAmB,iBAAiB,mBAAmB;AAE3D,QAAM,YAAiB,yBACnB,eACA,yDAAoB,cAAa;AAErC,QAAM,gBAAgB;AAAA,IACpB,yBAAyB,IAAI,SAAS,MACpC,mEAAyB,kBACzB,yBAAyB,IAAI,yDAAoB,SAAS,MAC1D,yDAAoB;AAAA,EACxB;AAEA,QAAM,qBAAqB,MAAM;AAC/B,QAAI,SAAS;AACX,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA,kBAAkB;AAAA,QAClB,GAAG;AAAA,MACL,IAAI;AACJ,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AAEA,YAAM,aACH,iBAAiB,yBAAyB,IAAI,SAAS,KAAM;AAEhE,YAAM,SAAS;AAAA,SACb,mEAAyB,YAAU,yDAAoB;AAAA,MACzD;AACA,YAAM,mBACJ,yBACC,0BACC,kBACC,yDAAoB,WAAS,yDAAoB;AAEtD,YAAM,OAA8B;AAAA,QAClC,GAAG;AAAA,QACH,GAAI,CAAC,0BAA0B;AAAA,UAC7B;AAAA,QACF;AAAA;AAAA;AAAA,QAGA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe,SAAQ,yDAAoB;AAAA,QAC3C;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MACL;AAGA,UAAI,aAAa,YAAY,CAAC,kBAAkB;AAC9C,aAAK,eAAe;AAAA,MACtB;AAEA,aAAO;AAAA,IACT;AAAA,EACF,GAAG;AAEH,QAAM,YAAY,gBAAgB,qBAAqB,CAAC,GAAG,SAAS;AAoCpE,aAAW,OAAO,aAAa;AAC7B,QAAI,OAAO;AAAW;AAEtB,cAAU,GAAG,IAAI,YAAY,GAAG;AAAA,EAClC;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/styled.tsx"],
4
- "sourcesContent": ["import { stylePropsAll } from '@tamagui/helpers'\nimport { forwardRef } from 'react'\n\nimport { createComponent } from './createComponent.js'\nimport { ReactNativeStaticConfigs } from './setupReactNative.js'\nimport type {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n TamaguiElement,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types.js'\n\n// TODO may be able to use this in the options?: arg below directly\nexport type StyledOptions<ParentComponent extends StylableComponent> =\n GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n }\n\ntype GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n infer P\n>\n ? P\n : GetProps<A>\n\ntype GetVariantProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n any,\n infer V\n>\n ? V\n : {}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n ComponentIn: 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 acceptsClassName?: boolean\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n // validate not using a variant over an existing valid style\n if (process.env.NODE_ENV !== 'production') {\n if (!ComponentIn) {\n throw new Error(`No component given to styled()`)\n }\n if (options?.variants) {\n for (const key in options.variants) {\n if (key in stylePropsAll) {\n console.error(\n `Invalid variant key overlaps with style key: ${key}. Tamagui prevents defining variants that use valid style keys to reduce complexity and confusion.`\n )\n }\n }\n }\n }\n\n const parentStaticConfig =\n 'staticConfig' in ComponentIn ? (ComponentIn.staticConfig as StaticConfig) : null\n\n const isPlainStyledComponent =\n !!parentStaticConfig &&\n !(parentStaticConfig.isReactNative || parentStaticConfig.isHOC)\n\n const Component: any = isPlainStyledComponent\n ? ComponentIn\n : parentStaticConfig?.Component || ComponentIn\n\n const isReactNative = Boolean(\n ReactNativeStaticConfigs.has(Component) ||\n staticExtractionOptions?.isReactNative ||\n ReactNativeStaticConfigs.has(parentStaticConfig?.Component) ||\n parentStaticConfig?.isReactNative\n )\n\n const staticConfigProps = (() => {\n if (options) {\n const {\n variants,\n name,\n defaultVariants,\n acceptsClassName: acceptsClassNameProp,\n ...defaultProps\n } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n\n const nativeConf =\n (isReactNative && ReactNativeStaticConfigs.get(Component)) || null\n\n const isText = Boolean(\n staticExtractionOptions?.isText || parentStaticConfig?.isText\n )\n const acceptsClassName =\n acceptsClassNameProp ??\n (isPlainStyledComponent ||\n isReactNative ||\n (parentStaticConfig?.isHOC && parentStaticConfig?.acceptsClassName))\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isPlainStyledComponent && {\n Component,\n }),\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 || parentStaticConfig?.componentName,\n isReactNative,\n isText,\n acceptsClassName,\n ...nativeConf,\n }\n\n // bail on non className views as well\n if (defaultProps.children || !acceptsClassName) {\n conf.neverFlatten = true\n }\n\n return conf\n }\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 // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = GetBaseProps<ParentComponent>\n type ParentVariants = GetVariantProps<ParentComponent>\n\n type OurVariants = Variants extends void\n ? {}\n : {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<\n any,\n infer Val\n >\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 type ParentStaticProperties = {\n [Key in Exclude<\n keyof ParentComponent,\n 'defaultProps' | 'propTypes' | '$$typeof' | 'staticConfig' | 'extractable'\n >]: ParentComponent[Key]\n }\n\n type StyledComponent = TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariants,\n ParentStaticProperties\n >\n\n for (const key in ComponentIn) {\n if (key in component) continue\n // @ts-expect-error assigning static properties over\n component[key] = ComponentIn[key]\n }\n\n return component as any as StyledComponent\n}\n\n// sanity check types\n// import { Stack } from './views/Stack'\n// const X = styled(Stack, {\n// variants: {\n// size: {\n// '...size': (val) => {\n// return {\n// pointerEvents: 'auto'\n// }\n// }\n// },\n// disabled: {\n// true: {\n// alignContent: 'center',\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,qBAAqB;AAG9B,SAAS,uBAAuB;AAChC,SAAS,gCAAgC;AAuClC,SAAS,OAId,aAEA,SAOA,yBACA;AAEA,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QAAI,CAAC,aAAa;AAChB,YAAM,IAAI,MAAM,gCAAgC;AAAA,IAClD;AACA,QAAI,mCAAS,UAAU;AACrB,iBAAW,OAAO,QAAQ,UAAU;AAClC,YAAI,OAAO,eAAe;AACxB,kBAAQ;AAAA,YACN,gDAAgD;AAAA,UAClD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,qBACJ,kBAAkB,cAAe,YAAY,eAAgC;AAE/E,QAAM,yBACJ,CAAC,CAAC,sBACF,EAAE,mBAAmB,iBAAiB,mBAAmB;AAE3D,QAAM,YAAiB,yBACnB,eACA,yDAAoB,cAAa;AAErC,QAAM,gBAAgB;AAAA,IACpB,yBAAyB,IAAI,SAAS,MACpC,mEAAyB,kBACzB,yBAAyB,IAAI,yDAAoB,SAAS,MAC1D,yDAAoB;AAAA,EACxB;AAEA,QAAM,qBAAqB,MAAM;AAC/B,QAAI,SAAS;AACX,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA,kBAAkB;AAAA,QAClB,GAAG;AAAA,MACL,IAAI;AACJ,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AAEA,YAAM,aACH,iBAAiB,yBAAyB,IAAI,SAAS,KAAM;AAEhE,YAAM,SAAS;AAAA,SACb,mEAAyB,YAAU,yDAAoB;AAAA,MACzD;AACA,YAAM,mBACJ,yBACC,0BACC,kBACC,yDAAoB,WAAS,yDAAoB;AAEtD,YAAM,OAA8B;AAAA,QAClC,GAAG;AAAA,QACH,GAAI,CAAC,0BAA0B;AAAA,UAC7B;AAAA,QACF;AAAA;AAAA;AAAA,QAGA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe,SAAQ,yDAAoB;AAAA,QAC3C;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MACL;AAGA,UAAI,aAAa,YAAY,CAAC,kBAAkB;AAC9C,aAAK,eAAe;AAAA,MACtB;AAEA,aAAO;AAAA,IACT;AAAA,EACF,GAAG;AAEH,QAAM,YAAY,gBAAgB,qBAAqB,CAAC,GAAG,SAAS;AA6CpE,aAAW,OAAO,aAAa;AAC7B,QAAI,OAAO;AAAW;AAEtB,cAAU,GAAG,IAAI,YAAY,GAAG;AAAA,EAClC;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { stylePropsAll } from '@tamagui/helpers'\nimport { forwardRef } from 'react'\n\nimport { createComponent } from './createComponent.js'\nimport { ReactNativeStaticConfigs } from './setupReactNative.js'\nimport type {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n TamaguiElement,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types.js'\n\ntype GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n infer P\n>\n ? P\n : GetProps<A>\n\ntype GetVariantProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n any,\n infer V\n>\n ? V\n : {}\n\ntype GetVariantAcceptedValues<V> = V extends Object\n ? {\n [Key in keyof V]?: V[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof V[Key]>\n }\n : undefined\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n ComponentIn: 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?: GetVariantAcceptedValues<Variants>\n acceptsClassName?: boolean\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n // validate not using a variant over an existing valid style\n if (process.env.NODE_ENV !== 'production') {\n if (!ComponentIn) {\n throw new Error(`No component given to styled()`)\n }\n if (options?.variants) {\n for (const key in options.variants) {\n if (key in stylePropsAll) {\n console.error(\n `Invalid variant key overlaps with style key: ${key}. Tamagui prevents defining variants that use valid style keys to reduce complexity and confusion.`\n )\n }\n }\n }\n }\n\n const parentStaticConfig =\n 'staticConfig' in ComponentIn ? (ComponentIn.staticConfig as StaticConfig) : null\n\n const isPlainStyledComponent =\n !!parentStaticConfig &&\n !(parentStaticConfig.isReactNative || parentStaticConfig.isHOC)\n\n const Component: any = isPlainStyledComponent\n ? ComponentIn\n : parentStaticConfig?.Component || ComponentIn\n\n const isReactNative = Boolean(\n ReactNativeStaticConfigs.has(Component) ||\n staticExtractionOptions?.isReactNative ||\n ReactNativeStaticConfigs.has(parentStaticConfig?.Component) ||\n parentStaticConfig?.isReactNative\n )\n\n const staticConfigProps = (() => {\n if (options) {\n const {\n variants,\n name,\n defaultVariants,\n acceptsClassName: acceptsClassNameProp,\n ...defaultProps\n } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n\n const nativeConf =\n (isReactNative && ReactNativeStaticConfigs.get(Component)) || null\n\n const isText = Boolean(\n staticExtractionOptions?.isText || parentStaticConfig?.isText\n )\n const acceptsClassName =\n acceptsClassNameProp ??\n (isPlainStyledComponent ||\n isReactNative ||\n (parentStaticConfig?.isHOC && parentStaticConfig?.acceptsClassName))\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isPlainStyledComponent && {\n Component,\n }),\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 || parentStaticConfig?.componentName,\n isReactNative,\n isText,\n acceptsClassName,\n ...nativeConf,\n }\n\n // bail on non className views as well\n if (defaultProps.children || !acceptsClassName) {\n conf.neverFlatten = true\n }\n\n return conf\n }\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 // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = GetBaseProps<ParentComponent>\n type ParentVariants = GetVariantProps<ParentComponent>\n\n type OurVariantProps = GetVariantAcceptedValues<Variants>\n\n type VariantProps = Omit<ParentVariants, keyof OurVariantProps> & OurVariantProps\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 type ParentStaticProperties = {\n [Key in Exclude<\n keyof ParentComponent,\n 'defaultProps' | 'propTypes' | '$$typeof' | 'staticConfig' | 'extractable'\n >]: ParentComponent[Key]\n }\n\n type StyledComponent = TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariantProps,\n ParentStaticProperties\n >\n\n for (const key in ComponentIn) {\n if (key in component) continue\n // @ts-expect-error assigning static properties over\n component[key] = ComponentIn[key]\n }\n\n return component as any as StyledComponent\n}\n\n// sanity check types\n// import { Stack } from './views/Stack'\n// const X = styled(Stack, {\n// variants: {\n// size: {\n// '...size': (val) => {\n// return {\n// pointerEvents: 'auto'\n// }\n// }\n// },\n// disabled: {\n// true: {\n// alignContent: 'center',\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,qBAAqB;AAG9B,SAAS,uBAAuB;AAChC,SAAS,gCAAgC;AAuClC,SAAS,OAId,aAEA,SAOA,yBACA;AAEA,MAAI,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e;AAAA,MACtB;AAEA,aAAO;AAAA,IACT;AAAA,EACF,GAAG;AAEH,QAAM,YAAY,gBAAgB,qBAAqB,CAAC,GAAG,SAAS;AAoCpE,aAAW,OAAO,aAAa;AAC7B,QAAI,OAAO;AAAW;AAEtB,cAAU,GAAG,IAAI,YAAY,GAAG;AAAA,EAClC;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/web",
3
- "version": "1.15.4",
3
+ "version": "1.15.6",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -27,19 +27,19 @@
27
27
  "reset.css"
28
28
  ],
29
29
  "dependencies": {
30
- "@tamagui/compose-refs": "1.15.4",
31
- "@tamagui/constants": "1.15.4",
32
- "@tamagui/helpers": "1.15.4",
33
- "@tamagui/normalize-css-color": "1.15.4",
34
- "@tamagui/use-did-finish-ssr": "1.15.4",
35
- "@tamagui/use-event": "1.15.4",
36
- "@tamagui/use-force-update": "1.15.4"
30
+ "@tamagui/compose-refs": "1.15.6",
31
+ "@tamagui/constants": "1.15.6",
32
+ "@tamagui/helpers": "1.15.6",
33
+ "@tamagui/normalize-css-color": "1.15.6",
34
+ "@tamagui/use-did-finish-ssr": "1.15.6",
35
+ "@tamagui/use-event": "1.15.6",
36
+ "@tamagui/use-force-update": "1.15.6"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": "*"
40
40
  },
41
41
  "devDependencies": {
42
- "@tamagui/build": "1.15.4",
42
+ "@tamagui/build": "1.15.6",
43
43
  "@testing-library/react": "^13.4.0",
44
44
  "csstype": "^3.0.10",
45
45
  "react": "^18.2.0",
package/src/styled.tsx CHANGED
@@ -16,14 +16,6 @@ import type {
16
16
  VariantSpreadFunction,
17
17
  } from './types.js'
18
18
 
19
- // TODO may be able to use this in the options?: arg below directly
20
- export type StyledOptions<ParentComponent extends StylableComponent> =
21
- GetProps<ParentComponent> & {
22
- name?: string
23
- variants?: VariantDefinitions<ParentComponent> | undefined
24
- defaultVariants?: { [key: string]: any }
25
- }
26
-
27
19
  type GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<
28
20
  any,
29
21
  any,
@@ -41,6 +33,14 @@ type GetVariantProps<A extends StylableComponent> = A extends TamaguiComponent<
41
33
  ? V
42
34
  : {}
43
35
 
36
+ type GetVariantAcceptedValues<V> = V extends Object
37
+ ? {
38
+ [Key in keyof V]?: V[Key] extends VariantSpreadFunction<any, infer Val>
39
+ ? Val
40
+ : GetVariantValues<keyof V[Key]>
41
+ }
42
+ : undefined
43
+
44
44
  export function styled<
45
45
  ParentComponent extends StylableComponent,
46
46
  Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void
@@ -51,7 +51,7 @@ export function styled<
51
51
  name?: string
52
52
  variants?: Variants | undefined
53
53
  // thought i had this typed, but can't get it linked
54
- defaultVariants?: { [key: string]: any }
54
+ defaultVariants?: GetVariantAcceptedValues<Variants>
55
55
  acceptsClassName?: boolean
56
56
  },
57
57
  staticExtractionOptions?: Partial<StaticConfig>
@@ -148,18 +148,9 @@ export function styled<
148
148
  type ParentPropsBase = GetBaseProps<ParentComponent>
149
149
  type ParentVariants = GetVariantProps<ParentComponent>
150
150
 
151
- type OurVariants = Variants extends void
152
- ? {}
153
- : {
154
- [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<
155
- any,
156
- infer Val
157
- >
158
- ? Val
159
- : GetVariantValues<keyof Variants[Key]>
160
- }
151
+ type OurVariantProps = GetVariantAcceptedValues<Variants>
161
152
 
162
- type VariantProps = Omit<ParentVariants, keyof OurVariants> & OurVariants
153
+ type VariantProps = Omit<ParentVariants, keyof OurVariantProps> & OurVariantProps
163
154
  type OurPropsBase = ParentPropsBase & VariantProps
164
155
 
165
156
  type Props = Variants extends void
@@ -182,7 +173,7 @@ export function styled<
182
173
  Props,
183
174
  TamaguiElement,
184
175
  ParentPropsBase,
185
- ParentVariants & OurVariants,
176
+ ParentVariants & OurVariantProps,
186
177
  ParentStaticProperties
187
178
  >
188
179
 
package/types/styled.d.ts CHANGED
@@ -1,20 +1,14 @@
1
1
  import type { GetProps, GetVariantValues, MediaProps, PseudoProps, StaticConfig, StylableComponent, TamaguiComponent, TamaguiElement, VariantDefinitions, VariantSpreadFunction } from './types.js';
2
- export type StyledOptions<ParentComponent extends StylableComponent> = GetProps<ParentComponent> & {
3
- name?: string;
4
- variants?: VariantDefinitions<ParentComponent> | undefined;
5
- defaultVariants?: {
6
- [key: string]: any;
7
- };
8
- };
9
2
  type GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<any, any, infer P> ? P : GetProps<A>;
10
3
  type GetVariantProps<A extends StylableComponent> = A extends TamaguiComponent<any, any, any, infer V> ? V : {};
4
+ type GetVariantAcceptedValues<V> = V extends Object ? {
5
+ [Key in keyof V]?: V[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof V[Key]>;
6
+ } : undefined;
11
7
  export declare function styled<ParentComponent extends StylableComponent, Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void>(ComponentIn: ParentComponent, options?: GetProps<ParentComponent> & {
12
8
  name?: string;
13
9
  variants?: Variants | undefined;
14
- defaultVariants?: {
15
- [key: string]: any;
16
- };
10
+ defaultVariants?: GetVariantAcceptedValues<Variants>;
17
11
  acceptsClassName?: boolean;
18
- }, staticExtractionOptions?: Partial<StaticConfig>): TamaguiComponent<Variants extends void ? GetProps<ParentComponent> : GetBaseProps<ParentComponent> & Omit<GetVariantProps<ParentComponent>, keyof (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })> & (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; }) & MediaProps<Partial<GetBaseProps<ParentComponent> & Omit<GetVariantProps<ParentComponent>, keyof (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })> & (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })>> & PseudoProps<Partial<GetBaseProps<ParentComponent> & Omit<GetVariantProps<ParentComponent>, keyof (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })> & (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })>>, TamaguiElement, GetBaseProps<ParentComponent>, GetVariantProps<ParentComponent> & (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; }), { [Key_1 in Exclude<keyof ParentComponent, "defaultProps" | "propTypes" | "staticConfig" | "extractable" | "$$typeof">]: ParentComponent[Key_1]; }>;
12
+ }, staticExtractionOptions?: Partial<StaticConfig>): TamaguiComponent<Variants extends void ? GetProps<ParentComponent> : GetBaseProps<ParentComponent> & Omit<GetVariantProps<ParentComponent>, keyof GetVariantAcceptedValues<Variants>> & GetVariantAcceptedValues<Variants> & MediaProps<Partial<GetBaseProps<ParentComponent> & Omit<GetVariantProps<ParentComponent>, keyof GetVariantAcceptedValues<Variants>> & GetVariantAcceptedValues<Variants>>> & PseudoProps<Partial<GetBaseProps<ParentComponent> & Omit<GetVariantProps<ParentComponent>, keyof GetVariantAcceptedValues<Variants>> & GetVariantAcceptedValues<Variants>>>, TamaguiElement, GetBaseProps<ParentComponent>, GetVariantProps<ParentComponent> & GetVariantAcceptedValues<Variants>, { [Key in Exclude<keyof ParentComponent, "defaultProps" | "propTypes" | "staticConfig" | "extractable" | "$$typeof">]: ParentComponent[Key]; }>;
19
13
  export {};
20
14
  //# sourceMappingURL=styled.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,YAAY,CAAA;AAGnB,MAAM,MAAM,aAAa,CAAC,eAAe,SAAS,iBAAiB,IACjE,QAAQ,CAAC,eAAe,CAAC,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,kBAAkB,CAAC,eAAe,CAAC,GAAG,SAAS,CAAA;IAC1D,eAAe,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;CACzC,CAAA;AAEH,KAAK,YAAY,CAAC,CAAC,SAAS,iBAAiB,IAAI,CAAC,SAAS,gBAAgB,CACzE,GAAG,EACH,GAAG,EACH,MAAM,CAAC,CACR,GACG,CAAC,GACD,QAAQ,CAAC,CAAC,CAAC,CAAA;AAEf,KAAK,eAAe,CAAC,CAAC,SAAS,iBAAiB,IAAI,CAAC,SAAS,gBAAgB,CAC5E,GAAG,EACH,GAAG,EACH,GAAG,EACH,MAAM,CAAC,CACR,GACG,CAAC,GACD,EAAE,CAAA;AAEN,wBAAgB,MAAM,CACpB,eAAe,SAAS,iBAAiB,EACzC,QAAQ,SAAS,kBAAkB,CAAC,eAAe,CAAC,GAAG,IAAI,GAAG,kBAAkB,CAAC,eAAe,CAAC,GAAG,IAAI,EAExG,WAAW,EAAE,eAAe,EAE5B,OAAO,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG;IACpC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,Q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