@tamagui/core 1.0.1-beta.56 → 1.0.1-beta.60

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 (111) hide show
  1. package/dist/cjs/Pressability.js +28 -0
  2. package/dist/cjs/Pressability.js.map +7 -0
  3. package/dist/cjs/Pressability.native.js +28 -0
  4. package/dist/cjs/Pressability.native.js.map +7 -0
  5. package/dist/cjs/conf.js +11 -2
  6. package/dist/cjs/conf.js.map +2 -2
  7. package/dist/cjs/createComponent.js +38 -10
  8. package/dist/cjs/createComponent.js.map +2 -2
  9. package/dist/cjs/createTamagui.js +10 -44
  10. package/dist/cjs/createTamagui.js.map +2 -2
  11. package/dist/cjs/createVariables.js.map +1 -1
  12. package/dist/cjs/helpers/generateAtomicStyles.js +18 -3
  13. package/dist/cjs/helpers/generateAtomicStyles.js.map +2 -2
  14. package/dist/cjs/helpers/getSplitStyles.js +0 -1
  15. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  16. package/dist/cjs/helpers/isTamaguiComponent.js +38 -0
  17. package/dist/cjs/helpers/isTamaguiComponent.js.map +7 -0
  18. package/dist/cjs/helpers/isTamaguiElement.js +2 -8
  19. package/dist/cjs/helpers/isTamaguiElement.js.map +2 -2
  20. package/dist/cjs/helpers/registerCSSVariable.js +41 -0
  21. package/dist/cjs/helpers/registerCSSVariable.js.map +7 -0
  22. package/dist/cjs/hooks/useFeatures.js.map +2 -2
  23. package/dist/cjs/hooks/useTheme.js +1 -1
  24. package/dist/cjs/hooks/useTheme.js.map +2 -2
  25. package/dist/cjs/index.js +2 -0
  26. package/dist/cjs/index.js.map +2 -2
  27. package/dist/cjs/insertFont.js +81 -0
  28. package/dist/cjs/insertFont.js.map +7 -0
  29. package/dist/cjs/registerCSSVariable.js +41 -0
  30. package/dist/cjs/registerCSSVariable.js.map +7 -0
  31. package/dist/cjs/types.js.map +1 -1
  32. package/dist/cjs/views/Slot.js +2 -1
  33. package/dist/cjs/views/Slot.js.map +2 -2
  34. package/dist/esm/Pressability.js +5 -0
  35. package/dist/esm/Pressability.js.map +7 -0
  36. package/dist/esm/Pressability.native.js +5 -0
  37. package/dist/esm/Pressability.native.js.map +7 -0
  38. package/dist/esm/conf.js +9 -1
  39. package/dist/esm/conf.js.map +2 -2
  40. package/dist/esm/createComponent.js +42 -17
  41. package/dist/esm/createComponent.js.map +2 -2
  42. package/dist/esm/createTamagui.js +11 -41
  43. package/dist/esm/createTamagui.js.map +2 -2
  44. package/dist/esm/createVariables.js.map +1 -1
  45. package/dist/esm/helpers/generateAtomicStyles.js +4 -2
  46. package/dist/esm/helpers/generateAtomicStyles.js.map +2 -2
  47. package/dist/esm/helpers/getSplitStyles.js +0 -1
  48. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  49. package/dist/esm/helpers/isTamaguiComponent.js +16 -0
  50. package/dist/esm/helpers/isTamaguiComponent.js.map +7 -0
  51. package/dist/esm/helpers/isTamaguiElement.js +2 -8
  52. package/dist/esm/helpers/isTamaguiElement.js.map +2 -2
  53. package/dist/esm/helpers/registerCSSVariable.js +17 -0
  54. package/dist/esm/helpers/registerCSSVariable.js.map +7 -0
  55. package/dist/esm/hooks/useFeatures.js.map +2 -2
  56. package/dist/esm/hooks/useTheme.js +2 -2
  57. package/dist/esm/hooks/useTheme.js.map +2 -2
  58. package/dist/esm/index.js +2 -0
  59. package/dist/esm/index.js.map +2 -2
  60. package/dist/esm/insertFont.js +57 -0
  61. package/dist/esm/insertFont.js.map +7 -0
  62. package/dist/esm/registerCSSVariable.js +17 -0
  63. package/dist/esm/registerCSSVariable.js.map +7 -0
  64. package/dist/esm/views/Slot.js +2 -1
  65. package/dist/esm/views/Slot.js.map +2 -2
  66. package/dist/jsx/Pressability.js +4 -0
  67. package/dist/jsx/Pressability.native.js +4 -0
  68. package/dist/jsx/conf.js +9 -1
  69. package/dist/jsx/createComponent.js +42 -13
  70. package/dist/jsx/createTamagui.js +11 -41
  71. package/dist/jsx/helpers/generateAtomicStyles.js +4 -2
  72. package/dist/jsx/helpers/getSplitStyles.js +0 -1
  73. package/dist/jsx/helpers/isTamaguiComponent.js +15 -0
  74. package/dist/jsx/helpers/isTamaguiElement.js +2 -8
  75. package/dist/jsx/helpers/registerCSSVariable.js +16 -0
  76. package/dist/jsx/hooks/useTheme.js +2 -2
  77. package/dist/jsx/index.js +2 -0
  78. package/dist/jsx/insertFont.js +56 -0
  79. package/dist/jsx/registerCSSVariable.js +16 -0
  80. package/dist/jsx/views/Slot.js +2 -1
  81. package/package.json +5 -5
  82. package/types/Pressability.d.ts +2 -0
  83. package/types/Pressability.d.ts.map +1 -0
  84. package/types/Pressability.native.d.ts +2 -0
  85. package/types/Pressability.native.d.ts.map +1 -0
  86. package/types/Tamagui.d.ts +1 -3
  87. package/types/Tamagui.d.ts.map +1 -1
  88. package/types/conf.d.ts +2 -3
  89. package/types/conf.d.ts.map +1 -1
  90. package/types/createComponent.d.ts.map +1 -1
  91. package/types/createTamagui.d.ts.map +1 -1
  92. package/types/createVariables.d.ts +1 -1
  93. package/types/createVariables.d.ts.map +1 -1
  94. package/types/helpers/generateAtomicStyles.d.ts.map +1 -1
  95. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  96. package/types/helpers/getVariantExtras.d.ts +1 -3
  97. package/types/helpers/getVariantExtras.d.ts.map +1 -1
  98. package/types/helpers/isTamaguiComponent.d.ts +5 -0
  99. package/types/helpers/isTamaguiComponent.d.ts.map +1 -0
  100. package/types/helpers/isTamaguiElement.d.ts.map +1 -1
  101. package/types/helpers/registerCSSVariable.d.ts +5 -0
  102. package/types/helpers/registerCSSVariable.d.ts.map +1 -0
  103. package/types/index.d.ts +2 -0
  104. package/types/index.d.ts.map +1 -1
  105. package/types/insertFont.d.ts +6 -0
  106. package/types/insertFont.d.ts.map +1 -0
  107. package/types/registerCSSVariable.d.ts +5 -0
  108. package/types/registerCSSVariable.d.ts.map +1 -0
  109. package/types/types.d.ts +1 -1
  110. package/types/types.d.ts.map +1 -1
  111. package/types/views/Slot.d.ts.map +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/useTheme.tsx"],
4
- "sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../conf'\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport { ThemeContext } from '../ThemeContext'\nimport { GetNextThemeProps, ThemeManager, ThemeManagerContext, emptyManager } from '../ThemeManager'\nimport { ThemeName, ThemeObject } from '../types'\nimport { useConstant } from './useConstant'\n\nexport type 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}\n\ntype UseThemeState = {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdate?: any\n): ThemeObject => {\n const { name, theme, themes, themeManager, className, didChangeTheme } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.debug === 'verbose') {\n console.log(' \u00BB useTheme', { themeName, componentName, name, className })\n }\n }\n\n const state = useRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n return useMemo(() => {\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme', { themeName, theme, componentName, className })\n }\n return themes[getConfig().defaultTheme || 'light' || Object.keys(themes)[0]]\n }\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') {\n key = key.slice(1)\n }\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (!name || key === '__proto__' || typeof key === 'symbol') {\n // TODO make this pattern better\n if (key === GetThemeManager) {\n if (process.env.NODE_ENV === 'development' && props?.debug) {\n console.log('>>', { themeName, didChangeTheme, name, componentName }, themeManager)\n }\n if (!didChangeTheme) return null\n return themeManager\n }\n return Reflect.get(_, key)\n }\n if (typeof key !== 'string' || key === '$typeof') {\n return Reflect.get(_, key)\n }\n if (key === 'name') {\n return name\n }\n if (key === 'className') {\n return className\n }\n if (!themeManager) {\n console.error('No themeManager')\n return\n }\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n const val = themeManager.getValue(key)\n if (val) {\n if (state.current.isRendering) {\n state.current.keys.add(key)\n if (process.env.NODE_ENV === 'development') {\n if (props?.['debug'] === 'verbose') {\n console.log(' \u00BB tracking theme key', key)\n }\n }\n }\n return val\n }\n },\n })\n }, [name, theme, className, didChangeTheme])\n}\n\nconst GetThemeManager = Symbol('GetThemeManager')\n\nexport const getThemeManagerIfChanged = (theme: any) => {\n return theme?.[GetThemeManager]\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent?.name || '')\n\n useIsomorphicLayoutEffect(() => {\n if (!parent) return\n return parent.onChangeTheme((next, manager) => {\n const name = opts?.parent ? manager.parentName || next : next\n if (!name) return\n setName(name)\n })\n }, [parent])\n\n return name\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)?.defaultTheme\n}\n\nexport const useChangeThemeEffect = (\n name?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdateProp?: any\n) => {\n const debug = props && props['debug']\n const parentManager = useContext(ThemeManagerContext) || emptyManager\n const { themes } = useContext(ThemeContext)!\n const reset = props?.reset || false\n const getThemeProps: GetNextThemeProps = { name, componentName, themes, reset }\n const next = parentManager.getNextTheme(getThemeProps, debug)\n const forceUpdate = forceUpdateProp || useForceUpdate()\n const themeManager = useConstant<ThemeManager | null>(() => {\n if (!next) return null\n return new ThemeManager(next.name, next.theme, parentManager, reset)\n })\n\n if (typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (!themeManager) return\n if (next?.name) {\n themeManager.update(next)\n }\n return parentManager.onChangeTheme(() => {\n const next = parentManager.getNextTheme(getThemeProps, debug)\n if (!next) return\n if (themeManager.update(next)) {\n forceUpdate()\n }\n })\n }, [themes, name, componentName, debug, next?.name])\n }\n\n const didChangeTheme = next && parentManager && next.name !== parentManager.fullName\n\n return {\n ...(parentManager && {\n name: parentManager.name,\n theme: parentManager.theme,\n }),\n ...next,\n didChangeTheme,\n themes,\n themeManager,\n }\n}\n"],
5
- "mappings": ";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAkBO,MAAM,WAAW,wBACtB,WACA,eACA,OACA,gBACgB;AAChB,QAAM,EAAE,MAAM,OAAO,QAAQ,cAAc,WAAW,mBAAmB,qBACvE,WACA,eACA,OACA,WACF;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,gCAAO,WAAU,WAAW;AAC9B,cAAQ,IAAI,mBAAgB,EAAE,WAAW,eAAe,MAAM,UAAU,CAAC;AAAA,IAC3E;AAAA,EACF;AAEA,QAAM,QAAQ,OAAO;AACrB,MAAI,CAAC,MAAM,SAAS;AAClB,UAAM,UAAU;AAAA,MACd,MAAM,CAAC;AAAA,MACP,MAAM,oBAAI,IAAI;AAAA,MACd,aAAa;AAAA,IACf;AAAA,EACF;AACA,QAAM,QAAQ,cAAc;AAG5B,4BAA0B,MAAM;AAC9B,UAAM,KAAK,MAAM;AACjB,OAAG,cAAc;AACjB,UAAM,MAAM,6CAAc,KAAK,IAAI,GAAG;AACtC,QAAI,CAAC,OAAO,CAAC,aAAa,GAAG,MAAM,GAAG,GAAG;AACvC,mDAAc,MAAM,GAAG,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AACtD,QAAM,eAAe,YAAiC,MAAM;AAC1D,QAAI,CAAC;AAAM,aAAO;AAClB,WAAO,IAAI,aAAa,KAAK,MAAM,KAAK,OAAO,eAAe,KAAK;AAAA,EACrE,CAAC;AAED,MAAI,OAAO,aAAa,aAAa;AACnC,oBAAgB,MAAM;AACpB,UAAI,CAAC;AAAc;AACnB,UAAI,6BAAM,MAAM;AACd,qBAAa,OAAO,IAAI;AAAA,MAC1B;AACA,aAAO,cAAc,cAAc,MAAM;AACvC,cAAM,QAAO,cAAc,aAAa,eAAe,KAAK;AAC5D,YAAI,CAAC;AAAM;AACX,YAAI,aAAa,OAAO,KAAI,GAAG;AAC7B,sBAAY;AAAA,QACd;AAAA,MACF,CAAC;AAAA,IACH,GAAG,CAAC,QAAQ,MAAM,eAAe,OAAO,6BAAM,IAAI,CAAC;AAAA,EACrD;AAEA,QAAM,iBAAiB,QAAQ,iBAAiB,KAAK,SAAS,cAAc;AAE5E,SAAO;AAAA,IACL,GAAI,iBAAiB;AAAA,MACnB,MAAM,cAAc;AAAA,MACpB,OAAO,cAAc;AAAA,IACvB;AAAA,IACA,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF,GA9CoC;",
4
+ "sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../conf'\nimport { isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport { ThemeContext } from '../ThemeContext'\nimport { GetNextThemeProps, ThemeManager, ThemeManagerContext, emptyManager } from '../ThemeManager'\nimport { ThemeName, ThemeObject } from '../types'\nimport { useConstant } from './useConstant'\n\nexport type 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}\n\ntype UseThemeState = {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdate?: any\n): ThemeObject => {\n const { name, theme, themes, themeManager, className, didChangeTheme } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.debug === 'verbose') {\n console.log(' \u00BB useTheme', { themeName, componentName, name, className })\n }\n }\n\n const state = useRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n return useMemo(() => {\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme', { themeName, theme, componentName, className })\n }\n return themes[getConfig().defaultTheme || 'light' || Object.keys(themes)[0]]\n }\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') {\n key = key.slice(1)\n }\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (!name || key === '__proto__' || typeof key === 'symbol') {\n // TODO make this pattern better\n if (key === GetThemeManager) {\n if (process.env.NODE_ENV === 'development' && props?.debug) {\n console.log('>>', { themeName, didChangeTheme, name, componentName }, themeManager)\n }\n if (!didChangeTheme) return null\n return themeManager\n }\n return Reflect.get(_, key)\n }\n if (typeof key !== 'string' || key === '$typeof') {\n return Reflect.get(_, key)\n }\n if (key === 'name') {\n return name\n }\n if (key === 'className') {\n return className\n }\n if (!themeManager) {\n console.error('No themeManager')\n return\n }\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n const val = themeManager.getValue(key)\n if (val) {\n if (state.current.isRendering) {\n state.current.keys.add(key)\n if (process.env.NODE_ENV === 'development') {\n if (props?.['debug'] === 'verbose') {\n console.log(' \u00BB tracking theme key', key)\n }\n }\n }\n return val\n }\n },\n })\n }, [name, theme, className, didChangeTheme])\n}\n\nconst GetThemeManager = Symbol('GetThemeManager')\n\nexport const getThemeManagerIfChanged = (theme: any) => {\n return theme?.[GetThemeManager]\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent?.name || '')\n\n useIsomorphicLayoutEffect(() => {\n if (!parent) return\n return parent.onChangeTheme((next, manager) => {\n const name = opts?.parent ? manager.parentName || next : next\n if (!name) return\n setName(name)\n })\n }, [parent])\n\n return name\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)?.defaultTheme\n}\n\nexport const useChangeThemeEffect = (\n name?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdateProp?: any\n) => {\n const debug = props && props['debug']\n const parentManager = useContext(ThemeManagerContext) || emptyManager\n const { themes } = useContext(ThemeContext)!\n const reset = props?.reset || false\n const getThemeProps: GetNextThemeProps = { name, componentName, themes, reset }\n const next = parentManager.getNextTheme(getThemeProps, debug)\n const forceUpdate = forceUpdateProp || useForceUpdate()\n const themeManager = useConstant<ThemeManager | null>(() => {\n if (!next) return null\n return new ThemeManager(next.name, next.theme, parentManager, reset)\n })\n\n if (!isWeb || typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (!themeManager) return\n if (next?.name) {\n themeManager.update(next)\n }\n return parentManager.onChangeTheme(() => {\n const next = parentManager.getNextTheme(getThemeProps, debug)\n if (!next) return\n if (themeManager.update(next)) {\n forceUpdate()\n }\n })\n }, [themes, name, componentName, debug, next?.name])\n }\n\n const didChangeTheme = next && parentManager && next.name !== parentManager.fullName\n\n return {\n ...(parentManager && {\n name: parentManager.name,\n theme: parentManager.theme,\n }),\n ...next,\n didChangeTheme,\n themes,\n themeManager,\n }\n}\n"],
5
+ "mappings": ";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAkBO,MAAM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iBAAiB,KAAK,SAAS,cAAc;AAE5E,SAAO;AAAA,IACL,GAAI,iBAAiB;AAAA,MACnB,MAAM,cAAc;AAAA,MACpB,OAAO,cAAc;AAAA,IACvB;AAAA,IACA,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF,GA9CoC;",
6
6
  "names": []
7
7
  }
package/dist/esm/index.js CHANGED
@@ -7,6 +7,7 @@ export * from "./createFont";
7
7
  export * from "./createTokens";
8
8
  export * from "./createVariable";
9
9
  export * from "./createVariables";
10
+ export * from "./insertFont";
10
11
  export * from "./styled";
11
12
  export * from "./types";
12
13
  import { RNWTextProps, RNWViewProps } from "./types-rnw";
@@ -25,6 +26,7 @@ export * from "./helpers/getStylesAtomic";
25
26
  export * from "./helpers/getTextSize";
26
27
  export * from "./helpers/isObj";
27
28
  export * from "./helpers/isTamaguiElement";
29
+ export * from "./helpers/isTamaguiComponent";
28
30
  export * from "./helpers/matchMedia";
29
31
  export * from "./helpers/themeable";
30
32
  export * from "./helpers/withStaticProperties";
@@ -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 './styled'\nexport * from './types'\n// for type portability\nexport { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './conf'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport * from './constants/rnw'\n\nexport * from './helpers/calc'\nexport * from './helpers/createShallowUpdate'\nexport * from './helpers/getStackSize'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/getTextSize'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/matchMedia'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\nexport * from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useUnmountEffect'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport * from './views/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/ThemeReset'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/helpers'\n"],
5
- "mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;",
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 './styled'\nexport * from './types'\n// for type portability\nexport { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './conf'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport * from './constants/rnw'\n\nexport * from './helpers/calc'\nexport * from './helpers/createShallowUpdate'\nexport * from './helpers/getStackSize'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/getTextSize'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/isTamaguiComponent'\nexport * from './helpers/matchMedia'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\nexport * from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useUnmountEffect'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport * from './views/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/ThemeReset'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/helpers'\n"],
5
+ "mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,57 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { setConfigFont } from "./conf";
4
+ import { createFont } from "./createFont";
5
+ import { createVariables } from "./createVariables";
6
+ import { registerCSSVariable } from "./helpers/registerCSSVariable";
7
+ function insertFont(name, fontIn) {
8
+ const font = createFont(fontIn);
9
+ const tokened = createVariables(font, name);
10
+ const parsed = parseFont(tokened);
11
+ registerFontVariables(parsed);
12
+ setConfigFont(name, parsed);
13
+ return parsed;
14
+ }
15
+ __name(insertFont, "insertFont");
16
+ function parseFont(definition) {
17
+ const parsed = {};
18
+ for (const attrKey in definition) {
19
+ const attr = definition[attrKey];
20
+ if (attrKey === "family") {
21
+ parsed[attrKey] = attr;
22
+ continue;
23
+ }
24
+ parsed[attrKey] = {};
25
+ for (const key in attr) {
26
+ let val = attr[key];
27
+ if (val.val[0] === "$") {
28
+ val = val.val;
29
+ }
30
+ parsed[attrKey][`$${key}`] = val;
31
+ }
32
+ }
33
+ return parsed;
34
+ }
35
+ __name(parseFont, "parseFont");
36
+ function registerFontVariables(parsedFont) {
37
+ for (const fkey in parsedFont) {
38
+ if (fkey === "family") {
39
+ registerCSSVariable(parsedFont[fkey]);
40
+ } else {
41
+ for (const fskey in parsedFont[fkey]) {
42
+ const fval = parsedFont[fkey][fskey];
43
+ if (typeof fval === "string") {
44
+ } else {
45
+ registerCSSVariable(parsedFont[fkey][fskey]);
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
51
+ __name(registerFontVariables, "registerFontVariables");
52
+ export {
53
+ insertFont,
54
+ parseFont,
55
+ registerFontVariables
56
+ };
57
+ //# sourceMappingURL=insertFont.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/insertFont.ts"],
4
+ "sourcesContent": ["import { setConfigFont } from './conf'\nimport { createFont } from './createFont'\nimport { Variable } from './createVariable'\nimport { DeepVariableObject, createVariables } from './createVariables'\nimport { registerCSSVariable } from './helpers/registerCSSVariable'\nimport { GenericFont } from './types'\n\nexport function insertFont<A extends GenericFont>(name: string, fontIn: A): DeepVariableObject<A> {\n const font = createFont(fontIn)\n const tokened = createVariables(font, name) as GenericFont\n const parsed = parseFont(tokened) as DeepVariableObject<A>\n registerFontVariables(parsed)\n setConfigFont(name, parsed)\n return parsed\n}\n\nexport function parseFont<A extends GenericFont>(definition: A): DeepVariableObject<A> {\n const parsed: any = {}\n for (const attrKey in definition) {\n const attr = definition[attrKey]\n if (attrKey === 'family') {\n parsed[attrKey] = attr\n continue\n }\n parsed[attrKey] = {}\n for (const key in attr) {\n let val = attr[key] as any as Variable\n // is a theme reference\n if (val.val[0] === '$') {\n val = val.val\n }\n parsed[attrKey][`$${key}`] = val\n }\n }\n return parsed\n}\n\nexport function registerFontVariables(parsedFont: any) {\n for (const fkey in parsedFont) {\n if (fkey === 'family') {\n registerCSSVariable(parsedFont[fkey])\n } else {\n for (const fskey in parsedFont[fkey]) {\n const fval = parsedFont[fkey][fskey]\n if (typeof fval === 'string') {\n // no need to add its a theme reference\n // tokenRules.add(`--var()`)\n } else {\n registerCSSVariable(parsedFont[fkey][fskey])\n }\n }\n }\n }\n}\n"],
5
+ "mappings": ";;AAAA;AACA;AAEA;AACA;AAGO,oBAA2C,MAAc,QAAkC;AAChG,QAAM,OAAO,WAAW,MAAM;AAC9B,QAAM,UAAU,gBAAgB,MAAM,IAAI;AAC1C,QAAM,SAAS,UAAU,OAAO;AAChC,wBAAsB,MAAM;AAC5B,gBAAc,MAAM,MAAM;AAC1B,SAAO;AACT;AAPgB;AAST,mBAA0C,YAAsC;AACrF,QAAM,SAAc,CAAC;AACrB,aAAW,WAAW,YAAY;AAChC,UAAM,OAAO,WAAW;AACxB,QAAI,YAAY,UAAU;AACxB,aAAO,WAAW;AAClB;AAAA,IACF;AACA,WAAO,WAAW,CAAC;AACnB,eAAW,OAAO,MAAM;AACtB,UAAI,MAAM,KAAK;AAEf,UAAI,IAAI,IAAI,OAAO,KAAK;AACtB,cAAM,IAAI;AAAA,MACZ;AACA,aAAO,SAAS,IAAI,SAAS;AAAA,IAC/B;AAAA,EACF;AACA,SAAO;AACT;AAnBgB;AAqBT,+BAA+B,YAAiB;AACrD,aAAW,QAAQ,YAAY;AAC7B,QAAI,SAAS,UAAU;AACrB,0BAAoB,WAAW,KAAK;AAAA,IACtC,OAAO;AACL,iBAAW,SAAS,WAAW,OAAO;AACpC,cAAM,OAAO,WAAW,MAAM;AAC9B,YAAI,OAAO,SAAS,UAAU;AAAA,QAG9B,OAAO;AACL,8BAAoB,WAAW,MAAM,MAAM;AAAA,QAC7C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAhBgB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,17 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { createCSSVariable } from "./createVariable";
4
+ const registerCSSVariable = /* @__PURE__ */ __name((v) => {
5
+ tokensValueToVariable.set(v.val, v);
6
+ const val = `--${createCSSVariable(v.name, false)}:${typeof v.val === "number" ? `${v.val}px` : v.val}`;
7
+ tokenRules.add(val);
8
+ return val;
9
+ }, "registerCSSVariable");
10
+ const tokensValueToVariable = /* @__PURE__ */ new Map();
11
+ const tokenRules = /* @__PURE__ */ new Set();
12
+ export {
13
+ registerCSSVariable,
14
+ tokenRules,
15
+ tokensValueToVariable
16
+ };
17
+ //# sourceMappingURL=registerCSSVariable.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/registerCSSVariable.ts"],
4
+ "sourcesContent": ["import { Variable, createCSSVariable } from './createVariable'\n\nexport const registerCSSVariable = (v: Variable) => {\n tokensValueToVariable.set(v.val, v)\n const val = `--${createCSSVariable(v.name, false)}:${\n typeof v.val === 'number' ? `${v.val}px` : v.val\n }`\n tokenRules.add(val)\n return val\n}\n\nexport const tokensValueToVariable = new Map<string, Variable>()\nexport const tokenRules = new Set<string>()\n"],
5
+ "mappings": ";;AAAA;AAEO,MAAM,sBAAsB,wBAAC,MAAgB;AAClD,wBAAsB,IAAI,EAAE,KAAK,CAAC;AAClC,QAAM,MAAM,KAAK,kBAAkB,EAAE,MAAM,KAAK,KAC9C,OAAO,EAAE,QAAQ,WAAW,GAAG,EAAE,UAAU,EAAE;AAE/C,aAAW,IAAI,GAAG;AAClB,SAAO;AACT,GAPmC;AAS5B,MAAM,wBAAwB,oBAAI,IAAsB;AACxD,MAAM,aAAa,oBAAI,IAAY;",
6
+ "names": []
7
+ }
@@ -50,7 +50,7 @@ function mergeProps(child, slotProps) {
50
50
  propName = pressMap[propName];
51
51
  delete overrideProps[propName];
52
52
  }
53
- const isHandler = /^on[A-Z]/.test(propName);
53
+ const isHandler = handleRegex.test(propName);
54
54
  if (isHandler) {
55
55
  overrideProps[propName] = mergeEvent(childPropValue, slotPropValue);
56
56
  } else if (propName === "style") {
@@ -62,6 +62,7 @@ function mergeProps(child, slotProps) {
62
62
  return { ...slotProps, ...overrideProps };
63
63
  }
64
64
  __name(mergeProps, "mergeProps");
65
+ const handleRegex = /^on[A-Z]/;
65
66
  function mergeEvent(a, b) {
66
67
  return (...args) => {
67
68
  a == null ? void 0 : a(...args);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/Slot.tsx"],
4
- "sourcesContent": ["// via radix\n\nimport { composeRefs } from '@tamagui/compose-refs'\nimport * as React from 'react'\n\nimport { isWeb } from '../constants/platform'\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\nexport type SlotProps = {\n children?: React.ReactNode\n}\n\nexport const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n )\n})\n\nSlot.displayName = 'Slot'\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode\n}\n\nconst SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n\n if (React.isValidElement(children)) {\n const childProps = {\n ...mergeProps(children, slotProps),\n ref: composeRefs(forwardedRef, (children as any).ref),\n }\n return React.cloneElement(children, childProps)\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null\n})\n\nSlotClone.displayName = 'SlotClone'\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Slottable = ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>\n\n// function isSlottable(child: React.ReactNode): child is React.ReactElement {\n// return React.isValidElement(child)\n// }\n\nconst pressMap = isWeb\n ? {\n onPress: 'onClick',\n onPressOut: 'onMouseUp',\n onPressIn: 'onMouseDown',\n }\n : {}\n\nfunction mergeProps(child: any, slotProps: AnyProps) {\n const childProps = child.props\n\n // all child props should override\n const overrideProps = { ...childProps }\n const isHTMLChild = typeof child.type === 'string'\n\n if (isHTMLChild) {\n for (const key in pressMap) {\n if (key in slotProps) {\n slotProps[pressMap[key]] = slotProps[key]\n delete slotProps[key]\n }\n }\n }\n\n for (let propName in childProps) {\n const slotPropValue = slotProps[propName]\n const childPropValue = childProps[propName]\n\n if (isHTMLChild && pressMap[propName]) {\n propName = pressMap[propName]\n delete overrideProps[propName]\n }\n\n const isHandler = /^on[A-Z]/.test(propName)\n // if it's a handler, modify the override by composing the base handler\n if (isHandler) {\n overrideProps[propName] = mergeEvent(childPropValue, slotPropValue)\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue }\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ')\n }\n }\n\n return { ...slotProps, ...overrideProps }\n}\n\nexport function mergeEvent(a?: Function, b?: Function) {\n return (...args: unknown[]) => {\n a?.(...args)\n b?.(...args)\n }\n}\n"],
5
- "mappings": ";;AAEA;AACA;AAEA;AAUO,MAAM,OAAO,MAAM,WAAmC,CAAC,OAAO,iBAAiB;AACpF,QAAM,EAAE,aAAa,cAAc;AACnC,SACE,oCAAC;AAAA,IAAW,GAAG;AAAA,IAAW,KAAK;AAAA,KAC5B,QACH;AAEJ,CAAC;AAED,KAAK,cAAc;AAUnB,MAAM,YAAY,MAAM,WAAgC,CAAC,OAAO,iBAAiB;AAC/E,QAAM,EAAE,aAAa,cAAc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AAG,WAAW,GAAG,cAAc;AAC1C;AAvCS;AAyCF,oBAAoB,GAAc,GAAc;AACrD,SAAO,IAAI,SAAoB;AAC7B,2BAAI,GAAG;AACP,2BAAI,GAAG;AAAA,EACT;AACF;AALgB;",
4
+ "sourcesContent": ["// via radix\n\nimport { composeRefs } from '@tamagui/compose-refs'\nimport * as React from 'react'\n\nimport { isWeb } from '../constants/platform'\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\nexport type SlotProps = {\n children?: React.ReactNode\n}\n\nexport const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n )\n})\n\nSlot.displayName = 'Slot'\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode\n}\n\nconst SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n\n if (React.isValidElement(children)) {\n const childProps = {\n ...mergeProps(children, slotProps),\n ref: composeRefs(forwardedRef, (children as any).ref),\n }\n return React.cloneElement(children, childProps)\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null\n})\n\nSlotClone.displayName = 'SlotClone'\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Slottable = ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>\n\n// function isSlottable(child: React.ReactNode): child is React.ReactElement {\n// return React.isValidElement(child)\n// }\n\nconst pressMap = isWeb\n ? {\n onPress: 'onClick',\n onPressOut: 'onMouseUp',\n onPressIn: 'onMouseDown',\n }\n : {}\n\nfunction mergeProps(child: any, slotProps: AnyProps) {\n const childProps = child.props\n\n // all child props should override\n const overrideProps = { ...childProps }\n const isHTMLChild = typeof child.type === 'string'\n\n if (isHTMLChild) {\n for (const key in pressMap) {\n if (key in slotProps) {\n slotProps[pressMap[key]] = slotProps[key]\n delete slotProps[key]\n }\n }\n }\n\n for (let propName in childProps) {\n const slotPropValue = slotProps[propName]\n const childPropValue = childProps[propName]\n\n if (isHTMLChild && pressMap[propName]) {\n propName = pressMap[propName]\n delete overrideProps[propName]\n }\n\n const isHandler = handleRegex.test(propName)\n // if it's a handler, modify the override by composing the base handler\n if (isHandler) {\n overrideProps[propName] = mergeEvent(childPropValue, slotPropValue)\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue }\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ')\n }\n }\n\n return { ...slotProps, ...overrideProps }\n}\n\nconst handleRegex = /^on[A-Z]/\n\nexport function mergeEvent(a?: Function, b?: Function) {\n return (...args: unknown[]) => {\n a?.(...args)\n b?.(...args)\n }\n}\n"],
5
+ "mappings": ";;AAEA;AACA;AAEA;AAUO,MAAM,OAAO,MAAM,WAAmC,CAAC,OAAO,iBAAiB;AACpF,QAAM,EAAE,aAAa,cAAc;AACnC,SACE,oCAAC;AAAA,IAAW,GAAG;AAAA,IAAW,KAAK;AAAA,KAC5B,QACH;AAEJ,CAAC;AAED,KAAK,cAAc;AAUnB,MAAM,YAAY,MAAM,WAAgC,CAAC,OAAO,iBAAiB;AAC/E,QAAM,EAAE,aAAa,cAAc;AAEnC,MAAI,MAAM,eAAe,QAAQ,GAAG;AAClC,UAAM,aAAa;AAAA,MACjB,GAAG,WAAW,UAAU,SAAS;AAAA,MACjC,KAAK,YAAY,cAAe,SAAiB,GAAG;AAAA,IACtD;AACA,WAAO,MAAM,aAAa,UAAU,UAAU;AAAA,EAChD;AAEA,SAAO,MAAM,SAAS,MAAM,QAAQ,IAAI,IAAI,MAAM,SAAS,KAAK,IAAI,IAAI;AAC1E,CAAC;AAED,UAAU,cAAc;AAMjB,MAAM,YAAY,wBAAC,EAAE,eAA8C;AACxE,SAAO,0DAAG,QAAS;AACrB,GAFyB;AAYzB,MAAM,WAAW,QACb;AAAA,EACE,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,WAAW;AACb,IACA,CAAC;AAEL,oBAAoB,OAAY,WAAqB;AACnD,QAAM,aAAa,MAAM;AAGzB,QAAM,gBAAgB,EAAE,GAAG,WAAW;AACtC,QAAM,cAAc,OAAO,MAAM,SAAS;AAE1C,MAAI,aAAa;AACf,eAAW,OAAO,UAAU;AAC1B,UAAI,OAAO,WAAW;AACpB,kBAAU,SAAS,QAAQ,UAAU;AACrC,eAAO,UAAU;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AAEA,WAAS,YAAY,YAAY;AAC/B,UAAM,gBAAgB,UAAU;AAChC,UAAM,iBAAiB,WAAW;AAElC,QAAI,eAAe,SAAS,WAAW;AACrC,iBAAW,SAAS;AACpB,aAAO,cAAc;AAAA,IACvB;AAEA,UAAM,YAAY,YAAY,KAAK,QAAQ;AAE3C,QAAI,WAAW;AACb,oBAAc,YAAY,WAAW,gBAAgB,aAAa;AAAA,IACpE,WAES,aAAa,SAAS;AAC7B,oBAAc,YAAY,EAAE,GAAG,eAAe,GAAG,eAAe;AAAA,IAClE,WAAW,aAAa,aAAa;AACnC,oBAAc,YAAY,CAAC,eAAe,cAAc,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,IACpF;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,WAAW,GAAG,cAAc;AAC1C;AAvCS;AAyCT,MAAM,cAAc;AAEb,oBAAoB,GAAc,GAAc;AACrD,SAAO,IAAI,SAAoB;AAC7B,2BAAI,GAAG;AACP,2BAAI,GAAG;AAAA,EACT;AACF;AALgB;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,4 @@
1
+ const Pressability = {};
2
+ export {
3
+ Pressability
4
+ };
@@ -0,0 +1,4 @@
1
+ const Pressability = require("react-native/Libraries/Pressability/Pressability").default;
2
+ export {
3
+ Pressability
4
+ };
package/dist/jsx/conf.js CHANGED
@@ -8,6 +8,13 @@ const setConfig = /* @__PURE__ */ __name((next) => {
8
8
  configListeners.clear();
9
9
  }
10
10
  }, "setConfig");
11
+ const setConfigFont = /* @__PURE__ */ __name((name, font) => {
12
+ if (process.env.NODE_ENV === "development") {
13
+ if (!conf)
14
+ throw new Error(`Haven't called createTamagui yet`);
15
+ }
16
+ Object.assign(conf.fonts, { [name]: font });
17
+ }, "setConfigFont");
11
18
  const getHasConfigured = /* @__PURE__ */ __name(() => !!conf, "getHasConfigured");
12
19
  const getConfig = /* @__PURE__ */ __name(() => conf, "getConfig");
13
20
  const getTokens = /* @__PURE__ */ __name(() => conf.tokensParsed, "getTokens");
@@ -27,5 +34,6 @@ export {
27
34
  getThemes,
28
35
  getTokens,
29
36
  onConfiguredOnce,
30
- setConfig
37
+ setConfig,
38
+ setConfigFont
31
39
  };
@@ -1,6 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { stylePropsView, validStyles } from "@tamagui/helpers";
3
+ import { composeEventHandlers, stylePropsView, validStyles } from "@tamagui/helpers";
4
4
  import { useForceUpdate } from "@tamagui/use-force-update";
5
5
  import React, {
6
6
  Children,
@@ -10,15 +10,11 @@ import React, {
10
10
  memo,
11
11
  useCallback,
12
12
  useContext,
13
+ useMemo,
13
14
  useRef,
14
15
  useState
15
16
  } from "react";
16
- import {
17
- StyleSheet,
18
- Text,
19
- TouchableWithoutFeedback,
20
- View
21
- } from "react-native";
17
+ import { StyleSheet, Text, View } from "react-native";
22
18
  import { onConfiguredOnce } from "./conf";
23
19
  import { stackDefaultStyles } from "./constants/constants";
24
20
  import { isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
@@ -34,6 +30,7 @@ import { useIsTouchDevice } from "./hooks/useIsTouchDevice";
34
30
  import { mediaState } from "./hooks/useMedia";
35
31
  import { usePressable } from "./hooks/usePressable";
36
32
  import { getThemeManagerIfChanged, useTheme } from "./hooks/useTheme";
33
+ import { Pressability } from "./Pressability";
37
34
  import { Slot, mergeEvent } from "./views/Slot";
38
35
  import { TextAncestorContext } from "./views/TextAncestorContext";
39
36
  React["keep"];
@@ -98,7 +95,7 @@ function createComponent(configIn, ParentComponent) {
98
95
  }
99
96
  __name(addPseudoToStyles, "addPseudoToStyles");
100
97
  const component = forwardRef((propsIn, forwardedRef) => {
101
- var _a, _b, _c;
98
+ var _a, _b, _c, _d, _e;
102
99
  const props = tamaguiDefaultProps && !propsIn.asChild ? { ...tamaguiDefaultProps, ...propsIn } : propsIn;
103
100
  const { Component, isText, isZStack } = staticConfig;
104
101
  const componentName = props.componentName || staticConfig.componentName;
@@ -338,8 +335,10 @@ function createComponent(configIn, ParentComponent) {
338
335
  }
339
336
  internal.current.isMounted = true;
340
337
  return () => {
338
+ var _a2;
341
339
  mouseUps.delete(unPress);
342
340
  internal.current.isMounted = false;
341
+ (_a2 = internal.current.unmountEffects) == null ? void 0 : _a2.forEach((cb) => cb());
343
342
  };
344
343
  }, [hasEnterStyle, props.animation]);
345
344
  let styles;
@@ -395,7 +394,7 @@ function createComponent(configIn, ParentComponent) {
395
394
  viewProps.style = styles;
396
395
  }
397
396
  const initialPseudos = initialSplitStyles.pseudos;
398
- const attachPress = !!(pseudos && pseudos.pressStyle || initialPseudos && initialPseudos.pressStyle || onPress || onPressOut || onPressIn || onClick);
397
+ const attachPress = !!((pseudos == null ? void 0 : pseudos.pressStyle) || (initialPseudos == null ? void 0 : initialPseudos.pressStyle) || onPress || onPressOut || onPressIn || onClick);
399
398
  const isTouch = useIsTouchDevice();
400
399
  const isHoverable = isWeb && !isTouch;
401
400
  const attachHover = isHoverable && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
@@ -464,7 +463,17 @@ function createComponent(configIn, ParentComponent) {
464
463
  unPress();
465
464
  onClick == null ? void 0 : onClick(e);
466
465
  onPress == null ? void 0 : onPress(e);
467
- } : null
466
+ } : null,
467
+ ...!isWeb && {
468
+ cancelable: !props.rejectResponderTermination,
469
+ disabled: props.disabled !== null ? props.disabled : (_b = props.accessibilityState) == null ? void 0 : _b.disabled,
470
+ hitSlop: props.hitSlop,
471
+ delayLongPress: props.delayLongPress,
472
+ delayPressIn: props.delayPressIn,
473
+ delayPressOut: props.delayPressOut,
474
+ focusable: (_c = viewProps.focusable) != null ? _c : true,
475
+ minPressDuration: 0
476
+ }
468
477
  } : null;
469
478
  let space = spaceProp;
470
479
  if (features.enabled.mediaQuery) {
@@ -524,12 +533,32 @@ function createComponent(configIn, ParentComponent) {
524
533
  });
525
534
  }
526
535
  }
527
- content = createElement(elementType, viewProps, childEls);
536
+ const pressability = isWeb ? null : useMemo(() => {
537
+ if (attachPress && events) {
538
+ const pressability2 = new Pressability(events);
539
+ internal.current.unmountEffects = [
540
+ () => {
541
+ pressability2.reset();
542
+ }
543
+ ];
544
+ return pressability2;
545
+ }
546
+ }, []);
528
547
  if (process.env.TAMAGUI_TARGET === "native") {
529
548
  if (attachPress && events) {
530
- content = <TouchableWithoutFeedback onPressIn={events[pressInKey]} onPress={events[pressKey]} onPressOut={events[pressOutKey]}>{content}</TouchableWithoutFeedback>;
549
+ pressability.configure(events);
550
+ const eventHandlers = pressability.getEventHandlers();
551
+ for (const key in eventHandlers) {
552
+ if (key === "onBlur" || key === "onFocus") {
553
+ continue;
554
+ }
555
+ const og = props[key];
556
+ const val = eventHandlers[key];
557
+ viewProps[key] = og ? composeEventHandlers(og, val) : val;
558
+ }
531
559
  }
532
560
  }
561
+ content = createElement(elementType, viewProps, childEls);
533
562
  if (isWeb && events && attachHover) {
534
563
  content = <span className="tui_Hoverable" style={{
535
564
  display: "contents"
@@ -537,7 +566,7 @@ function createComponent(configIn, ParentComponent) {
537
566
  }
538
567
  if (process.env.NODE_ENV === "development") {
539
568
  if (props["debug"]) {
540
- console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, splitStyles, animationStyles, isStringElement, classNamesIn: (_b = props.className) == null ? void 0 : _b.split(" "), classNamesOut: (_c = viewProps.className) == null ? void 0 : _c.split(" "), events, shouldAttach, ViewComponent: elementType, viewProps, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses, animation: props.animation, style, defaultNativeStyle, initialSplitStyles, ...typeof window !== "undefined" ? { theme, themeClassName: theme.className, staticConfig, tamaguiConfig } : null });
569
+ console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, splitStyles, animationStyles, isStringElement, classNamesIn: (_d = props.className) == null ? void 0 : _d.split(" "), classNamesOut: (_e = viewProps.className) == null ? void 0 : _e.split(" "), events, shouldAttach, ViewComponent: elementType, viewProps, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses, animation: props.animation, style, defaultNativeStyle, initialSplitStyles, ...typeof window !== "undefined" ? { theme, themeClassName: theme.className, staticConfig, tamaguiConfig } : null });
541
570
  }
542
571
  }
543
572
  if (features.elements.length) {
@@ -3,11 +3,17 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3
3
  import { configListeners, getHasConfigured, setConfig } from "./conf";
4
4
  import { THEME_CLASSNAME_PREFIX } from "./constants/constants";
5
5
  import { isWeb } from "./constants/platform";
6
- import { createCSSVariable, createVariable, isVariable } from "./createVariable";
6
+ import { createVariable, isVariable } from "./createVariable";
7
7
  import { createVariables } from "./createVariables";
8
8
  import { createTamaguiProvider } from "./helpers/createTamaguiProvider";
9
9
  import { getInsertedRules } from "./helpers/insertStyleRule";
10
+ import {
11
+ registerCSSVariable,
12
+ tokenRules,
13
+ tokensValueToVariable
14
+ } from "./helpers/registerCSSVariable";
10
15
  import { configureMedia } from "./hooks/useMedia";
16
+ import { parseFont, registerFontVariables } from "./insertFont";
11
17
  const createdConfigs = /* @__PURE__ */ new WeakMap();
12
18
  function createTamagui(config) {
13
19
  if (createdConfigs.has(config)) {
@@ -21,7 +27,7 @@ function createTamagui(config) {
21
27
  throw new Error(`No themes provided to Tamagui config`);
22
28
  }
23
29
  if (!config.fonts) {
24
- throw new Error(`No fonts defined!`);
30
+ throw new Error(`No fonts provided to Tamagui config`);
25
31
  }
26
32
  }
27
33
  if (getHasConfigured()) {
@@ -35,24 +41,7 @@ function createTamagui(config) {
35
41
  const fontsParsed = (() => {
36
42
  const res = {};
37
43
  for (const familyName in fontTokens) {
38
- const definition = fontTokens[familyName];
39
- const parsed = {};
40
- for (const attrKey in definition) {
41
- const attr = definition[attrKey];
42
- if (attrKey === "family") {
43
- parsed[attrKey] = attr;
44
- continue;
45
- }
46
- parsed[attrKey] = {};
47
- for (const key in attr) {
48
- let val = attr[key];
49
- if (val.val[0] === "$") {
50
- val = val.val;
51
- }
52
- parsed[attrKey][`$${key}`] = val;
53
- }
54
- }
55
- res[`$${familyName}`] = parsed;
44
+ res[`$${familyName}`] = parseFont(fontTokens[familyName]);
56
45
  }
57
46
  return res;
58
47
  })();
@@ -60,35 +49,16 @@ function createTamagui(config) {
60
49
  var _a, _b;
61
50
  const themes = { ...config.themes };
62
51
  let cssRules = [];
63
- const tokensValueToVariable = /* @__PURE__ */ new Map();
64
52
  if (isWeb) {
65
- const tokenRules = /* @__PURE__ */ new Set();
66
- const addVar = /* @__PURE__ */ __name((v) => {
67
- tokensValueToVariable.set(v.val, v);
68
- const rule = `--${createCSSVariable(v.name, false)}:${typeof v.val === "number" ? `${v.val}px` : v.val}`;
69
- tokenRules.add(rule);
70
- }, "addVar");
71
53
  for (const key in config.tokens) {
72
54
  for (const skey in config.tokens[key]) {
73
55
  const val = config.tokens[key][skey];
74
- addVar(val);
56
+ registerCSSVariable(val);
75
57
  }
76
58
  }
77
59
  for (const key in fontsParsed) {
78
60
  const val = fontsParsed[key];
79
- for (const fkey in val) {
80
- if (fkey === "family") {
81
- addVar(val[fkey]);
82
- } else {
83
- for (const fskey in val[fkey]) {
84
- const fval = val[fkey][fskey];
85
- if (typeof fval === "string") {
86
- } else {
87
- addVar(val[fkey][fskey]);
88
- }
89
- }
90
- }
91
- }
61
+ registerFontVariables(val);
92
62
  }
93
63
  const sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
94
64
  cssRules.push(`:root {${sep}${[...tokenRules].join(`;${sep}`)}${sep}}`);
@@ -30,11 +30,13 @@ const STYLE_SHORT_FORM_EXPANSIONS = {
30
30
  margin: ["marginTop", "marginRight", "marginBottom", "marginLeft"],
31
31
  marginHorizontal: ["marginRight", "marginLeft"],
32
32
  marginVertical: ["marginTop", "marginBottom"],
33
- overflow: ["overflowX", "overflowY"],
34
33
  overscrollBehavior: ["overscrollBehaviorX", "overscrollBehaviorY"],
35
34
  padding: ["paddingTop", "paddingRight", "paddingBottom", "paddingLeft"],
36
35
  paddingHorizontal: ["paddingRight", "paddingLeft"],
37
- paddingVertical: ["paddingTop", "paddingBottom"]
36
+ paddingVertical: ["paddingTop", "paddingBottom"],
37
+ ...isWeb && {
38
+ overflow: ["overflowX", "overflowY"]
39
+ }
38
40
  };
39
41
  const generateAtomicStyles = /* @__PURE__ */ __name((style) => {
40
42
  const res = expandStyles(style);
@@ -30,7 +30,6 @@ const skipProps = {
30
30
  selectable: true,
31
31
  cursor: true,
32
32
  contain: true,
33
- pointerEvents: true,
34
33
  boxSizing: true,
35
34
  boxShadow: true
36
35
  }
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ function isTamaguiComponent(comp, name) {
4
+ const config = comp && comp["staticConfig"];
5
+ if (!config || !config.parsed)
6
+ return false;
7
+ if (name) {
8
+ return name === config.componentName;
9
+ }
10
+ return true;
11
+ }
12
+ __name(isTamaguiComponent, "isTamaguiComponent");
13
+ export {
14
+ isTamaguiComponent
15
+ };
@@ -1,15 +1,9 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
  import { isValidElement } from "react";
4
+ import { isTamaguiComponent } from "./isTamaguiComponent";
4
5
  const isTamaguiElement = /* @__PURE__ */ __name((child, name) => {
5
- var _a;
6
- const isTamagui = isValidElement(child) && !!((_a = child.type["staticConfig"]) == null ? void 0 : _a.parsed);
7
- if (!isTamagui)
8
- return false;
9
- if (name) {
10
- return name === child.type["staticConfig"].componentName;
11
- }
12
- return true;
6
+ return isValidElement(child) && isTamaguiComponent(child.type, name);
13
7
  }, "isTamaguiElement");
14
8
  export {
15
9
  isTamaguiElement
@@ -0,0 +1,16 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { createCSSVariable } from "../createVariable";
4
+ const registerCSSVariable = /* @__PURE__ */ __name((v) => {
5
+ tokensValueToVariable.set(v.val, v);
6
+ const val = `--${createCSSVariable(v.name, false)}:${typeof v.val === "number" ? `${v.val}px` : v.val}`;
7
+ tokenRules.add(val);
8
+ return val;
9
+ }, "registerCSSVariable");
10
+ const tokensValueToVariable = /* @__PURE__ */ new Map();
11
+ const tokenRules = /* @__PURE__ */ new Set();
12
+ export {
13
+ registerCSSVariable,
14
+ tokenRules,
15
+ tokensValueToVariable
16
+ };
@@ -3,7 +3,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3
3
  import { useForceUpdate } from "@tamagui/use-force-update";
4
4
  import { useContext, useLayoutEffect, useMemo, useRef, useState } from "react";
5
5
  import { getConfig } from "../conf";
6
- import { useIsomorphicLayoutEffect } from "../constants/platform";
6
+ import { isWeb, useIsomorphicLayoutEffect } from "../constants/platform";
7
7
  import { areEqualSets } from "../helpers/areEqualSets";
8
8
  import { ThemeContext } from "../ThemeContext";
9
9
  import { ThemeManager, ThemeManagerContext, emptyManager } from "../ThemeManager";
@@ -128,7 +128,7 @@ const useChangeThemeEffect = /* @__PURE__ */ __name((name, componentName, props,
128
128
  return null;
129
129
  return new ThemeManager(next.name, next.theme, parentManager, reset);
130
130
  });
131
- if (typeof document !== "undefined") {
131
+ if (!isWeb || typeof document !== "undefined") {
132
132
  useLayoutEffect(() => {
133
133
  if (!themeManager)
134
134
  return;
package/dist/jsx/index.js CHANGED
@@ -7,6 +7,7 @@ export * from "./createFont";
7
7
  export * from "./createTokens";
8
8
  export * from "./createVariable";
9
9
  export * from "./createVariables";
10
+ export * from "./insertFont";
10
11
  export * from "./styled";
11
12
  export * from "./types";
12
13
  import { RNWTextProps, RNWViewProps } from "./types-rnw";
@@ -25,6 +26,7 @@ export * from "./helpers/getStylesAtomic";
25
26
  export * from "./helpers/getTextSize";
26
27
  export * from "./helpers/isObj";
27
28
  export * from "./helpers/isTamaguiElement";
29
+ export * from "./helpers/isTamaguiComponent";
28
30
  export * from "./helpers/matchMedia";
29
31
  export * from "./helpers/themeable";
30
32
  export * from "./helpers/withStaticProperties";