@fiscozen/composables 0.1.26 → 0.1.27

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/package.json CHANGED
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "name": "@fiscozen/composables",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "Design System utility composables",
5
+ "scripts": {
6
+ "coverage": "vitest run --coverage",
7
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts",
8
+ "format": "prettier --write src/",
9
+ "test:unit": "vitest run",
10
+ "build": "vite build"
11
+ },
5
12
  "main": "src/index.ts",
6
13
  "type": "module",
7
14
  "keywords": [],
@@ -11,6 +18,9 @@
11
18
  "vue": "^3.4.13"
12
19
  },
13
20
  "devDependencies": {
21
+ "@fiscozen/eslint-config": "workspace:^",
22
+ "@fiscozen/prettier-config": "workspace:^",
23
+ "@fiscozen/tsconfig": "workspace:^",
14
24
  "@rushstack/eslint-patch": "^1.3.3",
15
25
  "@types/jsdom": "^21.1.6",
16
26
  "@types/node": "^18.19.3",
@@ -24,17 +34,7 @@
24
34
  "typescript": "~5.3.0",
25
35
  "vite": "^5.0.10",
26
36
  "vitest": "^1.2.0",
27
- "vue-tsc": "^1.8.25",
28
- "@fiscozen/eslint-config": "^0.1.0",
29
- "@fiscozen/prettier-config": "^0.1.0",
30
- "@fiscozen/tsconfig": "^0.1.0"
37
+ "vue-tsc": "^1.8.25"
31
38
  },
32
- "license": "ISC",
33
- "scripts": {
34
- "coverage": "vitest run --coverage",
35
- "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts",
36
- "format": "prettier --write src/",
37
- "test:unit": "vitest run",
38
- "build": "vite build"
39
- }
40
- }
39
+ "license": "ISC"
40
+ }
package/src/types.ts CHANGED
@@ -5,7 +5,7 @@ type PositionSecondary = 'start' | 'end'
5
5
  export type FzFloatingPosition = PositionPrimary | `${PositionPrimary}-${PositionSecondary}`
6
6
 
7
7
  export interface FzFloatingProps {
8
- isOpen: boolean
8
+ isOpen?: boolean
9
9
  position?: FzFloatingPosition
10
10
  container?: string | null
11
11
  contentClass?:
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Fiscozen
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,439 +0,0 @@
1
- import { ref as m, reactive as H, onUnmounted as q, nextTick as T, onMounted as B, watch as R, onBeforeUnmount as F, getCurrentInstance as U, computed as L, defineComponent as G, useSlots as K, toRef as Q, openBlock as C, createElementBlock as S, renderSlot as x, createElementVNode as D, unref as $, withDirectives as M, normalizeClass as A, vShow as W, createCommentVNode as I, createBlock as X, Teleport as Y } from "vue";
2
- const E = new DOMRect(0, 0, window.innerWidth, window.innerHeight), w = (o, n, e, u, s) => {
3
- let a = s ? "bottom" : "right", h = s ? "bottom-start" : "right-start";
4
- E.width = window.innerWidth, E.height = window.innerHeight, E.x = 0, E.y = 0;
5
- const l = o ? o.getBoundingClientRect() : E, t = n.getBoundingClientRect(), c = e.getBoundingClientRect(), g = (c.left - l.left - t.width) / l.width, r = (l.right - c.right - t.width) / l.width, i = (c.top - l.top - t.height) / l.height, d = (l.bottom - c.bottom - t.height) / l.height;
6
- let f = [
7
- {
8
- key: "right",
9
- space: r
10
- },
11
- {
12
- key: "top",
13
- space: i
14
- },
15
- {
16
- key: "bottom",
17
- space: d
18
- },
19
- {
20
- key: "left",
21
- space: g
22
- }
23
- ].sort((p, v) => v.space - p.space);
24
- if (s && (f = f.filter((p) => p.key === "top" || p.key === "bottom")), a = f[0].key, !u)
25
- switch (a) {
26
- case "right":
27
- case "left":
28
- const p = (t.height - c.height) / 2;
29
- l.top > c.top - p && (u = "end"), l.bottom < c.top - p && (u = "start");
30
- break;
31
- }
32
- return h = u ? `${a}-${u}` : a, h;
33
- }, J = (o, n, e, u) => ({
34
- x: n.x + o.width * e / 100,
35
- y: n.y + o.height * u / 100
36
- }), Z = (o) => {
37
- const n = m(null), e = m(null), u = m(null), s = m(), a = m(), h = m("auto"), l = m(), t = H({
38
- position: { x: 0, y: 0 }
39
- }), c = {
40
- root: null,
41
- rootMargin: "0px",
42
- threshold: 1,
43
- ...o.element.intersectionOptions
44
- }, g = (f, p) => {
45
- }, r = m(new IntersectionObserver(g, c)), i = m(), d = () => T(() => {
46
- var N;
47
- if (i.value = o.position ? o.position.value : "auto", n.value = typeof o.element.domRef.value == "string" ? document.querySelector(o.element.domRef.value) : o.element.domRef.value, o.container ? (e.value = typeof o.container.domRef.value == "string" ? document.querySelector(o.container.domRef.value) : o.container.domRef.value, e.value ?? (e.value = document.body)) : e.value = document.body, !n.value)
48
- throw new Error("missing reference element for floating behavior");
49
- o.opener && (u.value = typeof o.opener.domRef.value == "string" ? document.querySelector(o.opener.domRef.value) : o.opener.domRef.value), l.value = n.value.getBoundingClientRect(), s.value = (N = u.value) == null ? void 0 : N.getBoundingClientRect(), a.value = e.value.getBoundingClientRect();
50
- const f = window.getComputedStyle(n.value);
51
- r.value.observe(n.value), r.value.observe(e.value);
52
- let p = 0, v = 0;
53
- if (o.opener && u.value && s && s.value) {
54
- const y = s.value.left - parseFloat(f.marginLeft) - parseFloat(f.marginRight), z = s.value.left - parseFloat(f.marginLeft), k = s.value.top - parseFloat(f.marginTop) - parseFloat(f.marginBottom), P = s.value.top - parseFloat(f.marginTop);
55
- switch (i.value) {
56
- case "auto":
57
- i.value = w(
58
- o.useViewport ? null : e.value,
59
- n.value,
60
- u.value
61
- );
62
- break;
63
- case "auto-vertical":
64
- i.value = w(
65
- o.useViewport ? null : e.value,
66
- n.value,
67
- u.value,
68
- void 0,
69
- !0
70
- );
71
- break;
72
- case "auto-start":
73
- i.value = w(
74
- o.useViewport ? null : e.value,
75
- n.value,
76
- u.value,
77
- "start"
78
- );
79
- break;
80
- case "auto-vertical-start":
81
- i.value = w(
82
- o.useViewport ? null : e.value,
83
- n.value,
84
- u.value,
85
- "start",
86
- !0
87
- );
88
- break;
89
- case "auto-end":
90
- i.value = w(
91
- o.useViewport ? null : e.value,
92
- n.value,
93
- u.value,
94
- "end"
95
- );
96
- break;
97
- case "auto-vertical-end":
98
- i.value = w(
99
- o.useViewport ? null : e.value,
100
- n.value,
101
- u.value,
102
- "end",
103
- !0
104
- );
105
- break;
106
- }
107
- switch (i.value) {
108
- case "bottom":
109
- t.position.y = s.value.bottom, t.position.x = z + s.value.width / 2, v = -50, p = 0;
110
- break;
111
- case "bottom-start":
112
- t.position.y = s.value.bottom, t.position.x = y, v = 0, p = 0;
113
- break;
114
- case "bottom-end":
115
- t.position.y = s.value.bottom, t.position.x = s.value.right, v = -100, p = 0;
116
- break;
117
- case "left-start":
118
- t.position.y = k, t.position.x = y, v = -100, p = 0;
119
- break;
120
- case "left":
121
- t.position.y = P + s.value.height / 2, t.position.x = y, p = -50, v = -100;
122
- break;
123
- case "left-end":
124
- t.position.y = s.value.bottom, t.position.x = y, p = -100, v = -100;
125
- break;
126
- case "top-start":
127
- t.position.y = k, t.position.x = y, p = -100, v = 0;
128
- break;
129
- case "top":
130
- t.position.y = k, t.position.x = z + s.value.width / 2, v = -50, p = -100;
131
- break;
132
- case "top-end":
133
- t.position.y = k, t.position.x = s.value.right, v = -100, p = -100;
134
- break;
135
- case "right-start":
136
- t.position.y = k, t.position.x = s.value.right, v = 0, p = 0;
137
- break;
138
- case "right":
139
- t.position.y = P + s.value.height / 2, t.position.x = s.value.right, p = -50, v = 0;
140
- break;
141
- case "right-end":
142
- t.position.y = s.value.bottom, t.position.x = s.value.right, p = -100, v = 0;
143
- break;
144
- }
145
- } else
146
- switch (i.value) {
147
- case "bottom":
148
- t.position.y = a.value.bottom - l.value.height, t.position.x = a.value.left + a.value.width / 2, v = -50;
149
- break;
150
- case "left-end":
151
- case "bottom-start":
152
- t.position.y = a.value.bottom - l.value.height, t.position.x = a.value.left;
153
- break;
154
- case "right-end":
155
- case "bottom-end":
156
- t.position.y = a.value.bottom - l.value.height, t.position.x = a.value.right - l.value.width;
157
- break;
158
- case "left":
159
- t.position.y = a.value.top + (a.value.height - l.value.height) / 2, t.position.x = a.value.left;
160
- break;
161
- case "top-start":
162
- case "left-start":
163
- t.position.y = a.value.top, t.position.x = a.value.left;
164
- break;
165
- case "top":
166
- t.position.y = a.value.top, t.position.x = a.value.left + (a.value.width - l.value.width) / 2;
167
- break;
168
- case "top-end":
169
- case "right-start":
170
- t.position.y = a.value.top, t.position.x = a.value.right - l.value.width;
171
- case "right":
172
- t.position.y = a.value.top + (a.value.height - l.value.height) / 2, t.position.x = a.value.right - l.value.width;
173
- break;
174
- }
175
- const b = J(l.value, t.position, v, p);
176
- if (t.position.x = b.x, t.position.y = b.y, b.x < a.value.left && (t.position.x = a.value.left, v = 0), b.x + l.value.width > a.value.right) {
177
- const y = a.value.right - l.value.width;
178
- y > 0 && (t.position.x = y), v = 0;
179
- }
180
- if (b.y < a.value.top && (t.position.y = a.value.top, p = 0), b.y + l.value.height > a.value.bottom) {
181
- const y = a.value.bottom - l.value.height;
182
- y > 0 && (t.position.y = y), p = 0;
183
- }
184
- n.value.style.top = `${t.position.y}px`, n.value.style.left = `${t.position.x}px`, n.value.style.position = "fixed", n.value.style.display = "flex", l.value = n.value.getBoundingClientRect(), o.callback && o.callback(l, s, a, h, i);
185
- });
186
- return q(() => {
187
- r.value.disconnect();
188
- }), {
189
- float: t,
190
- rect: l,
191
- setPosition: d,
192
- position: h,
193
- actualPosition: i,
194
- openerRect: s,
195
- containerRect: a
196
- };
197
- };
198
- function O(o) {
199
- const n = window.matchMedia(o), e = m(n.matches);
200
- function u(s) {
201
- e.value = s.matches;
202
- }
203
- return B(() => {
204
- n.addEventListener("change", u);
205
- }), q(() => {
206
- n.removeEventListener("change", u);
207
- }), e;
208
- }
209
- function j(o) {
210
- return {
211
- isGreater(n) {
212
- return O(`(min-width: ${o[n]})`);
213
- },
214
- isSmaller(n) {
215
- return O(`(max-width: ${o[n]})`);
216
- },
217
- isInBetween(n, e) {
218
- return O(`(min-width: ${o[n]}) and (max-width: ${o[e]})`);
219
- }
220
- };
221
- }
222
- function V(o, n, e) {
223
- if (!o)
224
- throw new Error("A target component has to be provided.");
225
- if (!n)
226
- throw new Error("A callback has to be provided.");
227
- const u = (s) => {
228
- !o.value || s.target === o.value || s.composedPath().includes(o.value) || typeof n == "function" && n();
229
- };
230
- e && R(e, (s, a) => {
231
- a && a.removeEventListener("click", u), s == null || s.addEventListener("click", u);
232
- }), B(() => {
233
- e || document.addEventListener("click", u);
234
- }), F(() => {
235
- if (e) {
236
- e.value.removeEventListener("click", u);
237
- return;
238
- }
239
- document.removeEventListener("click", u);
240
- });
241
- }
242
- function ee(o, n) {
243
- if (!o)
244
- throw new Error("A target component has to be provided.");
245
- if (!n || typeof n != "function")
246
- throw new Error("A callback has to be provided.");
247
- const e = (u) => {
248
- n(u);
249
- };
250
- B(() => {
251
- o.value.addEventListener("keydown", e);
252
- }), F(() => {
253
- o.value.removeEventListener("keydown", e);
254
- });
255
- }
256
- function te(o, n) {
257
- if (!o || typeof o != "function")
258
- throw new Error("A callback has to be provided.");
259
- const e = (u) => {
260
- o(u);
261
- };
262
- B(() => {
263
- if (!n) {
264
- document.addEventListener("keyup", e);
265
- return;
266
- }
267
- n.value.addEventListener("keyup", e);
268
- }), F(() => {
269
- if (!n) {
270
- document.removeEventListener("keyup", e);
271
- return;
272
- }
273
- n.value.removeEventListener("keyup", e);
274
- });
275
- }
276
- const oe = (o) => {
277
- const n = m(null), e = U(), u = L(() => e == null ? void 0 : e.props.amount), s = m(), a = (r) => {
278
- if (r === null)
279
- return "";
280
- const i = {
281
- minimumFractionDigits: o.minimumFractionDigits,
282
- useGrouping: !1
283
- };
284
- return o.maximumFractionDigits !== null && (i.maximumFractionDigits = o.maximumFractionDigits), r.toLocaleString("it-IT", i);
285
- }, h = (r) => parseFloat(r.replace(/,/g, ".")), l = (r) => {
286
- if (!Number.isNaN(r) && e) {
287
- if (s.value = r, e.props.nullOnEmpty && !r) {
288
- e.emit("update:amount", null);
289
- return;
290
- }
291
- e.emit("update:amount", typeof u.value == "number" ? r : r == null ? void 0 : r.toString());
292
- }
293
- }, t = (r) => {
294
- setTimeout(() => {
295
- n.value && (n.value.value = r);
296
- }, 0);
297
- }, c = (r) => (i) => {
298
- if (!n.value || !i.target)
299
- return;
300
- let { value: d } = r;
301
- d = d.replace(/[^0-9,.-]/g, ""), t(d);
302
- const f = e != null && e.props.nullOnEmpty && d === "" ? null : h(d);
303
- l(Number.isNaN(f) ? 0 : f);
304
- }, g = (r) => {
305
- if (!n.value || !r.target)
306
- return;
307
- const i = r.target.value.replace(/,/g, ".");
308
- let d;
309
- i === "" && (e != null && e.props.nullOnEmpty) ? d = null : (d = h(i), Number.isNaN(d) && (d = 0));
310
- const f = a(d);
311
- t(f), l(h(f));
312
- };
313
- return R(n, (r, i) => {
314
- r && (i && (i == null || i.removeEventListener("input", c(r)), i == null || i.removeEventListener("blur", g)), r.addEventListener("input", c(r)), r.addEventListener("blur", g), e != null && e.props.amount && (r.value = a(u.value)));
315
- }), R(u, (r) => {
316
- T(() => {
317
- if (!(!n.value || r === null || r === void 0) && s.value !== r) {
318
- const i = a(r);
319
- n.value.value = i, s.value = r;
320
- }
321
- });
322
- }), {
323
- inputRef: n,
324
- parse: h,
325
- format: a,
326
- emitAmount: l,
327
- setValue: t
328
- };
329
- }, ne = /* @__PURE__ */ G({
330
- __name: "FzFloating",
331
- props: {
332
- isOpen: { type: Boolean, default: !1 },
333
- position: { default: "auto" },
334
- container: {},
335
- contentClass: {},
336
- openerClass: {},
337
- overrideContentClass: { type: Boolean },
338
- teleport: { type: Boolean, default: !1 },
339
- useViewport: { type: Boolean }
340
- },
341
- emits: ["fzfloating:setPosition"],
342
- setup(o, { emit: n }) {
343
- const e = o, u = n, s = m(null), a = m(null), h = K();
344
- let l = !1;
345
- const t = {
346
- position: L(() => e.position),
347
- element: {
348
- // @ts-ignore
349
- domRef: a
350
- },
351
- container: {
352
- // @ts-ignore
353
- domRef: Q(e.container || document.body)
354
- },
355
- useViewport: L(() => e.useViewport),
356
- callback(...i) {
357
- u("fzfloating:setPosition", ...i);
358
- }
359
- };
360
- h.opener && (t.opener = {
361
- domRef: s
362
- });
363
- const c = Z(t), g = () => {
364
- l || (l = !0, requestAnimationFrame(() => {
365
- e.isOpen && c.setPosition(), l = !1;
366
- }));
367
- };
368
- R(
369
- () => e.position,
370
- () => g()
371
- ), R(
372
- () => e.isOpen,
373
- (i) => {
374
- if (!i || !a.value) {
375
- window.removeEventListener("scroll", g);
376
- return;
377
- }
378
- window.addEventListener("scroll", g), a.value.style.top = "0px", a.value.style.left = "0px", a.value.style.transform = "none", c.setPosition();
379
- }
380
- ), F(() => {
381
- window.removeEventListener("scroll", g);
382
- });
383
- const r = L(() => e.overrideContentClass ? e.contentClass : ["bg-core-white fixed p-4 z-10", e.contentClass]);
384
- return (i, d) => (C(), S("div", null, [
385
- x(i.$slots, "opener-start"),
386
- D("div", {
387
- ref_key: "opener",
388
- ref: s,
389
- class: "inline-flex"
390
- }, [
391
- x(i.$slots, "opener", {
392
- isOpen: i.isOpen,
393
- floating: $(c)
394
- })
395
- ], 512),
396
- x(i.$slots, "opener-end"),
397
- i.teleport ? I("", !0) : M((C(), S("div", {
398
- key: 0,
399
- ref_key: "content",
400
- ref: a,
401
- class: A(["fz__floating__content", r.value])
402
- }, [
403
- x(i.$slots, "default", {
404
- isOpen: i.isOpen,
405
- floating: $(c)
406
- })
407
- ], 2)), [
408
- [W, i.$slots.default && (!i.$slots.opener || i.$slots.opener && i.isOpen)]
409
- ]),
410
- i.teleport ? (C(), X(Y, {
411
- key: 1,
412
- to: "body"
413
- }, [
414
- M(D("div", {
415
- ref_key: "content",
416
- ref: a,
417
- class: A(["fz__floating__content", r.value])
418
- }, [
419
- x(i.$slots, "default", {
420
- isOpen: i.isOpen,
421
- floating: $(c)
422
- })
423
- ], 2), [
424
- [W, i.$slots.default && (!i.$slots.opener || i.$slots.opener && i.isOpen)]
425
- ])
426
- ])) : I("", !0)
427
- ]));
428
- }
429
- });
430
- export {
431
- ne as FzFloating,
432
- j as useBreakpoints,
433
- V as useClickOutside,
434
- oe as useCurrency,
435
- Z as useFloating,
436
- ee as useKeyDown,
437
- te as useKeyUp,
438
- O as useMediaQuery
439
- };
@@ -1 +0,0 @@
1
- (function(v,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(v=typeof globalThis<"u"?globalThis:v||self,e(v.FzComposables={},v.Vue))})(this,function(v,e){"use strict";const E=new DOMRect(0,0,window.innerWidth,window.innerHeight),w=(n,i,t,c,s)=>{let r=s?"bottom":"right",g=s?"bottom-start":"right-start";E.width=window.innerWidth,E.height=window.innerHeight,E.x=0,E.y=0;const u=n?n.getBoundingClientRect():E,o=i.getBoundingClientRect(),f=t.getBoundingClientRect(),y=(f.left-u.left-o.width)/u.width,l=(u.right-f.right-o.width)/u.width,a=(f.top-u.top-o.height)/u.height,h=(u.bottom-f.bottom-o.height)/u.height;let m=[{key:"right",space:l},{key:"top",space:a},{key:"bottom",space:h},{key:"left",space:y}].sort((p,d)=>d.space-p.space);if(s&&(m=m.filter(p=>p.key==="top"||p.key==="bottom")),r=m[0].key,!c)switch(r){case"right":case"left":const p=(o.height-f.height)/2;u.top>f.top-p&&(c="end"),u.bottom<f.top-p&&(c="start");break}return g=c?`${r}-${c}`:r,g},O=(n,i,t,c)=>({x:i.x+n.width*t/100,y:i.y+n.height*c/100}),B=n=>{const i=e.ref(null),t=e.ref(null),c=e.ref(null),s=e.ref(),r=e.ref(),g=e.ref("auto"),u=e.ref(),o=e.reactive({position:{x:0,y:0}}),f={root:null,rootMargin:"0px",threshold:1,...n.element.intersectionOptions},y=(m,p)=>{},l=e.ref(new IntersectionObserver(y,f)),a=e.ref(),h=()=>e.nextTick(()=>{var C;if(a.value=n.position?n.position.value:"auto",i.value=typeof n.element.domRef.value=="string"?document.querySelector(n.element.domRef.value):n.element.domRef.value,n.container?(t.value=typeof n.container.domRef.value=="string"?document.querySelector(n.container.domRef.value):n.container.domRef.value,t.value??(t.value=document.body)):t.value=document.body,!i.value)throw new Error("missing reference element for floating behavior");n.opener&&(c.value=typeof n.opener.domRef.value=="string"?document.querySelector(n.opener.domRef.value):n.opener.domRef.value),u.value=i.value.getBoundingClientRect(),s.value=(C=c.value)==null?void 0:C.getBoundingClientRect(),r.value=t.value.getBoundingClientRect();const m=window.getComputedStyle(i.value);l.value.observe(i.value),l.value.observe(t.value);let p=0,d=0;if(n.opener&&c.value&&s&&s.value){const b=s.value.left-parseFloat(m.marginLeft)-parseFloat(m.marginRight),L=s.value.left-parseFloat(m.marginLeft),R=s.value.top-parseFloat(m.marginTop)-parseFloat(m.marginBottom),F=s.value.top-parseFloat(m.marginTop);switch(a.value){case"auto":a.value=w(n.useViewport?null:t.value,i.value,c.value);break;case"auto-vertical":a.value=w(n.useViewport?null:t.value,i.value,c.value,void 0,!0);break;case"auto-start":a.value=w(n.useViewport?null:t.value,i.value,c.value,"start");break;case"auto-vertical-start":a.value=w(n.useViewport?null:t.value,i.value,c.value,"start",!0);break;case"auto-end":a.value=w(n.useViewport?null:t.value,i.value,c.value,"end");break;case"auto-vertical-end":a.value=w(n.useViewport?null:t.value,i.value,c.value,"end",!0);break}switch(a.value){case"bottom":o.position.y=s.value.bottom,o.position.x=L+s.value.width/2,d=-50,p=0;break;case"bottom-start":o.position.y=s.value.bottom,o.position.x=b,d=0,p=0;break;case"bottom-end":o.position.y=s.value.bottom,o.position.x=s.value.right,d=-100,p=0;break;case"left-start":o.position.y=R,o.position.x=b,d=-100,p=0;break;case"left":o.position.y=F+s.value.height/2,o.position.x=b,p=-50,d=-100;break;case"left-end":o.position.y=s.value.bottom,o.position.x=b,p=-100,d=-100;break;case"top-start":o.position.y=R,o.position.x=b,p=-100,d=0;break;case"top":o.position.y=R,o.position.x=L+s.value.width/2,d=-50,p=-100;break;case"top-end":o.position.y=R,o.position.x=s.value.right,d=-100,p=-100;break;case"right-start":o.position.y=R,o.position.x=s.value.right,d=0,p=0;break;case"right":o.position.y=F+s.value.height/2,o.position.x=s.value.right,p=-50,d=0;break;case"right-end":o.position.y=s.value.bottom,o.position.x=s.value.right,p=-100,d=0;break}}else switch(a.value){case"bottom":o.position.y=r.value.bottom-u.value.height,o.position.x=r.value.left+r.value.width/2,d=-50;break;case"left-end":case"bottom-start":o.position.y=r.value.bottom-u.value.height,o.position.x=r.value.left;break;case"right-end":case"bottom-end":o.position.y=r.value.bottom-u.value.height,o.position.x=r.value.right-u.value.width;break;case"left":o.position.y=r.value.top+(r.value.height-u.value.height)/2,o.position.x=r.value.left;break;case"top-start":case"left-start":o.position.y=r.value.top,o.position.x=r.value.left;break;case"top":o.position.y=r.value.top,o.position.x=r.value.left+(r.value.width-u.value.width)/2;break;case"top-end":case"right-start":o.position.y=r.value.top,o.position.x=r.value.right-u.value.width;case"right":o.position.y=r.value.top+(r.value.height-u.value.height)/2,o.position.x=r.value.right-u.value.width;break}const k=O(u.value,o.position,d,p);if(o.position.x=k.x,o.position.y=k.y,k.x<r.value.left&&(o.position.x=r.value.left,d=0),k.x+u.value.width>r.value.right){const b=r.value.right-u.value.width;b>0&&(o.position.x=b),d=0}if(k.y<r.value.top&&(o.position.y=r.value.top,p=0),k.y+u.value.height>r.value.bottom){const b=r.value.bottom-u.value.height;b>0&&(o.position.y=b),p=0}i.value.style.top=`${o.position.y}px`,i.value.style.left=`${o.position.x}px`,i.value.style.position="fixed",i.value.style.display="flex",u.value=i.value.getBoundingClientRect(),n.callback&&n.callback(u,s,r,g,a)});return e.onUnmounted(()=>{l.value.disconnect()}),{float:o,rect:u,setPosition:h,position:g,actualPosition:a,openerRect:s,containerRect:r}};function x(n){const i=window.matchMedia(n),t=e.ref(i.matches);function c(s){t.value=s.matches}return e.onMounted(()=>{i.addEventListener("change",c)}),e.onUnmounted(()=>{i.removeEventListener("change",c)}),t}function S(n){return{isGreater(i){return x(`(min-width: ${n[i]})`)},isSmaller(i){return x(`(max-width: ${n[i]})`)},isInBetween(i,t){return x(`(min-width: ${n[i]}) and (max-width: ${n[t]})`)}}}function $(n,i,t){if(!n)throw new Error("A target component has to be provided.");if(!i)throw new Error("A callback has to be provided.");const c=s=>{!n.value||s.target===n.value||s.composedPath().includes(n.value)||typeof i=="function"&&i()};t&&e.watch(t,(s,r)=>{r&&r.removeEventListener("click",c),s==null||s.addEventListener("click",c)}),e.onMounted(()=>{t||document.addEventListener("click",c)}),e.onBeforeUnmount(()=>{if(t){t.value.removeEventListener("click",c);return}document.removeEventListener("click",c)})}function N(n,i){if(!n)throw new Error("A target component has to be provided.");if(!i||typeof i!="function")throw new Error("A callback has to be provided.");const t=c=>{i(c)};e.onMounted(()=>{n.value.addEventListener("keydown",t)}),e.onBeforeUnmount(()=>{n.value.removeEventListener("keydown",t)})}function M(n,i){if(!n||typeof n!="function")throw new Error("A callback has to be provided.");const t=c=>{n(c)};e.onMounted(()=>{if(!i){document.addEventListener("keyup",t);return}i.value.addEventListener("keyup",t)}),e.onBeforeUnmount(()=>{if(!i){document.removeEventListener("keyup",t);return}i.value.removeEventListener("keyup",t)})}const z=n=>{const i=e.ref(null),t=e.getCurrentInstance(),c=e.computed(()=>t==null?void 0:t.props.amount),s=e.ref(),r=l=>{if(l===null)return"";const a={minimumFractionDigits:n.minimumFractionDigits,useGrouping:!1};return n.maximumFractionDigits!==null&&(a.maximumFractionDigits=n.maximumFractionDigits),l.toLocaleString("it-IT",a)},g=l=>parseFloat(l.replace(/,/g,".")),u=l=>{if(!Number.isNaN(l)&&t){if(s.value=l,t.props.nullOnEmpty&&!l){t.emit("update:amount",null);return}t.emit("update:amount",typeof c.value=="number"?l:l==null?void 0:l.toString())}},o=l=>{setTimeout(()=>{i.value&&(i.value.value=l)},0)},f=l=>a=>{if(!i.value||!a.target)return;let{value:h}=l;h=h.replace(/[^0-9,.-]/g,""),o(h);const m=t!=null&&t.props.nullOnEmpty&&h===""?null:g(h);u(Number.isNaN(m)?0:m)},y=l=>{if(!i.value||!l.target)return;const a=l.target.value.replace(/,/g,".");let h;a===""&&(t!=null&&t.props.nullOnEmpty)?h=null:(h=g(a),Number.isNaN(h)&&(h=0));const m=r(h);o(m),u(g(m))};return e.watch(i,(l,a)=>{l&&(a&&(a==null||a.removeEventListener("input",f(l)),a==null||a.removeEventListener("blur",y)),l.addEventListener("input",f(l)),l.addEventListener("blur",y),t!=null&&t.props.amount&&(l.value=r(c.value)))}),e.watch(c,l=>{e.nextTick(()=>{if(!(!i.value||l===null||l===void 0)&&s.value!==l){const a=r(l);i.value.value=a,s.value=l}})}),{inputRef:i,parse:g,format:r,emitAmount:u,setValue:o}},D=e.defineComponent({__name:"FzFloating",props:{isOpen:{type:Boolean,default:!1},position:{default:"auto"},container:{},contentClass:{},openerClass:{},overrideContentClass:{type:Boolean},teleport:{type:Boolean,default:!1},useViewport:{type:Boolean}},emits:["fzfloating:setPosition"],setup(n,{emit:i}){const t=n,c=i,s=e.ref(null),r=e.ref(null),g=e.useSlots();let u=!1;const o={position:e.computed(()=>t.position),element:{domRef:r},container:{domRef:e.toRef(t.container||document.body)},useViewport:e.computed(()=>t.useViewport),callback(...a){c("fzfloating:setPosition",...a)}};g.opener&&(o.opener={domRef:s});const f=B(o),y=()=>{u||(u=!0,requestAnimationFrame(()=>{t.isOpen&&f.setPosition(),u=!1}))};e.watch(()=>t.position,()=>y()),e.watch(()=>t.isOpen,a=>{if(!a||!r.value){window.removeEventListener("scroll",y);return}window.addEventListener("scroll",y),r.value.style.top="0px",r.value.style.left="0px",r.value.style.transform="none",f.setPosition()}),e.onBeforeUnmount(()=>{window.removeEventListener("scroll",y)});const l=e.computed(()=>t.overrideContentClass?t.contentClass:["bg-core-white fixed p-4 z-10",t.contentClass]);return(a,h)=>(e.openBlock(),e.createElementBlock("div",null,[e.renderSlot(a.$slots,"opener-start"),e.createElementVNode("div",{ref_key:"opener",ref:s,class:"inline-flex"},[e.renderSlot(a.$slots,"opener",{isOpen:a.isOpen,floating:e.unref(f)})],512),e.renderSlot(a.$slots,"opener-end"),a.teleport?e.createCommentVNode("",!0):e.withDirectives((e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"content",ref:r,class:e.normalizeClass(["fz__floating__content",l.value])},[e.renderSlot(a.$slots,"default",{isOpen:a.isOpen,floating:e.unref(f)})],2)),[[e.vShow,a.$slots.default&&(!a.$slots.opener||a.$slots.opener&&a.isOpen)]]),a.teleport?(e.openBlock(),e.createBlock(e.Teleport,{key:1,to:"body"},[e.withDirectives(e.createElementVNode("div",{ref_key:"content",ref:r,class:e.normalizeClass(["fz__floating__content",l.value])},[e.renderSlot(a.$slots,"default",{isOpen:a.isOpen,floating:e.unref(f)})],2),[[e.vShow,a.$slots.default&&(!a.$slots.opener||a.$slots.opener&&a.isOpen)]])])):e.createCommentVNode("",!0)]))}});v.FzFloating=D,v.useBreakpoints=S,v.useClickOutside=$,v.useCurrency=z,v.useFloating=B,v.useKeyDown=N,v.useKeyUp=M,v.useMediaQuery=x,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});