@tamagui/core 1.0.1-beta.59 → 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.
- package/dist/cjs/Pressability.js +28 -0
- package/dist/cjs/Pressability.js.map +7 -0
- package/dist/cjs/Pressability.native.js +28 -0
- package/dist/cjs/Pressability.native.js.map +7 -0
- package/dist/cjs/createComponent.js +38 -10
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/helpers/generateAtomicStyles.js +18 -3
- package/dist/cjs/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +0 -1
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/isTamaguiComponent.js +38 -0
- package/dist/cjs/helpers/isTamaguiComponent.js.map +7 -0
- package/dist/cjs/helpers/isTamaguiElement.js +2 -8
- package/dist/cjs/helpers/isTamaguiElement.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +1 -1
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/views/Slot.js +2 -1
- package/dist/cjs/views/Slot.js.map +2 -2
- package/dist/esm/Pressability.js +5 -0
- package/dist/esm/Pressability.js.map +7 -0
- package/dist/esm/Pressability.native.js +5 -0
- package/dist/esm/Pressability.native.js.map +7 -0
- package/dist/esm/createComponent.js +42 -12
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/helpers/generateAtomicStyles.js +4 -2
- package/dist/esm/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +0 -1
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/isTamaguiComponent.js +16 -0
- package/dist/esm/helpers/isTamaguiComponent.js.map +7 -0
- package/dist/esm/helpers/isTamaguiElement.js +2 -8
- package/dist/esm/helpers/isTamaguiElement.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +2 -2
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/views/Slot.js +2 -1
- package/dist/esm/views/Slot.js.map +2 -2
- package/dist/jsx/Pressability.js +4 -0
- package/dist/jsx/Pressability.native.js +4 -0
- package/dist/jsx/createComponent.js +42 -8
- package/dist/jsx/helpers/generateAtomicStyles.js +4 -2
- package/dist/jsx/helpers/getSplitStyles.js +0 -1
- package/dist/jsx/helpers/isTamaguiComponent.js +15 -0
- package/dist/jsx/helpers/isTamaguiElement.js +2 -8
- package/dist/jsx/hooks/useTheme.js +2 -2
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/views/Slot.js +2 -1
- package/package.json +5 -5
- package/types/Pressability.d.ts +2 -0
- package/types/Pressability.d.ts.map +1 -0
- package/types/Pressability.native.d.ts +2 -0
- package/types/Pressability.native.d.ts.map +1 -0
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/generateAtomicStyles.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/isTamaguiComponent.d.ts +5 -0
- package/types/helpers/isTamaguiComponent.d.ts.map +1 -0
- package/types/helpers/isTamaguiElement.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/views/Slot.d.ts.map +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/generateAtomicStyles.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Some parts adapted from react-native-web\n * Copyright (c) Nicolas Gallagher licensed under the MIT license.\n */\n\nimport { simpleHash } from '@tamagui/helpers'\nimport hyphenateStyleName from 'hyphenate-style-name'\nimport normalizeCSSColor from 'normalize-css-color'\nimport { TextStyle, ViewStyle } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { prefixInlineStyles, prefixStyles } from './prefixStyles'\n\nexport function expandStyles(style: any) {\n const res = {}\n for (const key in style) {\n updateReactDOMStyle(res, key, style[key])\n }\n return res\n}\n\n// TODO can use for inline styles...\n/**\n * Compile simple style object to inline DOM styles.\n * No support for 'animationKeyframes', 'placeholderTextColor', 'scrollbarWidth', or 'pointerEvents'.\n */\nexport function inline(style: Style): Object {\n return prefixInlineStyles(expandStyles(style))\n}\n\ntype Rule = string\ntype Rules = Array<Rule>\nexport type RulesData = {\n property?: string\n value?: string\n identifier: string\n rules: Rules\n}\ntype CompilerOutput = { [key: string]: RulesData }\ntype Value = Object | Array<any> | string | number\nexport type Style = { [key: string]: Value }\n\nconst STYLE_SHORT_FORM_EXPANSIONS = {\n borderColor: ['borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor'],\n borderRadius: [\n 'borderTopLeftRadius',\n 'borderTopRightRadius',\n 'borderBottomRightRadius',\n 'borderBottomLeftRadius',\n ],\n borderStyle: ['borderTopStyle', 'borderRightStyle', 'borderBottomStyle', 'borderLeftStyle'],\n borderWidth: ['borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth'],\n margin: ['marginTop', 'marginRight', 'marginBottom', 'marginLeft'],\n marginHorizontal: ['marginRight', 'marginLeft'],\n marginVertical: ['marginTop', 'marginBottom'],\n overflow: ['overflowX', 'overflowY'],\n overscrollBehavior: ['overscrollBehaviorX', 'overscrollBehaviorY'],\n padding: ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'],\n paddingHorizontal: ['paddingRight', 'paddingLeft'],\n paddingVertical: ['paddingTop', 'paddingBottom'],\n}\n\nexport const generateAtomicStyles = (style: ViewStyle & TextStyle): CompilerOutput => {\n const res = expandStyles(style)\n\n if (\n style.shadowColor != null ||\n style.shadowOffset != null ||\n style.shadowOpacity != null ||\n style.shadowRadius != null\n ) {\n boxShadowReducer(res, style)\n delete res['shadowColor']\n delete res['shadowOffset']\n delete res['shadowOpacity']\n delete res['shadowRadius']\n }\n\n if (\n style.textShadowColor != null ||\n style.textShadowOffset != null ||\n style.textShadowRadius != null\n ) {\n textShadowReducer(res, style)\n delete res['textShadowColor']\n delete res['textShadowOffset']\n delete res['textShadowRadius']\n }\n\n const out = {}\n for (const key in res) {\n const value = res[key]\n if (value != null) {\n const valueString = stringifyValueWithProperty(value, key)\n const cachedResult = cache.get(key, valueString)\n if (cachedResult != null) {\n const { identifier } = cachedResult\n out[identifier] = cachedResult\n } else {\n const identifier = createIdentifier('r', key, value)\n const rules = createAtomicRules(identifier, key, value)\n const cachedResult = cache.set(key, valueString, {\n property: key,\n value: stringifyValueWithProperty(value, key),\n identifier,\n rules,\n })\n out[identifier] = cachedResult\n }\n }\n }\n\n return out\n}\n\nfunction updateReactDOMStyle(style: Object, key: string, value: any) {\n value = normalizeValueWithProperty(value, key)\n const out = expandStyle(key, value)\n if (out) {\n Object.assign(style, Object.fromEntries(out))\n } else {\n style[key] = value\n }\n}\n\nexport function expandStyle(key: string, value: any) {\n if (key === 'flex') {\n // The 'flex' property value in React Native must be a positive integer,\n // 0, or -1.\n if (value <= -1) {\n return [\n ['flexGrow', 0],\n ['flexShrink', 1],\n ['flexBasis', 'auto'],\n ]\n }\n // normalizing to better align with native\n // see spec for flex shorthand https://developer.mozilla.org/en-US/docs/Web/CSS/flex\n if (value >= 0) {\n return [\n ['flexGrow', value],\n ['flexShrink', 1],\n ]\n }\n return\n }\n\n // web only\n switch (key) {\n // Ignore some React Native styles\n case 'elevation':\n case 'overlayColor':\n case 'resizeMode':\n case 'tintColor': {\n break\n }\n\n case 'aspectRatio': {\n return [[key, value.toString()]]\n }\n\n // TODO: remove once this issue is fixed\n // https://github.com/rofrischmann/inline-style-prefixer/issues/159\n case 'backgroundClip': {\n if (value === 'text') {\n return [\n ['backgroundClip', value],\n ['WebkitBackgroundClip', value],\n ]\n }\n break\n }\n\n case 'textAlignVertical': {\n return [['verticalAlign', value === 'center' ? 'middle' : value]]\n }\n\n case 'textDecorationLine': {\n return [['textDecorationLine', value]]\n }\n\n case 'transform': {\n if (Array.isArray(value)) {\n return [[key, value.map(mapTransform).join(' ')]]\n }\n break\n }\n\n case 'writingDirection': {\n return [['direction', value]]\n }\n }\n\n const longKey = STYLE_SHORT_FORM_EXPANSIONS[key]\n if (longKey) {\n return longKey.map((key) => {\n return [key, value]\n })\n } else {\n if (isWeb && Array.isArray(value)) {\n return [[key, value.join(',')]]\n }\n }\n}\n\nfunction createAtomicRules(identifier: string, property, value): Rules {\n const rules: string[] = []\n const selector = `.${identifier}`\n\n // Handle non-standard properties and object values that require multiple\n // CSS rules to be created.\n switch (property) {\n case 'animationKeyframes': {\n const { animationNames, rules: keyframesRules } = processKeyframesValue(value)\n const block = createDeclarationBlock({ animationName: animationNames.join(',') })\n rules.push(`${selector}${block}`, ...keyframesRules)\n break\n }\n\n // Equivalent to using '::placeholder'\n case 'placeholderTextColor': {\n const block = createDeclarationBlock({ color: value, opacity: 1 })\n rules.push(\n `${selector}::-webkit-input-placeholder${block}`,\n `${selector}::-moz-placeholder${block}`,\n `${selector}:-ms-input-placeholder${block}`,\n `${selector}::placeholder${block}`\n )\n break\n }\n\n // Polyfill for additional 'pointer-events' values\n // See d13f78622b233a0afc0c7a200c0a0792c8ca9e58\n case 'pointerEvents': {\n let finalValue = value\n if (value === 'auto' || value === 'box-only') {\n finalValue = 'auto!important'\n if (value === 'box-only') {\n const block = createDeclarationBlock({ pointerEvents: 'none' })\n rules.push(`${selector}>*${block}`)\n }\n } else if (value === 'none' || value === 'box-none') {\n finalValue = 'none!important'\n if (value === 'box-none') {\n const block = createDeclarationBlock({ pointerEvents: 'auto' })\n rules.push(`${selector}>*${block}`)\n }\n }\n const block = createDeclarationBlock({ pointerEvents: finalValue })\n rules.push(`${selector}${block}`)\n break\n }\n\n // Polyfill for draft spec\n // https://drafts.csswg.org/css-scrollbars-1/\n case 'scrollbarWidth': {\n if (value === 'none') {\n rules.push(`${selector}::-webkit-scrollbar{display:none}`)\n }\n const block = createDeclarationBlock({ scrollbarWidth: value })\n rules.push(`${selector}${block}`)\n break\n }\n\n default: {\n const block = createDeclarationBlock({ [property]: value })\n rules.push(`${selector}${block}`)\n break\n }\n }\n\n return rules\n}\n\n/**\n * Create CSS keyframes rules and names from a StyleSheet keyframes object.\n */\nfunction processKeyframesValue(keyframesValue: number | string[]) {\n if (typeof keyframesValue === 'number') {\n throw new Error(`Invalid CSS keyframes type: ${typeof keyframesValue}`)\n }\n\n const animationNames: string[] = []\n const rules: string[] = []\n const value = Array.isArray(keyframesValue) ? keyframesValue : [keyframesValue]\n\n for (const keyframes of value) {\n if (typeof keyframes === 'string') {\n // Support external animation libraries (identifiers only)\n animationNames.push(keyframes)\n } else {\n // Create rules for each of the keyframes\n const { identifier, rules: keyframesRules } = createKeyframes(keyframes)\n animationNames.push(identifier)\n rules.push(...keyframesRules)\n }\n }\n\n return { animationNames, rules }\n}\n\n/**\n * Create individual CSS keyframes rules.\n */\nfunction createKeyframes(keyframes) {\n const prefixes = ['-webkit-', '']\n const identifier = createIdentifier('r', 'animation', keyframes)\n\n const steps =\n '{' +\n Object.keys(keyframes)\n .map((stepName) => {\n const rule = keyframes[stepName]\n const block = createDeclarationBlock(rule)\n return `${stepName}${block}`\n })\n .join('') +\n '}'\n\n const rules = prefixes.map((prefix) => {\n return `@${prefix}keyframes ${identifier}${steps}`\n })\n return { identifier, rules }\n}\n\n/**\n * Creates a CSS declaration block from a StyleSheet object.\n */\nfunction createDeclarationBlock(style: Style) {\n const domStyle = prefixStyles(expandStyles(style))\n const declarationsString = Object.keys(domStyle)\n .map((property) => {\n const value = domStyle[property]\n const prop = hyphenateStyleName(property)\n // The prefixer may return an array of values:\n // { display: [ '-webkit-flex', 'flex' ] }\n // to represent \"fallback\" declarations\n // { display: -webkit-flex; display: flex; }\n if (Array.isArray(value)) {\n return value.map((v) => `${prop}:${v}`).join(';')\n } else {\n return `${prop}:${value}`\n }\n })\n // Once properties are hyphenated, this will put the vendor\n // prefixed and short-form properties first in the list.\n .sort()\n .join(';')\n\n return `{${declarationsString};}`\n}\n\nfunction createIdentifier(prefix: string, name: string, value): string {\n const hashedString = simpleHash(name + stringifyValueWithProperty(value, name))\n return `${prefix}-${hashedString}`\n}\n\nconst cache = {\n get(property, value) {\n if (\n cache[property] != null &&\n cache[property].hasOwnProperty(value) &&\n cache[property][value] != null\n ) {\n return cache[property][value]\n }\n },\n set(property, value, object) {\n if (cache[property] == null) {\n cache[property] = {}\n }\n return (cache[property][value] = object)\n },\n}\n\nfunction stringifyValueWithProperty(value: Value, property?: string): string {\n // e.g., 0 => '0px', 'black' => 'rgba(0,0,0,1)'\n const normalizedValue = normalizeValueWithProperty(value, property)\n return typeof normalizedValue !== 'string'\n ? JSON.stringify(normalizedValue || '')\n : normalizedValue\n}\n\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)'\nconst mapTransform = (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 } else {\n const normalizedValue = normalizeValueWithProperty(value, type)\n return `${type}(${normalizedValue})`\n }\n}\n\nconst colorProps = {\n backgroundColor: true,\n borderColor: true,\n borderTopColor: true,\n borderRightColor: true,\n borderBottomColor: true,\n borderLeftColor: true,\n color: true,\n shadowColor: true,\n textDecorationColor: true,\n textShadowColor: true,\n}\n\nfunction normalizeValueWithProperty(value: any, property?: string): any {\n if (process.env.TAMAGUI_TARGET === 'web') {\n if (\n (property === undefined || property === null || !unitlessNumbers[property]) &&\n typeof value === 'number'\n ) {\n return `${value}px`\n }\n }\n if (property && colorProps[property]) {\n return normalizeColor(value)\n }\n return value\n}\n\nconst normalizeColor = (color?: number | string, opacity = 1): void | string => {\n if (color == null || color == undefined) {\n return\n }\n if (process.env.TAMAGUI_TARGET === 'web') {\n if (typeof color === 'string' && isWebColor(color)) {\n return color\n }\n }\n const colorInt = processColor(color)\n if (colorInt != null) {\n const r = (colorInt >> 16) & 255\n const g = (colorInt >> 8) & 255\n const b = colorInt & 255\n const a = ((colorInt >> 24) & 255) / 255\n const alpha = (a * opacity).toFixed(2)\n return `rgba(${r},${g},${b},${alpha})`\n }\n}\n\nconst isWebColor = (color: string): boolean =>\n color === 'currentcolor' ||\n color === 'currentColor' ||\n color === 'inherit' ||\n color.indexOf('var(') === 0\n\nconst processColor = (color?: number | string): number | undefined | null => {\n if (color === undefined || color === null) {\n return color\n }\n let intColor = normalizeCSSColor(color)\n if (intColor === undefined || intColor === null) {\n return undefined\n }\n return ((+intColor << 24) | (+intColor >>> 8)) >>> 0\n}\n\nconst unitlessNumbers = {\n animationIterationCount: true,\n aspectRatio: true,\n borderImageOutset: true,\n borderImageSlice: true,\n borderImageWidth: true,\n boxFlex: true,\n boxFleGroup: true,\n boxOrdinalGroup: true,\n columnCount: true,\n flex: true,\n flexGrow: true,\n flexOrder: true,\n flexPositive: true,\n flexShrink: true,\n flexNegative: true,\n fontWeight: true,\n gridRow: true,\n gridRowEnd: true,\n gridRowGap: true,\n gridRowStart: true,\n gridColumn: true,\n gridColumnEnd: true,\n gridColumnGap: true,\n gridColumnStart: true,\n lineClamp: true,\n opacity: true,\n order: true,\n orphans: true,\n tabSize: true,\n widows: true,\n zIndex: true,\n zoom: true,\n fillOpacity: true,\n floodOpacity: true,\n stopOpacity: true,\n strokeDasharray: true,\n strokeDashoffset: true,\n strokeMiterlimit: true,\n strokeOpacity: true,\n strokeWidth: true,\n scale: true,\n scaleX: true,\n scaleY: true,\n scaleZ: true,\n shadowOpacity: true,\n}\n\n/**\n * Support style names that may come passed in prefixed by adding permutations\n * of vendor prefixes.\n */\nconst prefixes = ['ms', 'Moz', 'O', 'Webkit']\nconst prefixKey = (prefix: string, key: string) => {\n return prefix + key.charAt(0).toUpperCase() + key.substring(1)\n}\nObject.keys(unitlessNumbers).forEach((prop) => {\n prefixes.forEach((prefix) => {\n unitlessNumbers[prefixKey(prefix, prop)] = unitlessNumbers[prop]\n })\n})\n\nconst resolveShadowValue = (style: ViewStyle): void | string => {\n const { shadowColor, shadowOffset, shadowOpacity, shadowRadius } = style\n const { height, width } = shadowOffset || defaultOffset\n const offsetX = normalizeValueWithProperty(width)\n const offsetY = normalizeValueWithProperty(height)\n const blurRadius = normalizeValueWithProperty(shadowRadius || 0)\n // @ts-ignore\n const color = normalizeColor(shadowColor || 'black', shadowOpacity)\n if (color != null && offsetX != null && offsetY != null && blurRadius != null) {\n return `${offsetX} ${offsetY} ${blurRadius} ${color}`\n }\n}\n\nfunction boxShadowReducer(resolvedStyle, style) {\n const { boxShadow } = style\n const shadow = resolveShadowValue(style)\n if (shadow != null) {\n resolvedStyle.boxShadow = boxShadow ? `${boxShadow}, ${shadow}` : shadow\n }\n}\n\nconst defaultOffset = { height: 0, width: 0 }\nfunction textShadowReducer(resolvedStyle, style) {\n const { textShadowColor, textShadowOffset, textShadowRadius } = style\n const { height, width } = textShadowOffset || defaultOffset\n const radius = textShadowRadius || 0\n const offsetX = normalizeValueWithProperty(width)\n const offsetY = normalizeValueWithProperty(height)\n const blurRadius = normalizeValueWithProperty(radius)\n const color = normalizeValueWithProperty(textShadowColor, 'textShadowColor')\n\n if (\n color &&\n (height !== 0 || width !== 0 || radius !== 0) &&\n offsetX != null &&\n offsetY != null &&\n blurRadius != null\n ) {\n resolvedStyle.textShadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * Some parts adapted from react-native-web\n * Copyright (c) Nicolas Gallagher licensed under the MIT license.\n */\n\nimport { simpleHash } from '@tamagui/helpers'\nimport hyphenateStyleName from 'hyphenate-style-name'\nimport normalizeCSSColor from 'normalize-css-color'\nimport { TextStyle, ViewStyle } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { prefixInlineStyles, prefixStyles } from './prefixStyles'\n\nexport function expandStyles(style: any) {\n const res = {}\n for (const key in style) {\n updateReactDOMStyle(res, key, style[key])\n }\n return res\n}\n\n// TODO can use for inline styles...\n/**\n * Compile simple style object to inline DOM styles.\n * No support for 'animationKeyframes', 'placeholderTextColor', 'scrollbarWidth', or 'pointerEvents'.\n */\nexport function inline(style: Style): Object {\n return prefixInlineStyles(expandStyles(style))\n}\n\ntype Rule = string\ntype Rules = Array<Rule>\nexport type RulesData = {\n property?: string\n value?: string\n identifier: string\n rules: Rules\n}\ntype CompilerOutput = { [key: string]: RulesData }\ntype Value = Object | Array<any> | string | number\nexport type Style = { [key: string]: Value }\n\nconst STYLE_SHORT_FORM_EXPANSIONS = {\n borderColor: ['borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor'],\n borderRadius: [\n 'borderTopLeftRadius',\n 'borderTopRightRadius',\n 'borderBottomRightRadius',\n 'borderBottomLeftRadius',\n ],\n borderStyle: ['borderTopStyle', 'borderRightStyle', 'borderBottomStyle', 'borderLeftStyle'],\n borderWidth: ['borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth'],\n margin: ['marginTop', 'marginRight', 'marginBottom', 'marginLeft'],\n marginHorizontal: ['marginRight', 'marginLeft'],\n marginVertical: ['marginTop', 'marginBottom'],\n overscrollBehavior: ['overscrollBehaviorX', 'overscrollBehaviorY'],\n padding: ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'],\n paddingHorizontal: ['paddingRight', 'paddingLeft'],\n paddingVertical: ['paddingTop', 'paddingBottom'],\n ...(isWeb && {\n // react-native doesn't support X / Y\n overflow: ['overflowX', 'overflowY'],\n }),\n}\n\nexport const generateAtomicStyles = (style: ViewStyle & TextStyle): CompilerOutput => {\n const res = expandStyles(style)\n\n if (\n style.shadowColor != null ||\n style.shadowOffset != null ||\n style.shadowOpacity != null ||\n style.shadowRadius != null\n ) {\n boxShadowReducer(res, style)\n delete res['shadowColor']\n delete res['shadowOffset']\n delete res['shadowOpacity']\n delete res['shadowRadius']\n }\n\n if (\n style.textShadowColor != null ||\n style.textShadowOffset != null ||\n style.textShadowRadius != null\n ) {\n textShadowReducer(res, style)\n delete res['textShadowColor']\n delete res['textShadowOffset']\n delete res['textShadowRadius']\n }\n\n const out = {}\n for (const key in res) {\n const value = res[key]\n if (value != null) {\n const valueString = stringifyValueWithProperty(value, key)\n const cachedResult = cache.get(key, valueString)\n if (cachedResult != null) {\n const { identifier } = cachedResult\n out[identifier] = cachedResult\n } else {\n const identifier = createIdentifier('r', key, value)\n const rules = createAtomicRules(identifier, key, value)\n const cachedResult = cache.set(key, valueString, {\n property: key,\n value: stringifyValueWithProperty(value, key),\n identifier,\n rules,\n })\n out[identifier] = cachedResult\n }\n }\n }\n\n return out\n}\n\nfunction updateReactDOMStyle(style: Object, key: string, value: any) {\n value = normalizeValueWithProperty(value, key)\n const out = expandStyle(key, value)\n if (out) {\n Object.assign(style, Object.fromEntries(out))\n } else {\n style[key] = value\n }\n}\n\nexport function expandStyle(key: string, value: any) {\n if (key === 'flex') {\n // The 'flex' property value in React Native must be a positive integer,\n // 0, or -1.\n if (value <= -1) {\n return [\n ['flexGrow', 0],\n ['flexShrink', 1],\n ['flexBasis', 'auto'],\n ]\n }\n // normalizing to better align with native\n // see spec for flex shorthand https://developer.mozilla.org/en-US/docs/Web/CSS/flex\n if (value >= 0) {\n return [\n ['flexGrow', value],\n ['flexShrink', 1],\n ]\n }\n return\n }\n\n // web only\n switch (key) {\n // Ignore some React Native styles\n case 'elevation':\n case 'overlayColor':\n case 'resizeMode':\n case 'tintColor': {\n break\n }\n\n case 'aspectRatio': {\n return [[key, value.toString()]]\n }\n\n // TODO: remove once this issue is fixed\n // https://github.com/rofrischmann/inline-style-prefixer/issues/159\n case 'backgroundClip': {\n if (value === 'text') {\n return [\n ['backgroundClip', value],\n ['WebkitBackgroundClip', value],\n ]\n }\n break\n }\n\n case 'textAlignVertical': {\n return [['verticalAlign', value === 'center' ? 'middle' : value]]\n }\n\n case 'textDecorationLine': {\n return [['textDecorationLine', value]]\n }\n\n case 'transform': {\n if (Array.isArray(value)) {\n return [[key, value.map(mapTransform).join(' ')]]\n }\n break\n }\n\n case 'writingDirection': {\n return [['direction', value]]\n }\n }\n\n const longKey = STYLE_SHORT_FORM_EXPANSIONS[key]\n if (longKey) {\n return longKey.map((key) => {\n return [key, value]\n })\n } else {\n if (isWeb && Array.isArray(value)) {\n return [[key, value.join(',')]]\n }\n }\n}\n\nfunction createAtomicRules(identifier: string, property, value): Rules {\n const rules: string[] = []\n const selector = `.${identifier}`\n\n // Handle non-standard properties and object values that require multiple\n // CSS rules to be created.\n switch (property) {\n case 'animationKeyframes': {\n const { animationNames, rules: keyframesRules } = processKeyframesValue(value)\n const block = createDeclarationBlock({ animationName: animationNames.join(',') })\n rules.push(`${selector}${block}`, ...keyframesRules)\n break\n }\n\n // Equivalent to using '::placeholder'\n case 'placeholderTextColor': {\n const block = createDeclarationBlock({ color: value, opacity: 1 })\n rules.push(\n `${selector}::-webkit-input-placeholder${block}`,\n `${selector}::-moz-placeholder${block}`,\n `${selector}:-ms-input-placeholder${block}`,\n `${selector}::placeholder${block}`\n )\n break\n }\n\n // Polyfill for additional 'pointer-events' values\n // See d13f78622b233a0afc0c7a200c0a0792c8ca9e58\n case 'pointerEvents': {\n let finalValue = value\n if (value === 'auto' || value === 'box-only') {\n finalValue = 'auto!important'\n if (value === 'box-only') {\n const block = createDeclarationBlock({ pointerEvents: 'none' })\n rules.push(`${selector}>*${block}`)\n }\n } else if (value === 'none' || value === 'box-none') {\n finalValue = 'none!important'\n if (value === 'box-none') {\n const block = createDeclarationBlock({ pointerEvents: 'auto' })\n rules.push(`${selector}>*${block}`)\n }\n }\n const block = createDeclarationBlock({ pointerEvents: finalValue })\n rules.push(`${selector}${block}`)\n break\n }\n\n // Polyfill for draft spec\n // https://drafts.csswg.org/css-scrollbars-1/\n case 'scrollbarWidth': {\n if (value === 'none') {\n rules.push(`${selector}::-webkit-scrollbar{display:none}`)\n }\n const block = createDeclarationBlock({ scrollbarWidth: value })\n rules.push(`${selector}${block}`)\n break\n }\n\n default: {\n const block = createDeclarationBlock({ [property]: value })\n rules.push(`${selector}${block}`)\n break\n }\n }\n\n return rules\n}\n\n/**\n * Create CSS keyframes rules and names from a StyleSheet keyframes object.\n */\nfunction processKeyframesValue(keyframesValue: number | string[]) {\n if (typeof keyframesValue === 'number') {\n throw new Error(`Invalid CSS keyframes type: ${typeof keyframesValue}`)\n }\n\n const animationNames: string[] = []\n const rules: string[] = []\n const value = Array.isArray(keyframesValue) ? keyframesValue : [keyframesValue]\n\n for (const keyframes of value) {\n if (typeof keyframes === 'string') {\n // Support external animation libraries (identifiers only)\n animationNames.push(keyframes)\n } else {\n // Create rules for each of the keyframes\n const { identifier, rules: keyframesRules } = createKeyframes(keyframes)\n animationNames.push(identifier)\n rules.push(...keyframesRules)\n }\n }\n\n return { animationNames, rules }\n}\n\n/**\n * Create individual CSS keyframes rules.\n */\nfunction createKeyframes(keyframes) {\n const prefixes = ['-webkit-', '']\n const identifier = createIdentifier('r', 'animation', keyframes)\n\n const steps =\n '{' +\n Object.keys(keyframes)\n .map((stepName) => {\n const rule = keyframes[stepName]\n const block = createDeclarationBlock(rule)\n return `${stepName}${block}`\n })\n .join('') +\n '}'\n\n const rules = prefixes.map((prefix) => {\n return `@${prefix}keyframes ${identifier}${steps}`\n })\n return { identifier, rules }\n}\n\n/**\n * Creates a CSS declaration block from a StyleSheet object.\n */\nfunction createDeclarationBlock(style: Style) {\n const domStyle = prefixStyles(expandStyles(style))\n const declarationsString = Object.keys(domStyle)\n .map((property) => {\n const value = domStyle[property]\n const prop = hyphenateStyleName(property)\n // The prefixer may return an array of values:\n // { display: [ '-webkit-flex', 'flex' ] }\n // to represent \"fallback\" declarations\n // { display: -webkit-flex; display: flex; }\n if (Array.isArray(value)) {\n return value.map((v) => `${prop}:${v}`).join(';')\n } else {\n return `${prop}:${value}`\n }\n })\n // Once properties are hyphenated, this will put the vendor\n // prefixed and short-form properties first in the list.\n .sort()\n .join(';')\n\n return `{${declarationsString};}`\n}\n\nfunction createIdentifier(prefix: string, name: string, value): string {\n const hashedString = simpleHash(name + stringifyValueWithProperty(value, name))\n return `${prefix}-${hashedString}`\n}\n\nconst cache = {\n get(property, value) {\n if (\n cache[property] != null &&\n cache[property].hasOwnProperty(value) &&\n cache[property][value] != null\n ) {\n return cache[property][value]\n }\n },\n set(property, value, object) {\n if (cache[property] == null) {\n cache[property] = {}\n }\n return (cache[property][value] = object)\n },\n}\n\nfunction stringifyValueWithProperty(value: Value, property?: string): string {\n // e.g., 0 => '0px', 'black' => 'rgba(0,0,0,1)'\n const normalizedValue = normalizeValueWithProperty(value, property)\n return typeof normalizedValue !== 'string'\n ? JSON.stringify(normalizedValue || '')\n : normalizedValue\n}\n\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)'\nconst mapTransform = (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 } else {\n const normalizedValue = normalizeValueWithProperty(value, type)\n return `${type}(${normalizedValue})`\n }\n}\n\nconst colorProps = {\n backgroundColor: true,\n borderColor: true,\n borderTopColor: true,\n borderRightColor: true,\n borderBottomColor: true,\n borderLeftColor: true,\n color: true,\n shadowColor: true,\n textDecorationColor: true,\n textShadowColor: true,\n}\n\nfunction normalizeValueWithProperty(value: any, property?: string): any {\n if (process.env.TAMAGUI_TARGET === 'web') {\n if (\n (property === undefined || property === null || !unitlessNumbers[property]) &&\n typeof value === 'number'\n ) {\n return `${value}px`\n }\n }\n if (property && colorProps[property]) {\n return normalizeColor(value)\n }\n return value\n}\n\nconst normalizeColor = (color?: number | string, opacity = 1): void | string => {\n if (color == null || color == undefined) {\n return\n }\n if (process.env.TAMAGUI_TARGET === 'web') {\n if (typeof color === 'string' && isWebColor(color)) {\n return color\n }\n }\n const colorInt = processColor(color)\n if (colorInt != null) {\n const r = (colorInt >> 16) & 255\n const g = (colorInt >> 8) & 255\n const b = colorInt & 255\n const a = ((colorInt >> 24) & 255) / 255\n const alpha = (a * opacity).toFixed(2)\n return `rgba(${r},${g},${b},${alpha})`\n }\n}\n\nconst isWebColor = (color: string): boolean =>\n color === 'currentcolor' ||\n color === 'currentColor' ||\n color === 'inherit' ||\n color.indexOf('var(') === 0\n\nconst processColor = (color?: number | string): number | undefined | null => {\n if (color === undefined || color === null) {\n return color\n }\n let intColor = normalizeCSSColor(color)\n if (intColor === undefined || intColor === null) {\n return undefined\n }\n return ((+intColor << 24) | (+intColor >>> 8)) >>> 0\n}\n\nconst unitlessNumbers = {\n animationIterationCount: true,\n aspectRatio: true,\n borderImageOutset: true,\n borderImageSlice: true,\n borderImageWidth: true,\n boxFlex: true,\n boxFleGroup: true,\n boxOrdinalGroup: true,\n columnCount: true,\n flex: true,\n flexGrow: true,\n flexOrder: true,\n flexPositive: true,\n flexShrink: true,\n flexNegative: true,\n fontWeight: true,\n gridRow: true,\n gridRowEnd: true,\n gridRowGap: true,\n gridRowStart: true,\n gridColumn: true,\n gridColumnEnd: true,\n gridColumnGap: true,\n gridColumnStart: true,\n lineClamp: true,\n opacity: true,\n order: true,\n orphans: true,\n tabSize: true,\n widows: true,\n zIndex: true,\n zoom: true,\n fillOpacity: true,\n floodOpacity: true,\n stopOpacity: true,\n strokeDasharray: true,\n strokeDashoffset: true,\n strokeMiterlimit: true,\n strokeOpacity: true,\n strokeWidth: true,\n scale: true,\n scaleX: true,\n scaleY: true,\n scaleZ: true,\n shadowOpacity: true,\n}\n\n/**\n * Support style names that may come passed in prefixed by adding permutations\n * of vendor prefixes.\n */\nconst prefixes = ['ms', 'Moz', 'O', 'Webkit']\nconst prefixKey = (prefix: string, key: string) => {\n return prefix + key.charAt(0).toUpperCase() + key.substring(1)\n}\nObject.keys(unitlessNumbers).forEach((prop) => {\n prefixes.forEach((prefix) => {\n unitlessNumbers[prefixKey(prefix, prop)] = unitlessNumbers[prop]\n })\n})\n\nconst resolveShadowValue = (style: ViewStyle): void | string => {\n const { shadowColor, shadowOffset, shadowOpacity, shadowRadius } = style\n const { height, width } = shadowOffset || defaultOffset\n const offsetX = normalizeValueWithProperty(width)\n const offsetY = normalizeValueWithProperty(height)\n const blurRadius = normalizeValueWithProperty(shadowRadius || 0)\n // @ts-ignore\n const color = normalizeColor(shadowColor || 'black', shadowOpacity)\n if (color != null && offsetX != null && offsetY != null && blurRadius != null) {\n return `${offsetX} ${offsetY} ${blurRadius} ${color}`\n }\n}\n\nfunction boxShadowReducer(resolvedStyle, style) {\n const { boxShadow } = style\n const shadow = resolveShadowValue(style)\n if (shadow != null) {\n resolvedStyle.boxShadow = boxShadow ? `${boxShadow}, ${shadow}` : shadow\n }\n}\n\nconst defaultOffset = { height: 0, width: 0 }\nfunction textShadowReducer(resolvedStyle, style) {\n const { textShadowColor, textShadowOffset, textShadowRadius } = style\n const { height, width } = textShadowOffset || defaultOffset\n const radius = textShadowRadius || 0\n const offsetX = normalizeValueWithProperty(width)\n const offsetY = normalizeValueWithProperty(height)\n const blurRadius = normalizeValueWithProperty(radius)\n const color = normalizeValueWithProperty(textShadowColor, 'textShadowColor')\n\n if (\n color &&\n (height !== 0 || width !== 0 || radius !== 0) &&\n offsetX != null &&\n offsetY != null &&\n blurRadius != null\n ) {\n resolvedStyle.textShadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,qBAA2B;AAC3B,kCAA+B;AAC/B,iCAA8B;AAG9B,sBAAsB;AACtB,0BAAiD;AAE1C,sBAAsB,OAAY;AACvC,QAAM,MAAM,CAAC;AACb,aAAW,OAAO,OAAO;AACvB,wBAAoB,KAAK,KAAK,MAAM,IAAI;AAAA,EAC1C;AACA,SAAO;AACT;AANgB;AAaT,gBAAgB,OAAsB;AAC3C,SAAO,4CAAmB,aAAa,KAAK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AAS,mBAAmB,KAAK;AACvC,MAAI,UAAU,MAAM;AAClB,kBAAc,YAAY,YAAY,GAAG,cAAc,WAAW;AAAA,EACpE;AACF;AANS;AAQT,MAAM,gBAAgB,EAAE,QAAQ,GAAG,OAAO,EAAE;AAC5C,2BAA2B,eAAe,OAAO;AAC/C,QAAM,EAAE,iBAAiB,kBAAkB,qBAAqB;AAChE,QAAM,EAAE,QAAQ,UAAU,oBAAoB;AAC9C,QAAM,SAAS,oBAAoB;AACnC,QAAM,UAAU,2BAA2B,KAAK;AAChD,QAAM,UAAU,2BAA2B,MAAM;AACjD,QAAM,aAAa,2BAA2B,MAAM;AACpD,QAAM,QAAQ,2BAA2B,iBAAiB,iBAAiB;AAE3E,MACE,SACC,YAAW,KAAK,UAAU,KAAK,WAAW,MAC3C,WAAW,QACX,WAAW,QACX,cAAc,MACd;AACA,kBAAc,aAAa,GAAG,WAAW,WAAW,cAAc;AAAA,EACpE;AACF;AAlBS;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/getSplitStyles.tsx"],
|
|
4
|
-
"sourcesContent": ["import { stylePropsText, stylePropsTransform, validPseudoKeys, validStyles } from '@tamagui/helpers'\n// @ts-ignore\nimport { useInsertionEffect } from 'react'\nimport { ViewStyle } from 'react-native'\n\nimport { getConfig } from '../conf'\nimport { isClient, isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { mediaQueryConfig, mediaState } from '../hooks/useMedia'\nimport {\n MediaKeys,\n MediaQueryKey,\n PseudoStyles,\n PsuedoPropKeys,\n SplitStyleState,\n StackProps,\n StaticConfigParsed,\n TamaguiInternalConfig,\n ThemeObject,\n} from '../types'\nimport { createMediaStyle } from './createMediaStyle'\nimport { fixNativeShadow } from './fixNativeShadow'\nimport { getStylesAtomic, psuedoCNInverse } from './getStylesAtomic'\nimport {\n insertStyleRule,\n insertedTransforms,\n updateInserted,\n updateInsertedCache,\n} from './insertStyleRule'\nimport { mergeTransform } from './mergeTransform'\n\nexport type SplitStyles = ReturnType<typeof getSplitStyles>\nexport type ClassNamesObject = Record<string, string>\nexport type SplitStyleResult = ReturnType<typeof getSplitStyles>\n\nconst skipProps = {\n animation: true,\n animateOnly: true,\n debug: true,\n componentName: true,\n\n ...(!isWeb && {\n tag: true,\n whiteSpace: true,\n wordWrap: true,\n textOverflow: true,\n textDecorationDistance: true,\n userSelect: true,\n selectable: true,\n cursor: true,\n contain: true,\n pointerEvents: true,\n boxSizing: true,\n boxShadow: true,\n }),\n}\n\ntype TransformNamespaceKey = 'transform' | PsuedoPropKeys | MediaQueryKey\n\nlet conf: TamaguiInternalConfig\n\ntype StyleSplitter = (\n props: { [key: string]: any },\n staticConfig: StaticConfigParsed,\n theme: ThemeObject,\n state: SplitStyleState & {\n keepVariantsAsProps?: boolean\n },\n defaultClassNames?: any\n) => {\n pseudos: PseudoStyles\n medias: Record<MediaKeys, ViewStyle>\n style: ViewStyle\n classNames: ClassNamesObject\n rulesToInsert: [string, string][]\n viewProps: StackProps\n}\n\n// loop props backwards\n// track used keys:\n// const keys = new Set<string>()\n// keep classnames and styles separate:\n// const styles = {}\n// const classNames = {}\n\nexport const getSplitStyles: StyleSplitter = (\n props,\n staticConfig,\n theme,\n state,\n defaultClassNames\n) => {\n conf = conf || getConfig()\n const validStyleProps = staticConfig.isText ? stylePropsText : validStyles\n const viewProps: StackProps = {}\n const pseudos: PseudoStyles = {}\n const medias: Record<MediaKeys, ViewStyle> = {}\n const usedKeys = new Set<string>()\n\n let style: ViewStyle = {}\n let classNames: ClassNamesObject = {}\n // we need to gather these specific to each media query / pseudo\n // value is [hash, val], so [\"-jnjad-asdnjk\", \"scaleX(1) rotate(10deg)\"]\n let transforms: Record<TransformNamespaceKey, [string, string]> = {}\n\n const rulesToInsert: [string, string][] = []\n function addStyle(prop: string, rule: string) {\n rulesToInsert.push([prop, rule])\n updateInsertedCache(prop, rule)\n }\n\n function mergeClassName(key: string, val: string, isMediaOrPseudo = false) {\n // empty classnames passed by compiler sometimes\n if (!val) return\n if (val.startsWith('_transform-')) {\n // const isMediaOrPseudo = key !== 'transform'\n // const isMedia = isMediaOrPseudo && key[11] === '_'\n // const isPsuedo = (isMediaOrPseudo && key[11] === '0') || key.endsWith('Style')\n const namespace: TransformNamespaceKey = isMediaOrPseudo ? key : 'transform'\n\n let transform = insertedTransforms[val]\n if (isClient) {\n if (!transform) {\n // HMR or loaded a new chunk\n updateInserted()\n transform = insertedTransforms[val]\n }\n if (!transform) {\n if (isWeb && val[0] !== '_') {\n // runtime insert\n transform = val\n } else {\n // shouldn't reach\n }\n }\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n // prettier-ignore\n console.log(' \u00BB getSplitStyles mergeClassName transform', { key, val, namespace, transform, insertedTransforms })\n }\n }\n transforms[namespace] = transforms[namespace] || ['', '']\n const identifier = val.replace('_transform', '')\n transforms[namespace][0] += identifier\n // ssr doesn't need to do anything just make the right classname\n if (transform) {\n transforms[namespace][1] += transform\n }\n } else {\n classNames[key] = val\n }\n }\n\n const propKeys = Object.keys(props)\n\n for (let i = propKeys.length - 1; i >= 0; i--) {\n const keyInit = propKeys[i]\n if (usedKeys.has(keyInit)) continue\n if (skipProps[keyInit]) continue\n if (!isWeb && keyInit.startsWith('data-')) continue\n\n const valInit = props[keyInit]\n\n if (keyInit === 'style' || keyInit.startsWith('_style')) {\n if (!valInit) continue\n for (const key in valInit) {\n if (usedKeys.has(key)) continue\n if (valInit && typeof valInit === 'object') {\n // newer react native versions return a full object instead of ID\n for (const skey in valInit) {\n if (usedKeys.has(skey)) continue\n usedKeys.add(skey)\n style[skey] = valInit[skey]\n }\n } else {\n usedKeys.add(key)\n style[key] = valInit\n }\n }\n continue\n }\n\n if (keyInit === 'className') {\n let nonTamaguis = ''\n if (!valInit) {\n continue\n }\n for (const cn of valInit.split(' ')) {\n if (cn[0] === '_') {\n // tamagui, merge it expanded on key, eventually this will go away with better compiler\n const [shorthand, mediaOrPsuedo] = cn.slice(1).split('-')\n const isMedia = mediaOrPsuedo[0] === '_'\n const isPseudo = mediaOrPsuedo[0] === '0'\n const isMediaOrPseudo = isMedia || isPseudo\n let fullKey = conf.shorthands[shorthand]\n if (isMedia) {\n // is media\n let mediaShortKey = mediaOrPsuedo.slice(1)\n mediaShortKey = mediaShortKey.slice(0, mediaShortKey.indexOf('_'))\n fullKey += `-${mediaShortKey}`\n } else if (isPseudo) {\n // is psuedo\n const pseudoShortKey = mediaOrPsuedo.slice(1)\n fullKey += `-${psuedoCNInverse[pseudoShortKey]}`\n }\n usedKeys.add(fullKey)\n mergeClassName(fullKey, cn, isMediaOrPseudo)\n } else {\n nonTamaguis += ' ' + cn\n }\n }\n if (nonTamaguis) {\n mergeClassName(keyInit, nonTamaguis)\n }\n continue\n }\n\n if (validStyleProps[keyInit] && valInit && valInit[0] === '_') {\n usedKeys.add(keyInit)\n mergeClassName(keyInit, valInit)\n continue\n }\n\n if (\n state.keepVariantsAsProps &&\n staticConfig.defaultVariants &&\n keyInit in staticConfig.defaultVariants\n ) {\n viewProps[keyInit] = valInit\n }\n\n let isMedia = keyInit[0] === '$'\n let isPseudo = validPseudoKeys[keyInit]\n\n if (\n !isMedia &&\n !isPseudo &&\n !staticConfig.variants?.[keyInit] &&\n !validStyleProps[keyInit] &&\n !conf.shorthands[keyInit]\n ) {\n usedKeys.add(keyInit)\n viewProps[keyInit] = valInit\n continue\n }\n\n const expanded =\n isMedia || isPseudo\n ? [[keyInit, valInit]]\n : staticConfig.propMapper(keyInit, valInit, theme, props, state)\n\n let isMediaOrPseudo = isMedia || isPseudo\n\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n console.log(' \u00BB getSplitStyles', keyInit, expanded)\n }\n\n if (!expanded) {\n continue\n }\n\n for (const [key, val] of expanded) {\n if (val === undefined) continue\n\n if (key !== 'target' && val && val[0] === '_') {\n usedKeys.add(key)\n mergeClassName(key, val, isMediaOrPseudo)\n continue\n }\n\n isMedia = key[0] === '$'\n isPseudo = validPseudoKeys[key]\n isMediaOrPseudo = isMedia || isPseudo\n\n if (!isMediaOrPseudo) {\n if (usedKeys.has(key)) continue\n }\n\n if (\n (staticConfig.deoptProps && staticConfig.deoptProps.has(key)) ||\n (staticConfig.inlineProps && staticConfig.inlineProps.has(key))\n ) {\n viewProps[key] = val\n }\n\n // pseudo\n if (isPseudo) {\n if (!val) continue\n if (key === 'enterStyle' && state.mounted) {\n // once mounted we can ignore enterStyle\n continue\n }\n pseudos[key] = pseudos[key] || {}\n pseudos[key] = getSubStyle(val, staticConfig, theme, props, state, true)\n if (isWeb && !state.noClassNames) {\n const pseudoStyles = getStylesAtomic({ [key]: pseudos[key] })\n for (const style of pseudoStyles) {\n const fullKey = `${style.property}-${key}`\n if (!usedKeys.has(fullKey)) {\n usedKeys.add(fullKey)\n addStyle(style.identifier, style.rules[0])\n mergeClassName(fullKey, style.identifier, isMediaOrPseudo)\n }\n }\n }\n continue\n }\n\n // media\n if (isMedia) {\n const mediaKey = key\n const mediaKeyShort = mediaKey.slice(1)\n\n if (!mediaQueryConfig[mediaKeyShort]) {\n // this isn't a media key, pass through\n viewProps[key] = val\n continue\n }\n\n // dont check if media is active, we just apply *all* media styles\n // we combine the media props on top regular props, could proxy this\n // TODO test proxy here instead of merge\n // THIS USED TO PROXY BACK TO REGULAR PROPS BUT THAT IS THE WRONG BEHAVIOR\n // we avoid passing in default props for media queries because that would confuse things like SizableText.size:\n const mediaStyle = getSubStyle(val, staticConfig, theme, props, state)\n const shouldDoClasses = isWeb && !state.noClassNames\n\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n // prettier-ignore\n console.log(' \u00BB getSplitStyles mediaStyle', { mediaKey, mediaStyle, props, shouldDoClasses })\n }\n\n if (shouldDoClasses) {\n const mediaStyles = getStylesAtomic(mediaStyle)\n for (const style of mediaStyles) {\n const out = createMediaStyle(style, mediaKeyShort, mediaQueryConfig)\n // TODO handle psuedo + media, not too hard just need to set up example case\n const fullKey = `${style.property}-${mediaKeyShort}`\n if (!usedKeys.has(fullKey)) {\n usedKeys.add(fullKey)\n addStyle(out.identifier, out.styleRule)\n mergeClassName(fullKey, out.identifier, true)\n }\n }\n } else {\n if (mediaState[mediaKey]) {\n if (process.env.NODE_ENV === 'development' && props['debug']) {\n console.log('apply media style', mediaKey, mediaState)\n }\n Object.assign(shouldDoClasses ? medias : style, mediaStyle)\n }\n }\n continue\n }\n\n if (!isWeb && key === 'pointerEvents') {\n usedKeys.add(key)\n viewProps[key] = val\n continue\n }\n\n if (validStyleProps[key]) {\n usedKeys.add(key)\n if (val && val[0] === '_') {\n classNames[key] = val\n } else {\n if (key in stylePropsTransform) {\n if (process.env.NODE_ENV === 'development' && props['debug']) {\n console.log('mergeTransform', key, val)\n }\n mergeTransform(style, key, val, true)\n } else {\n style[key] = val\n }\n }\n\n continue\n }\n\n // pass to view props\n if (!staticConfig.variants || !(key in staticConfig.variants)) {\n if (!skipProps[key]) {\n // push()\n viewProps[key] = val\n usedKeys.add(key)\n }\n }\n }\n }\n\n // add in defaults if not set:\n if (defaultClassNames) {\n classNames = {\n ...defaultClassNames,\n ...classNames,\n }\n }\n\n if (isWeb && !state.noClassNames) {\n const atomic = getStylesAtomic(style)\n for (const atomicStyle of atomic) {\n const key = atomicStyle.property\n if (!state.dynamicStylesInline) {\n addStyle(atomicStyle.identifier, atomicStyle.rules[0])\n mergeClassName(key, atomicStyle.identifier)\n } else {\n style[key] = atomicStyle.value\n }\n }\n }\n\n if (transforms) {\n for (const namespace in transforms) {\n const [hash, val] = transforms[namespace]\n const identifier = `_transform${hash}`\n if (isClient) {\n if (!insertedTransforms[identifier]) {\n const rule = `.${identifier} { transform: ${val}; }`\n addStyle(identifier, rule)\n }\n }\n classNames[namespace] = identifier\n }\n }\n\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n if (typeof document !== 'undefined') {\n // prettier-ignore\n console.log(' \u00BB getSplitStyles out', { style, pseudos, medias, classNames, viewProps, state })\n }\n }\n\n return {\n viewProps,\n style,\n medias,\n pseudos,\n classNames,\n rulesToInsert,\n }\n}\n\nexport const insertSplitStyles: StyleSplitter = (...args) => {\n const res = getSplitStyles(...args)\n for (const [prop, rule] of res.rulesToInsert) {\n insertStyleRule(prop, rule)\n }\n return res\n}\n\nconst effect = isWeb ? useInsertionEffect || useIsomorphicLayoutEffect : useIsomorphicLayoutEffect\n\nexport const useSplitStyles: StyleSplitter = (...args) => {\n const res = getSplitStyles(...args)\n effect(() => {\n for (const [prop, rule] of res.rulesToInsert) {\n insertStyleRule(prop, rule)\n }\n })\n return res\n}\n\nexport const getSubStyle = (\n styleIn: Object,\n staticConfig: StaticConfigParsed,\n theme: ThemeObject,\n props: any,\n state: SplitStyleState,\n avoidDefaultProps?: boolean\n): ViewStyle => {\n const styleOut: ViewStyle = {}\n for (const key in styleIn) {\n const val = styleIn[key]\n const expanded = staticConfig.propMapper(key, val, theme, props, state, avoidDefaultProps)\n if (!expanded) continue\n for (const [skey, sval] of expanded) {\n if (skey in stylePropsTransform) {\n mergeTransform(styleOut, skey, sval)\n } else {\n styleOut[skey] = sval\n }\n }\n }\n return styleOut\n}\n\nexport function normalizeStyleObject(style: any) {\n if (!isWeb) {\n fixNativeShadow(style)\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAkF;AAElF,mBAAmC;AAGnC,kBAA0B;AAC1B,sBAA2D;AAC3D,sBAA6C;AAY7C,8BAAiC;AACjC,6BAAgC;AAChC,6BAAiD;AACjD,6BAKO;AACP,4BAA+B;AAM/B,MAAM,YAAY;AAAA,EAChB,WAAW;AAAA,EACX,aAAa;AAAA,EACb,OAAO;AAAA,EACP,eAAe;AAAA,GAEX,CAAC,yBAAS;AAAA,EACZ,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,cAAc;AAAA,EACd,wBAAwB;AAAA,EACxB,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,
|
|
4
|
+
"sourcesContent": ["import { stylePropsText, stylePropsTransform, validPseudoKeys, validStyles } from '@tamagui/helpers'\n// @ts-ignore\nimport { useInsertionEffect } from 'react'\nimport { ViewStyle } from 'react-native'\n\nimport { getConfig } from '../conf'\nimport { isClient, isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { mediaQueryConfig, mediaState } from '../hooks/useMedia'\nimport {\n MediaKeys,\n MediaQueryKey,\n PseudoStyles,\n PsuedoPropKeys,\n SplitStyleState,\n StackProps,\n StaticConfigParsed,\n TamaguiInternalConfig,\n ThemeObject,\n} from '../types'\nimport { createMediaStyle } from './createMediaStyle'\nimport { fixNativeShadow } from './fixNativeShadow'\nimport { getStylesAtomic, psuedoCNInverse } from './getStylesAtomic'\nimport {\n insertStyleRule,\n insertedTransforms,\n updateInserted,\n updateInsertedCache,\n} from './insertStyleRule'\nimport { mergeTransform } from './mergeTransform'\n\nexport type SplitStyles = ReturnType<typeof getSplitStyles>\nexport type ClassNamesObject = Record<string, string>\nexport type SplitStyleResult = ReturnType<typeof getSplitStyles>\n\nconst skipProps = {\n animation: true,\n animateOnly: true,\n debug: true,\n componentName: true,\n\n ...(!isWeb && {\n tag: true,\n whiteSpace: true,\n wordWrap: true,\n textOverflow: true,\n textDecorationDistance: true,\n userSelect: true,\n selectable: true,\n cursor: true,\n contain: true,\n boxSizing: true,\n boxShadow: true,\n }),\n}\n\ntype TransformNamespaceKey = 'transform' | PsuedoPropKeys | MediaQueryKey\n\nlet conf: TamaguiInternalConfig\n\ntype StyleSplitter = (\n props: { [key: string]: any },\n staticConfig: StaticConfigParsed,\n theme: ThemeObject,\n state: SplitStyleState & {\n keepVariantsAsProps?: boolean\n },\n defaultClassNames?: any\n) => {\n pseudos: PseudoStyles\n medias: Record<MediaKeys, ViewStyle>\n style: ViewStyle\n classNames: ClassNamesObject\n rulesToInsert: [string, string][]\n viewProps: StackProps\n}\n\n// loop props backwards\n// track used keys:\n// const keys = new Set<string>()\n// keep classnames and styles separate:\n// const styles = {}\n// const classNames = {}\n\nexport const getSplitStyles: StyleSplitter = (\n props,\n staticConfig,\n theme,\n state,\n defaultClassNames\n) => {\n conf = conf || getConfig()\n const validStyleProps = staticConfig.isText ? stylePropsText : validStyles\n const viewProps: StackProps = {}\n const pseudos: PseudoStyles = {}\n const medias: Record<MediaKeys, ViewStyle> = {}\n const usedKeys = new Set<string>()\n\n let style: ViewStyle = {}\n let classNames: ClassNamesObject = {}\n // we need to gather these specific to each media query / pseudo\n // value is [hash, val], so [\"-jnjad-asdnjk\", \"scaleX(1) rotate(10deg)\"]\n let transforms: Record<TransformNamespaceKey, [string, string]> = {}\n\n const rulesToInsert: [string, string][] = []\n function addStyle(prop: string, rule: string) {\n rulesToInsert.push([prop, rule])\n updateInsertedCache(prop, rule)\n }\n\n function mergeClassName(key: string, val: string, isMediaOrPseudo = false) {\n // empty classnames passed by compiler sometimes\n if (!val) return\n if (val.startsWith('_transform-')) {\n // const isMediaOrPseudo = key !== 'transform'\n // const isMedia = isMediaOrPseudo && key[11] === '_'\n // const isPsuedo = (isMediaOrPseudo && key[11] === '0') || key.endsWith('Style')\n const namespace: TransformNamespaceKey = isMediaOrPseudo ? key : 'transform'\n\n let transform = insertedTransforms[val]\n if (isClient) {\n if (!transform) {\n // HMR or loaded a new chunk\n updateInserted()\n transform = insertedTransforms[val]\n }\n if (!transform) {\n if (isWeb && val[0] !== '_') {\n // runtime insert\n transform = val\n } else {\n // shouldn't reach\n }\n }\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n // prettier-ignore\n console.log(' \u00BB getSplitStyles mergeClassName transform', { key, val, namespace, transform, insertedTransforms })\n }\n }\n transforms[namespace] = transforms[namespace] || ['', '']\n const identifier = val.replace('_transform', '')\n transforms[namespace][0] += identifier\n // ssr doesn't need to do anything just make the right classname\n if (transform) {\n transforms[namespace][1] += transform\n }\n } else {\n classNames[key] = val\n }\n }\n\n const propKeys = Object.keys(props)\n\n for (let i = propKeys.length - 1; i >= 0; i--) {\n const keyInit = propKeys[i]\n if (usedKeys.has(keyInit)) continue\n if (skipProps[keyInit]) continue\n if (!isWeb && keyInit.startsWith('data-')) continue\n\n const valInit = props[keyInit]\n\n if (keyInit === 'style' || keyInit.startsWith('_style')) {\n if (!valInit) continue\n for (const key in valInit) {\n if (usedKeys.has(key)) continue\n if (valInit && typeof valInit === 'object') {\n // newer react native versions return a full object instead of ID\n for (const skey in valInit) {\n if (usedKeys.has(skey)) continue\n usedKeys.add(skey)\n style[skey] = valInit[skey]\n }\n } else {\n usedKeys.add(key)\n style[key] = valInit\n }\n }\n continue\n }\n\n if (keyInit === 'className') {\n let nonTamaguis = ''\n if (!valInit) {\n continue\n }\n for (const cn of valInit.split(' ')) {\n if (cn[0] === '_') {\n // tamagui, merge it expanded on key, eventually this will go away with better compiler\n const [shorthand, mediaOrPsuedo] = cn.slice(1).split('-')\n const isMedia = mediaOrPsuedo[0] === '_'\n const isPseudo = mediaOrPsuedo[0] === '0'\n const isMediaOrPseudo = isMedia || isPseudo\n let fullKey = conf.shorthands[shorthand]\n if (isMedia) {\n // is media\n let mediaShortKey = mediaOrPsuedo.slice(1)\n mediaShortKey = mediaShortKey.slice(0, mediaShortKey.indexOf('_'))\n fullKey += `-${mediaShortKey}`\n } else if (isPseudo) {\n // is psuedo\n const pseudoShortKey = mediaOrPsuedo.slice(1)\n fullKey += `-${psuedoCNInverse[pseudoShortKey]}`\n }\n usedKeys.add(fullKey)\n mergeClassName(fullKey, cn, isMediaOrPseudo)\n } else {\n nonTamaguis += ' ' + cn\n }\n }\n if (nonTamaguis) {\n mergeClassName(keyInit, nonTamaguis)\n }\n continue\n }\n\n if (validStyleProps[keyInit] && valInit && valInit[0] === '_') {\n usedKeys.add(keyInit)\n mergeClassName(keyInit, valInit)\n continue\n }\n\n if (\n state.keepVariantsAsProps &&\n staticConfig.defaultVariants &&\n keyInit in staticConfig.defaultVariants\n ) {\n viewProps[keyInit] = valInit\n }\n\n let isMedia = keyInit[0] === '$'\n let isPseudo = validPseudoKeys[keyInit]\n\n if (\n !isMedia &&\n !isPseudo &&\n !staticConfig.variants?.[keyInit] &&\n !validStyleProps[keyInit] &&\n !conf.shorthands[keyInit]\n ) {\n usedKeys.add(keyInit)\n viewProps[keyInit] = valInit\n continue\n }\n\n const expanded =\n isMedia || isPseudo\n ? [[keyInit, valInit]]\n : staticConfig.propMapper(keyInit, valInit, theme, props, state)\n\n let isMediaOrPseudo = isMedia || isPseudo\n\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n console.log(' \u00BB getSplitStyles', keyInit, expanded)\n }\n\n if (!expanded) {\n continue\n }\n\n for (const [key, val] of expanded) {\n if (val === undefined) continue\n\n if (key !== 'target' && val && val[0] === '_') {\n usedKeys.add(key)\n mergeClassName(key, val, isMediaOrPseudo)\n continue\n }\n\n isMedia = key[0] === '$'\n isPseudo = validPseudoKeys[key]\n isMediaOrPseudo = isMedia || isPseudo\n\n if (!isMediaOrPseudo) {\n if (usedKeys.has(key)) continue\n }\n\n if (\n (staticConfig.deoptProps && staticConfig.deoptProps.has(key)) ||\n (staticConfig.inlineProps && staticConfig.inlineProps.has(key))\n ) {\n viewProps[key] = val\n }\n\n // pseudo\n if (isPseudo) {\n if (!val) continue\n if (key === 'enterStyle' && state.mounted) {\n // once mounted we can ignore enterStyle\n continue\n }\n pseudos[key] = pseudos[key] || {}\n pseudos[key] = getSubStyle(val, staticConfig, theme, props, state, true)\n if (isWeb && !state.noClassNames) {\n const pseudoStyles = getStylesAtomic({ [key]: pseudos[key] })\n for (const style of pseudoStyles) {\n const fullKey = `${style.property}-${key}`\n if (!usedKeys.has(fullKey)) {\n usedKeys.add(fullKey)\n addStyle(style.identifier, style.rules[0])\n mergeClassName(fullKey, style.identifier, isMediaOrPseudo)\n }\n }\n }\n continue\n }\n\n // media\n if (isMedia) {\n const mediaKey = key\n const mediaKeyShort = mediaKey.slice(1)\n\n if (!mediaQueryConfig[mediaKeyShort]) {\n // this isn't a media key, pass through\n viewProps[key] = val\n continue\n }\n\n // dont check if media is active, we just apply *all* media styles\n // we combine the media props on top regular props, could proxy this\n // TODO test proxy here instead of merge\n // THIS USED TO PROXY BACK TO REGULAR PROPS BUT THAT IS THE WRONG BEHAVIOR\n // we avoid passing in default props for media queries because that would confuse things like SizableText.size:\n const mediaStyle = getSubStyle(val, staticConfig, theme, props, state)\n const shouldDoClasses = isWeb && !state.noClassNames\n\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n // prettier-ignore\n console.log(' \u00BB getSplitStyles mediaStyle', { mediaKey, mediaStyle, props, shouldDoClasses })\n }\n\n if (shouldDoClasses) {\n const mediaStyles = getStylesAtomic(mediaStyle)\n for (const style of mediaStyles) {\n const out = createMediaStyle(style, mediaKeyShort, mediaQueryConfig)\n // TODO handle psuedo + media, not too hard just need to set up example case\n const fullKey = `${style.property}-${mediaKeyShort}`\n if (!usedKeys.has(fullKey)) {\n usedKeys.add(fullKey)\n addStyle(out.identifier, out.styleRule)\n mergeClassName(fullKey, out.identifier, true)\n }\n }\n } else {\n if (mediaState[mediaKey]) {\n if (process.env.NODE_ENV === 'development' && props['debug']) {\n console.log('apply media style', mediaKey, mediaState)\n }\n Object.assign(shouldDoClasses ? medias : style, mediaStyle)\n }\n }\n continue\n }\n\n if (!isWeb && key === 'pointerEvents') {\n usedKeys.add(key)\n viewProps[key] = val\n continue\n }\n\n if (validStyleProps[key]) {\n usedKeys.add(key)\n if (val && val[0] === '_') {\n classNames[key] = val\n } else {\n if (key in stylePropsTransform) {\n if (process.env.NODE_ENV === 'development' && props['debug']) {\n console.log('mergeTransform', key, val)\n }\n mergeTransform(style, key, val, true)\n } else {\n style[key] = val\n }\n }\n\n continue\n }\n\n // pass to view props\n if (!staticConfig.variants || !(key in staticConfig.variants)) {\n if (!skipProps[key]) {\n // push()\n viewProps[key] = val\n usedKeys.add(key)\n }\n }\n }\n }\n\n // add in defaults if not set:\n if (defaultClassNames) {\n classNames = {\n ...defaultClassNames,\n ...classNames,\n }\n }\n\n if (isWeb && !state.noClassNames) {\n const atomic = getStylesAtomic(style)\n for (const atomicStyle of atomic) {\n const key = atomicStyle.property\n if (!state.dynamicStylesInline) {\n addStyle(atomicStyle.identifier, atomicStyle.rules[0])\n mergeClassName(key, atomicStyle.identifier)\n } else {\n style[key] = atomicStyle.value\n }\n }\n }\n\n if (transforms) {\n for (const namespace in transforms) {\n const [hash, val] = transforms[namespace]\n const identifier = `_transform${hash}`\n if (isClient) {\n if (!insertedTransforms[identifier]) {\n const rule = `.${identifier} { transform: ${val}; }`\n addStyle(identifier, rule)\n }\n }\n classNames[namespace] = identifier\n }\n }\n\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n if (typeof document !== 'undefined') {\n // prettier-ignore\n console.log(' \u00BB getSplitStyles out', { style, pseudos, medias, classNames, viewProps, state })\n }\n }\n\n return {\n viewProps,\n style,\n medias,\n pseudos,\n classNames,\n rulesToInsert,\n }\n}\n\nexport const insertSplitStyles: StyleSplitter = (...args) => {\n const res = getSplitStyles(...args)\n for (const [prop, rule] of res.rulesToInsert) {\n insertStyleRule(prop, rule)\n }\n return res\n}\n\nconst effect = isWeb ? useInsertionEffect || useIsomorphicLayoutEffect : useIsomorphicLayoutEffect\n\nexport const useSplitStyles: StyleSplitter = (...args) => {\n const res = getSplitStyles(...args)\n effect(() => {\n for (const [prop, rule] of res.rulesToInsert) {\n insertStyleRule(prop, rule)\n }\n })\n return res\n}\n\nexport const getSubStyle = (\n styleIn: Object,\n staticConfig: StaticConfigParsed,\n theme: ThemeObject,\n props: any,\n state: SplitStyleState,\n avoidDefaultProps?: boolean\n): ViewStyle => {\n const styleOut: ViewStyle = {}\n for (const key in styleIn) {\n const val = styleIn[key]\n const expanded = staticConfig.propMapper(key, val, theme, props, state, avoidDefaultProps)\n if (!expanded) continue\n for (const [skey, sval] of expanded) {\n if (skey in stylePropsTransform) {\n mergeTransform(styleOut, skey, sval)\n } else {\n styleOut[skey] = sval\n }\n }\n }\n return styleOut\n}\n\nexport function normalizeStyleObject(style: any) {\n if (!isWeb) {\n fixNativeShadow(style)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAkF;AAElF,mBAAmC;AAGnC,kBAA0B;AAC1B,sBAA2D;AAC3D,sBAA6C;AAY7C,8BAAiC;AACjC,6BAAgC;AAChC,6BAAiD;AACjD,6BAKO;AACP,4BAA+B;AAM/B,MAAM,YAAY;AAAA,EAChB,WAAW;AAAA,EACX,aAAa;AAAA,EACb,OAAO;AAAA,EACP,eAAe;AAAA,GAEX,CAAC,yBAAS;AAAA,EACZ,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,cAAc;AAAA,EACd,wBAAwB;AAAA,EACxB,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,WAAW;AAAA,EACX,WAAW;AACb;AAKF,IAAI;AA0BG,MAAM,iBAAgC,wBAC3C,OACA,cACA,OACA,OACA,sBACG;AAzFL;AA0FE,SAAO,QAAQ,2BAAU;AACzB,QAAM,kBAAkB,aAAa,SAAS,gCAAiB;AAC/D,QAAM,YAAwB,CAAC;AAC/B,QAAM,UAAwB,CAAC;AAC/B,QAAM,SAAuC,CAAC;AAC9C,QAAM,WAAW,oBAAI,IAAY;AAEjC,MAAI,QAAmB,CAAC;AACxB,MAAI,aAA+B,CAAC;AAGpC,MAAI,aAA8D,CAAC;AAEnE,QAAM,gBAAoC,CAAC;AAC3C,oBAAkB,MAAc,MAAc;AAC5C,kBAAc,KAAK,CAAC,MAAM,IAAI,CAAC;AAC/B,oDAA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uBAAO;AACV,gDAAgB,KAAK;AAAA,EACvB;AACF;AAJgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var isTamaguiComponent_exports = {};
|
|
20
|
+
__export(isTamaguiComponent_exports, {
|
|
21
|
+
isTamaguiComponent: () => isTamaguiComponent
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(isTamaguiComponent_exports);
|
|
24
|
+
function isTamaguiComponent(comp, name) {
|
|
25
|
+
const config = comp && comp["staticConfig"];
|
|
26
|
+
if (!config || !config.parsed)
|
|
27
|
+
return false;
|
|
28
|
+
if (name) {
|
|
29
|
+
return name === config.componentName;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
__name(isTamaguiComponent, "isTamaguiComponent");
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
isTamaguiComponent
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=isTamaguiComponent.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/helpers/isTamaguiComponent.tsx"],
|
|
4
|
+
"sourcesContent": ["import { StaticConfig, StaticConfigParsed } from '../types'\n\nexport function isTamaguiComponent<A extends any>(\n comp: A,\n name?: string\n): comp is A & {\n staticConfig: StaticConfig\n} {\n const config = comp && (comp['staticConfig'] as StaticConfigParsed | undefined)\n if (!config || !config.parsed) return false\n if (name) {\n return name === config.componentName\n }\n return true\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,4BACL,MACA,MAGA;AACA,QAAM,SAAS,QAAS,KAAK;AAC7B,MAAI,CAAC,UAAU,CAAC,OAAO;AAAQ,WAAO;AACtC,MAAI,MAAM;AACR,WAAO,SAAS,OAAO;AAAA,EACzB;AACA,SAAO;AACT;AAZgB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -22,15 +22,9 @@ __export(isTamaguiElement_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(isTamaguiElement_exports);
|
|
24
24
|
var import_react = require("react");
|
|
25
|
+
var import_isTamaguiComponent = require("./isTamaguiComponent");
|
|
25
26
|
const isTamaguiElement = /* @__PURE__ */ __name((child, name) => {
|
|
26
|
-
|
|
27
|
-
const isTamagui = (0, import_react.isValidElement)(child) && !!((_a = child.type["staticConfig"]) == null ? void 0 : _a.parsed);
|
|
28
|
-
if (!isTamagui)
|
|
29
|
-
return false;
|
|
30
|
-
if (name) {
|
|
31
|
-
return name === child.type["staticConfig"].componentName;
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
27
|
+
return (0, import_react.isValidElement)(child) && (0, import_isTamaguiComponent.isTamaguiComponent)(child.type, name);
|
|
34
28
|
}, "isTamaguiElement");
|
|
35
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
30
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/isTamaguiElement.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { isValidElement } from 'react'\n\nexport const isTamaguiElement = (child: any, name?: string): child is React.ReactElement => {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsC;
|
|
4
|
+
"sourcesContent": ["import React, { isValidElement } from 'react'\n\nimport { isTamaguiComponent } from './isTamaguiComponent'\n\nexport const isTamaguiElement = (child: any, name?: string): child is React.ReactElement => {\n return isValidElement(child) && isTamaguiComponent(child.type, name)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsC;AAEtC,gCAAmC;AAE5B,MAAM,mBAAmB,wBAAC,OAAY,SAA+C;AAC1F,SAAO,iCAAe,KAAK,KAAK,kDAAmB,MAAM,MAAM,IAAI;AACrE,GAFgC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -170,7 +170,7 @@ const useChangeThemeEffect = /* @__PURE__ */ __name((name, componentName, props,
|
|
|
170
170
|
return null;
|
|
171
171
|
return new import_ThemeManager.ThemeManager(next.name, next.theme, parentManager, reset);
|
|
172
172
|
});
|
|
173
|
-
if (typeof document !== "undefined") {
|
|
173
|
+
if (!import_platform.isWeb || typeof document !== "undefined") {
|
|
174
174
|
(0, import_react.useLayoutEffect)(() => {
|
|
175
175
|
if (!themeManager)
|
|
176
176
|
return;
|
|
@@ -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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA+B;AAC/B,mBAA8E;AAE9E,kBAA0B;AAC1B,
|
|
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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA+B;AAC/B,mBAA8E;AAE9E,kBAA0B;AAC1B,sBAAiD;AACjD,0BAA6B;AAC7B,0BAA6B;AAC7B,0BAAmF;AAEnF,yBAA4B;AAkBrB,MAAM,WAAW,wBACtB,WACA,eACA,OACA,gBACgB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S,cAAc;AAE5E,SAAO,gDACD,iBAAiB;AAAA,IACnB,MAAM,cAAc;AAAA,IACpB,OAAO,cAAc;AAAA,EACvB,IACG,OALE;AAAA,IAML;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF,GA9CoC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -55,6 +55,7 @@ __reExport(src_exports, require("./helpers/getStylesAtomic"), module.exports);
|
|
|
55
55
|
__reExport(src_exports, require("./helpers/getTextSize"), module.exports);
|
|
56
56
|
__reExport(src_exports, require("./helpers/isObj"), module.exports);
|
|
57
57
|
__reExport(src_exports, require("./helpers/isTamaguiElement"), module.exports);
|
|
58
|
+
__reExport(src_exports, require("./helpers/isTamaguiComponent"), module.exports);
|
|
58
59
|
__reExport(src_exports, require("./helpers/matchMedia"), module.exports);
|
|
59
60
|
__reExport(src_exports, require("./helpers/themeable"), module.exports);
|
|
60
61
|
__reExport(src_exports, require("./helpers/withStaticProperties"), module.exports);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './insertFont'\nexport * from './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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,sBAAd;AACA,wBAAc,8BADd;AAEA,wBAAc,+BAFd;AAGA,wBAAc,0BAHd;AAIA,wBAAc,4BAJd;AAKA,wBAAc,yBALd;AAMA,wBAAc,2BANd;AAOA,wBAAc,6BAPd;AAQA,wBAAc,8BARd;AASA,wBAAc,yBATd;AAUA,wBAAc,qBAVd;AAWA,wBAAc,oBAXd;AAaA,uBAA2C;AAC3C,kBAAoF;AAEpF,wBAAc,kCAhBd;AAiBA,wBAAc,iCAjBd;AAkBA,wBAAc,4BAlBd;AAoBA,wBAAc,2BApBd;AAqBA,wBAAc,0CArBd;AAsBA,wBAAc,mCAtBd;AAuBA,wBAAc,uCAvBd;AAwBA,wBAAc,4CAxBd;AAyBA,wBAAc,8BAzBd;AA0BA,wBAAc,qCA1Bd;AA2BA,wBAAc,sCA3Bd;AA4BA,wBAAc,kCA5Bd;AA6BA,wBAAc,4BA7Bd;AA8BA,wBAAc,uCA9Bd;AA+BA,wBAAc,
|
|
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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,sBAAd;AACA,wBAAc,8BADd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overrideProps[propName];
|
|
105
105
|
}
|
|
106
|
-
const isHandler =
|
|
106
|
+
const isHandler = handleRegex.test(propName);
|
|
107
107
|
if (isHandler) {
|
|
108
108
|
overrideProps[propName] = mergeEvent(childPropValue, slotPropValue);
|
|
109
109
|
} else if (propName === "style") {
|
|
@@ -115,6 +115,7 @@ function mergeProps(child, slotProps) {
|
|
|
115
115
|
return __spreadValues(__spreadValues({}, slotProps), overrideProps);
|
|
116
116
|
}
|
|
117
117
|
__name(mergeProps, "mergeProps");
|
|
118
|
+
const handleRegex = /^on[A-Z]/;
|
|
118
119
|
function mergeEvent(a, b) {
|
|
119
120
|
return (...args) => {
|
|
120
121
|
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 =
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAA4B;AAC5B,YAAuB;AAEvB,sBAAsB;AAUf,MAAM,OAAO,MAAM,WAAmC,CAAC,OAAO,iBAAiB;AACpF,QAAmC,YAA3B,eAA2B,IAAd,sBAAc,IAAd,CAAb;AACR,SACE,oCAAC,4CAAc,YAAd;AAAA,IAAyB,KAAK;AAAA,MAC5B,QACH;AAEJ,CAAC;AAED,KAAK,cAAc;AAUnB,MAAM,YAAY,MAAM,WAAgC,CAAC,OAAO,iBAAiB;AAC/E,QAAmC,YAA3B,eAA2B,IAAd,sBAAc,IAAd,CAAb;AAER,MAAI,MAAM,eAAe,QAAQ,GAAG;AAClC,UAAM,aAAa,iCACd,WAAW,UAAU,SAAS,IADhB;AAAA,MAEjB,KAAK,qCAAY,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,wBACb;AAAA,EACE,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,WAAW;AACb,IACA,CAAC;AAEL,oBAAoB,OAAY,WAAqB;AACnD,QAAM,aAAa,MAAM;AAGzB,QAAM,gBAAgB,mBAAK;AAC3B,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,
|
|
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]/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