@tamagui/core 1.0.1-rc.0.3 → 1.0.1-rc.1

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 (59) hide show
  1. package/dist/cjs/createComponent.js +25 -42
  2. package/dist/cjs/createComponent.js.map +2 -2
  3. package/dist/cjs/createTamagui.js.map +2 -2
  4. package/dist/cjs/createVariable.js +15 -2
  5. package/dist/cjs/createVariable.js.map +2 -2
  6. package/dist/cjs/helpers/getSplitStyles.js +31 -13
  7. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  8. package/dist/cjs/helpers/matchMedia.js +7 -6
  9. package/dist/cjs/helpers/matchMedia.js.map +2 -2
  10. package/dist/cjs/helpers/matchMedia.native.js +22 -11
  11. package/dist/cjs/helpers/matchMedia.native.js.map +3 -3
  12. package/dist/cjs/hooks/useMedia.js +44 -36
  13. package/dist/cjs/hooks/useMedia.js.map +2 -2
  14. package/dist/cjs/hooks/useSafeRef.js +18 -17
  15. package/dist/cjs/hooks/useSafeRef.js.map +2 -2
  16. package/dist/cjs/index.js +0 -4
  17. package/dist/cjs/index.js.map +2 -2
  18. package/dist/cjs/types.js.map +1 -1
  19. package/dist/cjs/views/Stack.test.js +33 -0
  20. package/dist/cjs/views/Stack.test.js.map +7 -0
  21. package/dist/esm/createComponent.js +20 -37
  22. package/dist/esm/createComponent.js.map +2 -2
  23. package/dist/esm/createTamagui.js.map +2 -2
  24. package/dist/esm/createVariable.js +13 -2
  25. package/dist/esm/createVariable.js.map +2 -2
  26. package/dist/esm/helpers/getSplitStyles.js +32 -13
  27. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  28. package/dist/esm/helpers/matchMedia.js +5 -5
  29. package/dist/esm/helpers/matchMedia.js.map +2 -2
  30. package/dist/esm/helpers/matchMedia.native.js +20 -4
  31. package/dist/esm/helpers/matchMedia.native.js.map +2 -2
  32. package/dist/esm/hooks/useMedia.js +43 -35
  33. package/dist/esm/hooks/useMedia.js.map +2 -2
  34. package/dist/esm/hooks/useSafeRef.js +18 -17
  35. package/dist/esm/hooks/useSafeRef.js.map +2 -2
  36. package/dist/esm/index.js +0 -4
  37. package/dist/esm/index.js.map +2 -2
  38. package/dist/esm/views/Stack.test.js +32 -0
  39. package/dist/esm/views/Stack.test.js.map +7 -0
  40. package/package.json +12 -12
  41. package/src/createComponent.tsx +31 -42
  42. package/src/createTamagui.ts +1 -1
  43. package/src/createVariable.ts +13 -2
  44. package/src/helpers/getSplitStyles.tsx +38 -14
  45. package/src/helpers/matchMedia.native.ts +21 -4
  46. package/src/helpers/matchMedia.ts +8 -10
  47. package/src/hooks/useMedia.tsx +62 -41
  48. package/src/hooks/useSafeRef.ts +6 -9
  49. package/src/index.ts +0 -2
  50. package/src/types.tsx +9 -1
  51. package/src/views/Stack.test.tsx +74 -0
  52. package/types/createVariable.d.ts +2 -0
  53. package/types/helpers/getSplitStyles.d.ts +2 -1
  54. package/types/helpers/matchMedia.d.ts +5 -1
  55. package/types/helpers/matchMedia.native.d.ts +3 -2
  56. package/types/hooks/useMedia.d.ts +4 -4
  57. package/types/index.d.ts +1 -1
  58. package/types/types.d.ts +7 -1
  59. package/types/views/Stack.test.d.ts +2 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/useMedia.tsx"],
4
- "sourcesContent": ["import { useDeferredValue, useEffect, useMemo, useSyncExternalStore } from 'react'\n\nimport { getConfig } from '../config'\nimport { createProxy } from '../helpers/createProxy'\nimport { matchMedia } from '../helpers/matchMedia'\nimport {\n MediaQueries,\n MediaQueryKey,\n MediaQueryObject,\n MediaQueryState,\n TamaguiInternalConfig,\n} from '../types'\nimport { useSafeRef } from './useSafeRef'\n\nexport const mediaState: MediaQueryState =\n // development only safeguard\n process.env.NODE_ENV === 'development'\n ? createProxy(\n {},\n {\n get(target, key) {\n if (\n typeof key === 'string' &&\n key[0] === '$' &&\n // dont error on $$typeof\n key[1] !== '$'\n ) {\n throw new Error(`Access mediaState should not use \"$\": ${key}`)\n }\n return Reflect.get(target, key)\n },\n }\n )\n : ({} as any)\n\ntype MediaListener = (next: boolean) => void\n\nconst listeners: { [key: string]: Set<MediaListener> } = {}\n\nexport function addMediaQueryListener(key: MediaQueryKey, cb: MediaListener) {\n if (process.env.NODE_ENV === 'development' && key[0] === '$') {\n // eslint-disable-next-line no-console\n console.warn(`Warning, listening to media queries shouldn't use the \"$\" prefix`)\n }\n listeners[key] = listeners[key] || new Set()\n listeners[key].add(cb)\n return () => removeMediaQueryListener(key, cb)\n}\n\nexport function removeMediaQueryListener(key: MediaQueryKey, cb: MediaListener) {\n listeners[key]?.delete(cb)\n}\n\nexport const mediaQueryConfig: MediaQueries = {}\n\nexport const getMedia = () => mediaState\n\n// for SSR capture it at time of startup\nlet initState: MediaQueryState\nexport const getInitialMediaState = () => {\n return (getConfig().disableSSR ? mediaState : initState) || {}\n}\n\nlet mediaKeysOrdered: string[]\nexport const getMediaKeyImportance = (key: string) =>\n // + 2 because we set base usedKeys=1 in getSplitStyles and all media go above 1\n mediaKeysOrdered.indexOf(key[0] === '$' ? key.slice(1) : key) + 2\n\nconst dispose = new Set<Function>()\n\nexport const configureMedia = (config: TamaguiInternalConfig) => {\n const { media, mediaQueryDefaultActive } = config\n if (!media) return\n for (const key in media) {\n mediaState[key] = mediaQueryDefaultActive?.[key] || false\n }\n Object.assign(mediaQueryConfig, media)\n initState = { ...mediaState }\n updateCurrentState()\n mediaKeysOrdered = Object.keys(media)\n if (config.disableSSR) {\n setupMediaListeners()\n }\n}\n\nfunction unlisten() {\n dispose.forEach((cb) => cb())\n dispose.clear()\n}\n\n/**\n * Note: This should *not* set the state on the first render!\n * Because to avoid hydration issues SSR must match the server\n * *and then* re-render with the actual media query state.\n */\nlet configuredKey = ''\nfunction setupMediaListeners() {\n // avoid setting up more than once per config\n const nextKey = JSON.stringify(mediaQueryConfig)\n if (nextKey === configuredKey) {\n return\n }\n configuredKey = nextKey\n\n // hmr, undo existing before re-binding\n unlisten()\n\n for (const key in mediaQueryConfig) {\n const str = mediaObjectToString(mediaQueryConfig[key])\n const getMatch = () => matchMedia(str)\n const match = getMatch()\n if (!match) {\n throw new Error('\u26A0\uFE0F No match')\n }\n // react native needs these deprecated apis for now\n match.addListener(update)\n dispose.add(() => match.removeListener(update))\n\n update()\n\n function update() {\n const next = !!getMatch().matches\n if (next === mediaState[key]) return\n mediaState[key] = next\n updateCurrentState()\n const cur = listeners[key]\n if (cur?.size) {\n cur.forEach((cb) => cb(next))\n }\n }\n }\n}\n\nexport function useMediaListeners(config: TamaguiInternalConfig) {\n if (config.disableSSR) return\n useEffect(() => {\n setupMediaListeners()\n return unlisten\n }, [])\n}\n\nconst currentStateListeners = new Set<any>()\nfunction updateCurrentState() {\n currentStateListeners.forEach((cb) => cb(mediaState))\n}\nfunction subscribe(subscriber: any) {\n currentStateListeners.add(subscriber)\n return () => currentStateListeners.delete(subscriber)\n}\n\ntype MediaKeysState = {\n [key: string]: any\n}\n\nexport function useMedia(): {\n [key in MediaQueryKey]: boolean\n} {\n const keys = useSafeRef<MediaKeysState>({ prev: initState })\n const stateSync = useSyncExternalStore<MediaQueryState>(\n subscribe,\n () => {\n const { prev, ...curKeys } = keys.current\n const shouldUpdate = !prev || Object.keys(curKeys).some((k) => mediaState[k] !== prev[k])\n if (shouldUpdate) {\n const next = { ...mediaState }\n keys.current.prev = next\n return next\n }\n return prev\n },\n () => initState\n )\n const state = useDeferredValue(stateSync)\n\n return useMemo(() => {\n return new Proxy(state, {\n get(_, key: string) {\n if (!keys.current[key]) {\n keys.current[key] = true\n }\n return Reflect.get(state, key)\n },\n })\n }, [state])\n}\n\n/**\n * Useful for more complex components that need access to the currently active props,\n * accounting for the currently active media queries.\n *\n * Use sparingly, is will loop props and trigger re-render on all media queries.\n *\n * */\nexport function useMediaPropsActive<A extends Object>(\n props: A\n): {\n // remove all media\n [Key in keyof A extends `$${string}` ? never : keyof A]?: A[Key]\n} {\n const media = useMedia()\n\n return useMemo(() => {\n const next = {} as A\n const importancesUsed = {}\n const propNames = Object.keys(props)\n\n for (let i = propNames.length - 1; i >= 0; i--) {\n const key = propNames[i]\n const val = props[key]\n if (key[0] === '$') {\n if (!media[key.slice(1)]) {\n continue\n }\n if (val && typeof val === 'object') {\n const subKeys = Object.keys(val)\n for (let j = subKeys.length; j--; j >= 0) {\n const subKey = subKeys[j]\n mergeMediaByImportance(next, subKey, val[subKey], importancesUsed)\n }\n }\n } else {\n mergeMediaByImportance(next, key, val, importancesUsed)\n }\n }\n\n return next\n }, [media, props])\n}\n\nexport function mergeMediaByImportance(\n onto: Record<string, any>,\n key: string,\n value: any,\n importancesUsed: Record<string, number>\n) {\n const importance = getMediaKeyImportance(key)\n if (importancesUsed[key] > importance) {\n return false\n }\n importancesUsed[key] = importance\n onto[key] = value\n return true\n}\n\nfunction camelToHyphen(str: string) {\n return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase()\n}\n\nexport function mediaObjectToString(query: string | MediaQueryObject) {\n if (typeof query === 'string') {\n return query\n }\n return Object.entries(query)\n .map(([feature, value]) => {\n feature = camelToHyphen(feature)\n if (typeof value === 'string') {\n return `(${feature}: ${value})`\n }\n if (typeof value === 'number' && /[height|width]$/.test(feature)) {\n value = `${value}px`\n }\n return `(${feature}: ${value})`\n })\n .join(' and ')\n}\n"],
5
- "mappings": "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",
4
+ "sourcesContent": ["import { useEffect, useMemo, useSyncExternalStore } from 'react'\n\nimport { getConfig } from '../config'\nimport { createProxy } from '../helpers/createProxy'\nimport { matchMedia } from '../helpers/matchMedia'\nimport {\n MediaQueries,\n MediaQueryKey,\n MediaQueryObject,\n MediaQueryState,\n TamaguiInternalConfig,\n} from '../types'\nimport { useSafeRef } from './useSafeRef'\n\nexport const mediaState: MediaQueryState =\n // development only safeguard\n process.env.NODE_ENV === 'development'\n ? createProxy(\n {},\n {\n get(target, key) {\n if (\n typeof key === 'string' &&\n key[0] === '$' &&\n // dont error on $$typeof\n key[1] !== '$'\n ) {\n throw new Error(`Access mediaState should not use \"$\": ${key}`)\n }\n return Reflect.get(target, key)\n },\n }\n )\n : ({} as any)\n\nexport const mediaQueryConfig: MediaQueries = {}\nexport const getMedia = () => mediaState\n\n// for SSR capture it at time of startup\nlet initState: MediaQueryState\nexport const getInitialMediaState = () => {\n return (getConfig().disableSSR ? mediaState : initState) || {}\n}\n\nlet mediaKeysOrdered: string[]\nexport const getMediaKeyImportance = (key: string) =>\n // + 2 because we set base usedKeys=1 in getSplitStyles and all media go above 1\n mediaKeysOrdered.indexOf(key[0] === '$' ? key.slice(1) : key) + 2\n\nconst dispose = new Set<Function>()\n\nexport const configureMedia = (config: TamaguiInternalConfig) => {\n const { media, mediaQueryDefaultActive } = config\n if (!media) return\n for (const key in media) {\n mediaState[key] = mediaQueryDefaultActive?.[key] || false\n }\n Object.assign(mediaQueryConfig, media)\n initState = { ...mediaState }\n updateCurrentState()\n mediaKeysOrdered = Object.keys(media)\n if (config.disableSSR) {\n setupMediaListeners()\n }\n}\n\nfunction unlisten() {\n dispose.forEach((cb) => cb())\n dispose.clear()\n}\n\n/**\n * Note: This should *not* set the state on the first render!\n * Because to avoid hydration issues SSR must match the server\n * *and then* re-render with the actual media query state.\n */\nlet configuredKey = ''\nfunction setupMediaListeners() {\n // avoid setting up more than once per config\n const nextKey = JSON.stringify(mediaQueryConfig)\n if (nextKey === configuredKey) {\n return\n }\n configuredKey = nextKey\n\n // hmr, undo existing before re-binding\n unlisten()\n\n for (const key in mediaQueryConfig) {\n const str = mediaObjectToString(mediaQueryConfig[key])\n const getMatch = () => matchMedia(str)\n const match = getMatch()\n if (!match) {\n throw new Error('\u26A0\uFE0F No match')\n }\n // react native needs these deprecated apis for now\n match.addListener(update)\n dispose.add(() => match.removeListener(update))\n\n update()\n\n function update() {\n const next = !!getMatch().matches\n if (next === mediaState[key]) return\n mediaState[key] = next\n updateCurrentState()\n }\n }\n}\n\nexport function useMediaListeners(config: TamaguiInternalConfig) {\n if (config.disableSSR) return\n useEffect(() => {\n setupMediaListeners()\n return unlisten\n }, [])\n}\n\nconst currentStateListeners = new Set<any>()\nfunction updateCurrentState() {\n currentStateListeners.forEach((cb) => cb(mediaState))\n}\nfunction subscribe(subscriber: any) {\n currentStateListeners.add(subscriber)\n return () => currentStateListeners.delete(subscriber)\n}\n\ntype MediaKeysState = {\n [key: string]: any\n}\n\ntype UseMediaState = {\n [key in MediaQueryKey]: boolean\n}\n\nconst shouldUpdate = new WeakMap<any, boolean>()\nexport function setMediaShouldUpdate(ref: any, val: boolean) {\n return shouldUpdate.set(ref, val)\n}\n\ntype UseMediaInternalState = { prev: MediaKeysState; next: MediaKeysState }\nconst empty = {}\nlet initialUseState: UseMediaInternalState\n\nexport function useMedia(): UseMediaState {\n // setup once\n initialUseState ||= {\n prev: initState,\n next: empty,\n }\n\n const keys = useSafeRef<UseMediaInternalState>(initialUseState)\n const state = useSyncExternalStore<MediaQueryState>(\n subscribe,\n () => {\n const curState = keys.current\n const preventUpdate = arguments[0] && shouldUpdate.get(arguments[0]) !== true\n if (preventUpdate) {\n return curState.prev\n }\n\n let didUpdate = false\n\n // ensure we keep the minimal object of only used keys\n const next = {}\n\n for (const key in curState.next) {\n const val = mediaState[key]\n if (curState.prev[key] != val) {\n didUpdate = true\n }\n next[key] = val\n }\n\n // console.log('go', { didUpdate, next, mediaState, curState })\n\n if (!didUpdate) {\n return curState.prev\n }\n\n keys.current = { next, prev: next }\n return next\n },\n () => initState\n )\n\n return useMemo(() => {\n return new Proxy(state === empty ? initState : state, {\n get(_, key: string) {\n if (!(key in keys.current.next)) {\n keys.current.next[key] = true\n keys.current = { ...keys.current }\n }\n return Reflect.get(state, key)\n },\n })\n }, [state])\n}\n\n/**\n * Useful for more complex components that need access to the currently active props,\n * accounting for the currently active media queries.\n *\n * Use sparingly, is will loop props and trigger re-render on all media queries.\n *\n * */\nexport function useMediaPropsActive<A extends Object>(\n props: A\n): {\n // remove all media\n [Key in keyof A extends `$${string}` ? never : keyof A]?: A[Key]\n} {\n const media = useMedia()\n\n return useMemo(() => {\n const next = {} as A\n const importancesUsed = {}\n const propNames = Object.keys(props)\n\n for (let i = propNames.length - 1; i >= 0; i--) {\n const key = propNames[i]\n const val = props[key]\n if (key[0] === '$') {\n if (!media[key.slice(1)]) {\n continue\n }\n if (val && typeof val === 'object') {\n const subKeys = Object.keys(val)\n for (let j = subKeys.length; j--; j >= 0) {\n const subKey = subKeys[j]\n mergeMediaByImportance(next, subKey, val[subKey], importancesUsed)\n }\n }\n } else {\n mergeMediaByImportance(next, key, val, importancesUsed)\n }\n }\n\n return next\n }, [media, props])\n}\n\nexport const getMediaImportanceIfMoreImportant = (\n key: string,\n importancesUsed: Record<string, number>\n) => {\n const importance = getMediaKeyImportance(key)\n return !importancesUsed[key] || importance > importancesUsed[key] ? importance : null\n}\n\nexport function mergeMediaByImportance(\n onto: Record<string, any>,\n key: string,\n value: any,\n importancesUsed: Record<string, number>\n) {\n const importance = getMediaImportanceIfMoreImportant(key, importancesUsed)\n if (importance === null) {\n return false\n }\n importancesUsed[key] = importance\n onto[key] = value\n return true\n}\n\nfunction camelToHyphen(str: string) {\n return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase()\n}\n\nexport function mediaObjectToString(query: string | MediaQueryObject) {\n if (typeof query === 'string') {\n return query\n }\n return Object.entries(query)\n .map(([feature, value]) => {\n feature = camelToHyphen(feature)\n if (typeof value === 'string') {\n return `(${feature}: ${value})`\n }\n if (typeof value === 'number' && /[height|width]$/.test(feature)) {\n value = `${value}px`\n }\n return `(${feature}: ${value})`\n })\n .join(' and ')\n}\n"],
5
+ "mappings": "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",
6
6
  "names": ["update"]
7
7
  }
@@ -25,28 +25,29 @@ var import_constants = require("@tamagui/constants");
25
25
  var import_react = require("react");
26
26
  const useSafeRef = (initialValue) => {
27
27
  const rawRef = (0, import_react.useRef)();
28
- const raw = rawRef.current ?? (rawRef.current = {
29
- hold: true,
30
- next: initialValue,
31
- cur: initialValue,
32
- ref: {
33
- get current() {
34
- return raw.hold ? raw.cur : raw.next;
35
- },
36
- set current(v) {
37
- if (!raw.hold) {
38
- raw.next = v;
28
+ if (!rawRef.current) {
29
+ rawRef.current = {
30
+ hold: true,
31
+ next: initialValue,
32
+ cur: initialValue,
33
+ ref: {
34
+ get current() {
35
+ return raw.hold ? raw.cur : raw.next;
36
+ },
37
+ set current(v) {
38
+ if (!raw.hold) {
39
+ raw.next = v;
40
+ }
41
+ raw.cur = v;
39
42
  }
40
- raw.cur = v;
41
43
  }
42
- }
43
- });
44
+ };
45
+ }
46
+ const raw = rawRef.current;
44
47
  raw.hold = true;
45
- Promise.resolve().then(() => {
46
- raw.hold = false;
47
- });
48
48
  raw.cur = raw.next;
49
49
  (0, import_constants.useIsomorphicLayoutEffect)(() => {
50
+ raw.hold = false;
50
51
  raw.next = raw.cur;
51
52
  });
52
53
  return raw.ref;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/useSafeRef.ts"],
4
- "sourcesContent": ["import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useRef } from 'react'\n\n// dai-shi \uD83D\uDE4F\n// https://dev.to/uhyo_/a-concurrent-mode-safe-version-of-useref-1325\n// probably can live without it though to save a bit of b\n\ntype Raw<T> = {\n hold: boolean\n next: T\n cur: T\n ref: { current: T }\n}\n\nexport const useSafeRef = <T>(initialValue: T) => {\n const rawRef = useRef<Raw<T>>()\n\n const raw: Raw<T> =\n rawRef.current ??\n (rawRef.current = {\n hold: true,\n next: initialValue,\n cur: initialValue,\n ref: {\n get current() {\n return raw.hold ? raw.cur : raw.next\n },\n set current(v) {\n if (!raw.hold) {\n raw.next = v\n }\n raw.cur = v\n },\n },\n })\n\n raw.hold = true\n Promise.resolve().then(() => {\n raw.hold = false\n })\n raw.cur = raw.next\n\n useIsomorphicLayoutEffect(() => {\n raw.next = raw.cur\n })\n\n return raw.ref\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0C;AAC1C,mBAAuB;AAahB,MAAM,aAAa,CAAI,iBAAoB;AAChD,QAAM,aAAS,qBAAe;AAE9B,QAAM,MACJ,OAAO,YACN,OAAO,UAAU;AAAA,IAChB,MAAM;AAAA,IACN,MAAM;AAAA,IACN,KAAK;AAAA,IACL,KAAK;AAAA,MACH,IAAI,UAAU;AACZ,eAAO,IAAI,OAAO,IAAI,MAAM,IAAI;AAAA,MAClC;AAAA,MACA,IAAI,QAAQ,GAAG;AACb,YAAI,CAAC,IAAI,MAAM;AACb,cAAI,OAAO;AAAA,QACb;AACA,YAAI,MAAM;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEF,MAAI,OAAO;AACX,UAAQ,QAAQ,EAAE,KAAK,MAAM;AAC3B,QAAI,OAAO;AAAA,EACb,CAAC;AACD,MAAI,MAAM,IAAI;AAEd,kDAA0B,MAAM;AAC9B,QAAI,OAAO,IAAI;AAAA,EACjB,CAAC;AAED,SAAO,IAAI;AACb;",
4
+ "sourcesContent": ["import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useRef } from 'react'\n\n// dai-shi \uD83D\uDE4F\n// https://dev.to/uhyo_/a-concurrent-mode-safe-version-of-useref-1325\n// probably can live without it though to save a bit of b\n\ntype Raw<T> = {\n hold: boolean\n next: T\n cur: T\n ref: { current: T }\n}\n\nexport const useSafeRef = <T>(initialValue: T) => {\n const rawRef = useRef<Raw<T>>()\n if (!rawRef.current) {\n rawRef.current = {\n hold: true,\n next: initialValue,\n cur: initialValue,\n ref: {\n get current() {\n return raw.hold ? raw.cur : raw.next\n },\n set current(v) {\n if (!raw.hold) {\n raw.next = v\n }\n raw.cur = v\n },\n },\n }\n }\n\n const raw: Raw<T> = rawRef.current\n raw.hold = true\n raw.cur = raw.next\n useIsomorphicLayoutEffect(() => {\n raw.hold = false\n raw.next = raw.cur\n })\n\n return raw.ref\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0C;AAC1C,mBAAuB;AAahB,MAAM,aAAa,CAAI,iBAAoB;AAChD,QAAM,aAAS,qBAAe;AAC9B,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,UAAU;AAAA,MACf,MAAM;AAAA,MACN,MAAM;AAAA,MACN,KAAK;AAAA,MACL,KAAK;AAAA,QACH,IAAI,UAAU;AACZ,iBAAO,IAAI,OAAO,IAAI,MAAM,IAAI;AAAA,QAClC;AAAA,QACA,IAAI,QAAQ,GAAG;AACb,cAAI,CAAC,IAAI,MAAM;AACb,gBAAI,OAAO;AAAA,UACb;AACA,cAAI,MAAM;AAAA,QACZ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,MAAc,OAAO;AAC3B,MAAI,OAAO;AACX,MAAI,MAAM,IAAI;AACd,kDAA0B,MAAM;AAC9B,QAAI,OAAO;AACX,QAAI,OAAO,IAAI;AAAA,EACjB,CAAC;AAED,SAAO,IAAI;AACb;",
6
6
  "names": []
7
7
  }
package/dist/cjs/index.js CHANGED
@@ -19,7 +19,6 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
20
  var src_exports = {};
21
21
  __export(src_exports, {
22
- addMediaQueryListener: () => import_useMedia.addMediaQueryListener,
23
22
  configureMedia: () => import_useMedia.configureMedia,
24
23
  getConfig: () => import_config.getConfig,
25
24
  getMedia: () => import_useMedia.getMedia,
@@ -29,7 +28,6 @@ __export(src_exports, {
29
28
  mediaQueryConfig: () => import_useMedia.mediaQueryConfig,
30
29
  mediaState: () => import_useMedia.mediaState,
31
30
  onConfiguredOnce: () => import_config.onConfiguredOnce,
32
- removeMediaQueryListener: () => import_useMedia.removeMediaQueryListener,
33
31
  useMedia: () => import_useMedia.useMedia,
34
32
  useMediaPropsActive: () => import_useMedia.useMediaPropsActive
35
33
  });
@@ -89,7 +87,6 @@ __reExport(src_exports, require("@tamagui/helpers"), module.exports);
89
87
  __reExport(src_exports, require("@tamagui/constants"), module.exports);
90
88
  // Annotate the CommonJS export names for ESM import in node:
91
89
  0 && (module.exports = {
92
- addMediaQueryListener,
93
90
  configureMedia,
94
91
  getConfig,
95
92
  getMedia,
@@ -99,7 +96,6 @@ __reExport(src_exports, require("@tamagui/constants"), module.exports);
99
96
  mediaQueryConfig,
100
97
  mediaState,
101
98
  onConfiguredOnce,
102
- removeMediaQueryListener,
103
99
  useMedia,
104
100
  useMediaPropsActive
105
101
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './insertFont'\nexport * from './addTheme'\nexport * from './updateTheme'\nexport * from './styled'\nexport * from './types'\nexport * from './setupReactNative'\n\n// for type portability\nexport type { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getConfig, getThemes, getTokens, onConfiguredOnce } from './config'\n\nexport * from './constants/constants'\n\nexport * from './helpers/useShallowSetState'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getAnimationDriver'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/pseudoDescriptors'\nexport * from './helpers/mergeProps'\nexport * from './helpers/expandStyles'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/isTamaguiComponent'\nexport * from './helpers/matchMedia'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonNestingContext'\n\nexport * from './hooks/useId'\nexport * from './hooks/useIsTouchDevice'\n\nexport {\n configureMedia,\n getMedia,\n mediaState,\n useMedia,\n useMediaPropsActive,\n mediaObjectToString,\n addMediaQueryListener,\n removeMediaQueryListener,\n mediaQueryConfig,\n} from './hooks/useMedia'\nexport * from './hooks/useTheme'\nexport * from './hooks/useThemeName'\nexport * from './hooks/useSafeRef'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport * from './contexts/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeProvider'\nexport * from './views/FontLanguage'\nexport * from './views/TamaguiProvider'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/use-did-finish-ssr'\nexport * from '@tamagui/use-event'\nexport * from '@tamagui/compose-refs'\nexport * from '@tamagui/helpers'\nexport * from '@tamagui/constants'\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,sBAAd;AACA,wBAAc,8BADd;AAEA,wBAAc,+BAFd;AAGA,wBAAc,0BAHd;AAIA,wBAAc,4BAJd;AAKA,wBAAc,yBALd;AAMA,wBAAc,2BANd;AAOA,wBAAc,6BAPd;AAQA,wBAAc,8BARd;AASA,wBAAc,yBATd;AAUA,wBAAc,uBAVd;AAWA,wBAAc,0BAXd;AAYA,wBAAc,qBAZd;AAaA,wBAAc,oBAbd;AAcA,wBAAc,+BAdd;AAkBA,oBAAkE;AAElE,wBAAc,kCApBd;AAsBA,wBAAc,yCAtBd;AAuBA,wBAAc,uCAvBd;AAwBA,wBAAc,yCAxBd;AAyBA,wBAAc,4CAzBd;AA0BA,wBAAc,8BA1Bd;AA2BA,wBAAc,qCA3Bd;AA4BA,wBAAc,sCA5Bd;AA6BA,wBAAc,wCA7Bd;AA8BA,wBAAc,iCA9Bd;AA+BA,wBAAc,mCA/Bd;AAgCA,wBAAc,uCAhCd;AAiCA,wBAAc,yCAjCd;AAkCA,wBAAc,iCAlCd;AAmCA,wBAAc,gCAnCd;AAoCA,wBAAc,2CApCd;AAsCA,wBAAc,4CAtCd;AAwCA,wBAAc,0BAxCd;AAyCA,wBAAc,qCAzCd;AA2CA,sBAUO;AACP,wBAAc,6BAtDd;AAuDA,wBAAc,iCAvDd;AAwDA,wBAAc,+BAxDd;AA0DA,wBAAc,yBA1Dd;AA2DA,wBAAc,0BA3Dd;AA4DA,wBAAc,yBA5Dd;AA6DA,wBAAc,2CA7Dd;AA8DA,wBAAc,0BA9Dd;AA+DA,wBAAc,kCA/Dd;AAgEA,wBAAc,iCAhEd;AAiEA,wBAAc,oCAjEd;AAmEA,wBAAc,sCAnEd;AAoEA,wBAAc,wCApEd;AAqEA,wBAAc,+BArEd;AAsEA,wBAAc,kCAtEd;AAuEA,wBAAc,6BAvEd;AAwEA,wBAAc,+BAxEd;",
4
+ "sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './insertFont'\nexport * from './addTheme'\nexport * from './updateTheme'\nexport * from './styled'\nexport * from './types'\nexport * from './setupReactNative'\n\n// for type portability\nexport type { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getConfig, getThemes, getTokens, onConfiguredOnce } from './config'\n\nexport * from './constants/constants'\n\nexport * from './helpers/useShallowSetState'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getAnimationDriver'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/pseudoDescriptors'\nexport * from './helpers/mergeProps'\nexport * from './helpers/expandStyles'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/isTamaguiComponent'\nexport * from './helpers/matchMedia'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonNestingContext'\n\nexport * from './hooks/useId'\nexport * from './hooks/useIsTouchDevice'\n\nexport {\n configureMedia,\n getMedia,\n mediaState,\n useMedia,\n useMediaPropsActive,\n mediaObjectToString,\n mediaQueryConfig,\n} from './hooks/useMedia'\nexport * from './hooks/useTheme'\nexport * from './hooks/useThemeName'\nexport * from './hooks/useSafeRef'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport * from './contexts/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeProvider'\nexport * from './views/FontLanguage'\nexport * from './views/TamaguiProvider'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/use-did-finish-ssr'\nexport * from '@tamagui/use-event'\nexport * from '@tamagui/compose-refs'\nexport * from '@tamagui/helpers'\nexport * from '@tamagui/constants'\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,sBAAd;AACA,wBAAc,8BADd;AAEA,wBAAc,+BAFd;AAGA,wBAAc,0BAHd;AAIA,wBAAc,4BAJd;AAKA,wBAAc,yBALd;AAMA,wBAAc,2BANd;AAOA,wBAAc,6BAPd;AAQA,wBAAc,8BARd;AASA,wBAAc,yBATd;AAUA,wBAAc,uBAVd;AAWA,wBAAc,0BAXd;AAYA,wBAAc,qBAZd;AAaA,wBAAc,oBAbd;AAcA,wBAAc,+BAdd;AAkBA,oBAAkE;AAElE,wBAAc,kCApBd;AAsBA,wBAAc,yCAtBd;AAuBA,wBAAc,uCAvBd;AAwBA,wBAAc,yCAxBd;AAyBA,wBAAc,4CAzBd;AA0BA,wBAAc,8BA1Bd;AA2BA,wBAAc,qCA3Bd;AA4BA,wBAAc,sCA5Bd;AA6BA,wBAAc,wCA7Bd;AA8BA,wBAAc,iCA9Bd;AA+BA,wBAAc,mCA/Bd;AAgCA,wBAAc,uCAhCd;AAiCA,wBAAc,yCAjCd;AAkCA,wBAAc,iCAlCd;AAmCA,wBAAc,gCAnCd;AAoCA,wBAAc,2CApCd;AAsCA,wBAAc,4CAtCd;AAwCA,wBAAc,0BAxCd;AAyCA,wBAAc,qCAzCd;AA2CA,sBAQO;AACP,wBAAc,6BApDd;AAqDA,wBAAc,iCArDd;AAsDA,wBAAc,+BAtDd;AAwDA,wBAAc,yBAxDd;AAyDA,wBAAc,0BAzDd;AA0DA,wBAAc,yBA1Dd;AA2DA,wBAAc,2CA3Dd;AA4DA,wBAAc,0BA5Dd;AA6DA,wBAAc,kCA7Dd;AA8DA,wBAAc,iCA9Dd;AA+DA,wBAAc,oCA/Dd;AAiEA,wBAAc,sCAjEd;AAkEA,wBAAc,wCAlEd;AAmEA,wBAAc,+BAnEd;AAoEA,wBAAc,kCApEd;AAqEA,wBAAc,6BArEd;AAsEA,wBAAc,+BAtEd;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/types.tsx"],
4
- "sourcesContent": ["// TODO split this into own package @tamagui/types to share with animations packages\n\nimport type {\n Image,\n PressableProps,\n TextProps as ReactTextProps,\n Text,\n TextInput,\n TextStyle,\n View,\n ViewProps,\n ViewStyle,\n} from '@tamagui/types-react-native'\nimport type { Properties } from 'csstype'\nimport type {\n ComponentType,\n ForwardRefExoticComponent,\n FunctionComponent,\n HTMLAttributes,\n ReactNode,\n RefAttributes,\n RefObject,\n} from 'react'\n\nimport type { Variable } from './createVariable'\nimport type { ResolveVariableTypes } from './helpers/createPropMapper'\nimport type { TamaguiReactElement } from './static'\nimport type { RNWTextProps, RNWViewProps } from './types-rnw'\nimport type { FontLanguageProps } from './views/FontLanguage.types'\nimport type { ThemeProviderProps } from './views/ThemeProvider'\n\nexport type SpaceDirection = 'vertical' | 'horizontal' | 'both'\n\nexport type TamaguiElement = HTMLElement | View\n\nexport type DebugProp = boolean | 'break' | 'verbose'\n\n// base props that are accepted by createComponent (additional to react-native-web)\n\ntype DivAttributes = HTMLAttributes<HTMLDivElement>\n\nexport type TamaguiComponentPropsBase = {\n hitSlop?: PressableProps['hitSlop']\n asChild?: boolean\n space?: SpaceTokens | null\n spaceDirection?: SpaceDirection\n separator?: ReactNode\n dangerouslySetInnerHTML?: { __html: string }\n animation?: AnimationProp\n animateOnly?: string[]\n children?: any | any[]\n debug?: DebugProp\n disabled?: boolean\n className?: string\n themeShallow?: boolean\n id?: string\n tag?: string\n theme?: ThemeName | null\n componentName?: string\n /**\n * Forces the pseudo style state to be on\n */\n forceStyle?: 'hover' | 'press' | 'focus'\n onHoverIn?: DivAttributes['onMouseEnter']\n onHoverOut?: DivAttributes['onMouseLeave']\n onPress?: PressableProps['onPress']\n onPressIn?: PressableProps['onPress']\n onPressOut?: PressableProps['onPress']\n // WEB ONLY\n onMouseEnter?: DivAttributes['onMouseEnter']\n onMouseLeave?: DivAttributes['onMouseLeave']\n onMouseDown?: DivAttributes['onMouseDown']\n}\n\nexport type ReactComponentWithRef<Props, Ref> = ForwardRefExoticComponent<\n Props & RefAttributes<Ref>\n>\n\nexport type ConfigListener = (conf: TamaguiInternalConfig) => void\n\n// to prevent things from going circular, hoisting some types in this file\n// to generally order them as building up towards TamaguiConfig\n\nexport type VariableVal = number | string | Variable\nexport type VariableColorVal = string | Variable\n\ntype GenericKey = string | number | symbol\n\nexport interface CreateTokens<Val extends VariableVal = VariableVal> {\n color: { [key: GenericKey]: Val }\n space: { [key: GenericKey]: Val }\n size: { [key: GenericKey]: Val }\n radius: { [key: GenericKey]: Val }\n zIndex: { [key: GenericKey]: Val }\n}\n\nexport type TamaguiBaseTheme = {\n // defined for our tamagui kit , we could do this inside `tamagui`\n // but maybe helpful to have some sort of universally shared things +\n // + enforce if they want their own, redefine in their design sys\n background: VariableColorVal\n backgroundHover: VariableColorVal\n backgroundPress: VariableColorVal\n backgroundFocus: VariableColorVal\n color: VariableColorVal\n colorHover: VariableColorVal\n colorPress: VariableColorVal\n colorFocus: VariableColorVal\n borderColor: VariableColorVal\n borderColorHover: VariableColorVal\n borderColorPress: VariableColorVal\n borderColorFocus: VariableColorVal\n shadowColor: VariableColorVal\n shadowColorHover: VariableColorVal\n shadowColorPress: VariableColorVal\n shadowColorFocus: VariableColorVal\n}\n\ntype GenericTokens = CreateTokens\ntype GenericThemes = {\n [key: string]:\n | Partial<TamaguiBaseTheme> & {\n [key: string]: VariableVal\n }\n}\n\ntype AllStyleKeys = keyof StackStylePropsBase | keyof TextStylePropsBase\n\nexport type CreateShorthands = {\n [key: string]: AllStyleKeys\n}\n\nexport type GenericShorthands = {}\n\n// sm: { minWidth: 100 }\ntype GenericMedia = {\n [key: string]: {\n [key: string]: number | string\n }\n}\n\nexport type GenericFonts = Record<string, GenericFont>\n\ntype GenericAnimations = {\n [key: string]:\n | string\n | {\n [key: string]: any\n }\n | any[]\n}\n\n// this is the \"main\" typed object, which users re-define\n// (internal) keep all types directly on this object and reference them from elsewhere\n//\n// const config = createTamagui(...)\n// type MyConfig = typeof config\n// declare module 'tamagui' {\n// export interface TamaguiCustomConfig extends MyConfig {}\n// }\n// now your whole app/kit should be typed correctly\n//\nexport interface TamaguiCustomConfig {}\n\nexport interface TamaguiConfig\n extends Omit<GenericTamaguiConfig, keyof TamaguiCustomConfig>,\n TamaguiCustomConfig {}\n\nexport type CreateTamaguiConfig<\n A extends GenericTokens,\n B extends GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = {\n fonts: RemoveLanguagePostfixes<F>\n fontLanguages: GetLanguagePostfixes<F> extends never ? string[] : GetLanguagePostfixes<F>[]\n tokens: A\n // parsed\n themes: {\n [Name in keyof B]: {\n [Key in keyof B[Name]]: Variable\n }\n }\n shorthands: C\n media: D\n animations: AnimationDriver<E>\n}\n\ntype GetLanguagePostfix<Set> = Set extends string\n ? Set extends `${string}_${infer Postfix}`\n ? Postfix\n : never\n : never\n\ntype OmitLanguagePostfix<Set> = Set extends string\n ? Set extends `${infer Prefix}_${string}`\n ? Prefix\n : Set\n : never\n\ntype RemoveLanguagePostfixes<F extends GenericFonts> = {\n [Key in OmitLanguagePostfix<keyof F>]: F[Key]\n}\n\ntype GetLanguagePostfixes<F extends GenericFonts> = GetLanguagePostfix<keyof F>\n\n// test RemoveLanguagePostfixes\n// type x = CreateTamaguiConfig<any, any, any, any, any, {\n// body: any,\n// body_en: any\n// }>['fonts']\n\ntype ConfProps<\n A extends GenericTokens,\n B extends GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = {\n tokens: A\n themes: B\n shorthands?: C\n media?: D\n animations?: AnimationDriver<E>\n fonts: F\n}\n\nexport type InferTamaguiConfig<Conf> = Conf extends ConfProps<\n infer A,\n infer B,\n infer C,\n infer D,\n infer E,\n infer F\n>\n ? TamaguiInternalConfig<A, B, C, D, E, F>\n : unknown\n\n// for use in creation functions so it doesnt get overwrtitten\nexport type GenericTamaguiConfig = CreateTamaguiConfig<\n GenericTokens,\n GenericThemes,\n GenericShorthands,\n GenericMedia,\n GenericAnimations,\n GenericFonts\n>\n\n// since TamaguiConfig will be re-declared, these will all be typed globally\nexport type ThemeDefinition = TamaguiConfig['themes'][keyof TamaguiConfig['themes']]\nexport type ThemeKeys = keyof ThemeDefinition\nexport type ThemeParsed = {\n [key in ThemeKeys]: Variable<any>\n}\nexport type Tokens = TamaguiConfig['tokens']\nexport type Shorthands = TamaguiConfig['shorthands']\nexport type Media = TamaguiConfig['media']\nexport type Themes = TamaguiConfig['themes']\nexport type ThemeName = Exclude<GetAltThemeNames<keyof Themes>, number>\nexport type ThemeTokens = `$${ThemeKeys}`\nexport type AnimationKeys = TamaguiConfig['animations'] extends AnimationDriver<infer Config>\n ? keyof Config\n : string\nexport type FontLanguages = ArrayIntersection<TamaguiConfig['fontLanguages']>\n\nexport interface ThemeProps {\n className?: string\n disableThemeClass?: boolean\n name?: Exclude<ThemeName, number> | null\n componentName?: string\n children?: any\n reset?: boolean\n debug?: boolean | 'verbose'\n inverse?: boolean\n}\n\ntype ArrayIntersection<A extends any[]> = A[keyof A]\n\ntype GetAltThemeNames<S> = (S extends `${string}_${infer Alt}` ? GetAltThemeNames<Alt> : S) | S\n\ntype SpacerPropsBase = {\n size?: number | SpaceTokens | null\n flex?: boolean | number\n direction?: SpaceDirection\n}\ntype SpacerOwnProps = SpacerPropsBase &\n //\n WithThemeShorthandsPseudosMediaAnimation<SpacerPropsBase>\n\nexport type SpacerProps = Omit<StackProps, 'flex' | 'direction' | 'size'> &\n //\n SpacerOwnProps\n\nexport type CreateTamaguiProps = {\n reactNative?: any\n shorthands?: CreateShorthands\n media?: GenericTamaguiConfig['media']\n animations?: AnimationDriver<any>\n fonts: GenericTamaguiConfig['fonts']\n tokens: GenericTamaguiConfig['tokens']\n themes: {\n [key: string]: {\n [key: string]: string | number | Variable\n }\n }\n\n /**\n * *Advanced use case* For all CSS extracted views, this has no effect.\n *\n * For SSR compatibility on the web, Tamagui will render once with the settings\n * from `mediaQueryDefaultActive` set for all media queries. Then, it will render\n * again after the initial render using the proper media query values. This is so that\n * hydration will match perfectly with the server.\n *\n * Setting disableSSR will avoid this second render by setting the media query state\n * to the actual browser dimensions on initial load. This is only useful for client-only\n * apps.\n *\n */\n disableSSR?: boolean\n\n /**\n * Disable inserting a theme class in the DOM or context, allowing you to manually place it higher.\n * For custom use cases like integration with next-theme.\n */\n disableRootThemeClass?: boolean\n\n defaultProps?: Record<string, any> & {\n Stack?: StackProps\n Text?: TextProps\n Spacer?: SpacerProps\n }\n\n // for the first render, determines which media queries are true\n // useful for SSR\n mediaQueryDefaultActive?: Record<MediaQueryKey, boolean>\n\n // what's between each CSS style rule, set to \"\\n\" to be easier to read\n // defaults: \"\\n\" when NODE_ENV=development, \"\" otherwise\n cssStyleSeparator?: string\n\n // (Advanced)\n // on the web, tamagui treats `dark` and `light` themes as special and\n // generates extra CSS to avoid having to re-render the entire page.\n // this CSS relies on specificity hacks that multiply by your sub-themes.\n // this sets the maxiumum number of nested dark/light themes you can do\n // defaults to 3 for a balance, but can be higher if you nest them deeply.\n maxDarkLightNesting?: number\n\n // adds @media(prefers-color-scheme) media queries for dark/light\n shouldAddPrefersColorThemes?: boolean\n\n // only if you put the theme classname on the html element we have to generate diff\n themeClassNameOnRoot?: boolean\n}\n\n// this is the config generated via createTamagui()\nexport type TamaguiInternalConfig<\n A extends GenericTokens = GenericTokens,\n B extends GenericThemes = GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = Omit<CreateTamaguiProps, keyof GenericTamaguiConfig> &\n CreateTamaguiConfig<A, B, C, D, E, F> & {\n // TODO need to make it this but this breaks types, revisit\n // animations: E //AnimationDriver<E>\n // with $ prefixes for fast lookups (one time cost at startup vs every render)\n tokensParsed: CreateTokens<Variable>\n themeConfig: any\n fontsParsed: GenericFonts\n getCSS: () => string\n parsed: boolean\n inverseShorthands: Record<string, string>\n reactNative?: any\n }\n\nexport type GetAnimationKeys<A extends GenericTamaguiConfig> = keyof A['animations']\n\n// prevents const intersections from being clobbered into string, keeping the consts\nexport type UnionableString = string & {}\nexport type UnionableNumber = number & {}\nexport type PropTypes<A extends TamaguiComponent> = A extends FunctionComponent<infer Props>\n ? Props\n : unknown\n\nexport type GenericFont<Key extends number | string = number | string> = {\n size: { [key in Key]: number | Variable }\n lineHeight: Partial<{ [key in Key]: number | Variable }>\n letterSpacing: Partial<{ [key in Key]: number | Variable }>\n weight: Partial<{ [key in Key]: number | string | Variable }>\n family: string | Variable\n style?: Partial<{ [key in Key]: TextStyle['fontStyle'] | Variable }>\n transform?: Partial<{ [key in Key]: TextStyle['textTransform'] | Variable }>\n color?: Partial<{ [key in Key]: string | Variable }>\n // for native use only, lets you map to alternative fonts\n face?: Partial<{ [key in FontWeightSteps]: { normal?: string; italic?: string } }>\n}\n\n// media\nexport type MediaQueryObject = { [key: string]: string | number | string }\nexport type MediaQueryKey = keyof Media\nexport type MediaPropKeys = `$${MediaQueryKey}`\nexport type MediaQueryState = { [key in MediaPropKeys]: boolean }\nexport type MediaProps<A> = {\n [key in MediaPropKeys]?: A\n}\nexport type MediaQueries = {\n [key in MediaQueryKey]: MediaQueryObject\n}\n\nexport type TransformStyleProps = {\n x?: number\n y?: number\n perspective?: number\n scale?: number\n scaleX?: number\n scaleY?: number\n skewX?: string\n skewY?: string\n matrix?: number[]\n rotate?: string\n rotateY?: string\n rotateX?: string\n rotateZ?: string\n}\n\n// createComponent props helpers\n\n// animation=\"bouncy\"\n// animation={['bouncy', { }]}\n// { all: 'name' }\n\n// TODO can override for better types\nexport type AnimationConfigType = any\n\nexport type AnimationProp =\n | AnimationKeys\n | {\n [key: string]:\n | AnimationKeys\n | {\n type: AnimationKeys\n [key: string]: any\n }\n }\n | [\n AnimationKeys,\n {\n [key: string]:\n | AnimationKeys\n | {\n type?: AnimationKeys\n [key: string]: any\n }\n }\n ]\n\ntype GetTokenFontKeysFor<\n A extends\n | 'size'\n | 'weight'\n | 'letterSpacing'\n | 'family'\n | 'lineHeight'\n | 'transform'\n | 'style'\n | 'color'\n> = keyof TamaguiConfig['fonts']['body'][A]\n\ntype GetTokenString<A> = A extends string | number ? `$${A}` : `$${string}`\n\n// base tokens\nexport type SizeTokens = GetTokenString<keyof Tokens['size']> | number\nexport type SpaceTokens = GetTokenString<keyof Tokens['space']> | number | boolean\nexport type ColorTokens =\n | GetTokenString<keyof Tokens['color']>\n | GetTokenString<keyof ThemeParsed>\n | CSSColorNames\nexport type ZIndexTokens = GetTokenString<keyof Tokens['zIndex']> | number\nexport type RadiusTokens = GetTokenString<keyof Tokens['radius']> | number\n\n// font tokens\nexport type FontTokens = GetTokenString<keyof TamaguiConfig['fonts']>\nexport type FontSizeTokens = GetTokenString<GetTokenFontKeysFor<'size'>> | number\nexport type FontLineHeightTokens = `$${GetTokenFontKeysFor<'lineHeight'>}` | number\nexport type FontWeightSteps = `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}00`\nexport type FontWeightTokens = `$${GetTokenFontKeysFor<'weight'>}` | FontWeightSteps\nexport type FontColorTokens = `$${GetTokenFontKeysFor<'color'>}` | number\nexport type FontLetterSpacingTokens = `$${GetTokenFontKeysFor<'letterSpacing'>}` | number\nexport type FontStyleTokens = `$${GetTokenFontKeysFor<'style'>}` | TextStyle['fontStyle']\nexport type FontTransformTokens =\n | `$${GetTokenFontKeysFor<'transform'>}`\n | TextStyle['textTransform']\n\n//\n// adds theme short values to relevant props\n//\n\nexport type ThemeValueByCategory<K extends string | number | symbol> = K extends 'theme'\n ? ThemeTokens\n : K extends 'size'\n ? SizeTokens\n : K extends 'font'\n ? FontTokens\n : K extends 'fontSize'\n ? FontSizeTokens\n : K extends 'space'\n ? SpaceTokens\n : K extends 'color'\n ? ColorTokens\n : K extends 'zIndex'\n ? ZIndexTokens\n : K extends 'lineHeight'\n ? FontLineHeightTokens\n : K extends 'fontWeight'\n ? FontWeightTokens\n : K extends 'letterSpacing'\n ? FontLetterSpacingTokens\n : {}\n\ntype FontKeys = 'fontFamily'\ntype FontSizeKeys = 'fontSize'\ntype FontWeightKeys = 'fontWeight'\ntype FontLetterSpacingKeys = 'letterSpacing'\ntype LineHeightKeys = 'lineHeight'\ntype ZIndexKeys = 'zIndex'\n\nexport type ThemeValueGet<K extends string | number | symbol> = K extends 'theme'\n ? ThemeTokens\n : K extends SizeKeys\n ? SizeTokens\n : K extends FontKeys\n ? FontTokens\n : K extends FontSizeKeys\n ? FontSizeTokens\n : K extends `${`border${string | ''}Radius`}`\n ? RadiusTokens\n : K extends SpaceKeys\n ? K extends 'shadowOffset'\n ? { width: SpaceTokens; height: SpaceTokens }\n : SpaceTokens\n : K extends ColorKeys\n ? ColorTokens\n : K extends ZIndexKeys\n ? ZIndexTokens\n : K extends LineHeightKeys\n ? FontLineHeightTokens\n : K extends FontWeightKeys\n ? FontWeightTokens\n : K extends FontLetterSpacingKeys\n ? FontLetterSpacingTokens\n : never\n\nexport type ThemeValueFallback = UnionableString | Variable\n\nexport type WithThemeValues<T extends object> = {\n [K in keyof T]: ThemeValueGet<K> extends never\n ? T[K]\n : ThemeValueGet<K> | Exclude<T[K], string> | ThemeValueFallback\n}\n\n// adds shorthand props\nexport type WithShorthands<StyleProps> = {\n [Key in keyof Shorthands]?: Shorthands[Key] extends keyof StyleProps\n ? StyleProps[Shorthands[Key]] | null\n : undefined\n}\n\n// adds pseudo props\nexport type PseudoProps<A> = {\n hoverStyle?: A | null\n pressStyle?: A | null\n focusStyle?: A | null\n exitStyle?: A | null\n enterStyle?: A | null\n}\n\nexport type PseudoPropKeys = keyof PseudoProps<any>\n\nexport type PseudoStyles = {\n hoverStyle?: ViewStyle\n pressStyle?: ViewStyle\n focusStyle?: ViewStyle\n enterStyle?: ViewStyle\n exitStyle?: ViewStyle\n}\n\n//\n// add both theme and shorthands\n//\ntype WithThemeAndShorthands<A extends object> = WithThemeValues<A> &\n WithShorthands<WithThemeValues<A>>\n\n//\n// combines all of theme, shorthands, pseudos...\n//\ntype WithThemeShorthandsAndPseudos<A extends object> =\n | WithThemeAndShorthands<A> & PseudoProps<WithThemeAndShorthands<A>>\n\n//\n// ... media queries and animations\n//\ntype WithThemeShorthandsPseudosMediaAnimation<A extends object> = WithThemeShorthandsAndPseudos<A> &\n MediaProps<WithThemeShorthandsAndPseudos<A>>\n\n/**\n * Base style-only props (no media, pseudo):\n */\n\ntype StylePropsWebOnly = {\n // we make this a style prop as it is on web\n pointerEvents?: ViewProps['pointerEvents']\n // WEB ONLY\n cursor?: Properties['cursor']\n // WEB ONLY\n contain?: Properties['contain']\n // WEB ONLY values: inherit, inline, block, content\n display?: 'inherit' | 'none' | 'inline' | 'block' | 'contents' | 'flex' | 'inline-flex'\n // WEB ONLY\n userSelect?: Properties['userSelect']\n}\n\nexport type StackStylePropsBase = Omit<ViewStyle, 'display' | 'backfaceVisibility' | 'elevation'> &\n TransformStyleProps &\n StylePropsWebOnly\n\nexport type TextStylePropsBase = Omit<TextStyle, 'display' | 'backfaceVisibility'> &\n TransformStyleProps &\n StylePropsWebOnly & {\n ellipse?: boolean\n selectable?: boolean\n textDecorationDistance?: number\n textOverflow?: Properties['textOverflow']\n whiteSpace?: Properties['whiteSpace']\n wordWrap?: Properties['wordWrap']\n }\n\n//\n// Stack\n//\n\nexport type StackNonStyleProps = Omit<ViewProps, 'display' | 'children'> &\n RNWViewProps &\n TamaguiComponentPropsBase\n\nexport type StackStyleProps = WithThemeShorthandsPseudosMediaAnimation<StackStylePropsBase>\nexport type StackPropsBase = StackNonStyleProps & WithThemeAndShorthands<StackStylePropsBase>\nexport type StackProps = StackNonStyleProps & StackStyleProps\n\n//\n// Text props\n//\n\nexport type TextNonStyleProps = Omit<ReactTextProps, 'children'> &\n RNWTextProps &\n TamaguiComponentPropsBase\n\nexport type TextPropsBase = TextNonStyleProps & WithThemeAndShorthands<TextStylePropsBase>\nexport type TextStyleProps = WithThemeShorthandsPseudosMediaAnimation<TextStylePropsBase>\nexport type TextProps = TextNonStyleProps & TextStyleProps\n\n// could actually infer from parent\nexport type ViewOrTextProps = WithThemeShorthandsPseudosMediaAnimation<\n Omit<TextStylePropsBase, keyof StackStylePropsBase> & StackStylePropsBase\n>\n\n//\n// StaticComponent\n//\n\nexport type TamaguiComponent<\n Props = any,\n Ref = any,\n BaseProps = {},\n VariantProps = {}\n> = ReactComponentWithRef<Props, Ref> & StaticComponentObject\n\ntype StaticComponentObject = {\n staticConfig: StaticConfig\n /*\n * Only needed for more complex components\n * If you create a styled frame component this is a HoC to extract\n * styles from all parents.\n */\n extractable: <X>(a: X, opts?: Partial<StaticConfig>) => X\n}\n\nexport type TamaguiProviderProps = Partial<Omit<ThemeProviderProps, 'children'>> & {\n config: TamaguiInternalConfig\n disableInjectCSS?: boolean\n children?: ReactNode\n}\n\nexport type PropMapper = (\n key: string,\n value: any,\n theme: ThemeParsed,\n props: Record<string, any>,\n state: Partial<SplitStyleState>,\n languageContext?: FontLanguageProps,\n avoidDefaultProps?: boolean,\n debug?: DebugProp\n) => undefined | [string, any][]\n\nexport type StaticConfigParsed = StaticConfig & {\n parsed: true\n propMapper: PropMapper\n variantsParsed?: {\n [key: string]: {\n [key: string]: any\n }\n }\n}\n\nexport type GenericVariantDefinitions = {\n [key: string]: {\n [key: string]:\n | ((a: any, b: any) => any)\n | {\n [key: string]: any\n }\n }\n}\n\nexport type StaticConfigPublic = {\n /**\n * (compiler) If you need to pass context or something, prevents from ever\n * flattening. The 'jsx' option means it will never flatten. if you\n * pass JSX as a children (if its purely string, it will still flatten).\n */\n neverFlatten?: boolean | 'jsx'\n\n /**\n * Determines ultimate output tag (Text vs View)\n */\n isText?: boolean\n\n /**\n * Which style keys are allowed to be extracted.\n */\n validStyles?: { [key: string]: boolean }\n\n /**\n * (compiler) If these props are encountered, bail on all optimization.\n */\n deoptProps?: Set<string>\n\n /**\n * (compiler) If these props are encountered, leave them un-extracted.\n */\n inlineProps?: Set<string>\n\n /**\n * (compiler) If not flattening, leave this prop as original value.\n * Only applies to style attributes\n */\n inlineWhenUnflattened?: Set<string>\n\n /**\n * (compiler) A bit odd, only for more advanced heirarchies.\n * Indicates that the component will set this prop so the\n * static extraction can ensure it sets them to ={undefined}\n * so they get overriddent. In the future, this can be smarter.\n */\n ensureOverriddenProp?: { [key: string]: boolean }\n\n /**\n * Auto-detected, but can ovverride. Wraps children to space them on top\n */\n isZStack?: boolean\n\n /**\n * Auto-detect, but can override, passes styles properly to react-native-web\n */\n isReactNative?: boolean\n\n /**\n * By default if styled() doesn't recognize a parent Tamagui compoent or specific react-native views,\n * it will assume the passed in component only accepts style={} for react-native compatibility.\n * Setting `acceptsClassName: true` indicates Tamagui can pass in className props.\n */\n acceptsClassName?: boolean\n}\n\nexport type StaticConfig = StaticConfigPublic & {\n Component?: FunctionComponent<any> & StaticComponentObject\n\n variants?: GenericVariantDefinitions\n\n /**\n * Used for applying sub theme style\n */\n componentName?: string\n\n /**\n * Same as React.defaultProps, be sure to sync\n */\n defaultProps: Record<string, any>\n\n /**\n * Merges into defaultProps later on, used internally yonly\n */\n defaultVariants?: { [key: string]: any }\n\n /**\n * Memoize the component\n */\n memo?: boolean\n\n /**\n * Used insternally to attach default props to names\n */\n parentNames?: string[]\n\n /**\n * By default if styled() doesn't recognize a parent Tamagui compoent or specific react-native views,\n * it will assume the passed in component only accepts style={} for react-native compatibility.\n * Setting `acceptsClassName: true` indicates Tamagui can pass in className props.\n */\n acceptsClassName?: boolean\n\n /**\n * Used internally for handling focus\n */\n isInput?: boolean\n}\n\n/**\n * --------------------------------------------\n * variants\n * --------------------------------------------\n */\n\nexport type StylableComponent =\n | TamaguiComponent\n // * excessively deep type instantiation\n // | TamaguiReactElement\n | ComponentType<any>\n | ForwardRefExoticComponent<any>\n | ReactComponentWithRef<any, any>\n | (new (props: any) => any)\n | typeof View\n | typeof Text\n | typeof TextInput\n | typeof Image\n\nexport type GetStyledVariants<A extends TamaguiComponent> = A extends TamaguiComponent<\n any,\n any,\n any,\n infer Variants\n>\n ? Variants\n : never\n\nexport type GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n infer BaseProps\n>\n ? BaseProps\n : never\n\nexport type GetProps<A extends StylableComponent> = A extends TamaguiComponent<infer Props>\n ? Props\n : A extends TamaguiReactElement<infer Props>\n ? Props\n : A extends ComponentType<infer Props>\n ? GetGenericComponentTamaguiProps<Props>\n : A extends new (props: infer Props) => any\n ? GetGenericComponentTamaguiProps<Props>\n : {}\n\ntype GetGenericComponentTamaguiProps<P> = P &\n Omit<'textAlign' extends keyof P ? TextProps : StackProps, keyof P>\n\nexport type SpreadKeys =\n | '...fontSize'\n | '...fontStyle'\n | '...fontTransform'\n | '...lineHeight'\n | '...letterSpacing'\n | '...size'\n | '...space'\n | '...color'\n | '...zIndex'\n | '...theme'\n | '...radius'\n\nexport type VariantDefinitions<\n Parent extends StylableComponent = TamaguiComponent,\n MyProps extends Object = GetProps<Parent>,\n Val = any\n> = VariantDefinitionFromProps<MyProps, Val>\n\nexport type VariantDefinitionFromProps<MyProps, Val> = MyProps extends Object\n ? {\n [propName: string]:\n | VariantSpreadFunction<MyProps, Val>\n | ({\n [Key in SpreadKeys]?: Key extends '...fontSize'\n ? FontSizeVariantSpreadFunction<MyProps>\n : Key extends '...size'\n ? SizeVariantSpreadFunction<MyProps>\n : Key extends '...space'\n ? SpaceVariantSpreadFunction<MyProps>\n : Key extends '...color'\n ? ColorVariantSpreadFunction<MyProps>\n : Key extends '...lineHeight'\n ? FontLineHeightVariantSpreadFunction<MyProps>\n : Key extends '...fontTransform'\n ? FontTransformVariantSpreadFunction<MyProps>\n : Key extends '...fontStyle'\n ? FontStyleVariantSpreadFunction<MyProps>\n : Key extends '...letterSpacing'\n ? FontLetterSpacingVariantSpreadFunction<MyProps>\n : Key extends '...zIndex'\n ? ZIndexVariantSpreadFunction<MyProps>\n : Key extends '...radius'\n ? RadiusVariantSpreadFunction<MyProps>\n : Key extends '...theme'\n ? ThemeVariantSpreadFunction<MyProps>\n : never\n } & {\n [Key in string | number | 'true' | 'false']?:\n | MyProps\n | VariantSpreadFunction<MyProps, Val>\n } & {\n [Key in VariantTypeKeys]?: Key extends ':number'\n ? VariantSpreadFunction<MyProps, number>\n : Key extends ':boolean'\n ? VariantSpreadFunction<MyProps, boolean>\n : Key extends ':string'\n ? VariantSpreadFunction<MyProps, string>\n : never\n })\n }\n : never\n\nexport type GenericStackVariants = VariantDefinitionFromProps<StackProps, any>\nexport type GenericTextVariants = VariantDefinitionFromProps<StackProps, any>\n\nexport type GetVariantProps<Variants> = {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n}\n\nexport type VariantSpreadExtras<Props> = {\n fonts: TamaguiConfig['fonts']\n tokens: TamaguiConfig['tokens']\n theme: Themes extends { [key: string]: infer B } ? B : unknown\n props: Props\n}\n\ntype PropLike = { [key: string]: any }\n\nexport type VariantSpreadFunction<Props extends PropLike, Val = any> = (\n val: Val,\n config: VariantSpreadExtras<Props>\n) =>\n | {\n [Key in keyof Props]: Props[Key] | Variable\n }\n | null\n | undefined\n\nexport type VariantTypeKeys = ':string' | ':boolean' | ':number'\n\nexport type GetVariantValues<Key> = Key extends `...${infer VariantSpread}`\n ? ThemeValueByCategory<VariantSpread>\n : Key extends 'true' | 'false'\n ? boolean\n : Key extends ':string'\n ? string\n : Key extends ':boolean'\n ? boolean\n : Key extends ':number'\n ? number\n : Key\n\nexport type FontSizeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontSizeTokens\n>\nexport type SizeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, SizeTokens>\nexport type SpaceVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, SpaceTokens>\nexport type ColorVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, ColorTokens>\nexport type FontLineHeightVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontLineHeightTokens\n>\nexport type FontLetterSpacingVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontLetterSpacingTokens\n>\nexport type FontStyleVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontStyleTokens\n>\nexport type FontTransformVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontTransformTokens\n>\nexport type ZIndexVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, ZIndexTokens>\nexport type RadiusVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, RadiusTokens>\nexport type ThemeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, ThemeTokens>\n\n/**\n * --------------------------------------------\n * end variants\n * --------------------------------------------\n */\n\ntype SizeKeys =\n | 'width'\n | 'height'\n | 'minWidth'\n | 'minHeight'\n | 'maxWidth'\n | 'maxHeight'\n | 'shadowRadius'\n\ntype ColorKeys =\n | 'color'\n | 'backgroundColor'\n | 'borderColor'\n | 'borderBottomColor'\n | 'borderTopColor'\n | 'borderLeftColor'\n | 'borderRightColor'\n | 'shadowColor'\n | 'textShadowColor'\n\ntype SpaceKeys =\n | 'space'\n | 'padding'\n | 'paddingHorizontal'\n | 'paddingVertical'\n | 'paddingLeft'\n | 'paddingTop'\n | 'paddingBottom'\n | 'paddingLeft'\n | 'paddingRight'\n | 'paddingEnd'\n | 'paddingStart'\n | 'margin'\n | 'marginHorizontal'\n | 'marginVertical'\n | 'marginLeft'\n | 'marginTop'\n | 'marginBottom'\n | 'marginLeft'\n | 'marginRight'\n | 'marginEnd'\n | 'marginStart'\n | 'x'\n | 'y'\n | 'scale'\n | 'scaleX'\n | 'scaleY'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderTopStartRadius'\n | 'borderBottomEndRadius'\n | 'borderBottomLeftRadius'\n | 'borderBottomRightRadius'\n | 'borderBottomStartRadius'\n | 'borderBottomWidth'\n | 'borderLeftWidth'\n | 'borderRadius'\n | 'borderRightWidth'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderEndWidth'\n | 'borderStartWidth'\n | 'borderTopStartRadius'\n | 'borderTopWidth'\n | 'borderWidth'\n | 'left'\n | 'top'\n | 'right'\n | 'bottom'\n | 'shadowOffset'\n\ntype CSSColorNames =\n | 'aliceblue'\n | 'antiquewhite'\n | 'aqua'\n | 'aquamarine'\n | 'azure'\n | 'beige'\n | 'bisque'\n | 'black'\n | 'blanchedalmond'\n | 'blue'\n | 'blueviolet'\n | 'brown'\n | 'burlywood'\n | 'cadetblue'\n | 'chartreuse'\n | 'chocolate'\n | 'coral'\n | 'cornflowerblue'\n | 'cornsilk'\n | 'crimson'\n | 'cyan'\n | 'darkblue'\n | 'darkcyan'\n | 'darkgoldenrod'\n | 'darkgray'\n | 'darkgreen'\n | 'darkkhaki'\n | 'darkmagenta'\n | 'darkolivegreen'\n | 'darkorange'\n | 'darkorchid'\n | 'darkred'\n | 'darksalmon'\n | 'darkseagreen'\n | 'darkslateblue'\n | 'darkslategray'\n | 'darkturquoise'\n | 'darkviolet'\n | 'deeppink'\n | 'deepskyblue'\n | 'dimgray'\n | 'dodgerblue'\n | 'firebrick'\n | 'floralwhite'\n | 'forestgreen'\n | 'fuchsia'\n | 'gainsboro'\n | 'ghostwhite'\n | 'gold'\n | 'goldenrod'\n | 'gray'\n | 'green'\n | 'greenyellow'\n | 'honeydew'\n | 'hotpink'\n | 'indianred '\n | 'indigo '\n | 'ivory'\n | 'khaki'\n | 'lavender'\n | 'lavenderblush'\n | 'lawngreen'\n | 'lemonchiffon'\n | 'lightblue'\n | 'lightcoral'\n | 'lightcyan'\n | 'lightgoldenrodyellow'\n | 'lightgrey'\n | 'lightgreen'\n | 'lightpink'\n | 'lightsalmon'\n | 'lightseagreen'\n | 'lightskyblue'\n | 'lightslategray'\n | 'lightsteelblue'\n | 'lightyellow'\n | 'lime'\n | 'limegreen'\n | 'linen'\n | 'magenta'\n | 'maroon'\n | 'mediumaquamarine'\n | 'mediumblue'\n | 'mediumorchid'\n | 'mediumpurple'\n | 'mediumseagreen'\n | 'mediumslateblue'\n | 'mediumspringgreen'\n | 'mediumturquoise'\n | 'mediumvioletred'\n | 'midnightblue'\n | 'mintcream'\n | 'mistyrose'\n | 'moccasin'\n | 'navajowhite'\n | 'navy'\n | 'oldlace'\n | 'olive'\n | 'olivedrab'\n | 'orange'\n | 'orangered'\n | 'orchid'\n | 'palegoldenrod'\n | 'palegreen'\n | 'paleturquoise'\n | 'palevioletred'\n | 'papayawhip'\n | 'peachpuff'\n | 'peru'\n | 'pink'\n | 'plum'\n | 'powderblue'\n | 'purple'\n | 'red'\n | 'rosybrown'\n | 'royalblue'\n | 'saddlebrown'\n | 'salmon'\n | 'sandybrown'\n | 'seagreen'\n | 'seashell'\n | 'sienna'\n | 'silver'\n | 'skyblue'\n | 'slateblue'\n | 'slategray'\n | 'snow'\n | 'springgreen'\n | 'steelblue'\n | 'tan'\n | 'teal'\n | 'thistle'\n | 'tomato'\n | 'turquoise'\n | 'violet'\n | 'wheat'\n | 'white'\n | 'whitesmoke'\n | 'yellow'\n | 'yellowgreen'\n\nexport type TamaguiComponentState = {\n hover: boolean\n press: boolean\n pressIn: boolean\n focus: boolean\n unmounted: boolean\n mediaState?: null | Record<string, boolean>\n animation?: null | {\n style?: any\n avoidClasses?: boolean\n }\n}\n\nexport type SplitStyleState = TamaguiComponentState & {\n noClassNames?: boolean\n dynamicStylesInline?: boolean\n resolveVariablesAs?: ResolveVariableTypes\n fallbackProps?: Record<string, any>\n keepVariantsAsProps?: boolean\n hasTextAncestor?: boolean\n\n // for animations\n isExiting?: boolean\n exitVariant?: string\n enterVariant?: string\n}\n\n// Presence\n\nexport interface PresenceContextProps {\n id: string\n isPresent: boolean\n register: (id: string) => () => void\n onExitComplete?: (id: string) => void\n initial?: false | string | string[]\n custom?: any\n exitVariant?: string | null\n enterVariant?: string | null\n}\n\ntype SafeToRemoveCallback = () => void\ntype AlwaysPresent = [true, null, null]\ntype Present = [true, undefined, PresenceContextProps]\ntype NotPresent = [false, SafeToRemoveCallback, PresenceContextProps]\n\nexport type UsePresenceResult = AlwaysPresent | Present | NotPresent\n\n// Animations:\n\ntype AnimationConfig = {\n [key: string]: any\n}\n\n// includes a very limited adapter between various impls for number => style\n// this is useful only in limited scenarios like `Sheet`, but necessary in those cases\n\nexport type AnimatedNumberStrategy =\n // only values shared between reanimated/react-native for now\n | {\n type: 'spring'\n stiffness?: number\n damping?: number\n mass?: number\n overshootClamping?: boolean\n restSpeedThreshold?: number\n restDisplacementThreshold?: number\n }\n | { type: 'timing'; duration: number }\n | { type: 'direct' }\n\nexport type UniversalAnimatedNumber<A> = {\n getInstance(): A\n getValue(): number\n setValue(next: number, config?: AnimatedNumberStrategy): void\n stop(): void\n}\n\nexport type AnimationDriver<A extends AnimationConfig = AnimationConfig> = {\n isReactNative?: boolean\n useAnimations: UseAnimationHook\n usePresence: () => UsePresenceResult\n useAnimatedNumber: (initial: number) => UniversalAnimatedNumber<any>\n useAnimatedNumberStyle: <V extends UniversalAnimatedNumber<any>>(\n val: V,\n getStyle: (current: any) => any\n ) => any\n useAnimatedNumberReaction: (\n val: UniversalAnimatedNumber<any>,\n onValue: (current: number) => void\n ) => void\n animations: A\n View?: any\n Text?: any\n}\n\nexport type UseAnimationProps = TamaguiComponentPropsBase & Record<string, any>\n\nexport type UseAnimationHook = (props: {\n style: Record<string, any>\n props: Record<string, any>\n presence?: UsePresenceResult | null\n hostRef: RefObject<HTMLElement | View>\n staticConfig: StaticConfigParsed\n state: SplitStyleState\n pseudos: PseudoProps<ViewStyle>\n onDidAnimate?: any\n delay?: number\n}) => null | {\n style?: StackStylePropsBase | StackStylePropsBase[]\n}\n\nexport type GestureReponderEvent = Exclude<View['props']['onResponderMove'], void> extends (\n event: infer Event\n) => void\n ? Event\n : never\n"],
4
+ "sourcesContent": ["// TODO split this into own package @tamagui/types to share with animations packages\n\nimport type {\n Image,\n PressableProps,\n TextProps as ReactTextProps,\n Text,\n TextInput,\n TextStyle,\n View,\n ViewProps,\n ViewStyle,\n} from '@tamagui/types-react-native'\nimport type { Properties } from 'csstype'\nimport type {\n ComponentType,\n ForwardRefExoticComponent,\n FunctionComponent,\n HTMLAttributes,\n ReactNode,\n RefAttributes,\n RefObject,\n} from 'react'\n\nimport type { Variable } from './createVariable'\nimport type { ResolveVariableTypes } from './helpers/createPropMapper'\nimport type { TamaguiReactElement } from './static'\nimport type { RNWTextProps, RNWViewProps } from './types-rnw'\nimport type { FontLanguageProps } from './views/FontLanguage.types'\nimport type { ThemeProviderProps } from './views/ThemeProvider'\n\nexport type SpaceDirection = 'vertical' | 'horizontal' | 'both'\n\nexport type TamaguiElement = HTMLElement | View\n\nexport type DebugProp = boolean | 'break' | 'verbose'\n\n// base props that are accepted by createComponent (additional to react-native-web)\n\ntype DivAttributes = HTMLAttributes<HTMLDivElement>\n\nexport type TamaguiComponentPropsBase = {\n hitSlop?: PressableProps['hitSlop']\n asChild?: boolean\n space?: SpaceTokens | null\n spaceDirection?: SpaceDirection\n separator?: ReactNode\n dangerouslySetInnerHTML?: { __html: string }\n animation?: AnimationProp\n animateOnly?: string[]\n children?: any | any[]\n debug?: DebugProp\n disabled?: boolean\n className?: string\n themeShallow?: boolean\n id?: string\n tag?: string\n theme?: ThemeName | null\n componentName?: string\n /**\n * Forces the pseudo style state to be on\n */\n forceStyle?: 'hover' | 'press' | 'focus'\n onHoverIn?: DivAttributes['onMouseEnter']\n onHoverOut?: DivAttributes['onMouseLeave']\n onPress?: PressableProps['onPress']\n onPressIn?: PressableProps['onPress']\n onPressOut?: PressableProps['onPress']\n // WEB ONLY\n onMouseEnter?: DivAttributes['onMouseEnter']\n onMouseLeave?: DivAttributes['onMouseLeave']\n onMouseDown?: DivAttributes['onMouseDown']\n}\n\nexport type ReactComponentWithRef<Props, Ref> = ForwardRefExoticComponent<\n Props & RefAttributes<Ref>\n>\n\nexport type ConfigListener = (conf: TamaguiInternalConfig) => void\n\n// to prevent things from going circular, hoisting some types in this file\n// to generally order them as building up towards TamaguiConfig\n\nexport type VariableVal = number | string | Variable\nexport type VariableColorVal = string | Variable\n\ntype GenericKey = string | number | symbol\n\nexport interface CreateTokens<Val extends VariableVal = VariableVal> {\n color: { [key: GenericKey]: Val }\n space: { [key: GenericKey]: Val }\n size: { [key: GenericKey]: Val }\n radius: { [key: GenericKey]: Val }\n zIndex: { [key: GenericKey]: Val }\n}\n\nexport type TamaguiBaseTheme = {\n // defined for our tamagui kit , we could do this inside `tamagui`\n // but maybe helpful to have some sort of universally shared things +\n // + enforce if they want their own, redefine in their design sys\n background: VariableColorVal\n backgroundHover: VariableColorVal\n backgroundPress: VariableColorVal\n backgroundFocus: VariableColorVal\n color: VariableColorVal\n colorHover: VariableColorVal\n colorPress: VariableColorVal\n colorFocus: VariableColorVal\n borderColor: VariableColorVal\n borderColorHover: VariableColorVal\n borderColorPress: VariableColorVal\n borderColorFocus: VariableColorVal\n shadowColor: VariableColorVal\n shadowColorHover: VariableColorVal\n shadowColorPress: VariableColorVal\n shadowColorFocus: VariableColorVal\n}\n\ntype GenericTokens = CreateTokens\ntype GenericThemes = {\n [key: string]:\n | Partial<TamaguiBaseTheme> & {\n [key: string]: VariableVal\n }\n}\n\ntype AllStyleKeys = keyof StackStylePropsBase | keyof TextStylePropsBase\n\nexport type CreateShorthands = {\n [key: string]: AllStyleKeys\n}\n\nexport type GenericShorthands = {}\n\n// sm: { minWidth: 100 }\ntype GenericMedia = {\n [key: string]: {\n [key: string]: number | string\n }\n}\n\nexport type GenericFonts = Record<string, GenericFont>\n\ntype GenericAnimations = {\n [key: string]:\n | string\n | {\n [key: string]: any\n }\n | any[]\n}\n\n// this is the \"main\" typed object, which users re-define\n// (internal) keep all types directly on this object and reference them from elsewhere\n//\n// const config = createTamagui(...)\n// type MyConfig = typeof config\n// declare module 'tamagui' {\n// export interface TamaguiCustomConfig extends MyConfig {}\n// }\n// now your whole app/kit should be typed correctly\n//\nexport interface TamaguiCustomConfig {}\n\nexport interface TamaguiConfig\n extends Omit<GenericTamaguiConfig, keyof TamaguiCustomConfig>,\n TamaguiCustomConfig {}\n\nexport type CreateTamaguiConfig<\n A extends GenericTokens,\n B extends GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = {\n fonts: RemoveLanguagePostfixes<F>\n fontLanguages: GetLanguagePostfixes<F> extends never ? string[] : GetLanguagePostfixes<F>[]\n tokens: A\n // parsed\n themes: {\n [Name in keyof B]: {\n [Key in keyof B[Name]]: Variable\n }\n }\n shorthands: C\n media: D\n animations: AnimationDriver<E>\n}\n\ntype GetLanguagePostfix<Set> = Set extends string\n ? Set extends `${string}_${infer Postfix}`\n ? Postfix\n : never\n : never\n\ntype OmitLanguagePostfix<Set> = Set extends string\n ? Set extends `${infer Prefix}_${string}`\n ? Prefix\n : Set\n : never\n\ntype RemoveLanguagePostfixes<F extends GenericFonts> = {\n [Key in OmitLanguagePostfix<keyof F>]: F[Key]\n}\n\ntype GetLanguagePostfixes<F extends GenericFonts> = GetLanguagePostfix<keyof F>\n\n// test RemoveLanguagePostfixes\n// type x = CreateTamaguiConfig<any, any, any, any, any, {\n// body: any,\n// body_en: any\n// }>['fonts']\n\ntype ConfProps<\n A extends GenericTokens,\n B extends GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = {\n tokens: A\n themes: B\n shorthands?: C\n media?: D\n animations?: AnimationDriver<E>\n fonts: F\n}\n\nexport type InferTamaguiConfig<Conf> = Conf extends ConfProps<\n infer A,\n infer B,\n infer C,\n infer D,\n infer E,\n infer F\n>\n ? TamaguiInternalConfig<A, B, C, D, E, F>\n : unknown\n\n// for use in creation functions so it doesnt get overwrtitten\nexport type GenericTamaguiConfig = CreateTamaguiConfig<\n GenericTokens,\n GenericThemes,\n GenericShorthands,\n GenericMedia,\n GenericAnimations,\n GenericFonts\n>\n\n// since TamaguiConfig will be re-declared, these will all be typed globally\nexport type ThemeDefinition = TamaguiConfig['themes'][keyof TamaguiConfig['themes']]\nexport type ThemeKeys = keyof ThemeDefinition\nexport type ThemeParsed = {\n [key in ThemeKeys]: Variable<any>\n}\nexport type Tokens = TamaguiConfig['tokens']\nexport type Shorthands = TamaguiConfig['shorthands']\nexport type Media = TamaguiConfig['media']\nexport type Themes = TamaguiConfig['themes']\nexport type ThemeName = Exclude<GetAltThemeNames<keyof Themes>, number>\nexport type ThemeTokens = `$${ThemeKeys}`\nexport type AnimationKeys = TamaguiConfig['animations'] extends AnimationDriver<infer Config>\n ? keyof Config\n : string\nexport type FontLanguages = ArrayIntersection<TamaguiConfig['fontLanguages']>\n\nexport interface ThemeProps {\n className?: string\n disableThemeClass?: boolean\n name?: Exclude<ThemeName, number> | null\n componentName?: string\n children?: any\n reset?: boolean\n debug?: boolean | 'verbose'\n inverse?: boolean\n}\n\ntype ArrayIntersection<A extends any[]> = A[keyof A]\n\ntype GetAltThemeNames<S> = (S extends `${string}_${infer Alt}` ? GetAltThemeNames<Alt> : S) | S\n\ntype SpacerPropsBase = {\n size?: number | SpaceTokens | null\n flex?: boolean | number\n direction?: SpaceDirection\n}\ntype SpacerOwnProps = SpacerPropsBase &\n //\n WithThemeShorthandsPseudosMediaAnimation<SpacerPropsBase>\n\nexport type SpacerProps = Omit<StackProps, 'flex' | 'direction' | 'size'> &\n //\n SpacerOwnProps\n\nexport type CreateTamaguiProps = {\n reactNative?: any\n shorthands?: CreateShorthands\n media?: GenericTamaguiConfig['media']\n animations?: AnimationDriver<any>\n fonts: GenericTamaguiConfig['fonts']\n tokens: GenericTamaguiConfig['tokens']\n themes: {\n [key: string]: {\n [key: string]: string | number | Variable\n }\n }\n\n /**\n * *Advanced use case* For all CSS extracted views, this has no effect.\n *\n * For SSR compatibility on the web, Tamagui will render once with the settings\n * from `mediaQueryDefaultActive` set for all media queries. Then, it will render\n * again after the initial render using the proper media query values. This is so that\n * hydration will match perfectly with the server.\n *\n * Setting disableSSR will avoid this second render by setting the media query state\n * to the actual browser dimensions on initial load. This is only useful for client-only\n * apps.\n *\n */\n disableSSR?: boolean\n\n /**\n * Disable inserting a theme class in the DOM or context, allowing you to manually place it higher.\n * For custom use cases like integration with next-theme.\n */\n disableRootThemeClass?: boolean\n\n defaultProps?: Record<string, any> & {\n Stack?: StackProps\n Text?: TextProps\n Spacer?: SpacerProps\n }\n\n // for the first render, determines which media queries are true\n // useful for SSR\n mediaQueryDefaultActive?: Record<MediaQueryKey, boolean>\n\n // what's between each CSS style rule, set to \"\\n\" to be easier to read\n // defaults: \"\\n\" when NODE_ENV=development, \"\" otherwise\n cssStyleSeparator?: string\n\n // (Advanced)\n // on the web, tamagui treats `dark` and `light` themes as special and\n // generates extra CSS to avoid having to re-render the entire page.\n // this CSS relies on specificity hacks that multiply by your sub-themes.\n // this sets the maxiumum number of nested dark/light themes you can do\n // defaults to 3 for a balance, but can be higher if you nest them deeply.\n maxDarkLightNesting?: number\n\n // adds @media(prefers-color-scheme) media queries for dark/light\n shouldAddPrefersColorThemes?: boolean\n\n // only if you put the theme classname on the html element we have to generate diff\n themeClassNameOnRoot?: boolean\n}\n\n// this is the config generated via createTamagui()\nexport type TamaguiInternalConfig<\n A extends GenericTokens = GenericTokens,\n B extends GenericThemes = GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = Omit<CreateTamaguiProps, keyof GenericTamaguiConfig> &\n CreateTamaguiConfig<A, B, C, D, E, F> & {\n // TODO need to make it this but this breaks types, revisit\n // animations: E //AnimationDriver<E>\n // with $ prefixes for fast lookups (one time cost at startup vs every render)\n tokensParsed: CreateTokens<Variable>\n themeConfig: any\n fontsParsed: GenericFonts\n getCSS: () => string\n parsed: boolean\n inverseShorthands: Record<string, string>\n reactNative?: any\n }\n\nexport type GetAnimationKeys<A extends GenericTamaguiConfig> = keyof A['animations']\n\n// prevents const intersections from being clobbered into string, keeping the consts\nexport type UnionableString = string & {}\nexport type UnionableNumber = number & {}\nexport type PropTypes<A extends TamaguiComponent> = A extends FunctionComponent<infer Props>\n ? Props\n : unknown\n\nexport type GenericFont<Key extends number | string = number | string> = {\n size: { [key in Key]: number | Variable }\n lineHeight: Partial<{ [key in Key]: number | Variable }>\n letterSpacing: Partial<{ [key in Key]: number | Variable }>\n weight: Partial<{ [key in Key]: number | string | Variable }>\n family: string | Variable\n style?: Partial<{ [key in Key]: TextStyle['fontStyle'] | Variable }>\n transform?: Partial<{ [key in Key]: TextStyle['textTransform'] | Variable }>\n color?: Partial<{ [key in Key]: string | Variable }>\n // for native use only, lets you map to alternative fonts\n face?: Partial<{ [key in FontWeightSteps]: { normal?: string; italic?: string } }>\n}\n\n// media\nexport type MediaQueryObject = { [key: string]: string | number | string }\nexport type MediaQueryKey = keyof Media\nexport type MediaPropKeys = `$${MediaQueryKey}`\nexport type MediaQueryState = { [key in MediaPropKeys]: boolean }\nexport type MediaProps<A> = {\n [key in MediaPropKeys]?: A\n}\nexport type MediaQueries = {\n [key in MediaQueryKey]: MediaQueryObject\n}\n\nexport interface MediaQueryList {\n addListener(listener?: any): void\n removeListener(listener?: any): void\n matches: boolean\n}\n\nexport type MatchMedia = (query: string) => MediaQueryList\n\nexport type TransformStyleProps = {\n x?: number\n y?: number\n perspective?: number\n scale?: number\n scaleX?: number\n scaleY?: number\n skewX?: string\n skewY?: string\n matrix?: number[]\n rotate?: string\n rotateY?: string\n rotateX?: string\n rotateZ?: string\n}\n\n// createComponent props helpers\n\n// animation=\"bouncy\"\n// animation={['bouncy', { }]}\n// { all: 'name' }\n\n// TODO can override for better types\nexport type AnimationConfigType = any\n\nexport type AnimationProp =\n | AnimationKeys\n | {\n [key: string]:\n | AnimationKeys\n | {\n type: AnimationKeys\n [key: string]: any\n }\n }\n | [\n AnimationKeys,\n {\n [key: string]:\n | AnimationKeys\n | {\n type?: AnimationKeys\n [key: string]: any\n }\n }\n ]\n\ntype GetTokenFontKeysFor<\n A extends\n | 'size'\n | 'weight'\n | 'letterSpacing'\n | 'family'\n | 'lineHeight'\n | 'transform'\n | 'style'\n | 'color'\n> = keyof TamaguiConfig['fonts']['body'][A]\n\ntype GetTokenString<A> = A extends string | number ? `$${A}` : `$${string}`\n\n// base tokens\nexport type SizeTokens = GetTokenString<keyof Tokens['size']> | number\nexport type SpaceTokens = GetTokenString<keyof Tokens['space']> | number | boolean\nexport type ColorTokens =\n | GetTokenString<keyof Tokens['color']>\n | GetTokenString<keyof ThemeParsed>\n | CSSColorNames\nexport type ZIndexTokens = GetTokenString<keyof Tokens['zIndex']> | number\nexport type RadiusTokens = GetTokenString<keyof Tokens['radius']> | number\n\n// font tokens\nexport type FontTokens = GetTokenString<keyof TamaguiConfig['fonts']>\nexport type FontSizeTokens = GetTokenString<GetTokenFontKeysFor<'size'>> | number\nexport type FontLineHeightTokens = `$${GetTokenFontKeysFor<'lineHeight'>}` | number\nexport type FontWeightSteps = `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}00`\nexport type FontWeightTokens = `$${GetTokenFontKeysFor<'weight'>}` | FontWeightSteps\nexport type FontColorTokens = `$${GetTokenFontKeysFor<'color'>}` | number\nexport type FontLetterSpacingTokens = `$${GetTokenFontKeysFor<'letterSpacing'>}` | number\nexport type FontStyleTokens = `$${GetTokenFontKeysFor<'style'>}` | TextStyle['fontStyle']\nexport type FontTransformTokens =\n | `$${GetTokenFontKeysFor<'transform'>}`\n | TextStyle['textTransform']\n\n//\n// adds theme short values to relevant props\n//\n\nexport type ThemeValueByCategory<K extends string | number | symbol> = K extends 'theme'\n ? ThemeTokens\n : K extends 'size'\n ? SizeTokens\n : K extends 'font'\n ? FontTokens\n : K extends 'fontSize'\n ? FontSizeTokens\n : K extends 'space'\n ? SpaceTokens\n : K extends 'color'\n ? ColorTokens\n : K extends 'zIndex'\n ? ZIndexTokens\n : K extends 'lineHeight'\n ? FontLineHeightTokens\n : K extends 'fontWeight'\n ? FontWeightTokens\n : K extends 'letterSpacing'\n ? FontLetterSpacingTokens\n : {}\n\ntype FontKeys = 'fontFamily'\ntype FontSizeKeys = 'fontSize'\ntype FontWeightKeys = 'fontWeight'\ntype FontLetterSpacingKeys = 'letterSpacing'\ntype LineHeightKeys = 'lineHeight'\ntype ZIndexKeys = 'zIndex'\n\nexport type ThemeValueGet<K extends string | number | symbol> = K extends 'theme'\n ? ThemeTokens\n : K extends SizeKeys\n ? SizeTokens\n : K extends FontKeys\n ? FontTokens\n : K extends FontSizeKeys\n ? FontSizeTokens\n : K extends `${`border${string | ''}Radius`}`\n ? RadiusTokens\n : K extends SpaceKeys\n ? K extends 'shadowOffset'\n ? { width: SpaceTokens; height: SpaceTokens }\n : SpaceTokens\n : K extends ColorKeys\n ? ColorTokens\n : K extends ZIndexKeys\n ? ZIndexTokens\n : K extends LineHeightKeys\n ? FontLineHeightTokens\n : K extends FontWeightKeys\n ? FontWeightTokens\n : K extends FontLetterSpacingKeys\n ? FontLetterSpacingTokens\n : never\n\nexport type ThemeValueFallback = UnionableString | Variable\n\nexport type WithThemeValues<T extends object> = {\n [K in keyof T]: ThemeValueGet<K> extends never\n ? T[K]\n : ThemeValueGet<K> | Exclude<T[K], string> | ThemeValueFallback\n}\n\n// adds shorthand props\nexport type WithShorthands<StyleProps> = {\n [Key in keyof Shorthands]?: Shorthands[Key] extends keyof StyleProps\n ? StyleProps[Shorthands[Key]] | null\n : undefined\n}\n\n// adds pseudo props\nexport type PseudoProps<A> = {\n hoverStyle?: A | null\n pressStyle?: A | null\n focusStyle?: A | null\n exitStyle?: A | null\n enterStyle?: A | null\n}\n\nexport type PseudoPropKeys = keyof PseudoProps<any>\n\nexport type PseudoStyles = {\n hoverStyle?: ViewStyle\n pressStyle?: ViewStyle\n focusStyle?: ViewStyle\n enterStyle?: ViewStyle\n exitStyle?: ViewStyle\n}\n\n//\n// add both theme and shorthands\n//\ntype WithThemeAndShorthands<A extends object> = WithThemeValues<A> &\n WithShorthands<WithThemeValues<A>>\n\n//\n// combines all of theme, shorthands, pseudos...\n//\ntype WithThemeShorthandsAndPseudos<A extends object> =\n | WithThemeAndShorthands<A> & PseudoProps<WithThemeAndShorthands<A>>\n\n//\n// ... media queries and animations\n//\ntype WithThemeShorthandsPseudosMediaAnimation<A extends object> = WithThemeShorthandsAndPseudos<A> &\n MediaProps<WithThemeShorthandsAndPseudos<A>>\n\n/**\n * Base style-only props (no media, pseudo):\n */\n\ntype StylePropsWebOnly = {\n // we make this a style prop as it is on web\n pointerEvents?: ViewProps['pointerEvents']\n // WEB ONLY\n cursor?: Properties['cursor']\n // WEB ONLY\n contain?: Properties['contain']\n // WEB ONLY values: inherit, inline, block, content\n display?: 'inherit' | 'none' | 'inline' | 'block' | 'contents' | 'flex' | 'inline-flex'\n // WEB ONLY\n userSelect?: Properties['userSelect']\n}\n\nexport type StackStylePropsBase = Omit<ViewStyle, 'display' | 'backfaceVisibility' | 'elevation'> &\n TransformStyleProps &\n StylePropsWebOnly\n\nexport type TextStylePropsBase = Omit<TextStyle, 'display' | 'backfaceVisibility'> &\n TransformStyleProps &\n StylePropsWebOnly & {\n ellipse?: boolean\n selectable?: boolean\n textDecorationDistance?: number\n textOverflow?: Properties['textOverflow']\n whiteSpace?: Properties['whiteSpace']\n wordWrap?: Properties['wordWrap']\n }\n\n//\n// Stack\n//\n\nexport type StackNonStyleProps = Omit<ViewProps, 'display' | 'children'> &\n RNWViewProps &\n TamaguiComponentPropsBase\n\nexport type StackStyleProps = WithThemeShorthandsPseudosMediaAnimation<StackStylePropsBase>\nexport type StackPropsBase = StackNonStyleProps & WithThemeAndShorthands<StackStylePropsBase>\nexport type StackProps = StackNonStyleProps & StackStyleProps\n\n//\n// Text props\n//\n\nexport type TextNonStyleProps = Omit<ReactTextProps, 'children'> &\n RNWTextProps &\n TamaguiComponentPropsBase\n\nexport type TextPropsBase = TextNonStyleProps & WithThemeAndShorthands<TextStylePropsBase>\nexport type TextStyleProps = WithThemeShorthandsPseudosMediaAnimation<TextStylePropsBase>\nexport type TextProps = TextNonStyleProps & TextStyleProps\n\n// could actually infer from parent\nexport type ViewOrTextProps = WithThemeShorthandsPseudosMediaAnimation<\n Omit<TextStylePropsBase, keyof StackStylePropsBase> & StackStylePropsBase\n>\n\n//\n// StaticComponent\n//\n\nexport type TamaguiComponent<\n Props = any,\n Ref = any,\n BaseProps = {},\n VariantProps = {}\n> = ReactComponentWithRef<Props, Ref> & StaticComponentObject\n\ntype StaticComponentObject = {\n staticConfig: StaticConfig\n /*\n * Only needed for more complex components\n * If you create a styled frame component this is a HoC to extract\n * styles from all parents.\n */\n extractable: <X>(a: X, opts?: Partial<StaticConfig>) => X\n}\n\nexport type TamaguiProviderProps = Partial<Omit<ThemeProviderProps, 'children'>> & {\n config: TamaguiInternalConfig\n disableInjectCSS?: boolean\n children?: ReactNode\n}\n\nexport type PropMapper = (\n key: string,\n value: any,\n theme: ThemeParsed,\n props: Record<string, any>,\n state: Partial<SplitStyleState>,\n languageContext?: FontLanguageProps,\n avoidDefaultProps?: boolean,\n debug?: DebugProp\n) => undefined | [string, any][]\n\nexport type StaticConfigParsed = StaticConfig & {\n parsed: true\n propMapper: PropMapper\n variantsParsed?: {\n [key: string]: {\n [key: string]: any\n }\n }\n}\n\nexport type GenericVariantDefinitions = {\n [key: string]: {\n [key: string]:\n | ((a: any, b: any) => any)\n | {\n [key: string]: any\n }\n }\n}\n\nexport type StaticConfigPublic = {\n /**\n * (compiler) If you need to pass context or something, prevents from ever\n * flattening. The 'jsx' option means it will never flatten. if you\n * pass JSX as a children (if its purely string, it will still flatten).\n */\n neverFlatten?: boolean | 'jsx'\n\n /**\n * Determines ultimate output tag (Text vs View)\n */\n isText?: boolean\n\n /**\n * Which style keys are allowed to be extracted.\n */\n validStyles?: { [key: string]: boolean }\n\n /**\n * (compiler) If these props are encountered, bail on all optimization.\n */\n deoptProps?: Set<string>\n\n /**\n * (compiler) If these props are encountered, leave them un-extracted.\n */\n inlineProps?: Set<string>\n\n /**\n * (compiler) If not flattening, leave this prop as original value.\n * Only applies to style attributes\n */\n inlineWhenUnflattened?: Set<string>\n\n /**\n * (compiler) A bit odd, only for more advanced heirarchies.\n * Indicates that the component will set this prop so the\n * static extraction can ensure it sets them to ={undefined}\n * so they get overriddent. In the future, this can be smarter.\n */\n ensureOverriddenProp?: { [key: string]: boolean }\n\n /**\n * Auto-detected, but can ovverride. Wraps children to space them on top\n */\n isZStack?: boolean\n\n /**\n * Auto-detect, but can override, passes styles properly to react-native-web\n */\n isReactNative?: boolean\n\n /**\n * By default if styled() doesn't recognize a parent Tamagui compoent or specific react-native views,\n * it will assume the passed in component only accepts style={} for react-native compatibility.\n * Setting `acceptsClassName: true` indicates Tamagui can pass in className props.\n */\n acceptsClassName?: boolean\n}\n\nexport type StaticConfig = StaticConfigPublic & {\n Component?: FunctionComponent<any> & StaticComponentObject\n\n variants?: GenericVariantDefinitions\n\n /**\n * Used for applying sub theme style\n */\n componentName?: string\n\n /**\n * Same as React.defaultProps, be sure to sync\n */\n defaultProps: Record<string, any>\n\n /**\n * Merges into defaultProps later on, used internally yonly\n */\n defaultVariants?: { [key: string]: any }\n\n /**\n * Memoize the component\n */\n memo?: boolean\n\n /**\n * Used insternally to attach default props to names\n */\n parentNames?: string[]\n\n /**\n * By default if styled() doesn't recognize a parent Tamagui compoent or specific react-native views,\n * it will assume the passed in component only accepts style={} for react-native compatibility.\n * Setting `acceptsClassName: true` indicates Tamagui can pass in className props.\n */\n acceptsClassName?: boolean\n\n /**\n * Used internally for handling focus\n */\n isInput?: boolean\n}\n\n/**\n * --------------------------------------------\n * variants\n * --------------------------------------------\n */\n\nexport type StylableComponent =\n | TamaguiComponent\n // * excessively deep type instantiation\n // | TamaguiReactElement\n | ComponentType<any>\n | ForwardRefExoticComponent<any>\n | ReactComponentWithRef<any, any>\n | (new (props: any) => any)\n | typeof View\n | typeof Text\n | typeof TextInput\n | typeof Image\n\nexport type GetStyledVariants<A extends TamaguiComponent> = A extends TamaguiComponent<\n any,\n any,\n any,\n infer Variants\n>\n ? Variants\n : never\n\nexport type GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n infer BaseProps\n>\n ? BaseProps\n : never\n\nexport type GetProps<A extends StylableComponent> = A extends TamaguiComponent<infer Props>\n ? Props\n : A extends TamaguiReactElement<infer Props>\n ? Props\n : A extends ComponentType<infer Props>\n ? GetGenericComponentTamaguiProps<Props>\n : A extends new (props: infer Props) => any\n ? GetGenericComponentTamaguiProps<Props>\n : {}\n\ntype GetGenericComponentTamaguiProps<P> = P &\n Omit<'textAlign' extends keyof P ? TextProps : StackProps, keyof P>\n\nexport type SpreadKeys =\n | '...fontSize'\n | '...fontStyle'\n | '...fontTransform'\n | '...lineHeight'\n | '...letterSpacing'\n | '...size'\n | '...space'\n | '...color'\n | '...zIndex'\n | '...theme'\n | '...radius'\n\nexport type VariantDefinitions<\n Parent extends StylableComponent = TamaguiComponent,\n MyProps extends Object = GetProps<Parent>,\n Val = any\n> = VariantDefinitionFromProps<MyProps, Val>\n\nexport type VariantDefinitionFromProps<MyProps, Val> = MyProps extends Object\n ? {\n [propName: string]:\n | VariantSpreadFunction<MyProps, Val>\n | ({\n [Key in SpreadKeys]?: Key extends '...fontSize'\n ? FontSizeVariantSpreadFunction<MyProps>\n : Key extends '...size'\n ? SizeVariantSpreadFunction<MyProps>\n : Key extends '...space'\n ? SpaceVariantSpreadFunction<MyProps>\n : Key extends '...color'\n ? ColorVariantSpreadFunction<MyProps>\n : Key extends '...lineHeight'\n ? FontLineHeightVariantSpreadFunction<MyProps>\n : Key extends '...fontTransform'\n ? FontTransformVariantSpreadFunction<MyProps>\n : Key extends '...fontStyle'\n ? FontStyleVariantSpreadFunction<MyProps>\n : Key extends '...letterSpacing'\n ? FontLetterSpacingVariantSpreadFunction<MyProps>\n : Key extends '...zIndex'\n ? ZIndexVariantSpreadFunction<MyProps>\n : Key extends '...radius'\n ? RadiusVariantSpreadFunction<MyProps>\n : Key extends '...theme'\n ? ThemeVariantSpreadFunction<MyProps>\n : never\n } & {\n [Key in string | number | 'true' | 'false']?:\n | MyProps\n | VariantSpreadFunction<MyProps, Val>\n } & {\n [Key in VariantTypeKeys]?: Key extends ':number'\n ? VariantSpreadFunction<MyProps, number>\n : Key extends ':boolean'\n ? VariantSpreadFunction<MyProps, boolean>\n : Key extends ':string'\n ? VariantSpreadFunction<MyProps, string>\n : never\n })\n }\n : never\n\nexport type GenericStackVariants = VariantDefinitionFromProps<StackProps, any>\nexport type GenericTextVariants = VariantDefinitionFromProps<StackProps, any>\n\nexport type GetVariantProps<Variants> = {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n}\n\nexport type VariantSpreadExtras<Props> = {\n fonts: TamaguiConfig['fonts']\n tokens: TamaguiConfig['tokens']\n theme: Themes extends { [key: string]: infer B } ? B : unknown\n props: Props\n}\n\ntype PropLike = { [key: string]: any }\n\nexport type VariantSpreadFunction<Props extends PropLike, Val = any> = (\n val: Val,\n config: VariantSpreadExtras<Props>\n) =>\n | {\n [Key in keyof Props]: Props[Key] | Variable\n }\n | null\n | undefined\n\nexport type VariantTypeKeys = ':string' | ':boolean' | ':number'\n\nexport type GetVariantValues<Key> = Key extends `...${infer VariantSpread}`\n ? ThemeValueByCategory<VariantSpread>\n : Key extends 'true' | 'false'\n ? boolean\n : Key extends ':string'\n ? string\n : Key extends ':boolean'\n ? boolean\n : Key extends ':number'\n ? number\n : Key\n\nexport type FontSizeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontSizeTokens\n>\nexport type SizeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, SizeTokens>\nexport type SpaceVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, SpaceTokens>\nexport type ColorVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, ColorTokens>\nexport type FontLineHeightVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontLineHeightTokens\n>\nexport type FontLetterSpacingVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontLetterSpacingTokens\n>\nexport type FontStyleVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontStyleTokens\n>\nexport type FontTransformVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontTransformTokens\n>\nexport type ZIndexVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, ZIndexTokens>\nexport type RadiusVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, RadiusTokens>\nexport type ThemeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, ThemeTokens>\n\n/**\n * --------------------------------------------\n * end variants\n * --------------------------------------------\n */\n\ntype SizeKeys =\n | 'width'\n | 'height'\n | 'minWidth'\n | 'minHeight'\n | 'maxWidth'\n | 'maxHeight'\n | 'shadowRadius'\n\ntype ColorKeys =\n | 'color'\n | 'backgroundColor'\n | 'borderColor'\n | 'borderBottomColor'\n | 'borderTopColor'\n | 'borderLeftColor'\n | 'borderRightColor'\n | 'shadowColor'\n | 'textShadowColor'\n\ntype SpaceKeys =\n | 'space'\n | 'padding'\n | 'paddingHorizontal'\n | 'paddingVertical'\n | 'paddingLeft'\n | 'paddingTop'\n | 'paddingBottom'\n | 'paddingLeft'\n | 'paddingRight'\n | 'paddingEnd'\n | 'paddingStart'\n | 'margin'\n | 'marginHorizontal'\n | 'marginVertical'\n | 'marginLeft'\n | 'marginTop'\n | 'marginBottom'\n | 'marginLeft'\n | 'marginRight'\n | 'marginEnd'\n | 'marginStart'\n | 'x'\n | 'y'\n | 'scale'\n | 'scaleX'\n | 'scaleY'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderTopStartRadius'\n | 'borderBottomEndRadius'\n | 'borderBottomLeftRadius'\n | 'borderBottomRightRadius'\n | 'borderBottomStartRadius'\n | 'borderBottomWidth'\n | 'borderLeftWidth'\n | 'borderRadius'\n | 'borderRightWidth'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderEndWidth'\n | 'borderStartWidth'\n | 'borderTopStartRadius'\n | 'borderTopWidth'\n | 'borderWidth'\n | 'left'\n | 'top'\n | 'right'\n | 'bottom'\n | 'shadowOffset'\n\ntype CSSColorNames =\n | 'aliceblue'\n | 'antiquewhite'\n | 'aqua'\n | 'aquamarine'\n | 'azure'\n | 'beige'\n | 'bisque'\n | 'black'\n | 'blanchedalmond'\n | 'blue'\n | 'blueviolet'\n | 'brown'\n | 'burlywood'\n | 'cadetblue'\n | 'chartreuse'\n | 'chocolate'\n | 'coral'\n | 'cornflowerblue'\n | 'cornsilk'\n | 'crimson'\n | 'cyan'\n | 'darkblue'\n | 'darkcyan'\n | 'darkgoldenrod'\n | 'darkgray'\n | 'darkgreen'\n | 'darkkhaki'\n | 'darkmagenta'\n | 'darkolivegreen'\n | 'darkorange'\n | 'darkorchid'\n | 'darkred'\n | 'darksalmon'\n | 'darkseagreen'\n | 'darkslateblue'\n | 'darkslategray'\n | 'darkturquoise'\n | 'darkviolet'\n | 'deeppink'\n | 'deepskyblue'\n | 'dimgray'\n | 'dodgerblue'\n | 'firebrick'\n | 'floralwhite'\n | 'forestgreen'\n | 'fuchsia'\n | 'gainsboro'\n | 'ghostwhite'\n | 'gold'\n | 'goldenrod'\n | 'gray'\n | 'green'\n | 'greenyellow'\n | 'honeydew'\n | 'hotpink'\n | 'indianred '\n | 'indigo '\n | 'ivory'\n | 'khaki'\n | 'lavender'\n | 'lavenderblush'\n | 'lawngreen'\n | 'lemonchiffon'\n | 'lightblue'\n | 'lightcoral'\n | 'lightcyan'\n | 'lightgoldenrodyellow'\n | 'lightgrey'\n | 'lightgreen'\n | 'lightpink'\n | 'lightsalmon'\n | 'lightseagreen'\n | 'lightskyblue'\n | 'lightslategray'\n | 'lightsteelblue'\n | 'lightyellow'\n | 'lime'\n | 'limegreen'\n | 'linen'\n | 'magenta'\n | 'maroon'\n | 'mediumaquamarine'\n | 'mediumblue'\n | 'mediumorchid'\n | 'mediumpurple'\n | 'mediumseagreen'\n | 'mediumslateblue'\n | 'mediumspringgreen'\n | 'mediumturquoise'\n | 'mediumvioletred'\n | 'midnightblue'\n | 'mintcream'\n | 'mistyrose'\n | 'moccasin'\n | 'navajowhite'\n | 'navy'\n | 'oldlace'\n | 'olive'\n | 'olivedrab'\n | 'orange'\n | 'orangered'\n | 'orchid'\n | 'palegoldenrod'\n | 'palegreen'\n | 'paleturquoise'\n | 'palevioletred'\n | 'papayawhip'\n | 'peachpuff'\n | 'peru'\n | 'pink'\n | 'plum'\n | 'powderblue'\n | 'purple'\n | 'red'\n | 'rosybrown'\n | 'royalblue'\n | 'saddlebrown'\n | 'salmon'\n | 'sandybrown'\n | 'seagreen'\n | 'seashell'\n | 'sienna'\n | 'silver'\n | 'skyblue'\n | 'slateblue'\n | 'slategray'\n | 'snow'\n | 'springgreen'\n | 'steelblue'\n | 'tan'\n | 'teal'\n | 'thistle'\n | 'tomato'\n | 'turquoise'\n | 'violet'\n | 'wheat'\n | 'white'\n | 'whitesmoke'\n | 'yellow'\n | 'yellowgreen'\n\nexport type TamaguiComponentState = {\n hover: boolean\n press: boolean\n pressIn: boolean\n focus: boolean\n unmounted: boolean\n animation?: null | {\n style?: any\n avoidClasses?: boolean\n }\n}\n\nexport type SplitStyleState = TamaguiComponentState & {\n mediaState?: Record<string, boolean>\n noClassNames?: boolean\n dynamicStylesInline?: boolean\n resolveVariablesAs?: ResolveVariableTypes\n fallbackProps?: Record<string, any>\n keepVariantsAsProps?: boolean\n hasTextAncestor?: boolean\n\n // for animations\n isExiting?: boolean\n exitVariant?: string\n enterVariant?: string\n}\n\n// Presence\n\nexport interface PresenceContextProps {\n id: string\n isPresent: boolean\n register: (id: string) => () => void\n onExitComplete?: (id: string) => void\n initial?: false | string | string[]\n custom?: any\n exitVariant?: string | null\n enterVariant?: string | null\n}\n\ntype SafeToRemoveCallback = () => void\ntype AlwaysPresent = [true, null, null]\ntype Present = [true, undefined, PresenceContextProps]\ntype NotPresent = [false, SafeToRemoveCallback, PresenceContextProps]\n\nexport type UsePresenceResult = AlwaysPresent | Present | NotPresent\n\n// Animations:\n\ntype AnimationConfig = {\n [key: string]: any\n}\n\n// includes a very limited adapter between various impls for number => style\n// this is useful only in limited scenarios like `Sheet`, but necessary in those cases\n\nexport type AnimatedNumberStrategy =\n // only values shared between reanimated/react-native for now\n | {\n type: 'spring'\n stiffness?: number\n damping?: number\n mass?: number\n overshootClamping?: boolean\n restSpeedThreshold?: number\n restDisplacementThreshold?: number\n }\n | { type: 'timing'; duration: number }\n | { type: 'direct' }\n\nexport type UniversalAnimatedNumber<A> = {\n getInstance(): A\n getValue(): number\n setValue(next: number, config?: AnimatedNumberStrategy): void\n stop(): void\n}\n\nexport type AnimationDriver<A extends AnimationConfig = AnimationConfig> = {\n isReactNative?: boolean\n useAnimations: UseAnimationHook\n usePresence: () => UsePresenceResult\n useAnimatedNumber: (initial: number) => UniversalAnimatedNumber<any>\n useAnimatedNumberStyle: <V extends UniversalAnimatedNumber<any>>(\n val: V,\n getStyle: (current: any) => any\n ) => any\n useAnimatedNumberReaction: (\n val: UniversalAnimatedNumber<any>,\n onValue: (current: number) => void\n ) => void\n animations: A\n View?: any\n Text?: any\n}\n\nexport type UseAnimationProps = TamaguiComponentPropsBase & Record<string, any>\n\nexport type UseAnimationHook = (props: {\n style: Record<string, any>\n props: Record<string, any>\n presence?: UsePresenceResult | null\n hostRef: RefObject<HTMLElement | View>\n staticConfig: StaticConfigParsed\n state: SplitStyleState\n pseudos: PseudoProps<ViewStyle>\n onDidAnimate?: any\n delay?: number\n}) => null | {\n style?: StackStylePropsBase | StackStylePropsBase[]\n}\n\nexport type GestureReponderEvent = Exclude<View['props']['onResponderMove'], void> extends (\n event: infer Event\n) => void\n ? Event\n : never\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var import_jsx_runtime = require("react/jsx-runtime");
3
+ var import_config_default_node = require("@tamagui/config-default-node");
4
+ var import_react = require("@testing-library/react");
5
+ var import_vitest = require("vitest");
6
+ var import_createTamagui = require("../createTamagui");
7
+ var import_Stack = require("./Stack");
8
+ var import_TamaguiProvider = require("./TamaguiProvider");
9
+ process.env.TAMAGUI_TARGET = "web";
10
+ const conf = (0, import_createTamagui.createTamagui)((0, import_config_default_node.getDefaultTamaguiConfig)());
11
+ const TestStackRenders = ({
12
+ renderCount,
13
+ ...props
14
+ }) => {
15
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TamaguiProvider.TamaguiProvider, {
16
+ config: conf,
17
+ defaultTheme: "light",
18
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Stack.Stack, {
19
+ "data-test-renders": renderCount,
20
+ ...props
21
+ })
22
+ });
23
+ };
24
+ (0, import_vitest.describe)("Stack", () => {
25
+ (0, import_vitest.test)(`renders once`, async () => {
26
+ const renderCount = { current: 0 };
27
+ (0, import_react.render)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TestStackRenders, {
28
+ renderCount
29
+ }));
30
+ (0, import_vitest.expect)(renderCount.current).toBe(1);
31
+ });
32
+ });
33
+ //# sourceMappingURL=Stack.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/views/Stack.test.tsx"],
4
+ "sourcesContent": ["process.env.TAMAGUI_TARGET = 'web'\n\nimport { getDefaultTamaguiConfig } from '@tamagui/config-default-node'\nimport { render } from '@testing-library/react'\nimport { describe, expect, test } from 'vitest'\n\nimport { createTamagui } from '../createTamagui'\nimport { Stack } from './Stack'\nimport { TamaguiProvider } from './TamaguiProvider'\nimport { StackProps, configureMedia } from '..'\n\nconst conf = createTamagui(getDefaultTamaguiConfig())\n\nconst TestStackRenders = ({\n renderCount,\n ...props\n}: StackProps & { renderCount: { current: number } }) => {\n return (\n <TamaguiProvider config={conf} defaultTheme=\"light\">\n <Stack data-test-renders={renderCount} {...props} />\n </TamaguiProvider>\n )\n}\n\ndescribe('Stack', () => {\n test(`renders once`, async () => {\n const renderCount = { current: 0 }\n render(<TestStackRenders renderCount={renderCount} />)\n expect(renderCount.current).toBe(1)\n })\n\n // test(`doesn't re-render on media query change if CSS`, async () => {\n // const renderCount = { current: 0 }\n\n // render(\n // <TestStackRenders\n // renderCount={renderCount}\n // backgroundColor=\"blue\"\n // $sm={{ backgroundColor: 'red' }}\n // />\n // )\n\n // expect(renderCount.current).toBe(1)\n\n // // re-configuring re-runs the media queries...\n // configureMedia(conf)\n\n // expect(renderCount.current).toBe(1)\n // })\n\n // test(`does re-render on media query change if not CSS`, async () => {\n // const renderCount = { current: 0 }\n\n // render(\n // <TestStackRenders\n // renderCount={renderCount}\n // backgroundColor=\"blue\"\n // // @ts-ignore\n // $sm={{ space: '$2' }}\n // />\n // )\n\n // expect(renderCount.current).toBe(1)\n\n // // re-configuring re-runs the media queries...\n // // configureMedia({\n // // ...conf,\n // // media: {\n // // def\n // // },\n // // })\n // // expect(renderCount.current).toBe(2)\n // })\n})\n"],
5
+ "mappings": ";AAmBM;AAjBN,iCAAwC;AACxC,mBAAuB;AACvB,oBAAuC;AAEvC,2BAA8B;AAC9B,mBAAsB;AACtB,6BAAgC;AARhC,QAAQ,IAAI,iBAAiB;AAW7B,MAAM,WAAO,wCAAc,oDAAwB,CAAC;AAEpD,MAAM,mBAAmB,CAAC;AAAA,EACxB;AAAA,KACG;AACL,MAAyD;AACvD,SACE,4CAAC;AAAA,IAAgB,QAAQ;AAAA,IAAM,cAAa;AAAA,IAC1C,sDAAC;AAAA,MAAM,qBAAmB;AAAA,MAAc,GAAG;AAAA,KAAO;AAAA,GACpD;AAEJ;AAAA,IAEA,wBAAS,SAAS,MAAM;AACtB,0BAAK,gBAAgB,YAAY;AAC/B,UAAM,cAAc,EAAE,SAAS,EAAE;AACjC,6BAAO,4CAAC;AAAA,MAAiB;AAAA,KAA0B,CAAE;AACrD,8BAAO,YAAY,OAAO,EAAE,KAAK,CAAC;AAAA,EACpC,CAAC;AA4CH,CAAC;",
6
+ "names": []
7
+ }
@@ -24,6 +24,7 @@ import { onConfiguredOnce } from "./config";
24
24
  import { stackDefaultStyles } from "./constants/constants";
25
25
  import { FontLanguageContext } from "./contexts/FontLanguageContext";
26
26
  import { TextAncestorContext } from "./contexts/TextAncestorContext";
27
+ import { didGetVariableValue, setDidGetVariableValue } from "./createVariable";
27
28
  import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
28
29
  import { getRect } from "./helpers/getRect";
29
30
  import { useSplitStyles } from "./helpers/getSplitStyles";
@@ -32,7 +33,7 @@ import { mergeProps } from "./helpers/mergeProps";
32
33
  import { proxyThemeVariables } from "./helpers/proxyThemeVariables";
33
34
  import { useShallowSetState } from "./helpers/useShallowSetState";
34
35
  import { measureLayout, useElementLayout } from "./hooks/useElementLayout";
35
- import { addMediaQueryListener, getInitialMediaState } from "./hooks/useMedia";
36
+ import { setMediaShouldUpdate, useMedia } from "./hooks/useMedia";
36
37
  import { useServerRef, useServerState } from "./hooks/useServerHooks";
37
38
  import { getThemeIsNewTheme, getThemeManager, useTheme } from "./hooks/useTheme";
38
39
  import { usePressability } from "./vendor/Pressability";
@@ -82,6 +83,12 @@ function createComponent(configIn, ParentComponent) {
82
83
  let defaultTag;
83
84
  const component = forwardRef((propsIn, forwardedRef) => {
84
85
  var _a, _b, _c, _d, _e, _f, _g;
86
+ if (process.env.NODE_ENV === "test") {
87
+ if (propsIn["data-test-renders"]) {
88
+ propsIn["data-test-renders"]["current"] ??= 0;
89
+ propsIn["data-test-renders"]["current"] += 1;
90
+ }
91
+ }
85
92
  let props;
86
93
  if (tamaguiDefaultProps && !propsIn.asChild) {
87
94
  props = mergeProps(tamaguiDefaultProps, propsIn)[0];
@@ -174,12 +181,17 @@ function createComponent(configIn, ParentComponent) {
174
181
  elementType = Component || elementType;
175
182
  const isStringElement = typeof elementType === "string";
176
183
  const isExiting = (presence == null ? void 0 : presence[0]) === false;
184
+ const mediaState = useMedia(
185
+ stateRef
186
+ );
187
+ setDidGetVariableValue(false);
177
188
  const splitStyles = useSplitStyles(
178
189
  props,
179
190
  staticConfig,
180
191
  theme,
181
192
  {
182
193
  ...state,
194
+ mediaState,
183
195
  noClassNames,
184
196
  dynamicStylesInline: noClassNames,
185
197
  hasTextAncestor,
@@ -191,6 +203,10 @@ function createComponent(configIn, ParentComponent) {
191
203
  elementType,
192
204
  debugProp
193
205
  );
206
+ const shouldListenForMediaChanges = didGetVariableValue() || splitStyles.hasMedia === "space" || noClassNames === true && splitStyles.hasMedia;
207
+ if (shouldListenForMediaChanges) {
208
+ setMediaShouldUpdate(stateRef, shouldListenForMediaChanges);
209
+ }
194
210
  const hostRef = useServerRef(null);
195
211
  const isAnimatedReactNativeWeb = isAnimated && avoidClassesWhileAnimating;
196
212
  if (process.env.NODE_ENV === "development") {
@@ -217,7 +233,7 @@ function createComponent(configIn, ParentComponent) {
217
233
  medias,
218
234
  style: splitStylesStyle,
219
235
  classNames,
220
- mediaKeys
236
+ space
221
237
  } = splitStyles;
222
238
  const propsWithAnimation = props;
223
239
  let animationStyles;
@@ -236,27 +252,6 @@ function createComponent(configIn, ParentComponent) {
236
252
  animationStyles = animations.style;
237
253
  }
238
254
  }
239
- useIsomorphicLayoutEffect(() => {
240
- const disposers = mediaKeys.map((key) => {
241
- return addMediaQueryListener(key, (next) => {
242
- setState((prev) => {
243
- if (prev.mediaState[key] !== next) {
244
- return {
245
- ...prev,
246
- mediaState: getMediaStateObject({
247
- ...prev.mediaState,
248
- [key]: next
249
- })
250
- };
251
- }
252
- return prev;
253
- });
254
- });
255
- });
256
- return () => {
257
- disposers.forEach((d) => d());
258
- };
259
- }, [mediaKeys.join(",")]);
260
255
  const {
261
256
  hitSlop,
262
257
  asChild,
@@ -267,7 +262,6 @@ function createComponent(configIn, ParentComponent) {
267
262
  onHoverIn,
268
263
  onHoverOut,
269
264
  themeShallow,
270
- space: spaceProp,
271
265
  spaceDirection: _spaceDirection,
272
266
  disabled: disabledProp,
273
267
  onMouseUp,
@@ -538,14 +532,6 @@ function createComponent(configIn, ParentComponent) {
538
532
  minPressDuration: 0
539
533
  }
540
534
  } : null;
541
- let space = spaceProp;
542
- if (state.mediaState && mediaKeys.length) {
543
- for (const key in state.mediaState) {
544
- if (key in state.mediaState && key in props && props[key].space !== void 0) {
545
- space = props[key].space;
546
- }
547
- }
548
- }
549
535
  const themeShouldReset = Boolean(themeShallow && themeManager && themeIsNew);
550
536
  const shouldProvideThemeManager = themeShouldReset || themeManager && themeIsNew;
551
537
  if (shouldProvideThemeManager) {
@@ -641,8 +627,7 @@ function createComponent(configIn, ParentComponent) {
641
627
  press: false,
642
628
  pressIn: false,
643
629
  focus: false,
644
- unmounted: true,
645
- mediaState: getMediaStateObject(getInitialMediaState())
630
+ unmounted: true
646
631
  };
647
632
  defaultComponentStateMounted = {
648
633
  ...defaultComponentState,
@@ -737,6 +722,7 @@ const Unspaced = (props) => {
737
722
  };
738
723
  Unspaced["isUnspaced"] = true;
739
724
  const Spacer = createComponent({
725
+ acceptsClassName: true,
740
726
  memo: true,
741
727
  componentName: "Spacer",
742
728
  validStyles,
@@ -925,9 +911,6 @@ const AbsoluteFill = createComponent({
925
911
  const dontComposePressabilityKeys = {
926
912
  onClick: true
927
913
  };
928
- function getMediaStateObject(obj) {
929
- return Object.fromEntries(Object.entries(obj).flatMap(([k, v]) => v ? [[`$${k}`, v]] : []));
930
- }
931
914
  export {
932
915
  Spacer,
933
916
  Unspaced,