@schwarzdavid/ui-kit 0.0.1-alpha.3 → 0.0.1-alpha.4

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