@qynpm/ui 1.0.36 → 1.0.37

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.
Files changed (45) hide show
  1. package/README.md +22 -6
  2. package/dist/index.cjs +2 -2
  3. package/dist/index.mjs +4 -4
  4. package/dist/qy-action-bar/index.cjs +1 -1
  5. package/dist/qy-action-bar/index.mjs +1 -1
  6. package/dist/qy-dialog/index.cjs +1 -1
  7. package/dist/qy-dialog/index.mjs +1 -1
  8. package/dist/qy-form-section/index.cjs +1 -1
  9. package/dist/qy-form-section/index.mjs +1 -1
  10. package/dist/qy-fullscreen/index.cjs +1 -1
  11. package/dist/qy-fullscreen/index.mjs +1 -1
  12. package/dist/qy-icon/index.cjs +1 -1
  13. package/dist/qy-icon/index.mjs +2 -2
  14. package/dist/qy-icon-picker/index.cjs +2 -2
  15. package/dist/qy-icon-picker/index.mjs +2 -2
  16. package/dist/qy-image-upload/index.cjs +1 -1
  17. package/dist/qy-image-upload/index.mjs +1 -1
  18. package/dist/qy-legacy-selection-dialog/index.cjs +1 -1
  19. package/dist/qy-legacy-selection-dialog/index.mjs +1 -1
  20. package/dist/qy-record-quote-search/index.cjs +1 -1
  21. package/dist/qy-record-quote-search/index.mjs +1 -1
  22. package/dist/qy-remark-image/index.cjs +1 -1
  23. package/dist/qy-remark-image/index.mjs +1 -1
  24. package/dist/qy-remote-select/index.cjs +1 -1
  25. package/dist/qy-remote-select/index.mjs +1 -1
  26. package/dist/qy-search-input/index.cjs +1 -1
  27. package/dist/qy-search-input/index.mjs +1 -1
  28. package/dist/qy-selection-dialog/index.cjs +1 -1
  29. package/dist/qy-selection-dialog/index.mjs +1 -1
  30. package/dist/shared/{index-D654b42n.mjs → index-3KGa3jVi.mjs} +3 -3
  31. package/dist/shared/{index-DY-CA7Vr.mjs → index-BF6f9QDU.mjs} +1 -1
  32. package/dist/shared/{index-Bi9wgcgT.cjs → index-BQEymEbE.cjs} +1 -1
  33. package/dist/shared/{index-3qEac4h8.cjs → index-BTbiht5h.cjs} +1 -1
  34. package/dist/shared/{index-S8HW36Mc.mjs → index-Crr3HB8g.mjs} +1 -1
  35. package/dist/shared/index-D8kce2jH.cjs +1 -0
  36. package/dist/shared/{index-aIqtIYsu.cjs → index-Di_xbC7d.cjs} +1 -1
  37. package/dist/shared/index-Dm8kY2v6.mjs +285 -0
  38. package/dist/shared/index.vue_vue_type_style_index_0_lang-CAW_QOyJ.cjs +1 -0
  39. package/dist/shared/index.vue_vue_type_style_index_0_lang-Dr9Elmzn.mjs +317 -0
  40. package/package.json +4 -3
  41. package/qy-icon/index.d.ts +9 -6
  42. package/dist/shared/index-AMu0L6uU.cjs +0 -1
  43. package/dist/shared/index-C91mzAI3.mjs +0 -254
  44. package/dist/shared/index.vue_vue_type_style_index_0_lang-BcZb1U13.cjs +0 -1
  45. package/dist/shared/index.vue_vue_type_style_index_0_lang-CIcZet5j.mjs +0 -286
@@ -1 +0,0 @@
1
- "use strict";const r=require("vue"),N=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),I=Symbol("QyIconRegistry"),E=new WeakMap;function z(e){const t=[],n=new Map;for(const a of(e==null?void 0:e.icons)??[]){const s=d(a==null?void 0:a.name);if(!s)throw new Error("QyIcon definition name must not be empty.");const u=p(s);if(n.has(u))throw new Error(`Duplicate icon name "${s}".`);const l=K(a,s);t.push(l),n.set(u,l)}const c=[],i=new Map;for(const a of C(e==null?void 0:e.aliases)){const s=d(a.name),u=d(a.target),l=p(s),w=p(u);if(!s)throw new Error("QyIcon alias name must not be empty.");if(!u)throw new Error(`QyIcon alias "${s}" target must not be empty.`);if(n.has(l))throw new Error(`Icon alias "${s}" conflicts with a canonical icon name.`);if(i.has(l))throw new Error(`Duplicate icon alias "${s}".`);const m=n.get(w);if(!m)throw new Error(`Icon alias "${s}" target "${u}" not found.`);i.set(l,p(m.name)),c.push(Object.freeze({name:s,target:m.name}))}const g=Object.freeze({definitions:Object.freeze(t),aliases:Object.freeze(c),byName:n,aliasTargets:i}),f=Object.freeze({resolve(a){const s=p(d(a)),u=i.get(s)??s,l=n.get(u);return l?Q(l):void 0},has(a){const s=p(d(a));return n.has(i.get(s)??s)},list(){return Object.freeze(t.map(Q))}});return E.set(f,g),f}function x(...e){const t=[],n=[];for(const c of e){const i=E.get(c);if(!i)throw new TypeError("mergeQyIconRegistries accepts only QyIcon registries created by this package.");t.push(...i.definitions),n.push(...i.aliases)}try{return z({icons:t,aliases:n})}catch(c){const i=c instanceof Error?c.message:String(c);throw new Error(`Icon registry merge conflict: ${i}`)}}function B(e){if(!E.has(e))throw new TypeError("createQyIconPlugin accepts only a QyIcon registry created by this package.");return Object.freeze({install(t){t.provide(I,e)}})}function d(e){const t=typeof e=="string"||typeof e=="number"?String(e).trim():"";if(!t)return"";const n=/^#icon-(.+)$/i.exec(t);if(n)return n[1].trim();const c=/^icon-\[([^\[\]]+?)--([^\[\]]+?)\]$/i.exec(t);return c?`iconify:${c[1]}:${c[2]}`:t}function p(e){return e.toLocaleLowerCase()}function C(e){return e?Array.isArray(e)?[...e]:Object.entries(e).map(([t,n])=>({name:t,target:n})):[]}function K(e,t){const n={...e.label===void 0?{}:{label:q(e.label,t)},...e.keywords===void 0?{}:{keywords:D(e.keywords,t)}};switch(e.source){case"symbol":return b({name:t,source:"symbol",value:v("symbol",e.value,t),...n});case"component":return b({name:t,source:"component",value:v("component",e.value,t),...n});case"class":return b({name:t,source:"class",value:v("class",e.value,t),...n});default:throw new Error(`QyIcon definition "${t}" has unsupported source "${String(e.source)}".`)}}function v(e,t,n){if(e==="symbol"){if(typeof t!="string"||!/^#[^\s#]+$/.test(t))throw new Error(`QyIcon symbol "${n}" must be a same-document #fragment.`);return t}if(e==="component"){if(typeof t!="object"&&typeof t!="function"||t===null)throw new Error(`QyIcon component "${n}" must be a Vue component.`);return t}if(e!=="class")throw new Error(`QyIcon definition "${n}" has unsupported source "${String(e)}".`);if(typeof t!="string"||!t.trim()||!/^[A-Za-z0-9_:.\/\[\]%-]+(?:\s+[A-Za-z0-9_:.\/\[\]%-]+)*$/.test(t.trim()))throw new Error(`QyIcon class "${n}" must be a trusted static class string.`);return t.trim()}function q(e,t){if(typeof e!="string")throw new Error(`QyIcon label "${t}" must be a string.`);return e}function D(e,t){if(!Array.isArray(e)||e.some(n=>typeof n!="string"))throw new Error(`QyIcon keywords "${t}" must be strings.`);return Object.freeze([...e])}function b(e){return e.keywords&&!Object.isFrozen(e.keywords)&&(e={...e,keywords:Object.freeze([...e.keywords])}),Object.freeze(e)}function Q(e){return b({...e,...e.keywords?{keywords:[...e.keywords]}:{}})}const P=["role","aria-label","aria-hidden","data-qy-icon-missing"],L={key:1,"aria-hidden":"true",focusable:"false"},T=["href","xlink:href"],V=r.defineComponent({name:"QyIcon",inheritAttrs:!1,__name:"index",props:{name:{},icon:{},size:{default:"1em"},color:{default:"currentColor"},spin:{type:Boolean,default:!1},label:{}},setup(e){const t=e,n=r.useAttrs(),c=r.useSlots(),i=r.inject(I,null),g=r.computed(()=>t.icon?r.markRaw(r.toRaw(t.icon)):void 0),f=r.computed(()=>t.name===void 0||t.name===null?"":d(t.name)),a=r.computed(()=>{if(!(t.icon||!i||!f.value))return i.resolve(f.value)}),s=r.ref(null),u=r.computed(()=>!!(!t.icon&&f.value&&!a.value)),l=r.computed(()=>{const o=typeof t.label=="string"?t.label.trim():"";if(o)return o;const y=n["aria-label"];return R(y)?String(y):""}),w=r.computed(()=>l.value?"img":n.role),m=r.computed(()=>O(t.size)),$=r.computed(()=>({width:m.value,height:m.value,fontSize:m.value,color:t.color||"currentColor"})),S=r.computed(()=>{const o={};for(const[y,h]of Object.entries(n))A(y)&&(o[y]=h);return o}),j=r.computed(()=>Object.freeze({name:f.value}));r.watchEffect(()=>{const o=a.value;s.value&&(o==null?void 0:o.source)==="symbol"&&(s.value.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o.value),s.value.setAttribute("xlink:href",o.value))}),r.watchEffect(()=>{});function O(o){return typeof o=="number"?Number.isFinite(o)&&o>0?`${o}px`:"1em":o.trim()||"1em"}function R(o){return typeof o=="string"?o.trim().length>0:o!=null&&o!==!1}function A(o){return o!=="class"&&o!=="style"&&o!=="role"&&o!=="aria-label"&&o!=="aria-hidden"&&o!=="data-qy-icon-missing"&&(o==="id"||o==="title"||o.startsWith("data-")||o.startsWith("aria-"))}return(o,y)=>{var h,k,_;return r.openBlock(),r.createElementBlock("span",r.mergeProps(S.value,{class:["qy-icon",[r.unref(n).class,{"is-spin":t.spin}]],style:[r.unref(n).style,$.value],role:w.value,"aria-label":l.value||void 0,"aria-hidden":l.value?void 0:"true","data-qy-icon-missing":u.value?f.value:void 0}),[g.value?(r.openBlock(),r.createBlock(r.resolveDynamicComponent(g.value),{key:0,"aria-hidden":"true"})):((h=a.value)==null?void 0:h.source)==="symbol"?(r.openBlock(),r.createElementBlock("svg",L,[r.createElementVNode("use",{ref_key:"symbolElement",ref:s,href:a.value.value,"xlink:href":a.value.value},null,8,T)])):((k=a.value)==null?void 0:k.source)==="component"?(r.openBlock(),r.createBlock(r.resolveDynamicComponent(a.value.value),{key:2,"aria-hidden":"true"})):((_=a.value)==null?void 0:_.source)==="class"?(r.openBlock(),r.createElementBlock("span",{key:3,class:r.normalizeClass(["qy-icon__class",a.value.value]),"aria-hidden":"true"},null,2)):u.value&&r.unref(c).fallback?r.renderSlot(o.$slots,"fallback",r.normalizeProps(r.guardReactiveProps(j.value)),void 0,!0,4):r.createCommentVNode("",!0)],16,P)}}}),Y=N._export_sfc(V,[["__scopeId","data-v-e4e9c6ae"]]);exports.Icon=Y;exports.QY_ICON_REGISTRY_KEY=I;exports.createQyIconPlugin=B;exports.createQyIconRegistry=z;exports.mergeQyIconRegistries=x;exports.normalizeQyIconName=d;
@@ -1,254 +0,0 @@
1
- import { defineComponent as L, useAttrs as P, useSlots as q, inject as B, computed as u, markRaw as T, toRaw as V, ref as M, watchEffect as k, openBlock as h, createElementBlock as I, mergeProps as W, unref as E, createBlock as S, resolveDynamicComponent as j, createElementVNode as Y, normalizeClass as F, renderSlot as Z, normalizeProps as G, guardReactiveProps as H, createCommentVNode as J } from "vue";
2
- import { _ as U } from "./_plugin-vue_export-helper-CHgC5LLL.mjs";
3
- const A = Symbol("QyIconRegistry"), _ = /* @__PURE__ */ new WeakMap();
4
- function X(e) {
5
- const t = [], n = /* @__PURE__ */ new Map();
6
- for (const s of (e == null ? void 0 : e.icons) ?? []) {
7
- const o = g(s == null ? void 0 : s.name);
8
- if (!o)
9
- throw new Error("QyIcon definition name must not be empty.");
10
- const l = d(o);
11
- if (n.has(l))
12
- throw new Error(`Duplicate icon name "${o}".`);
13
- const i = te(s, o);
14
- t.push(i), n.set(l, i);
15
- }
16
- const a = [], c = /* @__PURE__ */ new Map();
17
- for (const s of ee(e == null ? void 0 : e.aliases)) {
18
- const o = g(s.name), l = g(s.target), i = d(o), v = d(l);
19
- if (!o)
20
- throw new Error("QyIcon alias name must not be empty.");
21
- if (!l)
22
- throw new Error(`QyIcon alias "${o}" target must not be empty.`);
23
- if (n.has(i))
24
- throw new Error(`Icon alias "${o}" conflicts with a canonical icon name.`);
25
- if (c.has(i))
26
- throw new Error(`Duplicate icon alias "${o}".`);
27
- const m = n.get(v);
28
- if (!m)
29
- throw new Error(`Icon alias "${o}" target "${l}" not found.`);
30
- c.set(i, d(m.name)), a.push(Object.freeze({ name: o, target: m.name }));
31
- }
32
- const b = Object.freeze({
33
- definitions: Object.freeze(t),
34
- aliases: Object.freeze(a),
35
- byName: n,
36
- aliasTargets: c
37
- }), f = Object.freeze({
38
- resolve(s) {
39
- const o = d(g(s)), l = c.get(o) ?? o, i = n.get(l);
40
- return i ? O(i) : void 0;
41
- },
42
- has(s) {
43
- const o = d(g(s));
44
- return n.has(c.get(o) ?? o);
45
- },
46
- list() {
47
- return Object.freeze(t.map(O));
48
- }
49
- });
50
- return _.set(f, b), f;
51
- }
52
- function ue(...e) {
53
- const t = [], n = [];
54
- for (const a of e) {
55
- const c = _.get(a);
56
- if (!c)
57
- throw new TypeError("mergeQyIconRegistries accepts only QyIcon registries created by this package.");
58
- t.push(...c.definitions), n.push(...c.aliases);
59
- }
60
- try {
61
- return X({ icons: t, aliases: n });
62
- } catch (a) {
63
- const c = a instanceof Error ? a.message : String(a);
64
- throw new Error(`Icon registry merge conflict: ${c}`);
65
- }
66
- }
67
- function fe(e) {
68
- if (!_.has(e))
69
- throw new TypeError("createQyIconPlugin accepts only a QyIcon registry created by this package.");
70
- return Object.freeze({
71
- install(t) {
72
- t.provide(A, e);
73
- }
74
- });
75
- }
76
- function g(e) {
77
- const t = typeof e == "string" || typeof e == "number" ? String(e).trim() : "";
78
- if (!t) return "";
79
- const n = /^#icon-(.+)$/i.exec(t);
80
- if (n) return n[1].trim();
81
- const a = /^icon-\[([^\[\]]+?)--([^\[\]]+?)\]$/i.exec(t);
82
- return a ? `iconify:${a[1]}:${a[2]}` : t;
83
- }
84
- function d(e) {
85
- return e.toLocaleLowerCase();
86
- }
87
- function ee(e) {
88
- return e ? Array.isArray(e) ? [...e] : Object.entries(e).map(([t, n]) => ({ name: t, target: n })) : [];
89
- }
90
- function te(e, t) {
91
- const n = {
92
- ...e.label === void 0 ? {} : { label: re(e.label, t) },
93
- ...e.keywords === void 0 ? {} : { keywords: ne(e.keywords, t) }
94
- };
95
- switch (e.source) {
96
- case "symbol":
97
- return p({
98
- name: t,
99
- source: "symbol",
100
- value: z("symbol", e.value, t),
101
- ...n
102
- });
103
- case "component":
104
- return p({
105
- name: t,
106
- source: "component",
107
- value: z("component", e.value, t),
108
- ...n
109
- });
110
- case "class":
111
- return p({
112
- name: t,
113
- source: "class",
114
- value: z("class", e.value, t),
115
- ...n
116
- });
117
- default:
118
- throw new Error(`QyIcon definition "${t}" has unsupported source "${String(e.source)}".`);
119
- }
120
- }
121
- function z(e, t, n) {
122
- if (e === "symbol") {
123
- if (typeof t != "string" || !/^#[^\s#]+$/.test(t))
124
- throw new Error(`QyIcon symbol "${n}" must be a same-document #fragment.`);
125
- return t;
126
- }
127
- if (e === "component") {
128
- if (typeof t != "object" && typeof t != "function" || t === null)
129
- throw new Error(`QyIcon component "${n}" must be a Vue component.`);
130
- return t;
131
- }
132
- if (e !== "class")
133
- throw new Error(`QyIcon definition "${n}" has unsupported source "${String(e)}".`);
134
- if (typeof t != "string" || !t.trim() || !/^[A-Za-z0-9_:.\/\[\]%-]+(?:\s+[A-Za-z0-9_:.\/\[\]%-]+)*$/.test(t.trim()))
135
- throw new Error(`QyIcon class "${n}" must be a trusted static class string.`);
136
- return t.trim();
137
- }
138
- function re(e, t) {
139
- if (typeof e != "string")
140
- throw new Error(`QyIcon label "${t}" must be a string.`);
141
- return e;
142
- }
143
- function ne(e, t) {
144
- if (!Array.isArray(e) || e.some((n) => typeof n != "string"))
145
- throw new Error(`QyIcon keywords "${t}" must be strings.`);
146
- return Object.freeze([...e]);
147
- }
148
- function p(e) {
149
- return e.keywords && !Object.isFrozen(e.keywords) && (e = { ...e, keywords: Object.freeze([...e.keywords]) }), Object.freeze(e);
150
- }
151
- function O(e) {
152
- return p({
153
- ...e,
154
- ...e.keywords ? { keywords: [...e.keywords] } : {}
155
- });
156
- }
157
- const oe = ["role", "aria-label", "aria-hidden", "data-qy-icon-missing"], se = {
158
- key: 1,
159
- "aria-hidden": "true",
160
- focusable: "false"
161
- }, ae = ["href", "xlink:href"], ce = /* @__PURE__ */ L({
162
- name: "QyIcon",
163
- inheritAttrs: !1,
164
- __name: "index",
165
- props: {
166
- name: {},
167
- icon: {},
168
- size: { default: "1em" },
169
- color: { default: "currentColor" },
170
- spin: { type: Boolean, default: !1 },
171
- label: {}
172
- },
173
- setup(e) {
174
- const t = e, n = P(), a = q(), c = B(A, null), b = u(
175
- () => t.icon ? T(V(t.icon)) : void 0
176
- ), f = u(
177
- () => t.name === void 0 || t.name === null ? "" : g(t.name)
178
- ), s = u(() => {
179
- if (!(t.icon || !c || !f.value))
180
- return c.resolve(f.value);
181
- }), o = M(null), l = u(() => !!(!t.icon && f.value && !s.value)), i = u(() => {
182
- const r = typeof t.label == "string" ? t.label.trim() : "";
183
- if (r) return r;
184
- const y = n["aria-label"];
185
- return K(y) ? String(y) : "";
186
- }), v = u(() => i.value ? "img" : n.role), m = u(() => C(t.size)), x = u(() => ({
187
- width: m.value,
188
- height: m.value,
189
- fontSize: m.value,
190
- color: t.color || "currentColor"
191
- })), N = u(() => {
192
- const r = {};
193
- for (const [y, w] of Object.entries(n))
194
- D(y) && (r[y] = w);
195
- return r;
196
- }), R = u(() => Object.freeze({ name: f.value }));
197
- k(() => {
198
- const r = s.value;
199
- o.value && (r == null ? void 0 : r.source) === "symbol" && (o.value.setAttributeNS(
200
- "http://www.w3.org/1999/xlink",
201
- "xlink:href",
202
- r.value
203
- ), o.value.setAttribute("xlink:href", r.value));
204
- }), k(() => {
205
- });
206
- function C(r) {
207
- return typeof r == "number" ? Number.isFinite(r) && r > 0 ? `${r}px` : "1em" : r.trim() || "1em";
208
- }
209
- function K(r) {
210
- return typeof r == "string" ? r.trim().length > 0 : r != null && r !== !1;
211
- }
212
- function D(r) {
213
- return r !== "class" && r !== "style" && r !== "role" && r !== "aria-label" && r !== "aria-hidden" && r !== "data-qy-icon-missing" && (r === "id" || r === "title" || r.startsWith("data-") || r.startsWith("aria-"));
214
- }
215
- return (r, y) => {
216
- var w, $, Q;
217
- return h(), I("span", W(N.value, {
218
- class: ["qy-icon", [E(n).class, { "is-spin": t.spin }]],
219
- style: [E(n).style, x.value],
220
- role: v.value,
221
- "aria-label": i.value || void 0,
222
- "aria-hidden": i.value ? void 0 : "true",
223
- "data-qy-icon-missing": l.value ? f.value : void 0
224
- }), [
225
- b.value ? (h(), S(j(b.value), {
226
- key: 0,
227
- "aria-hidden": "true"
228
- })) : ((w = s.value) == null ? void 0 : w.source) === "symbol" ? (h(), I("svg", se, [
229
- Y("use", {
230
- ref_key: "symbolElement",
231
- ref: o,
232
- href: s.value.value,
233
- "xlink:href": s.value.value
234
- }, null, 8, ae)
235
- ])) : (($ = s.value) == null ? void 0 : $.source) === "component" ? (h(), S(j(s.value.value), {
236
- key: 2,
237
- "aria-hidden": "true"
238
- })) : ((Q = s.value) == null ? void 0 : Q.source) === "class" ? (h(), I("span", {
239
- key: 3,
240
- class: F(["qy-icon__class", s.value.value]),
241
- "aria-hidden": "true"
242
- }, null, 2)) : l.value && E(a).fallback ? Z(r.$slots, "fallback", G(H(R.value)), void 0, !0, 4) : J("", !0)
243
- ], 16, oe);
244
- };
245
- }
246
- }), me = /* @__PURE__ */ U(ce, [["__scopeId", "data-v-e4e9c6ae"]]);
247
- export {
248
- me as I,
249
- A as Q,
250
- X as a,
251
- fe as c,
252
- ue as m,
253
- g as n
254
- };
@@ -1 +0,0 @@
1
- "use strict";const e=require("vue"),E=require("./index-Bi9wgcgT.cjs"),K=require("./index-nSFTxVz8.cjs"),j=require("../qy-popover/index.cjs"),L=require("./index-AMu0L6uU.cjs");function F(l,p){const f=p==null?"":String(p),n=l&&f?l.resolve(f):void 0;return Object.freeze({value:f,known:!!n,canonicalName:n==null?void 0:n.name,definition:n})}function Y(l,p,f=""){const n=(l==null?void 0:l.list())??[],c=p===void 0?void 0:new Set(p.map(r=>{var s;return(s=l==null?void 0:l.resolve(r))==null?void 0:s.name}).filter(r=>!!r).map(P)),h=String(f).trim().toLocaleLowerCase();return Object.freeze(n.filter(r=>c&&!c.has(P(r.name))?!1:h?[r.name,r.label,...r.keywords??[]].some(s=>typeof s=="string"&&s.toLocaleLowerCase().includes(h)):!0))}function P(l){return L.normalizeQyIconName(l).toLocaleLowerCase()}const W={class:"qy-icon-picker"},G=["onKeydown"],H={class:"qy-icon-picker__preview","aria-hidden":"true"},J={key:1,class:"qy-icon-picker__missing","aria-hidden":"true"},X=["id"],Z={class:"qy-icon-picker__search","data-testid":"qy-icon-picker-search"},ee=["aria-label"],ae=["id","data-qy-icon-option","data-qy-icon-active","aria-selected","tabindex","onClick","onFocus","onKeydown"],ne={class:"qy-icon-picker__option-label"},oe={key:1,class:"qy-icon-picker__empty"};let te=0;const le=e.defineComponent({name:"QyIconPicker",__name:"index",props:{modelValue:{default:""},allowedNames:{},disabled:{type:Boolean,default:!1},clearable:{type:Boolean,default:!1},size:{default:"default"},placeholder:{default:"点击选择图标"},searchPlaceholder:{default:"搜索图标名称、标签或关键词"},emptyText:{default:"暂无匹配图标"},panelWidth:{default:540},open:{type:Boolean,default:void 0},id:{},ariaLabel:{}},emits:["update:modelValue","change","clear","update:open","open-change"],setup(l,{expose:p,emit:f}){const n=l,c=f,h=e.inject(L.QY_ICON_REGISTRY_KEY,null),r=e.ref(""),s=e.ref(!1),i=e.ref(-1),b=e.ref([]),y=e.ref(null),x=e.ref(null),w=e.ref("pointer"),Q=`qy-icon-picker-${++te}`,v=e.computed(()=>F(h,n.modelValue)),d=e.computed(()=>Y(h,n.allowedNames,r.value)),k=e.computed(()=>n.open!==void 0),m=e.computed(()=>k.value?n.open===!0:s.value),R=e.computed(()=>"click"),g=e.computed(()=>`${n.id||Q}-panel`);e.watch(m,(a,o)=>{!a||o||(r.value="",i.value=M(),b.value=[],w.value==="keyboard"&&e.nextTick(()=>{var t,u;return(u=(t=x.value)==null?void 0:t.focus)==null?void 0:u.call(t)}))}),e.watch(d,()=>{if(!d.value.length){i.value=-1;return}i.value>=d.value.length&&(i.value=0),i.value<0&&(i.value=0)});function N(){n.disabled||(w.value="keyboard",I("keyboard"))}function T(a){n.disabled||k.value&&n.open!==!1||(a.stopImmediatePropagation(),I("pointer"))}function z(a){q(a)}function $(a){a===m.value&&(k.value||(s.value=a),c("open-change",a),a||e.nextTick(()=>{var o,t;return(t=(o=y.value)==null?void 0:o.focus)==null?void 0:t.call(o)}))}function q(a){a&&n.disabled||a!==m.value&&(k.value||(s.value=a),c("update:open",a))}function I(a="programmatic"){w.value=a,q(!0)}function B(){q(!1),e.nextTick(()=>{var a,o;return(o=(a=y.value)==null?void 0:a.focus)==null?void 0:o.call(a)})}function V(){n.disabled||(c("update:modelValue",""),c("change",""),c("clear"))}function C(a){n.disabled||(c("update:modelValue",a.name),c("change",a.name),B())}function S(a){if(a.key==="Escape"){a.preventDefault(),B();return}if(!d.value.length||!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"].includes(a.key))return;a.preventDefault();const o=a.key==="ArrowUp"||a.key==="ArrowLeft"?-1:1,t=d.value.length;i.value=(i.value+o+t)%t,e.nextTick(()=>{var u;return(u=b.value[i.value])==null?void 0:u.focus()})}function M(){const a=v.value.canonicalName;if(!a)return d.value.length?0:-1;const o=d.value.findIndex(({name:t})=>t===a);return o>=0?o:d.value.length?0:-1}function A(a,o){a instanceof HTMLElement&&(b.value[o]=a)}function O(a){return`${g.value}-${encodeURIComponent(a)}`}function D(){var a,o;(o=(a=y.value)==null?void 0:a.focus)==null||o.call(a)}function U(){var a,o;(o=(a=y.value)==null?void 0:a.blur)==null||o.call(a)}return p({focus:D,blur:U,open:I,close:B}),(a,o)=>(e.openBlock(),e.createElementBlock("div",W,[e.createVNode(e.unref(j.QyPopover),{ref:"popoverRef",class:"qy-icon-picker__popover",open:m.value,trigger:R.value,placement:"bottom-start",width:n.panelWidth,"show-delay":0,"hide-delay":0,disabled:n.disabled||k.value&&n.open===!1,"onUpdate:open":z,onOpenChange:$},{reference:e.withCtx(()=>[e.createElementVNode("div",{class:"qy-icon-picker__trigger","data-testid":"qy-icon-picker-trigger",onClick:T,onKeydown:[e.withKeys(e.withModifiers(N,["prevent"]),["enter"]),e.withKeys(e.withModifiers(N,["prevent"]),["space"])]},[e.createVNode(e.unref(K.QyInput),{ref_key:"triggerRef",ref:y,id:n.id,"model-value":v.value.value,size:n.size,disabled:n.disabled,clearable:n.clearable,readonly:"",placeholder:n.placeholder,"aria-label":n.ariaLabel,"aria-haspopup":"listbox","aria-expanded":m.value?"true":"false","aria-controls":g.value,onClear:V},{prefix:e.withCtx(()=>[e.createElementVNode("span",H,[v.value.definition?(e.openBlock(),e.createBlock(e.unref(E.QyIcon),{key:0,name:v.value.definition.name,size:18},null,8,["name"])):(e.openBlock(),e.createElementBlock("span",J,"?"))])]),suffix:e.withCtx(()=>[n.clearable&&v.value.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"qy-icon-picker__clear","data-testid":"qy-icon-picker-clear","aria-label":"清空图标",onClick:e.withModifiers(V,["stop","prevent"])},[...o[1]||(o[1]=[e.createElementVNode("span",{"aria-hidden":"true"},"×",-1)])])):e.createCommentVNode("",!0)]),_:1},8,["id","model-value","size","disabled","clearable","placeholder","aria-label","aria-expanded","aria-controls"])],40,G)]),default:e.withCtx(()=>[m.value?(e.openBlock(),e.createElementBlock("div",{key:0,id:g.value,class:"qy-icon-picker__panel",onKeydown:S},[e.createElementVNode("div",Z,[e.createVNode(e.unref(K.QyInput),{ref_key:"searchRef",ref:x,modelValue:r.value,"onUpdate:modelValue":o[0]||(o[0]=t=>r.value=t),type:"search",clearable:"",placeholder:n.searchPlaceholder,"aria-label":"搜索图标"},null,8,["modelValue","placeholder"])]),d.value.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:"qy-icon-picker__grid",role:"listbox","aria-label":n.ariaLabel||"图标列表"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(t,u)=>(e.openBlock(),e.createElementBlock("div",{id:O(t.name),key:t.name,ref_for:!0,ref:_=>A(_,u),class:e.normalizeClass(["qy-icon-picker__option",{"is-active":i.value===u}]),"data-qy-icon-option":t.name,"data-qy-icon-active":i.value===u?"true":void 0,role:"option","aria-selected":v.value.canonicalName===t.name?"true":"false",tabindex:i.value===u?0:-1,onClick:_=>C(t),onFocus:_=>i.value=u,onKeydown:[e.withKeys(e.withModifiers(_=>C(t),["prevent"]),["enter"]),e.withKeys(e.withModifiers(_=>C(t),["prevent"]),["space"])]},[e.createVNode(e.unref(E.QyIcon),{name:t.name,size:18,"aria-hidden":"true"},null,8,["name"]),e.createElementVNode("span",ne,e.toDisplayString(t.label||t.name),1)],42,ae))),128))],8,ee)):(e.openBlock(),e.createElementBlock("div",oe,[e.renderSlot(a.$slots,"empty",{},()=>[e.createTextVNode(e.toDisplayString(n.emptyText),1)])]))],40,X)):e.createCommentVNode("",!0)]),_:3},8,["open","trigger","width","disabled"])]))}});exports._sfc_main=le;
@@ -1,286 +0,0 @@
1
- import { defineComponent as oe, inject as le, ref as m, computed as _, watch as E, nextTick as L, openBlock as d, createElementBlock as f, createVNode as P, unref as q, withCtx as Q, createElementVNode as I, Fragment as te, renderList as re, withKeys as R, withModifiers as C, normalizeClass as ie, toDisplayString as O, renderSlot as ce, createTextVNode as ue, createCommentVNode as U, createBlock as se } from "vue";
2
- import { Q as D } from "./index-DY-CA7Vr.mjs";
3
- import { Q as j } from "./index-JjHutKmT.mjs";
4
- import { QyPopover as de } from "../qy-popover/index.mjs";
5
- import { n as pe, Q as fe } from "./index-C91mzAI3.mjs";
6
- function ve(l, p) {
7
- const v = p == null ? "" : String(p), a = l && v ? l.resolve(v) : void 0;
8
- return Object.freeze({
9
- value: v,
10
- known: !!a,
11
- canonicalName: a == null ? void 0 : a.name,
12
- definition: a
13
- });
14
- }
15
- function me(l, p, v = "") {
16
- const a = (l == null ? void 0 : l.list()) ?? [], i = p === void 0 ? void 0 : new Set(
17
- p.map((t) => {
18
- var s;
19
- return (s = l == null ? void 0 : l.resolve(t)) == null ? void 0 : s.name;
20
- }).filter((t) => !!t).map(F)
21
- ), k = String(v).trim().toLocaleLowerCase();
22
- return Object.freeze(
23
- a.filter((t) => i && !i.has(F(t.name)) ? !1 : k ? [
24
- t.name,
25
- t.label,
26
- ...t.keywords ?? []
27
- ].some(
28
- (s) => typeof s == "string" && s.toLocaleLowerCase().includes(k)
29
- ) : !0)
30
- );
31
- }
32
- function F(l) {
33
- return pe(l).toLocaleLowerCase();
34
- }
35
- const ye = { class: "qy-icon-picker" }, he = ["onKeydown"], _e = {
36
- class: "qy-icon-picker__preview",
37
- "aria-hidden": "true"
38
- }, ke = {
39
- key: 1,
40
- class: "qy-icon-picker__missing",
41
- "aria-hidden": "true"
42
- }, be = ["id"], ge = {
43
- class: "qy-icon-picker__search",
44
- "data-testid": "qy-icon-picker-search"
45
- }, we = ["aria-label"], qe = ["id", "data-qy-icon-option", "data-qy-icon-active", "aria-selected", "tabindex", "onClick", "onFocus", "onKeydown"], Ie = { class: "qy-icon-picker__option-label" }, Ce = {
46
- key: 1,
47
- class: "qy-icon-picker__empty"
48
- };
49
- let Le = 0;
50
- const Ne = /* @__PURE__ */ oe({
51
- name: "QyIconPicker",
52
- __name: "index",
53
- props: {
54
- modelValue: { default: "" },
55
- allowedNames: {},
56
- disabled: { type: Boolean, default: !1 },
57
- clearable: { type: Boolean, default: !1 },
58
- size: { default: "default" },
59
- placeholder: { default: "点击选择图标" },
60
- searchPlaceholder: { default: "搜索图标名称、标签或关键词" },
61
- emptyText: { default: "暂无匹配图标" },
62
- panelWidth: { default: 540 },
63
- open: { type: Boolean, default: void 0 },
64
- id: {},
65
- ariaLabel: {}
66
- },
67
- emits: ["update:modelValue", "change", "clear", "update:open", "open-change"],
68
- setup(l, { expose: p, emit: v }) {
69
- const a = l, i = v, k = le(fe, null), t = m(""), s = m(!1), r = m(-1), z = m([]), b = m(null), B = m(null), K = m("pointer"), M = `qy-icon-picker-${++Le}`, y = _(
70
- () => ve(k, a.modelValue)
71
- ), u = _(
72
- () => me(k, a.allowedNames, t.value)
73
- ), g = _(() => a.open !== void 0), h = _(
74
- () => g.value ? a.open === !0 : s.value
75
- ), Y = _(() => "click"), N = _(() => `${a.id || M}-panel`);
76
- E(
77
- h,
78
- (e, n) => {
79
- !e || n || (t.value = "", r.value = X(), z.value = [], K.value === "keyboard" && L(() => {
80
- var o, c;
81
- return (c = (o = B.value) == null ? void 0 : o.focus) == null ? void 0 : c.call(o);
82
- }));
83
- }
84
- ), E(u, () => {
85
- if (!u.value.length) {
86
- r.value = -1;
87
- return;
88
- }
89
- r.value >= u.value.length && (r.value = 0), r.value < 0 && (r.value = 0);
90
- });
91
- function S() {
92
- a.disabled || (K.value = "keyboard", V("keyboard"));
93
- }
94
- function W(e) {
95
- a.disabled || g.value && a.open !== !1 || (e.stopImmediatePropagation(), V("pointer"));
96
- }
97
- function G(e) {
98
- x(e);
99
- }
100
- function H(e) {
101
- e === h.value && (g.value || (s.value = e), i("open-change", e), e || L(() => {
102
- var n, o;
103
- return (o = (n = b.value) == null ? void 0 : n.focus) == null ? void 0 : o.call(n);
104
- }));
105
- }
106
- function x(e) {
107
- e && a.disabled || e !== h.value && (g.value || (s.value = e), i("update:open", e));
108
- }
109
- function V(e = "programmatic") {
110
- K.value = e, x(!0);
111
- }
112
- function T() {
113
- x(!1), L(() => {
114
- var e, n;
115
- return (n = (e = b.value) == null ? void 0 : e.focus) == null ? void 0 : n.call(e);
116
- });
117
- }
118
- function A() {
119
- a.disabled || (i("update:modelValue", ""), i("change", ""), i("clear"));
120
- }
121
- function $(e) {
122
- a.disabled || (i("update:modelValue", e.name), i("change", e.name), T());
123
- }
124
- function J(e) {
125
- if (e.key === "Escape") {
126
- e.preventDefault(), T();
127
- return;
128
- }
129
- if (!u.value.length || !["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"].includes(e.key)) return;
130
- e.preventDefault();
131
- const n = e.key === "ArrowUp" || e.key === "ArrowLeft" ? -1 : 1, o = u.value.length;
132
- r.value = (r.value + n + o) % o, L(() => {
133
- var c;
134
- return (c = z.value[r.value]) == null ? void 0 : c.focus();
135
- });
136
- }
137
- function X() {
138
- const e = y.value.canonicalName;
139
- if (!e) return u.value.length ? 0 : -1;
140
- const n = u.value.findIndex(({ name: o }) => o === e);
141
- return n >= 0 ? n : u.value.length ? 0 : -1;
142
- }
143
- function Z(e, n) {
144
- e instanceof HTMLElement && (z.value[n] = e);
145
- }
146
- function ee(e) {
147
- return `${N.value}-${encodeURIComponent(e)}`;
148
- }
149
- function ae() {
150
- var e, n;
151
- (n = (e = b.value) == null ? void 0 : e.focus) == null || n.call(e);
152
- }
153
- function ne() {
154
- var e, n;
155
- (n = (e = b.value) == null ? void 0 : e.blur) == null || n.call(e);
156
- }
157
- return p({ focus: ae, blur: ne, open: V, close: T }), (e, n) => (d(), f("div", ye, [
158
- P(q(de), {
159
- ref: "popoverRef",
160
- class: "qy-icon-picker__popover",
161
- open: h.value,
162
- trigger: Y.value,
163
- placement: "bottom-start",
164
- width: a.panelWidth,
165
- "show-delay": 0,
166
- "hide-delay": 0,
167
- disabled: a.disabled || g.value && a.open === !1,
168
- "onUpdate:open": G,
169
- onOpenChange: H
170
- }, {
171
- reference: Q(() => [
172
- I("div", {
173
- class: "qy-icon-picker__trigger",
174
- "data-testid": "qy-icon-picker-trigger",
175
- onClick: W,
176
- onKeydown: [
177
- R(C(S, ["prevent"]), ["enter"]),
178
- R(C(S, ["prevent"]), ["space"])
179
- ]
180
- }, [
181
- P(q(j), {
182
- ref_key: "triggerRef",
183
- ref: b,
184
- id: a.id,
185
- "model-value": y.value.value,
186
- size: a.size,
187
- disabled: a.disabled,
188
- clearable: a.clearable,
189
- readonly: "",
190
- placeholder: a.placeholder,
191
- "aria-label": a.ariaLabel,
192
- "aria-haspopup": "listbox",
193
- "aria-expanded": h.value ? "true" : "false",
194
- "aria-controls": N.value,
195
- onClear: A
196
- }, {
197
- prefix: Q(() => [
198
- I("span", _e, [
199
- y.value.definition ? (d(), se(q(D), {
200
- key: 0,
201
- name: y.value.definition.name,
202
- size: 18
203
- }, null, 8, ["name"])) : (d(), f("span", ke, "?"))
204
- ])
205
- ]),
206
- suffix: Q(() => [
207
- a.clearable && y.value.value ? (d(), f("button", {
208
- key: 0,
209
- type: "button",
210
- class: "qy-icon-picker__clear",
211
- "data-testid": "qy-icon-picker-clear",
212
- "aria-label": "清空图标",
213
- onClick: C(A, ["stop", "prevent"])
214
- }, [...n[1] || (n[1] = [
215
- I("span", { "aria-hidden": "true" }, "×", -1)
216
- ])])) : U("", !0)
217
- ]),
218
- _: 1
219
- }, 8, ["id", "model-value", "size", "disabled", "clearable", "placeholder", "aria-label", "aria-expanded", "aria-controls"])
220
- ], 40, he)
221
- ]),
222
- default: Q(() => [
223
- h.value ? (d(), f("div", {
224
- key: 0,
225
- id: N.value,
226
- class: "qy-icon-picker__panel",
227
- onKeydown: J
228
- }, [
229
- I("div", ge, [
230
- P(q(j), {
231
- ref_key: "searchRef",
232
- ref: B,
233
- modelValue: t.value,
234
- "onUpdate:modelValue": n[0] || (n[0] = (o) => t.value = o),
235
- type: "search",
236
- clearable: "",
237
- placeholder: a.searchPlaceholder,
238
- "aria-label": "搜索图标"
239
- }, null, 8, ["modelValue", "placeholder"])
240
- ]),
241
- u.value.length ? (d(), f("div", {
242
- key: 0,
243
- class: "qy-icon-picker__grid",
244
- role: "listbox",
245
- "aria-label": a.ariaLabel || "图标列表"
246
- }, [
247
- (d(!0), f(te, null, re(u.value, (o, c) => (d(), f("div", {
248
- id: ee(o.name),
249
- key: o.name,
250
- ref_for: !0,
251
- ref: (w) => Z(w, c),
252
- class: ie(["qy-icon-picker__option", { "is-active": r.value === c }]),
253
- "data-qy-icon-option": o.name,
254
- "data-qy-icon-active": r.value === c ? "true" : void 0,
255
- role: "option",
256
- "aria-selected": y.value.canonicalName === o.name ? "true" : "false",
257
- tabindex: r.value === c ? 0 : -1,
258
- onClick: (w) => $(o),
259
- onFocus: (w) => r.value = c,
260
- onKeydown: [
261
- R(C((w) => $(o), ["prevent"]), ["enter"]),
262
- R(C((w) => $(o), ["prevent"]), ["space"])
263
- ]
264
- }, [
265
- P(q(D), {
266
- name: o.name,
267
- size: 18,
268
- "aria-hidden": "true"
269
- }, null, 8, ["name"]),
270
- I("span", Ie, O(o.label || o.name), 1)
271
- ], 42, qe))), 128))
272
- ], 8, we)) : (d(), f("div", Ce, [
273
- ce(e.$slots, "empty", {}, () => [
274
- ue(O(a.emptyText), 1)
275
- ])
276
- ]))
277
- ], 40, be)) : U("", !0)
278
- ]),
279
- _: 3
280
- }, 8, ["open", "trigger", "width", "disabled"])
281
- ]));
282
- }
283
- });
284
- export {
285
- Ne as _
286
- };