@mobilon-dev/chotto 0.3.85 → 0.3.86

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,6 +1,6 @@
1
1
  import { needsAttributeConfirmation as m } from "./useCommunicationAttributes.js";
2
- import { resolveRecentChannelSelection as J } from "./useCommunicationRecentSelection.js";
3
- function Y({
2
+ import { resolveRecentChannelSelection as K } from "./useCommunicationRecentSelection.js";
3
+ function Z({
4
4
  activeChannelType: l,
5
5
  channels: v,
6
6
  selectedChannel: i,
@@ -9,7 +9,8 @@ function Y({
9
9
  confirmingAttributeId: q,
10
10
  isAttributeBlocked: u,
11
11
  closeMenu: a,
12
- hasMultipleChannels: A,
12
+ pinMenuOpen: A,
13
+ hasMultipleChannels: G,
13
14
  getSingleChannelForType: x,
14
15
  getAvailableChannels: C,
15
16
  isChannelEmpty: d,
@@ -20,13 +21,13 @@ function Y({
20
21
  panelPendingSelection: f
21
22
  }) {
22
23
  const b = (n, e, r) => {
23
- u(n) || (q.value = n.id, t("confirm-attribute", {
24
+ u(n) || (A(), q.value = n.id, t("confirm-attribute", {
24
25
  attributeId: n.id,
25
26
  channelId: e,
26
27
  channelType: r,
27
28
  attribute: n
28
29
  }));
29
- }, G = (n, e, r) => {
30
+ }, H = (n, e, r) => {
30
31
  if (m(n)) {
31
32
  b(n, e, r);
32
33
  return;
@@ -60,34 +61,36 @@ function Y({
60
61
  h(n);
61
62
  return;
62
63
  }
63
- if (!A(e)) {
64
+ if (!G(e)) {
64
65
  const r = x(e);
65
- r && G(n, r.channelId, e);
66
+ r && H(n, r.channelId, e);
66
67
  }
67
68
  }
68
69
  },
69
70
  selectSingleChannel: j,
70
71
  selectChannel: (n) => {
71
72
  const e = z.value, r = l.value;
72
- if (!e || !r || u(e)) {
73
+ if (!e || !r) {
73
74
  a();
74
75
  return;
75
76
  }
76
- if (m(e)) {
77
- b(e, n, r);
78
- return;
77
+ if (!u(e)) {
78
+ if (m(e)) {
79
+ b(e, n, r);
80
+ return;
81
+ }
82
+ t("select-attribute-channel", {
83
+ attributeId: e.id,
84
+ channelId: n
85
+ }), s.value = r, i.value = v.value.find((c) => c.channelId === n) ?? {}, d(n) && I.value ? R() : S(), a();
79
86
  }
80
- t("select-attribute-channel", {
81
- attributeId: e.id,
82
- channelId: n
83
- }), s.value = r, i.value = v.value.find((c) => c.channelId === n) ?? {}, d(n) && I.value ? R() : S(), a();
84
87
  },
85
88
  availableChannels: () => {
86
89
  const n = l.value;
87
90
  return n ? C(n) : [];
88
91
  },
89
92
  applyRecentChannelButtonSelection: (n, e, r) => {
90
- const c = J(
93
+ const c = K(
91
94
  n,
92
95
  e,
93
96
  r,
@@ -104,7 +107,7 @@ function Y({
104
107
  }), t("select-attribute-channel", {
105
108
  attributeId: P.id,
106
109
  channelId: o
107
- }), s.value = n, i.value = v.value.find((H) => H.channelId === o) ?? {}, d(o) && I.value ? R() : S(), !0);
110
+ }), s.value = n, i.value = v.value.find((J) => J.channelId === o) ?? {}, d(o) && I.value ? R() : S(), !0);
108
111
  },
109
112
  clearPanelPendingSelection: () => {
110
113
  f && (f.value = null);
@@ -112,5 +115,5 @@ function Y({
112
115
  };
113
116
  }
114
117
  export {
115
- Y as useCommunicationActions
118
+ Z as useCommunicationActions
116
119
  };
@@ -1,45 +1,50 @@
1
- import { ref as l, nextTick as f } from "vue";
2
- function M({
3
- panelRef: v,
4
- selectedChannelType: d,
5
- frozenAttribute: c
1
+ import { ref as n, nextTick as p } from "vue";
2
+ function w({
3
+ panelRef: d,
4
+ selectedChannelType: h,
5
+ frozenAttribute: r
6
6
  }) {
7
- const n = l(null), h = l(null), u = l(!1), a = l(!1), s = l(!1), t = () => {
8
- u.value = !1, n.value = null, c.value = null, a.value = !1;
9
- }, C = () => {
10
- s.value = !0, f(() => {
11
- f(() => {
12
- s.value = !1;
7
+ const u = n(null), C = n(null), a = n(!1), s = n(!1), t = n(!1), l = n(!1), i = () => {
8
+ l.value = !1, a.value = !1, u.value = null, r.value = null, s.value = !1;
9
+ }, m = () => {
10
+ l.value = !0;
11
+ }, c = () => {
12
+ t.value = !0, p(() => {
13
+ p(() => {
14
+ t.value = !1;
13
15
  });
14
16
  });
15
- }, i = (e) => {
16
- n.value = e, u.value = !0, a.value = !1, c.value = null, C();
17
+ }, f = (e) => {
18
+ l.value = !1, u.value = e, a.value = !0, s.value = !1, r.value = null, c();
17
19
  };
18
20
  return {
19
- activeChannelType: n,
20
- hoveredChannel: h,
21
- showMenu: u,
22
- showSubMenu: a,
21
+ activeChannelType: u,
22
+ hoveredChannel: C,
23
+ showMenu: a,
24
+ showSubMenu: s,
25
+ retainOpenUntilDismiss: l,
23
26
  handleChannelClick: (e) => {
24
- if (d.value === e && n.value === e) {
25
- t();
27
+ if (h.value === e && u.value === e) {
28
+ i();
26
29
  return;
27
30
  }
28
- i(e);
31
+ f(e);
29
32
  },
30
- openMenu: i,
31
- closeMenu: t,
33
+ openMenu: f,
34
+ closeMenu: i,
35
+ pinMenuOpen: m,
36
+ armOutsideClickSuppression: c,
32
37
  handleClickOutside: (e) => {
33
- if (s.value)
38
+ if (t.value || l.value)
34
39
  return;
35
- const o = v.value;
40
+ const o = d.value;
36
41
  if (!o)
37
42
  return;
38
- const r = typeof e.composedPath == "function" ? e.composedPath() : [];
39
- Array.isArray(r) && r.includes(o) || o.contains(e.target) || t();
43
+ const v = typeof e.composedPath == "function" ? e.composedPath() : [];
44
+ Array.isArray(v) && v.includes(o) || o.contains(e.target) || i();
40
45
  }
41
46
  };
42
47
  }
43
48
  export {
44
- M as useCommunicationMenu
49
+ w as useCommunicationMenu
45
50
  };
@@ -1,58 +1,67 @@
1
- import { ref as C } from "vue";
2
- function N({
3
- activeChannelType: g,
4
- showSubMenu: n,
5
- frozenAttribute: o,
6
- hoveredAttribute: b,
7
- hasMultipleChannels: h,
8
- isAttributeBlocked: M
1
+ import { ref as E } from "vue";
2
+ function O({
3
+ activeChannelType: S,
4
+ showSubMenu: u,
5
+ frozenAttribute: n,
6
+ hoveredAttribute: c,
7
+ confirmingAttributeId: v,
8
+ retainOpenUntilDismiss: i,
9
+ hasMultipleChannels: b,
10
+ isAttributeBlocked: f
9
11
  }) {
10
- const t = C(0);
12
+ const l = E(0), y = () => i.value || !!v.value || f(c.value ?? n.value);
11
13
  return {
12
- subMenuTop: t,
13
- handleAttributeMouseEnter: (e, l) => {
14
- const u = g.value;
15
- return !u || !h(u) || M(e) ? null : (b.value = e, n.value = !0, o.value = e, l);
14
+ subMenuTop: l,
15
+ handleAttributeMouseEnter: (e, o) => {
16
+ const t = S.value;
17
+ if (!t || !b(t))
18
+ return null;
19
+ if (i.value || v.value) {
20
+ const a = n.value ?? c.value;
21
+ if (u.value || a && a.id !== e.id)
22
+ return null;
23
+ }
24
+ return c.value = e, u.value = !0, n.value = e, o;
16
25
  },
17
26
  handleAttributeMouseLeave: () => {
18
- n.value || (o.value = null);
27
+ u.value || (n.value = null);
19
28
  },
20
29
  keepSubMenuOpen: () => {
21
- n.value = !0;
30
+ u.value = !0;
22
31
  },
23
32
  closeSubMenu: () => {
24
- n.value = !1, o.value = null;
33
+ y() || (u.value = !1, n.value = null);
25
34
  },
26
- alignSubMenuWithTarget: (e, l) => {
27
- var u, r, s;
28
- if (!l) {
29
- t.value = 0;
35
+ alignSubMenuWithTarget: (e, o) => {
36
+ var t, a, d;
37
+ if (!o) {
38
+ l.value = 0;
30
39
  return;
31
40
  }
32
41
  try {
33
- const i = (u = e.value) == null ? void 0 : u.querySelector(".attributes-menu"), a = (r = e.value) == null ? void 0 : r.querySelector(".sub-menu-header"), v = (s = e.value) == null ? void 0 : s.querySelector(".sub-menu");
34
- if (!i) {
35
- t.value = 0;
42
+ const p = (t = e.value) == null ? void 0 : t.querySelector(".attributes-menu"), s = (a = e.value) == null ? void 0 : a.querySelector(".sub-menu-header"), m = (d = e.value) == null ? void 0 : d.querySelector(".sub-menu");
43
+ if (!p) {
44
+ l.value = 0;
36
45
  return;
37
46
  }
38
- const S = i.getBoundingClientRect(), y = l.getBoundingClientRect();
39
- let m = 0;
40
- if (a) {
41
- const c = a.getBoundingClientRect(), f = getComputedStyle(a), p = parseFloat(f.marginBottom || "0");
42
- m = c.height + (Number.isNaN(p) ? 0 : p);
47
+ const B = p.getBoundingClientRect(), C = o.getBoundingClientRect();
48
+ let g = 0;
49
+ if (s) {
50
+ const r = s.getBoundingClientRect(), T = getComputedStyle(s), h = parseFloat(T.marginBottom || "0");
51
+ g = r.height + (Number.isNaN(h) ? 0 : h);
43
52
  }
44
- let d = 0;
45
- if (v) {
46
- const c = getComputedStyle(v);
47
- d = parseFloat(c.paddingTop || "0") || 0;
53
+ let M = 0;
54
+ if (m) {
55
+ const r = getComputedStyle(m);
56
+ M = parseFloat(r.paddingTop || "0") || 0;
48
57
  }
49
- t.value = y.top - S.top - m - d - 2;
58
+ l.value = C.top - B.top - g - M - 2;
50
59
  } catch {
51
- t.value = 0;
60
+ l.value = 0;
52
61
  }
53
62
  }
54
63
  };
55
64
  }
56
65
  export {
57
- N as useCommunicationSubMenu
66
+ O as useCommunicationSubMenu
58
67
  };
@@ -1,4 +1,6 @@
1
1
  declare const _default: import("vue").DefineComponent<{}, {
2
+ /** Снять pin и закрыть оба меню (вызывать с host при ОК на splash). */
3
+ closeMenu: () => void;
2
4
  $emit: (event: "select-attribute-channel" | "confirm-attribute" | "phone-call" | "reset-blocked-attributes", ...args: any[]) => void;
3
5
  channels: unknown[];
4
6
  messages: unknown[];
@@ -32,6 +32,8 @@ interface UseCommunicationActionsOptions {
32
32
  confirmingAttributeId: Ref<string | null>;
33
33
  isAttributeBlocked: (attribute: ContactAttribute | null | undefined) => boolean;
34
34
  closeMenu: () => void;
35
+ /** Закрепить меню до closeMenu (клик снаружи) — на время confirm-attribute. */
36
+ pinMenuOpen: () => void;
35
37
  hasMultipleChannels: (channelType: string) => boolean;
36
38
  getSingleChannelForType: (channelType: string) => Channel | null;
37
39
  getAvailableChannels: (channelType: string) => Channel[];
@@ -50,7 +52,7 @@ interface UseCommunicationActionsOptions {
50
52
  /**
51
53
  * Инкапсулирует действия панели: звонок, выбор каналов, выбор атрибутов.
52
54
  */
53
- export declare function useCommunicationActions({ activeChannelType, channels, selectedChannel, selectedChannelType, hoveredAttribute, confirmingAttributeId, isAttributeBlocked, closeMenu, hasMultipleChannels, getSingleChannelForType, getAvailableChannels, isChannelEmpty, isNewDialog, showDefaultChannelTooltipWithTimer, clearDefaultChannelTooltip, emit, panelPendingSelection, }: UseCommunicationActionsOptions): {
55
+ export declare function useCommunicationActions({ activeChannelType, channels, selectedChannel, selectedChannelType, hoveredAttribute, confirmingAttributeId, isAttributeBlocked, closeMenu, pinMenuOpen, hasMultipleChannels, getSingleChannelForType, getAvailableChannels, isChannelEmpty, isNewDialog, showDefaultChannelTooltipWithTimer, clearDefaultChannelTooltip, emit, panelPendingSelection, }: UseCommunicationActionsOptions): {
54
56
  handlePhoneCall: (attribute: ContactAttribute | null | undefined) => void;
55
57
  handleAttributeClick: (attribute: ContactAttribute) => void;
56
58
  selectSingleChannel: (attribute: ContactAttribute, channelId: string) => void;
@@ -18,9 +18,12 @@ export declare function useCommunicationMenu({ panelRef, selectedChannelType, fr
18
18
  hoveredChannel: Ref<string | null, string | null>;
19
19
  showMenu: Ref<boolean, boolean>;
20
20
  showSubMenu: Ref<boolean, boolean>;
21
+ retainOpenUntilDismiss: Ref<boolean, boolean>;
21
22
  handleChannelClick: (channelType: string) => void;
22
23
  openMenu: (channelType: string) => void;
23
24
  closeMenu: () => void;
25
+ pinMenuOpen: () => void;
26
+ armOutsideClickSuppression: () => void;
24
27
  handleClickOutside: (event: Event) => void;
25
28
  };
26
29
  export {};
@@ -1,17 +1,19 @@
1
- import { type Ref } from 'vue';
1
+ import { type ComputedRef, type Ref } from 'vue';
2
2
  import type { ContactAttribute } from './useCommunicationAttributes';
3
3
  interface UseCommunicationSubMenuOptions {
4
4
  activeChannelType: Ref<string | null>;
5
5
  showSubMenu: Ref<boolean>;
6
6
  frozenAttribute: Ref<ContactAttribute | null>;
7
7
  hoveredAttribute: Ref<ContactAttribute | null>;
8
+ confirmingAttributeId: Ref<string | null> | ComputedRef<string | null>;
9
+ retainOpenUntilDismiss: Ref<boolean>;
8
10
  hasMultipleChannels: (channelType: string) => boolean;
9
11
  isAttributeBlocked: (attribute: ContactAttribute | null | undefined) => boolean;
10
12
  }
11
13
  /**
12
14
  * Управляет состоянием подменю выбора канала и hover-состояниями атрибутов.
13
15
  */
14
- export declare function useCommunicationSubMenu({ activeChannelType, showSubMenu, frozenAttribute, hoveredAttribute, hasMultipleChannels, isAttributeBlocked, }: UseCommunicationSubMenuOptions): {
16
+ export declare function useCommunicationSubMenu({ activeChannelType, showSubMenu, frozenAttribute, hoveredAttribute, confirmingAttributeId, retainOpenUntilDismiss, hasMultipleChannels, isAttributeBlocked, }: UseCommunicationSubMenuOptions): {
15
17
  subMenuTop: Ref<number, number>;
16
18
  handleAttributeMouseEnter: (attribute: ContactAttribute, eventTarget: EventTarget | null) => EventTarget | null;
17
19
  handleAttributeMouseLeave: () => void;
@@ -2,6 +2,7 @@ import type { StoryObj } from '@storybook/vue3-vite';
2
2
  declare const meta: {
3
3
  title: string;
4
4
  component: import("vue").DefineComponent<{}, {
5
+ closeMenu: () => void;
5
6
  $emit: (event: "select-attribute-channel" | "confirm-attribute" | "phone-call" | "reset-blocked-attributes", ...args: any[]) => void;
6
7
  channels: unknown[];
7
8
  messages: unknown[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mobilon-dev/chotto",
3
- "version": "0.3.85",
3
+ "version": "0.3.86",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",