@iconify/vue
Advanced tools
Comparing version 3.1.4 to 3.2.0
@@ -584,8 +584,6 @@ import type { AllowedComponentProps } from 'vue'; | ||
export declare const loadIcon: (icon: IconifyIconName | string) => LoadIconResult; | ||
/** | ||
* Cache for loadIcon promises | ||
*/ | ||
declare type LoadIconResult = Promise<Required<IconifyIcon>>; | ||
export declare const loadIcon: (icon: IconifyIconName | string) => Promise<Required<IconifyIcon>>; | ||
@@ -592,0 +590,0 @@ /** |
@@ -7,5 +7,4 @@ (function (global, factory) { | ||
// src/icon/index.ts | ||
var matchName = /^[a-z0-9]+(-[a-z0-9]+)*$/; | ||
var iconDefaults = Object.freeze({ | ||
const matchName = /^[a-z0-9]+(-[a-z0-9]+)*$/; | ||
const iconDefaults = Object.freeze({ | ||
left: 0, | ||
@@ -23,3 +22,2 @@ top: 0, | ||
// src/icon/merge.ts | ||
function mergeIconData(icon, alias) { | ||
@@ -51,6 +49,4 @@ const result = { ...icon }; | ||
// src/icon-set/get-icon.ts | ||
function getIconData(data, name, full = false) { | ||
function getIcon(name2, iteration) { | ||
var _a, _b, _c, _d; | ||
if (data.icons[name2] !== void 0) { | ||
@@ -62,4 +58,4 @@ return Object.assign({}, data.icons[name2]); | ||
} | ||
if (((_a = data.aliases) == null ? void 0 : _a[name2]) !== void 0) { | ||
const item = (_b = data.aliases) == null ? void 0 : _b[name2]; | ||
if (data.aliases?.[name2] !== void 0) { | ||
const item = data.aliases?.[name2]; | ||
const result2 = getIcon(item.parent, iteration + 1); | ||
@@ -71,4 +67,4 @@ if (result2) { | ||
} | ||
if (iteration === 0 && ((_c = data.chars) == null ? void 0 : _c[name2]) !== void 0) { | ||
return getIcon((_d = data.chars) == null ? void 0 : _d[name2], iteration + 1); | ||
if (iteration === 0 && data.chars?.[name2] !== void 0) { | ||
return getIcon(data.chars?.[name2], iteration + 1); | ||
} | ||
@@ -88,4 +84,3 @@ return null; | ||
// src/icon-set/validate.ts | ||
var matchChar = /^[a-f0-9]+(-[a-f0-9]+)*$/; | ||
const matchChar = /^[a-f0-9]+(-[a-f0-9]+)*$/; | ||
function validateIconProps(item, fix) { | ||
@@ -147,4 +142,3 @@ for (const key in item) { | ||
function validateIconSet(obj, options) { | ||
var _a; | ||
const fix = !!(options == null ? void 0 : options.fix); | ||
const fix = !!options?.fix; | ||
if (typeof obj !== "object" || obj === null || typeof obj.icons !== "object" || !obj.icons) { | ||
@@ -154,3 +148,3 @@ throw new Error("Bad icon set"); | ||
const data = obj; | ||
if (typeof (options == null ? void 0 : options.prefix) === "string") { | ||
if (typeof options?.prefix === "string") { | ||
data.prefix = options.prefix; | ||
@@ -160,3 +154,3 @@ } else if (typeof data.prefix !== "string" || !data.prefix.match(matchName)) { | ||
} | ||
if (typeof (options == null ? void 0 : options.provider) === "string") { | ||
if (typeof options?.provider === "string") { | ||
data.provider = options.provider; | ||
@@ -206,3 +200,3 @@ } else if (data.provider !== void 0) { | ||
} | ||
if (!Object.keys(data.icons).length && !((_a = data.not_found) == null ? void 0 : _a.length)) { | ||
if (!Object.keys(data.icons).length && !data.not_found?.length) { | ||
throw new Error("Icon set is empty"); | ||
@@ -288,4 +282,3 @@ } | ||
Object.keys(chars).forEach((char) => { | ||
var _a2; | ||
if (!char.match(matchChar) || typeof chars[char] !== "string") { | ||
if (!matchChar.exec(char) || typeof chars[char] !== "string") { | ||
if (fix) { | ||
@@ -298,3 +291,3 @@ delete chars[char]; | ||
const target = chars[char]; | ||
if (data.icons[target] === void 0 && ((_a2 = data.aliases) == null ? void 0 : _a2[target]) === void 0) { | ||
if (data.icons[target] === void 0 && data.aliases?.[target] === void 0) { | ||
if (fix) { | ||
@@ -314,3 +307,2 @@ delete chars[char]; | ||
// src/icon-set/parse.ts | ||
function isVariation(item) { | ||
@@ -369,4 +361,3 @@ for (const key in iconDefaults) { | ||
// src/customisations/index.ts | ||
var defaults = Object.freeze({ | ||
const defaults = Object.freeze({ | ||
inline: false, | ||
@@ -426,4 +417,3 @@ width: null, | ||
// src/customisations/shorthand.ts | ||
var separator = /[\s,]+/; | ||
const separator = /[\s,]+/; | ||
function flipFromString(custom, flip) { | ||
@@ -466,3 +456,2 @@ flip.split(separator).forEach((str) => { | ||
// src/customisations/rotate.ts | ||
function rotateFromString(value, defaultValue = 0) { | ||
@@ -500,5 +489,4 @@ const units = value.replace(/^-?[0-9.]*/, ""); | ||
// src/svg/size.ts | ||
var unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g; | ||
var unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g; | ||
const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g; | ||
const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g; | ||
function calculateSize(size, ratio, precision) { | ||
@@ -541,3 +529,2 @@ if (ratio === 1) { | ||
// src/svg/build.ts | ||
function preserveAspectRatio(props) { | ||
@@ -585,3 +572,3 @@ let result = ""; | ||
} else { | ||
transformations.push("translate(" + (box.width + box.left) + " " + (0 - box.top) + ")"); | ||
transformations.push("translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"); | ||
transformations.push("scale(-1 1)"); | ||
@@ -591,3 +578,3 @@ box.top = box.left = 0; | ||
} else if (vFlip) { | ||
transformations.push("translate(" + (0 - box.left) + " " + (box.height + box.top) + ")"); | ||
transformations.push("translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"); | ||
transformations.push("scale(1 -1)"); | ||
@@ -604,10 +591,10 @@ box.top = box.left = 0; | ||
tempValue = box.height / 2 + box.top; | ||
transformations.unshift("rotate(90 " + tempValue + " " + tempValue + ")"); | ||
transformations.unshift("rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"); | ||
break; | ||
case 2: | ||
transformations.unshift("rotate(180 " + (box.width / 2 + box.left) + " " + (box.height / 2 + box.top) + ")"); | ||
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 + " " + tempValue + ")"); | ||
transformations.unshift("rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"); | ||
break; | ||
@@ -651,4 +638,4 @@ } | ||
} | ||
width = typeof width === "string" ? width : width + ""; | ||
height = typeof height === "string" ? height : height + ""; | ||
width = typeof width === "string" ? width : width.toString() + ""; | ||
height = typeof height === "string" ? height : height.toString() + ""; | ||
const result = { | ||
@@ -659,3 +646,3 @@ attributes: { | ||
preserveAspectRatio: preserveAspectRatio(customisations), | ||
viewBox: box.left + " " + box.top + " " + box.width + " " + box.height | ||
viewBox: box.left.toString() + " " + box.top.toString() + " " + box.width.toString() + " " + box.height.toString() | ||
}, | ||
@@ -670,6 +657,5 @@ body | ||
// src/svg/id.ts | ||
var regex = /\sid="(\S+)"/g; | ||
var randomPrefix = "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16); | ||
var counter = 0; | ||
const regex = /\sid="(\S+)"/g; | ||
const randomPrefix = "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16); | ||
let counter = 0; | ||
function replaceIDs(body, prefix = randomPrefix) { | ||
@@ -685,3 +671,3 @@ const ids = []; | ||
ids.forEach((id) => { | ||
const newID = typeof prefix === "function" ? prefix(id) : prefix + counter++; | ||
const newID = typeof prefix === "function" ? prefix(id) : prefix + (counter++).toString(); | ||
const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); | ||
@@ -688,0 +674,0 @@ body = body.replace(new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"), "$1" + newID + "$3"); |
@@ -5,3 +5,3 @@ { | ||
"author": "Vjacheslav Trushkin", | ||
"version": "3.1.4", | ||
"version": "3.2.0", | ||
"license": "MIT", | ||
@@ -22,3 +22,3 @@ "bugs": "https://github.com/iconify/iconify/issues", | ||
"build:api": "api-extractor run --local --verbose --config api-extractor.iconify.json", | ||
"test": "jest --runInBand" | ||
"test": "vitest" | ||
}, | ||
@@ -48,12 +48,12 @@ "main": "dist/iconify.js", | ||
"@babel/preset-env": "^7.16.11", | ||
"@iconify/core": "^1.2.4", | ||
"@iconify/core": "^1.3.0", | ||
"@microsoft/api-extractor": "^7.19.4", | ||
"@rollup/plugin-node-resolve": "^13.1.3", | ||
"@types/jest": "^27.4.0", | ||
"@vue/test-utils": "^2.0.0-rc.18", | ||
"@vue/vue3-jest": "^27.0.0-alpha.4", | ||
"babel-jest": "^27.4.6", | ||
"jest": "^27.4.7", | ||
"@types/jest": "^27.4.1", | ||
"@vitejs/plugin-vue": "^2.2.4", | ||
"@vue/test-utils": "^2.0.0-rc.17", | ||
"jsdom": "^19.0.0", | ||
"rollup": "^2.66.0", | ||
"typescript": "^4.5.5", | ||
"vitest": "^0.7.6", | ||
"vue": "3" | ||
@@ -60,0 +60,0 @@ }, |
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
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
18
224690
7092