vira 31.8.0 → 31.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/pop-up/vira-menu-item.element.js +1 -0
- package/dist/icons/index.d.ts +1 -1
- package/dist/icons/index.js +1 -1
- package/dist/icons/lucide-icons.d.ts +21 -0
- package/dist/icons/lucide-icons.js +89 -0
- package/package.json +3 -5
- package/dist/icons/feather-icons.d.ts +0 -24
- package/dist/icons/feather-icons.js +0 -89
package/dist/icons/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './colored-icon.js';
|
|
2
|
-
export * from './feather-icons.js';
|
|
3
2
|
export * from './icon-css-vars.js';
|
|
4
3
|
export * from './icon-svg.js';
|
|
4
|
+
export * from './lucide-icons.js';
|
|
5
5
|
export * from './sized-icon.js';
|
|
6
6
|
export * from './icon-svgs/16/check-16.icon.js';
|
|
7
7
|
export * from './icon-svgs/16/chevron-down-16.icon.js';
|
package/dist/icons/index.js
CHANGED
|
@@ -55,9 +55,9 @@ import { Sun24Icon } from './icon-svgs/24/sun-24.icon.js';
|
|
|
55
55
|
import { Upload24Icon } from './icon-svgs/24/upload-24.icon.js';
|
|
56
56
|
import { X24Icon } from './icon-svgs/24/x-24.icon.js';
|
|
57
57
|
export * from './colored-icon.js';
|
|
58
|
-
export * from './feather-icons.js';
|
|
59
58
|
export * from './icon-css-vars.js';
|
|
60
59
|
export * from './icon-svg.js';
|
|
60
|
+
export * from './lucide-icons.js';
|
|
61
61
|
export * from './sized-icon.js';
|
|
62
62
|
export * from './icon-svgs/16/check-16.icon.js';
|
|
63
63
|
export * from './icon-svgs/16/chevron-down-16.icon.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as lucideStaticImport from 'lucide-static';
|
|
2
|
+
import { type ViraIconSvg } from './icon-svg.js';
|
|
3
|
+
/**
|
|
4
|
+
* All supported Lucide icon names.
|
|
5
|
+
*
|
|
6
|
+
* @category Internal
|
|
7
|
+
*/
|
|
8
|
+
export type LucideIconKey = keyof typeof lucideStaticImport;
|
|
9
|
+
/**
|
|
10
|
+
* An entry in {@link lucideIcons}.
|
|
11
|
+
*
|
|
12
|
+
* @category Internal
|
|
13
|
+
*/
|
|
14
|
+
export type LucideIconEntry = ViraIconSvg & ((options: Readonly<Record<string, string | number>>) => ViraIconSvg);
|
|
15
|
+
/**
|
|
16
|
+
* All [Lucide icons](https://lucide.dev) in a format compatible with `ViraIcon`. Each icon entry
|
|
17
|
+
* can be accessed directly or customized by calling it as a function.
|
|
18
|
+
*
|
|
19
|
+
* @category Icon
|
|
20
|
+
*/
|
|
21
|
+
export declare const lucideIcons: Readonly<Record<LucideIconKey, LucideIconEntry>>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { html, unsafeHTML } from 'element-vir';
|
|
2
|
+
import * as lucideStaticImport from 'lucide-static';
|
|
3
|
+
import { viraIconCssVars } from './icon-css-vars.js';
|
|
4
|
+
const defaultLucideAttributes = {
|
|
5
|
+
fill: String(viraIconCssVars['vira-icon-fill-color'].value),
|
|
6
|
+
stroke: String(viraIconCssVars['vira-icon-stroke-color'].value),
|
|
7
|
+
'stroke-width': String(viraIconCssVars['vira-icon-stroke-width'].value),
|
|
8
|
+
};
|
|
9
|
+
function setSvgAttribute(svgString, attributeName, value) {
|
|
10
|
+
const escapedName = attributeName.replace(/[.*+?^${}()|[\]\\]/g, String.raw `\$&`);
|
|
11
|
+
const regex = new RegExp(String.raw `(\s)${escapedName}="[^"]*"`);
|
|
12
|
+
return regex.test(svgString)
|
|
13
|
+
? svgString.replace(regex, `$1${attributeName}="${value}"`)
|
|
14
|
+
: svgString.replace(/<svg\b/, `<svg ${attributeName}="${value}"`);
|
|
15
|
+
}
|
|
16
|
+
function applySvgAttributes(svgString, attributes) {
|
|
17
|
+
return Object.entries(attributes).reduce((result, [key, value,]) => setSvgAttribute(result, key, String(value)), svgString);
|
|
18
|
+
}
|
|
19
|
+
function isLucideIconKey(key) {
|
|
20
|
+
return key in lucideStaticImport;
|
|
21
|
+
}
|
|
22
|
+
function getLucideIconSvg(key) {
|
|
23
|
+
const svg = lucideStaticImport[key];
|
|
24
|
+
if (typeof svg !== 'string') {
|
|
25
|
+
throw new TypeError(`Lucide icon "${key}" is not a valid SVG string.`);
|
|
26
|
+
}
|
|
27
|
+
return svg;
|
|
28
|
+
}
|
|
29
|
+
function createLucideIconEntry(iconKey) {
|
|
30
|
+
const svgString = getLucideIconSvg(iconKey);
|
|
31
|
+
const configureIconCallback = (options) => {
|
|
32
|
+
return {
|
|
33
|
+
name: iconKey,
|
|
34
|
+
svgTemplate: html `
|
|
35
|
+
${unsafeHTML(applySvgAttributes(svgString, {
|
|
36
|
+
...defaultLucideAttributes,
|
|
37
|
+
...options,
|
|
38
|
+
}))}
|
|
39
|
+
`,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(configureIconCallback, 'name', {
|
|
43
|
+
value: iconKey,
|
|
44
|
+
writable: false,
|
|
45
|
+
configurable: true,
|
|
46
|
+
});
|
|
47
|
+
return Object.assign(configureIconCallback, {
|
|
48
|
+
svgTemplate: html `
|
|
49
|
+
${unsafeHTML(applySvgAttributes(svgString, defaultLucideAttributes))}
|
|
50
|
+
`,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const lucideIconCache = new Map();
|
|
54
|
+
/**
|
|
55
|
+
* All [Lucide icons](https://lucide.dev) in a format compatible with `ViraIcon`. Each icon entry
|
|
56
|
+
* can be accessed directly or customized by calling it as a function.
|
|
57
|
+
*
|
|
58
|
+
* @category Icon
|
|
59
|
+
*/
|
|
60
|
+
export const lucideIcons = new Proxy({}, {
|
|
61
|
+
get(_target, property) {
|
|
62
|
+
if (!isLucideIconKey(property)) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
const cached = lucideIconCache.get(property);
|
|
66
|
+
if (cached) {
|
|
67
|
+
return cached;
|
|
68
|
+
}
|
|
69
|
+
const entry = createLucideIconEntry(property);
|
|
70
|
+
lucideIconCache.set(property, entry);
|
|
71
|
+
return entry;
|
|
72
|
+
},
|
|
73
|
+
has(_target, property) {
|
|
74
|
+
return isLucideIconKey(property);
|
|
75
|
+
},
|
|
76
|
+
ownKeys() {
|
|
77
|
+
return Object.keys(lucideStaticImport);
|
|
78
|
+
},
|
|
79
|
+
getOwnPropertyDescriptor(_target, property) {
|
|
80
|
+
if (isLucideIconKey(property)) {
|
|
81
|
+
return {
|
|
82
|
+
configurable: true,
|
|
83
|
+
enumerable: true,
|
|
84
|
+
writable: false,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return undefined;
|
|
88
|
+
},
|
|
89
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vira",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.9.0",
|
|
4
4
|
"description": "A simple and highly versatile design system using element-vir.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design",
|
|
@@ -53,15 +53,14 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@augment-vir/test": "^31.68.1",
|
|
56
|
-
"@types/feather-icons": "^4.29.4",
|
|
57
56
|
"@web/dev-server-esbuild": "^1.0.5",
|
|
58
57
|
"@web/test-runner": "^0.20.2",
|
|
59
58
|
"@web/test-runner-commands": "^0.9.0",
|
|
60
59
|
"@web/test-runner-playwright": "^0.11.1",
|
|
61
60
|
"@web/test-runner-visual-regression": "^0.10.0",
|
|
62
61
|
"esbuild": "^0.27.3",
|
|
63
|
-
"feather-icons": "^4.29.2",
|
|
64
62
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
63
|
+
"lucide-static": "^0.577.0",
|
|
65
64
|
"markdown-code-example-inserter": "^3.0.3",
|
|
66
65
|
"theme-vir": "^28.23.1",
|
|
67
66
|
"typedoc": "^0.28.17",
|
|
@@ -70,9 +69,8 @@
|
|
|
70
69
|
"vite-tsconfig-paths": "^6.1.1"
|
|
71
70
|
},
|
|
72
71
|
"peerDependencies": {
|
|
73
|
-
"@types/feather-icons": ">=4",
|
|
74
72
|
"element-vir": ">=26",
|
|
75
|
-
"
|
|
73
|
+
"lucide-static": ">=0.460",
|
|
76
74
|
"theme-vir": ">=28"
|
|
77
75
|
},
|
|
78
76
|
"engines": {
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type * as featherIconsImportType from 'feather-icons';
|
|
2
|
-
import { type FeatherAttributes } from 'feather-icons';
|
|
3
|
-
import { type ViraIconSvg } from './icon-svg.js';
|
|
4
|
-
declare const featherIconsImported: typeof featherIconsImportType;
|
|
5
|
-
/**
|
|
6
|
-
* All supported feather icon names.
|
|
7
|
-
*
|
|
8
|
-
* @category Internal
|
|
9
|
-
*/
|
|
10
|
-
export type FeatherIconKey = keyof typeof featherIconsImported.icons;
|
|
11
|
-
/**
|
|
12
|
-
* An entry in {@link featherIcons}.
|
|
13
|
-
*
|
|
14
|
-
* @category Internal
|
|
15
|
-
*/
|
|
16
|
-
export type FeatherIconEntry = ViraIconSvg & ((options: Readonly<Partial<FeatherAttributes>>) => ViraIconSvg);
|
|
17
|
-
/**
|
|
18
|
-
* All [Feather icons](https://feathericons.com) in a format compatible with `ViraIcon`. Each icon
|
|
19
|
-
* entry can be accessed directly or customized by calling it as a function.
|
|
20
|
-
*
|
|
21
|
-
* @category Icon
|
|
22
|
-
*/
|
|
23
|
-
export declare const featherIcons: Readonly<Record<FeatherIconKey, FeatherIconEntry>>;
|
|
24
|
-
export {};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { check } from '@augment-vir/assert';
|
|
2
|
-
import { html, unsafeHTML } from 'element-vir';
|
|
3
|
-
import { viraIconCssVars } from './icon-css-vars.js';
|
|
4
|
-
/** Feather's export format is all messed up so we have to do this to catch all its possible cases. */
|
|
5
|
-
async function importFeatherIcons() {
|
|
6
|
-
const imported = (await import('feather-icons'));
|
|
7
|
-
function recurseImport(imported) {
|
|
8
|
-
if (check.isObject(imported)) {
|
|
9
|
-
if (check.hasKey(imported, 'default')) {
|
|
10
|
-
return recurseImport(imported.default);
|
|
11
|
-
}
|
|
12
|
-
else if (check.hasKey(imported, 'icons')) {
|
|
13
|
-
return imported;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
return (recurseImport(imported) ||
|
|
19
|
-
/** Unfortunately, Feather will attach itself to the global state sometimes. */
|
|
20
|
-
globalThis.feather);
|
|
21
|
-
}
|
|
22
|
-
const featherIconsImported = await importFeatherIcons();
|
|
23
|
-
const defaultFeatherOptions = {
|
|
24
|
-
fill: String(viraIconCssVars['vira-icon-fill-color'].value),
|
|
25
|
-
stroke: String(viraIconCssVars['vira-icon-stroke-color'].value),
|
|
26
|
-
'stroke-width': String(viraIconCssVars['vira-icon-stroke-width'].value),
|
|
27
|
-
};
|
|
28
|
-
function createFeatherIconEntry(iconKey) {
|
|
29
|
-
const featherIcon = featherIconsImported.icons[iconKey];
|
|
30
|
-
const configureIconCallback = (options) => {
|
|
31
|
-
return {
|
|
32
|
-
name: featherIcon.name,
|
|
33
|
-
svgTemplate: html `
|
|
34
|
-
${unsafeHTML(featherIcon.toSvg({
|
|
35
|
-
...defaultFeatherOptions,
|
|
36
|
-
...options,
|
|
37
|
-
}))}
|
|
38
|
-
`,
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(configureIconCallback, 'name', {
|
|
42
|
-
value: featherIcon.name,
|
|
43
|
-
writable: false,
|
|
44
|
-
configurable: true,
|
|
45
|
-
});
|
|
46
|
-
return Object.assign(configureIconCallback, {
|
|
47
|
-
svgTemplate: html `
|
|
48
|
-
${unsafeHTML(featherIcon.toSvg(defaultFeatherOptions))}
|
|
49
|
-
`,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const featherIconCache = new Map();
|
|
53
|
-
/**
|
|
54
|
-
* All [Feather icons](https://feathericons.com) in a format compatible with `ViraIcon`. Each icon
|
|
55
|
-
* entry can be accessed directly or customized by calling it as a function.
|
|
56
|
-
*
|
|
57
|
-
* @category Icon
|
|
58
|
-
*/
|
|
59
|
-
export const featherIcons = new Proxy({}, {
|
|
60
|
-
get(_target, property) {
|
|
61
|
-
const iconKey = property;
|
|
62
|
-
if (!(iconKey in featherIconsImported.icons)) {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
const cached = featherIconCache.get(iconKey);
|
|
66
|
-
if (cached) {
|
|
67
|
-
return cached;
|
|
68
|
-
}
|
|
69
|
-
const entry = createFeatherIconEntry(iconKey);
|
|
70
|
-
featherIconCache.set(iconKey, entry);
|
|
71
|
-
return entry;
|
|
72
|
-
},
|
|
73
|
-
has(_target, property) {
|
|
74
|
-
return property in featherIconsImported.icons;
|
|
75
|
-
},
|
|
76
|
-
ownKeys() {
|
|
77
|
-
return Object.keys(featherIconsImported.icons);
|
|
78
|
-
},
|
|
79
|
-
getOwnPropertyDescriptor(_target, property) {
|
|
80
|
-
if (property in featherIconsImported.icons) {
|
|
81
|
-
return {
|
|
82
|
-
configurable: true,
|
|
83
|
-
enumerable: true,
|
|
84
|
-
writable: false,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
return undefined;
|
|
88
|
-
},
|
|
89
|
-
});
|