vue-composable-ui 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,90 +1,95 @@
1
- import { ref as T, onBeforeMount as _, onMounted as F, watch as U, nextTick as P, onBeforeUnmount as j } from "vue";
2
- import { useHTMLElement as k } from "./composable-ui24.js";
3
- function G(y, z, {
1
+ import { ref as _, watch as F, nextTick as y, onBeforeMount as U, onMounted as V, onBeforeUnmount as j, toValue as z } from "vue";
2
+ import { useHTMLElement as A } from "./composable-ui24.js";
3
+ function G(L, B, {
4
4
  direction: c = "down",
5
5
  align: u = "left",
6
- position: L = "fixed",
7
- closeOnOutsideClick: A = !0,
8
- closeOnInsideClick: M = !1
6
+ position: C = "fixed",
7
+ closeOnOutsideClick: M = !0,
8
+ closeOnInsideClick: O = !1
9
9
  } = {}) {
10
- const s = T(!1);
10
+ const s = _(!1);
11
11
  function v() {
12
- const t = k(y);
13
- if (!t.value) throw new Error("Activator element is undefined");
14
- return t.value;
12
+ const e = A(L);
13
+ if (!e.value)
14
+ throw new Error(
15
+ "Activator element is undefined: " + z(L)
16
+ );
17
+ return e.value;
15
18
  }
16
19
  function $() {
17
- const t = k(z);
18
- if (!t.value) throw new Error("Popover element is undefined");
19
- return t.value;
20
+ const e = A(B);
21
+ if (!e.value)
22
+ throw new Error("Popover element is undefined: " + z(B));
23
+ return e.value;
20
24
  }
21
- function B({ focus: t = !0 } = {}) {
22
- s.value = !0, t && P(() => {
25
+ function P({ focus: e = !0 } = {}) {
26
+ s.value = !0, e && y(() => {
23
27
  $().focus();
24
28
  });
25
29
  }
26
- function E({ focus: t = !0 } = {}) {
27
- s.value = !1, t && v().focus();
30
+ function E({ focus: e = !0 } = {}) {
31
+ s.value = !1, e && v().focus();
28
32
  }
29
- function O(t) {
30
- s.value ? E(t) : B(t);
33
+ function R(e) {
34
+ s.value ? E(e) : P(e);
31
35
  }
32
36
  function h() {
33
37
  if (!s.value) return;
34
- const t = v(), r = $();
35
- r.style.position = L;
38
+ const e = v(), r = $();
39
+ r.style.position = C;
36
40
  const {
37
41
  top: f,
38
42
  right: l,
39
43
  bottom: w,
40
- left: p,
44
+ left: a,
41
45
  width: m,
42
46
  height: W
43
- } = t.getBoundingClientRect(), a = r.offsetHeight, d = r.offsetWidth, x = document.documentElement.clientHeight, b = document.documentElement.clientWidth;
47
+ } = e.getBoundingClientRect(), p = r.offsetHeight, d = r.offsetWidth, x = document.documentElement.clientHeight, b = document.documentElement.clientWidth;
44
48
  let i = c;
45
- c == "up" ? f - a < 0 && (i = "down") : c == "down" ? w + a > x && (i = "up") : c == "right" ? l + d > b && (i = "left") : c == "left" && p - d < 0 && (i = "right");
49
+ c == "up" ? f - p < 0 && (i = "down") : c == "down" ? w + p > x && (i = "up") : c == "right" ? l + d > b && (i = "left") : c == "left" && a - d < 0 && (i = "right");
46
50
  let o = u;
47
- u == "left" ? p + d > b && (o = "right") : u == "right" ? l - d < 0 && (o = "left") : u == "top" ? f + a > x && (o = "bottom") : u == "bottom" && w - a < 0 && (o = "top");
48
- const e = {
51
+ u == "left" ? a + d > b && (o = "right") : u == "right" ? l - d < 0 && (o = "left") : u == "top" ? f + p > x && (o = "bottom") : u == "bottom" && w - p < 0 && (o = "top");
52
+ const t = {
49
53
  top: "auto",
50
54
  bottom: "auto",
51
55
  left: "auto",
52
56
  right: "auto",
53
57
  width: "auto"
54
- }, n = L === "fixed";
55
- i == "up" ? e.bottom = `${W + (n ? x - w : 0)}px` : i == "down" ? e.top = `${W + (n ? f : 0)}px` : i == "right" ? e.left = `${m + (n ? p : 0)}px` : i == "left" && (e.right = `${m + (n ? b - l : 0)}px`), ["up", "down"].includes(i) ? o == "right" ? e.right = `${n ? b - l : 0}px` : o == "left" || o == "stretch" ? e.left = `${n ? p : 0}px` : o == "center" && (e.left = `${(n ? p : 0) - (d - m) / 2}px`) : o == "bottom" ? e.bottom = `${n ? x - w : 0}px` : o == "top" ? e.top = `${n ? f : 0}px` : o == "center" && (e.top = `${(n ? f : 0) - (a - W) / 2}px`), ["up", "down"].includes(i) && o === "stretch" && (e.width = m + "px");
56
- for (const C in e)
57
- r.style[C] = e[C];
58
+ }, n = C === "fixed";
59
+ i == "up" ? t.bottom = `${W + (n ? x - w : 0)}px` : i == "down" ? t.top = `${W + (n ? f : 0)}px` : i == "right" ? t.left = `${m + (n ? a : 0)}px` : i == "left" && (t.right = `${m + (n ? b - l : 0)}px`), ["up", "down"].includes(i) ? o == "right" ? t.right = `${n ? b - l : 0}px` : o == "left" || o == "stretch" ? t.left = `${n ? a : 0}px` : o == "center" && (t.left = `${(n ? a : 0) - (d - m) / 2}px`) : o == "bottom" ? t.bottom = `${n ? x - w : 0}px` : o == "top" ? t.top = `${n ? f : 0}px` : o == "center" && (t.top = `${(n ? f : 0) - (p - W) / 2}px`), ["up", "down"].includes(i) && o === "stretch" && (t.width = m + "px");
60
+ for (const k in t)
61
+ r.style[k] = t[k];
58
62
  }
59
- function R(t) {
60
- const r = t.target;
63
+ F(
64
+ s,
65
+ (e) => {
66
+ e && y(() => {
67
+ h();
68
+ });
69
+ },
70
+ { flush: "pre" }
71
+ );
72
+ function T(e) {
73
+ const r = e.target;
61
74
  if (!v().contains(r))
62
75
  try {
63
- $().contains(r) ? M && E() : A && (s.value = !1);
76
+ $().contains(r) ? O && E() : M && (s.value = !1);
64
77
  } catch {
65
78
  }
66
79
  }
67
80
  let H;
68
81
  const g = new AbortController();
69
- return _(() => {
82
+ return U(() => {
70
83
  H = new ResizeObserver(h);
71
- }), F(() => {
72
- U(
73
- s,
74
- (t) => {
75
- t && P(() => {
76
- h();
77
- });
78
- },
79
- { flush: "post" }
80
- ), window.addEventListener("resize", h, {
84
+ }), V(() => {
85
+ window.addEventListener("resize", h, {
81
86
  passive: !0,
82
87
  signal: g.signal
83
88
  }), window.addEventListener("scroll", h, {
84
89
  passive: !0,
85
90
  //capture: true,
86
91
  signal: g.signal
87
- }), window.addEventListener("click", R, {
92
+ }), window.addEventListener("click", T, {
88
93
  passive: !0,
89
94
  signal: g.signal
90
95
  }), H.observe(v());
@@ -92,9 +97,9 @@ function G(y, z, {
92
97
  g.abort(), H.disconnect();
93
98
  }), {
94
99
  isOpen: s,
95
- open: B,
100
+ open: P,
96
101
  close: E,
97
- toggle: O
102
+ toggle: R
98
103
  };
99
104
  }
100
105
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-composable-ui",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",