@mobilon-dev/chotto 0.3.82 → 0.3.83

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,7 +1,7 @@
1
1
  import o from "./Tooltip.vue2.js";
2
2
  /* empty css */
3
3
  import t from "../../../_virtual/_plugin-vue_export-helper.js";
4
- const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-0487e8ee"]]);
4
+ const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-7691fdbe"]]);
5
5
  export {
6
6
  m as default
7
7
  };
@@ -1,13 +1,13 @@
1
- import { defineComponent as et, inject as ot, ref as u, computed as _, onUnmounted as lt, createElementBlock as h, openBlock as c, Fragment as I, createElementVNode as it, createBlock as rt, renderSlot as at, Teleport as nt, createVNode as ut, Transition as st, withCtx as ct, createCommentVNode as ft, renderList as mt, normalizeStyle as pt, normalizeClass as ht, unref as S, toDisplayString as vt, nextTick as M } from "vue";
1
+ import { defineComponent as ot, inject as lt, ref as u, computed as S, onMounted as it, onUnmounted as rt, createElementBlock as g, openBlock as c, Fragment as O, createElementVNode as at, createBlock as nt, renderSlot as ut, Teleport as st, createVNode as ct, Transition as ft, withCtx as mt, createCommentVNode as ht, renderList as pt, normalizeStyle as vt, normalizeClass as dt, unref as M, toDisplayString as gt, nextTick as k } from "vue";
2
2
  import "../../../hooks/useMessageDraft.js";
3
3
  import "../../../hooks/useSearchModel.js";
4
- import { useTheme as gt } from "../../../hooks/useTheme.js";
4
+ import { useTheme as Tt } from "../../../hooks/useTheme.js";
5
5
  /* empty css */
6
6
  /* empty css */
7
7
  import "../../../node_modules/linkifyjs/dist/linkify.js";
8
8
  import "../../../node_modules/linkify-string/dist/linkify-string.js";
9
9
  import "../../../functions/parseMarkdown.js";
10
- const Tt = { key: 0 }, dt = ["data-theme"], yt = 6, wt = 120, Dt = /* @__PURE__ */ et({
10
+ const yt = { key: 0 }, wt = ["data-theme"], xt = 6, _t = 120, Nt = /* @__PURE__ */ ot({
11
11
  __name: "Tooltip",
12
12
  props: {
13
13
  text: {
@@ -40,21 +40,25 @@ const Tt = { key: 0 }, dt = ["data-theme"], yt = 6, wt = 120, Dt = /* @__PURE__
40
40
  type: Number,
41
41
  default: 600
42
42
  },
43
+ hideOnClick: {
44
+ type: Boolean,
45
+ default: !1
46
+ },
43
47
  maxWidth: {
44
48
  type: String,
45
49
  default: ""
46
50
  }
47
51
  },
48
- setup(N, { expose: P }) {
49
- const v = ot("chatAppId"), { getTheme: A } = gt(v), g = u(), f = u([]), s = u(!1), m = u(null), n = u(null), i = u(null), T = u(!1), d = u(!1), e = N, $ = _(() => ({
52
+ setup(P, { expose: $ }) {
53
+ const T = lt("chatAppId"), { getTheme: C } = Tt(T), y = u(), f = u([]), s = u(!1), m = u(null), n = u(null), i = u(null), h = u(!1), p = u(!1), e = P, W = S(() => ({
50
54
  tooltip__text: !0,
51
55
  [`tooltip--${e.position}`]: !0
52
- })), W = _(() => ({
56
+ })), R = S(() => ({
53
57
  maxWidth: e.maxWidth || void 0
54
- })), R = _(() => {
58
+ })), H = S(() => {
55
59
  const t = Array.isArray(e.texts) ? e.texts.map((o) => String(o ?? "").trim()).filter(Boolean) : [];
56
60
  return t.length > 0 ? t : e.text ? [e.text] : [];
57
- }), H = (t, o) => {
61
+ }), V = (t, o) => {
58
62
  const l = o.left < 0 ? o.left : 0, r = o.top < 0 ? o.top : 0;
59
63
  return {
60
64
  left: {
@@ -87,76 +91,87 @@ const Tt = { key: 0 }, dt = ["data-theme"], yt = 6, wt = 120, Dt = /* @__PURE__
87
91
  }
88
92
  }[e.position];
89
93
  }, L = () => {
90
- if (!g.value || f.value.length === 0) return;
91
- const t = g.value.getBoundingClientRect(), o = e.position.startsWith("top"), l = 8, r = v ? document.getElementById(v) : null, a = r == null ? void 0 : r.getBoundingClientRect(), K = (a == null ? void 0 : a.top) ?? 0, U = (a == null ? void 0 : a.left) ?? 0, X = (a == null ? void 0 : a.right) ?? window.innerWidth, Y = (a == null ? void 0 : a.bottom) ?? window.innerHeight;
92
- f.value.forEach((w, J) => {
93
- const p = w.getBoundingClientRect(), x = H(t, p), C = J * (p.height + yt), Q = o ? x.top - C : x.top + C, E = K + l, Z = Y - p.height - l, D = U + l, b = X - p.width - l, B = Math.min(Math.max(Q, E), Math.max(E, Z)), tt = Math.min(Math.max(x.left, D), Math.max(D, b));
94
- w.style.top = `${B}px`, w.style.left = `${tt}px`;
94
+ if (!y.value || f.value.length === 0) return;
95
+ const t = y.value.getBoundingClientRect(), o = e.position.startsWith("top"), l = 8, r = T ? document.getElementById(T) : null, a = r == null ? void 0 : r.getBoundingClientRect(), U = (a == null ? void 0 : a.top) ?? 0, X = (a == null ? void 0 : a.left) ?? 0, Y = (a == null ? void 0 : a.right) ?? window.innerWidth, J = (a == null ? void 0 : a.bottom) ?? window.innerHeight;
96
+ f.value.forEach((x, Q) => {
97
+ const d = x.getBoundingClientRect(), _ = V(t, d), D = Q * (d.height + xt), Z = o ? _.top - D : _.top + D, I = U + l, b = J - d.height - l, N = X + l, B = Y - d.width - l, tt = Math.min(Math.max(Z, I), Math.max(I, b)), et = Math.min(Math.max(_.left, N), Math.max(N, B));
98
+ x.style.top = `${tt}px`, x.style.left = `${et}px`;
95
99
  });
96
- }, V = () => {
100
+ }, q = () => {
97
101
  e.trigger !== "auto" && (n.value && (clearTimeout(n.value), n.value = null), i.value && (clearTimeout(i.value), i.value = null), n.value = setTimeout(() => {
98
- s.value = !0, M(() => {
102
+ s.value = !0, k(() => {
99
103
  L();
100
104
  }), n.value = null;
101
105
  }, e.delay));
102
- }, q = () => {
103
- e.trigger !== "auto" && (n.value && (clearTimeout(n.value), n.value = null), i.value && (clearTimeout(i.value), i.value = null), s.value = !1, M(() => {
104
- S(f).forEach((o) => {
106
+ }, w = () => {
107
+ e.trigger !== "auto" && (n.value && (clearTimeout(n.value), n.value = null), i.value && (clearTimeout(i.value), i.value = null), s.value = !1, k(() => {
108
+ M(f).forEach((o) => {
105
109
  o.style.top = "0", o.style.left = "0";
106
110
  });
107
111
  }));
108
- }, k = () => {
112
+ }, A = () => {
109
113
  e.trigger !== "auto" && (i.value && clearTimeout(i.value), i.value = setTimeout(() => {
110
- !T.value && !d.value && q();
111
- }, wt));
114
+ !h.value && !p.value && w();
115
+ }, _t));
112
116
  }, z = () => {
113
- T.value = !0, V();
114
- }, O = () => {
115
- T.value = !1, k();
117
+ h.value = !0, q();
116
118
  }, j = () => {
117
- d.value = !0, i.value && (clearTimeout(i.value), i.value = null);
119
+ h.value = !1, A();
118
120
  }, F = () => {
119
- d.value = !1, k();
121
+ p.value = !0, i.value && (clearTimeout(i.value), i.value = null);
120
122
  }, G = () => {
121
- y(), s.value = !0, M(() => {
123
+ p.value = !1, A();
124
+ }, E = () => {
125
+ if (e.hideOnClick) {
126
+ if (h.value = !1, p.value = !1, e.trigger === "auto") {
127
+ v(), s.value = !1;
128
+ return;
129
+ }
130
+ w();
131
+ }
132
+ }, K = () => {
133
+ v(), s.value = !0, k(() => {
122
134
  L();
123
135
  }), e.autoShowDuration > 0 && (m.value = setTimeout(() => {
124
136
  s.value = !1;
125
137
  }, e.autoShowDuration));
126
- }, y = () => {
138
+ }, v = () => {
127
139
  m.value && (clearTimeout(m.value), m.value = null);
128
140
  };
129
- return lt(() => {
130
- n.value && clearTimeout(n.value), i.value && clearTimeout(i.value), y();
131
- }), P({
132
- startAutoShow: G,
133
- clearAutoTimer: y
134
- }), (t, o) => (c(), h(I, null, [
135
- it("div", {
141
+ return it(() => {
142
+ e.hideOnClick && document.addEventListener("mousedown", E, !0);
143
+ }), rt(() => {
144
+ e.hideOnClick && document.removeEventListener("mousedown", E, !0), n.value && clearTimeout(n.value), i.value && clearTimeout(i.value), v();
145
+ }), $({
146
+ startAutoShow: K,
147
+ clearAutoTimer: v,
148
+ hide: w
149
+ }), (t, o) => (c(), g(O, null, [
150
+ at("div", {
136
151
  ref_key: "container",
137
- ref: g,
152
+ ref: y,
138
153
  class: "tooltip-wrapper",
139
154
  onMouseenter: z,
140
- onMouseleave: O
155
+ onMouseleave: j
141
156
  }, [
142
- at(t.$slots, "default", {}, void 0, !0)
157
+ ut(t.$slots, "default", {}, void 0, !0)
143
158
  ], 544),
144
- (c(), rt(nt, { to: "body" }, [
145
- ut(st, null, {
146
- default: ct(() => [
147
- s.value ? (c(), h("div", Tt, [
148
- (c(!0), h(I, null, mt(R.value, (l, r) => (c(), h("span", {
159
+ (c(), nt(st, { to: "body" }, [
160
+ ct(ft, null, {
161
+ default: mt(() => [
162
+ s.value ? (c(), g("div", yt, [
163
+ (c(!0), g(O, null, pt(H.value, (l, r) => (c(), g("span", {
149
164
  key: `${l}-${r}`,
150
165
  ref_for: !0,
151
166
  ref_key: "tooltipItems",
152
167
  ref: f,
153
- "data-theme": S(A)().theme ? S(A)().theme : "light",
154
- class: ht($.value),
155
- style: pt(W.value),
156
- onMouseenter: j,
157
- onMouseleave: F
158
- }, vt(l), 47, dt))), 128))
159
- ])) : ft("", !0)
168
+ "data-theme": M(C)().theme ? M(C)().theme : "light",
169
+ class: dt(W.value),
170
+ style: vt(R.value),
171
+ onMouseenter: F,
172
+ onMouseleave: G
173
+ }, gt(l), 47, wt))), 128))
174
+ ])) : ht("", !0)
160
175
  ]),
161
176
  _: 1
162
177
  })
@@ -165,5 +180,5 @@ const Tt = { key: 0 }, dt = ["data-theme"], yt = 6, wt = 120, Dt = /* @__PURE__
165
180
  }
166
181
  });
167
182
  export {
168
- Dt as default
183
+ Nt as default
169
184
  };