@schwarzdavid/ui-kit 0.0.1-alpha.1 → 0.0.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui-kit.d.ts CHANGED
@@ -8,6 +8,7 @@ import { DefineComponent } from 'vue';
8
8
  import { MaybeRefOrGetter } from 'vue';
9
9
  import { MethodOptions } from 'vue';
10
10
  import { PublicProps } from 'vue';
11
+ import { Ref } from 'vue';
11
12
 
12
13
  declare interface ConfirmDialogBaseProps {
13
14
  title: string;
@@ -87,6 +88,17 @@ export declare interface InfoDialogValueCta<T> extends InfoDialogBaseCta {
87
88
  value: T;
88
89
  }
89
90
 
91
+ export declare type LoadingAction = (...args: any) => any | Promise<any>;
92
+
93
+ export declare interface LoadingComposable<A extends LoadingAction> {
94
+ loading: Readonly<Ref<boolean>>;
95
+ action(...args: Parameters<A>): Promise<Awaited<ReturnType<A>>>;
96
+ }
97
+
98
+ export declare interface LoadingOptions {
99
+ overlay: MaybeRefOrGetter<boolean>;
100
+ }
101
+
90
102
  export declare type PromptDialogComponent<T> = ComponentPublicInstance<PromptDialogComponentProps<T>, any, any, ComputedOptions, MethodOptions, ComponentOptionsMixin, ComponentOptionsMixin, PromptDialogComponentEmits<T>>;
91
103
 
92
104
  export declare type PromptDialogComponentEmits<T> = (name: 'update:modelValue', value: T | null) => unknown;
@@ -118,8 +130,21 @@ export declare enum PromptDialogSize {
118
130
  LARGE = "lg"
119
131
  }
120
132
 
133
+ export declare interface ToastComposable {
134
+ info(message: string): Promise<void>;
135
+ warn(message: string): Promise<void>;
136
+ error(message: string): Promise<void>;
137
+ success(message: string): Promise<void>;
138
+ }
139
+
121
140
  export declare const UiKitOutlet: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
122
141
 
123
142
  export declare function useDialog(): DialogComposable;
124
143
 
144
+ export declare function useLoading<A extends LoadingAction>(actionCallback: A, { overlay }?: Partial<LoadingOptions>): LoadingComposable<A>;
145
+
146
+ export declare function useLoadingOverlay(): Ref<boolean>;
147
+
148
+ export declare function useToast(): ToastComposable;
149
+
125
150
  export { }
package/dist/ui-kit.js CHANGED
@@ -1,62 +1,62 @@
1
- import { ref as V, readonly as ne, markRaw as ae, defineComponent as w, openBlock as m, createElementBlock as j, Fragment as L, renderList as K, unref as r, createBlock as g, resolveDynamicComponent as N, mergeProps as O, onMounted as me, withCtx as i, createTextVNode as W, toDisplayString as H, getCurrentInstance as pe, inject as fe, computed as f, TransitionGroup as ve, normalizeClass as oe, createVNode as l, createElementVNode as M, createCommentVNode as k, normalizeProps as le, toValue as Z } from "vue";
2
- import { VAlert as ge, VDialog as X, VCard as J, VCardTitle as re, VBtn as x, VCardText as ue, VCardActions as Y, VToolbar as _e, VToolbarTitle as Ce, VSpacer as ee, VDivider as ye } from "vuetify/components";
3
- import { merge as S } from "lodash";
4
- import { useI18n as Te } from "vue-i18n";
1
+ import { ref as b, readonly as J, markRaw as le, defineComponent as A, openBlock as m, createElementBlock as L, Fragment as R, renderList as Y, unref as u, createBlock as g, resolveDynamicComponent as B, mergeProps as G, onMounted as fe, withCtx as c, createTextVNode as H, toDisplayString as K, getCurrentInstance as ve, inject as ge, computed as f, TransitionGroup as _e, normalizeClass as re, isRef as ye, createVNode as s, createElementVNode as Q, createCommentVNode as k, normalizeProps as ue, toValue as X } from "vue";
2
+ import { VAlert as Ce, VOverlay as Te, VProgressCircular as be, VDialog as Z, VCard as ee, VCardTitle as se, VBtn as x, VCardText as ie, VCardActions as te, VToolbar as he, VToolbarTitle as we, VSpacer as ae, VDivider as xe } from "vuetify/components";
3
+ import { merge as $ } from "lodash";
4
+ import { useI18n as Ae } from "vue-i18n";
5
5
  const v = [];
6
6
  for (let e = 0; e < 256; ++e)
7
7
  v.push((e + 256).toString(16).slice(1));
8
- function be(e, n = 0) {
8
+ function Ve(e, n = 0) {
9
9
  return (v[e[n + 0]] + v[e[n + 1]] + v[e[n + 2]] + v[e[n + 3]] + "-" + v[e[n + 4]] + v[e[n + 5]] + "-" + v[e[n + 6]] + v[e[n + 7]] + "-" + v[e[n + 8]] + v[e[n + 9]] + "-" + v[e[n + 10]] + v[e[n + 11]] + v[e[n + 12]] + v[e[n + 13]] + v[e[n + 14]] + v[e[n + 15]]).toLowerCase();
10
10
  }
11
- let z;
12
- const he = new Uint8Array(16);
13
- function xe() {
14
- if (!z) {
11
+ let q;
12
+ const De = new Uint8Array(16);
13
+ function ke() {
14
+ if (!q) {
15
15
  if (typeof crypto > "u" || !crypto.getRandomValues)
16
16
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
17
- z = crypto.getRandomValues.bind(crypto);
17
+ q = crypto.getRandomValues.bind(crypto);
18
18
  }
19
- return z(he);
19
+ return q(De);
20
20
  }
21
- const Ae = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), te = { randomUUID: Ae };
22
- function se(e, n, t) {
23
- if (te.randomUUID && !n && !e)
24
- return te.randomUUID();
21
+ const Ee = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), oe = { randomUUID: Ee };
22
+ function ce(e, n, t) {
23
+ if (oe.randomUUID && !n && !e)
24
+ return oe.randomUUID();
25
25
  e = e || {};
26
- const a = e.random || (e.rng || xe)();
27
- return a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, be(a);
26
+ const a = e.random || (e.rng || ke)();
27
+ return a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, Ve(a);
28
28
  }
29
- const R = V([]);
30
- function ce() {
29
+ const U = b([]);
30
+ function de() {
31
31
  function e() {
32
32
  let a;
33
33
  for (; ; )
34
- if (a = se(), !R.value.some((o) => o.id === a))
34
+ if (a = ce(), !U.value.some((o) => o.id === a))
35
35
  return a;
36
36
  }
37
37
  function n(a) {
38
- const o = e(), c = ae({ ...a, id: o, resolve: (d) => {
38
+ const o = e(), i = le({ ...a, id: o, resolve: (d) => {
39
39
  t(o), a.resolve(d);
40
40
  }, reject: (d) => {
41
41
  t(o), a.reject(d);
42
42
  } });
43
- return R.value.push(c), c;
43
+ return U.value.push(i), i;
44
44
  }
45
45
  function t(a) {
46
- const o = typeof a == "string" ? a : a.id, u = R.value.findIndex((s) => s.id === o);
47
- u >= 0 && R.value.splice(u, 1);
46
+ const o = typeof a == "string" ? a : a.id, l = U.value.findIndex((r) => r.id === o);
47
+ l >= 0 && U.value.splice(l, 1);
48
48
  }
49
49
  return {
50
- queue: ne(R),
50
+ queue: J(U),
51
51
  addToQueue: n,
52
52
  removeFromQueue: t
53
53
  };
54
54
  }
55
- const Ve = /* @__PURE__ */ w({
55
+ const Ie = /* @__PURE__ */ A({
56
56
  __name: "DialogOutlet",
57
57
  setup(e) {
58
- const { queue: n } = ce();
59
- return (t, a) => (m(!0), j(L, null, K(r(n), (o) => (m(), g(N(o.component), O({
58
+ const { queue: n } = de();
59
+ return (t, a) => (m(!0), L(R, null, Y(u(n), (o) => (m(), g(B(o.component), G({
60
60
  key: o.id,
61
61
  ref_for: !0
62
62
  }, o.props, {
@@ -64,90 +64,90 @@ const Ve = /* @__PURE__ */ w({
64
64
  onReject: o.reject
65
65
  }), null, 16, ["onResolve", "onReject"]))), 128));
66
66
  }
67
- }), P = V([]);
68
- function ie() {
67
+ }), P = b([]);
68
+ function ne() {
69
69
  function e() {
70
70
  let a;
71
71
  for (; ; )
72
- if (a = se(), !P.value.some((o) => o.id === a))
72
+ if (a = ce(), !P.value.some((o) => o.id === a))
73
73
  return a;
74
74
  }
75
75
  function n(a) {
76
- const o = e(), s = ae({ ...a, id: o, resolve: () => {
76
+ const o = e(), r = le({ ...a, id: o, resolve: () => {
77
77
  t(o), a.resolve();
78
78
  } });
79
- return P.value.unshift(s), s;
79
+ return P.value.unshift(r), r;
80
80
  }
81
81
  function t(a) {
82
- const o = typeof a == "string" ? a : a.id, u = P.value.findIndex((s) => s.id === o);
83
- u >= 0 && P.value.splice(u, 1);
82
+ const o = typeof a == "string" ? a : a.id, l = P.value.findIndex((r) => r.id === o);
83
+ l >= 0 && P.value.splice(l, 1);
84
84
  }
85
85
  return {
86
- queue: ne(P),
86
+ queue: J(P),
87
87
  addToQueue: n,
88
88
  removeFromQueue: t
89
89
  };
90
90
  }
91
- const we = /* @__PURE__ */ w({
91
+ const Le = /* @__PURE__ */ A({
92
92
  __name: "ToastEntry",
93
93
  props: {
94
94
  entry: {}
95
95
  },
96
96
  setup(e) {
97
- const n = e, t = ie(), a = V(-1);
97
+ const n = e, t = ne(), a = b(-1);
98
98
  function o() {
99
99
  window.clearTimeout(a.value), t.removeFromQueue(n.entry.id);
100
100
  }
101
- return me(() => {
101
+ return fe(() => {
102
102
  a.value = window.setTimeout(() => {
103
103
  o();
104
104
  }, n.entry.timeout);
105
- }), (u, s) => (m(), g(r(ge), {
105
+ }), (l, r) => (m(), g(u(Ce), {
106
106
  theme: "dark",
107
107
  class: "toast-entry",
108
108
  closable: "",
109
109
  "onClick:close": o
110
110
  }, {
111
- default: i(() => [
112
- W(H(u.entry.message), 1)
111
+ default: c(() => [
112
+ H(K(l.entry.message), 1)
113
113
  ]),
114
114
  _: 1
115
115
  }));
116
116
  }
117
- }), F = (e, n) => {
117
+ }), N = (e, n) => {
118
118
  const t = e.__vccOpts || e;
119
119
  for (const [a, o] of n)
120
120
  t[a] = o;
121
121
  return t;
122
- }, De = /* @__PURE__ */ F(we, [["__scopeId", "data-v-419b7d95"]]);
123
- function $() {
122
+ }, Re = /* @__PURE__ */ N(Le, [["__scopeId", "data-v-419b7d95"]]);
123
+ function S() {
124
124
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
125
- if ($.cache.has(e)) return $.cache.get(e);
125
+ if (S.cache.has(e)) return S.cache.get(e);
126
126
  const n = e.replace(/[^a-z]/gi, "-").replace(/\B([A-Z])/g, "-$1").toLowerCase();
127
- return $.cache.set(e, n), n;
127
+ return S.cache.set(e, n), n;
128
128
  }
129
- $.cache = /* @__PURE__ */ new Map();
130
- function ke(e, n) {
131
- const t = pe();
129
+ S.cache = /* @__PURE__ */ new Map();
130
+ function je(e, n) {
131
+ const t = ve();
132
132
  if (!t)
133
133
  throw new Error(`[Vuetify] ${e} must be called from inside a setup function`);
134
134
  return t;
135
135
  }
136
- function Ee() {
136
+ function Ue() {
137
137
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "composables";
138
- const n = ke(e).type;
139
- return $((n == null ? void 0 : n.aliasName) || (n == null ? void 0 : n.name));
138
+ const n = je(e).type;
139
+ return S((n == null ? void 0 : n.aliasName) || (n == null ? void 0 : n.name));
140
140
  }
141
- const Ie = Symbol.for("vuetify:display");
142
- function de() {
143
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Ee();
144
- const t = fe(Ie);
141
+ const Pe = Symbol.for("vuetify:display");
142
+ function me() {
143
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Ue();
144
+ const t = ge(Pe);
145
145
  if (!t) throw new Error("Could not find Vuetify display injection");
146
146
  const a = f(() => {
147
147
  if (e.mobile != null) return e.mobile;
148
148
  if (!e.mobileBreakpoint) return t.mobile.value;
149
- const u = typeof e.mobileBreakpoint == "number" ? e.mobileBreakpoint : t.thresholds.value[e.mobileBreakpoint];
150
- return t.width.value < u;
149
+ const l = typeof e.mobileBreakpoint == "number" ? e.mobileBreakpoint : t.thresholds.value[e.mobileBreakpoint];
150
+ return t.width.value < l;
151
151
  }), o = f(() => n ? {
152
152
  [`${n}--mobile`]: a.value
153
153
  } : {});
@@ -157,52 +157,77 @@ function de() {
157
157
  mobile: a
158
158
  };
159
159
  }
160
- const je = /* @__PURE__ */ w({
160
+ const Oe = /* @__PURE__ */ A({
161
161
  __name: "ToastOutlet",
162
162
  setup(e) {
163
- const { queue: n } = ie(), { mobile: t } = de(), a = f(() => t.value ? "" : "toast-outlet--desktop");
164
- function o(u) {
165
- const { width: s } = u.getBoundingClientRect();
166
- u instanceof HTMLElement && (u.style.width = `${s.toFixed()}px`);
163
+ const { queue: n } = ne(), { mobile: t } = me(), a = f(() => t.value ? "" : "toast-outlet--desktop");
164
+ function o(l) {
165
+ const { width: r } = l.getBoundingClientRect();
166
+ l instanceof HTMLElement && (l.style.width = `${r.toFixed()}px`);
167
167
  }
168
- return (u, s) => (m(), g(ve, {
168
+ return (l, r) => (m(), g(_e, {
169
169
  name: "fade",
170
170
  tag: "div",
171
- class: oe(["toast-outlet", a.value]),
171
+ class: re(["toast-outlet", a.value]),
172
172
  onBeforeLeave: o
173
173
  }, {
174
- default: i(() => [
175
- (m(!0), j(L, null, K(r(n), (c) => (m(), g(De, {
176
- key: c.id,
177
- entry: c
174
+ default: c(() => [
175
+ (m(!0), L(R, null, Y(u(n), (i) => (m(), g(Re, {
176
+ key: i.id,
177
+ entry: i
178
178
  }, null, 8, ["entry"]))), 128))
179
179
  ]),
180
180
  _: 1
181
181
  }, 8, ["class"]));
182
182
  }
183
- }), Le = /* @__PURE__ */ F(je, [["__scopeId", "data-v-93b5ec8a"]]), He = /* @__PURE__ */ w({
183
+ }), Se = /* @__PURE__ */ N(Oe, [["__scopeId", "data-v-93b5ec8a"]]), Qe = b(!1);
184
+ function pe() {
185
+ return Qe;
186
+ }
187
+ const $e = /* @__PURE__ */ A({
188
+ __name: "LoadingOverlay",
189
+ setup(e) {
190
+ const n = pe();
191
+ return (t, a) => (m(), g(u(Te), {
192
+ modelValue: u(n),
193
+ "onUpdate:modelValue": a[0] || (a[0] = (o) => ye(n) ? n.value = o : null),
194
+ persistent: "",
195
+ class: "d-flex align-center justify-center"
196
+ }, {
197
+ default: c(() => [
198
+ s(u(be), {
199
+ indeterminate: "",
200
+ color: "primary",
201
+ size: "100"
202
+ })
203
+ ]),
204
+ _: 1
205
+ }, 8, ["modelValue"]));
206
+ }
207
+ }), tt = /* @__PURE__ */ A({
184
208
  __name: "UiKitOutlet",
185
209
  setup(e) {
186
- return (n, t) => (m(), j(L, null, [
187
- l(Ve),
188
- l(Le)
210
+ return (n, t) => (m(), L(R, null, [
211
+ s(Ie),
212
+ s(Se),
213
+ s($e)
189
214
  ], 64));
190
215
  }
191
- }), y = /* @__PURE__ */ w({
216
+ }), C = /* @__PURE__ */ A({
192
217
  __name: "MaybeTranslation",
193
218
  props: {
194
219
  content: {},
195
220
  translate: { type: Boolean, default: !0 }
196
221
  },
197
222
  setup(e) {
198
- const { t: n } = Te({ useScope: "global" });
199
- return (t, a) => t.translate ? (m(), j(L, { key: 0 }, [
200
- W(H(r(n)(t.content)), 1)
201
- ], 64)) : (m(), j(L, { key: 1 }, [
202
- W(H(t.content), 1)
223
+ const { t: n } = Ae({ useScope: "global" });
224
+ return (t, a) => t.translate ? (m(), L(R, { key: 0 }, [
225
+ H(K(u(n)(t.content)), 1)
226
+ ], 64)) : (m(), L(R, { key: 1 }, [
227
+ H(K(t.content), 1)
203
228
  ], 64));
204
229
  }
205
- }), Ue = { class: "d-flex justify-space-between pr-2 py-2" }, Re = 650, Pe = /* @__PURE__ */ w({
230
+ }), Ne = { class: "d-flex justify-space-between pr-2 py-2" }, Fe = 650, Me = /* @__PURE__ */ A({
206
231
  __name: "InfoDialog",
207
232
  props: {
208
233
  data: {}
@@ -214,87 +239,87 @@ const je = /* @__PURE__ */ w({
214
239
  translateText: !0,
215
240
  value: null
216
241
  };
217
- let u = null;
218
- const s = V(!0), c = f(() => Object.hasOwn(t.data, "content") ? {
242
+ let l = null;
243
+ const r = b(!0), i = f(() => Object.hasOwn(t.data, "content") ? {
219
244
  content: t.data.content,
220
245
  translateContent: t.data.translateContent
221
246
  } : null), d = f(() => Object.hasOwn(t.data, "component") ? {
222
247
  component: t.data.component,
223
248
  props: t.data.props
224
- } : null), _ = f(() => t.data.defaultCta === !1 ? null : S({}, o, t.data.defaultCta));
225
- function A(p) {
226
- E(p) ? p.action() : b(p.value);
249
+ } : null), _ = f(() => t.data.defaultCta === !1 ? null : $({}, o, t.data.defaultCta));
250
+ function V(p) {
251
+ E(p) ? p.action() : h(p.value);
227
252
  }
228
253
  function E(p) {
229
254
  return Object.hasOwn(p, "action");
230
255
  }
231
- function b(p = null) {
232
- u = p, s.value = !1;
256
+ function h(p = null) {
257
+ l = p, r.value = !1;
233
258
  }
234
259
  function I() {
235
- a("resolve", u);
260
+ a("resolve", l);
236
261
  }
237
- return (p, h) => (m(), g(r(X), {
238
- modelValue: s.value,
239
- "onUpdate:modelValue": h[1] || (h[1] = (C) => s.value = C),
240
- "max-width": p.data.width ?? Re,
262
+ return (p, w) => (m(), g(u(Z), {
263
+ modelValue: r.value,
264
+ "onUpdate:modelValue": w[1] || (w[1] = (y) => r.value = y),
265
+ "max-width": p.data.width ?? Fe,
241
266
  onAfterLeave: I
242
267
  }, {
243
- default: i(() => [
244
- l(r(J), { class: "info-dialog-card" }, {
245
- default: i(() => [
246
- M("div", Ue, [
247
- l(r(re), null, {
248
- default: i(() => [
249
- l(y, {
268
+ default: c(() => [
269
+ s(u(ee), { class: "info-dialog-card" }, {
270
+ default: c(() => [
271
+ Q("div", Ne, [
272
+ s(u(se), null, {
273
+ default: c(() => [
274
+ s(C, {
250
275
  translate: p.data.translateTitle,
251
276
  content: p.data.title
252
277
  }, null, 8, ["translate", "content"])
253
278
  ]),
254
279
  _: 1
255
280
  }),
256
- l(r(x), {
281
+ s(u(x), {
257
282
  icon: "$close",
258
283
  variant: "text",
259
- onClick: h[0] || (h[0] = (C) => b(null))
284
+ onClick: w[0] || (w[0] = (y) => h(null))
260
285
  })
261
286
  ]),
262
- c.value ? (m(), g(r(ue), { key: 0 }, {
263
- default: i(() => [
264
- M("p", null, [
265
- l(y, {
266
- translate: c.value.translateContent,
267
- content: c.value.content
287
+ i.value ? (m(), g(u(ie), { key: 0 }, {
288
+ default: c(() => [
289
+ Q("p", null, [
290
+ s(C, {
291
+ translate: i.value.translateContent,
292
+ content: i.value.content
268
293
  }, null, 8, ["translate", "content"])
269
294
  ])
270
295
  ]),
271
296
  _: 1
272
297
  })) : k("", !0),
273
- d.value ? (m(), g(N(d.value.component), le(O({ key: 1 }, d.value.props)), null, 16)) : k("", !0),
274
- l(r(Y), { class: "justify-end" }, {
275
- default: i(() => [
276
- (m(!0), j(L, null, K(p.data.additionalCta ?? [], (C, T) => (m(), g(r(x), {
298
+ d.value ? (m(), g(B(d.value.component), ue(G({ key: 1 }, d.value.props)), null, 16)) : k("", !0),
299
+ s(u(te), { class: "justify-end" }, {
300
+ default: c(() => [
301
+ (m(!0), L(R, null, Y(p.data.additionalCta ?? [], (y, T) => (m(), g(u(x), {
277
302
  key: T,
278
303
  color: "primary",
279
304
  variant: "text",
280
- onClick: () => A(C)
305
+ onClick: () => V(y)
281
306
  }, {
282
- default: i(() => [
283
- l(y, {
284
- translate: C.translateText,
285
- content: C.text
307
+ default: c(() => [
308
+ s(C, {
309
+ translate: y.translateText,
310
+ content: y.text
286
311
  }, null, 8, ["translate", "content"])
287
312
  ]),
288
313
  _: 2
289
314
  }, 1032, ["onClick"]))), 128)),
290
- _.value ? (m(), g(r(x), {
315
+ _.value ? (m(), g(u(x), {
291
316
  key: 0,
292
317
  color: "primary",
293
318
  variant: "elevated",
294
- onClick: b
319
+ onClick: h
295
320
  }, {
296
- default: i(() => [
297
- l(y, {
321
+ default: c(() => [
322
+ s(C, {
298
323
  translate: _.value.translateText,
299
324
  content: _.value.text
300
325
  }, null, 8, ["translate", "content"])
@@ -311,9 +336,9 @@ const je = /* @__PURE__ */ w({
311
336
  _: 1
312
337
  }, 8, ["modelValue", "max-width"]));
313
338
  }
314
- }), $e = /* @__PURE__ */ F(Pe, [["__scopeId", "data-v-ab153f63"]]);
339
+ }), Be = /* @__PURE__ */ N(Me, [["__scopeId", "data-v-ab153f63"]]);
315
340
  var D = /* @__PURE__ */ ((e) => (e.SMALL = "sm", e.LARGE = "lg", e))(D || {});
316
- const Me = /* @__PURE__ */ w({
341
+ const Ge = /* @__PURE__ */ A({
317
342
  __name: "PromptDialog",
318
343
  props: {
319
344
  data: {}
@@ -323,92 +348,92 @@ const Me = /* @__PURE__ */ w({
323
348
  const t = e, a = n, o = {
324
349
  [D.SMALL]: 650,
325
350
  [D.LARGE]: 1200
326
- }, u = {
351
+ }, l = {
327
352
  text: "APP.CANCEL",
328
353
  translateText: !0
329
- }, s = {
354
+ }, r = {
330
355
  text: "APP.SAVE",
331
356
  translateText: !0
332
- }, c = V(!0), d = V(Z(t.data.initialValue) ?? null), _ = V(null), { mobile: A } = de(), E = f(() => t.data.required && !d.value), b = f(() => o[t.data.size ?? D.SMALL]), I = f(() => t.data.size === D.LARGE ? A.value : !1), p = f(() => S({}, u, t.data.abortCta)), h = f(() => S({}, s, t.data.saveCta)), C = f(() => t.data.size === D.LARGE ? "secondary" : "primary");
357
+ }, i = b(!0), d = b(X(t.data.initialValue) ?? null), _ = b(null), { mobile: V } = me(), E = f(() => t.data.required && !d.value), h = f(() => o[t.data.size ?? D.SMALL]), I = f(() => t.data.size === D.LARGE ? V.value : !1), p = f(() => $({}, l, t.data.abortCta)), w = f(() => $({}, r, t.data.saveCta)), y = f(() => t.data.size === D.LARGE ? "secondary" : "primary");
333
358
  function T() {
334
- d.value = Z(t.data.initialValue) ?? null, c.value = !1;
359
+ d.value = X(t.data.initialValue) ?? null, i.value = !1;
335
360
  }
336
- function Q() {
337
- c.value = !1;
361
+ function F() {
362
+ i.value = !1;
338
363
  }
339
- function G() {
364
+ function W() {
340
365
  if (t.data.required && !d.value) {
341
366
  a("reject");
342
367
  return;
343
368
  }
344
369
  a("resolve", d.value);
345
370
  }
346
- return (U, B) => (m(), g(r(X), {
347
- modelValue: c.value,
348
- "onUpdate:modelValue": B[1] || (B[1] = (q) => c.value = q),
349
- "max-width": b.value,
371
+ return (j, M) => (m(), g(u(Z), {
372
+ modelValue: i.value,
373
+ "onUpdate:modelValue": M[1] || (M[1] = (z) => i.value = z),
374
+ "max-width": h.value,
350
375
  fullscreen: I.value,
351
- scrollable: U.data.size === r(D).LARGE,
352
- onAfterLeave: G
376
+ scrollable: j.data.size === u(D).LARGE,
377
+ onAfterLeave: W
353
378
  }, {
354
- default: i(() => [
355
- l(r(J), { class: "prompt-dialog-card" }, {
356
- default: i(() => [
357
- l(r(_e), { color: "primary" }, {
358
- default: i(() => [
359
- l(r(Ce), null, {
360
- default: i(() => [
361
- l(y, {
362
- translate: U.data.translateTitle,
363
- content: U.data.title
379
+ default: c(() => [
380
+ s(u(ee), { class: "prompt-dialog-card" }, {
381
+ default: c(() => [
382
+ s(u(he), { color: "primary" }, {
383
+ default: c(() => [
384
+ s(u(we), null, {
385
+ default: c(() => [
386
+ s(C, {
387
+ translate: j.data.translateTitle,
388
+ content: j.data.title
364
389
  }, null, 8, ["translate", "content"])
365
390
  ]),
366
391
  _: 1
367
392
  }),
368
- l(r(ee)),
369
- M("div", {
393
+ s(u(ae)),
394
+ Q("div", {
370
395
  ref_key: "toolbar",
371
396
  ref: _,
372
397
  class: "prompt-dialog-toolbar-slot"
373
398
  }, null, 512),
374
- l(r(x), {
399
+ s(u(x), {
375
400
  icon: "mdi-close",
376
401
  onClick: T
377
402
  })
378
403
  ]),
379
404
  _: 1
380
405
  }),
381
- _.value ? (m(), g(N(U.data.component), O({ key: 0 }, U.data.props, {
406
+ _.value ? (m(), g(B(j.data.component), G({ key: 0 }, j.data.props, {
382
407
  modelValue: d.value,
383
- "onUpdate:modelValue": B[0] || (B[0] = (q) => d.value = q),
408
+ "onUpdate:modelValue": M[0] || (M[0] = (z) => d.value = z),
384
409
  toolbar: _.value
385
410
  }), null, 16, ["modelValue", "toolbar"])) : k("", !0),
386
- l(r(ye)),
387
- l(r(Y), null, {
388
- default: i(() => [
389
- l(r(ee)),
390
- l(r(x), {
391
- color: C.value,
411
+ s(u(xe)),
412
+ s(u(te), null, {
413
+ default: c(() => [
414
+ s(u(ae)),
415
+ s(u(x), {
416
+ color: y.value,
392
417
  onClick: T
393
418
  }, {
394
- default: i(() => [
395
- l(y, {
419
+ default: c(() => [
420
+ s(C, {
396
421
  translate: p.value.translateText,
397
422
  content: p.value.text
398
423
  }, null, 8, ["translate", "content"])
399
424
  ]),
400
425
  _: 1
401
426
  }, 8, ["color"]),
402
- l(r(x), {
427
+ s(u(x), {
403
428
  variant: "elevated",
404
- color: C.value,
429
+ color: y.value,
405
430
  disabled: E.value,
406
- onClick: Q
431
+ onClick: F
407
432
  }, {
408
- default: i(() => [
409
- l(y, {
410
- translate: h.value.translateText,
411
- content: h.value.text
433
+ default: c(() => [
434
+ s(C, {
435
+ translate: w.value.translateText,
436
+ content: w.value.text
412
437
  }, null, 8, ["translate", "content"])
413
438
  ]),
414
439
  _: 1
@@ -423,7 +448,7 @@ const Me = /* @__PURE__ */ w({
423
448
  _: 1
424
449
  }, 8, ["modelValue", "max-width", "fullscreen", "scrollable"]));
425
450
  }
426
- }), Se = /* @__PURE__ */ F(Me, [["__scopeId", "data-v-1f5a0caf"]]), Fe = { class: "d-flex justify-space-between pr-2 py-2" }, Qe = 550, Be = /* @__PURE__ */ w({
451
+ }), We = /* @__PURE__ */ N(Ge, [["__scopeId", "data-v-1f5a0caf"]]), ze = { class: "d-flex justify-space-between pr-2 py-2" }, qe = 550, He = /* @__PURE__ */ A({
427
452
  __name: "ConfirmDialog",
428
453
  props: {
429
454
  data: {}
@@ -433,95 +458,95 @@ const Me = /* @__PURE__ */ w({
433
458
  const t = e, a = n, o = {
434
459
  text: "APP.YES",
435
460
  translateText: !0
436
- }, u = {
461
+ }, l = {
437
462
  text: "APP.NO",
438
463
  translateText: !0
439
464
  };
440
- let s = !1;
441
- const c = V(!0), d = f(() => Object.hasOwn(t.data, "content") ? {
465
+ let r = !1;
466
+ const i = b(!0), d = f(() => Object.hasOwn(t.data, "content") ? {
442
467
  content: t.data.content,
443
468
  translateContent: t.data.translateContent
444
469
  } : null), _ = f(() => Object.hasOwn(t.data, "component") ? {
445
470
  component: t.data.component,
446
471
  props: t.data.props
447
- } : null), A = f(() => S({}, o, t.data.confirmCta)), E = f(() => S({}, u, t.data.rejectCta)), b = f(() => t.data.highlightCta ?? "confirm"), I = f(() => t.data.level ?? "primary");
472
+ } : null), V = f(() => $({}, o, t.data.confirmCta)), E = f(() => $({}, l, t.data.rejectCta)), h = f(() => t.data.highlightCta ?? "confirm"), I = f(() => t.data.level ?? "primary");
448
473
  function p() {
449
- c.value = !1;
474
+ i.value = !1;
450
475
  }
451
- function h() {
452
- s = !0, c.value = !1;
476
+ function w() {
477
+ r = !0, i.value = !1;
453
478
  }
454
- function C() {
455
- if (t.data.throwOnReject && !s) {
479
+ function y() {
480
+ if (t.data.throwOnReject && !r) {
456
481
  a("reject");
457
482
  return;
458
483
  }
459
- a("resolve", s);
484
+ a("resolve", r);
460
485
  }
461
- return (T, Q) => (m(), g(r(X), {
462
- modelValue: c.value,
463
- "onUpdate:modelValue": Q[0] || (Q[0] = (G) => c.value = G),
486
+ return (T, F) => (m(), g(u(Z), {
487
+ modelValue: i.value,
488
+ "onUpdate:modelValue": F[0] || (F[0] = (W) => i.value = W),
464
489
  persistent: !!T.data.permanent,
465
- "max-width": T.data.maxWidth ?? Qe,
466
- onAfterLeave: C
490
+ "max-width": T.data.maxWidth ?? qe,
491
+ onAfterLeave: y
467
492
  }, {
468
- default: i(() => [
469
- l(r(J), { class: "confirm-dialog-card" }, {
470
- default: i(() => [
471
- M("div", Fe, [
472
- l(r(re), null, {
473
- default: i(() => [
474
- l(y, {
493
+ default: c(() => [
494
+ s(u(ee), { class: "confirm-dialog-card" }, {
495
+ default: c(() => [
496
+ Q("div", ze, [
497
+ s(u(se), null, {
498
+ default: c(() => [
499
+ s(C, {
475
500
  translate: T.data.translateTitle,
476
501
  content: T.data.title
477
502
  }, null, 8, ["translate", "content"])
478
503
  ]),
479
504
  _: 1
480
505
  }),
481
- T.data.permanent ? k("", !0) : (m(), g(r(x), {
506
+ T.data.permanent ? k("", !0) : (m(), g(u(x), {
482
507
  key: 0,
483
508
  icon: "$close",
484
509
  variant: "text",
485
510
  onClick: p
486
511
  }))
487
512
  ]),
488
- d.value ? (m(), g(r(ue), { key: 0 }, {
489
- default: i(() => [
490
- l(y, {
513
+ d.value ? (m(), g(u(ie), { key: 0 }, {
514
+ default: c(() => [
515
+ s(C, {
491
516
  translate: d.value.translateContent,
492
517
  content: d.value.content
493
518
  }, null, 8, ["translate", "content"])
494
519
  ]),
495
520
  _: 1
496
521
  })) : k("", !0),
497
- _.value ? (m(), g(N(_.value.component), le(O({ key: 1 }, _.value.props)), null, 16)) : k("", !0),
498
- l(r(Y), { class: "justify-end" }, {
499
- default: i(() => [
500
- M("div", {
501
- class: oe(["d-flex align-center", b.value === "confirm" ? "" : "flex-row-reverse"])
522
+ _.value ? (m(), g(B(_.value.component), ue(G({ key: 1 }, _.value.props)), null, 16)) : k("", !0),
523
+ s(u(te), { class: "justify-end" }, {
524
+ default: c(() => [
525
+ Q("div", {
526
+ class: re(["d-flex align-center", h.value === "confirm" ? "" : "flex-row-reverse"])
502
527
  }, [
503
- l(r(x), {
504
- variant: b.value === "reject" ? "elevated" : "text",
528
+ s(u(x), {
529
+ variant: h.value === "reject" ? "elevated" : "text",
505
530
  color: I.value,
506
531
  onClick: p
507
532
  }, {
508
- default: i(() => [
509
- l(y, {
533
+ default: c(() => [
534
+ s(C, {
510
535
  translate: E.value.translateText,
511
536
  content: E.value.text
512
537
  }, null, 8, ["translate", "content"])
513
538
  ]),
514
539
  _: 1
515
540
  }, 8, ["variant", "color"]),
516
- l(r(x), {
517
- variant: b.value === "confirm" ? "elevated" : "text",
541
+ s(u(x), {
542
+ variant: h.value === "confirm" ? "elevated" : "text",
518
543
  color: I.value,
519
- onClick: h
544
+ onClick: w
520
545
  }, {
521
- default: i(() => [
522
- l(y, {
523
- translate: A.value.translateText,
524
- content: A.value.text
546
+ default: c(() => [
547
+ s(C, {
548
+ translate: V.value.translateText,
549
+ content: V.value.text
525
550
  }, null, 8, ["translate", "content"])
526
551
  ]),
527
552
  _: 1
@@ -537,51 +562,51 @@ const Me = /* @__PURE__ */ w({
537
562
  _: 1
538
563
  }, 8, ["modelValue", "persistent", "max-width"]));
539
564
  }
540
- }), Ne = /* @__PURE__ */ F(Be, [["__scopeId", "data-v-634f1f39"]]);
541
- function Ke() {
542
- const e = ce();
543
- function n(o, u) {
544
- let s;
545
- return typeof o == "string" ? s = {
565
+ }), Ke = /* @__PURE__ */ N(He, [["__scopeId", "data-v-634f1f39"]]);
566
+ function nt() {
567
+ const e = de();
568
+ function n(o, l) {
569
+ let r;
570
+ return typeof o == "string" ? r = {
546
571
  title: o,
547
- content: u ?? ""
548
- } : s = o, new Promise((c) => {
572
+ content: l ?? ""
573
+ } : r = o, new Promise((i) => {
549
574
  const d = {
550
- component: $e,
551
- props: { data: s },
552
- resolve: c,
575
+ component: Be,
576
+ props: { data: r },
577
+ resolve: i,
553
578
  reject: () => {
554
- c(null);
579
+ i(null);
555
580
  }
556
581
  };
557
582
  e.addToQueue(d);
558
583
  });
559
584
  }
560
585
  function t(o) {
561
- return new Promise((u, s) => {
562
- const c = {
563
- component: Se,
586
+ return new Promise((l, r) => {
587
+ const i = {
588
+ component: We,
564
589
  props: { data: o },
565
- resolve: u,
566
- reject: s
590
+ resolve: l,
591
+ reject: r
567
592
  };
568
- e.addToQueue(c);
593
+ e.addToQueue(i);
569
594
  });
570
595
  }
571
- function a(o, u, s) {
572
- let c = o;
573
- return typeof o == "string" && typeof u == "string" && (c = {
596
+ function a(o, l, r) {
597
+ let i = o;
598
+ return typeof o == "string" && typeof l == "string" && (i = {
574
599
  title: o,
575
- content: u,
576
- level: s
600
+ content: l,
601
+ level: r
577
602
  }), new Promise((d, _) => {
578
- const A = {
579
- component: Ne,
580
- props: { data: c },
603
+ const V = {
604
+ component: Ke,
605
+ props: { data: i },
581
606
  resolve: d,
582
607
  reject: _
583
608
  };
584
- e.addToQueue(A);
609
+ e.addToQueue(V);
585
610
  });
586
611
  }
587
612
  return {
@@ -590,10 +615,77 @@ function Ke() {
590
615
  confirm: a
591
616
  };
592
617
  }
593
- var Oe = /* @__PURE__ */ ((e) => (e.DEFAULT = "primary", e.WARNING = "warning", e.DANGER = "error", e))(Oe || {});
618
+ var Xe = /* @__PURE__ */ ((e) => (e.DEFAULT = "primary", e.WARNING = "warning", e.DANGER = "error", e))(Xe || {}), O = /* @__PURE__ */ ((e) => (e.SUCCESS = "success", e.INFO = "info", e.WARNING = "warning", e.ERROR = "error", e))(O || {});
619
+ function at() {
620
+ const e = ne();
621
+ function n(l) {
622
+ return new Promise((r) => {
623
+ e.addToQueue({
624
+ message: l,
625
+ resolve: r,
626
+ timeout: 4e3,
627
+ type: O.INFO
628
+ });
629
+ });
630
+ }
631
+ function t(l) {
632
+ return new Promise((r) => {
633
+ e.addToQueue({
634
+ message: l,
635
+ resolve: r,
636
+ timeout: 4e3,
637
+ type: O.WARNING
638
+ });
639
+ });
640
+ }
641
+ function a(l) {
642
+ return new Promise((r) => {
643
+ e.addToQueue({
644
+ message: l,
645
+ resolve: r,
646
+ timeout: 4e3,
647
+ type: O.ERROR
648
+ });
649
+ });
650
+ }
651
+ function o(l) {
652
+ return new Promise((r) => {
653
+ e.addToQueue({
654
+ message: l,
655
+ resolve: r,
656
+ timeout: 4e3,
657
+ type: O.SUCCESS
658
+ });
659
+ });
660
+ }
661
+ return {
662
+ info: n,
663
+ warn: t,
664
+ error: a,
665
+ success: o
666
+ };
667
+ }
668
+ function ot(e, { overlay: n } = {}) {
669
+ const t = b(!1), a = pe();
670
+ async function o(...l) {
671
+ const r = X(n);
672
+ t.value = !0, r && (a.value = !0);
673
+ try {
674
+ return await e(...l);
675
+ } catch (i) {
676
+ throw i;
677
+ } finally {
678
+ t.value = !1, r && (a.value = !1);
679
+ }
680
+ }
681
+ return { loading: J(t), action: o };
682
+ }
594
683
  export {
595
- Oe as ConfirmDialogLevel,
684
+ Xe as ConfirmDialogLevel,
596
685
  D as PromptDialogSize,
597
- He as UiKitOutlet,
598
- Ke as useDialog
686
+ tt as UiKitOutlet,
687
+ nt as useDialog,
688
+ ot as useLoading,
689
+ pe as useLoadingOverlay,
690
+ at as useToast
599
691
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schwarzdavid/ui-kit",
3
- "version": "0.0.1-alpha.1",
3
+ "version": "0.0.1-alpha.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "preview": "vite preview",