vue-composable-ui 1.0.3 → 1.0.5

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.
@@ -8,7 +8,7 @@ const ae = /* @__PURE__ */ B({
8
8
  inheritAttrs: !1,
9
9
  __name: "combobox",
10
10
  props: /* @__PURE__ */ H({
11
- displayValue: { type: Function, default: (e) => Array.isArray(e) ? e.map((t) => t.toString()).join(", ") : e.toString() },
11
+ displayValue: { type: Function, default: (e) => e && Array.isArray(e) ? e.map((o) => o.toString()).join(", ") : e.toString() || void 0 },
12
12
  id: {},
13
13
  activatorId: {},
14
14
  name: {},
@@ -19,7 +19,7 @@ const ae = /* @__PURE__ */ B({
19
19
  }),
20
20
  emits: ["update:modelValue"],
21
21
  setup(e) {
22
- const t = e, I = p(() => u.value ? l.value.map((a) => t.formValue(a)) : t.formValue(l.value)), l = T(e, "modelValue"), i = t.id ?? j(), y = t.activatorId ?? i, n = `${i}-popover`, { isOpen: o, toggle: E, open: s, close: c } = z(
22
+ const o = e, I = p(() => u.value ? l.value.map((a) => o.formValue(a)) : o.formValue(l.value)), l = T(e, "modelValue"), i = o.id ?? j(), y = o.activatorId ?? i, n = `${i}-popover`, { isOpen: t, toggle: E, open: s, close: c } = z(
23
23
  `#${y}`,
24
24
  `#${n}`,
25
25
  {
@@ -39,7 +39,7 @@ const ae = /* @__PURE__ */ B({
39
39
  activateLastItem: V,
40
40
  activateNextItem: C,
41
41
  activatePrevItem: M
42
- } = G(l), g = p(() => t.displayValue(l.value));
42
+ } = G(l), g = p(() => o.displayValue(l.value));
43
43
  N(w, () => {
44
44
  !f.value && w.value.length && (S({ focus: !1 }), f.value || d({ focus: !1 }));
45
45
  });
@@ -47,7 +47,7 @@ const ae = /* @__PURE__ */ B({
47
47
  q(`#${y}`).value?.focus();
48
48
  }
49
49
  function D(a) {
50
- if (o.value)
50
+ if (t.value)
51
51
  switch (a.code) {
52
52
  case "Space":
53
53
  m(), u.value || c({ focus: !0 });
@@ -99,8 +99,8 @@ const ae = /* @__PURE__ */ B({
99
99
  onkeydown: D,
100
100
  onclick: () => s({ focus: !1 }),
101
101
  id: i,
102
- "aria-controls": o.value ? n : void 0,
103
- "aria-expanded": o.value,
102
+ "aria-controls": t.value ? n : void 0,
103
+ "aria-expanded": t.value,
104
104
  "aria-activedescendant": f.value?.element.value?.id,
105
105
  "aria-haspopup": "listbox",
106
106
  role: "combobox"
@@ -108,7 +108,7 @@ const ae = /* @__PURE__ */ B({
108
108
  return P(J, {
109
109
  displayValue: g,
110
110
  popoverId: n,
111
- isOpen: o,
111
+ isOpen: t,
112
112
  open: s,
113
113
  close: c,
114
114
  focus: O,
@@ -127,7 +127,7 @@ const ae = /* @__PURE__ */ B({
127
127
  ], 64)) : U("", !0),
128
128
  K(a.$slots, "default", {
129
129
  popoverId: n,
130
- isOpen: k(o),
130
+ isOpen: k(t),
131
131
  toggle: () => k(E)(),
132
132
  displayValue: g.value,
133
133
  attrs: x.value
@@ -16,7 +16,7 @@ import { _ as k } from "./tooltip.vue_vue_type_script_setup_true_lang-D4uAZmQb.j
16
16
  import { _ as w } from "./menu.vue_vue_type_script_setup_true_lang-Ci7q2rOg.js";
17
17
  import { _ as z } from "./menuItems.vue_vue_type_script_setup_true_lang-p9vftREy.js";
18
18
  import { _ as B } from "./menuItem.vue_vue_type_script_setup_true_lang-ezPw3j-i.js";
19
- import { _ as J } from "./combobox.vue_vue_type_script_setup_true_lang-DpM6lN_3.js";
19
+ import { _ as J } from "./combobox.vue_vue_type_script_setup_true_lang-CAbgDlD9.js";
20
20
  import { _ as N } from "./comboboxInput.vue_vue_type_script_setup_true_lang-DzRfJ5ke.js";
21
21
  import { _ as R } from "./comboboxOptions.vue_vue_type_script_setup_true_lang-Doy6MfEQ.js";
22
22
  import { _ as U } from "./comboboxOption.vue_vue_type_script_setup_true_lang-DPEArk3M.js";
@@ -1,4 +1,4 @@
1
- import { _ as f } from "./combobox.vue_vue_type_script_setup_true_lang-DpM6lN_3.js";
1
+ import { _ as f } from "./combobox.vue_vue_type_script_setup_true_lang-CAbgDlD9.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -1,80 +1,83 @@
1
- import { ref as _, watch as M, nextTick as k, onMounted as F, onBeforeUnmount as U } from "vue";
2
- import { useHTMLElement as y } from "./composable-ui23.js";
3
- function D(z, A, {
1
+ import { ref as T, watch as _, nextTick as P, onBeforeMount as F, onMounted as U, onBeforeUnmount as j } from "vue";
2
+ import { useHTMLElement as k } from "./composable-ui23.js";
3
+ function G(y, z, {
4
4
  direction: c = "down",
5
- align: p = "left",
6
- position: W = "fixed",
7
- closeOnOutsideClick: B = !0,
8
- closeOnInsideClick: O = !1
5
+ align: u = "left",
6
+ position: L = "fixed",
7
+ closeOnOutsideClick: A = !0,
8
+ closeOnInsideClick: M = !1
9
9
  } = {}) {
10
- const s = _(!1);
10
+ const s = T(!1);
11
11
  function v() {
12
- const t = y(z);
13
- if (!t.value) throw new Error("Activator element is undefined");
14
- return t.value;
12
+ const e = k(y);
13
+ if (!e.value) throw new Error("Activator element is undefined");
14
+ return e.value;
15
15
  }
16
16
  function $() {
17
- const t = y(A);
18
- if (!t.value) throw new Error("Popover element is undefined");
19
- return t.value;
17
+ const e = k(z);
18
+ if (!e.value) throw new Error("Popover element is undefined");
19
+ return e.value;
20
20
  }
21
- function L({ focus: t = !0 } = {}) {
22
- s.value = !0, t && k(() => {
21
+ function B({ focus: e = !0 } = {}) {
22
+ s.value = !0, e && P(() => {
23
23
  $().focus();
24
24
  });
25
25
  }
26
- function E({ focus: t = !0 } = {}) {
27
- s.value = !1, t && v().focus();
26
+ function E({ focus: e = !0 } = {}) {
27
+ s.value = !1, e && v().focus();
28
28
  }
29
- function R(t) {
30
- s.value ? E(t) : L(t);
29
+ function O(e) {
30
+ s.value ? E(e) : B(e);
31
31
  }
32
32
  function h() {
33
33
  if (!s.value) return;
34
- const t = v(), r = $();
35
- r.style.position = W;
34
+ const e = v(), r = $();
35
+ r.style.position = L;
36
36
  const {
37
37
  top: f,
38
38
  right: l,
39
39
  bottom: w,
40
- left: u,
40
+ left: p,
41
41
  width: m,
42
- height: H
43
- } = t.getBoundingClientRect(), a = r.offsetHeight, d = r.offsetWidth, x = document.documentElement.clientHeight, b = document.documentElement.clientWidth;
42
+ height: W
43
+ } = e.getBoundingClientRect(), a = r.offsetHeight, d = r.offsetWidth, x = document.documentElement.clientHeight, b = document.documentElement.clientWidth;
44
44
  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" && u - d < 0 && (i = "right");
46
- let o = p;
47
- p == "left" ? u + d > b && (o = "right") : p == "right" ? l - d < 0 && (o = "left") : p == "top" ? f + a > x && (o = "bottom") : p == "bottom" && w - a < 0 && (o = "top");
48
- const e = {
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");
46
+ 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 t = {
49
49
  top: "auto",
50
50
  bottom: "auto",
51
51
  left: "auto",
52
52
  right: "auto",
53
53
  width: "auto"
54
- }, n = W === "fixed";
55
- i == "up" ? e.bottom = `${H + (n ? x - w : 0)}px` : i == "down" ? e.top = `${H + (n ? f : 0)}px` : i == "right" ? e.left = `${m + (n ? u : 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 ? u : 0}px` : o == "center" && (e.left = `${(n ? u : 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 - H) / 2}px`), ["up", "down"].includes(i) && o === "stretch" && (e.width = m + "px");
56
- for (const P in e)
57
- r.style[P] = e[P];
54
+ }, n = L === "fixed";
55
+ 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 ? p : 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 ? p : 0}px` : o == "center" && (t.left = `${(n ? p : 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) - (a - W) / 2}px`), ["up", "down"].includes(i) && o === "stretch" && (t.width = m + "px");
56
+ for (const C in t)
57
+ r.style[C] = t[C];
58
58
  }
59
- M(
59
+ _(
60
60
  s,
61
- (t) => {
62
- t && k(() => {
61
+ (e) => {
62
+ e && P(() => {
63
63
  h();
64
64
  });
65
65
  },
66
66
  { flush: "pre" }
67
67
  );
68
- function T(t) {
69
- const r = t.target;
68
+ function R(e) {
69
+ const r = e.target;
70
70
  if (!v().contains(r))
71
71
  try {
72
- $().contains(r) ? O && E() : B && (s.value = !1);
72
+ $().contains(r) ? M && E() : A && (s.value = !1);
73
73
  } catch {
74
74
  }
75
75
  }
76
- const C = new ResizeObserver(h), g = new AbortController();
76
+ let H;
77
+ const g = new AbortController();
77
78
  return F(() => {
79
+ H = new ResizeObserver(h);
80
+ }), U(() => {
78
81
  window.addEventListener("resize", h, {
79
82
  passive: !0,
80
83
  signal: g.signal
@@ -82,19 +85,19 @@ function D(z, A, {
82
85
  passive: !0,
83
86
  //capture: true,
84
87
  signal: g.signal
85
- }), window.addEventListener("click", T, {
88
+ }), window.addEventListener("click", R, {
86
89
  passive: !0,
87
90
  signal: g.signal
88
- }), C.observe(v());
89
- }), U(() => {
90
- g.abort(), C.disconnect();
91
+ }), H.observe(v());
92
+ }), j(() => {
93
+ g.abort(), H.disconnect();
91
94
  }), {
92
95
  isOpen: s,
93
- open: L,
96
+ open: B,
94
97
  close: E,
95
- toggle: R
98
+ toggle: O
96
99
  };
97
100
  }
98
101
  export {
99
- D as usePopover
102
+ G as usePopover
100
103
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-composable-ui",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",