@mobilon-dev/chotto 0.3.66 → 0.3.68

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-a2bb5769"]]);
4
+ const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-0487e8ee"]]);
5
5
  export {
6
6
  m as default
7
7
  };
@@ -1,18 +1,24 @@
1
- import { defineComponent as k, inject as N, ref as n, computed as A, onUnmounted as D, createElementBlock as T, openBlock as s, Fragment as R, createElementVNode as V, createBlock as E, renderSlot as I, Teleport as L, createVNode as M, Transition as $, withCtx as j, createCommentVNode as q, normalizeClass as z, unref as g, toDisplayString as F, nextTick as v } from "vue";
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";
2
2
  import "../../../hooks/useMessageDraft.js";
3
3
  import "../../../hooks/useSearchModel.js";
4
- import { useTheme as P } from "../../../hooks/useTheme.js";
4
+ import { useTheme as gt } 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 U = ["data-theme"], Z = /* @__PURE__ */ k({
10
+ const Tt = { key: 0 }, dt = ["data-theme"], yt = 6, wt = 120, Dt = /* @__PURE__ */ et({
11
11
  __name: "Tooltip",
12
12
  props: {
13
13
  text: {
14
14
  type: String,
15
- required: !0
15
+ required: !1,
16
+ default: ""
17
+ },
18
+ texts: {
19
+ type: Array,
20
+ required: !1,
21
+ default: () => []
16
22
  },
17
23
  position: {
18
24
  type: String,
@@ -33,79 +39,124 @@ const U = ["data-theme"], Z = /* @__PURE__ */ k({
33
39
  delay: {
34
40
  type: Number,
35
41
  default: 600
42
+ },
43
+ maxWidth: {
44
+ type: String,
45
+ default: ""
36
46
  }
37
47
  },
38
- setup(w, { expose: d }) {
39
- const x = N("chatAppId"), { getTheme: y } = P(x), a = n(), p = n(), c = n(!1), u = n(null), r = n(null), o = w, _ = A(() => ({
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, $ = _(() => ({
40
50
  tooltip__text: !0,
41
- [`tooltip--${o.position}`]: !0
42
- })), B = () => {
43
- o.trigger !== "auto" && (r.value && (clearTimeout(r.value), r.value = null), r.value = setTimeout(() => {
44
- c.value = !0, v(() => {
45
- if (a.value && p.value) {
46
- const f = p.value, t = a.value.getBoundingClientRect(), e = p.value.getBoundingClientRect(), l = e.left < 0 ? e.left : 0, i = e.top < 0 ? e.top : 0, h = {
47
- left: { top: t.top - (e.height - t.height) / 2 - i, left: (t == null ? void 0 : t.left) - e.width - l - o.offset },
48
- right: { top: t.top - (e.height - t.height) / 2 - i, left: (t == null ? void 0 : t.left) + t.width - l + o.offset },
49
- bottom: { top: (t == null ? void 0 : t.bottom) - i + o.offset, left: (t == null ? void 0 : t.left) - l },
50
- "bottom-center": { top: (t == null ? void 0 : t.bottom) - i + o.offset, left: (t == null ? void 0 : t.left) + t.width / 2 - e.width / 2 - l },
51
- top: { top: t.top - e.height - o.offset - i, left: (t == null ? void 0 : t.left) - l },
52
- "top-center": { top: t.top - e.height - o.offset - i, left: (t == null ? void 0 : t.left) + t.width / 2 - e.width / 2 - l },
53
- "bottom-left": { top: (t == null ? void 0 : t.bottom) - i + o.offset, left: (t == null ? void 0 : t.left) + t.width - e.width - l }
54
- };
55
- f.style.top = h[o.position].top + "px", f.style.left = h[o.position].left + "px";
56
- }
57
- }), r.value = null;
58
- }, o.delay));
59
- }, C = () => {
60
- o.trigger !== "auto" && (r.value && (clearTimeout(r.value), r.value = null), c.value = !1, v(() => {
61
- const f = g(p);
62
- f && (f.style.top = "0", f.style.left = "0");
63
- }));
64
- }, S = () => {
65
- m(), c.value = !0, v(() => {
66
- if (a.value && p.value) {
67
- const f = p.value, t = a.value.getBoundingClientRect(), e = p.value.getBoundingClientRect(), l = e.left < 0 ? e.left : 0, i = e.top < 0 ? e.top : 0, h = {
68
- left: { top: t.top - (e.height - t.height) / 2 - i, left: (t == null ? void 0 : t.left) - e.width - l - o.offset },
69
- right: { top: t.top - (e.height - t.height) / 2 - i, left: (t == null ? void 0 : t.left) + t.width - l + o.offset },
70
- bottom: { top: (t == null ? void 0 : t.bottom) - i + o.offset, left: (t == null ? void 0 : t.left) - l },
71
- "bottom-center": { top: (t == null ? void 0 : t.bottom) - i + o.offset, left: (t == null ? void 0 : t.left) + t.width / 2 - e.width / 2 - l },
72
- top: { top: t.top - e.height - o.offset - i, left: (t == null ? void 0 : t.left) - l },
73
- "top-center": { top: t.top - e.height - o.offset - i, left: (t == null ? void 0 : t.left) + t.width / 2 - e.width / 2 - l },
74
- "bottom-left": { top: (t == null ? void 0 : t.bottom) - i + o.offset, left: (t == null ? void 0 : t.left) + t.width - e.width - l }
75
- };
76
- f.style.top = h[o.position].top + "px", f.style.left = h[o.position].left + "px";
51
+ [`tooltip--${e.position}`]: !0
52
+ })), W = _(() => ({
53
+ maxWidth: e.maxWidth || void 0
54
+ })), R = _(() => {
55
+ const t = Array.isArray(e.texts) ? e.texts.map((o) => String(o ?? "").trim()).filter(Boolean) : [];
56
+ return t.length > 0 ? t : e.text ? [e.text] : [];
57
+ }), H = (t, o) => {
58
+ const l = o.left < 0 ? o.left : 0, r = o.top < 0 ? o.top : 0;
59
+ return {
60
+ left: {
61
+ top: t.top - (o.height - t.height) / 2 - r,
62
+ left: t.left - o.width - l - e.offset
63
+ },
64
+ right: {
65
+ top: t.top - (o.height - t.height) / 2 - r,
66
+ left: t.left + t.width - l + e.offset
67
+ },
68
+ bottom: {
69
+ top: t.bottom - r + e.offset,
70
+ left: t.left - l
71
+ },
72
+ "bottom-center": {
73
+ top: t.bottom - r + e.offset,
74
+ left: t.left + t.width / 2 - o.width / 2 - l
75
+ },
76
+ top: {
77
+ top: t.top - o.height - e.offset - r,
78
+ left: t.left - l
79
+ },
80
+ "top-center": {
81
+ top: t.top - o.height - e.offset - r,
82
+ left: t.left + t.width / 2 - o.width / 2 - l
83
+ },
84
+ "bottom-left": {
85
+ top: t.bottom - r + e.offset,
86
+ left: t.left + t.width - o.width - l
77
87
  }
78
- }), o.autoShowDuration > 0 && (u.value = setTimeout(() => {
79
- c.value = !1;
80
- }, o.autoShowDuration));
81
- }, m = () => {
82
- u.value && (clearTimeout(u.value), u.value = null);
88
+ }[e.position];
89
+ }, 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`;
95
+ });
96
+ }, V = () => {
97
+ 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(() => {
99
+ L();
100
+ }), n.value = null;
101
+ }, 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) => {
105
+ o.style.top = "0", o.style.left = "0";
106
+ });
107
+ }));
108
+ }, k = () => {
109
+ e.trigger !== "auto" && (i.value && clearTimeout(i.value), i.value = setTimeout(() => {
110
+ !T.value && !d.value && q();
111
+ }, wt));
112
+ }, z = () => {
113
+ T.value = !0, V();
114
+ }, O = () => {
115
+ T.value = !1, k();
116
+ }, j = () => {
117
+ d.value = !0, i.value && (clearTimeout(i.value), i.value = null);
118
+ }, F = () => {
119
+ d.value = !1, k();
120
+ }, G = () => {
121
+ y(), s.value = !0, M(() => {
122
+ L();
123
+ }), e.autoShowDuration > 0 && (m.value = setTimeout(() => {
124
+ s.value = !1;
125
+ }, e.autoShowDuration));
126
+ }, y = () => {
127
+ m.value && (clearTimeout(m.value), m.value = null);
83
128
  };
84
- return D(() => {
85
- r.value && clearTimeout(r.value), m();
86
- }), d({
87
- startAutoShow: S,
88
- clearAutoTimer: m
89
- }), (f, t) => (s(), T(R, null, [
90
- V("div", {
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", {
91
136
  ref_key: "container",
92
- ref: a,
137
+ ref: g,
93
138
  class: "tooltip-wrapper",
94
- onMouseover: B,
95
- onMouseout: C
139
+ onMouseenter: z,
140
+ onMouseleave: O
96
141
  }, [
97
- I(f.$slots, "default", {}, void 0, !0)
142
+ at(t.$slots, "default", {}, void 0, !0)
98
143
  ], 544),
99
- (s(), E(L, { to: "body" }, [
100
- M($, null, {
101
- default: j(() => [
102
- c.value ? (s(), T("span", {
103
- key: 0,
104
- ref_key: "tooltip",
105
- ref: p,
106
- "data-theme": g(y)().theme ? g(y)().theme : "light",
107
- class: z(_.value)
108
- }, F(w.text), 11, U)) : q("", !0)
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", {
149
+ key: `${l}-${r}`,
150
+ ref_for: !0,
151
+ ref_key: "tooltipItems",
152
+ 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)
109
160
  ]),
110
161
  _: 1
111
162
  })
@@ -114,5 +165,5 @@ const U = ["data-theme"], Z = /* @__PURE__ */ k({
114
165
  }
115
166
  });
116
167
  export {
117
- Z as default
168
+ Dt as default
118
169
  };