@tamagui/web
Advanced tools
Comparing version 1.105.1 to 1.105.2
@@ -21,2 +21,3 @@ var __defProp = Object.defineProperty; | ||
getFont: () => getFont, | ||
getSetting: () => getSetting, | ||
getThemes: () => getThemes, | ||
@@ -38,3 +39,8 @@ getToken: () => getToken, | ||
let conf; | ||
const setConfig = (next) => { | ||
const getSetting = (key) => { | ||
if (process.env.NODE_ENV === "development" && !conf) | ||
throw new Error("Haven't called createTamagui yet"); | ||
return conf.settings[key] ?? // @ts-expect-error | ||
conf[key]; | ||
}, setConfig = (next) => { | ||
conf = next; | ||
@@ -41,0 +47,0 @@ }, setConfigFont = (name, font, fontParsed) => { |
@@ -22,2 +22,3 @@ "use strict"; | ||
getFont: () => getFont, | ||
getSetting: () => getSetting, | ||
getThemes: () => getThemes, | ||
@@ -79,3 +80,11 @@ getToken: () => getToken, | ||
} | ||
var conf, setConfig = function(next) { | ||
var conf, getSetting = function(key) { | ||
if (process.env.NODE_ENV === "development" && !conf) | ||
throw new Error("Haven't called createTamagui yet"); | ||
var _conf_settings_key; | ||
return (_conf_settings_key = conf.settings[key]) !== null && _conf_settings_key !== void 0 ? _conf_settings_key : ( | ||
// @ts-expect-error | ||
conf[key] | ||
); | ||
}, setConfig = function(next) { | ||
conf = next; | ||
@@ -138,2 +147,3 @@ }, setConfigFont = function(name, font, fontParsed) { | ||
getFont, | ||
getSetting, | ||
getThemes, | ||
@@ -140,0 +150,0 @@ getToken, |
@@ -256,3 +256,3 @@ var __create = Object.create; | ||
if ("themeInverse" in props && (themeStateProps.inverse = props.themeInverse), "theme" in props && (themeStateProps.name = props.theme), typeof curStateRef.isListeningToTheme == "boolean" && (themeStateProps.shouldUpdate = () => stateRef.current.isListeningToTheme), process.env.NODE_ENV === "development" && debugProp && debugProp !== "profile") { | ||
const name = `${componentName2 || Component?.displayName || Component?.name || "[Unnamed Component]"}`, type = (hasEnterStyle ? "(hasEnter)" : " ") + (isAnimated ? "(animated)" : " ") + (isReactNative ? "(rnw)" : " ") + (shouldAvoidClasses ? "(shouldAvoidClasses)" : " ") + (presenceState?.isPresent === !1 ? "(EXIT)" : ""), dataIs = propsIn["data-is"] || "", banner = `${internalID} ${name}${dataIs ? ` ${dataIs}` : ""} ${type}`; | ||
const name = `${componentName2 || Component?.displayName || Component?.name || "[Unnamed Component]"}`, type = (hasEnterStyle ? "(hasEnter)" : " ") + (isAnimated ? "(animated)" : " ") + (isReactNative ? "(rnw)" : " ") + (shouldAvoidClasses ? "(shouldAvoidClasses)" : " ") + (state.press || state.pressIn ? "(PRESSED)" : " ") + (state.hover ? "(HOVERED)" : " ") + (state.focus ? "(FOCUSED)" : " ") + (presenceState?.isPresent === !1 ? "(EXIT)" : ""), dataIs = propsIn["data-is"] || "", banner = `${internalID} ${name}${dataIs ? ` ${dataIs}` : ""} ${type}`; | ||
if (console.info( | ||
@@ -265,5 +265,5 @@ `%c ${banner} (hydrated: ${isHydrated}) (unmounted: ${state.unmounted})`, | ||
console.groupEnd(); | ||
const stateLog = `${`${state.press || state.pressIn ? " PRESS " : ""}`}${state.hover ? " HOVER " : ""}${state.focus ? " FOCUS" : " "}`, ch = propsIn.children; | ||
const ch = propsIn.children; | ||
let childLog = typeof ch == "string" ? ch.length > 4 ? ch.slice(0, 4) + "..." : ch : ""; | ||
childLog.length && (childLog = `(children: ${childLog})`), console.groupCollapsed(`${childLog}${stateLog}Props:`), (0, import_log.log)("props in:", propsIn), (0, import_log.log)("final props:", props), (0, import_log.log)({ state, staticConfig, elementType, themeStateProps }), (0, import_log.log)({ contextProps: styledContextProps, overriddenContextProps }), (0, import_log.log)({ presence, isAnimated, isHOC, hasAnimationProp, useAnimations }), console.groupEnd(); | ||
childLog.length && (childLog = `(children: ${childLog})`), console.groupCollapsed(`${childLog} Props:`), (0, import_log.log)("props in:", propsIn), (0, import_log.log)("final props:", props), (0, import_log.log)({ state, staticConfig, elementType, themeStateProps }), (0, import_log.log)({ contextProps: styledContextProps, overriddenContextProps }), (0, import_log.log)({ presence, isAnimated, isHOC, hasAnimationProp, useAnimations }), console.groupEnd(); | ||
} | ||
@@ -385,3 +385,3 @@ } | ||
const { pseudoGroups, mediaGroups } = splitStyles, unPress = () => setStateShallow({ press: !1, pressIn: !1 }); | ||
process.env.NODE_ENV === "development" && (0, import_constants.useIsomorphicLayoutEffect)(() => { | ||
process.env.NODE_ENV === "development" && import_constants.isWeb && (0, import_constants.useIsomorphicLayoutEffect)(() => { | ||
debugProp && (console.groupCollapsed("Rendered style >"), console.warn(getComputedStyle(stateRef.current.host)), console.groupEnd()); | ||
@@ -417,3 +417,13 @@ }), (0, import_react.useEffect)(() => { | ||
const runtimePressStyle = !disabled && noClassNames && pseudos?.pressStyle, runtimeFocusStyle = !disabled && noClassNames && pseudos?.focusStyle, runtimeFocusVisibleStyle = !disabled && noClassNames && pseudos?.focusVisibleStyle, attachFocus = !!(runtimePressStyle || runtimeFocusStyle || runtimeFocusVisibleStyle || onFocus || onBlur), attachPress = !!(groupName || runtimePressStyle || onPress || onPressOut || onPressIn || onMouseDown || onMouseUp || onLongPress || onClick || pseudos?.focusVisibleStyle), runtimeHoverStyle = !disabled && noClassNames && pseudos?.hoverStyle, needsHoverState = !!(groupName || runtimeHoverStyle || onHoverIn || onHoverOut), attachHover = import_constants.isWeb && !!(groupName || needsHoverState || onMouseEnter || onMouseLeave), shouldAttach = !disabled && !props.asChild && !!(attachFocus || attachPress || attachHover || runtimePressStyle || runtimeHoverStyle || runtimeFocusStyle), needsPressState = !!(groupName || runtimePressStyle); | ||
process.env.NODE_ENV === "development" && time && time`events-setup`; | ||
process.env.NODE_ENV === "development" && time && time`events-setup`, process.env.NODE_ENV === "development" && debugProp === "verbose" && (0, import_log.log)("\u{1FAA9} events()", { | ||
runtimeFocusStyle, | ||
runtimePressStyle, | ||
runtimeHoverStyle, | ||
runtimeFocusVisibleStyle, | ||
attachPress, | ||
attachFocus, | ||
attachHover, | ||
shouldAttach, | ||
needsHoverState | ||
}); | ||
const events = shouldAttach ? { | ||
@@ -768,7 +778,2 @@ onPressOut: attachPress ? (e) => { | ||
} | ||
function getMediaState(mediaGroups, layout) { | ||
return Object.fromEntries( | ||
[...mediaGroups].map((mediaKey) => [mediaKey, (0, import_useMedia.mediaKeyMatch)(mediaKey, layout)]) | ||
); | ||
} | ||
const fromPx = (val) => typeof val != "string" ? val : +val.replace("px", ""), isDisabled = (props) => props.disabled || props.accessibilityState?.disabled || props["aria-disabled"] || props.accessibilityDisabled || !1, subscribeToContextGroup = ({ | ||
@@ -791,3 +796,3 @@ disabled = !1, | ||
else if (layout && mediaGroups) { | ||
const mediaState = getMediaState(mediaGroups, layout), next = (0, import_createShallowSetState.mergeIfNotShallowEqual)(current.media, mediaState); | ||
const mediaState = (0, import_useMedia.getMediaState)(mediaGroups, layout), next = (0, import_createShallowSetState.mergeIfNotShallowEqual)(current.media, mediaState); | ||
next !== current.media && (Object.assign(current.media, next), persist()); | ||
@@ -794,0 +799,0 @@ } |
@@ -539,3 +539,3 @@ "use strict"; | ||
}), themeStateProps.deopt = willBeAnimated, process.env.NODE_ENV === "development" && debugProp && debugProp !== "profile") { | ||
var name = "".concat(componentName2 || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]"), type = (hasEnterStyle ? "(hasEnter)" : " ") + (isAnimated ? "(animated)" : " ") + (isReactNative ? "(rnw)" : " ") + (shouldAvoidClasses ? "(shouldAvoidClasses)" : " ") + ((presenceState == null ? void 0 : presenceState.isPresent) === !1 ? "(EXIT)" : ""), dataIs = propsIn["data-is"] || "", banner = "".concat(internalID, " ").concat(name).concat(dataIs ? " ".concat(dataIs) : "", " ").concat(type); | ||
var name = "".concat(componentName2 || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]"), type = (hasEnterStyle ? "(hasEnter)" : " ") + (isAnimated ? "(animated)" : " ") + (isReactNative ? "(rnw)" : " ") + (shouldAvoidClasses ? "(shouldAvoidClasses)" : " ") + (state.press || state.pressIn ? "(PRESSED)" : " ") + (state.hover ? "(HOVERED)" : " ") + (state.focus ? "(FOCUSED)" : " ") + ((presenceState == null ? void 0 : presenceState.isPresent) === !1 ? "(EXIT)" : ""), dataIs = propsIn["data-is"] || "", banner = "".concat(internalID, " ").concat(name).concat(dataIs ? " ".concat(dataIs) : "", " ").concat(type); | ||
if (console.info("%c ".concat(banner, " (hydrated: ").concat(isHydrated, ") (unmounted: ").concat(state.unmounted, ")"), "background: green; color: white;"), import_constants.isServer) | ||
@@ -551,4 +551,4 @@ (0, import_log.log)({ | ||
console.groupEnd(); | ||
var pressLog = "".concat(state.press || state.pressIn ? " PRESS " : ""), stateLog = "".concat(pressLog).concat(state.hover ? " HOVER " : "").concat(state.focus ? " FOCUS" : " "), ch = propsIn.children, childLog = typeof ch == "string" ? ch.length > 4 ? ch.slice(0, 4) + "..." : ch : ""; | ||
childLog.length && (childLog = "(children: ".concat(childLog, ")")), console.groupCollapsed("".concat(childLog).concat(stateLog, "Props:")), (0, import_log.log)("props in:", propsIn), (0, import_log.log)("final props:", props), (0, import_log.log)({ | ||
var ch = propsIn.children, childLog = typeof ch == "string" ? ch.length > 4 ? ch.slice(0, 4) + "..." : ch : ""; | ||
childLog.length && (childLog = "(children: ".concat(childLog, ")")), console.groupCollapsed("".concat(childLog, " Props:")), (0, import_log.log)("props in:", propsIn), (0, import_log.log)("final props:", props), (0, import_log.log)({ | ||
state, | ||
@@ -660,3 +660,3 @@ staticConfig, | ||
}; | ||
process.env.NODE_ENV === "development" && (0, import_constants.useIsomorphicLayoutEffect)(function() { | ||
process.env.NODE_ENV === "development" && import_constants.isWeb && (0, import_constants.useIsomorphicLayoutEffect)(function() { | ||
debugProp && (console.groupCollapsed("Rendered style >"), console.warn(getComputedStyle(stateRef.current.host)), console.groupEnd()); | ||
@@ -696,3 +696,13 @@ }), (0, import_react.useEffect)(function() { | ||
var runtimePressStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.pressStyle), runtimeFocusStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.focusStyle), runtimeFocusVisibleStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.focusVisibleStyle), attachFocus = !!(runtimePressStyle || runtimeFocusStyle || runtimeFocusVisibleStyle || onFocus || onBlur), attachPress = !!(groupName || runtimePressStyle || onPress || onPressOut || onPressIn || onMouseDown || onMouseUp || onLongPress || onClick || pseudos != null && pseudos.focusVisibleStyle), runtimeHoverStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.hoverStyle), needsHoverState = !!(groupName || runtimeHoverStyle || onHoverIn || onHoverOut), attachHover = import_constants.isWeb && !!(groupName || needsHoverState || onMouseEnter || onMouseLeave), shouldAttach = !disabled && !props.asChild && !!(attachFocus || attachPress || attachHover || runtimePressStyle || runtimeHoverStyle || runtimeFocusStyle), needsPressState = !!(groupName || runtimePressStyle); | ||
process.env.NODE_ENV === "development" && time && time(_templateObject14()); | ||
process.env.NODE_ENV === "development" && time && time(_templateObject14()), process.env.NODE_ENV === "development" && debugProp === "verbose" && (0, import_log.log)("\u{1FAA9} events()", { | ||
runtimeFocusStyle, | ||
runtimePressStyle, | ||
runtimeHoverStyle, | ||
runtimeFocusVisibleStyle, | ||
attachPress, | ||
attachFocus, | ||
attachHover, | ||
shouldAttach, | ||
needsHoverState | ||
}); | ||
var events = shouldAttach ? _object_spread(_object_spread_props(_object_spread({ | ||
@@ -1030,10 +1040,2 @@ onPressOut: attachPress ? function(e) { | ||
} | ||
function getMediaState(mediaGroups, layout) { | ||
return Object.fromEntries(_to_consumable_array(mediaGroups).map(function(mediaKey) { | ||
return [ | ||
mediaKey, | ||
(0, import_useMedia.mediaKeyMatch)(mediaKey, layout) | ||
]; | ||
})); | ||
} | ||
var fromPx = function(val) { | ||
@@ -1061,3 +1063,3 @@ return typeof val != "string" ? val : +val.replace("px", ""); | ||
else if (layout && mediaGroups) { | ||
var mediaState = getMediaState(mediaGroups, layout), next = (0, import_createShallowSetState.mergeIfNotShallowEqual)(current.media, mediaState); | ||
var mediaState = (0, import_useMedia.getMediaState)(mediaGroups, layout), next = (0, import_createShallowSetState.mergeIfNotShallowEqual)(current.media, mediaState); | ||
next !== current.media && (Object.assign(current.media, next), persist()); | ||
@@ -1064,0 +1066,0 @@ } |
@@ -126,3 +126,3 @@ var __defProp = Object.defineProperty; | ||
}, getNewCSS = (opts) => getCSS({ ...opts, sinceLastCall: !0 }); | ||
let defaultFontName = configIn.defaultFont || // uses font named "body" if present for compat | ||
let defaultFontName = (configIn.settings?.defaultFont ?? configIn.defaultFont) || // uses font named "body" if present for compat | ||
configIn.fonts && ("body" in configIn.fonts ? "body" : ""); | ||
@@ -138,3 +138,3 @@ !defaultFontName && configIn.fonts && (defaultFontName = Object.keys(configIn.fonts)[0]), defaultFontName?.[0] === "$" && (defaultFontName = defaultFontName.slice(1)); | ||
unset: { | ||
fontFamily: configIn.defaultFont ? defaultFont : void 0, | ||
fontFamily: defaultFontName ? defaultFont : void 0, | ||
...configIn.unset | ||
@@ -163,3 +163,3 @@ }, | ||
}; | ||
return (0, import_useMedia.configureMedia)(config), (0, import_config.setConfig)(config), createdConfigs.set(config, !0), import_config.configListeners.size && (import_config.configListeners.forEach((cb) => cb(config)), import_config.configListeners.clear()), process.env.NODE_ENV === "development" && (process.env.DEBUG?.startsWith("tamagui") && console.info("Tamagui config:", config), globalThis.Tamagui || (globalThis.Tamagui = import_Tamagui.Tamagui)), config; | ||
return (0, import_config.setConfig)(config), (0, import_useMedia.configureMedia)(config), createdConfigs.set(config, !0), import_config.configListeners.size && (import_config.configListeners.forEach((cb) => cb(config)), import_config.configListeners.clear()), process.env.NODE_ENV === "development" && (process.env.DEBUG?.startsWith("tamagui") && console.info("Tamagui config:", config), globalThis.Tamagui || (globalThis.Tamagui = import_Tamagui.Tamagui)), config; | ||
} | ||
@@ -166,0 +166,0 @@ function getThemesDeduped(themes) { |
@@ -111,2 +111,3 @@ "use strict"; | ||
function createTamagui(configIn) { | ||
var _configIn_settings; | ||
if (createdConfigs.has(configIn)) | ||
@@ -237,3 +238,3 @@ return configIn; | ||
})); | ||
}, defaultFontName = configIn.defaultFont || // uses font named "body" if present for compat | ||
}, _configIn_settings_defaultFont, defaultFontSetting = (_configIn_settings_defaultFont = (_configIn_settings = configIn.settings) === null || _configIn_settings === void 0 ? void 0 : _configIn_settings.defaultFont) !== null && _configIn_settings_defaultFont !== void 0 ? _configIn_settings_defaultFont : configIn.defaultFont, defaultFontName = defaultFontSetting || // uses font named "body" if present for compat | ||
configIn.fonts && ("body" in configIn.fonts ? "body" : ""); | ||
@@ -249,3 +250,3 @@ !defaultFontName && configIn.fonts && (defaultFontName = Object.keys(configIn.fonts)[0]), (defaultFontName == null ? void 0 : defaultFontName[0]) === "$" && (defaultFontName = defaultFontName.slice(1)); | ||
unset: _object_spread({ | ||
fontFamily: configIn.defaultFont ? defaultFont : void 0 | ||
fontFamily: defaultFontName ? defaultFont : void 0 | ||
}, configIn.unset), | ||
@@ -276,3 +277,3 @@ settings: _object_spread({ | ||
}); | ||
if ((0, import_useMedia.configureMedia)(config), (0, import_config.setConfig)(config), createdConfigs.set(config, !0), import_config.configListeners.size && (import_config.configListeners.forEach(function(cb) { | ||
if ((0, import_config.setConfig)(config), (0, import_useMedia.configureMedia)(config), createdConfigs.set(config, !0), import_config.configListeners.size && (import_config.configListeners.forEach(function(cb) { | ||
return cb(config); | ||
@@ -279,0 +280,0 @@ }), import_config.configListeners.clear()), process.env.NODE_ENV === "development") { |
@@ -34,3 +34,3 @@ var __defProp = Object.defineProperty; | ||
groupMediaKey = groupInfo?.media, isGroup && (containerName = mediaName); | ||
const name = (isGroup ? "group_" : "") + mediaName, selectorStart = styleInner.indexOf(":root"), selectorEnd = styleInner.lastIndexOf("{"), selector = styleInner.slice(selectorStart, selectorEnd), precedenceSpace = conf.themeClassNameOnRoot && isTheme ? "" : " ", pseudoSelectorName = groupInfo.pseudo ? groupPseudoToPseudoCSSMap[groupInfo.pseudo] || groupInfo.pseudo : void 0, pseudoSelector = pseudoSelectorName ? `:${pseudoSelectorName}` : "", presedencePrefix = `:root${precedenceImportancePrefix}${precedenceSpace}`, mediaSelector = `.t_${name}${pseudoSelector}`, nextSelector = `${presedencePrefix}${mediaSelector} ${selector.replace( | ||
const name = (isGroup ? "group_" : "") + mediaName, selectorStart = styleInner.indexOf(":root"), selectorEnd = styleInner.lastIndexOf("{"), selector = styleInner.slice(selectorStart, selectorEnd), precedenceSpace = (0, import_config.getSetting)("themeClassNameOnRoot") && isTheme ? "" : " ", pseudoSelectorName = groupInfo.pseudo ? groupPseudoToPseudoCSSMap[groupInfo.pseudo] || groupInfo.pseudo : void 0, pseudoSelector = pseudoSelectorName ? `:${pseudoSelectorName}` : "", presedencePrefix = `:root${precedenceImportancePrefix}${precedenceSpace}`, mediaSelector = `.t_${name}${pseudoSelector}`, nextSelector = `${presedencePrefix}${mediaSelector} ${selector.replace( | ||
":root", | ||
@@ -37,0 +37,0 @@ "" |
@@ -75,3 +75,3 @@ "use strict"; | ||
groupMediaKey = groupInfo == null ? void 0 : groupInfo.media, isGroup && (containerName = mediaName); | ||
var name = (isGroup ? "group_" : "") + mediaName, selectorStart = styleInner.indexOf(":root"), selectorEnd = styleInner.lastIndexOf("{"), selector = styleInner.slice(selectorStart, selectorEnd), precedenceSpace = conf.themeClassNameOnRoot && isTheme ? "" : " ", pseudoSelectorName = groupInfo.pseudo ? groupPseudoToPseudoCSSMap[groupInfo.pseudo] || groupInfo.pseudo : void 0, pseudoSelector = pseudoSelectorName ? ":".concat(pseudoSelectorName) : "", presedencePrefix = ":root".concat(precedenceImportancePrefix).concat(precedenceSpace), mediaSelector = ".t_".concat(name).concat(pseudoSelector), nextSelector = "".concat(presedencePrefix).concat(mediaSelector, " ").concat(selector.replace(":root", "")); | ||
var name = (isGroup ? "group_" : "") + mediaName, selectorStart = styleInner.indexOf(":root"), selectorEnd = styleInner.lastIndexOf("{"), selector = styleInner.slice(selectorStart, selectorEnd), precedenceSpace = (0, import_config.getSetting)("themeClassNameOnRoot") && isTheme ? "" : " ", pseudoSelectorName = groupInfo.pseudo ? groupPseudoToPseudoCSSMap[groupInfo.pseudo] || groupInfo.pseudo : void 0, pseudoSelector = pseudoSelectorName ? ":".concat(pseudoSelectorName) : "", presedencePrefix = ":root".concat(precedenceImportancePrefix).concat(precedenceSpace), mediaSelector = ".t_".concat(name).concat(pseudoSelector), nextSelector = "".concat(presedencePrefix).concat(mediaSelector, " ").concat(selector.replace(":root", "")); | ||
styleRule = styleInner.replace(selector, nextSelector); | ||
@@ -78,0 +78,0 @@ } else |
@@ -34,3 +34,3 @@ var __defProp = Object.defineProperty; | ||
return prev || next; | ||
if (process.env.NODE_ENV === "development" && debug && (console.warn("setStateShallow CHANGE", { prev, next }), debug === "break")) | ||
if (process.env.NODE_ENV === "development" && debug && (console.info("setStateShallow CHANGE", { prev, next }), debug === "break")) | ||
debugger; | ||
@@ -37,0 +37,0 @@ return { ...prev, ...next }; |
@@ -59,3 +59,3 @@ "use strict"; | ||
return prev || next; | ||
if (process.env.NODE_ENV === "development" && debug && (console.warn("setStateShallow CHANGE", { | ||
if (process.env.NODE_ENV === "development" && debug && (console.info("setStateShallow CHANGE", { | ||
prev, | ||
@@ -62,0 +62,0 @@ next |
@@ -24,2 +24,3 @@ var __defProp = Object.defineProperty; | ||
var import_constants = require("@tamagui/constants"), import_helpers = require("@tamagui/helpers"), import_react = require("react"), import_config = require("../config"), import_accessibilityDirectMap = require("../constants/accessibilityDirectMap"), import_constants2 = require("../constants/constants"), import_isDevTools = require("../constants/isDevTools"), import_useMedia = require("../hooks/useMedia"), import_createMediaStyle = require("./createMediaStyle"), import_expandStyles = require("./expandStyles"), import_getGroupPropParts = require("./getGroupPropParts"), import_getStylesAtomic = require("./getStylesAtomic"), import_insertStyleRule = require("./insertStyleRule"), import_log = require("./log"), import_normalizeValueWithProperty = require("./normalizeValueWithProperty"), import_propMapper = require("./propMapper"), import_pseudoDescriptors = require("./pseudoDescriptors"), import_skipProps = require("./skipProps"), import_transformsToString = require("./transformsToString"); | ||
const consoleGroupCollapsed = import_constants.isWeb ? console.groupCollapsed : console.info; | ||
let conf; | ||
@@ -67,3 +68,3 @@ const PROP_SPLIT = "-"; | ||
}; | ||
process.env.NODE_ENV === "development" && debug && debug !== "profile" && import_constants.isClient && (console.groupCollapsed("getSplitStyles (collapsed)"), (0, import_log.log)({ | ||
process.env.NODE_ENV === "development" && debug && debug !== "profile" && import_constants.isClient && (consoleGroupCollapsed("getSplitStyles (collapsed)"), (0, import_log.log)({ | ||
props, | ||
@@ -195,3 +196,3 @@ staticConfig, | ||
isHOC && parentVariants && keyInit in parentVariants || inlineProps?.has(keyInit), parentVariant = parentVariants?.[keyInit], isHOCShouldPassThrough = !!(isHOC && (isShorthand || isValidStyleKeyInit || isMediaOrPseudo || parentVariant || keyInit in import_skipProps.skipProps)), shouldPassThrough = shouldPassProp || isHOCShouldPassThrough; | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupEnd(), console.groupEnd(), console.groupCollapsed( | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupEnd(), console.groupEnd(), consoleGroupCollapsed( | ||
` \u{1F511} ${keyOg}${keyInit !== keyOg ? ` (shorthand for ${keyInit})` : ""} ${shouldPassThrough ? "(pass)" : ""}` | ||
@@ -221,3 +222,3 @@ ), (0, import_log.log)({ isVariant, valInit, shouldPassProp }), import_constants.isClient && (0, import_log.log)({ | ||
if (process.env.NODE_ENV === "development" && debug === "verbose") { | ||
console.groupCollapsed(" \u{1F4A0} expanded", keyInit, valInit); | ||
consoleGroupCollapsed(" \u{1F4A0} expanded", keyInit, valInit); | ||
try { | ||
@@ -232,3 +233,2 @@ !import_constants.isServer && import_isDevTools.isDevTools && ((0, import_log.log)({ | ||
isHOCShouldPassThrough, | ||
theme, | ||
usedKeys: { ...usedKeys }, | ||
@@ -254,3 +254,3 @@ curProps: { ...styleState.curProps } | ||
if (isPseudo = key in import_helpers.validPseudoKeys, isMedia = !isPseudo && !isValidStyleKeyInit && (0, import_useMedia.isMediaKey)(key), isMediaOrPseudo = !!(isMedia || isPseudo), isVariant = variants && key in variants, (inlineProps?.has(key) || process.env.IS_STATIC === "is_static" && inlineWhenUnflattened?.has(key)) && (viewProps[key] = props[key] ?? val), styleProps.noExpand && isPseudo || isHOC && (isMediaOrPseudo || parentStaticConfig?.variants?.[keyInit])) { | ||
passDownProp(viewProps, key, val, isMediaOrPseudo), process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed(` - passing down prop ${key}`), (0, import_log.log)({ val, after: { ...viewProps[key] } }), console.groupEnd()); | ||
passDownProp(viewProps, key, val, isMediaOrPseudo), process.env.NODE_ENV === "development" && debug === "verbose" && (consoleGroupCollapsed(` - passing down prop ${key}`), (0, import_log.log)({ val, after: { ...viewProps[key] } }), console.groupEnd()); | ||
continue; | ||
@@ -274,3 +274,3 @@ } | ||
const pseudoStyles = (0, import_getStylesAtomic.getStyleAtomic)(pseudoStyleObject, descriptor); | ||
process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed("pseudo (classes)", key), (0, import_log.log)({ pseudoStyleObject, pseudoStyles }), console.groupEnd()); | ||
process.env.NODE_ENV === "development" && debug === "verbose" && (consoleGroupCollapsed("pseudo (classes)", key), (0, import_log.log)({ pseudoStyleObject, pseudoStyles }), console.groupEnd()); | ||
for (const psuedoStyle of pseudoStyles) { | ||
@@ -291,3 +291,3 @@ const fullKey = `${psuedoStyle[import_helpers.StyleObjectProperty]}${PROP_SPLIT}${descriptor.name}`; | ||
let isDisabled = componentState[descriptorKey] === !1; | ||
isExit && (isDisabled = !styleProps.isExiting), isEnter && componentState.unmounted === !1 && (isDisabled = !0), process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed("pseudo", key, { isDisabled }), (0, import_log.log)({ pseudoStyleObject, isDisabled, descriptor, componentState }), console.groupEnd()); | ||
isExit && (isDisabled = !styleProps.isExiting), isEnter && componentState.unmounted === !1 && (isDisabled = !0), process.env.NODE_ENV === "development" && debug === "verbose" && (consoleGroupCollapsed("pseudo", key, { isDisabled }), (0, import_log.log)({ pseudoStyleObject, isDisabled, descriptor, componentState }), console.groupEnd()); | ||
const importance = descriptor.priority; | ||
@@ -391,3 +391,3 @@ for (const pkey in pseudoStyleObject) { | ||
if (!groupContext) { | ||
process.env.NODE_ENV === "development" && debug && console.warn(`No parent with group prop, skipping styles: ${groupName}`); | ||
process.env.NODE_ENV === "development" && debug && (0, import_log.log)(`No parent with group prop, skipping styles: ${groupName}`); | ||
continue; | ||
@@ -400,9 +400,13 @@ } | ||
let isActive = mediaState2?.[groupMediaKey]; | ||
if (!mediaState2 && groupContext.layout && (isActive = (0, import_useMedia.mediaKeyMatch)(groupMediaKey, groupContext.layout)), !isActive) continue; | ||
if (!mediaState2 && groupContext.layout && (isActive = (0, import_useMedia.mediaKeyMatch)(groupMediaKey, groupContext.layout)), process.env.NODE_ENV === "development" && debug === "verbose" && (0, import_log.log)(` \u{1F3D8}\uFE0F GROUP media ${groupMediaKey} active? ${isActive}`), !isActive) continue; | ||
importanceBump = 2; | ||
} | ||
if (groupPseudoKey) { | ||
if (pseudoGroups ||= /* @__PURE__ */ new Set(), pseudoGroups.add(groupName), !(componentGroupState || // fallback to context initially | ||
context.groups.state[groupName]).pseudo?.[groupPseudoKey]) continue; | ||
importanceBump = import_pseudoDescriptors.pseudoPriorities[groupPseudoKey]; | ||
pseudoGroups ||= /* @__PURE__ */ new Set(), pseudoGroups.add(groupName); | ||
const isActive = (componentGroupState || // fallback to context initially | ||
context.groups.state[groupName]).pseudo?.[groupPseudoKey], priority = import_pseudoDescriptors.pseudoPriorities[groupPseudoKey]; | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && (0, import_log.log)( | ||
` \u{1F3D8}\uFE0F GROUP pseudo ${groupMediaKey} active? ${isActive}, priority ${priority}` | ||
), !isActive) continue; | ||
importanceBump = priority; | ||
} | ||
@@ -422,3 +426,4 @@ } | ||
mediaState[mediaKeyShort], | ||
importanceBump | ||
importanceBump, | ||
debug | ||
), key === "fontFamily" && (styleState.fontFamily = mediaStyle.fontFamily); | ||
@@ -467,3 +472,3 @@ } | ||
} | ||
process.env.NODE_ENV === "development" && props.debug === "verbose" && (console.groupEnd(), console.groupCollapsed("\u{1F539} getSplitStyles final style object"), console.info(styleState.style), console.groupEnd()), (shouldRetain || process.env.IS_STATIC !== "is_static") && (styleState.style = retainedStyles || {}); | ||
process.env.NODE_ENV === "development" && props.debug === "verbose" && (console.groupEnd(), consoleGroupCollapsed("\u{1F539} getSplitStyles final style object"), console.info(styleState.style), console.groupEnd()), (shouldRetain || process.env.IS_STATIC !== "is_static") && (styleState.style = retainedStyles || {}); | ||
} | ||
@@ -473,3 +478,3 @@ if (transforms) | ||
if (!transforms[namespace]) { | ||
process.env.NODE_ENV === "development" && console.warn("Error no transform", transforms, namespace); | ||
process.env.NODE_ENV === "development" && (0, import_log.log)("Error no transform", transforms, namespace); | ||
continue; | ||
@@ -549,3 +554,3 @@ } | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && import_isDevTools.isDevTools) { | ||
console.groupCollapsed("\u{1F539} getSplitStyles ===>"); | ||
consoleGroupCollapsed("\u{1F539} getSplitStyles ===>"); | ||
try { | ||
@@ -655,3 +660,3 @@ const logs = { | ||
} | ||
function mergeMediaByImportance(styleState, mediaKey, key, value, importancesUsed, isSizeMedia, importanceBump) { | ||
function mergeMediaByImportance(styleState, mediaKey, key, value, importancesUsed, isSizeMedia, importanceBump, debugProp) { | ||
let importance = (0, import_useMedia.getMediaImportanceIfMoreImportant)( | ||
@@ -663,3 +668,15 @@ mediaKey, | ||
); | ||
return importanceBump && (importance = (importance || 0) + importanceBump), importance === null ? !1 : (importancesUsed[key] = importance, mergeStyle(styleState, key, value), !0); | ||
if (importanceBump && (importance = (importance || 0) + importanceBump), process.env.NODE_ENV === "development" && debugProp === "verbose" && (0, import_log.log)( | ||
`mergeMediaByImportance ${key} importance existing ${importancesUsed[key]} next ${importance}` | ||
), importance === null) | ||
return !1; | ||
if (importancesUsed[key] = importance, key in import_pseudoDescriptors.pseudoDescriptors) { | ||
const descriptor = import_pseudoDescriptors.pseudoDescriptors[key], descriptorKey = descriptor.stateKey || descriptor.name; | ||
if (styleState.componentState[descriptorKey] === !1) | ||
return !1; | ||
for (const subKey in value) | ||
mergeStyle(styleState, subKey, value[subKey]); | ||
} else | ||
mergeStyle(styleState, key, value); | ||
return !0; | ||
} | ||
@@ -666,0 +683,0 @@ function normalizeStyle(style) { |
@@ -104,3 +104,3 @@ "use strict"; | ||
} | ||
var conf, PROP_SPLIT = "-"; | ||
var consoleGroupCollapsed = import_constants.isWeb ? console.groupCollapsed : console.info, conf, PROP_SPLIT = "-"; | ||
function isValidStyleKey(key, staticConfig) { | ||
@@ -135,3 +135,3 @@ var _staticConfig_accept, validStyleProps = staticConfig.validStyles || (staticConfig.isText || staticConfig.isInput ? import_helpers.stylePropsText : import_helpers.validStyles); | ||
}; | ||
process.env.NODE_ENV === "development" && debug && debug !== "profile" && import_constants.isClient && (console.groupCollapsed("getSplitStyles (collapsed)"), (0, import_log.log)({ | ||
process.env.NODE_ENV === "development" && debug && debug !== "profile" && import_constants.isClient && (consoleGroupCollapsed("getSplitStyles (collapsed)"), (0, import_log.log)({ | ||
props, | ||
@@ -192,3 +192,3 @@ staticConfig, | ||
isHOC && parentVariants && keyInit in parentVariants || (inlineProps == null ? void 0 : inlineProps.has(keyInit)), parentVariant = parentVariants == null ? void 0 : parentVariants[keyInit], isHOCShouldPassThrough = !!(isHOC && (isShorthand || isValidStyleKeyInit || isMediaOrPseudo1 || parentVariant || keyInit in import_skipProps.skipProps)), shouldPassThrough = shouldPassProp || isHOCShouldPassThrough; | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupEnd(), console.groupEnd(), console.groupCollapsed(" \u{1F511} ".concat(keyOg).concat(keyInit !== keyOg ? " (shorthand for ".concat(keyInit, ")") : "", " ").concat(shouldPassThrough ? "(pass)" : "")), (0, import_log.log)({ | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupEnd(), console.groupEnd(), consoleGroupCollapsed(" \u{1F511} ".concat(keyOg).concat(keyInit !== keyOg ? " (shorthand for ".concat(keyInit, ")") : "", " ").concat(shouldPassThrough ? "(pass)" : "")), (0, import_log.log)({ | ||
isVariant, | ||
@@ -220,3 +220,3 @@ valInit, | ||
if (process.env.NODE_ENV === "development" && debug === "verbose") { | ||
console.groupCollapsed(" \u{1F4A0} expanded", keyInit, valInit); | ||
consoleGroupCollapsed(" \u{1F4A0} expanded", keyInit, valInit); | ||
try { | ||
@@ -231,3 +231,2 @@ !import_constants.isServer && import_isDevTools.isDevTools && ((0, import_log.log)({ | ||
isHOCShouldPassThrough, | ||
theme, | ||
usedKeys: _object_spread({}, usedKeys), | ||
@@ -255,3 +254,3 @@ curProps: _object_spread({}, styleState.curProps) | ||
if (shouldPassThrough1) { | ||
passDownProp(viewProps, key, val, isMediaOrPseudo1), process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed(" - passing down prop ".concat(key)), (0, import_log.log)({ | ||
passDownProp(viewProps, key, val, isMediaOrPseudo1), process.env.NODE_ENV === "development" && debug === "verbose" && (consoleGroupCollapsed(" - passing down prop ".concat(key)), (0, import_log.log)({ | ||
val, | ||
@@ -276,3 +275,3 @@ after: _object_spread({}, viewProps[key]) | ||
var pseudoStyles = (0, import_getStylesAtomic.getStyleAtomic)(pseudoStyleObject, descriptor); | ||
process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed("pseudo (classes)", key), (0, import_log.log)({ | ||
process.env.NODE_ENV === "development" && debug === "verbose" && (consoleGroupCollapsed("pseudo (classes)", key), (0, import_log.log)({ | ||
pseudoStyleObject, | ||
@@ -300,3 +299,3 @@ pseudoStyles | ||
var descriptorKey = descriptor.stateKey || descriptor.name, isDisabled = componentState[descriptorKey] === !1; | ||
isExit && (isDisabled = !styleProps.isExiting), isEnter && componentState.unmounted === !1 && (isDisabled = !0), process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed("pseudo", key, { | ||
isExit && (isDisabled = !styleProps.isExiting), isEnter && componentState.unmounted === !1 && (isDisabled = !0), process.env.NODE_ENV === "development" && debug === "verbose" && (consoleGroupCollapsed("pseudo", key, { | ||
isDisabled | ||
@@ -401,3 +400,3 @@ }), (0, import_log.log)({ | ||
if (!groupContext) { | ||
process.env.NODE_ENV === "development" && debug && console.warn("No parent with group prop, skipping styles: ".concat(groupName)); | ||
process.env.NODE_ENV === "development" && debug && (0, import_log.log)("No parent with group prop, skipping styles: ".concat(groupName)); | ||
continue; | ||
@@ -409,3 +408,3 @@ } | ||
var mediaState1 = componentGroupState == null ? void 0 : componentGroupState.media, isActive = mediaState1 == null ? void 0 : mediaState1[groupMediaKey]; | ||
if (!mediaState1 && groupContext.layout && (isActive = (0, import_useMedia.mediaKeyMatch)(groupMediaKey, groupContext.layout)), !isActive) continue; | ||
if (!mediaState1 && groupContext.layout && (isActive = (0, import_useMedia.mediaKeyMatch)(groupMediaKey, groupContext.layout)), process.env.NODE_ENV === "development" && debug === "verbose" && (0, import_log.log)(" \u{1F3D8}\uFE0F GROUP media ".concat(groupMediaKey, " active? ").concat(isActive)), !isActive) continue; | ||
importanceBump = 2; | ||
@@ -416,5 +415,4 @@ } | ||
var componentGroupPseudoState = (componentGroupState || // fallback to context initially | ||
context.groups.state[groupName]).pseudo, isActive1 = componentGroupPseudoState == null ? void 0 : componentGroupPseudoState[groupPseudoKey]; | ||
if (!isActive1) continue; | ||
var priority1 = import_pseudoDescriptors.pseudoPriorities[groupPseudoKey]; | ||
context.groups.state[groupName]).pseudo, isActive1 = componentGroupPseudoState == null ? void 0 : componentGroupPseudoState[groupPseudoKey], priority1 = import_pseudoDescriptors.pseudoPriorities[groupPseudoKey]; | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && (0, import_log.log)(" \u{1F3D8}\uFE0F GROUP pseudo ".concat(groupMediaKey, " active? ").concat(isActive1, ", priority ").concat(priority1)), !isActive1) continue; | ||
importanceBump = priority1; | ||
@@ -429,3 +427,3 @@ } | ||
} | ||
(_styleState1 = styleState).style || (_styleState1.style = {}), mergeMediaByImportance(styleState, mediaKeyShort, subKey, mediaStyle1[subKey], usedKeys, mediaState[mediaKeyShort], importanceBump), key === "fontFamily" && (styleState.fontFamily = mediaStyle1.fontFamily); | ||
(_styleState1 = styleState).style || (_styleState1.style = {}), mergeMediaByImportance(styleState, mediaKeyShort, subKey, mediaStyle1[subKey], usedKeys, mediaState[mediaKeyShort], importanceBump, debug), key === "fontFamily" && (styleState.fontFamily = mediaStyle1.fontFamily); | ||
} | ||
@@ -571,3 +569,3 @@ } | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && import_isDevTools.isDevTools) { | ||
console.groupCollapsed("\u{1F539} getSplitStyles ===>"); | ||
consoleGroupCollapsed("\u{1F539} getSplitStyles ===>"); | ||
try { | ||
@@ -686,5 +684,15 @@ var logs = _object_spread_props(_object_spread({}, result), { | ||
} | ||
function mergeMediaByImportance(styleState, mediaKey, key, value, importancesUsed, isSizeMedia, importanceBump) { | ||
function mergeMediaByImportance(styleState, mediaKey, key, value, importancesUsed, isSizeMedia, importanceBump, debugProp) { | ||
var importance = (0, import_useMedia.getMediaImportanceIfMoreImportant)(mediaKey, key, importancesUsed, isSizeMedia); | ||
return importanceBump && (importance = (importance || 0) + importanceBump), importance === null ? !1 : (importancesUsed[key] = importance, mergeStyle(styleState, key, value), !0); | ||
if (importanceBump && (importance = (importance || 0) + importanceBump), process.env.NODE_ENV === "development" && debugProp === "verbose" && (0, import_log.log)("mergeMediaByImportance ".concat(key, " importance existing ").concat(importancesUsed[key], " next ").concat(importance)), importance === null) | ||
return !1; | ||
if (importancesUsed[key] = importance, key in import_pseudoDescriptors.pseudoDescriptors) { | ||
var descriptor = import_pseudoDescriptors.pseudoDescriptors[key], descriptorKey = descriptor.stateKey || descriptor.name, isDisabled = styleState.componentState[descriptorKey] === !1; | ||
if (isDisabled) | ||
return !1; | ||
for (var subKey in value) | ||
mergeStyle(styleState, subKey, value[subKey]); | ||
} else | ||
mergeStyle(styleState, key, value); | ||
return !0; | ||
} | ||
@@ -691,0 +699,0 @@ function normalizeStyle(style) { |
@@ -20,3 +20,3 @@ var __defProp = Object.defineProperty; | ||
module.exports = __toCommonJS(getThemeCSSRules_exports); | ||
var import_helpers = require("@tamagui/helpers"), import_constants = require("../constants/constants"), import_createVariable = require("../createVariable"), import_registerCSSVariable = require("./registerCSSVariable"); | ||
var import_helpers = require("@tamagui/helpers"), import_constants = require("../constants/constants"), import_createVariable = require("../createVariable"), import_registerCSSVariable = require("./registerCSSVariable"), import_config = require("../config"); | ||
function getThemeCSSRules(props) { | ||
@@ -37,3 +37,3 @@ const cssRuleSets = []; | ||
if (hasDarkLight) { | ||
const maxDepth = config.maxDarkLightNesting ?? 3; | ||
const maxDepth = (0, import_config.getSetting)("maxDarkLightNesting") ?? 3; | ||
for (const subName of names) { | ||
@@ -61,4 +61,4 @@ const isDark = isDarkBase || subName.startsWith("dark_"), isLight = !isDark && (isLightBase || subName.startsWith("light_")); | ||
} | ||
const selectors = [...selectorsSet].sort((a, b) => a.localeCompare(b)), css = `${selectors.map((x) => `:root${isBaseTheme(x) && config.themeClassNameOnRoot ? "" : " "}${x}`).join(", ")} {${vars}}`; | ||
if (cssRuleSets.push(css), config.shouldAddPrefersColorThemes) { | ||
const selectors = [...selectorsSet].sort((a, b) => a.localeCompare(b)), css = `${selectors.map((x) => `:root${isBaseTheme(x) && (0, import_config.getSetting)("themeClassNameOnRoot") ? "" : " "}${x}`).join(", ")} {${vars}}`; | ||
if (cssRuleSets.push(css), (0, import_config.getSetting)("shouldAddPrefersColorThemes")) { | ||
const bgString = theme.background ? `background:${(0, import_createVariable.variableToString)(theme.background)};` : "", fgString = theme.color ? `color:${(0, import_createVariable.variableToString)(theme.color)}` : "", bodyRules = `body{${bgString}${fgString}}`, isDark = themeName.startsWith("dark"), baseName = isDark ? "dark" : "light", themeRules = `${selectors.map((x) => { | ||
@@ -74,4 +74,5 @@ if (x == darkSelector || x === lightSelector) return ":root"; | ||
} | ||
if (config.selectionStyles) { | ||
const rules = config.selectionStyles(theme); | ||
const selectionStyles = (0, import_config.getSetting)("selectionStyles"); | ||
if (selectionStyles) { | ||
const rules = selectionStyles(theme); | ||
if (rules) { | ||
@@ -78,0 +79,0 @@ const selectionSelectors = baseSelectors.map((s) => `${s} ::selection`).join(", "), styles = Object.entries(rules).flatMap( |
@@ -20,6 +20,13 @@ var __defProp = Object.defineProperty; | ||
module.exports = __toCommonJS(log_exports); | ||
var import_useMedia = require("../hooks/useMedia"); | ||
function log(...args) { | ||
if (process.env.NODE_ENV !== "production") | ||
return console.info(...args); | ||
if (process.env.NODE_ENV !== "production") { | ||
(0, import_useMedia._dmt)(!0); | ||
try { | ||
return console.info(...args); | ||
} finally { | ||
(0, import_useMedia._dmt)(!1); | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=log.js.map |
@@ -21,2 +21,3 @@ "use strict"; | ||
module.exports = __toCommonJS(log_exports); | ||
var import_useMedia = require("../hooks/useMedia"); | ||
function _array_like_to_array(arr, len) { | ||
@@ -50,7 +51,12 @@ (len == null || len > arr.length) && (len = arr.length); | ||
args[_key] = arguments[_key]; | ||
var _console; | ||
if (process.env.NODE_ENV !== "production") { | ||
if (0) | ||
var _console1; | ||
return (_console = console).log.apply(_console, _to_consumable_array(args)); | ||
(0, import_useMedia._dmt)(!0); | ||
try { | ||
var _console; | ||
if (0) | ||
var _console1; | ||
return (_console = console).log.apply(_console, _to_consumable_array(args)); | ||
} finally { | ||
(0, import_useMedia._dmt)(!1); | ||
} | ||
} | ||
@@ -57,0 +63,0 @@ } |
@@ -26,4 +26,5 @@ var __defProp = Object.defineProperty; | ||
if (lastFontFamilyToken = null, key === "elevationAndroid") return; | ||
const { conf, styleProps, fontFamily, staticConfig } = styleStateIn; | ||
if (value === "unset") { | ||
const unsetVal = styleStateIn.conf.unset?.[key]; | ||
const unsetVal = conf.unset?.[key]; | ||
if (unsetVal != null) | ||
@@ -34,7 +35,7 @@ value = unsetVal; | ||
} | ||
const subProps = styleStateIn.styleProps.fallbackProps || subPropsIn, styleState = subProps ? new Proxy(styleStateIn, { | ||
const subProps = styleProps.fallbackProps || subPropsIn, styleState = subProps ? new Proxy(styleStateIn, { | ||
get(_, k) { | ||
return k === "curProps" ? subProps : Reflect.get(_, k); | ||
} | ||
}) : styleStateIn, { conf, styleProps, fontFamily, staticConfig } = styleState, { variants } = staticConfig; | ||
}) : styleStateIn, { variants } = staticConfig; | ||
if (process.env.NODE_ENV === "development" && fontFamily && fontFamily[0] === "$" && !(fontFamily in conf.fontsParsed) && console.warn( | ||
@@ -41,0 +42,0 @@ `Warning: no fontFamily "${fontFamily}" found in config: ${Object.keys( |
@@ -91,4 +91,5 @@ "use strict"; | ||
if (lastFontFamilyToken = null, !(!import_constants.isAndroid && key === "elevationAndroid")) { | ||
var conf = styleStateIn.conf, styleProps = styleStateIn.styleProps, fontFamily = styleStateIn.fontFamily, staticConfig = styleStateIn.staticConfig; | ||
if (value === "unset") { | ||
var _styleStateIn_conf_unset, unsetVal = (_styleStateIn_conf_unset = styleStateIn.conf.unset) === null || _styleStateIn_conf_unset === void 0 ? void 0 : _styleStateIn_conf_unset[key]; | ||
var _conf_unset, unsetVal = (_conf_unset = conf.unset) === null || _conf_unset === void 0 ? void 0 : _conf_unset[key]; | ||
if (unsetVal != null) | ||
@@ -99,7 +100,7 @@ value = unsetVal; | ||
} | ||
var subProps = styleStateIn.styleProps.fallbackProps || subPropsIn, styleState = subProps ? new Proxy(styleStateIn, { | ||
var subProps = styleProps.fallbackProps || subPropsIn, styleState = subProps ? new Proxy(styleStateIn, { | ||
get: function(_, k) { | ||
return k === "curProps" ? subProps : Reflect.get(_, k); | ||
} | ||
}) : styleStateIn, conf = styleState.conf, styleProps = styleState.styleProps, fontFamily = styleState.fontFamily, staticConfig = styleState.staticConfig, variants = staticConfig.variants; | ||
}) : styleStateIn, variants = staticConfig.variants; | ||
if (process.env.NODE_ENV === "development" && fontFamily && fontFamily[0] === "$" && !(fontFamily in conf.fontsParsed) && console.warn('Warning: no fontFamily "'.concat(fontFamily, '" found in config: ').concat(Object.keys(conf.fontsParsed).join(", "))), !styleProps.noExpand && variants && key in variants) { | ||
@@ -106,0 +107,0 @@ styleState.curProps[key] = value; |
@@ -22,4 +22,4 @@ var __defProp = Object.defineProperty; | ||
function getDisableSSR(componentContext) { | ||
return componentContext?.disableSSR ?? (0, import_config.getConfig)().disableSSR; | ||
return componentContext?.disableSSR ?? (0, import_config.getSetting)("disableSSR"); | ||
} | ||
//# sourceMappingURL=useDisableSSR.js.map |
@@ -24,3 +24,3 @@ "use strict"; | ||
var _componentContext_disableSSR; | ||
return (_componentContext_disableSSR = componentContext == null ? void 0 : componentContext.disableSSR) !== null && _componentContext_disableSSR !== void 0 ? _componentContext_disableSSR : (0, import_config.getConfig)().disableSSR; | ||
return (_componentContext_disableSSR = componentContext == null ? void 0 : componentContext.disableSSR) !== null && _componentContext_disableSSR !== void 0 ? _componentContext_disableSSR : (0, import_config.getSetting)("disableSSR"); | ||
} | ||
@@ -27,0 +27,0 @@ // Annotate the CommonJS export names for ESM import in node: |
@@ -17,2 +17,3 @@ var __defProp = Object.defineProperty; | ||
__export(useMedia_exports, { | ||
_dmt: () => _dmt, | ||
configureMedia: () => configureMedia, | ||
@@ -22,2 +23,3 @@ getMedia: () => getMedia, | ||
getMediaKeyImportance: () => getMediaKeyImportance, | ||
getMediaState: () => getMediaState, | ||
isMediaKey: () => isMediaKey, | ||
@@ -68,3 +70,3 @@ mediaKeyMatch: () => mediaKeyMatch, | ||
const configureMedia = (config) => { | ||
const { media, mediaQueryDefaultActive } = config; | ||
const { media } = config, mediaQueryDefaultActive = (0, import_config.getSetting)("mediaQueryDefaultActive"); | ||
if (media) { | ||
@@ -150,8 +152,25 @@ mediaVersion++; | ||
get(_, key) { | ||
return typeof key == "string" && (componentState.keys ||= {}, componentState.keys[key] = !0, process.env.NODE_ENV === "development" && debug && console.info("useMedia() TOUCH", key)), Reflect.get(state, key); | ||
if (!disableMediaTouch) | ||
return typeof key == "string" && (componentState.keys ||= {}, componentState.keys[key] = !0, process.env.NODE_ENV === "development" && debug && console.info("useMedia() TOUCH", key)), Reflect.get(state, key); | ||
} | ||
}); | ||
} | ||
let disableMediaTouch = !1; | ||
function _dmt(val) { | ||
disableMediaTouch = val; | ||
} | ||
function getMediaState(mediaGroups, layout) { | ||
disableMediaTouch = !0; | ||
let res; | ||
try { | ||
res = Object.fromEntries( | ||
[...mediaGroups].map((mediaKey) => [mediaKey, mediaKeyMatch(mediaKey, layout)]) | ||
); | ||
} finally { | ||
disableMediaTouch = !1; | ||
} | ||
return res; | ||
} | ||
const getMediaImportanceIfMoreImportant = (mediaKey, key, importancesUsed, isSizeMedia) => { | ||
const conf = (0, import_config.getConfig)(), importance = isSizeMedia && !conf.settings.mediaPropOrder ? getMediaKeyImportance(mediaKey) : defaultMediaImportance; | ||
const importance = isSizeMedia && !(0, import_config.getSetting)("mediaPropOrder") ? getMediaKeyImportance(mediaKey) : defaultMediaImportance; | ||
return !importancesUsed[key] || importance > importancesUsed[key] ? importance : null; | ||
@@ -158,0 +177,0 @@ }; |
@@ -18,2 +18,3 @@ "use strict"; | ||
__export(useMedia_exports, { | ||
_dmt: () => _dmt, | ||
configureMedia: () => configureMedia, | ||
@@ -23,2 +24,3 @@ getMedia: () => getMedia, | ||
getMediaKeyImportance: () => getMediaKeyImportance, | ||
getMediaState: () => getMediaState, | ||
isMediaKey: () => isMediaKey, | ||
@@ -45,2 +47,5 @@ mediaKeyMatch: () => mediaKeyMatch, | ||
} | ||
function _array_without_holes(arr) { | ||
if (Array.isArray(arr)) return _array_like_to_array(arr); | ||
} | ||
function _define_property(obj, key, value) { | ||
@@ -54,2 +59,5 @@ return key in obj ? Object.defineProperty(obj, key, { | ||
} | ||
function _iterable_to_array(iter) { | ||
if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); | ||
} | ||
function _iterable_to_array_limit(arr, i) { | ||
@@ -77,2 +85,5 @@ var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"]; | ||
} | ||
function _non_iterable_spread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
function _object_spread(target) { | ||
@@ -107,2 +118,5 @@ for (var i = 1; i < arguments.length; i++) { | ||
} | ||
function _to_consumable_array(arr) { | ||
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread(); | ||
} | ||
function _unsupported_iterable_to_array(o, minLen) { | ||
@@ -141,3 +155,3 @@ if (o) { | ||
}, dispose = /* @__PURE__ */ new Set(), mediaVersion = 0, configureMedia = function(config) { | ||
var media = config.media, mediaQueryDefaultActive = config.mediaQueryDefaultActive; | ||
var media = config.media, mediaQueryDefaultActive = (0, import_config.getSetting)("mediaQueryDefaultActive"); | ||
if (media) { | ||
@@ -225,12 +239,33 @@ mediaVersion++; | ||
get: function(_, key) { | ||
if (typeof key == "string") { | ||
var _componentState; | ||
(_componentState = componentState).keys || (_componentState.keys = {}), componentState.keys[key] = !0, process.env.NODE_ENV === "development" && debug && console.info("useMedia() TOUCH", key); | ||
if (!disableMediaTouch) { | ||
if (typeof key == "string") { | ||
var _componentState; | ||
(_componentState = componentState).keys || (_componentState.keys = {}), componentState.keys[key] = !0, process.env.NODE_ENV === "development" && debug && console.info("useMedia() TOUCH", key); | ||
} | ||
return Reflect.get(state, key); | ||
} | ||
return Reflect.get(state, key); | ||
} | ||
}); | ||
} | ||
var disableMediaTouch = !1; | ||
function _dmt(val) { | ||
disableMediaTouch = val; | ||
} | ||
function getMediaState(mediaGroups, layout) { | ||
disableMediaTouch = !0; | ||
var res; | ||
try { | ||
res = Object.fromEntries(_to_consumable_array(mediaGroups).map(function(mediaKey) { | ||
return [ | ||
mediaKey, | ||
mediaKeyMatch(mediaKey, layout) | ||
]; | ||
})); | ||
} finally { | ||
disableMediaTouch = !1; | ||
} | ||
return res; | ||
} | ||
var getMediaImportanceIfMoreImportant = function(mediaKey, key, importancesUsed, isSizeMedia) { | ||
var conf = (0, import_config.getConfig)(), importance = isSizeMedia && !conf.settings.mediaPropOrder ? getMediaKeyImportance(mediaKey) : defaultMediaImportance; | ||
var importance = isSizeMedia && !(0, import_config.getSetting)("mediaPropOrder") ? getMediaKeyImportance(mediaKey) : defaultMediaImportance; | ||
return !importancesUsed[key] || importance > importancesUsed[key] ? importance : null; | ||
@@ -267,2 +302,3 @@ }; | ||
0 && (module.exports = { | ||
_dmt, | ||
configureMedia, | ||
@@ -272,2 +308,3 @@ getMedia, | ||
getMediaKeyImportance, | ||
getMediaState, | ||
isMediaKey, | ||
@@ -274,0 +311,0 @@ mediaKeyMatch, |
@@ -53,3 +53,3 @@ var __defProp = Object.defineProperty; | ||
), { themeManager, state } = changedThemeState; | ||
process.env.NODE_ENV === "development" && (state?.theme || process.env.TAMAGUI_DISABLE_NO_THEME_WARNING !== "1" && console.warn( | ||
process.env.NODE_ENV === "development" && (state?.theme || process.env.TAMAGUI_DISABLE_NO_THEME_WARNING !== "1" && console.error( | ||
`[tamagui] No theme found, this could be due to an invalid theme name (given theme props ${JSON.stringify( | ||
@@ -113,3 +113,10 @@ props | ||
} | ||
}, useChangeThemeEffect = (props, isRoot = !1, keys, shouldUpdate) => { | ||
}, ogLog = console.error, preventWarnSetState = process.env.NODE_ENV === "production" ? ogLog : ( | ||
// temporary fix for logs, they are harmless in that i've tried to rewrite this | ||
// a few times using the "right" ways, but they are always slower. maybe skill issue | ||
(a, ...args) => { | ||
if (!(typeof a == "string" && a.includes("Cannot update a component"))) | ||
return ogLog(a, ...args); | ||
} | ||
), useChangeThemeEffect = (props, isRoot = !1, keys, shouldUpdate) => { | ||
const { disable } = props, parentManagerId = (0, import_react.useContext)(import_ThemeManagerContext.ThemeManagerIDContext), parentManager = getThemeManager(parentManagerId); | ||
@@ -142,3 +149,3 @@ if (!isRoot && !parentManager || disable) | ||
const selfListenerDispose = themeManager.onChangeTheme((_a, _b, forced) => { | ||
forced && setThemeState((prev) => createState(prev, !0)); | ||
forced && (console.error = preventWarnSetState, setThemeState((prev) => createState(prev, !0)), console.error = ogLog); | ||
}), disposeChangeListener = parentManager?.onChangeTheme( | ||
@@ -154,3 +161,3 @@ (name, manager, forced) => { | ||
keys | ||
}), shouldTryUpdate && setThemeState((prev) => createState(prev, force)); | ||
}), shouldTryUpdate && (console.error = preventWarnSetState, setThemeState((prev) => createState(prev, force)), console.error = ogLog); | ||
}, | ||
@@ -210,3 +217,3 @@ themeManager.id | ||
isNewTheme2 && registerThemeManager(themeManager2); | ||
const isWebSSR = import_constants.isWeb ? !(0, import_config.getConfig)().disableSSR : !1, mounted2 = isWebSSR ? isRoot || prev?.mounted : !0; | ||
const isWebSSR = import_constants.isWeb ? !(0, import_config.getSetting)("disableSSR") : !1, mounted2 = isWebSSR ? isRoot || prev?.mounted : !0; | ||
state2 || (isNewTheme2 ? state2 = themeManager2.state : (state2 = parentManager.state, themeManager2 = parentManager)); | ||
@@ -213,0 +220,0 @@ const wasInversed = prev?.inversed, isInherentlyInversed = isNewTheme2 && state2.scheme !== parentManager?.state.scheme, inversed2 = isRoot ? !1 : isInherentlyInversed ? !0 : isWebSSR ? wasInversed != null ? !1 : null : props.inverse, response = { |
@@ -144,3 +144,3 @@ "use strict"; | ||
}), themeManager = changedThemeState.themeManager, state = changedThemeState.state; | ||
process.env.NODE_ENV === "development" && (state != null && state.theme || process.env.TAMAGUI_DISABLE_NO_THEME_WARNING !== "1" && console.warn("[tamagui] No theme found, this could be due to an invalid theme name (given theme props ".concat(JSON.stringify(props), `). | ||
process.env.NODE_ENV === "development" && (state != null && state.theme || process.env.TAMAGUI_DISABLE_NO_THEME_WARNING !== "1" && console.error("[tamagui] No theme found, this could be due to an invalid theme name (given theme props ".concat(JSON.stringify(props), `). | ||
@@ -192,3 +192,3 @@ If this is intended and you are using Tamagui without any themes, you can disable this warning by setting the environment variable TAMAGUI_DISABLE_NO_THEME_WARNING=1`))); | ||
var outVal = (0, import_createVariable.getVariable)(val); | ||
if (platform !== "web" && import_constants.isIos && !deopt && config.settings.fastSchemeChange && !someParentIsInversed(themeManager) && scheme) { | ||
if (platform !== "web" && import_constants.isIos && !deopt && (0, import_config.getSetting)("fastSchemeChange") && !someParentIsInversed(themeManager) && scheme) { | ||
var oppositeThemeName = name.replace(scheme === "dark" ? "dark" : "light", scheme === "dark" ? "light" : "dark"), oppositeTheme = config.themes[oppositeThemeName], oppositeVal = (0, import_createVariable.getVariable)(oppositeTheme == null ? void 0 : oppositeTheme[keyString]); | ||
@@ -235,3 +235,14 @@ if (oppositeVal) { | ||
} | ||
}, useChangeThemeEffect = function(props) { | ||
}, ogLog = console.error, preventWarnSetState = process.env.NODE_ENV === "production" ? ogLog : ( | ||
// temporary fix for logs, they are harmless in that i've tried to rewrite this | ||
// a few times using the "right" ways, but they are always slower. maybe skill issue | ||
function(a) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) | ||
args[_key - 1] = arguments[_key]; | ||
if (!(typeof a == "string" && a.includes("Cannot update a component"))) | ||
return ogLog.apply(void 0, [ | ||
a | ||
].concat(_to_consumable_array(args))); | ||
} | ||
), useChangeThemeEffect = function(props) { | ||
var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, keys = arguments.length > 2 ? arguments[2] : void 0, shouldUpdate = arguments.length > 3 ? arguments[3] : void 0, getShouldUpdateTheme = function() { | ||
@@ -263,3 +274,3 @@ var manager = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : themeManager, nextState = arguments.length > 1 ? arguments[1] : void 0, prevState = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : state, forceShouldChange = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1, forceUpdate = shouldUpdate == null ? void 0 : shouldUpdate(); | ||
isNewTheme2 && registerThemeManager(themeManager2); | ||
var isWebSSR = import_constants.isWeb ? !(0, import_config.getConfig)().disableSSR : !1, mounted2 = isWebSSR ? isRoot || (prev == null ? void 0 : prev.mounted) : !0; | ||
var isWebSSR = import_constants.isWeb ? !(0, import_config.getSetting)("disableSSR") : !1, mounted2 = isWebSSR ? isRoot || (prev == null ? void 0 : prev.mounted) : !0; | ||
state2 || (isNewTheme2 ? state2 = themeManager2.state : (state2 = parentManager.state, themeManager2 = parentManager)); | ||
@@ -310,5 +321,5 @@ var wasInversed = prev == null ? void 0 : prev.inversed, isInherentlyInversed = isNewTheme2 && state2.scheme !== (parentManager == null ? void 0 : parentManager.state.scheme), inversed2 = isRoot ? !1 : isInherentlyInversed ? !0 : isWebSSR ? wasInversed != null ? !1 : null : props.inverse, response = { | ||
var selfListenerDispose = themeManager.onChangeTheme(function(_a, _b, forced) { | ||
forced && setThemeState(function(prev) { | ||
forced && (console.error = preventWarnSetState, setThemeState(function(prev) { | ||
return createState(prev, !0); | ||
}); | ||
}), console.error = ogLog); | ||
}), disposeChangeListener = parentManager == null ? void 0 : parentManager.onChangeTheme(function(name, manager, forced) { | ||
@@ -323,5 +334,5 @@ var force = forced || (shouldUpdate == null ? void 0 : shouldUpdate()) || props.deopt || props["disable-child-theme"], shouldTryUpdate = force ?? !!(keys != null && keys.length || isNewTheme); | ||
keys | ||
}), shouldTryUpdate && setThemeState(function(prev) { | ||
}), shouldTryUpdate && (console.error = preventWarnSetState, setThemeState(function(prev) { | ||
return createState(prev, force); | ||
}); | ||
}), console.error = ogLog); | ||
}, themeManager.id); | ||
@@ -328,0 +339,0 @@ return function() { |
@@ -20,3 +20,3 @@ var __defProp = Object.defineProperty; | ||
module.exports = __toCommonJS(TamaguiProvider_exports); | ||
var import_constants = require("@tamagui/constants"), import_react = require("react"), import_ComponentContext = require("../contexts/ComponentContext"), import_useDidHydrateOnce = require("../hooks/useDidHydrateOnce"), import_useMedia = require("../hooks/useMedia"), import_ThemeProvider = require("./ThemeProvider"), import_jsx_runtime = require("react/jsx-runtime"); | ||
var import_constants = require("@tamagui/constants"), import_react = require("react"), import_ComponentContext = require("../contexts/ComponentContext"), import_useDidHydrateOnce = require("../hooks/useDidHydrateOnce"), import_useMedia = require("../hooks/useMedia"), import_ThemeProvider = require("./ThemeProvider"), import_config = require("../config"), import_jsx_runtime = require("react/jsx-runtime"); | ||
function TamaguiProvider({ | ||
@@ -42,4 +42,4 @@ children, | ||
{ | ||
themeClassNameOnRoot: themeClassNameOnRoot ?? config?.themeClassNameOnRoot, | ||
disableRootThemeClass: disableRootThemeClass ?? config?.disableRootThemeClass, | ||
themeClassNameOnRoot: themeClassNameOnRoot ?? (0, import_config.getSetting)("themeClassNameOnRoot"), | ||
disableRootThemeClass: disableRootThemeClass ?? (0, import_config.getSetting)("disableRootThemeClass"), | ||
defaultTheme: defaultTheme ?? (config ? Object.keys(config.themes)[0] : ""), | ||
@@ -46,0 +46,0 @@ reset, |
@@ -21,3 +21,3 @@ "use strict"; | ||
module.exports = __toCommonJS(TamaguiProvider_exports); | ||
var import_jsx_runtime = require("react/jsx-runtime"), import_constants = require("@tamagui/constants"), import_react = require("react"), import_ComponentContext = require("../contexts/ComponentContext"), import_useDidHydrateOnce = require("../hooks/useDidHydrateOnce"), import_useMedia = require("../hooks/useMedia"), import_ThemeProvider = require("./ThemeProvider"); | ||
var import_jsx_runtime = require("react/jsx-runtime"), import_constants = require("@tamagui/constants"), import_react = require("react"), import_ComponentContext = require("../contexts/ComponentContext"), import_useDidHydrateOnce = require("../hooks/useDidHydrateOnce"), import_useMedia = require("../hooks/useMedia"), import_ThemeProvider = require("./ThemeProvider"), import_config = require("../config"); | ||
function _array_like_to_array(arr, len) { | ||
@@ -80,4 +80,4 @@ (len == null || len > arr.length) && (len = arr.length); | ||
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ThemeProvider.ThemeProvider, { | ||
themeClassNameOnRoot: themeClassNameOnRoot ?? (config == null ? void 0 : config.themeClassNameOnRoot), | ||
disableRootThemeClass: disableRootThemeClass ?? (config == null ? void 0 : config.disableRootThemeClass), | ||
themeClassNameOnRoot: themeClassNameOnRoot ?? (0, import_config.getSetting)("themeClassNameOnRoot"), | ||
disableRootThemeClass: disableRootThemeClass ?? (0, import_config.getSetting)("disableRootThemeClass"), | ||
defaultTheme: defaultTheme ?? (config ? Object.keys(config.themes)[0] : ""), | ||
@@ -84,0 +84,0 @@ reset, |
@@ -20,6 +20,6 @@ var __defProp = Object.defineProperty; | ||
module.exports = __toCommonJS(ThemeProvider_exports); | ||
var import_constants = require("@tamagui/constants"), import_react = require("react"), import_constants2 = require("../constants/constants"), import_Theme = require("./Theme"), import_jsx_runtime = require("react/jsx-runtime"); | ||
var import_constants = require("@tamagui/constants"), import_react = require("react"), import_constants2 = require("../constants/constants"), import_Theme = require("./Theme"), import_config = require("../config"), import_jsx_runtime = require("react/jsx-runtime"); | ||
const ThemeProvider = (props) => (import_constants.isClient && (0, import_react.useLayoutEffect)(() => { | ||
if (props.disableRootThemeClass) return; | ||
const cn = `${import_constants2.THEME_CLASSNAME_PREFIX}${props.defaultTheme}`, target = props.themeClassNameOnRoot ? document.documentElement : document.body; | ||
const cn = `${import_constants2.THEME_CLASSNAME_PREFIX}${props.defaultTheme}`, target = props.themeClassNameOnRoot ?? (0, import_config.getSetting)("themeClassNameOnRoot") ? document.documentElement : document.body; | ||
return target.classList.add(cn), () => { | ||
@@ -26,0 +26,0 @@ target.classList.remove(cn); |
@@ -21,6 +21,6 @@ "use strict"; | ||
module.exports = __toCommonJS(ThemeProvider_exports); | ||
var import_jsx_runtime = require("react/jsx-runtime"), import_constants = require("@tamagui/constants"), import_react = require("react"), import_constants2 = require("../constants/constants"), import_Theme = require("./Theme"), ThemeProvider = function(props) { | ||
var import_jsx_runtime = require("react/jsx-runtime"), import_constants = require("@tamagui/constants"), import_react = require("react"), import_constants2 = require("../constants/constants"), import_Theme = require("./Theme"), import_config = require("../config"), ThemeProvider = function(props) { | ||
return import_constants.isClient && (0, import_react.useLayoutEffect)(function() { | ||
if (!props.disableRootThemeClass) { | ||
var cn = "".concat(import_constants2.THEME_CLASSNAME_PREFIX).concat(props.defaultTheme), target = props.themeClassNameOnRoot ? document.documentElement : document.body; | ||
var cn = "".concat(import_constants2.THEME_CLASSNAME_PREFIX).concat(props.defaultTheme), _props_themeClassNameOnRoot, target = ((_props_themeClassNameOnRoot = props.themeClassNameOnRoot) !== null && _props_themeClassNameOnRoot !== void 0 ? _props_themeClassNameOnRoot : (0, import_config.getSetting)("themeClassNameOnRoot")) ? document.documentElement : document.body; | ||
return target.classList.add(cn), function() { | ||
@@ -27,0 +27,0 @@ target.classList.remove(cn); |
import { isWeb } from "@tamagui/constants"; | ||
let conf; | ||
const setConfig = (next) => { | ||
const getSetting = (key) => { | ||
if (process.env.NODE_ENV === "development" && !conf) | ||
throw new Error("Haven't called createTamagui yet"); | ||
return conf.settings[key] ?? // @ts-expect-error | ||
conf[key]; | ||
}, setConfig = (next) => { | ||
conf = next; | ||
@@ -52,2 +57,3 @@ }, setConfigFont = (name, font, fontParsed) => { | ||
getFont, | ||
getSetting, | ||
getThemes, | ||
@@ -54,0 +60,0 @@ getToken, |
@@ -43,3 +43,11 @@ import { isWeb } from "@tamagui/constants"; | ||
} | ||
var conf, setConfig = function(next) { | ||
var conf, getSetting = function(key) { | ||
if (process.env.NODE_ENV === "development" && !conf) | ||
throw new Error("Haven't called createTamagui yet"); | ||
var _conf_settings_key; | ||
return (_conf_settings_key = conf.settings[key]) !== null && _conf_settings_key !== void 0 ? _conf_settings_key : ( | ||
// @ts-expect-error | ||
conf[key] | ||
); | ||
}, setConfig = function(next) { | ||
conf = next; | ||
@@ -101,2 +109,3 @@ }, setConfigFont = function(name, font, fontParsed) { | ||
getFont, | ||
getSetting, | ||
getThemes, | ||
@@ -103,0 +112,0 @@ getToken, |
@@ -43,3 +43,7 @@ import { composeRefs } from "@tamagui/compose-refs"; | ||
import { useDidHydrateOnce } from "./hooks/useDidHydrateOnce"; | ||
import { mediaKeyMatch, setMediaShouldUpdate, useMedia } from "./hooks/useMedia"; | ||
import { | ||
getMediaState, | ||
setMediaShouldUpdate, | ||
useMedia | ||
} from "./hooks/useMedia"; | ||
import { useThemeWithState } from "./hooks/useTheme"; | ||
@@ -271,3 +275,3 @@ import { hooks } from "./setupHooks"; | ||
if ("themeInverse" in props && (themeStateProps.inverse = props.themeInverse), "theme" in props && (themeStateProps.name = props.theme), typeof curStateRef.isListeningToTheme == "boolean" && (themeStateProps.shouldUpdate = () => stateRef.current.isListeningToTheme), process.env.NODE_ENV === "development" && debugProp && debugProp !== "profile") { | ||
const name = `${componentName2 || Component?.displayName || Component?.name || "[Unnamed Component]"}`, type = (hasEnterStyle ? "(hasEnter)" : " ") + (isAnimated ? "(animated)" : " ") + (isReactNative ? "(rnw)" : " ") + (shouldAvoidClasses ? "(shouldAvoidClasses)" : " ") + (presenceState?.isPresent === !1 ? "(EXIT)" : ""), dataIs = propsIn["data-is"] || "", banner = `${internalID} ${name}${dataIs ? ` ${dataIs}` : ""} ${type}`; | ||
const name = `${componentName2 || Component?.displayName || Component?.name || "[Unnamed Component]"}`, type = (hasEnterStyle ? "(hasEnter)" : " ") + (isAnimated ? "(animated)" : " ") + (isReactNative ? "(rnw)" : " ") + (shouldAvoidClasses ? "(shouldAvoidClasses)" : " ") + (state.press || state.pressIn ? "(PRESSED)" : " ") + (state.hover ? "(HOVERED)" : " ") + (state.focus ? "(FOCUSED)" : " ") + (presenceState?.isPresent === !1 ? "(EXIT)" : ""), dataIs = propsIn["data-is"] || "", banner = `${internalID} ${name}${dataIs ? ` ${dataIs}` : ""} ${type}`; | ||
if (console.info( | ||
@@ -280,5 +284,5 @@ `%c ${banner} (hydrated: ${isHydrated}) (unmounted: ${state.unmounted})`, | ||
console.groupEnd(); | ||
const stateLog = `${`${state.press || state.pressIn ? " PRESS " : ""}`}${state.hover ? " HOVER " : ""}${state.focus ? " FOCUS" : " "}`, ch = propsIn.children; | ||
const ch = propsIn.children; | ||
let childLog = typeof ch == "string" ? ch.length > 4 ? ch.slice(0, 4) + "..." : ch : ""; | ||
childLog.length && (childLog = `(children: ${childLog})`), console.groupCollapsed(`${childLog}${stateLog}Props:`), log("props in:", propsIn), log("final props:", props), log({ state, staticConfig, elementType, themeStateProps }), log({ contextProps: styledContextProps, overriddenContextProps }), log({ presence, isAnimated, isHOC, hasAnimationProp, useAnimations }), console.groupEnd(); | ||
childLog.length && (childLog = `(children: ${childLog})`), console.groupCollapsed(`${childLog} Props:`), log("props in:", propsIn), log("final props:", props), log({ state, staticConfig, elementType, themeStateProps }), log({ contextProps: styledContextProps, overriddenContextProps }), log({ presence, isAnimated, isHOC, hasAnimationProp, useAnimations }), console.groupEnd(); | ||
} | ||
@@ -400,3 +404,3 @@ } | ||
const { pseudoGroups, mediaGroups } = splitStyles, unPress = () => setStateShallow({ press: !1, pressIn: !1 }); | ||
process.env.NODE_ENV === "development" && useIsomorphicLayoutEffect(() => { | ||
process.env.NODE_ENV === "development" && isWeb && useIsomorphicLayoutEffect(() => { | ||
debugProp && (console.groupCollapsed("Rendered style >"), console.warn(getComputedStyle(stateRef.current.host)), console.groupEnd()); | ||
@@ -432,3 +436,13 @@ }), useEffect(() => { | ||
const runtimePressStyle = !disabled && noClassNames && pseudos?.pressStyle, runtimeFocusStyle = !disabled && noClassNames && pseudos?.focusStyle, runtimeFocusVisibleStyle = !disabled && noClassNames && pseudos?.focusVisibleStyle, attachFocus = !!(runtimePressStyle || runtimeFocusStyle || runtimeFocusVisibleStyle || onFocus || onBlur), attachPress = !!(groupName || runtimePressStyle || onPress || onPressOut || onPressIn || onMouseDown || onMouseUp || onLongPress || onClick || pseudos?.focusVisibleStyle), runtimeHoverStyle = !disabled && noClassNames && pseudos?.hoverStyle, needsHoverState = !!(groupName || runtimeHoverStyle || onHoverIn || onHoverOut), attachHover = isWeb && !!(groupName || needsHoverState || onMouseEnter || onMouseLeave), shouldAttach = !disabled && !props.asChild && !!(attachFocus || attachPress || attachHover || runtimePressStyle || runtimeHoverStyle || runtimeFocusStyle), needsPressState = !!(groupName || runtimePressStyle); | ||
process.env.NODE_ENV === "development" && time && time`events-setup`; | ||
process.env.NODE_ENV === "development" && time && time`events-setup`, process.env.NODE_ENV === "development" && debugProp === "verbose" && log("\u{1FAA9} events()", { | ||
runtimeFocusStyle, | ||
runtimePressStyle, | ||
runtimeHoverStyle, | ||
runtimeFocusVisibleStyle, | ||
attachPress, | ||
attachFocus, | ||
attachHover, | ||
shouldAttach, | ||
needsHoverState | ||
}); | ||
const events = shouldAttach ? { | ||
@@ -783,7 +797,2 @@ onPressOut: attachPress ? (e) => { | ||
} | ||
function getMediaState(mediaGroups, layout) { | ||
return Object.fromEntries( | ||
[...mediaGroups].map((mediaKey) => [mediaKey, mediaKeyMatch(mediaKey, layout)]) | ||
); | ||
} | ||
const fromPx = (val) => typeof val != "string" ? val : +val.replace("px", ""), isDisabled = (props) => props.disabled || props.accessibilityState?.disabled || props["aria-disabled"] || props.accessibilityDisabled || !1, subscribeToContextGroup = ({ | ||
@@ -790,0 +799,0 @@ disabled = !1, |
@@ -20,3 +20,3 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
import { useDidHydrateOnce } from "./hooks/useDidHydrateOnce"; | ||
import { mediaKeyMatch, setMediaShouldUpdate, useMedia } from "./hooks/useMedia"; | ||
import { getMediaState, setMediaShouldUpdate, useMedia } from "./hooks/useMedia"; | ||
import { useThemeWithState } from "./hooks/useTheme"; | ||
@@ -529,3 +529,3 @@ import { hooks } from "./setupHooks"; | ||
}), themeStateProps.deopt = willBeAnimated, process.env.NODE_ENV === "development" && debugProp && debugProp !== "profile") { | ||
var name = "".concat(componentName2 || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]"), type = (hasEnterStyle ? "(hasEnter)" : " ") + (isAnimated ? "(animated)" : " ") + (isReactNative ? "(rnw)" : " ") + (shouldAvoidClasses ? "(shouldAvoidClasses)" : " ") + ((presenceState == null ? void 0 : presenceState.isPresent) === !1 ? "(EXIT)" : ""), dataIs = propsIn["data-is"] || "", banner = "".concat(internalID, " ").concat(name).concat(dataIs ? " ".concat(dataIs) : "", " ").concat(type); | ||
var name = "".concat(componentName2 || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]"), type = (hasEnterStyle ? "(hasEnter)" : " ") + (isAnimated ? "(animated)" : " ") + (isReactNative ? "(rnw)" : " ") + (shouldAvoidClasses ? "(shouldAvoidClasses)" : " ") + (state.press || state.pressIn ? "(PRESSED)" : " ") + (state.hover ? "(HOVERED)" : " ") + (state.focus ? "(FOCUSED)" : " ") + ((presenceState == null ? void 0 : presenceState.isPresent) === !1 ? "(EXIT)" : ""), dataIs = propsIn["data-is"] || "", banner = "".concat(internalID, " ").concat(name).concat(dataIs ? " ".concat(dataIs) : "", " ").concat(type); | ||
if (console.info("%c ".concat(banner, " (hydrated: ").concat(isHydrated, ") (unmounted: ").concat(state.unmounted, ")"), "background: green; color: white;"), isServer) | ||
@@ -541,4 +541,4 @@ log({ | ||
console.groupEnd(); | ||
var pressLog = "".concat(state.press || state.pressIn ? " PRESS " : ""), stateLog = "".concat(pressLog).concat(state.hover ? " HOVER " : "").concat(state.focus ? " FOCUS" : " "), ch = propsIn.children, childLog = typeof ch == "string" ? ch.length > 4 ? ch.slice(0, 4) + "..." : ch : ""; | ||
childLog.length && (childLog = "(children: ".concat(childLog, ")")), console.groupCollapsed("".concat(childLog).concat(stateLog, "Props:")), log("props in:", propsIn), log("final props:", props), log({ | ||
var ch = propsIn.children, childLog = typeof ch == "string" ? ch.length > 4 ? ch.slice(0, 4) + "..." : ch : ""; | ||
childLog.length && (childLog = "(children: ".concat(childLog, ")")), console.groupCollapsed("".concat(childLog, " Props:")), log("props in:", propsIn), log("final props:", props), log({ | ||
state, | ||
@@ -650,3 +650,3 @@ staticConfig, | ||
}; | ||
process.env.NODE_ENV === "development" && useIsomorphicLayoutEffect(function() { | ||
process.env.NODE_ENV === "development" && isWeb && useIsomorphicLayoutEffect(function() { | ||
debugProp && (console.groupCollapsed("Rendered style >"), console.warn(getComputedStyle(stateRef.current.host)), console.groupEnd()); | ||
@@ -686,3 +686,13 @@ }), useEffect(function() { | ||
var runtimePressStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.pressStyle), runtimeFocusStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.focusStyle), runtimeFocusVisibleStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.focusVisibleStyle), attachFocus = !!(runtimePressStyle || runtimeFocusStyle || runtimeFocusVisibleStyle || onFocus || onBlur), attachPress = !!(groupName || runtimePressStyle || onPress || onPressOut || onPressIn || onMouseDown || onMouseUp || onLongPress || onClick || pseudos != null && pseudos.focusVisibleStyle), runtimeHoverStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.hoverStyle), needsHoverState = !!(groupName || runtimeHoverStyle || onHoverIn || onHoverOut), attachHover = isWeb && !!(groupName || needsHoverState || onMouseEnter || onMouseLeave), shouldAttach = !disabled && !props.asChild && !!(attachFocus || attachPress || attachHover || runtimePressStyle || runtimeHoverStyle || runtimeFocusStyle), needsPressState = !!(groupName || runtimePressStyle); | ||
process.env.NODE_ENV === "development" && time && time(_templateObject14()); | ||
process.env.NODE_ENV === "development" && time && time(_templateObject14()), process.env.NODE_ENV === "development" && debugProp === "verbose" && log("\u{1FAA9} events()", { | ||
runtimeFocusStyle, | ||
runtimePressStyle, | ||
runtimeHoverStyle, | ||
runtimeFocusVisibleStyle, | ||
attachPress, | ||
attachFocus, | ||
attachHover, | ||
shouldAttach, | ||
needsHoverState | ||
}); | ||
var events = shouldAttach ? _object_spread(_object_spread_props(_object_spread({ | ||
@@ -1020,10 +1030,2 @@ onPressOut: attachPress ? function(e) { | ||
} | ||
function getMediaState(mediaGroups, layout) { | ||
return Object.fromEntries(_to_consumable_array(mediaGroups).map(function(mediaKey) { | ||
return [ | ||
mediaKey, | ||
mediaKeyMatch(mediaKey, layout) | ||
]; | ||
})); | ||
} | ||
var fromPx = function(val) { | ||
@@ -1030,0 +1032,0 @@ return typeof val != "string" ? val : +val.replace("px", ""); |
@@ -121,3 +121,3 @@ import { isWeb } from "@tamagui/constants"; | ||
}, getNewCSS = (opts) => getCSS({ ...opts, sinceLastCall: !0 }); | ||
let defaultFontName = configIn.defaultFont || // uses font named "body" if present for compat | ||
let defaultFontName = (configIn.settings?.defaultFont ?? configIn.defaultFont) || // uses font named "body" if present for compat | ||
configIn.fonts && ("body" in configIn.fonts ? "body" : ""); | ||
@@ -133,3 +133,3 @@ !defaultFontName && configIn.fonts && (defaultFontName = Object.keys(configIn.fonts)[0]), defaultFontName?.[0] === "$" && (defaultFontName = defaultFontName.slice(1)); | ||
unset: { | ||
fontFamily: configIn.defaultFont ? defaultFont : void 0, | ||
fontFamily: defaultFontName ? defaultFont : void 0, | ||
...configIn.unset | ||
@@ -158,3 +158,3 @@ }, | ||
}; | ||
return configureMedia(config), setConfig(config), createdConfigs.set(config, !0), configListeners.size && (configListeners.forEach((cb) => cb(config)), configListeners.clear()), process.env.NODE_ENV === "development" && (process.env.DEBUG?.startsWith("tamagui") && console.info("Tamagui config:", config), globalThis.Tamagui || (globalThis.Tamagui = Tamagui)), config; | ||
return setConfig(config), configureMedia(config), createdConfigs.set(config, !0), configListeners.size && (configListeners.forEach((cb) => cb(config)), configListeners.clear()), process.env.NODE_ENV === "development" && (process.env.DEBUG?.startsWith("tamagui") && console.info("Tamagui config:", config), globalThis.Tamagui || (globalThis.Tamagui = Tamagui)), config; | ||
} | ||
@@ -161,0 +161,0 @@ function getThemesDeduped(themes) { |
@@ -101,2 +101,3 @@ import { isWeb } from "@tamagui/constants"; | ||
function createTamagui(configIn) { | ||
var _configIn_settings; | ||
if (createdConfigs.has(configIn)) | ||
@@ -227,3 +228,3 @@ return configIn; | ||
})); | ||
}, defaultFontName = configIn.defaultFont || // uses font named "body" if present for compat | ||
}, _configIn_settings_defaultFont, defaultFontSetting = (_configIn_settings_defaultFont = (_configIn_settings = configIn.settings) === null || _configIn_settings === void 0 ? void 0 : _configIn_settings.defaultFont) !== null && _configIn_settings_defaultFont !== void 0 ? _configIn_settings_defaultFont : configIn.defaultFont, defaultFontName = defaultFontSetting || // uses font named "body" if present for compat | ||
configIn.fonts && ("body" in configIn.fonts ? "body" : ""); | ||
@@ -239,3 +240,3 @@ !defaultFontName && configIn.fonts && (defaultFontName = Object.keys(configIn.fonts)[0]), (defaultFontName == null ? void 0 : defaultFontName[0]) === "$" && (defaultFontName = defaultFontName.slice(1)); | ||
unset: _object_spread({ | ||
fontFamily: configIn.defaultFont ? defaultFont : void 0 | ||
fontFamily: defaultFontName ? defaultFont : void 0 | ||
}, configIn.unset), | ||
@@ -266,3 +267,3 @@ settings: _object_spread({ | ||
}); | ||
if (configureMedia(config), setConfig(config), createdConfigs.set(config, !0), configListeners.size && (configListeners.forEach(function(cb) { | ||
if (setConfig(config), configureMedia(config), createdConfigs.set(config, !0), configListeners.size && (configListeners.forEach(function(cb) { | ||
return cb(config); | ||
@@ -269,0 +270,0 @@ }), configListeners.clear()), process.env.NODE_ENV === "development") { |
@@ -1,2 +0,2 @@ | ||
import { getConfig } from "../config"; | ||
import { getConfig, getSetting } from "../config"; | ||
import { mediaObjectToString } from "../hooks/useMedia"; | ||
@@ -16,3 +16,3 @@ import { getGroupPropParts } from "./getGroupPropParts"; | ||
groupMediaKey = groupInfo?.media, isGroup && (containerName = mediaName); | ||
const name = (isGroup ? "group_" : "") + mediaName, selectorStart = styleInner.indexOf(":root"), selectorEnd = styleInner.lastIndexOf("{"), selector = styleInner.slice(selectorStart, selectorEnd), precedenceSpace = conf.themeClassNameOnRoot && isTheme ? "" : " ", pseudoSelectorName = groupInfo.pseudo ? groupPseudoToPseudoCSSMap[groupInfo.pseudo] || groupInfo.pseudo : void 0, pseudoSelector = pseudoSelectorName ? `:${pseudoSelectorName}` : "", presedencePrefix = `:root${precedenceImportancePrefix}${precedenceSpace}`, mediaSelector = `.t_${name}${pseudoSelector}`, nextSelector = `${presedencePrefix}${mediaSelector} ${selector.replace( | ||
const name = (isGroup ? "group_" : "") + mediaName, selectorStart = styleInner.indexOf(":root"), selectorEnd = styleInner.lastIndexOf("{"), selector = styleInner.slice(selectorStart, selectorEnd), precedenceSpace = getSetting("themeClassNameOnRoot") && isTheme ? "" : " ", pseudoSelectorName = groupInfo.pseudo ? groupPseudoToPseudoCSSMap[groupInfo.pseudo] || groupInfo.pseudo : void 0, pseudoSelector = pseudoSelectorName ? `:${pseudoSelectorName}` : "", presedencePrefix = `:root${precedenceImportancePrefix}${precedenceSpace}`, mediaSelector = `.t_${name}${pseudoSelector}`, nextSelector = `${presedencePrefix}${mediaSelector} ${selector.replace( | ||
":root", | ||
@@ -19,0 +19,0 @@ "" |
@@ -1,2 +0,2 @@ | ||
import { getConfig } from "../config"; | ||
import { getConfig, getSetting } from "../config"; | ||
import { mediaObjectToString } from "../hooks/useMedia"; | ||
@@ -56,3 +56,3 @@ import { getGroupPropParts } from "./getGroupPropParts"; | ||
groupMediaKey = groupInfo == null ? void 0 : groupInfo.media, isGroup && (containerName = mediaName); | ||
var name = (isGroup ? "group_" : "") + mediaName, selectorStart = styleInner.indexOf(":root"), selectorEnd = styleInner.lastIndexOf("{"), selector = styleInner.slice(selectorStart, selectorEnd), precedenceSpace = conf.themeClassNameOnRoot && isTheme ? "" : " ", pseudoSelectorName = groupInfo.pseudo ? groupPseudoToPseudoCSSMap[groupInfo.pseudo] || groupInfo.pseudo : void 0, pseudoSelector = pseudoSelectorName ? ":".concat(pseudoSelectorName) : "", presedencePrefix = ":root".concat(precedenceImportancePrefix).concat(precedenceSpace), mediaSelector = ".t_".concat(name).concat(pseudoSelector), nextSelector = "".concat(presedencePrefix).concat(mediaSelector, " ").concat(selector.replace(":root", "")); | ||
var name = (isGroup ? "group_" : "") + mediaName, selectorStart = styleInner.indexOf(":root"), selectorEnd = styleInner.lastIndexOf("{"), selector = styleInner.slice(selectorStart, selectorEnd), precedenceSpace = getSetting("themeClassNameOnRoot") && isTheme ? "" : " ", pseudoSelectorName = groupInfo.pseudo ? groupPseudoToPseudoCSSMap[groupInfo.pseudo] || groupInfo.pseudo : void 0, pseudoSelector = pseudoSelectorName ? ":".concat(pseudoSelectorName) : "", presedencePrefix = ":root".concat(precedenceImportancePrefix).concat(precedenceSpace), mediaSelector = ".t_".concat(name).concat(pseudoSelector), nextSelector = "".concat(presedencePrefix).concat(mediaSelector, " ").concat(selector.replace(":root", "")); | ||
styleRule = styleInner.replace(selector, nextSelector); | ||
@@ -59,0 +59,0 @@ } else |
@@ -13,3 +13,3 @@ import { startTransition } from "react"; | ||
return prev || next; | ||
if (process.env.NODE_ENV === "development" && debug && (console.warn("setStateShallow CHANGE", { prev, next }), debug === "break")) | ||
if (process.env.NODE_ENV === "development" && debug && (console.info("setStateShallow CHANGE", { prev, next }), debug === "break")) | ||
debugger; | ||
@@ -16,0 +16,0 @@ return { ...prev, ...next }; |
@@ -37,3 +37,3 @@ import { startTransition } from "react"; | ||
return prev || next; | ||
if (process.env.NODE_ENV === "development" && debug && (console.warn("setStateShallow CHANGE", { | ||
if (process.env.NODE_ENV === "development" && debug && (console.info("setStateShallow CHANGE", { | ||
prev, | ||
@@ -40,0 +40,0 @@ next |
@@ -51,2 +51,3 @@ import { | ||
import { transformsToString } from "./transformsToString"; | ||
const consoleGroupCollapsed = isWeb ? console.groupCollapsed : console.info; | ||
let conf; | ||
@@ -94,3 +95,3 @@ const PROP_SPLIT = "-"; | ||
}; | ||
process.env.NODE_ENV === "development" && debug && debug !== "profile" && isClient && (console.groupCollapsed("getSplitStyles (collapsed)"), log({ | ||
process.env.NODE_ENV === "development" && debug && debug !== "profile" && isClient && (consoleGroupCollapsed("getSplitStyles (collapsed)"), log({ | ||
props, | ||
@@ -222,3 +223,3 @@ staticConfig, | ||
isHOC && parentVariants && keyInit in parentVariants || inlineProps?.has(keyInit), parentVariant = parentVariants?.[keyInit], isHOCShouldPassThrough = !!(isHOC && (isShorthand || isValidStyleKeyInit || isMediaOrPseudo || parentVariant || keyInit in skipProps)), shouldPassThrough = shouldPassProp || isHOCShouldPassThrough; | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupEnd(), console.groupEnd(), console.groupCollapsed( | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupEnd(), console.groupEnd(), consoleGroupCollapsed( | ||
` \u{1F511} ${keyOg}${keyInit !== keyOg ? ` (shorthand for ${keyInit})` : ""} ${shouldPassThrough ? "(pass)" : ""}` | ||
@@ -248,3 +249,3 @@ ), log({ isVariant, valInit, shouldPassProp }), isClient && log({ | ||
if (process.env.NODE_ENV === "development" && debug === "verbose") { | ||
console.groupCollapsed(" \u{1F4A0} expanded", keyInit, valInit); | ||
consoleGroupCollapsed(" \u{1F4A0} expanded", keyInit, valInit); | ||
try { | ||
@@ -259,3 +260,2 @@ !isServer && isDevTools && (log({ | ||
isHOCShouldPassThrough, | ||
theme, | ||
usedKeys: { ...usedKeys }, | ||
@@ -281,3 +281,3 @@ curProps: { ...styleState.curProps } | ||
if (isPseudo = key in validPseudoKeys, isMedia = !isPseudo && !isValidStyleKeyInit && isMediaKey(key), isMediaOrPseudo = !!(isMedia || isPseudo), isVariant = variants && key in variants, (inlineProps?.has(key) || process.env.IS_STATIC === "is_static" && inlineWhenUnflattened?.has(key)) && (viewProps[key] = props[key] ?? val), styleProps.noExpand && isPseudo || isHOC && (isMediaOrPseudo || parentStaticConfig?.variants?.[keyInit])) { | ||
passDownProp(viewProps, key, val, isMediaOrPseudo), process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed(` - passing down prop ${key}`), log({ val, after: { ...viewProps[key] } }), console.groupEnd()); | ||
passDownProp(viewProps, key, val, isMediaOrPseudo), process.env.NODE_ENV === "development" && debug === "verbose" && (consoleGroupCollapsed(` - passing down prop ${key}`), log({ val, after: { ...viewProps[key] } }), console.groupEnd()); | ||
continue; | ||
@@ -301,3 +301,3 @@ } | ||
const pseudoStyles = getStyleAtomic(pseudoStyleObject, descriptor); | ||
process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed("pseudo (classes)", key), log({ pseudoStyleObject, pseudoStyles }), console.groupEnd()); | ||
process.env.NODE_ENV === "development" && debug === "verbose" && (consoleGroupCollapsed("pseudo (classes)", key), log({ pseudoStyleObject, pseudoStyles }), console.groupEnd()); | ||
for (const psuedoStyle of pseudoStyles) { | ||
@@ -318,3 +318,3 @@ const fullKey = `${psuedoStyle[StyleObjectProperty]}${PROP_SPLIT}${descriptor.name}`; | ||
let isDisabled = componentState[descriptorKey] === !1; | ||
isExit && (isDisabled = !styleProps.isExiting), isEnter && componentState.unmounted === !1 && (isDisabled = !0), process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed("pseudo", key, { isDisabled }), log({ pseudoStyleObject, isDisabled, descriptor, componentState }), console.groupEnd()); | ||
isExit && (isDisabled = !styleProps.isExiting), isEnter && componentState.unmounted === !1 && (isDisabled = !0), process.env.NODE_ENV === "development" && debug === "verbose" && (consoleGroupCollapsed("pseudo", key, { isDisabled }), log({ pseudoStyleObject, isDisabled, descriptor, componentState }), console.groupEnd()); | ||
const importance = descriptor.priority; | ||
@@ -418,3 +418,3 @@ for (const pkey in pseudoStyleObject) { | ||
if (!groupContext) { | ||
process.env.NODE_ENV === "development" && debug && console.warn(`No parent with group prop, skipping styles: ${groupName}`); | ||
process.env.NODE_ENV === "development" && debug && log(`No parent with group prop, skipping styles: ${groupName}`); | ||
continue; | ||
@@ -427,9 +427,13 @@ } | ||
let isActive = mediaState2?.[groupMediaKey]; | ||
if (!mediaState2 && groupContext.layout && (isActive = mediaKeyMatch(groupMediaKey, groupContext.layout)), !isActive) continue; | ||
if (!mediaState2 && groupContext.layout && (isActive = mediaKeyMatch(groupMediaKey, groupContext.layout)), process.env.NODE_ENV === "development" && debug === "verbose" && log(` \u{1F3D8}\uFE0F GROUP media ${groupMediaKey} active? ${isActive}`), !isActive) continue; | ||
importanceBump = 2; | ||
} | ||
if (groupPseudoKey) { | ||
if (pseudoGroups ||= /* @__PURE__ */ new Set(), pseudoGroups.add(groupName), !(componentGroupState || // fallback to context initially | ||
context.groups.state[groupName]).pseudo?.[groupPseudoKey]) continue; | ||
importanceBump = pseudoPriorities[groupPseudoKey]; | ||
pseudoGroups ||= /* @__PURE__ */ new Set(), pseudoGroups.add(groupName); | ||
const isActive = (componentGroupState || // fallback to context initially | ||
context.groups.state[groupName]).pseudo?.[groupPseudoKey], priority = pseudoPriorities[groupPseudoKey]; | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && log( | ||
` \u{1F3D8}\uFE0F GROUP pseudo ${groupMediaKey} active? ${isActive}, priority ${priority}` | ||
), !isActive) continue; | ||
importanceBump = priority; | ||
} | ||
@@ -449,3 +453,4 @@ } | ||
mediaState[mediaKeyShort], | ||
importanceBump | ||
importanceBump, | ||
debug | ||
), key === "fontFamily" && (styleState.fontFamily = mediaStyle.fontFamily); | ||
@@ -494,3 +499,3 @@ } | ||
} | ||
process.env.NODE_ENV === "development" && props.debug === "verbose" && (console.groupEnd(), console.groupCollapsed("\u{1F539} getSplitStyles final style object"), console.info(styleState.style), console.groupEnd()), (shouldRetain || process.env.IS_STATIC !== "is_static") && (styleState.style = retainedStyles || {}); | ||
process.env.NODE_ENV === "development" && props.debug === "verbose" && (console.groupEnd(), consoleGroupCollapsed("\u{1F539} getSplitStyles final style object"), console.info(styleState.style), console.groupEnd()), (shouldRetain || process.env.IS_STATIC !== "is_static") && (styleState.style = retainedStyles || {}); | ||
} | ||
@@ -500,3 +505,3 @@ if (transforms) | ||
if (!transforms[namespace]) { | ||
process.env.NODE_ENV === "development" && console.warn("Error no transform", transforms, namespace); | ||
process.env.NODE_ENV === "development" && log("Error no transform", transforms, namespace); | ||
continue; | ||
@@ -576,3 +581,3 @@ } | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && isDevTools) { | ||
console.groupCollapsed("\u{1F539} getSplitStyles ===>"); | ||
consoleGroupCollapsed("\u{1F539} getSplitStyles ===>"); | ||
try { | ||
@@ -682,3 +687,3 @@ const logs = { | ||
} | ||
function mergeMediaByImportance(styleState, mediaKey, key, value, importancesUsed, isSizeMedia, importanceBump) { | ||
function mergeMediaByImportance(styleState, mediaKey, key, value, importancesUsed, isSizeMedia, importanceBump, debugProp) { | ||
let importance = getMediaImportanceIfMoreImportant( | ||
@@ -690,3 +695,15 @@ mediaKey, | ||
); | ||
return importanceBump && (importance = (importance || 0) + importanceBump), importance === null ? !1 : (importancesUsed[key] = importance, mergeStyle(styleState, key, value), !0); | ||
if (importanceBump && (importance = (importance || 0) + importanceBump), process.env.NODE_ENV === "development" && debugProp === "verbose" && log( | ||
`mergeMediaByImportance ${key} importance existing ${importancesUsed[key]} next ${importance}` | ||
), importance === null) | ||
return !1; | ||
if (importancesUsed[key] = importance, key in pseudoDescriptors) { | ||
const descriptor = pseudoDescriptors[key], descriptorKey = descriptor.stateKey || descriptor.name; | ||
if (styleState.componentState[descriptorKey] === !1) | ||
return !1; | ||
for (const subKey in value) | ||
mergeStyle(styleState, subKey, value[subKey]); | ||
} else | ||
mergeStyle(styleState, key, value); | ||
return !0; | ||
} | ||
@@ -693,0 +710,0 @@ function normalizeStyle(style) { |
@@ -99,3 +99,3 @@ import { currentPlatform, isAndroid, isClient, isServer, isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants"; | ||
} | ||
var conf, PROP_SPLIT = "-"; | ||
var consoleGroupCollapsed = isWeb ? console.groupCollapsed : console.info, conf, PROP_SPLIT = "-"; | ||
function isValidStyleKey(key, staticConfig) { | ||
@@ -130,3 +130,3 @@ var _staticConfig_accept, validStyleProps = staticConfig.validStyles || (staticConfig.isText || staticConfig.isInput ? stylePropsText : validStyles); | ||
}; | ||
process.env.NODE_ENV === "development" && debug && debug !== "profile" && isClient && (console.groupCollapsed("getSplitStyles (collapsed)"), log({ | ||
process.env.NODE_ENV === "development" && debug && debug !== "profile" && isClient && (consoleGroupCollapsed("getSplitStyles (collapsed)"), log({ | ||
props, | ||
@@ -187,3 +187,3 @@ staticConfig, | ||
isHOC && parentVariants && keyInit in parentVariants || (inlineProps == null ? void 0 : inlineProps.has(keyInit)), parentVariant = parentVariants == null ? void 0 : parentVariants[keyInit], isHOCShouldPassThrough = !!(isHOC && (isShorthand || isValidStyleKeyInit || isMediaOrPseudo1 || parentVariant || keyInit in skipProps)), shouldPassThrough = shouldPassProp || isHOCShouldPassThrough; | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupEnd(), console.groupEnd(), console.groupCollapsed(" \u{1F511} ".concat(keyOg).concat(keyInit !== keyOg ? " (shorthand for ".concat(keyInit, ")") : "", " ").concat(shouldPassThrough ? "(pass)" : "")), log({ | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupEnd(), console.groupEnd(), consoleGroupCollapsed(" \u{1F511} ".concat(keyOg).concat(keyInit !== keyOg ? " (shorthand for ".concat(keyInit, ")") : "", " ").concat(shouldPassThrough ? "(pass)" : "")), log({ | ||
isVariant, | ||
@@ -215,3 +215,3 @@ valInit, | ||
if (process.env.NODE_ENV === "development" && debug === "verbose") { | ||
console.groupCollapsed(" \u{1F4A0} expanded", keyInit, valInit); | ||
consoleGroupCollapsed(" \u{1F4A0} expanded", keyInit, valInit); | ||
try { | ||
@@ -226,3 +226,2 @@ !isServer && isDevTools && (log({ | ||
isHOCShouldPassThrough, | ||
theme, | ||
usedKeys: _object_spread({}, usedKeys), | ||
@@ -250,3 +249,3 @@ curProps: _object_spread({}, styleState.curProps) | ||
if (shouldPassThrough1) { | ||
passDownProp(viewProps, key, val, isMediaOrPseudo1), process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed(" - passing down prop ".concat(key)), log({ | ||
passDownProp(viewProps, key, val, isMediaOrPseudo1), process.env.NODE_ENV === "development" && debug === "verbose" && (consoleGroupCollapsed(" - passing down prop ".concat(key)), log({ | ||
val, | ||
@@ -271,3 +270,3 @@ after: _object_spread({}, viewProps[key]) | ||
var pseudoStyles = getStyleAtomic(pseudoStyleObject, descriptor); | ||
process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed("pseudo (classes)", key), log({ | ||
process.env.NODE_ENV === "development" && debug === "verbose" && (consoleGroupCollapsed("pseudo (classes)", key), log({ | ||
pseudoStyleObject, | ||
@@ -295,3 +294,3 @@ pseudoStyles | ||
var descriptorKey = descriptor.stateKey || descriptor.name, isDisabled = componentState[descriptorKey] === !1; | ||
isExit && (isDisabled = !styleProps.isExiting), isEnter && componentState.unmounted === !1 && (isDisabled = !0), process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed("pseudo", key, { | ||
isExit && (isDisabled = !styleProps.isExiting), isEnter && componentState.unmounted === !1 && (isDisabled = !0), process.env.NODE_ENV === "development" && debug === "verbose" && (consoleGroupCollapsed("pseudo", key, { | ||
isDisabled | ||
@@ -396,3 +395,3 @@ }), log({ | ||
if (!groupContext) { | ||
process.env.NODE_ENV === "development" && debug && console.warn("No parent with group prop, skipping styles: ".concat(groupName)); | ||
process.env.NODE_ENV === "development" && debug && log("No parent with group prop, skipping styles: ".concat(groupName)); | ||
continue; | ||
@@ -404,3 +403,3 @@ } | ||
var mediaState1 = componentGroupState == null ? void 0 : componentGroupState.media, isActive = mediaState1 == null ? void 0 : mediaState1[groupMediaKey]; | ||
if (!mediaState1 && groupContext.layout && (isActive = mediaKeyMatch(groupMediaKey, groupContext.layout)), !isActive) continue; | ||
if (!mediaState1 && groupContext.layout && (isActive = mediaKeyMatch(groupMediaKey, groupContext.layout)), process.env.NODE_ENV === "development" && debug === "verbose" && log(" \u{1F3D8}\uFE0F GROUP media ".concat(groupMediaKey, " active? ").concat(isActive)), !isActive) continue; | ||
importanceBump = 2; | ||
@@ -411,5 +410,4 @@ } | ||
var componentGroupPseudoState = (componentGroupState || // fallback to context initially | ||
context.groups.state[groupName]).pseudo, isActive1 = componentGroupPseudoState == null ? void 0 : componentGroupPseudoState[groupPseudoKey]; | ||
if (!isActive1) continue; | ||
var priority1 = pseudoPriorities[groupPseudoKey]; | ||
context.groups.state[groupName]).pseudo, isActive1 = componentGroupPseudoState == null ? void 0 : componentGroupPseudoState[groupPseudoKey], priority1 = pseudoPriorities[groupPseudoKey]; | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && log(" \u{1F3D8}\uFE0F GROUP pseudo ".concat(groupMediaKey, " active? ").concat(isActive1, ", priority ").concat(priority1)), !isActive1) continue; | ||
importanceBump = priority1; | ||
@@ -424,3 +422,3 @@ } | ||
} | ||
(_styleState1 = styleState).style || (_styleState1.style = {}), mergeMediaByImportance(styleState, mediaKeyShort, subKey, mediaStyle1[subKey], usedKeys, mediaState[mediaKeyShort], importanceBump), key === "fontFamily" && (styleState.fontFamily = mediaStyle1.fontFamily); | ||
(_styleState1 = styleState).style || (_styleState1.style = {}), mergeMediaByImportance(styleState, mediaKeyShort, subKey, mediaStyle1[subKey], usedKeys, mediaState[mediaKeyShort], importanceBump, debug), key === "fontFamily" && (styleState.fontFamily = mediaStyle1.fontFamily); | ||
} | ||
@@ -566,3 +564,3 @@ } | ||
if (process.env.NODE_ENV === "development" && debug === "verbose" && isDevTools) { | ||
console.groupCollapsed("\u{1F539} getSplitStyles ===>"); | ||
consoleGroupCollapsed("\u{1F539} getSplitStyles ===>"); | ||
try { | ||
@@ -681,5 +679,15 @@ var logs = _object_spread_props(_object_spread({}, result), { | ||
} | ||
function mergeMediaByImportance(styleState, mediaKey, key, value, importancesUsed, isSizeMedia, importanceBump) { | ||
function mergeMediaByImportance(styleState, mediaKey, key, value, importancesUsed, isSizeMedia, importanceBump, debugProp) { | ||
var importance = getMediaImportanceIfMoreImportant(mediaKey, key, importancesUsed, isSizeMedia); | ||
return importanceBump && (importance = (importance || 0) + importanceBump), importance === null ? !1 : (importancesUsed[key] = importance, mergeStyle(styleState, key, value), !0); | ||
if (importanceBump && (importance = (importance || 0) + importanceBump), process.env.NODE_ENV === "development" && debugProp === "verbose" && log("mergeMediaByImportance ".concat(key, " importance existing ").concat(importancesUsed[key], " next ").concat(importance)), importance === null) | ||
return !1; | ||
if (importancesUsed[key] = importance, key in pseudoDescriptors) { | ||
var descriptor = pseudoDescriptors[key], descriptorKey = descriptor.stateKey || descriptor.name, isDisabled = styleState.componentState[descriptorKey] === !1; | ||
if (isDisabled) | ||
return !1; | ||
for (var subKey in value) | ||
mergeStyle(styleState, subKey, value[subKey]); | ||
} else | ||
mergeStyle(styleState, key, value); | ||
return !0; | ||
} | ||
@@ -686,0 +694,0 @@ function normalizeStyle(style) { |
@@ -5,2 +5,3 @@ import { simpleHash } from "@tamagui/helpers"; | ||
import { tokensValueToVariable } from "./registerCSSVariable"; | ||
import { getSetting } from "../config"; | ||
function getThemeCSSRules(props) { | ||
@@ -21,3 +22,3 @@ const cssRuleSets = []; | ||
if (hasDarkLight) { | ||
const maxDepth = config.maxDarkLightNesting ?? 3; | ||
const maxDepth = getSetting("maxDarkLightNesting") ?? 3; | ||
for (const subName of names) { | ||
@@ -45,4 +46,4 @@ const isDark = isDarkBase || subName.startsWith("dark_"), isLight = !isDark && (isLightBase || subName.startsWith("light_")); | ||
} | ||
const selectors = [...selectorsSet].sort((a, b) => a.localeCompare(b)), css = `${selectors.map((x) => `:root${isBaseTheme(x) && config.themeClassNameOnRoot ? "" : " "}${x}`).join(", ")} {${vars}}`; | ||
if (cssRuleSets.push(css), config.shouldAddPrefersColorThemes) { | ||
const selectors = [...selectorsSet].sort((a, b) => a.localeCompare(b)), css = `${selectors.map((x) => `:root${isBaseTheme(x) && getSetting("themeClassNameOnRoot") ? "" : " "}${x}`).join(", ")} {${vars}}`; | ||
if (cssRuleSets.push(css), getSetting("shouldAddPrefersColorThemes")) { | ||
const bgString = theme.background ? `background:${variableToString(theme.background)};` : "", fgString = theme.color ? `color:${variableToString(theme.color)}` : "", bodyRules = `body{${bgString}${fgString}}`, isDark = themeName.startsWith("dark"), baseName = isDark ? "dark" : "light", themeRules = `${selectors.map((x) => { | ||
@@ -58,4 +59,5 @@ if (x == darkSelector || x === lightSelector) return ":root"; | ||
} | ||
if (config.selectionStyles) { | ||
const rules = config.selectionStyles(theme); | ||
const selectionStyles = getSetting("selectionStyles"); | ||
if (selectionStyles) { | ||
const rules = selectionStyles(theme); | ||
if (rules) { | ||
@@ -62,0 +64,0 @@ const selectionSelectors = baseSelectors.map((s) => `${s} ::selection`).join(", "), styles = Object.entries(rules).flatMap( |
@@ -0,4 +1,11 @@ | ||
import { _dmt } from "../hooks/useMedia"; | ||
function log(...args) { | ||
if (process.env.NODE_ENV !== "production") | ||
return console.info(...args); | ||
if (process.env.NODE_ENV !== "production") { | ||
_dmt(!0); | ||
try { | ||
return console.info(...args); | ||
} finally { | ||
_dmt(!1); | ||
} | ||
} | ||
} | ||
@@ -5,0 +12,0 @@ export { |
@@ -0,1 +1,2 @@ | ||
import { _dmt } from "../hooks/useMedia"; | ||
function _array_like_to_array(arr, len) { | ||
@@ -29,7 +30,12 @@ (len == null || len > arr.length) && (len = arr.length); | ||
args[_key] = arguments[_key]; | ||
var _console; | ||
if (process.env.NODE_ENV !== "production") { | ||
if (0) | ||
var _console1; | ||
return (_console = console).log.apply(_console, _to_consumable_array(args)); | ||
_dmt(!0); | ||
try { | ||
var _console; | ||
if (0) | ||
var _console1; | ||
return (_console = console).log.apply(_console, _to_consumable_array(args)); | ||
} finally { | ||
_dmt(!1); | ||
} | ||
} | ||
@@ -36,0 +42,0 @@ } |
@@ -13,4 +13,5 @@ import "@tamagui/constants"; | ||
if (lastFontFamilyToken = null, key === "elevationAndroid") return; | ||
const { conf, styleProps, fontFamily, staticConfig } = styleStateIn; | ||
if (value === "unset") { | ||
const unsetVal = styleStateIn.conf.unset?.[key]; | ||
const unsetVal = conf.unset?.[key]; | ||
if (unsetVal != null) | ||
@@ -21,7 +22,7 @@ value = unsetVal; | ||
} | ||
const subProps = styleStateIn.styleProps.fallbackProps || subPropsIn, styleState = subProps ? new Proxy(styleStateIn, { | ||
const subProps = styleProps.fallbackProps || subPropsIn, styleState = subProps ? new Proxy(styleStateIn, { | ||
get(_, k) { | ||
return k === "curProps" ? subProps : Reflect.get(_, k); | ||
} | ||
}) : styleStateIn, { conf, styleProps, fontFamily, staticConfig } = styleState, { variants } = staticConfig; | ||
}) : styleStateIn, { variants } = staticConfig; | ||
if (process.env.NODE_ENV === "development" && fontFamily && fontFamily[0] === "$" && !(fontFamily in conf.fontsParsed) && console.warn( | ||
@@ -28,0 +29,0 @@ `Warning: no fontFamily "${fontFamily}" found in config: ${Object.keys( |
@@ -77,4 +77,5 @@ import { isAndroid } from "@tamagui/constants"; | ||
if (lastFontFamilyToken = null, !(!isAndroid && key === "elevationAndroid")) { | ||
var conf = styleStateIn.conf, styleProps = styleStateIn.styleProps, fontFamily = styleStateIn.fontFamily, staticConfig = styleStateIn.staticConfig; | ||
if (value === "unset") { | ||
var _styleStateIn_conf_unset, unsetVal = (_styleStateIn_conf_unset = styleStateIn.conf.unset) === null || _styleStateIn_conf_unset === void 0 ? void 0 : _styleStateIn_conf_unset[key]; | ||
var _conf_unset, unsetVal = (_conf_unset = conf.unset) === null || _conf_unset === void 0 ? void 0 : _conf_unset[key]; | ||
if (unsetVal != null) | ||
@@ -85,7 +86,7 @@ value = unsetVal; | ||
} | ||
var subProps = styleStateIn.styleProps.fallbackProps || subPropsIn, styleState = subProps ? new Proxy(styleStateIn, { | ||
var subProps = styleProps.fallbackProps || subPropsIn, styleState = subProps ? new Proxy(styleStateIn, { | ||
get: function(_, k) { | ||
return k === "curProps" ? subProps : Reflect.get(_, k); | ||
} | ||
}) : styleStateIn, conf = styleState.conf, styleProps = styleState.styleProps, fontFamily = styleState.fontFamily, staticConfig = styleState.staticConfig, variants = staticConfig.variants; | ||
}) : styleStateIn, variants = staticConfig.variants; | ||
if (process.env.NODE_ENV === "development" && fontFamily && fontFamily[0] === "$" && !(fontFamily in conf.fontsParsed) && console.warn('Warning: no fontFamily "'.concat(fontFamily, '" found in config: ').concat(Object.keys(conf.fontsParsed).join(", "))), !styleProps.noExpand && variants && key in variants) { | ||
@@ -92,0 +93,0 @@ styleState.curProps[key] = value; |
@@ -1,4 +0,4 @@ | ||
import { getConfig } from "../config"; | ||
import { getSetting } from "../config"; | ||
function getDisableSSR(componentContext) { | ||
return componentContext?.disableSSR ?? getConfig().disableSSR; | ||
return componentContext?.disableSSR ?? getSetting("disableSSR"); | ||
} | ||
@@ -5,0 +5,0 @@ export { |
@@ -1,5 +0,5 @@ | ||
import { getConfig } from "../config"; | ||
import { getSetting } from "../config"; | ||
function getDisableSSR(componentContext) { | ||
var _componentContext_disableSSR; | ||
return (_componentContext_disableSSR = componentContext == null ? void 0 : componentContext.disableSSR) !== null && _componentContext_disableSSR !== void 0 ? _componentContext_disableSSR : getConfig().disableSSR; | ||
return (_componentContext_disableSSR = componentContext == null ? void 0 : componentContext.disableSSR) !== null && _componentContext_disableSSR !== void 0 ? _componentContext_disableSSR : getSetting("disableSSR"); | ||
} | ||
@@ -6,0 +6,0 @@ export { |
import { isServer, isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants"; | ||
import { useRef, useState, useSyncExternalStore } from "react"; | ||
import { getConfig } from "../config"; | ||
import { getConfig, getSetting } from "../config"; | ||
import { matchMedia } from "../helpers/matchMedia"; | ||
@@ -39,3 +39,3 @@ import { pseudoDescriptors } from "../helpers/pseudoDescriptors"; | ||
const configureMedia = (config) => { | ||
const { media, mediaQueryDefaultActive } = config; | ||
const { media } = config, mediaQueryDefaultActive = getSetting("mediaQueryDefaultActive"); | ||
if (media) { | ||
@@ -121,8 +121,25 @@ mediaVersion++; | ||
get(_, key) { | ||
return typeof key == "string" && (componentState.keys ||= {}, componentState.keys[key] = !0, process.env.NODE_ENV === "development" && debug && console.info("useMedia() TOUCH", key)), Reflect.get(state, key); | ||
if (!disableMediaTouch) | ||
return typeof key == "string" && (componentState.keys ||= {}, componentState.keys[key] = !0, process.env.NODE_ENV === "development" && debug && console.info("useMedia() TOUCH", key)), Reflect.get(state, key); | ||
} | ||
}); | ||
} | ||
let disableMediaTouch = !1; | ||
function _dmt(val) { | ||
disableMediaTouch = val; | ||
} | ||
function getMediaState(mediaGroups, layout) { | ||
disableMediaTouch = !0; | ||
let res; | ||
try { | ||
res = Object.fromEntries( | ||
[...mediaGroups].map((mediaKey) => [mediaKey, mediaKeyMatch(mediaKey, layout)]) | ||
); | ||
} finally { | ||
disableMediaTouch = !1; | ||
} | ||
return res; | ||
} | ||
const getMediaImportanceIfMoreImportant = (mediaKey, key, importancesUsed, isSizeMedia) => { | ||
const conf = getConfig(), importance = isSizeMedia && !conf.settings.mediaPropOrder ? getMediaKeyImportance(mediaKey) : defaultMediaImportance; | ||
const importance = isSizeMedia && !getSetting("mediaPropOrder") ? getMediaKeyImportance(mediaKey) : defaultMediaImportance; | ||
return !importancesUsed[key] || importance > importancesUsed[key] ? importance : null; | ||
@@ -153,2 +170,3 @@ }; | ||
export { | ||
_dmt, | ||
configureMedia, | ||
@@ -158,2 +176,3 @@ getMedia, | ||
getMediaKeyImportance, | ||
getMediaState, | ||
isMediaKey, | ||
@@ -160,0 +179,0 @@ mediaKeyMatch, |
import { isServer, isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants"; | ||
import { useRef, useState, useSyncExternalStore } from "react"; | ||
import { getConfig } from "../config"; | ||
import { getConfig, getSetting } from "../config"; | ||
import { matchMedia } from "../helpers/matchMedia"; | ||
@@ -15,2 +15,5 @@ import { pseudoDescriptors } from "../helpers/pseudoDescriptors"; | ||
} | ||
function _array_without_holes(arr) { | ||
if (Array.isArray(arr)) return _array_like_to_array(arr); | ||
} | ||
function _define_property(obj, key, value) { | ||
@@ -24,2 +27,5 @@ return key in obj ? Object.defineProperty(obj, key, { | ||
} | ||
function _iterable_to_array(iter) { | ||
if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); | ||
} | ||
function _iterable_to_array_limit(arr, i) { | ||
@@ -47,2 +53,5 @@ var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"]; | ||
} | ||
function _non_iterable_spread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
function _object_spread(target) { | ||
@@ -77,2 +86,5 @@ for (var i = 1; i < arguments.length; i++) { | ||
} | ||
function _to_consumable_array(arr) { | ||
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread(); | ||
} | ||
function _unsupported_iterable_to_array(o, minLen) { | ||
@@ -111,3 +123,3 @@ if (o) { | ||
}, dispose = /* @__PURE__ */ new Set(), mediaVersion = 0, configureMedia = function(config) { | ||
var media = config.media, mediaQueryDefaultActive = config.mediaQueryDefaultActive; | ||
var media = config.media, mediaQueryDefaultActive = getSetting("mediaQueryDefaultActive"); | ||
if (media) { | ||
@@ -195,12 +207,33 @@ mediaVersion++; | ||
get: function(_, key) { | ||
if (typeof key == "string") { | ||
var _componentState; | ||
(_componentState = componentState).keys || (_componentState.keys = {}), componentState.keys[key] = !0, process.env.NODE_ENV === "development" && debug && console.info("useMedia() TOUCH", key); | ||
if (!disableMediaTouch) { | ||
if (typeof key == "string") { | ||
var _componentState; | ||
(_componentState = componentState).keys || (_componentState.keys = {}), componentState.keys[key] = !0, process.env.NODE_ENV === "development" && debug && console.info("useMedia() TOUCH", key); | ||
} | ||
return Reflect.get(state, key); | ||
} | ||
return Reflect.get(state, key); | ||
} | ||
}); | ||
} | ||
var disableMediaTouch = !1; | ||
function _dmt(val) { | ||
disableMediaTouch = val; | ||
} | ||
function getMediaState(mediaGroups, layout) { | ||
disableMediaTouch = !0; | ||
var res; | ||
try { | ||
res = Object.fromEntries(_to_consumable_array(mediaGroups).map(function(mediaKey) { | ||
return [ | ||
mediaKey, | ||
mediaKeyMatch(mediaKey, layout) | ||
]; | ||
})); | ||
} finally { | ||
disableMediaTouch = !1; | ||
} | ||
return res; | ||
} | ||
var getMediaImportanceIfMoreImportant = function(mediaKey, key, importancesUsed, isSizeMedia) { | ||
var conf = getConfig(), importance = isSizeMedia && !conf.settings.mediaPropOrder ? getMediaKeyImportance(mediaKey) : defaultMediaImportance; | ||
var importance = isSizeMedia && !getSetting("mediaPropOrder") ? getMediaKeyImportance(mediaKey) : defaultMediaImportance; | ||
return !importancesUsed[key] || importance > importancesUsed[key] ? importance : null; | ||
@@ -236,2 +269,3 @@ }; | ||
export { | ||
_dmt, | ||
configureMedia, | ||
@@ -241,2 +275,3 @@ getMedia, | ||
getMediaKeyImportance, | ||
getMediaState, | ||
isMediaKey, | ||
@@ -243,0 +278,0 @@ mediaKeyMatch, |
import { isClient, isServer, isWeb } from "@tamagui/constants"; | ||
import { useContext, useEffect, useMemo, useRef, useState } from "react"; | ||
import { getConfig } from "../config"; | ||
import { getConfig, getSetting } from "../config"; | ||
import { getVariable } from "../createVariable"; | ||
@@ -35,3 +35,3 @@ import { ThemeManager, getHasThemeUpdatingProps } from "../helpers/ThemeManager"; | ||
), { themeManager, state } = changedThemeState; | ||
process.env.NODE_ENV === "development" && (state?.theme || process.env.TAMAGUI_DISABLE_NO_THEME_WARNING !== "1" && console.warn( | ||
process.env.NODE_ENV === "development" && (state?.theme || process.env.TAMAGUI_DISABLE_NO_THEME_WARNING !== "1" && console.error( | ||
`[tamagui] No theme found, this could be due to an invalid theme name (given theme props ${JSON.stringify( | ||
@@ -95,3 +95,10 @@ props | ||
} | ||
}, useChangeThemeEffect = (props, isRoot = !1, keys, shouldUpdate) => { | ||
}, ogLog = console.error, preventWarnSetState = process.env.NODE_ENV === "production" ? ogLog : ( | ||
// temporary fix for logs, they are harmless in that i've tried to rewrite this | ||
// a few times using the "right" ways, but they are always slower. maybe skill issue | ||
(a, ...args) => { | ||
if (!(typeof a == "string" && a.includes("Cannot update a component"))) | ||
return ogLog(a, ...args); | ||
} | ||
), useChangeThemeEffect = (props, isRoot = !1, keys, shouldUpdate) => { | ||
const { disable } = props, parentManagerId = useContext(ThemeManagerIDContext), parentManager = getThemeManager(parentManagerId); | ||
@@ -124,3 +131,3 @@ if (!isRoot && !parentManager || disable) | ||
const selfListenerDispose = themeManager.onChangeTheme((_a, _b, forced) => { | ||
forced && setThemeState((prev) => createState(prev, !0)); | ||
forced && (console.error = preventWarnSetState, setThemeState((prev) => createState(prev, !0)), console.error = ogLog); | ||
}), disposeChangeListener = parentManager?.onChangeTheme( | ||
@@ -136,3 +143,3 @@ (name, manager, forced) => { | ||
keys | ||
}), shouldTryUpdate && setThemeState((prev) => createState(prev, force)); | ||
}), shouldTryUpdate && (console.error = preventWarnSetState, setThemeState((prev) => createState(prev, force)), console.error = ogLog); | ||
}, | ||
@@ -192,3 +199,3 @@ themeManager.id | ||
isNewTheme2 && registerThemeManager(themeManager2); | ||
const isWebSSR = isWeb ? !getConfig().disableSSR : !1, mounted2 = isWebSSR ? isRoot || prev?.mounted : !0; | ||
const isWebSSR = isWeb ? !getSetting("disableSSR") : !1, mounted2 = isWebSSR ? isRoot || prev?.mounted : !0; | ||
state2 || (isNewTheme2 ? state2 = themeManager2.state : (state2 = parentManager.state, themeManager2 = parentManager)); | ||
@@ -195,0 +202,0 @@ const wasInversed = prev?.inversed, isInherentlyInversed = isNewTheme2 && state2.scheme !== parentManager?.state.scheme, inversed2 = isRoot ? !1 : isInherentlyInversed ? !0 : isWebSSR ? wasInversed != null ? !1 : null : props.inverse, response = { |
import { isClient, isIos, isServer, isWeb } from "@tamagui/constants"; | ||
import { useContext, useEffect, useMemo, useRef, useState } from "react"; | ||
import { getConfig } from "../config"; | ||
import { getConfig, getSetting } from "../config"; | ||
import { getVariable } from "../createVariable"; | ||
@@ -125,3 +125,3 @@ import { ThemeManager, getHasThemeUpdatingProps } from "../helpers/ThemeManager"; | ||
}), themeManager = changedThemeState.themeManager, state = changedThemeState.state; | ||
process.env.NODE_ENV === "development" && (state != null && state.theme || process.env.TAMAGUI_DISABLE_NO_THEME_WARNING !== "1" && console.warn("[tamagui] No theme found, this could be due to an invalid theme name (given theme props ".concat(JSON.stringify(props), `). | ||
process.env.NODE_ENV === "development" && (state != null && state.theme || process.env.TAMAGUI_DISABLE_NO_THEME_WARNING !== "1" && console.error("[tamagui] No theme found, this could be due to an invalid theme name (given theme props ".concat(JSON.stringify(props), `). | ||
@@ -173,3 +173,3 @@ If this is intended and you are using Tamagui without any themes, you can disable this warning by setting the environment variable TAMAGUI_DISABLE_NO_THEME_WARNING=1`))); | ||
var outVal = getVariable(val); | ||
if (platform !== "web" && isIos && !deopt && config.settings.fastSchemeChange && !someParentIsInversed(themeManager) && scheme) { | ||
if (platform !== "web" && isIos && !deopt && getSetting("fastSchemeChange") && !someParentIsInversed(themeManager) && scheme) { | ||
var oppositeThemeName = name.replace(scheme === "dark" ? "dark" : "light", scheme === "dark" ? "light" : "dark"), oppositeTheme = config.themes[oppositeThemeName], oppositeVal = getVariable(oppositeTheme == null ? void 0 : oppositeTheme[keyString]); | ||
@@ -216,3 +216,14 @@ if (oppositeVal) { | ||
} | ||
}, useChangeThemeEffect = function(props) { | ||
}, ogLog = console.error, preventWarnSetState = process.env.NODE_ENV === "production" ? ogLog : ( | ||
// temporary fix for logs, they are harmless in that i've tried to rewrite this | ||
// a few times using the "right" ways, but they are always slower. maybe skill issue | ||
function(a) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) | ||
args[_key - 1] = arguments[_key]; | ||
if (!(typeof a == "string" && a.includes("Cannot update a component"))) | ||
return ogLog.apply(void 0, [ | ||
a | ||
].concat(_to_consumable_array(args))); | ||
} | ||
), useChangeThemeEffect = function(props) { | ||
var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, keys = arguments.length > 2 ? arguments[2] : void 0, shouldUpdate = arguments.length > 3 ? arguments[3] : void 0, getShouldUpdateTheme = function() { | ||
@@ -244,3 +255,3 @@ var manager = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : themeManager, nextState = arguments.length > 1 ? arguments[1] : void 0, prevState = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : state, forceShouldChange = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1, forceUpdate = shouldUpdate == null ? void 0 : shouldUpdate(); | ||
isNewTheme2 && registerThemeManager(themeManager2); | ||
var isWebSSR = isWeb ? !getConfig().disableSSR : !1, mounted2 = isWebSSR ? isRoot || (prev == null ? void 0 : prev.mounted) : !0; | ||
var isWebSSR = isWeb ? !getSetting("disableSSR") : !1, mounted2 = isWebSSR ? isRoot || (prev == null ? void 0 : prev.mounted) : !0; | ||
state2 || (isNewTheme2 ? state2 = themeManager2.state : (state2 = parentManager.state, themeManager2 = parentManager)); | ||
@@ -291,5 +302,5 @@ var wasInversed = prev == null ? void 0 : prev.inversed, isInherentlyInversed = isNewTheme2 && state2.scheme !== (parentManager == null ? void 0 : parentManager.state.scheme), inversed2 = isRoot ? !1 : isInherentlyInversed ? !0 : isWebSSR ? wasInversed != null ? !1 : null : props.inverse, response = { | ||
var selfListenerDispose = themeManager.onChangeTheme(function(_a, _b, forced) { | ||
forced && setThemeState(function(prev) { | ||
forced && (console.error = preventWarnSetState, setThemeState(function(prev) { | ||
return createState(prev, !0); | ||
}); | ||
}), console.error = ogLog); | ||
}), disposeChangeListener = parentManager == null ? void 0 : parentManager.onChangeTheme(function(name, manager, forced) { | ||
@@ -304,5 +315,5 @@ var force = forced || (shouldUpdate == null ? void 0 : shouldUpdate()) || props.deopt || props["disable-child-theme"], shouldTryUpdate = force ?? !!(keys != null && keys.length || isNewTheme); | ||
keys | ||
}), shouldTryUpdate && setThemeState(function(prev) { | ||
}), shouldTryUpdate && (console.error = preventWarnSetState, setThemeState(function(prev) { | ||
return createState(prev, force); | ||
}); | ||
}), console.error = ogLog); | ||
}, themeManager.id); | ||
@@ -309,0 +320,0 @@ return function() { |
@@ -7,2 +7,3 @@ import { isClient, isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants"; | ||
import { ThemeProvider } from "./ThemeProvider"; | ||
import { getSetting } from "../config"; | ||
import { jsx } from "react/jsx-runtime"; | ||
@@ -29,4 +30,4 @@ function TamaguiProvider({ | ||
{ | ||
themeClassNameOnRoot: themeClassNameOnRoot ?? config?.themeClassNameOnRoot, | ||
disableRootThemeClass: disableRootThemeClass ?? config?.disableRootThemeClass, | ||
themeClassNameOnRoot: themeClassNameOnRoot ?? getSetting("themeClassNameOnRoot"), | ||
disableRootThemeClass: disableRootThemeClass ?? getSetting("disableRootThemeClass"), | ||
defaultTheme: defaultTheme ?? (config ? Object.keys(config.themes)[0] : ""), | ||
@@ -33,0 +34,0 @@ reset, |
@@ -8,2 +8,3 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
import { ThemeProvider } from "./ThemeProvider"; | ||
import { getSetting } from "../config"; | ||
function _array_like_to_array(arr, len) { | ||
@@ -66,4 +67,4 @@ (len == null || len > arr.length) && (len = arr.length); | ||
children: /* @__PURE__ */ _jsx(ThemeProvider, { | ||
themeClassNameOnRoot: themeClassNameOnRoot ?? (config == null ? void 0 : config.themeClassNameOnRoot), | ||
disableRootThemeClass: disableRootThemeClass ?? (config == null ? void 0 : config.disableRootThemeClass), | ||
themeClassNameOnRoot: themeClassNameOnRoot ?? getSetting("themeClassNameOnRoot"), | ||
disableRootThemeClass: disableRootThemeClass ?? getSetting("disableRootThemeClass"), | ||
defaultTheme: defaultTheme ?? (config ? Object.keys(config.themes)[0] : ""), | ||
@@ -70,0 +71,0 @@ reset, |
@@ -5,6 +5,7 @@ import { isClient } from "@tamagui/constants"; | ||
import { Theme } from "./Theme"; | ||
import { getSetting } from "../config"; | ||
import { jsx } from "react/jsx-runtime"; | ||
const ThemeProvider = (props) => (isClient && useLayoutEffect(() => { | ||
if (props.disableRootThemeClass) return; | ||
const cn = `${THEME_CLASSNAME_PREFIX}${props.defaultTheme}`, target = props.themeClassNameOnRoot ? document.documentElement : document.body; | ||
const cn = `${THEME_CLASSNAME_PREFIX}${props.defaultTheme}`, target = props.themeClassNameOnRoot ?? getSetting("themeClassNameOnRoot") ? document.documentElement : document.body; | ||
return target.classList.add(cn), () => { | ||
@@ -11,0 +12,0 @@ target.classList.remove(cn); |
@@ -6,6 +6,7 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
import { Theme } from "./Theme"; | ||
import { getSetting } from "../config"; | ||
var ThemeProvider = function(props) { | ||
return isClient && useLayoutEffect(function() { | ||
if (!props.disableRootThemeClass) { | ||
var cn = "".concat(THEME_CLASSNAME_PREFIX).concat(props.defaultTheme), target = props.themeClassNameOnRoot ? document.documentElement : document.body; | ||
var cn = "".concat(THEME_CLASSNAME_PREFIX).concat(props.defaultTheme), _props_themeClassNameOnRoot, target = ((_props_themeClassNameOnRoot = props.themeClassNameOnRoot) !== null && _props_themeClassNameOnRoot !== void 0 ? _props_themeClassNameOnRoot : getSetting("themeClassNameOnRoot")) ? document.documentElement : document.body; | ||
return target.classList.add(cn), function() { | ||
@@ -12,0 +13,0 @@ target.classList.remove(cn); |
{ | ||
"name": "@tamagui/web", | ||
"version": "1.105.1", | ||
"version": "1.105.2", | ||
"source": "src/index.ts", | ||
@@ -30,14 +30,14 @@ "main": "dist/cjs", | ||
"dependencies": { | ||
"@tamagui/compose-refs": "1.105.1", | ||
"@tamagui/constants": "1.105.1", | ||
"@tamagui/helpers": "1.105.1", | ||
"@tamagui/normalize-css-color": "1.105.1", | ||
"@tamagui/timer": "1.105.1", | ||
"@tamagui/types": "1.105.1", | ||
"@tamagui/use-did-finish-ssr": "1.105.1", | ||
"@tamagui/use-event": "1.105.1", | ||
"@tamagui/use-force-update": "1.105.1" | ||
"@tamagui/compose-refs": "1.105.2", | ||
"@tamagui/constants": "1.105.2", | ||
"@tamagui/helpers": "1.105.2", | ||
"@tamagui/normalize-css-color": "1.105.2", | ||
"@tamagui/timer": "1.105.2", | ||
"@tamagui/types": "1.105.2", | ||
"@tamagui/use-did-finish-ssr": "1.105.2", | ||
"@tamagui/use-event": "1.105.2", | ||
"@tamagui/use-force-update": "1.105.2" | ||
}, | ||
"devDependencies": { | ||
"@tamagui/build": "1.105.1", | ||
"@tamagui/build": "1.105.2", | ||
"@testing-library/react": "^14.0.0", | ||
@@ -44,0 +44,0 @@ "csstype": "^3.0.10", |
@@ -5,2 +5,3 @@ import { isWeb } from '@tamagui/constants' | ||
ConfigListener, | ||
GenericTamaguiSettings, | ||
TamaguiInternalConfig, | ||
@@ -14,2 +15,15 @@ Token, | ||
export const getSetting = <Key extends keyof GenericTamaguiSettings>( | ||
key: Key | ||
): GenericTamaguiSettings[Key] => { | ||
if (process.env.NODE_ENV === 'development') { | ||
if (!conf) throw new Error(`Haven't called createTamagui yet`) | ||
} | ||
return ( | ||
conf!.settings[key] ?? | ||
// @ts-expect-error | ||
conf[key] | ||
) | ||
} | ||
export const setConfig = (next: TamaguiInternalConfig) => { | ||
@@ -16,0 +30,0 @@ conf = next |
@@ -230,4 +230,6 @@ import { isWeb } from '@tamagui/constants' | ||
const defaultFontSetting = configIn.settings?.defaultFont ?? configIn.defaultFont | ||
let defaultFontName = | ||
configIn.defaultFont || | ||
defaultFontSetting || | ||
// uses font named "body" if present for compat | ||
@@ -256,3 +258,3 @@ (configIn.fonts && ('body' in configIn.fonts ? 'body' : '')) | ||
unset: { | ||
fontFamily: configIn.defaultFont ? defaultFont : undefined, | ||
fontFamily: defaultFontName ? defaultFont : undefined, | ||
...configIn.unset, | ||
@@ -284,4 +286,4 @@ }, | ||
setConfig(config) | ||
configureMedia(config) | ||
setConfig(config) | ||
@@ -288,0 +290,0 @@ createdConfigs.set(config, true) |
@@ -1,2 +0,2 @@ | ||
import { getConfig } from '../config' | ||
import { getConfig, getSetting } from '../config' | ||
import { mediaObjectToString } from '../hooks/useMedia' | ||
@@ -59,3 +59,3 @@ import type { IsMediaType, MediaQueries, MediaStyleObject, StyleObject } from '../types' | ||
const selector = styleInner.slice(selectorStart, selectorEnd) | ||
const precedenceSpace = conf.themeClassNameOnRoot && isTheme ? '' : ' ' | ||
const precedenceSpace = getSetting('themeClassNameOnRoot') && isTheme ? '' : ' ' | ||
const pseudoSelectorName = groupInfo.pseudo | ||
@@ -62,0 +62,0 @@ ? groupPseudoToPseudoCSSMap[groupInfo.pseudo] || groupInfo.pseudo |
@@ -8,2 +8,3 @@ import { simpleHash } from '@tamagui/helpers' | ||
import { tokensValueToVariable } from './registerCSSVariable' | ||
import { getSetting } from '../config' | ||
@@ -63,3 +64,3 @@ export function getThemeCSSRules(props: { | ||
if (hasDarkLight) { | ||
const maxDepth = config.maxDarkLightNesting ?? 3 | ||
const maxDepth = getSetting('maxDarkLightNesting') ?? 3 | ||
@@ -120,3 +121,3 @@ for (const subName of names) { | ||
.map((x) => { | ||
const rootSep = isBaseTheme(x) && config.themeClassNameOnRoot ? '' : ' ' | ||
const rootSep = isBaseTheme(x) && getSetting('themeClassNameOnRoot') ? '' : ' ' | ||
return `:root${rootSep}${x}` | ||
@@ -129,3 +130,3 @@ }) | ||
if (config.shouldAddPrefersColorThemes) { | ||
if (getSetting('shouldAddPrefersColorThemes')) { | ||
const bgString = theme.background | ||
@@ -161,4 +162,5 @@ ? `background:${variableToString(theme.background)};` | ||
if (config.selectionStyles) { | ||
const rules = config.selectionStyles(theme as any) | ||
const selectionStyles = getSetting('selectionStyles') | ||
if (selectionStyles) { | ||
const rules = selectionStyles(theme as any) | ||
if (rules) { | ||
@@ -165,0 +167,0 @@ const selectionSelectors = baseSelectors.map((s) => `${s} ::selection`).join(', ') |
@@ -0,9 +1,16 @@ | ||
import { _dmt } from '../hooks/useMedia' | ||
export function log(...args: any[]) { | ||
if (process.env.NODE_ENV === 'production') return | ||
if (process.env.TAMAGUI_TARGET === 'web') { | ||
return console.info(...args) | ||
_dmt(true) | ||
try { | ||
if (process.env.TAMAGUI_TARGET === 'web') { | ||
return console.info(...args) | ||
} | ||
// react native doesn't log in the cli unless it's log | ||
// biome-ignore lint/suspicious/noConsoleLog: <explanation> | ||
return console.log(...args) | ||
} finally { | ||
_dmt(false) | ||
} | ||
// react native doesn't log in the cli unless it's log | ||
// biome-ignore lint/suspicious/noConsoleLog: <explanation> | ||
return console.log(...args) | ||
} |
@@ -31,4 +31,6 @@ import { isAndroid } from '@tamagui/constants' | ||
const { conf, styleProps, fontFamily, staticConfig } = styleStateIn | ||
if (value === 'unset') { | ||
const unsetVal = styleStateIn.conf.unset?.[key] | ||
const unsetVal = conf.unset?.[key] | ||
if (unsetVal != null) { | ||
@@ -45,3 +47,3 @@ value = unsetVal | ||
// also we need to override the props here because subStyles pass in a sub-style props object | ||
const subProps = styleStateIn.styleProps.fallbackProps || subPropsIn | ||
const subProps = styleProps.fallbackProps || subPropsIn | ||
const styleState = subProps | ||
@@ -55,3 +57,2 @@ ? new Proxy(styleStateIn, { | ||
const { conf, styleProps, fontFamily, staticConfig } = styleState | ||
const { variants } = staticConfig | ||
@@ -58,0 +59,0 @@ |
@@ -1,2 +0,3 @@ | ||
import type { ConfigListener, TamaguiInternalConfig, Token, Tokens, TokensMerged } from './types'; | ||
import type { ConfigListener, GenericTamaguiSettings, TamaguiInternalConfig, Token, Tokens, TokensMerged } from './types'; | ||
export declare const getSetting: <Key extends keyof GenericTamaguiSettings>(key: Key) => GenericTamaguiSettings[Key]; | ||
export declare const setConfig: (next: TamaguiInternalConfig) => void; | ||
@@ -3,0 +4,0 @@ export declare const setConfigFont: (name: string, font: any, fontParsed: any) => void; |
@@ -10,2 +10,3 @@ export declare const useConfiguration: () => { | ||
reactNative?: any; | ||
defaultFont?: string; | ||
selectionStyles?: (theme: Record<string, string>) => null | { | ||
@@ -58,43 +59,3 @@ backgroundColor?: any; | ||
onlyAllowShorthands: boolean | undefined; | ||
defaultFont: string | undefined; | ||
settings: { | ||
styleCompat?: "react-native"; | ||
allowedStyleValues?: (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web") | { | ||
space?: "number" | (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web") | "percent"; | ||
size?: "number" | (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web") | "percent"; | ||
radius?: "number" | (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web"); | ||
zIndex?: "number" | (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web"); | ||
color?: (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web") | "named"; | ||
}; | ||
autocompleteSpecificTokens?: boolean | "except-special"; | ||
mediaPropOrder?: boolean; | ||
fastSchemeChange?: boolean; | ||
webContainerType?: "normal" | "size" | "inline-size" | "inherit" | "initial" | "revert" | "revert-layer" | "unset"; | ||
} & Omit<{ | ||
styleCompat?: "react-native"; | ||
allowedStyleValues?: (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web") | { | ||
space?: "number" | (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web") | "percent"; | ||
size?: "number" | (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web") | "percent"; | ||
radius?: "number" | (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web"); | ||
zIndex?: "number" | (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web"); | ||
color?: (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web") | "named"; | ||
}; | ||
autocompleteSpecificTokens?: boolean | "except-special"; | ||
mediaPropOrder?: boolean; | ||
fastSchemeChange?: boolean; | ||
webContainerType?: "normal" | "size" | "inline-size" | "inherit" | "initial" | "revert" | "revert-layer" | "unset"; | ||
}, keyof { | ||
styleCompat?: "react-native"; | ||
allowedStyleValues?: (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web") | { | ||
space?: "number" | (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web") | "percent"; | ||
size?: "number" | (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web") | "percent"; | ||
radius?: "number" | (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web"); | ||
zIndex?: "number" | (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web"); | ||
color?: (boolean | "strict" | "somewhat-strict" | "strict-web" | "somewhat-strict-web") | "named"; | ||
}; | ||
autocompleteSpecificTokens?: boolean | "except-special"; | ||
mediaPropOrder?: boolean; | ||
fastSchemeChange?: boolean; | ||
webContainerType?: "normal" | "size" | "inline-size" | "inherit" | "initial" | "revert" | "revert-layer" | "unset"; | ||
}>; | ||
settings: import("..").GenericTamaguiSettings & Omit<import("..").GenericTamaguiSettings, keyof import("..").GenericTamaguiSettings>; | ||
tokens: Omit<{ | ||
@@ -101,0 +62,0 @@ [x: string]: { |
@@ -1,2 +0,2 @@ | ||
import type { ComponentContextI, DebugProp, IsMediaType, MediaQueries, MediaQueryObject, MediaQueryState, TamaguiInternalConfig, UseMediaState } from '../types'; | ||
import type { ComponentContextI, DebugProp, IsMediaType, LayoutEvent, MediaQueries, MediaQueryObject, MediaQueryState, TamaguiInternalConfig, UseMediaState } from '../types'; | ||
export declare let mediaState: MediaQueryState; | ||
@@ -20,2 +20,4 @@ export declare const mediaQueryConfig: MediaQueries; | ||
export declare function useMedia(uidIn?: any, componentContext?: ComponentContextI, debug?: DebugProp): UseMediaState; | ||
export declare function _dmt(val: boolean): void; | ||
export declare function getMediaState(mediaGroups: Set<string>, layout: LayoutEvent['nativeEvent']['layout']): Record<string, boolean>; | ||
export declare const getMediaImportanceIfMoreImportant: (mediaKey: string, key: string, importancesUsed: Record<string, number>, isSizeMedia: boolean) => number | null; | ||
@@ -22,0 +24,0 @@ export declare function mediaObjectToString(query: string | MediaQueryObject, key?: string): string; |
@@ -5,2 +5,3 @@ export type ThemeProviderProps = { | ||
disableRootThemeClass?: boolean; | ||
/** @deprecated moved to createTamagui({ settings: { disableRootThemeClass } }) */ | ||
themeClassNameOnRoot?: boolean; | ||
@@ -7,0 +8,0 @@ children?: any; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2950529
1268
47027
758
+ Added@tamagui/compose-refs@1.105.2(transitive)
+ Added@tamagui/constants@1.105.2(transitive)
+ Added@tamagui/helpers@1.105.2(transitive)
+ Added@tamagui/normalize-css-color@1.105.2(transitive)
+ Added@tamagui/simple-hash@1.105.2(transitive)
+ Added@tamagui/timer@1.105.2(transitive)
+ Added@tamagui/types@1.105.2(transitive)
+ Added@tamagui/use-did-finish-ssr@1.105.2(transitive)
+ Added@tamagui/use-event@1.105.2(transitive)
+ Added@tamagui/use-force-update@1.105.2(transitive)
- Removed@tamagui/compose-refs@1.105.1(transitive)
- Removed@tamagui/constants@1.105.1(transitive)
- Removed@tamagui/helpers@1.105.1(transitive)
- Removed@tamagui/normalize-css-color@1.105.1(transitive)
- Removed@tamagui/simple-hash@1.105.1(transitive)
- Removed@tamagui/timer@1.105.1(transitive)
- Removed@tamagui/types@1.105.1(transitive)
- Removed@tamagui/use-did-finish-ssr@1.105.1(transitive)
- Removed@tamagui/use-event@1.105.1(transitive)
- Removed@tamagui/use-force-update@1.105.1(transitive)
Updated@tamagui/constants@1.105.2
Updated@tamagui/helpers@1.105.2
Updated@tamagui/timer@1.105.2
Updated@tamagui/types@1.105.2
Updated@tamagui/use-event@1.105.2