@iconify/react
Advanced tools
Comparing version 4.0.0-beta.2 to 4.0.0
@@ -60,8 +60,10 @@ 'use strict'; | ||
const defaultIconDimensions = Object.freeze({ | ||
left: 0, | ||
top: 0, | ||
width: 16, | ||
height: 16 | ||
}); | ||
const defaultIconDimensions = Object.freeze( | ||
{ | ||
left: 0, | ||
top: 0, | ||
width: 16, | ||
height: 16 | ||
} | ||
); | ||
const defaultIconTransformations = Object.freeze({ | ||
@@ -100,9 +102,9 @@ rotate: 0, | ||
for (const key in defaultExtendedIconProps) { | ||
if (defaultIconTransformations[key] !== void 0) { | ||
if (result[key] === void 0 && parent[key] !== void 0) { | ||
if (key in defaultIconTransformations) { | ||
if (key in parent && !(key in result)) { | ||
result[key] = defaultIconTransformations[key]; | ||
} | ||
} else if (child[key] !== void 0) { | ||
} else if (key in child) { | ||
result[key] = child[key]; | ||
} else if (parent[key] !== void 0) { | ||
} else if (key in parent) { | ||
result[key] = parent[key]; | ||
@@ -122,3 +124,3 @@ } | ||
} | ||
if (resolved[name] === void 0) { | ||
if (!(name in resolved)) { | ||
resolved[name] = null; | ||
@@ -142,3 +144,6 @@ const parent = aliases[name] && aliases[name].parent; | ||
function parse(name2) { | ||
currentProps = mergeIconData(icons[name2] || aliases[name2], currentProps); | ||
currentProps = mergeIconData( | ||
icons[name2] || aliases[name2], | ||
currentProps | ||
); | ||
} | ||
@@ -180,3 +185,3 @@ parse(name); | ||
for (const prop in defaults) { | ||
if (item[prop] !== void 0 && typeof item[prop] !== typeof defaults[prop]) { | ||
if (prop in item && typeof item[prop] !== typeof defaults[prop]) { | ||
return false; | ||
@@ -201,3 +206,6 @@ } | ||
const icon = icons[name]; | ||
if (!name.match(matchIconName) || typeof icon.body !== "string" || !checkOptionalProps(icon, defaultExtendedIconProps)) { | ||
if (!name.match(matchIconName) || typeof icon.body !== "string" || !checkOptionalProps( | ||
icon, | ||
defaultExtendedIconProps | ||
)) { | ||
return null; | ||
@@ -210,3 +218,6 @@ } | ||
const parent = icon.parent; | ||
if (!name.match(matchIconName) || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(icon, defaultExtendedIconProps)) { | ||
if (!name.match(matchIconName) || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps( | ||
icon, | ||
defaultExtendedIconProps | ||
)) { | ||
return null; | ||
@@ -260,3 +271,7 @@ } | ||
const storage = getStorage(provider2, prefix2); | ||
allIcons = allIcons.concat(Object.keys(storage.icons).map((name) => (provider2 !== "" ? "@" + provider2 + ":" : "") + prefix2 + ":" + name)); | ||
allIcons = allIcons.concat( | ||
Object.keys(storage.icons).map( | ||
(name) => (provider2 !== "" ? "@" + provider2 + ":" : "") + prefix2 + ":" + name | ||
) | ||
); | ||
}); | ||
@@ -295,5 +310,5 @@ }); | ||
if (typeof provider !== "string") { | ||
provider = typeof data.provider === "string" ? data.provider : ""; | ||
provider = data.provider || ""; | ||
} | ||
if (simpleNames && provider === "" && (typeof data.prefix !== "string" || data.prefix === "")) { | ||
if (simpleNames && !provider && !data.prefix) { | ||
let added = false; | ||
@@ -310,5 +325,6 @@ if (quicklyValidateIconSet(data)) { | ||
} | ||
if (typeof data.prefix !== "string" || !validateIconName({ | ||
const prefix = data.prefix; | ||
if (!validateIconName({ | ||
provider, | ||
prefix: data.prefix, | ||
prefix, | ||
name: "a" | ||
@@ -318,3 +334,3 @@ })) { | ||
} | ||
const storage = getStorage(provider, data.prefix); | ||
const storage = getStorage(provider, prefix); | ||
return !!addIconSet(storage, data); | ||
@@ -348,3 +364,3 @@ } | ||
} | ||
precision = precision === void 0 ? 100 : precision; | ||
precision = precision || 100; | ||
if (typeof size === "number") { | ||
@@ -407,3 +423,5 @@ return Math.ceil(size * ratio * precision) / precision; | ||
} else { | ||
transformations.push("translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"); | ||
transformations.push( | ||
"translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")" | ||
); | ||
transformations.push("scale(-1 1)"); | ||
@@ -413,3 +431,5 @@ box.top = box.left = 0; | ||
} else if (vFlip) { | ||
transformations.push("translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"); | ||
transformations.push( | ||
"translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")" | ||
); | ||
transformations.push("scale(1 -1)"); | ||
@@ -426,10 +446,16 @@ box.top = box.left = 0; | ||
tempValue = box.height / 2 + box.top; | ||
transformations.unshift("rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"); | ||
transformations.unshift( | ||
"rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")" | ||
); | ||
break; | ||
case 2: | ||
transformations.unshift("rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"); | ||
transformations.unshift( | ||
"rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")" | ||
); | ||
break; | ||
case 3: | ||
tempValue = box.width / 2 + box.left; | ||
transformations.unshift("rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"); | ||
transformations.unshift( | ||
"rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")" | ||
); | ||
break; | ||
@@ -492,3 +518,6 @@ } | ||
const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); | ||
body = body.replace(new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"), "$1" + newID + "$3"); | ||
body = body.replace( | ||
new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"), | ||
"$1" + newID + "$3" | ||
); | ||
}); | ||
@@ -724,12 +753,6 @@ return body; | ||
const name = icon.name; | ||
if (storage[provider] === void 0) { | ||
storage[provider] = /* @__PURE__ */ Object.create(null); | ||
} | ||
const providerStorage = storage[provider]; | ||
if (providerStorage[prefix] === void 0) { | ||
providerStorage[prefix] = getStorage(provider, prefix); | ||
} | ||
const localStorage = providerStorage[prefix]; | ||
const providerStorage = storage[provider] || (storage[provider] = /* @__PURE__ */ Object.create(null)); | ||
const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix)); | ||
let list; | ||
if (localStorage.icons[name] !== void 0) { | ||
if (name in localStorage.icons) { | ||
list = result.loaded; | ||
@@ -779,3 +802,3 @@ } else if (prefix === "" || localStorage.missing.has(name)) { | ||
const name = icon.name; | ||
if (storage.icons[name] !== void 0) { | ||
if (storage.icons[name]) { | ||
icons.loaded.push({ | ||
@@ -802,3 +825,8 @@ provider, | ||
} | ||
item.callback(icons.loaded.slice(0), icons.missing.slice(0), icons.pending.slice(0), item.abort); | ||
item.callback( | ||
icons.loaded.slice(0), | ||
icons.missing.slice(0), | ||
icons.pending.slice(0), | ||
item.abort | ||
); | ||
} | ||
@@ -831,3 +859,3 @@ }); | ||
list.forEach((item) => { | ||
const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames) : { ...item }; | ||
const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames) : item; | ||
if (icon) { | ||
@@ -1018,8 +1046,13 @@ result.push(icon); | ||
function query(payload, queryCallback, doneCallback) { | ||
const query2 = sendQuery(config, payload, queryCallback, (data, error) => { | ||
cleanup(); | ||
if (doneCallback) { | ||
doneCallback(data, error); | ||
const query2 = sendQuery( | ||
config, | ||
payload, | ||
queryCallback, | ||
(data, error) => { | ||
cleanup(); | ||
if (doneCallback) { | ||
doneCallback(data, error); | ||
} | ||
} | ||
}); | ||
); | ||
queries.push(query2); | ||
@@ -1049,3 +1082,3 @@ return query2; | ||
function getRedundancyCache(provider) { | ||
if (redundancyCache[provider] === void 0) { | ||
if (!redundancyCache[provider]) { | ||
const config = getAPIConfig(provider); | ||
@@ -1211,3 +1244,6 @@ if (!config) { | ||
const prefix = iconSet.prefix; | ||
const storage = getStorage(provider, prefix); | ||
const storage = getStorage( | ||
provider, | ||
prefix | ||
); | ||
if (!addIconSet(storage, iconSet).length) { | ||
@@ -1263,3 +1299,7 @@ return false; | ||
}; | ||
return setStoredItem(func, browserCachePrefix + index.toString(), JSON.stringify(item)); | ||
return setStoredItem( | ||
func, | ||
browserCachePrefix + index.toString(), | ||
JSON.stringify(item) | ||
); | ||
} | ||
@@ -1321,3 +1361,6 @@ if (data.lastModified && !updateLastModified(storage, data.lastModified)) { | ||
try { | ||
const parsed = addIconSet(storage, data); | ||
const parsed = addIconSet( | ||
storage, | ||
data | ||
); | ||
if (!parsed.length) { | ||
@@ -1351,3 +1394,8 @@ return; | ||
if (callCallback) { | ||
callback(sortedIcons.loaded, sortedIcons.missing, sortedIcons.pending, emptyCallback); | ||
callback( | ||
sortedIcons.loaded, | ||
sortedIcons.missing, | ||
sortedIcons.pending, | ||
emptyCallback | ||
); | ||
} | ||
@@ -1354,0 +1402,0 @@ }); |
@@ -11,8 +11,10 @@ 'use strict'; | ||
const defaultIconDimensions = Object.freeze({ | ||
left: 0, | ||
top: 0, | ||
width: 16, | ||
height: 16 | ||
}); | ||
const defaultIconDimensions = Object.freeze( | ||
{ | ||
left: 0, | ||
top: 0, | ||
width: 16, | ||
height: 16 | ||
} | ||
); | ||
const defaultIconTransformations = Object.freeze({ | ||
@@ -51,9 +53,9 @@ rotate: 0, | ||
for (const key in defaultExtendedIconProps) { | ||
if (defaultIconTransformations[key] !== void 0) { | ||
if (result[key] === void 0 && parent[key] !== void 0) { | ||
if (key in defaultIconTransformations) { | ||
if (key in parent && !(key in result)) { | ||
result[key] = defaultIconTransformations[key]; | ||
} | ||
} else if (child[key] !== void 0) { | ||
} else if (key in child) { | ||
result[key] = child[key]; | ||
} else if (parent[key] !== void 0) { | ||
} else if (key in parent) { | ||
result[key] = parent[key]; | ||
@@ -73,3 +75,3 @@ } | ||
} | ||
if (resolved[name] === void 0) { | ||
if (!(name in resolved)) { | ||
resolved[name] = null; | ||
@@ -93,3 +95,6 @@ const parent = aliases[name] && aliases[name].parent; | ||
function parse(name2) { | ||
currentProps = mergeIconData(icons[name2] || aliases[name2], currentProps); | ||
currentProps = mergeIconData( | ||
icons[name2] || aliases[name2], | ||
currentProps | ||
); | ||
} | ||
@@ -133,3 +138,3 @@ parse(name); | ||
for (const prop in defaults) { | ||
if (item[prop] !== void 0 && typeof item[prop] !== typeof defaults[prop]) { | ||
if (prop in item && typeof item[prop] !== typeof defaults[prop]) { | ||
return false; | ||
@@ -154,3 +159,6 @@ } | ||
const icon = icons[name]; | ||
if (!name.match(matchIconName) || typeof icon.body !== "string" || !checkOptionalProps(icon, defaultExtendedIconProps)) { | ||
if (!name.match(matchIconName) || typeof icon.body !== "string" || !checkOptionalProps( | ||
icon, | ||
defaultExtendedIconProps | ||
)) { | ||
return null; | ||
@@ -163,3 +171,6 @@ } | ||
const parent = icon.parent; | ||
if (!name.match(matchIconName) || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(icon, defaultExtendedIconProps)) { | ||
if (!name.match(matchIconName) || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps( | ||
icon, | ||
defaultExtendedIconProps | ||
)) { | ||
return null; | ||
@@ -251,3 +262,3 @@ } | ||
} | ||
precision = precision === void 0 ? 100 : precision; | ||
precision = precision || 100; | ||
if (typeof size === "number") { | ||
@@ -310,3 +321,5 @@ return Math.ceil(size * ratio * precision) / precision; | ||
} else { | ||
transformations.push("translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"); | ||
transformations.push( | ||
"translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")" | ||
); | ||
transformations.push("scale(-1 1)"); | ||
@@ -316,3 +329,5 @@ box.top = box.left = 0; | ||
} else if (vFlip) { | ||
transformations.push("translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"); | ||
transformations.push( | ||
"translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")" | ||
); | ||
transformations.push("scale(1 -1)"); | ||
@@ -329,10 +344,16 @@ box.top = box.left = 0; | ||
tempValue = box.height / 2 + box.top; | ||
transformations.unshift("rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"); | ||
transformations.unshift( | ||
"rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")" | ||
); | ||
break; | ||
case 2: | ||
transformations.unshift("rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"); | ||
transformations.unshift( | ||
"rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")" | ||
); | ||
break; | ||
case 3: | ||
tempValue = box.width / 2 + box.left; | ||
transformations.unshift("rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"); | ||
transformations.unshift( | ||
"rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")" | ||
); | ||
break; | ||
@@ -395,3 +416,6 @@ } | ||
const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); | ||
body = body.replace(new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"), "$1" + newID + "$3"); | ||
body = body.replace( | ||
new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"), | ||
"$1" + newID + "$3" | ||
); | ||
}); | ||
@@ -398,0 +422,0 @@ return body; |
@@ -5,3 +5,3 @@ { | ||
"author": "Vjacheslav Trushkin", | ||
"version": "4.0.0-beta.2", | ||
"version": "4.0.0", | ||
"license": "MIT", | ||
@@ -38,19 +38,19 @@ "bugs": "https://github.com/iconify/iconify/issues", | ||
"dependencies": { | ||
"@iconify/types": "^2.0.0-beta.1" | ||
"@iconify/types": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/preset-env": "^7.18.2", | ||
"@babel/preset-react": "^7.17.12", | ||
"@iconify/core": "^2.0.0-beta.3", | ||
"@iconify/utils": "^2.0.0-beta.4", | ||
"@microsoft/api-extractor": "^7.25.2", | ||
"@rollup/plugin-node-resolve": "^13.3.0", | ||
"@types/react": "^17.0.47", | ||
"babel-jest": "^27.5.1", | ||
"jest": "^28.1.1", | ||
"react": "^17.0.2", | ||
"react-test-renderer": "^17.0.2", | ||
"@babel/preset-env": "^7.19.0", | ||
"@babel/preset-react": "^7.18.6", | ||
"@iconify/core": "^2.0.0", | ||
"@iconify/utils": "^2.0.0", | ||
"@microsoft/api-extractor": "^7.30.0", | ||
"@rollup/plugin-node-resolve": "^14.0.0", | ||
"@types/react": "^17.0.49", | ||
"babel-jest": "^29.0.2", | ||
"jest": "^29.0.2", | ||
"react": "^18.2.0", | ||
"react-test-renderer": "^18.2.0", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.75.6", | ||
"typescript": "^4.7.4" | ||
"rollup": "^2.79.0", | ||
"typescript": "^4.8.2" | ||
}, | ||
@@ -57,0 +57,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
174383
5652
0
Updated@iconify/types@^2.0.0