@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,19 +1,31 @@
1
- import { toRef as E, computed as T, ref as f, onMounted as W, nextTick as q, onUnmounted as J, watch as K, createElementBlock as a, openBlock as o, normalizeClass as s, createCommentVNode as u, createElementVNode as d, normalizeStyle as O, Fragment as A, renderList as w, createBlock as y, withCtx as k, toDisplayString as M, createVNode as R } from "vue";
2
- import Q from "../../1_atoms/ButtonContextMenu/ButtonContextMenu.vue.js";
3
- import F from "../../1_icons/SettingsIcon.vue.js";
4
- import L from "../../1_atoms/Tooltip/Tooltip.vue.js";
1
+ import { toRef as R, computed as y, ref as m, onMounted as Q, nextTick as p, onUnmounted as X, watch as N, createElementBlock as s, openBlock as i, normalizeClass as r, createCommentVNode as l, createElementVNode as c, normalizeStyle as Z, Fragment as F, renderList as L, createBlock as _, withCtx as h, toDisplayString as V, createVNode as H } from "vue";
2
+ import $ from "../../1_atoms/ButtonContextMenu/ButtonContextMenu.vue.js";
3
+ import Y from "../../1_icons/SettingsIcon.vue.js";
4
+ import I from "../../1_atoms/Tooltip/Tooltip.vue.js";
5
5
  /* empty css */
6
- import X from "../../../_virtual/_plugin-vue_export-helper.js";
7
- const Z = ["onClick"], $ = ["src", "alt"], ee = {
6
+ import tt from "../../../_virtual/_plugin-vue_export-helper.js";
7
+ const et = ["onClick"], ot = ["src", "alt"], it = {
8
8
  key: 1,
9
9
  class: "sidebar__notification-count"
10
- }, te = { class: "sidebar__scroll-container" }, ne = ["onClick"], oe = ["src", "alt"], ie = ["src"], ae = { key: 2 }, se = {
10
+ }, nt = { class: "sidebar__scroll-container" }, st = ["onClick"], at = ["src", "alt"], rt = ["src"], lt = { key: 2 }, ct = {
11
11
  key: 2,
12
12
  class: "sidebar__settings-container"
13
- }, re = {
13
+ }, ut = {
14
14
  class: "sidebar__settings-btn",
15
15
  type: "button"
16
- }, le = {
16
+ }, dt = {
17
+ key: 0,
18
+ class: "sidebar__settings-indicator-anchor"
19
+ }, ft = {
20
+ key: 1,
21
+ class: "sidebar__settings-indicator"
22
+ }, mt = {
23
+ key: 0,
24
+ class: "sidebar__settings-indicator-anchor"
25
+ }, gt = {
26
+ key: 1,
27
+ class: "sidebar__settings-indicator"
28
+ }, _t = {
17
29
  __name: "SideBar",
18
30
  props: {
19
31
  sidebarItems: {
@@ -41,173 +53,246 @@ const Z = ["onClick"], $ = ["src", "alt"], ee = {
41
53
  required: !1,
42
54
  default: "menu"
43
55
  // 'menu' | 'action'
56
+ },
57
+ showSettingsIndicator: {
58
+ type: Boolean,
59
+ required: !1,
60
+ default: !1
61
+ },
62
+ settingsIndicatorTooltip: {
63
+ type: String,
64
+ required: !1,
65
+ default: ""
66
+ },
67
+ /** Список строк для тултипа индикатора (будут показаны друг под другом) */
68
+ settingsIndicatorTooltipItems: {
69
+ type: Array,
70
+ required: !1,
71
+ default: () => []
72
+ },
73
+ /** Длительность автопоказа тултипа индикатора при появлении кружка, мс */
74
+ settingsIndicatorTooltipAutoShowMs: {
75
+ type: Number,
76
+ required: !1,
77
+ default: 8e3
44
78
  }
45
79
  },
46
80
  emits: ["selectItem", "settingsClick"],
47
- setup(i, { emit: N }) {
48
- const C = i, m = E(C, "sidebarItems"), p = E(C, "menuActions"), z = N, x = T(
49
- () => m.value.filter((e) => e.isFixedBottom).sort((e, t) => t.notificationCount - e.notificationCount)
50
- ), V = T(
51
- () => m.value.filter((e) => !e.isFixedBottom).sort((e, t) => t.notificationCount - e.notificationCount)
52
- ), H = (e) => {
53
- const t = m.value.find((n) => n.itemId === e);
54
- z("selectItem", t);
55
- }, B = (e, t) => {
56
- P(e.currentTarget), H(t);
57
- }, Y = (e) => {
58
- const t = e.split(" ");
59
- return t.length > 2 ? t.slice(0, 2).join(" ") : e;
60
- }, j = (e) => {
61
- console.log("Выбрано действие:", e), typeof e.action == "function" && e.action();
62
- }, D = () => {
81
+ setup(n, { emit: j }) {
82
+ const u = n, v = R(u, "sidebarItems"), w = R(u, "menuActions"), B = j, k = y(
83
+ () => Array.isArray(u.settingsIndicatorTooltipItems) ? u.settingsIndicatorTooltipItems.map((t) => String(t ?? "").trim()).filter(Boolean) : []
84
+ ), x = y(
85
+ () => k.value.length > 0 || !!u.settingsIndicatorTooltip.trim()
86
+ ), A = y(
87
+ () => v.value.filter((t) => t.isFixedBottom).sort((t, e) => e.notificationCount - t.notificationCount)
88
+ ), D = y(
89
+ () => v.value.filter((t) => !t.isFixedBottom).sort((t, e) => e.notificationCount - t.notificationCount)
90
+ ), G = (t) => {
91
+ const e = v.value.find((o) => o.itemId === t);
92
+ B("selectItem", e);
93
+ }, q = (t, e) => {
94
+ K(t.currentTarget), G(e);
95
+ }, P = (t) => {
96
+ const e = t.split(" ");
97
+ return e.length > 2 ? e.slice(0, 2).join(" ") : t;
98
+ }, U = (t) => {
99
+ console.log("Выбрано действие:", t), typeof t.action == "function" && t.action();
100
+ }, W = () => {
63
101
  console.log("Кнопка меню была нажата");
64
- }, G = () => {
65
- var t;
66
- z("settingsClick");
67
- const e = (t = p.value) == null ? void 0 : t[0];
68
- e && typeof e.action == "function" && !e.disabled && e.action();
69
- }, l = f(null), h = f(!1), v = f(0), g = f(40), b = f(!1), I = (e) => {
70
- const t = l.value;
71
- if (!t || !e) return 0;
72
- const n = t.getBoundingClientRect(), r = e.getBoundingClientRect(), U = r.top + r.height / 2 - n.top - g.value / 2;
73
- return Math.max(0, U);
74
- }, _ = () => {
75
- if (!l.value) return;
76
- const t = l.value.querySelector(".sidebar__image--active");
77
- t ? (v.value = I(t), h.value = !0) : h.value = !1;
78
- }, P = (e) => {
102
+ }, J = () => {
103
+ var e;
104
+ B("settingsClick");
105
+ const t = (e = w.value) == null ? void 0 : e[0];
106
+ t && typeof t.action == "function" && !t.disabled && t.action();
107
+ }, d = m(null), C = m(null), S = m(!1), T = m(0), b = m(40), z = m(!1), E = (t) => {
108
+ const e = d.value;
109
+ if (!e || !t) return 0;
110
+ const o = e.getBoundingClientRect(), a = t.getBoundingClientRect(), O = a.top + a.height / 2 - o.top - b.value / 2;
111
+ return Math.max(0, O);
112
+ }, g = () => {
113
+ if (!d.value) return;
114
+ const e = d.value.querySelector(".sidebar__image--active");
115
+ e ? (T.value = E(e), S.value = !0) : S.value = !1;
116
+ }, K = (t) => {
79
117
  try {
80
- if (!e || !l.value) return;
81
- const t = e.querySelector(".sidebar__image");
82
- if (!t) return;
83
- const n = I(t), r = 12, c = 160;
84
- b.value = !0, g.value = r, setTimeout(() => {
85
- v.value = n, requestAnimationFrame(() => {
86
- g.value = 40, setTimeout(() => {
87
- b.value = !1;
88
- }, c);
118
+ if (!t || !d.value) return;
119
+ const e = t.querySelector(".sidebar__image");
120
+ if (!e) return;
121
+ const o = E(e), a = 12, f = 160;
122
+ z.value = !0, b.value = a, setTimeout(() => {
123
+ T.value = o, requestAnimationFrame(() => {
124
+ b.value = 40, setTimeout(() => {
125
+ z.value = !1;
126
+ }, f);
89
127
  });
90
- }, c);
128
+ }, f);
91
129
  } catch {
92
130
  }
93
- }, S = () => _();
94
- return W(() => {
95
- var t;
96
- q(_), window.addEventListener("resize", S);
97
- const e = (t = l.value) == null ? void 0 : t.querySelector(".sidebar__scroll-container");
98
- e && e.addEventListener("scroll", _);
99
- }), J(() => {
100
- var t;
101
- window.removeEventListener("resize", S);
102
- const e = (t = l.value) == null ? void 0 : t.querySelector(".sidebar__scroll-container");
103
- e && e.removeEventListener("scroll", _);
104
- }), K(() => m.value.map((e) => e.selected), () => q(_)), (e, t) => (o(), a("div", {
131
+ }, M = () => g();
132
+ return Q(() => {
133
+ var e;
134
+ p(g), window.addEventListener("resize", M);
135
+ const t = (e = d.value) == null ? void 0 : e.querySelector(".sidebar__scroll-container");
136
+ t && t.addEventListener("scroll", g);
137
+ }), X(() => {
138
+ var e;
139
+ window.removeEventListener("resize", M);
140
+ const t = (e = d.value) == null ? void 0 : e.querySelector(".sidebar__scroll-container");
141
+ t && t.removeEventListener("scroll", g);
142
+ }), N(() => v.value.map((t) => t.selected), () => p(g)), N(
143
+ () => u.showSettings && u.showSettingsIndicator && x.value,
144
+ (t, e) => {
145
+ !t || e === !0 || p(() => {
146
+ p(() => {
147
+ var o, a;
148
+ (a = (o = C.value) == null ? void 0 : o.startAutoShow) == null || a.call(o);
149
+ });
150
+ });
151
+ },
152
+ { flush: "post", immediate: !0 }
153
+ ), (t, e) => (i(), s("div", {
105
154
  ref_key: "containerRef",
106
- ref: l,
107
- class: s(["sidebar__container", { "sidebar-horizontal__container": i.horizontal }])
155
+ ref: d,
156
+ class: r(["sidebar__container", { "sidebar-horizontal__container": n.horizontal }])
108
157
  }, [
109
- !i.horizontal && h.value ? (o(), a("span", {
158
+ !n.horizontal && S.value ? (i(), s("span", {
110
159
  key: 0,
111
- class: s(["sidebar__selected-bar", { "is-animating": b.value }]),
112
- style: O({ top: v.value + "px", height: g.value + "px" })
113
- }, null, 6)) : u("", !0),
114
- x.value.length > 0 ? (o(), a("ul", {
160
+ class: r(["sidebar__selected-bar", { "is-animating": z.value }]),
161
+ style: Z({ top: T.value + "px", height: b.value + "px" })
162
+ }, null, 6)) : l("", !0),
163
+ A.value.length > 0 ? (i(), s("ul", {
115
164
  key: 1,
116
- class: s(["sidebar__list-fixed", { "sidebar-horizontal__list-fixed": i.horizontal }])
165
+ class: r(["sidebar__list-fixed", { "sidebar-horizontal__list-fixed": n.horizontal }])
117
166
  }, [
118
- (o(!0), a(A, null, w(x.value, (n, r) => (o(), a("li", {
119
- key: r,
120
- class: s(["sidebar__item-fixed", { "sidebar-horizontal__item": i.horizontal }]),
121
- onClick: (c) => B(c, n.itemId)
167
+ (i(!0), s(F, null, L(A.value, (o, a) => (i(), s("li", {
168
+ key: a,
169
+ class: r(["sidebar__item-fixed", { "sidebar-horizontal__item": n.horizontal }]),
170
+ onClick: (f) => q(f, o.itemId)
122
171
  }, [
123
- n.name ? (o(), y(L, {
172
+ o.name ? (i(), _(I, {
124
173
  key: 0,
125
- text: Y(n.name),
174
+ text: P(o.name),
126
175
  position: "right",
127
176
  offset: 8
128
177
  }, {
129
- default: k(() => [
130
- d("img", {
131
- src: n.icon,
132
- alt: n.name,
133
- class: s(["sidebar__image", {
134
- "sidebar__image--active": n.selected === !0,
135
- "sidebar-horizontal__image": i.horizontal
178
+ default: h(() => [
179
+ c("img", {
180
+ src: o.icon,
181
+ alt: o.name,
182
+ class: r(["sidebar__image", {
183
+ "sidebar__image--active": o.selected === !0,
184
+ "sidebar-horizontal__image": n.horizontal
136
185
  }])
137
- }, null, 10, $),
138
- t[0] || (t[0] = d("p", null, "Мои", -1))
186
+ }, null, 10, ot),
187
+ e[0] || (e[0] = c("p", null, "Мои", -1))
139
188
  ]),
140
189
  _: 2
141
- }, 1032, ["text"])) : u("", !0),
142
- n.notificationCount ? (o(), a("span", ee, M(n.notificationCount > 99 ? "99+" : n.notificationCount), 1)) : u("", !0)
143
- ], 10, Z))), 128))
144
- ], 2)) : u("", !0),
145
- d("div", te, [
146
- d("ul", {
147
- class: s(["sidebar__list", { "sidebar-horizontal__list": i.horizontal }])
190
+ }, 1032, ["text"])) : l("", !0),
191
+ o.notificationCount ? (i(), s("span", it, V(o.notificationCount > 99 ? "99+" : o.notificationCount), 1)) : l("", !0)
192
+ ], 10, et))), 128))
193
+ ], 2)) : l("", !0),
194
+ c("div", nt, [
195
+ c("ul", {
196
+ class: r(["sidebar__list", { "sidebar-horizontal__list": n.horizontal }])
148
197
  }, [
149
- (o(!0), a(A, null, w(V.value, (n, r) => (o(), a("li", {
150
- key: r,
151
- class: s(["sidebar__item", { "sidebar-horizontal__item": i.horizontal }]),
152
- onClick: (c) => B(c, n.itemId)
198
+ (i(!0), s(F, null, L(D.value, (o, a) => (i(), s("li", {
199
+ key: a,
200
+ class: r(["sidebar__item", { "sidebar-horizontal__item": n.horizontal }]),
201
+ onClick: (f) => q(f, o.itemId)
153
202
  }, [
154
- n.name ? (o(), y(L, {
203
+ o.name ? (i(), _(I, {
155
204
  key: 0,
156
- text: n.name,
205
+ text: o.name,
157
206
  position: "right",
158
207
  offset: 8
159
208
  }, {
160
- default: k(() => [
161
- d("img", {
162
- src: n.icon,
163
- alt: n.name,
164
- class: s(["sidebar__image", {
165
- "sidebar__image--active": n.selected === !0,
166
- "sidebar-horizontal__image": i.horizontal
209
+ default: h(() => [
210
+ c("img", {
211
+ src: o.icon,
212
+ alt: o.name,
213
+ class: r(["sidebar__image", {
214
+ "sidebar__image--active": o.selected === !0,
215
+ "sidebar-horizontal__image": n.horizontal
167
216
  }])
168
- }, null, 10, oe)
217
+ }, null, 10, at)
169
218
  ]),
170
219
  _: 2
171
- }, 1032, ["text"])) : (o(), a("img", {
220
+ }, 1032, ["text"])) : (i(), s("img", {
172
221
  key: 1,
173
- src: n.icon,
222
+ src: o.icon,
174
223
  alt: "icon",
175
- class: s(["sidebar__image", {
176
- "sidebar__image--active": n.selected === !0,
177
- "sidebar-horizontal__image": i.horizontal
224
+ class: r(["sidebar__image", {
225
+ "sidebar__image--active": o.selected === !0,
226
+ "sidebar-horizontal__image": n.horizontal
178
227
  }])
179
- }, null, 10, ie)),
180
- n.notificationCount ? (o(), a("span", ae, M(n.notificationCount > 99 ? "99+" : n.notificationCount), 1)) : u("", !0)
181
- ], 10, ne))), 128))
228
+ }, null, 10, rt)),
229
+ o.notificationCount ? (i(), s("span", lt, V(o.notificationCount > 99 ? "99+" : o.notificationCount), 1)) : l("", !0)
230
+ ], 10, st))), 128))
182
231
  ], 2)
183
232
  ]),
184
- i.showSettings ? (o(), a("div", se, [
185
- i.settingsButtonMode === "menu" ? (o(), y(Q, {
233
+ n.showSettings ? (i(), s("div", ct, [
234
+ n.settingsButtonMode === "menu" ? (i(), _($, {
186
235
  key: 0,
187
- actions: p.value,
236
+ actions: w.value,
188
237
  mode: "click",
189
238
  "menu-side": "top-right",
190
- onClick: j,
191
- onButtonClick: D
239
+ onClick: U,
240
+ onButtonClick: W
192
241
  }, {
193
- default: k(() => [
194
- d("button", re, [
195
- R(F)
242
+ default: h(() => [
243
+ c("button", ut, [
244
+ H(Y),
245
+ n.showSettingsIndicator ? (i(), s("span", dt, [
246
+ x.value ? (i(), _(I, {
247
+ key: 0,
248
+ ref_key: "settingsIndicatorTooltipRef",
249
+ ref: C,
250
+ text: n.settingsIndicatorTooltip,
251
+ texts: k.value,
252
+ position: "top",
253
+ offset: 8,
254
+ "max-width": "460px",
255
+ "auto-show-duration": n.settingsIndicatorTooltipAutoShowMs
256
+ }, {
257
+ default: h(() => [...e[1] || (e[1] = [
258
+ c("span", { class: "sidebar__settings-indicator" }, null, -1)
259
+ ])]),
260
+ _: 1
261
+ }, 8, ["text", "texts", "auto-show-duration"])) : (i(), s("span", ft))
262
+ ])) : l("", !0)
196
263
  ])
197
264
  ]),
198
265
  _: 1
199
- }, 8, ["actions"])) : (o(), a("button", {
266
+ }, 8, ["actions"])) : (i(), s("button", {
200
267
  key: 1,
201
268
  class: "sidebar__settings-btn",
202
269
  type: "button",
203
- onClick: G
270
+ onClick: J
204
271
  }, [
205
- R(F)
272
+ H(Y),
273
+ n.showSettingsIndicator ? (i(), s("span", mt, [
274
+ x.value ? (i(), _(I, {
275
+ key: 0,
276
+ ref_key: "settingsIndicatorTooltipRef",
277
+ ref: C,
278
+ text: n.settingsIndicatorTooltip,
279
+ texts: k.value,
280
+ position: "top",
281
+ offset: 8,
282
+ "max-width": "460px",
283
+ "auto-show-duration": n.settingsIndicatorTooltipAutoShowMs
284
+ }, {
285
+ default: h(() => [...e[2] || (e[2] = [
286
+ c("span", { class: "sidebar__settings-indicator" }, null, -1)
287
+ ])]),
288
+ _: 1
289
+ }, 8, ["text", "texts", "auto-show-duration"])) : (i(), s("span", gt))
290
+ ])) : l("", !0)
206
291
  ]))
207
- ])) : u("", !0)
292
+ ])) : l("", !0)
208
293
  ], 2));
209
294
  }
210
- }, ge = /* @__PURE__ */ X(le, [["__scopeId", "data-v-eb5412c6"]]);
295
+ }, kt = /* @__PURE__ */ tt(_t, [["__scopeId", "data-v-f93a9b48"]]);
211
296
  export {
212
- ge as default
297
+ kt as default
213
298
  };