@ui0/icon 0.1.4 → 0.1.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"getIcon.d.ts","sourceRoot":"","sources":["../src/getIcon.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,wBAAgB,OAAO,IAAI,QAAQ,CASlC"}
1
+ {"version":3,"file":"getIcon.d.ts","sourceRoot":"","sources":["../src/getIcon.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,wBAAgB,OAAO,IAAI,QAAQ,CAOlC"}
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  var ne = Object.defineProperty;
2
- var ce = (o, s, e) => s in o ? ne(o, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[s] = e;
3
- var z = (o, s, e) => ce(o, typeof s != "symbol" ? s + "" : s, e);
2
+ var ce = (s, o, e) => o in s ? ne(s, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[o] = e;
3
+ var z = (s, o, e) => ce(s, typeof o != "symbol" ? o + "" : o, e);
4
4
  import { newErrorForSetupCall as ie, isArray as re, hyphenate as ae } from "@ui0/util";
5
- import { inject as Z, getCurrentInstance as le, h as E, reactive as ue, onScopeDispose as pe, resolveComponent as fe, defineComponent as de, useCssModule as he, useAttrs as me, openBlock as ge, createBlock as ve, mergeProps as G, camelize as ke } from "vue";
5
+ import { hasInjectionContext as le, inject as Z, h as E, reactive as pe, onScopeDispose as ue, resolveComponent as fe, defineComponent as de, useCssModule as he, useAttrs as me, openBlock as ge, createBlock as ve, mergeProps as G, camelize as ke } from "vue";
6
6
  import { useComponentId as we } from "@ui0/composable";
7
7
  const ye = Symbol.for("ui0-icon"), Y = Symbol("ui0-icon-instance");
8
- function ps() {
9
- const o = Z(Y, void 0);
10
- if (o) return o;
11
- const s = le();
12
- if (!s) throw ie("getIcon");
13
- return s.appContext.config.globalProperties.$ui0Icon;
8
+ function us() {
9
+ if (le()) {
10
+ const s = Z(Y, void 0);
11
+ if (s) return s;
12
+ }
13
+ throw ie("getIcon");
14
14
  }
15
15
  const be = {
16
16
  value: "fake",
@@ -32,15 +32,15 @@ const be = {
32
32
  guides: !1
33
33
  }
34
34
  };
35
- function xe(o, s) {
35
+ function xe(s, o) {
36
36
  const e = [
37
- o,
38
37
  s,
38
+ o,
39
39
  be
40
40
  ], d = (n) => {
41
41
  for (const i of e) {
42
- const u = i == null ? void 0 : i[n];
43
- if (u !== void 0) return u;
42
+ const p = i == null ? void 0 : i[n];
43
+ if (p !== void 0) return p;
44
44
  }
45
45
  };
46
46
  return new Proxy({}, {
@@ -65,51 +65,51 @@ const q = {
65
65
  heptagon: "M462.6,40.8L133.9,199.2c-11,5.3-18.9,15.3-21.6,27.1L31.1,582c-2.7,11.9.1,24.3,7.7,33.8l227.5,285.3c7.6,9.5,19.1,15.1,31.3,15.1h364.9c12.2,0,23.7-5.5,31.3-15.1l227.5-285.3c7.6-9.5,10.4-22,7.7-33.8l-81.2-355.7c-2.7-11.9-10.7-21.9-21.6-27.1L497.4,40.8c-11-5.3-23.7-5.3-34.7,0Z",
66
66
  octagon: "M523,38.5l238.7,98.9c27.6,11.4,49.5,33.3,60.9,60.9l98.9,238.7c11.4,27.6,11.4,58.5,0,86.1l-98.9,238.7c-11.4,27.6-33.3,49.5-60.9,60.9l-238.7,98.9c-27.6,11.4-58.5,11.4-86.1,0l-238.7-98.9c-27.6-11.4-49.5-33.3-60.9-60.9l-98.9-238.7c-11.4-27.6-11.4-58.5,0-86.1l98.9-238.7c11.4-27.6,33.3-49.5,60.9-60.9l238.7-98.9c27.6-11.4,58.5-11.4,86.1,0h0Z"
67
67
  };
68
- function _e(o) {
69
- return o in q;
68
+ function _e(s) {
69
+ return s in q;
70
70
  }
71
- function W(o) {
72
- return !!o && "customOptions" in o;
71
+ function W(s) {
72
+ return !!s && "customOptions" in s;
73
73
  }
74
- function R(o) {
75
- return (s) => E("g", o, s || []);
74
+ function R(s) {
75
+ return (o) => E("g", s, o || []);
76
76
  }
77
77
  class Se {
78
78
  constructor() {
79
79
  z(this, "stack", []);
80
80
  }
81
- add(s) {
82
- this.stack.push(s);
81
+ add(o) {
82
+ this.stack.push(o);
83
83
  }
84
84
  render() {
85
- return this.stack.reduce((s, e) => e(s), {});
85
+ return this.stack.reduce((o, e) => e(o), {});
86
86
  }
87
87
  }
88
- function X(o) {
89
- return Array.isArray(o) ? o.filter((s) => typeof s == "string" && s.length > 0) : typeof o == "string" ? o.split(/[\s,]+/).filter(Boolean) : [];
88
+ function X(s) {
89
+ return Array.isArray(s) ? s.filter((o) => typeof o == "string" && o.length > 0) : typeof s == "string" ? s.split(/[\s,]+/).filter(Boolean) : [];
90
90
  }
91
- function Be(o, s) {
91
+ function Be(s, o) {
92
92
  const e = /* @__PURE__ */ new Set();
93
- for (const d of o) {
93
+ for (const d of s) {
94
94
  const n = d.match(/^(.+?)(?::|-)(hover|active|focus)$/);
95
- n ? s[n[2]] && e.add(n[1]) : e.add(d);
95
+ n ? o[n[2]] && e.add(n[1]) : e.add(d);
96
96
  }
97
97
  return [...e];
98
98
  }
99
- function Ee(o) {
100
- return o.some((s) => /(?::|-)(hover|active|focus)$/.test(s));
99
+ function Ee(s) {
100
+ return s.some((o) => /(?::|-)(hover|active|focus)$/.test(o));
101
101
  }
102
- function Me(o, s) {
103
- const e = { hover: o.matches(":hover"), active: o.matches(":active"), focus: o.matches(":focus-within") }, d = () => o.closest("button, input, a, [data-icon-host]");
102
+ function Me(s, o) {
103
+ const e = { hover: s.matches(":hover"), active: s.matches(":active"), focus: s.matches(":focus-within") }, d = () => s.closest("button, input, a, [data-icon-host]");
104
104
  let n = null;
105
- const i = { hover: !1, active: !1, focus: !1 }, u = () => s({ hover: e.hover || i.hover, active: e.active || i.active, focus: e.focus || i.focus });
105
+ const i = { hover: !1, active: !1, focus: !1 }, p = () => o({ hover: e.hover || i.hover, active: e.active || i.active, focus: e.focus || i.focus });
106
106
  let v = () => {
107
107
  };
108
108
  const h = () => {
109
109
  e.active = i.active = !1, v(), v = () => {
110
- }, u();
111
- }, L = o.ownerDocument.defaultView, F = (f, P) => {
112
- if (f.type === "pointerdown" && f.button !== 0 || f.type === "keydown" && ![" ", "Enter"].includes(f.key) || (h(), P.active = !0, u(), !L)) return;
110
+ }, p();
111
+ }, L = s.ownerDocument.defaultView, F = (f, P) => {
112
+ if (f.type === "pointerdown" && f.button !== 0 || f.type === "keydown" && ![" ", "Enter"].includes(f.key) || (h(), P.active = !0, p(), !L)) return;
113
113
  const O = (g) => {
114
114
  (g.type !== "keyup" || [" ", "Enter"].includes(g.key)) && h();
115
115
  };
@@ -120,51 +120,51 @@ function Me(o, s) {
120
120
  }, I = (f, P) => {
121
121
  const O = {
122
122
  pointerenter: () => {
123
- P.hover = !0, u();
123
+ P.hover = !0, p();
124
124
  },
125
125
  pointerleave: () => {
126
- P.hover = !1, u();
126
+ P.hover = !1, p();
127
127
  },
128
128
  pointerdown: (g) => F(g, P),
129
129
  keydown: (g) => F(g, P),
130
130
  focusin: () => {
131
- P.focus = !0, u();
131
+ P.focus = !0, p();
132
132
  },
133
133
  focusout: (g) => {
134
134
  const A = g.relatedTarget;
135
- P.focus = A !== null && f.contains(A), u();
135
+ P.focus = A !== null && f.contains(A), p();
136
136
  }
137
137
  };
138
138
  for (const [g, A] of Object.entries(O)) f.addEventListener(g, A);
139
139
  return () => {
140
140
  for (const [g, A] of Object.entries(O)) f.removeEventListener(g, A);
141
141
  };
142
- }, j = I(o, e);
142
+ }, j = I(s, e);
143
143
  let C = () => {
144
144
  };
145
145
  const _ = () => {
146
146
  const f = d();
147
- f !== n && (n = f, C(), C = f && f !== o ? I(f, i) : () => {
147
+ f !== n && (n = f, C(), C = f && f !== s ? I(f, i) : () => {
148
148
  }, i.hover = (f == null ? void 0 : f.matches(":hover")) ?? !1, i.active = (f == null ? void 0 : f.matches(":active")) ?? !1, i.focus = (f == null ? void 0 : f.matches(":focus-within")) ?? !1);
149
149
  };
150
150
  _();
151
151
  const D = () => _();
152
- return o.addEventListener("pointerenter", _), o.addEventListener("focusin", _), o.ownerDocument.addEventListener("pointerover", D), u(), () => {
153
- j(), C(), o.removeEventListener("pointerenter", _), o.removeEventListener("focusin", _), o.ownerDocument.removeEventListener("pointerover", D), v();
152
+ return s.addEventListener("pointerenter", _), s.addEventListener("focusin", _), s.ownerDocument.addEventListener("pointerover", D), p(), () => {
153
+ j(), C(), s.removeEventListener("pointerenter", _), s.removeEventListener("focusin", _), s.ownerDocument.removeEventListener("pointerover", D), v();
154
154
  };
155
155
  }
156
156
  function $e() {
157
- const o = ue({ hover: !1, active: !1, focus: !1 });
158
- let s = null, e = () => {
157
+ const s = pe({ hover: !1, active: !1, focus: !1 });
158
+ let o = null, e = () => {
159
159
  };
160
160
  const d = (n) => {
161
161
  const i = n instanceof Element ? n : null;
162
- i !== s && (e(), s = i, Object.assign(o, { hover: !1, active: !1, focus: !1 }), e = i ? Me(i, (u) => Object.assign(o, u)) : () => {
162
+ i !== o && (e(), o = i, Object.assign(s, { hover: !1, active: !1, focus: !1 }), e = i ? Me(i, (p) => Object.assign(s, p)) : () => {
163
163
  });
164
164
  };
165
- return pe(() => d(null)), { state: o, elementRef: d };
165
+ return ue(() => d(null)), { state: s, elementRef: d };
166
166
  }
167
- function Ce(o, s) {
167
+ function Ce(s, o) {
168
168
  const e = () => n.params.value ? `icon-${n.params.pack}-${n.params.value}` : "icon-none", n = {
169
169
  modifiers: [],
170
170
  params: {},
@@ -176,16 +176,16 @@ function Ce(o, s) {
176
176
  return typeof D == "string" ? null : D;
177
177
  }
178
178
  };
179
- if (!o) return n;
180
- const i = o.includes("/") ? o : `/${o}`, [u, v = ""] = i.split("?", 2), h = u.indexOf("/"), L = u.slice(0, h), F = u.slice(h + 1), [I, ...j] = F.split(".");
181
- return j.length && (n.modifiers = j.reduce((C, _) => [...C, _.replace(":", "-")], [])), v && (n.params = Object.fromEntries(v.split("&").map((C) => C.split("=", 2)))), n.params.pack = L || s.pack || "ui0", I && (n.params.value = I), n;
179
+ if (!s) return n;
180
+ const i = s.includes("/") ? s : `/${s}`, [p, v = ""] = i.split("?", 2), h = p.indexOf("/"), L = p.slice(0, h), F = p.slice(h + 1), [I, ...j] = F.split(".");
181
+ return j.length && (n.modifiers = j.reduce((C, _) => [...C, _.replace(":", "-")], [])), v && (n.params = Object.fromEntries(v.split("&").map((C) => C.split("=", 2)))), n.params.pack = L || o.pack || "ui0", I && (n.params.value = I), n;
182
182
  }
183
- function Q(o, s) {
184
- const e = Ce(o, s);
185
- for (const [n, i] of Object.entries(s))
183
+ function Q(s, o) {
184
+ const e = Ce(s, o);
185
+ for (const [n, i] of Object.entries(o))
186
186
  i !== void 0 && n !== "value" && e.params[n] === void 0 && (e.params[n] = i);
187
187
  const d = {
188
- ...s,
188
+ ...o,
189
189
  ...e.params
190
190
  };
191
191
  return {
@@ -216,9 +216,9 @@ const Pe = /* @__PURE__ */ de({
216
216
  height: {},
217
217
  color: {}
218
218
  },
219
- setup(o) {
219
+ setup(s) {
220
220
  var U, H;
221
- const s = o, e = he(), d = Ie(), n = (U = d.useTheme) == null ? void 0 : U.call(d, s, e), i = xe(s, (H = d.useDefaults) == null ? void 0 : H.call(d)), u = oe(), [, v] = we("icon"), h = {
221
+ const o = s, e = he(), d = Ie(), n = (U = d.useTheme) == null ? void 0 : U.call(d, o, e), i = xe(o, (H = d.useDefaults) == null ? void 0 : H.call(d)), p = oe(), [, v] = we("icon"), h = {
222
222
  badge: v("badge"),
223
223
  radial: v("radial"),
224
224
  shape: v("shape"),
@@ -228,47 +228,47 @@ const Pe = /* @__PURE__ */ de({
228
228
  icon: v("icon"),
229
229
  iconMask: v("mask-icon")
230
230
  }, L = E("rect", {
231
- ...u.viewBox,
231
+ ...p.viewBox,
232
232
  fill: "#FFF"
233
233
  }), I = {
234
- ...te(s),
235
- viewBox: u.getViewBox()
234
+ ...te(o),
235
+ viewBox: p.getViewBox()
236
236
  }, j = $e(), C = me();
237
237
  function _(c) {
238
- const a = [], t = Object.keys(c), p = ["size", "color", "value", "fill", "weight"];
238
+ const a = [], t = Object.keys(c), u = ["size", "color", "value", "fill", "weight"];
239
239
  for (let l = 0; l < t.length; l++) {
240
240
  const k = c[t[l]];
241
- p.includes(t[l]) && k !== void 0 && ["string", "number", "boolean"].includes(typeof k) && a.push(`icon-${t[l]}-${k}`);
241
+ u.includes(t[l]) && k !== void 0 && ["string", "number", "boolean"].includes(typeof k) && a.push(`icon-${t[l]}-${k}`);
242
242
  }
243
243
  return a;
244
244
  }
245
245
  const D = () => {
246
- const { value: c } = s;
246
+ const { value: c } = o;
247
247
  if (!c) return null;
248
248
  const a = Q(re(c) ? c[0] : c, i), t = [e.icon];
249
249
  n ? t.push(...n.classes(a.params)) : t.push(..._(a.params));
250
- const p = {
250
+ const u = {
251
251
  class: t,
252
252
  ref: Ee([...a.modifiers, ...X(a.params.modifiers)]) ? j.elementRef : void 0
253
253
  };
254
254
  if (a.params.value === "fake")
255
- return E("i", G(C, p));
255
+ return E("i", G(C, u));
256
256
  const l = P(a);
257
- return l ? E("i", G(C, p), l) : null;
257
+ return l ? E("i", G(C, u), l) : null;
258
258
  }, f = (c, a) => E("symbol", a, c), P = (c) => {
259
259
  const a = O(c);
260
260
  if (!a) return null;
261
- const t = c.params, p = t.color && t.color.length === 2, l = t.color && t.color.length > 2, k = (p || l) && t.rendering && t.rendering === "multicolor", r = [e.canvas];
261
+ const t = c.params, u = t.color && t.color.length === 2, l = t.color && t.color.length > 2, k = (u || l) && t.rendering && t.rendering === "multicolor", r = [e.canvas];
262
262
  n && r.push(...n.classes(t, e));
263
263
  const m = [], S = [], V = {
264
- viewBox: u.getViewBox(),
264
+ viewBox: p.getViewBox(),
265
265
  class: r
266
266
  };
267
- p && r.push(e.doubleColored), l && r.push(e.tripleColored);
267
+ u && r.push(e.doubleColored), l && r.push(e.tripleColored);
268
268
  let y = {};
269
269
  const M = /* @__PURE__ */ new Map(), T = (b, x, w) => {
270
270
  const $ = x.getComponent();
271
- W($) && (Array.from($.customOptions.modifiers).length > 0 || $.customOptions.flags.some((N) => ["animation", "animate"].includes(N))) ? M.set(b, () => O(x)) : m.push(f(w, { id: b, viewBox: u.getViewBox() }));
271
+ W($) && (Array.from($.customOptions.modifiers).length > 0 || $.customOptions.flags.some((N) => ["animation", "animate"].includes(N))) ? M.set(b, () => O(x)) : m.push(f(w, { id: b, viewBox: p.getViewBox() }));
272
272
  }, B = (b, x = {}, w = {}) => {
273
273
  const $ = M.get(b);
274
274
  return g(b, x, w, $);
@@ -299,7 +299,7 @@ const Pe = /* @__PURE__ */ de({
299
299
  if (t.badge && w.push(x), y.shape) {
300
300
  const $ = {
301
301
  ...I,
302
- viewBox: u.getViewBox()
302
+ viewBox: p.getViewBox()
303
303
  };
304
304
  w.push(
305
305
  B(
@@ -317,7 +317,7 @@ const Pe = /* @__PURE__ */ de({
317
317
  $ && m.push(
318
318
  f($, {
319
319
  id: h.shape,
320
- viewBox: u.getViewBox()
320
+ viewBox: p.getViewBox()
321
321
  })
322
322
  ), m.push(B(h.shape, {}, k ? { mask: h.iconMask } : { mask: h.iconMask }));
323
323
  }
@@ -327,7 +327,7 @@ const Pe = /* @__PURE__ */ de({
327
327
  }, O = (c) => {
328
328
  const a = c.getComponent();
329
329
  if (!W(a)) return null;
330
- const t = new Se(), p = a.customOptions, l = Be(
330
+ const t = new Se(), u = a.customOptions, l = Be(
331
331
  [...c.modifiers, ...X(c.params.modifiers)],
332
332
  j.state
333
333
  ), k = {
@@ -339,19 +339,19 @@ const Pe = /* @__PURE__ */ de({
339
339
  class: r,
340
340
  style: "--0-icon-weight: 800;"
341
341
  };
342
- p.flags.includes("no-fill") || r.push(e.fillable), !p.flags.includes("no-stroke") && !p.flags.includes("no-process-stroke") && r.push(e.weighty), p.flags.includes("no-cap") || r.push(e.cap), p.flags.includes("no-join") || r.push(e.join), c.params.shape && r.push(e.shaped);
342
+ u.flags.includes("no-fill") || r.push(e.fillable), !u.flags.includes("no-stroke") && !u.flags.includes("no-process-stroke") && r.push(e.weighty), u.flags.includes("no-cap") || r.push(e.cap), u.flags.includes("no-join") || r.push(e.join), c.params.shape && r.push(e.shaped);
343
343
  const S = c.params.filled;
344
344
  (S !== void 0 ? S === !0 || S === "true" : l.some((B) => B === "fill" || B === "filled")) && r.push(e.filled), c.params.rendering && r.push(e[ke(c.params.rendering)]), t.add(() => E(a, k)), t.add(R(m)), c.params.animation && t.add(R({})), (c.params.flipped || l.includes("flip")) && t.add(R({ class: e.flip }));
345
- const y = Number(c.params.rotate ?? 0), M = u.viewBox.x + u.viewBox.width / 2, T = u.viewBox.y + u.viewBox.height / 2;
345
+ const y = Number(c.params.rotate ?? 0), M = p.viewBox.x + p.viewBox.width / 2, T = p.viewBox.y + p.viewBox.height / 2;
346
346
  return t.add(
347
347
  R({
348
348
  "data-icon-rotate": "",
349
349
  transform: `rotate(${Number.isFinite(y) ? y : 0} ${M} ${T})`
350
350
  })
351
351
  ), t.render();
352
- }, g = (c, a = {}, t = {}, p) => {
352
+ }, g = (c, a = {}, t = {}, u) => {
353
353
  let l = {
354
- "--0-icon-weight": +(a.weight ?? 400) / 100 * u.getStrokeUnit(),
354
+ "--0-icon-weight": +(a.weight ?? 400) / 100 * p.getStrokeUnit(),
355
355
  "--0-icon-progress": a.progress ?? 100
356
356
  };
357
357
  const k = Array.isArray(t.class) ? t.class : [t.class];
@@ -362,21 +362,21 @@ const Pe = /* @__PURE__ */ de({
362
362
  ...t,
363
363
  class: k
364
364
  };
365
- return t.mask && (r.mask = `url(#${t.mask})`), p ? (delete r.href, r.viewBox ?? (r.viewBox = u.getViewBox()), r["data-icon-inline"] = "", E("svg", r, [p()])) : E("use", r);
365
+ return t.mask && (r.mask = `url(#${t.mask})`), u ? (delete r.href, r.viewBox ?? (r.viewBox = p.getViewBox()), r["data-icon-inline"] = "", E("svg", r, [u()])) : E("use", r);
366
366
  }, A = (c, a = []) => E("mask", { id: c }, [L, ...a]), ee = (c) => {
367
367
  const a = c.params;
368
368
  if (!a.shape) return;
369
- const t = [], p = se(c), l = a.shape;
369
+ const t = [], u = se(c), l = a.shape;
370
370
  return l === "rect" || l === "circle" ? t.push(
371
371
  E("rect", {
372
- ...p,
372
+ ...u,
373
373
  rx: l === "circle" ? "50%" : "10%"
374
374
  // mask: 'url(#badgenumber)'
375
375
  })
376
376
  ) : _e(l) && t.push(
377
377
  E("path", {
378
378
  // 'stroke-width': 80,
379
- ...p,
379
+ ...u,
380
380
  x: void 0,
381
381
  y: void 0,
382
382
  "stroke-linejoin": "round",
@@ -387,12 +387,12 @@ const Pe = /* @__PURE__ */ de({
387
387
  ), t;
388
388
  };
389
389
  function se(c) {
390
- const l = u.viewBox.height - u.viewBox.height / 16, k = l, r = l, m = (
390
+ const l = p.viewBox.height - p.viewBox.height / 16, k = l, r = l, m = (
391
391
  /* isChild && isMask ? measure.x : */
392
- u.viewBox.width / 32
392
+ p.viewBox.width / 32
393
393
  ), S = (
394
394
  /*isChild && isMask ? measure.y : */
395
- u.viewBox.height / 32
395
+ p.viewBox.height / 32
396
396
  ), V = [e.shape];
397
397
  return n && V.push(...n.classes(c.params, e)), {
398
398
  class: V,
@@ -425,10 +425,10 @@ const Pe = /* @__PURE__ */ de({
425
425
  };
426
426
  }
427
427
  function te(c) {
428
- const { options: a } = c, t = 960, p = t / 4 * 3, l = (t - p) / 2, k = {
429
- small: p / 4,
430
- normal: p / 3,
431
- large: p / 2
428
+ const { options: a } = c, t = 960, u = t / 4 * 3, l = (t - u) / 2, k = {
429
+ small: u / 4,
430
+ normal: u / 3,
431
+ large: u / 2
432
432
  }, r = a == null ? void 0 : a.badge, m = r !== void 0 && r.scale || "normal", S = r == null ? void 0 : r.cell, V = r == null ? void 0 : r.x, y = r == null ? void 0 : r.y;
433
433
  if (m === "full" || m === 1)
434
434
  return {
@@ -438,12 +438,12 @@ const Pe = /* @__PURE__ */ de({
438
438
  height: `${t}px`
439
439
  };
440
440
  let M;
441
- if (typeof m == "number" ? M = m > 0.75 ? m * t : Math.min(p, Math.round(p * m)) : M = k[m], S) {
441
+ if (typeof m == "number" ? M = m > 0.75 ? m * t : Math.min(u, Math.round(u * m)) : M = k[m], S) {
442
442
  const x = typeof m == "string" ? {
443
443
  small: 4,
444
444
  normal: 3,
445
445
  large: 2
446
- }[m] : 3, w = p / x, [$, K] = S.split(/\s|-|,/).map(Number), N = x - 1;
446
+ }[m] : 3, w = u / x, [$, K] = S.split(/\s|-|,/).map(Number), N = x - 1;
447
447
  return {
448
448
  x: `${l + Math.min($, N) * w}`,
449
449
  y: `${l + Math.min(K, N) * w}`,
@@ -452,7 +452,7 @@ const Pe = /* @__PURE__ */ de({
452
452
  };
453
453
  }
454
454
  const T = (b) => {
455
- const x = b === "x" ? V : y, w = p - M;
455
+ const x = b === "x" ? V : y, w = u - M;
456
456
  switch (x) {
457
457
  case "center":
458
458
  return l + w / 2;
@@ -493,17 +493,17 @@ const Pe = /* @__PURE__ */ de({
493
493
  join: Qe,
494
494
  cap: Ye,
495
495
  flip: Je
496
- }, es = (o, s) => {
497
- const e = o.__vccOpts || o;
498
- for (const [d, n] of s)
496
+ }, es = (s, o) => {
497
+ const e = s.__vccOpts || s;
498
+ for (const [d, n] of o)
499
499
  e[d] = n;
500
500
  return e;
501
501
  }, ss = {
502
502
  $style: qe
503
503
  }, os = /* @__PURE__ */ es(Pe, [["__cssModules", ss]]);
504
- function ts(o) {
505
- const s = ae(o.replace("Icon", "")), e = s.split("-")[0];
506
- return e ? e + "/" + s.replace(e + "-", "") : s.replace(e + "-", "");
504
+ function ts(s) {
505
+ const o = ae(s.replace("Icon", "")), e = o.split("-")[0];
506
+ return e ? e + "/" + o.replace(e + "-", "") : o.replace(e + "-", "");
507
507
  }
508
508
  class ns {
509
509
  constructor() {
@@ -516,40 +516,40 @@ class ns {
516
516
  * add icon pack plugin
517
517
  * @param plugin
518
518
  */
519
- addPack(s) {
520
- Object.keys(s.components).forEach((e) => this.add(e, s.components[e])), this.packs[s.name] = s.config;
519
+ addPack(o) {
520
+ Object.keys(o.components).forEach((e) => this.add(e, o.components[e])), this.packs[o.name] = o.config;
521
521
  }
522
522
  /**
523
523
  * returns installed icons list
524
524
  * @param pack
525
525
  */
526
- list(s) {
527
- return s ? this.icons.filter((e) => e.startsWith(`${s}/`)) : this.icons;
526
+ list(o) {
527
+ return o ? this.icons.filter((e) => e.startsWith(`${o}/`)) : this.icons;
528
528
  }
529
529
  /**
530
530
  * add icon component
531
531
  * @param name
532
532
  * @param component
533
533
  */
534
- add(s, e) {
534
+ add(o, e) {
535
535
  var n;
536
- const d = ts(s);
537
- this.icons.push(d), this.vueApp ? (n = this.vueApp) == null || n.component(s, e) : this.deferred.push([s, e]);
536
+ const d = ts(o);
537
+ this.icons.push(d), this.vueApp ? (n = this.vueApp) == null || n.component(o, e) : this.deferred.push([o, e]);
538
538
  }
539
- setVue(s) {
540
- if (!s) throw new Error("app is null");
539
+ setVue(o) {
540
+ if (!o) throw new Error("app is null");
541
541
  if (!this.vueApp)
542
- this.vueApp = s, this.deferred.length && this.deferred.forEach((e) => s.component(...e));
542
+ this.vueApp = o, this.deferred.length && this.deferred.forEach((e) => o.component(...e));
543
543
  else
544
544
  throw new Error("vue already installed");
545
545
  }
546
546
  }
547
- function fs(o = {}, s) {
547
+ function fs(s = {}, o) {
548
548
  const e = new ns();
549
549
  return {
550
550
  install: (i) => {
551
551
  if (!i) throw new Error("@ui0/icon can be run with vue 3 only");
552
- i.provide(Y, e), o.framework && i.provide(J, o.framework), i.component("Icon", os), e.setVue(i), i.config.globalProperties.$ui0Icon = e;
552
+ i.provide(Y, e), s.framework && i.provide(J, s.framework), i.component("Icon", os), e.setVue(i);
553
553
  },
554
554
  use: (i) => {
555
555
  e.addPack(i);
@@ -566,7 +566,7 @@ export {
566
566
  os as Icon,
567
567
  J as IconFrameworkKey,
568
568
  fs as createIcon,
569
- ps as getIcon,
569
+ us as getIcon,
570
570
  xe as resolveIconDefaults,
571
571
  Ie as useIconFramework
572
572
  };
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,KAAK,EAAO,MAAM,EAAE,MAAM,KAAK,CAAA;AAEtC,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAIlE,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEnD,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,SAAS,CAAC,EAAE,aAAa,CAAA;CAC1B;AAED,KAAK,aAAa,GAAG,MAAM,GACzB,aAAa,GAAG;IACd,GAAG,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA;CAClC,CAAA;AAEH,OAAO,QAAQ,KAAK,CAAC;IACnB,UAAU,yBAAyB;QACjC,QAAQ,CAAC,EAAE,QAAQ,CAAA;KACpB;CACF;AAED,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,aAAa,CAoB9F"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,KAAK,EAAO,MAAM,EAAE,MAAM,KAAK,CAAA;AAEtC,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAIlE,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEnD,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,SAAS,CAAC,EAAE,aAAa,CAAA;CAC1B;AAED,KAAK,aAAa,GAAG,MAAM,GACzB,aAAa,GAAG;IACd,GAAG,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA;CAClC,CAAA;AAEH,OAAO,QAAQ,KAAK,CAAC;IACnB,UAAU,yBAAyB;QACjC,QAAQ,CAAC,EAAE,QAAQ,CAAA;KACpB;CACF;AAED,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,aAAa,CAmB9F"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui0/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,aAAa,CAatD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui0/index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,aAAa,CAetD"}
package/dist/ui0/index.js CHANGED
@@ -1,19 +1,23 @@
1
- import { getComponentDefaults as r } from "@ui0/core";
2
- import { useTheme as n, useThemeContext as i } from "@ui0/theme";
3
- import { getCurrentInstance as u } from "vue";
4
- function f() {
1
+ import { getUi0CoreInstance as r } from "@ui0/composable";
2
+ import { getComponentDefaults as n } from "@ui0/core";
3
+ import { useTheme as i, useThemeContext as m } from "@ui0/theme";
4
+ import { hasInjectionContext as u } from "vue";
5
+ function p() {
5
6
  return {
6
7
  useTheme: (e, t) => {
7
- if (!n()) return;
8
- const [, o] = i(e, t);
8
+ if (!i()) return;
9
+ const [, o] = m(e, t);
9
10
  return o ?? void 0;
10
11
  },
11
12
  useDefaults: () => {
12
- const e = u(), t = e == null ? void 0 : e.appContext.config.globalProperties.$ui0;
13
- return r("icon", t) ?? {};
13
+ if (u()) {
14
+ const e = r();
15
+ return n("icon", e) ?? {};
16
+ }
17
+ return {};
14
18
  }
15
19
  };
16
20
  }
17
21
  export {
18
- f as createUi0IconFramework
22
+ p as createUi0IconFramework
19
23
  };