@tamagui/web 1.5.20 → 1.5.22

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.
Files changed (41) hide show
  1. package/dist/cjs/createComponent.js +15 -18
  2. package/dist/cjs/createComponent.js.map +2 -2
  3. package/dist/cjs/helpers/getSplitStyles.js +7 -2
  4. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  5. package/dist/cjs/styled.js +0 -14
  6. package/dist/cjs/styled.js.map +3 -3
  7. package/dist/cjs/views/Theme.js +23 -31
  8. package/dist/cjs/views/Theme.js.map +2 -2
  9. package/dist/esm/createComponent.js +15 -18
  10. package/dist/esm/createComponent.js.map +2 -2
  11. package/dist/esm/createComponent.mjs +15 -18
  12. package/dist/esm/createComponent.mjs.map +2 -2
  13. package/dist/esm/helpers/getSplitStyles.js +7 -2
  14. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  15. package/dist/esm/helpers/getSplitStyles.mjs +7 -2
  16. package/dist/esm/helpers/getSplitStyles.mjs.map +2 -2
  17. package/dist/esm/styled.js +0 -14
  18. package/dist/esm/styled.js.map +3 -3
  19. package/dist/esm/styled.mjs +0 -14
  20. package/dist/esm/styled.mjs.map +3 -3
  21. package/dist/esm/views/Theme.js +24 -32
  22. package/dist/esm/views/Theme.js.map +2 -2
  23. package/dist/esm/views/Theme.mjs +24 -32
  24. package/dist/esm/views/Theme.mjs.map +2 -2
  25. package/package.json +9 -9
  26. package/src/createComponent.tsx +5 -5
  27. package/src/helpers/getSplitStyles.tsx +9 -2
  28. package/src/styled.tsx +0 -17
  29. package/src/views/Theme.tsx +62 -41
  30. package/types/createComponent.d.ts.map +1 -1
  31. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  32. package/types/styled.d.ts.map +1 -1
  33. package/types/views/Theme.d.ts +1 -0
  34. package/types/views/Theme.d.ts.map +1 -1
  35. package/dist/cjs/helpers/mergeTransform.js +0 -47
  36. package/dist/cjs/helpers/mergeTransform.js.map +0 -7
  37. package/dist/esm/helpers/mergeTransform.js +0 -21
  38. package/dist/esm/helpers/mergeTransform.js.map +0 -7
  39. package/dist/esm/helpers/mergeTransform.mjs +0 -21
  40. package/dist/esm/helpers/mergeTransform.mjs.map +0 -7
  41. package/types/helpers/mergeTransform.d.ts.map +0 -1
@@ -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 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 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 (!Component) {\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 implementation complexity.`\n )\n }\n }\n }\n }\n\n const parentStaticConfig =\n 'staticConfig' in Component ? (Component.staticConfig as StaticConfig) : null\n const isTamagui = !!parentStaticConfig\n\n const isReactNative = Boolean(\n ReactNativeStaticConfigs.has(Component) ||\n staticExtractionOptions?.isReactNative ||\n ReactNativeStaticConfigs.has(parentStaticConfig?.Component) ||\n parentStaticConfig?.isReactNative\n )\n\n // unrecognized, just pass through as default props\n if (!isTamagui && !isReactNative) {\n if (process.env.NODE_ENV === 'development') {\n // TODO variants would need to work through props to support this\n if (options?.variants) {\n console.warn(\n `Warning: wrapping a non-Tamagui element in styled() and passing variants isn't supported (yet).`\n )\n }\n }\n\n return forwardRef(function styled(props, ref) {\n // @ts-ignore\n return <Component ref={ref} {...options} {...props} />\n }) as StyledComponent\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 Comp = isReactNative\n ? parentStaticConfig?.Component || Component\n : (Component as any)\n\n const nativeConf = (isReactNative && ReactNativeStaticConfigs.get(Comp)) || null\n\n const isText = Boolean(\n staticExtractionOptions?.isText || parentStaticConfig?.isText\n )\n const acceptsClassName = acceptsClassNameProp ?? (isTamagui || isReactNative)\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\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,\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 StyledComponent = TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n\n return component 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": "AAkGa;AAlGb,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAE3B,SAAS,uBAAuB;AAChC,SAAS,gCAAgC;AAuClC,SAAS,OAId,WAEA,SAOA,yBACA;AAEA,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QAAI,CAAC,WAAW;AACd,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;AAA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AG;AAEH,QAAM,YAAY,gBAAgB,qBAAqB,CAAC,GAAG,SAAS;AAqCpE,SAAO;AACT;",
6
- "names": ["styled"]
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 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 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 (!Component) {\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 implementation complexity.`\n )\n }\n }\n }\n }\n\n const parentStaticConfig =\n 'staticConfig' in Component ? (Component.staticConfig as StaticConfig) : null\n const isTamagui = !!parentStaticConfig\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 Comp = isReactNative\n ? parentStaticConfig?.Component || Component\n : (Component as any)\n\n const nativeConf = (isReactNative && ReactNativeStaticConfigs.get(Comp)) || null\n\n const isText = Boolean(\n staticExtractionOptions?.isText || parentStaticConfig?.isText\n )\n const acceptsClassName = acceptsClassNameProp ?? (isTamagui || isReactNative)\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\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,\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 StyledComponent = TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n\n return component 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,WAEA,SAOA,yBACA;AAEA,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QAAI,CAAC,WAAW;AACd,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,YAAa,UAAU,eAAgC;AAC3E,QAAM,YAAY,CAAC,CAAC;AAEpB,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,OAAO,iBACT,yDAAoB,cAAa,YAChC;AAEL,YAAM,aAAc,iBAAiB,yBAAyB,IAAI,IAAI,KAAM;AAE5E,YAAM,SAAS;AAAA,SACb,mEAAyB,YAAU,yDAAoB;AAAA,MACzD;AACA,YAAM,mBAAmB,yBAAyB,aAAa;AAE/D,YAAM,OAA8B;AAAA,QAClC,GAAG;AAAA,QACH,GAAI,CAAC,aAAa;AAAA,UAChB,WAAW;AAAA,QACb;AAAA;AAAA;AAAA,QAGA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;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;AAqCpE,SAAO;AACT;",
6
+ "names": []
7
7
  }
@@ -1,6 +1,4 @@
1
- import { jsx } from "react/jsx-runtime";
2
1
  import { stylePropsAll } from "@tamagui/helpers";
3
- import { forwardRef } from "react";
4
2
  import { createComponent } from "./createComponent.js";
5
3
  import { ReactNativeStaticConfigs } from "./setupReactNative.js";
6
4
  function styled(Component, options, staticExtractionOptions) {
@@ -23,18 +21,6 @@ function styled(Component, options, staticExtractionOptions) {
23
21
  const isReactNative = Boolean(
24
22
  ReactNativeStaticConfigs.has(Component) || (staticExtractionOptions == null ? void 0 : staticExtractionOptions.isReactNative) || ReactNativeStaticConfigs.has(parentStaticConfig == null ? void 0 : parentStaticConfig.Component) || (parentStaticConfig == null ? void 0 : parentStaticConfig.isReactNative)
25
23
  );
26
- if (!isTamagui && !isReactNative) {
27
- if (process.env.NODE_ENV === "development") {
28
- if (options == null ? void 0 : options.variants) {
29
- console.warn(
30
- `Warning: wrapping a non-Tamagui element in styled() and passing variants isn't supported (yet).`
31
- );
32
- }
33
- }
34
- return forwardRef(function styled2(props, ref) {
35
- return /* @__PURE__ */ jsx(Component, { ref, ...options, ...props });
36
- });
37
- }
38
24
  const staticConfigProps = (() => {
39
25
  if (options) {
40
26
  const {
@@ -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 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 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 (!Component) {\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 implementation complexity.`\n )\n }\n }\n }\n }\n\n const parentStaticConfig =\n 'staticConfig' in Component ? (Component.staticConfig as StaticConfig) : null\n const isTamagui = !!parentStaticConfig\n\n const isReactNative = Boolean(\n ReactNativeStaticConfigs.has(Component) ||\n staticExtractionOptions?.isReactNative ||\n ReactNativeStaticConfigs.has(parentStaticConfig?.Component) ||\n parentStaticConfig?.isReactNative\n )\n\n // unrecognized, just pass through as default props\n if (!isTamagui && !isReactNative) {\n if (process.env.NODE_ENV === 'development') {\n // TODO variants would need to work through props to support this\n if (options?.variants) {\n console.warn(\n `Warning: wrapping a non-Tamagui element in styled() and passing variants isn't supported (yet).`\n )\n }\n }\n\n return forwardRef(function styled(props, ref) {\n // @ts-ignore\n return <Component ref={ref} {...options} {...props} />\n }) as StyledComponent\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 Comp = isReactNative\n ? parentStaticConfig?.Component || Component\n : (Component as any)\n\n const nativeConf = (isReactNative && ReactNativeStaticConfigs.get(Comp)) || null\n\n const isText = Boolean(\n staticExtractionOptions?.isText || parentStaticConfig?.isText\n )\n const acceptsClassName = acceptsClassNameProp ?? (isTamagui || isReactNative)\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\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,\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 StyledComponent = TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n\n return component 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": "AAkGa;AAlGb,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAE3B,SAAS,uBAAuB;AAChC,SAAS,gCAAgC;AAuClC,SAAS,OAId,WAEA,SAOA,yBACA;AAEA,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QAAI,CAAC,WAAW;AACd,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,YAAa,UAAU,eAAgC;AAC3E,QAAM,YAAY,CAAC,CAAC;AAEpB,QAAM,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"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 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 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 (!Component) {\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 implementation complexity.`\n )\n }\n }\n }\n }\n\n const parentStaticConfig =\n 'staticConfig' in Component ? (Component.staticConfig as StaticConfig) : null\n const isTamagui = !!parentStaticConfig\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 Comp = isReactNative\n ? parentStaticConfig?.Component || Component\n : (Component as any)\n\n const nativeConf = (isReactNative && ReactNativeStaticConfigs.get(Comp)) || null\n\n const isText = Boolean(\n staticExtractionOptions?.isText || parentStaticConfig?.isText\n )\n const acceptsClassName = acceptsClassNameProp ?? (isTamagui || isReactNative)\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\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,\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 StyledComponent = TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n\n return component 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,WAEA,SAOA,yBACA;AAEA,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QAAI,CAAC,WAAW;AACd,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,YAAa,UAAU,eAAgC;AAC3E,QAAM,YAAY,CAAC,CAAC;AAEpB,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,OAAO,iBACT,yDAAoB,cAAa,YAChC;AAEL,YAAM,aAAc,iBAAiB,yBAAyB,IAAI,IAAI,KAAM;AAE5E,YAAM,SAAS;AAAA,SACb,mEAAyB,YAAU,yDAAoB;AAAA,MACzD;AACA,YAAM,mBAAmB,yBAAyB,aAAa;AAE/D,YAAM,OAA8B;AAAA,QAClC,GAAG;AAAA,QACH,GAAI,CAAC,aAAa;AAAA,UAChB,WAAW;AAAA,QACb;AAAA;AAAA;AAAA,QAGA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;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;AAqCpE,SAAO;AACT;",
6
+ "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { isWeb } from "@tamagui/constants";
3
- import { Children, cloneElement } from "react";
3
+ import { Children, cloneElement, isValidElement } from "react";
4
4
  import { variableToString } from "../createVariable.js";
5
5
  import { ThemeManagerContext } from "../helpers/ThemeManagerContext.js";
6
6
  import { useServerRef } from "../hooks/useServerHooks.js";
@@ -23,38 +23,30 @@ function useThemedChildren(themeState, children, options) {
23
23
  if (isNewTheme) {
24
24
  hasEverThemed.current = true;
25
25
  }
26
- if (!isNewTheme && !hasEverThemed.current && !forceClassName && !shallow) {
27
- return children;
26
+ if (isNewTheme || hasEverThemed.current || forceClassName) {
27
+ let next = Children.toArray(children);
28
+ if (shallow && themeManager) {
29
+ next = next.map((child) => {
30
+ return isValidElement(child) ? cloneElement(
31
+ child,
32
+ void 0,
33
+ /* @__PURE__ */ jsx(Theme, { name: themeManager.state.parentName, children: child.props.children })
34
+ ) : child;
35
+ });
36
+ }
37
+ const wrapped = /* @__PURE__ */ jsx(ThemeManagerContext.Provider, { value: themeManager, children: next });
38
+ if (forceClassName === false) {
39
+ return wrapped;
40
+ }
41
+ if (isWeb && !options.passPropsToChildren) {
42
+ const themeColor = theme && isNewTheme ? variableToString(theme.color) : "";
43
+ const colorStyle = {
44
+ color: themeColor
45
+ };
46
+ return /* @__PURE__ */ jsx("span", { className: `${className || ""} _dsp_contents`, style: colorStyle, children: wrapped });
47
+ }
28
48
  }
29
- let next = children;
30
- if (shallow && themeManager) {
31
- next = Children.map(next, (child) => {
32
- return cloneElement(
33
- child,
34
- void 0,
35
- /* @__PURE__ */ jsx(Theme, { name: themeManager.state.parentName, children: child.props.children })
36
- );
37
- });
38
- }
39
- next = /* @__PURE__ */ jsx(ThemeManagerContext.Provider, { value: themeManager, children: next });
40
- if (isWeb) {
41
- const enableClassName = forceClassName ?? (forceClassName !== false && isNewTheme);
42
- return /* @__PURE__ */ jsx(
43
- "span",
44
- {
45
- className: "_dsp_contents",
46
- ...theme && enableClassName && {
47
- className: `${className} _dsp_contents`,
48
- style: {
49
- // in order to provide currentColor, set color by default
50
- color: variableToString(theme.color)
51
- }
52
- },
53
- children: next
54
- }
55
- );
56
- }
57
- return next;
49
+ return children;
58
50
  }
59
51
  export {
60
52
  Theme,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/Theme.tsx"],
4
- "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { Children, cloneElement } from 'react'\n\nimport { variableToString } from '../createVariable.js'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'\nimport { useServerRef } from '../hooks/useServerHooks.js'\nimport { ChangedThemeResponse, useChangeThemeEffect } from '../hooks/useTheme.js'\nimport type { ThemeProps } from '../types.js'\n\nexport function Theme(props: ThemeProps) {\n // @ts-expect-error only for internal views\n if (props.disable) return props.children\n const isRoot = !!props['_isRoot']\n const themeState = useChangeThemeEffect(props, isRoot)\n const children = props['data-themeable']\n ? Children.map(props.children, (child) =>\n cloneElement(child, { ['data-themeable']: true })\n )\n : props.children\n\n return useThemedChildren(themeState, children, props)\n}\n\nexport function useThemedChildren(\n themeState: ChangedThemeResponse,\n children: any,\n options: { forceClassName?: boolean; shallow?: boolean }\n) {\n const { themeManager, isNewTheme, className, theme } = themeState\n const { shallow, forceClassName } = options\n\n const hasEverThemed = useServerRef(false)\n if (isNewTheme) {\n hasEverThemed.current = true\n }\n\n // once a theme is set it always passes the context to avoid reparenting\n // until then no context to avoid lots of context\n if (!isNewTheme && !hasEverThemed.current && !forceClassName && !shallow) {\n return children\n }\n\n // be sure to memoize shouldReset to avoid reparenting\n let next = children\n\n if (shallow && themeManager) {\n next = Children.map(next, (child) => {\n return cloneElement(\n child,\n undefined,\n <Theme name={themeManager.state.parentName}>{child.props.children}</Theme>\n )\n })\n }\n\n next = (\n <ThemeManagerContext.Provider value={themeManager}>\n {next}\n </ThemeManagerContext.Provider>\n )\n\n if (isWeb) {\n const enableClassName = forceClassName ?? (forceClassName !== false && isNewTheme)\n return (\n <span\n className=\"_dsp_contents\"\n {...(theme &&\n enableClassName && {\n className: `${className} _dsp_contents`,\n style: {\n // in order to provide currentColor, set color by default\n color: variableToString(theme.color),\n },\n })}\n >\n {next}\n </span>\n )\n }\n\n return next\n}\n"],
5
- "mappings": "AAkDQ;AAlDR,SAAS,aAAa;AACtB,SAAS,UAAU,oBAAoB;AAEvC,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAA+B,4BAA4B;AAGpD,SAAS,MAAM,OAAmB;AAEvC,MAAI,MAAM;AAAS,WAAO,MAAM;AAChC,QAAM,SAAS,CAAC,CAAC,MAAM,SAAS;AAChC,QAAM,aAAa,qBAAqB,OAAO,MAAM;AACrD,QAAM,WAAW,MAAM,gBAAgB,IACnC,SAAS;AAAA,IAAI,MAAM;AAAA,IAAU,CAAC,UAC5B,aAAa,OAAO,EAAE,CAAC,gBAAgB,GAAG,KAAK,CAAC;AAAA,EAClD,IACA,MAAM;AAEV,SAAO,kBAAkB,YAAY,UAAU,KAAK;AACtD;AAEO,SAAS,kBACd,YACA,UACA,SACA;AACA,QAAM,EAAE,cAAc,YAAY,WAAW,MAAM,IAAI;AACvD,QAAM,EAAE,SAAS,eAAe,IAAI;AAEpC,QAAM,gBAAgB,aAAa,KAAK;AACxC,MAAI,YAAY;AACd,kBAAc,UAAU;AAAA,EAC1B;AAIA,MAAI,CAAC,cAAc,CAAC,cAAc,WAAW,CAAC,kBAAkB,CAAC,SAAS;AACxE,WAAO;AAAA,EACT;AAGA,MAAI,OAAO;AAEX,MAAI,WAAW,cAAc;AAC3B,WAAO,SAAS,IAAI,MAAM,CAAC,UAAU;AACnC,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA,oBAAC,SAAM,MAAM,aAAa,MAAM,YAAa,gBAAM,MAAM,UAAS;AAAA,MACpE;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SACE,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,cAClC,gBACH;AAGF,MAAI,OAAO;AACT,UAAM,kBAAkB,mBAAmB,mBAAmB,SAAS;AACvE,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACT,GAAI,SACH,mBAAmB;AAAA,UACjB,WAAW,GAAG;AAAA,UACd,OAAO;AAAA;AAAA,YAEL,OAAO,iBAAiB,MAAM,KAAK;AAAA,UACrC;AAAA,QACF;AAAA,QAED;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { Children, cloneElement, isValidElement } from 'react'\n\nimport { variableToString } from '../createVariable.js'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'\nimport { useServerRef } from '../hooks/useServerHooks.js'\nimport { ChangedThemeResponse, useChangeThemeEffect } from '../hooks/useTheme.js'\nimport type { ThemeProps } from '../types.js'\n\nexport function Theme(props: ThemeProps) {\n // @ts-expect-error only for internal views\n if (props.disable) return props.children\n const isRoot = !!props['_isRoot']\n const themeState = useChangeThemeEffect(props, isRoot)\n const children = props['data-themeable']\n ? Children.map(props.children, (child) =>\n cloneElement(child, { ['data-themeable']: true })\n )\n : props.children\n\n return useThemedChildren(themeState, children, props)\n}\n\nexport function useThemedChildren(\n themeState: ChangedThemeResponse,\n children: any,\n options: {\n forceClassName?: boolean\n shallow?: boolean\n passPropsToChildren?: boolean\n }\n) {\n const { themeManager, isNewTheme, className, theme } = themeState\n const { shallow, forceClassName } = options\n const hasEverThemed = useServerRef(false)\n if (isNewTheme) {\n hasEverThemed.current = true\n }\n\n if (isNewTheme || hasEverThemed.current || forceClassName) {\n // be sure to memoize shouldReset to avoid reparenting\n let next = Children.toArray(children)\n\n // each children of these children wont get the theme\n if (shallow && themeManager) {\n next = next.map((child) => {\n return isValidElement(child)\n ? cloneElement(\n child,\n undefined,\n <Theme name={themeManager.state.parentName}>\n {(child as any).props.children}\n </Theme>\n )\n : child\n })\n }\n\n // tried this but themes css doesn't fully like it\n // if (shouldAttachClassName && options.passPropsToChildren) {\n // next = next.map((child: any) => {\n // const childStyle = child.props?.style\n // console.log('pass it down', className, child.props.className || '')\n // const newProps = {\n // className: (child.props.className || '') + ' ' + className,\n // style: Array.isArray(childStyle)\n // ? [colorStyle, ...childStyle]\n // : {\n // ...colorStyle,\n // ...childStyle,\n // },\n // }\n // return isValidElement(child) ? cloneElement(child as any, newProps) : child\n // })\n // }\n\n const wrapped = (\n <ThemeManagerContext.Provider value={themeManager}>\n {next}\n </ThemeManagerContext.Provider>\n )\n\n if (forceClassName === false) {\n return wrapped\n }\n\n if (isWeb && !options.passPropsToChildren) {\n // in order to provide currentColor, set color by default\n const themeColor = theme && isNewTheme ? variableToString(theme.color) : ''\n const colorStyle = {\n color: themeColor,\n }\n\n return (\n <span className={`${className || ''} _dsp_contents`} style={colorStyle}>\n {wrapped}\n </span>\n )\n }\n }\n\n return children\n}\n"],
5
+ "mappings": "AAkDc;AAlDd,SAAS,aAAa;AACtB,SAAS,UAAU,cAAc,sBAAsB;AAEvD,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7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AAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { isWeb } from "@tamagui/constants";
3
- import { Children, cloneElement } from "react";
3
+ import { Children, cloneElement, isValidElement } from "react";
4
4
  import { variableToString } from "../createVariable.js";
5
5
  import { ThemeManagerContext } from "../helpers/ThemeManagerContext.js";
6
6
  import { useServerRef } from "../hooks/useServerHooks.js";
@@ -23,38 +23,30 @@ function useThemedChildren(themeState, children, options) {
23
23
  if (isNewTheme) {
24
24
  hasEverThemed.current = true;
25
25
  }
26
- if (!isNewTheme && !hasEverThemed.current && !forceClassName && !shallow) {
27
- return children;
26
+ if (isNewTheme || hasEverThemed.current || forceClassName) {
27
+ let next = Children.toArray(children);
28
+ if (shallow && themeManager) {
29
+ next = next.map((child) => {
30
+ return isValidElement(child) ? cloneElement(
31
+ child,
32
+ void 0,
33
+ /* @__PURE__ */ jsx(Theme, { name: themeManager.state.parentName, children: child.props.children })
34
+ ) : child;
35
+ });
36
+ }
37
+ const wrapped = /* @__PURE__ */ jsx(ThemeManagerContext.Provider, { value: themeManager, children: next });
38
+ if (forceClassName === false) {
39
+ return wrapped;
40
+ }
41
+ if (isWeb && !options.passPropsToChildren) {
42
+ const themeColor = theme && isNewTheme ? variableToString(theme.color) : "";
43
+ const colorStyle = {
44
+ color: themeColor
45
+ };
46
+ return /* @__PURE__ */ jsx("span", { className: `${className || ""} _dsp_contents`, style: colorStyle, children: wrapped });
47
+ }
28
48
  }
29
- let next = children;
30
- if (shallow && themeManager) {
31
- next = Children.map(next, (child) => {
32
- return cloneElement(
33
- child,
34
- void 0,
35
- /* @__PURE__ */ jsx(Theme, { name: themeManager.state.parentName, children: child.props.children })
36
- );
37
- });
38
- }
39
- next = /* @__PURE__ */ jsx(ThemeManagerContext.Provider, { value: themeManager, children: next });
40
- if (isWeb) {
41
- const enableClassName = forceClassName ?? (forceClassName !== false && isNewTheme);
42
- return /* @__PURE__ */ jsx(
43
- "span",
44
- {
45
- className: "_dsp_contents",
46
- ...theme && enableClassName && {
47
- className: `${className} _dsp_contents`,
48
- style: {
49
- // in order to provide currentColor, set color by default
50
- color: variableToString(theme.color)
51
- }
52
- },
53
- children: next
54
- }
55
- );
56
- }
57
- return next;
49
+ return children;
58
50
  }
59
51
  export {
60
52
  Theme,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/Theme.tsx"],
4
- "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { Children, cloneElement } from 'react'\n\nimport { variableToString } from '../createVariable.js'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'\nimport { useServerRef } from '../hooks/useServerHooks.js'\nimport { ChangedThemeResponse, useChangeThemeEffect } from '../hooks/useTheme.js'\nimport type { ThemeProps } from '../types.js'\n\nexport function Theme(props: ThemeProps) {\n // @ts-expect-error only for internal views\n if (props.disable) return props.children\n const isRoot = !!props['_isRoot']\n const themeState = useChangeThemeEffect(props, isRoot)\n const children = props['data-themeable']\n ? Children.map(props.children, (child) =>\n cloneElement(child, { ['data-themeable']: true })\n )\n : props.children\n\n return useThemedChildren(themeState, children, props)\n}\n\nexport function useThemedChildren(\n themeState: ChangedThemeResponse,\n children: any,\n options: { forceClassName?: boolean; shallow?: boolean }\n) {\n const { themeManager, isNewTheme, className, theme } = themeState\n const { shallow, forceClassName } = options\n\n const hasEverThemed = useServerRef(false)\n if (isNewTheme) {\n hasEverThemed.current = true\n }\n\n // once a theme is set it always passes the context to avoid reparenting\n // until then no context to avoid lots of context\n if (!isNewTheme && !hasEverThemed.current && !forceClassName && !shallow) {\n return children\n }\n\n // be sure to memoize shouldReset to avoid reparenting\n let next = children\n\n if (shallow && themeManager) {\n next = Children.map(next, (child) => {\n return cloneElement(\n child,\n undefined,\n <Theme name={themeManager.state.parentName}>{child.props.children}</Theme>\n )\n })\n }\n\n next = (\n <ThemeManagerContext.Provider value={themeManager}>\n {next}\n </ThemeManagerContext.Provider>\n )\n\n if (isWeb) {\n const enableClassName = forceClassName ?? (forceClassName !== false && isNewTheme)\n return (\n <span\n className=\"_dsp_contents\"\n {...(theme &&\n enableClassName && {\n className: `${className} _dsp_contents`,\n style: {\n // in order to provide currentColor, set color by default\n color: variableToString(theme.color),\n },\n })}\n >\n {next}\n </span>\n )\n }\n\n return next\n}\n"],
5
- "mappings": "AAkDQ;AAlDR,SAAS,aAAa;AACtB,SAAS,UAAU,oBAAoB;AAEvC,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAA+B,4BAA4B;AAGpD,SAAS,MAAM,OAAmB;AAEvC,MAAI,MAAM;AAAS,WAAO,MAAM;AAChC,QAAM,SAAS,CAAC,CAAC,MAAM,SAAS;AAChC,QAAM,aAAa,qBAAqB,OAAO,MAAM;AACrD,QAAM,WAAW,MAAM,gBAAgB,IACnC,SAAS;AAAA,IAAI,MAAM;AAAA,IAAU,CAAC,UAC5B,aAAa,OAAO,EAAE,CAAC,gBAAgB,GAAG,KAAK,CAAC;AAAA,EAClD,IACA,MAAM;AAEV,SAAO,kBAAkB,YAAY,UAAU,KAAK;AACtD;AAEO,SAAS,kBACd,YACA,UACA,SACA;AACA,QAAM,EAAE,cAAc,YAAY,WAAW,MAAM,IAAI;AACvD,QAAM,EAAE,SAAS,eAAe,IAAI;AAEpC,QAAM,gBAAgB,aAAa,KAAK;AACxC,MAAI,YAAY;AACd,kBAAc,UAAU;AAAA,EAC1B;AAIA,MAAI,CAAC,cAAc,CAAC,cAAc,WAAW,CAAC,kBAAkB,CAAC,SAAS;AACxE,WAAO;AAAA,EACT;AAGA,MAAI,OAAO;AAEX,MAAI,WAAW,cAAc;AAC3B,WAAO,SAAS,IAAI,MAAM,CAAC,UAAU;AACnC,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA,oBAAC,SAAM,MAAM,aAAa,MAAM,YAAa,gBAAM,MAAM,UAAS;AAAA,MACpE;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SACE,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,cAClC,gBACH;AAGF,MAAI,OAAO;AACT,UAAM,kBAAkB,mBAAmB,mBAAmB,SAAS;AACvE,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACT,GAAI,SACH,mBAAmB;AAAA,UACjB,WAAW,GAAG;AAAA,UACd,OAAO;AAAA;AAAA,YAEL,OAAO,iBAAiB,MAAM,KAAK;AAAA,UACrC;AAAA,QACF;AAAA,QAED;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { Children, cloneElement, isValidElement } from 'react'\n\nimport { variableToString } from '../createVariable.js'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'\nimport { useServerRef } from '../hooks/useServerHooks.js'\nimport { ChangedThemeResponse, useChangeThemeEffect } from '../hooks/useTheme.js'\nimport type { ThemeProps } from '../types.js'\n\nexport function Theme(props: ThemeProps) {\n // @ts-expect-error only for internal views\n if (props.disable) return props.children\n const isRoot = !!props['_isRoot']\n const themeState = useChangeThemeEffect(props, isRoot)\n const children = props['data-themeable']\n ? Children.map(props.children, (child) =>\n cloneElement(child, { ['data-themeable']: true })\n )\n : props.children\n\n return useThemedChildren(themeState, children, props)\n}\n\nexport function useThemedChildren(\n themeState: ChangedThemeResponse,\n children: any,\n options: {\n forceClassName?: boolean\n shallow?: boolean\n passPropsToChildren?: boolean\n }\n) {\n const { themeManager, isNewTheme, className, theme } = themeState\n const { shallow, forceClassName } = options\n const hasEverThemed = useServerRef(false)\n if (isNewTheme) {\n hasEverThemed.current = true\n }\n\n if (isNewTheme || hasEverThemed.current || forceClassName) {\n // be sure to memoize shouldReset to avoid reparenting\n let next = Children.toArray(children)\n\n // each children of these children wont get the theme\n if (shallow && themeManager) {\n next = next.map((child) => {\n return isValidElement(child)\n ? cloneElement(\n child,\n undefined,\n <Theme name={themeManager.state.parentName}>\n {(child as any).props.children}\n </Theme>\n )\n : child\n })\n }\n\n // tried this but themes css doesn't fully like it\n // if (shouldAttachClassName && options.passPropsToChildren) {\n // next = next.map((child: any) => {\n // const childStyle = child.props?.style\n // console.log('pass it down', className, child.props.className || '')\n // const newProps = {\n // className: (child.props.className || '') + ' ' + className,\n // style: Array.isArray(childStyle)\n // ? [colorStyle, ...childStyle]\n // : {\n // ...colorStyle,\n // ...childStyle,\n // },\n // }\n // return isValidElement(child) ? cloneElement(child as any, newProps) : child\n // })\n // }\n\n const wrapped = (\n <ThemeManagerContext.Provider value={themeManager}>\n {next}\n </ThemeManagerContext.Provider>\n )\n\n if (forceClassName === false) {\n return wrapped\n }\n\n if (isWeb && !options.passPropsToChildren) {\n // in order to provide currentColor, set color by default\n const themeColor = theme && isNewTheme ? variableToString(theme.color) : ''\n const colorStyle = {\n color: themeColor,\n }\n\n return (\n <span className={`${className || ''} _dsp_contents`} style={colorStyle}>\n {wrapped}\n </span>\n )\n }\n }\n\n return children\n}\n"],
5
+ "mappings": "AAkDc;AAlDd,SAAS,aAAa;AACtB,SAAS,UAAU,cAAc,sBAAsB;AAEvD,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAA+B,4BAA4B;AAGpD,SAAS,MAAM,OAAmB;AAEvC,MAAI,MAAM;AAAS,WAAO,MAAM;AAChC,QAAM,SAAS,CAAC,CAAC,MAAM,SAAS;AAChC,QAAM,aAAa,qBAAqB,OAAO,MAAM;AACrD,QAAM,WAAW,MAAM,gBAAgB,IACnC,SAAS;AAAA,IAAI,MAAM;AAAA,IAAU,CAAC,UAC5B,aAAa,OAAO,EAAE,CAAC,gBAAgB,GAAG,KAAK,CAAC;AAAA,EAClD,IACA,MAAM;AAEV,SAAO,kBAAkB,YAAY,UAAU,KAAK;AACtD;AAEO,SAAS,kBACd,YACA,UACA,SAKA;AACA,QAAM,EAAE,cAAc,YAAY,WAAW,MAAM,IAAI;AACvD,QAAM,EAAE,SAAS,eAAe,IAAI;AACpC,QAAM,gBAAgB,aAAa,KAAK;AACxC,MAAI,YAAY;AACd,kBAAc,UAAU;AAAA,EAC1B;AAEA,MAAI,cAAc,cAAc,WAAW,gBAAgB;AAEzD,QAAI,OAAO,SAAS,QAAQ,QAAQ;AAGpC,QAAI,WAAW,cAAc;AAC3B,aAAO,KAAK,IAAI,CAAC,UAAU;AACzB,eAAO,eAAe,KAAK,IACvB;AAAA,UACE;AAAA,UACA;AAAA,UACA,oBAAC,SAAM,MAAM,aAAa,MAAM,YAC5B,gBAAc,MAAM,UACxB;AAAA,QACF,IACA;AAAA,MACN,CAAC;AAAA,IACH;AAoBA,UAAM,UACJ,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,cAClC,gBACH;AAGF,QAAI,mBAAmB,OAAO;AAC5B,aAAO;AAAA,IACT;AAEA,QAAI,SAAS,CAAC,QAAQ,qBAAqB;AAEzC,YAAM,aAAa,SAAS,aAAa,iBAAiB,MAAM,KAAK,IAAI;AACzE,YAAM,aAAa;AAAA,QACjB,OAAO;AAAA,MACT;AAEA,aACE,oBAAC,UAAK,WAAW,GAAG,aAAa,oBAAoB,OAAO,YACzD,mBACH;AAAA,IAEJ;AAAA,EACF;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.5.20",
3
+ "version": "1.5.22",
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.5.20",
31
- "@tamagui/constants": "^1.5.20",
32
- "@tamagui/helpers": "^1.5.20",
33
- "@tamagui/normalize-css-color": "^1.5.20",
34
- "@tamagui/use-did-finish-ssr": "^1.5.20",
35
- "@tamagui/use-event": "^1.5.20",
36
- "@tamagui/use-force-update": "^1.5.20"
30
+ "@tamagui/compose-refs": "^1.5.22",
31
+ "@tamagui/constants": "^1.5.22",
32
+ "@tamagui/helpers": "^1.5.22",
33
+ "@tamagui/normalize-css-color": "^1.5.22",
34
+ "@tamagui/use-did-finish-ssr": "^1.5.22",
35
+ "@tamagui/use-event": "^1.5.22",
36
+ "@tamagui/use-force-update": "^1.5.22"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": "*"
40
40
  },
41
41
  "devDependencies": {
42
- "@tamagui/build": "^1.5.20",
42
+ "@tamagui/build": "^1.5.22",
43
43
  "@testing-library/react": "^13.4.0",
44
44
  "csstype": "^3.0.10",
45
45
  "react": "^18.2.0",
@@ -209,6 +209,7 @@ export function createComponent<
209
209
 
210
210
  const isAnimated = (() => {
211
211
  const next = !!(
212
+ !staticConfig.isHOC &&
212
213
  useAnimations &&
213
214
  (props.animation || (props.style && hasAnimatedStyleValue(props.style)))
214
215
  )
@@ -379,7 +380,7 @@ export function createComponent<
379
380
  // once you set animation prop don't remove it, you can set to undefined/false
380
381
  // reason is animations are heavy - no way around it, and must be run inline here (🙅 loading as a sub-component)
381
382
  let animationStyles: any
382
- if (!isRSC && isAnimated && useAnimations) {
383
+ if (!isRSC && isAnimated && useAnimations && !staticConfig.isHOC) {
383
384
  const animations = useAnimations({
384
385
  props: propsWithAnimation,
385
386
  style: splitStylesStyle,
@@ -719,6 +720,7 @@ export function createComponent<
719
720
 
720
721
  content = useThemedChildren(themeState, content, {
721
722
  shallow: stateRef.current.themeShallow,
723
+ // passPropsToChildren: true,
722
724
  })
723
725
 
724
726
  if (process.env.TAMAGUI_TARGET === 'web') {
@@ -1065,7 +1067,6 @@ type CreateSpacerProps = SpacedChildrenProps & { key: string }
1065
1067
 
1066
1068
  function createSpacer({ key, direction, space, spaceFlex }: CreateSpacerProps) {
1067
1069
  return (
1068
- // @ts-ignore this one blew up but the types seem better
1069
1070
  <Spacer
1070
1071
  key={key}
1071
1072
  size={space}
@@ -1078,8 +1079,8 @@ function createSpacer({ key, direction, space, spaceFlex }: CreateSpacerProps) {
1078
1079
  }
1079
1080
 
1080
1081
  function isUnspaced(child: React.ReactNode) {
1081
- // console.log('unspaced?', child, getMedia())
1082
- return child?.['type']?.['isVisuallyHidden'] || child?.['type']?.['isUnspaced']
1082
+ const t = child?.['type']
1083
+ return t?.['isVisuallyHidden'] || t?.['isUnspaced']
1083
1084
  }
1084
1085
 
1085
1086
  const DefaultProps = new Map()
@@ -1121,7 +1122,6 @@ function mergeConfigDefaultProps(
1121
1122
  }
1122
1123
 
1123
1124
  const AbsoluteFill: any = createComponent({
1124
- componentName: 'AbsoluteFill',
1125
1125
  defaultProps: {
1126
1126
  ...stackDefaultStyles,
1127
1127
  flexDirection: 'column',
@@ -314,7 +314,13 @@ export const getSplitStyles: StyleSplitter = (
314
314
  }
315
315
  }
316
316
 
317
- if (keyInit in usedKeys || keyInit in skipProps) {
317
+ if (!staticConfig.isHOC) {
318
+ if (keyInit in skipProps) {
319
+ continue
320
+ }
321
+ }
322
+
323
+ if (keyInit in usedKeys) {
318
324
  continue
319
325
  }
320
326
 
@@ -505,6 +511,7 @@ export const getSplitStyles: StyleSplitter = (
505
511
  let isPseudo = keyInit in validPseudoKeys
506
512
 
507
513
  const isHOCShouldPassThrough = staticConfig.isHOC && (isMedia || isPseudo)
514
+
508
515
  const shouldPassProp = !(
509
516
  isMedia ||
510
517
  isPseudo ||
@@ -679,7 +686,7 @@ export const getSplitStyles: StyleSplitter = (
679
686
  }
680
687
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
681
688
  // prettier-ignore
682
- console.log('Merged pseudo?', shouldMerge, { importance, curImportance, pkey, val })
689
+ console.log(' merge pseudo?', keyInit, shouldMerge, { importance, curImportance, pkey, val })
683
690
  }
684
691
  }
685
692
  }
package/src/styled.tsx CHANGED
@@ -83,23 +83,6 @@ export function styled<
83
83
  parentStaticConfig?.isReactNative
84
84
  )
85
85
 
86
- // unrecognized, just pass through as default props
87
- if (!isTamagui && !isReactNative) {
88
- if (process.env.NODE_ENV === 'development') {
89
- // TODO variants would need to work through props to support this
90
- if (options?.variants) {
91
- console.warn(
92
- `Warning: wrapping a non-Tamagui element in styled() and passing variants isn't supported (yet).`
93
- )
94
- }
95
- }
96
-
97
- return forwardRef(function styled(props, ref) {
98
- // @ts-ignore
99
- return <Component ref={ref} {...options} {...props} />
100
- }) as StyledComponent
101
- }
102
-
103
86
  const staticConfigProps = (() => {
104
87
  if (options) {
105
88
  const {
@@ -1,5 +1,5 @@
1
1
  import { isWeb } from '@tamagui/constants'
2
- import { Children, cloneElement } from 'react'
2
+ import { Children, cloneElement, isValidElement } from 'react'
3
3
 
4
4
  import { variableToString } from '../createVariable.js'
5
5
  import { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'
@@ -24,59 +24,80 @@ export function Theme(props: ThemeProps) {
24
24
  export function useThemedChildren(
25
25
  themeState: ChangedThemeResponse,
26
26
  children: any,
27
- options: { forceClassName?: boolean; shallow?: boolean }
27
+ options: {
28
+ forceClassName?: boolean
29
+ shallow?: boolean
30
+ passPropsToChildren?: boolean
31
+ }
28
32
  ) {
29
33
  const { themeManager, isNewTheme, className, theme } = themeState
30
34
  const { shallow, forceClassName } = options
31
-
32
35
  const hasEverThemed = useServerRef(false)
33
36
  if (isNewTheme) {
34
37
  hasEverThemed.current = true
35
38
  }
36
39
 
37
- // once a theme is set it always passes the context to avoid reparenting
38
- // until then no context to avoid lots of context
39
- if (!isNewTheme && !hasEverThemed.current && !forceClassName && !shallow) {
40
- return children
41
- }
40
+ if (isNewTheme || hasEverThemed.current || forceClassName) {
41
+ // be sure to memoize shouldReset to avoid reparenting
42
+ let next = Children.toArray(children)
42
43
 
43
- // be sure to memoize shouldReset to avoid reparenting
44
- let next = children
45
-
46
- if (shallow && themeManager) {
47
- next = Children.map(next, (child) => {
48
- return cloneElement(
49
- child,
50
- undefined,
51
- <Theme name={themeManager.state.parentName}>{child.props.children}</Theme>
52
- )
53
- })
54
- }
44
+ // each children of these children wont get the theme
45
+ if (shallow && themeManager) {
46
+ next = next.map((child) => {
47
+ return isValidElement(child)
48
+ ? cloneElement(
49
+ child,
50
+ undefined,
51
+ <Theme name={themeManager.state.parentName}>
52
+ {(child as any).props.children}
53
+ </Theme>
54
+ )
55
+ : child
56
+ })
57
+ }
55
58
 
56
- next = (
57
- <ThemeManagerContext.Provider value={themeManager}>
58
- {next}
59
- </ThemeManagerContext.Provider>
60
- )
59
+ // tried this but themes css doesn't fully like it
60
+ // if (shouldAttachClassName && options.passPropsToChildren) {
61
+ // next = next.map((child: any) => {
62
+ // const childStyle = child.props?.style
63
+ // console.log('pass it down', className, child.props.className || '')
64
+ // const newProps = {
65
+ // className: (child.props.className || '') + ' ' + className,
66
+ // style: Array.isArray(childStyle)
67
+ // ? [colorStyle, ...childStyle]
68
+ // : {
69
+ // ...colorStyle,
70
+ // ...childStyle,
71
+ // },
72
+ // }
73
+ // return isValidElement(child) ? cloneElement(child as any, newProps) : child
74
+ // })
75
+ // }
61
76
 
62
- if (isWeb) {
63
- const enableClassName = forceClassName ?? (forceClassName !== false && isNewTheme)
64
- return (
65
- <span
66
- className="_dsp_contents"
67
- {...(theme &&
68
- enableClassName && {
69
- className: `${className} _dsp_contents`,
70
- style: {
71
- // in order to provide currentColor, set color by default
72
- color: variableToString(theme.color),
73
- },
74
- })}
75
- >
77
+ const wrapped = (
78
+ <ThemeManagerContext.Provider value={themeManager}>
76
79
  {next}
77
- </span>
80
+ </ThemeManagerContext.Provider>
78
81
  )
82
+
83
+ if (forceClassName === false) {
84
+ return wrapped
85
+ }
86
+
87
+ if (isWeb && !options.passPropsToChildren) {
88
+ // in order to provide currentColor, set color by default
89
+ const themeColor = theme && isNewTheme ? variableToString(theme.color) : ''
90
+ const colorStyle = {
91
+ color: themeColor,
92
+ }
93
+
94
+ return (
95
+ <span className={`${className || ''} _dsp_contents`} style={colorStyle}>
96
+ {wrapped}
97
+ </span>
98
+ )
99
+ }
79
100
  }
80
101
 
81
- return next
102
+ return children
82
103
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAUN,MAAM,OAAO,CAAA;AAiBd,OAAO,EACL,SAAS,EACT,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAEhB,qBAAqB,EAErB,cAAc,EAIf,MAAM,SAAS,CAAA;AAmBhB,eAAO,MAAM,qBAAqB,EAAE,qBAMnC,CAAA;AAeD,eAAO,MAAM,QAAQ,eAAsB,CAAA;AA8B3C,wBAAgB,eAAe,CAC7B,kBAAkB,SAAS,MAAM,GAAG,EAAE,EACtC,GAAG,GAAG,cAAc,EACpB,SAAS,GAAG,KAAK,EAEjB,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,kBAAkB,EACpD,eAAe,CAAC,EAAE,iBAAiB,4DAqwBpC;AAGD,eAAO,MAAM,QAAQ;YAAW;QAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;KAAE;;CAEjD,CAAA;AAMD,eAAO,MAAM,MAAM,0DA8CjB,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAAA;IACnC,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAC5B,SAAS,CAAC,EAAE,cAAc,CAAA;IAC1B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,mBAiGxD"}
1
+ {"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAUN,MAAM,OAAO,CA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