@lumal/icons-vue 0.0.1-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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lumal contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # @lumal/icons-vue
2
+
3
+ `@lumal/icons` 的 Vue 3 组件与响应式适配层,提供 `LumalIcon`、`LumalIconPicker`、`LumalIconPickerDialog` 和 `useIconRegistry`。
4
+
5
+ ```vue
6
+ <script setup lang="ts">
7
+ import { LumalIcon } from '@lumal/icons-vue'
8
+ import '@lumal/icons-vue/style.css'
9
+ </script>
10
+
11
+ <template>
12
+ <LumalIcon name="lumal:settings" color="#1677ff" :size="20" />
13
+ </template>
14
+ ```
15
+
16
+ SVG 改色、渐变、合成、Data URI 和注册表等纯 TypeScript 能力由 `@lumal/icons` 提供。
@@ -0,0 +1,2 @@
1
+ .lumal-icon[data-v-111a6ce8]{width:var(--lumal-icon-size);height:var(--lumal-icon-size);vertical-align:-.125em;justify-content:center;align-items:center;line-height:1;display:inline-flex}.lumal-icon__svg[data-v-111a6ce8],.lumal-icon__component[data-v-111a6ce8]{width:100%;height:100%}.lumal-icon__svg[data-v-111a6ce8] svg{width:100%;height:100%;display:block}.lumal-icon-picker[data-v-937c0d9c]{gap:12px;display:grid}.lumal-icon-picker__toolbar[data-v-937c0d9c]{grid-template-columns:minmax(0,1fr) minmax(140px,200px);gap:12px;display:grid}.lumal-icon-picker__field[data-v-937c0d9c]{gap:6px;display:grid}.lumal-icon-picker__field-label[data-v-937c0d9c],.lumal-icon-picker__summary[data-v-937c0d9c],.lumal-icon-picker__empty[data-v-937c0d9c]{color:var(--el-text-color-secondary,CanvasText);font-size:13px}.lumal-icon-picker__field input[data-v-937c0d9c],.lumal-icon-picker__field select[data-v-937c0d9c],.lumal-icon-picker__pagination button[data-v-937c0d9c]{border:1px solid var(--el-border-color,currentColor);border-radius:var(--lumal-radius-base,8px);min-height:44px;color:var(--el-text-color-primary,CanvasText);background:var(--el-bg-color,Canvas);padding:0 12px}.lumal-icon-picker__summary[data-v-937c0d9c],.lumal-icon-picker__empty[data-v-937c0d9c]{margin:0}.lumal-icon-picker__grid[data-v-937c0d9c]{grid-template-columns:repeat(auto-fill,minmax(52px,1fr));gap:8px;display:grid}.lumal-icon-picker__item[data-v-937c0d9c]{border:1px solid var(--el-border-color-lighter,currentColor);border-radius:var(--lumal-radius-small,6px);min-width:44px;min-height:52px;color:var(--el-text-color-regular,CanvasText);background:var(--el-bg-color,Canvas);cursor:pointer;transition:border-color var(--lumal-motion-fast,.16s), background-color var(--lumal-motion-fast,.16s);flex-direction:column;justify-content:center;align-items:center;gap:6px;padding:8px;display:inline-flex}.lumal-icon-picker__item[data-v-937c0d9c]:hover,.lumal-icon-picker__item.is-selected[data-v-937c0d9c]{border-color:var(--el-color-primary,Highlight);background:var(--el-color-primary-light-9,Canvas)}.lumal-icon-picker__item[data-v-937c0d9c]:focus-visible,.lumal-icon-picker__field input[data-v-937c0d9c]:focus-visible,.lumal-icon-picker__field select[data-v-937c0d9c]:focus-visible,.lumal-icon-picker__pagination button[data-v-937c0d9c]:focus-visible{outline:2px solid var(--el-color-primary,Highlight);outline-offset:2px}.lumal-icon-picker__item span[data-v-937c0d9c]{text-overflow:ellipsis;white-space:nowrap;max-width:100%;font-size:11px;overflow:hidden}.lumal-icon-picker__pagination[data-v-937c0d9c]{justify-content:center;align-items:center;gap:12px;display:flex}.lumal-icon-picker__pagination button[data-v-937c0d9c]:disabled{cursor:not-allowed;opacity:.5}@media (width<=640px){.lumal-icon-picker__toolbar[data-v-937c0d9c]{grid-template-columns:minmax(0,1fr)}}@media (prefers-reduced-motion:reduce){.lumal-icon-picker__item[data-v-937c0d9c]{transition:none}}.lumal-icon-picker-dialog[data-v-9bd629e7]{z-index:var(--lumal-z-dialog,500);background:color-mix(in srgb, CanvasText 48%, transparent);justify-content:center;align-items:center;padding:24px;display:flex;position:fixed;inset:0}.lumal-icon-picker-dialog__body[data-v-9bd629e7]{border-radius:var(--lumal-radius-large,12px);width:min(680px,100%);max-height:min(680px,88dvh);color:var(--el-text-color-primary,CanvasText);background:var(--el-bg-color,Canvas);box-shadow:var(--lumal-shadow-dialog,0 18px 48px color-mix(in srgb, CanvasText 18%, transparent));display:grid;overflow:hidden}.lumal-icon-picker-dialog__header[data-v-9bd629e7],.lumal-icon-picker-dialog__footer[data-v-9bd629e7]{justify-content:space-between;align-items:center;gap:12px;min-height:56px;padding:12px 20px;display:flex}.lumal-icon-picker-dialog__header[data-v-9bd629e7]{border-bottom:1px solid var(--el-border-color-lighter,currentColor)}.lumal-icon-picker-dialog__header h3[data-v-9bd629e7]{margin:0;font-size:17px}.lumal-icon-picker-dialog__content[data-v-9bd629e7]{min-height:0;padding:20px;overflow:auto}.lumal-icon-picker-dialog__footer[data-v-9bd629e7]{border-top:1px solid var(--el-border-color-lighter,currentColor);justify-content:flex-end}.lumal-icon-picker-dialog button[data-v-9bd629e7]{border:1px solid var(--el-border-color,currentColor);border-radius:var(--lumal-radius-base,8px);min-width:44px;min-height:44px;color:inherit;background:var(--el-bg-color,Canvas);cursor:pointer;padding:0 14px}.lumal-icon-picker-dialog button.is-primary[data-v-9bd629e7]{border-color:var(--el-color-primary,Highlight);color:var(--el-color-white,HighlightText);background:var(--el-color-primary,Highlight)}.lumal-icon-picker-dialog button[data-v-9bd629e7]:disabled{cursor:not-allowed;opacity:.5}@media (width<=640px){.lumal-icon-picker-dialog[data-v-9bd629e7]{align-items:flex-end;padding:0}.lumal-icon-picker-dialog__body[data-v-9bd629e7]{border-radius:var(--lumal-radius-large,12px) var(--lumal-radius-large,12px) 0 0;max-height:92dvh}}
2
+ /*$vite$:1*/
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("vue"),t=require("@iconify/vue"),n=require("@lumal/icons");function r(){let t=(0,e.shallowRef)(0);(0,e.onScopeDispose)((0,n.subscribeIconRegistry)(()=>{t.value+=1}));let r=(0,e.computed)(()=>(t.value,(0,n.getRegisteredIconDefinitions)())),i=(0,e.computed)(()=>(t.value,(0,n.getRegisteredIconGroups)()));function a(e){return t.value,(0,n.resolveIconDefinition)(e)}return{groups:i,icons:r,resolve:a}}var i=[`title`],a=[`innerHTML`],o=(0,e.defineComponent)({__name:`LumalIcon`,props:{name:{},icon:{},size:{},color:{},gradient:{},title:{}},setup(o){let s=o,c=`lumal-icon-gradient-${(0,e.useId)()}`,l=r(),u=(0,e.computed)(()=>{if(s.name)return l.resolve(s.name)}),d=(0,e.computed)(()=>{let e=s.icon,t=u.value?.svgText??(typeof e==`string`&&e.trim().startsWith(`<svg`)?e:``)??(typeof e==`object`&&e&&`svgText`in e?String(e.svgText??``):``);return t?s.gradient?(0,n.applySvgGradient)(t,{...s.gradient,id:s.gradient.id??c}):(0,n.recolorSvgString)(t,s.color):``}),f=(0,e.computed)(()=>{let e=u.value?.component;if(typeof e==`function`||typeof e==`object`&&e)return e;if(typeof s.icon==`object`&&s.icon&&`component`in s.icon){let e=s.icon.component;return typeof e==`function`||typeof e==`object`&&e?e:void 0}return typeof s.icon==`function`||typeof s.icon==`object`?s.icon:void 0}),p=(0,e.computed)(()=>{if(u.value?.source===`iconify`)return u.value.icon;if(typeof s.icon==`object`&&s.icon&&`source`in s.icon&&s.icon.source===`iconify`)return s.icon.icon}),m=(0,e.computed)(()=>({"--lumal-icon-size":typeof s.size==`number`?`${s.size}px`:s.size??`1em`,color:s.color})),h=(0,e.computed)(()=>!!(d.value||f.value||p.value)),g=(0,e.computed)(()=>s.title??u.value?.label);return(n,r)=>h.value?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,{key:0,class:`lumal-icon`,style:(0,e.normalizeStyle)(m.value),title:g.value,"aria-hidden":`true`},[f.value?((0,e.openBlock)(),(0,e.createBlock)((0,e.resolveDynamicComponent)(f.value),{key:0,class:`lumal-icon__component`})):p.value?((0,e.openBlock)(),(0,e.createBlock)((0,e.unref)(t.Icon),{key:1,class:`lumal-icon__component`,icon:p.value},null,8,[`icon`])):((0,e.openBlock)(),(0,e.createElementBlock)(`span`,{key:2,class:`lumal-icon__svg`,innerHTML:d.value},null,8,a))],12,i)):(0,e.createCommentVNode)(``,!0)}}),s=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},c=s(o,[[`__scopeId`,`data-v-111a6ce8`]]),l={class:`lumal-icon-picker`},u={class:`lumal-icon-picker__toolbar`},d={key:0,class:`lumal-icon-picker__field`},f={key:1,class:`lumal-icon-picker__field`},p=[`value`],m={class:`lumal-icon-picker__summary`,role:`status`},h={key:0,class:`lumal-icon-picker__grid`,role:`listbox`,"aria-label":`图标列表`},g=[`aria-label`,`aria-selected`,`title`,`onClick`],_={key:0},v={key:1,class:`lumal-icon-picker__empty`},y={key:2,class:`lumal-icon-picker__pagination`},b=[`disabled`],x=[`disabled`],S=s((0,e.defineComponent)({__name:`LumalIconPicker`,props:(0,e.mergeModels)({group:{default:``},pageSize:{default:48},searchable:{type:Boolean,default:!0},showLabels:{type:Boolean,default:!1},storageKey:{default:``}},{modelValue:{},modelModifiers:{}}),emits:(0,e.mergeModels)([`select`],[`update:modelValue`]),setup(t,{emit:n}){let i=t,a=n,o=(0,e.useModel)(t,`modelValue`),s=(0,e.ref)(``),S=(0,e.ref)(i.group),C=(0,e.ref)(1),w=(0,e.computed)(()=>Math.max(1,i.pageSize)),T=r(),E=T.icons,D=(0,e.computed)(()=>{let e=T.groups.value,t=new Set(e.map(e=>e.key)),n=E.value.map(e=>e.group).filter(e=>typeof e==`string`&&!t.has(e)).filter((e,t,n)=>n.indexOf(e)===t).map(e=>({key:e,label:e}));return[...e,...n]}),O=(0,e.computed)(()=>{let e=s.value.trim().toLocaleLowerCase();return E.value.filter(t=>{let n=!S.value||t.group===S.value,r=!e||t.key.toLocaleLowerCase().includes(e)||t.label?.toLocaleLowerCase().includes(e);return n&&r})}),k=(0,e.computed)(()=>Math.max(1,Math.ceil(O.value.length/w.value))),A=(0,e.computed)(()=>{let e=(C.value-1)*w.value;return O.value.slice(e,e+w.value)});(0,e.watch)([s,S,w],()=>{C.value=1}),(0,e.watch)(()=>i.group,e=>{S.value=e}),(0,e.watch)(k,e=>{C.value=Math.min(C.value,e)}),i.storageKey&&typeof localStorage<`u`&&!o.value&&(o.value=localStorage.getItem(i.storageKey)??void 0);function j(e){o.value=e.key,i.storageKey&&typeof localStorage<`u`&&localStorage.setItem(i.storageKey,e.key),a(`select`,e)}return(n,r)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,l,[(0,e.createElementVNode)(`div`,u,[t.searchable?((0,e.openBlock)(),(0,e.createElementBlock)(`label`,d,[r[4]||=(0,e.createElementVNode)(`span`,{class:`lumal-icon-picker__field-label`},`搜索图标`,-1),(0,e.withDirectives)((0,e.createElementVNode)(`input`,{"onUpdate:modelValue":r[0]||=e=>s.value=e,type:`search`,placeholder:`输入名称或 key`},null,512),[[e.vModelText,s.value]])])):(0,e.createCommentVNode)(``,!0),D.value.length?((0,e.openBlock)(),(0,e.createElementBlock)(`label`,f,[r[6]||=(0,e.createElementVNode)(`span`,{class:`lumal-icon-picker__field-label`},`图标分组`,-1),(0,e.withDirectives)((0,e.createElementVNode)(`select`,{"onUpdate:modelValue":r[1]||=e=>S.value=e},[r[5]||=(0,e.createElementVNode)(`option`,{value:``},`全部分组`,-1),((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(D.value,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`option`,{key:t.key,value:t.key},(0,e.toDisplayString)(t.label),9,p))),128))],512),[[e.vModelSelect,S.value]])])):(0,e.createCommentVNode)(``,!0)]),(0,e.createElementVNode)(`p`,m,` 共 `+(0,e.toDisplayString)(O.value.length)+` 个图标 `,1),A.value.length?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,h,[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(A.value,n=>((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:n.key,class:(0,e.normalizeClass)([`lumal-icon-picker__item`,{"is-selected":o.value===n.key}]),type:`button`,role:`option`,"aria-label":n.label||n.key,"aria-selected":o.value===n.key,title:n.label||n.key,onClick:e=>j(n)},[(0,e.createVNode)(c,{name:n.key},null,8,[`name`]),t.showLabels?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,_,(0,e.toDisplayString)(n.label||n.key),1)):(0,e.createCommentVNode)(``,!0)],10,g))),128))])):((0,e.openBlock)(),(0,e.createElementBlock)(`p`,v,` 未找到匹配图标 `)),k.value>1?((0,e.openBlock)(),(0,e.createElementBlock)(`footer`,y,[(0,e.createElementVNode)(`button`,{type:`button`,disabled:C.value<=1,onClick:r[2]||=e=>--C.value},` 上一页 `,8,b),(0,e.createElementVNode)(`span`,null,`第 `+(0,e.toDisplayString)(C.value)+` / `+(0,e.toDisplayString)(k.value)+` 页`,1),(0,e.createElementVNode)(`button`,{type:`button`,disabled:C.value>=k.value,onClick:r[3]||=e=>C.value+=1},` 下一页 `,8,x)])):(0,e.createCommentVNode)(``,!0)]))}}),[[`__scopeId`,`data-v-937c0d9c`]]),C=[`aria-label`],w={class:`lumal-icon-picker-dialog__header`},T={class:`lumal-icon-picker-dialog__content`},E={class:`lumal-icon-picker-dialog__footer`},D=[`disabled`],O=s((0,e.defineComponent)({__name:`LumalIconPickerDialog`,props:(0,e.mergeModels)({cancelText:{default:`取消`},confirmText:{default:`确认选择`},title:{default:`选择图标`}},{visible:{type:Boolean,default:!1},visibleModifiers:{},modelValue:{},modelModifiers:{}}),emits:(0,e.mergeModels)([`cancel`,`confirm`],[`update:visible`,`update:modelValue`]),setup(t,{emit:n}){let r=n,i=(0,e.useModel)(t,`visible`),a=(0,e.useModel)(t,`modelValue`),o=(0,e.ref)(``),s=(0,e.ref)();(0,e.watch)(i,async t=>{t&&(o.value=a.value??``,await(0,e.nextTick)(),s.value?.focus())},{immediate:!0});function c(){i.value=!1,r(`cancel`)}function l(){o.value&&(a.value=o.value,i.value=!1,r(`confirm`,o.value))}return(n,r)=>i.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`lumal-icon-picker-dialog`,role:`presentation`,onMousedown:(0,e.withModifiers)(c,[`self`])},[(0,e.createElementVNode)(`section`,{ref_key:`dialogRef`,ref:s,class:`lumal-icon-picker-dialog__body`,role:`dialog`,"aria-modal":`true`,"aria-label":t.title,tabindex:`-1`,onKeydown:(0,e.withKeys)(c,[`esc`])},[(0,e.createElementVNode)(`header`,w,[(0,e.createElementVNode)(`h3`,null,(0,e.toDisplayString)(t.title),1),(0,e.createElementVNode)(`button`,{type:`button`,"aria-label":`关闭图标选择器`,onClick:c},` × `)]),(0,e.createElementVNode)(`div`,T,[(0,e.createVNode)(S,{modelValue:o.value,"onUpdate:modelValue":r[0]||=e=>o.value=e},null,8,[`modelValue`])]),(0,e.createElementVNode)(`footer`,E,[(0,e.createElementVNode)(`button`,{type:`button`,onClick:c},(0,e.toDisplayString)(t.cancelText),1),(0,e.createElementVNode)(`button`,{type:`button`,class:`is-primary`,disabled:!o.value,onClick:l},(0,e.toDisplayString)(t.confirmText),9,D)])],40,C)],32)):(0,e.createCommentVNode)(``,!0)}}),[[`__scopeId`,`data-v-9bd629e7`]]);exports.LumalIcon=c,exports.LumalIconPicker=S,exports.LumalIconPickerDialog=O,exports.useIconRegistry=r;
package/dist/index.js ADDED
@@ -0,0 +1,253 @@
1
+ import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createVNode as o, defineComponent as s, mergeModels as c, nextTick as l, normalizeClass as u, normalizeStyle as d, onScopeDispose as f, openBlock as p, ref as m, renderList as h, resolveDynamicComponent as g, shallowRef as _, toDisplayString as v, unref as y, useId as b, useModel as x, vModelSelect as S, vModelText as C, watch as w, withDirectives as T, withKeys as E, withModifiers as D } from "vue";
2
+ import { Icon as O } from "@iconify/vue";
3
+ import { applySvgGradient as k, getRegisteredIconDefinitions as A, getRegisteredIconGroups as j, recolorSvgString as M, resolveIconDefinition as N, subscribeIconRegistry as ee } from "@lumal/icons";
4
+ //#region src/composables/useIconRegistry.ts
5
+ function P() {
6
+ let e = _(0);
7
+ f(ee(() => {
8
+ e.value += 1;
9
+ }));
10
+ let n = t(() => (e.value, A())), r = t(() => (e.value, j()));
11
+ function i(t) {
12
+ return e.value, N(t);
13
+ }
14
+ return {
15
+ groups: r,
16
+ icons: n,
17
+ resolve: i
18
+ };
19
+ }
20
+ //#endregion
21
+ //#region src/components/LumalIcon.vue?vue&type=script&setup=true&lang.ts
22
+ var F = ["title"], I = ["innerHTML"], L = /*@__PURE__*/ s({
23
+ __name: "LumalIcon",
24
+ props: {
25
+ name: {},
26
+ icon: {},
27
+ size: {},
28
+ color: {},
29
+ gradient: {},
30
+ title: {}
31
+ },
32
+ setup(e) {
33
+ let a = e, o = `lumal-icon-gradient-${b()}`, s = P(), c = t(() => {
34
+ if (a.name) return s.resolve(a.name);
35
+ }), l = t(() => {
36
+ let e = a.icon, t = c.value?.svgText ?? (typeof e == "string" && e.trim().startsWith("<svg") ? e : "") ?? (typeof e == "object" && e && "svgText" in e ? String(e.svgText ?? "") : "");
37
+ return t ? a.gradient ? k(t, {
38
+ ...a.gradient,
39
+ id: a.gradient.id ?? o
40
+ }) : M(t, a.color) : "";
41
+ }), u = t(() => {
42
+ let e = c.value?.component;
43
+ if (typeof e == "function" || typeof e == "object" && e) return e;
44
+ if (typeof a.icon == "object" && a.icon && "component" in a.icon) {
45
+ let e = a.icon.component;
46
+ return typeof e == "function" || typeof e == "object" && e ? e : void 0;
47
+ }
48
+ return typeof a.icon == "function" || typeof a.icon == "object" ? a.icon : void 0;
49
+ }), f = t(() => {
50
+ if (c.value?.source === "iconify") return c.value.icon;
51
+ if (typeof a.icon == "object" && a.icon && "source" in a.icon && a.icon.source === "iconify") return a.icon.icon;
52
+ }), m = t(() => ({
53
+ "--lumal-icon-size": typeof a.size == "number" ? `${a.size}px` : a.size ?? "1em",
54
+ color: a.color
55
+ })), h = t(() => !!(l.value || u.value || f.value)), _ = t(() => a.title ?? c.value?.label);
56
+ return (e, t) => h.value ? (p(), i("span", {
57
+ key: 0,
58
+ class: "lumal-icon",
59
+ style: d(m.value),
60
+ title: _.value,
61
+ "aria-hidden": "true"
62
+ }, [u.value ? (p(), n(g(u.value), {
63
+ key: 0,
64
+ class: "lumal-icon__component"
65
+ })) : f.value ? (p(), n(y(O), {
66
+ key: 1,
67
+ class: "lumal-icon__component",
68
+ icon: f.value
69
+ }, null, 8, ["icon"])) : (p(), i("span", {
70
+ key: 2,
71
+ class: "lumal-icon__svg",
72
+ innerHTML: l.value
73
+ }, null, 8, I))], 12, F)) : r("", !0);
74
+ }
75
+ }), R = (e, t) => {
76
+ let n = e.__vccOpts || e;
77
+ for (let [e, r] of t) n[e] = r;
78
+ return n;
79
+ }, z = /*#__PURE__*/ R(L, [["__scopeId", "data-v-111a6ce8"]]), B = { class: "lumal-icon-picker" }, V = { class: "lumal-icon-picker__toolbar" }, H = {
80
+ key: 0,
81
+ class: "lumal-icon-picker__field"
82
+ }, U = {
83
+ key: 1,
84
+ class: "lumal-icon-picker__field"
85
+ }, W = ["value"], G = {
86
+ class: "lumal-icon-picker__summary",
87
+ role: "status"
88
+ }, K = {
89
+ key: 0,
90
+ class: "lumal-icon-picker__grid",
91
+ role: "listbox",
92
+ "aria-label": "图标列表"
93
+ }, q = [
94
+ "aria-label",
95
+ "aria-selected",
96
+ "title",
97
+ "onClick"
98
+ ], J = { key: 0 }, Y = {
99
+ key: 1,
100
+ class: "lumal-icon-picker__empty"
101
+ }, X = {
102
+ key: 2,
103
+ class: "lumal-icon-picker__pagination"
104
+ }, Z = ["disabled"], Q = ["disabled"], $ = /*#__PURE__*/ R(/* @__PURE__ */ s({
105
+ __name: "LumalIconPicker",
106
+ props: /*@__PURE__*/ c({
107
+ group: { default: "" },
108
+ pageSize: { default: 48 },
109
+ searchable: {
110
+ type: Boolean,
111
+ default: !0
112
+ },
113
+ showLabels: {
114
+ type: Boolean,
115
+ default: !1
116
+ },
117
+ storageKey: { default: "" }
118
+ }, {
119
+ modelValue: {},
120
+ modelModifiers: {}
121
+ }),
122
+ emits: /*@__PURE__*/ c(["select"], ["update:modelValue"]),
123
+ setup(n, { emit: s }) {
124
+ let c = n, l = s, d = x(n, "modelValue"), f = m(""), g = m(c.group), _ = m(1), y = t(() => Math.max(1, c.pageSize)), b = P(), E = b.icons, D = t(() => {
125
+ let e = b.groups.value, t = new Set(e.map((e) => e.key)), n = E.value.map((e) => e.group).filter((e) => typeof e == "string" && !t.has(e)).filter((e, t, n) => n.indexOf(e) === t).map((e) => ({
126
+ key: e,
127
+ label: e
128
+ }));
129
+ return [...e, ...n];
130
+ }), O = t(() => {
131
+ let e = f.value.trim().toLocaleLowerCase();
132
+ return E.value.filter((t) => {
133
+ let n = !g.value || t.group === g.value, r = !e || t.key.toLocaleLowerCase().includes(e) || t.label?.toLocaleLowerCase().includes(e);
134
+ return n && r;
135
+ });
136
+ }), k = t(() => Math.max(1, Math.ceil(O.value.length / y.value))), A = t(() => {
137
+ let e = (_.value - 1) * y.value;
138
+ return O.value.slice(e, e + y.value);
139
+ });
140
+ w([
141
+ f,
142
+ g,
143
+ y
144
+ ], () => {
145
+ _.value = 1;
146
+ }), w(() => c.group, (e) => {
147
+ g.value = e;
148
+ }), w(k, (e) => {
149
+ _.value = Math.min(_.value, e);
150
+ }), c.storageKey && typeof localStorage < "u" && !d.value && (d.value = localStorage.getItem(c.storageKey) ?? void 0);
151
+ function j(e) {
152
+ d.value = e.key, c.storageKey && typeof localStorage < "u" && localStorage.setItem(c.storageKey, e.key), l("select", e);
153
+ }
154
+ return (t, s) => (p(), i("div", B, [
155
+ a("div", V, [n.searchable ? (p(), i("label", H, [s[4] ||= a("span", { class: "lumal-icon-picker__field-label" }, "搜索图标", -1), T(a("input", {
156
+ "onUpdate:modelValue": s[0] ||= (e) => f.value = e,
157
+ type: "search",
158
+ placeholder: "输入名称或 key"
159
+ }, null, 512), [[C, f.value]])])) : r("", !0), D.value.length ? (p(), i("label", U, [s[6] ||= a("span", { class: "lumal-icon-picker__field-label" }, "图标分组", -1), T(a("select", { "onUpdate:modelValue": s[1] ||= (e) => g.value = e }, [s[5] ||= a("option", { value: "" }, "全部分组", -1), (p(!0), i(e, null, h(D.value, (e) => (p(), i("option", {
160
+ key: e.key,
161
+ value: e.key
162
+ }, v(e.label), 9, W))), 128))], 512), [[S, g.value]])])) : r("", !0)]),
163
+ a("p", G, " 共 " + v(O.value.length) + " 个图标 ", 1),
164
+ A.value.length ? (p(), i("div", K, [(p(!0), i(e, null, h(A.value, (e) => (p(), i("button", {
165
+ key: e.key,
166
+ class: u(["lumal-icon-picker__item", { "is-selected": d.value === e.key }]),
167
+ type: "button",
168
+ role: "option",
169
+ "aria-label": e.label || e.key,
170
+ "aria-selected": d.value === e.key,
171
+ title: e.label || e.key,
172
+ onClick: (t) => j(e)
173
+ }, [o(z, { name: e.key }, null, 8, ["name"]), n.showLabels ? (p(), i("span", J, v(e.label || e.key), 1)) : r("", !0)], 10, q))), 128))])) : (p(), i("p", Y, " 未找到匹配图标 ")),
174
+ k.value > 1 ? (p(), i("footer", X, [
175
+ a("button", {
176
+ type: "button",
177
+ disabled: _.value <= 1,
178
+ onClick: s[2] ||= (e) => --_.value
179
+ }, " 上一页 ", 8, Z),
180
+ a("span", null, "第 " + v(_.value) + " / " + v(k.value) + " 页", 1),
181
+ a("button", {
182
+ type: "button",
183
+ disabled: _.value >= k.value,
184
+ onClick: s[3] ||= (e) => _.value += 1
185
+ }, " 下一页 ", 8, Q)
186
+ ])) : r("", !0)
187
+ ]));
188
+ }
189
+ }), [["__scopeId", "data-v-937c0d9c"]]), te = ["aria-label"], ne = { class: "lumal-icon-picker-dialog__header" }, re = { class: "lumal-icon-picker-dialog__content" }, ie = { class: "lumal-icon-picker-dialog__footer" }, ae = ["disabled"], oe = /*#__PURE__*/ R(/* @__PURE__ */ s({
190
+ __name: "LumalIconPickerDialog",
191
+ props: /*@__PURE__*/ c({
192
+ cancelText: { default: "取消" },
193
+ confirmText: { default: "确认选择" },
194
+ title: { default: "选择图标" }
195
+ }, {
196
+ visible: {
197
+ type: Boolean,
198
+ default: !1
199
+ },
200
+ visibleModifiers: {},
201
+ modelValue: {},
202
+ modelModifiers: {}
203
+ }),
204
+ emits: /*@__PURE__*/ c(["cancel", "confirm"], ["update:visible", "update:modelValue"]),
205
+ setup(e, { emit: t }) {
206
+ let n = t, s = x(e, "visible"), c = x(e, "modelValue"), u = m(""), d = m();
207
+ w(s, async (e) => {
208
+ e && (u.value = c.value ?? "", await l(), d.value?.focus());
209
+ }, { immediate: !0 });
210
+ function f() {
211
+ s.value = !1, n("cancel");
212
+ }
213
+ function h() {
214
+ u.value && (c.value = u.value, s.value = !1, n("confirm", u.value));
215
+ }
216
+ return (t, n) => s.value ? (p(), i("div", {
217
+ key: 0,
218
+ class: "lumal-icon-picker-dialog",
219
+ role: "presentation",
220
+ onMousedown: D(f, ["self"])
221
+ }, [a("section", {
222
+ ref_key: "dialogRef",
223
+ ref: d,
224
+ class: "lumal-icon-picker-dialog__body",
225
+ role: "dialog",
226
+ "aria-modal": "true",
227
+ "aria-label": e.title,
228
+ tabindex: "-1",
229
+ onKeydown: E(f, ["esc"])
230
+ }, [
231
+ a("header", ne, [a("h3", null, v(e.title), 1), a("button", {
232
+ type: "button",
233
+ "aria-label": "关闭图标选择器",
234
+ onClick: f
235
+ }, " × ")]),
236
+ a("div", re, [o($, {
237
+ modelValue: u.value,
238
+ "onUpdate:modelValue": n[0] ||= (e) => u.value = e
239
+ }, null, 8, ["modelValue"])]),
240
+ a("footer", ie, [a("button", {
241
+ type: "button",
242
+ onClick: f
243
+ }, v(e.cancelText), 1), a("button", {
244
+ type: "button",
245
+ class: "is-primary",
246
+ disabled: !u.value,
247
+ onClick: h
248
+ }, v(e.confirmText), 9, ae)])
249
+ ], 40, te)], 32)) : r("", !0);
250
+ }
251
+ }), [["__scopeId", "data-v-9bd629e7"]]);
252
+ //#endregion
253
+ export { z as LumalIcon, $ as LumalIconPicker, oe as LumalIconPickerDialog, P as useIconRegistry };
@@ -0,0 +1,15 @@
1
+ import type { IconDefinition, IconGradientOptions } from '@lumal/icons';
2
+ import type { Component } from 'vue';
3
+ /***********************属性定义*********************/
4
+ type __VLS_Props = {
5
+ name?: string;
6
+ icon?: Component | IconDefinition<Component> | string;
7
+ size?: number | string;
8
+ color?: string;
9
+ gradient?: IconGradientOptions;
10
+ title?: string;
11
+ };
12
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
+ declare const _default: typeof __VLS_export;
14
+ export default _default;
15
+ //# sourceMappingURL=LumalIcon.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LumalIcon.vue.d.ts","sourceRoot":"","sources":["../../../src/components/LumalIcon.vue"],"names":[],"mappings":"AAuIA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAMpC,kDAAkD;AAClD,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,SAAS,GAAG,cAAc,CAAC,SAAS,CAAC,GAAG,MAAM,CAAA;IACrD,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,mBAAmB,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAC;AAyJF,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -0,0 +1,28 @@
1
+ import type { IconDefinition } from '@lumal/icons';
2
+ type __VLS_Props = {
3
+ group?: string;
4
+ pageSize?: number;
5
+ searchable?: boolean;
6
+ showLabels?: boolean;
7
+ storageKey?: string;
8
+ };
9
+ type __VLS_ModelProps = {
10
+ modelValue?: string;
11
+ };
12
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
13
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
14
+ select: (icon: IconDefinition<unknown>) => any;
15
+ "update:modelValue": (value: string | undefined) => any;
16
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
17
+ onSelect?: ((icon: IconDefinition<unknown>) => any) | undefined;
18
+ "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
19
+ }>, {
20
+ group: string;
21
+ pageSize: number;
22
+ searchable: boolean;
23
+ showLabels: boolean;
24
+ storageKey: string;
25
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
26
+ declare const _default: typeof __VLS_export;
27
+ export default _default;
28
+ //# sourceMappingURL=LumalIconPicker.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LumalIconPicker.vue.d.ts","sourceRoot":"","sources":["../../../src/components/LumalIconPicker.vue"],"names":[],"mappings":"AA4PA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAKlD,KAAK,WAAW,GAAG;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAC;AA2EF,KAAK,gBAAgB,GAAG;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAYF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AA6LxD,QAAA,MAAM,YAAY;;;;;;;WA3RR,MAAM;cACH,MAAM;gBACJ,OAAO;gBACP,OAAO;gBACP,MAAM;6EA2RnB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -0,0 +1,29 @@
1
+ /***********************属性与事件*********************/
2
+ type __VLS_Props = {
3
+ cancelText?: string;
4
+ confirmText?: string;
5
+ title?: string;
6
+ };
7
+ type __VLS_ModelProps = {
8
+ 'visible'?: boolean;
9
+ modelValue?: string;
10
+ };
11
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
12
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
+ "update:modelValue": (value: string | undefined) => any;
14
+ cancel: () => any;
15
+ confirm: (icon: string) => any;
16
+ "update:visible": (value: boolean) => any;
17
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
18
+ "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
19
+ onCancel?: (() => any) | undefined;
20
+ onConfirm?: ((icon: string) => any) | undefined;
21
+ "onUpdate:visible"?: ((value: boolean) => any) | undefined;
22
+ }>, {
23
+ title: string;
24
+ cancelText: string;
25
+ confirmText: string;
26
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
27
+ declare const _default: typeof __VLS_export;
28
+ export default _default;
29
+ //# sourceMappingURL=LumalIconPickerDialog.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LumalIconPickerDialog.vue.d.ts","sourceRoot":"","sources":["../../../src/components/LumalIconPickerDialog.vue"],"names":[],"mappings":"AAkLA,mDAAmD;AACnD,KAAK,WAAW,GAAG;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAC;AA+CF,KAAK,gBAAgB,GAAG;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAWF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAqGxD,QAAA,MAAM,YAAY;;;;;;;;;;;WAnKR,MAAM;gBAFD,MAAM;iBACL,MAAM;6EAwKpB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -0,0 +1,10 @@
1
+ import type { IconDefinition, IconGroupDefinition, IconKey } from '@lumal/icons';
2
+ import type { ComputedRef } from 'vue';
3
+ export interface UseIconRegistryReturn {
4
+ groups: ComputedRef<IconGroupDefinition[]>;
5
+ icons: ComputedRef<IconDefinition[]>;
6
+ resolve: (key: IconKey) => IconDefinition | undefined;
7
+ }
8
+ /***********************Vue 响应式适配*********************/
9
+ export declare function useIconRegistry(): UseIconRegistryReturn;
10
+ //# sourceMappingURL=useIconRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIconRegistry.d.ts","sourceRoot":"","sources":["../../../src/composables/useIconRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AAStC,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,WAAW,CAAC,mBAAmB,EAAE,CAAC,CAAA;IAC1C,KAAK,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC,CAAA;IACpC,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,cAAc,GAAG,SAAS,CAAA;CACtD;AAED,uDAAuD;AACvD,wBAAgB,eAAe,IAAI,qBAAqB,CA2BvD"}
@@ -0,0 +1,7 @@
1
+ import LumalIcon from './components/LumalIcon.vue';
2
+ import LumalIconPicker from './components/LumalIconPicker.vue';
3
+ import LumalIconPickerDialog from './components/LumalIconPickerDialog.vue';
4
+ export { LumalIcon, LumalIconPicker, LumalIconPickerDialog, };
5
+ export { useIconRegistry } from './composables/useIconRegistry';
6
+ export type { UseIconRegistryReturn } from './composables/useIconRegistry';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,eAAe,MAAM,kCAAkC,CAAA;AAC9D,OAAO,qBAAqB,MAAM,wCAAwC,CAAA;AAE1E,OAAO,EACL,SAAS,EACT,eAAe,EACf,qBAAqB,GACtB,CAAA;AACD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,YAAY,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@lumal/icons-vue",
3
+ "type": "module",
4
+ "version": "0.0.1-beta",
5
+ "description": "Vue components and reactive adapters for @lumal/icons.",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "lumal",
9
+ "vue",
10
+ "icons",
11
+ "iconify",
12
+ "svg"
13
+ ],
14
+ "sideEffects": [
15
+ "**/*.css"
16
+ ],
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/src/index.d.ts",
23
+ "import": "./dist/index.js",
24
+ "require": "./dist/index.cjs"
25
+ },
26
+ "./style.css": "./dist/icons-vue.css"
27
+ },
28
+ "main": "./dist/index.cjs",
29
+ "module": "./dist/index.js",
30
+ "types": "./dist/src/index.d.ts",
31
+ "files": [
32
+ "README.md",
33
+ "dist"
34
+ ],
35
+ "peerDependencies": {
36
+ "@iconify/vue": "^5.0.0",
37
+ "vue": "^3.5.0"
38
+ },
39
+ "dependencies": {
40
+ "@lumal/icons": "0.0.1-beta"
41
+ },
42
+ "scripts": {
43
+ "build": "vite build --config vite.config.ts && vue-tsc -p tsconfig.json --emitDeclarationOnly --outDir dist && node ../../scripts/clean-package-dist.mjs dist",
44
+ "typecheck": "vue-tsc --noEmit -p tsconfig.json",
45
+ "test": "vitest run --config ../../vitest.config.ts tests"
46
+ }
47
+ }