@fiscozen/composables 0.1.28 → 0.1.30

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,327 +1,333 @@
1
- import { ref as d, reactive as H, onUnmounted as q, nextTick as T, onMounted as B, watch as x, onBeforeUnmount as C, getCurrentInstance as U, computed as L, defineComponent as G, useSlots as K, toRef as Q, openBlock as $, createElementBlock as S, renderSlot as E, createElementVNode as M, unref as F, withDirectives as A, normalizeClass as D, vShow as W, createCommentVNode as I, createBlock as X, Teleport as Y } from "vue";
2
- const R = new DOMRect(0, 0, window.innerWidth, window.innerHeight), w = (o, e, i, u, s) => {
3
- let n = s ? "bottom" : "right", h = s ? "bottom-start" : "right-start";
4
- R.width = window.innerWidth, R.height = window.innerHeight, R.x = 0, R.y = 0;
5
- const l = o ? o.getBoundingClientRect() : R, t = e.getBoundingClientRect(), v = i.getBoundingClientRect(), r = (v.left - l.left - t.width) / l.width, c = (l.right - v.right - t.width) / l.width, a = (v.top - l.top - t.height) / l.height, y = (l.bottom - v.bottom - t.height) / l.height;
6
- let m = [
1
+ import { ref as m, reactive as te, onUnmounted as j, nextTick as V, onMounted as L, watch as k, onBeforeUnmount as O, getCurrentInstance as oe, computed as ee, defineComponent as ne, useSlots as ie, toRef as K, toRefs as ae, openBlock as B, createElementBlock as Q, renderSlot as x, createElementVNode as X, unref as F, withDirectives as Y, normalizeClass as J, vShow as Z, createCommentVNode as _, createBlock as le, Teleport as se } from "vue";
2
+ const E = new DOMRect(0, 0, window.innerWidth, window.innerHeight), w = (o, n, e, u, i) => {
3
+ let a = i ? "bottom" : "right", h = i ? "bottom-start" : "right-start";
4
+ E.width = window.innerWidth, E.height = window.innerHeight, E.x = 0, E.y = 0;
5
+ const r = o ? o.getBoundingClientRect() : E, t = n.getBoundingClientRect(), d = e.getBoundingClientRect(), g = (d.left - r.left - t.width) / r.width, l = (r.right - d.right - t.width) / r.width, v = (d.top - r.top - t.height) / r.height, s = (r.bottom - d.bottom - t.height) / r.height;
6
+ let c = [
7
7
  {
8
8
  key: "right",
9
- space: c
9
+ space: l
10
10
  },
11
11
  {
12
12
  key: "top",
13
- space: a
13
+ space: v
14
14
  },
15
15
  {
16
16
  key: "bottom",
17
- space: y
17
+ space: s
18
18
  },
19
19
  {
20
20
  key: "left",
21
- space: r
21
+ space: g
22
22
  }
23
23
  ].sort((p, f) => f.space - p.space);
24
- if (s && (m = m.filter((p) => p.key === "top" || p.key === "bottom")), n = m[0].key, !u)
25
- switch (n) {
24
+ if (i && (c = c.filter((p) => p.key === "top" || p.key === "bottom")), a = c[0].key, !u)
25
+ switch (a) {
26
26
  case "right":
27
27
  case "left":
28
- const p = (t.height - v.height) / 2;
29
- l.top > v.top - p && (u = "end"), l.bottom < v.top - p && (u = "start");
28
+ const p = (t.height - d.height) / 2;
29
+ r.top > d.top - p && (u = "end"), r.bottom < d.top - p && (u = "start");
30
30
  break;
31
31
  }
32
- return h = u ? `${n}-${u}` : n, h;
33
- }, J = (o, e, i, u) => ({
34
- x: e.x + o.width * i / 100,
35
- y: e.y + o.height * u / 100
36
- }), Z = (o) => {
37
- const e = d(null), i = d(null), u = d(null), s = d(), n = d(), h = d("auto"), l = d(), t = H({
32
+ return h = u ? `${a}-${u}` : a, h;
33
+ }, re = (o, n, e, u) => ({
34
+ x: n.x + o.width * e / 100,
35
+ y: n.y + o.height * u / 100
36
+ }), ue = (o) => {
37
+ const n = m(null), e = m(null), u = m(null), i = m(), a = m(), h = m("auto"), r = m(), t = te({
38
38
  position: { x: 0, y: 0 }
39
- }), v = {
39
+ }), d = {
40
40
  root: null,
41
41
  rootMargin: "0px",
42
42
  threshold: 1,
43
- ...o.element.intersectionOptions
44
- }, r = (m, p) => {
45
- }, c = d(new IntersectionObserver(r, v)), a = d(), y = () => T(() => {
46
- var N;
47
- if (a.value = o.position ? o.position.value : "auto", e.value = typeof o.element.domRef.value == "string" ? document.querySelector(o.element.domRef.value) : o.element.domRef.value, o.container ? (i.value = typeof o.container.domRef.value == "string" ? document.querySelector(o.container.domRef.value) : o.container.domRef.value, i.value ?? (i.value = document.body)) : i.value = document.body, !e.value)
43
+ ...o.element.value.intersectionOptions
44
+ }, g = (c, p) => {
45
+ }, l = m(new IntersectionObserver(g, d)), v = m(), s = () => V(() => {
46
+ var $, N, z, P, S, D, M, A, W, I, q, T, H;
47
+ if (v.value = o.position ? o.position.value : "auto", n.value = typeof o.element.value.domRef.value == "string" ? document.querySelector(o.element.value.domRef.value) : o.element.value.domRef.value, ($ = o.container) != null && $.value ? (e.value = typeof ((N = o.container.value) == null ? void 0 : N.domRef.value) == "string" ? document.querySelector(o.container.value.domRef.value) : (z = o.container.value) == null ? void 0 : z.domRef.value, e.value ?? (e.value = document.body)) : e.value = document.body, !n.value)
48
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 = e.value.getBoundingClientRect(), s.value = (N = u.value) == null ? void 0 : N.getBoundingClientRect(), n.value = i.value.getBoundingClientRect();
50
- const m = window.getComputedStyle(e.value);
51
- c.value.observe(e.value), c.value.observe(i.value);
49
+ (P = o.opener) != null && P.value && (u.value = typeof ((S = o.opener.value) == null ? void 0 : S.domRef.value) == "string" ? document.querySelector(o.opener.value.domRef.value) : (D = o.opener.value) == null ? void 0 : D.domRef.value), r.value = n.value.getBoundingClientRect(), i.value = (M = u.value) == null ? void 0 : M.getBoundingClientRect(), a.value = e.value.getBoundingClientRect();
50
+ const c = window.getComputedStyle(n.value);
51
+ l.value.observe(n.value), l.value.observe(e.value);
52
52
  let p = 0, f = 0;
53
- if (o.opener && u.value && s && s.value) {
54
- const g = s.value.left - parseFloat(m.marginLeft) - parseFloat(m.marginRight), z = s.value.left - parseFloat(m.marginLeft), k = s.value.top - parseFloat(m.marginTop) - parseFloat(m.marginBottom), P = s.value.top - parseFloat(m.marginTop);
55
- switch (a.value) {
53
+ if (o.opener && o.opener.value && u.value && i && i.value) {
54
+ const y = i.value.left - parseFloat(c.marginLeft) - parseFloat(c.marginRight), U = i.value.left - parseFloat(c.marginLeft), R = i.value.top - parseFloat(c.marginTop) - parseFloat(c.marginBottom), G = i.value.top - parseFloat(c.marginTop);
55
+ switch (v.value) {
56
56
  case "auto":
57
- a.value = w(
58
- o.useViewport ? null : i.value,
59
- e.value,
57
+ v.value = w(
58
+ (A = o.useViewport) != null && A.value ? null : e.value,
59
+ n.value,
60
60
  u.value
61
61
  );
62
62
  break;
63
63
  case "auto-vertical":
64
- a.value = w(
65
- o.useViewport ? null : i.value,
66
- e.value,
64
+ v.value = w(
65
+ (W = o.useViewport) != null && W.value ? null : e.value,
66
+ n.value,
67
67
  u.value,
68
68
  void 0,
69
69
  !0
70
70
  );
71
71
  break;
72
72
  case "auto-start":
73
- a.value = w(
74
- o.useViewport ? null : i.value,
75
- e.value,
73
+ v.value = w(
74
+ (I = o.useViewport) != null && I.value ? null : e.value,
75
+ n.value,
76
76
  u.value,
77
77
  "start"
78
78
  );
79
79
  break;
80
80
  case "auto-vertical-start":
81
- a.value = w(
82
- o.useViewport ? null : i.value,
83
- e.value,
81
+ v.value = w(
82
+ (q = o.useViewport) != null && q.value ? null : e.value,
83
+ n.value,
84
84
  u.value,
85
85
  "start",
86
86
  !0
87
87
  );
88
88
  break;
89
89
  case "auto-end":
90
- a.value = w(
91
- o.useViewport ? null : i.value,
92
- e.value,
90
+ v.value = w(
91
+ (T = o.useViewport) != null && T.value ? null : e.value,
92
+ n.value,
93
93
  u.value,
94
94
  "end"
95
95
  );
96
96
  break;
97
97
  case "auto-vertical-end":
98
- a.value = w(
99
- o.useViewport ? null : i.value,
100
- e.value,
98
+ v.value = w(
99
+ (H = o.useViewport) != null && H.value ? null : e.value,
100
+ n.value,
101
101
  u.value,
102
102
  "end",
103
103
  !0
104
104
  );
105
105
  break;
106
106
  }
107
- switch (a.value) {
107
+ switch (v.value) {
108
108
  case "bottom":
109
- t.position.y = s.value.bottom, t.position.x = z + s.value.width / 2, f = -50, p = 0;
109
+ t.position.y = i.value.bottom, t.position.x = U + i.value.width / 2, f = -50, p = 0;
110
110
  break;
111
111
  case "bottom-start":
112
- t.position.y = s.value.bottom, t.position.x = g, f = 0, p = 0;
112
+ t.position.y = i.value.bottom, t.position.x = y, f = 0, p = 0;
113
113
  break;
114
114
  case "bottom-end":
115
- t.position.y = s.value.bottom, t.position.x = s.value.right, f = -100, p = 0;
115
+ t.position.y = i.value.bottom, t.position.x = i.value.right, f = -100, p = 0;
116
116
  break;
117
117
  case "left-start":
118
- t.position.y = k, t.position.x = g, f = -100, p = 0;
118
+ t.position.y = R, t.position.x = y, f = -100, p = 0;
119
119
  break;
120
120
  case "left":
121
- t.position.y = P + s.value.height / 2, t.position.x = g, p = -50, f = -100;
121
+ t.position.y = G + i.value.height / 2, t.position.x = y, p = -50, f = -100;
122
122
  break;
123
123
  case "left-end":
124
- t.position.y = s.value.bottom, t.position.x = g, p = -100, f = -100;
124
+ t.position.y = i.value.bottom, t.position.x = y, p = -100, f = -100;
125
125
  break;
126
126
  case "top-start":
127
- t.position.y = k, t.position.x = g, p = -100, f = 0;
127
+ t.position.y = R, t.position.x = y, p = -100, f = 0;
128
128
  break;
129
129
  case "top":
130
- t.position.y = k, t.position.x = z + s.value.width / 2, f = -50, p = -100;
130
+ t.position.y = R, t.position.x = U + i.value.width / 2, f = -50, p = -100;
131
131
  break;
132
132
  case "top-end":
133
- t.position.y = k, t.position.x = s.value.right, f = -100, p = -100;
133
+ t.position.y = R, t.position.x = i.value.right, f = -100, p = -100;
134
134
  break;
135
135
  case "right-start":
136
- t.position.y = k, t.position.x = s.value.right, f = 0, p = 0;
136
+ t.position.y = R, t.position.x = i.value.right, f = 0, p = 0;
137
137
  break;
138
138
  case "right":
139
- t.position.y = P + s.value.height / 2, t.position.x = s.value.right, p = -50, f = 0;
139
+ t.position.y = G + i.value.height / 2, t.position.x = i.value.right, p = -50, f = 0;
140
140
  break;
141
141
  case "right-end":
142
- t.position.y = s.value.bottom, t.position.x = s.value.right, p = -100, f = 0;
142
+ t.position.y = i.value.bottom, t.position.x = i.value.right, p = -100, f = 0;
143
143
  break;
144
144
  }
145
145
  } else
146
- switch (a.value) {
146
+ switch (v.value) {
147
147
  case "bottom":
148
- t.position.y = n.value.bottom - l.value.height, t.position.x = n.value.left + n.value.width / 2, f = -50;
148
+ t.position.y = a.value.bottom - r.value.height, t.position.x = a.value.left + a.value.width / 2, f = -50;
149
149
  break;
150
150
  case "left-end":
151
151
  case "bottom-start":
152
- t.position.y = n.value.bottom - l.value.height, t.position.x = n.value.left;
152
+ t.position.y = a.value.bottom - r.value.height, t.position.x = a.value.left;
153
153
  break;
154
154
  case "right-end":
155
155
  case "bottom-end":
156
- t.position.y = n.value.bottom - l.value.height, t.position.x = n.value.right - l.value.width;
156
+ t.position.y = a.value.bottom - r.value.height, t.position.x = a.value.right - r.value.width;
157
157
  break;
158
158
  case "left":
159
- t.position.y = n.value.top + (n.value.height - l.value.height) / 2, t.position.x = n.value.left;
159
+ t.position.y = a.value.top + (a.value.height - r.value.height) / 2, t.position.x = a.value.left;
160
160
  break;
161
161
  case "top-start":
162
162
  case "left-start":
163
- t.position.y = n.value.top, t.position.x = n.value.left;
163
+ t.position.y = a.value.top, t.position.x = a.value.left;
164
164
  break;
165
165
  case "top":
166
- t.position.y = n.value.top, t.position.x = n.value.left + (n.value.width - l.value.width) / 2;
166
+ t.position.y = a.value.top, t.position.x = a.value.left + (a.value.width - r.value.width) / 2;
167
167
  break;
168
168
  case "top-end":
169
169
  case "right-start":
170
- t.position.y = n.value.top, t.position.x = n.value.right - l.value.width;
170
+ t.position.y = a.value.top, t.position.x = a.value.right - r.value.width;
171
171
  case "right":
172
- t.position.y = n.value.top + (n.value.height - l.value.height) / 2, t.position.x = n.value.right - l.value.width;
172
+ t.position.y = a.value.top + (a.value.height - r.value.height) / 2, t.position.x = a.value.right - r.value.width;
173
173
  break;
174
174
  }
175
- const b = J(l.value, t.position, f, p);
176
- if (t.position.x = b.x, t.position.y = b.y, b.x < n.value.left && (t.position.x = n.value.left, f = 0), b.x + l.value.width > n.value.right) {
177
- const g = n.value.right - l.value.width;
178
- g > 0 && (t.position.x = g), f = 0;
175
+ const b = re(r.value, t.position, f, p);
176
+ if (t.position.x = b.x, t.position.y = b.y, b.x < a.value.left && (t.position.x = a.value.left, f = 0), b.x + r.value.width > a.value.right) {
177
+ const y = a.value.right - r.value.width;
178
+ y > 0 && (t.position.x = y), f = 0;
179
179
  }
180
- if (b.y < n.value.top && (t.position.y = n.value.top, p = 0), b.y + l.value.height > n.value.bottom) {
181
- const g = n.value.bottom - l.value.height;
182
- g > 0 && (t.position.y = g), p = 0;
180
+ if (b.y < a.value.top && (t.position.y = a.value.top, p = 0), b.y + r.value.height > a.value.bottom) {
181
+ const y = a.value.bottom - r.value.height;
182
+ y > 0 && (t.position.y = y), p = 0;
183
183
  }
184
- e.value.style.top = `${t.position.y}px`, e.value.style.left = `${t.position.x}px`, e.value.style.position = "fixed", e.value.style.display = "flex", l.value = e.value.getBoundingClientRect(), o.callback && o.callback(l, s, n, h, a);
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", r.value = n.value.getBoundingClientRect(), o.callback && o.callback.value && o.callback.value(r, i, a, h, v);
185
185
  });
186
- return q(() => {
187
- c.value.disconnect();
186
+ return j(() => {
187
+ l.value.disconnect();
188
188
  }), {
189
189
  float: t,
190
- rect: l,
191
- setPosition: y,
190
+ rect: r,
191
+ setPosition: s,
192
192
  position: h,
193
- actualPosition: a,
194
- openerRect: s,
195
- containerRect: n
193
+ actualPosition: v,
194
+ openerRect: i,
195
+ containerRect: a
196
196
  };
197
197
  };
198
- function O(o) {
199
- const e = window.matchMedia(o), i = d(e.matches);
200
- function u(s) {
201
- i.value = s.matches;
198
+ function C(o) {
199
+ const n = window.matchMedia(o), e = m(n.matches);
200
+ function u(i) {
201
+ e.value = i.matches;
202
202
  }
203
- return B(() => {
204
- e.addEventListener("change", u);
205
- }), q(() => {
206
- e.removeEventListener("change", u);
207
- }), i;
203
+ return L(() => {
204
+ n.addEventListener("change", u);
205
+ }), j(() => {
206
+ n.removeEventListener("change", u);
207
+ }), e;
208
208
  }
209
- function j(o) {
209
+ function pe(o) {
210
210
  return {
211
- isGreater(e) {
212
- return O(`(min-width: ${o[e]})`);
211
+ isGreater(n) {
212
+ return C(`(min-width: ${o[n]})`);
213
213
  },
214
- isSmaller(e) {
215
- return O(`(max-width: ${o[e]})`);
214
+ isSmaller(n) {
215
+ return C(`(max-width: ${o[n]})`);
216
216
  },
217
- isInBetween(e, i) {
218
- return O(`(min-width: ${o[e]}) and (max-width: ${o[i]})`);
217
+ isInBetween(n, e) {
218
+ return C(`(min-width: ${o[n]}) and (max-width: ${o[e]})`);
219
219
  }
220
220
  };
221
221
  }
222
- function V(o, e, i) {
222
+ function ce(o, n, e) {
223
223
  if (!o)
224
224
  throw new Error("A target component has to be provided.");
225
- if (!e)
225
+ if (!n)
226
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 e == "function" && e();
227
+ const u = (i) => {
228
+ !o.value || i.target === o.value || i.composedPath().includes(o.value) || typeof n == "function" && n();
229
229
  };
230
- i && x(i, (s, n) => {
231
- n && n.removeEventListener("click", u), s == null || s.addEventListener("click", u);
232
- }), B(() => {
233
- i || document.addEventListener("click", u);
234
- }), C(() => {
235
- if (i) {
236
- i.value.removeEventListener("click", u);
230
+ e && k(e, (i, a) => {
231
+ a && a.removeEventListener("click", u), i == null || i.addEventListener("click", u);
232
+ }), L(() => {
233
+ e || document.addEventListener("click", u);
234
+ }), O(() => {
235
+ var i;
236
+ if (e) {
237
+ (i = e.value) == null || i.removeEventListener("click", u);
237
238
  return;
238
239
  }
239
240
  document.removeEventListener("click", u);
240
241
  });
241
242
  }
242
- function ee(o, e) {
243
+ function fe(o, n) {
243
244
  if (!o)
244
245
  throw new Error("A target component has to be provided.");
245
- if (!e || typeof e != "function")
246
+ if (!n || typeof n != "function")
246
247
  throw new Error("A callback has to be provided.");
247
- const i = (u) => {
248
- e(u);
248
+ const e = (u) => {
249
+ n(u);
249
250
  };
250
- B(() => {
251
- o.value.addEventListener("keydown", i);
252
- }), C(() => {
253
- o.value.removeEventListener("keydown", i);
251
+ L(() => {
252
+ o.value.addEventListener("keydown", e);
253
+ }), O(() => {
254
+ o.value.removeEventListener("keydown", e);
254
255
  });
255
256
  }
256
- function te(o, e) {
257
+ function de(o, n) {
257
258
  if (!o || typeof o != "function")
258
259
  throw new Error("A callback has to be provided.");
259
- const i = (u) => {
260
+ const e = (u) => {
260
261
  o(u);
261
262
  };
262
- B(() => {
263
- if (!e) {
264
- document.addEventListener("keyup", i);
263
+ L(() => {
264
+ if (!n) {
265
+ document.addEventListener("keyup", e);
265
266
  return;
266
267
  }
267
- e.value.addEventListener("keyup", i);
268
- }), C(() => {
269
- if (!e) {
270
- document.removeEventListener("keyup", i);
268
+ n.value.addEventListener("keyup", e);
269
+ }), O(() => {
270
+ if (!n) {
271
+ document.removeEventListener("keyup", e);
271
272
  return;
272
273
  }
273
- e.value.removeEventListener("keyup", i);
274
+ n.value.removeEventListener("keyup", e);
274
275
  });
275
276
  }
276
- const oe = () => {
277
- const o = d(null), e = U(), i = L(() => e == null ? void 0 : e.props.amount), u = d(), s = (r) => r === null ? "" : r.toLocaleString("it-IT", {
278
- minimumFractionDigits: 2,
279
- maximumFractionDigits: 2,
280
- useGrouping: !1
281
- }), n = (r) => parseFloat(r.replace(/,/g, ".")), h = (r) => {
282
- if (!Number.isNaN(r) && e) {
283
- if (u.value = r, e.props.nullOnEmpty && !r) {
277
+ const me = (o) => {
278
+ const n = m(null), e = oe(), u = ee(() => e == null ? void 0 : e.props.amount), i = m(), a = (l) => {
279
+ if (l === null)
280
+ return "";
281
+ const v = {
282
+ minimumFractionDigits: o.minimumFractionDigits,
283
+ useGrouping: !1
284
+ };
285
+ return o.maximumFractionDigits !== null && (v.maximumFractionDigits = o.maximumFractionDigits), l.toLocaleString("it-IT", v);
286
+ }, h = (l) => parseFloat(l.replace(/,/g, ".")), r = (l) => {
287
+ if (!Number.isNaN(l) && e) {
288
+ if (i.value = l, e.props.nullOnEmpty && !l) {
284
289
  e.emit("update:amount", null);
285
290
  return;
286
291
  }
287
- e.emit("update:amount", typeof i.value == "number" ? r : r == null ? void 0 : r.toString());
292
+ e.emit("update:amount", typeof u.value == "number" ? l : l == null ? void 0 : l.toString());
288
293
  }
289
- }, l = (r) => {
294
+ }, t = (l) => {
290
295
  setTimeout(() => {
291
- o.value && (o.value.value = r);
296
+ n.value && (n.value.value = l);
292
297
  }, 0);
293
- }, t = (r) => (c) => {
294
- if (!o.value || !c.target)
298
+ }, d = (l) => (v) => {
299
+ if (!n.value || !v.target)
295
300
  return;
296
- let { value: a } = r;
297
- a = a.replace(/[^0-9,.]/g, ""), l(a);
298
- const y = e != null && e.props.nullOnEmpty && a === "" ? null : n(a);
299
- h(Number.isNaN(y) ? 0 : y);
300
- }, v = (r) => {
301
- if (!o.value || !r.target)
301
+ let { value: s } = l;
302
+ s = s.replace(/[^0-9,.-]/g, ""), t(s);
303
+ const c = e != null && e.props.nullOnEmpty && s === "" ? null : h(s);
304
+ r(Number.isNaN(c) ? 0 : c);
305
+ }, g = (l) => {
306
+ if (!n.value || !l.target)
302
307
  return;
303
- let c = r.target.value.replace(/,/g, "."), a;
304
- c === "" && (e != null && e.props.nullOnEmpty) ? a = null : (a = n(c), Number.isNaN(a) && (a = 0));
305
- const y = s(a);
306
- l(y), h(n(y));
308
+ const v = l.target.value.replace(/,/g, ".");
309
+ let s;
310
+ v === "" && (e != null && e.props.nullOnEmpty) ? s = null : (s = h(v), Number.isNaN(s) && (s = 0));
311
+ const c = a(s);
312
+ t(c), r(h(c));
307
313
  };
308
- return x(o, (r, c) => {
309
- r && (c && (c == null || c.removeEventListener("input", t(r)), c == null || c.removeEventListener("blur", v)), r.addEventListener("input", t(r)), r.addEventListener("blur", v), e != null && e.props.amount && (r.value = s(i.value)));
310
- }), x(i, (r) => {
311
- T(() => {
312
- if (!(!o.value || r === null || r === void 0) && u.value !== r) {
313
- const c = s(r);
314
- o.value.value = c, u.value = r;
314
+ return k(n, (l, v) => {
315
+ l && (v && (v == null || v.removeEventListener("input", d(l)), v == null || v.removeEventListener("blur", g)), l.addEventListener("input", d(l)), l.addEventListener("blur", g), e != null && e.props.amount && (l.value = a(u.value)));
316
+ }), k(u, (l) => {
317
+ V(() => {
318
+ if (!(!n.value || l === null || l === void 0) && i.value !== l) {
319
+ const v = a(l);
320
+ n.value.value = v, i.value = l;
315
321
  }
316
322
  });
317
323
  }), {
318
- inputRef: o,
319
- parse: n,
320
- format: s,
321
- emitAmount: h,
322
- setValue: l
324
+ inputRef: n,
325
+ parse: h,
326
+ format: a,
327
+ emitAmount: r,
328
+ setValue: t
323
329
  };
324
- }, ne = /* @__PURE__ */ G({
330
+ }, he = /* @__PURE__ */ ne({
325
331
  __name: "FzFloating",
326
332
  props: {
327
333
  isOpen: { type: Boolean, default: !1 },
@@ -330,105 +336,116 @@ const oe = () => {
330
336
  contentClass: {},
331
337
  openerClass: {},
332
338
  overrideContentClass: { type: Boolean },
339
+ overrideOpener: {},
333
340
  teleport: { type: Boolean, default: !1 },
334
341
  useViewport: { type: Boolean }
335
342
  },
336
343
  emits: ["fzfloating:setPosition"],
337
- setup(o, { emit: e }) {
338
- const i = o, u = e, s = d(null), n = d(null), h = K();
339
- let l = !1;
344
+ setup(o, { emit: n }) {
345
+ const e = o, u = n, i = m(null), a = m(null), h = ie();
346
+ let r = !1;
340
347
  const t = {
341
- position: L(() => i.position),
348
+ position: e.position,
342
349
  element: {
343
350
  // @ts-ignore
344
- domRef: n
351
+ domRef: i
345
352
  },
346
353
  container: {
347
354
  // @ts-ignore
348
- domRef: Q(i.container || document.body)
355
+ domRef: K(e.container || document.body)
356
+ },
357
+ opener: {
358
+ domRef: K(null)
349
359
  },
350
- useViewport: L(() => i.useViewport),
351
- callback(...a) {
352
- u("fzfloating:setPosition", ...a);
360
+ useViewport: e.useViewport,
361
+ callback(...s) {
362
+ u("fzfloating:setPosition", ...s);
353
363
  }
354
- };
364
+ }, d = ae(t);
355
365
  h.opener && (t.opener = {
356
- domRef: s
366
+ domRef: a
357
367
  });
358
- const v = Z(t), r = () => {
359
- l || (l = !0, requestAnimationFrame(() => {
360
- i.isOpen && v.setPosition(), l = !1;
368
+ const g = ue(d), l = () => {
369
+ r || (r = !0, requestAnimationFrame(() => {
370
+ e.isOpen && g.setPosition(), r = !1;
361
371
  }));
362
372
  };
363
- x(
364
- () => i.position,
365
- () => r()
366
- ), x(
367
- () => i.isOpen,
368
- (a) => {
369
- if (!a || !n.value) {
370
- window.removeEventListener("scroll", r);
373
+ k(
374
+ () => e.position,
375
+ () => l()
376
+ ), k(
377
+ () => e.isOpen,
378
+ (s) => {
379
+ if (!s || !i.value) {
380
+ window.removeEventListener("scroll", l);
371
381
  return;
372
382
  }
373
- window.addEventListener("scroll", r), n.value.style.top = "0px", n.value.style.left = "0px", n.value.style.transform = "none", v.setPosition();
383
+ window.addEventListener("scroll", l), i.value.style.top = "0px", i.value.style.left = "0px", i.value.style.transform = "none", g.setPosition();
384
+ }
385
+ ), k(
386
+ () => e.overrideOpener,
387
+ (s) => {
388
+ s && d.opener && d.opener.value && (d.opener.value = {
389
+ domRef: s
390
+ });
374
391
  }
375
- ), C(() => {
376
- window.removeEventListener("scroll", r);
392
+ ), O(() => {
393
+ window.removeEventListener("scroll", l);
377
394
  });
378
- const c = L(() => i.overrideContentClass ? i.contentClass : ["bg-core-white fixed p-4 z-10", i.contentClass]);
379
- return (a, y) => ($(), S("div", null, [
380
- E(a.$slots, "opener-start"),
381
- M("div", {
395
+ const v = ee(() => e.overrideContentClass ? e.contentClass : ["bg-core-white fixed p-4 z-10", e.contentClass]);
396
+ return (s, c) => (B(), Q("div", null, [
397
+ x(s.$slots, "opener-start"),
398
+ X("div", {
382
399
  ref_key: "opener",
383
- ref: s,
400
+ ref: a,
384
401
  class: "inline-flex"
385
402
  }, [
386
- E(a.$slots, "opener", {
387
- isOpen: a.isOpen,
388
- floating: F(v)
403
+ x(s.$slots, "opener", {
404
+ isOpen: s.isOpen,
405
+ floating: F(g)
389
406
  })
390
407
  ], 512),
391
- E(a.$slots, "opener-end"),
392
- a.teleport ? I("", !0) : A(($(), S("div", {
408
+ x(s.$slots, "opener-end"),
409
+ s.teleport ? _("", !0) : Y((B(), Q("div", {
393
410
  key: 0,
394
411
  ref_key: "content",
395
- ref: n,
396
- class: D(["fz__floating__content", c.value])
412
+ ref: i,
413
+ class: J(["fz__floating__content", v.value])
397
414
  }, [
398
- E(a.$slots, "default", {
399
- isOpen: a.isOpen,
400
- floating: F(v)
415
+ x(s.$slots, "default", {
416
+ isOpen: s.isOpen,
417
+ floating: F(g)
401
418
  })
402
419
  ], 2)), [
403
- [W, a.$slots.default && (!a.$slots.opener || a.$slots.opener && a.isOpen)]
420
+ [Z, s.$slots.default && (!s.$slots.opener || s.$slots.opener && s.isOpen)]
404
421
  ]),
405
- a.teleport ? ($(), X(Y, {
422
+ s.teleport ? (B(), le(se, {
406
423
  key: 1,
407
424
  to: "body"
408
425
  }, [
409
- A(M("div", {
426
+ Y(X("div", {
410
427
  ref_key: "content",
411
- ref: n,
412
- class: D(["fz__floating__content", c.value])
428
+ ref: i,
429
+ class: J(["fz__floating__content", v.value])
413
430
  }, [
414
- E(a.$slots, "default", {
415
- isOpen: a.isOpen,
416
- floating: F(v)
431
+ x(s.$slots, "default", {
432
+ isOpen: s.isOpen,
433
+ floating: F(g)
417
434
  })
418
435
  ], 2), [
419
- [W, a.$slots.default && (!a.$slots.opener || a.$slots.opener && a.isOpen)]
436
+ [Z, s.$slots.default && (!s.$slots.opener || s.$slots.opener && s.isOpen)]
420
437
  ])
421
- ])) : I("", !0)
438
+ ])) : _("", !0)
422
439
  ]));
423
440
  }
424
441
  });
425
442
  export {
426
- ne as FzFloating,
427
- j as useBreakpoints,
428
- V as useClickOutside,
429
- oe as useCurrency,
430
- Z as useFloating,
431
- ee as useKeyDown,
432
- te as useKeyUp,
433
- O as useMediaQuery
443
+ he as FzFloating,
444
+ pe as useBreakpoints,
445
+ ce as useClickOutside,
446
+ me as useCurrency,
447
+ ue as useFloating,
448
+ fe as useKeyDown,
449
+ de as useKeyUp,
450
+ C as useMediaQuery
434
451
  };
@@ -1 +1 @@
1
- (function(m,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(m=typeof globalThis<"u"?globalThis:m||self,e(m.FzComposables={},m.Vue))})(this,function(m,e){"use strict";const E=new DOMRect(0,0,window.innerWidth,window.innerHeight),w=(n,t,a,c,s)=>{let i=s?"bottom":"right",v=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=t.getBoundingClientRect(),d=a.getBoundingClientRect(),l=(d.left-u.left-o.width)/u.width,f=(u.right-d.right-o.width)/u.width,r=(d.top-u.top-o.height)/u.height,b=(u.bottom-d.bottom-o.height)/u.height;let g=[{key:"right",space:f},{key:"top",space:r},{key:"bottom",space:b},{key:"left",space:l}].sort((p,h)=>h.space-p.space);if(s&&(g=g.filter(p=>p.key==="top"||p.key==="bottom")),i=g[0].key,!c)switch(i){case"right":case"left":const p=(o.height-d.height)/2;u.top>d.top-p&&(c="end"),u.bottom<d.top-p&&(c="start");break}return v=c?`${i}-${c}`:i,v},O=(n,t,a,c)=>({x:t.x+n.width*a/100,y:t.y+n.height*c/100}),x=n=>{const t=e.ref(null),a=e.ref(null),c=e.ref(null),s=e.ref(),i=e.ref(),v=e.ref("auto"),u=e.ref(),o=e.reactive({position:{x:0,y:0}}),d={root:null,rootMargin:"0px",threshold:1,...n.element.intersectionOptions},l=(g,p)=>{},f=e.ref(new IntersectionObserver(l,d)),r=e.ref(),b=()=>e.nextTick(()=>{var C;if(r.value=n.position?n.position.value:"auto",t.value=typeof n.element.domRef.value=="string"?document.querySelector(n.element.domRef.value):n.element.domRef.value,n.container?(a.value=typeof n.container.domRef.value=="string"?document.querySelector(n.container.domRef.value):n.container.domRef.value,a.value??(a.value=document.body)):a.value=document.body,!t.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=t.value.getBoundingClientRect(),s.value=(C=c.value)==null?void 0:C.getBoundingClientRect(),i.value=a.value.getBoundingClientRect();const g=window.getComputedStyle(t.value);f.value.observe(t.value),f.value.observe(a.value);let p=0,h=0;if(n.opener&&c.value&&s&&s.value){const y=s.value.left-parseFloat(g.marginLeft)-parseFloat(g.marginRight),L=s.value.left-parseFloat(g.marginLeft),R=s.value.top-parseFloat(g.marginTop)-parseFloat(g.marginBottom),F=s.value.top-parseFloat(g.marginTop);switch(r.value){case"auto":r.value=w(n.useViewport?null:a.value,t.value,c.value);break;case"auto-vertical":r.value=w(n.useViewport?null:a.value,t.value,c.value,void 0,!0);break;case"auto-start":r.value=w(n.useViewport?null:a.value,t.value,c.value,"start");break;case"auto-vertical-start":r.value=w(n.useViewport?null:a.value,t.value,c.value,"start",!0);break;case"auto-end":r.value=w(n.useViewport?null:a.value,t.value,c.value,"end");break;case"auto-vertical-end":r.value=w(n.useViewport?null:a.value,t.value,c.value,"end",!0);break}switch(r.value){case"bottom":o.position.y=s.value.bottom,o.position.x=L+s.value.width/2,h=-50,p=0;break;case"bottom-start":o.position.y=s.value.bottom,o.position.x=y,h=0,p=0;break;case"bottom-end":o.position.y=s.value.bottom,o.position.x=s.value.right,h=-100,p=0;break;case"left-start":o.position.y=R,o.position.x=y,h=-100,p=0;break;case"left":o.position.y=F+s.value.height/2,o.position.x=y,p=-50,h=-100;break;case"left-end":o.position.y=s.value.bottom,o.position.x=y,p=-100,h=-100;break;case"top-start":o.position.y=R,o.position.x=y,p=-100,h=0;break;case"top":o.position.y=R,o.position.x=L+s.value.width/2,h=-50,p=-100;break;case"top-end":o.position.y=R,o.position.x=s.value.right,h=-100,p=-100;break;case"right-start":o.position.y=R,o.position.x=s.value.right,h=0,p=0;break;case"right":o.position.y=F+s.value.height/2,o.position.x=s.value.right,p=-50,h=0;break;case"right-end":o.position.y=s.value.bottom,o.position.x=s.value.right,p=-100,h=0;break}}else switch(r.value){case"bottom":o.position.y=i.value.bottom-u.value.height,o.position.x=i.value.left+i.value.width/2,h=-50;break;case"left-end":case"bottom-start":o.position.y=i.value.bottom-u.value.height,o.position.x=i.value.left;break;case"right-end":case"bottom-end":o.position.y=i.value.bottom-u.value.height,o.position.x=i.value.right-u.value.width;break;case"left":o.position.y=i.value.top+(i.value.height-u.value.height)/2,o.position.x=i.value.left;break;case"top-start":case"left-start":o.position.y=i.value.top,o.position.x=i.value.left;break;case"top":o.position.y=i.value.top,o.position.x=i.value.left+(i.value.width-u.value.width)/2;break;case"top-end":case"right-start":o.position.y=i.value.top,o.position.x=i.value.right-u.value.width;case"right":o.position.y=i.value.top+(i.value.height-u.value.height)/2,o.position.x=i.value.right-u.value.width;break}const k=O(u.value,o.position,h,p);if(o.position.x=k.x,o.position.y=k.y,k.x<i.value.left&&(o.position.x=i.value.left,h=0),k.x+u.value.width>i.value.right){const y=i.value.right-u.value.width;y>0&&(o.position.x=y),h=0}if(k.y<i.value.top&&(o.position.y=i.value.top,p=0),k.y+u.value.height>i.value.bottom){const y=i.value.bottom-u.value.height;y>0&&(o.position.y=y),p=0}t.value.style.top=`${o.position.y}px`,t.value.style.left=`${o.position.x}px`,t.value.style.position="fixed",t.value.style.display="flex",u.value=t.value.getBoundingClientRect(),n.callback&&n.callback(u,s,i,v,r)});return e.onUnmounted(()=>{f.value.disconnect()}),{float:o,rect:u,setPosition:b,position:v,actualPosition:r,openerRect:s,containerRect:i}};function B(n){const t=window.matchMedia(n),a=e.ref(t.matches);function c(s){a.value=s.matches}return e.onMounted(()=>{t.addEventListener("change",c)}),e.onUnmounted(()=>{t.removeEventListener("change",c)}),a}function S(n){return{isGreater(t){return B(`(min-width: ${n[t]})`)},isSmaller(t){return B(`(max-width: ${n[t]})`)},isInBetween(t,a){return B(`(min-width: ${n[t]}) and (max-width: ${n[a]})`)}}}function $(n,t,a){if(!n)throw new Error("A target component has to be provided.");if(!t)throw new Error("A callback has to be provided.");const c=s=>{!n.value||s.target===n.value||s.composedPath().includes(n.value)||typeof t=="function"&&t()};a&&e.watch(a,(s,i)=>{i&&i.removeEventListener("click",c),s==null||s.addEventListener("click",c)}),e.onMounted(()=>{a||document.addEventListener("click",c)}),e.onBeforeUnmount(()=>{if(a){a.value.removeEventListener("click",c);return}document.removeEventListener("click",c)})}function N(n,t){if(!n)throw new Error("A target component has to be provided.");if(!t||typeof t!="function")throw new Error("A callback has to be provided.");const a=c=>{t(c)};e.onMounted(()=>{n.value.addEventListener("keydown",a)}),e.onBeforeUnmount(()=>{n.value.removeEventListener("keydown",a)})}function M(n,t){if(!n||typeof n!="function")throw new Error("A callback has to be provided.");const a=c=>{n(c)};e.onMounted(()=>{if(!t){document.addEventListener("keyup",a);return}t.value.addEventListener("keyup",a)}),e.onBeforeUnmount(()=>{if(!t){document.removeEventListener("keyup",a);return}t.value.removeEventListener("keyup",a)})}const z=()=>{const n=e.ref(null),t=e.getCurrentInstance(),a=e.computed(()=>t==null?void 0:t.props.amount),c=e.ref(),s=l=>l===null?"":l.toLocaleString("it-IT",{minimumFractionDigits:2,maximumFractionDigits:2,useGrouping:!1}),i=l=>parseFloat(l.replace(/,/g,".")),v=l=>{if(!Number.isNaN(l)&&t){if(c.value=l,t.props.nullOnEmpty&&!l){t.emit("update:amount",null);return}t.emit("update:amount",typeof a.value=="number"?l:l==null?void 0:l.toString())}},u=l=>{setTimeout(()=>{n.value&&(n.value.value=l)},0)},o=l=>f=>{if(!n.value||!f.target)return;let{value:r}=l;r=r.replace(/[^0-9,.]/g,""),u(r);const b=t!=null&&t.props.nullOnEmpty&&r===""?null:i(r);v(Number.isNaN(b)?0:b)},d=l=>{if(!n.value||!l.target)return;let f=l.target.value.replace(/,/g,"."),r;f===""&&(t!=null&&t.props.nullOnEmpty)?r=null:(r=i(f),Number.isNaN(r)&&(r=0));const b=s(r);u(b),v(i(b))};return e.watch(n,(l,f)=>{l&&(f&&(f==null||f.removeEventListener("input",o(l)),f==null||f.removeEventListener("blur",d)),l.addEventListener("input",o(l)),l.addEventListener("blur",d),t!=null&&t.props.amount&&(l.value=s(a.value)))}),e.watch(a,l=>{e.nextTick(()=>{if(!(!n.value||l===null||l===void 0)&&c.value!==l){const f=s(l);n.value.value=f,c.value=l}})}),{inputRef:n,parse:i,format:s,emitAmount:v,setValue:u}},P=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:t}){const a=n,c=t,s=e.ref(null),i=e.ref(null),v=e.useSlots();let u=!1;const o={position:e.computed(()=>a.position),element:{domRef:i},container:{domRef:e.toRef(a.container||document.body)},useViewport:e.computed(()=>a.useViewport),callback(...r){c("fzfloating:setPosition",...r)}};v.opener&&(o.opener={domRef:s});const d=x(o),l=()=>{u||(u=!0,requestAnimationFrame(()=>{a.isOpen&&d.setPosition(),u=!1}))};e.watch(()=>a.position,()=>l()),e.watch(()=>a.isOpen,r=>{if(!r||!i.value){window.removeEventListener("scroll",l);return}window.addEventListener("scroll",l),i.value.style.top="0px",i.value.style.left="0px",i.value.style.transform="none",d.setPosition()}),e.onBeforeUnmount(()=>{window.removeEventListener("scroll",l)});const f=e.computed(()=>a.overrideContentClass?a.contentClass:["bg-core-white fixed p-4 z-10",a.contentClass]);return(r,b)=>(e.openBlock(),e.createElementBlock("div",null,[e.renderSlot(r.$slots,"opener-start"),e.createElementVNode("div",{ref_key:"opener",ref:s,class:"inline-flex"},[e.renderSlot(r.$slots,"opener",{isOpen:r.isOpen,floating:e.unref(d)})],512),e.renderSlot(r.$slots,"opener-end"),r.teleport?e.createCommentVNode("",!0):e.withDirectives((e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"content",ref:i,class:e.normalizeClass(["fz__floating__content",f.value])},[e.renderSlot(r.$slots,"default",{isOpen:r.isOpen,floating:e.unref(d)})],2)),[[e.vShow,r.$slots.default&&(!r.$slots.opener||r.$slots.opener&&r.isOpen)]]),r.teleport?(e.openBlock(),e.createBlock(e.Teleport,{key:1,to:"body"},[e.withDirectives(e.createElementVNode("div",{ref_key:"content",ref:i,class:e.normalizeClass(["fz__floating__content",f.value])},[e.renderSlot(r.$slots,"default",{isOpen:r.isOpen,floating:e.unref(d)})],2),[[e.vShow,r.$slots.default&&(!r.$slots.opener||r.$slots.opener&&r.isOpen)]])])):e.createCommentVNode("",!0)]))}});m.FzFloating=P,m.useBreakpoints=S,m.useClickOutside=$,m.useCurrency=z,m.useFloating=x,m.useKeyDown=N,m.useKeyUp=M,m.useMediaQuery=B,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
1
+ (function(h,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(h=typeof globalThis<"u"?globalThis:h||self,e(h.FzComposables={},h.Vue))})(this,function(h,e){"use strict";const R=new DOMRect(0,0,window.innerWidth,window.innerHeight),w=(n,i,t,c,a)=>{let r=a?"bottom":"right",g=a?"bottom-start":"right-start";R.width=window.innerWidth,R.height=window.innerHeight,R.x=0,R.y=0;const u=n?n.getBoundingClientRect():R,o=i.getBoundingClientRect(),m=t.getBoundingClientRect(),y=(m.left-u.left-o.width)/u.width,l=(u.right-m.right-o.width)/u.width,p=(m.top-u.top-o.height)/u.height,s=(u.bottom-m.bottom-o.height)/u.height;let d=[{key:"right",space:l},{key:"top",space:p},{key:"bottom",space:s},{key:"left",space:y}].sort((f,v)=>v.space-f.space);if(a&&(d=d.filter(f=>f.key==="top"||f.key==="bottom")),r=d[0].key,!c)switch(r){case"right":case"left":const f=(o.height-m.height)/2;u.top>m.top-f&&(c="end"),u.bottom<m.top-f&&(c="start");break}return g=c?`${r}-${c}`:r,g},I=(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),a=e.ref(),r=e.ref(),g=e.ref("auto"),u=e.ref(),o=e.reactive({position:{x:0,y:0}}),m={root:null,rootMargin:"0px",threshold:1,...n.element.value.intersectionOptions},y=(d,f)=>{},l=e.ref(new IntersectionObserver(y,m)),p=e.ref(),s=()=>e.nextTick(()=>{var C,L,O,F,S,$,N,M,z,D,P,A,T;if(p.value=n.position?n.position.value:"auto",i.value=typeof n.element.value.domRef.value=="string"?document.querySelector(n.element.value.domRef.value):n.element.value.domRef.value,(C=n.container)!=null&&C.value?(t.value=typeof((L=n.container.value)==null?void 0:L.domRef.value)=="string"?document.querySelector(n.container.value.domRef.value):(O=n.container.value)==null?void 0:O.domRef.value,t.value??(t.value=document.body)):t.value=document.body,!i.value)throw new Error("missing reference element for floating behavior");(F=n.opener)!=null&&F.value&&(c.value=typeof((S=n.opener.value)==null?void 0:S.domRef.value)=="string"?document.querySelector(n.opener.value.domRef.value):($=n.opener.value)==null?void 0:$.domRef.value),u.value=i.value.getBoundingClientRect(),a.value=(N=c.value)==null?void 0:N.getBoundingClientRect(),r.value=t.value.getBoundingClientRect();const d=window.getComputedStyle(i.value);l.value.observe(i.value),l.value.observe(t.value);let f=0,v=0;if(n.opener&&n.opener.value&&c.value&&a&&a.value){const b=a.value.left-parseFloat(d.marginLeft)-parseFloat(d.marginRight),U=a.value.left-parseFloat(d.marginLeft),E=a.value.top-parseFloat(d.marginTop)-parseFloat(d.marginBottom),W=a.value.top-parseFloat(d.marginTop);switch(p.value){case"auto":p.value=w((M=n.useViewport)!=null&&M.value?null:t.value,i.value,c.value);break;case"auto-vertical":p.value=w((z=n.useViewport)!=null&&z.value?null:t.value,i.value,c.value,void 0,!0);break;case"auto-start":p.value=w((D=n.useViewport)!=null&&D.value?null:t.value,i.value,c.value,"start");break;case"auto-vertical-start":p.value=w((P=n.useViewport)!=null&&P.value?null:t.value,i.value,c.value,"start",!0);break;case"auto-end":p.value=w((A=n.useViewport)!=null&&A.value?null:t.value,i.value,c.value,"end");break;case"auto-vertical-end":p.value=w((T=n.useViewport)!=null&&T.value?null:t.value,i.value,c.value,"end",!0);break}switch(p.value){case"bottom":o.position.y=a.value.bottom,o.position.x=U+a.value.width/2,v=-50,f=0;break;case"bottom-start":o.position.y=a.value.bottom,o.position.x=b,v=0,f=0;break;case"bottom-end":o.position.y=a.value.bottom,o.position.x=a.value.right,v=-100,f=0;break;case"left-start":o.position.y=E,o.position.x=b,v=-100,f=0;break;case"left":o.position.y=W+a.value.height/2,o.position.x=b,f=-50,v=-100;break;case"left-end":o.position.y=a.value.bottom,o.position.x=b,f=-100,v=-100;break;case"top-start":o.position.y=E,o.position.x=b,f=-100,v=0;break;case"top":o.position.y=E,o.position.x=U+a.value.width/2,v=-50,f=-100;break;case"top-end":o.position.y=E,o.position.x=a.value.right,v=-100,f=-100;break;case"right-start":o.position.y=E,o.position.x=a.value.right,v=0,f=0;break;case"right":o.position.y=W+a.value.height/2,o.position.x=a.value.right,f=-50,v=0;break;case"right-end":o.position.y=a.value.bottom,o.position.x=a.value.right,f=-100,v=0;break}}else switch(p.value){case"bottom":o.position.y=r.value.bottom-u.value.height,o.position.x=r.value.left+r.value.width/2,v=-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=I(u.value,o.position,v,f);if(o.position.x=k.x,o.position.y=k.y,k.x<r.value.left&&(o.position.x=r.value.left,v=0),k.x+u.value.width>r.value.right){const b=r.value.right-u.value.width;b>0&&(o.position.x=b),v=0}if(k.y<r.value.top&&(o.position.y=r.value.top,f=0),k.y+u.value.height>r.value.bottom){const b=r.value.bottom-u.value.height;b>0&&(o.position.y=b),f=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.value&&n.callback.value(u,a,r,g,p)});return e.onUnmounted(()=>{l.value.disconnect()}),{float:o,rect:u,setPosition:s,position:g,actualPosition:p,openerRect:a,containerRect:r}};function x(n){const i=window.matchMedia(n),t=e.ref(i.matches);function c(a){t.value=a.matches}return e.onMounted(()=>{i.addEventListener("change",c)}),e.onUnmounted(()=>{i.removeEventListener("change",c)}),t}function q(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 K(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=a=>{!n.value||a.target===n.value||a.composedPath().includes(n.value)||typeof i=="function"&&i()};t&&e.watch(t,(a,r)=>{r&&r.removeEventListener("click",c),a==null||a.addEventListener("click",c)}),e.onMounted(()=>{t||document.addEventListener("click",c)}),e.onBeforeUnmount(()=>{var a;if(t){(a=t.value)==null||a.removeEventListener("click",c);return}document.removeEventListener("click",c)})}function H(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 Q(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 G=n=>{const i=e.ref(null),t=e.getCurrentInstance(),c=e.computed(()=>t==null?void 0:t.props.amount),a=e.ref(),r=l=>{if(l===null)return"";const p={minimumFractionDigits:n.minimumFractionDigits,useGrouping:!1};return n.maximumFractionDigits!==null&&(p.maximumFractionDigits=n.maximumFractionDigits),l.toLocaleString("it-IT",p)},g=l=>parseFloat(l.replace(/,/g,".")),u=l=>{if(!Number.isNaN(l)&&t){if(a.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)},m=l=>p=>{if(!i.value||!p.target)return;let{value:s}=l;s=s.replace(/[^0-9,.-]/g,""),o(s);const d=t!=null&&t.props.nullOnEmpty&&s===""?null:g(s);u(Number.isNaN(d)?0:d)},y=l=>{if(!i.value||!l.target)return;const p=l.target.value.replace(/,/g,".");let s;p===""&&(t!=null&&t.props.nullOnEmpty)?s=null:(s=g(p),Number.isNaN(s)&&(s=0));const d=r(s);o(d),u(g(d))};return e.watch(i,(l,p)=>{l&&(p&&(p==null||p.removeEventListener("input",m(l)),p==null||p.removeEventListener("blur",y)),l.addEventListener("input",m(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)&&a.value!==l){const p=r(l);i.value.value=p,a.value=l}})}),{inputRef:i,parse:g,format:r,emitAmount:u,setValue:o}},X=e.defineComponent({__name:"FzFloating",props:{isOpen:{type:Boolean,default:!1},position:{default:"auto"},container:{},contentClass:{},openerClass:{},overrideContentClass:{type:Boolean},overrideOpener:{},teleport:{type:Boolean,default:!1},useViewport:{type:Boolean}},emits:["fzfloating:setPosition"],setup(n,{emit:i}){const t=n,c=i,a=e.ref(null),r=e.ref(null),g=e.useSlots();let u=!1;const o={position:t.position,element:{domRef:a},container:{domRef:e.toRef(t.container||document.body)},opener:{domRef:e.toRef(null)},useViewport:t.useViewport,callback(...s){c("fzfloating:setPosition",...s)}},m=e.toRefs(o);g.opener&&(o.opener={domRef:r});const y=B(m),l=()=>{u||(u=!0,requestAnimationFrame(()=>{t.isOpen&&y.setPosition(),u=!1}))};e.watch(()=>t.position,()=>l()),e.watch(()=>t.isOpen,s=>{if(!s||!a.value){window.removeEventListener("scroll",l);return}window.addEventListener("scroll",l),a.value.style.top="0px",a.value.style.left="0px",a.value.style.transform="none",y.setPosition()}),e.watch(()=>t.overrideOpener,s=>{s&&m.opener&&m.opener.value&&(m.opener.value={domRef:s})}),e.onBeforeUnmount(()=>{window.removeEventListener("scroll",l)});const p=e.computed(()=>t.overrideContentClass?t.contentClass:["bg-core-white fixed p-4 z-10",t.contentClass]);return(s,d)=>(e.openBlock(),e.createElementBlock("div",null,[e.renderSlot(s.$slots,"opener-start"),e.createElementVNode("div",{ref_key:"opener",ref:r,class:"inline-flex"},[e.renderSlot(s.$slots,"opener",{isOpen:s.isOpen,floating:e.unref(y)})],512),e.renderSlot(s.$slots,"opener-end"),s.teleport?e.createCommentVNode("",!0):e.withDirectives((e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"content",ref:a,class:e.normalizeClass(["fz__floating__content",p.value])},[e.renderSlot(s.$slots,"default",{isOpen:s.isOpen,floating:e.unref(y)})],2)),[[e.vShow,s.$slots.default&&(!s.$slots.opener||s.$slots.opener&&s.isOpen)]]),s.teleport?(e.openBlock(),e.createBlock(e.Teleport,{key:1,to:"body"},[e.withDirectives(e.createElementVNode("div",{ref_key:"content",ref:a,class:e.normalizeClass(["fz__floating__content",p.value])},[e.renderSlot(s.$slots,"default",{isOpen:s.isOpen,floating:e.unref(y)})],2),[[e.vShow,s.$slots.default&&(!s.$slots.opener||s.$slots.opener&&s.isOpen)]])])):e.createCommentVNode("",!0)]))}});h.FzFloating=X,h.useBreakpoints=q,h.useClickOutside=K,h.useCurrency=G,h.useFloating=B,h.useKeyDown=H,h.useKeyUp=Q,h.useMediaQuery=x,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiscozen/composables",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
4
4
  "description": "Design System utility composables",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -25,8 +25,8 @@
25
25
  "vite": "^5.0.10",
26
26
  "vitest": "^1.2.0",
27
27
  "vue-tsc": "^1.8.25",
28
- "@fiscozen/prettier-config": "^0.1.0",
29
28
  "@fiscozen/eslint-config": "^0.1.0",
29
+ "@fiscozen/prettier-config": "^0.1.0",
30
30
  "@fiscozen/tsconfig": "^0.1.0"
31
31
  },
32
32
  "license": "ISC",
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { ref, useSlots, watch, toRef, computed, onMounted, onBeforeUnmount } from 'vue'
2
+ import { ref, useSlots, watch, toRef, computed, onBeforeUnmount, toRefs } from 'vue'
3
3
  import { useFloating } from './composables'
4
4
  import { FzFloatingProps, FzUseFloatingArgs } from './types'
5
5
 
@@ -11,15 +11,15 @@ const props = withDefaults(defineProps<FzFloatingProps>(), {
11
11
 
12
12
  const emits = defineEmits(['fzfloating:setPosition'])
13
13
 
14
- const opener = ref(null)
15
14
  const content = ref<HTMLElement | null>(null)
15
+ const opener = ref<HTMLElement | null>(null)
16
16
 
17
17
  const slots = useSlots()
18
18
 
19
19
  let scheduledAnimationFrame = false
20
20
 
21
21
  const useFloatingOpts: FzUseFloatingArgs = {
22
- position: computed(() => props.position),
22
+ position: props.position,
23
23
  element: {
24
24
  // @ts-ignore
25
25
  domRef: content
@@ -28,18 +28,23 @@ const useFloatingOpts: FzUseFloatingArgs = {
28
28
  // @ts-ignore
29
29
  domRef: toRef(props.container || document.body)
30
30
  },
31
- useViewport: computed(() => props.useViewport),
31
+ opener: {
32
+ domRef: toRef(null)
33
+ },
34
+ useViewport: props.useViewport,
32
35
  callback(...args) {
33
36
  emits('fzfloating:setPosition', ...args)
34
37
  }
35
38
  }
39
+
40
+ const dynamicOpts = toRefs(useFloatingOpts)
36
41
  if (slots.opener) {
37
42
  useFloatingOpts.opener = {
38
43
  domRef: opener
39
44
  }
40
45
  }
41
46
 
42
- const floating = useFloating(useFloatingOpts)
47
+ const floating = useFloating(dynamicOpts)
43
48
 
44
49
  const setPositionWhenOpen = () => {
45
50
  if (scheduledAnimationFrame) {
@@ -71,6 +76,19 @@ watch(
71
76
  floating.setPosition()
72
77
  }
73
78
  )
79
+ watch(
80
+ () => props.overrideOpener,
81
+ (newVal) => {
82
+ if (!newVal) {
83
+ return
84
+ }
85
+ if (dynamicOpts.opener && dynamicOpts.opener.value) {
86
+ dynamicOpts.opener.value = {
87
+ domRef: newVal
88
+ }
89
+ }
90
+ }
91
+ )
74
92
  onBeforeUnmount(() => {
75
93
  window.removeEventListener('scroll', setPositionWhenOpen)
76
94
  })
@@ -3,7 +3,7 @@
3
3
  exports[`FzFloating > should match snapshot 1`] = `
4
4
  "<div>
5
5
  <div class="inline-flex"><button>opener</button></div>
6
- <div class="fz__floating__content bg-core-white fixed z-10 p-4 bg-core-white fixed p-4 z-10">
6
+ <div class="fz__floating__content bg-core-white fixed p-4 z-10">
7
7
  <div>content</div>
8
8
  </div>
9
9
  <!--v-if-->
@@ -13,7 +13,7 @@ exports[`FzFloating > should match snapshot 1`] = `
13
13
  exports[`FzFloating > should match snapshot 2`] = `
14
14
  "<div>
15
15
  <div class="inline-flex"><button>opener</button></div>
16
- <div class="fz__floating__content bg-core-white fixed z-10 p-4 bg-core-white fixed p-4 z-10">
16
+ <div class="fz__floating__content bg-core-white fixed p-4 z-10">
17
17
  <div>content</div>
18
18
  </div>
19
19
  <!--v-if-->
@@ -23,7 +23,7 @@ exports[`FzFloating > should match snapshot 2`] = `
23
23
  exports[`FzFloating > should match snapshot 3`] = `
24
24
  "<div>
25
25
  <div class="inline-flex"><button>opener</button></div>
26
- <div class="fz__floating__content bg-core-white fixed z-10 p-4 bg-core-white fixed p-4 z-10">
26
+ <div class="fz__floating__content bg-core-white fixed p-4 z-10">
27
27
  <div>content</div>
28
28
  </div>
29
29
  <!--v-if-->
@@ -33,7 +33,7 @@ exports[`FzFloating > should match snapshot 3`] = `
33
33
  exports[`FzFloating > should match snapshot 4`] = `
34
34
  "<div>
35
35
  <div class="inline-flex"><button>opener</button></div>
36
- <div class="fz__floating__content bg-core-white fixed z-10 p-4 bg-core-white fixed p-4 z-10">
36
+ <div class="fz__floating__content bg-core-white fixed p-4 z-10">
37
37
  <div>content</div>
38
38
  </div>
39
39
  <!--v-if-->
@@ -43,7 +43,7 @@ exports[`FzFloating > should match snapshot 4`] = `
43
43
  exports[`FzFloating > should match snapshot 5`] = `
44
44
  "<div>
45
45
  <div class="inline-flex"><button>opener</button></div>
46
- <div class="fz__floating__content bg-core-white fixed z-10 p-4 bg-core-white fixed p-4 z-10">
46
+ <div class="fz__floating__content bg-core-white fixed p-4 z-10">
47
47
  <div>content</div>
48
48
  </div>
49
49
  <!--v-if-->
@@ -53,7 +53,7 @@ exports[`FzFloating > should match snapshot 5`] = `
53
53
  exports[`FzFloating > should match snapshot 6`] = `
54
54
  "<div>
55
55
  <div class="inline-flex"><button>opener</button></div>
56
- <div class="fz__floating__content bg-core-white fixed z-10 p-4 bg-core-white fixed p-4 z-10">
56
+ <div class="fz__floating__content bg-core-white fixed p-4 z-10">
57
57
  <div>content</div>
58
58
  </div>
59
59
  <!--v-if-->
@@ -63,7 +63,7 @@ exports[`FzFloating > should match snapshot 6`] = `
63
63
  exports[`FzFloating > should match snapshot 7`] = `
64
64
  "<div>
65
65
  <div class="inline-flex"><button>opener</button></div>
66
- <div class="fz__floating__content bg-core-white fixed z-10 p-4 bg-core-white fixed p-4 z-10">
66
+ <div class="fz__floating__content bg-core-white fixed p-4 z-10">
67
67
  <div>content</div>
68
68
  </div>
69
69
  <!--v-if-->
@@ -73,7 +73,7 @@ exports[`FzFloating > should match snapshot 7`] = `
73
73
  exports[`FzFloating > should match snapshot 8`] = `
74
74
  "<div>
75
75
  <div class="inline-flex"><button>opener</button></div>
76
- <div class="fz__floating__content bg-core-white fixed z-10 p-4 bg-core-white fixed p-4 z-10">
76
+ <div class="fz__floating__content bg-core-white fixed p-4 z-10">
77
77
  <div>content</div>
78
78
  </div>
79
79
  <!--v-if-->
@@ -83,7 +83,7 @@ exports[`FzFloating > should match snapshot 8`] = `
83
83
  exports[`FzFloating > should match snapshot 9`] = `
84
84
  "<div>
85
85
  <div class="inline-flex"><button>opener</button></div>
86
- <div class="fz__floating__content bg-core-white fixed z-10 p-4 bg-core-white fixed p-4 z-10">
86
+ <div class="fz__floating__content bg-core-white fixed p-4 z-10">
87
87
  <div>content</div>
88
88
  </div>
89
89
  <!--v-if-->
@@ -93,7 +93,7 @@ exports[`FzFloating > should match snapshot 9`] = `
93
93
  exports[`FzFloating > should match snapshot 10`] = `
94
94
  "<div>
95
95
  <div class="inline-flex"><button>opener</button></div>
96
- <div class="fz__floating__content bg-core-white fixed z-10 p-4 bg-core-white fixed p-4 z-10">
96
+ <div class="fz__floating__content bg-core-white fixed p-4 z-10">
97
97
  <div>content</div>
98
98
  </div>
99
99
  <!--v-if-->
@@ -103,7 +103,7 @@ exports[`FzFloating > should match snapshot 10`] = `
103
103
  exports[`FzFloating > should match snapshot 11`] = `
104
104
  "<div>
105
105
  <div class="inline-flex"><button>opener</button></div>
106
- <div class="fz__floating__content bg-core-white fixed z-10 p-4 bg-core-white fixed p-4 z-10">
106
+ <div class="fz__floating__content bg-core-white fixed p-4 z-10">
107
107
  <div>content</div>
108
108
  </div>
109
109
  <!--v-if-->
@@ -113,7 +113,7 @@ exports[`FzFloating > should match snapshot 11`] = `
113
113
  exports[`FzFloating > should match snapshot 12`] = `
114
114
  "<div>
115
115
  <div class="inline-flex"><button>opener</button></div>
116
- <div class="fz__floating__content bg-core-white fixed z-10 p-4 bg-core-white fixed p-4 z-10">
116
+ <div class="fz__floating__content bg-core-white fixed p-4 z-10">
117
117
  <div>content</div>
118
118
  </div>
119
119
  <!--v-if-->
@@ -14,8 +14,8 @@ export const useCurrency = (options: FzUseCurrencyOptions) => {
14
14
  }
15
15
  const safeOptions: Intl.NumberFormatOptions = {
16
16
  minimumFractionDigits: options.minimumFractionDigits,
17
- useGrouping: false
18
- };
17
+ useGrouping: options.useGrouping || false
18
+ }
19
19
  if (options.maximumFractionDigits !== null) {
20
20
  safeOptions.maximumFractionDigits = options.maximumFractionDigits
21
21
  }
@@ -1,9 +1,9 @@
1
1
  import { FzFloatingPosition, FzRect, FzUseFloatingArgs } from '../types'
2
- import { ref, reactive, onUnmounted, Ref, nextTick } from 'vue'
2
+ import { ref, reactive, onUnmounted, Ref, nextTick, ToRefs } from 'vue'
3
3
  import { calcRealPos, getHighestAvailableSpacePos } from '../utils'
4
4
 
5
5
  export const useFloating = (
6
- args: FzUseFloatingArgs
6
+ args: ToRefs<FzUseFloatingArgs>
7
7
  ): {
8
8
  float: FzRect
9
9
  rect: Ref<DOMRect | undefined>
@@ -27,7 +27,7 @@ export const useFloating = (
27
27
  root: null,
28
28
  rootMargin: '0px',
29
29
  threshold: 1.0,
30
- ...args.element.intersectionOptions
30
+ ...args.element.value.intersectionOptions
31
31
  }
32
32
 
33
33
  const handleIntersect = (
@@ -42,17 +42,17 @@ export const useFloating = (
42
42
  nextTick(() => {
43
43
  actualPosition.value = args.position ? args.position.value : 'auto'
44
44
  safeElementDomRef.value = (
45
- typeof args.element.domRef.value === 'string'
46
- ? document.querySelector(args.element.domRef.value)
47
- : args.element.domRef.value
45
+ typeof args.element.value.domRef.value === 'string'
46
+ ? document.querySelector(args.element.value.domRef.value)
47
+ : args.element.value.domRef.value
48
48
  ) as HTMLElement
49
- if (!args.container) {
49
+ if (!args.container?.value) {
50
50
  safeContainerDomRef.value = document.body
51
51
  } else {
52
52
  safeContainerDomRef.value = (
53
- typeof args.container.domRef.value === 'string'
54
- ? document.querySelector(args.container.domRef.value)
55
- : args.container.domRef.value
53
+ typeof args.container.value?.domRef.value === 'string'
54
+ ? document.querySelector(args.container.value.domRef.value)
55
+ : args.container.value?.domRef.value
56
56
  ) as HTMLElement
57
57
  safeContainerDomRef.value ??= document.body
58
58
  }
@@ -61,11 +61,11 @@ export const useFloating = (
61
61
  throw new Error('missing reference element for floating behavior')
62
62
  }
63
63
 
64
- if (args.opener) {
64
+ if (args.opener?.value) {
65
65
  safeOpenerDomRef.value = (
66
- typeof args.opener.domRef.value === 'string'
67
- ? document.querySelector(args.opener.domRef.value)
68
- : args.opener.domRef.value
66
+ typeof args.opener.value?.domRef.value === 'string'
67
+ ? document.querySelector(args.opener.value.domRef.value)
68
+ : args.opener.value?.domRef.value
69
69
  ) as HTMLElement
70
70
  }
71
71
 
@@ -82,7 +82,7 @@ export const useFloating = (
82
82
  let translateY = 0
83
83
  let translateX = 0
84
84
 
85
- if (args.opener && safeOpenerDomRef.value && openerRect && openerRect.value) {
85
+ if (args.opener?.value && safeOpenerDomRef.value && openerRect?.value) {
86
86
  const leftWithoutXMargin =
87
87
  openerRect.value.left - parseFloat(elStyle.marginLeft) - parseFloat(elStyle.marginRight)
88
88
  const leftWithoutLeftMargin = openerRect.value.left - parseFloat(elStyle.marginLeft)
@@ -93,14 +93,14 @@ export const useFloating = (
93
93
  switch (actualPosition.value) {
94
94
  case 'auto':
95
95
  actualPosition.value = getHighestAvailableSpacePos(
96
- args.useViewport ? null : (safeContainerDomRef.value as HTMLElement),
96
+ args.useViewport?.value ? null : (safeContainerDomRef.value as HTMLElement),
97
97
  safeElementDomRef.value as HTMLElement,
98
98
  safeOpenerDomRef.value as HTMLElement
99
99
  )
100
100
  break
101
101
  case 'auto-vertical':
102
102
  actualPosition.value = getHighestAvailableSpacePos(
103
- args.useViewport ? null : (safeContainerDomRef.value as HTMLElement),
103
+ args.useViewport?.value ? null : (safeContainerDomRef.value as HTMLElement),
104
104
  safeElementDomRef.value as HTMLElement,
105
105
  safeOpenerDomRef.value as HTMLElement,
106
106
  undefined,
@@ -109,7 +109,7 @@ export const useFloating = (
109
109
  break
110
110
  case 'auto-start':
111
111
  actualPosition.value = getHighestAvailableSpacePos(
112
- args.useViewport ? null : (safeContainerDomRef.value as HTMLElement),
112
+ args.useViewport?.value ? null : (safeContainerDomRef.value as HTMLElement),
113
113
  safeElementDomRef.value as HTMLElement,
114
114
  safeOpenerDomRef.value as HTMLElement,
115
115
  'start'
@@ -117,7 +117,7 @@ export const useFloating = (
117
117
  break
118
118
  case 'auto-vertical-start':
119
119
  actualPosition.value = getHighestAvailableSpacePos(
120
- args.useViewport ? null : (safeContainerDomRef.value as HTMLElement),
120
+ args.useViewport?.value ? null : (safeContainerDomRef.value as HTMLElement),
121
121
  safeElementDomRef.value as HTMLElement,
122
122
  safeOpenerDomRef.value as HTMLElement,
123
123
  'start',
@@ -126,7 +126,7 @@ export const useFloating = (
126
126
  break
127
127
  case 'auto-end':
128
128
  actualPosition.value = getHighestAvailableSpacePos(
129
- args.useViewport ? null : (safeContainerDomRef.value as HTMLElement),
129
+ args.useViewport?.value ? null : (safeContainerDomRef.value as HTMLElement),
130
130
  safeElementDomRef.value as HTMLElement,
131
131
  safeOpenerDomRef.value as HTMLElement,
132
132
  'end'
@@ -134,7 +134,7 @@ export const useFloating = (
134
134
  break
135
135
  case 'auto-vertical-end':
136
136
  actualPosition.value = getHighestAvailableSpacePos(
137
- args.useViewport ? null : (safeContainerDomRef.value as HTMLElement),
137
+ args.useViewport?.value ? null : (safeContainerDomRef.value as HTMLElement),
138
138
  safeElementDomRef.value as HTMLElement,
139
139
  safeOpenerDomRef.value as HTMLElement,
140
140
  'end',
@@ -304,7 +304,9 @@ export const useFloating = (
304
304
 
305
305
  rect.value = safeElementDomRef.value.getBoundingClientRect()
306
306
 
307
- args.callback && args.callback(rect, openerRect, containerRect, position, actualPosition)
307
+ if (args.callback?.value) {
308
+ args.callback.value(rect, openerRect, containerRect, position, actualPosition)
309
+ }
308
310
  })
309
311
 
310
312
  onUnmounted(() => {
package/src/types.ts CHANGED
@@ -19,6 +19,7 @@ export interface FzFloatingProps {
19
19
  | Record<string, boolean | undefined>
20
20
  | Array<string | Record<string, boolean | undefined>>
21
21
  overrideContentClass?: boolean
22
+ overrideOpener?: Ref<HTMLElement>
22
23
  teleport?: boolean
23
24
  useViewport?: boolean
24
25
  }
@@ -39,9 +40,9 @@ export interface FzFloatElement {
39
40
  export interface FzUseFloatingArgs {
40
41
  element: FzFloatElement
41
42
  container?: FzFloatElement
42
- opener?: FzFloatElement
43
- position?: Ref<FzFloatingPosition>
44
- useViewport?: Ref<boolean>
43
+ opener: FzFloatElement
44
+ position?: FzFloatingPosition
45
+ useViewport?: boolean
45
46
  callback?: (
46
47
  rect: Ref<DOMRect | undefined>,
47
48
  openerRect: Ref<DOMRect | undefined>,
@@ -52,6 +53,7 @@ export interface FzUseFloatingArgs {
52
53
  }
53
54
 
54
55
  export interface FzUseCurrencyOptions {
55
- minimumFractionDigits: number,
56
- maximumFractionDigits: number|null,
57
- }
56
+ minimumFractionDigits: number
57
+ maximumFractionDigits: number | null
58
+ useGrouping?: boolean
59
+ }