@kommo-crm/crm-react-ui-kit 1.1.1-beta.1 → 1.1.1-beta.4

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.
Files changed (43) hide show
  1. package/dist/assets/ItemRightSlot.css +1 -1
  2. package/dist/components/ContextMenu/ContextMenu.js +1 -1
  3. package/dist/components/ContextMenu/components/CheckboxItem/CheckboxItem.d.ts.map +1 -1
  4. package/dist/components/ContextMenu/components/CheckboxItem/CheckboxItem.js +64 -43
  5. package/dist/components/ContextMenu/components/Content/Content.d.ts.map +1 -1
  6. package/dist/components/ContextMenu/components/Content/Content.js +1 -1
  7. package/dist/components/ContextMenu/components/Content/index.js +1 -1
  8. package/dist/components/ContextMenu/components/Item/Item.d.ts.map +1 -1
  9. package/dist/components/ContextMenu/components/Item/Item.js +77 -58
  10. package/dist/components/ContextMenu/components/ItemRightSlot/ItemRightSlot.d.ts.map +1 -1
  11. package/dist/components/ContextMenu/components/ItemRightSlot/ItemRightSlot.js +44 -21
  12. package/dist/components/ContextMenu/components/RadioItem/RadioItem.d.ts.map +1 -1
  13. package/dist/components/ContextMenu/components/RadioItem/RadioItem.js +60 -33
  14. package/dist/components/ContextMenu/components/Sub/Sub.js +1 -1
  15. package/dist/components/ContextMenu/components/SubContent/SubContent.d.ts.map +1 -1
  16. package/dist/components/ContextMenu/components/SubContent/SubContent.js +64 -52
  17. package/dist/components/ContextMenu/components/SubRoot/SubRoot.js +1 -1
  18. package/dist/components/ContextMenu/components/SubRoot/components/Content/Content.d.ts.map +1 -1
  19. package/dist/components/ContextMenu/components/SubRoot/components/Content/Content.js +83 -74
  20. package/dist/components/ContextMenu/components/SubRoot/components/Trigger/Trigger.d.ts.map +1 -1
  21. package/dist/components/ContextMenu/components/SubRoot/components/Trigger/Trigger.js +58 -36
  22. package/dist/components/ContextMenu/components/SubTrigger/SubTrigger.d.ts.map +1 -1
  23. package/dist/components/ContextMenu/components/SubTrigger/SubTrigger.js +82 -60
  24. package/dist/components/ContextMenu/components/Trigger/Trigger.d.ts.map +1 -1
  25. package/dist/components/ContextMenu/components/Trigger/Trigger.js +40 -22
  26. package/dist/components/ContextMenu/hooks/index.js +1 -1
  27. package/dist/components/ContextMenu/hooks/useContentPositioning/useContentPositioning.d.ts.map +1 -1
  28. package/dist/components/ContextMenu/hooks/useContentPositioning/useContentPositioning.js +1 -1
  29. package/dist/components/ContextMenu/hooks/useContextMenu/useContextMenu.d.ts.map +1 -1
  30. package/dist/components/ContextMenu/hooks/useContextMenu/useContextMenu.js +57 -57
  31. package/dist/components/ContextMenu/hooks/useContextMenuSub/useContextMenuSub.js +1 -1
  32. package/dist/components/ContextMenu/hooks/useContextMenuSubMenu/useContextMenuSubMenu.d.ts.map +1 -1
  33. package/dist/components/ContextMenu/hooks/useContextMenuSubMenu/useContextMenuSubMenu.js +40 -40
  34. package/dist/components/ContextMenu/hooks/useStopContextMenuEvents/useStopContextMenuEvents.d.ts +11 -10
  35. package/dist/components/ContextMenu/hooks/useStopContextMenuEvents/useStopContextMenuEvents.d.ts.map +1 -1
  36. package/dist/components/ContextMenu/hooks/useStopContextMenuEvents/useStopContextMenuEvents.js +17 -15
  37. package/dist/components/ContextMenu/hooks/useStopContextMenuEvents/useStopContextMenuEvents.types.d.ts +3 -0
  38. package/dist/components/ContextMenu/hooks/useStopContextMenuEvents/useStopContextMenuEvents.types.d.ts.map +1 -0
  39. package/dist/components/ContextMenu/hooks/useStopContextMenuEvents/useStopContextMenuEvents.types.js +1 -0
  40. package/dist/components/ContextMenu/index.js +1 -1
  41. package/dist/useContentPositioning-BLCC-Xty.mjs +213 -0
  42. package/package.json +2 -2
  43. package/dist/useContentPositioning-27D32n5u.mjs +0 -185
@@ -0,0 +1,213 @@
1
+ import { forwardRef as A, useState as H, useLayoutEffect as v } from "react";
2
+ import { jsx as P } from "react/jsx-runtime";
3
+ import { C as F } from "./index-BA3njR2k.mjs";
4
+ import { c as R } from "./index-L8X2o7IH.mjs";
5
+ import { u as U, a as k, e as S } from "./react-spring_web.modern-Dnq1lqN5.mjs";
6
+ import { mergeRefs as z } from "./lib/utils.js";
7
+ import { LevelProvider as B } from "./components/ContextMenu/providers/LevelProvider/LevelProvider.js";
8
+ import { useContextMenuContext as j } from "./components/ContextMenu/ContextMenu.context.js";
9
+ import { ContextMenuMode as w } from "./components/ContextMenu/ContextMenu.enums.js";
10
+ import { Direction as e } from "./components/ContextMenu/components/Content/Content.enums.js";
11
+ import { directionToSide as K } from "./components/ContextMenu/components/Content/Content.utils.js";
12
+ import './assets/useContentPositioning.css';const q = "_content_k9opk_1", X = {
13
+ content: q
14
+ }, x = "ContextMenu.Content", Y = A(
15
+ ({
16
+ style: a,
17
+ className: g,
18
+ children: h,
19
+ alignOffset: o,
20
+ arrowPadding: c = 5,
21
+ collisionBoundary: C,
22
+ direction: O = e.DOWN_RIGHT,
23
+ disableAutoPositioning: p = !1,
24
+ onMouseEnter: E,
25
+ onMouseLeave: b,
26
+ ...N
27
+ }, G) => {
28
+ const [W, r] = H(!1), [i, I] = H(null), {
29
+ triggerRef: s,
30
+ contentRef: f,
31
+ animatedOpen: _,
32
+ animationDuration: u,
33
+ mode: l,
34
+ temporaryHoverClose: d,
35
+ onMouseEnter: n,
36
+ onMouseLeave: t
37
+ } = j(x), { align: m, labelOffset: D, isPositioned: L } = J({
38
+ direction: O,
39
+ alignOffset: o,
40
+ disableAutoPositioning: p,
41
+ triggerRef: s,
42
+ contentRef: f,
43
+ collisionBoundary: C,
44
+ children: h
45
+ }), y = U({
46
+ opacity: L && (l === w.CLICK && !d || _) ? 1 : 0,
47
+ config: l === w.CLICK && !d ? { duration: 0 } : { duration: u, easing: S.easeInOutCubic }
48
+ });
49
+ return /* @__PURE__ */ P(
50
+ B,
51
+ {
52
+ hasItemWithIcon: W,
53
+ setHasItemWithIcon: r,
54
+ activeItemId: i,
55
+ setActiveItemId: I,
56
+ children: /* @__PURE__ */ P(
57
+ k.div,
58
+ {
59
+ style: {
60
+ zIndex: Number.MAX_SAFE_INTEGER,
61
+ position: "fixed",
62
+ ...y
63
+ },
64
+ "data-content-wrapper": !0,
65
+ children: /* @__PURE__ */ P(
66
+ F,
67
+ {
68
+ ref: z(f, G),
69
+ className: R(X.content, g),
70
+ style: {
71
+ ...a || {},
72
+ pointerEvents: p || L ? "auto" : "none"
73
+ },
74
+ collisionBoundary: C,
75
+ side: K[O],
76
+ align: m,
77
+ arrowPadding: c,
78
+ alignOffset: D,
79
+ onMouseEnter: (T) => {
80
+ n == null || n(T), E == null || E(T);
81
+ },
82
+ onMouseLeave: (T) => {
83
+ t == null || t(T), b == null || b(T);
84
+ },
85
+ ...N,
86
+ children: h
87
+ }
88
+ )
89
+ }
90
+ )
91
+ }
92
+ );
93
+ }
94
+ );
95
+ Y.displayName = x;
96
+ function J({
97
+ direction: a,
98
+ alignOffset: g = 0,
99
+ disableAutoPositioning: h,
100
+ triggerRef: o,
101
+ contentRef: c,
102
+ collisionBoundary: C,
103
+ children: O
104
+ }) {
105
+ const [p, E] = H(
106
+ a === e.UP_RIGHT || a === e.DOWN_RIGHT || a === e.RIGHT_UP || a === e.RIGHT_DOWN ? "start" : "end"
107
+ ), [b, N] = H(g), [G, W] = H(!1);
108
+ return v(() => {
109
+ const r = c == null ? void 0 : c.current;
110
+ if (!r || h || [
111
+ e.DOWN_LEFT,
112
+ e.DOWN_RIGHT,
113
+ e.UP_LEFT,
114
+ e.UP_RIGHT
115
+ ].includes(a))
116
+ return;
117
+ const i = r.children;
118
+ if (!i || i.length === 0)
119
+ return;
120
+ const I = r.firstElementChild;
121
+ let s = null;
122
+ if (p === "start") {
123
+ const t = i.item(1);
124
+ if (t instanceof Element && t.hasAttribute("data-separator")) {
125
+ const m = i.item(2);
126
+ m instanceof Element ? s = m : s = null;
127
+ } else t instanceof Element && (s = t);
128
+ } else {
129
+ const t = i.length - 1, m = i.item(t);
130
+ if (m instanceof Element && m.hasAttribute("data-arrow")) {
131
+ const D = i.item(t - 1);
132
+ D instanceof Element ? s = D : s = null;
133
+ } else m instanceof Element && (s = m);
134
+ }
135
+ const f = o == null ? void 0 : o.current;
136
+ if (!f || !s)
137
+ return;
138
+ const _ = s.getBoundingClientRect(), u = f.getBoundingClientRect(), l = _.height, n = (u.height - l) / 2;
139
+ if (p === "start") {
140
+ if (I instanceof Element && I.hasAttribute("data-label")) {
141
+ const t = I.getBoundingClientRect().height;
142
+ N(g - t + n);
143
+ }
144
+ } else
145
+ N(g + n - 1);
146
+ }, [
147
+ O,
148
+ a,
149
+ c,
150
+ o,
151
+ p,
152
+ g,
153
+ h
154
+ ]), v(() => {
155
+ if (h || !(o != null && o.current))
156
+ return;
157
+ let r = null, i = !0;
158
+ const I = C instanceof Element && C || document.documentElement, s = () => {
159
+ if (!i)
160
+ return;
161
+ const f = o.current, _ = c.current;
162
+ if (!f || !_)
163
+ return;
164
+ const u = f.getBoundingClientRect(), l = _.getBoundingClientRect();
165
+ if (l.width <= 0)
166
+ return;
167
+ const d = I.getBoundingClientRect(), n = {
168
+ right: d.right - u.right >= l.width,
169
+ left: u.left - d.left >= l.width,
170
+ bottom: d.bottom - u.bottom >= l.height,
171
+ top: u.top - d.top >= l.height
172
+ };
173
+ let t = "start";
174
+ switch (a) {
175
+ case e.UP_RIGHT:
176
+ case e.DOWN_RIGHT: {
177
+ n.right ? t = "start" : n.left ? t = "end" : t = "start";
178
+ break;
179
+ }
180
+ case e.UP_LEFT:
181
+ case e.DOWN_LEFT: {
182
+ n.left ? t = "end" : n.right ? t = "start" : t = "end";
183
+ break;
184
+ }
185
+ case e.RIGHT_DOWN:
186
+ case e.LEFT_DOWN: {
187
+ n.bottom ? t = "start" : n.top ? t = "end" : t = "start";
188
+ break;
189
+ }
190
+ case e.RIGHT_UP:
191
+ case e.LEFT_UP: {
192
+ n.top ? t = "end" : n.bottom ? t = "start" : t = "end";
193
+ break;
194
+ }
195
+ }
196
+ E(t), W(!0);
197
+ };
198
+ return requestAnimationFrame(s), c.current && typeof ResizeObserver < "u" && (r = new ResizeObserver(s), r.observe(c.current)), () => {
199
+ i = !1, r == null || r.disconnect();
200
+ };
201
+ }, [
202
+ a,
203
+ h,
204
+ o,
205
+ c,
206
+ C
207
+ ]), { align: p, labelOffset: b, isPositioned: G };
208
+ }
209
+ export {
210
+ Y as C,
211
+ X as s,
212
+ J as u
213
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kommo-crm/crm-react-ui-kit",
3
3
  "description": "Ready-to-use React components which implements Kommo design",
4
- "version": "1.1.1-beta.1",
4
+ "version": "1.1.1-beta.4",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "engines": {
@@ -221,4 +221,4 @@
221
221
  "react-dom": "^18.0"
222
222
  },
223
223
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
224
- }
224
+ }
@@ -1,185 +0,0 @@
1
- import { forwardRef as W, useState as _, useLayoutEffect as D } from "react";
2
- import { jsx as N } from "react/jsx-runtime";
3
- import { C as x } from "./index-BA3njR2k.mjs";
4
- import { c as A } from "./index-L8X2o7IH.mjs";
5
- import { u as M, a as w, e as y } from "./react-spring_web.modern-Dnq1lqN5.mjs";
6
- import { mergeRefs as F } from "./lib/utils.js";
7
- import { LevelProvider as U } from "./components/ContextMenu/providers/LevelProvider/LevelProvider.js";
8
- import { useContextMenuContext as k } from "./components/ContextMenu/ContextMenu.context.js";
9
- import { ContextMenuMode as G } from "./components/ContextMenu/ContextMenu.enums.js";
10
- import { Direction as e } from "./components/ContextMenu/components/Content/Content.enums.js";
11
- import { directionToSide as S } from "./components/ContextMenu/components/Content/Content.utils.js";
12
- import './assets/useContentPositioning.css';const z = "_content_k9opk_1", B = {
13
- content: z
14
- }, v = "ContextMenu.Content", j = W(
15
- ({
16
- style: s,
17
- className: C,
18
- children: f,
19
- alignOffset: a,
20
- arrowPadding: c = 5,
21
- collisionBoundary: h,
22
- direction: b = e.DOWN_RIGHT,
23
- disableAutoPositioning: m = !1,
24
- ...T
25
- }, H) => {
26
- const [E, O] = _(!1), [L, t] = _(null), {
27
- triggerRef: u,
28
- contentRef: r,
29
- animatedOpen: d,
30
- animationDuration: g,
31
- mode: p,
32
- temporaryHoverClose: o,
33
- onMouseEnter: l,
34
- onMouseLeave: I
35
- } = k(v), { align: i, labelOffset: n, isPositioned: R } = K({
36
- direction: b,
37
- alignOffset: a,
38
- disableAutoPositioning: m,
39
- triggerRef: u,
40
- contentRef: r,
41
- collisionBoundary: h,
42
- children: f
43
- }), P = M({
44
- opacity: R && (p === G.CLICK && !o || d) ? 1 : 0,
45
- config: p === G.CLICK && !o ? { duration: 0 } : { duration: g, easing: y.easeInOutCubic }
46
- });
47
- return /* @__PURE__ */ N(
48
- U,
49
- {
50
- hasItemWithIcon: E,
51
- setHasItemWithIcon: O,
52
- activeItemId: L,
53
- setActiveItemId: t,
54
- children: /* @__PURE__ */ N(
55
- w.div,
56
- {
57
- style: {
58
- zIndex: Number.MAX_SAFE_INTEGER,
59
- position: "fixed",
60
- ...P
61
- },
62
- "data-content-wrapper": !0,
63
- children: /* @__PURE__ */ N(
64
- x,
65
- {
66
- ref: F(r, H),
67
- className: A(B.content, C),
68
- style: {
69
- ...s || {},
70
- pointerEvents: m || R ? "auto" : "none"
71
- },
72
- collisionBoundary: h,
73
- side: S[b],
74
- align: i,
75
- arrowPadding: c,
76
- alignOffset: n,
77
- onMouseEnter: l,
78
- onMouseLeave: I,
79
- ...T,
80
- children: f
81
- }
82
- )
83
- }
84
- )
85
- }
86
- );
87
- }
88
- );
89
- j.displayName = v;
90
- function K({
91
- direction: s,
92
- alignOffset: C = 0,
93
- disableAutoPositioning: f,
94
- triggerRef: a,
95
- contentRef: c,
96
- collisionBoundary: h,
97
- children: b
98
- }) {
99
- const [m, T] = _(
100
- s === e.UP_RIGHT || s === e.DOWN_RIGHT || s === e.RIGHT_UP || s === e.RIGHT_DOWN ? "start" : "end"
101
- ), [H, E] = _(C), [O, L] = _(!1);
102
- return D(() => {
103
- if (!c.current || f || [
104
- e.DOWN_LEFT,
105
- e.DOWN_RIGHT,
106
- e.UP_LEFT,
107
- e.UP_RIGHT
108
- ].includes(s))
109
- return;
110
- const t = c.current, u = t.firstElementChild;
111
- let r;
112
- m === "start" ? t.children[1].hasAttribute("data-separator") ? r = t.children[2] : r = t.children[1] : t.children[t.children.length - 1].hasAttribute(
113
- "data-arrow"
114
- ) ? r = t.children[t.children.length - 2] : r = t.children[t.children.length - 1];
115
- const d = a.current;
116
- if (d) {
117
- const g = r.getBoundingClientRect().height, o = (d.getBoundingClientRect().height - g) / 2;
118
- if (m === "start") {
119
- if (u instanceof HTMLElement && u.hasAttribute("data-label")) {
120
- const l = u.getBoundingClientRect().height;
121
- E(C - l + o);
122
- }
123
- } else
124
- E(C + o - 1);
125
- }
126
- }, [b, s, c, a, m]), D(() => {
127
- if (f || !(a != null && a.current))
128
- return;
129
- let t = null, u = !0;
130
- const r = h instanceof Element && h || document.documentElement, d = () => {
131
- if (!u)
132
- return;
133
- const g = a.current, p = c.current;
134
- if (!g || !p)
135
- return;
136
- const o = g.getBoundingClientRect(), l = p.getBoundingClientRect();
137
- if (l.width <= 0)
138
- return;
139
- const I = r.getBoundingClientRect(), i = {
140
- right: I.right - o.right >= l.width,
141
- left: o.left - I.left >= l.width,
142
- bottom: I.bottom - o.bottom >= l.height,
143
- top: o.top - I.top >= l.height
144
- };
145
- let n = "start";
146
- switch (s) {
147
- case e.UP_RIGHT:
148
- case e.DOWN_RIGHT: {
149
- i.right ? n = "start" : i.left ? n = "end" : n = "start";
150
- break;
151
- }
152
- case e.UP_LEFT:
153
- case e.DOWN_LEFT: {
154
- i.left ? n = "end" : i.right ? n = "start" : n = "end";
155
- break;
156
- }
157
- case e.RIGHT_DOWN:
158
- case e.LEFT_DOWN: {
159
- i.bottom ? n = "start" : i.top ? n = "end" : n = "start";
160
- break;
161
- }
162
- case e.RIGHT_UP:
163
- case e.LEFT_UP: {
164
- i.top ? n = "end" : i.bottom ? n = "start" : n = "end";
165
- break;
166
- }
167
- }
168
- T(n), L(!0);
169
- };
170
- return requestAnimationFrame(d), c.current && typeof ResizeObserver < "u" && (t = new ResizeObserver(d), t.observe(c.current)), () => {
171
- u = !1, t == null || t.disconnect();
172
- };
173
- }, [
174
- s,
175
- f,
176
- a,
177
- c,
178
- h
179
- ]), { align: m, labelOffset: H, isPositioned: O };
180
- }
181
- export {
182
- j as C,
183
- B as s,
184
- K as u
185
- };