@tamagui/core 1.0.0-beta.179 → 1.0.0-beta.207

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 (120) hide show
  1. package/dist/cjs/constants/pseudos.js +37 -0
  2. package/dist/cjs/constants/pseudos.js.map +7 -0
  3. package/dist/cjs/createComponent.js +45 -45
  4. package/dist/cjs/createComponent.js.map +2 -2
  5. package/dist/cjs/createShallowUpdate.js +1 -0
  6. package/dist/cjs/createShallowUpdate.js.map +7 -0
  7. package/dist/cjs/defaultComponentState.js +0 -30
  8. package/dist/cjs/defaultComponentState.js.map +3 -3
  9. package/dist/cjs/devtools.js +32 -0
  10. package/dist/cjs/devtools.js.map +7 -0
  11. package/dist/cjs/helpers/RNComponents.js +34 -0
  12. package/dist/cjs/helpers/RNComponents.js.map +7 -0
  13. package/dist/cjs/helpers/createMediaStyle.js +5 -6
  14. package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
  15. package/dist/cjs/helpers/createPropMapper.js.map +1 -1
  16. package/dist/cjs/helpers/createShallowUpdate.js +51 -0
  17. package/dist/cjs/helpers/createShallowUpdate.js.map +7 -0
  18. package/dist/cjs/helpers/createTamaguiProvider.js +1 -5
  19. package/dist/cjs/helpers/createTamaguiProvider.js.map +2 -2
  20. package/dist/cjs/helpers/getSplitStyles.js +7 -7
  21. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  22. package/dist/cjs/helpers/insertStyleRule.js +6 -5
  23. package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
  24. package/dist/cjs/hooks/useFeatures.js +11 -6
  25. package/dist/cjs/hooks/useFeatures.js.map +2 -2
  26. package/dist/cjs/hooks/useMedia.js +5 -31
  27. package/dist/cjs/hooks/useMedia.js.map +2 -2
  28. package/dist/cjs/styled.js +2 -12
  29. package/dist/cjs/styled.js.map +2 -2
  30. package/dist/cjs/tamagui-base.css +8 -0
  31. package/dist/cjs/tamagui-base.css.map +7 -0
  32. package/dist/cjs/types-rnw.js.map +1 -1
  33. package/dist/cjs/types.js.map +1 -1
  34. package/dist/cjs/views/Stack.js.map +2 -2
  35. package/dist/cjs/views/Text.js.map +2 -2
  36. package/dist/cjs/views/Theme.js +7 -16
  37. package/dist/cjs/views/Theme.js.map +2 -2
  38. package/dist/esm/constants/pseudos.js +18 -0
  39. package/dist/esm/constants/pseudos.js.map +7 -0
  40. package/dist/esm/createComponent.js +43 -43
  41. package/dist/esm/createComponent.js.map +2 -2
  42. package/dist/esm/createShallowUpdate.js +1 -0
  43. package/dist/esm/createShallowUpdate.js.map +7 -0
  44. package/dist/esm/defaultComponentState.js +0 -11
  45. package/dist/esm/defaultComponentState.js.map +3 -3
  46. package/dist/esm/devtools.js +14 -0
  47. package/dist/esm/devtools.js.map +7 -0
  48. package/dist/esm/helpers/RNComponents.js +12 -0
  49. package/dist/esm/helpers/RNComponents.js.map +7 -0
  50. package/dist/esm/helpers/createMediaStyle.js +5 -6
  51. package/dist/esm/helpers/createMediaStyle.js.map +2 -2
  52. package/dist/esm/helpers/createPropMapper.js.map +1 -1
  53. package/dist/esm/helpers/createShallowUpdate.js +19 -0
  54. package/dist/esm/helpers/createShallowUpdate.js.map +7 -0
  55. package/dist/esm/helpers/createTamaguiProvider.js +1 -4
  56. package/dist/esm/helpers/createTamaguiProvider.js.map +2 -2
  57. package/dist/esm/helpers/getSplitStyles.js +7 -7
  58. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  59. package/dist/esm/helpers/insertStyleRule.js +6 -5
  60. package/dist/esm/helpers/insertStyleRule.js.map +2 -2
  61. package/dist/esm/hooks/useFeatures.js +17 -11
  62. package/dist/esm/hooks/useFeatures.js.map +2 -2
  63. package/dist/esm/hooks/useMedia.js +5 -31
  64. package/dist/esm/hooks/useMedia.js.map +2 -2
  65. package/dist/esm/styled.js +1 -8
  66. package/dist/esm/styled.js.map +2 -2
  67. package/dist/esm/tamagui-base.css +8 -0
  68. package/dist/esm/tamagui-base.css.map +7 -0
  69. package/dist/esm/views/Stack.js.map +2 -2
  70. package/dist/esm/views/Text.js.map +2 -2
  71. package/dist/esm/views/Theme.js +7 -16
  72. package/dist/esm/views/Theme.js.map +2 -2
  73. package/dist/jsx/constants/pseudos.js +17 -0
  74. package/dist/jsx/createComponent.js +39 -40
  75. package/dist/jsx/createShallowUpdate.js +0 -0
  76. package/dist/jsx/defaultComponentState.js +0 -11
  77. package/dist/jsx/devtools.js +13 -0
  78. package/dist/jsx/helpers/RNComponents.js +11 -0
  79. package/dist/jsx/helpers/createMediaStyle.js +5 -6
  80. package/dist/jsx/helpers/createShallowUpdate.js +18 -0
  81. package/dist/jsx/helpers/createTamaguiProvider.js +1 -2
  82. package/dist/jsx/helpers/getSplitStyles.js +7 -7
  83. package/dist/jsx/helpers/insertStyleRule.js +6 -5
  84. package/dist/jsx/hooks/useFeatures.js +17 -11
  85. package/dist/jsx/hooks/useMedia.js +5 -31
  86. package/dist/jsx/styled.js +1 -8
  87. package/dist/jsx/tamagui-base.css +7 -0
  88. package/dist/jsx/views/Theme.js +7 -16
  89. package/package.json +6 -6
  90. package/types/createComponent.d.ts +5 -6
  91. package/types/createComponent.d.ts.map +1 -1
  92. package/types/defaultComponentState.d.ts +0 -12
  93. package/types/defaultComponentState.d.ts.map +1 -1
  94. package/types/helpers/RNComponents.d.ts +2 -0
  95. package/types/helpers/RNComponents.d.ts.map +1 -0
  96. package/types/helpers/createMediaStyle.d.ts +1 -1
  97. package/types/helpers/createMediaStyle.d.ts.map +1 -1
  98. package/types/helpers/createPropMapper.d.ts +1 -1
  99. package/types/helpers/createPropMapper.d.ts.map +1 -1
  100. package/types/helpers/createShallowUpdate.d.ts +4 -0
  101. package/types/helpers/createShallowUpdate.d.ts.map +1 -0
  102. package/types/helpers/createTamaguiProvider.d.ts +1 -1
  103. package/types/helpers/createTamaguiProvider.d.ts.map +1 -1
  104. package/types/helpers/getSplitStyles.d.ts +2 -3
  105. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  106. package/types/helpers/insertStyleRule.d.ts.map +1 -1
  107. package/types/hooks/useFeatures.d.ts +3 -4
  108. package/types/hooks/useFeatures.d.ts.map +1 -1
  109. package/types/hooks/useMedia.d.ts.map +1 -1
  110. package/types/styled.d.ts +3 -7
  111. package/types/styled.d.ts.map +1 -1
  112. package/types/types-rnw.d.ts +0 -5
  113. package/types/types-rnw.d.ts.map +1 -1
  114. package/types/types.d.ts +61 -62
  115. package/types/types.d.ts.map +1 -1
  116. package/types/views/Stack.d.ts +2 -2
  117. package/types/views/Stack.d.ts.map +1 -1
  118. package/types/views/Text.d.ts +2 -2
  119. package/types/views/Text.d.ts.map +1 -1
  120. package/types/views/Theme.d.ts.map +1 -1
@@ -33,17 +33,18 @@ function updateInserted() {
33
33
  for (let i = 0; i < sheets.length; i++) {
34
34
  const rules = sheets[i].cssRules;
35
35
  const firstRule = rules[0];
36
- if (!firstRule)
36
+ if (!(firstRule instanceof CSSStyleRule))
37
37
  continue;
38
- const firstSelector = firstRule["selectorText"];
38
+ const firstSelector = firstRule.selectorText;
39
39
  if (!firstSelector)
40
40
  continue;
41
41
  if (firstSelector === ":root" || firstSelector.startsWith("._")) {
42
- for (const rule of rules) {
43
- if (!rule.selectorText)
42
+ for (let i2 = 0; i2 < rules.length; i2++) {
43
+ const rule = rules.item(i2);
44
+ if (!(rule instanceof CSSStyleRule))
44
45
  continue;
45
46
  const identifier = rule.selectorText.slice(1);
46
- allSelectors[identifier] = true;
47
+ allSelectors[identifier] = process.env.NODE_ENV === "development" ? rule.cssText : true;
47
48
  if (identifier.startsWith("_transform")) {
48
49
  addTransform(identifier, rule.cssText);
49
50
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/helpers/insertStyleRule.tsx"],
4
- "sourcesContent": ["// this needs to check if its inserted already? 99% of the time it is\n// this should avoid re-inserts, but need to test the perf trade-offs\n// i tested with the site itself and the initial insert was trivial\n\nconst allSelectors = {}\nconst insertedSelectors = {}\nexport const insertedTransforms = {}\n\nexport const getAllSelectors = () => allSelectors\nexport const getInsertedRules = () => Object.values(insertedSelectors)\nexport const getAllTransforms = () => insertedTransforms\n\n// keep transforms in map for merging later\nfunction addTransform(identifier: string, rule: string) {\n const s = rule.indexOf('transform:')\n if (s === -1) {\n console.error(`not a transform ${identifier} ${rule}`)\n return\n }\n const startI = s + 'transform:'.length\n const endI = rule.indexOf(';')\n const value = rule.slice(startI, endI)\n insertedTransforms[identifier] = value\n}\n\n// gets existing ones (client side)\n// takes ~0.1ms for a fairly large page\n// used now for three things:\n// 1. debugging at dev time\n// 2. avoid duplicate insert styles at runtime\n// 3. used now for merging transforms atomically\nlet hasInsertedSinceUpdate = true\nexport function updateInserted() {\n if (typeof document === 'undefined') {\n return\n }\n if (!hasInsertedSinceUpdate) {\n console.warn('hasnt inserted since')\n return\n }\n const sheets = document.styleSheets\n if (!sheets) return\n for (let i = 0; i < sheets.length; i++) {\n const rules = sheets[i].cssRules\n const firstRule = rules[0]\n if (!firstRule) continue\n const firstSelector = firstRule['selectorText']\n if (!firstSelector) continue\n if (firstSelector === ':root' || firstSelector.startsWith('._')) {\n for (const rule of rules as any) {\n if (!rule.selectorText) continue\n const identifier = rule.selectorText.slice(1)\n allSelectors[identifier] = true\n if (identifier.startsWith('_transform')) {\n addTransform(identifier, rule.cssText)\n }\n }\n }\n }\n hasInsertedSinceUpdate = false\n}\n\nupdateInserted()\n\nconst newRulesStyleTag =\n typeof document !== 'undefined'\n ? document.head.appendChild(document.createElement('style'))\n : null\n\nexport function insertStyleRule(identifier: string, rule: string) {\n if (allSelectors[identifier]) {\n return\n }\n hasInsertedSinceUpdate = true\n insertedSelectors[identifier] = rule\n allSelectors[identifier] = process.env.NODE_ENV === 'development' ? rule : true\n if (identifier.startsWith('_transform')) {\n addTransform(identifier, rule)\n }\n if (!newRulesStyleTag) {\n return\n }\n const sheet = newRulesStyleTag.sheet!\n sheet.insertRule(rule, sheet.cssRules.length)\n return identifier\n}\n"],
5
- "mappings": ";;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,cAChB,SAAS,KAAK,YAAY,SAAS,cAAc,OAAO,CAAC,IACzD;AAEC,yBAAyB,YAAoB,MAAc;AAChE,MAAI,aAAa,aAAa;AAC5B;AAAA,EACF;AACA,2BAAyB;AACzB,oBAAkB,cAAc;AAChC,eAAa,cAAc,QAAQ,IAAI,aAAa,gBAAgB,OAAO;AAC3E,MAAI,WAAW,WAAW,YAAY,GAAG;AACvC,iBAAa,YAAY,IAAI;AAAA,EAC/B;AACA,MAAI,CAAC,kBAAkB;AACrB;AAAA,EACF;AACA,QAAM,QAAQ,iBAAiB;AAC/B,QAAM,WAAW,MAAM,MAAM,SAAS,MAAM;AAC5C,SAAO;AACT;AAhBgB;",
4
+ "sourcesContent": ["// this needs to check if its inserted already? 99% of the time it is\n// this should avoid re-inserts, but need to test the perf trade-offs\n// i tested with the site itself and the initial insert was trivial\n\nconst allSelectors = {}\nconst insertedSelectors = {}\nexport const insertedTransforms = {}\n\nexport const getAllSelectors = () => allSelectors\nexport const getInsertedRules = () => Object.values(insertedSelectors)\nexport const getAllTransforms = () => insertedTransforms\n\n// keep transforms in map for merging later\nfunction addTransform(identifier: string, rule: string) {\n const s = rule.indexOf('transform:')\n if (s === -1) {\n console.error(`not a transform ${identifier} ${rule}`)\n return\n }\n const startI = s + 'transform:'.length\n const endI = rule.indexOf(';')\n const value = rule.slice(startI, endI)\n insertedTransforms[identifier] = value\n}\n\n// gets existing ones (client side)\n// takes ~0.1ms for a fairly large page\n// used now for three things:\n// 1. debugging at dev time\n// 2. avoid duplicate insert styles at runtime\n// 3. used now for merging transforms atomically\nlet hasInsertedSinceUpdate = true\nexport function updateInserted() {\n if (typeof document === 'undefined') {\n return\n }\n if (!hasInsertedSinceUpdate) {\n console.warn('hasnt inserted since')\n return\n }\n const sheets = document.styleSheets\n if (!sheets) return\n for (let i = 0; i < sheets.length; i++) {\n const rules = sheets[i].cssRules\n const firstRule = rules[0]\n if (!(firstRule instanceof CSSStyleRule)) continue\n const firstSelector = firstRule.selectorText\n if (!firstSelector) continue\n if (firstSelector === ':root' || firstSelector.startsWith('._')) {\n for (let i = 0; i < rules.length; i++) {\n const rule = rules.item(i)\n if (!(rule instanceof CSSStyleRule)) continue\n const identifier = rule.selectorText.slice(1)\n allSelectors[identifier] = process.env.NODE_ENV === 'development' ? rule.cssText : true\n if (identifier.startsWith('_transform')) {\n addTransform(identifier, rule.cssText)\n }\n }\n }\n }\n hasInsertedSinceUpdate = false\n}\n\nupdateInserted()\n\nconst newRulesStyleTag =\n typeof document !== 'undefined'\n ? document.head.appendChild(document.createElement('style'))\n : null\n\nexport function insertStyleRule(identifier: string, rule: string) {\n if (allSelectors[identifier]) {\n return\n }\n hasInsertedSinceUpdate = true\n insertedSelectors[identifier] = rule\n allSelectors[identifier] = process.env.NODE_ENV === 'development' ? rule : true\n if (identifier.startsWith('_transform')) {\n addTransform(identifier, rule)\n }\n if (!newRulesStyleTag) {\n return\n }\n const sheet = newRulesStyleTag.sheet!\n sheet.insertRule(rule, sheet.cssRules.length)\n return identifier\n}\n"],
5
+ "mappings": ";;AAIA,MAAM,eAAe,CAAC;AACtB,MAAM,oBAAoB,CAAC;AACpB,MAAM,qBAAqB,CAAC;AAE5B,MAAM,kBAAkB,6BAAM,cAAN;AACxB,MAAM,mBAAmB,6BAAM,OAAO,OAAO,iBAAiB,GAArC;AACzB,MAAM,mBAAmB,6BAAM,oBAAN;AAGhC,sBAAsB,YAAoB,MAAc;AACtD,QAAM,IAAI,KAAK,QAAQ,YAAY;AACnC,MAAI,MAAM,IAAI;AACZ,YAAQ,MAAM,mBAAmB,cAAc,MAAM;AACrD;AAAA,EACF;AACA,QAAM,SAAS,IAAI,aAAa;AAChC,QAAM,OAAO,KAAK,QAAQ,GAAG;AAC7B,QAAM,QAAQ,KAAK,MAAM,QAAQ,IAAI;AACrC,qBAAmB,cAAc;AACnC;AAVS;AAkBT,IAAI,yBAAyB;AACtB,0BAA0B;AAC/B,MAAI,OAAO,aAAa,aAAa;AACnC;AAAA,EACF;AAC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AnimationFeature() {
45
45
  console.error("no useAnimations hook provided");
46
46
  return null;
47
47
  }
48
- const animatedStyleIn = {
49
- ...style,
50
- ...state.hover && pseudos.hoverStyle,
51
- ...state.focus && pseudos.focusStyle,
52
- ...state.press && pseudos.pressStyle
53
- };
54
- const res = useAnimations(props, {
55
- isMounted: state.mounted,
56
- style: animatedStyleIn,
57
- exitStyle: pseudos == null ? void 0 : pseudos.exitStyle
48
+ const propsWithAnimation = props;
49
+ const styleKey = JSON.stringify(style);
50
+ const res = useAnimations(propsWithAnimation, {
51
+ styleKey,
52
+ style: style || {},
53
+ state,
54
+ pseudos,
55
+ mergedStyles(props2) {
56
+ return {
57
+ ...style,
58
+ ...state.hover && pseudos.hoverStyle,
59
+ ...state.focus && pseudos.focusStyle,
60
+ ...state.press && pseudos.pressStyle,
61
+ ...(props2 == null ? void 0 : props2.isExiting) && pseudos.exitStyle
62
+ };
63
+ }
58
64
  });
59
65
  useIsomorphicLayoutEffect(() => {
60
66
  setStateShallow({
61
67
  animation: res
62
68
  });
63
- }, [JSON.stringify(style)]);
69
+ }, [styleKey]);
64
70
  return null;
65
71
  },
66
72
  propNames: ["animation"]
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/useFeatures.tsx"],
4
- "sourcesContent": ["import React from 'react'\nimport { ViewStyle } from 'react-native'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { ComponentState } from '../defaultComponentState'\nimport { PseudoStyles } from '../static'\nimport { UseAnimationHook } from '../types'\nimport { addMediaQueryListener, mediaState, removeMediaQueryListener } from './useMedia'\n\ntype FeatureDefinition = {\n isEnabled: (props: any) => boolean\n Component: any\n}\n\ntype FeatureUtils = {\n forceUpdate: Function\n state: ComponentState\n setStateShallow: (next: Partial<ComponentState>) => void\n useAnimations?: UseAnimationHook\n pseudos: PseudoStyles\n style: ViewStyle | null | undefined\n}\n\nconst createDefinition = ({\n Component,\n propNames,\n}: {\n Component: (props: { _utils: FeatureUtils; [key: string]: any }) => void\n propNames: string[]\n}): FeatureDefinition => ({\n isEnabled: (props: any) => propNames.some((name) => !!props[name]),\n Component,\n})\n\nlet featureDefinitions: Record<string, FeatureDefinition> | null = null\n\nexport const useFeatures = (props: any, utils?: FeatureUtils) => {\n if (!featureDefinitions) {\n featureDefinitions = loadFeatures()\n }\n const features: JSX.Element[] = []\n for (const name in featureDefinitions) {\n const { isEnabled, Component } = featureDefinitions[name]\n if (isEnabled(props) && Component) {\n features.push(<Component key={name} {...props} _utils={utils} />)\n }\n }\n return features\n}\n\nfunction loadFeatures(): Record<string, FeatureDefinition> {\n return {\n // loads animations and sets state with the results\n animation: loadAnimationFeature(),\n\n // will update the parent whenever media query changes\n // no need on web, media queries are inserted and run in css\n ...(!isWeb && {\n mediaQuery: loadMediaQueryFeature(),\n }),\n }\n}\n\nfunction loadAnimationFeature() {\n return createDefinition({\n Component: ({ _utils, ...props }) => {\n const { state, useAnimations, pseudos, style, setStateShallow } = _utils\n\n if (!useAnimations) {\n console.error('no useAnimations hook provided')\n return null\n }\n\n const animatedStyleIn = {\n ...style,\n ...(state.hover && pseudos.hoverStyle),\n ...(state.focus && pseudos.focusStyle),\n ...(state.press && pseudos.pressStyle),\n }\n\n const res = useAnimations(props as any, {\n isMounted: state.mounted,\n style: animatedStyleIn,\n exitStyle: pseudos?.exitStyle,\n // onDidAnimate, delay\n })\n\n useIsomorphicLayoutEffect(() => {\n setStateShallow({\n animation: res,\n })\n }, [JSON.stringify(style)])\n\n return null\n },\n propNames: ['animation'],\n })\n}\n\nfunction loadMediaQueryFeature() {\n const mediaPropNames = Object.keys(mediaState)\n\n return createDefinition({\n Component: (props: any) => {\n const keys = mediaPropNames.flatMap((x) => (x in props ? x.slice(1) : []))\n\n useIsomorphicLayoutEffect(() => {\n for (const key of keys) {\n addMediaQueryListener(key, props._utils.forceUpdate)\n }\n return () => {\n for (const key of keys) {\n removeMediaQueryListener(key, props._utils.forceUpdate)\n }\n }\n }, [keys.join(',')])\n\n return null\n },\n propNames: mediaPropNames,\n })\n}\n\n// TODO\n// measureLayout: createDefinition({\n// Component: (props) => {\n// console.log('measure', props)\n// return null\n// },\n// propNames: ['onLayout'],\n// }),\n"],
5
- "mappings": ";;AAAA;AAGA;AAIA;AAgBA,MAAM,mBAAmB,wBAAC;AAAA,EACxB;AAAA,EACA;AAAA,MAIwB;AAAA,EACxB,WAAW,CAAC,UAAe,UAAU,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK;AAAA,EACjE;AACF,IATyB;AAWzB,IAAI,qBAA+D;AAE5D,MAAM,cAAc,wBAAC,OAAY,UAAyB;AAC/D,MAAI,CAAC,oBAAoB;AACvB,yBAAqB,aAAa;AAAA,EACpC;AACA,QAAM,WAA0B,CAAC;AACjC,aAAW,QAAQ,oBAAoB;AACrC,UAAM,EAAE,WAAW,cAAc,mBAAmB;AACpD,QAAI,UAAU,KAAK,KAAK,WAAW;AACjC,eAAS,KAAK,oCAAC;AAAA,QAAU,KAAK;AAAA,WAAU;AAAA,QAAO,QAAQ;AAAA,OAAO,CAAE;AAAA,IAClE;AAAA,EACF;AACA,SAAO;AACT,GAZ2B;AAc3B,wBAA2D;AACzD,SAAO;AAAA,IAEL,WAAW,qBAAqB;AAAA,OAI5B,CAAC,SAAS;AAAA,MACZ,YAAY,sBAAsB;AAAA,IACpC;AAAA,EACF;AACF;AAXS;AAaT,gCAAgC;AAC9B,SAAO,iBAAiB;AAAA,IACtB,WAAW,CAAC,EAAE,WAAW,YAAY;AACnC,YAAM,EAAE,OAAO,eAAe,SAAS,OAAO,oBAAoB;AAElE,UAAI,CAAC,eAAe;AAClB,gBAAQ,MAAM,gCAAgC;AAC9C,eAAO;AAAA,MACT;AAEA,YAAM,kBAAkB;AAAA,WACnB;AAAA,WACC,MAAM,SAAS,QAAQ;AAAA,WACvB,MAAM,SAAS,QAAQ;AAAA,WACvB,MAAM,SAAS,QAAQ;AAAA,MAC7B;AAEA,YAAM,MAAM,cAAc,OAAc;AAAA,QACtC,WAAW,MAAM;AAAA,QACjB,OAAO;AAAA,QACP,WAAW,mCAAS;AAAA,MAEtB,CAAC;AAED,gCAA0B,MAAM;AAC9B,wBAAgB;AAAA,UACd,WAAW;AAAA,QACb,CAAC;AAAA,MACH,GAAG,CAAC,KAAK,UAAU,KAAK,CAAC,CAAC;AAE1B,aAAO;AAAA,IACT;AAAA,IACA,WAAW,CAAC,WAAW;AAAA,EACzB,CAAC;AACH;AAlCS;AAoCT,iCAAiC;AAC/B,QAAM,iBAAiB,OAAO,KAAK,UAAU;AAE7C,SAAO,iBAAiB;AAAA,IACtB,WAAW,CAAC,UAAe;AACzB,YAAM,OAAO,eAAe,QAAQ,CAAC,MAAO,KAAK,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAE;AAEzE,gCAA0B,MAAM;AAC9B,mBAAW,OAAO,MAAM;AACtB,gCAAsB,KAAK,MAAM,OAAO,WAAW;AAAA,QACrD;AACA,eAAO,MAAM;AACX,qBAAW,OAAO,MAAM;AACtB,qCAAyB,KAAK,MAAM,OAAO,WAAW;AAAA,UACxD;AAAA,QACF;AAAA,MACF,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,CAAC;AAEnB,aAAO;AAAA,IACT;AAAA,IACA,WAAW;AAAA,EACb,CAAC;AACH;AAtBS;",
4
+ "sourcesContent": ["import React from 'react'\nimport { ViewStyle } from 'react-native'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { PseudoStyles } from '../static'\nimport { TamaguiComponentState, UseAnimationHook, UseAnimationProps } from '../types'\nimport { addMediaQueryListener, mediaState, removeMediaQueryListener } from './useMedia'\n\ntype FeatureDefinition = {\n isEnabled: (props: any) => boolean\n Component: any\n}\n\ntype FeatureUtils = {\n forceUpdate: Function\n state: TamaguiComponentState\n setStateShallow: (next: Partial<TamaguiComponentState>) => void\n useAnimations?: UseAnimationHook\n pseudos: PseudoStyles\n style: ViewStyle | null | undefined\n}\n\nconst createDefinition = ({\n Component,\n propNames,\n}: {\n Component: (props: { _utils: FeatureUtils; [key: string]: any }) => void\n propNames: string[]\n}): FeatureDefinition => ({\n isEnabled: (props: any) => propNames.some((name) => !!props[name]),\n Component,\n})\n\nlet featureDefinitions: Record<string, FeatureDefinition> | null = null\n\nexport const useFeatures = (props: any, utils?: FeatureUtils) => {\n if (!featureDefinitions) {\n featureDefinitions = loadFeatures()\n }\n const features: JSX.Element[] = []\n for (const name in featureDefinitions) {\n const { isEnabled, Component } = featureDefinitions[name]\n if (isEnabled(props) && Component) {\n features.push(<Component key={name} {...props} _utils={utils} />)\n }\n }\n return features\n}\n\nfunction loadFeatures(): Record<string, FeatureDefinition> {\n return {\n // loads animations and sets state with the results\n animation: loadAnimationFeature(),\n\n // will update the parent whenever media query changes\n // no need on web, media queries are inserted and run in css\n ...(!isWeb && {\n mediaQuery: loadMediaQueryFeature(),\n }),\n }\n}\n\nfunction loadAnimationFeature() {\n return createDefinition({\n Component: ({ _utils, ...props }) => {\n const { state, useAnimations, pseudos, style, setStateShallow } = _utils\n\n if (!useAnimations) {\n console.error('no useAnimations hook provided')\n return null\n }\n\n // const animatedStyleIn =\n\n // we always have .animation set\n const propsWithAnimation = props as UseAnimationProps\n const styleKey = JSON.stringify(style)\n\n const res = useAnimations(propsWithAnimation, {\n styleKey,\n style: style || {},\n state,\n pseudos,\n mergedStyles(props) {\n return {\n ...style,\n ...(state.hover && pseudos.hoverStyle),\n ...(state.focus && pseudos.focusStyle),\n ...(state.press && pseudos.pressStyle),\n ...(props?.isExiting && pseudos.exitStyle),\n }\n },\n // onDidAnimate, delay\n })\n\n useIsomorphicLayoutEffect(() => {\n setStateShallow({\n animation: res,\n })\n }, [styleKey])\n\n return null\n },\n propNames: ['animation'],\n })\n}\n\nfunction loadMediaQueryFeature() {\n const mediaPropNames = Object.keys(mediaState)\n\n return createDefinition({\n Component: (props: any) => {\n const keys = mediaPropNames.flatMap((x) => (x in props ? x.slice(1) : []))\n\n useIsomorphicLayoutEffect(() => {\n for (const key of keys) {\n addMediaQueryListener(key, props._utils.forceUpdate)\n }\n return () => {\n for (const key of keys) {\n removeMediaQueryListener(key, props._utils.forceUpdate)\n }\n }\n }, [keys.join(',')])\n\n return null\n },\n propNames: mediaPropNames,\n })\n}\n\n// TODO\n// measureLayout: createDefinition({\n// Component: (props) => {\n// console.log('measure', props)\n// return null\n// },\n// propNames: ['onLayout'],\n// }),\n"],
5
+ "mappings": ";;AAAA;AAGA;AAGA;AAgBA,MAAM,mBAAmB,wBAAC;AAAA,EACxB;AAAA,EACA;AAAA,MAIwB;AAAA,EACxB,WAAW,CAAC,UAAe,UAAU,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK;AAAA,EACjE;AACF,IATyB;AAWzB,IAAI,qBAA+D;AAE5D,MAAM,cAAc,wBAAC,OAAY,UAAyB;AAC/D,MAAI,CAAC,oBAAoB;AACvB,yBAAqB,aAAa;AAAA,EACpC;AACA,QAAM,WAA0B,CAAC;AACjC,aAAW,QAAQ,oBAAoB;AACrC,UAAM,EAAE,WAAW,cAAc,mBAAmB;AACpD,QAAI,UAAU,KAAK,KAAK,WAAW;AACjC,eAAS,KAAK,oCAAC;AAAA,QAAU,KAAK;AAAA,WAAU;AAAA,QAAO,QAAQ;AAAA,OAAO,CAAE;AAAA,IAClE;AAAA,EACF;AACA,SAAO;AACT,GAZ2B;AAc3B,wBAA2D;AACzD,SAAO;AAAA,IAEL,WAAW,qBAAqB;AAAA,OAI5B,CAAC,SAAS;AAAA,MACZ,YAAY,sBAAsB;AAAA,IACpC;AAAA,EACF;AACF;AAXS;AAaT,gCAAgC;AAC9B,SAAO,iBAAiB;AAAA,IACtB,WAAW,CAAC,EAAE,WAAW,YAAY;AACnC,YAAM,EAAE,OAAO,eAAe,SAAS,OAAO,oBAAoB;AAElE,UAAI,CAAC,eAAe;AAClB,gBAAQ,MAAM,gCAAgC;AAC9C,eAAO;AAAA,MACT;AAKA,YAAM,qBAAqB;AAC3B,YAAM,WAAW,KAAK,UAAU,KAAK;AAErC,YAAM,MAAM,cAAc,oBAAoB;AAAA,QAC5C;AAAA,QACA,OAAO,SAAS,CAAC;AAAA,QACjB;AAAA,QACA;AAAA,QACA,aAAa,QAAO;AAClB,iBAAO;AAAA,eACF;AAAA,eACC,MAAM,SAAS,QAAQ;AAAA,eACvB,MAAM,SAAS,QAAQ;AAAA,eACvB,MAAM,SAAS,QAAQ;AAAA,eACvB,kCAAO,cAAa,QAAQ;AAAA,UAClC;AAAA,QACF;AAAA,MAEF,CAAC;AAED,gCAA0B,MAAM;AAC9B,wBAAgB;AAAA,UACd,WAAW;AAAA,QACb,CAAC;AAAA,MACH,GAAG,CAAC,QAAQ,CAAC;AAEb,aAAO;AAAA,IACT;AAAA,IACA,WAAW,CAAC,WAAW;AAAA,EACzB,CAAC;AACH;AA3CS;AA6CT,iCAAiC;AAC/B,QAAM,iBAAiB,OAAO,KAAK,UAAU;AAE7C,SAAO,iBAAiB;AAAA,IACtB,WAAW,CAAC,UAAe;AACzB,YAAM,OAAO,eAAe,QAAQ,CAAC,MAAO,KAAK,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAE;AAEzE,gCAA0B,MAAM;AAC9B,mBAAW,OAAO,MAAM;AACtB,gCAAsB,KAAK,MAAM,OAAO,WAAW;AAAA,QACrD;AACA,eAAO,MAAM;AACX,qBAAW,OAAO,MAAM;AACtB,qCAAyB,KAAK,MAAM,OAAO,WAAW;AAAA,UACxD;AAAA,QACF;AAAA,MACF,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,CAAC;AAEnB,aAAO;AAAA,IACT;AAAA,IACA,WAAW;AAAA,EACb,CAAC;AACH;AAtBS;",
6
6
  "names": []
7
7
  }
@@ -15,36 +15,9 @@ const removeMediaQueryListener = /* @__PURE__ */ __name((key, cb) => {
15
15
  var _a;
16
16
  (_a = mediaQueryListeners[key]) == null ? void 0 : _a.delete(cb);
17
17
  }, "removeMediaQueryListener");
18
- let conf = null;
19
- const mediaQueryConfig = new Proxy({}, {
20
- get(target, key) {
21
- if (key === "$$typeof") {
22
- return Reflect.get(target, key);
23
- }
24
- if (!conf) {
25
- console.warn("Tamagui: accessing media query before init");
26
- return null;
27
- }
28
- return Reflect.get(conf, key);
29
- },
30
- ownKeys() {
31
- if (!conf) {
32
- console.warn("Tamagui: accessing media query before init");
33
- return [];
34
- }
35
- return Object.keys(conf);
36
- },
37
- getOwnPropertyDescriptor() {
38
- return {
39
- enumerable: true,
40
- configurable: true
41
- };
42
- }
43
- });
18
+ let hasConfigured = false;
19
+ const mediaQueryConfig = {};
44
20
  const getMedia = /* @__PURE__ */ __name(() => {
45
- if (!conf) {
46
- throw new Error(`not configured yet`);
47
- }
48
21
  return mediaState;
49
22
  }, "getMedia");
50
23
  const configureMedia = /* @__PURE__ */ __name(({
@@ -52,11 +25,12 @@ const configureMedia = /* @__PURE__ */ __name(({
52
25
  defaultActive = ["sm", "xs"]
53
26
  } = {}) => {
54
27
  var _a;
55
- if (conf) {
28
+ if (hasConfigured) {
56
29
  console.warn(`Already configured mediaQueries once (you may have called getMedia() before configureMedia())`);
57
30
  }
58
31
  if (queries) {
59
- conf = queries;
32
+ Object.assign(mediaQueryConfig, queries);
33
+ hasConfigured = true;
60
34
  }
61
35
  for (const key in queries) {
62
36
  const str = mediaObjectToString(queries[key]);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/useMedia.tsx"],
4
- "sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport { useRef } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { matchMedia } from '../helpers/matchMedia'\nimport {\n ConfigureMediaQueryOptions,\n MediaQueries,\n MediaQueryObject,\n MediaQueryState,\n} from '../types'\nimport { useConstant } from './useConstant'\n\nexport const mediaState: { [key in keyof MediaQueryState]: boolean } = {} as any\nconst mediaQueryListeners: { [key: string]: Set<Function> } = {}\n\nexport const addMediaQueryListener = (key: string, cb: any) => {\n mediaQueryListeners[key] = mediaQueryListeners[key] || new Set()\n mediaQueryListeners[key].add(cb)\n}\n\nexport const removeMediaQueryListener = (key: string, cb: any) => {\n mediaQueryListeners[key]?.delete(cb)\n}\n\nlet conf: MediaQueries | null = null\n\nexport const mediaQueryConfig = new Proxy<MediaQueries>({} as any, {\n get(target, key) {\n if (key === '$$typeof') {\n return Reflect.get(target, key)\n }\n if (!conf) {\n console.warn('Tamagui: accessing media query before init')\n return null\n }\n return Reflect.get(conf, key)\n },\n ownKeys() {\n if (!conf) {\n console.warn('Tamagui: accessing media query before init')\n return []\n }\n return Object.keys(conf)\n },\n getOwnPropertyDescriptor() {\n return {\n enumerable: true,\n configurable: true,\n }\n },\n})\n\nexport const getMedia = () => {\n if (!conf) {\n throw new Error(`not configured yet`)\n }\n return mediaState\n}\n\nexport const configureMedia = ({\n queries,\n defaultActive = ['sm', 'xs'],\n}: ConfigureMediaQueryOptions = {}) => {\n if (conf) {\n console.warn(\n `Already configured mediaQueries once (you may have called getMedia() before configureMedia())`\n )\n }\n\n if (queries) {\n conf = queries\n }\n\n // setup\n for (const key in queries) {\n const str = mediaObjectToString(queries[key])\n try {\n const getMatch = () => matchMedia(str)\n const match = getMatch()\n if (!match || typeof match.addListener !== 'function') {\n // caught below\n throw new Error('\u26A0\uFE0F No match (seeing this in RN sometimes)')\n }\n mediaState[key] = !!match.matches\n match.addListener(() => {\n const next = !!getMatch().matches\n if (next === mediaState[key]) return\n mediaState[key] = next\n const listeners = mediaQueryListeners[key]\n if (listeners?.size) {\n for (const cb of [...listeners]) {\n cb()\n }\n }\n })\n } catch (err: any) {\n console.error('Error running media query', str, err.message, err.stack)\n const isDefaultActive = defaultActive?.includes(key as any) ?? true\n mediaState[key] = isDefaultActive\n }\n }\n}\n\ntype UseMediaState = {\n selections: { [key: string]: boolean }\n nextSelections: { [key: string]: boolean }\n isRendering: boolean\n isUnmounted: boolean\n}\n\nexport const useMedia = () => {\n const forceUpdate = useForceUpdate()\n const state = useRef() as React.MutableRefObject<UseMediaState>\n if (!state.current) {\n state.current = {\n selections: {},\n nextSelections: {},\n isUnmounted: false,\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n // delete old\n for (const key in st.selections) {\n if (!(key in st.nextSelections)) {\n removeMediaQueryListener(key, forceUpdate)\n }\n }\n // add new\n for (const key in st.nextSelections) {\n if (!(key in st.selections)) {\n addMediaQueryListener(key, forceUpdate)\n }\n }\n })\n\n // unmount\n useIsomorphicLayoutEffect(() => {\n return () => {\n const st = state.current\n st.isUnmounted = true\n const allKeys = {\n ...st.selections,\n ...st.nextSelections,\n }\n for (const key in allKeys) {\n removeMediaQueryListener(key, forceUpdate)\n }\n }\n }, [])\n\n return useConstant(() => {\n const st = state.current\n return new Proxy(mediaState, {\n get(target, key: string) {\n if (!(key in mediaState)) {\n return Reflect.get(target, key)\n }\n if (!st.isUnmounted) {\n if (st.isRendering) {\n st.nextSelections[key] = true\n }\n }\n if (key in mediaState) {\n return mediaState[key]\n }\n return Reflect.get(mediaState, key)\n },\n })\n })\n}\n\nfunction camelToHyphen(str: string) {\n return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase()\n}\n\nexport function mediaObjectToString(query: string | MediaQueryObject) {\n if (typeof query === 'string') {\n return query\n }\n return Object.entries(query)\n .map(([feature, value]) => {\n feature = camelToHyphen(feature)\n if (typeof value === 'string') {\n return `(${feature}: ${value})`\n }\n if (typeof value === 'number' && /[height|width]$/.test(feature)) {\n value = `${value}px`\n }\n return `(${feature}: ${value})`\n })\n .join(' and ')\n}\n"],
5
- "mappings": ";;AAAA;AACA;AAEA;AACA;AAOA;AAEO,MAAM,aAA0D,CAAC;AACxE,MAAM,sBAAwD,CAAC;AAExD,MAAM,wBAAwB,wBAAC,KAAa,OAAY;AAC7D,sBAAoB,OAAO,oBAAoB,QAAQ,oBAAI,IAAI;AAC/D,sBAAoB,KAAK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K,WAAW;AAAA,MAC3C;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO,YAAY,MAAM;AACvB,UAAM,KAAK,MAAM;AACjB,WAAO,IAAI,MAAM,YAAY;AAAA,MAC3B,IAAI,QAAQ,KAAa;AACvB,YAAI,CAAE,QAAO,aAAa;AACxB,iBAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,QAChC;AACA,YAAI,CAAC,GAAG,aAAa;AACnB,cAAI,GAAG,aAAa;AAClB,eAAG,eAAe,OAAO;AAAA,UAC3B;AAAA,QACF;AACA,YAAI,OAAO,YAAY;AACrB,iBAAO,WAAW;AAAA,QACpB;AACA,eAAO,QAAQ,IAAI,YAAY,GAAG;AAAA,MACpC;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH,GAjEwB;AAmExB,uBAAuB,KAAa;AAClC,SAAO,IAAI,QAAQ,UAAU,CAAC,MAAM,IAAI,EAAE,YAAY,GAAG,EAAE,YAAY;AACzE;AAFS;AAIF,6BAA6B,OAAkC;AACpE,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO,OAAO,QAAQ,KAAK,EACxB,IAAI,CAAC,CAAC,SAAS,WAAW;AACzB,cAAU,cAAc,OAAO;AAC/B,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,IAAI,YAAY;AAAA,IACzB;AACA,QAAI,OAAO,UAAU,YAAY,kBAAkB,KAAK,OAAO,GAAG;AAChE,cAAQ,GAAG;AAAA,IACb;AACA,WAAO,IAAI,YAAY;AAAA,EACzB,CAAC,EACA,KAAK,OAAO;AACjB;AAhBgB;",
4
+ "sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport { useRef } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { matchMedia } from '../helpers/matchMedia'\nimport {\n ConfigureMediaQueryOptions,\n MediaQueries,\n MediaQueryObject,\n MediaQueryState,\n} from '../types'\nimport { useConstant } from './useConstant'\n\nexport const mediaState: { [key in keyof MediaQueryState]: boolean } = {} as any\nconst mediaQueryListeners: { [key: string]: Set<Function> } = {}\n\nexport const addMediaQueryListener = (key: string, cb: any) => {\n mediaQueryListeners[key] = mediaQueryListeners[key] || new Set()\n mediaQueryListeners[key].add(cb)\n}\n\nexport const removeMediaQueryListener = (key: string, cb: any) => {\n mediaQueryListeners[key]?.delete(cb)\n}\n\nlet hasConfigured = false\nexport const mediaQueryConfig: MediaQueries = {}\n\nexport const getMedia = () => {\n return mediaState\n}\n\nexport const configureMedia = ({\n queries,\n defaultActive = ['sm', 'xs'],\n}: ConfigureMediaQueryOptions = {}) => {\n if (hasConfigured) {\n console.warn(\n `Already configured mediaQueries once (you may have called getMedia() before configureMedia())`\n )\n }\n\n if (queries) {\n Object.assign(mediaQueryConfig, queries)\n hasConfigured = true\n }\n\n // setup\n for (const key in queries) {\n const str = mediaObjectToString(queries[key])\n try {\n const getMatch = () => matchMedia(str)\n const match = getMatch()\n if (!match || typeof match.addListener !== 'function') {\n // caught below\n throw new Error('\u26A0\uFE0F No match (seeing this in RN sometimes)')\n }\n mediaState[key] = !!match.matches\n match.addListener(() => {\n const next = !!getMatch().matches\n if (next === mediaState[key]) return\n mediaState[key] = next\n const listeners = mediaQueryListeners[key]\n if (listeners?.size) {\n for (const cb of [...listeners]) {\n cb()\n }\n }\n })\n } catch (err: any) {\n console.error('Error running media query', str, err.message, err.stack)\n const isDefaultActive = defaultActive?.includes(key as any) ?? true\n mediaState[key] = isDefaultActive\n }\n }\n}\n\ntype UseMediaState = {\n selections: { [key: string]: boolean }\n nextSelections: { [key: string]: boolean }\n isRendering: boolean\n isUnmounted: boolean\n}\n\nexport const useMedia = () => {\n const forceUpdate = useForceUpdate()\n const state = useRef() as React.MutableRefObject<UseMediaState>\n if (!state.current) {\n state.current = {\n selections: {},\n nextSelections: {},\n isUnmounted: false,\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n // delete old\n for (const key in st.selections) {\n if (!(key in st.nextSelections)) {\n removeMediaQueryListener(key, forceUpdate)\n }\n }\n // add new\n for (const key in st.nextSelections) {\n if (!(key in st.selections)) {\n addMediaQueryListener(key, forceUpdate)\n }\n }\n })\n\n // unmount\n useIsomorphicLayoutEffect(() => {\n return () => {\n const st = state.current\n st.isUnmounted = true\n const allKeys = {\n ...st.selections,\n ...st.nextSelections,\n }\n for (const key in allKeys) {\n removeMediaQueryListener(key, forceUpdate)\n }\n }\n }, [])\n\n return useConstant(() => {\n const st = state.current\n return new Proxy(mediaState, {\n get(target, key: string) {\n if (!(key in mediaState)) {\n return Reflect.get(target, key)\n }\n if (!st.isUnmounted) {\n if (st.isRendering) {\n st.nextSelections[key] = true\n }\n }\n if (key in mediaState) {\n return mediaState[key]\n }\n return Reflect.get(mediaState, key)\n },\n })\n })\n}\n\nfunction camelToHyphen(str: string) {\n return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase()\n}\n\nexport function mediaObjectToString(query: string | MediaQueryObject) {\n if (typeof query === 'string') {\n return query\n }\n return Object.entries(query)\n .map(([feature, value]) => {\n feature = camelToHyphen(feature)\n if (typeof value === 'string') {\n return `(${feature}: ${value})`\n }\n if (typeof value === 'number' && /[height|width]$/.test(feature)) {\n value = `${value}px`\n }\n return `(${feature}: ${value})`\n })\n .join(' and ')\n}\n"],
5
+ "mappings": ";;AAAA;AACA;AAEA;AACA;AAOA;AAEO,MAAM,aAA0D,CAAC;AACxE,MAAM,sBAAwD,CAAC;AAExD,MAAM,wBAAwB,wBAAC,KAAa,OAAY;AAC7D,sBAAoB,OAAO,oBAAoB,QAAQ,oBAAI,IAAI;AAC/D,sBAAoB,KAAK,IAAI,EAAE;AACjC,GAHqC;AAK9B,MAAM,2BAA2B,wBAAC,KAAa,OAAY;AArBlE;AAsBE,4BAAoB,SAApB,mBAA0B,OAAO;AACnC,GAFwC;AAIxC,IAAI,gBAAgB;AACb,M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UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO,OAAO,QAAQ,KAAK,EACxB,IAAI,CAAC,CAAC,SAAS,WAAW;AACzB,cAAU,cAAc,OAAO;AAC/B,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,IAAI,YAAY;AAAA,IACzB;AACA,QAAI,OAAO,UAAU,YAAY,kBAAkB,KAAK,OAAO,GAAG;AAChE,cAAQ,GAAG;AAAA,IACb;AACA,WAAO,IAAI,YAAY;AAAA,EACzB,CAAC,EACA,KAAK,OAAO;AACjB;AAhBgB;",
6
6
  "names": []
7
7
  }
@@ -1,16 +1,9 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import * as ReactNative from "react-native";
4
3
  import { Image, Text, TextInput } from "react-native";
5
4
  import { createComponent } from "./createComponent";
6
5
  import { extendStaticConfig } from "./helpers/extendStaticConfig";
7
- const RNComponents = /* @__PURE__ */ new WeakMap();
8
- for (const key of ["Image", "TextInput", "Text", "View"]) {
9
- const val = ReactNative[key];
10
- if (val && typeof val === "object") {
11
- RNComponents.set(val, true);
12
- }
13
- }
6
+ import { RNComponents } from "./helpers/RNComponents";
14
7
  function styled(Component, options, staticExtractionOptions) {
15
8
  const staticConfigProps = (() => {
16
9
  if (options) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/styled.tsx"],
4
- "sourcesContent": ["import * as ReactNative from 'react-native'\nimport { Image, Text, TextInput } from 'react-native'\n\nimport { createComponent } from './createComponent'\nimport { extendStaticConfig } from './helpers/extendStaticConfig'\nimport {\n GetProps,\n GetVariantProps,\n MediaPropKeys,\n MediaProps,\n PseudoProps,\n PsuedoPropKeys,\n StaticComponent,\n StaticConfig,\n StylableComponent,\n VariantDefinitions,\n} from './types'\n\n// bye bye tree shaking... but only way to properly detect react-native components...\n// also neither rnw nor react support tree shaking atm\nconst RNComponents = new WeakMap()\n// I was looping over all of them, but casuses deprecation warnings and there's only a few\n// we realistically support - lets whitelist rather than blacklist\nfor (const key of ['Image', 'TextInput', 'Text', 'View']) {\n const val = ReactNative[key]\n if (val && typeof val === 'object') {\n RNComponents.set(val, true)\n }\n}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n // = VariantDefinitions<GetProps<ParentComponent>> gives type inference to variants: { true: { ... } }\n // but causes \"Type instantiation is excessively deep and possibly infinite.\"...\n Variants extends VariantDefinitions<any> | symbol =\n | VariantDefinitions<GetProps<ParentComponent>>\n | symbol\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 defaultVariants?: Variants extends Object ? GetVariantProps<Variants> : never\n },\n staticExtractionOptions?: StaticConfig\n) {\n const staticConfigProps = (() => {\n if (options) {\n const { variants, name, defaultVariants, ...defaultProps } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n const isReactNativeWeb = RNComponents.has(Component)\n const isTamagui = !isReactNativeWeb && 'staticConfig' in Component\n const Comp = Component as any\n const isImage = !!(defaultProps.isImage || (!isTamagui ? Comp === Image : false))\n const isInput = !!(defaultProps.isInput || (!isTamagui ? Comp === TextInput : false))\n const isText = !!(defaultProps.isText || (!isTamagui ? isInput || Comp === Text : false))\n const conf: StaticConfig = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\n }),\n isTamagui,\n // this type gets messed up by options?: Partial<GetProps<ParentComponent>> above\n // take away the Partial<> and it's fine\n variants,\n defaultProps,\n componentName: name,\n isReactNativeWeb,\n isInput,\n isText,\n isImage,\n }\n return conf\n }\n return {}\n })()\n const config = extendStaticConfig(Component, staticConfigProps)\n const component = createComponent(config!) // error is good here its on init\n\n type ParentProps = GetProps<ParentComponent>\n type VariantProps = Variants extends symbol ? {} : Expand<GetVariantProps<Variants>>\n type VariantKeys = Variants extends symbol ? never : keyof Variants[keyof Variants]\n type ParentPropsWithoutOurVariants = VariantKeys extends never\n ? ParentProps\n : Omit<ParentProps, VariantKeys>\n type StyleProps = VariantProps & ParentPropsWithoutOurVariants\n type Props = Variants extends undefined | symbol\n ? ParentProps\n : Omit<\n ParentProps extends Object ? ParentProps : {},\n (VariantKeys extends never ? ImpossibleKey : VariantKeys) | MediaPropKeys | PsuedoPropKeys\n > &\n VariantProps &\n MediaProps<StyleProps> &\n PseudoProps<StyleProps>\n\n return component as StaticComponent<Props, VariantProps>\n}\n\ntype ImpossibleKey = 1234556123312321\ntype Expand<T> = T extends infer O ? { [K in keyof O]?: O[K] } : never\n"],
5
- "mappings": ";;AAAA;AACA;AAEA;AACA;AAgBA,MAAM,eAAe,oBAAI,QAAQ;AAGjC,WAAW,OAAO,CAAC,SAAS,aAAa,QAAQ,MAAM,GAAG;AACxD,QAAM,MAAM,YAAY;AACxB,MAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,iBAAa,IAAI,KAAK,IAAI;AAAA,EAC5B;AACF;AAEO,gBAQL,WAEA,SAKA,yBACA;AACA,QAAM,oBAAqB,OAAM;AAC/B,QAAI,SAAS;AACX,YAAM,EAAE,UAAU,MAAM,oBAAoB,iBAAiB;AAC7D,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AACA,YAAM,mBAAmB,aAAa,IAAI,SAAS;AACnD,YAAM,YAAY,CAAC,oBAAoB,kBAAkB;AACzD,YAAM,OAAO;AACb,YAAM,UAAU,CAAC,CAAE,cAAa,WAAY,EAAC,YAAY,SAAS,QAAQ;AAC1E,YAAM,UAAU,CAAC,CAAE,cAAa,WAAY,EAAC,YAAY,SAAS,YAAY;AAC9E,YAAM,SAAS,CAAC,CAAE,cAAa,UAAW,EAAC,YAAY,WAAW,SAAS,OAAO;AAClF,YAAM,OAAqB;AAAA,WACtB;AAAA,WACC,CAAC,aAAa;AAAA,UAChB,WAAW;AAAA,QACb;AAAA,QACA;AAAA,QAGA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,GAAG;AACH,QAAM,SAAS,mBAAmB,WAAW,iBAAiB;AAC9D,QAAM,YAAY,gBAAgB,MAAO;AAmBzC,SAAO;AACT;AAtEgB;",
4
+ "sourcesContent": ["import { Image, Text, TextInput } from 'react-native'\n\nimport { createComponent } from './createComponent'\nimport { extendStaticConfig } from './helpers/extendStaticConfig'\nimport { RNComponents } from './helpers/RNComponents'\nimport {\n GetProps,\n GetVariantProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n VariantDefinitions,\n} from './types'\n\nexport function styled<\n ParentComponent extends StylableComponent,\n // = VariantDefinitions<GetProps<ParentComponent>> gives type inference to variants: { true: { ... } }\n // but causes \"Type instantiation is excessively deep and possibly infinite.\"...\n Variants extends VariantDefinitions<{}> = {}\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 defaultVariants?: Variants extends Object ? GetVariantProps<Variants> : never\n },\n staticExtractionOptions?: StaticConfig\n) {\n const staticConfigProps = (() => {\n if (options) {\n const { variants, name, defaultVariants, ...defaultProps } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n const isReactNativeWeb = RNComponents.has(Component)\n const isTamagui = !isReactNativeWeb && 'staticConfig' in Component\n const Comp = Component as any\n const isImage = !!(defaultProps.isImage || (!isTamagui ? Comp === Image : false))\n const isInput = !!(defaultProps.isInput || (!isTamagui ? Comp === TextInput : false))\n const isText = !!(defaultProps.isText || (!isTamagui ? isInput || Comp === Text : false))\n const conf: StaticConfig = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\n }),\n isTamagui,\n // this type gets messed up by options?: Partial<GetProps<ParentComponent>> above\n // take away the Partial<> and it's fine\n variants,\n defaultProps,\n componentName: name,\n isReactNativeWeb,\n isInput,\n isText,\n isImage,\n }\n return conf\n }\n return {}\n })()\n const config = extendStaticConfig(Component, staticConfigProps)\n const component = createComponent(config!) // error is good here its on init\n\n // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = ParentComponent extends TamaguiComponent<any, any, infer P>\n ? P\n : GetProps<ParentComponent>\n type ParentVariants = ParentComponent extends TamaguiComponent<any, any, any, infer V>\n ? V\n : Object\n\n // sprinkle in our variants\n type OurVariants = Variants extends Object\n ? {\n [Key in keyof Variants]?: GetVariantValues<keyof Variants[Key]>\n }\n : {}\n\n type VariantProps = ParentVariants & OurVariants\n type OurPropsBase = ParentPropsBase & VariantProps\n\n type Props = Variants extends void | symbol\n ? GetProps<ParentComponent>\n : // start with base props\n OurPropsBase &\n // add in media (+ pseudos nested)\n MediaProps<OurPropsBase> &\n // add in pseudos\n PseudoProps<OurPropsBase>\n\n return component as TamaguiComponent<\n Props,\n // TODO infer ref\n any,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n}\n\n// type Merge<A, B> = Omit<A, keyof B> & B\n// import { Stack } from './views/Stack'\n// export const SizableText = styled(Stack, {\n// name: 'SizableText',\n// backgroundColor: 'red',\n// variants: {\n// size: {\n// '...fontSize': (val, { props }) => {\n// return {\n// backgroundColor: '',\n// }\n// },\n// },\n// },\n// })\n// export const Paragraph = styled(SizableText, {\n// name: 'Paragraph',\n// tag: 'p',\n// // variants: {\n// // another: {\n// // true: {}\n// // }\n// // }\n// })\n// export const Paragraph2 = styled(Paragraph, {\n// name: 'Paragraph',\n// tag: 'p',\n// variants: {\n// another: {\n// true: {\n// color: 'red'\n// },\n// }\n// }\n// })\n// const a = <SizableText size=\"$10\" />\n// const y = <Paragraph2 size=\"$10\" another />\n// export const SizableText2 = styled(SizableText, {\n// })\n// const xx = <SizableText2 abc />\n// export const Paragraph = styled(SizableText, {\n// name: 'Paragraph',\n// })\n// export const Heading = styled(Paragraph, {\n// tag: 'span',\n// margin: 0,\n// })\n// export const H2 = styled(Heading, {\n// name: 'H2',\n// })\n// const x = <H2 color=\"red\" />\n"],
5
+ "mappings": ";;AAAA;AAEA;AACA;AACA;AAaO,gBAML,WAEA,SAKA,yBACA;AACA,QAAM,oBAAqB,OAAM;AAC/B,QAAI,SAAS;AACX,YAAM,EAAE,UAAU,MAAM,oBAAoB,iBAAiB;AAC7D,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AACA,YAAM,mBAAmB,aAAa,IAAI,SAAS;AACnD,YAAM,YAAY,CAAC,oBAAoB,kBAAkB;AACzD,YAAM,OAAO;AACb,YAAM,UAAU,CAAC,CAAE,cAAa,WAAY,EAAC,YAAY,SAAS,QAAQ;AAC1E,YAAM,UAAU,CAAC,CAAE,cAAa,WAAY,EAAC,YAAY,SAAS,YAAY;AAC9E,YAAM,SAAS,CAAC,CAAE,cAAa,UAAW,EAAC,YAAY,WAAW,SAAS,OAAO;AAClF,YAAM,OAAqB;AAAA,WACtB;AAAA,WACC,CAAC,aAAa;AAAA,UAChB,WAAW;AAAA,QACb;AAAA,QACA;AAAA,QAGA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,GAAG;AACH,QAAM,SAAS,mBAAmB,WAAW,iBAAiB;AAC9D,QAAM,YAAY,gBAAgB,MAAO;AA6BzC,SAAO;AAOT;AApFgB;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,8 @@
1
+ .tamagui-absolute-fill {
2
+ position: absolute;
3
+ top: 0;
4
+ left: 0;
5
+ right: 0;
6
+ bottom: 0;
7
+ }
8
+ /*# sourceMappingURL=tamagui-base.css.map */
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/tamagui-base.css"],
4
+ "sourcesContent": [".tamagui-absolute-fill {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n}\n"],
5
+ "mappings": "AAAA;AACE;AACA;AACA;AACA;AACA;AAAA;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/Stack.tsx"],
4
- "sourcesContent": ["import { View } from 'react-native'\n\nimport { stackDefaultStyles } from '../constants/constants'\nimport { createComponent } from '../createComponent'\nimport { StackProps } from '../types'\n\nexport const Stack = createComponent<StackProps, View>({\n defaultProps: {\n ...stackDefaultStyles,\n flexDirection: 'column',\n },\n})\n\n// test types\n// export const YStack = styled(Stack, {\n// flexDirection: 'column',\n// })\n// // test types\n// const x00 = <Stack missing={0} /> // should err\n// const x0 = <YStack missing={0} /> // should err\n// const x1 = (props: StackProps) => <YStack {...props} />\n// type ys = typeof YStack\n// type ysv = ys extends StaticComponent<any, infer V> ? V : unknown\n"],
5
- "mappings": "AAEA;AACA;AAGO,MAAM,QAAQ,gBAAkC;AAAA,EACrD,cAAc;AAAA,OACT;AAAA,IACH,eAAe;AAAA,EACjB;AACF,CAAC;",
4
+ "sourcesContent": ["import { View } from 'react-native'\n\nimport { stackDefaultStyles } from '../constants/constants'\nimport { createComponent } from '../createComponent'\nimport { StackProps, StackPropsBase } from '../types'\n\nexport const Stack = createComponent<StackProps, View, StackPropsBase>({\n defaultProps: {\n ...stackDefaultStyles,\n flexDirection: 'column',\n },\n})\n\n// test types\n// export const YStack = styled(Stack, {\n// flexDirection: 'column',\n// })\n// // test types\n// const x00 = <Stack missing={0} /> // should err\n// const x0 = <YStack missing={0} /> // should err\n// const x1 = (props: StackProps) => <YStack {...props} />\n// type ys = typeof YStack\n// type ysv = ys extends StaticComponent<any, infer V> ? V : unknown\n"],
5
+ "mappings": "AAEA;AACA;AAGO,MAAM,QAAQ,gBAAkD;AAAA,EACrE,cAAc;AAAA,OACT;AAAA,IACH,eAAe;AAAA,EACjB;AACF,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/Text.tsx"],
4
- "sourcesContent": ["import { stylePropsTextOnly, validStyles } from '@tamagui/helpers'\nimport { Text as TextView } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { createComponent } from '../createComponent'\nimport { TextProps } from '../types'\n\nconst ellipseStyle = {\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}\n\nexport const Text = createComponent<TextProps, TextView>({\n isText: true,\n defaultProps: {\n display: isWeb ? 'inline' : 'flex',\n boxSizing: 'border-box',\n fontFamily: 'System',\n wordWrap: 'break-word',\n },\n variants: {\n numberOfLines: {\n 1: ellipseStyle,\n // TODO imply fn, test 1, could do types `>1` `<2`\n ':number': (lines) => (lines > 1 ? { WebkitLineClamp: 1 } : null),\n },\n\n selectable: {\n true: {\n userSelect: 'text',\n cursor: 'text',\n },\n false: {\n userSelect: 'none',\n },\n },\n\n pressable: {\n true: {\n cursor: 'pointer',\n },\n },\n\n ellipse: {\n true: isWeb\n ? ellipseStyle\n : {\n numberOfLines: 1,\n lineBreakMode: 'clip',\n },\n },\n },\n deoptProps: new Set(isWeb ? [] : ['ellipse']),\n validStyles: {\n ...validStyles,\n ...stylePropsTextOnly,\n ...(isWeb && {\n userSelect: true,\n textOverflow: true,\n whiteSpace: true,\n wordWrap: true,\n selectable: true,\n cursor: true,\n }),\n },\n})\n"],
5
- "mappings": "AAAA;AAGA;AACA;AAGA,MAAM,eAAe;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AACd;AAEO,MAAM,OAAO,gBAAqC;AAAA,EACvD,QAAQ;AAAA,EACR,cAAc;AAAA,IACZ,SAAS,QAAQ,WAAW;AAAA,IAC5B,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAAA,EACA,UAAU;AAAA,IACR,eAAe;AAAA,MACb,GAAG;AAAA,MAEH,WAAW,CAAC,UAAW,QAAQ,IAAI,EAAE,iBAAiB,EAAE,IAAI;AAAA,IAC9D;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,QACJ,YAAY;AAAA,QACZ,QAAQ;AAAA,MACV;AAAA,MACA,OAAO;AAAA,QACL,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IAEA,WAAW;AAAA,MACT,MAAM;AAAA,QACJ,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,IAEA,SAAS;AAAA,MACP,MAAM,QACF,eACA;AAAA,QACE,eAAe;AAAA,QACf,eAAe;AAAA,MACjB;AAAA,IACN;AAAA,EACF;AAAA,EACA,YAAY,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;AAAA,EAC5C,aAAa;AAAA,OACR;AAAA,OACA;AAAA,OACC,SAAS;AAAA,MACX,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,QAAQ;AAAA,IACV;AAAA,EACF;AACF,CAAC;",
4
+ "sourcesContent": ["import { stylePropsTextOnly, validStyles } from '@tamagui/helpers'\nimport { Text as TextView } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { createComponent } from '../createComponent'\nimport { TextProps, TextPropsBase } from '../types'\n\nconst ellipseStyle = {\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}\n\nexport const Text = createComponent<TextProps, TextView, TextPropsBase>({\n isText: true,\n defaultProps: {\n display: isWeb ? 'inline' : 'flex',\n boxSizing: 'border-box',\n fontFamily: 'System',\n wordWrap: 'break-word',\n },\n variants: {\n numberOfLines: {\n 1: ellipseStyle,\n // TODO imply fn, test 1, could do types `>1` `<2`\n ':number': (lines) => (lines > 1 ? { WebkitLineClamp: 1 } : null),\n },\n\n selectable: {\n true: {\n userSelect: 'text',\n cursor: 'text',\n },\n false: {\n userSelect: 'none',\n },\n },\n\n pressable: {\n true: {\n cursor: 'pointer',\n },\n },\n\n ellipse: {\n true: isWeb\n ? ellipseStyle\n : {\n numberOfLines: 1,\n lineBreakMode: 'clip',\n },\n },\n },\n deoptProps: new Set(isWeb ? [] : ['ellipse']),\n validStyles: {\n ...validStyles,\n ...stylePropsTextOnly,\n ...(isWeb && {\n userSelect: true,\n textOverflow: true,\n whiteSpace: true,\n wordWrap: true,\n selectable: true,\n cursor: true,\n }),\n },\n})\n"],
5
+ "mappings": "AAAA;AAGA;AACA;AAGA,MAAM,eAAe;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AACd;AAEO,MAAM,OAAO,gBAAoD;AAAA,EACtE,QAAQ;AAAA,EACR,cAAc;AAAA,IACZ,SAAS,QAAQ,WAAW;AAAA,IAC5B,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAAA,EACA,UAAU;AAAA,IACR,eAAe;AAAA,MACb,GAAG;AAAA,MAEH,WAAW,CAAC,UAAW,QAAQ,IAAI,EAAE,iBAAiB,EAAE,IAAI;AAAA,IAC9D;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,QACJ,YAAY;AAAA,QACZ,QAAQ;AAAA,MACV;AAAA,MACA,OAAO;AAAA,QACL,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IAEA,WAAW;AAAA,MACT,MAAM;AAAA,QACJ,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,IAEA,SAAS;AAAA,MACP,MAAM,QACF,eACA;AAAA,QACE,eAAe;AAAA,QACf,eAAe;AAAA,MACjB;AAAA,IACN;AAAA,EACF;AAAA,EACA,YAAY,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;AAAA,EAC5C,aAAa;AAAA,OACR;AAAA,OACA;AAAA,OACC,SAAS;AAAA,MACX,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,QAAQ;AAAA,IACV;AAAA,EACF;AACF,CAAC;",
6
6
  "names": []
7
7
  }
@@ -8,28 +8,19 @@ React["createElement"];
8
8
  const Theme = memo(/* @__PURE__ */ __name(function Theme2(props) {
9
9
  var _a, _b;
10
10
  const { name, theme, themeManager, themes, className } = useChangeThemeEffect(props.name, void 0, props);
11
- const contents = useMemo(() => {
12
- if (!name || !theme) {
13
- return props.children;
14
- }
15
- return wrapThemeManagerContext(props.children, themeManager);
16
- }, [props.children, themeManager]);
17
- if (!themes) {
18
- console.warn("Error, no themes in context", props);
19
- return props.children;
20
- }
21
- if (!name || !theme) {
22
- if (process.env.NODE_ENV === "development" && name && !theme) {
11
+ if (!themes || !name || !theme) {
12
+ if (name && !theme && process.env.NODE_ENV === "development") {
23
13
  console.warn(`No theme found by name ${name}`);
24
14
  }
25
15
  return props.children;
26
16
  }
17
+ const contents = useMemo(() => wrapThemeManagerContext(props.children, themeManager), [props.children, themeManager]);
27
18
  if (isWeb) {
28
- if (props.disableThemeClass) {
29
- return contents;
30
- }
31
19
  return /* @__PURE__ */ React.createElement("div", {
32
- className: props.className ? `${className || ""} ${props.className || ""}` : className || "",
20
+ className: [
21
+ `tui_Theme`,
22
+ ...!props.disableThemeClass ? [props.className, className].filter(Boolean) : []
23
+ ].join(" "),
33
24
  style: {
34
25
  display: "contents",
35
26
  color: (_b = (_a = themes[name]) == null ? void 0 : _a.color) == null ? void 0 : _b.toString()
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/Theme.tsx"],
4
- "sourcesContent": ["import React, { memo, useMemo } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { wrapThemeManagerContext } from '../helpers/wrapThemeManagerContext'\nimport { useChangeThemeEffect } from '../static'\nimport { ThemeName } from '../types'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport type ThemeProps = {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n children?: any\n debug?: boolean\n}\n\nexport const Theme = memo(function Theme(props: ThemeProps) {\n const { name, theme, themeManager, themes, className } = useChangeThemeEffect(\n props.name,\n undefined,\n props\n )\n\n // memo here, changing theme without re-rendering all children is a critical optimization\n // may require some effort of end user to memoize but without this memo they'd have no option\n const contents = useMemo(() => {\n if (!name || !theme) {\n return props.children\n }\n return wrapThemeManagerContext(props.children, themeManager)\n }, [props.children, themeManager])\n\n if (!themes) {\n console.warn('Error, no themes in context', props)\n return props.children\n }\n\n if (!name || !theme) {\n if (process.env.NODE_ENV === 'development' && name && !theme) {\n console.warn(`No theme found by name ${name}`)\n }\n return props.children\n }\n\n if (isWeb) {\n if (props.disableThemeClass) {\n return contents\n }\n return (\n <div\n className={\n props.className ? `${className || ''} ${props.className || ''}` : className || ''\n }\n style={{\n display: 'contents',\n // in order to provide currentColor, set color by default\n color: themes[name]?.color?.toString(),\n }}\n >\n {contents}\n </div>\n )\n }\n\n return contents\n})\n"],
5
- "mappings": ";;AAAA;AAEA;AACA;AACA;AAIA,MAAM;AAUC,MAAM,QAAQ,KAAK,uCAAe,OAAmB;AAlB5D;AAmBE,QAAM,EAAE,MAAM,OAAO,cAAc,QAAQ,cAAc,qBACvD,MAAM,MACN,QACA,KACF;AAIA,QAAM,WAAW,QAAQ,MAAM;AAC7B,QAAI,CAAC,QAAQ,CAAC,OAAO;AACnB,aAAO,MAAM;AAAA,IACf;AACA,WAAO,wBAAwB,MAAM,UAAU,YAAY;AAAA,EAC7D,GAAG,CAAC,MAAM,UAAU,YAAY,CAAC;AAEjC,MAAI,CAAC,QAAQ;AACX,YAAQ,KAAK,+BAA+B,KAAK;AACjD,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,CAAC,QAAQ,CAAC,OAAO;AACnB,QAAI,QAAQ,IAAI,aAAa,iBAAiB,QAAQ,CAAC,OAAO;AAC5D,cAAQ,KAAK,0BAA0B,MAAM;AAAA,IAC/C;AACA,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,OAAO;AACT,QAAI,MAAM,mBAAmB;AAC3B,aAAO;AAAA,IACT;AACA,WACE,oCAAC;AAAA,MACC,WACE,MAAM,YAAY,GAAG,aAAa,MAAM,MAAM,aAAa,OAAO,aAAa;AAAA,MAEjF,OAAO;AAAA,QACL,SAAS;AAAA,QAET,OAAO,mBAAO,UAAP,mBAAc,UAAd,mBAAqB;AAAA,MAC9B;AAAA,OAEC,QACH;AAAA,EAEJ;AAEA,SAAO;AACT,GAjD0B,QAiDzB;",
4
+ "sourcesContent": ["import React, { memo, useMemo } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { wrapThemeManagerContext } from '../helpers/wrapThemeManagerContext'\nimport { useChangeThemeEffect } from '../static'\nimport { ThemeName } from '../types'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport type ThemeProps = {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n children?: any\n debug?: boolean\n}\n\nexport const Theme = memo(function Theme(props: ThemeProps) {\n const { name, theme, themeManager, themes, className } = useChangeThemeEffect(\n props.name,\n undefined,\n props\n )\n\n if (!themes || !name || !theme) {\n if (name && !theme && process.env.NODE_ENV === 'development') {\n console.warn(`No theme found by name ${name}`)\n }\n return props.children\n }\n\n // memo here, changing theme without re-rendering all children is a critical optimization\n // may require some effort of end user to memoize but without this memo they'd have no option\n const contents = useMemo(\n () => wrapThemeManagerContext(props.children, themeManager),\n [props.children, themeManager]\n )\n\n if (isWeb) {\n return (\n <div\n className={[\n `tui_Theme`,\n ...(!props.disableThemeClass ? [props.className, className].filter(Boolean) : []),\n ].join(' ')}\n style={{\n display: 'contents',\n // in order to provide currentColor, set color by default\n color: themes[name]?.color?.toString(),\n }}\n >\n {contents}\n </div>\n )\n }\n\n return contents\n})\n"],
5
+ "mappings": ";;AAAA;AAEA;AACA;AACA;AAIA,MAAM;AAUC,MAAM,QAAQ,KAAK,uCAAe,OAAmB;AAlB5D;AAmBE,QAAM,EAAE,MAAM,OAAO,cAAc,QAAQ,cAAc,qBACvD,MAAM,MACN,QACA,KACF;AAEA,MAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO;AAC9B,QAAI,QAAQ,CAAC,SAAS,QAAQ,IAAI,aAAa,eAAe;AAC5D,cAAQ,KAAK,0BAA0B,MAAM;AAAA,IAC/C;AACA,WAAO,MAAM;AAAA,EACf;AAIA,QAAM,WAAW,QACf,MAAM,wBAAwB,MAAM,UAAU,YAAY,GAC1D,CAAC,MAAM,UAAU,YAAY,CAC/B;AAEA,MAAI,OAAO;AACT,WACE,oCAAC;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,GAAI,CAAC,MAAM,oBAAoB,CAAC,MAAM,WAAW,SAAS,EAAE,OAAO,OAAO,IAAI,CAAC;AAAA,MACjF,EAAE,KAAK,GAAG;AAAA,MACV,OAAO;AAAA,QACL,SAAS;AAAA,QAET,OAAO,mBAAO,UAAP,mBAAc,UAAd,mBAAqB;AAAA,MAC9B;AAAA,OAEC,QACH;AAAA,EAEJ;AAEA,SAAO;AACT,GAxC0B,QAwCzB;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,17 @@
1
+ const pseudos = {
2
+ focusStyle: {
3
+ name: "focus",
4
+ priority: 3
5
+ },
6
+ pressStyle: {
7
+ name: "active",
8
+ priority: 2
9
+ },
10
+ hoverStyle: {
11
+ name: "hover",
12
+ priority: 1
13
+ }
14
+ };
15
+ export {
16
+ pseudos
17
+ };
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
  import { stylePropsView } from "@tamagui/helpers";
4
4
  import { useForceUpdate } from "@tamagui/use-force-update";
5
- import {
5
+ import React, {
6
6
  Children,
7
7
  Fragment,
8
8
  createElement,
@@ -20,16 +20,26 @@ import { stackDefaultStyles } from "./constants/constants";
20
20
  import { isAndroid, isTouchDevice, isWeb } from "./constants/platform";
21
21
  import { rnw } from "./constants/rnw";
22
22
  import { isVariable } from "./createVariable";
23
- import { defaultComponentState } from "./defaultComponentState";
23
+ import { createShallowUpdate } from "./helpers/createShallowUpdate";
24
24
  import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
25
25
  import {
26
26
  getSplitStyles
27
27
  } from "./helpers/getSplitStyles";
28
+ import { getAllSelectors } from "./helpers/insertStyleRule";
28
29
  import { wrapThemeManagerContext } from "./helpers/wrapThemeManagerContext";
29
30
  import { useFeatures } from "./hooks/useFeatures";
30
31
  import { usePressable } from "./hooks/usePressable";
31
32
  import { getThemeManagerIfChanged, useTheme } from "./hooks/useTheme";
32
33
  import { TextAncestorContext } from "./views/TextAncestorContext";
34
+ React["keep"];
35
+ const defaultComponentState = {
36
+ hover: false,
37
+ press: false,
38
+ pressIn: false,
39
+ focus: false,
40
+ mounted: false,
41
+ animation: null
42
+ };
33
43
  const mouseUps = /* @__PURE__ */ new Set();
34
44
  if (typeof document !== "undefined") {
35
45
  document.addEventListener("mouseup", () => {
@@ -37,19 +47,6 @@ if (typeof document !== "undefined") {
37
47
  mouseUps.clear();
38
48
  });
39
49
  }
40
- function createShallowUpdate(setter) {
41
- return (next) => {
42
- setter((prev) => {
43
- for (const key in next) {
44
- if (prev[key] !== next[key]) {
45
- return { ...prev, ...next };
46
- }
47
- }
48
- return prev;
49
- });
50
- };
51
- }
52
- __name(createShallowUpdate, "createShallowUpdate");
53
50
  function createComponent(configIn) {
54
51
  let staticConfig;
55
52
  if ("parsed" in configIn) {
@@ -63,13 +60,13 @@ function createComponent(configIn) {
63
60
  let tamaguiConfig;
64
61
  let AnimatedText;
65
62
  let AnimatedView;
66
- let avoidClasses = false;
63
+ let avoidClasses = true;
67
64
  let defaultPseudos = {};
68
65
  let defaultNativeStyle;
69
66
  let defaultNativeStyleSheet = null;
70
67
  let defaultsClassName = null;
71
68
  let initialTheme;
72
- let splitStyleResult = null;
69
+ let defaultSplitStyleResult = null;
73
70
  function addPseudoToStyles(styles, name, pseudos) {
74
71
  const pseudoStyle = pseudos[name];
75
72
  if (pseudoStyle) {
@@ -94,12 +91,13 @@ function createComponent(configIn) {
94
91
  const theme = useTheme(props.theme, componentName, props, forceUpdate);
95
92
  const [state, set_] = useState(defaultComponentState);
96
93
  const setStateShallow = createShallowUpdate(set_);
97
- const shouldAvoidClasses = !!(state.animation && avoidClasses);
98
- const splitInfo = getSplitStyles(props, staticConfig, theme, shouldAvoidClasses ? { ...state, noClassNames: true, resolveVariablesAs: "value" } : state, defaultsClassName);
99
- const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitInfo;
94
+ const shouldAvoidClasses = !!(props.animation && avoidClasses);
95
+ const splitStyles = getSplitStyles(props, staticConfig, theme, shouldAvoidClasses ? { ...state, noClassNames: true, resolveVariablesAs: "value" } : state, shouldAvoidClasses ? null : defaultsClassName);
96
+ const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitStyles;
100
97
  const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
101
98
  const isAnimated = !!(useAnimations && props.animation);
102
- const styleWithPseudos = props.animation ? merge({ ...defaultNativeStyle, ...style }, state.hover && pseudos.hoverStyle, state.press && pseudos.pressStyle, state.focus && pseudos.focusStyle, ...Object.values(medias)) : null;
99
+ const hasEnterStyle = !!props.enterStyle;
100
+ const styleWithPseudos = props.animation ? merge({ ...defaultNativeStyle, ...style }, state.hover && pseudos.hoverStyle, state.press && pseudos.pressStyle, state.focus && pseudos.focusStyle, hasEnterStyle && !state.mounted && pseudos.enterStyle, ...Object.values(medias)) : null;
103
101
  const features = useFeatures(props, {
104
102
  forceUpdate,
105
103
  setStateShallow,
@@ -160,7 +158,6 @@ function createComponent(configIn) {
160
158
  }
161
159
  const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false;
162
160
  const hostRef = useRef(null);
163
- const hasEnterStyle = !!props.enterStyle;
164
161
  const internal = useRef();
165
162
  if (!internal.current) {
166
163
  internal.current = {
@@ -254,10 +251,11 @@ function createComponent(configIn) {
254
251
  const className = classList.join(" ");
255
252
  if (process.env.NODE_ENV === "development") {
256
253
  if (props["debug"]) {
257
- console.log(" \xBB className", { isStringElement, pseudos, state, defaultsClassName, classNames, propsClassName: props.className, style, classList, className: className.trim().split(" "), themeClassName: theme.className });
254
+ console.log(" \xBB className", { isStringElement, pseudos, state, defaultsClassName, classNames, propsClassName: props.className, style, classList, className: className.trim().split(" "), themeClassName: theme.className, values: Object.fromEntries(Object.entries(classNames).map(([k, v]) => [v, getAllSelectors()[v]])) });
258
255
  }
259
256
  }
260
257
  viewProps.className = className;
258
+ viewProps.style = animationStyles;
261
259
  } else {
262
260
  viewProps.style = styles;
263
261
  }
@@ -377,18 +375,6 @@ function createComponent(configIn) {
377
375
  } : {
378
376
  disabled: true
379
377
  });
380
- if (events) {
381
- if (!isStringElement) {
382
- Object.assign(viewProps, pressProps);
383
- } else {
384
- Object.assign(viewProps, events);
385
- }
386
- if (isWeb && isHoverable) {
387
- childEls = <span style={{
388
- display: "contents"
389
- }} onMouseEnter={events.onMouseEnter} onMouseLeave={events.onMouseLeave}>{children}</span>;
390
- }
391
- }
392
378
  let content;
393
379
  if (isWeb) {
394
380
  if (staticConfig.isReactNativeWeb) {
@@ -405,11 +391,23 @@ function createComponent(configIn) {
405
391
  }
406
392
  }
407
393
  }
394
+ if (events) {
395
+ if (!isStringElement) {
396
+ Object.assign(viewProps, pressProps);
397
+ } else {
398
+ Object.assign(viewProps, events);
399
+ }
400
+ }
408
401
  content = createElement(ViewComponent, viewProps, childEls);
402
+ if (isWeb && events && attachHover) {
403
+ content = <span className="tui_Hoverable" style={{
404
+ display: "contents"
405
+ }} onMouseEnter={events.onMouseEnter} onMouseLeave={events.onMouseLeave}>{content}</span>;
406
+ }
409
407
  if (process.env.NODE_ENV === "development") {
410
408
  if (props["debug"]) {
411
409
  viewProps["debug"] = true;
412
- console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, animationStyles, isStringElement, classNamesIn: (_c = props.className) == null ? void 0 : _c.split(" "), classNamesOut: (_d = viewProps.className) == null ? void 0 : _d.split(" "), pressProps, events, shouldAttach, ViewComponent, viewProps, state, styles, pseudos, content, childEls, shouldAvoidClasses, animation: props.animation, style, defaultNativeStyle, splitStyleResult, ...typeof window !== "undefined" ? { theme, themeState: theme.__state, themeClassName: theme.className, staticConfig, tamaguiConfig } : null });
410
+ console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, styleWithPseudos, splitStyles, defaultsClassName, animationStyles, isStringElement, classNamesIn: (_c = props.className) == null ? void 0 : _c.split(" "), classNamesOut: (_d = viewProps.className) == null ? void 0 : _d.split(" "), pressProps, events, shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses, animation: props.animation, style, defaultNativeStyle, defaultSplitStyleResult, ...typeof window !== "undefined" ? { theme, themeState: theme.__state, themeClassName: theme.className, staticConfig, tamaguiConfig } : null });
413
411
  }
414
412
  }
415
413
  if (features.length) {
@@ -428,11 +426,11 @@ function createComponent(configIn) {
428
426
  AnimatedText = (_c = tamaguiConfig.animations) == null ? void 0 : _c.Text;
429
427
  AnimatedView = (_d = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _d.View;
430
428
  initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]];
431
- splitStyleResult = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, {
429
+ defaultSplitStyleResult = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, {
432
430
  mounted: true,
433
- resolveVariablesAs: "variable"
431
+ resolveVariablesAs: "both"
434
432
  });
435
- const { classNames, pseudos, style, viewProps } = splitStyleResult;
433
+ const { classNames, pseudos, style, viewProps } = defaultSplitStyleResult;
436
434
  if (isWeb) {
437
435
  defaultsClassName = classNames;
438
436
  }
@@ -451,7 +449,7 @@ function createComponent(configIn) {
451
449
  ...component.defaultProps
452
450
  };
453
451
  if (process.env.NODE_ENV === "development" && shouldDebug && process.env.IS_STATIC !== "is_static") {
454
- console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, { staticConfig, ...splitStyleResult });
452
+ console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, { staticConfig, ...defaultSplitStyleResult });
455
453
  }
456
454
  });
457
455
  let res = component;
@@ -593,6 +591,7 @@ export {
593
591
  AbsoluteFill,
594
592
  Spacer,
595
593
  createComponent,
594
+ defaultComponentState,
596
595
  mouseUps,
597
596
  spacedChildren
598
597
  };
File without changes