@tamagui/core 1.0.1-beta.226 → 1.0.1-beta.228

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 (135) hide show
  1. package/dist/cjs/constants/platform.js +65 -0
  2. package/dist/cjs/constants/platform.js.map +7 -0
  3. package/dist/cjs/constants/platform.native.js +62 -0
  4. package/dist/cjs/constants/platform.native.js.map +7 -0
  5. package/dist/cjs/createComponent.js +22 -38
  6. package/dist/cjs/createComponent.js.map +2 -2
  7. package/dist/cjs/createVariable.js +1 -1
  8. package/dist/cjs/createVariable.js.map +2 -2
  9. package/dist/cjs/helpers/ThemeManager.js +19 -12
  10. package/dist/cjs/helpers/ThemeManager.js.map +3 -3
  11. package/dist/cjs/helpers/ThemeManager.test.js +16 -0
  12. package/dist/cjs/helpers/ThemeManager.test.js.map +2 -2
  13. package/dist/cjs/helpers/assignNativePropsToWeb.js +188 -0
  14. package/dist/cjs/helpers/assignNativePropsToWeb.js.map +7 -0
  15. package/dist/cjs/helpers/assignNativePropsToWeb.native.js +30 -0
  16. package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +7 -0
  17. package/dist/cjs/helpers/calc.js +71 -0
  18. package/dist/cjs/helpers/calc.js.map +7 -0
  19. package/dist/cjs/helpers/createPropMapper.js +3 -5
  20. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  21. package/dist/cjs/helpers/createShallowUpdate.js +44 -0
  22. package/dist/cjs/helpers/createShallowUpdate.js.map +7 -0
  23. package/dist/cjs/helpers/getFont.js +66 -0
  24. package/dist/cjs/helpers/getFont.js.map +7 -0
  25. package/dist/cjs/helpers/getSplitStyles.js +85 -67
  26. package/dist/cjs/helpers/getSplitStyles.js.map +3 -3
  27. package/dist/cjs/helpers/getStackSize.js +46 -0
  28. package/dist/cjs/helpers/getStackSize.js.map +7 -0
  29. package/dist/cjs/helpers/normalizeColor.js +2 -2
  30. package/dist/cjs/helpers/normalizeColor.js.map +2 -2
  31. package/dist/cjs/helpers/startTransition.js +36 -0
  32. package/dist/cjs/helpers/startTransition.js.map +7 -0
  33. package/dist/cjs/helpers/timer.js +35 -0
  34. package/dist/cjs/helpers/timer.js.map +7 -0
  35. package/dist/cjs/helpers/validate.js +2 -0
  36. package/dist/cjs/helpers/validate.js.map +7 -0
  37. package/dist/cjs/hooks/useConstant.js +39 -0
  38. package/dist/cjs/hooks/useConstant.js.map +7 -0
  39. package/dist/cjs/hooks/useIsMounted.js +40 -0
  40. package/dist/cjs/hooks/useIsMounted.js.map +7 -0
  41. package/dist/cjs/hooks/useIsSSR.js +46 -0
  42. package/dist/cjs/hooks/useIsSSR.js.map +7 -0
  43. package/dist/cjs/hooks/usePressable.js +36 -0
  44. package/dist/cjs/hooks/usePressable.js.map +7 -0
  45. package/dist/cjs/hooks/useTheme.js +24 -20
  46. package/dist/cjs/hooks/useTheme.js.map +3 -3
  47. package/dist/cjs/hooks/useUnmountEffect.js +32 -0
  48. package/dist/cjs/hooks/useUnmountEffect.js.map +7 -0
  49. package/dist/cjs/injectStyles.js +40 -0
  50. package/dist/cjs/injectStyles.js.map +7 -0
  51. package/dist/cjs/styled.js +0 -10
  52. package/dist/cjs/styled.js.map +2 -2
  53. package/dist/cjs/types.js.map +1 -1
  54. package/dist/cjs/views/Theme.js +5 -9
  55. package/dist/cjs/views/Theme.js.map +2 -2
  56. package/dist/cjs/views/ThemeInverse.js +18 -25
  57. package/dist/cjs/views/ThemeInverse.js.map +2 -2
  58. package/dist/cjs/views/ThemeReset.js +12 -12
  59. package/dist/cjs/views/ThemeReset.js.map +2 -2
  60. package/dist/esm/constants/platform.js +30 -0
  61. package/dist/esm/constants/platform.js.map +7 -0
  62. package/dist/esm/constants/platform.native.js +28 -0
  63. package/dist/esm/constants/platform.native.js.map +7 -0
  64. package/dist/esm/createComponent.js +22 -38
  65. package/dist/esm/createComponent.js.map +2 -2
  66. package/dist/esm/createVariable.js +1 -1
  67. package/dist/esm/createVariable.js.map +2 -2
  68. package/dist/esm/helpers/ThemeManager.js +14 -7
  69. package/dist/esm/helpers/ThemeManager.js.map +2 -2
  70. package/dist/esm/helpers/ThemeManager.test.js +16 -0
  71. package/dist/esm/helpers/ThemeManager.test.js.map +2 -2
  72. package/dist/esm/helpers/assignNativePropsToWeb.js +164 -0
  73. package/dist/esm/helpers/assignNativePropsToWeb.js.map +7 -0
  74. package/dist/esm/helpers/assignNativePropsToWeb.native.js +6 -0
  75. package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +7 -0
  76. package/dist/esm/helpers/calc.js +47 -0
  77. package/dist/esm/helpers/calc.js.map +7 -0
  78. package/dist/esm/helpers/createPropMapper.js +3 -5
  79. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  80. package/dist/esm/helpers/createShallowUpdate.js +20 -0
  81. package/dist/esm/helpers/createShallowUpdate.js.map +7 -0
  82. package/dist/esm/helpers/getFont.js +42 -0
  83. package/dist/esm/helpers/getFont.js.map +7 -0
  84. package/dist/esm/helpers/getSplitStyles.js +85 -67
  85. package/dist/esm/helpers/getSplitStyles.js.map +3 -3
  86. package/dist/esm/helpers/getStackSize.js +22 -0
  87. package/dist/esm/helpers/getStackSize.js.map +7 -0
  88. package/dist/esm/helpers/normalizeColor.js +1 -1
  89. package/dist/esm/helpers/normalizeColor.js.map +1 -1
  90. package/dist/esm/helpers/startTransition.js +6 -0
  91. package/dist/esm/helpers/startTransition.js.map +7 -0
  92. package/dist/esm/helpers/timer.js +11 -0
  93. package/dist/esm/helpers/timer.js.map +7 -0
  94. package/dist/esm/helpers/validate.js +1 -0
  95. package/dist/esm/helpers/validate.js.map +7 -0
  96. package/dist/esm/hooks/useConstant.js +15 -0
  97. package/dist/esm/hooks/useConstant.js.map +7 -0
  98. package/dist/esm/hooks/useIsMounted.js +16 -0
  99. package/dist/esm/hooks/useIsMounted.js.map +7 -0
  100. package/dist/esm/hooks/useIsSSR.js +22 -0
  101. package/dist/esm/hooks/useIsSSR.js.map +7 -0
  102. package/dist/esm/hooks/usePressable.js +12 -0
  103. package/dist/esm/hooks/usePressable.js.map +7 -0
  104. package/dist/esm/hooks/useTheme.js +24 -20
  105. package/dist/esm/hooks/useTheme.js.map +3 -3
  106. package/dist/esm/hooks/useUnmountEffect.js +8 -0
  107. package/dist/esm/hooks/useUnmountEffect.js.map +7 -0
  108. package/dist/esm/injectStyles.js +16 -0
  109. package/dist/esm/injectStyles.js.map +7 -0
  110. package/dist/esm/styled.js +0 -10
  111. package/dist/esm/styled.js.map +2 -2
  112. package/dist/esm/views/Theme.js +5 -9
  113. package/dist/esm/views/Theme.js.map +2 -2
  114. package/dist/esm/views/ThemeInverse.js +17 -23
  115. package/dist/esm/views/ThemeInverse.js.map +2 -2
  116. package/dist/esm/views/ThemeReset.js +12 -12
  117. package/dist/esm/views/ThemeReset.js.map +2 -2
  118. package/package.json +13 -13
  119. package/src/createComponent.tsx +22 -81
  120. package/src/createVariable.ts +1 -1
  121. package/src/helpers/ThemeManager.test.tsx +17 -0
  122. package/src/helpers/ThemeManager.tsx +29 -14
  123. package/src/helpers/createPropMapper.ts +4 -5
  124. package/src/helpers/getSplitStyles.tsx +130 -91
  125. package/src/helpers/normalizeColor.ts +1 -1
  126. package/src/helpers/timer.ts +9 -0
  127. package/src/hooks/useTheme.tsx +29 -22
  128. package/src/styled.tsx +0 -12
  129. package/src/types.tsx +2 -5
  130. package/src/views/Theme.tsx +5 -9
  131. package/types/helpers/ThemeManager.d.ts +2 -2
  132. package/types/helpers/getSplitStyles.d.ts +22 -6
  133. package/types/helpers/timer.d.ts +2 -0
  134. package/types/hooks/useTheme.d.ts +0 -1
  135. package/types/types.d.ts +1 -5
@@ -41,7 +41,7 @@ __export(ThemeManager_exports, {
41
41
  });
42
42
  module.exports = __toCommonJS(ThemeManager_exports);
43
43
  var import_config = require("../config");
44
- var import_constants2 = require("../constants/constants");
44
+ var import_constants = require("../constants/constants");
45
45
  var import_getThemeUnwrapped = require("../hooks/getThemeUnwrapped");
46
46
  var _allKeys;
47
47
  const emptyState = { name: "" };
@@ -95,14 +95,19 @@ class ThemeManager {
95
95
  }
96
96
  }
97
97
  getStateIfChanged(props = this.props, state = this.state, parentManager = this.parentManager) {
98
- const _ = getState(props, parentManager) || (process.env.TAMAGUI_TARGET === "native" ? parentManager == null ? void 0 : parentManager.state : void 0);
99
- if (!_ || !_.theme || _.theme === state.theme) {
98
+ const _ = this.getState(props, parentManager);
99
+ if (state && state !== emptyState && !_) {
100
+ return parentManager == null ? void 0 : parentManager.state;
101
+ }
102
+ if (!_ || !_.theme || _.theme === (state == null ? void 0 : state.theme)) {
103
+ if (process.env.NODE_ENV === "development" && props.debug === "verbose")
104
+ console.log(`getStateIfChanged not changed`, (_ == null ? void 0 : _.theme) === (state == null ? void 0 : state.theme), _, state);
100
105
  return null;
101
106
  }
102
107
  return _;
103
108
  }
104
- getState(props = this.props) {
105
- return getState(props, this.parentManager);
109
+ getState(props = this.props, parentManager = this.parentManager) {
110
+ return getState(props, parentManager) || (process.env.TAMAGUI_TARGET === "native" ? parentManager == null ? void 0 : parentManager.state : void 0);
106
111
  }
107
112
  get allKeys() {
108
113
  var _a;
@@ -135,7 +140,7 @@ class ThemeManager {
135
140
  }
136
141
  _allKeys = new WeakMap();
137
142
  function getNextThemeClassName(name, isInverting = false) {
138
- const next = `${import_constants2.THEME_CLASSNAME_PREFIX}${name}`;
143
+ const next = `${import_constants.THEME_CLASSNAME_PREFIX}${name}`;
139
144
  if (isInverting) {
140
145
  return next;
141
146
  }
@@ -153,19 +158,19 @@ function getState(props, parentManager) {
153
158
  const nextName = props.reset ? ((_b = (_a = parentManager == null ? void 0 : parentManager.parentManager) == null ? void 0 : _a.state) == null ? void 0 : _b.name) || "" : props.name || "";
154
159
  const { componentName } = props;
155
160
  const parentName = ((_c = parentManager == null ? void 0 : parentManager.state) == null ? void 0 : _c.name) || "";
156
- const base = parentName.split(import_constants2.THEME_NAME_SEPARATOR);
161
+ const base = parentName.split(import_constants.THEME_NAME_SEPARATOR);
157
162
  const lastSegment = base[base.length - 1];
158
163
  const isParentAComponentTheme = parentName && lastSegment[0].toUpperCase() === lastSegment[0];
159
164
  if (isParentAComponentTheme) {
160
165
  base.pop();
161
166
  }
162
- const parentBaseTheme = isParentAComponentTheme ? base.slice(0, base.length).join(import_constants2.THEME_NAME_SEPARATOR) : parentName;
167
+ const parentBaseTheme = isParentAComponentTheme ? base.slice(0, base.length).join(import_constants.THEME_NAME_SEPARATOR) : parentName;
163
168
  const max = base.length;
164
- const min = componentName ? max : 0;
169
+ const min = componentName && !nextName ? max : 0;
165
170
  if (process.env.NODE_ENV === "development" && props.debug === "verbose")
166
- console.log("getState", props, { parentName, parentBaseTheme, base, min, max, isParentAComponentTheme, parentManager });
171
+ [console.groupCollapsed("getState", props, { parentName, parentBaseTheme, base, min, max, isParentAComponentTheme }), console.trace(), console.groupEnd()];
167
172
  for (let i = max; i >= min; i--) {
168
- let prefix = base.slice(0, i).join(import_constants2.THEME_NAME_SEPARATOR);
173
+ let prefix = base.slice(0, i).join(import_constants.THEME_NAME_SEPARATOR);
169
174
  if (props.inverse) {
170
175
  prefix = inverseThemeName(prefix);
171
176
  }
@@ -184,7 +189,9 @@ function getState(props, parentManager) {
184
189
  }
185
190
  if (componentName) {
186
191
  if (nextName) {
187
- potentials.push(`${prefix.replace(/_.*$/, "")}_${nextName}_${componentName}`);
192
+ potentials.push(
193
+ `${prefix.slice(0, prefix.indexOf(import_constants.THEME_NAME_SEPARATOR))}_${nextName}_${componentName}`
194
+ );
188
195
  }
189
196
  potentials.push(`${prefix}_${componentName}`);
190
197
  if (nextName) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/helpers/ThemeManager.tsx"],
4
- "sourcesContent": ["import { isWeb } from '@tamagui/constants'\n\nimport { getThemes } from '../config'\nimport { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from '../constants/constants'\nimport { getThemeUnwrapped } from '../hooks/getThemeUnwrapped'\nimport { ThemeParsed, ThemeProps } from '../types'\n\ntype ThemeListener = (name: string | null, themeManager: ThemeManager) => void\n\nexport type SetActiveThemeProps = {\n className?: string\n parentManager?: ThemeManager | null\n name?: string | null\n theme?: any\n reset?: boolean\n}\n\nexport type ThemeManagerState = {\n name: string\n theme?: ThemeParsed | null\n className?: string\n parentName?: string\n}\n\nconst emptyState: ThemeManagerState = { name: '' }\n\nexport function hasNoThemeUpdatingProps(props: ThemeProps) {\n return !props.name && !props.componentName && !props.inverse && !props.reset\n}\n\nexport class ThemeManager {\n themeListeners = new Set<ThemeListener>()\n parentManager: ThemeManager | null = null\n state: ThemeManagerState = emptyState\n\n constructor(\n public props: ThemeProps = {},\n parentManager?: ThemeManager | 'root' | null | undefined\n ) {\n if (parentManager === 'root') {\n this.updateState(props, false)\n return\n }\n if (!parentManager) {\n throw new Error(`Must set up root first`)\n }\n // no change no props\n if (hasNoThemeUpdatingProps(props)) {\n return parentManager\n }\n if (parentManager) {\n this.parentManager = parentManager\n }\n const updatedState = this.getStateIfChanged(props)\n if (updatedState) {\n this.state = updatedState\n return\n }\n return parentManager || this\n }\n\n updateState(props: ThemeProps & { forceTheme?: ThemeParsed } = this.props || {}, notify = true) {\n const shouldFlush = (() => {\n if (props.forceTheme) {\n this.state.theme = props.forceTheme\n this.state.name = props.name || ''\n return true\n }\n const nextState = this.getStateIfChanged(props)\n if (nextState) {\n this.state = nextState\n return true\n }\n })()\n if (shouldFlush) {\n // reset any derived state\n this.#allKeys = null\n notify && this.notify()\n return this.state\n }\n }\n\n getStateIfChanged(props = this.props, state = this.state, parentManager = this.parentManager) {\n const _ =\n getState(props, parentManager) ||\n (process.env.TAMAGUI_TARGET === 'native' ? parentManager?.state : undefined)\n if (!_ || !_.theme || _.theme === state.theme) {\n return null\n }\n return _\n }\n\n getState(props = this.props) {\n return getState(props, this.parentManager)\n }\n\n #allKeys: Set<string> | null = null\n get allKeys() {\n this.#allKeys ??= new Set([\n ...(this.parentManager?.allKeys || []),\n ...Object.keys(this.state.theme || {}),\n ])\n return this.#allKeys\n }\n\n // gets value going up to parents\n getValue(key: string, state?: ThemeManagerState) {\n let theme = (state || this.state).theme\n let manager = this as ThemeManager | null\n while (theme && manager) {\n if (key in theme) {\n return theme[key]\n }\n manager = manager.parentManager\n theme = manager?.state.theme\n }\n }\n\n notify() {\n this.themeListeners.forEach((cb) => cb(this.state.name, this))\n }\n\n onChangeTheme(cb: ThemeListener) {\n this.themeListeners.add(cb)\n return () => {\n this.themeListeners.delete(cb)\n }\n }\n}\n\nfunction getNextThemeClassName(name: string, isInverting = false) {\n const next = `${THEME_CLASSNAME_PREFIX}${name}`\n if (isInverting) {\n return next\n }\n return next.replace('light_', '').replace('dark_', '')\n}\n\nfunction getState(\n props: ThemeProps,\n parentManager?: ThemeManager | null\n): ThemeManagerState | null {\n const themes = getThemes()\n\n if (props.name && props.reset) {\n throw new Error(`Cannot reset + set new name`)\n }\n if (props.reset && !parentManager?.parentManager) {\n throw new Error(`Cannot reset no grandparent exists`)\n }\n\n const nextName = props.reset ? parentManager?.parentManager?.state?.name || '' : props.name || ''\n const { componentName } = props\n const parentName = parentManager?.state?.name || ''\n\n // components look for most specific, fallback upwards\n const base = parentName.split(THEME_NAME_SEPARATOR)\n const lastSegment = base[base.length - 1]\n const isParentAComponentTheme = parentName && lastSegment[0].toUpperCase() === lastSegment[0]\n if (isParentAComponentTheme) {\n base.pop() // always remove componentName they can't nest\n }\n const parentBaseTheme = isParentAComponentTheme\n ? base.slice(0, base.length).join(THEME_NAME_SEPARATOR)\n : parentName\n const max = base.length\n const min = componentName\n ? max // component themes don't search upwards\n : 0\n\n // prettier-ignore\n // eslint-disable-next-line no-console\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') console.log('getState', props, { parentName, parentBaseTheme, base, min, max, isParentAComponentTheme, parentManager })\n\n for (let i = max; i >= min; i--) {\n let prefix = base.slice(0, i).join(THEME_NAME_SEPARATOR)\n if (props.inverse) {\n prefix = inverseThemeName(prefix)\n }\n const potentials: string[] = []\n if (prefix && prefix !== parentBaseTheme) {\n potentials.push(prefix)\n }\n if (nextName) {\n potentials.unshift(prefix ? `${prefix}_${nextName}` : nextName)\n }\n if (i === 1) {\n const lastSegment = potentials.findIndex((x) => !x.includes('_'))\n if (lastSegment > 0) {\n potentials.splice(lastSegment, 0, nextName) // last try prefer our new name to parent\n }\n }\n if (componentName) {\n // components only look for component themes\n if (nextName) {\n potentials.push(`${prefix.replace(/_.*$/, '')}_${nextName}_${componentName}`)\n }\n potentials.push(`${prefix}_${componentName}`)\n if (nextName) {\n potentials.unshift(`${prefix}_${nextName}_${componentName}`)\n }\n }\n\n // prettier-ignore\n // eslint-disable-next-line no-console\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') console.log('getState potentials', potentials)\n\n const found = potentials.find((t) => t in themes)\n if (found) {\n // optimization return null if not changed\n if (found === parentName) {\n return null\n }\n const theme = themes[found]\n return {\n // need to put concurrent safe things here\n name: found,\n theme: getThemeUnwrapped(theme),\n className: getNextThemeClassName(found, props.inverse),\n parentName,\n }\n }\n }\n\n return null\n}\n\nconst inverseThemeName = (themeName: string) => {\n return themeName.startsWith('light')\n ? themeName.replace(/^light/, 'dark')\n : themeName.replace(/^dark/, 'light')\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA0B;AAC1B,IAAAA,oBAA6D;AAC7D,+BAAkC;AAJlC;AAwBA,MAAM,aAAgC,EAAE,MAAM,GAAG;AAE1C,SAAS,wBAAwB,OAAmB;AACzD,SAAO,CAAC,MAAM,QAAQ,CAAC,MAAM,iBAAiB,CAAC,MAAM,WAAW,CAAC,MAAM;AACzE;AAEO,MAAM,aAAa;AAAA,EAKxB,YACS,QAAoB,CAAC,GAC5B,eACA;AAFO;AALT,0BAAiB,oBAAI,IAAmB;AACxC,yBAAqC;AACrC,iBAA2B;AA+D3B,iCAA+B;AAzD7B,QAAI,kBAAkB,QAAQ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aAAa,iBAAiB,MAAM,UAAU;AAAW,cAAQ,IAAI,uBAAuB,UAAU;AAEtH,UAAM,QAAQ,WAAW,KAAK,CAAC,MAAM,KAAK,MAAM;AAChD,QAAI,OAAO;AAET,UAAI,UAAU,YAAY;AACxB,eAAO;AAAA,MACT;AACA,YAAM,QAAQ,OAAO;AACrB,aAAO;AAAA,QAEL,MAAM;AAAA,QACN,WAAO,4CAAkB,KAAK;AAAA,QAC9B,WAAW,sBAAsB,OAAO,MAAM,OAAO;AAAA,QACrD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEA,MAAM,mBAAmB,CAAC,cAAsB;AAC9C,SAAO,UAAU,WAAW,OAAO,IAC/B,UAAU,QAAQ,UAAU,MAAM,IAClC,UAAU,QAAQ,SAAS,OAAO;AACxC;",
6
- "names": ["import_constants", "lastSegment"]
4
+ "sourcesContent": ["import { getThemes } from '../config'\nimport { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from '../constants/constants'\nimport { getThemeUnwrapped } from '../hooks/getThemeUnwrapped'\nimport { ThemeParsed, ThemeProps } from '../types'\n\ntype ThemeListener = (name: string | null, themeManager: ThemeManager) => void\n\nexport type SetActiveThemeProps = {\n className?: string\n parentManager?: ThemeManager | null\n name?: string | null\n theme?: any\n reset?: boolean\n}\n\nexport type ThemeManagerState = {\n name: string\n theme?: ThemeParsed | null\n className?: string\n parentName?: string\n}\n\nconst emptyState: ThemeManagerState = { name: '' }\n\nexport function hasNoThemeUpdatingProps(props: ThemeProps) {\n return !props.name && !props.componentName && !props.inverse && !props.reset\n}\n\nexport class ThemeManager {\n themeListeners = new Set<ThemeListener>()\n parentManager: ThemeManager | null = null\n state: ThemeManagerState = emptyState\n\n constructor(\n public props: ThemeProps = {},\n parentManager?: ThemeManager | 'root' | null | undefined\n ) {\n if (parentManager === 'root') {\n this.updateState(props, false)\n return\n }\n if (!parentManager) {\n throw new Error(`Must set up root first`)\n }\n // no change no props\n if (hasNoThemeUpdatingProps(props)) {\n return parentManager\n }\n if (parentManager) {\n this.parentManager = parentManager\n }\n const updatedState = this.getStateIfChanged(props)\n if (updatedState) {\n this.state = updatedState\n return\n }\n return parentManager || this\n }\n\n updateState(props: ThemeProps & { forceTheme?: ThemeParsed } = this.props || {}, notify = true) {\n const shouldFlush = (() => {\n if (props.forceTheme) {\n this.state.theme = props.forceTheme\n this.state.name = props.name || ''\n return true\n }\n const nextState = this.getStateIfChanged(props)\n if (nextState) {\n this.state = nextState\n return true\n }\n })()\n if (shouldFlush) {\n // reset any derived state\n this.#allKeys = null\n notify && this.notify()\n return this.state\n }\n }\n\n getStateIfChanged(\n props = this.props,\n state: ThemeManagerState | null = this.state,\n parentManager = this.parentManager\n ) {\n const _ = this.getState(props, parentManager)\n\n // is removing\n if (state && state !== emptyState && !_) {\n return parentManager?.state\n }\n\n if (!_ || !_.theme || _.theme === state?.theme) {\n // prettier-ignore\n // eslint-disable-next-line no-console\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') console.log(`getStateIfChanged not changed`, _?.theme === state?.theme, _, state)\n return null\n }\n return _\n }\n\n getState(props = this.props, parentManager = this.parentManager) {\n return (\n getState(props, parentManager) ||\n (process.env.TAMAGUI_TARGET === 'native' ? parentManager?.state : undefined)\n )\n }\n\n #allKeys: Set<string> | null = null\n get allKeys() {\n this.#allKeys ??= new Set([\n ...(this.parentManager?.allKeys || []),\n ...Object.keys(this.state.theme || {}),\n ])\n return this.#allKeys\n }\n\n // gets value going up to parents\n getValue(key: string, state?: ThemeManagerState) {\n let theme = (state || this.state).theme\n let manager = this as ThemeManager | null\n while (theme && manager) {\n if (key in theme) {\n return theme[key]\n }\n manager = manager.parentManager\n theme = manager?.state.theme\n }\n }\n\n notify() {\n this.themeListeners.forEach((cb) => cb(this.state.name, this))\n }\n\n onChangeTheme(cb: ThemeListener) {\n this.themeListeners.add(cb)\n return () => {\n this.themeListeners.delete(cb)\n }\n }\n}\n\nfunction getNextThemeClassName(name: string, isInverting = false) {\n const next = `${THEME_CLASSNAME_PREFIX}${name}`\n if (isInverting) {\n return next\n }\n return next.replace('light_', '').replace('dark_', '')\n}\n\nfunction getState(\n props: ThemeProps,\n parentManager?: ThemeManager | null\n): ThemeManagerState | null {\n const themes = getThemes()\n\n if (props.name && props.reset) {\n throw new Error(`Cannot reset + set new name`)\n }\n if (props.reset && !parentManager?.parentManager) {\n throw new Error(`Cannot reset no grandparent exists`)\n }\n\n const nextName = props.reset ? parentManager?.parentManager?.state?.name || '' : props.name || ''\n const { componentName } = props\n const parentName = parentManager?.state?.name || ''\n\n // components look for most specific, fallback upwards\n const base = parentName.split(THEME_NAME_SEPARATOR)\n const lastSegment = base[base.length - 1]\n const isParentAComponentTheme = parentName && lastSegment[0].toUpperCase() === lastSegment[0]\n if (isParentAComponentTheme) {\n base.pop() // always remove componentName they can't nest\n }\n const parentBaseTheme = isParentAComponentTheme\n ? base.slice(0, base.length).join(THEME_NAME_SEPARATOR)\n : parentName\n const max = base.length\n const min =\n componentName && !nextName\n ? max // component name only don't search upwards\n : 0\n\n // prettier-ignore\n // eslint-disable-next-line no-console\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') [console.groupCollapsed('getState', props, { parentName, parentBaseTheme, base, min, max, isParentAComponentTheme }), console.trace(), console.groupEnd()]\n\n for (let i = max; i >= min; i--) {\n let prefix = base.slice(0, i).join(THEME_NAME_SEPARATOR)\n if (props.inverse) {\n prefix = inverseThemeName(prefix)\n }\n const potentials: string[] = []\n if (prefix && prefix !== parentBaseTheme) {\n potentials.push(prefix)\n }\n if (nextName) {\n potentials.unshift(prefix ? `${prefix}_${nextName}` : nextName)\n }\n if (i === 1) {\n const lastSegment = potentials.findIndex((x) => !x.includes('_'))\n if (lastSegment > 0) {\n potentials.splice(lastSegment, 0, nextName) // last try prefer our new name to parent\n }\n }\n if (componentName) {\n // components only look for component themes\n if (nextName) {\n potentials.push(\n `${prefix.slice(0, prefix.indexOf(THEME_NAME_SEPARATOR))}_${nextName}_${componentName}`\n )\n }\n potentials.push(`${prefix}_${componentName}`)\n if (nextName) {\n potentials.unshift(`${prefix}_${nextName}_${componentName}`)\n }\n }\n\n // prettier-ignore\n // eslint-disable-next-line no-console\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') console.log('getState potentials', potentials)\n\n const found = potentials.find((t) => t in themes)\n if (found) {\n // optimization return null if not changed\n if (found === parentName) {\n return null\n }\n const theme = themes[found]\n return {\n // need to put concurrent safe things here\n name: found,\n theme: getThemeUnwrapped(theme),\n className: getNextThemeClassName(found, props.inverse),\n parentName,\n }\n }\n }\n\n return null\n}\n\nconst inverseThemeName = (themeName: string) => {\n return themeName.startsWith('light')\n ? themeName.replace(/^light/, 'dark')\n : themeName.replace(/^dark/, 'light')\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA0B;AAC1B,uBAA6D;AAC7D,+BAAkC;AAFlC;AAsBA,MAAM,aAAgC,EAAE,MAAM,GAAG;AAE1C,SAAS,wBAAwB,OAAmB;AACzD,SAAO,CAAC,MAAM,QAAQ,CAAC,MAAM,iBAAiB,CAAC,MAAM,WAAW,CAAC,MAAM;AACzE;AAEO,MAAM,aAAa;AAAA,EAKxB,YACS,QAAoB,CAAC,GAC5B,eACA;AAFO;AALT,0BAAiB,oBAAI,IAAmB;AACxC,yBAAqC;AACrC,iBAA2B;AA6E3B,iCAA+B;AAvE7B,QAAI,kBAAkB,QAAQ;AAC5B,WAAK,YAAY,OAAO,KAAK;AAC7B;AAAA,IACF;AACA,QAAI,CAAC,eAAe;AAClB,YAAM,IAAI,MAAM,wBAAwB;AAAA,IAC1C;AAEA,QAAI,wBAAwB,KAAK,GAAG;AAClC,aAAO;AAAA,IACT;AACA,QAAI,eAAe;AACjB,WAAK,gBAAgB;AAAA,IACvB;AACA,UAAM,eAAe,KAAK,kBAAkB,KAAK;AACjD,QAAI,cAAc;AAChB,W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,IAAI,aAAa,iBAAiB,MAAM,UAAU;AAAW,cAAQ,IAAI,uBAAuB,UAAU;AAEtH,UAAM,QAAQ,WAAW,KAAK,CAAC,MAAM,KAAK,MAAM;AAChD,QAAI,OAAO;AAET,UAAI,UAAU,YAAY;AACxB,eAAO;AAAA,MACT;AACA,YAAM,QAAQ,OAAO;AACrB,aAAO;AAAA,QAEL,MAAM;AAAA,QACN,WAAO,4CAAkB,KAAK;AAAA,QAC9B,WAAW,sBAAsB,OAAO,MAAM,OAAO;AAAA,QACrD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEA,MAAM,mBAAmB,CAAC,cAAsB;AAC9C,SAAO,UAAU,WAAW,OAAO,IAC/B,UAAU,QAAQ,UAAU,MAAM,IAClC,UAAU,QAAQ,SAAS,OAAO;AACxC;",
6
+ "names": ["lastSegment"]
7
7
  }
@@ -445,5 +445,21 @@ const conf = (0, import_config_default_node.getDefaultTamaguiConfig)();
445
445
  );
446
446
  (0, import_vitest.expect)(child.state.name).toBe("dark_yellow_Button");
447
447
  });
448
+ (0, import_vitest.test)(`Component name + name finds one up when component name missing`, () => {
449
+ const parent = new import_ThemeManager.ThemeManager(
450
+ {
451
+ name: "dark_red_alt1"
452
+ },
453
+ "root"
454
+ );
455
+ const child = new import_ThemeManager.ThemeManager(
456
+ {
457
+ name: "alt2",
458
+ componentName: "Missing"
459
+ },
460
+ parent
461
+ );
462
+ (0, import_vitest.expect)(child.state.name).toBe("dark_red_alt2");
463
+ });
448
464
  });
449
465
  //# sourceMappingURL=ThemeManager.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/helpers/ThemeManager.test.tsx"],
4
- "sourcesContent": ["import { getDefaultTamaguiConfig } from '@tamagui/config-default-node'\nimport { beforeAll, describe, expect, test } from 'vitest'\n\nimport { createTamagui } from '../createTamagui'\nimport { ThemeManager } from './ThemeManager'\n\nconst conf = getDefaultTamaguiConfig()\n\ndescribe('ThemeManager', () => {\n beforeAll(() => {\n createTamagui(conf)\n })\n\n test('Changes theme to dark', () => {\n const manager = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n expect(manager.state.name).toBe('dark')\n })\n\n test('Given parent theme \"dark\" and child theme \"red\" to return theme \"dark_red\"', () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'red',\n },\n parent\n )\n expect(parent.state.name).toBe('dark')\n expect(child.state.name).toBe('dark_red')\n })\n\n test('Given parent theme \"dark\", child theme \"red_alt2\" and component \"Button\" returns \"dark_red_alt2_Button\"', () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const child1 = new ThemeManager(\n {\n name: 'red',\n },\n parent\n )\n expect(child1.state.name).toBe('dark_red')\n const child2 = new ThemeManager(\n {\n name: 'alt2',\n componentName: 'Button',\n },\n child1\n )\n expect(child2.state.name).toBe('dark_red_alt2_Button')\n })\n\n test('Given parent theme \"dark\", child theme \"red\" and component \"Button\" returns \"dark_red_Button\"', () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const child1 = new ThemeManager(\n {\n name: 'red',\n },\n parent\n )\n expect(child1.state.name).toBe('dark_red')\n const child2 = new ThemeManager(\n {\n componentName: 'Button',\n },\n child1\n )\n expect(child2.state.name).toBe('dark_red_Button')\n })\n\n test('Given parent theme \"dark\", child theme \"red\" and missing component \"Card\" returns \"dark_red\"', () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const child1 = new ThemeManager(\n {\n name: 'red',\n },\n parent\n )\n expect(child1.state.name).toBe('dark_red')\n const child2 = new ThemeManager(\n {\n componentName: 'Card',\n },\n child1\n )\n expect(child2.state.name).toBe('dark_red')\n })\n\n test('Changes \"light\" to \"dark\"', () => {\n const parent = new ThemeManager(\n {\n name: 'light',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'dark',\n },\n parent\n )\n expect(parent.state.name).toBe('light')\n expect(child.state.name).toBe('dark')\n })\n\n test('Inverts \"light\" to \"dark\"', () => {\n const parent = new ThemeManager(\n {\n name: 'light',\n },\n 'root'\n )\n const child1 = new ThemeManager(\n {\n inverse: true,\n },\n parent\n )\n expect(child1.state.name).toBe('dark')\n })\n\n test('Inverts \"light_red\" to \"dark_red\"', () => {\n const parent = new ThemeManager(\n {\n name: 'light',\n },\n 'root'\n )\n const child1 = new ThemeManager(\n {\n name: 'red',\n inverse: true,\n },\n parent\n )\n expect(child1.state.name).toBe('dark_red')\n })\n\n test('Updates state', () => {\n const parent = new ThemeManager(\n {\n name: 'light',\n },\n 'root'\n )\n const newState = parent.updateState({\n name: 'dark',\n })\n expect(newState).toMatchInlineSnapshot(`\n {\n \"className\": \"t_dark\",\n \"name\": \"dark\",\n \"parentName\": \"\",\n \"theme\": {\n \"background\": {\n \"isVar\": true,\n \"key\": \"color-2\",\n \"name\": \"background\",\n \"val\": \"#000\",\n \"variable\": \"\",\n },\n \"color\": {\n \"isVar\": true,\n \"key\": \"color-1\",\n \"name\": \"color\",\n \"val\": \"#fff\",\n \"variable\": \"\",\n },\n },\n }\n `)\n expect(parent.state.name).toBe('dark')\n })\n\n test('Returns parent on empty', () => {\n const parent = new ThemeManager(\n {\n name: 'light',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: null,\n },\n parent\n )\n expect(child).toBe(parent)\n })\n\n test('Resets theme', () => {\n const parent = new ThemeManager(\n {\n name: 'light',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'dark',\n },\n parent\n )\n expect(child.state.name).toBe('dark')\n expect(child.parentManager).toBe(parent)\n const child2 = new ThemeManager(\n {\n reset: true,\n },\n child\n )\n expect(child2.parentManager).toBe(child)\n expect(child2.state.name).toBe('light')\n })\n\n test('Nested invert and reset', () => {\n const parent = new ThemeManager(\n {\n name: 'light',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'dark',\n },\n parent\n )\n const child2 = new ThemeManager(\n {\n reset: true,\n },\n child\n )\n const child3 = new ThemeManager(\n {\n inverse: true,\n },\n child2\n )\n expect(child3.state.name).toBe('dark')\n })\n\n test('Updates from null the new theme nested 3 themes', () => {\n const a = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const b = new ThemeManager(\n {\n name: 'red',\n },\n a\n )\n expect(b.state.name).toBe('dark_red')\n const c = new ThemeManager(\n {\n name: 'alt2',\n },\n b\n )\n expect(c.state.name).toBe('dark_red_alt2')\n })\n\n test('Ignored dup themes', () => {\n const a = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const b = new ThemeManager(\n {\n name: 'dark',\n },\n a\n )\n expect(b === a).toBe(true)\n })\n\n test('Nested component themes fallback to grandparents', () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'red',\n componentName: 'Button',\n },\n parent\n )\n const child2 = new ThemeManager(\n {\n name: 'blue',\n },\n child\n )\n expect(child2.state.name).toBe('dark_blue')\n const child3 = new ThemeManager(\n {\n componentName: 'Button',\n },\n child2\n )\n expect(child3.state.name).toBe('dark_blue_Button')\n })\n\n test(`Component theme with sub component that doesn't exist keeps same theme`, () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'red',\n componentName: 'Button',\n },\n parent\n )\n const child2 = new ThemeManager(\n {\n componentName: 'Spacer',\n },\n child\n )\n expect(child2).toBe(child)\n })\n\n test(`Doesn't find invalid parent when only passing component`, () => {\n expect(!!conf.themes['dark_Card']).toBeTruthy()\n\n const parent = new ThemeManager(\n {\n name: 'dark_red',\n },\n 'root'\n )\n\n const child = new ThemeManager(\n {\n componentName: 'Card',\n },\n parent\n )\n\n // dont find dark_Card because dark_red is highest it should climb\n expect(child.state.name).toBe(parent.state.name)\n })\n\n test(`Finds sub-theme when componentName and name are passed but componentName doesn't exist`, () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n\n const child = new ThemeManager(\n {\n name: 'red',\n componentName: 'Missing',\n },\n parent\n )\n\n // dont find dark_Card because dark_red is highest it should climb\n expect(child.state.name).toBe('dark_red')\n })\n\n test(`Uses the full className without the light/dark prefix`, () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'red_alt2',\n },\n parent\n )\n expect(child.state.className).toBe('t_red_alt2')\n\n const child2 = new ThemeManager(\n {\n name: 'red',\n },\n parent\n )\n const child3 = new ThemeManager(\n {\n name: 'alt2',\n },\n child2\n )\n expect(child3.state.className).toBe('t_red_alt2')\n })\n\n test(`Finds component dark_red + Button`, () => {\n const parent = new ThemeManager(\n {\n name: 'dark_red',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'dark_red',\n componentName: 'Button',\n },\n parent\n )\n expect(child.state.className).toBe('t_red_Button')\n expect(child.state.name).toBe('dark_red_Button')\n })\n\n test(`Drops componentName if only regular name found at stronger level`, () => {\n const parent = new ThemeManager(\n {\n name: 'dark_red',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'alt1',\n componentName: 'Button',\n },\n parent\n )\n expect(child.state.name).toBe('dark_red_alt1')\n })\n\n test(`Component name + theme change when nested already`, () => {\n const parent = new ThemeManager(\n {\n name: 'dark_red',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'yellow',\n componentName: 'Button',\n },\n parent\n )\n expect(child.state.name).toBe('dark_yellow_Button')\n })\n})\n"],
5
- "mappings": ";AAAA,iCAAwC;AACxC,oBAAkD;AAElD,2BAA8B;AAC9B,0BAA6B;AAE7B,MAAM,WAAO,oDAAwB;AAAA,IAErC,wBAAS,gBAAgB,MAAM;AAC7B,+BAAU,MAAM;AACd,4CAAc,IAAI;AAAA,EACpB,CAAC;AAED,0BAAK,yBAAyB,MAAM;AAClC,UAAM,UAAU,IAAI;AAAA,MAClB;AAAA,QACE,MAAM;AAAA,MACR;AA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AA,MACA;AAAA,IACF;AACA,UAAM,QAAQ,IAAI;AAAA,MAChB;AAAA,QACE,MAAM;AAAA,QACN,eAAe;AAAA,MACjB;AAAA,MACA;AAAA,IACF;AACA,8BAAO,MAAM,MAAM,IAAI,EAAE,KAAK,oBAAoB;AAAA,EACpD,CAAC;AACH,CAAC;",
4
+ "sourcesContent": ["import { getDefaultTamaguiConfig } from '@tamagui/config-default-node'\nimport { beforeAll, describe, expect, test } from 'vitest'\n\nimport { createTamagui } from '../createTamagui'\nimport { ThemeManager } from './ThemeManager'\n\nconst conf = getDefaultTamaguiConfig()\n\ndescribe('ThemeManager', () => {\n beforeAll(() => {\n createTamagui(conf)\n })\n\n test('Changes theme to dark', () => {\n const manager = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n expect(manager.state.name).toBe('dark')\n })\n\n test('Given parent theme \"dark\" and child theme \"red\" to return theme \"dark_red\"', () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'red',\n },\n parent\n )\n expect(parent.state.name).toBe('dark')\n expect(child.state.name).toBe('dark_red')\n })\n\n test('Given parent theme \"dark\", child theme \"red_alt2\" and component \"Button\" returns \"dark_red_alt2_Button\"', () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const child1 = new ThemeManager(\n {\n name: 'red',\n },\n parent\n )\n expect(child1.state.name).toBe('dark_red')\n const child2 = new ThemeManager(\n {\n name: 'alt2',\n componentName: 'Button',\n },\n child1\n )\n expect(child2.state.name).toBe('dark_red_alt2_Button')\n })\n\n test('Given parent theme \"dark\", child theme \"red\" and component \"Button\" returns \"dark_red_Button\"', () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const child1 = new ThemeManager(\n {\n name: 'red',\n },\n parent\n )\n expect(child1.state.name).toBe('dark_red')\n const child2 = new ThemeManager(\n {\n componentName: 'Button',\n },\n child1\n )\n expect(child2.state.name).toBe('dark_red_Button')\n })\n\n test('Given parent theme \"dark\", child theme \"red\" and missing component \"Card\" returns \"dark_red\"', () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const child1 = new ThemeManager(\n {\n name: 'red',\n },\n parent\n )\n expect(child1.state.name).toBe('dark_red')\n const child2 = new ThemeManager(\n {\n componentName: 'Card',\n },\n child1\n )\n expect(child2.state.name).toBe('dark_red')\n })\n\n test('Changes \"light\" to \"dark\"', () => {\n const parent = new ThemeManager(\n {\n name: 'light',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'dark',\n },\n parent\n )\n expect(parent.state.name).toBe('light')\n expect(child.state.name).toBe('dark')\n })\n\n test('Inverts \"light\" to \"dark\"', () => {\n const parent = new ThemeManager(\n {\n name: 'light',\n },\n 'root'\n )\n const child1 = new ThemeManager(\n {\n inverse: true,\n },\n parent\n )\n expect(child1.state.name).toBe('dark')\n })\n\n test('Inverts \"light_red\" to \"dark_red\"', () => {\n const parent = new ThemeManager(\n {\n name: 'light',\n },\n 'root'\n )\n const child1 = new ThemeManager(\n {\n name: 'red',\n inverse: true,\n },\n parent\n )\n expect(child1.state.name).toBe('dark_red')\n })\n\n test('Updates state', () => {\n const parent = new ThemeManager(\n {\n name: 'light',\n },\n 'root'\n )\n const newState = parent.updateState({\n name: 'dark',\n })\n expect(newState).toMatchInlineSnapshot(`\n {\n \"className\": \"t_dark\",\n \"name\": \"dark\",\n \"parentName\": \"\",\n \"theme\": {\n \"background\": {\n \"isVar\": true,\n \"key\": \"color-2\",\n \"name\": \"background\",\n \"val\": \"#000\",\n \"variable\": \"\",\n },\n \"color\": {\n \"isVar\": true,\n \"key\": \"color-1\",\n \"name\": \"color\",\n \"val\": \"#fff\",\n \"variable\": \"\",\n },\n },\n }\n `)\n expect(parent.state.name).toBe('dark')\n })\n\n test('Returns parent on empty', () => {\n const parent = new ThemeManager(\n {\n name: 'light',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: null,\n },\n parent\n )\n expect(child).toBe(parent)\n })\n\n test('Resets theme', () => {\n const parent = new ThemeManager(\n {\n name: 'light',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'dark',\n },\n parent\n )\n expect(child.state.name).toBe('dark')\n expect(child.parentManager).toBe(parent)\n const child2 = new ThemeManager(\n {\n reset: true,\n },\n child\n )\n expect(child2.parentManager).toBe(child)\n expect(child2.state.name).toBe('light')\n })\n\n test('Nested invert and reset', () => {\n const parent = new ThemeManager(\n {\n name: 'light',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'dark',\n },\n parent\n )\n const child2 = new ThemeManager(\n {\n reset: true,\n },\n child\n )\n const child3 = new ThemeManager(\n {\n inverse: true,\n },\n child2\n )\n expect(child3.state.name).toBe('dark')\n })\n\n test('Updates from null the new theme nested 3 themes', () => {\n const a = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const b = new ThemeManager(\n {\n name: 'red',\n },\n a\n )\n expect(b.state.name).toBe('dark_red')\n const c = new ThemeManager(\n {\n name: 'alt2',\n },\n b\n )\n expect(c.state.name).toBe('dark_red_alt2')\n })\n\n test('Ignored dup themes', () => {\n const a = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const b = new ThemeManager(\n {\n name: 'dark',\n },\n a\n )\n expect(b === a).toBe(true)\n })\n\n test('Nested component themes fallback to grandparents', () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'red',\n componentName: 'Button',\n },\n parent\n )\n const child2 = new ThemeManager(\n {\n name: 'blue',\n },\n child\n )\n expect(child2.state.name).toBe('dark_blue')\n const child3 = new ThemeManager(\n {\n componentName: 'Button',\n },\n child2\n )\n expect(child3.state.name).toBe('dark_blue_Button')\n })\n\n test(`Component theme with sub component that doesn't exist keeps same theme`, () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'red',\n componentName: 'Button',\n },\n parent\n )\n const child2 = new ThemeManager(\n {\n componentName: 'Spacer',\n },\n child\n )\n expect(child2).toBe(child)\n })\n\n test(`Doesn't find invalid parent when only passing component`, () => {\n expect(!!conf.themes['dark_Card']).toBeTruthy()\n\n const parent = new ThemeManager(\n {\n name: 'dark_red',\n },\n 'root'\n )\n\n const child = new ThemeManager(\n {\n componentName: 'Card',\n },\n parent\n )\n\n // dont find dark_Card because dark_red is highest it should climb\n expect(child.state.name).toBe(parent.state.name)\n })\n\n test(`Finds sub-theme when componentName and name are passed but componentName doesn't exist`, () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n\n const child = new ThemeManager(\n {\n name: 'red',\n componentName: 'Missing',\n },\n parent\n )\n\n // dont find dark_Card because dark_red is highest it should climb\n expect(child.state.name).toBe('dark_red')\n })\n\n test(`Uses the full className without the light/dark prefix`, () => {\n const parent = new ThemeManager(\n {\n name: 'dark',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'red_alt2',\n },\n parent\n )\n expect(child.state.className).toBe('t_red_alt2')\n\n const child2 = new ThemeManager(\n {\n name: 'red',\n },\n parent\n )\n const child3 = new ThemeManager(\n {\n name: 'alt2',\n },\n child2\n )\n expect(child3.state.className).toBe('t_red_alt2')\n })\n\n test(`Finds component dark_red + Button`, () => {\n const parent = new ThemeManager(\n {\n name: 'dark_red',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'dark_red',\n componentName: 'Button',\n },\n parent\n )\n expect(child.state.className).toBe('t_red_Button')\n expect(child.state.name).toBe('dark_red_Button')\n })\n\n test(`Drops componentName if only regular name found at stronger level`, () => {\n const parent = new ThemeManager(\n {\n name: 'dark_red',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'alt1',\n componentName: 'Button',\n },\n parent\n )\n expect(child.state.name).toBe('dark_red_alt1')\n })\n\n test(`Component name + theme change when nested already`, () => {\n const parent = new ThemeManager(\n {\n name: 'dark_red',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'yellow',\n componentName: 'Button',\n },\n parent\n )\n expect(child.state.name).toBe('dark_yellow_Button')\n })\n\n test(`Component name + name finds one up when component name missing`, () => {\n const parent = new ThemeManager(\n {\n name: 'dark_red_alt1',\n },\n 'root'\n )\n const child = new ThemeManager(\n {\n name: 'alt2',\n componentName: 'Missing',\n },\n parent\n )\n expect(child.state.name).toBe('dark_red_alt2')\n })\n})\n"],
5
+ "mappings": ";AAAA,iCAAwC;AACxC,oBAAkD;AAElD,2BAA8B;AAC9B,0BAA6B;AAE7B,MAAM,WAAO,oDAAwB;AAAA,IAErC,wBAAS,gBAAgB,MAAM;AAC7B,+BAAU,MAAM;AACd,4CAAc,IAAI;AAAA,EACpB,CAAC;AAED,0BAAK,yBAAyB,MAAM;AAClC,UAAM,UAAU,IAAI;AAAA,MAClB;AAAA,QACE,MAAM;AAAA,MACR;AAAA,MACA;AAAA,IACF;AACA,8BAAO,QAAQ,MAAM,IAAI,EAAE,KAAK,MAAM;AAAA,EACxC,CAAC;AAED,0BAAK,8EAA8E,MAAM;AACvF,UAAM,SAAS,IAAI;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,MACR;AAAA,MACA;AAAA,IACF;AACA,UAAM,QAAQ,IAAI;AAAA,MAChB;AAAA,QACE,MAAM;AAAA,MACR;AAAA,MACA;AAAA,IACF;AACA,8BAAO,OAAO,MAAM,IAAI,EAAE,KAAK,MAAM;AACrC,8BAAO,MAAM,MAAM,IAAI,EAAE,KAAK,UAAU;AAAA,EAC1C,CAAC;AAED,0BAAK,2GAA2G,MAAM;AACpH,UAAM,SAAS,IAAI;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,MACR;AAAA,MACA;AAAA,IACF;AACA,UAAM,SAAS,IAAI;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,MACR;AAAA,MACA;AAAA,IACF;AACA,8BAAO,OAAO,MAAM,IAAI,EAAE,KAAK,UAAU;AACzC,UAAM,SAAS,IAAI;AAAA,MACjB;AA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M;AAAA,QACN,eAAe;AAAA,MACjB;AAAA,MACA;AAAA,IACF;AACA,8BAAO,MAAM,MAAM,SAAS,EAAE,KAAK,cAAc;AACjD,8BAAO,MAAM,MAAM,IAAI,EAAE,KAAK,iBAAiB;AAAA,EACjD,CAAC;AAED,0BAAK,oEAAoE,MAAM;AAC7E,UAAM,SAAS,IAAI;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,MACR;AAAA,MACA;AAAA,IACF;AACA,UAAM,QAAQ,IAAI;AAAA,MAChB;AAAA,QACE,MAAM;AAAA,QACN,eAAe;AAAA,MACjB;AAAA,MACA;AAAA,IACF;AACA,8BAAO,MAAM,MAAM,IAAI,EAAE,KAAK,eAAe;AAAA,EAC/C,CAAC;AAED,0BAAK,qDAAqD,MAAM;AAC9D,UAAM,SAAS,IAAI;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,MACR;AAAA,MACA;AAAA,IACF;AACA,UAAM,QAAQ,IAAI;AAAA,MAChB;AAAA,QACE,MAAM;AAAA,QACN,eAAe;AAAA,MACjB;AAAA,MACA;AAAA,IACF;AACA,8BAAO,MAAM,MAAM,IAAI,EAAE,KAAK,oBAAoB;AAAA,EACpD,CAAC;AAED,0BAAK,kEAAkE,MAAM;AAC3E,UAAM,SAAS,IAAI;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,MACR;AAAA,MACA;AAAA,IACF;AACA,UAAM,QAAQ,IAAI;AAAA,MAChB;AAAA,QACE,MAAM;AAAA,QACN,eAAe;AAAA,MACjB;AAAA,MACA;AAAA,IACF;AACA,8BAAO,MAAM,MAAM,IAAI,EAAE,KAAK,eAAe;AAAA,EAC/C,CAAC;AACH,CAAC;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var assignNativePropsToWeb_exports = {};
20
+ __export(assignNativePropsToWeb_exports, {
21
+ assignNativePropsToWeb: () => assignNativePropsToWeb
22
+ });
23
+ module.exports = __toCommonJS(assignNativePropsToWeb_exports);
24
+ var import_createComponent = require("../createComponent");
25
+ function assignNativePropsToWeb(elementType, viewProps, nativeProps) {
26
+ if (!viewProps.role && nativeProps.accessibilityRole) {
27
+ if (nativeProps.accessibilityRole === "none") {
28
+ viewProps.role = "presentation";
29
+ } else {
30
+ const webRole = import_createComponent.accessibilityRoleToWebRole[nativeProps.accessibilityRole];
31
+ if (webRole != null) {
32
+ viewProps.role = webRole || nativeProps.accessibilityRole;
33
+ }
34
+ }
35
+ }
36
+ if (nativeProps.accessibilityActiveDescendant != null) {
37
+ viewProps["aria-activedescendant"] = nativeProps.accessibilityActiveDescendant;
38
+ }
39
+ if (nativeProps.accessibilityAtomic != null) {
40
+ viewProps["aria-atomic"] = nativeProps.accessibilityAtomic;
41
+ }
42
+ if (nativeProps.accessibilityAutoComplete != null) {
43
+ viewProps["aria-autocomplete"] = nativeProps.accessibilityAutoComplete;
44
+ }
45
+ if (nativeProps.accessibilityBusy != null) {
46
+ viewProps["aria-busy"] = nativeProps.accessibilityBusy;
47
+ }
48
+ if (nativeProps.accessibilityChecked != null) {
49
+ viewProps["aria-checked"] = nativeProps.accessibilityChecked;
50
+ }
51
+ if (nativeProps.accessibilityColumnCount != null) {
52
+ viewProps["aria-colcount"] = nativeProps.accessibilityColumnCount;
53
+ }
54
+ if (nativeProps.accessibilityColumnIndex != null) {
55
+ viewProps["aria-colindex"] = nativeProps.accessibilityColumnIndex;
56
+ }
57
+ if (nativeProps.accessibilityColumnSpan != null) {
58
+ viewProps["aria-colspan"] = nativeProps.accessibilityColumnSpan;
59
+ }
60
+ if (nativeProps.accessibilityControls != null) {
61
+ viewProps["aria-controls"] = (0, import_createComponent.processIDRefList)(nativeProps.accessibilityControls);
62
+ }
63
+ if (nativeProps.accessibilityCurrent != null) {
64
+ viewProps["aria-current"] = nativeProps.accessibilityCurrent;
65
+ }
66
+ if (nativeProps.accessibilityDescribedBy != null) {
67
+ viewProps["aria-describedby"] = (0, import_createComponent.processIDRefList)(nativeProps.accessibilityDescribedBy);
68
+ }
69
+ if (nativeProps.accessibilityDetails != null) {
70
+ viewProps["aria-details"] = nativeProps.accessibilityDetails;
71
+ }
72
+ if (nativeProps.disabled === true) {
73
+ viewProps["aria-disabled"] = true;
74
+ if (elementType === "button" || elementType === "form" || elementType === "input" || elementType === "select" || elementType === "textarea") {
75
+ viewProps.disabled = true;
76
+ }
77
+ }
78
+ if (nativeProps.accessibilityErrorMessage != null) {
79
+ viewProps["aria-errormessage"] = nativeProps.accessibilityErrorMessage;
80
+ }
81
+ if (nativeProps.accessibilityExpanded != null) {
82
+ viewProps["aria-expanded"] = nativeProps.accessibilityExpanded;
83
+ }
84
+ if (nativeProps.accessibilityFlowTo != null) {
85
+ viewProps["aria-flowto"] = (0, import_createComponent.processIDRefList)(nativeProps.accessibilityFlowTo);
86
+ }
87
+ if (nativeProps.accessibilityHasPopup != null) {
88
+ viewProps["aria-haspopup"] = nativeProps.accessibilityHasPopup;
89
+ }
90
+ if (nativeProps.accessibilityHidden === true) {
91
+ viewProps["aria-hidden"] = nativeProps.accessibilityHidden;
92
+ }
93
+ if (nativeProps.accessibilityInvalid != null) {
94
+ viewProps["aria-invalid"] = nativeProps.accessibilityInvalid;
95
+ }
96
+ if (nativeProps.accessibilityKeyShortcuts != null && Array.isArray(nativeProps.accessibilityKeyShortcuts)) {
97
+ viewProps["aria-keyshortcuts"] = nativeProps.accessibilityKeyShortcuts.join(" ");
98
+ }
99
+ if (nativeProps.accessibilityLabel != null) {
100
+ viewProps["aria-label"] = nativeProps.accessibilityLabel;
101
+ }
102
+ if (nativeProps.accessibilityLabelledBy != null) {
103
+ viewProps["aria-labelledby"] = (0, import_createComponent.processIDRefList)(nativeProps.accessibilityLabelledBy);
104
+ }
105
+ if (nativeProps.accessibilityLevel != null) {
106
+ viewProps["aria-level"] = nativeProps.accessibilityLevel;
107
+ }
108
+ if (nativeProps.accessibilityLiveRegion != null) {
109
+ viewProps["aria-live"] = nativeProps.accessibilityLiveRegion === "none" ? "off" : nativeProps.accessibilityLiveRegion;
110
+ }
111
+ if (nativeProps.accessibilityModal != null) {
112
+ viewProps["aria-modal"] = nativeProps.accessibilityModal;
113
+ }
114
+ if (nativeProps.accessibilityMultiline != null) {
115
+ viewProps["aria-multiline"] = nativeProps.accessibilityMultiline;
116
+ }
117
+ if (nativeProps.accessibilityMultiSelectable != null) {
118
+ viewProps["aria-multiselectable"] = nativeProps.accessibilityMultiSelectable;
119
+ }
120
+ if (nativeProps.accessibilityOrientation != null) {
121
+ viewProps["aria-orientation"] = nativeProps.accessibilityOrientation;
122
+ }
123
+ if (nativeProps.accessibilityOwns != null) {
124
+ viewProps["aria-owns"] = (0, import_createComponent.processIDRefList)(nativeProps.accessibilityOwns);
125
+ }
126
+ if (nativeProps.accessibilityPlaceholder != null) {
127
+ viewProps["aria-placeholder"] = nativeProps.accessibilityPlaceholder;
128
+ }
129
+ if (nativeProps.accessibilityPosInSet != null) {
130
+ viewProps["aria-posinset"] = nativeProps.accessibilityPosInSet;
131
+ }
132
+ if (nativeProps.accessibilityPressed != null) {
133
+ viewProps["aria-pressed"] = nativeProps.accessibilityPressed;
134
+ }
135
+ if (nativeProps.accessibilityReadOnly != null) {
136
+ viewProps["aria-readonly"] = nativeProps.accessibilityReadOnly;
137
+ if (elementType === "input" || elementType === "select" || elementType === "textarea") {
138
+ viewProps.readOnly = true;
139
+ }
140
+ }
141
+ if (nativeProps.accessibilityRequired != null) {
142
+ viewProps["aria-required"] = nativeProps.accessibilityRequired;
143
+ if (elementType === "input" || elementType === "select" || elementType === "textarea") {
144
+ viewProps.required = true;
145
+ }
146
+ }
147
+ if (nativeProps.accessibilityRoleDescription != null) {
148
+ viewProps["aria-roledescription"] = nativeProps.accessibilityRoleDescription;
149
+ }
150
+ if (nativeProps.accessibilityRowCount != null) {
151
+ viewProps["aria-rowcount"] = nativeProps.accessibilityRowCount;
152
+ }
153
+ if (nativeProps.accessibilityRowIndex != null) {
154
+ viewProps["aria-rowindex"] = nativeProps.accessibilityRowIndex;
155
+ }
156
+ if (nativeProps.accessibilityRowSpan != null) {
157
+ viewProps["aria-rowspan"] = nativeProps.accessibilityRowSpan;
158
+ }
159
+ if (nativeProps.accessibilitySelected != null) {
160
+ viewProps["aria-selected"] = nativeProps.accessibilitySelected;
161
+ }
162
+ if (nativeProps.accessibilitySetSize != null) {
163
+ viewProps["aria-setsize"] = nativeProps.accessibilitySetSize;
164
+ }
165
+ if (nativeProps.accessibilitySort != null) {
166
+ viewProps["aria-sort"] = nativeProps.accessibilitySort;
167
+ }
168
+ if (nativeProps.accessibilityValueMax != null) {
169
+ viewProps["aria-valuemax"] = nativeProps.accessibilityValueMax;
170
+ }
171
+ if (nativeProps.accessibilityValueMin != null) {
172
+ viewProps["aria-valuemin"] = nativeProps.accessibilityValueMin;
173
+ }
174
+ if (nativeProps.accessibilityValueNow != null) {
175
+ viewProps["aria-valuenow"] = nativeProps.accessibilityValueNow;
176
+ }
177
+ if (nativeProps.accessibilityValueText != null) {
178
+ viewProps["aria-valuetext"] = nativeProps.accessibilityValueText;
179
+ }
180
+ if (nativeProps.nativeID) {
181
+ viewProps.id = nativeProps.nativeID;
182
+ }
183
+ }
184
+ // Annotate the CommonJS export names for ESM import in node:
185
+ 0 && (module.exports = {
186
+ assignNativePropsToWeb
187
+ });
188
+ //# sourceMappingURL=assignNativePropsToWeb.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/helpers/assignNativePropsToWeb.tsx"],
4
+ "sourcesContent": ["import { accessibilityRoleToWebRole, processIDRefList } from '../createComponent'\n\n// adapted from react-native-web\n\nexport function assignNativePropsToWeb(elementType: string, viewProps: any, nativeProps: any) {\n if (!viewProps.role && nativeProps.accessibilityRole) {\n if (nativeProps.accessibilityRole === 'none') {\n viewProps.role = 'presentation'\n } else {\n const webRole = accessibilityRoleToWebRole[nativeProps.accessibilityRole]\n if (webRole != null) {\n viewProps.role = webRole || nativeProps.accessibilityRole\n }\n }\n }\n\n if (nativeProps.accessibilityActiveDescendant != null) {\n viewProps['aria-activedescendant'] = nativeProps.accessibilityActiveDescendant\n }\n if (nativeProps.accessibilityAtomic != null) {\n viewProps['aria-atomic'] = nativeProps.accessibilityAtomic\n }\n if (nativeProps.accessibilityAutoComplete != null) {\n viewProps['aria-autocomplete'] = nativeProps.accessibilityAutoComplete\n }\n if (nativeProps.accessibilityBusy != null) {\n viewProps['aria-busy'] = nativeProps.accessibilityBusy\n }\n if (nativeProps.accessibilityChecked != null) {\n viewProps['aria-checked'] = nativeProps.accessibilityChecked\n }\n if (nativeProps.accessibilityColumnCount != null) {\n viewProps['aria-colcount'] = nativeProps.accessibilityColumnCount\n }\n if (nativeProps.accessibilityColumnIndex != null) {\n viewProps['aria-colindex'] = nativeProps.accessibilityColumnIndex\n }\n if (nativeProps.accessibilityColumnSpan != null) {\n viewProps['aria-colspan'] = nativeProps.accessibilityColumnSpan\n }\n if (nativeProps.accessibilityControls != null) {\n viewProps['aria-controls'] = processIDRefList(nativeProps.accessibilityControls)\n }\n if (nativeProps.accessibilityCurrent != null) {\n viewProps['aria-current'] = nativeProps.accessibilityCurrent\n }\n if (nativeProps.accessibilityDescribedBy != null) {\n viewProps['aria-describedby'] = processIDRefList(nativeProps.accessibilityDescribedBy)\n }\n if (nativeProps.accessibilityDetails != null) {\n viewProps['aria-details'] = nativeProps.accessibilityDetails\n }\n if (nativeProps.disabled === true) {\n viewProps['aria-disabled'] = true\n // Enhance with native semantics\n if (\n elementType === 'button' ||\n elementType === 'form' ||\n elementType === 'input' ||\n elementType === 'select' ||\n elementType === 'textarea'\n ) {\n viewProps.disabled = true\n }\n }\n if (nativeProps.accessibilityErrorMessage != null) {\n viewProps['aria-errormessage'] = nativeProps.accessibilityErrorMessage\n }\n if (nativeProps.accessibilityExpanded != null) {\n viewProps['aria-expanded'] = nativeProps.accessibilityExpanded\n }\n if (nativeProps.accessibilityFlowTo != null) {\n viewProps['aria-flowto'] = processIDRefList(nativeProps.accessibilityFlowTo)\n }\n if (nativeProps.accessibilityHasPopup != null) {\n viewProps['aria-haspopup'] = nativeProps.accessibilityHasPopup\n }\n if (nativeProps.accessibilityHidden === true) {\n viewProps['aria-hidden'] = nativeProps.accessibilityHidden\n }\n if (nativeProps.accessibilityInvalid != null) {\n viewProps['aria-invalid'] = nativeProps.accessibilityInvalid\n }\n if (\n nativeProps.accessibilityKeyShortcuts != null &&\n Array.isArray(nativeProps.accessibilityKeyShortcuts)\n ) {\n viewProps['aria-keyshortcuts'] = nativeProps.accessibilityKeyShortcuts.join(' ')\n }\n if (nativeProps.accessibilityLabel != null) {\n viewProps['aria-label'] = nativeProps.accessibilityLabel\n }\n if (nativeProps.accessibilityLabelledBy != null) {\n viewProps['aria-labelledby'] = processIDRefList(nativeProps.accessibilityLabelledBy)\n }\n if (nativeProps.accessibilityLevel != null) {\n viewProps['aria-level'] = nativeProps.accessibilityLevel\n }\n if (nativeProps.accessibilityLiveRegion != null) {\n viewProps['aria-live'] =\n nativeProps.accessibilityLiveRegion === 'none' ? 'off' : nativeProps.accessibilityLiveRegion\n }\n if (nativeProps.accessibilityModal != null) {\n viewProps['aria-modal'] = nativeProps.accessibilityModal\n }\n if (nativeProps.accessibilityMultiline != null) {\n viewProps['aria-multiline'] = nativeProps.accessibilityMultiline\n }\n if (nativeProps.accessibilityMultiSelectable != null) {\n viewProps['aria-multiselectable'] = nativeProps.accessibilityMultiSelectable\n }\n if (nativeProps.accessibilityOrientation != null) {\n viewProps['aria-orientation'] = nativeProps.accessibilityOrientation\n }\n if (nativeProps.accessibilityOwns != null) {\n viewProps['aria-owns'] = processIDRefList(nativeProps.accessibilityOwns)\n }\n if (nativeProps.accessibilityPlaceholder != null) {\n viewProps['aria-placeholder'] = nativeProps.accessibilityPlaceholder\n }\n if (nativeProps.accessibilityPosInSet != null) {\n viewProps['aria-posinset'] = nativeProps.accessibilityPosInSet\n }\n if (nativeProps.accessibilityPressed != null) {\n viewProps['aria-pressed'] = nativeProps.accessibilityPressed\n }\n if (nativeProps.accessibilityReadOnly != null) {\n viewProps['aria-readonly'] = nativeProps.accessibilityReadOnly\n // Enhance with native semantics\n if (elementType === 'input' || elementType === 'select' || elementType === 'textarea') {\n viewProps.readOnly = true\n }\n }\n if (nativeProps.accessibilityRequired != null) {\n viewProps['aria-required'] = nativeProps.accessibilityRequired\n // Enhance with native semantics\n if (elementType === 'input' || elementType === 'select' || elementType === 'textarea') {\n viewProps.required = true\n }\n }\n if (nativeProps.accessibilityRoleDescription != null) {\n viewProps['aria-roledescription'] = nativeProps.accessibilityRoleDescription\n }\n if (nativeProps.accessibilityRowCount != null) {\n viewProps['aria-rowcount'] = nativeProps.accessibilityRowCount\n }\n if (nativeProps.accessibilityRowIndex != null) {\n viewProps['aria-rowindex'] = nativeProps.accessibilityRowIndex\n }\n if (nativeProps.accessibilityRowSpan != null) {\n viewProps['aria-rowspan'] = nativeProps.accessibilityRowSpan\n }\n if (nativeProps.accessibilitySelected != null) {\n viewProps['aria-selected'] = nativeProps.accessibilitySelected\n }\n if (nativeProps.accessibilitySetSize != null) {\n viewProps['aria-setsize'] = nativeProps.accessibilitySetSize\n }\n if (nativeProps.accessibilitySort != null) {\n viewProps['aria-sort'] = nativeProps.accessibilitySort\n }\n if (nativeProps.accessibilityValueMax != null) {\n viewProps['aria-valuemax'] = nativeProps.accessibilityValueMax\n }\n if (nativeProps.accessibilityValueMin != null) {\n viewProps['aria-valuemin'] = nativeProps.accessibilityValueMin\n }\n if (nativeProps.accessibilityValueNow != null) {\n viewProps['aria-valuenow'] = nativeProps.accessibilityValueNow\n }\n if (nativeProps.accessibilityValueText != null) {\n viewProps['aria-valuetext'] = nativeProps.accessibilityValueText\n }\n\n if (nativeProps.nativeID) {\n viewProps.id = nativeProps.nativeID\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAA6D;AAItD,SAAS,uBAAuB,aAAqB,WAAgB,aAAkB;AAC5F,MAAI,CAAC,UAAU,QAAQ,YAAY,mBAAmB;AACpD,QAAI,YAAY,sBAAsB,QAAQ;AAC5C,gBAAU,OAAO;AAAA,IACnB,OAAO;AACL,YAAM,UAAU,kDAA2B,YAAY;AACvD,UAAI,WAAW,MAAM;AACnB,kBAAU,OAAO,WAAW,YAAY;AAAA,MAC1C;AAAA,IACF;AAAA,EACF;AAEA,MAAI,YAAY,iCAAiC,MAAM;AACrD,cAAU,2BAA2B,YAAY;AAAA,EACnD;AACA,MAAI,YAAY,uBAAuB,MAAM;AAC3C,cAAU,iBAAiB,YAAY;AAAA,EACzC;AACA,MAAI,YAAY,6BAA6B,MAAM;AACjD,cAAU,uBAAuB,YAAY;AAAA,EAC/C;AACA,MAAI,YAAY,qBAAqB,MAAM;AACzC,cAAU,eAAe,YAAY;AAAA,EACvC;AACA,MAAI,YAAY,wBAAwB,MAAM;AAC5C,cAAU,kBAAkB,YAAY;AAAA,EAC1C;AACA,MAAI,YAAY,4BAA4B,MAAM;AAChD,cAAU,mBAAmB,YAAY;AAAA,EAC3C;AACA,MAAI,YAAY,4BAA4B,MAAM;AAChD,cAAU,mBAAmB,YAAY;AAAA,EAC3C;AACA,MAAI,YAAY,2BAA2B,MAAM;AAC/C,cAAU,kBAAk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AY,yBAAyB,MAAM;AAC7C,cAAU,mBAAmB,YAAY;AAAA,EAC3C;AACA,MAAI,YAAY,wBAAwB,MAAM;AAC5C,cAAU,kBAAkB,YAAY;AAAA,EAC1C;AACA,MAAI,YAAY,yBAAyB,MAAM;AAC7C,cAAU,mBAAmB,YAAY;AAAA,EAC3C;AACA,MAAI,YAAY,wBAAwB,MAAM;AAC5C,cAAU,kBAAkB,YAAY;AAAA,EAC1C;AACA,MAAI,YAAY,qBAAqB,MAAM;AACzC,cAAU,eAAe,YAAY;AAAA,EACvC;AACA,MAAI,YAAY,yBAAyB,MAAM;AAC7C,cAAU,mBAAmB,YAAY;AAAA,EAC3C;AACA,MAAI,YAAY,yBAAyB,MAAM;AAC7C,cAAU,mBAAmB,YAAY;AAAA,EAC3C;AACA,MAAI,YAAY,yBAAyB,MAAM;AAC7C,cAAU,mBAAmB,YAAY;AAAA,EAC3C;AACA,MAAI,YAAY,0BAA0B,MAAM;AAC9C,cAAU,oBAAoB,YAAY;AAAA,EAC5C;AAEA,MAAI,YAAY,UAAU;AACxB,cAAU,KAAK,YAAY;AAAA,EAC7B;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var assignNativePropsToWeb_native_exports = {};
20
+ __export(assignNativePropsToWeb_native_exports, {
21
+ assignNativePropsToWeb: () => assignNativePropsToWeb
22
+ });
23
+ module.exports = __toCommonJS(assignNativePropsToWeb_native_exports);
24
+ function assignNativePropsToWeb(elementType, viewProps, nativeProps) {
25
+ }
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ assignNativePropsToWeb
29
+ });
30
+ //# sourceMappingURL=assignNativePropsToWeb.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/helpers/assignNativePropsToWeb.native.tsx"],
4
+ "sourcesContent": ["export function assignNativePropsToWeb(elementType: string, viewProps: any, nativeProps: any) {}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,uBAAuB,aAAqB,WAAgB,aAAkB;AAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var calc_exports = {};
20
+ __export(calc_exports, {
21
+ calc: () => calc
22
+ });
23
+ module.exports = __toCommonJS(calc_exports);
24
+ var import_platform = require("../constants/platform");
25
+ var import_createVariable = require("../createVariable");
26
+ const operators = {
27
+ "+": (a, b) => a + b,
28
+ "-": (a, b) => a - b,
29
+ "/": (a, b) => a / b,
30
+ "*": (a, b) => a * b
31
+ };
32
+ const calc = (...valuesAndOperators) => {
33
+ if (import_platform.isWeb) {
34
+ let res2 = "calc(";
35
+ for (const cur of valuesAndOperators) {
36
+ if (operators[cur]) {
37
+ res2 += " " + cur + " ";
38
+ } else {
39
+ res2 += convertToVariableOrNumber(cur);
40
+ }
41
+ }
42
+ return res2 + ")";
43
+ }
44
+ let res = 0;
45
+ let nextOp = null;
46
+ for (const cur of valuesAndOperators) {
47
+ if (operators[cur]) {
48
+ nextOp = operators[cur];
49
+ } else {
50
+ if (nextOp) {
51
+ res = nextOp(res, cur);
52
+ nextOp = null;
53
+ } else {
54
+ res = +cur;
55
+ }
56
+ }
57
+ }
58
+ return res;
59
+ };
60
+ const convertToVariableOrNumber = (v) => {
61
+ const varOrVal = (0, import_createVariable.getVariableVariable)(v);
62
+ if (typeof varOrVal === "number") {
63
+ return `${varOrVal}px`;
64
+ }
65
+ return varOrVal;
66
+ };
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ calc
70
+ });
71
+ //# sourceMappingURL=calc.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/helpers/calc.ts"],
4
+ "sourcesContent": ["import { isWeb } from '../constants/platform'\nimport { getVariableVariable } from '../createVariable'\nimport { FontLineHeightTokens, FontSizeTokens, SizeTokens, SpaceTokens } from '../types'\n\n/**\n * Simple calc() that handles native + web\n * on web: outputs a calc() string\n * on native: outputs a plain number\n */\n\nexport type CalcVal =\n | string\n | number\n | SizeTokens\n | SpaceTokens\n | FontSizeTokens\n | FontLineHeightTokens\n\nconst operators = {\n '+': (a: number, b: number) => a + b,\n '-': (a: number, b: number) => a - b,\n '/': (a: number, b: number) => a / b,\n '*': (a: number, b: number) => a * b,\n}\n\ntype Operator = keyof typeof operators\n\nexport const calc = (...valuesAndOperators: (CalcVal | Operator)[]) => {\n if (isWeb) {\n let res = 'calc('\n for (const cur of valuesAndOperators) {\n if (operators[cur as any]) {\n // spaces are significant\n res += ' ' + cur + ' '\n } else {\n res += convertToVariableOrNumber(cur)\n }\n }\n return res + ')'\n }\n\n let res = 0\n let nextOp: any = null\n for (const cur of valuesAndOperators) {\n if (operators[cur as any]) {\n nextOp = operators[cur as any]\n } else {\n if (nextOp) {\n res = nextOp(res, cur)\n nextOp = null\n } else {\n res = +cur\n }\n }\n }\n return res\n}\n\nconst convertToVariableOrNumber = (v: any) => {\n const varOrVal = getVariableVariable(v)\n if (typeof varOrVal === 'number') {\n return `${varOrVal}px`\n }\n return varOrVal\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAsB;AACtB,4BAAoC;AAiBpC,MAAM,YAAY;AAAA,EAChB,KAAK,CAAC,GAAW,MAAc,IAAI;AAAA,EACnC,KAAK,CAAC,GAAW,MAAc,IAAI;AAAA,EACnC,KAAK,CAAC,GAAW,MAAc,IAAI;AAAA,EACnC,KAAK,CAAC,GAAW,MAAc,IAAI;AACrC;AAIO,MAAM,OAAO,IAAI,uBAA+C;AACrE,MAAI,uBAAO;AACT,QAAIA,OAAM;AACV,eAAW,OAAO,oBAAoB;AACpC,UAAI,UAAU,MAAa;AAEzB,QAAAA,QAAO,MAAM,MAAM;AAAA,MACrB,OAAO;AACL,QAAAA,QAAO,0BAA0B,GAAG;AAAA,MACtC;AAAA,IACF;AACA,WAAOA,OAAM;AAAA,EACf;AAEA,MAAI,MAAM;AACV,MAAI,SAAc;AAClB,aAAW,OAAO,oBAAoB;AACpC,QAAI,UAAU,MAAa;AACzB,eAAS,UAAU;AAAA,IACrB,OAAO;AACL,UAAI,QAAQ;AACV,cAAM,OAAO,KAAK,GAAG;AACrB,iBAAS;AAAA,MACX,OAAO;AACL,cAAM,CAAC;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEA,MAAM,4BAA4B,CAAC,MAAW;AAC5C,QAAM,eAAW,2CAAoB,CAAC;AACtC,MAAI,OAAO,aAAa,UAAU;AAChC,WAAO,GAAG;AAAA,EACZ;AACA,SAAO;AACT;",
6
+ "names": ["res"]
7
+ }
@@ -39,11 +39,9 @@ const getReturnVariablesAs = (props, state) => {
39
39
  const createPropMapper = (staticConfig) => {
40
40
  const variants = staticConfig.variants || {};
41
41
  const defaultProps = (0, import_mergeProps.mergeProps)(staticConfig.defaultProps || {}, {}, false)[0];
42
+ let conf;
42
43
  const mapper = (key, value, theme, propsIn, state, languageContext, avoidDefaultProps = false, debug) => {
43
- const conf = (0, import_config.getConfig)();
44
- if (!conf) {
45
- throw new Error(`No tamagui config setup`);
46
- }
44
+ conf || (conf = (0, import_config.getConfig)());
47
45
  const props = state.fallbackProps || propsIn;
48
46
  const returnVariablesAs = getReturnVariablesAs(props, state);
49
47
  const fontFamily = props[conf.inverseShorthands.fontFamily] || props.fontFamily || defaultProps.fontFamily || propsIn.fontFamily || "$body";
@@ -67,7 +65,7 @@ const createPropMapper = (staticConfig) => {
67
65
  return variantValue;
68
66
  }
69
67
  let shouldReturn = value !== void 0 && value !== null;
70
- if (conf.shorthands[key]) {
68
+ if (key in conf.shorthands) {
71
69
  shouldReturn = true;
72
70
  key = conf.shorthands[key];
73
71
  }