This commit is contained in:
nik
2025-10-03 22:27:28 +03:00
parent 829fad0e17
commit 871cf7e792
16520 changed files with 2967597 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
/**
* Get boolean customisation value from attribute
*/
declare function toBoolean(name: string, value: unknown, defaultValue: boolean): boolean;
export { toBoolean };

20
node_modules/@iconify/utils/lib/customisations/bool.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
/**
* Get boolean customisation value from attribute
*/
function toBoolean(name, value, defaultValue) {
switch (typeof value) {
case "boolean": return value;
case "number": return !!value;
case "string": switch (value.toLowerCase()) {
case "1":
case "true":
case name.toLowerCase(): return true;
case "0":
case "false":
case "": return false;
}
}
return defaultValue;
}
export { toBoolean };

View File

@@ -0,0 +1,23 @@
import { IconifyTransformations } from "@iconify/types";
/**
* Icon size
*/
type IconifyIconSize = null | string | number;
/**
* Dimensions
*/
interface IconifyIconSizeCustomisations {
width?: IconifyIconSize;
height?: IconifyIconSize;
}
/**
* Icon customisations
*/
interface IconifyIconCustomisations extends IconifyTransformations, IconifyIconSizeCustomisations {}
type FullIconCustomisations = Required<IconifyIconCustomisations>;
/**
* Default icon customisations values
*/
declare const defaultIconSizeCustomisations: Required<IconifyIconSizeCustomisations>;
declare const defaultIconCustomisations: FullIconCustomisations;
export { FullIconCustomisations, IconifyIconCustomisations, IconifyIconSize, IconifyIconSizeCustomisations, defaultIconCustomisations, defaultIconSizeCustomisations };

View File

@@ -0,0 +1,15 @@
import { defaultIconTransformations } from "../icon/defaults.js";
/**
* Default icon customisations values
*/
const defaultIconSizeCustomisations = Object.freeze({
width: null,
height: null
});
const defaultIconCustomisations = Object.freeze({
...defaultIconSizeCustomisations,
...defaultIconTransformations
});
export { defaultIconCustomisations, defaultIconSizeCustomisations };

View File

@@ -0,0 +1,12 @@
import { IconifyIconCustomisations } from "./defaults.js";
/**
* Additional shorthand customisations
*/
interface ShorthandIconCustomisations {
flip?: string;
}
/**
* Apply "flip" string to icon customisations
*/
declare function flipFromString(custom: IconifyIconCustomisations, flip: string): void;
export { ShorthandIconCustomisations, flipFromString };

19
node_modules/@iconify/utils/lib/customisations/flip.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
const separator = /[\s,]+/;
/**
* Apply "flip" string to icon customisations
*/
function flipFromString(custom, flip) {
flip.split(separator).forEach((str) => {
const value = str.trim();
switch (value) {
case "horizontal":
custom.hFlip = true;
break;
case "vertical":
custom.vFlip = true;
break;
}
});
}
export { flipFromString };

View File

@@ -0,0 +1,6 @@
import { FullIconCustomisations, IconifyIconCustomisations } from "./defaults.js";
/**
* Convert IconifyIconCustomisations to FullIconCustomisations, checking value types
*/
declare function mergeCustomisations<T extends FullIconCustomisations>(defaults: T, item: IconifyIconCustomisations): T;
export { mergeCustomisations };

View File

@@ -0,0 +1,18 @@
import { defaultIconSizeCustomisations } from "./defaults.js";
/**
* Convert IconifyIconCustomisations to FullIconCustomisations, checking value types
*/
function mergeCustomisations(defaults, item) {
const result = { ...defaults };
for (const key in item) {
const value = item[key];
const valueType = typeof value;
if (key in defaultIconSizeCustomisations) {
if (value === null || value && (valueType === "string" || valueType === "number")) result[key] = value;
} else if (valueType === typeof result[key]) result[key] = key === "rotate" ? value % 4 : value;
}
return result;
}
export { mergeCustomisations };

View File

@@ -0,0 +1,5 @@
/**
* Get rotation value
*/
declare function rotateFromString(value: string, defaultValue?: number): number;
export { rotateFromString };

View File

@@ -0,0 +1,31 @@
/**
* Get rotation value
*/
function rotateFromString(value, defaultValue = 0) {
const units = value.replace(/^-?[0-9.]*/, "");
function cleanup(value$1) {
while (value$1 < 0) value$1 += 4;
return value$1 % 4;
}
if (units === "") {
const num = parseInt(value);
return isNaN(num) ? 0 : cleanup(num);
} else if (units !== value) {
let split = 0;
switch (units) {
case "%":
split = 25;
break;
case "deg": split = 90;
}
if (split) {
let num = parseFloat(value.slice(0, value.length - units.length));
if (isNaN(num)) return 0;
num = num / split;
return num % 1 === 0 ? cleanup(num) : 0;
}
}
return defaultValue;
}
export { rotateFromString };