@fiscozen/composables 0.1.39-next.0 → 1.0.1

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,262 +1,386 @@
1
- import { ref as g, reactive as se, onUnmounted as ue, nextTick as U, onMounted as W, computed as R, watch as z, onBeforeUnmount as P, getCurrentInstance as pe, defineComponent as ve, useSlots as ce, toRef as V, toRefs as fe, createElementBlock as ee, openBlock as A, renderSlot as $, createElementVNode as te, withDirectives as oe, createCommentVNode as ae, createBlock as de, unref as D, normalizeClass as le, vShow as ie, Teleport as ye } from "vue";
2
- const re = (e) => (t) => {
3
- if (t === null)
4
- return "";
5
- const o = {
6
- maximumFractionDigits: e.maximumFractionDigits || 2,
7
- minimumFractionDigits: e.minimumFractionDigits,
8
- useGrouping: e.useGrouping || !1
9
- };
10
- return t.toLocaleString("it-IT", o);
11
- }, B = (e) => {
1
+ import { ref as g, reactive as Y, onUnmounted as Q, nextTick as J, onMounted as k, computed as F, watch as B, onBeforeUnmount as N, defineComponent as Z, useSlots as _, toRef as I, toRefs as ee, createElementBlock as j, openBlock as M, renderSlot as C, createElementVNode as V, withDirectives as T, createCommentVNode as U, createBlock as te, unref as P, normalizeClass as q, vShow as G, Teleport as oe } from "vue";
2
+ const le = (e, t) => {
3
+ const o = Math.pow(10, t);
4
+ return Math.trunc(e * o) / o;
5
+ }, ne = (e, {
6
+ minimumFractionDigits: t = 0,
7
+ maximumFractionDigits: o = 2,
8
+ roundDecimals: l = !0,
9
+ useGrouping: r = !0
10
+ } = {}) => e == null || isNaN(e) || !isFinite(e) ? "" : (l ? e : le(e, o)).toLocaleString("it-IT", {
11
+ minimumFractionDigits: t,
12
+ maximumFractionDigits: o,
13
+ useGrouping: r
14
+ }), re = (e) => {
12
15
  if (!e || typeof e != "string")
13
16
  return NaN;
14
17
  let t = e.trim();
15
18
  return t.includes(",") && (t = t.replace(/\./g, ""), t = t.replace(",", ".")), parseFloat(t);
16
- }, me = (e, t) => {
19
+ }, ze = (e, t) => {
17
20
  let o = t;
18
- const a = t % e, n = t >= 0 ? e : -e;
19
- return a !== 0 && (o = Math.abs(a) >= e / 2 ? t + n - a : t - a), o;
20
- }, M = new DOMRect(0, 0, window.innerWidth, window.innerHeight), C = (e, t, o, a, n) => {
21
- let i = n ? "bottom" : "right", x = n ? "bottom-start" : "right-start";
22
- M.width = window.innerWidth, M.height = window.innerHeight, M.x = 0, M.y = 0;
23
- const s = e ? e.getBoundingClientRect() : M, l = t.getBoundingClientRect(), d = o.getBoundingClientRect(), p = (d.left - s.left - l.width) / s.width, v = (s.right - d.right - l.width) / s.width, u = (d.top - s.top - l.height) / s.height, m = (s.bottom - d.bottom - l.height) / s.height;
24
- let h = [
21
+ const l = t % e, r = t >= 0 ? e : -e;
22
+ return l !== 0 && (o = Math.abs(l) >= e / 2 ? t + r - l : t - l), o;
23
+ }, ke = (e, t, o) => Math.max(e, Math.min(t, o)), z = new DOMRect(0, 0, window.innerWidth, window.innerHeight), b = (e, t, o, l, r) => {
24
+ let n = r ? "bottom" : "right", p = r ? "bottom-start" : "right-start";
25
+ z.width = window.innerWidth, z.height = window.innerHeight, z.x = 0, z.y = 0;
26
+ const y = e ? e.getBoundingClientRect() : z, d = t.getBoundingClientRect(), v = o.getBoundingClientRect(), h = (v.left - y.left - d.width) / y.width, x = (y.right - v.right - d.width) / y.width, c = (v.top - y.top - d.height) / y.height, i = (y.bottom - v.bottom - d.height) / y.height;
27
+ let s = [
25
28
  {
26
29
  key: "right",
27
- space: v
30
+ space: x
28
31
  },
29
32
  {
30
33
  key: "top",
31
- space: u
34
+ space: c
32
35
  },
33
36
  {
34
37
  key: "bottom",
35
- space: m
38
+ space: i
36
39
  },
37
40
  {
38
41
  key: "left",
39
- space: p
42
+ space: h
40
43
  }
41
- ].sort((r, c) => c.space - r.space);
42
- if (n && (h = h.filter((r) => r.key === "top" || r.key === "bottom")), i = h[0].key, !a) {
43
- const r = (l.height - d.height) / 2;
44
- switch (i) {
44
+ ].sort((u, f) => f.space - u.space);
45
+ if (r && (s = s.filter((u) => u.key === "top" || u.key === "bottom")), n = s[0].key, !l) {
46
+ const u = (d.height - v.height) / 2;
47
+ switch (n) {
45
48
  case "right":
46
49
  case "left":
47
- s.top > d.top - r && (a = "end"), s.bottom < d.top - r && (a = "start");
50
+ y.top > v.top - u && (l = "end"), y.bottom < v.top - u && (l = "start");
48
51
  break;
49
52
  }
50
53
  }
51
- return x = a ? `${i}-${a}` : i, x;
52
- }, he = (e, t, o, a) => ({
54
+ return p = l ? `${n}-${l}` : n, p;
55
+ }, ae = (e, t, o, l) => ({
53
56
  x: t.x + e.width * o / 100,
54
- y: t.y + e.height * a / 100
55
- }), ge = (e) => {
56
- const t = g(null), o = g(null), a = g(null), n = g(), i = g(), x = g("auto"), s = g(), l = se({
57
- position: { x: 0, y: 0 }
58
- }), d = {
57
+ y: t.y + e.height * l / 100
58
+ }), W = (e) => typeof e == "string" ? document.querySelector(e) : e, ie = (e) => ({
59
+ left: parseFloat(e.marginLeft),
60
+ right: parseFloat(e.marginRight),
61
+ top: parseFloat(e.marginTop),
62
+ bottom: parseFloat(e.marginBottom)
63
+ }), se = {
64
+ // Bottom positions - content below opener
65
+ bottom: (e, t) => ({
66
+ position: {
67
+ x: e.left - t.left + e.width / 2,
68
+ y: e.bottom
69
+ },
70
+ transform: { x: -50, y: 0 }
71
+ }),
72
+ "bottom-start": (e, t) => ({
73
+ position: {
74
+ x: e.left - t.left,
75
+ y: e.bottom
76
+ },
77
+ transform: { x: 0, y: 0 }
78
+ }),
79
+ "bottom-end": (e, t) => ({
80
+ position: {
81
+ x: e.right + t.right,
82
+ y: e.bottom
83
+ },
84
+ transform: { x: -100, y: 0 }
85
+ }),
86
+ // Top positions - content above opener
87
+ top: (e, t) => ({
88
+ position: {
89
+ x: e.left - t.left + e.width / 2,
90
+ y: e.top - t.bottom
91
+ },
92
+ transform: { x: -50, y: -100 }
93
+ }),
94
+ "top-start": (e, t) => ({
95
+ position: {
96
+ x: e.left - t.left,
97
+ y: e.top - t.bottom
98
+ },
99
+ transform: { x: 0, y: -100 }
100
+ }),
101
+ "top-end": (e, t) => ({
102
+ position: {
103
+ x: e.right + t.right,
104
+ y: e.top - t.bottom
105
+ },
106
+ transform: { x: -100, y: -100 }
107
+ }),
108
+ // Left positions - content to left of opener
109
+ left: (e, t) => ({
110
+ position: {
111
+ x: e.left - t.right,
112
+ y: e.top - t.top + e.height / 2
113
+ },
114
+ transform: { x: -100, y: -50 }
115
+ }),
116
+ "left-start": (e, t) => ({
117
+ position: {
118
+ x: e.left - t.right,
119
+ y: e.top - t.top
120
+ },
121
+ transform: { x: -100, y: 0 }
122
+ }),
123
+ "left-end": (e, t) => ({
124
+ position: {
125
+ x: e.left - t.right,
126
+ y: e.bottom + t.bottom
127
+ },
128
+ transform: { x: -100, y: -100 }
129
+ }),
130
+ // Right positions - content to right of opener
131
+ right: (e, t) => ({
132
+ position: {
133
+ x: e.right + t.left,
134
+ y: e.top - t.top + e.height / 2
135
+ },
136
+ transform: { x: 0, y: -50 }
137
+ }),
138
+ "right-start": (e, t) => ({
139
+ position: {
140
+ x: e.right + t.left,
141
+ y: e.top - t.top
142
+ },
143
+ transform: { x: 0, y: 0 }
144
+ }),
145
+ "right-end": (e, t) => ({
146
+ position: {
147
+ x: e.right + t.left,
148
+ y: e.bottom + t.bottom
149
+ },
150
+ transform: { x: 0, y: -100 }
151
+ })
152
+ }, pe = (e, t, o) => {
153
+ const l = se[e];
154
+ return l ? l(t, o) : { position: { x: 0, y: 0 }, transform: { x: 0, y: 0 } };
155
+ }, ue = {
156
+ bottom: (e, t) => ({
157
+ position: {
158
+ x: e.left + e.width / 2,
159
+ y: e.bottom - t.height
160
+ },
161
+ transform: { x: -50, y: 0 }
162
+ }),
163
+ "bottom-start": (e, t) => ({
164
+ position: {
165
+ x: e.left,
166
+ y: e.bottom - t.height
167
+ },
168
+ transform: { x: 0, y: 0 }
169
+ }),
170
+ "bottom-end": (e, t) => ({
171
+ position: {
172
+ x: e.right - t.width,
173
+ y: e.bottom - t.height
174
+ },
175
+ transform: { x: 0, y: 0 }
176
+ }),
177
+ top: (e) => ({
178
+ position: {
179
+ x: e.left + e.width / 2,
180
+ y: e.top
181
+ },
182
+ transform: { x: -50, y: 0 }
183
+ }),
184
+ "top-start": (e) => ({
185
+ position: {
186
+ x: e.left,
187
+ y: e.top
188
+ },
189
+ transform: { x: 0, y: 0 }
190
+ }),
191
+ "top-end": (e, t) => ({
192
+ position: {
193
+ x: e.right - t.width,
194
+ y: e.top
195
+ },
196
+ transform: { x: 0, y: 0 }
197
+ }),
198
+ left: (e, t) => ({
199
+ position: {
200
+ x: e.left,
201
+ y: e.top + (e.height - t.height) / 2
202
+ },
203
+ transform: { x: 0, y: 0 }
204
+ }),
205
+ "left-start": (e) => ({
206
+ position: {
207
+ x: e.left,
208
+ y: e.top
209
+ },
210
+ transform: { x: 0, y: 0 }
211
+ }),
212
+ "left-end": (e, t) => ({
213
+ position: {
214
+ x: e.left,
215
+ y: e.bottom - t.height
216
+ },
217
+ transform: { x: 0, y: 0 }
218
+ }),
219
+ right: (e, t) => ({
220
+ position: {
221
+ x: e.right - t.width,
222
+ y: e.top + (e.height - t.height) / 2
223
+ },
224
+ transform: { x: 0, y: 0 }
225
+ }),
226
+ "right-start": (e, t) => ({
227
+ position: {
228
+ x: e.right - t.width,
229
+ y: e.top
230
+ },
231
+ transform: { x: 0, y: 0 }
232
+ }),
233
+ "right-end": (e, t) => ({
234
+ position: {
235
+ x: e.right - t.width,
236
+ y: e.bottom - t.height
237
+ },
238
+ transform: { x: 0, y: 0 }
239
+ })
240
+ }, ce = (e, t, o) => {
241
+ const l = ue[e];
242
+ return l ? l(t, o) : { position: { x: 0, y: 0 }, transform: { x: 0, y: 0 } };
243
+ }, fe = (e, t, o, l) => {
244
+ const r = { ...e }, n = { ...l };
245
+ if (e.x < o.left && (r.x = o.left, n.x = 0), e.x + t.width > o.right) {
246
+ const p = o.right - t.width;
247
+ p > 0 && (r.x = p), n.x = 0;
248
+ }
249
+ if (e.y < o.top && (r.y = o.top, n.y = 0), e.y + t.height > o.bottom) {
250
+ const p = o.bottom - t.height;
251
+ p > 0 && (r.y = p), n.y = 0;
252
+ }
253
+ return { position: r, transform: n };
254
+ }, ye = (e, t, o, l, r) => {
255
+ const n = r ? null : t;
256
+ switch (e) {
257
+ case "auto":
258
+ return b(n, o, l);
259
+ case "auto-vertical":
260
+ return b(n, o, l, void 0, !0);
261
+ case "auto-start":
262
+ return b(n, o, l, "start");
263
+ case "auto-vertical-start":
264
+ return b(n, o, l, "start", !0);
265
+ case "auto-end":
266
+ return b(n, o, l, "end");
267
+ case "auto-vertical-end":
268
+ return b(n, o, l, "end", !0);
269
+ default:
270
+ return "bottom-start";
271
+ }
272
+ }, ve = (e) => e.startsWith("auto"), de = (e) => {
273
+ const t = g("auto"), o = g(), l = g(), r = g(), n = g(), p = Y({ position: { x: 0, y: 0 } }), y = {
59
274
  root: null,
60
275
  rootMargin: "0px",
61
276
  threshold: 1,
62
277
  ...e.element.value.intersectionOptions
63
- }, p = (h, r) => {
64
- }, v = g(new IntersectionObserver(p, d)), u = g(), m = (h = !1) => U(() => {
65
- var I, f, b, w, O, S, F, q, G, _, j, K, Q, X, Y;
66
- if (u.value = e.position ? e.position.value : "auto", t.value = typeof e.element.value.domRef.value == "string" ? document.querySelector(e.element.value.domRef.value) : e.element.value.domRef.value, (I = e.container) != null && I.value ? (o.value = typeof ((f = e.container.value) == null ? void 0 : f.domRef.value) == "string" ? document.querySelector(e.container.value.domRef.value) : (b = e.container.value) == null ? void 0 : b.domRef.value, o.value ?? (o.value = document.body)) : o.value = document.body, !t.value)
67
- throw new Error("missing reference element for floating behavior");
68
- (w = e.opener) != null && w.value && (a.value = typeof ((O = e.opener.value) == null ? void 0 : O.domRef.value) == "string" ? document.querySelector(e.opener.value.domRef.value) : (S = e.opener.value) == null ? void 0 : S.domRef.value), s.value = t.value.getBoundingClientRect(), n.value = (F = a.value) == null ? void 0 : F.getBoundingClientRect(), i.value = o.value.getBoundingClientRect();
69
- const r = window.getComputedStyle(t.value);
70
- v.value.observe(t.value), v.value.observe(o.value);
71
- let c = 0, y = 0;
72
- if ((q = e.opener) != null && q.value && a.value && (n != null && n.value)) {
73
- const k = n.value.left - parseFloat(r.marginLeft) - parseFloat(r.marginRight), J = n.value.left - parseFloat(r.marginLeft), L = n.value.top - parseFloat(r.marginTop) - parseFloat(r.marginBottom), Z = n.value.top - parseFloat(r.marginTop);
74
- switch (u.value) {
75
- case "auto":
76
- u.value = C(
77
- (G = e.useViewport) != null && G.value ? null : o.value,
78
- t.value,
79
- a.value
80
- );
81
- break;
82
- case "auto-vertical":
83
- u.value = C(
84
- (_ = e.useViewport) != null && _.value ? null : o.value,
85
- t.value,
86
- a.value,
87
- void 0,
88
- !0
89
- );
90
- break;
91
- case "auto-start":
92
- u.value = C(
93
- (j = e.useViewport) != null && j.value ? null : o.value,
94
- t.value,
95
- a.value,
96
- "start"
97
- );
98
- break;
99
- case "auto-vertical-start":
100
- u.value = C(
101
- (K = e.useViewport) != null && K.value ? null : o.value,
102
- t.value,
103
- a.value,
104
- "start",
105
- !0
106
- );
107
- break;
108
- case "auto-end":
109
- u.value = C(
110
- (Q = e.useViewport) != null && Q.value ? null : o.value,
111
- t.value,
112
- a.value,
113
- "end"
114
- );
115
- break;
116
- case "auto-vertical-end":
117
- u.value = C(
118
- (X = e.useViewport) != null && X.value ? null : o.value,
119
- t.value,
120
- a.value,
121
- "end",
122
- !0
123
- );
124
- break;
125
- }
126
- switch (u.value) {
127
- case "bottom":
128
- l.position.y = n.value.bottom, l.position.x = J + n.value.width / 2, y = -50, c = 0;
129
- break;
130
- case "bottom-start":
131
- l.position.y = n.value.bottom, l.position.x = k, y = 0, c = 0;
132
- break;
133
- case "bottom-end":
134
- l.position.y = n.value.bottom, l.position.x = n.value.right, y = -100, c = 0;
135
- break;
136
- case "left-start":
137
- l.position.y = L, l.position.x = k, y = -100, c = 0;
138
- break;
139
- case "left":
140
- l.position.y = Z + n.value.height / 2, l.position.x = k, c = -50, y = -100;
141
- break;
142
- case "left-end":
143
- l.position.y = n.value.bottom, l.position.x = k, c = -100, y = -100;
144
- break;
145
- case "top-start":
146
- l.position.y = L, l.position.x = k, c = -100, y = 0;
147
- break;
148
- case "top":
149
- l.position.y = L, l.position.x = J + n.value.width / 2, y = -50, c = -100;
150
- break;
151
- case "top-end":
152
- l.position.y = L, l.position.x = n.value.right, y = -100, c = -100;
153
- break;
154
- case "right-start":
155
- l.position.y = L, l.position.x = n.value.right, y = 0, c = 0;
156
- break;
157
- case "right":
158
- l.position.y = Z + n.value.height / 2, l.position.x = n.value.right, c = -50, y = 0;
159
- break;
160
- case "right-end":
161
- l.position.y = n.value.bottom, l.position.x = n.value.right, c = -100, y = 0;
162
- break;
163
- }
164
- } else
165
- switch (u.value) {
166
- case "bottom":
167
- l.position.y = i.value.bottom - s.value.height, l.position.x = i.value.left + i.value.width / 2, y = -50;
168
- break;
169
- case "left-end":
170
- case "bottom-start":
171
- l.position.y = i.value.bottom - s.value.height, l.position.x = i.value.left;
172
- break;
173
- case "right-end":
174
- case "bottom-end":
175
- l.position.y = i.value.bottom - s.value.height, l.position.x = i.value.right - s.value.width;
176
- break;
177
- case "left":
178
- l.position.y = i.value.top + (i.value.height - s.value.height) / 2, l.position.x = i.value.left;
179
- break;
180
- case "top-start":
181
- case "left-start":
182
- l.position.y = i.value.top, l.position.x = i.value.left;
183
- break;
184
- case "top":
185
- l.position.y = i.value.top, l.position.x = i.value.left + (i.value.width - s.value.width) / 2;
186
- break;
187
- case "top-end":
188
- case "right-start":
189
- l.position.y = i.value.top, l.position.x = i.value.right - s.value.width;
190
- case "right":
191
- l.position.y = i.value.top + (i.value.height - s.value.height) / 2, l.position.x = i.value.right - s.value.width;
192
- break;
193
- }
194
- const E = he(s.value, l.position, y, c);
195
- if (l.position.x = E.x, l.position.y = E.y, E.x < i.value.left && (l.position.x = i.value.left, y = 0), E.x + s.value.width > i.value.right) {
196
- const k = i.value.right - s.value.width;
197
- k > 0 && (l.position.x = k), y = 0;
198
- }
199
- if (E.y < i.value.top && (l.position.y = i.value.top, c = 0), E.y + s.value.height > i.value.bottom) {
200
- const k = i.value.bottom - s.value.height;
201
- k > 0 && (l.position.y = k), c = 0;
202
- }
203
- t.value.style.top = `${l.position.y}px`, t.value.style.left = `${l.position.x}px`, t.value.style.position = "fixed", t.value.style.display = "flex", s.value = t.value.getBoundingClientRect(), (Y = e.callback) != null && Y.value && !h && e.callback.value(s, n, i, x, u);
278
+ }, d = g(new IntersectionObserver(() => {
279
+ }, y)), v = () => {
280
+ var u, f;
281
+ const c = W(e.element.value.domRef.value);
282
+ if (!c)
283
+ return null;
284
+ const i = (u = e.container) != null && u.value ? W(e.container.value.domRef.value) ?? document.body : document.body, s = (f = e.opener) != null && f.value ? W(e.opener.value.domRef.value) : null;
285
+ return { element: c, container: i, opener: s };
286
+ }, h = (c) => {
287
+ var i;
288
+ return {
289
+ element: c.element.getBoundingClientRect(),
290
+ container: c.container.getBoundingClientRect(),
291
+ opener: ((i = c.opener) == null ? void 0 : i.getBoundingClientRect()) ?? null
292
+ };
293
+ }, x = (c = !1) => J(() => {
294
+ var O, R, L;
295
+ o.value = ((O = e.position) == null ? void 0 : O.value) ?? "auto";
296
+ const i = v();
297
+ if (!i) return;
298
+ Object.assign(i.element.style, {
299
+ position: "fixed",
300
+ top: "0px",
301
+ left: "0px"
302
+ });
303
+ const s = h(i);
304
+ l.value = s.element, r.value = s.opener ?? void 0, n.value = s.container, d.value.observe(i.element), d.value.observe(i.container), ve(o.value) && i.opener && (o.value = ye(
305
+ o.value,
306
+ i.container,
307
+ i.element,
308
+ i.opener,
309
+ ((R = e.useViewport) == null ? void 0 : R.value) ?? !1
310
+ ));
311
+ const u = ie(window.getComputedStyle(i.element)), f = i.opener && s.opener ? pe(o.value, s.opener, u) : ce(o.value, s.container, s.element), E = ae(
312
+ s.element,
313
+ f.position,
314
+ f.transform.x,
315
+ f.transform.y
316
+ ), S = fe(
317
+ E,
318
+ s.element,
319
+ s.container,
320
+ f.transform
321
+ );
322
+ p.position.x = S.position.x, p.position.y = S.position.y, Object.assign(i.element.style, {
323
+ top: `${p.position.y}px`,
324
+ left: `${p.position.x}px`,
325
+ position: "fixed",
326
+ display: "flex"
327
+ }), l.value = i.element.getBoundingClientRect(), (L = e.callback) != null && L.value && !c && e.callback.value(l, r, n, t, o);
204
328
  });
205
- return ue(() => {
206
- v.value.disconnect();
329
+ return Q(() => {
330
+ d.value.disconnect();
207
331
  }), {
208
- float: l,
209
- rect: s,
210
- setPosition: m,
211
- position: x,
212
- actualPosition: u,
213
- openerRect: n,
214
- containerRect: i
332
+ float: p,
333
+ rect: l,
334
+ setPosition: x,
335
+ position: t,
336
+ actualPosition: o,
337
+ openerRect: r,
338
+ containerRect: n
215
339
  };
216
340
  };
217
- function H(e) {
341
+ function $(e) {
218
342
  const t = window.matchMedia(e), o = g(t.matches);
219
- function a(n) {
220
- o.value = n.matches;
343
+ function l(r) {
344
+ o.value = r.matches;
221
345
  }
222
- return W(() => {
223
- t.addEventListener("change", a);
224
- }), ue(() => {
225
- t.removeEventListener("change", a);
226
- }), R(() => o.value);
346
+ return k(() => {
347
+ t.addEventListener("change", l);
348
+ }), Q(() => {
349
+ t.removeEventListener("change", l);
350
+ }), F(() => o.value);
227
351
  }
228
- function Oe(e) {
352
+ function Ee(e) {
229
353
  return {
230
354
  isGreater(t) {
231
- return H(`(min-width: ${e[t]})`);
355
+ return $(`(min-width: ${e[t]})`);
232
356
  },
233
357
  isSmaller(t) {
234
- return H(`(max-width: ${e[t]})`);
358
+ return $(`(max-width: ${e[t]})`);
235
359
  },
236
360
  isInBetween(t, o) {
237
- return H(`(min-width: ${e[t]}) and (max-width: ${e[o]})`);
361
+ return $(`(min-width: ${e[t]}) and (max-width: ${e[o]})`);
238
362
  }
239
363
  };
240
364
  }
241
- function Fe(e, t, o) {
365
+ function Oe(e, t, o) {
242
366
  if (!e)
243
367
  throw new Error("A target component has to be provided.");
244
368
  if (!t)
245
369
  throw new Error("A callback has to be provided.");
246
- const a = (n) => {
247
- !e.value || n.target === e.value || n.composedPath().includes(e.value) || typeof t == "function" && t();
370
+ const l = (r) => {
371
+ !e.value || r.target === e.value || r.composedPath().includes(e.value) || typeof t == "function" && t();
248
372
  };
249
- o && z(o, (n, i) => {
250
- i && i.removeEventListener("click", a), n == null || n.addEventListener("click", a);
251
- }), W(() => {
252
- o || document.addEventListener("click", a);
253
- }), P(() => {
254
- var n;
373
+ o && B(o, (r, n) => {
374
+ n && n.removeEventListener("click", l), r == null || r.addEventListener("click", l);
375
+ }), k(() => {
376
+ o || document.addEventListener("click", l);
377
+ }), N(() => {
378
+ var r;
255
379
  if (o) {
256
- (n = o.value) == null || n.removeEventListener("click", a);
380
+ (r = o.value) == null || r.removeEventListener("click", l);
257
381
  return;
258
382
  }
259
- document.removeEventListener("click", a);
383
+ document.removeEventListener("click", l);
260
384
  });
261
385
  }
262
386
  function Le(e, t) {
@@ -264,28 +388,28 @@ function Le(e, t) {
264
388
  throw new Error("A target component has to be provided.");
265
389
  if (!t || typeof t != "function")
266
390
  throw new Error("A callback has to be provided.");
267
- const o = (a) => {
268
- t(a);
391
+ const o = (l) => {
392
+ t(l);
269
393
  };
270
- W(() => {
394
+ k(() => {
271
395
  e.value.addEventListener("keydown", o);
272
- }), P(() => {
396
+ }), N(() => {
273
397
  e.value.removeEventListener("keydown", o);
274
398
  });
275
399
  }
276
- function $e(e, t) {
400
+ function Be(e, t) {
277
401
  if (!e || typeof e != "function")
278
402
  throw new Error("A callback has to be provided.");
279
- const o = (a) => {
280
- e(a);
403
+ const o = (l) => {
404
+ e(l);
281
405
  };
282
- W(() => {
406
+ k(() => {
283
407
  if (!t) {
284
408
  document.addEventListener("keyup", o);
285
409
  return;
286
410
  }
287
411
  t.value.addEventListener("keyup", o);
288
- }), P(() => {
412
+ }), N(() => {
289
413
  if (!t) {
290
414
  document.removeEventListener("keyup", o);
291
415
  return;
@@ -293,152 +417,10 @@ function $e(e, t) {
293
417
  t.value.removeEventListener("keyup", o);
294
418
  });
295
419
  }
296
- const Me = (e) => {
297
- const t = g(null), o = pe(), a = R(() => o == null ? void 0 : o.props.amount), n = g(), i = re(e), x = (p) => {
298
- if (!Number.isNaN(p) && o) {
299
- if (n.value = p, o.props.nullOnEmpty && !p) {
300
- o.emit("update:amount", null);
301
- return;
302
- }
303
- o.emit("update:amount", p);
304
- }
305
- }, s = (p) => {
306
- setTimeout(() => {
307
- t.value && (t.value.value = p);
308
- }, 0);
309
- }, l = (p) => (v) => {
310
- if (!t.value || !v.target)
311
- return;
312
- let { value: u } = p;
313
- u = u.replace(/[^0-9,.-]/g, "");
314
- const m = B(u);
315
- s(u);
316
- const h = o != null && o.props.nullOnEmpty && u === "" ? null : m;
317
- x(Number.isNaN(h) ? 0 : h);
318
- }, d = (p) => {
319
- if (!t.value || !p.target)
320
- return;
321
- const v = p.target.value.replace(/,/g, ".");
322
- let u;
323
- v === "" && (o != null && o.props.nullOnEmpty) ? u = null : (u = B(v), Number.isNaN(u) && (u = 0), e.step && (o != null && o.props.forceStep) && (u = me(e.step, u)), e.min && e.min > u && (u = e.min), e.max && e.max < u && (u = e.max));
324
- const m = i(u);
325
- s(m), x(B(m));
326
- };
327
- return z(t, (p, v) => {
328
- p && (v && (v == null || v.removeEventListener("input", l(p)), v == null || v.removeEventListener("blur", d)), p.addEventListener("input", l(p)), p.addEventListener("blur", d), o != null && o.props.amount && (p.value = i(a.value)));
329
- }), z(a, (p) => {
330
- U(() => {
331
- if (!(!t.value || p === null || p === void 0) && n.value !== p) {
332
- const v = i(p);
333
- t.value.value = v, n.value = p;
334
- }
335
- });
336
- }), {
337
- inputRef: t,
338
- parse: B,
339
- format: i,
340
- emitAmount: x,
341
- setValue: s
342
- };
343
- };
344
- function xe(e, t) {
345
- if (!(e == null || e === "")) {
346
- if (typeof e == "number")
347
- return e;
348
- if (typeof e == "string") {
349
- console.warn(
350
- `[useCurrencyModel] String values in v-model are deprecated and will be removed in a future version. Please use number | undefined instead. Received: "${e}". The string format is deprecated and will be replaced by "number | undefined". Parsing as number for retrocompatibility.`
351
- );
352
- const o = t(e);
353
- return isNaN(o) || !isFinite(o) ? void 0 : o;
354
- }
355
- }
356
- }
357
- function Be(e) {
358
- const {
359
- model: t,
360
- displayModel: o,
361
- inputRef: a,
362
- nullOnEmpty: n = !1,
363
- onModelUpdate: i,
364
- ...x
365
- } = e, s = re(x), l = B, d = g(!1), p = g(!1), v = g(!1);
366
- let u = !1;
367
- const m = () => {
368
- u || (u = !0, U(() => {
369
- v.value = !1, u = !1;
370
- }));
371
- }, h = (f) => xe(f, l), r = (f) => {
372
- const b = !f || f.trim() === "";
373
- if (d.value && !p.value && t.value === void 0 && !b)
374
- return s(0);
375
- }, c = (f, b) => {
376
- if (f === void 0) {
377
- if (p.value) {
378
- o.value = void 0, a != null && a.value && (a.value.value = "");
379
- return;
380
- }
381
- const w = r(b);
382
- o.value = w, a != null && a.value && (a.value.value = w || "");
383
- } else {
384
- const w = s(f);
385
- o.value = w, a != null && a.value && (a.value.value = w);
386
- }
387
- }, y = (f) => {
388
- if (p.value = !0, !(f != null && f.trim())) {
389
- o.value = void 0, a != null && a.value && (a.value.value = "");
390
- const S = n ? void 0 : 0;
391
- v.value = !0, i ? i(S) : t.value = S, m();
392
- return;
393
- }
394
- o.value = f;
395
- const b = l(f), w = isNaN(b) || !isFinite(b) ? void 0 : b;
396
- if (h(t.value) !== w) {
397
- v.value = !0;
398
- const S = w !== void 0 ? w : 0;
399
- i ? i(S) : t.value = S, m();
400
- }
401
- }, E = () => {
402
- p.value = !0;
403
- };
404
- return z(
405
- () => t.value,
406
- (f, b) => {
407
- var F;
408
- if (v.value) {
409
- m();
410
- return;
411
- }
412
- const w = h(f), O = h(b);
413
- if (w === O)
414
- return;
415
- f === void 0 && (d.value = !0);
416
- const S = ((F = a == null ? void 0 : a.value) == null ? void 0 : F.value) || o.value || "";
417
- c(w, S), f !== void 0 && typeof f == "number" && (p.value = !0);
418
- }
419
- ), {
420
- format: s,
421
- parse: l,
422
- normalize: h,
423
- handleInputUpdate: y,
424
- markUserModified: E,
425
- initialize: () => {
426
- var f;
427
- if (d.value = t.value === void 0, (f = a == null ? void 0 : a.value) != null && f.value)
428
- o.value = a.value.value, p.value = !0;
429
- else if (t.value !== void 0 && t.value !== null && t.value !== "") {
430
- const b = h(t.value);
431
- b === void 0 ? o.value = void 0 : (o.value = s(b), p.value = !0);
432
- } else
433
- t.value === void 0 ? o.value = s(0) : o.value = void 0;
434
- },
435
- resetInternalUpdateFlag: m,
436
- isInternalUpdate: R(() => v.value),
437
- userHasModified: R(() => p.value),
438
- initialValueWasUndefined: R(() => d.value)
439
- };
440
- }
441
- const be = {
420
+ const $e = (e) => ({
421
+ format: ne,
422
+ parse: re
423
+ }), xe = {
442
424
  blue: {
443
425
  50: {
444
426
  value: "#eff1ff",
@@ -1271,9 +1253,9 @@ const be = {
1271
1253
  type: "lineHeights"
1272
1254
  }
1273
1255
  }
1274
- }, T = {
1275
- global: be
1276
- }, we = [
1256
+ }, H = {
1257
+ global: xe
1258
+ }, he = [
1277
1259
  "blue",
1278
1260
  "purple",
1279
1261
  "orange",
@@ -1281,40 +1263,40 @@ const be = {
1281
1263
  "yellow",
1282
1264
  "grey",
1283
1265
  "core"
1284
- ], ke = {
1285
- safeColorNames: we
1286
- }, Se = [
1266
+ ], ge = {
1267
+ safeColorNames: he
1268
+ }, me = [
1287
1269
  "error",
1288
1270
  "warning",
1289
1271
  "success",
1290
1272
  "info"
1291
- ], Ee = {
1292
- semanticColorNames: Se
1293
- }, ze = ke.safeColorNames, Ce = Ee.semanticColorNames, N = {};
1294
- ze.forEach((e) => {
1295
- const t = T.global[e];
1273
+ ], be = {
1274
+ semanticColorNames: me
1275
+ }, we = ge.safeColorNames, Se = be.semanticColorNames, w = {};
1276
+ we.forEach((e) => {
1277
+ const t = H.global[e];
1296
1278
  t && Object.keys(t).forEach((o) => {
1297
- var n;
1298
- const a = (n = t[o]) == null ? void 0 : n.value;
1299
- a && (N[e] || (N[e] = {}), N[e][o] = a);
1279
+ var r;
1280
+ const l = (r = t[o]) == null ? void 0 : r.value;
1281
+ l && (w[e] || (w[e] = {}), w[e][o] = l);
1300
1282
  });
1301
1283
  });
1302
- const ne = T.global.semantic;
1303
- ne && Ce.forEach((e) => {
1304
- const t = ne[e];
1284
+ const K = H.global.semantic;
1285
+ K && Se.forEach((e) => {
1286
+ const t = K[e];
1305
1287
  t && typeof t == "object" && Object.keys(t).forEach((o) => {
1306
- var n;
1307
- const a = (n = t[o]) == null ? void 0 : n.value;
1308
- if (a) {
1309
- const i = `semantic-${e}`;
1310
- N[i] || (N[i] = {}), N[i][o] = a;
1288
+ var r;
1289
+ const l = (r = t[o]) == null ? void 0 : r.value;
1290
+ if (l) {
1291
+ const n = `semantic-${e}`;
1292
+ w[n] || (w[n] = {}), w[n][o] = l;
1311
1293
  }
1312
1294
  });
1313
1295
  });
1314
- const Re = Object.entries(T.global.breakpoint).reduce(
1296
+ const Re = Object.entries(H.global.breakpoint).reduce(
1315
1297
  (e, [t, o]) => (e[t] = o.value, e),
1316
1298
  {}
1317
- ), He = /* @__PURE__ */ ve({
1299
+ ), Ne = /* @__PURE__ */ Z({
1318
1300
  __name: "FzFloating",
1319
1301
  props: {
1320
1302
  isOpen: { type: Boolean, default: !1 },
@@ -1329,123 +1311,143 @@ const Re = Object.entries(T.global.breakpoint).reduce(
1329
1311
  },
1330
1312
  emits: ["fzfloating:setPosition"],
1331
1313
  setup(e, { expose: t, emit: o }) {
1332
- const a = e, n = o, i = g(null), x = g(null), s = ce(), l = H(`(max-width: ${Re.xs})`);
1333
- let d = !1;
1334
- const p = {
1335
- position: a.position,
1314
+ const l = e, r = o, n = g(null), p = g(null), y = _(), d = $(`(max-width: ${Re.xs})`);
1315
+ let v = !1, h = !1, x = null, c = null;
1316
+ const i = {
1317
+ position: l.position,
1336
1318
  element: {
1337
1319
  // @ts-ignore
1338
- domRef: i
1320
+ domRef: n
1339
1321
  },
1340
1322
  container: {
1341
1323
  // @ts-ignore
1342
- domRef: V(a.container || document.body)
1324
+ domRef: I(l.container || document.body)
1343
1325
  },
1344
1326
  opener: {
1345
- domRef: V(null)
1327
+ domRef: I(null)
1346
1328
  },
1347
- useViewport: a.useViewport,
1348
- callback(...r) {
1349
- n("fzfloating:setPosition", ...r);
1329
+ useViewport: l.useViewport,
1330
+ callback(...a) {
1331
+ r("fzfloating:setPosition", ...a);
1350
1332
  }
1351
- }, v = fe(p);
1352
- s.opener && (p.opener = {
1333
+ }, s = ee(i);
1334
+ y.opener && (i.opener = {
1353
1335
  // @ts-ignore
1354
- domRef: x
1336
+ domRef: p
1355
1337
  });
1356
- const u = ge(v), m = () => {
1357
- d || (d = !0, requestAnimationFrame(() => {
1358
- a.isOpen && u.setPosition(), d = !1;
1338
+ const u = de(s), f = () => {
1339
+ v || !h || (v = !0, requestAnimationFrame(() => {
1340
+ h && l.isOpen && u.setPosition(), v = !1;
1359
1341
  }));
1360
1342
  };
1361
- z(
1362
- () => a.position,
1363
- () => m()
1364
- ), z(
1365
- () => a.isOpen,
1366
- (r) => {
1367
- var y;
1368
- if (!r || !i.value) {
1369
- window.removeEventListener("scroll", m);
1343
+ k(() => {
1344
+ h = !0;
1345
+ });
1346
+ const E = () => {
1347
+ f();
1348
+ }, S = () => {
1349
+ f();
1350
+ }, O = () => {
1351
+ window.addEventListener("scroll", E, !0), window.addEventListener("resize", S), n.value && !x && (x = new ResizeObserver(() => {
1352
+ f();
1353
+ }), x.observe(n.value)), p.value && !c && (c = new ResizeObserver(() => {
1354
+ f();
1355
+ }), c.observe(p.value));
1356
+ }, R = () => {
1357
+ window.removeEventListener("scroll", E, !0), window.removeEventListener("resize", S), x && (x.disconnect(), x = null), c && (c.disconnect(), c = null);
1358
+ };
1359
+ B(
1360
+ () => l.position,
1361
+ () => f()
1362
+ ), B(
1363
+ () => l.isOpen,
1364
+ (a) => {
1365
+ var D;
1366
+ if (!a || !n.value || !h) {
1367
+ R();
1370
1368
  return;
1371
1369
  }
1372
- window.addEventListener("scroll", m);
1373
- const c = (y = x.value) == null ? void 0 : y.getBoundingClientRect();
1374
- i.value.style.top = "0px", i.value.style.left = "0px", i.value.style.transform = "none", i.value.style.width = l.value ? (c == null ? void 0 : c.width) + "px" : "auto", u.setPosition();
1370
+ O();
1371
+ const m = (D = p.value) == null ? void 0 : D.getBoundingClientRect();
1372
+ n.value.style.position = "fixed", n.value.style.top = "0px", n.value.style.left = "0px", n.value.style.transform = "none", n.value.style.width = d.value ? (m == null ? void 0 : m.width) + "px" : "auto", u.setPosition();
1375
1373
  }
1376
- ), z(
1377
- () => a.overrideOpener,
1378
- (r) => {
1379
- r && v.opener && v.opener.value && (v.opener.value = {
1380
- domRef: r
1374
+ ), B(
1375
+ () => l.overrideOpener,
1376
+ (a) => {
1377
+ a && s.opener && s.opener.value && (s.opener.value = {
1378
+ domRef: a
1381
1379
  });
1382
1380
  }
1383
- ), P(() => {
1384
- window.removeEventListener("scroll", m);
1381
+ ), N(() => {
1382
+ h = !1, R();
1385
1383
  });
1386
- const h = R(() => a.overrideContentClass ? a.contentClass : ["bg-core-white fixed p-4", a.contentClass]);
1384
+ const L = (a) => a.startsWith("bottom") ? "mt-4" : a.startsWith("top") ? "mb-4" : a.startsWith("left") ? "mr-4" : a.startsWith("right") ? "ml-4" : "mt-4", X = F(() => {
1385
+ var m;
1386
+ const a = ((m = u.actualPosition) == null ? void 0 : m.value) ?? l.position;
1387
+ return L(a);
1388
+ }), A = F(() => l.overrideContentClass ? l.contentClass : ["bg-core-white fixed", X.value, l.contentClass]);
1387
1389
  return t({
1388
1390
  setPosition: u.setPosition
1389
- }), (r, c) => (A(), ee("div", null, [
1390
- $(r.$slots, "opener-start"),
1391
- te("div", {
1391
+ }), (a, m) => (M(), j("div", null, [
1392
+ C(a.$slots, "opener-start"),
1393
+ V("div", {
1392
1394
  ref_key: "opener",
1393
- ref: x,
1395
+ ref: p,
1394
1396
  class: "inline-flex w-full sm:w-auto"
1395
1397
  }, [
1396
- $(r.$slots, "opener", {
1397
- isOpen: r.isOpen,
1398
- floating: D(u)
1398
+ C(a.$slots, "opener", {
1399
+ isOpen: e.isOpen,
1400
+ floating: P(u)
1399
1401
  })
1400
1402
  ], 512),
1401
- $(r.$slots, "opener-end"),
1402
- r.teleport ? ae("", !0) : oe((A(), ee("div", {
1403
+ C(a.$slots, "opener-end"),
1404
+ e.teleport ? U("", !0) : T((M(), j("div", {
1403
1405
  key: 0,
1404
1406
  ref_key: "content",
1405
- ref: i,
1406
- class: le(["fz__floating__content w-full sm:w-auto", h.value])
1407
+ ref: n,
1408
+ class: q(["fz__floating__content w-full sm:w-auto", A.value])
1407
1409
  }, [
1408
- $(r.$slots, "default", {
1409
- isOpen: r.isOpen,
1410
- floating: D(u)
1410
+ C(a.$slots, "default", {
1411
+ isOpen: e.isOpen,
1412
+ floating: P(u)
1411
1413
  })
1412
1414
  ], 2)), [
1413
- [ie, r.$slots.default && (!r.$slots.opener || r.$slots.opener && r.isOpen)]
1415
+ [G, a.$slots.default && (!a.$slots.opener || a.$slots.opener && e.isOpen)]
1414
1416
  ]),
1415
- r.teleport ? (A(), de(ye, {
1417
+ e.teleport ? (M(), te(oe, {
1416
1418
  key: 1,
1417
1419
  to: "body"
1418
1420
  }, [
1419
- oe(te("div", {
1421
+ T(V("div", {
1420
1422
  ref_key: "content",
1421
- ref: i,
1422
- class: le(["fz__floating__content", h.value])
1423
+ ref: n,
1424
+ class: q(["fz__floating__content", A.value])
1423
1425
  }, [
1424
- $(r.$slots, "default", {
1425
- isOpen: r.isOpen,
1426
- floating: D(u)
1426
+ C(a.$slots, "default", {
1427
+ isOpen: e.isOpen,
1428
+ floating: P(u)
1427
1429
  })
1428
1430
  ], 2), [
1429
- [ie, r.$slots.default && (!r.$slots.opener || r.$slots.opener && r.isOpen)]
1431
+ [G, a.$slots.default && (!a.$slots.opener || a.$slots.opener && e.isOpen)]
1430
1432
  ])
1431
- ])) : ae("", !0)
1433
+ ])) : U("", !0)
1432
1434
  ]));
1433
1435
  }
1434
1436
  });
1435
1437
  export {
1436
- He as FzFloating,
1437
- he as calcRealPos,
1438
- re as format,
1439
- C as getHighestAvailableSpacePos,
1440
- xe as normalizeModelValue,
1441
- B as parse,
1442
- me as roundTo,
1443
- Oe as useBreakpoints,
1444
- Fe as useClickOutside,
1445
- Me as useCurrency,
1446
- Be as useCurrencyModel,
1447
- ge as useFloating,
1438
+ Ne as FzFloating,
1439
+ ae as calcRealPos,
1440
+ ke as clamp,
1441
+ ne as format,
1442
+ b as getHighestAvailableSpacePos,
1443
+ re as parse,
1444
+ ze as roundTo,
1445
+ le as truncateDecimals,
1446
+ Ee as useBreakpoints,
1447
+ Oe as useClickOutside,
1448
+ $e as useCurrency,
1449
+ de as useFloating,
1448
1450
  Le as useKeyDown,
1449
- $e as useKeyUp,
1450
- H as useMediaQuery
1451
+ Be as useKeyUp,
1452
+ $ as useMediaQuery
1451
1453
  };