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

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 (73) hide show
  1. package/dist/cjs/Tamagui.js +5 -0
  2. package/dist/cjs/Tamagui.js.map +2 -2
  3. package/dist/cjs/createComponent.js +23 -45
  4. package/dist/cjs/createComponent.js.map +2 -2
  5. package/dist/cjs/helpers/createPropMapper.js +25 -26
  6. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  7. package/dist/cjs/helpers/getSplitStyles.js +20 -9
  8. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  9. package/dist/cjs/helpers/getStylesAtomic.js +1 -0
  10. package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
  11. package/dist/cjs/helpers/insertStyleRule.js +5 -1
  12. package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
  13. package/dist/cjs/hooks/useFeatures.js +88 -7
  14. package/dist/cjs/hooks/useFeatures.js.map +2 -2
  15. package/dist/cjs/hooks/useTheme.js +13 -14
  16. package/dist/cjs/hooks/useTheme.js.map +2 -2
  17. package/dist/cjs/styled.js.map +2 -2
  18. package/dist/cjs/types.js.map +1 -1
  19. package/dist/cjs/views/Stack.js +1 -0
  20. package/dist/cjs/views/Stack.js.map +2 -2
  21. package/dist/cjs/views/Text.js +1 -0
  22. package/dist/cjs/views/Text.js.map +2 -2
  23. package/dist/esm/Tamagui.js +2 -0
  24. package/dist/esm/Tamagui.js.map +2 -2
  25. package/dist/esm/createComponent.js +25 -50
  26. package/dist/esm/createComponent.js.map +2 -2
  27. package/dist/esm/helpers/createPropMapper.js +25 -26
  28. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  29. package/dist/esm/helpers/getSplitStyles.js +20 -9
  30. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  31. package/dist/esm/helpers/getStylesAtomic.js +1 -0
  32. package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
  33. package/dist/esm/helpers/insertStyleRule.js +5 -1
  34. package/dist/esm/helpers/insertStyleRule.js.map +2 -2
  35. package/dist/esm/hooks/useFeatures.js +88 -13
  36. package/dist/esm/hooks/useFeatures.js.map +2 -2
  37. package/dist/esm/hooks/useTheme.js +13 -14
  38. package/dist/esm/hooks/useTheme.js.map +2 -2
  39. package/dist/esm/styled.js.map +2 -2
  40. package/dist/esm/views/Stack.js +1 -0
  41. package/dist/esm/views/Stack.js.map +2 -2
  42. package/dist/esm/views/Text.js +1 -0
  43. package/dist/esm/views/Text.js.map +2 -2
  44. package/dist/jsx/Tamagui.js +2 -0
  45. package/dist/jsx/createComponent.js +25 -50
  46. package/dist/jsx/helpers/createPropMapper.js +25 -26
  47. package/dist/jsx/helpers/getSplitStyles.js +20 -9
  48. package/dist/jsx/helpers/getStylesAtomic.js +1 -0
  49. package/dist/jsx/helpers/insertStyleRule.js +5 -1
  50. package/dist/jsx/hooks/useFeatures.js +88 -13
  51. package/dist/jsx/hooks/useTheme.js +13 -14
  52. package/dist/jsx/views/Stack.js +1 -0
  53. package/dist/jsx/views/Text.js +1 -0
  54. package/package.json +6 -6
  55. package/types/Tamagui.d.ts +2 -0
  56. package/types/Tamagui.d.ts.map +1 -1
  57. package/types/createComponent.d.ts.map +1 -1
  58. package/types/createFont.d.ts +1 -1
  59. package/types/createFont.d.ts.map +1 -1
  60. package/types/helpers/createPropMapper.d.ts +1 -1
  61. package/types/helpers/createPropMapper.d.ts.map +1 -1
  62. package/types/helpers/getSplitStyles.d.ts +3 -13
  63. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  64. package/types/helpers/getStylesAtomic.d.ts.map +1 -1
  65. package/types/helpers/insertStyleRule.d.ts.map +1 -1
  66. package/types/hooks/useFeatures.d.ts +6 -3
  67. package/types/hooks/useFeatures.d.ts.map +1 -1
  68. package/types/styled.d.ts +2 -2
  69. package/types/styled.d.ts.map +1 -1
  70. package/types/types.d.ts +29 -15
  71. package/types/types.d.ts.map +1 -1
  72. package/types/views/Stack.d.ts.map +1 -1
  73. package/types/views/Text.d.ts.map +1 -1
@@ -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 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;AACA,MAAI,CAAC,wBAAwB;AAC3B,YAAQ,KAAK,sBAAsB;AACnC;AAAA,EACF;AACA,QAAM,SAAS,SAAS;AACxB,MAAI,CAAC;AAAQ;AACb,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,UAAM,QAAQ,OAAO,GAAG;AACxB,UAAM,YAAY,MAAM;AACxB,QAAI,CAAE,sBAAqB;AAAe;AAC1C,UAAM,gBAAgB,UAAU;AAChC,QAAI,CAAC;AAAe;AACpB,QAAI,kBAAkB,WAAW,cAAc,WAAW,IAAI,GAAG;AAC/D,eAAS,KAAI,GAAG,KAAI,MAAM,QAAQ,MAAK;AACrC,cAAM,OAAO,MAAM,KAAK,EAAC;AACzB,YAAI,CAAE,iBAAgB;AAAe;AACrC,cAAM,aAAa,KAAK,aAAa,MAAM,CAAC;AAC5C,qBAAa,cAAc,QAAQ,IAAI,aAAa,gBAAgB,KAAK,UAAU;AACnF,YAAI,WAAW,WAAW,YAAY,GAAG;AACvC,uBAAa,YAAY,KAAK,OAAO;AAAA,QACvC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,2BAAyB;AAC3B;AA7BgB;AA+BhB,eAAe;AAEf,MAAM,mBACJ,OAAO,aAAa,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\nconst isClient = typeof document !== 'undefined'\nexport function updateInserted() {\n if (!isClient) {\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 if (identifier === '_transform-1abwpjw') {\n console.trace('inserting', identifier, rule)\n }\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,oBA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AAA,IACF;AAAA,EACF;AACA,2BAAyB;AAC3B;AA7BgB;AA+BhB,eAAe;AAEf,MAAM,mBACJ,OAAO,aAAa,cAChB,SAAS,KAAK,YAAY,SAAS,cAAc,OAAO,CAAC,IACzD;AAEC,yBAAyB,YAAoB,MAAc;AAChE,MAAI,aAAa,aAAa;AAC5B;AAAA,EACF;AACA,2BAAyB;AACzB,MAAI,eAAe,sBAAsB;AACvC,YAAQ,MAAM,aAAa,YAAY,IAAI;AAAA,EAC7C;AACA,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;AAnBgB;",
6
6
  "names": []
7
7
  }
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
  import React from "react";
4
4
  import { isWeb, useIsomorphicLayoutEffect } from "../constants/platform";
5
+ import { getSubStyle } from "../helpers/getSplitStyles";
5
6
  import { addMediaQueryListener, mediaState, removeMediaQueryListener } from "./useMedia";
6
7
  const createDefinition = /* @__PURE__ */ __name(({
7
8
  Component,
@@ -40,39 +41,113 @@ __name(loadFeatures, "loadFeatures");
40
41
  function loadAnimationFeature() {
41
42
  return createDefinition({
42
43
  Component: ({ _utils, ...props }) => {
43
- const { state, useAnimations, pseudos, style, setStateShallow } = _utils;
44
+ const {
45
+ state,
46
+ useAnimations,
47
+ pseudos,
48
+ style: inStyle,
49
+ setStateShallow,
50
+ staticConfig,
51
+ theme,
52
+ onDidAnimate
53
+ } = _utils;
44
54
  if (!useAnimations) {
45
55
  console.error("no useAnimations hook provided");
46
56
  return null;
47
57
  }
48
58
  const propsWithAnimation = props;
49
- const styleKey = JSON.stringify(style);
50
59
  const res = useAnimations(propsWithAnimation, {
51
- styleKey,
52
- style: style || {},
53
60
  state,
54
61
  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
- };
62
+ onDidAnimate,
63
+ staticConfig,
64
+ getStyle({ isEntering, exitVariant, enterVariant } = {}) {
65
+ var _a, _b, _c, _d;
66
+ const style = inStyle || {};
67
+ const enterStyle = isEntering === true || state.mounted === false ? enterVariant && ((_a = staticConfig.variants) == null ? void 0 : _a[enterVariant]["true"]) ? getSubStyle((_b = staticConfig.variants) == null ? void 0 : _b[enterVariant]["true"], staticConfig, theme, props, state) || pseudos.enterStyle : pseudos.enterStyle : null;
68
+ const exitStyle = isEntering === false ? exitVariant && ((_c = staticConfig.variants) == null ? void 0 : _c[exitVariant]["true"]) ? getSubStyle((_d = staticConfig.variants) == null ? void 0 : _d[exitVariant]["true"], staticConfig, theme, props, state) || pseudos.exitStyle : pseudos.exitStyle : null;
69
+ ensureBaseHasDefaults(style, enterStyle, pseudos.hoverStyle, pseudos.focusStyle, pseudos.pressStyle, pseudos.pressStyle);
70
+ enterStyle && merge(style, enterStyle);
71
+ state.hover && pseudos.hoverStyle && merge(style, pseudos.hoverStyle);
72
+ state.focus && pseudos.focusStyle && merge(style, pseudos.focusStyle);
73
+ state.press && pseudos.pressStyle && merge(style, pseudos.pressStyle);
74
+ exitStyle && merge(style, exitStyle);
75
+ return style;
63
76
  }
64
77
  });
65
78
  useIsomorphicLayoutEffect(() => {
66
79
  setStateShallow({
67
80
  animation: res
68
81
  });
69
- }, [styleKey]);
82
+ }, [res]);
70
83
  return null;
71
84
  },
72
85
  propNames: ["animation"]
73
86
  });
74
87
  }
75
88
  __name(loadAnimationFeature, "loadAnimationFeature");
89
+ const defaults = {
90
+ left: 0,
91
+ right: 0,
92
+ top: 0,
93
+ bottom: 0,
94
+ opacity: 1,
95
+ translateX: 0,
96
+ translateY: 0,
97
+ skew: 0,
98
+ skewX: 0,
99
+ skewY: 0,
100
+ scale: 1,
101
+ rotate: "0deg",
102
+ rotateY: "0deg",
103
+ rotateX: "0deg"
104
+ };
105
+ function ensureBaseHasDefaults(base, ...pseudos) {
106
+ for (const pseudo of pseudos) {
107
+ if (!pseudo)
108
+ continue;
109
+ for (const key in pseudo) {
110
+ const val = pseudo[key];
111
+ if (key === "transform") {
112
+ for (const t of val) {
113
+ const tkey = Object.keys(t)[0];
114
+ const defaultVal = defaults[tkey];
115
+ const tDefaultVal = { [tkey]: defaultVal };
116
+ if (!base.transform) {
117
+ base.transform = [tDefaultVal];
118
+ } else {
119
+ if (!base.transform.find((x) => x[tkey])) {
120
+ base.transform.push(tDefaultVal);
121
+ }
122
+ }
123
+ }
124
+ } else {
125
+ if (!(key in base)) {
126
+ base[key] = defaults[key];
127
+ }
128
+ }
129
+ }
130
+ }
131
+ }
132
+ __name(ensureBaseHasDefaults, "ensureBaseHasDefaults");
133
+ function merge(base, next) {
134
+ if (!next.transform || !base.transform) {
135
+ Object.assign(base, next);
136
+ return;
137
+ }
138
+ const { transform, ...rest } = next;
139
+ Object.assign(base, rest);
140
+ for (const t of transform) {
141
+ const key = Object.keys(t)[0];
142
+ const existing = base.transform.find((x) => key in x);
143
+ if (existing) {
144
+ existing[key] = t[key];
145
+ } else {
146
+ base.transform.push(t);
147
+ }
148
+ }
149
+ }
150
+ __name(merge, "merge");
76
151
  function loadMediaQueryFeature() {
77
152
  const mediaPropNames = Object.keys(mediaState);
78
153
  return createDefinition({
@@ -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 { 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,SA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ACF,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 { getSubStyle } from '../helpers/getSplitStyles'\nimport { PseudoStyles, SplitStyleState } from '../types'\nimport {\n StaticConfig,\n StaticConfigParsed,\n TamaguiComponentState,\n UseAnimationHook,\n UseAnimationProps,\n} 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: SplitStyleState\n setStateShallow: (next: Partial<TamaguiComponentState>) => void\n useAnimations?: UseAnimationHook\n pseudos: PseudoStyles\n style: ViewStyle | null | undefined\n staticConfig: StaticConfigParsed\n theme: any\n onDidAnimate?: () => void\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 {\n state,\n useAnimations,\n pseudos,\n style: inStyle,\n setStateShallow,\n staticConfig,\n theme,\n onDidAnimate,\n } = _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\n const res = useAnimations(propsWithAnimation, {\n state,\n pseudos,\n onDidAnimate,\n staticConfig,\n getStyle({ isEntering, exitVariant, enterVariant } = {}) {\n // we have to merge such that transforms keys all exist\n const style = inStyle || {}\n\n const enterStyle =\n isEntering === true || state.mounted === false\n ? enterVariant && staticConfig.variants?.[enterVariant]['true']\n ? getSubStyle(\n staticConfig.variants?.[enterVariant]['true'],\n staticConfig,\n theme,\n props,\n state\n ) || pseudos.enterStyle\n : null || pseudos.enterStyle\n : null\n\n const exitStyle =\n isEntering === false\n ? exitVariant && staticConfig.variants?.[exitVariant]['true']\n ? getSubStyle(\n staticConfig.variants?.[exitVariant]['true'],\n staticConfig,\n theme,\n props,\n state\n ) || pseudos.exitStyle\n : null || pseudos.exitStyle\n : null\n\n // if you have hoverStyle={{ scale: 1.1 }} and don't have scale set on the base style\n // no animation will run! this is really confusing. this will look at all variants,\n // and fill in base styles if they don't exist. eg:\n // input:\n // base: {}\n // hoverStyle: { scale: 2 }\n // enterStyle: { x: 100 }\n // output:\n // base: { x: 0, scale: 1 }\n ensureBaseHasDefaults(\n style,\n enterStyle,\n pseudos.hoverStyle,\n pseudos.focusStyle,\n pseudos.pressStyle,\n pseudos.pressStyle\n )\n\n enterStyle && merge(style, enterStyle)\n state.hover && pseudos.hoverStyle && merge(style, pseudos.hoverStyle)\n state.focus && pseudos.focusStyle && merge(style, pseudos.focusStyle)\n state.press && pseudos.pressStyle && merge(style, pseudos.pressStyle)\n exitStyle && merge(style, exitStyle)\n\n return style\n },\n //, delay\n })\n\n useIsomorphicLayoutEffect(() => {\n setStateShallow({\n animation: res,\n })\n }, [res])\n\n return null\n },\n propNames: ['animation'],\n })\n}\n\nconst defaults = {\n left: 0,\n right: 0,\n top: 0,\n bottom: 0,\n opacity: 1,\n translateX: 0,\n translateY: 0,\n skew: 0,\n skewX: 0,\n skewY: 0,\n scale: 1,\n rotate: '0deg',\n rotateY: '0deg',\n rotateX: '0deg',\n}\n\nfunction ensureBaseHasDefaults(base: ViewStyle, ...pseudos: (ViewStyle | null | undefined)[]) {\n for (const pseudo of pseudos) {\n if (!pseudo) continue\n for (const key in pseudo) {\n const val = pseudo[key]\n if (key === 'transform') {\n for (const t of val) {\n const tkey = Object.keys(t)[0]\n const defaultVal = defaults[tkey]\n const tDefaultVal = { [tkey]: defaultVal } as any\n if (!base.transform) {\n base.transform = [tDefaultVal]\n } else {\n if (!base.transform.find((x) => x[tkey])) {\n base.transform.push(tDefaultVal)\n }\n }\n }\n } else {\n if (!(key in base)) {\n base[key] = defaults[key]\n }\n }\n }\n }\n}\n\nfunction merge(base: ViewStyle, next: ViewStyle) {\n if (!next.transform || !base.transform) {\n Object.assign(base, next)\n return\n }\n const { transform, ...rest } = next\n Object.assign(base, rest)\n for (const t of transform) {\n const key = Object.keys(t)[0]\n const existing = base.transform.find((x) => key in x)\n if (existing) {\n existing[key] = t[key]\n } else {\n base.transform.push(t)\n }\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;AAC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,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
  }
@@ -49,14 +49,14 @@ const useTheme = /* @__PURE__ */ __name((themeName, componentName, props, forceU
49
49
  return Reflect.has(theme, key);
50
50
  },
51
51
  get(_, key) {
52
- if (!name || key === "__proto__") {
53
- return Reflect.get(_, key);
54
- }
55
- if (key === GetThemeManager) {
56
- if (!didChangeTheme) {
57
- return null;
52
+ if (!name || key === "__proto__" || typeof key === "symbol") {
53
+ if (key === GetThemeManager) {
54
+ if (!didChangeTheme) {
55
+ return null;
56
+ }
57
+ return themeManager;
58
58
  }
59
- return themeManager;
59
+ return Reflect.get(_, key);
60
60
  }
61
61
  if (process.env.NODE_ENV === "development") {
62
62
  if (key === "__state") {
@@ -73,11 +73,6 @@ const useTheme = /* @__PURE__ */ __name((themeName, componentName, props, forceU
73
73
  console.error("No themeManager");
74
74
  return;
75
75
  }
76
- if (process.env.NODE_ENV === "development") {
77
- if ((props == null ? void 0 : props["debug"]) === "verbose") {
78
- console.log(" \xBB accessing theme val", key, { ...state.current });
79
- }
80
- }
81
76
  if (typeof key === "string") {
82
77
  if (key[0] === "$") {
83
78
  key = key.slice(1);
@@ -86,12 +81,16 @@ const useTheme = /* @__PURE__ */ __name((themeName, componentName, props, forceU
86
81
  if (val) {
87
82
  if (state.current.isRendering) {
88
83
  state.current.keys.add(key);
84
+ if (process.env.NODE_ENV === "development") {
85
+ if ((props == null ? void 0 : props["debug"]) === "verbose") {
86
+ console.log(" \xBB tracking theme key", key);
87
+ }
88
+ }
89
89
  }
90
90
  return val;
91
91
  }
92
92
  if (process.env.NODE_ENV === "development") {
93
- console.warn(`No theme value "${String(key)}" in ${name}`);
94
- return null;
93
+ console.log(`No theme value "${String(key)}" in ${name}`);
95
94
  }
96
95
  }
97
96
  return Reflect.get(_, key);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/useTheme.tsx"],
4
- "sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../conf'\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport { ThemeContext } from '../ThemeContext'\nimport { ThemeManager, ThemeManagerContext, emptyManager } from '../ThemeManager'\nimport { ThemeObject } from '../types'\nimport { useConstant } from './useConstant'\n\ntype UseThemeState = {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: any,\n forceUpdate?: any\n): ThemeObject => {\n const { name, theme, themes, themeManager, className, didChangeTheme } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.['debug'] === 'verbose') {\n console.log(' \u00BB useTheme', { themeName, componentName, name, className })\n }\n }\n\n const state = useRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\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 const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n return useMemo(() => {\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme', { themeName, theme, componentName, className })\n }\n return themes[getConfig().defaultTheme || 'light' || Object.keys(themes)[0]]\n }\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') {\n key = key.slice(1)\n }\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (!name || key === '__proto__') {\n return Reflect.get(_, key)\n }\n // TODO make this pattern better\n if (key === GetThemeManager) {\n if (!didChangeTheme) {\n return null\n }\n // TODO\n // console.log('DID CHANGE THEME')\n return themeManager\n }\n if (process.env.NODE_ENV === 'development') {\n if (key === '__state') {\n return state.current\n }\n }\n if (key === 'name') {\n return name\n }\n if (key === 'className') {\n return className\n }\n if (!themeManager) {\n console.error('No themeManager')\n return\n }\n if (process.env.NODE_ENV === 'development') {\n if (props?.['debug'] === 'verbose') {\n console.log(' \u00BB accessing theme val', key, { ...state.current })\n }\n }\n if (typeof key === 'string') {\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n const val = themeManager.getValue(key)\n if (val) {\n if (state.current.isRendering) {\n state.current.keys.add(key)\n }\n return val\n }\n if (process.env.NODE_ENV === 'development') {\n console.warn(`No theme value \"${String(key)}\" in ${name}`)\n return null\n }\n }\n return Reflect.get(_, key)\n },\n })\n }, [name, theme, className, didChangeTheme])\n}\n\nconst GetThemeManager = Symbol('GetThemeManager')\n\nexport const getThemeManagerIfChanged = (theme: any) => {\n return theme?.[GetThemeManager]\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent?.name || '')\n\n useIsomorphicLayoutEffect(() => {\n if (!parent) return\n return parent.onChangeTheme((next, manager) => {\n const name = opts?.parent ? manager.parentName || next : next\n if (!name) return\n setName(name)\n })\n }, [parent])\n\n return name\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)?.defaultTheme\n}\n\nexport const useChangeThemeEffect = (\n name?: string | null,\n componentName?: string,\n props?: any,\n forceUpdateProp?: any\n) => {\n const debug = props && props['debug']\n const parentManager = useContext(ThemeManagerContext) || emptyManager\n const { themes } = useContext(ThemeContext)!\n const next = parentManager.getNextTheme({ name, componentName, themes }, props)\n const forceUpdate = forceUpdateProp || useForceUpdate()\n const themeManager = useConstant<ThemeManager | null>(() => {\n if (!next) {\n return null\n }\n return new ThemeManager(next.name, next.theme, parentManager)\n })\n\n if (typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (!themeManager) return\n if (next?.name) {\n themeManager.update(next)\n }\n return parentManager.onChangeTheme(() => {\n const next = parentManager.getNextTheme({ name, componentName, themes }, debug)\n if (!next) return\n if (themeManager.update(next)) {\n forceUpdate()\n }\n })\n }, [themes, name, componentName, debug, next?.name])\n }\n\n const didChangeTheme = next && parentManager && next.name !== parentManager.fullName\n\n return {\n ...(parentManager && {\n name: parentManager.name,\n theme: parentManager.theme,\n }),\n ...next,\n didChangeTheme,\n themes,\n themeManager,\n }\n}\n"],
5
- "mappings": ";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAQO,MAAM,WAAW,wBACtB,WACA,eACA,OACA,gBACgB;AAChB,QAAM,EAAE,MAAM,OAAO,QAAQ,cAAc,WAAW,mBAAmB,qBACvE,WACA,eACA,OACA,WACF;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,gCAAQ,cAAa,WAAW;AAClC,cAAQ,IAAI,mBAAgB,EAAE,WAAW,eAAe,MAAM,UAAU,CAAC;AAAA,IAC3E;AAAA,EACF;AAEA,QAAM,QAAQ,OAAO;AACrB,MAAI,CAAC,MAAM,SAAS;AAClB,UAAM,UAAU;AAAA,MACd,MAAM,CAAC;AAAA,MACP,MAAM,oBAAI,IAAI;AAAA,MACd,aAAa;AAAA,IACf;AAAA,EACF;AACA,QAAM,QAAQ,cAAc;AAG5B,4BAA0B,MAAM;AAC9B,UAAM,KAAK,MAAM;AACjB,OAAG,cAAc;AACjB,UAAM,MAAM,6CAAc,KAAK,IAAI,GAAG;AACtC,QAAI,CAAC,OAAO,CAAC,aAAa,GAAG,MAAM,GAAG,GAAG;AACvC,mDAAc,MAAM,GAAG,MAAM,GAAG;AAAA,IAClC;AAAA,EACF,CAAC;AAED,SAAO,QAAQ,MAAM;AACnB,QAAI,CAAC,OAAO;AACV,UAAI,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T;AACA,WAAO,IAAI,aAAa,KAAK,MAAM,KAAK,OAAO,aAAa;AAAA,EAC9D,CAAC;AAED,MAAI,OAAO,aAAa,aAAa;AACnC,oBAAgB,MAAM;AACpB,UAAI,CAAC;AAAc;AACnB,UAAI,6BAAM,MAAM;AACd,qBAAa,OAAO,IAAI;AAAA,MAC1B;AACA,aAAO,cAAc,cAAc,MAAM;AACvC,cAAM,QAAO,cAAc,aAAa,EAAE,MAAM,eAAe,OAAO,GAAG,KAAK;AAC9E,YAAI,CAAC;AAAM;AACX,YAAI,aAAa,OAAO,KAAI,GAAG;AAC7B,sBAAY;AAAA,QACd;AAAA,MACF,CAAC;AAAA,IACH,GAAG,CAAC,QAAQ,MAAM,eAAe,OAAO,6BAAM,IAAI,CAAC;AAAA,EACrD;AAEA,QAAM,iBAAiB,QAAQ,iBAAiB,KAAK,SAAS,cAAc;AAE5E,SAAO;AAAA,OACD,iBAAiB;AAAA,MACnB,MAAM,cAAc;AAAA,MACpB,OAAO,cAAc;AAAA,IACvB;AAAA,OACG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF,GA9CoC;",
4
+ "sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../conf'\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport { ThemeContext } from '../ThemeContext'\nimport { ThemeManager, ThemeManagerContext, emptyManager } from '../ThemeManager'\nimport { ThemeObject } from '../types'\nimport { useConstant } from './useConstant'\n\ntype UseThemeState = {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: any,\n forceUpdate?: any\n): ThemeObject => {\n const { name, theme, themes, themeManager, className, didChangeTheme } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.['debug'] === 'verbose') {\n console.log(' \u00BB useTheme', { themeName, componentName, name, className })\n }\n }\n\n const state = useRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\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 const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n return useMemo(() => {\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme', { themeName, theme, componentName, className })\n }\n return themes[getConfig().defaultTheme || 'light' || Object.keys(themes)[0]]\n }\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') {\n key = key.slice(1)\n }\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (!name || key === '__proto__' || typeof key === 'symbol') {\n // TODO make this pattern better\n if (key === GetThemeManager) {\n if (!didChangeTheme) {\n return null\n }\n // TODO\n // console.log('DID CHANGE THEME')\n return themeManager\n }\n return Reflect.get(_, key)\n }\n if (process.env.NODE_ENV === 'development') {\n if (key === '__state') {\n return state.current\n }\n }\n if (key === 'name') {\n return name\n }\n if (key === 'className') {\n return className\n }\n if (!themeManager) {\n console.error('No themeManager')\n return\n }\n if (typeof key === 'string') {\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n const val = themeManager.getValue(key)\n if (val) {\n if (state.current.isRendering) {\n state.current.keys.add(key)\n if (process.env.NODE_ENV === 'development') {\n if (props?.['debug'] === 'verbose') {\n console.log(' \u00BB tracking theme key', key)\n }\n }\n }\n return val\n }\n // react native debuger uses toJSON\n if (process.env.NODE_ENV === 'development') {\n console.log(`No theme value \"${String(key)}\" in ${name}`)\n }\n }\n return Reflect.get(_, key)\n },\n })\n }, [name, theme, className, didChangeTheme])\n}\n\nconst GetThemeManager = Symbol('GetThemeManager')\n\nexport const getThemeManagerIfChanged = (theme: any) => {\n return theme?.[GetThemeManager]\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent?.name || '')\n\n useIsomorphicLayoutEffect(() => {\n if (!parent) return\n return parent.onChangeTheme((next, manager) => {\n const name = opts?.parent ? manager.parentName || next : next\n if (!name) return\n setName(name)\n })\n }, [parent])\n\n return name\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)?.defaultTheme\n}\n\nexport const useChangeThemeEffect = (\n name?: string | null,\n componentName?: string,\n props?: any,\n forceUpdateProp?: any\n) => {\n const debug = props && props['debug']\n const parentManager = useContext(ThemeManagerContext) || emptyManager\n const { themes } = useContext(ThemeContext)!\n const next = parentManager.getNextTheme({ name, componentName, themes }, props)\n const forceUpdate = forceUpdateProp || useForceUpdate()\n const themeManager = useConstant<ThemeManager | null>(() => {\n if (!next) {\n return null\n }\n return new ThemeManager(next.name, next.theme, parentManager)\n })\n\n if (typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (!themeManager) return\n if (next?.name) {\n themeManager.update(next)\n }\n return parentManager.onChangeTheme(() => {\n const next = parentManager.getNextTheme({ name, componentName, themes }, debug)\n if (!next) return\n if (themeManager.update(next)) {\n forceUpdate()\n }\n })\n }, [themes, name, componentName, debug, next?.name])\n }\n\n const didChangeTheme = next && parentManager && next.name !== parentManager.fullName\n\n return {\n ...(parentManager && {\n name: parentManager.name,\n theme: parentManager.theme,\n }),\n ...next,\n didChangeTheme,\n themes,\n themeManager,\n }\n}\n"],
5
+ "mappings": ";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAQO,MAAM,WAAW,wBACtB,WACA,eACA,OACA,gBACgB;AAChB,QAAM,EAAE,MAAM,OAAO,QAAQ,cAAc,WAAW,mBAAmB,qBACvE,WACA,eACA,OACA,WACF;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,gCAAQ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AAA,IACA;AAAA,IACA;AAAA,EACF;AACF,GA9CoC;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/styled.tsx"],
4
- "sourcesContent": ["import { Image, Text, TextInput } from 'react-native'\n\nimport { createComponent } from './createComponent'\nimport { 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;",
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<ParentComponent> | symbol =\n | VariantDefinitions<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 // 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 symbol\n ? {}\n : {\n [Key in keyof Variants]?: 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 | symbol\n ? GetProps<ParentComponent>\n : // start with base props\n OurPropsBase &\n // add in media (+ pseudos nested)\n MediaProps<Partial<OurPropsBase>> &\n // add in pseudos\n PseudoProps<Partial<OurPropsBase>>\n\n return component as TamaguiComponent<\n Props,\n // TODO infer ref\n any,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n}\n\n// test types:\n\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 Heading = styled(SizableText, {\n// tag: 'span',\n// name: 'Heading',\n// accessibilityRole: 'header',\n// size: '$8',\n// margin: 0,\n// })\n// export const Paragraph = styled(SizableText, {\n// tag: 'p',\n// margin: 10,\n// variants: {\n// another: {\n// true: {},\n// },\n// },\n// })\n// export const Paragraph2 = styled(Paragraph, {\n// tag: 'p',\n// variants: {\n// another: {\n// '...color': (val) => ({\n// backgroundColor: 'red',\n// }),\n// },\n// },\n// })\n// const a = <SizableText size=\"$10\" />\n// const b = <Paragraph size=\"$10\" another />\n// const c = <Paragraph2 size=\"$10\" another=\"aliceblue\" />\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,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;AA6BzC,SAAO;AAOT;AAtFgB;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,7 @@
1
1
  import { stackDefaultStyles } from "../constants/constants";
2
2
  import { createComponent } from "../createComponent";
3
3
  const Stack = createComponent({
4
+ componentName: "Stack",
4
5
  defaultProps: {
5
6
  ...stackDefaultStyles,
6
7
  flexDirection: "column"
@@ -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, 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;",
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 componentName: 'Stack',\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,eAAe;AAAA,EACf,cAAc;AAAA,OACT;AAAA,IACH,eAAe;AAAA,EACjB;AACF,CAAC;",
6
6
  "names": []
7
7
  }
@@ -8,6 +8,7 @@ const ellipseStyle = {
8
8
  whiteSpace: "nowrap"
9
9
  };
10
10
  const Text = createComponent({
11
+ componentName: "Text",
11
12
  isText: true,
12
13
  defaultProps: {
13
14
  display: isWeb ? "inline" : "flex",
@@ -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, 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;",
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 componentName: 'Text',\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,eAAe;AAAA,EACf,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
  }
@@ -1,11 +1,13 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import * as Helpers from "@tamagui/helpers";
3
4
  import { rnw } from "./constants/rnw";
4
5
  import { getAllSelectors, getAllTransforms } from "./helpers/insertStyleRule";
5
6
  class TamaguiManager {
6
7
  constructor() {
7
8
  this.config = null;
8
9
  this.rnw = rnw;
10
+ this.Helpers = Helpers;
9
11
  }
10
12
  get allSelectors() {
11
13
  return getAllSelectors();
@@ -10,21 +10,18 @@ import React, {
10
10
  memo,
11
11
  useCallback,
12
12
  useContext,
13
- useEffect,
14
13
  useRef,
15
14
  useState
16
15
  } from "react";
17
16
  import { StyleSheet, Text, View } from "react-native";
18
17
  import { onConfiguredOnce } from "./conf";
19
18
  import { stackDefaultStyles } from "./constants/constants";
20
- import { isAndroid, isTouchDevice, isWeb } from "./constants/platform";
19
+ import { isAndroid, isTouchDevice, isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
21
20
  import { rnw } from "./constants/rnw";
22
21
  import { isVariable } from "./createVariable";
23
22
  import { createShallowUpdate } from "./helpers/createShallowUpdate";
24
23
  import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
25
- import {
26
- getSplitStyles
27
- } from "./helpers/getSplitStyles";
24
+ import { getSplitStyles } from "./helpers/getSplitStyles";
28
25
  import { getAllSelectors } from "./helpers/insertStyleRule";
29
26
  import { wrapThemeManagerContext } from "./helpers/wrapThemeManagerContext";
30
27
  import { useFeatures } from "./hooks/useFeatures";
@@ -82,7 +79,8 @@ function createComponent(configIn) {
82
79
  var _a, _b, _c, _d;
83
80
  if (process.env.NODE_ENV === "development") {
84
81
  if (props["debug"]) {
85
- console.warn(componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", " debug prop on:", { props: Object.entries(props) });
82
+ console.warn(componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "debug on");
83
+ console.log("props in:", props);
86
84
  if (props["debug"] === "break")
87
85
  debugger;
88
86
  }
@@ -97,14 +95,16 @@ function createComponent(configIn) {
97
95
  const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
98
96
  const isAnimated = !!(useAnimations && props.animation);
99
97
  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;
101
98
  const features = useFeatures(props, {
102
99
  forceUpdate,
103
100
  setStateShallow,
104
101
  useAnimations,
105
102
  state,
106
- style: styleWithPseudos,
107
- pseudos
103
+ style: props.animation ? { ...defaultNativeStyle, ...style } : null,
104
+ pseudos,
105
+ staticConfig,
106
+ theme,
107
+ onDidAnimate: props.onDidAnimate
108
108
  });
109
109
  const {
110
110
  tag,
@@ -164,18 +164,16 @@ function createComponent(configIn) {
164
164
  isMounted: true
165
165
  };
166
166
  }
167
- useEffect(() => {
168
- if (hasEnterStyle) {
169
- setStateShallow({
170
- mounted: true
171
- });
172
- }
167
+ useIsomorphicLayoutEffect(() => {
168
+ setStateShallow({
169
+ mounted: true
170
+ });
173
171
  internal.current.isMounted = true;
174
172
  return () => {
175
173
  mouseUps.delete(unPress);
176
174
  internal.current.isMounted = false;
177
175
  };
178
- }, []);
176
+ }, [hasEnterStyle]);
179
177
  if (nativeID) {
180
178
  viewProps.id = nativeID;
181
179
  }
@@ -292,7 +290,7 @@ function createComponent(configIn) {
292
290
  viewProps.ref = forwardedRef;
293
291
  }
294
292
  }
295
- const attachPress = !!(pseudos && pseudos.pressStyle || onPress || onPressOut || onPressIn);
293
+ const attachPress = !!(pseudos && pseudos.pressStyle || defaultPseudos && defaultPseudos.pressStyle || onPress || onPressOut || onPressIn);
296
294
  const isHoverable = isWeb && !isTouchDevice;
297
295
  const attachHover = isHoverable && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
298
296
  const pressEventKey = isStringElement ? "onClick" : "onPress";
@@ -407,7 +405,7 @@ function createComponent(configIn) {
407
405
  if (process.env.NODE_ENV === "development") {
408
406
  if (props["debug"]) {
409
407
  viewProps["debug"] = true;
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 });
408
+ console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, 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 });
411
409
  }
412
410
  }
413
411
  if (features.length) {
@@ -420,6 +418,9 @@ function createComponent(configIn) {
420
418
  });
421
419
  onConfiguredOnce((conf) => {
422
420
  var _a, _b, _c, _d;
421
+ if (process.env.IS_STATIC === "is_static") {
422
+ return;
423
+ }
423
424
  const shouldDebug = (_a = staticConfig.defaultProps) == null ? void 0 : _a.debug;
424
425
  tamaguiConfig = conf;
425
426
  avoidClasses = !!((_b = tamaguiConfig.animations) == null ? void 0 : _b.avoidClasses);
@@ -428,6 +429,10 @@ function createComponent(configIn) {
428
429
  initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]];
429
430
  defaultSplitStyleResult = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, {
430
431
  mounted: true,
432
+ hover: false,
433
+ press: false,
434
+ pressIn: false,
435
+ focus: false,
431
436
  resolveVariablesAs: "both"
432
437
  });
433
438
  const { classNames, pseudos, style, viewProps } = defaultSplitStyleResult;
@@ -456,6 +461,7 @@ function createComponent(configIn) {
456
461
  if (configIn.memo) {
457
462
  res = memo(res);
458
463
  }
464
+ res["whyDidYouRender"] = true;
459
465
  res["staticConfig"] = {
460
466
  validStyles: validStyleProps,
461
467
  ...staticConfig
@@ -476,6 +482,7 @@ function createComponent(configIn) {
476
482
  __name(createComponent, "createComponent");
477
483
  const Spacer = createComponent({
478
484
  memo: true,
485
+ componentName: "Spacer",
479
486
  defaultProps: {
480
487
  ...stackDefaultStyles,
481
488
  size: true
@@ -548,38 +555,6 @@ function spacedChildren({
548
555
  return next;
549
556
  }
550
557
  __name(spacedChildren, "spacedChildren");
551
- const merge = /* @__PURE__ */ __name((...styles) => {
552
- if (!styles[0])
553
- return;
554
- const res = {};
555
- const len = styles.length;
556
- for (let i = len - 1; i >= 0; i--) {
557
- const cur = styles[i];
558
- if (!cur)
559
- continue;
560
- for (const key in cur) {
561
- const val = cur[key];
562
- if (key !== "transform") {
563
- if (!(key in res)) {
564
- res[key] = val;
565
- }
566
- continue;
567
- }
568
- if (!res.transform) {
569
- res.transform = val;
570
- continue;
571
- }
572
- for (const t of val) {
573
- const tkey = Object.keys(t)[0];
574
- if (res.transform.find((existing) => tkey in existing)) {
575
- continue;
576
- }
577
- res.transform.push(t);
578
- }
579
- }
580
- }
581
- return res;
582
- }, "merge");
583
558
  const AbsoluteFill = /* @__PURE__ */ __name((props) => isWeb ? <div style={{
584
559
  position: "absolute",
585
560
  top: 0,