@tamagui/core 1.0.0-beta.12 → 1.0.0-beta.13
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/createComponent.js +55 -33
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +22 -3
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/views/Slot.js +22 -3
- package/dist/cjs/views/Slot.js.map +2 -2
- package/dist/cjs/views/Text.js +9 -14
- package/dist/cjs/views/Text.js.map +2 -2
- package/dist/cjs/views/ThemeInverse.js +5 -1
- package/dist/cjs/views/ThemeInverse.js.map +2 -2
- package/dist/esm/createComponent.js +56 -36
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +22 -2
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/views/Slot.js +22 -3
- package/dist/esm/views/Slot.js.map +2 -2
- package/dist/esm/views/Text.js +9 -14
- package/dist/esm/views/Text.js.map +2 -2
- package/dist/esm/views/ThemeInverse.js +6 -2
- package/dist/esm/views/ThemeInverse.js.map +2 -2
- package/dist/jsx/createComponent.js +51 -36
- package/dist/jsx/helpers/getSplitStyles.js +22 -2
- package/dist/jsx/views/Slot.js +22 -3
- package/dist/jsx/views/Text.js +9 -14
- package/dist/jsx/views/ThemeInverse.js +6 -1
- package/package.json +5 -5
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/views/Text.d.ts.map +1 -1
- package/types/views/ThemeInverse.d.ts.map +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/getSplitStyles.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n mergeTransform,\n stylePropsText,\n stylePropsTransform,\n validPseudoKeys,\n validStyles,\n} 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 { ViewStyleWithPseudos, getStylesAtomic } from './getStylesAtomic'\nimport {\n insertStyleRule,\n insertedTransforms,\n updateInserted,\n updateInsertedCache,\n} from './insertStyleRule'\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}\n\ntype TransformNamespaceKey = 'transform' | PsuedoPropKeys | MediaQueryKey\n\n// TODO can make a few of these objects lazy if profiling seems slow\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\nexport const getSplitStyles: StyleSplitter = (\n props,\n staticConfig,\n theme,\n state,\n defaultClassNames\n) => {\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n console.log(' \u00BB getSplitStyles', { props, state, defaultClassNames })\n }\n\n conf = conf || getConfig()\n const validStyleProps = staticConfig.isText ? stylePropsText : validStyles\n const viewProps: StackProps = {}\n const style: ViewStyle = {}\n const classNames: ClassNamesObject = {\n ...defaultClassNames,\n }\n const pseudos: PseudoStyles = {}\n const medias: Record<MediaKeys, ViewStyle> = {}\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 let cur: ViewStyleWithPseudos | null = null\n\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 function mergeClassName(key: string, val: string) {\n if (!val) {\n // empty classnames passed by compiler sometimes\n return\n }\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 = isMedia\n ? key.split('_')[2]\n : isPsuedo\n ? key.split('-')[1]\n : '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 // error\n console.trace('?', key, val, cur, props, state)\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 if (process.env.NODE_ENV === 'development') {\n if (!transform) {\n console.trace('NO TRANSFORM?', { key, val, transform })\n }\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 function push() {\n if (!cur) return\n normalizeStyleObject(cur)\n\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n console.log(' \u00BB getSplitStyles push', cur, state)\n }\n\n if (isWeb && !state.noClassNames) {\n const atomic = getStylesAtomic(cur)\n for (const atomicStyle of atomic) {\n if (!state.noClassNames) {\n addStyle(atomicStyle.identifier, atomicStyle.rules[0])\n mergeClassName(atomicStyle.property, atomicStyle.identifier)\n } else {\n style[atomicStyle.property] = atomicStyle.value\n }\n }\n }\n\n if (\n !isWeb ||\n state.noClassNames ||\n state.resolveVariablesAs === 'value' ||\n state.resolveVariablesAs === 'both'\n ) {\n for (const key in cur) {\n if (key in stylePropsTransform) {\n mergeTransform(style, key, cur[key])\n } else {\n style[key] = cur[key]\n }\n }\n }\n\n // reset it for next group of styles\n cur = null\n }\n\n for (const keyInit in props) {\n if (skipProps[keyInit]) {\n continue\n }\n\n const valInit = props[keyInit]\n\n // TODO\n if (keyInit === 'style' || keyInit.startsWith('_style')) {\n push()\n cur = valInit\n push()\n continue\n }\n\n if (keyInit === 'className' || (validStyleProps[keyInit] && valInit && valInit[0] === '_')) {\n push()\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 viewProps[keyInit] = valInit\n continue\n }\n\n const out =\n isMedia || isPseudo\n ? true\n : staticConfig.propMapper(\n keyInit,\n valInit,\n theme,\n state.fallbackProps || props,\n state.resolveVariablesAs\n )\n\n const expanded = out === true || !out ? [[keyInit, valInit]] : Object.entries(out)\n\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n console.log(' \u00BB getSplitStyles', keyInit, expanded)\n }\n\n for (const [key, val] of expanded) {\n if (val === undefined) {\n continue\n }\n\n if (key !== 'target' && val && val[0] === '_') {\n mergeClassName(key, val)\n continue\n }\n\n isMedia = key[0] === '$'\n isPseudo = validPseudoKeys[key]\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 addStyle(style.identifier, style.rules[0])\n mergeClassName(`${style.property}-${key}`, style.identifier)\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\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n console.log(' \u00BB getSplitStyles mediaStyle', mediaKey, mediaStyle, props)\n }\n\n const shouldDoClasses = isWeb && !state.noClassNames\n if (shouldDoClasses) {\n const mediaStyles = getStylesAtomic(mediaStyle)\n for (const style of mediaStyles) {\n const out = createMediaStyle(style, mediaKeyShort, mediaQueryConfig)\n addStyle(out.identifier, out.styleRule)\n mergeClassName(`${out.identifier}-${mediaKey}`, out.identifier)\n }\n } else {\n if (mediaState[mediaKey]) {\n push()\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 viewProps[key] = val\n continue\n }\n\n if (validStyleProps[key]) {\n cur = cur || {}\n cur[key] = val\n continue\n }\n\n // pass to view props\n if (!staticConfig.variants || !(key in staticConfig.variants)) {\n if (key !== 'animation' && key !== 'debug') {\n push()\n viewProps[key] = val\n }\n }\n }\n }\n\n push()\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 console.log(' \u00BB getSplitStyles out', { style, pseudos, medias, classNames, viewProps, state })\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 = useInsertionEffect || useIsomorphicLayoutEffect\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 out = staticConfig.propMapper(\n key,\n val,\n theme,\n state.fallbackProps || props,\n state.resolveVariablesAs,\n avoidDefaultProps\n )\n const expanded = out === true || !out ? [[key, val]] : Object.entries(out)\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 normalizeStyleObject(styleOut)\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;AAQA;AAGA;AACA;AACA;AAYA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,MAAM,YAAY;AAAA,EAChB,WAAW;AAAA,EACX,aAAa;AAAA,EACb,OAAO;
|
|
4
|
+
"sourcesContent": ["import {\n mergeTransform,\n stylePropsText,\n stylePropsTransform,\n validPseudoKeys,\n validStyles,\n} 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 { ViewStyleWithPseudos, getStylesAtomic } from './getStylesAtomic'\nimport {\n insertStyleRule,\n insertedTransforms,\n updateInserted,\n updateInsertedCache,\n} from './insertStyleRule'\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\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\n// TODO can make a few of these objects lazy if profiling seems slow\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\nexport const getSplitStyles: StyleSplitter = (\n props,\n staticConfig,\n theme,\n state,\n defaultClassNames\n) => {\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n console.log(' \u00BB getSplitStyles', { props, state, defaultClassNames })\n }\n\n conf = conf || getConfig()\n const validStyleProps = staticConfig.isText ? stylePropsText : validStyles\n const viewProps: StackProps = {}\n const style: ViewStyle = {}\n const classNames: ClassNamesObject = {\n ...defaultClassNames,\n }\n const pseudos: PseudoStyles = {}\n const medias: Record<MediaKeys, ViewStyle> = {}\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 let cur: ViewStyleWithPseudos | null = null\n\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 function mergeClassName(key: string, val: string) {\n if (!val) {\n // empty classnames passed by compiler sometimes\n return\n }\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 = isMedia\n ? key.split('_')[2]\n : isPsuedo\n ? key.split('-')[1]\n : '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 // error\n console.trace('?', key, val, cur, props, state)\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 if (process.env.NODE_ENV === 'development') {\n if (!transform) {\n console.trace('NO TRANSFORM?', { key, val, transform })\n }\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 function push() {\n if (!cur) return\n normalizeStyleObject(cur)\n\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n console.log(' \u00BB getSplitStyles push', cur, state)\n }\n\n if (isWeb && !state.noClassNames) {\n const atomic = getStylesAtomic(cur)\n for (const atomicStyle of atomic) {\n if (!state.noClassNames) {\n addStyle(atomicStyle.identifier, atomicStyle.rules[0])\n mergeClassName(atomicStyle.property, atomicStyle.identifier)\n } else {\n style[atomicStyle.property] = atomicStyle.value\n }\n }\n }\n\n if (\n !isWeb ||\n state.noClassNames ||\n state.resolveVariablesAs === 'value' ||\n state.resolveVariablesAs === 'both'\n ) {\n for (const key in cur) {\n if (skipProps[key]) {\n continue\n }\n if (key in stylePropsTransform) {\n mergeTransform(style, key, cur[key])\n } else {\n style[key] = cur[key]\n }\n }\n }\n\n // reset it for next group of styles\n cur = null\n }\n\n for (const keyInit in props) {\n if (skipProps[keyInit]) {\n continue\n }\n if (!isWeb && keyInit.startsWith('data-')) {\n continue\n }\n\n const valInit = props[keyInit]\n\n // TODO\n if (keyInit === 'style' || keyInit.startsWith('_style')) {\n push()\n cur = valInit\n push()\n continue\n }\n\n if (keyInit === 'className' || (validStyleProps[keyInit] && valInit && valInit[0] === '_')) {\n push()\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 viewProps[keyInit] = valInit\n continue\n }\n\n const out =\n isMedia || isPseudo\n ? true\n : staticConfig.propMapper(\n keyInit,\n valInit,\n theme,\n state.fallbackProps || props,\n state.resolveVariablesAs\n )\n\n const expanded = out === true || !out ? [[keyInit, valInit]] : Object.entries(out)\n\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n console.log(' \u00BB getSplitStyles', keyInit, expanded)\n }\n\n for (const [key, val] of expanded) {\n if (val === undefined) {\n continue\n }\n\n if (key !== 'target' && val && val[0] === '_') {\n mergeClassName(key, val)\n continue\n }\n\n isMedia = key[0] === '$'\n isPseudo = validPseudoKeys[key]\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 addStyle(style.identifier, style.rules[0])\n mergeClassName(`${style.property}-${key}`, style.identifier)\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\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n console.log(' \u00BB getSplitStyles mediaStyle', mediaKey, mediaStyle, props)\n }\n\n const shouldDoClasses = isWeb && !state.noClassNames\n if (shouldDoClasses) {\n const mediaStyles = getStylesAtomic(mediaStyle)\n for (const style of mediaStyles) {\n const out = createMediaStyle(style, mediaKeyShort, mediaQueryConfig)\n addStyle(out.identifier, out.styleRule)\n mergeClassName(`${out.identifier}-${mediaKey}`, out.identifier)\n }\n } else {\n if (mediaState[mediaKey]) {\n push()\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 viewProps[key] = val\n continue\n }\n\n if (validStyleProps[key]) {\n cur = cur || {}\n cur[key] = val\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 }\n }\n }\n }\n\n push()\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 console.log(' \u00BB getSplitStyles out', { style, pseudos, medias, classNames, viewProps, state })\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 = useInsertionEffect || useIsomorphicLayoutEffect\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 out = staticConfig.propMapper(\n key,\n val,\n theme,\n state.fallbackProps || props,\n state.resolveVariablesAs,\n avoidDefaultProps\n )\n const expanded = out === true || !out ? [[key, val]] : Object.entries(out)\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 normalizeStyleObject(styleOut)\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;AAQA;AAGA;AACA;AACA;AAYA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,MAAM,YAAY;AAAA,EAChB,WAAW;AAAA,EACX,aAAa;AAAA,EACb,OAAO;AAAA,KAEH,CAAC,SAAS;AAAA,IACZ,KAAK;AAAA,IACL,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,cAAc;AAAA,IACd,wBAAwB;AAAA,IACxB,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,eAAe;AAAA,IACf,WAAW;AAAA,IACX,WAAW;AAAA,EACb;AACF;AAMA,IAAI;AAmBG,MAAM,iBAAgC,wBAC3C,OACA,cACA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AAgC,2BAAI,SAAS;AACxD,QAAM,MAAM,eAAe,GAAG,IAAI;AAClC,SAAO,MAAM;AACX,eAAW,CAAC,MAAM,SAAS,IAAI,eAAe;AAC5C,sBAAgB,MAAM,IAAI;AAAA,IAC5B;AAAA,EACF,CAAC;AACD,SAAO;AACT,GAR6C;AAUtC,MAAM,cAAc,wBACzB,SACA,cACA,OACA,OACA,OACA,sBACc;AACd,QAAM,WAAsB,CAAC;AAC7B,aAAW,OAAO,SAAS;AACzB,UAAM,MAAM,QAAQ;AACpB,UAAM,MAAM,aAAa,WACvB,KACA,KACA,OACA,MAAM,iBAAiB,OACvB,MAAM,oBACN,iBACF;AACA,UAAM,WAAW,QAAQ,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,GAAG,CAAC,IAAI,OAAO,QAAQ,GAAG;AACzE,eAAW,CAAC,MAAM,SAAS,UAAU;AACnC,UAAI,QAAQ,qBAAqB;AAC/B,uBAAe,UAAU,MAAM,IAAI;AAAA,MACrC,OAAO;AACL,iBAAS,QAAQ;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AACA,uBAAqB,QAAQ;AAC7B,SAAO;AACT,GA9B2B;AAgCpB,8BAA8B,OAAY;AAC/C,MAAI,CAAC,OAAO;AACV,oBAAgB,KAAK;AAAA,EACvB;AACF;AAJgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/views/Slot.js
CHANGED
|
@@ -22,7 +22,7 @@ const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
|
22
22
|
const { children, ...slotProps } = props;
|
|
23
23
|
if (React.isValidElement(children)) {
|
|
24
24
|
return React.cloneElement(children, {
|
|
25
|
-
...mergeProps(
|
|
25
|
+
...mergeProps(children, slotProps),
|
|
26
26
|
ref: composeRefs(forwardedRef, children.ref)
|
|
27
27
|
});
|
|
28
28
|
}
|
|
@@ -36,11 +36,30 @@ function isSlottable(child) {
|
|
|
36
36
|
return React.isValidElement(child);
|
|
37
37
|
}
|
|
38
38
|
__name(isSlottable, "isSlottable");
|
|
39
|
-
|
|
39
|
+
const pressMap = {
|
|
40
|
+
onPress: "onClick",
|
|
41
|
+
onPressOut: "onMouseOut",
|
|
42
|
+
onPressIn: "onMouseIn"
|
|
43
|
+
};
|
|
44
|
+
function mergeProps(child, slotProps) {
|
|
45
|
+
const childProps = child.props;
|
|
40
46
|
const overrideProps = { ...childProps };
|
|
41
|
-
|
|
47
|
+
const isHTMLChild = typeof child.type === "string";
|
|
48
|
+
if (isHTMLChild) {
|
|
49
|
+
for (const key in pressMap) {
|
|
50
|
+
if (key in slotProps) {
|
|
51
|
+
slotProps[pressMap[key]] = slotProps[key];
|
|
52
|
+
delete slotProps[key];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
for (let propName in childProps) {
|
|
42
57
|
const slotPropValue = slotProps[propName];
|
|
43
58
|
const childPropValue = childProps[propName];
|
|
59
|
+
if (isHTMLChild && pressMap[propName]) {
|
|
60
|
+
propName = pressMap[propName];
|
|
61
|
+
delete overrideProps[propName];
|
|
62
|
+
}
|
|
44
63
|
const isHandler = /^on[A-Z]/.test(propName);
|
|
45
64
|
if (isHandler) {
|
|
46
65
|
overrideProps[propName] = (...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\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\n if (React.Children.toArray(children).some(isSlottable)) {\n return (\n <>\n {React.Children.map(children, (child) => {\n return isSlottable(child) ? (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {child.props.children}\n </SlotClone>\n ) : (\n child\n )\n })}\n </>\n )\n }\n\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 return React.cloneElement(children, {\n ...mergeProps(
|
|
5
|
-
"mappings": ";;AAEA;AACA;AAUO,MAAM,OAAO,MAAM,WAAmC,CAAC,OAAO,iBAAiB;AACpF,QAAM,EAAE,aAAa,cAAc;AAEnC,MAAI,MAAM,SAAS,QAAQ,QAAQ,EAAE,KAAK,WAAW,GAAG;AACtD,WACE,0DACG,MAAM,SAAS,IAAI,UAAU,CAAC,UAAU;AACvC,aAAO,YAAY,KAAK,IACtB,oCAAC;AAAA,WAAc;AAAA,QAAW,KAAK;AAAA,SAC5B,MAAM,MAAM,QACf,IAEA;AAAA,IAEJ,CAAC,CACH;AAAA,EAEJ;AAEA,SACE,oCAAC;AAAA,OAAc;AAAA,IAAW,KAAK;AAAA,KAC5B,QACH;AAEJ,CAAC;AAED,KAAK,cAAc;AAUnB,MAAM,YAAY,MAAM,WAAgC,CAAC,OAAO,iBAAiB;AAC/E,QAAM,EAAE,aAAa,cAAc;AAEnC,MAAI,MAAM,eAAe,QAAQ,GAAG;AAClC,WAAO,MAAM,aAAa,UAAU;AAAA,SAC/B,WAAW,
|
|
4
|
+
"sourcesContent": ["// via radix\n\nimport { composeRefs } from '@tamagui/compose-refs'\nimport * as React from 'react'\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\n if (React.Children.toArray(children).some(isSlottable)) {\n return (\n <>\n {React.Children.map(children, (child) => {\n return isSlottable(child) ? (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {child.props.children}\n </SlotClone>\n ) : (\n child\n )\n })}\n </>\n )\n }\n\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 return React.cloneElement(children, {\n ...mergeProps(children, slotProps),\n ref: composeRefs(forwardedRef, (children as any).ref),\n })\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\nfunction isSlottable(child: React.ReactNode): child is React.ReactElement {\n return React.isValidElement(child)\n}\n\nconst pressMap = {\n onPress: 'onClick',\n onPressOut: 'onMouseOut',\n onPressIn: 'onMouseIn',\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\n const isHTMLChild = typeof child.type === 'string'\n\n if (isHTMLChild) {\n for (const key in pressMap) {\n if (key in slotProps) {\n slotProps[pressMap[key]] = slotProps[key]\n delete slotProps[key]\n }\n }\n }\n\n for (let propName in childProps) {\n const slotPropValue = slotProps[propName]\n const childPropValue = childProps[propName]\n\n if (isHTMLChild && pressMap[propName]) {\n propName = pressMap[propName]\n delete overrideProps[propName]\n }\n\n const isHandler = /^on[A-Z]/.test(propName)\n // if it's a handler, modify the override by composing the base handler\n if (isHandler) {\n overrideProps[propName] = (...args: unknown[]) => {\n childPropValue?.(...args)\n slotPropValue?.(...args)\n }\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"],
|
|
5
|
+
"mappings": ";;AAEA;AACA;AAUO,MAAM,OAAO,MAAM,WAAmC,CAAC,OAAO,iBAAiB;AACpF,QAAM,EAAE,aAAa,cAAc;AAEnC,MAAI,MAAM,SAAS,QAAQ,QAAQ,EAAE,KAAK,WAAW,GAAG;AACtD,WACE,0DACG,MAAM,SAAS,IAAI,UAAU,CAAC,UAAU;AACvC,aAAO,YAAY,KAAK,IACtB,oCAAC;AAAA,WAAc;AAAA,QAAW,KAAK;AAAA,SAC5B,MAAM,MAAM,QACf,IAEA;AAAA,IAEJ,CAAC,CACH;AAAA,EAEJ;AAEA,SACE,oCAAC;AAAA,OAAc;AAAA,IAAW,KAAK;AAAA,KAC5B,QACH;AAEJ,CAAC;AAED,KAAK,cAAc;AAUnB,MAAM,YAAY,MAAM,WAAgC,CAAC,OAAO,iBAAiB;AAC/E,QAAM,EAAE,aAAa,cAAc;AAEnC,MAAI,MAAM,eAAe,QAAQ,GAAG;AAClC,WAAO,MAAM,aAAa,UAAU;AAAA,SAC/B,WAAW,UAAU,SAAS;AAAA,MACjC,KAAK,YAAY,cAAe,SAAiB,GAAG;AAAA,IACtD,CAAC;AAAA,EACH;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;AAQzB,qBAAqB,OAAqD;AACxE,SAAO,MAAM,eAAe,KAAK;AACnC;AAFS;AAIT,MAAM,WAAW;AAAA,EACf,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,WAAW;AACb;AAEA,oBAAoB,OAAY,WAAqB;AACnD,QAAM,aAAa,MAAM;AAGzB,QAAM,gBAAgB,KAAK,WAAW;AAEtC,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,WAAW,KAAK,QAAQ;AAE1C,QAAI,WAAW;AACb,oBAAc,YAAY,IAAI,SAAoB;AAChD,yDAAiB,GAAG;AACpB,uDAAgB,GAAG;AAAA,MACrB;AAAA,IACF,WAES,aAAa,SAAS;AAC7B,oBAAc,YAAY,KAAK,kBAAkB,eAAe;AAAA,IAClE,WAAW,aAAa,aAAa;AACnC,oBAAc,YAAY,CAAC,eAAe,cAAc,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,IACpF;AAAA,EACF;AAEA,SAAO,KAAK,cAAc,cAAc;AAC1C;AA3CS;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/views/Text.js
CHANGED
|
@@ -11,15 +11,18 @@ const Text = createComponent({
|
|
|
11
11
|
componentName: "Text",
|
|
12
12
|
isText: true,
|
|
13
13
|
defaultProps: {
|
|
14
|
-
display:
|
|
15
|
-
boxSizing: "border-box",
|
|
14
|
+
display: "flex",
|
|
16
15
|
fontFamily: "System",
|
|
17
|
-
|
|
16
|
+
...isWeb && {
|
|
17
|
+
display: "inline",
|
|
18
|
+
boxSizing: "border-box",
|
|
19
|
+
wordWrap: "break-word"
|
|
20
|
+
}
|
|
18
21
|
},
|
|
19
22
|
variants: {
|
|
20
23
|
numberOfLines: {
|
|
21
|
-
1: ellipseStyle,
|
|
22
|
-
":number": (
|
|
24
|
+
1: isWeb ? ellipseStyle : { numberOfLines: 1 },
|
|
25
|
+
":number": (numberOfLines) => isWeb ? numberOfLines >= 1 ? { WebkitLineClamp: numberOfLines } : null : { numberOfLines }
|
|
23
26
|
},
|
|
24
27
|
selectable: {
|
|
25
28
|
true: {
|
|
@@ -45,15 +48,7 @@ const Text = createComponent({
|
|
|
45
48
|
deoptProps: new Set(isWeb ? [] : ["ellipse"]),
|
|
46
49
|
validStyles: {
|
|
47
50
|
...validStyles,
|
|
48
|
-
...stylePropsTextOnly
|
|
49
|
-
...isWeb && {
|
|
50
|
-
userSelect: true,
|
|
51
|
-
textOverflow: true,
|
|
52
|
-
whiteSpace: true,
|
|
53
|
-
wordWrap: true,
|
|
54
|
-
selectable: true,
|
|
55
|
-
cursor: true
|
|
56
|
-
}
|
|
51
|
+
...stylePropsTextOnly
|
|
57
52
|
}
|
|
58
53
|
});
|
|
59
54
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Text.tsx"],
|
|
4
|
-
"sourcesContent": ["import { stylePropsTextOnly, validStyles } from '@tamagui/helpers'\nimport { Text as TextView } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { createComponent } from '../createComponent'\nimport { TextProps, TextPropsBase } from '../types'\n\nconst ellipseStyle = {\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}\n\nexport const Text = createComponent<TextProps, TextView, TextPropsBase>({\n componentName: 'Text',\n isText: true,\n defaultProps: {\n display:
|
|
5
|
-
"mappings": "AAAA;AAGA;AACA;AAGA,MAAM,eAAe;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AACd;AAEO,MAAM,OAAO,gBAAoD;AAAA,EACtE,eAAe;AAAA,EACf,QAAQ;AAAA,
|
|
4
|
+
"sourcesContent": ["import { stylePropsTextOnly, validStyles } from '@tamagui/helpers'\nimport { Text as TextView } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { createComponent } from '../createComponent'\nimport { TextProps, TextPropsBase } from '../types'\n\nconst ellipseStyle = {\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}\n\nexport const Text = createComponent<TextProps, TextView, TextPropsBase>({\n componentName: 'Text',\n isText: true,\n\n defaultProps: {\n display: 'flex',\n fontFamily: 'System',\n ...(isWeb && {\n display: 'inline',\n boxSizing: 'border-box',\n wordWrap: 'break-word',\n }),\n },\n\n variants: {\n numberOfLines: {\n 1: isWeb ? ellipseStyle : { numberOfLines: 1 },\n\n ':number': (numberOfLines) =>\n isWeb\n ? numberOfLines >= 1\n ? { WebkitLineClamp: numberOfLines }\n : null\n : { numberOfLines },\n },\n\n selectable: {\n true: {\n userSelect: 'text',\n cursor: 'text',\n },\n false: {\n userSelect: 'none',\n },\n },\n\n pressable: {\n true: {\n cursor: 'pointer',\n },\n },\n\n ellipse: {\n true: isWeb\n ? ellipseStyle\n : {\n numberOfLines: 1,\n lineBreakMode: 'clip',\n },\n },\n },\n\n deoptProps: new Set(isWeb ? [] : ['ellipse']),\n\n validStyles: {\n ...validStyles,\n ...stylePropsTextOnly,\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA;AAGA;AACA;AAGA,MAAM,eAAe;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AACd;AAEO,MAAM,OAAO,gBAAoD;AAAA,EACtE,eAAe;AAAA,EACf,QAAQ;AAAA,EAER,cAAc;AAAA,IACZ,SAAS;AAAA,IACT,YAAY;AAAA,OACR,SAAS;AAAA,MACX,SAAS;AAAA,MACT,WAAW;AAAA,MACX,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EAEA,UAAU;AAAA,IACR,eAAe;AAAA,MACb,GAAG,QAAQ,eAAe,EAAE,eAAe,EAAE;AAAA,MAE7C,WAAW,CAAC,kBACV,QACI,iBAAiB,IACf,EAAE,iBAAiB,cAAc,IACjC,OACF,EAAE,cAAc;AAAA,IACxB;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,QACJ,YAAY;AAAA,QACZ,QAAQ;AAAA,MACV;AAAA,MACA,OAAO;AAAA,QACL,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IAEA,WAAW;AAAA,MACT,MAAM;AAAA,QACJ,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,IAEA,SAAS;AAAA,MACP,MAAM,QACF,eACA;AAAA,QACE,eAAe;AAAA,QACf,eAAe;AAAA,MACjB;AAAA,IACN;AAAA,EACF;AAAA,EAEA,YAAY,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;AAAA,EAE5C,aAAa;AAAA,OACR;AAAA,OACA;AAAA,EACL;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import React from "react";
|
|
3
|
+
import React, { useState } from "react";
|
|
4
|
+
import { useIsomorphicLayoutEffect } from "../constants/platform";
|
|
4
5
|
import { useDefaultThemeName, useThemeName } from "../hooks/useTheme";
|
|
5
6
|
import { Theme } from "./Theme";
|
|
6
7
|
let inversions = {
|
|
@@ -14,7 +15,10 @@ __name(setThemeInversions, "setThemeInversions");
|
|
|
14
15
|
const ThemeInverse = /* @__PURE__ */ __name((props) => {
|
|
15
16
|
const themeName = useThemeName();
|
|
16
17
|
const defaultTheme = useDefaultThemeName();
|
|
17
|
-
const name
|
|
18
|
+
const [name, setName] = useState(null);
|
|
19
|
+
useIsomorphicLayoutEffect(() => {
|
|
20
|
+
setName(inversions[themeName] || inversions[defaultTheme || ""] || null);
|
|
21
|
+
}, [defaultTheme, themeName]);
|
|
18
22
|
return /* @__PURE__ */ React.createElement(Theme, {
|
|
19
23
|
name
|
|
20
24
|
}, props.children);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/ThemeInverse.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react'\n\nimport { useDefaultThemeName, useThemeName } from '../hooks/useTheme'\nimport { Theme } from './Theme'\n\ntype StringRecord = { [key: string]: string }\n\nlet inversions: StringRecord = {\n light: 'dark',\n dark: 'light',\n}\n\nexport function setThemeInversions(next: StringRecord) {\n inversions = next\n}\n\nexport const ThemeInverse = (props: { children: any }) => {\n const themeName = useThemeName()\n const defaultTheme = useDefaultThemeName()\n const name = inversions[themeName] || inversions[defaultTheme || ''] || null\n return <Theme name={name}>{props.children}</Theme>\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA;AAEA;AACA;AAIA,IAAI,aAA2B;AAAA,EAC7B,OAAO;AAAA,EACP,MAAM;AACR;AAEO,4BAA4B,MAAoB;AACrD,eAAa;AACf;AAFgB;AAIT,MAAM,eAAe,wBAAC,UAA6B;AACxD,QAAM,YAAY,aAAa;AAC/B,QAAM,eAAe,oBAAoB;AACzC,QAAM,
|
|
4
|
+
"sourcesContent": ["import React, { useState } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { useDefaultThemeName, useThemeName } from '../hooks/useTheme'\nimport { Theme } from './Theme'\n\ntype StringRecord = { [key: string]: string }\n\nlet inversions: StringRecord = {\n light: 'dark',\n dark: 'light',\n}\n\nexport function setThemeInversions(next: StringRecord) {\n inversions = next\n}\n\nexport const ThemeInverse = (props: { children: any }) => {\n const themeName = useThemeName()\n const defaultTheme = useDefaultThemeName()\n const [name, setName] = useState<null | string>(null)\n\n // ssr\n useIsomorphicLayoutEffect(() => {\n setName(inversions[themeName] || inversions[defaultTheme || ''] || null)\n }, [defaultTheme, themeName])\n\n return <Theme name={name}>{props.children}</Theme>\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEA;AACA;AACA;AAIA,IAAI,aAA2B;AAAA,EAC7B,OAAO;AAAA,EACP,MAAM;AACR;AAEO,4BAA4B,MAAoB;AACrD,eAAa;AACf;AAFgB;AAIT,MAAM,eAAe,wBAAC,UAA6B;AACxD,QAAM,YAAY,aAAa;AAC/B,QAAM,eAAe,oBAAoB;AACzC,QAAM,CAAC,MAAM,WAAW,SAAwB,IAAI;AAGpD,4BAA0B,MAAM;AAC9B,YAAQ,WAAW,cAAc,WAAW,gBAAgB,OAAO,IAAI;AAAA,EACzE,GAAG,CAAC,cAAc,SAAS,CAAC;AAE5B,SAAO,oCAAC;AAAA,IAAM;AAAA,KAAa,MAAM,QAAS;AAC5C,GAX4B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -13,7 +13,8 @@ import React, {
|
|
|
13
13
|
useRef,
|
|
14
14
|
useState
|
|
15
15
|
} from "react";
|
|
16
|
-
import { StyleSheet, Text, View } from "react-native";
|
|
16
|
+
import { Pressable, StyleSheet, Text, View } from "react-native";
|
|
17
|
+
import { BaseButton } from "react-native-gesture-handler";
|
|
17
18
|
import { onConfiguredOnce } from "./conf";
|
|
18
19
|
import { stackDefaultStyles } from "./constants/constants";
|
|
19
20
|
import { isAndroid, isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
|
|
@@ -82,13 +83,13 @@ function createComponent(configIn, ParentComponent) {
|
|
|
82
83
|
function addPseudoToStyles(styles, name, pseudos) {
|
|
83
84
|
const pseudoStyle = pseudos[name];
|
|
84
85
|
const shouldNestObject = isWeb && name !== "enterStyle" && name !== "exitStyle";
|
|
85
|
-
if (pseudoStyle) {
|
|
86
|
-
styles.push(shouldNestObject ? { [name]: pseudoStyle } : pseudoStyle);
|
|
87
|
-
}
|
|
88
86
|
const defaultPseudoStyle = initialSplitStyles.pseudos[name];
|
|
89
87
|
if (defaultPseudoStyle) {
|
|
90
88
|
styles.push(shouldNestObject ? { [name]: defaultPseudoStyle } : defaultPseudoStyle);
|
|
91
89
|
}
|
|
90
|
+
if (pseudoStyle) {
|
|
91
|
+
styles.push(shouldNestObject ? { [name]: pseudoStyle } : pseudoStyle);
|
|
92
|
+
}
|
|
92
93
|
}
|
|
93
94
|
__name(addPseudoToStyles, "addPseudoToStyles");
|
|
94
95
|
const component = forwardRef((props, forwardedRef) => {
|
|
@@ -318,7 +319,10 @@ function createComponent(configIn, ParentComponent) {
|
|
|
318
319
|
const isTouch = useIsTouchDevice();
|
|
319
320
|
const isHoverable = isWeb && !isTouch;
|
|
320
321
|
const attachHover = isHoverable && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
|
|
321
|
-
const
|
|
322
|
+
const handlesPressEvents = !isStringElement && !asChild;
|
|
323
|
+
const pressKey = handlesPressEvents ? "onPress" : "onClick";
|
|
324
|
+
const pressInKey = handlesPressEvents ? "onPressIn" : "onMouseDown";
|
|
325
|
+
const pressOutKey = handlesPressEvents ? "onPressOut" : "onMouseUp";
|
|
322
326
|
const shouldAttach = !asChild && (attachPress || attachHover || "pressStyle" in props || "onPress" in props || "onPressIn" in props || "onPressOut" in props || isWeb && ("hoverStyle" in props || "onHoverIn" in props || "onHoverOut" in props || "onMouseEnter" in props || "onMouseLeave" in props));
|
|
323
327
|
const unPress = useCallback(() => {
|
|
324
328
|
if (!internal.current.isMounted)
|
|
@@ -329,12 +333,10 @@ function createComponent(configIn, ParentComponent) {
|
|
|
329
333
|
});
|
|
330
334
|
}, []);
|
|
331
335
|
const events = shouldAttach ? {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
},
|
|
336
|
+
[pressOutKey]: attachPress ? (e) => {
|
|
337
|
+
unPress();
|
|
338
|
+
onPressOut == null ? void 0 : onPressOut(e);
|
|
339
|
+
} : void 0,
|
|
338
340
|
...isHoverable && {
|
|
339
341
|
onMouseEnter: attachHover ? (e) => {
|
|
340
342
|
let next = {};
|
|
@@ -367,7 +369,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
367
369
|
onMouseLeave == null ? void 0 : onMouseLeave(e);
|
|
368
370
|
} : void 0
|
|
369
371
|
},
|
|
370
|
-
|
|
372
|
+
[pressInKey]: attachPress ? (e) => {
|
|
371
373
|
setStateShallow({
|
|
372
374
|
press: true,
|
|
373
375
|
pressIn: true
|
|
@@ -378,11 +380,10 @@ function createComponent(configIn, ParentComponent) {
|
|
|
378
380
|
mouseUps.add(unPress);
|
|
379
381
|
}
|
|
380
382
|
} : null,
|
|
381
|
-
[
|
|
383
|
+
[pressKey]: attachPress ? (e) => {
|
|
384
|
+
unPress();
|
|
382
385
|
onClick == null ? void 0 : onClick(e);
|
|
383
386
|
onPress == null ? void 0 : onPress(e);
|
|
384
|
-
unPress();
|
|
385
|
-
onPressOut == null ? void 0 : onPressOut(e);
|
|
386
387
|
} : null
|
|
387
388
|
} : null;
|
|
388
389
|
const childEls = !children || asChild ? children : wrapThemeManagerContext(spacedChildren({
|
|
@@ -391,17 +392,6 @@ function createComponent(configIn, ParentComponent) {
|
|
|
391
392
|
flexDirection: props.flexDirection || ((_b = staticConfig.defaultProps) == null ? void 0 : _b.flexDirection),
|
|
392
393
|
isZStack
|
|
393
394
|
}), getThemeManagerIfChanged(theme));
|
|
394
|
-
const [pressProps] = usePressable(events ? {
|
|
395
|
-
disabled,
|
|
396
|
-
...hitSlop && {
|
|
397
|
-
hitSlop
|
|
398
|
-
},
|
|
399
|
-
onPressIn: events.onMouseDown,
|
|
400
|
-
onPressOut: events.onPressOut,
|
|
401
|
-
onPress: events[pressEventKey]
|
|
402
|
-
} : {
|
|
403
|
-
disabled: true
|
|
404
|
-
});
|
|
405
395
|
let content;
|
|
406
396
|
if (isWeb) {
|
|
407
397
|
if (staticConfig.isReactNativeWeb) {
|
|
@@ -418,19 +408,41 @@ function createComponent(configIn, ParentComponent) {
|
|
|
418
408
|
}
|
|
419
409
|
}
|
|
420
410
|
}
|
|
421
|
-
if (events) {
|
|
422
|
-
if (!isStringElement) {
|
|
423
|
-
Object.assign(viewProps, pressProps);
|
|
424
|
-
} else {
|
|
425
|
-
Object.assign(viewProps, events);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
411
|
if (asChild) {
|
|
429
412
|
ViewComponent = Slot;
|
|
430
413
|
const onlyChild = React.Children.only(children);
|
|
431
414
|
Object.assign(viewProps, onlyChild.props);
|
|
432
415
|
}
|
|
416
|
+
if (isWeb) {
|
|
417
|
+
const [pressableProps] = usePressable(events ? {
|
|
418
|
+
disabled,
|
|
419
|
+
...hitSlop && {
|
|
420
|
+
hitSlop
|
|
421
|
+
},
|
|
422
|
+
onPressOut: events[pressOutKey],
|
|
423
|
+
onPressIn: events[pressInKey],
|
|
424
|
+
onPress: events[pressKey]
|
|
425
|
+
} : {
|
|
426
|
+
disabled: true
|
|
427
|
+
});
|
|
428
|
+
if (events) {
|
|
429
|
+
if (handlesPressEvents) {
|
|
430
|
+
Object.assign(viewProps, pressableProps);
|
|
431
|
+
} else {
|
|
432
|
+
Object.assign(viewProps, events);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
433
436
|
content = createElement(ViewComponent, viewProps, childEls);
|
|
437
|
+
if (!isWeb) {
|
|
438
|
+
if (attachPress && events) {
|
|
439
|
+
content = <Pressable onPressIn={events[pressInKey]} onPress={events[pressKey]}><BaseButton onActiveStateChange={(isActive) => {
|
|
440
|
+
if (!isActive) {
|
|
441
|
+
unPress();
|
|
442
|
+
}
|
|
443
|
+
}}>{content}</BaseButton></Pressable>;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
434
446
|
if (isWeb && events && attachHover) {
|
|
435
447
|
content = <span className="tui_Hoverable" style={{
|
|
436
448
|
display: "contents"
|
|
@@ -438,8 +450,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
438
450
|
}
|
|
439
451
|
if (process.env.NODE_ENV === "development") {
|
|
440
452
|
if (props["debug"]) {
|
|
441
|
-
viewProps
|
|
442
|
-
console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, splitStyles, animationStyles, isStringElement, classNamesIn: (_c = props.className) == null ? void 0 : _c.split(" "), classNamesOut: (_d = viewProps.className) == null ? void 0 : _d.split(" "), pressProps, events, shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses, animation: props.animation, style, defaultNativeStyle, initialSplitStyles, ...typeof window !== "undefined" ? { theme, themeState: theme.__state, themeClassName: theme.className, staticConfig, tamaguiConfig } : null });
|
|
453
|
+
console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, splitStyles, animationStyles, isStringElement, classNamesIn: (_c = props.className) == null ? void 0 : _c.split(" "), classNamesOut: (_d = viewProps.className) == null ? void 0 : _d.split(" "), events, shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses, animation: props.animation, style, defaultNativeStyle, initialSplitStyles, ...typeof window !== "undefined" ? { theme, themeState: theme.__state, themeClassName: theme.className, staticConfig, tamaguiConfig } : null });
|
|
443
454
|
}
|
|
444
455
|
}
|
|
445
456
|
if (features.length) {
|
|
@@ -476,9 +487,10 @@ function createComponent(configIn, ParentComponent) {
|
|
|
476
487
|
...initialSplitStyles.viewProps
|
|
477
488
|
};
|
|
478
489
|
defaultNativeStyle = {};
|
|
490
|
+
const validStyles = staticConfig.validStyles || stylePropsView;
|
|
479
491
|
for (const key in staticConfig.defaultProps) {
|
|
480
492
|
const val = staticConfig.defaultProps[key];
|
|
481
|
-
if (typeof val === "string" && val[0] === "$") {
|
|
493
|
+
if (typeof val === "string" && val[0] === "$" || !validStyles[key]) {
|
|
482
494
|
defaults[key] = val;
|
|
483
495
|
} else {
|
|
484
496
|
defaultNativeStyle[key] = val;
|
|
@@ -564,6 +576,9 @@ const Spacer = createComponent({
|
|
|
564
576
|
minWidth: 0
|
|
565
577
|
}
|
|
566
578
|
}
|
|
579
|
+
},
|
|
580
|
+
defaultVariants: {
|
|
581
|
+
direction: "horizontal"
|
|
567
582
|
}
|
|
568
583
|
});
|
|
569
584
|
function spacedChildren({
|
|
@@ -23,7 +23,21 @@ import {
|
|
|
23
23
|
const skipProps = {
|
|
24
24
|
animation: true,
|
|
25
25
|
animateOnly: true,
|
|
26
|
-
debug: true
|
|
26
|
+
debug: true,
|
|
27
|
+
...!isWeb && {
|
|
28
|
+
tag: true,
|
|
29
|
+
whiteSpace: true,
|
|
30
|
+
wordWrap: true,
|
|
31
|
+
textOverflow: true,
|
|
32
|
+
textDecorationDistance: true,
|
|
33
|
+
userSelect: true,
|
|
34
|
+
selectable: true,
|
|
35
|
+
cursor: true,
|
|
36
|
+
contain: true,
|
|
37
|
+
pointerEvents: true,
|
|
38
|
+
boxSizing: true,
|
|
39
|
+
boxShadow: true
|
|
40
|
+
}
|
|
27
41
|
};
|
|
28
42
|
let conf;
|
|
29
43
|
const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state, defaultClassNames) => {
|
|
@@ -110,6 +124,9 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
110
124
|
}
|
|
111
125
|
if (!isWeb || state.noClassNames || state.resolveVariablesAs === "value" || state.resolveVariablesAs === "both") {
|
|
112
126
|
for (const key in cur) {
|
|
127
|
+
if (skipProps[key]) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
113
130
|
if (key in stylePropsTransform) {
|
|
114
131
|
mergeTransform(style, key, cur[key]);
|
|
115
132
|
} else {
|
|
@@ -124,6 +141,9 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
124
141
|
if (skipProps[keyInit]) {
|
|
125
142
|
continue;
|
|
126
143
|
}
|
|
144
|
+
if (!isWeb && keyInit.startsWith("data-")) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
127
147
|
const valInit = props[keyInit];
|
|
128
148
|
if (keyInit === "style" || keyInit.startsWith("_style")) {
|
|
129
149
|
push();
|
|
@@ -220,7 +240,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
220
240
|
continue;
|
|
221
241
|
}
|
|
222
242
|
if (!staticConfig.variants || !(key in staticConfig.variants)) {
|
|
223
|
-
if (key
|
|
243
|
+
if (!skipProps[key]) {
|
|
224
244
|
push();
|
|
225
245
|
viewProps[key] = val;
|
|
226
246
|
}
|
package/dist/jsx/views/Slot.js
CHANGED
|
@@ -16,7 +16,7 @@ const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
|
16
16
|
const { children, ...slotProps } = props;
|
|
17
17
|
if (React.isValidElement(children)) {
|
|
18
18
|
return React.cloneElement(children, {
|
|
19
|
-
...mergeProps(
|
|
19
|
+
...mergeProps(children, slotProps),
|
|
20
20
|
ref: composeRefs(forwardedRef, children.ref)
|
|
21
21
|
});
|
|
22
22
|
}
|
|
@@ -30,11 +30,30 @@ function isSlottable(child) {
|
|
|
30
30
|
return React.isValidElement(child);
|
|
31
31
|
}
|
|
32
32
|
__name(isSlottable, "isSlottable");
|
|
33
|
-
|
|
33
|
+
const pressMap = {
|
|
34
|
+
onPress: "onClick",
|
|
35
|
+
onPressOut: "onMouseOut",
|
|
36
|
+
onPressIn: "onMouseIn"
|
|
37
|
+
};
|
|
38
|
+
function mergeProps(child, slotProps) {
|
|
39
|
+
const childProps = child.props;
|
|
34
40
|
const overrideProps = { ...childProps };
|
|
35
|
-
|
|
41
|
+
const isHTMLChild = typeof child.type === "string";
|
|
42
|
+
if (isHTMLChild) {
|
|
43
|
+
for (const key in pressMap) {
|
|
44
|
+
if (key in slotProps) {
|
|
45
|
+
slotProps[pressMap[key]] = slotProps[key];
|
|
46
|
+
delete slotProps[key];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
for (let propName in childProps) {
|
|
36
51
|
const slotPropValue = slotProps[propName];
|
|
37
52
|
const childPropValue = childProps[propName];
|
|
53
|
+
if (isHTMLChild && pressMap[propName]) {
|
|
54
|
+
propName = pressMap[propName];
|
|
55
|
+
delete overrideProps[propName];
|
|
56
|
+
}
|
|
38
57
|
const isHandler = /^on[A-Z]/.test(propName);
|
|
39
58
|
if (isHandler) {
|
|
40
59
|
overrideProps[propName] = (...args) => {
|
package/dist/jsx/views/Text.js
CHANGED
|
@@ -11,15 +11,18 @@ const Text = createComponent({
|
|
|
11
11
|
componentName: "Text",
|
|
12
12
|
isText: true,
|
|
13
13
|
defaultProps: {
|
|
14
|
-
display:
|
|
15
|
-
boxSizing: "border-box",
|
|
14
|
+
display: "flex",
|
|
16
15
|
fontFamily: "System",
|
|
17
|
-
|
|
16
|
+
...isWeb && {
|
|
17
|
+
display: "inline",
|
|
18
|
+
boxSizing: "border-box",
|
|
19
|
+
wordWrap: "break-word"
|
|
20
|
+
}
|
|
18
21
|
},
|
|
19
22
|
variants: {
|
|
20
23
|
numberOfLines: {
|
|
21
|
-
1: ellipseStyle,
|
|
22
|
-
":number": (
|
|
24
|
+
1: isWeb ? ellipseStyle : { numberOfLines: 1 },
|
|
25
|
+
":number": (numberOfLines) => isWeb ? numberOfLines >= 1 ? { WebkitLineClamp: numberOfLines } : null : { numberOfLines }
|
|
23
26
|
},
|
|
24
27
|
selectable: {
|
|
25
28
|
true: {
|
|
@@ -45,15 +48,7 @@ const Text = createComponent({
|
|
|
45
48
|
deoptProps: new Set(isWeb ? [] : ["ellipse"]),
|
|
46
49
|
validStyles: {
|
|
47
50
|
...validStyles,
|
|
48
|
-
...stylePropsTextOnly
|
|
49
|
-
...isWeb && {
|
|
50
|
-
userSelect: true,
|
|
51
|
-
textOverflow: true,
|
|
52
|
-
whiteSpace: true,
|
|
53
|
-
wordWrap: true,
|
|
54
|
-
selectable: true,
|
|
55
|
-
cursor: true
|
|
56
|
-
}
|
|
51
|
+
...stylePropsTextOnly
|
|
57
52
|
}
|
|
58
53
|
});
|
|
59
54
|
export {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { useIsomorphicLayoutEffect } from "../constants/platform";
|
|
3
5
|
import { useDefaultThemeName, useThemeName } from "../hooks/useTheme";
|
|
4
6
|
import { Theme } from "./Theme";
|
|
5
7
|
let inversions = {
|
|
@@ -13,7 +15,10 @@ __name(setThemeInversions, "setThemeInversions");
|
|
|
13
15
|
const ThemeInverse = /* @__PURE__ */ __name((props) => {
|
|
14
16
|
const themeName = useThemeName();
|
|
15
17
|
const defaultTheme = useDefaultThemeName();
|
|
16
|
-
const name
|
|
18
|
+
const [name, setName] = useState(null);
|
|
19
|
+
useIsomorphicLayoutEffect(() => {
|
|
20
|
+
setName(inversions[themeName] || inversions[defaultTheme || ""] || null);
|
|
21
|
+
}, [defaultTheme, themeName]);
|
|
17
22
|
return <Theme name={name}>{props.children}</Theme>;
|
|
18
23
|
}, "ThemeInverse");
|
|
19
24
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.13",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@expo/match-media": "^0.3.0",
|
|
23
|
-
"@tamagui/helpers": "^1.0.0-beta.
|
|
23
|
+
"@tamagui/helpers": "^1.0.0-beta.13",
|
|
24
24
|
"@tamagui/ow": "^0.28.1",
|
|
25
|
-
"@tamagui/use-debounce": "^1.0.0-beta.
|
|
26
|
-
"@tamagui/use-force-update": "^1.0.0-beta.
|
|
25
|
+
"@tamagui/use-debounce": "^1.0.0-beta.13",
|
|
26
|
+
"@tamagui/use-force-update": "^1.0.0-beta.13",
|
|
27
27
|
"expo-screen-orientation": "^4.2.0",
|
|
28
28
|
"react": "*",
|
|
29
29
|
"react-dom": "*"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"react-native-web": "*"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@tamagui/build": "^1.0.0-beta.
|
|
35
|
+
"@tamagui/build": "^1.0.0-beta.13",
|
|
36
36
|
"@types/react": "^17.0.35",
|
|
37
37
|
"csstype": "^3.0.10",
|
|
38
38
|
"esbuild": "^0.14.36",
|