Socket
Socket
Sign inDemoInstall

@tamagui/web

Package Overview
Dependencies
Maintainers
2
Versions
799
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tamagui/web - npm Package Compare versions

Comparing version 1.21.4 to 1.22.0

4

dist/cjs/helpers/getSplitStyles.js

@@ -495,3 +495,3 @@ "use strict";

if (shouldDoClasses && !isEnter && !isExit) {
const pseudoStyles = (0, import_getStylesAtomic.getAtomicStyle)(pseudoStyleObject, descriptor);
const pseudoStyles = (0, import_getStylesAtomic.generateAtomicStyles)(pseudoStyleObject, descriptor);
for (const psuedoStyle of pseudoStyles) {

@@ -726,3 +726,3 @@ const fullKey = `${psuedoStyle.property}${PROP_SPLIT}${descriptor.name}`;

if (props.animateOnly && props.animateOnly.includes(key)) {
retainedStyles[key] = atomicStyle.value;
retainedStyles[key] = style[key];
} else {

@@ -729,0 +729,0 @@ addStyleToInsertRules(rulesToInsert, atomicStyle);

@@ -21,3 +21,3 @@ "use strict";

__export(getStylesAtomic_exports, {
getAtomicStyle: () => getAtomicStyle,
generateAtomicStyles: () => generateAtomicStyles,
getStylesAtomic: () => getStylesAtomic,

@@ -39,3 +39,3 @@ styleToCSS: () => styleToCSS

if (!(stylesIn.hoverStyle || stylesIn.pressStyle || stylesIn.focusStyle)) {
return getAtomicStyle(stylesIn);
return generateAtomicStyles(stylesIn);
}

@@ -48,21 +48,13 @@ const { hoverStyle, pressStyle, focusStyle, ...base } = stylesIn;

const pseudo = pseudosOrdered[index];
res = [...res, ...getAtomicStyle(style, pseudo)];
res = [...res, ...generateAtomicStyles(style, pseudo)];
}
return res;
}
function getAtomicStyle(style, pseudo) {
if (!style)
return [];
if (process.env.NODE_ENV === "development") {
if (!style || typeof style !== "object") {
throw new Error(`Wrong style type: "${typeof style}": ${style}`);
}
}
return generateAtomicStyles(style, pseudo);
}
let conf;
const generateAtomicStyles = (styleIn, pseudo) => {
if (!styleIn)
return [];
conf = conf || (0, import_config.getConfig)();
const style = styleIn;
if (style.transform && Array.isArray(style.transform)) {
if ("transform" in style && Array.isArray(style.transform)) {
style.transform = style.transform.map(

@@ -88,8 +80,3 @@ // { scale: 2 } => 'scale(2)'

continue;
let hash;
if (presetHashes[value]) {
hash = value;
} else {
hash = (0, import_helpers.simpleHash)(`${value}`);
}
const hash = (0, import_helpers.simpleHash)(`${value}`);
const pseudoPrefix = pseudo ? `0${pseudo.name}-` : "";

@@ -102,13 +89,10 @@ const shortProp = conf.inverseShorthands[key] || key;

pseudo: pseudo == null ? void 0 : pseudo.name,
value,
identifier,
rules
};
if (process.env.NODE_ENV === "test") {
styleObject.value = value;
}
out.push(styleObject);
}
if (process.env.NODE_ENV === "development" && process.env.TAMAGUI_DEBUG) {
if (out.find((x) => x.property === "transform" && x.value.includes(`[object Object]`))) {
debugger;
}
}
return out;

@@ -120,4 +104,4 @@ };

function styleToCSS(style) {
const { shadowOffset, shadowRadius, shadowColor } = style;
if (style.shadowRadius !== void 0) {
if ("shadowRadius" in style) {
const { shadowOffset, shadowRadius, shadowColor } = style;
const offset = shadowOffset || import_defaultOffset.defaultOffset;

@@ -134,4 +118,4 @@ const shadow = `${(0, import_normalizeValueWithProperty.normalizeValueWithProperty)(

}
const { textShadowColor, textShadowOffset, textShadowRadius } = style;
if (textShadowColor || textShadowOffset || textShadowRadius) {
if ("textShadowColor" in style || "textShadowOffset" in style || "textShadowRadius" in style) {
const { textShadowColor, textShadowOffset, textShadowRadius } = style;
const { height, width } = textShadowOffset || import_defaultOffset.defaultOffset;

@@ -153,5 +137,4 @@ const radius = textShadowRadius || 0;

let next = "";
for (const key in style) {
for (const [key, value] of style) {
const prop = hyphenateStyleName(key);
const value = style[key];
next += `${prop}:${value}${important ? " !important" : ""};`;

@@ -164,6 +147,6 @@ }

const hyphenateStyleName = (key) => {
let val = hcache[key];
if (val)
return val;
hcache[key] = val = key.replace(/[A-Z]/g, toHyphenLower);
if (key in hcache)
return hcache[key];
const val = key.replace(/[A-Z]/g, toHyphenLower);
hcache[key] = val;
return val;

@@ -185,3 +168,9 @@ };

case "placeholderTextColor": {
const block = createDeclarationBlock({ color: value, opacity: 1 }, important);
const block = createDeclarationBlock(
[
["color", value],
["opacity", 1]
],
important
);
rules.push(`${selector}::placeholder${block}`);

@@ -195,3 +184,6 @@ break;

const block = createDeclarationBlock(
{ [property]: value, [webkitProperty]: value },
[
[property, value],
[webkitProperty, value]
],
important

@@ -215,3 +207,3 @@ );

}
const block = createDeclarationBlock({ pointerEvents: finalValue }, true);
const block = createDeclarationBlock([["pointerEvents", finalValue]], true);
rules.push(`${selector}${block}`);

@@ -221,3 +213,3 @@ break;

default: {
const block = createDeclarationBlock({ [property]: value }, important);
const block = createDeclarationBlock([[property, value]], important);
rules.push(`${selector}${block}`);

@@ -232,7 +224,7 @@ break;

}
const boxNone = createDeclarationBlock({ pointerEvents: "auto" }, true);
const boxOnly = createDeclarationBlock({ pointerEvents: "none" }, true);
const boxNone = createDeclarationBlock([["pointerEvents", "auto"]], true);
const boxOnly = createDeclarationBlock([["pointerEvents", "none"]], true);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
getAtomicStyle,
generateAtomicStyles,
getStylesAtomic,

@@ -239,0 +231,0 @@ styleToCSS

@@ -29,7 +29,4 @@ "use strict";

var import_normalizeStylePropKeys = require("./normalizeStylePropKeys");
const colorCache = {};
const colorCache = /* @__PURE__ */ new Map();
function normalizeValueWithProperty(value, property) {
if (value in colorCache) {
return colorCache[value];
}
if (property && property in unitlessNumbers) {

@@ -40,5 +37,11 @@ return value;

if (property && (property in import_normalizeStylePropKeys.normalizeStylePropKeys || value in import_normalizeColor.names)) {
if (colorCache.has(value)) {
return colorCache.get(value);
}
res = (0, import_normalizeColor.normalizeColor)(value);
colorCache[value] = res;
} else if (process.env.TAMAGUI_TARGET === "web" && typeof value === "number" && (property === void 0 || !(property in unitlessNumbers || property in stringNumbers))) {
if (colorCache.size > 1e3) {
colorCache.clear();
}
colorCache.set(value, res);
} else if (import_constants.isWeb && typeof value === "number" && (property === void 0 || !(property in unitlessNumbers || property in stringNumbers))) {
res = `${value}px`;

@@ -45,0 +48,0 @@ } else if (import_constants.isWeb && property !== void 0 && property in stringNumbers) {

@@ -30,3 +30,3 @@ import {

import { fixStyles } from "./expandStyles.js";
import { getAtomicStyle, getStylesAtomic, styleToCSS } from "./getStylesAtomic";
import { generateAtomicStyles, getStylesAtomic, styleToCSS } from "./getStylesAtomic";
import {

@@ -499,3 +499,3 @@ insertStyleRules,

if (shouldDoClasses && !isEnter && !isExit) {
const pseudoStyles = getAtomicStyle(pseudoStyleObject, descriptor);
const pseudoStyles = generateAtomicStyles(pseudoStyleObject, descriptor);
for (const psuedoStyle of pseudoStyles) {

@@ -730,3 +730,3 @@ const fullKey = `${psuedoStyle.property}${PROP_SPLIT}${descriptor.name}`;

if (props.animateOnly && props.animateOnly.includes(key)) {
retainedStyles[key] = atomicStyle.value;
retainedStyles[key] = style[key];
} else {

@@ -733,0 +733,0 @@ addStyleToInsertRules(rulesToInsert, atomicStyle);

@@ -13,3 +13,3 @@ import { simpleHash } from "@tamagui/helpers";

if (!(stylesIn.hoverStyle || stylesIn.pressStyle || stylesIn.focusStyle)) {
return getAtomicStyle(stylesIn);
return generateAtomicStyles(stylesIn);
}

@@ -22,21 +22,13 @@ const { hoverStyle, pressStyle, focusStyle, ...base } = stylesIn;

const pseudo = pseudosOrdered[index];
res = [...res, ...getAtomicStyle(style, pseudo)];
res = [...res, ...generateAtomicStyles(style, pseudo)];
}
return res;
}
function getAtomicStyle(style, pseudo) {
if (!style)
return [];
if (process.env.NODE_ENV === "development") {
if (!style || typeof style !== "object") {
throw new Error(`Wrong style type: "${typeof style}": ${style}`);
}
}
return generateAtomicStyles(style, pseudo);
}
let conf;
const generateAtomicStyles = (styleIn, pseudo) => {
if (!styleIn)
return [];
conf = conf || getConfig();
const style = styleIn;
if (style.transform && Array.isArray(style.transform)) {
if ("transform" in style && Array.isArray(style.transform)) {
style.transform = style.transform.map(

@@ -62,8 +54,3 @@ // { scale: 2 } => 'scale(2)'

continue;
let hash;
if (presetHashes[value]) {
hash = value;
} else {
hash = simpleHash(`${value}`);
}
const hash = simpleHash(`${value}`);
const pseudoPrefix = pseudo ? `0${pseudo.name}-` : "";

@@ -76,13 +63,10 @@ const shortProp = conf.inverseShorthands[key] || key;

pseudo: pseudo == null ? void 0 : pseudo.name,
value,
identifier,
rules
};
if (process.env.NODE_ENV === "test") {
styleObject.value = value;
}
out.push(styleObject);
}
if (process.env.NODE_ENV === "development" && process.env.TAMAGUI_DEBUG) {
if (out.find((x) => x.property === "transform" && x.value.includes(`[object Object]`))) {
debugger;
}
}
return out;

@@ -94,4 +78,4 @@ };

function styleToCSS(style) {
const { shadowOffset, shadowRadius, shadowColor } = style;
if (style.shadowRadius !== void 0) {
if ("shadowRadius" in style) {
const { shadowOffset, shadowRadius, shadowColor } = style;
const offset = shadowOffset || defaultOffset;

@@ -108,4 +92,4 @@ const shadow = `${normalizeValueWithProperty(

}
const { textShadowColor, textShadowOffset, textShadowRadius } = style;
if (textShadowColor || textShadowOffset || textShadowRadius) {
if ("textShadowColor" in style || "textShadowOffset" in style || "textShadowRadius" in style) {
const { textShadowColor, textShadowOffset, textShadowRadius } = style;
const { height, width } = textShadowOffset || defaultOffset;

@@ -127,5 +111,4 @@ const radius = textShadowRadius || 0;

let next = "";
for (const key in style) {
for (const [key, value] of style) {
const prop = hyphenateStyleName(key);
const value = style[key];
next += `${prop}:${value}${important ? " !important" : ""};`;

@@ -138,6 +121,6 @@ }

const hyphenateStyleName = (key) => {
let val = hcache[key];
if (val)
return val;
hcache[key] = val = key.replace(/[A-Z]/g, toHyphenLower);
if (key in hcache)
return hcache[key];
const val = key.replace(/[A-Z]/g, toHyphenLower);
hcache[key] = val;
return val;

@@ -159,3 +142,9 @@ };

case "placeholderTextColor": {
const block = createDeclarationBlock({ color: value, opacity: 1 }, important);
const block = createDeclarationBlock(
[
["color", value],
["opacity", 1]
],
important
);
rules.push(`${selector}::placeholder${block}`);

@@ -169,3 +158,6 @@ break;

const block = createDeclarationBlock(
{ [property]: value, [webkitProperty]: value },
[
[property, value],
[webkitProperty, value]
],
important

@@ -189,3 +181,3 @@ );

}
const block = createDeclarationBlock({ pointerEvents: finalValue }, true);
const block = createDeclarationBlock([["pointerEvents", finalValue]], true);
rules.push(`${selector}${block}`);

@@ -195,3 +187,3 @@ break;

default: {
const block = createDeclarationBlock({ [property]: value }, important);
const block = createDeclarationBlock([[property, value]], important);
rules.push(`${selector}${block}`);

@@ -206,6 +198,6 @@ break;

}
const boxNone = createDeclarationBlock({ pointerEvents: "auto" }, true);
const boxOnly = createDeclarationBlock({ pointerEvents: "none" }, true);
const boxNone = createDeclarationBlock([["pointerEvents", "auto"]], true);
const boxOnly = createDeclarationBlock([["pointerEvents", "none"]], true);
export {
getAtomicStyle,
generateAtomicStyles,
getStylesAtomic,

@@ -212,0 +204,0 @@ styleToCSS

@@ -5,7 +5,4 @@ import { isWeb } from "@tamagui/constants";

import { normalizeStylePropKeys } from "./normalizeStylePropKeys";
const colorCache = {};
const colorCache = /* @__PURE__ */ new Map();
function normalizeValueWithProperty(value, property) {
if (value in colorCache) {
return colorCache[value];
}
if (property && property in unitlessNumbers) {

@@ -16,5 +13,11 @@ return value;

if (property && (property in normalizeStylePropKeys || value in names)) {
if (colorCache.has(value)) {
return colorCache.get(value);
}
res = normalizeColor(value);
colorCache[value] = res;
} else if (process.env.TAMAGUI_TARGET === "web" && typeof value === "number" && (property === void 0 || !(property in unitlessNumbers || property in stringNumbers))) {
if (colorCache.size > 1e3) {
colorCache.clear();
}
colorCache.set(value, res);
} else if (isWeb && typeof value === "number" && (property === void 0 || !(property in unitlessNumbers || property in stringNumbers))) {
res = `${value}px`;

@@ -21,0 +24,0 @@ } else if (isWeb && property !== void 0 && property in stringNumbers) {

{
"name": "@tamagui/web",
"version": "1.21.4",
"version": "1.22.0",
"source": "src/index.ts",

@@ -30,9 +30,9 @@ "main": "dist/cjs",

"dependencies": {
"@tamagui/compose-refs": "1.21.4",
"@tamagui/constants": "1.21.4",
"@tamagui/helpers": "1.21.4",
"@tamagui/normalize-css-color": "1.21.4",
"@tamagui/use-did-finish-ssr": "1.21.4",
"@tamagui/use-event": "1.21.4",
"@tamagui/use-force-update": "1.21.4"
"@tamagui/compose-refs": "1.22.0",
"@tamagui/constants": "1.22.0",
"@tamagui/helpers": "1.22.0",
"@tamagui/normalize-css-color": "1.22.0",
"@tamagui/use-did-finish-ssr": "1.22.0",
"@tamagui/use-event": "1.22.0",
"@tamagui/use-force-update": "1.22.0"
},

@@ -43,3 +43,3 @@ "peerDependencies": {

"devDependencies": {
"@tamagui/build": "1.21.4",
"@tamagui/build": "1.22.0",
"@testing-library/react": "^13.4.0",

@@ -46,0 +46,0 @@ "csstype": "^3.0.10",

@@ -26,3 +26,3 @@ /**

if (!(stylesIn.hoverStyle || stylesIn.pressStyle || stylesIn.focusStyle)) {
return getAtomicStyle(stylesIn)
return generateAtomicStyles(stylesIn)
}

@@ -37,3 +37,3 @@

const pseudo = pseudosOrdered[index]
res = [...res, ...getAtomicStyle(style, pseudo)]
res = [...res, ...generateAtomicStyles(style, pseudo)]
}

@@ -43,21 +43,10 @@ return res

export function getAtomicStyle(
style: ViewStyleWithPseudos,
pseudo?: PseudoDescriptor
): StyleObject[] {
if (!style) return []
if (process.env.NODE_ENV === 'development') {
if (!style || typeof style !== 'object') {
throw new Error(`Wrong style type: "${typeof style}": ${style}`)
}
}
return generateAtomicStyles(style, pseudo)
}
let conf: TamaguiInternalConfig
const generateAtomicStyles = (
export const generateAtomicStyles = (
styleIn: ViewStyleWithPseudos,
pseudo?: PseudoDescriptor
): StyleObject[] => {
if (!styleIn) return []
conf = conf || getConfig()

@@ -69,3 +58,3 @@

// transform
if (style.transform && Array.isArray(style.transform)) {
if ('transform' in style && Array.isArray(style.transform)) {
style.transform = style.transform

@@ -95,9 +84,3 @@ .map(

let hash: string
if (presetHashes[value]) {
hash = value as string
} else {
hash = simpleHash(`${value}`)
}
const hash = simpleHash(`${value}`)
const pseudoPrefix = pseudo ? `0${pseudo.name}-` : ''

@@ -110,19 +93,11 @@ const shortProp = conf.inverseShorthands[key] || key

pseudo: pseudo?.name as any,
value,
identifier,
rules,
}
if (process.env.NODE_ENV === 'test') {
styleObject.value = value
}
out.push(styleObject)
}
if (process.env.NODE_ENV === 'development' && process.env.TAMAGUI_DEBUG) {
// when Animated.Value gets passed into Tamagui problems are caused this helps debug
if (
out.find((x) => x.property === 'transform' && x.value.includes(`[object Object]`))
) {
// rome-ignore lint/suspicious/noDebugger: only dev
debugger
}
}
return out

@@ -137,4 +112,4 @@ }

// box-shadow
const { shadowOffset, shadowRadius, shadowColor } = style
if (style.shadowRadius !== undefined) {
if ('shadowRadius' in style) {
const { shadowOffset, shadowRadius, shadowColor } = style
const offset = shadowOffset || defaultOffset

@@ -153,4 +128,8 @@ const shadow = `${normalizeValueWithProperty(

// text-shadow
const { textShadowColor, textShadowOffset, textShadowRadius } = style
if (textShadowColor || textShadowOffset || textShadowRadius) {
if (
'textShadowColor' in style ||
'textShadowOffset' in style ||
'textShadowRadius' in style
) {
const { textShadowColor, textShadowOffset, textShadowRadius } = style
const { height, width } = textShadowOffset || defaultOffset

@@ -171,7 +150,6 @@ const radius = textShadowRadius || 0

function createDeclarationBlock(style: Record<string, any>, important = false) {
function createDeclarationBlock(style: [string, any][], important = false) {
let next = ''
for (const key in style) {
for (const [key, value] of style) {
const prop = hyphenateStyleName(key)
const value = style[key]
next += `${prop}:${value}${important ? ' !important' : ''};`

@@ -185,5 +163,5 @@ }

const hyphenateStyleName = (key: string) => {
let val = hcache[key]
if (val) return val
hcache[key] = val = key.replace(/[A-Z]/g, toHyphenLower)
if (key in hcache) return hcache[key]
const val = key.replace(/[A-Z]/g, toHyphenLower)
hcache[key] = val
return val

@@ -219,3 +197,9 @@ }

case 'placeholderTextColor': {
const block = createDeclarationBlock({ color: value, opacity: 1 }, important)
const block = createDeclarationBlock(
[
['color', value],
['opacity', 1],
],
important
)
rules.push(`${selector}::placeholder${block}`)

@@ -231,3 +215,6 @@ break

const block = createDeclarationBlock(
{ [property]: value, [webkitProperty]: value },
[
[property, value],
[webkitProperty, value],
],
important

@@ -253,3 +240,3 @@ )

}
const block = createDeclarationBlock({ pointerEvents: finalValue }, true)
const block = createDeclarationBlock([['pointerEvents', finalValue]], true)
rules.push(`${selector}${block}`)

@@ -260,3 +247,3 @@ break

default: {
const block = createDeclarationBlock({ [property]: value }, important)
const block = createDeclarationBlock([[property, value]], important)
rules.push(`${selector}${block}`)

@@ -279,3 +266,3 @@ break

const boxNone = createDeclarationBlock({ pointerEvents: 'auto' }, true)
const boxOnly = createDeclarationBlock({ pointerEvents: 'none' }, true)
const boxNone = createDeclarationBlock([['pointerEvents', 'auto']], true)
const boxOnly = createDeclarationBlock([['pointerEvents', 'none']], true)

@@ -12,8 +12,5 @@ /**

const colorCache = {}
const colorCache = new Map()
export function normalizeValueWithProperty(value: any, property?: string): any {
if (value in colorCache) {
return colorCache[value]
}
if (property && property in unitlessNumbers) {

@@ -24,6 +21,13 @@ return value

if (property && (property in normalizeStylePropKeys || value in names)) {
if (colorCache.has(value)) {
return colorCache.get(value)
}
res = normalizeColor(value)
colorCache[value] = res
// avoid memory pressure
if (colorCache.size > 1000) {
colorCache.clear()
}
colorCache.set(value, res)
} else if (
process.env.TAMAGUI_TARGET === 'web' &&
isWeb &&
typeof value === 'number' &&

@@ -30,0 +34,0 @@ (property === undefined ||

@@ -24,4 +24,4 @@ /**

export declare function getVariableVariable(v: Variable | any): any;
export declare const createCSSVariable: (nameProp: string, includeVar?: boolean) => string;
export declare const createCSSVariable: (nameProp: string, includeVar?: boolean) => any;
export {};
//# sourceMappingURL=createVariable.d.ts.map

@@ -9,4 +9,4 @@ /**

export declare function getStylesAtomic(stylesIn: ViewStyleWithPseudos): StyleObject[];
export declare function getAtomicStyle(style: ViewStyleWithPseudos, pseudo?: PseudoDescriptor): StyleObject[];
export declare const generateAtomicStyles: (styleIn: ViewStyleWithPseudos, pseudo?: PseudoDescriptor) => StyleObject[];
export declare function styleToCSS(style: Record<string, any>): void;
//# sourceMappingURL=getStylesAtomic.d.ts.map

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc