@lumal/icons 0.0.3-beta → 0.0.4-beta
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/CHANGELOG.md +11 -0
- package/README.md +40 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -186
- package/dist/morph.cjs +1 -0
- package/dist/morph.js +180 -0
- package/dist/src/builtin-icons.d.ts.map +1 -1
- package/dist/src/morph/controller.d.ts +4 -0
- package/dist/src/morph/controller.d.ts.map +1 -0
- package/dist/src/morph/index.d.ts +4 -0
- package/dist/src/morph/index.d.ts.map +1 -0
- package/dist/src/morph/runtime.d.ts +12 -0
- package/dist/src/morph/runtime.d.ts.map +1 -0
- package/dist/src/morph/svg.d.ts +11 -0
- package/dist/src/morph/svg.d.ts.map +1 -0
- package/dist/src/morph/types.d.ts +26 -0
- package/dist/src/morph/types.d.ts.map +1 -0
- package/dist/src/runtime/svg.d.ts.map +1 -1
- package/dist/src-D3frEoCr.cjs +1 -0
- package/dist/src-DdoSzl-p.js +196 -0
- package/package.json +17 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @lumal/icons
|
|
2
2
|
|
|
3
|
+
## 0.0.4-beta (2026-10-20)
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 新增独立 morph 入口,提供 SVG 转换和原生 DOM 形变控制器;可选 Morphicons 2.0.0 按需加载,保留静态及 SSR 回退。
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- SVG Data URI 补齐独立图片命名空间,修正设置图标轮廓并补充状态图标。
|
|
12
|
+
- 补充 ESM/CJS、并发更新、销毁清理、减少动画和不支持图形的回归检查。
|
|
13
|
+
|
|
3
14
|
## 0.0.3-beta (2026-10-16)
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -18,4 +18,43 @@ registerIcons([
|
|
|
18
18
|
const blueSvg = recolorSvgString(svgText, '#1677ff')
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
静态根入口没有强制运行时依赖,也不引用 Vue。Vue 组件由 `@lumal/icons-vue` 提供;状态形变属于本包的通用可选入口,不影响 SVG/Data URI 输出或图标来源类型。
|
|
22
|
+
|
|
23
|
+
## 通用状态形变
|
|
24
|
+
|
|
25
|
+
当前仓库提供 `@lumal/icons/morph`;已发布版本请核对安装包的 `exports` 和声明文件。原生 DOM 或其他框架使用时显式安装可选 peer:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm add @lumal/icons@0.0.4-beta morphicons@2.0.0
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { createIconMorph, prepareIconMorph } from '@lumal/icons/morph'
|
|
33
|
+
|
|
34
|
+
// 应用侧在客户端传入专用图标容器,不接管按钮本身。
|
|
35
|
+
export function mountIcon(target: HTMLElement) {
|
|
36
|
+
const icon = createIconMorph(target, 'lumal:sidebar-collapse', { size: 20, spring: 'smooth' })
|
|
37
|
+
return {
|
|
38
|
+
ready: icon.ready,
|
|
39
|
+
collapse: () => icon.update('lumal:sidebar-expand'),
|
|
40
|
+
destroy: () => icon.destroy(),
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 返回 Morphicons 原生 IconInput,可交给官方 React/Svelte 等绑定。
|
|
45
|
+
const prepared = await prepareIconMorph('lumal:sun')
|
|
46
|
+
console.log(prepared?.icon)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- `createIconMorph` 同步显示静态 SVG,首次就绪不播放;`update(source, options?)` 切换目标,连续操作从中间形状继续。
|
|
50
|
+
- `ready` 和 `update` 返回 `Promise<boolean>`,`false` 表示静态回退或任务失效。选项包含 `enabled`、`spring`、`size`、`color`、`title`,默认开启、`smooth`、`1em`。
|
|
51
|
+
- 容器只放图标,卸载时调用 `destroy()`。关闭、减少动画、转换失败会清理实例并恢复静态目标;销毁也取消异步任务和监听。
|
|
52
|
+
- `prepareIconMorph` 支持注册名、直接定义和可信单色 SVG;SSR、加载失败或不能保真转换时返回 `undefined`,由框架保留原来的静态渲染。返回值还包含 `d`、`shape`、颜色及描边元数据。
|
|
53
|
+
- 原生控制器只渲染本地 SVG;组件、Iconify 和未知名称由消费方处理,渐变和其他复杂 SVG 保持静态。转换数据不依赖框架,其他框架绑定的生命周期、静态回退和减少动画策略由消费方负责。
|
|
54
|
+
- Morphicons 仅为可选 peer,通过动态 `import()` 加载;静态根入口无需安装或加载引擎。ESM/CJS 均保留动态边界。
|
|
55
|
+
|
|
56
|
+
完整 API 边界及 Vue 调用方式见仓库 `docs/icons.md`。
|
|
57
|
+
|
|
58
|
+
内置图标包含 `lumal:menu`、`lumal:search`、`lumal:arrow-up`、`lumal:arrow-down`、`lumal:arrow-right`、`lumal:copy` 和 `lumal:download` 等通用操作。Admin 的“功能示例 / 图标”提供图标库、三种来源、渲染参数、选择器和 SVG 工具示例。
|
|
59
|
+
|
|
60
|
+
系统状态图标包含太阳/月亮、`lumal:sidebar-expand` / `lumal:sidebar-collapse`、`lumal:maximize` / `lumal:restore` 和 `lumal:fullscreen` / `lumal:fullscreen-exit`。侧栏图标统一为 24×24 单色描边,最大化图标仅保留描边轮廓。
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./src-D3frEoCr.cjs");exports.applySvgGradient=e.a,exports.builtinIconDefinitions=e.S,exports.clearIconDataUriCache=e.t,exports.composeSvgIcons=e.o,exports.createComponentIconDefinitions=e.g,exports.createIconifyIconDefinitions=e._,exports.getGradientIconDataUri=e.n,exports.getIconDataUri=e.r,exports.getIconSvgText=e.i,exports.getRegisteredIconDefinitions=e.v,exports.getRegisteredIconGroups=e.m,exports.getStaticLocalSvgIconDefinitions=e.d,exports.recolorSvgString=e.s,exports.registerIconGroups=e.h,exports.registerIcons=e.y,exports.registerStaticLocalSvgIcons=e.f,exports.resolveAnyIconDefinition=e.u,exports.resolveIconDefinition=e.b,exports.resolveStaticLocalSvgIconDefinition=e.p,exports.subscribeIconRegistry=e.x,exports.svgToDataUri=e.c,exports.validateMonochromeSvg=e.l;
|
package/dist/index.js
CHANGED
|
@@ -1,186 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return {
|
|
4
|
-
group: "lumal",
|
|
5
|
-
key: `lumal:${e}`,
|
|
6
|
-
label: t,
|
|
7
|
-
source: "local-svg",
|
|
8
|
-
svgText: `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">${n}</svg>`
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
var t = [
|
|
12
|
-
e("sun", "浅色模式", "<circle cx=\"12\" cy=\"12\" r=\"4\" fill=\"currentColor\"/><path d=\"M12 2v2M12 20v2M4.93 4.93l1.42 1.42M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.42-1.42M17.66 6.34l1.41-1.41\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/>"),
|
|
13
|
-
e("moon", "深色模式", "<path d=\"M20.2 15.4A8.5 8.5 0 0 1 8.6 3.8 8.5 8.5 0 1 0 20.2 15.4Z\" fill=\"currentColor\"/>"),
|
|
14
|
-
e("monitor", "跟随系统", "<rect x=\"3\" y=\"4\" width=\"18\" height=\"13\" rx=\"2\" stroke=\"currentColor\" stroke-width=\"1.8\"/><path d=\"M8 21h8M12 17v4\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/>"),
|
|
15
|
-
e("palette", "主题设置", "<path d=\"M12 3a9 9 0 0 0 0 18h1.3a2.2 2.2 0 0 0 1.56-3.76l-.38-.38a1.1 1.1 0 0 1 .78-1.86H17a4 4 0 0 0 3.72-5.47A9 9 0 0 0 12 3Z\" stroke=\"currentColor\" stroke-width=\"1.7\"/><circle cx=\"7.5\" cy=\"10\" r=\"1.2\" fill=\"currentColor\"/><circle cx=\"10.5\" cy=\"6.8\" r=\"1.2\" fill=\"currentColor\"/><circle cx=\"15\" cy=\"7.5\" r=\"1.2\" fill=\"currentColor\"/>"),
|
|
16
|
-
e("settings", "设置", "<path d=\"M12 8.5a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7Z\" stroke=\"currentColor\" stroke-width=\"1.8\"/><path d=\"m19.4 15 .1-1-.1-1 2-1.5-2-3.4-2.5 1a8 8 0 0 0-1.7-1L14.8 5h-4l-.4 3.1a8 8 0 0 0-1.7 1l-2.5-1-2 3.4 2 1.5-.1 1 .1 1-2 1.5 2 3.4 2.5-1a8 8 0 0 0 1.7 1l.4 3.1h4l.4-3.1a8 8 0 0 0 1.7-1l2.5 1 2-3.4-2-1.5Z\" stroke=\"currentColor\" stroke-width=\"1.4\" stroke-linejoin=\"round\"/>"),
|
|
17
|
-
e("reset", "恢复默认", "<path d=\"M4 7v5h5M5.5 11A7 7 0 1 1 7 18.5\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"),
|
|
18
|
-
e("plus", "新增", "<path d=\"M12 5v14M5 12h14\" stroke=\"currentColor\" stroke-width=\"1.9\" stroke-linecap=\"round\"/>"),
|
|
19
|
-
e("filter", "筛选", "<path d=\"M4 5h16l-6.2 7.1v5.2l-3.6 1.8v-7L4 5Z\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linejoin=\"round\"/>"),
|
|
20
|
-
e("refresh", "刷新", "<path d=\"M20 7v5h-5M4 17v-5h5M18.5 11A7 7 0 0 0 6 7.5L4 10M5.5 13A7 7 0 0 0 18 16.5l2-2.5\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"),
|
|
21
|
-
e("fullscreen", "全屏", "<path d=\"M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"),
|
|
22
|
-
e("fullscreen-exit", "退出全屏", "<path d=\"M9 4v5H4M20 9h-5V4M15 20v-5h5M4 15h5v5\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"),
|
|
23
|
-
e("grid", "列设置", "<rect x=\"4\" y=\"4\" width=\"6\" height=\"6\" rx=\"1\" stroke=\"currentColor\" stroke-width=\"1.7\"/><rect x=\"14\" y=\"4\" width=\"6\" height=\"6\" rx=\"1\" stroke=\"currentColor\" stroke-width=\"1.7\"/><rect x=\"4\" y=\"14\" width=\"6\" height=\"6\" rx=\"1\" stroke=\"currentColor\" stroke-width=\"1.7\"/><rect x=\"14\" y=\"14\" width=\"6\" height=\"6\" rx=\"1\" stroke=\"currentColor\" stroke-width=\"1.7\"/>"),
|
|
24
|
-
e("close", "关闭", "<path d=\"M6 6l12 12M18 6L6 18\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/>"),
|
|
25
|
-
e("chevron-left", "上一页", "<path d=\"M15 6l-6 6 6 6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" fill=\"none\"/>"),
|
|
26
|
-
e("chevron-right", "下一页", "<path d=\"M9 6l6 6-6 6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" fill=\"none\"/>"),
|
|
27
|
-
e("more", "更多", "<circle cx=\"5\" cy=\"12\" r=\"1.6\" fill=\"currentColor\"/><circle cx=\"12\" cy=\"12\" r=\"1.6\" fill=\"currentColor\"/><circle cx=\"19\" cy=\"12\" r=\"1.6\" fill=\"currentColor\"/>"),
|
|
28
|
-
e("pin", "固定", "<path d=\"M9 4h6l-1 6 4 3v2H6v-2l4-3-1-6Z\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linejoin=\"round\" fill=\"none\"/><path d=\"M12 14v6\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linecap=\"round\"/>"),
|
|
29
|
-
e("pin-off", "取消固定", "<path d=\"M9 4h6l-1 6 4 3v2H6v-2l4-3-1-6Z\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linejoin=\"round\" fill=\"none\"/><path d=\"M12 14v6M4 4l16 16\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linecap=\"round\"/>"),
|
|
30
|
-
e("external-link", "新窗口打开", "<path d=\"M14 4h6v6M20 4l-8 8M14 4H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linecap=\"round\" stroke-linejoin=\"round\" fill=\"none\"/>"),
|
|
31
|
-
e("maximize", "内容最大化", "<path d=\"M8 3H3v5M16 3h5v5M3 16v5h5M21 16v5h-5\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linecap=\"round\" stroke-linejoin=\"round\" fill=\"none\"/><path d=\"M3 12h18\" stroke=\"currentColor\" stroke-width=\"1.4\" stroke-linecap=\"round\" stroke-dasharray=\"2 3\" opacity=\"0.45\"/>"),
|
|
32
|
-
e("restore", "还原", "<path d=\"M8 3v3a2 2 0 0 1-2 2H3M16 3v3a2 2 0 0 0 2 2h3M3 16h3a2 2 0 0 1 2 2v3M21 16h-3a2 2 0 0 0-2 2v3\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linecap=\"round\" stroke-linejoin=\"round\" fill=\"none\"/>")
|
|
33
|
-
], n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
34
|
-
function a() {
|
|
35
|
-
for (let e of i) e();
|
|
36
|
-
}
|
|
37
|
-
function o(e) {
|
|
38
|
-
return i.add(e), () => {
|
|
39
|
-
i.delete(e);
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/registry/icons.ts
|
|
44
|
-
function s(e) {
|
|
45
|
-
for (let t of e) n.set(t.key, t);
|
|
46
|
-
e.length && a();
|
|
47
|
-
}
|
|
48
|
-
function c(e) {
|
|
49
|
-
return n.get(e);
|
|
50
|
-
}
|
|
51
|
-
function l() {
|
|
52
|
-
return [...n.values()];
|
|
53
|
-
}
|
|
54
|
-
function u(e, t) {
|
|
55
|
-
return Object.entries(t).map(([t, n]) => ({
|
|
56
|
-
component: n,
|
|
57
|
-
group: e,
|
|
58
|
-
key: `${e}:${t}`,
|
|
59
|
-
label: t,
|
|
60
|
-
source: "component"
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
function d(e, t) {
|
|
64
|
-
return t.map((t) => ({
|
|
65
|
-
group: e,
|
|
66
|
-
icon: t,
|
|
67
|
-
key: `${e}:${t}`,
|
|
68
|
-
label: t,
|
|
69
|
-
source: "iconify"
|
|
70
|
-
}));
|
|
71
|
-
}
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/registry/groups.ts
|
|
74
|
-
function f(e) {
|
|
75
|
-
for (let t of e) r.set(t.key, t);
|
|
76
|
-
e.length && a();
|
|
77
|
-
}
|
|
78
|
-
function p() {
|
|
79
|
-
return [...r.values()].sort((e, t) => (e.order ?? 2 ** 53 - 1) - (t.order ?? 2 ** 53 - 1) || e.label.localeCompare(t.label));
|
|
80
|
-
}
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region src/runtime/static-local.ts
|
|
83
|
-
var m = /* @__PURE__ */ new Map();
|
|
84
|
-
function h(e) {
|
|
85
|
-
for (let t of e) m.set(t.key, t);
|
|
86
|
-
s(e);
|
|
87
|
-
}
|
|
88
|
-
function g() {
|
|
89
|
-
return [...m.values()];
|
|
90
|
-
}
|
|
91
|
-
function _(e) {
|
|
92
|
-
return m.get(e) ?? c(e);
|
|
93
|
-
}
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/runtime/resolver.ts
|
|
96
|
-
function v(e) {
|
|
97
|
-
return c(e) ?? _(e);
|
|
98
|
-
}
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region src/runtime/svg.ts
|
|
101
|
-
var y = /currentColor/g, b = /(?:fill|stroke)=["']([^"']+)["']/gi;
|
|
102
|
-
function x(e) {
|
|
103
|
-
if (!/^\s*<svg\b[\s\S]*<\/svg>\s*$/i.test(e)) return {
|
|
104
|
-
reason: "内容不是完整 SVG",
|
|
105
|
-
valid: !1
|
|
106
|
-
};
|
|
107
|
-
if (/<script\b|\bon\w+\s*=|(?:href|src)=["']https?:/i.test(e)) return {
|
|
108
|
-
reason: "SVG 包含不安全的脚本或外部资源",
|
|
109
|
-
valid: !1
|
|
110
|
-
};
|
|
111
|
-
for (let t of e.matchAll(b)) {
|
|
112
|
-
let e = t[1]?.trim();
|
|
113
|
-
if (e && ![
|
|
114
|
-
"currentColor",
|
|
115
|
-
"inherit",
|
|
116
|
-
"none"
|
|
117
|
-
].includes(e) && !e.startsWith("url(#")) return {
|
|
118
|
-
reason: `检测到固定颜色 ${e}`,
|
|
119
|
-
valid: !1
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
return { valid: !0 };
|
|
123
|
-
}
|
|
124
|
-
function S(e) {
|
|
125
|
-
let t = e.filter((e) => x(e).valid);
|
|
126
|
-
if (t.length === 0) return "";
|
|
127
|
-
let n = t[0].match(/<svg\b([^>]*)>/i)?.[1]?.trim(), r = t.map((e, t) => `<g data-lumal-icon-layer="${t}">${e.replace(/^\s*<svg\b[^>]*>/i, "").replace(/<\/svg>\s*$/i, "")}</g>`).join("");
|
|
128
|
-
return `<svg${n ? ` ${n}` : ""}>${r}</svg>`;
|
|
129
|
-
}
|
|
130
|
-
function C(e) {
|
|
131
|
-
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`;
|
|
132
|
-
}
|
|
133
|
-
function w(e, t = "currentColor") {
|
|
134
|
-
return e.replace(y, t);
|
|
135
|
-
}
|
|
136
|
-
function T(e) {
|
|
137
|
-
return e.stops?.length ? e.stops : [{
|
|
138
|
-
offset: "0%",
|
|
139
|
-
color: e.from ?? "currentColor"
|
|
140
|
-
}, {
|
|
141
|
-
offset: "100%",
|
|
142
|
-
color: e.to ?? e.from ?? "currentColor"
|
|
143
|
-
}];
|
|
144
|
-
}
|
|
145
|
-
function E(e) {
|
|
146
|
-
let t = e.direction === "vertical", n = T(e).map((e) => {
|
|
147
|
-
let t = e.opacity == null ? "" : ` stop-opacity="${e.opacity}"`;
|
|
148
|
-
return `<stop offset="${e.offset}" stop-color="${e.color}"${t}/>`;
|
|
149
|
-
}).join("");
|
|
150
|
-
return `<defs><linearGradient id="${e.id}" x1="0%" y1="0%" x2="${t ? "0%" : "100%"}" y2="${t ? "100%" : "0%"}">${n}</linearGradient></defs>`;
|
|
151
|
-
}
|
|
152
|
-
function D(e, t) {
|
|
153
|
-
let n = t.id ?? "lumal-icon-gradient", r = E({
|
|
154
|
-
...t,
|
|
155
|
-
id: n
|
|
156
|
-
});
|
|
157
|
-
return e.replace(/<svg([^>]*)>/, `<svg$1>${r}`).replace(y, `url(#${n})`);
|
|
158
|
-
}
|
|
159
|
-
//#endregion
|
|
160
|
-
//#region src/runtime/data-uri.ts
|
|
161
|
-
var O = /* @__PURE__ */ new Map(), k = 256;
|
|
162
|
-
function A(e, t) {
|
|
163
|
-
let n = O.get(e);
|
|
164
|
-
if (n !== void 0) return n;
|
|
165
|
-
let r = t();
|
|
166
|
-
return O.size >= k && O.delete(O.keys().next().value), O.set(e, r), r;
|
|
167
|
-
}
|
|
168
|
-
function j() {
|
|
169
|
-
O.clear();
|
|
170
|
-
}
|
|
171
|
-
function M(e) {
|
|
172
|
-
return v(e)?.svgText ?? "";
|
|
173
|
-
}
|
|
174
|
-
function N(e, t) {
|
|
175
|
-
let n = M(e);
|
|
176
|
-
return n ? A(`${n}:${t ?? "currentColor"}`, () => C(w(n, t))) : "";
|
|
177
|
-
}
|
|
178
|
-
function P(e, t) {
|
|
179
|
-
let n = M(e);
|
|
180
|
-
return n ? A(`${n}:${JSON.stringify(t)}`, () => C(D(n, t))) : "";
|
|
181
|
-
}
|
|
182
|
-
//#endregion
|
|
183
|
-
//#region src/index.ts
|
|
184
|
-
s(t);
|
|
185
|
-
//#endregion
|
|
186
|
-
export { D as applySvgGradient, t as builtinIconDefinitions, j as clearIconDataUriCache, S as composeSvgIcons, u as createComponentIconDefinitions, d as createIconifyIconDefinitions, P as getGradientIconDataUri, N as getIconDataUri, M as getIconSvgText, l as getRegisteredIconDefinitions, p as getRegisteredIconGroups, g as getStaticLocalSvgIconDefinitions, w as recolorSvgString, f as registerIconGroups, s as registerIcons, h as registerStaticLocalSvgIcons, v as resolveAnyIconDefinition, c as resolveIconDefinition, _ as resolveStaticLocalSvgIconDefinition, o as subscribeIconRegistry, C as svgToDataUri, x as validateMonochromeSvg };
|
|
1
|
+
import { S as e, _ as t, a as n, b as r, c as i, d as a, f as o, g as s, h as c, i as l, l as u, m as d, n as f, o as p, p as m, r as h, s as g, t as _, u as v, v as y, x as b, y as x } from "./src-DdoSzl-p.js";
|
|
2
|
+
export { n as applySvgGradient, e as builtinIconDefinitions, _ as clearIconDataUriCache, p as composeSvgIcons, s as createComponentIconDefinitions, t as createIconifyIconDefinitions, f as getGradientIconDataUri, h as getIconDataUri, l as getIconSvgText, y as getRegisteredIconDefinitions, d as getRegisteredIconGroups, a as getStaticLocalSvgIconDefinitions, g as recolorSvgString, c as registerIconGroups, x as registerIcons, o as registerStaticLocalSvgIcons, v as resolveAnyIconDefinition, r as resolveIconDefinition, m as resolveStaticLocalSvgIconDefinition, b as subscribeIconRegistry, i as svgToDataUri, u as validateMonochromeSvg };
|
package/dist/morph.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./src-D3frEoCr.cjs");var t=new Set([`path`,`line`,`circle`,`ellipse`,`rect`,`polyline`,`polygon`]),n=new Set([`x`,`y`,`x1`,`y1`,`x2`,`y2`,`cx`,`cy`,`r`,`rx`,`ry`,`width`,`height`]),r=new Set(`xmlns.viewBox.width.height.version.id.role.focusable.preserveAspectRatio.fill.stroke.stroke-width.stroke-linecap.stroke-linejoin.fill-rule.d.x.y.x1.y1.x2.y2.cx.cy.r.rx.ry.points`.split(`.`));function i(e){if(typeof DOMParser>`u`)return;let i=new DOMParser().parseFromString(e,`image/svg+xml`),a=i.documentElement;if(a.localName!==`svg`||i.querySelector(`parsererror`))return;let o=a.getAttribute(`viewBox`)?.trim().split(/[\s,]+/).map(Number);if(!o||o.length!==4||!o.every(Number.isFinite)||o[2]<=0||o[3]<=0)return;let s=a.getAttribute(`preserveAspectRatio`);if(s&&s.trim()!==`xMidYMid meet`&&s.trim()!==`xMidYMid`)return;let c=new Set,l=[],u=!1,d=0;function f(e,i){let o=e.localName;if(!t.has(o)&&![`svg`,`g`,`title`,`desc`].includes(o)||o===`svg`&&e!==a||[...e.attributes].some(e=>!r.has(e.name)&&!/^(?:aria-|data-)/.test(e.name)))return!1;if(o===`title`||o===`desc`)return e.children.length===0;let s={...i};for(let t of[`fill`,`stroke`]){let n=e.getAttribute(t)?.trim();n&&n!==`inherit`&&(s[t]=n)}if(e.hasAttribute(`stroke-width`)&&(s.width=Number(e.getAttribute(`stroke-width`))),s.linecap=e.getAttribute(`stroke-linecap`)??i.linecap,s.linejoin=e.getAttribute(`stroke-linejoin`)??i.linejoin,!Number.isFinite(s.width)||s.width<=0)return!1;if(t.has(o)){if(d++,[...e.attributes].some(e=>n.has(e.name)&&!Number.isFinite(Number(e.value))))return!1;for(let e of[`fill`,`stroke`])if(s[e]!==`none`){if(/url\s*\(/i.test(s[e]))return!1;c.add(s[e])}if(s.fill!==`none`&&(u=!0),s.stroke!==`none`&&l.push(s),s.fill===`none`&&s.stroke===`none`)return!1;e.setAttribute(`fill`,s.fill),e.setAttribute(`stroke`,s.stroke)}return[...e.children].every(e=>f(e,s))}if(!f(a,{fill:`black`,stroke:`none`,width:1,linecap:`butt`,linejoin:`miter`})||!d||c.size!==1)return;let p=l[0];if(!l.some(e=>e.width!==p.width||e.linecap!==p.linecap||e.linejoin!==p.linejoin)&&!(u&&l.some(e=>e.linecap!==`round`||e.linejoin!==`round`)))return{svgText:a.outerHTML,filled:u,color:[...c][0],strokeWidth:(p?.width??2)*Math.min(24/o[2],24/o[3]),linecap:p?.linecap??`round`,linejoin:p?.linejoin??`round`}}var a;function o(){return a??=Promise.all([import(`morphicons/adapters`),import(`morphicons/dom`)]).then(async([e,t])=>({adapter:e,dom:t,region:await t.preloadRegion()})).catch(e=>{throw a=void 0,e}),a}function s(t){if(typeof t==`string`&&t.trim().startsWith(`<svg`))return t;let n=typeof t==`string`?e.u(t):t;return n?.source===`local-svg`?n.svgText??``:``}async function c(e){try{let t=i(s(e));if(!t)return;let{adapter:n,dom:r,region:a}=await o(),c=n.svgToIcon(t.svgText),l=t.filled?a.toRegion(c,{strokeWidth:t.strokeWidth}):c,u=r.canonicalD(l);return!u||/NaN|Infinity/.test(u)?void 0:{...t,icon:l,d:u,shape:`${t.filled}:${u}`}}catch{return}}function l(t,n,r={}){let i=n,a={enabled:!0,spring:`smooth`,...r},l=0,u=!1,d,f,p,m=t.ownerDocument.defaultView?.matchMedia?.(`(prefers-reduced-motion: reduce)`);function h(){d?.destroy(),d=void 0,f=void 0,p=void 0}function g(){t.innerHTML=e.s(s(i),a.color);let n=t.querySelector(`svg`);n&&(n.style.width=`100%`,n.style.height=`100%`,n.style.display=`block`)}function _(){let n=typeof a.size==`number`?`${a.size}px`:a.size??`1em`;t.style.display=`inline-flex`,t.style.width=n,t.style.height=n,t.style.color=a.color??``,t.setAttribute(`aria-hidden`,`true`);let r=typeof i==`string`?e.u(i):i;t.title=a.title??r?.label??``}function v(e){if(f)for(let[t,n]of Object.entries({color:e.color,stroke:e.color,"stroke-width":e.strokeWidth,"stroke-linecap":e.linecap,"stroke-linejoin":e.linejoin}))f.setAttribute(t,String(n))}async function y(e,n){if(u)return!1;let r=++l;if(i=e,a={...a,...n},_(),d||g(),a.enabled===!1||m?.matches)return h(),g(),!1;let s=await c(e);if(u||r!==l)return!1;if(!s)return h(),g(),!1;try{let{dom:e}=await o();if(u||r!==l)return!1;if(d)v(s),d.strokeWidth=s.strokeWidth,p?.shape!==s.shape&&d.morphTo(s.icon,a.spring);else{f=t.ownerDocument.createElementNS(`http://www.w3.org/2000/svg`,`svg`),f.setAttribute(`viewBox`,`0 0 24 24`),f.setAttribute(`width`,`100%`),f.setAttribute(`height`,`100%`),f.setAttribute(`fill`,`none`);let n=t.ownerDocument.createElementNS(`http://www.w3.org/2000/svg`,`path`);f.append(n),v(s),d=e.createMorph(n,s.icon,{reducedMotion:`user`,strokeWidth:s.strokeWidth}),t.replaceChildren(f)}return p=s,!0}catch{return h(),g(),!1}}function b(){y(i)}return typeof m?.addEventListener==`function`?m.addEventListener(`change`,b):m?.addListener?.(b),{ready:y(n),update:y,destroy(){u||(u=!0,l++,h(),g(),typeof m?.removeEventListener==`function`?m.removeEventListener(`change`,b):m?.removeListener?.(b))}}}exports.createIconMorph=l,exports.prepareIconMorph=c;
|
package/dist/morph.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { s as e, u as t } from "./src-DdoSzl-p.js";
|
|
2
|
+
//#region src/morph/svg.ts
|
|
3
|
+
var n = /* @__PURE__ */ new Set([
|
|
4
|
+
"path",
|
|
5
|
+
"line",
|
|
6
|
+
"circle",
|
|
7
|
+
"ellipse",
|
|
8
|
+
"rect",
|
|
9
|
+
"polyline",
|
|
10
|
+
"polygon"
|
|
11
|
+
]), r = /* @__PURE__ */ new Set([
|
|
12
|
+
"x",
|
|
13
|
+
"y",
|
|
14
|
+
"x1",
|
|
15
|
+
"y1",
|
|
16
|
+
"x2",
|
|
17
|
+
"y2",
|
|
18
|
+
"cx",
|
|
19
|
+
"cy",
|
|
20
|
+
"r",
|
|
21
|
+
"rx",
|
|
22
|
+
"ry",
|
|
23
|
+
"width",
|
|
24
|
+
"height"
|
|
25
|
+
]), i = /* @__PURE__ */ new Set(/* @__PURE__ */ "xmlns.viewBox.width.height.version.id.role.focusable.preserveAspectRatio.fill.stroke.stroke-width.stroke-linecap.stroke-linejoin.fill-rule.d.x.y.x1.y1.x2.y2.cx.cy.r.rx.ry.points".split("."));
|
|
26
|
+
function a(e) {
|
|
27
|
+
if (typeof DOMParser > "u") return;
|
|
28
|
+
let t = new DOMParser().parseFromString(e, "image/svg+xml"), a = t.documentElement;
|
|
29
|
+
if (a.localName !== "svg" || t.querySelector("parsererror")) return;
|
|
30
|
+
let o = a.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number);
|
|
31
|
+
if (!o || o.length !== 4 || !o.every(Number.isFinite) || o[2] <= 0 || o[3] <= 0) return;
|
|
32
|
+
let s = a.getAttribute("preserveAspectRatio");
|
|
33
|
+
if (s && s.trim() !== "xMidYMid meet" && s.trim() !== "xMidYMid") return;
|
|
34
|
+
let c = /* @__PURE__ */ new Set(), l = [], u = !1, d = 0;
|
|
35
|
+
function f(e, t) {
|
|
36
|
+
let o = e.localName;
|
|
37
|
+
if (!n.has(o) && ![
|
|
38
|
+
"svg",
|
|
39
|
+
"g",
|
|
40
|
+
"title",
|
|
41
|
+
"desc"
|
|
42
|
+
].includes(o) || o === "svg" && e !== a || [...e.attributes].some((e) => !i.has(e.name) && !/^(?:aria-|data-)/.test(e.name))) return !1;
|
|
43
|
+
if (o === "title" || o === "desc") return e.children.length === 0;
|
|
44
|
+
let s = { ...t };
|
|
45
|
+
for (let t of ["fill", "stroke"]) {
|
|
46
|
+
let n = e.getAttribute(t)?.trim();
|
|
47
|
+
n && n !== "inherit" && (s[t] = n);
|
|
48
|
+
}
|
|
49
|
+
if (e.hasAttribute("stroke-width") && (s.width = Number(e.getAttribute("stroke-width"))), s.linecap = e.getAttribute("stroke-linecap") ?? t.linecap, s.linejoin = e.getAttribute("stroke-linejoin") ?? t.linejoin, !Number.isFinite(s.width) || s.width <= 0) return !1;
|
|
50
|
+
if (n.has(o)) {
|
|
51
|
+
if (d++, [...e.attributes].some((e) => r.has(e.name) && !Number.isFinite(Number(e.value)))) return !1;
|
|
52
|
+
for (let e of ["fill", "stroke"]) if (s[e] !== "none") {
|
|
53
|
+
if (/url\s*\(/i.test(s[e])) return !1;
|
|
54
|
+
c.add(s[e]);
|
|
55
|
+
}
|
|
56
|
+
if (s.fill !== "none" && (u = !0), s.stroke !== "none" && l.push(s), s.fill === "none" && s.stroke === "none") return !1;
|
|
57
|
+
e.setAttribute("fill", s.fill), e.setAttribute("stroke", s.stroke);
|
|
58
|
+
}
|
|
59
|
+
return [...e.children].every((e) => f(e, s));
|
|
60
|
+
}
|
|
61
|
+
if (!f(a, {
|
|
62
|
+
fill: "black",
|
|
63
|
+
stroke: "none",
|
|
64
|
+
width: 1,
|
|
65
|
+
linecap: "butt",
|
|
66
|
+
linejoin: "miter"
|
|
67
|
+
}) || !d || c.size !== 1) return;
|
|
68
|
+
let p = l[0];
|
|
69
|
+
if (!l.some((e) => e.width !== p.width || e.linecap !== p.linecap || e.linejoin !== p.linejoin) && !(u && l.some((e) => e.linecap !== "round" || e.linejoin !== "round"))) return {
|
|
70
|
+
svgText: a.outerHTML,
|
|
71
|
+
filled: u,
|
|
72
|
+
color: [...c][0],
|
|
73
|
+
strokeWidth: (p?.width ?? 2) * Math.min(24 / o[2], 24 / o[3]),
|
|
74
|
+
linecap: p?.linecap ?? "round",
|
|
75
|
+
linejoin: p?.linejoin ?? "round"
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/morph/runtime.ts
|
|
80
|
+
var o;
|
|
81
|
+
function s() {
|
|
82
|
+
return o ??= Promise.all([import("morphicons/adapters"), import("morphicons/dom")]).then(async ([e, t]) => ({
|
|
83
|
+
adapter: e,
|
|
84
|
+
dom: t,
|
|
85
|
+
region: await t.preloadRegion()
|
|
86
|
+
})).catch((e) => {
|
|
87
|
+
throw o = void 0, e;
|
|
88
|
+
}), o;
|
|
89
|
+
}
|
|
90
|
+
function c(e) {
|
|
91
|
+
if (typeof e == "string" && e.trim().startsWith("<svg")) return e;
|
|
92
|
+
let n = typeof e == "string" ? t(e) : e;
|
|
93
|
+
return n?.source === "local-svg" ? n.svgText ?? "" : "";
|
|
94
|
+
}
|
|
95
|
+
async function l(e) {
|
|
96
|
+
try {
|
|
97
|
+
let t = a(c(e));
|
|
98
|
+
if (!t) return;
|
|
99
|
+
let { adapter: n, dom: r, region: i } = await s(), o = n.svgToIcon(t.svgText), l = t.filled ? i.toRegion(o, { strokeWidth: t.strokeWidth }) : o, u = r.canonicalD(l);
|
|
100
|
+
return !u || /NaN|Infinity/.test(u) ? void 0 : {
|
|
101
|
+
...t,
|
|
102
|
+
icon: l,
|
|
103
|
+
d: u,
|
|
104
|
+
shape: `${t.filled}:${u}`
|
|
105
|
+
};
|
|
106
|
+
} catch {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/morph/controller.ts
|
|
112
|
+
function u(n, r, i = {}) {
|
|
113
|
+
let a = r, o = {
|
|
114
|
+
enabled: !0,
|
|
115
|
+
spring: "smooth",
|
|
116
|
+
...i
|
|
117
|
+
}, u = 0, d = !1, f, p, m, h = n.ownerDocument.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)");
|
|
118
|
+
function g() {
|
|
119
|
+
f?.destroy(), f = void 0, p = void 0, m = void 0;
|
|
120
|
+
}
|
|
121
|
+
function _() {
|
|
122
|
+
n.innerHTML = e(c(a), o.color);
|
|
123
|
+
let t = n.querySelector("svg");
|
|
124
|
+
t && (t.style.width = "100%", t.style.height = "100%", t.style.display = "block");
|
|
125
|
+
}
|
|
126
|
+
function v() {
|
|
127
|
+
let e = typeof o.size == "number" ? `${o.size}px` : o.size ?? "1em";
|
|
128
|
+
n.style.display = "inline-flex", n.style.width = e, n.style.height = e, n.style.color = o.color ?? "", n.setAttribute("aria-hidden", "true");
|
|
129
|
+
let r = typeof a == "string" ? t(a) : a;
|
|
130
|
+
n.title = o.title ?? r?.label ?? "";
|
|
131
|
+
}
|
|
132
|
+
function y(e) {
|
|
133
|
+
if (p) for (let [t, n] of Object.entries({
|
|
134
|
+
color: e.color,
|
|
135
|
+
stroke: e.color,
|
|
136
|
+
"stroke-width": e.strokeWidth,
|
|
137
|
+
"stroke-linecap": e.linecap,
|
|
138
|
+
"stroke-linejoin": e.linejoin
|
|
139
|
+
})) p.setAttribute(t, String(n));
|
|
140
|
+
}
|
|
141
|
+
async function b(e, t) {
|
|
142
|
+
if (d) return !1;
|
|
143
|
+
let r = ++u;
|
|
144
|
+
if (a = e, o = {
|
|
145
|
+
...o,
|
|
146
|
+
...t
|
|
147
|
+
}, v(), f || _(), o.enabled === !1 || h?.matches) return g(), _(), !1;
|
|
148
|
+
let i = await l(e);
|
|
149
|
+
if (d || r !== u) return !1;
|
|
150
|
+
if (!i) return g(), _(), !1;
|
|
151
|
+
try {
|
|
152
|
+
let { dom: e } = await s();
|
|
153
|
+
if (d || r !== u) return !1;
|
|
154
|
+
if (f) y(i), f.strokeWidth = i.strokeWidth, m?.shape !== i.shape && f.morphTo(i.icon, o.spring);
|
|
155
|
+
else {
|
|
156
|
+
p = n.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "svg"), p.setAttribute("viewBox", "0 0 24 24"), p.setAttribute("width", "100%"), p.setAttribute("height", "100%"), p.setAttribute("fill", "none");
|
|
157
|
+
let t = n.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
158
|
+
p.append(t), y(i), f = e.createMorph(t, i.icon, {
|
|
159
|
+
reducedMotion: "user",
|
|
160
|
+
strokeWidth: i.strokeWidth
|
|
161
|
+
}), n.replaceChildren(p);
|
|
162
|
+
}
|
|
163
|
+
return m = i, !0;
|
|
164
|
+
} catch {
|
|
165
|
+
return g(), _(), !1;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function x() {
|
|
169
|
+
b(a);
|
|
170
|
+
}
|
|
171
|
+
return typeof h?.addEventListener == "function" ? h.addEventListener("change", x) : h?.addListener?.(x), {
|
|
172
|
+
ready: b(r),
|
|
173
|
+
update: b,
|
|
174
|
+
destroy() {
|
|
175
|
+
d || (d = !0, u++, g(), _(), typeof h?.removeEventListener == "function" ? h.removeEventListener("change", x) : h?.removeListener?.(x));
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
export { u as createIconMorph, l as prepareIconMorph };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-icons.d.ts","sourceRoot":"","sources":["../../src/builtin-icons.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAY7C,eAAO,MAAM,sBAAsB,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"builtin-icons.d.ts","sourceRoot":"","sources":["../../src/builtin-icons.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAY7C,eAAO,MAAM,sBAAsB,EAAE,cAAc,EAgClD,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IconMorphController, IconMorphOptions, IconMorphSource } from './types';
|
|
2
|
+
/** 接管独立图标容器的子节点;不依赖框架,也不接管按钮等父级业务事件。 */
|
|
3
|
+
export declare function createIconMorph(target: HTMLElement, initial: IconMorphSource, options?: IconMorphOptions): IconMorphController;
|
|
4
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/morph/controller.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,eAAe,EAAqB,MAAM,SAAS,CAAA;AAIxG,wCAAwC;AACxC,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,eAAe,EACxB,OAAO,GAAE,gBAAqB,GAC7B,mBAAmB,CAmIrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/morph/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IconMorphSource, PreparedIconMorph } from './types';
|
|
2
|
+
interface IconMorphRuntime {
|
|
3
|
+
adapter: typeof import('morphicons/adapters');
|
|
4
|
+
dom: typeof import('morphicons/dom');
|
|
5
|
+
region: typeof import('morphicons/region');
|
|
6
|
+
}
|
|
7
|
+
export declare function loadIconMorphRuntime(): Promise<IconMorphRuntime>;
|
|
8
|
+
export declare function resolveMorphSvgText(source: IconMorphSource): string;
|
|
9
|
+
/** unsupported、SSR 或可选引擎加载失败时返回 undefined,由消费层保留静态资源。 */
|
|
10
|
+
export declare function prepareIconMorph(source: IconMorphSource): Promise<PreparedIconMorph | undefined>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/morph/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAIjE,UAAU,gBAAgB;IACxB,OAAO,EAAE,cAAc,qBAAqB,CAAC,CAAA;IAC7C,GAAG,EAAE,cAAc,gBAAgB,CAAC,CAAA;IACpC,MAAM,EAAE,cAAc,mBAAmB,CAAC,CAAA;CAC3C;AAID,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAchE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAKnE;AAED,yDAAyD;AACzD,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAgBtG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface MorphSvg {
|
|
2
|
+
svgText: string;
|
|
3
|
+
color: string;
|
|
4
|
+
filled: boolean;
|
|
5
|
+
strokeWidth: number;
|
|
6
|
+
linecap: string;
|
|
7
|
+
linejoin: string;
|
|
8
|
+
}
|
|
9
|
+
/** 仅判定官方单路径渲染器能否保真转换,不承担 SVG 安全净化。 */
|
|
10
|
+
export declare function readMorphSvg(svgText: string): MorphSvg | undefined;
|
|
11
|
+
//# sourceMappingURL=svg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../../../src/morph/svg.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,OAAO,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;CACjB;AAmCD,sCAAsC;AACtC,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAkFlE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IconInput } from 'morphicons';
|
|
2
|
+
import type { IconDefinition } from '../types';
|
|
3
|
+
import type { MorphSvg } from './svg';
|
|
4
|
+
export type LumalIconMorphSpring = 'smooth' | 'snappy' | 'bouncy';
|
|
5
|
+
export type IconMorphSource = string | IconDefinition;
|
|
6
|
+
/** 可直接交给 Morphicons 的任意框架绑定,不包含 Vue 等框架对象。 */
|
|
7
|
+
export interface PreparedIconMorph extends MorphSvg {
|
|
8
|
+
icon: IconInput;
|
|
9
|
+
d: string;
|
|
10
|
+
shape: string;
|
|
11
|
+
}
|
|
12
|
+
export interface IconMorphOptions {
|
|
13
|
+
enabled?: boolean;
|
|
14
|
+
spring?: LumalIconMorphSpring;
|
|
15
|
+
size?: number | string;
|
|
16
|
+
color?: string;
|
|
17
|
+
title?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface IconMorphController {
|
|
20
|
+
/** 初始静态图标同步可见;就绪不触发入场动画。false 表示静态回退。 */
|
|
21
|
+
ready: Promise<boolean>;
|
|
22
|
+
update: (source: IconMorphSource, options?: IconMorphOptions) => Promise<boolean>;
|
|
23
|
+
/** 取消动画、异步任务与偏好监听,留下当前目标的静态 SVG。 */
|
|
24
|
+
destroy: () => void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/morph/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAErC,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;AACjE,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,cAAc,CAAA;AAErD,8CAA8C;AAC9C,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD,IAAI,EAAE,SAAS,CAAA;IACf,CAAC,EAAE,MAAM,CAAA;IACT,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,oBAAoB,CAAA;IAC7B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,yCAAyC;IACzC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IACvB,MAAM,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IACjF,oCAAoC;IACpC,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../../../src/runtime/svg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAoB,MAAM,UAAU,CAAA;AAKrE,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;CACf;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB,CAiB1E;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAa1D;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../../../src/runtime/svg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAoB,MAAM,UAAU,CAAA;AAKrE,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;CACf;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB,CAiB1E;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAa1D;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAOpD;AAED,oDAAoD;AACpD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,SAAiB,GAAG,MAAM,CAEhF;AA0BD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAMtF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,t,n){return{group:`lumal`,key:`lumal:${e}`,label:t,source:`local-svg`,svgText:`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">${n}</svg>`}}var t=[e(`sun`,`浅色模式`,`<circle cx="12" cy="12" r="4" fill="currentColor"/><path d="M12 2v2M12 20v2M4.93 4.93l1.42 1.42M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.42-1.42M17.66 6.34l1.41-1.41" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`),e(`moon`,`深色模式`,`<path d="M20.2 15.4A8.5 8.5 0 0 1 8.6 3.8 8.5 8.5 0 1 0 20.2 15.4Z" fill="currentColor"/>`),e(`monitor`,`跟随系统`,`<rect x="3" y="4" width="18" height="13" rx="2" stroke="currentColor" stroke-width="1.8"/><path d="M8 21h8M12 17v4" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>`),e(`palette`,`主题设置`,`<path d="M12 3a9 9 0 0 0 0 18h1.3a2.2 2.2 0 0 0 1.56-3.76l-.38-.38a1.1 1.1 0 0 1 .78-1.86H17a4 4 0 0 0 3.72-5.47A9 9 0 0 0 12 3Z" stroke="currentColor" stroke-width="1.7"/><circle cx="7.5" cy="10" r="1.2" fill="currentColor"/><circle cx="10.5" cy="6.8" r="1.2" fill="currentColor"/><circle cx="15" cy="7.5" r="1.2" fill="currentColor"/>`),e(`settings`,`设置`,`<path d="M10 3h4l.4 3.1a8 8 0 0 1 1.7 1l2.5-1 2 3.4-2 1.5.1 1-.1 1 2 1.5-2 3.4-2.5-1a8 8 0 0 1-1.7 1L14 21h-4l-.4-3.1a8 8 0 0 1-1.7-1l-2.5 1-2-3.4 2-1.5-.1-1 .1-1-2-1.5 2-3.4 2.5 1a8 8 0 0 1 1.7-1L10 3Z" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><circle cx="12" cy="12" r="3.5" stroke="currentColor" stroke-width="1.8"/>`),e(`reset`,`恢复默认`,`<path d="M4 7v5h5M5.5 11A7 7 0 1 1 7 18.5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`),e(`plus`,`新增`,`<path d="M12 5v14M5 12h14" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"/>`),e(`filter`,`筛选`,`<path d="M4 5h16l-6.2 7.1v5.2l-3.6 1.8v-7L4 5Z" stroke="currentColor" stroke-width="1.7" stroke-linejoin="round"/>`),e(`refresh`,`刷新`,`<path d="M20 7v5h-5M4 17v-5h5M18.5 11A7 7 0 0 0 6 7.5L4 10M5.5 13A7 7 0 0 0 18 16.5l2-2.5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`),e(`fullscreen`,`全屏`,`<path d="M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`),e(`fullscreen-exit`,`退出全屏`,`<path d="M9 4v5H4M20 9h-5V4M15 20v-5h5M4 15h5v5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`),e(`grid`,`列设置`,`<rect x="4" y="4" width="6" height="6" rx="1" stroke="currentColor" stroke-width="1.7"/><rect x="14" y="4" width="6" height="6" rx="1" stroke="currentColor" stroke-width="1.7"/><rect x="4" y="14" width="6" height="6" rx="1" stroke="currentColor" stroke-width="1.7"/><rect x="14" y="14" width="6" height="6" rx="1" stroke="currentColor" stroke-width="1.7"/>`),e(`close`,`关闭`,`<path d="M6 6l12 12M18 6L6 18" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>`),e(`menu`,`折叠菜单`,`<path d="M4 7h16M4 12h16M4 17h16" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>`),e(`sidebar-expand`,`展开侧边栏`,`<rect x="3" y="4" width="18" height="16" rx="2" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><path d="M9 4v16m4-11 3 3-3 3" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`),e(`sidebar-collapse`,`收起侧边栏`,`<rect x="3" y="4" width="18" height="16" rx="2" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><path d="M9 4v16m7-11-3 3 3 3" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`),e(`search`,`搜索`,`<circle cx="11" cy="11" r="7" stroke="currentColor" stroke-width="1.8"/><path d="m16.2 16.2 4 4" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>`),e(`arrow-up`,`上移`,`<path d="M12 20V4m-6 6 6-6 6 6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`),e(`arrow-down`,`下移`,`<path d="M12 4v16m-6-6 6 6 6-6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`),e(`arrow-right`,`前往`,`<path d="M4 12h16m-6-6 6 6-6 6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`),e(`copy`,`复制`,`<rect x="8" y="8" width="12" height="12" rx="2" stroke="currentColor" stroke-width="1.8"/><path d="M16 8V4H4v12h4" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/>`),e(`download`,`下载`,`<path d="M12 3v12m-5-5 5 5 5-5M4 16v5h16v-5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`),e(`chevron-left`,`上一页`,`<path d="M15 6l-6 6 6 6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" fill="none"/>`),e(`chevron-right`,`下一页`,`<path d="M9 6l6 6-6 6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" fill="none"/>`),e(`more`,`更多`,`<circle cx="5" cy="12" r="1.6" fill="currentColor"/><circle cx="12" cy="12" r="1.6" fill="currentColor"/><circle cx="19" cy="12" r="1.6" fill="currentColor"/>`),e(`pin`,`固定`,`<path d="M9 4h6l-1 6 4 3v2H6v-2l4-3-1-6Z" stroke="currentColor" stroke-width="1.7" stroke-linejoin="round" fill="none"/><path d="M12 14v6" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/>`),e(`pin-off`,`取消固定`,`<path d="M9 4h6l-1 6 4 3v2H6v-2l4-3-1-6Z" stroke="currentColor" stroke-width="1.7" stroke-linejoin="round" fill="none"/><path d="M12 14v6M4 4l16 16" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/>`),e(`external-link`,`新窗口打开`,`<path d="M14 4h6v6M20 4l-8 8M14 4H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" fill="none"/>`),e(`maximize`,`内容最大化`,`<path d="M8 3H3v5M16 3h5v5M3 16v5h5M21 16v5h-5" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" fill="none"/>`),e(`restore`,`还原`,`<path d="M8 3v3a2 2 0 0 1-2 2H3M16 3v3a2 2 0 0 0 2 2h3M3 16h3a2 2 0 0 1 2 2v3M21 16h-3a2 2 0 0 0-2 2v3" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" fill="none"/>`)],n=new Map,r=new Map,i=new Set;function a(){for(let e of i)e()}function o(e){return i.add(e),()=>{i.delete(e)}}function s(e){for(let t of e)n.set(t.key,t);e.length&&a()}function c(e){return n.get(e)}function l(){return[...n.values()]}function u(e,t){return Object.entries(t).map(([t,n])=>({component:n,group:e,key:`${e}:${t}`,label:t,source:`component`}))}function d(e,t){return t.map(t=>({group:e,icon:t,key:`${e}:${t}`,label:t,source:`iconify`}))}function f(e){for(let t of e)r.set(t.key,t);e.length&&a()}function p(){return[...r.values()].sort((e,t)=>(e.order??2**53-1)-(t.order??2**53-1)||e.label.localeCompare(t.label))}var m=new Map;function h(e){for(let t of e)m.set(t.key,t);s(e)}function g(){return[...m.values()]}function _(e){return m.get(e)??c(e)}function v(e){return c(e)??_(e)}var y=/currentColor/g,b=/(?:fill|stroke)=["']([^"']+)["']/gi;function x(e){if(!/^\s*<svg\b[\s\S]*<\/svg>\s*$/i.test(e))return{reason:`内容不是完整 SVG`,valid:!1};if(/<script\b|\bon\w+\s*=|(?:href|src)=["']https?:/i.test(e))return{reason:`SVG 包含不安全的脚本或外部资源`,valid:!1};for(let t of e.matchAll(b)){let e=t[1]?.trim();if(e&&![`currentColor`,`inherit`,`none`].includes(e)&&!e.startsWith(`url(#`))return{reason:`检测到固定颜色 ${e}`,valid:!1}}return{valid:!0}}function S(e){let t=e.filter(e=>x(e).valid);if(t.length===0)return``;let n=t[0].match(/<svg\b([^>]*)>/i)?.[1]?.trim(),r=t.map((e,t)=>`<g data-lumal-icon-layer="${t}">${e.replace(/^\s*<svg\b[^>]*>/i,``).replace(/<\/svg>\s*$/i,``)}</g>`).join(``);return`<svg${n?` ${n}`:``}>${r}</svg>`}function C(e){let t=e.replace(/<svg\b[^>]*>/i,e=>/\sxmlns\s*=/.test(e)?e:e.replace(/<svg\b/i,`$& xmlns="http://www.w3.org/2000/svg"`));return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}function w(e,t=`currentColor`){return e.replace(y,t)}function T(e){return e.stops?.length?e.stops:[{offset:`0%`,color:e.from??`currentColor`},{offset:`100%`,color:e.to??e.from??`currentColor`}]}function E(e){let t=e.direction===`vertical`,n=T(e).map(e=>{let t=e.opacity==null?``:` stop-opacity="${e.opacity}"`;return`<stop offset="${e.offset}" stop-color="${e.color}"${t}/>`}).join(``);return`<defs><linearGradient id="${e.id}" x1="0%" y1="0%" x2="${t?`0%`:`100%`}" y2="${t?`100%`:`0%`}">${n}</linearGradient></defs>`}function D(e,t){let n=t.id??`lumal-icon-gradient`,r=E({...t,id:n});return e.replace(/<svg([^>]*)>/,`<svg$1>${r}`).replace(y,`url(#${n})`)}var O=new Map,k=256;function A(e,t){let n=O.get(e);if(n!==void 0)return n;let r=t();return O.size>=k&&O.delete(O.keys().next().value),O.set(e,r),r}function j(){O.clear()}function M(e){return v(e)?.svgText??``}function N(e,t){let n=M(e);return n?A(`${n}:${t??`currentColor`}`,()=>C(w(n,t))):``}function P(e,t){let n=M(e);return n?A(`${n}:${JSON.stringify(t)}`,()=>C(D(n,t))):``}s(t),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return s}});
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
//#region src/builtin-icons.ts
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
return {
|
|
4
|
+
group: "lumal",
|
|
5
|
+
key: `lumal:${e}`,
|
|
6
|
+
label: t,
|
|
7
|
+
source: "local-svg",
|
|
8
|
+
svgText: `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">${n}</svg>`
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
var t = [
|
|
12
|
+
e("sun", "浅色模式", "<circle cx=\"12\" cy=\"12\" r=\"4\" fill=\"currentColor\"/><path d=\"M12 2v2M12 20v2M4.93 4.93l1.42 1.42M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.42-1.42M17.66 6.34l1.41-1.41\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"),
|
|
13
|
+
e("moon", "深色模式", "<path d=\"M20.2 15.4A8.5 8.5 0 0 1 8.6 3.8 8.5 8.5 0 1 0 20.2 15.4Z\" fill=\"currentColor\"/>"),
|
|
14
|
+
e("monitor", "跟随系统", "<rect x=\"3\" y=\"4\" width=\"18\" height=\"13\" rx=\"2\" stroke=\"currentColor\" stroke-width=\"1.8\"/><path d=\"M8 21h8M12 17v4\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/>"),
|
|
15
|
+
e("palette", "主题设置", "<path d=\"M12 3a9 9 0 0 0 0 18h1.3a2.2 2.2 0 0 0 1.56-3.76l-.38-.38a1.1 1.1 0 0 1 .78-1.86H17a4 4 0 0 0 3.72-5.47A9 9 0 0 0 12 3Z\" stroke=\"currentColor\" stroke-width=\"1.7\"/><circle cx=\"7.5\" cy=\"10\" r=\"1.2\" fill=\"currentColor\"/><circle cx=\"10.5\" cy=\"6.8\" r=\"1.2\" fill=\"currentColor\"/><circle cx=\"15\" cy=\"7.5\" r=\"1.2\" fill=\"currentColor\"/>"),
|
|
16
|
+
e("settings", "设置", "<path d=\"M10 3h4l.4 3.1a8 8 0 0 1 1.7 1l2.5-1 2 3.4-2 1.5.1 1-.1 1 2 1.5-2 3.4-2.5-1a8 8 0 0 1-1.7 1L14 21h-4l-.4-3.1a8 8 0 0 1-1.7-1l-2.5 1-2-3.4 2-1.5-.1-1 .1-1-2-1.5 2-3.4 2.5 1a8 8 0 0 1 1.7-1L10 3Z\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linejoin=\"round\"/><circle cx=\"12\" cy=\"12\" r=\"3.5\" stroke=\"currentColor\" stroke-width=\"1.8\"/>"),
|
|
17
|
+
e("reset", "恢复默认", "<path d=\"M4 7v5h5M5.5 11A7 7 0 1 1 7 18.5\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"),
|
|
18
|
+
e("plus", "新增", "<path d=\"M12 5v14M5 12h14\" stroke=\"currentColor\" stroke-width=\"1.9\" stroke-linecap=\"round\"/>"),
|
|
19
|
+
e("filter", "筛选", "<path d=\"M4 5h16l-6.2 7.1v5.2l-3.6 1.8v-7L4 5Z\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linejoin=\"round\"/>"),
|
|
20
|
+
e("refresh", "刷新", "<path d=\"M20 7v5h-5M4 17v-5h5M18.5 11A7 7 0 0 0 6 7.5L4 10M5.5 13A7 7 0 0 0 18 16.5l2-2.5\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"),
|
|
21
|
+
e("fullscreen", "全屏", "<path d=\"M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"),
|
|
22
|
+
e("fullscreen-exit", "退出全屏", "<path d=\"M9 4v5H4M20 9h-5V4M15 20v-5h5M4 15h5v5\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"),
|
|
23
|
+
e("grid", "列设置", "<rect x=\"4\" y=\"4\" width=\"6\" height=\"6\" rx=\"1\" stroke=\"currentColor\" stroke-width=\"1.7\"/><rect x=\"14\" y=\"4\" width=\"6\" height=\"6\" rx=\"1\" stroke=\"currentColor\" stroke-width=\"1.7\"/><rect x=\"4\" y=\"14\" width=\"6\" height=\"6\" rx=\"1\" stroke=\"currentColor\" stroke-width=\"1.7\"/><rect x=\"14\" y=\"14\" width=\"6\" height=\"6\" rx=\"1\" stroke=\"currentColor\" stroke-width=\"1.7\"/>"),
|
|
24
|
+
e("close", "关闭", "<path d=\"M6 6l12 12M18 6L6 18\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/>"),
|
|
25
|
+
e("menu", "折叠菜单", "<path d=\"M4 7h16M4 12h16M4 17h16\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/>"),
|
|
26
|
+
e("sidebar-expand", "展开侧边栏", "<rect x=\"3\" y=\"4\" width=\"18\" height=\"16\" rx=\"2\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M9 4v16m4-11 3 3-3 3\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"),
|
|
27
|
+
e("sidebar-collapse", "收起侧边栏", "<rect x=\"3\" y=\"4\" width=\"18\" height=\"16\" rx=\"2\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M9 4v16m7-11-3 3 3 3\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"),
|
|
28
|
+
e("search", "搜索", "<circle cx=\"11\" cy=\"11\" r=\"7\" stroke=\"currentColor\" stroke-width=\"1.8\"/><path d=\"m16.2 16.2 4 4\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/>"),
|
|
29
|
+
e("arrow-up", "上移", "<path d=\"M12 20V4m-6 6 6-6 6 6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"),
|
|
30
|
+
e("arrow-down", "下移", "<path d=\"M12 4v16m-6-6 6 6 6-6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"),
|
|
31
|
+
e("arrow-right", "前往", "<path d=\"M4 12h16m-6-6 6 6-6 6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"),
|
|
32
|
+
e("copy", "复制", "<rect x=\"8\" y=\"8\" width=\"12\" height=\"12\" rx=\"2\" stroke=\"currentColor\" stroke-width=\"1.8\"/><path d=\"M16 8V4H4v12h4\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linejoin=\"round\"/>"),
|
|
33
|
+
e("download", "下载", "<path d=\"M12 3v12m-5-5 5 5 5-5M4 16v5h16v-5\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"),
|
|
34
|
+
e("chevron-left", "上一页", "<path d=\"M15 6l-6 6 6 6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" fill=\"none\"/>"),
|
|
35
|
+
e("chevron-right", "下一页", "<path d=\"M9 6l6 6-6 6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" fill=\"none\"/>"),
|
|
36
|
+
e("more", "更多", "<circle cx=\"5\" cy=\"12\" r=\"1.6\" fill=\"currentColor\"/><circle cx=\"12\" cy=\"12\" r=\"1.6\" fill=\"currentColor\"/><circle cx=\"19\" cy=\"12\" r=\"1.6\" fill=\"currentColor\"/>"),
|
|
37
|
+
e("pin", "固定", "<path d=\"M9 4h6l-1 6 4 3v2H6v-2l4-3-1-6Z\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linejoin=\"round\" fill=\"none\"/><path d=\"M12 14v6\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linecap=\"round\"/>"),
|
|
38
|
+
e("pin-off", "取消固定", "<path d=\"M9 4h6l-1 6 4 3v2H6v-2l4-3-1-6Z\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linejoin=\"round\" fill=\"none\"/><path d=\"M12 14v6M4 4l16 16\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linecap=\"round\"/>"),
|
|
39
|
+
e("external-link", "新窗口打开", "<path d=\"M14 4h6v6M20 4l-8 8M14 4H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linecap=\"round\" stroke-linejoin=\"round\" fill=\"none\"/>"),
|
|
40
|
+
e("maximize", "内容最大化", "<path d=\"M8 3H3v5M16 3h5v5M3 16v5h5M21 16v5h-5\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linecap=\"round\" stroke-linejoin=\"round\" fill=\"none\"/>"),
|
|
41
|
+
e("restore", "还原", "<path d=\"M8 3v3a2 2 0 0 1-2 2H3M16 3v3a2 2 0 0 0 2 2h3M3 16h3a2 2 0 0 1 2 2v3M21 16h-3a2 2 0 0 0-2 2v3\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linecap=\"round\" stroke-linejoin=\"round\" fill=\"none\"/>")
|
|
42
|
+
], n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
43
|
+
function a() {
|
|
44
|
+
for (let e of i) e();
|
|
45
|
+
}
|
|
46
|
+
function o(e) {
|
|
47
|
+
return i.add(e), () => {
|
|
48
|
+
i.delete(e);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/registry/icons.ts
|
|
53
|
+
function s(e) {
|
|
54
|
+
for (let t of e) n.set(t.key, t);
|
|
55
|
+
e.length && a();
|
|
56
|
+
}
|
|
57
|
+
function c(e) {
|
|
58
|
+
return n.get(e);
|
|
59
|
+
}
|
|
60
|
+
function l() {
|
|
61
|
+
return [...n.values()];
|
|
62
|
+
}
|
|
63
|
+
function u(e, t) {
|
|
64
|
+
return Object.entries(t).map(([t, n]) => ({
|
|
65
|
+
component: n,
|
|
66
|
+
group: e,
|
|
67
|
+
key: `${e}:${t}`,
|
|
68
|
+
label: t,
|
|
69
|
+
source: "component"
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
function d(e, t) {
|
|
73
|
+
return t.map((t) => ({
|
|
74
|
+
group: e,
|
|
75
|
+
icon: t,
|
|
76
|
+
key: `${e}:${t}`,
|
|
77
|
+
label: t,
|
|
78
|
+
source: "iconify"
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/registry/groups.ts
|
|
83
|
+
function f(e) {
|
|
84
|
+
for (let t of e) r.set(t.key, t);
|
|
85
|
+
e.length && a();
|
|
86
|
+
}
|
|
87
|
+
function p() {
|
|
88
|
+
return [...r.values()].sort((e, t) => (e.order ?? 2 ** 53 - 1) - (t.order ?? 2 ** 53 - 1) || e.label.localeCompare(t.label));
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/runtime/static-local.ts
|
|
92
|
+
var m = /* @__PURE__ */ new Map();
|
|
93
|
+
function h(e) {
|
|
94
|
+
for (let t of e) m.set(t.key, t);
|
|
95
|
+
s(e);
|
|
96
|
+
}
|
|
97
|
+
function g() {
|
|
98
|
+
return [...m.values()];
|
|
99
|
+
}
|
|
100
|
+
function _(e) {
|
|
101
|
+
return m.get(e) ?? c(e);
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/runtime/resolver.ts
|
|
105
|
+
function v(e) {
|
|
106
|
+
return c(e) ?? _(e);
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/runtime/svg.ts
|
|
110
|
+
var y = /currentColor/g, b = /(?:fill|stroke)=["']([^"']+)["']/gi;
|
|
111
|
+
function x(e) {
|
|
112
|
+
if (!/^\s*<svg\b[\s\S]*<\/svg>\s*$/i.test(e)) return {
|
|
113
|
+
reason: "内容不是完整 SVG",
|
|
114
|
+
valid: !1
|
|
115
|
+
};
|
|
116
|
+
if (/<script\b|\bon\w+\s*=|(?:href|src)=["']https?:/i.test(e)) return {
|
|
117
|
+
reason: "SVG 包含不安全的脚本或外部资源",
|
|
118
|
+
valid: !1
|
|
119
|
+
};
|
|
120
|
+
for (let t of e.matchAll(b)) {
|
|
121
|
+
let e = t[1]?.trim();
|
|
122
|
+
if (e && ![
|
|
123
|
+
"currentColor",
|
|
124
|
+
"inherit",
|
|
125
|
+
"none"
|
|
126
|
+
].includes(e) && !e.startsWith("url(#")) return {
|
|
127
|
+
reason: `检测到固定颜色 ${e}`,
|
|
128
|
+
valid: !1
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return { valid: !0 };
|
|
132
|
+
}
|
|
133
|
+
function S(e) {
|
|
134
|
+
let t = e.filter((e) => x(e).valid);
|
|
135
|
+
if (t.length === 0) return "";
|
|
136
|
+
let n = t[0].match(/<svg\b([^>]*)>/i)?.[1]?.trim(), r = t.map((e, t) => `<g data-lumal-icon-layer="${t}">${e.replace(/^\s*<svg\b[^>]*>/i, "").replace(/<\/svg>\s*$/i, "")}</g>`).join("");
|
|
137
|
+
return `<svg${n ? ` ${n}` : ""}>${r}</svg>`;
|
|
138
|
+
}
|
|
139
|
+
function C(e) {
|
|
140
|
+
let t = e.replace(/<svg\b[^>]*>/i, (e) => /\sxmlns\s*=/.test(e) ? e : e.replace(/<svg\b/i, "$& xmlns=\"http://www.w3.org/2000/svg\""));
|
|
141
|
+
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`;
|
|
142
|
+
}
|
|
143
|
+
function w(e, t = "currentColor") {
|
|
144
|
+
return e.replace(y, t);
|
|
145
|
+
}
|
|
146
|
+
function T(e) {
|
|
147
|
+
return e.stops?.length ? e.stops : [{
|
|
148
|
+
offset: "0%",
|
|
149
|
+
color: e.from ?? "currentColor"
|
|
150
|
+
}, {
|
|
151
|
+
offset: "100%",
|
|
152
|
+
color: e.to ?? e.from ?? "currentColor"
|
|
153
|
+
}];
|
|
154
|
+
}
|
|
155
|
+
function E(e) {
|
|
156
|
+
let t = e.direction === "vertical", n = T(e).map((e) => {
|
|
157
|
+
let t = e.opacity == null ? "" : ` stop-opacity="${e.opacity}"`;
|
|
158
|
+
return `<stop offset="${e.offset}" stop-color="${e.color}"${t}/>`;
|
|
159
|
+
}).join("");
|
|
160
|
+
return `<defs><linearGradient id="${e.id}" x1="0%" y1="0%" x2="${t ? "0%" : "100%"}" y2="${t ? "100%" : "0%"}">${n}</linearGradient></defs>`;
|
|
161
|
+
}
|
|
162
|
+
function D(e, t) {
|
|
163
|
+
let n = t.id ?? "lumal-icon-gradient", r = E({
|
|
164
|
+
...t,
|
|
165
|
+
id: n
|
|
166
|
+
});
|
|
167
|
+
return e.replace(/<svg([^>]*)>/, `<svg$1>${r}`).replace(y, `url(#${n})`);
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/runtime/data-uri.ts
|
|
171
|
+
var O = /* @__PURE__ */ new Map(), k = 256;
|
|
172
|
+
function A(e, t) {
|
|
173
|
+
let n = O.get(e);
|
|
174
|
+
if (n !== void 0) return n;
|
|
175
|
+
let r = t();
|
|
176
|
+
return O.size >= k && O.delete(O.keys().next().value), O.set(e, r), r;
|
|
177
|
+
}
|
|
178
|
+
function j() {
|
|
179
|
+
O.clear();
|
|
180
|
+
}
|
|
181
|
+
function M(e) {
|
|
182
|
+
return v(e)?.svgText ?? "";
|
|
183
|
+
}
|
|
184
|
+
function N(e, t) {
|
|
185
|
+
let n = M(e);
|
|
186
|
+
return n ? A(`${n}:${t ?? "currentColor"}`, () => C(w(n, t))) : "";
|
|
187
|
+
}
|
|
188
|
+
function P(e, t) {
|
|
189
|
+
let n = M(e);
|
|
190
|
+
return n ? A(`${n}:${JSON.stringify(t)}`, () => C(D(n, t))) : "";
|
|
191
|
+
}
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/index.ts
|
|
194
|
+
s(t);
|
|
195
|
+
//#endregion
|
|
196
|
+
export { t as S, d as _, D as a, c as b, C as c, g as d, h as f, u as g, f as h, M as i, x as l, p as m, P as n, S as o, _ as p, N as r, w as s, j as t, v as u, l as v, o as x, s as y };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumal/icons",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4-beta",
|
|
5
5
|
"description": "Framework-agnostic Lumal icon registry and SVG utilities.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
"import": "./dist/index.js",
|
|
21
21
|
"require": "./dist/index.cjs"
|
|
22
22
|
},
|
|
23
|
+
"./morph": {
|
|
24
|
+
"types": "./dist/src/morph/index.d.ts",
|
|
25
|
+
"import": "./dist/morph.js",
|
|
26
|
+
"require": "./dist/morph.cjs"
|
|
27
|
+
},
|
|
23
28
|
"./vite": {
|
|
24
29
|
"types": "./dist/src/vite/index.d.ts",
|
|
25
30
|
"import": "./dist/vite.js",
|
|
@@ -34,6 +39,17 @@
|
|
|
34
39
|
"README.md",
|
|
35
40
|
"dist"
|
|
36
41
|
],
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"morphicons": "2.0.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"morphicons": {
|
|
47
|
+
"optional": true
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"morphicons": "2.0.0"
|
|
52
|
+
},
|
|
37
53
|
"scripts": {
|
|
38
54
|
"build": "vite build --config vite.config.ts && tsc -p tsconfig.json --emitDeclarationOnly && node ../../scripts/clean-package-dist.mjs dist",
|
|
39
55
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|