@tamagui/core 1.0.1-rc.9 → 1.0.2
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.
- package/dist/cjs/config.js +3 -5
- package/dist/cjs/config.js.map +2 -2
- package/dist/cjs/constants/constants.js.map +2 -2
- package/dist/cjs/createComponent.js +25 -27
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createFont.js.map +2 -2
- package/dist/cjs/createTamagui.js +2 -1
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/helpers/ThemeManager.js +7 -17
- package/dist/cjs/helpers/ThemeManager.js.map +2 -2
- package/dist/cjs/helpers/Unwrap.js +29 -0
- package/dist/cjs/helpers/Unwrap.js.map +7 -0
- package/dist/cjs/helpers/cache.js +9 -13
- package/dist/cjs/helpers/cache.js.map +2 -2
- package/dist/cjs/helpers/expandStyle.js +29 -41
- package/dist/cjs/helpers/expandStyle.js.map +2 -2
- package/dist/cjs/helpers/getBoundingClientRect.js +3 -6
- package/dist/cjs/helpers/getBoundingClientRect.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +8 -14
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.js +12 -18
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/insertStyleRule.js +0 -2
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/isTamaguiComponent.js +2 -7
- package/dist/cjs/helpers/isTamaguiComponent.js.map +2 -2
- package/dist/cjs/helpers/mergeProps.js +1 -1
- package/dist/cjs/helpers/mergeProps.js.map +2 -2
- package/dist/cjs/hooks/getThemeUnwrapped.js +1 -4
- package/dist/cjs/hooks/getThemeUnwrapped.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +45 -50
- package/dist/cjs/hooks/useTheme.js.map +3 -3
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/views/FontLanguage.js.map +2 -2
- package/dist/cjs/views/TamaguiProvider.js +3 -0
- package/dist/cjs/views/TamaguiProvider.js.map +2 -2
- package/dist/cjs/views/Text.js +0 -5
- package/dist/cjs/views/Text.js.map +2 -2
- package/dist/cjs/views/Theme.js +15 -21
- package/dist/cjs/views/Theme.js.map +3 -3
- package/dist/cjs/views/ThemeProvider.js +5 -6
- package/dist/cjs/views/ThemeProvider.js.map +2 -2
- package/dist/esm/config.js +3 -5
- package/dist/esm/config.js.map +2 -2
- package/dist/esm/constants/constants.js.map +2 -2
- package/dist/esm/createComponent.js +26 -28
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createFont.js.map +2 -2
- package/dist/esm/createTamagui.js +2 -1
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/helpers/ThemeManager.js +7 -17
- package/dist/esm/helpers/ThemeManager.js.map +2 -2
- package/dist/esm/helpers/Unwrap.js +5 -0
- package/dist/esm/helpers/Unwrap.js.map +7 -0
- package/dist/esm/helpers/cache.js +9 -12
- package/dist/esm/helpers/cache.js.map +2 -2
- package/dist/esm/helpers/expandStyle.js +26 -38
- package/dist/esm/helpers/expandStyle.js.map +2 -2
- package/dist/esm/helpers/getBoundingClientRect.js +3 -6
- package/dist/esm/helpers/getBoundingClientRect.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +8 -14
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +12 -18
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +0 -2
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/isTamaguiComponent.js +2 -7
- package/dist/esm/helpers/isTamaguiComponent.js.map +2 -2
- package/dist/esm/helpers/mergeProps.js +1 -1
- package/dist/esm/helpers/mergeProps.js.map +2 -2
- package/dist/esm/hooks/getThemeUnwrapped.js +1 -4
- package/dist/esm/hooks/getThemeUnwrapped.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +45 -50
- package/dist/esm/hooks/useTheme.js.map +3 -3
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/views/FontLanguage.js.map +2 -2
- package/dist/esm/views/TamaguiProvider.js +3 -0
- package/dist/esm/views/TamaguiProvider.js.map +2 -2
- package/dist/esm/views/Text.js +0 -5
- package/dist/esm/views/Text.js.map +2 -2
- package/dist/esm/views/Theme.js +14 -14
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/ThemeProvider.js +5 -6
- package/dist/esm/views/ThemeProvider.js.map +2 -2
- package/package.json +13 -13
- package/src/config.ts +4 -6
- package/src/constants/constants.ts +0 -2
- package/src/createComponent.tsx +47 -43
- package/src/createFont.ts +0 -2
- package/src/createTamagui.ts +2 -1
- package/src/helpers/ThemeManager.tsx +10 -21
- package/src/helpers/cache.ts +8 -13
- package/src/helpers/expandStyle.ts +27 -41
- package/src/helpers/getBoundingClientRect.tsx +2 -5
- package/src/helpers/getSplitStyles.tsx +23 -14
- package/src/helpers/getStylesAtomic.ts +16 -24
- package/src/helpers/insertStyleRule.tsx +0 -2
- package/src/helpers/isTamaguiComponent.tsx +2 -6
- package/src/helpers/mergeProps.ts +1 -1
- package/src/hooks/getThemeUnwrapped.tsx +1 -3
- package/src/hooks/useTheme.tsx +67 -48
- package/src/styled.tsx +1 -1
- package/src/views/FontLanguage.tsx +0 -2
- package/src/views/TamaguiProvider.tsx +6 -0
- package/src/views/Text.tsx +0 -6
- package/src/views/Theme.tsx +15 -22
- package/src/views/ThemeProvider.tsx +8 -8
- package/types/createComponent.d.ts +1 -1
- package/types/helpers/ThemeManager.d.ts +1 -1
- package/types/helpers/cache.d.ts +4 -6
- package/types/hooks/useTheme.d.ts +1 -1
- package/types/views/Theme.d.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/getStylesAtomic.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Some parts adapted from react-native-web\n * Copyright (c) Nicolas Gallagher licensed under the MIT license.\n */\n\nimport { StyleObject, simpleHash } from '@tamagui/helpers'\nimport type { TextStyle, ViewStyle } from 'react-native'\n\nimport { getConfig } from '../config'\nimport { TamaguiInternalConfig } from '../types'\nimport { Style, cache } from './cache'\nimport { defaultOffset } from './expandStyles'\nimport { normalizeValueWithProperty } from './normalizeValueWithProperty.js'\nimport { PseudoDescriptor, pseudoDescriptors } from './pseudoDescriptors'\n\n// refactor this file away next...\n\ntype ViewOrTextStyle = ViewStyle | TextStyle\n\nexport type ViewStyleWithPseudos = ViewOrTextStyle & {\n hoverStyle?: ViewOrTextStyle\n pressStyle?: ViewOrTextStyle\n focusStyle?: ViewOrTextStyle\n}\n\n// matching order of the below *0\nconst pseudosOrdered = [\n pseudoDescriptors.hoverStyle,\n pseudoDescriptors.pressStyle,\n pseudoDescriptors.focusStyle,\n]\n\nexport function getStylesAtomic(stylesIn: ViewStyleWithPseudos) {\n // performance optimization\n if (!(stylesIn.hoverStyle || stylesIn.pressStyle || stylesIn.focusStyle)) {\n return getAtomicStyle(stylesIn)\n }\n\n // only for pseudos\n const { hoverStyle, pressStyle, focusStyle, ...base } = stylesIn\n let res: StyleObject[] = []\n // *1 order matched to *0\n for (const [index, style] of [hoverStyle, pressStyle, focusStyle, base].entries()) {\n if (!style) continue\n const pseudo = pseudosOrdered[index]\n res = [...res, ...getAtomicStyle(style, pseudo)]\n }\n return res\n}\n\nexport function getAtomicStyle(\n style: ViewOrTextStyle,\n pseudo?: PseudoDescriptor\n): StyleObject[] {\n if (process.env.NODE_ENV === 'development') {\n if (!style || typeof style !== 'object') {\n throw new Error(`Wrong style type: \"${typeof style}\": ${style}`)\n }\n }
|
|
5
|
-
"mappings": "AAKA,SAAsB,kBAAkB;AAGxC,SAAS,iBAAiB;AAE1B,SAAgB,aAAa;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,kCAAkC;AAC3C,SAA2B,yBAAyB;AAapD,MAAM,iBAAiB;AAAA,EACrB,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,kBAAkB;AACpB;AAEO,SAAS,gBAAgB,UAAgC;AAE9D,MAAI,EAAE,SAAS,cAAc,SAAS,cAAc,SAAS,aAAa;AACxE,WAAO,eAAe,QAAQ;AAAA,EAChC;AAGA,QAAM,EAAE,YAAY,YAAY,eAAe,KAAK,IAAI;AACxD,MAAI,MAAqB,CAAC;AAE1B,aAAW,CAAC,OAAO,KAAK,KAAK,CAAC,YAAY,YAAY,YAAY,IAAI,EAAE,QAAQ,GAAG;AACjF,QAAI,CAAC;AAAO;AACZ,UAAM,SAAS,eAAe;AAC9B,UAAM,CAAC,GAAG,KAAK,GAAG,eAAe,OAAO,MAAM,CAAC;AAAA,EACjD;AACA,SAAO;AACT;AAEO,SAAS,eACd,OACA,QACe;AACf,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,YAAM,IAAI,MAAM,sBAAsB,OAAO,WAAW,OAAO;AAAA,IACjE;AAAA,EACF
|
|
4
|
+
"sourcesContent": ["/**\n * Some parts adapted from react-native-web\n * Copyright (c) Nicolas Gallagher licensed under the MIT license.\n */\n\nimport { StyleObject, simpleHash } from '@tamagui/helpers'\nimport type { TextStyle, ViewStyle } from 'react-native'\n\nimport { getConfig } from '../config'\nimport { TamaguiInternalConfig } from '../types'\nimport { Style, cache } from './cache'\nimport { defaultOffset } from './expandStyles'\nimport { normalizeValueWithProperty } from './normalizeValueWithProperty.js'\nimport { PseudoDescriptor, pseudoDescriptors } from './pseudoDescriptors'\n\n// refactor this file away next...\n\ntype ViewOrTextStyle = ViewStyle | TextStyle\n\nexport type ViewStyleWithPseudos = ViewOrTextStyle & {\n hoverStyle?: ViewOrTextStyle\n pressStyle?: ViewOrTextStyle\n focusStyle?: ViewOrTextStyle\n}\n\n// matching order of the below *0\nconst pseudosOrdered = [\n pseudoDescriptors.hoverStyle,\n pseudoDescriptors.pressStyle,\n pseudoDescriptors.focusStyle,\n]\n\nexport function getStylesAtomic(stylesIn: ViewStyleWithPseudos) {\n // performance optimization\n if (!(stylesIn.hoverStyle || stylesIn.pressStyle || stylesIn.focusStyle)) {\n return getAtomicStyle(stylesIn)\n }\n\n // only for pseudos\n const { hoverStyle, pressStyle, focusStyle, ...base } = stylesIn\n let res: StyleObject[] = []\n // *1 order matched to *0\n for (const [index, style] of [hoverStyle, pressStyle, focusStyle, base].entries()) {\n if (!style) continue\n const pseudo = pseudosOrdered[index]\n res = [...res, ...getAtomicStyle(style, pseudo)]\n }\n return res\n}\n\nexport function getAtomicStyle(\n style: ViewOrTextStyle,\n pseudo?: PseudoDescriptor\n): StyleObject[] {\n if (process.env.NODE_ENV === 'development') {\n if (!style || typeof style !== 'object') {\n throw new Error(`Wrong style type: \"${typeof style}\": ${style}`)\n }\n }\n if (!style) return []\n return generateAtomicStyles(style, pseudo)\n}\n\nlet conf: TamaguiInternalConfig\n\nconst generateAtomicStyles = (\n styleIn: ViewStyle & TextStyle,\n pseudo?: PseudoDescriptor\n): StyleObject[] => {\n conf = conf || getConfig()\n\n // were converting to css styles\n const style = styleIn as Record<string, string | null | undefined>\n\n // transform\n if (style.transform && Array.isArray(style.transform)) {\n style.transform = style.transform\n .map(\n // { scale: 2 } => 'scale(2)'\n // { translateX: 20 } => 'translateX(20px)'\n // { matrix: [1,2,3,4,5,6] } => 'matrix(1,2,3,4,5,6)'\n (transform) => {\n const type = Object.keys(transform)[0]\n const value = transform[type]\n if (type === 'matrix' || type === 'matrix3d') {\n return `${type}(${value.join(',')})`\n }\n return `${type}(${normalizeValueWithProperty(value, type)})`\n }\n )\n .join(' ')\n }\n\n styleToCSS(style)\n\n const out: StyleObject[] = []\n for (const key in style) {\n const value = style[key]\n if (value != null && value !== undefined) {\n const uid = key + (pseudo?.name || '')\n const cachedResult = cache.get(uid, value)\n if (cachedResult !== undefined) {\n out.push(cachedResult)\n } else {\n const hash = presetHashes[value]\n ? value\n : typeof value === 'string'\n ? simpleHash(value)\n : `${value}`.replace('.', 'dot')\n\n const pseudoPrefix = pseudo ? `0${pseudo.name}-` : ''\n const shortProp = conf.inverseShorthands[key] || key\n const identifier = `_${shortProp}-${pseudoPrefix}${hash}`\n const rules = createAtomicRules(identifier, key, value, pseudo)\n const styleObject: StyleObject = {\n property: key,\n pseudo: pseudo?.name as any,\n value,\n identifier,\n rules,\n }\n\n cache.set(uid, value, styleObject)\n out.push(styleObject)\n }\n }\n }\n return out\n}\n\nconst presetHashes = {\n none: true,\n}\n\nconst n = normalizeValueWithProperty\n\nexport function styleToCSS(style: Record<string, any>) {\n // box-shadow\n const { shadowOffset, shadowRadius, shadowColor } = style\n if (style.shadowRadius !== undefined) {\n const offset = shadowOffset || defaultOffset\n const shadow = `${n(offset.width)} ${n(offset.height)} ${n(\n shadowRadius\n )} ${shadowColor}`\n style.boxShadow = style.boxShadow ? `${style.boxShadow}, ${shadow}` : shadow\n style.shadowOffset = undefined\n style.shadowRadius = undefined\n style.shadowColor = undefined\n }\n\n // text-shadow\n const { textShadowColor, textShadowOffset, textShadowRadius } = style\n if (textShadowColor || textShadowOffset || textShadowRadius) {\n const { height, width } = textShadowOffset || defaultOffset\n const radius = textShadowRadius || 0\n const color = normalizeValueWithProperty(textShadowColor, 'textShadowColor')\n if (color && (height !== 0 || width !== 0 || radius !== 0)) {\n const blurRadius = normalizeValueWithProperty(radius)\n const offsetX = normalizeValueWithProperty(width)\n const offsetY = normalizeValueWithProperty(height)\n style.textShadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`\n }\n style.textShadowColor = undefined\n style.textShadowOffset = undefined\n style.textShadowRadius = undefined\n }\n}\n\nfunction createDeclarationBlock(style: Style, important = false) {\n let next = ''\n for (const key in style) {\n const prop = hyphenateStyleName(key)\n const value = style[key]\n next += `${prop}:${value}${important ? ' !important' : ''};`\n }\n return `{${next}}`\n}\n\nconst hcache = {}\nconst toHyphenLower = (match: string) => `-${match.toLowerCase()}`\nconst hyphenateStyleName = (key: string) => {\n let val = hcache[key]\n if (val) return val\n hcache[key] = val = key.replace(/[A-Z]/g, toHyphenLower)\n return val\n}\n\nconst pseudoSelectorPrefixes = (() => {\n const res: Record<string, string> = {}\n for (const key in pseudoDescriptors) {\n const pseudo = pseudoDescriptors[key]\n res[pseudo.name] = `${[...Array(pseudo.priority)].map(() => ':root').join('')} `\n }\n return res\n})()\n\nfunction createAtomicRules(\n identifier: string,\n property: string,\n value: any,\n pseudo?: PseudoDescriptor\n): string[] {\n const selector = pseudo\n ? `${pseudoSelectorPrefixes[pseudo.name]} .${identifier}:${pseudo.name}`\n : `.${identifier}`\n const important = !!pseudo\n\n let rules: string[] = []\n\n // Handle non-standard properties and object values that require multiple\n // CSS rules to be created.\n switch (property) {\n // Equivalent to using '::placeholder'\n case 'placeholderTextColor': {\n const block = createDeclarationBlock({ color: value, opacity: 1 }, important)\n rules.push(`${selector}::placeholder${block}`)\n break\n }\n\n // all webkit prefixed rules\n case 'backgroundClip':\n case 'userSelect': {\n const propertyCapitalized = `${property[0].toUpperCase()}${property.slice(1)}`\n const webkitProperty = `Webkit${propertyCapitalized}`\n const block = createDeclarationBlock(\n { [property]: value, [webkitProperty]: value },\n important\n )\n rules.push(`${selector}${block}`)\n break\n }\n\n // Polyfill for additional 'pointer-events' values\n case 'pointerEvents': {\n let finalValue = value\n if (value === 'auto' || value === 'box-only') {\n finalValue = 'auto'\n if (value === 'box-only') {\n rules.push(`${selector}>*${boxOnly}`)\n }\n } else if (value === 'none' || value === 'box-none') {\n finalValue = 'none'\n if (value === 'box-none') {\n rules.push(`${selector}>*${boxNone}`)\n }\n }\n const block = createDeclarationBlock({ pointerEvents: finalValue }, true)\n rules.push(`${selector}${block}`)\n break\n }\n\n default: {\n const block = createDeclarationBlock({ [property]: value }, important)\n rules.push(`${selector}${block}`)\n break\n }\n }\n\n // hover styles need to be conditional\n // perhaps this can be generalized but for now lets just shortcut\n // and hardcode for hover styles, if we need to later we can\n // WEIRD SYNTAX, SEE:\n // https://stackoverflow.com/questions/40532204/media-query-for-devices-supporting-hover\n if (pseudo && pseudo.name === 'hover') {\n rules = rules.map((r) => `@media not all and (hover: none) { ${r} }`)\n }\n\n return rules\n}\n\nconst boxNone = createDeclarationBlock({ pointerEvents: 'auto' }, true)\nconst boxOnly = createDeclarationBlock({ pointerEvents: 'none' }, true)\n"],
|
|
5
|
+
"mappings": "AAKA,SAAsB,kBAAkB;AAGxC,SAAS,iBAAiB;AAE1B,SAAgB,aAAa;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,kCAAkC;AAC3C,SAA2B,yBAAyB;AAapD,MAAM,iBAAiB;AAAA,EACrB,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,kBAAkB;AACpB;AAEO,SAAS,gBAAgB,UAAgC;AAE9D,MAAI,EAAE,SAAS,cAAc,SAAS,cAAc,SAAS,aAAa;AACxE,WAAO,eAAe,QAAQ;AAAA,EAChC;AAGA,QAAM,EAAE,YAAY,YAAY,eAAe,KAAK,IAAI;AACxD,MAAI,MAAqB,CAAC;AAE1B,aAAW,CAAC,OAAO,KAAK,KAAK,CAAC,YAAY,YAAY,YAAY,IAAI,EAAE,QAAQ,GAAG;AACjF,QAAI,CAAC;AAAO;AACZ,UAAM,SAAS,eAAe;AAC9B,UAAM,CAAC,GAAG,KAAK,GAAG,eAAe,OAAO,MAAM,CAAC;AAAA,EACjD;AACA,SAAO;AACT;AAEO,SAAS,eACd,OACA,QACe;AACf,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,YAAM,IAAI,MAAM,sBAAsB,OAAO,WAAW,OAAO;AAAA,IACjE;AAAA,EACF;AACA,MAAI,CAAC;AAAO,WAAO,CAAC;AACpB,SAAO,qBAAqB,OAAO,MAAM;AAC3C;AAEA,IAAI;AAEJ,MAAM,uBAAuB,CAC3B,SACA,WACkB;AAClB,SAAO,QAAQ,UAAU;AAGzB,QAAM,QAA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IAAI;AACxE,YAAM,KAAK,GAAG,WAAW,OAAO;AAChC;AAAA,IACF;AAAA,aAES;AACP,YAAM,QAAQ,uBAAuB,EAAE,CAAC,WAAW,MAAM,GAAG,SAAS;AACrE,YAAM,KAAK,GAAG,WAAW,OAAO;AAChC;AAAA,IACF;AAAA;AAQF,MAAI,UAAU,OAAO,SAAS,SAAS;AACrC,YAAQ,MAAM,IAAI,CAAC,MAAM,sCAAsC,KAAK;AAAA,EACtE;AAEA,SAAO;AACT;AAEA,MAAM,UAAU,uBAAuB,EAAE,eAAe,OAAO,GAAG,IAAI;AACtE,MAAM,UAAU,uBAAuB,EAAE,eAAe,OAAO,GAAG,IAAI;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -24,13 +24,11 @@ function addTransform(identifier, css, rule) {
|
|
|
24
24
|
const isClient = typeof document !== "undefined";
|
|
25
25
|
const scannedNum = /* @__PURE__ */ new WeakMap();
|
|
26
26
|
const totalSheetSelectors = /* @__PURE__ */ new Map();
|
|
27
|
-
const referencesInSheet = /* @__PURE__ */ new WeakMap();
|
|
28
27
|
function listenForSheetChanges() {
|
|
29
28
|
if (!isClient)
|
|
30
29
|
return;
|
|
31
30
|
function handleNode(node, remove = false) {
|
|
32
31
|
if (node instanceof HTMLStyleElement && node.sheet) {
|
|
33
|
-
console.warn("update", node.sheet);
|
|
34
32
|
updateSheetStyles(node.sheet, remove);
|
|
35
33
|
}
|
|
36
34
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/insertStyleRule.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { StyleObject } from '@tamagui/helpers'\n\nconst allSelectors: Record<string, string> = {}\nconst allRules: Record<string, string> = {}\nexport const insertedTransforms = {}\n\nexport const getAllSelectors = () => allSelectors\nexport const getAllRules = () => Object.values(allRules)\nexport const getAllTransforms = () => insertedTransforms\n\n// keep transforms in map for merging later\nfunction addTransform(identifier: string, css: string, rule?: CSSRule) {\n const s = css.indexOf('transform:')\n if (s === -1) {\n if (process.env.NODE_ENV === 'development') {\n console.error(`\u274C Invalid transform, likely used deg/% improperly ${identifier}`)\n }\n return false\n }\n const startI = s + 'transform:'.length\n const endI = css.indexOf(';')\n const value = css.slice(startI, endI)\n if (!insertedTransforms[identifier]) {\n insertedTransforms[identifier] = value\n return true\n }\n return false\n}\n\nconst isClient = typeof document !== 'undefined'\n\n// gets existing ones (client side)\n// takes ~0.1ms for a fairly large page\n// used now for three things:\n// 1. debugging at dev time\n// 2. avoid duplicate insert styles at runtime\n// 3. used now for merging transforms atomically\n\n// multiple sheets could have the same ids so we have to count\n\nconst scannedNum = new WeakMap<CSSStyleSheet, number>()\nconst totalSheetSelectors = new Map<string, number>()\
|
|
5
|
-
"mappings": "AAEA,MAAM,eAAuC,CAAC;AAC9C,MAAM,WAAmC,CAAC;AACnC,MAAM,qBAAqB,CAAC;AAE5B,MAAM,kBAAkB,MAAM;AAC9B,MAAM,cAAc,MAAM,OAAO,OAAO,QAAQ;AAChD,MAAM,mBAAmB,MAAM;AAGtC,SAAS,aAAa,YAAoB,KAAa,MAAgB;AACrE,QAAM,IAAI,IAAI,QAAQ,YAAY;AAClC,MAAI,MAAM,IAAI;AACZ,QAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,cAAQ,MAAM,0DAAqD,YAAY;AAAA,IACjF;AACA,WAAO;AAAA,EACT;AACA,QAAM,SAAS,IAAI,aAAa;AAChC,QAAM,OAAO,IAAI,QAAQ,GAAG;AAC5B,QAAM,QAAQ,IAAI,MAAM,QAAQ,IAAI;AACpC,MAAI,CAAC,mBAAmB,aAAa;AACnC,uBAAmB,cAAc;AACjC,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,MAAM,WAAW,OAAO,aAAa;AAWrC,MAAM,aAAa,oBAAI,QAA+B;AACtD,MAAM,sBAAsB,oBAAI,IAAoB;
|
|
4
|
+
"sourcesContent": ["import type { StyleObject } from '@tamagui/helpers'\n\nconst allSelectors: Record<string, string> = {}\nconst allRules: Record<string, string> = {}\nexport const insertedTransforms = {}\n\nexport const getAllSelectors = () => allSelectors\nexport const getAllRules = () => Object.values(allRules)\nexport const getAllTransforms = () => insertedTransforms\n\n// keep transforms in map for merging later\nfunction addTransform(identifier: string, css: string, rule?: CSSRule) {\n const s = css.indexOf('transform:')\n if (s === -1) {\n if (process.env.NODE_ENV === 'development') {\n console.error(`\u274C Invalid transform, likely used deg/% improperly ${identifier}`)\n }\n return false\n }\n const startI = s + 'transform:'.length\n const endI = css.indexOf(';')\n const value = css.slice(startI, endI)\n if (!insertedTransforms[identifier]) {\n insertedTransforms[identifier] = value\n return true\n }\n return false\n}\n\nconst isClient = typeof document !== 'undefined'\n\n// gets existing ones (client side)\n// takes ~0.1ms for a fairly large page\n// used now for three things:\n// 1. debugging at dev time\n// 2. avoid duplicate insert styles at runtime\n// 3. used now for merging transforms atomically\n\n// multiple sheets could have the same ids so we have to count\n\nconst scannedNum = new WeakMap<CSSStyleSheet, number>()\nconst totalSheetSelectors = new Map<string, number>()\n\nexport function listenForSheetChanges() {\n if (!isClient) return\n function handleNode(node: Node, remove = false) {\n if (node instanceof HTMLStyleElement && node.sheet) {\n updateSheetStyles(node.sheet, remove)\n }\n }\n const mo = new MutationObserver((entries) => {\n for (const entry of entries) {\n entry.addedNodes.forEach((node) => handleNode(node))\n entry.removedNodes.forEach((node) => handleNode(node, true))\n }\n })\n mo.observe(document.head, {\n childList: true,\n })\n}\n\nexport function scanAllSheets() {\n if (process.env.NODE_ENV === 'test') return\n if (!isClient) return\n const sheets = document.styleSheets\n if (!sheets) return\n for (let i = 0; i < sheets.length; i++) {\n const sheet = sheets[i]\n if (!sheet) continue\n updateSheetStyles(sheet)\n }\n}\n\nfunction track(id: string, remove = false) {\n const next = (totalSheetSelectors.get(id) || 0) + (remove ? -1 : 1)\n totalSheetSelectors.set(id, next)\n return next\n}\n\nfunction updateSheetStyles(sheet: CSSStyleSheet, remove = false) {\n // avoid errors on cross origin sheets\n // https://stackoverflow.com/questions/49993633/uncaught-domexception-failed-to-read-the-cssrules-property\n let rules: CSSRuleList\n try {\n rules = sheet.cssRules\n } catch {\n return\n }\n\n const len = rules.length\n const lastScanned = scannedNum.get(sheet) || 0\n\n if (!remove) {\n // avoid work dumb but works\n if (lastScanned === len) {\n return\n }\n }\n\n for (let i = lastScanned; i < len; i++) {\n const rule = rules[i]\n const response = getTamaguiSelector(rule)\n if (!response) {\n return\n }\n\n const [identifier, cssRule] = response\n\n // track references\n const total = track(identifier, remove)\n\n if (remove) {\n if (total === 0) {\n delete allSelectors[identifier]\n }\n } else {\n if (!(identifier in allSelectors)) {\n const isTransform = identifier.startsWith('_transform')\n const shouldInsert = isTransform\n ? addTransform(identifier, cssRule.cssText, cssRule)\n : true\n if (shouldInsert) {\n allSelectors[identifier] = cssRule.cssText\n }\n }\n }\n }\n\n scannedNum.set(sheet, len)\n}\n\nfunction getTamaguiSelector(\n rule: CSSRule | null\n): readonly [string, CSSStyleRule] | null {\n if (rule instanceof CSSStyleRule) {\n const text = rule.selectorText\n // .startsWith('._')\n if (text[0] === '.' && text[1] === '_') {\n return [text.slice(1), rule]\n }\n if (text.startsWith(':root') && text.includes('._')) {\n return [getIdentifierFromTamaguiSelector(text), rule]\n }\n } else if (rule instanceof CSSMediaRule) {\n // tamagui only ever inserts 1 rule per media\n if (rule.cssRules.length > 1) return null\n return getTamaguiSelector(rule.cssRules[0])\n }\n return null\n}\n\nconst getIdentifierFromTamaguiSelector = (selector: string) =>\n selector\n .replace(/(:root)+\\s+/, '')\n .replace(/:[a-z]+$/, '')\n .slice(1)\n\nconst sheet = isClient\n ? document.head.appendChild(document.createElement('style')).sheet\n : null\n\nexport function updateRules(identifier: string, rules: string[]) {\n if (allRules[identifier]) return false\n allRules[identifier] = rules.join(' ')\n if (identifier.startsWith('_transform')) {\n return addTransform(identifier, rules[0])\n }\n return true\n}\n\n// [property, identifier, rules]\nexport type PartialStyleObject = Pick<StyleObject, 'identifier' | 'property' | 'rules'>\nexport type RulesToInsert = PartialStyleObject[]\n\nexport function insertStyleRules(rulesToInsert: RulesToInsert) {\n if (!rulesToInsert.length) return\n if (isClient && !sheet) {\n if (process.env.NODE_ENV === 'development') throw 'impossible'\n return\n }\n for (const { identifier, rules } of rulesToInsert) {\n if (identifier in allSelectors) continue\n allSelectors[identifier] =\n process.env.NODE_ENV === 'development' ? rules.join('\\n') : ' '\n updateRules(identifier, rules)\n if (sheet) {\n for (const rule of rules) {\n sheet.insertRule(rule, sheet.cssRules.length)\n }\n }\n }\n}\n\nconst IS_STATIC = process.env.IS_STATIC === 'is_static'\n\nexport function shouldInsertStyleRules(styleObject: PartialStyleObject) {\n if (IS_STATIC) {\n return true\n }\n return !(styleObject.identifier in allSelectors)\n}\n"],
|
|
5
|
+
"mappings": "AAEA,MAAM,eAAuC,CAAC;AAC9C,MAAM,WAAmC,CAAC;AACnC,MAAM,qBAAqB,CAAC;AAE5B,MAAM,kBAAkB,MAAM;AAC9B,MAAM,cAAc,MAAM,OAAO,OAAO,QAAQ;AAChD,MAAM,mBAAmB,MAAM;AAGtC,SAAS,aAAa,YAAoB,KAAa,MAAgB;AACrE,QAAM,IAAI,IAAI,QAAQ,YAAY;AAClC,MAAI,MAAM,IAAI;AACZ,QAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,cAAQ,MAAM,0DAAqD,YAAY;AAAA,IACjF;AACA,WAAO;AAAA,EACT;AACA,QAAM,SAAS,IAAI,aAAa;AAChC,QAAM,OAAO,IAAI,QAAQ,GAAG;AAC5B,QAAM,QAAQ,IAAI,MAAM,QAAQ,IAAI;AACpC,MAAI,CAAC,mBAAmB,aAAa;AACnC,uBAAmB,cAAc;AACjC,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,MAAM,WAAW,OAAO,aAAa;AAWrC,MAAM,aAAa,oBAAI,QAA+B;AACtD,MAAM,sBAAsB,oBAAI,IAAoB;AAE7C,SAAS,wBAAwB;AACtC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M,EAAE;AAAA,EAC1C;AACA,SAAO;AACT;AAMO,SAAS,iBAAiB,eAA8B;AAC7D,MAAI,CAAC,cAAc;AAAQ;AAC3B,MAAI,YAAY,CAAC,OAAO;AACtB,QAAI,QAAQ,IAAI,aAAa;AAAe,YAAM;AAClD;AAAA,EACF;AACA,aAAW,EAAE,YAAY,MAAM,KAAK,eAAe;AACjD,QAAI,cAAc;AAAc;AAChC,iBAAa,cACX,QAAQ,IAAI,aAAa,gBAAgB,MAAM,KAAK,IAAI,IAAI;AAC9D,gBAAY,YAAY,KAAK;AAC7B,QAAI,OAAO;AACT,iBAAW,QAAQ,OAAO;AACxB,cAAM,WAAW,MAAM,MAAM,SAAS,MAAM;AAAA,MAC9C;AAAA,IACF;AAAA,EACF;AACF;AAEA,MAAM,YAAY,QAAQ,IAAI,cAAc;AAErC,SAAS,uBAAuB,aAAiC;AACtE,MAAI,WAAW;AACb,WAAO;AAAA,EACT;AACA,SAAO,EAAE,YAAY,cAAc;AACrC;",
|
|
6
6
|
"names": ["sheet"]
|
|
7
7
|
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
function isTamaguiComponent(comp, name) {
|
|
2
|
-
const config = comp
|
|
3
|
-
|
|
4
|
-
return false;
|
|
5
|
-
if (name) {
|
|
6
|
-
return name === config.componentName;
|
|
7
|
-
}
|
|
8
|
-
return true;
|
|
2
|
+
const config = comp == null ? void 0 : comp["staticConfig"];
|
|
3
|
+
return (config == null ? void 0 : config.parsed) && (name ? name === config.componentName : true) || false;
|
|
9
4
|
}
|
|
10
5
|
export {
|
|
11
6
|
isTamaguiComponent
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/isTamaguiComponent.tsx"],
|
|
4
|
-
"sourcesContent": ["import { StaticConfig, StaticConfigParsed } from '../types'\n\nexport function isTamaguiComponent<A>(\n comp: A,\n name?: string\n): comp is A & {\n staticConfig: StaticConfig\n} {\n const config = comp
|
|
5
|
-
"mappings": "AAEO,SAAS,mBACd,MACA,MAGA;AACA,QAAM,SAAS,
|
|
4
|
+
"sourcesContent": ["import { StaticConfig, StaticConfigParsed } from '../types'\n\nexport function isTamaguiComponent<A>(\n comp: A,\n name?: string\n): comp is A & {\n staticConfig: StaticConfig\n} {\n const config = comp?.['staticConfig'] as StaticConfigParsed | undefined\n return (config?.parsed && (name ? name === config.componentName : true)) || false\n}\n"],
|
|
5
|
+
"mappings": "AAEO,SAAS,mBACd,MACA,MAGA;AACA,QAAM,SAAS,6BAAO;AACtB,UAAQ,iCAAQ,YAAW,OAAO,SAAS,OAAO,gBAAgB,SAAU;AAC9E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -11,7 +11,7 @@ const mergeProps = (a, b, leaveOutClassNames = false, inverseShorthands) => {
|
|
|
11
11
|
};
|
|
12
12
|
function mergeProp(out, outCns, a, b, key, leaveOutClassNames, inverseShorthands) {
|
|
13
13
|
const val = a[key];
|
|
14
|
-
const shorthand = inverseShorthands ? inverseShorthands[key]
|
|
14
|
+
const shorthand = (inverseShorthands == null ? void 0 : inverseShorthands[key]) || null;
|
|
15
15
|
if (b && (key in b || shorthand && shorthand in b)) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/mergeProps.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Preserves prop ordering, so that the order most closely matches the last spread objects\n * Useful for having { ...defaultProps, ...props } that ensure props ordering is always kept\n *\n * Given:\n * mergeProps({ a: 1, b: 2 }, { b: 1, a: 2 })\n * The final key order will be:\n * b, a\n *\n * Handles a couple special tamagui cases\n * - classNames can be extracted out separately\n * - shorthands can be expanded before merging\n */\n\ntype AnyRecord = Record<string, any>\n\nexport const mergeProps = (\n a: Object,\n b: Object,\n leaveOutClassNames = false,\n inverseShorthands?: AnyRecord\n) => {\n const out: AnyRecord = {}\n const outCns: AnyRecord = leaveOutClassNames ? {} : (null as any)\n for (const key in a) {\n mergeProp(out, outCns, a, b, key, leaveOutClassNames, inverseShorthands)\n }\n for (const key in b) {\n mergeProp(out, outCns, b, undefined, key, leaveOutClassNames, inverseShorthands)\n }\n return [out, outCns] as const\n}\n\nfunction mergeProp(\n out: AnyRecord,\n outCns: AnyRecord,\n a: Object,\n b: Object | undefined,\n key: string,\n leaveOutClassNames: boolean,\n inverseShorthands?: AnyRecord\n) {\n const val = a[key]\n const shorthand = inverseShorthands
|
|
5
|
-
"mappings": "AAgBO,MAAM,aAAa,CACxB,GACA,GACA,qBAAqB,OACrB,sBACG;AACH,QAAM,MAAiB,CAAC;AACxB,QAAM,SAAoB,qBAAqB,CAAC,IAAK;AACrD,aAAW,OAAO,GAAG;AACnB,cAAU,KAAK,QAAQ,GAAG,GAAG,KAAK,oBAAoB,iBAAiB;AAAA,EACzE;AACA,aAAW,OAAO,GAAG;AACnB,cAAU,KAAK,QAAQ,GAAG,QAAW,KAAK,oBAAoB,iBAAiB;AAAA,EACjF;AACA,SAAO,CAAC,KAAK,MAAM;AACrB;AAEA,SAAS,UACP,KACA,QACA,GACA,GACA,KACA,oBACA,mBACA;AACA,QAAM,MAAM,EAAE;AACd,QAAM,
|
|
4
|
+
"sourcesContent": ["/**\n * Preserves prop ordering, so that the order most closely matches the last spread objects\n * Useful for having { ...defaultProps, ...props } that ensure props ordering is always kept\n *\n * Given:\n * mergeProps({ a: 1, b: 2 }, { b: 1, a: 2 })\n * The final key order will be:\n * b, a\n *\n * Handles a couple special tamagui cases\n * - classNames can be extracted out separately\n * - shorthands can be expanded before merging\n */\n\ntype AnyRecord = Record<string, any>\n\nexport const mergeProps = (\n a: Object,\n b: Object,\n leaveOutClassNames = false,\n inverseShorthands?: AnyRecord\n) => {\n const out: AnyRecord = {}\n const outCns: AnyRecord = leaveOutClassNames ? {} : (null as any)\n for (const key in a) {\n mergeProp(out, outCns, a, b, key, leaveOutClassNames, inverseShorthands)\n }\n for (const key in b) {\n mergeProp(out, outCns, b, undefined, key, leaveOutClassNames, inverseShorthands)\n }\n return [out, outCns] as const\n}\n\nfunction mergeProp(\n out: AnyRecord,\n outCns: AnyRecord,\n a: Object,\n b: Object | undefined,\n key: string,\n leaveOutClassNames: boolean,\n inverseShorthands?: AnyRecord\n) {\n const val = a[key]\n const shorthand = inverseShorthands?.[key] || null\n if (b && (key in b || (shorthand && shorthand in b))) {\n return\n }\n if (shorthand) {\n key = shorthand\n }\n if (leaveOutClassNames && val?.[0] === '_') {\n outCns[key] = val\n } else {\n out[key] = val\n }\n}\n"],
|
|
5
|
+
"mappings": "AAgBO,MAAM,aAAa,CACxB,GACA,GACA,qBAAqB,OACrB,sBACG;AACH,QAAM,MAAiB,CAAC;AACxB,QAAM,SAAoB,qBAAqB,CAAC,IAAK;AACrD,aAAW,OAAO,GAAG;AACnB,cAAU,KAAK,QAAQ,GAAG,GAAG,KAAK,oBAAoB,iBAAiB;AAAA,EACzE;AACA,aAAW,OAAO,GAAG;AACnB,cAAU,KAAK,QAAQ,GAAG,QAAW,KAAK,oBAAoB,iBAAiB;AAAA,EACjF;AACA,SAAO,CAAC,KAAK,MAAM;AACrB;AAEA,SAAS,UACP,KACA,QACA,GACA,GACA,KACA,oBACA,mBACA;AACA,QAAM,MAAM,EAAE;AACd,QAAM,aAAY,uDAAoB,SAAQ;AAC9C,MAAI,MAAM,OAAO,KAAM,aAAa,aAAa,IAAK;AACpD;AAAA,EACF;AACA,MAAI,WAAW;AACb,UAAM;AAAA,EACR;AACA,MAAI,uBAAsB,2BAAM,QAAO,KAAK;AAC1C,WAAO,OAAO;AAAA,EAChB,OAAO;AACL,QAAI,OAAO;AAAA,EACb;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/getThemeUnwrapped.tsx"],
|
|
4
|
-
"sourcesContent": ["export const getThemeUnwrapped = (theme: any) => {\n
|
|
5
|
-
"mappings": "AAAO,MAAM,oBAAoB,CAAC,UAAe;AAC/C,
|
|
4
|
+
"sourcesContent": ["export const getThemeUnwrapped = (theme: any) => {\n return theme?.[GetThemeUnwrapped] || theme\n}\n\nexport const GetThemeUnwrapped = Symbol()\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,oBAAoB,CAAC,UAAe;AAC/C,UAAO,+BAAQ,uBAAsB;AACvC;AAEO,MAAM,oBAAoB,OAAO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from "../helpers/ThemeManager";
|
|
10
10
|
import { ThemeManagerContext } from "../helpers/ThemeManagerContext";
|
|
11
11
|
import { GetThemeUnwrapped } from "./getThemeUnwrapped";
|
|
12
|
+
import { useServerRef } from "./useServerHooks";
|
|
12
13
|
const emptyProps = { name: null };
|
|
13
14
|
function getDefaultThemeProxied() {
|
|
14
15
|
const config = getConfig();
|
|
@@ -19,13 +20,24 @@ function getDefaultThemeProxied() {
|
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
const useTheme = (props = emptyProps) => {
|
|
22
|
-
var _a;
|
|
23
|
+
var _a, _b;
|
|
23
24
|
if (isRSC) {
|
|
24
25
|
return getDefaultThemeProxied();
|
|
25
26
|
}
|
|
26
|
-
const
|
|
27
|
+
const state = useServerRef();
|
|
28
|
+
if (isClient && !state.current) {
|
|
29
|
+
state.current = {
|
|
30
|
+
keys: /* @__PURE__ */ new Set()
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
(_a = state.current) == null ? void 0 : _a.keys.clear();
|
|
34
|
+
const { name, theme, themeManager, className, isNewTheme } = useChangeThemeEffect(
|
|
35
|
+
props,
|
|
36
|
+
false,
|
|
37
|
+
isClient ? () => state.current.keys.size === 0 : void 0
|
|
38
|
+
);
|
|
27
39
|
if (process.env.NODE_ENV === "development") {
|
|
28
|
-
if (isWeb && isNewTheme && className === ((
|
|
40
|
+
if (isWeb && isNewTheme && className === ((_b = themeManager == null ? void 0 : themeManager.parentManager) == null ? void 0 : _b.state.className)) {
|
|
29
41
|
console.error("Should always change, duplicating ThemeMananger bug", themeManager);
|
|
30
42
|
}
|
|
31
43
|
if (props.debug === "verbose") {
|
|
@@ -49,7 +61,8 @@ const useTheme = (props = emptyProps) => {
|
|
|
49
61
|
theme,
|
|
50
62
|
name,
|
|
51
63
|
className,
|
|
52
|
-
themeManager
|
|
64
|
+
themeManager,
|
|
65
|
+
state
|
|
53
66
|
});
|
|
54
67
|
}, [theme, isNewTheme, name, className, themeManager]);
|
|
55
68
|
};
|
|
@@ -58,7 +71,8 @@ function getThemeProxied({
|
|
|
58
71
|
name,
|
|
59
72
|
className,
|
|
60
73
|
themeManager,
|
|
61
|
-
isNewTheme
|
|
74
|
+
isNewTheme,
|
|
75
|
+
state
|
|
62
76
|
}) {
|
|
63
77
|
return createProxy(theme, {
|
|
64
78
|
has(_, key) {
|
|
@@ -88,7 +102,20 @@ function getThemeProxied({
|
|
|
88
102
|
if (!themeManager) {
|
|
89
103
|
return theme[key];
|
|
90
104
|
}
|
|
91
|
-
|
|
105
|
+
const val = themeManager.getValue(key);
|
|
106
|
+
if (val && state) {
|
|
107
|
+
if (isClient) {
|
|
108
|
+
return new Proxy(val, {
|
|
109
|
+
get(_2, subkey) {
|
|
110
|
+
if (subkey === "val") {
|
|
111
|
+
state.current.keys.add(key);
|
|
112
|
+
}
|
|
113
|
+
return Reflect.get(val, subkey);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return val;
|
|
92
119
|
}
|
|
93
120
|
});
|
|
94
121
|
}
|
|
@@ -97,7 +124,7 @@ const GetIsNewTheme = Symbol();
|
|
|
97
124
|
const getThemeManager = (theme) => theme == null ? void 0 : theme[GetThemeManager];
|
|
98
125
|
const getThemeIsNewTheme = (theme) => theme == null ? void 0 : theme[GetIsNewTheme];
|
|
99
126
|
const activeThemeManagers = /* @__PURE__ */ new Set();
|
|
100
|
-
const useChangeThemeEffect = (props, root = false) => {
|
|
127
|
+
const useChangeThemeEffect = (props, root = false, disableUpdate) => {
|
|
101
128
|
if (isRSC) {
|
|
102
129
|
return {
|
|
103
130
|
...createState().state,
|
|
@@ -129,20 +156,8 @@ const useChangeThemeEffect = (props, root = false) => {
|
|
|
129
156
|
return;
|
|
130
157
|
}
|
|
131
158
|
activeThemeManagers.add(themeManager);
|
|
132
|
-
const disposeChangeListener = parentManager == null ? void 0 : parentManager.onChangeTheme(() => {
|
|
133
|
-
if (!(isNewTheme || isWeb)) {
|
|
134
|
-
setThemeState({
|
|
135
|
-
...themeState,
|
|
136
|
-
state: { ...themeManager.state },
|
|
137
|
-
isNewTheme: false
|
|
138
|
-
});
|
|
139
|
-
} else {
|
|
140
|
-
updateState();
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
159
|
return () => {
|
|
144
160
|
activeThemeManagers.delete(themeManager);
|
|
145
|
-
disposeChangeListener == null ? void 0 : disposeChangeListener();
|
|
146
161
|
};
|
|
147
162
|
}, [disable, state, isNewTheme, debug]);
|
|
148
163
|
}
|
|
@@ -152,12 +167,7 @@ const useChangeThemeEffect = (props, root = false) => {
|
|
|
152
167
|
if (!parentManager)
|
|
153
168
|
throw "impossible";
|
|
154
169
|
if (process.env.NODE_ENV === "development" && props.debug === "verbose")
|
|
155
|
-
console.log(
|
|
156
|
-
"useTheme hasNoThemeUpdatingProps",
|
|
157
|
-
parentManager.state.name,
|
|
158
|
-
"isInversingOnMount",
|
|
159
|
-
isInversingOnMount
|
|
160
|
-
);
|
|
170
|
+
console.log("useTheme hasNoThemeUpdatingProps", parentManager.state.name, "isInversingOnMount", isInversingOnMount);
|
|
161
171
|
return {
|
|
162
172
|
...parentManager.state,
|
|
163
173
|
className: isInversingOnMount ? "" : parentManager.state.className,
|
|
@@ -172,27 +182,11 @@ const useChangeThemeEffect = (props, root = false) => {
|
|
|
172
182
|
themeManager
|
|
173
183
|
};
|
|
174
184
|
function createState(prev) {
|
|
185
|
+
if (prev && (disableUpdate == null ? void 0 : disableUpdate())) {
|
|
186
|
+
return prev;
|
|
187
|
+
}
|
|
175
188
|
const _ = new ThemeManager(props, root ? "root" : parentManager);
|
|
176
189
|
const isNewTheme2 = _ !== parentManager;
|
|
177
|
-
if (process.env.NODE_ENV === "development" && debug)
|
|
178
|
-
[
|
|
179
|
-
console.groupCollapsed("useTheme create() isNewTheme", isNewTheme2),
|
|
180
|
-
console.log(
|
|
181
|
-
"parent.state.name",
|
|
182
|
-
parentManager == null ? void 0 : parentManager.state.name,
|
|
183
|
-
"\n",
|
|
184
|
-
"props",
|
|
185
|
-
props,
|
|
186
|
-
"\n",
|
|
187
|
-
isClient ? parentManager : "",
|
|
188
|
-
"getState",
|
|
189
|
-
isNewTheme2 && isClient ? _.getState(props) : "",
|
|
190
|
-
"\n",
|
|
191
|
-
"state",
|
|
192
|
-
isClient ? { ..._.state } : ""
|
|
193
|
-
),
|
|
194
|
-
console.groupEnd()
|
|
195
|
-
];
|
|
196
190
|
const mounted2 = !props.inverse ? true : root || (prev == null ? void 0 : prev.mounted);
|
|
197
191
|
return {
|
|
198
192
|
isNewTheme: isNewTheme2,
|
|
@@ -201,12 +195,13 @@ const useChangeThemeEffect = (props, root = false) => {
|
|
|
201
195
|
mounted: mounted2
|
|
202
196
|
};
|
|
203
197
|
}
|
|
204
|
-
function updateState() {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
);
|
|
198
|
+
function updateState(updatingManager) {
|
|
199
|
+
if (disableUpdate == null ? void 0 : disableUpdate()) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const manager = updatingManager ?? themeManager;
|
|
203
|
+
const next = manager.getState(props, parentManager);
|
|
204
|
+
const shouldChange = manager.getStateShouldChange(next, isNewTheme ? state : null);
|
|
210
205
|
if (shouldChange) {
|
|
211
206
|
setThemeState(createState);
|
|
212
207
|
} else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useTheme.tsx"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable no-console */\nimport { isClient, isRSC, isServer, isWeb } from '@tamagui/constants'\nimport { useContext, useEffect,
|
|
5
|
-
"mappings": "AACA,SAAS,UAAU,OAAO,UAAU,aAAa;AACjD,SAAS,YAAY,
|
|
6
|
-
"names": ["isNewTheme", "mounted"]
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-console */\nimport { isClient, isRSC, isServer, isWeb } from '@tamagui/constants'\nimport { useContext, useEffect, useMemo, useState } from 'react'\n\nimport { getConfig } from '../config'\nimport { isDevTools } from '../constants/isDevTools'\nimport { createProxy } from '../helpers/createProxy'\nimport {\n ThemeManager,\n ThemeManagerState,\n hasNoThemeUpdatingProps,\n} from '../helpers/ThemeManager'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext'\nimport { ThemeParsed, ThemeProps } from '../types'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped'\nimport { useServerRef } from './useServerHooks'\n\nexport type ChangedThemeResponse = {\n themeManager: ThemeManager | null\n name: string\n isNewTheme?: boolean\n theme?: ThemeParsed | null\n className?: string\n}\n\nconst emptyProps = { name: null }\n\nfunction getDefaultThemeProxied() {\n const config = getConfig()\n const name = Object.keys(config.themes)[0]\n return getThemeProxied({\n theme: config.themes[name],\n name,\n })\n}\n\ninterface UseThemeState {\n keys: Set<string>\n}\n\nexport const useTheme = (props: ThemeProps = emptyProps): ThemeParsed => {\n if (isRSC) {\n return getDefaultThemeProxied()\n }\n\n const state = useServerRef() as React.MutableRefObject<UseThemeState>\n if (isClient && !state.current) {\n state.current = {\n keys: new Set(),\n }\n }\n state.current?.keys.clear()\n\n const { name, theme, themeManager, className, isNewTheme } = useChangeThemeEffect(\n props,\n false,\n isClient ? () => state.current.keys.size === 0 : undefined\n )\n\n if (process.env.NODE_ENV === 'development') {\n // ensure we aren't creating too many ThemeManagers\n if (\n isWeb &&\n isNewTheme &&\n className === themeManager?.parentManager?.state.className\n ) {\n console.error('Should always change, duplicating ThemeMananger bug', themeManager)\n }\n if (props.debug === 'verbose') {\n console.groupCollapsed(' \uD83D\uDD39 useTheme =>', name)\n const logs = { ...props, name, className, ...(isDevTools && { theme }) }\n for (const key in logs) {\n console.log(' ', key, logs[key])\n }\n console.groupEnd()\n }\n }\n\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme found', name, props, themeManager)\n }\n return getDefaultThemeProxied()\n }\n\n return useMemo(() => {\n return getThemeProxied({\n isNewTheme,\n theme,\n name,\n className,\n themeManager,\n state,\n })\n }, [theme, isNewTheme, name, className, themeManager])\n}\n\nfunction getThemeProxied({\n theme,\n name,\n className,\n themeManager,\n isNewTheme,\n state,\n}: {\n theme: any\n name: string\n className?: string\n themeManager?: ThemeManager | null\n isNewTheme?: boolean\n state?: React.RefObject<UseThemeState>\n}) {\n return createProxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') key = key.slice(1)\n return themeManager?.allKeys.has(key)\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n } else if (key === GetThemeManager) {\n return themeManager\n } else if (key === GetIsNewTheme) {\n return isNewTheme\n } else if (key === 'name') {\n return name\n } else if (key === 'className') {\n return className\n } else if (\n !name ||\n key === '__proto__' ||\n typeof key === 'symbol' ||\n key === '$typeof'\n ) {\n return Reflect.get(_, key)\n }\n // auto convert variables to plain\n if (key[0] === '$') key = key.slice(1)\n if (!themeManager) {\n return theme[key]\n }\n const val = themeManager.getValue(key)\n if (val && state) {\n if (isClient) {\n return new Proxy(val as any, {\n get(_, subkey) {\n if (subkey === 'val') {\n state.current!.keys.add(key as any)\n }\n return Reflect.get(val, subkey)\n },\n })\n }\n }\n return val\n },\n })\n}\n\nconst GetThemeManager = Symbol()\nconst GetIsNewTheme = Symbol()\n\nexport const getThemeManager = (theme: any): ThemeManager | undefined =>\n theme?.[GetThemeManager]\nexport const getThemeIsNewTheme = (theme: any): ThemeManager | undefined =>\n theme?.[GetIsNewTheme]\n\nexport const activeThemeManagers = new Set<ThemeManager>()\n\nexport const useChangeThemeEffect = (\n props: ThemeProps,\n root = false,\n disableUpdate?: () => boolean\n): ChangedThemeResponse => {\n if (isRSC) {\n // we need context working for this to work well\n return {\n ...createState().state,\n themeManager: null,\n }\n }\n const parentManager = useContext(ThemeManagerContext)\n\n const {\n debug,\n // @ts-expect-error internal use only\n disable,\n } = props\n\n if (disable) {\n if (!parentManager) throw new Error('Disable topmost')\n return {\n ...parentManager.state,\n isNewTheme: false,\n themeManager: parentManager,\n }\n }\n\n type State = {\n isNewTheme: boolean\n state: ThemeManagerState\n themeManager: ThemeManager\n mounted?: boolean\n }\n\n const [themeState, setThemeState] = useState<State>(createState)\n const { isNewTheme, state, themeManager, mounted } = themeState\n\n if (!isServer) {\n useEffect(() => {\n if (disable) return\n // SSR safe inverse (because server can't know prefers scheme)\n // could be done through fancy selectors like how we do prefers-media\n // but may be a bit of explosion of selectors\n if (props.inverse && !mounted) {\n setThemeState({ ...themeState, mounted: true })\n return\n }\n activeThemeManagers.add(themeManager)\n // const disposeChangeListener = parentManager?.onChangeTheme((name, manager) => {\n // // console.log('hi', props, state, name, manager)\n // if (state.theme !== manager.state.theme) {\n // console.warn('now update to', manager.state.name)\n // updateState(manager)\n // }\n // })\n return () => {\n activeThemeManagers.delete(themeManager)\n // disposeChangeListener?.()\n }\n }, [disable, state, isNewTheme, debug])\n }\n\n const isInversingOnMount = Boolean(!themeState.mounted && props.inverse)\n const shouldReturnParentState = hasNoThemeUpdatingProps(props) || isInversingOnMount\n\n if (shouldReturnParentState) {\n if (!parentManager) throw 'impossible'\n // prettier-ignore\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') console.log('useTheme hasNoThemeUpdatingProps', parentManager.state.name, 'isInversingOnMount', isInversingOnMount)\n return {\n ...parentManager.state,\n className: isInversingOnMount ? '' : parentManager.state.className,\n themeManager: parentManager,\n isNewTheme: false,\n }\n }\n\n // run inline in render\n updateState()\n\n return {\n ...state,\n isNewTheme,\n themeManager,\n }\n\n function createState(prev?: State) {\n if (prev && disableUpdate?.()) {\n return prev\n }\n // returns previous theme manager if no change\n const _ = new ThemeManager(props, root ? 'root' : parentManager)\n const isNewTheme = _ !== parentManager\n // prettier-ignore\n\n // if (prev?.isNewTheme && _.state.theme !== parentManager?.state.theme) {\n // console.warn('notify')\n // _.notify()\n // }\n\n // only inverse relies on this for ssr\n const mounted = !props.inverse ? true : root || prev?.mounted\n return {\n // ThemeManager returns parentManager if no change\n isNewTheme,\n state: { ..._.state },\n themeManager: _,\n mounted,\n }\n }\n\n function updateState(updatingManager?: ThemeManager) {\n if (disableUpdate?.()) {\n return\n }\n const manager = updatingManager ?? themeManager\n const next = manager.getState(props, parentManager)\n const shouldChange = manager.getStateShouldChange(next, isNewTheme ? state : null)\n // console.log(`got it`, next, isNewTheme, shouldChange, { ...updatingManager?.state })\n if (shouldChange) {\n setThemeState(createState)\n } else {\n if (!next && parentManager?.state.name !== state.name) {\n // were changing back to parent state\n setThemeState(createState)\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,UAAU,OAAO,UAAU,aAAa;AACjD,SAAS,YAAY,WAAW,SAAS,gBAAgB;AAEzD,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AACP,SAAS,2BAA2B;AAEpC,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAU7B,MAAM,aAAa,EAAE,MAAM,KAAK;AAEhC,SAAS,yBAAyB;AAChC,QAAM,SAAS,UAAU;AACzB,QAAM,OAAO,OAAO,KAAK,OAAO,MAAM,EAAE;AACxC,SAAO,gBAAgB;AAAA,IACrB,OAAO,OAAO,OAAO;AAAA,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;AAAA,IACd;AAAA,EACF;AAGA,cAAY;AAEZ,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AAEA,WAAS,YAAY,MAAc;AACjC,QAAI,SAAQ,mDAAmB;AAC7B,aAAO;AAAA,IACT;AAEA,UAAM,IAAI,IAAI,aAAa,OAAO,OAAO,SAAS,aAAa;AAC/D,UAAMC,cAAa,MAAM;AASzB,UAAMC,WAAU,CAAC,MAAM,UAAU,OAAO,SAAQ,6BAAM;AACtD,WAAO;AAAA,MAEL,YAAAD;AAAA,MACA,OAAO,EAAE,GAAG,EAAE,MAAM;AAAA,MACpB,cAAc;AAAA,MACd,SAAAC;AAAA,IACF;AAAA,EACF;AAEA,WAAS,YAAY,iBAAgC;AACnD,QAAI,kDAAmB;AACrB;AAAA,IACF;AACA,UAAM,UAAU,mBAAmB;AACnC,UAAM,OAAO,QAAQ,SAAS,OAAO,aAAa;AAClD,UAAM,eAAe,QAAQ,qBAAqB,MAAM,aAAa,QAAQ,IAAI;AAEjF,QAAI,cAAc;AAChB,oBAAc,WAAW;AAAA,IAC3B,OAAO;AACL,UAAI,CAAC,SAAQ,+CAAe,MAAM,UAAS,MAAM,MAAM;AAErD,sBAAc,WAAW;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["_", "isNewTheme", "mounted"]
|
|
7
7
|
}
|
package/dist/esm/styled.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/styled.tsx"],
|
|
4
|
-
"sourcesContent": ["import { stylePropsAll
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { stylePropsAll } from '@tamagui/helpers'\n\nimport { createComponent } from './createComponent'\nimport { ReactNativeStaticConfigs } from './setupReactNative'\nimport {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n TamaguiElement,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types'\n\n// TODO may be able to use this in the options?: arg below directly\nexport type StyledOptions<ParentComponent extends StylableComponent> =\n GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n }\n\n// can't infer from styled(<YStack />) which would be nice\n// * excessively deep type instantiation\n\ntype GetBaseProps<A extends StylableComponent> =\n // A extends TamaguiReactElement\n // ? GetBaseProps<A['type']> :\n A extends TamaguiComponent<any, any, infer P> ? P : GetProps<A>\n\ntype GetVariantProps<A extends StylableComponent> =\n // A extends TamaguiReactElement\n // ? GetVariantProps<A['type']>\n // :\n A extends TamaguiComponent<any, any, any, infer V> ? V : {}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n Component: ParentComponent,\n // this should be Partial<GetProps<ParentComponent>> but causes excessively deep type issues\n options?: GetProps<ParentComponent> & {\n name?: string\n variants?: Variants | undefined\n // thought i had this typed, but can't get it linked\n defaultVariants?: { [key: string]: any }\n acceptsClassName?: boolean\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n // allows passing styled(<H1 bc=\"red\" />)\n // but to get types right would be tricky\n // if (isValidElement(Component) && isTamaguiComponent(Component.type)) {\n // const props = Component.props\n // if (props && typeof props === 'object') {\n // Component = Component.type as any\n // options = options ? ({ ...props, ...options } as any) : props\n // }\n // }\n\n // validate not using a variant over an existing valid style\n if (process.env.NODE_ENV === 'development') {\n if (options?.variants) {\n for (const key in options.variants) {\n if (key in stylePropsAll) {\n console.error(\n `Invalid variant key overlaps with style key: ${key}. Tamagui prevents defining variants that use valid style keys to reduce implementation complexity.`\n )\n }\n }\n }\n }\n\n const staticConfigProps = (() => {\n const parentStaticConfig =\n 'staticConfig' in Component ? (Component.staticConfig as StaticConfig) : null\n\n if (options) {\n const {\n variants,\n name,\n defaultVariants,\n acceptsClassName: acceptsClassNameProp,\n ...defaultProps\n } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n const isReactNative = Boolean(\n ReactNativeStaticConfigs.has(Component) ||\n ReactNativeStaticConfigs.has(parentStaticConfig?.Component) ||\n parentStaticConfig?.isReactNative ||\n staticExtractionOptions?.isReactNative\n )\n const isTamagui = !isReactNative && !!parentStaticConfig\n\n const Comp = isReactNative\n ? parentStaticConfig?.Component || Component\n : (Component as any)\n const nativeConf = (isReactNative && ReactNativeStaticConfigs.get(Comp)) || null\n\n const isText = Boolean(\n staticExtractionOptions?.isText || parentStaticConfig?.isText\n )\n const acceptsClassName = acceptsClassNameProp ?? (isTamagui || isReactNative)\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\n }),\n // this type gets messed up by options?: Partial<GetProps<ParentComponent>> above\n // take away the Partial<> and it's fine\n variants,\n defaultProps,\n defaultVariants,\n componentName: name,\n isReactNative,\n isText,\n acceptsClassName,\n ...nativeConf,\n }\n\n // bail on non className views as well\n if (defaultProps.children || !acceptsClassName) {\n conf.neverFlatten = true\n }\n\n return conf\n }\n return {}\n })()\n\n const component = createComponent(staticConfigProps, Component)\n\n // get parent props without pseudos and medias so we can rebuild both with new variants\n // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = GetBaseProps<ParentComponent>\n type ParentVariants = GetVariantProps<ParentComponent>\n\n type OurVariants = Variants extends void\n ? {}\n : {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<\n any,\n infer Val\n >\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n }\n\n type VariantProps = Omit<ParentVariants, keyof OurVariants> & OurVariants\n type OurPropsBase = ParentPropsBase & VariantProps\n\n type Props = Variants extends void\n ? GetProps<ParentComponent>\n : // start with base props\n OurPropsBase &\n // add in media (+ pseudos nested)\n MediaProps<Partial<OurPropsBase>> &\n // add in pseudos\n PseudoProps<Partial<OurPropsBase>>\n\n type StyledComponent = TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n\n return component as StyledComponent\n}\n\n// sanity check types\n// import { Stack } from './views/Stack'\n// const X = styled(Stack, {\n// variants: {\n// size: {\n// '...size': (val) => {\n// return {\n// pointerEvents: 'auto'\n// }\n// }\n// },\n// disabled: {\n// true: {\n// alignContent: 'center',\n// opacity: 0.5,\n// pointerEvents: 'none',\n// },\n// },\n// } as const\n// })\n// // type variants = GetStyledVariants<typeof X>\n// const y = <X disabled size=\"$10\" />\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,qBAAqB;AAE9B,SAAS,uBAAuB;AAChC,SAAS,gCAAgC;AAoClC,SAAS,OAId,WAEA,SAOA,yBACA;AAYA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,mCAAS,UAAU;AACrB,iBAAW,OAAO,QAAQ,UAAU;AAClC,YAAI,OAAO,eAAe;AACxB,kBAAQ;AAAA,YACN,gDAAgD;AAAA,UAClD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,qBAAqB,MAAM;AAC/B,UAAM,qBACJ,kBAAkB,YAAa,UAAU,eAAgC;AAE3E,QAAI,SAAS;AACX,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA,kBAAkB;AAAA,WACf;AAAA,MACL,IAAI;AACJ,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AACA,YAAM,gBAAgB;AAAA,QACpB,yBAAyB,IAAI,SAAS,KACpC,yBAAyB,IAAI,yDAAoB,SAAS,MAC1D,yDAAoB,mBACpB,mEAAyB;AAAA,MAC7B;AACA,YAAM,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAEtC,YAAM,OAAO,iBACT,yDAAoB,cAAa,YAChC;AACL,YAAM,aAAc,iBAAiB,yBAAyB,IAAI,IAAI,KAAM;AAE5E,YAAM,SAAS;AAAA,SACb,mEAAyB,YAAU,yDAAoB;AAAA,MACzD;AACA,YAAM,mBAAmB,yBAAyB,aAAa;AAE/D,YAAM,OAA8B;AAAA,QAClC,GAAG;AAAA,QACH,GAAI,CAAC,aAAa;AAAA,UAChB,WAAW;AAAA,QACb;AAAA,QAGA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MACL;AAGA,UAAI,aAAa,YAAY,CAAC,kBAAkB;AAC9C,aAAK,eAAe;AAAA,MACtB;AAEA,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,GAAG;AAEH,QAAM,YAAY,gBAAgB,mBAAmB,SAAS;AAqC9D,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/FontLanguage.tsx"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { FontLanguageProps } from './FontLanguage.types'\n\nexport const FontLanguage = ({ children, ...props }: FontLanguageProps) => {\n return (\n <div\n style={{\n display: 'contents',\n }}\n className={Object.entries(props)\n .map(([name, language]) => `t_lang-${name}-${language}`)\n .join(' ')}\n >\n {children}\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": "AAII;AAFG,MAAM,eAAe,CAAC,EAAE,aAAa,MAAM,MAAyB;AACzE,SACE,oBAAC;AAAA,IACC,OAAO;AAAA,MACL,SAAS;AAAA,IACX;AAAA,IACA,WAAW,OAAO,QAAQ,KAAK,EAC5B,IAAI,CAAC,CAAC,MAAM,QAAQ,MAAM,UAAU,QAAQ,UAAU,EACtD,KAAK,GAAG;AAAA,IAEV;AAAA,GACH;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -23,6 +23,9 @@ function TamaguiProvider({
|
|
|
23
23
|
}
|
|
24
24
|
if (isClient) {
|
|
25
25
|
React.useLayoutEffect(() => {
|
|
26
|
+
if (document.documentElement.classList.contains("t_unmounted")) {
|
|
27
|
+
document.documentElement.classList.remove("t_unmounted");
|
|
28
|
+
}
|
|
26
29
|
if (disableInjectCSS)
|
|
27
30
|
return;
|
|
28
31
|
const style = document.createElement("style");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/TamaguiProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import { isClient, isRSC, isServer, isWeb } from '@tamagui/constants'\nimport * as React from 'react'\n\nimport { ButtonNestingContext } from '../contexts/ButtonNestingContext'\nimport { TextAncestorContext } from '../contexts/TextAncestorContext'\nimport { useMediaListeners } from '../hooks/useMedia'\nimport type { TamaguiProviderProps } from '../types'\nimport { ThemeProvider } from './ThemeProvider'\n\nexport function TamaguiProvider({\n children,\n disableInjectCSS,\n config,\n ...themePropsProvider\n}: TamaguiProviderProps) {\n if (isRSC) {\n return (\n <span\n style={{ display: 'contents' }}\n className={`t_${Object.keys(config.themes)[0] || 'light'}`}\n >\n {children}\n </span>\n )\n }\n\n if (!(isWeb && isServer)) {\n useMediaListeners(config)\n }\n\n if (isClient) {\n // inject CSS if asked to (not SSR compliant)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useLayoutEffect(() => {\n if (disableInjectCSS) return\n const style = document.createElement('style')\n style.appendChild(document.createTextNode(config.getCSS()))\n document.head.appendChild(style)\n return () => {\n document.head.removeChild(style)\n }\n }, [config, disableInjectCSS])\n }\n\n return (\n <ButtonNestingContext.Provider value={false}>\n <TextAncestorContext.Provider value={false}>\n <ThemeProvider\n themeClassNameOnRoot={config.themeClassNameOnRoot}\n disableRootThemeClass={config.disableRootThemeClass}\n {...themePropsProvider}\n defaultTheme={themePropsProvider.defaultTheme ?? Object.keys(config.themes)[0]}\n >\n {children}\n </ThemeProvider>\n </TextAncestorContext.Provider>\n </ButtonNestingContext.Provider>\n )\n}\n"],
|
|
5
|
-
"mappings": "AAiBM;AAjBN,SAAS,UAAU,OAAO,UAAU,aAAa;AACjD,YAAY,WAAW;AAEvB,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,SAAS,yBAAyB;AAElC,SAAS,qBAAqB;AAEvB,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,KACG;AACL,GAAyB;AACvB,MAAI,OAAO;AACT,WACE,oBAAC;AAAA,MACC,OAAO,EAAE,SAAS,WAAW;AAAA,MAC7B,WAAW,KAAK,OAAO,KAAK,OAAO,MAAM,EAAE,MAAM;AAAA,MAEhD;AAAA,KACH;AAAA,EAEJ;AAEA,MAAI,EAAE,SAAS,WAAW;AACxB,sBAAkB,MAAM;AAAA,EAC1B;AAEA,MAAI,UAAU;AAGZ,UAAM,gBAAgB,MAAM;
|
|
4
|
+
"sourcesContent": ["import { isClient, isRSC, isServer, isWeb } from '@tamagui/constants'\nimport * as React from 'react'\n\nimport { ButtonNestingContext } from '../contexts/ButtonNestingContext'\nimport { TextAncestorContext } from '../contexts/TextAncestorContext'\nimport { useMediaListeners } from '../hooks/useMedia'\nimport type { TamaguiProviderProps } from '../types'\nimport { ThemeProvider } from './ThemeProvider'\n\nexport function TamaguiProvider({\n children,\n disableInjectCSS,\n config,\n ...themePropsProvider\n}: TamaguiProviderProps) {\n if (isRSC) {\n return (\n <span\n style={{ display: 'contents' }}\n className={`t_${Object.keys(config.themes)[0] || 'light'}`}\n >\n {children}\n </span>\n )\n }\n\n if (!(isWeb && isServer)) {\n useMediaListeners(config)\n }\n\n if (isClient) {\n // inject CSS if asked to (not SSR compliant)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useLayoutEffect(() => {\n // for easier support of hidden-until-js mount animations\n // user must set t_unmounted on documentElement from SSR\n if (document.documentElement.classList.contains('t_unmounted')) {\n document.documentElement.classList.remove('t_unmounted')\n }\n\n if (disableInjectCSS) return\n const style = document.createElement('style')\n style.appendChild(document.createTextNode(config.getCSS()))\n document.head.appendChild(style)\n return () => {\n document.head.removeChild(style)\n }\n }, [config, disableInjectCSS])\n }\n\n return (\n <ButtonNestingContext.Provider value={false}>\n <TextAncestorContext.Provider value={false}>\n <ThemeProvider\n themeClassNameOnRoot={config.themeClassNameOnRoot}\n disableRootThemeClass={config.disableRootThemeClass}\n {...themePropsProvider}\n defaultTheme={themePropsProvider.defaultTheme ?? Object.keys(config.themes)[0]}\n >\n {children}\n </ThemeProvider>\n </TextAncestorContext.Provider>\n </ButtonNestingContext.Provider>\n )\n}\n"],
|
|
5
|
+
"mappings": "AAiBM;AAjBN,SAAS,UAAU,OAAO,UAAU,aAAa;AACjD,YAAY,WAAW;AAEvB,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,SAAS,yBAAyB;AAElC,SAAS,qBAAqB;AAEvB,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,KACG;AACL,GAAyB;AACvB,MAAI,OAAO;AACT,WACE,oBAAC;AAAA,MACC,OAAO,EAAE,SAAS,WAAW;AAAA,MAC7B,WAAW,KAAK,OAAO,KAAK,OAAO,MAAM,EAAE,MAAM;AAAA,MAEhD;AAAA,KACH;AAAA,EAEJ;AAEA,MAAI,EAAE,SAAS,WAAW;AACxB,sBAAkB,MAAM;AAAA,EAC1B;AAEA,MAAI,UAAU;AAGZ,UAAM,gBAAgB,MAAM;AAG1B,UAAI,SAAS,gBAAgB,UAAU,SAAS,aAAa,GAAG;AAC9D,iBAAS,gBAAgB,UAAU,OAAO,aAAa;AAAA,MACzD;AAEA,UAAI;AAAkB;AACtB,YAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,YAAM,YAAY,SAAS,eAAe,OAAO,OAAO,CAAC,CAAC;AAC1D,eAAS,KAAK,YAAY,KAAK;AAC/B,aAAO,MAAM;AACX,iBAAS,KAAK,YAAY,KAAK;AAAA,MACjC;AAAA,IACF,GAAG,CAAC,QAAQ,gBAAgB,CAAC;AAAA,EAC/B;AAEA,SACE,oBAAC,qBAAqB,UAArB;AAAA,IAA8B,OAAO;AAAA,IACpC,8BAAC,oBAAoB,UAApB;AAAA,MAA6B,OAAO;AAAA,MACnC,8BAAC;AAAA,QACC,sBAAsB,OAAO;AAAA,QAC7B,uBAAuB,OAAO;AAAA,QAC7B,GAAG;AAAA,QACJ,cAAc,mBAAmB,gBAAgB,OAAO,KAAK,OAAO,MAAM,EAAE;AAAA,QAE3E;AAAA,OACH;AAAA,KACF;AAAA,GACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/views/Text.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Text.tsx"],
|
|
4
|
-
"sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { stylePropsTextOnly, validStyles } from '@tamagui/helpers'\n// @ts-ignore\nimport type { Text as TextView } from '@types/react-native'\n\nimport { createComponent } from '../createComponent'\nimport { TextProps, TextPropsBase } from '../types'\n\nconst ellipseStyle = {\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}\n\nexport const Text = createComponent<TextProps, TextView, TextPropsBase>({\n componentName: 'Text',\n acceptsClassName: true,\n isText: true,\n\n defaultProps: {\n // @ts-ignore\n display: 'flex',\n fontFamily: 'System',\n ...(isWeb\n ? {\n display: 'inline',\n boxSizing: 'border-box',\n wordWrap: 'break-word',\n margin: 0,\n }\n : {\n suppressHighlighting: true,\n }),\n },\n\n inlineWhenUnflattened: new Set(['fontFamily']),\n\n variants: {\n ...(isWeb && {\n numberOfLines: {\n 1: ellipseStyle,\n\n ':number': (numberOfLines) =>\n numberOfLines >= 1\n ? {\n WebkitLineClamp: numberOfLines,\n WebkitBoxOrient: 'vertical',\n display: '-webkit-box',\n overflow: 'hidden',\n }\n : null,\n },\n }),\n\n // ??\n ellipsizeMode: {\n '...': () => null,\n },\n\n selectable: {\n true: {\n userSelect: 'text',\n cursor: 'text',\n },\n false: {\n userSelect: 'none',\n cursor: 'default',\n },\n },\n\n
|
|
5
|
-
"mappings": "AAAA,SAAS,aAAa;AACtB,SAAS,oBAAoB,mBAAmB;AAIhD,SAAS,uBAAuB;AAGhC,MAAM,eAAe;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AACd;AAEO,MAAM,OAAO,gBAAoD;AAAA,EACtE,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EAER,cAAc;AAAA,IAEZ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,GAAI,QACA;AAAA,MACE,SAAS;AAAA,MACT,WAAW;AAAA,MACX,UAAU;AAAA,MACV,QAAQ;AAAA,IACV,IACA;AAAA,MACE,sBAAsB;AAAA,IACxB;AAAA,EACN;AAAA,EAEA,uBAAuB,oBAAI,IAAI,CAAC,YAAY,CAAC;AAAA,EAE7C,UAAU;AAAA,IACR,GAAI,SAAS;AAAA,MACX,eAAe;AAAA,QACb,GAAG;AAAA,QAEH,WAAW,CAAC,kBACV,iBAAiB,IACb;AAAA,UACE,iBAAiB;AAAA,UACjB,iBAAiB;AAAA,UACjB,SAAS;AAAA,UACT,UAAU;AAAA,QACZ,IACA;AAAA,MACR;AAAA,IACF;AAAA,IAGA,eAAe;AAAA,MACb,OAAO,MAAM;AAAA,IACf;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,QACJ,YAAY;AAAA,QACZ,QAAQ;AAAA,MACV;AAAA,MACA,OAAO;AAAA,QACL,YAAY;AAAA,QACZ,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,IAEA,
|
|
4
|
+
"sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { stylePropsTextOnly, validStyles } from '@tamagui/helpers'\n// @ts-ignore\nimport type { Text as TextView } from '@types/react-native'\n\nimport { createComponent } from '../createComponent'\nimport { TextProps, TextPropsBase } from '../types'\n\nconst ellipseStyle = {\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}\n\nexport const Text = createComponent<TextProps, TextView, TextPropsBase>({\n componentName: 'Text',\n acceptsClassName: true,\n isText: true,\n\n defaultProps: {\n // @ts-ignore\n display: 'flex',\n fontFamily: 'System',\n ...(isWeb\n ? {\n display: 'inline',\n boxSizing: 'border-box',\n wordWrap: 'break-word',\n margin: 0,\n }\n : {\n suppressHighlighting: true,\n }),\n },\n\n inlineWhenUnflattened: new Set(['fontFamily']),\n\n variants: {\n ...(isWeb && {\n numberOfLines: {\n 1: ellipseStyle,\n\n ':number': (numberOfLines) =>\n numberOfLines >= 1\n ? {\n WebkitLineClamp: numberOfLines,\n WebkitBoxOrient: 'vertical',\n display: '-webkit-box',\n overflow: 'hidden',\n }\n : null,\n },\n }),\n\n // ??\n ellipsizeMode: {\n '...': () => null,\n },\n\n selectable: {\n true: {\n userSelect: 'text',\n cursor: 'text',\n },\n false: {\n userSelect: 'none',\n cursor: 'default',\n },\n },\n\n ellipse: {\n true: isWeb\n ? ellipseStyle\n : {\n numberOfLines: 1,\n lineBreakMode: 'clip',\n },\n },\n },\n\n deoptProps: new Set(isWeb ? [] : ['ellipse']),\n\n validStyles: {\n ...validStyles,\n ...stylePropsTextOnly,\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,aAAa;AACtB,SAAS,oBAAoB,mBAAmB;AAIhD,SAAS,uBAAuB;AAGhC,MAAM,eAAe;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AACd;AAEO,MAAM,OAAO,gBAAoD;AAAA,EACtE,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EAER,cAAc;AAAA,IAEZ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,GAAI,QACA;AAAA,MACE,SAAS;AAAA,MACT,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