@tamagui/web
Advanced tools
Comparing version 1.2.13 to 1.2.14
@@ -92,3 +92,3 @@ "use strict"; | ||
for (const key in style) { | ||
const value = style[key]; | ||
const value = (0, import_normalizeValueWithProperty.normalizeValueWithProperty)(style[key], key); | ||
if (value == null || value == void 0) | ||
@@ -115,3 +115,2 @@ continue; | ||
}; | ||
const n = import_normalizeValueWithProperty.normalizeValueWithProperty; | ||
function styleToCSS(style) { | ||
@@ -121,3 +120,5 @@ const { shadowOffset, shadowRadius, shadowColor } = style; | ||
const offset = shadowOffset || import_expandStyles.defaultOffset; | ||
const shadow = `${n(offset.width)} ${n(offset.height)} ${n( | ||
const shadow = `${(0, import_normalizeValueWithProperty.normalizeValueWithProperty)( | ||
offset.width | ||
)} ${(0, import_normalizeValueWithProperty.normalizeValueWithProperty)(offset.height)} ${(0, import_normalizeValueWithProperty.normalizeValueWithProperty)( | ||
shadowRadius | ||
@@ -124,0 +125,0 @@ )} ${shadowColor}`; |
@@ -28,5 +28,5 @@ "use strict"; | ||
var import_normalizeColor = require("./normalizeColor"); | ||
const cache = {}; | ||
const colorCache = {}; | ||
function normalizeValueWithProperty(value, property) { | ||
const cached = cache[value]; | ||
const cached = colorCache[value]; | ||
if (cached !== void 0) { | ||
@@ -39,9 +39,9 @@ return cached; | ||
let res = value; | ||
if (process.env.TAMAGUI_TARGET === "web" && typeof value === "number" && (property === void 0 || !(unitlessNumbers[property] || stringNumbers[property]))) { | ||
if (process.env.TAMAGUI_TARGET === "web" && typeof value === "number" && (property === void 0 || !(property in unitlessNumbers || property in stringNumbers))) { | ||
res = `${value}px`; | ||
} else if (import_constants.isWeb && property !== void 0 && stringNumbers[property]) { | ||
} else if (import_constants.isWeb && property !== void 0 && property in stringNumbers) { | ||
res = `${res}`; | ||
} else if (property && property in colorProps) { | ||
res = (0, import_normalizeColor.normalizeColor)(value); | ||
cache[value] = res; | ||
colorCache[value] = res; | ||
} | ||
@@ -48,0 +48,0 @@ return res; |
@@ -67,3 +67,3 @@ import { simpleHash } from "@tamagui/helpers"; | ||
for (const key in style) { | ||
const value = style[key]; | ||
const value = normalizeValueWithProperty(style[key], key); | ||
if (value == null || value == void 0) | ||
@@ -90,3 +90,2 @@ continue; | ||
}; | ||
const n = normalizeValueWithProperty; | ||
function styleToCSS(style) { | ||
@@ -96,3 +95,5 @@ const { shadowOffset, shadowRadius, shadowColor } = style; | ||
const offset = shadowOffset || defaultOffset; | ||
const shadow = `${n(offset.width)} ${n(offset.height)} ${n( | ||
const shadow = `${normalizeValueWithProperty( | ||
offset.width | ||
)} ${normalizeValueWithProperty(offset.height)} ${normalizeValueWithProperty( | ||
shadowRadius | ||
@@ -99,0 +100,0 @@ )} ${shadowColor}`; |
import { isWeb } from "@tamagui/constants"; | ||
import { getAllSelectors } from "./insertStyleRule"; | ||
import { normalizeColor } from "./normalizeColor"; | ||
const cache = {}; | ||
const colorCache = {}; | ||
function normalizeValueWithProperty(value, property) { | ||
const cached = cache[value]; | ||
const cached = colorCache[value]; | ||
if (cached !== void 0) { | ||
@@ -14,9 +14,9 @@ return cached; | ||
let res = value; | ||
if (process.env.TAMAGUI_TARGET === "web" && typeof value === "number" && (property === void 0 || !(unitlessNumbers[property] || stringNumbers[property]))) { | ||
if (process.env.TAMAGUI_TARGET === "web" && typeof value === "number" && (property === void 0 || !(property in unitlessNumbers || property in stringNumbers))) { | ||
res = `${value}px`; | ||
} else if (isWeb && property !== void 0 && stringNumbers[property]) { | ||
} else if (isWeb && property !== void 0 && property in stringNumbers) { | ||
res = `${res}`; | ||
} else if (property && property in colorProps) { | ||
res = normalizeColor(value); | ||
cache[value] = res; | ||
colorCache[value] = res; | ||
} | ||
@@ -23,0 +23,0 @@ return res; |
{ | ||
"name": "@tamagui/web", | ||
"version": "1.2.13", | ||
"version": "1.2.14", | ||
"source": "src/index.ts", | ||
@@ -30,9 +30,9 @@ "main": "dist/cjs", | ||
"dependencies": { | ||
"@tamagui/compose-refs": "^1.2.13", | ||
"@tamagui/constants": "^1.2.13", | ||
"@tamagui/helpers": "^1.2.13", | ||
"@tamagui/normalize-css-color": "^1.2.13", | ||
"@tamagui/use-did-finish-ssr": "^1.2.13", | ||
"@tamagui/use-event": "^1.2.13", | ||
"@tamagui/use-force-update": "^1.2.13" | ||
"@tamagui/compose-refs": "^1.2.14", | ||
"@tamagui/constants": "^1.2.14", | ||
"@tamagui/helpers": "^1.2.14", | ||
"@tamagui/normalize-css-color": "^1.2.14", | ||
"@tamagui/use-did-finish-ssr": "^1.2.14", | ||
"@tamagui/use-event": "^1.2.14", | ||
"@tamagui/use-force-update": "^1.2.14" | ||
}, | ||
@@ -44,3 +44,3 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@tamagui/build": "^1.2.13", | ||
"@tamagui/build": "^1.2.14", | ||
"@testing-library/react": "^13.4.0", | ||
@@ -47,0 +47,0 @@ "csstype": "^3.0.10", |
@@ -108,3 +108,3 @@ /** | ||
for (const key in style) { | ||
const value = style[key] | ||
const value = normalizeValueWithProperty(style[key], key) | ||
if (value == null || value == undefined) continue | ||
@@ -138,4 +138,2 @@ const hash = presetHashes[value] | ||
const n = normalizeValueWithProperty | ||
export function styleToCSS(style: Record<string, any>) { | ||
@@ -146,3 +144,5 @@ // box-shadow | ||
const offset = shadowOffset || defaultOffset | ||
const shadow = `${n(offset.width)} ${n(offset.height)} ${n( | ||
const shadow = `${normalizeValueWithProperty( | ||
offset.width | ||
)} ${normalizeValueWithProperty(offset.height)} ${normalizeValueWithProperty( | ||
shadowRadius | ||
@@ -149,0 +149,0 @@ )} ${shadowColor}` |
@@ -11,6 +11,6 @@ /** | ||
const cache = {} | ||
const colorCache = {} | ||
export function normalizeValueWithProperty(value: any, property?: string): any { | ||
const cached = cache[value] | ||
const cached = colorCache[value] | ||
if (cached !== undefined) { | ||
@@ -26,10 +26,11 @@ return cached | ||
typeof value === 'number' && | ||
(property === undefined || !(unitlessNumbers[property] || stringNumbers[property])) | ||
(property === undefined || | ||
!(property in unitlessNumbers || property in stringNumbers)) | ||
) { | ||
res = `${value}px` | ||
} else if (isWeb && property !== undefined && stringNumbers[property]) { | ||
} else if (isWeb && property !== undefined && property in stringNumbers) { | ||
res = `${res}` | ||
} else if (property && property in colorProps) { | ||
res = normalizeColor(value) | ||
cache[value] = res | ||
colorCache[value] = res | ||
} | ||
@@ -36,0 +37,0 @@ return res |
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
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
2007482
27970