@kommo-crm/crm-react-ui-kit 1.3.0-beta.1 → 1.3.0-beta.3
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.
- package/dist/ContextMenu-CeyT26LX.mjs +229 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +2 -2
- package/dist/components/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.js +5 -5
- package/dist/components/ContextMenu/ContextMenu.props.d.ts +19 -3
- package/dist/components/ContextMenu/ContextMenu.props.d.ts.map +1 -1
- package/dist/components/ContextMenu/components/CheckboxItem/CheckboxItem.js +1 -1
- package/dist/components/ContextMenu/components/Content/Content.d.ts.map +1 -1
- package/dist/components/ContextMenu/components/Content/Content.js +1 -1
- package/dist/components/ContextMenu/components/Content/index.js +1 -1
- package/dist/components/ContextMenu/components/Item/Item.js +1 -1
- package/dist/components/ContextMenu/components/Label/Label.js +1 -1
- package/dist/components/ContextMenu/components/RadioItem/RadioItem.js +1 -1
- package/dist/components/ContextMenu/components/Sub/Sub.js +1 -1
- package/dist/components/ContextMenu/components/Sub/Sub.props.d.ts +3 -3
- package/dist/components/ContextMenu/components/Sub/Sub.props.d.ts.map +1 -1
- package/dist/components/ContextMenu/components/Sub/hooks/useContextMenuSub/useContextMenuSub.d.ts.map +1 -1
- package/dist/components/ContextMenu/components/Sub/hooks/useContextMenuSub/useContextMenuSub.js +80 -88
- package/dist/components/ContextMenu/components/Sub/hooks/useContextMenuSub/useContextMenuSub.types.d.ts +2 -2
- package/dist/components/ContextMenu/components/Sub/hooks/useContextMenuSub/useContextMenuSub.types.d.ts.map +1 -1
- package/dist/components/ContextMenu/components/Sub/index.js +1 -1
- package/dist/components/ContextMenu/components/SubContent/SubContent.js +1 -1
- package/dist/components/ContextMenu/components/SubRoot/components/Content/Content.js +1 -1
- package/dist/components/ContextMenu/components/SubRoot/components/Trigger/Trigger.js +1 -1
- package/dist/components/ContextMenu/components/SubRoot/hooks/useContextMenuSubMenu/useContextMenuSubMenu.js +1 -1
- package/dist/components/ContextMenu/components/SubTrigger/SubTrigger.js +1 -1
- package/dist/components/ContextMenu/hooks/index.js +1 -1
- package/dist/components/ContextMenu/hooks/useContentPositioning/useContentPositioning.d.ts.map +1 -1
- package/dist/components/ContextMenu/hooks/useContentPositioning/useContentPositioning.js +1 -1
- package/dist/components/ContextMenu/hooks/useContextMenu/useContextMenu.d.ts.map +1 -1
- package/dist/components/ContextMenu/hooks/useContextMenu/useContextMenu.js +142 -133
- package/dist/components/ContextMenu/hooks/useContextMenu/useContextMenu.types.d.ts +14 -2
- package/dist/components/ContextMenu/hooks/useContextMenu/useContextMenu.types.d.ts.map +1 -1
- package/dist/components/ContextMenu/hooks/useContextMenu/utils/contextMenuBus/contextMenuBus.d.ts +3 -1
- package/dist/components/ContextMenu/hooks/useContextMenu/utils/contextMenuBus/contextMenuBus.d.ts.map +1 -1
- package/dist/components/ContextMenu/hooks/useContextMenu/utils/contextMenuBus/contextMenuBus.js +16 -10
- package/dist/components/ContextMenu/hooks/useContextMenu/utils/contextMenuBus/contextMenuBus.types.d.ts +4 -0
- package/dist/components/ContextMenu/hooks/useContextMenu/utils/contextMenuBus/contextMenuBus.types.d.ts.map +1 -1
- package/dist/components/ContextMenu/hooks/useContextMenuItemFocus/useContextMenuItemFocus.d.ts.map +1 -1
- package/dist/components/ContextMenu/hooks/useContextMenuItemFocus/useContextMenuItemFocus.js +47 -42
- package/dist/components/ContextMenu/index.js +1 -1
- package/dist/components/List/List.js +1 -1
- package/dist/components/Select/components/List/List.js +1 -1
- package/dist/index-DBS3EIVR.mjs +273 -0
- package/dist/{useContentPositioning-DfyirIME.mjs → useContentPositioning-Dfjbylz5.mjs} +456 -451
- package/package.json +3 -3
- package/dist/ContextMenu-BUiakpJf.mjs +0 -223
- package/dist/index-BH2CXQ4d.mjs +0 -257
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.3.0-beta.
|
|
4
|
+
"version": "1.3.0-beta.3",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"engines": {
|
|
@@ -204,7 +204,7 @@
|
|
|
204
204
|
"vite-plugin-svgr": "4.2.0"
|
|
205
205
|
},
|
|
206
206
|
"dependencies": {
|
|
207
|
-
"@kommo-crm/react-hooks": "1.2.1-beta.
|
|
207
|
+
"@kommo-crm/react-hooks": "1.2.1-beta.2",
|
|
208
208
|
"@radix-ui/react-dropdown-menu": "2.1.15",
|
|
209
209
|
"@react-spring/web": "10.0.1",
|
|
210
210
|
"classnames": "2.5.1",
|
|
@@ -221,4 +221,4 @@
|
|
|
221
221
|
"react-dom": "^18.0"
|
|
222
222
|
},
|
|
223
223
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
224
|
-
}
|
|
224
|
+
}
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { S as Y, a as w } from "./index-aPaPKjUe.mjs";
|
|
3
|
-
import { useContextMenu as B } from "./components/ContextMenu/hooks/useContextMenu/useContextMenu.js";
|
|
4
|
-
import "react";
|
|
5
|
-
import { C as K } from "./useContentPositioning-DfyirIME.mjs";
|
|
6
|
-
import "./components/ContextMenu/components/Content/Content.utils.js";
|
|
7
|
-
import "./components/ContextMenu/providers/LevelProvider/LevelProvider.js";
|
|
8
|
-
import "./components/ContextMenu/providers/SubMenuProvider/SubMenuProvider.js";
|
|
9
|
-
import { useContextMenuKeyboardNavigation as j } from "./components/ContextMenu/hooks/useContextMenuKeyboardNavigation/useContextMenuKeyboardNavigation.js";
|
|
10
|
-
import { Trigger as k } from "./components/ContextMenu/components/Trigger/Trigger.js";
|
|
11
|
-
import { Portal as H } from "./components/ContextMenu/components/Portal/Portal.js";
|
|
12
|
-
import { ContextMenuMode as V } from "./components/ContextMenu/ContextMenu.enums.js";
|
|
13
|
-
import { SubTrigger as $ } from "./components/ContextMenu/components/SubTrigger/SubTrigger.js";
|
|
14
|
-
import { SubContent as q } from "./components/ContextMenu/components/SubContent/SubContent.js";
|
|
15
|
-
import { Arrow as z } from "./components/ContextMenu/components/Arrow/Arrow.js";
|
|
16
|
-
import { Item as J } from "./components/ContextMenu/components/Item/Item.js";
|
|
17
|
-
import { ItemRightSlot as Q } from "./components/ContextMenu/components/ItemRightSlot/ItemRightSlot.js";
|
|
18
|
-
import { Group as X } from "./components/ContextMenu/components/Group/Group.js";
|
|
19
|
-
import { Label as Z } from "./components/ContextMenu/components/Label/Label.js";
|
|
20
|
-
import { CheckboxItem as ee } from "./components/ContextMenu/components/CheckboxItem/CheckboxItem.js";
|
|
21
|
-
import { ItemIndicator as oe } from "./components/ContextMenu/components/ItemIndicator/ItemIndicator.js";
|
|
22
|
-
import { RadioGroup as te } from "./components/ContextMenu/components/RadioGroup/RadioGroup.js";
|
|
23
|
-
import { RadioItem as ne } from "./components/ContextMenu/components/RadioItem/RadioItem.js";
|
|
24
|
-
import { Separator as re } from "./components/ContextMenu/components/Separator/Separator.js";
|
|
25
|
-
import { ItemIcon as ie } from "./components/ContextMenu/components/ItemIcon/ItemIcon.js";
|
|
26
|
-
import { __experimental_SubRoot as me } from "./components/ContextMenu/components/SubRoot/SubRoot.js";
|
|
27
|
-
import { DISPLAY_NAME as se, ContextMenuRootProvider as pe, ContextMenuProvider as ae } from "./components/ContextMenu/ContextMenu.context.js";
|
|
28
|
-
import { useContextMenuSub as ue } from "./components/ContextMenu/components/Sub/hooks/useContextMenuSub/useContextMenuSub.js";
|
|
29
|
-
import { ContextMenuSubProvider as de, DISPLAY_NAME as L } from "./components/ContextMenu/components/Sub/Sub.context.js";
|
|
30
|
-
const N = (p) => {
|
|
31
|
-
const {
|
|
32
|
-
children: a,
|
|
33
|
-
mode: n = V.HOVER,
|
|
34
|
-
onOpen: e,
|
|
35
|
-
defaultOpen: r,
|
|
36
|
-
shouldCloseRootMenuOnSelect: u = !0,
|
|
37
|
-
shouldCloseCurrentMenuOnSelect: d = !0,
|
|
38
|
-
onAiming: l,
|
|
39
|
-
isAimingTolerance: c = T,
|
|
40
|
-
isAimingIdleTimeout: O = v,
|
|
41
|
-
...C
|
|
42
|
-
} = p, {
|
|
43
|
-
isOpen: i,
|
|
44
|
-
setIsOpen: I,
|
|
45
|
-
isAnimatedOpen: o,
|
|
46
|
-
handleContentEnter: f,
|
|
47
|
-
handleContentLeave: h,
|
|
48
|
-
handleOpenChange: m,
|
|
49
|
-
triggerId: A,
|
|
50
|
-
onOpenByKeyboard: g,
|
|
51
|
-
contentRef: M,
|
|
52
|
-
triggerRef: R,
|
|
53
|
-
onChildOpen: S,
|
|
54
|
-
onSubRootOpen: s,
|
|
55
|
-
closeMenuImmediately: _,
|
|
56
|
-
itemWithFocusedInput: b,
|
|
57
|
-
setItemWithFocusedInput: E,
|
|
58
|
-
isAiming: D,
|
|
59
|
-
handlePointerDownOutside: x
|
|
60
|
-
} = ue({
|
|
61
|
-
displayName: L,
|
|
62
|
-
mode: n,
|
|
63
|
-
defaultOpen: r,
|
|
64
|
-
onOpen: e,
|
|
65
|
-
onAiming: l,
|
|
66
|
-
isAimingTolerance: c,
|
|
67
|
-
isAimingIdleTimeout: O
|
|
68
|
-
});
|
|
69
|
-
return /* @__PURE__ */ t(
|
|
70
|
-
de,
|
|
71
|
-
{
|
|
72
|
-
mode: n,
|
|
73
|
-
isOpen: i,
|
|
74
|
-
setIsOpen: I,
|
|
75
|
-
isAnimatedOpen: o,
|
|
76
|
-
defaultOpen: r,
|
|
77
|
-
onContentEnter: f,
|
|
78
|
-
onContentLeave: h,
|
|
79
|
-
onOpenByKeyboard: g,
|
|
80
|
-
triggerId: A,
|
|
81
|
-
contentRef: M,
|
|
82
|
-
triggerRef: R,
|
|
83
|
-
onChildOpen: S,
|
|
84
|
-
onSubRootOpen: s,
|
|
85
|
-
shouldCloseRootMenuOnSelect: u,
|
|
86
|
-
shouldCloseCurrentMenuOnSelect: d,
|
|
87
|
-
closeMenuImmediately: _,
|
|
88
|
-
itemWithFocusedInput: b,
|
|
89
|
-
setItemWithFocusedInput: E,
|
|
90
|
-
isAiming: D,
|
|
91
|
-
onPointerDownOutside: x,
|
|
92
|
-
children: /* @__PURE__ */ t(
|
|
93
|
-
Y,
|
|
94
|
-
{
|
|
95
|
-
open: i,
|
|
96
|
-
onOpenChange: m,
|
|
97
|
-
...C,
|
|
98
|
-
children: a
|
|
99
|
-
}
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
|
-
N.displayName = L;
|
|
105
|
-
const le = 200, ce = 150, T = 0, v = 200, y = (p) => {
|
|
106
|
-
const {
|
|
107
|
-
children: a,
|
|
108
|
-
mode: n,
|
|
109
|
-
isOpen: e,
|
|
110
|
-
defaultOpen: r,
|
|
111
|
-
shouldCloseCurrentMenuOnSelect: u = !0,
|
|
112
|
-
onOpen: d,
|
|
113
|
-
onAnimatedOpen: l,
|
|
114
|
-
onAiming: c,
|
|
115
|
-
isAimingTolerance: O = T,
|
|
116
|
-
isAimingIdleTimeout: C = v,
|
|
117
|
-
...i
|
|
118
|
-
} = p, {
|
|
119
|
-
mode: I,
|
|
120
|
-
isOpen: o,
|
|
121
|
-
triggerRef: f,
|
|
122
|
-
contentRef: h,
|
|
123
|
-
isAnimatedOpen: m,
|
|
124
|
-
animationDuration: A,
|
|
125
|
-
hoverCloseDelay: g,
|
|
126
|
-
isRootContentBlocked: M,
|
|
127
|
-
isChildOpen: R,
|
|
128
|
-
itemWithFocusedInput: S,
|
|
129
|
-
closeMenuImmediately: s,
|
|
130
|
-
onOpenChange: _,
|
|
131
|
-
onContentEnter: b,
|
|
132
|
-
onContentLeave: E,
|
|
133
|
-
onOpenByKeyboard: D,
|
|
134
|
-
onChildOpen: x,
|
|
135
|
-
onSubmenuOpen: P,
|
|
136
|
-
setItemWithFocusedInput: F,
|
|
137
|
-
shouldPreventFocusRestore: G,
|
|
138
|
-
setOnFocusOutside: U
|
|
139
|
-
} = B({
|
|
140
|
-
mode: n,
|
|
141
|
-
defaultOpen: r,
|
|
142
|
-
animationDuration: ce,
|
|
143
|
-
hoverCloseDelay: le,
|
|
144
|
-
isOpen: e,
|
|
145
|
-
onOpen: d,
|
|
146
|
-
onAnimatedOpen: l,
|
|
147
|
-
onAiming: c,
|
|
148
|
-
isAimingTolerance: O,
|
|
149
|
-
isAimingIdleTimeout: C
|
|
150
|
-
}), { navigationContentRef: W } = j({
|
|
151
|
-
isOpen: e ?? o,
|
|
152
|
-
isAnimatedOpen: m
|
|
153
|
-
});
|
|
154
|
-
return /* @__PURE__ */ t(
|
|
155
|
-
pe,
|
|
156
|
-
{
|
|
157
|
-
closeRootMenuImmediately: s,
|
|
158
|
-
navigationContentRef: W,
|
|
159
|
-
children: /* @__PURE__ */ t(
|
|
160
|
-
ae,
|
|
161
|
-
{
|
|
162
|
-
mode: I,
|
|
163
|
-
triggerRef: f,
|
|
164
|
-
contentRef: h,
|
|
165
|
-
isAnimatedOpen: m,
|
|
166
|
-
animationDuration: A,
|
|
167
|
-
hoverCloseDelay: g,
|
|
168
|
-
closeMenuImmediately: s,
|
|
169
|
-
onContentEnter: b,
|
|
170
|
-
onContentLeave: E,
|
|
171
|
-
onOpenByKeyboard: D,
|
|
172
|
-
shouldCloseCurrentMenuOnSelect: u,
|
|
173
|
-
onChildOpen: x,
|
|
174
|
-
isOpen: o,
|
|
175
|
-
onSubmenuOpen: P,
|
|
176
|
-
isRootContentBlocked: M,
|
|
177
|
-
isChildOpen: R,
|
|
178
|
-
itemWithFocusedInput: S,
|
|
179
|
-
setItemWithFocusedInput: F,
|
|
180
|
-
shouldPreventFocusRestore: G,
|
|
181
|
-
setOnFocusOutside: U,
|
|
182
|
-
children: /* @__PURE__ */ t(
|
|
183
|
-
w,
|
|
184
|
-
{
|
|
185
|
-
open: e ?? o,
|
|
186
|
-
onOpenChange: _,
|
|
187
|
-
modal: !1,
|
|
188
|
-
...i,
|
|
189
|
-
children: a
|
|
190
|
-
}
|
|
191
|
-
)
|
|
192
|
-
}
|
|
193
|
-
)
|
|
194
|
-
}
|
|
195
|
-
);
|
|
196
|
-
}, je = Object.assign(y, {
|
|
197
|
-
displayName: se,
|
|
198
|
-
Root: y,
|
|
199
|
-
experimental_SubRoot: me,
|
|
200
|
-
Trigger: k,
|
|
201
|
-
Content: K,
|
|
202
|
-
Portal: H,
|
|
203
|
-
Sub: N,
|
|
204
|
-
SubTrigger: $,
|
|
205
|
-
SubContent: q,
|
|
206
|
-
Arrow: z,
|
|
207
|
-
Item: J,
|
|
208
|
-
ItemRightSlot: Q,
|
|
209
|
-
Group: X,
|
|
210
|
-
Label: Z,
|
|
211
|
-
CheckboxItem: ee,
|
|
212
|
-
RadioGroup: te,
|
|
213
|
-
RadioItem: ne,
|
|
214
|
-
ItemIndicator: oe,
|
|
215
|
-
Separator: re,
|
|
216
|
-
ItemIcon: ie
|
|
217
|
-
});
|
|
218
|
-
export {
|
|
219
|
-
je as C,
|
|
220
|
-
T as D,
|
|
221
|
-
N as S,
|
|
222
|
-
v as a
|
|
223
|
-
};
|
package/dist/index-BH2CXQ4d.mjs
DELETED
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import { useState as M, useEffect as A, useCallback as C, useRef as E } from "react";
|
|
2
|
-
var I = "ArrowUp", D = "ArrowDown", O = "Escape", L = "Enter", k = "Space", S = [I, D, L, k], z = (e) => {
|
|
3
|
-
const {
|
|
4
|
-
itemsLength: t,
|
|
5
|
-
onSelect: n,
|
|
6
|
-
onToggle: r,
|
|
7
|
-
onHoveredIndexChange: c = () => {
|
|
8
|
-
},
|
|
9
|
-
isOpened: o = !1,
|
|
10
|
-
hoveredIndex: i = 0,
|
|
11
|
-
listRef: f
|
|
12
|
-
} = e, [u, g] = M(i);
|
|
13
|
-
A(() => {
|
|
14
|
-
g(i);
|
|
15
|
-
}, [i]);
|
|
16
|
-
const x = (m) => {
|
|
17
|
-
g(m), c(m);
|
|
18
|
-
}, y = C((m) => {
|
|
19
|
-
if (!f || !f.current)
|
|
20
|
-
return;
|
|
21
|
-
const l = f.current, s = l.querySelector(
|
|
22
|
-
`li:nth-child(${m + 1})`
|
|
23
|
-
);
|
|
24
|
-
if (!s)
|
|
25
|
-
return;
|
|
26
|
-
const a = l.getBoundingClientRect().top, v = s.getBoundingClientRect().top, h = l.scrollTop + (v - a) - l.offsetHeight / 2 + s.offsetHeight / 2;
|
|
27
|
-
l.scrollTop = h, x(m);
|
|
28
|
-
}, []), d = C(
|
|
29
|
-
(m) => {
|
|
30
|
-
switch (S.includes(m.code) && m.preventDefault(), m.code) {
|
|
31
|
-
case O:
|
|
32
|
-
o && r(!1);
|
|
33
|
-
break;
|
|
34
|
-
case I:
|
|
35
|
-
o && y(
|
|
36
|
-
u > 0 ? u - 1 : t - 1
|
|
37
|
-
);
|
|
38
|
-
break;
|
|
39
|
-
case D:
|
|
40
|
-
o && y(
|
|
41
|
-
u < t - 1 ? u + 1 : 0
|
|
42
|
-
);
|
|
43
|
-
break;
|
|
44
|
-
case L:
|
|
45
|
-
case k:
|
|
46
|
-
o && u >= 0 && u < t ? n(u) : r(!0);
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
[u, o, t, n, r]
|
|
51
|
-
);
|
|
52
|
-
return A(() => {
|
|
53
|
-
o && (x(u), y(u));
|
|
54
|
-
}, [o]), {
|
|
55
|
-
currentHoveredIndex: u,
|
|
56
|
-
updateHoveredIndex: x,
|
|
57
|
-
updateListPosition: y,
|
|
58
|
-
onKeyDown: d
|
|
59
|
-
};
|
|
60
|
-
}, Y = (e, t) => e.filter((n) => n !== t), T = {}, B = (e) => {
|
|
61
|
-
for (const t in T) {
|
|
62
|
-
const n = T[t];
|
|
63
|
-
for (let r = n.length - 1; r > -1; r--) {
|
|
64
|
-
const { ref: c, handler: o } = n[r], i = c.current;
|
|
65
|
-
if (i) {
|
|
66
|
-
if (i.contains(e.target))
|
|
67
|
-
break;
|
|
68
|
-
o(e);
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
document.addEventListener("click", B);
|
|
75
|
-
var G = (e) => {
|
|
76
|
-
const { handler: t, ref: n, context: r = "global" } = e;
|
|
77
|
-
A(() => {
|
|
78
|
-
T[r] || (T[r] = []);
|
|
79
|
-
const c = { handler: t, ref: n };
|
|
80
|
-
return setTimeout(() => {
|
|
81
|
-
var o;
|
|
82
|
-
(o = T[r]) == null || o.push(c);
|
|
83
|
-
}), () => {
|
|
84
|
-
T[r] = Y(T[r], c);
|
|
85
|
-
};
|
|
86
|
-
}, [t, n, r]);
|
|
87
|
-
}, J = () => {
|
|
88
|
-
const [e, t] = M(() => typeof window > "u" ? !1 : "ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
89
|
-
return A(() => {
|
|
90
|
-
const n = (r) => {
|
|
91
|
-
r.pointerType === "touch" ? t(!0) : r.pointerType === "mouse" && t(!1);
|
|
92
|
-
};
|
|
93
|
-
return window.addEventListener("pointerdown", n), () => {
|
|
94
|
-
window.removeEventListener("pointerdown", n);
|
|
95
|
-
};
|
|
96
|
-
}, []), e;
|
|
97
|
-
}, _ = 20, H = 500, R = (e, t, n) => (t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x), K = (e, t, n, r) => {
|
|
98
|
-
const c = R(e, t, n), o = R(e, n, r), i = R(e, r, t), f = c < 0 || o < 0 || i < 0, u = c > 0 || o > 0 || i > 0;
|
|
99
|
-
return !(f && u);
|
|
100
|
-
}, N = (e, t, n) => Math.abs(R(e, t, n)) / 2, X = (e) => {
|
|
101
|
-
const t = e.getBoundingClientRect(), n = window.scrollX, r = window.scrollY;
|
|
102
|
-
return [
|
|
103
|
-
{
|
|
104
|
-
x: t.left + n,
|
|
105
|
-
y: t.top + r
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
x: t.right + n,
|
|
109
|
-
y: t.top + r
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
x: t.right + n,
|
|
113
|
-
y: t.bottom + r
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
x: t.left + n,
|
|
117
|
-
y: t.bottom + r
|
|
118
|
-
}
|
|
119
|
-
];
|
|
120
|
-
}, U = (e) => {
|
|
121
|
-
if (e.length < 3)
|
|
122
|
-
return 0;
|
|
123
|
-
let t = 0;
|
|
124
|
-
for (let n = 0; n < e.length; n++) {
|
|
125
|
-
const r = (n + 1) % e.length;
|
|
126
|
-
t += e[n].x * e[r].y, t -= e[r].x * e[n].y;
|
|
127
|
-
}
|
|
128
|
-
return Math.abs(t) / 2;
|
|
129
|
-
}, j = (e, t, n, r) => {
|
|
130
|
-
const c = (r.y - n.y) * (t.x - e.x) - (r.x - n.x) * (t.y - e.y);
|
|
131
|
-
if (Math.abs(c) < 1e-10)
|
|
132
|
-
return null;
|
|
133
|
-
const o = ((r.x - n.x) * (e.y - n.y) - (r.y - n.y) * (e.x - n.x)) / c, i = ((t.x - e.x) * (e.y - n.y) - (t.y - e.y) * (e.x - n.x)) / c;
|
|
134
|
-
return o < 0 || o > 1 || i < 0 || i > 1 ? null : {
|
|
135
|
-
x: e.x + o * (t.x - e.x),
|
|
136
|
-
y: e.y + o * (t.y - e.y)
|
|
137
|
-
};
|
|
138
|
-
}, P = (e, t) => {
|
|
139
|
-
const [n, r, c, o] = t, i = Math.min(n.x, o.x), f = Math.max(r.x, c.x), u = Math.min(n.y, r.y), g = Math.max(o.y, c.y);
|
|
140
|
-
return e.x >= i && e.x <= f && e.y >= u && e.y <= g;
|
|
141
|
-
}, q = (e, t) => {
|
|
142
|
-
const [n, r, c] = e, [o, i, f, u] = t, g = [];
|
|
143
|
-
for (const l of [n, r, c])
|
|
144
|
-
P(l, t) && g.push(l);
|
|
145
|
-
const x = [
|
|
146
|
-
[o, i],
|
|
147
|
-
[i, f],
|
|
148
|
-
[f, u],
|
|
149
|
-
[u, o]
|
|
150
|
-
], y = [
|
|
151
|
-
[n, r],
|
|
152
|
-
[r, c],
|
|
153
|
-
[c, n]
|
|
154
|
-
];
|
|
155
|
-
for (const l of y)
|
|
156
|
-
for (const s of x) {
|
|
157
|
-
const a = j(
|
|
158
|
-
l[0],
|
|
159
|
-
l[1],
|
|
160
|
-
s[0],
|
|
161
|
-
s[1]
|
|
162
|
-
);
|
|
163
|
-
a && g.push(a);
|
|
164
|
-
}
|
|
165
|
-
const d = [];
|
|
166
|
-
for (const l of g)
|
|
167
|
-
d.some(
|
|
168
|
-
(a) => Math.abs(a.x - l.x) < 1e-6 && Math.abs(a.y - l.y) < 1e-6
|
|
169
|
-
) || d.push(l);
|
|
170
|
-
if (d.length < 3)
|
|
171
|
-
return [];
|
|
172
|
-
const m = {
|
|
173
|
-
x: d.reduce(function(s, a) {
|
|
174
|
-
return s + a.x;
|
|
175
|
-
}, 0) / d.length,
|
|
176
|
-
y: d.reduce(function(s, a) {
|
|
177
|
-
return s + a.y;
|
|
178
|
-
}, 0) / d.length
|
|
179
|
-
};
|
|
180
|
-
return d.sort(function(s, a) {
|
|
181
|
-
const v = Math.atan2(s.y - m.y, s.x - m.x), h = Math.atan2(a.y - m.y, a.x - m.x);
|
|
182
|
-
return v - h;
|
|
183
|
-
}), d;
|
|
184
|
-
}, F = (e, t, n, r) => {
|
|
185
|
-
const o = q([e, t, n], r);
|
|
186
|
-
return o.length < 3 ? 0 : U(o);
|
|
187
|
-
}, V = (e, t) => {
|
|
188
|
-
const n = [
|
|
189
|
-
[0, 1],
|
|
190
|
-
[0, 2],
|
|
191
|
-
[0, 3],
|
|
192
|
-
[1, 2],
|
|
193
|
-
[1, 3],
|
|
194
|
-
[2, 3]
|
|
195
|
-
];
|
|
196
|
-
let r = null, c = -1;
|
|
197
|
-
for (const [o, i] of n) {
|
|
198
|
-
const f = t[o], u = t[i], g = N(e, f, u), x = F(e, f, u, t), y = g - x;
|
|
199
|
-
y > c && (c = y, r = [f, u]);
|
|
200
|
-
}
|
|
201
|
-
return r;
|
|
202
|
-
}, W = (e, t, n, r) => K(t, e, n, r), Q = (e) => {
|
|
203
|
-
const {
|
|
204
|
-
tolerance: t = _,
|
|
205
|
-
isEnabled: n = !0,
|
|
206
|
-
onChange: r,
|
|
207
|
-
idleTimeout: c = H
|
|
208
|
-
} = e, o = E(null), i = E(!1), f = E(null), u = E(null), g = E(null), x = E(0), y = E(null), d = (s, a = !1) => {
|
|
209
|
-
i.current !== s || a ? (i.current = s, r == null || r(s)) : i.current = s;
|
|
210
|
-
}, m = () => i.current, l = C(() => {
|
|
211
|
-
const s = f.current, a = u.current, v = o.current;
|
|
212
|
-
if (!s || !a || !v) {
|
|
213
|
-
d(!1), g.current = null, x.current = 0;
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
const h = X(v);
|
|
217
|
-
if (P(s, h)) {
|
|
218
|
-
d(!1), g.current = s, x.current = 0;
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
const w = V(s, h);
|
|
222
|
-
if (!w) {
|
|
223
|
-
d(!1), x.current = 0, g.current = s;
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
const b = W(a, s, w[0], w[1]);
|
|
227
|
-
i.current && !b && x.current < t || (x.current = 0, g.current = s, d(b));
|
|
228
|
-
}, [t]);
|
|
229
|
-
return A(() => {
|
|
230
|
-
if (!n) {
|
|
231
|
-
d(!1, !0), f.current = null, u.current = null, g.current = null, x.current = 0;
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
const s = (a) => {
|
|
235
|
-
const v = { x: a.pageX, y: a.pageY }, h = f.current;
|
|
236
|
-
if (u.current = f.current, f.current = v, h) {
|
|
237
|
-
const w = v.x - h.x, b = v.y - h.y, p = Math.sqrt(w * w + b * b);
|
|
238
|
-
x.current += p;
|
|
239
|
-
}
|
|
240
|
-
y.current && (clearTimeout(y.current), y.current = null), l(), y.current = window.setTimeout(() => {
|
|
241
|
-
d(!1), x.current = 0, g.current = null;
|
|
242
|
-
}, c);
|
|
243
|
-
};
|
|
244
|
-
return document.addEventListener("mousemove", s), () => {
|
|
245
|
-
document.removeEventListener("mousemove", s), y.current && clearTimeout(y.current);
|
|
246
|
-
};
|
|
247
|
-
}, [n, l, c]), {
|
|
248
|
-
isAiming: m,
|
|
249
|
-
ref: o
|
|
250
|
-
};
|
|
251
|
-
};
|
|
252
|
-
export {
|
|
253
|
-
J as a,
|
|
254
|
-
Q as b,
|
|
255
|
-
z as c,
|
|
256
|
-
G as u
|
|
257
|
-
};
|