@topconsultnpm/sdkui-react 6.20.0-dev1.4 → 6.20.0-dev1.41
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/lib/components/NewComponents/ContextMenu/TMContextMenu.d.ts +4 -0
- package/lib/components/NewComponents/ContextMenu/TMContextMenu.js +307 -0
- package/lib/components/NewComponents/ContextMenu/hooks.d.ts +13 -0
- package/lib/components/NewComponents/ContextMenu/hooks.js +61 -0
- package/lib/components/NewComponents/ContextMenu/index.d.ts +2 -0
- package/lib/components/NewComponents/ContextMenu/index.js +1 -0
- package/lib/components/NewComponents/ContextMenu/styles.d.ts +31 -0
- package/lib/components/NewComponents/ContextMenu/styles.js +336 -0
- package/lib/components/NewComponents/ContextMenu/types.d.ts +38 -0
- package/lib/components/NewComponents/ContextMenu/types.js +1 -0
- package/lib/components/NewComponents/FloatingMenuBar/TMFloatingMenuBar.d.ts +4 -0
- package/lib/components/NewComponents/FloatingMenuBar/TMFloatingMenuBar.js +471 -0
- package/lib/components/NewComponents/FloatingMenuBar/index.d.ts +2 -0
- package/lib/components/NewComponents/FloatingMenuBar/index.js +2 -0
- package/lib/components/NewComponents/FloatingMenuBar/styles.d.ts +47 -0
- package/lib/components/NewComponents/FloatingMenuBar/styles.js +346 -0
- package/lib/components/NewComponents/FloatingMenuBar/types.d.ts +29 -0
- package/lib/components/NewComponents/FloatingMenuBar/types.js +1 -0
- package/lib/components/base/TMCustomButton.js +61 -17
- package/lib/components/base/TMDataGrid.d.ts +7 -4
- package/lib/components/base/TMDataGrid.js +112 -11
- package/lib/components/choosers/TMMetadataChooser.js +8 -1
- package/lib/components/editors/TMHtmlEditor.js +1 -1
- package/lib/components/editors/TMMetadataValues.js +20 -2
- package/lib/components/features/documents/TMDcmtBlog.d.ts +1 -7
- package/lib/components/features/documents/TMDcmtBlog.js +29 -2
- package/lib/components/features/documents/TMDcmtForm.js +269 -169
- package/lib/components/features/documents/TMDcmtPreview.js +37 -66
- package/lib/components/features/documents/TMMasterDetailDcmts.js +1 -1
- package/lib/components/features/search/TMDcmtCheckoutInfoForm.d.ts +8 -0
- package/lib/components/features/search/{TMSearchResultCheckoutInfoForm.js → TMDcmtCheckoutInfoForm.js} +6 -11
- package/lib/components/features/search/TMSearch.js +30 -5
- package/lib/components/features/search/TMSearchQueryPanel.js +13 -12
- package/lib/components/features/search/TMSearchResult.js +71 -120
- package/lib/components/features/search/TMSearchResultsMenuItems.d.ts +3 -3
- package/lib/components/features/search/TMSearchResultsMenuItems.js +216 -180
- package/lib/components/features/search/TMSignSettingsForm.js +1 -1
- package/lib/components/features/search/TMSignatureInfoContent.d.ts +6 -0
- package/lib/components/features/search/TMSignatureInfoContent.js +140 -0
- package/lib/components/features/search/TMViewHistoryDcmt.js +1 -1
- package/lib/components/features/tasks/TMTasksView.js +2 -2
- package/lib/components/forms/Login/LoginValidatorService.d.ts +2 -0
- package/lib/components/forms/Login/LoginValidatorService.js +7 -2
- package/lib/components/forms/Login/TMLoginForm.js +34 -6
- package/lib/components/forms/TMChooserForm.js +1 -1
- package/lib/components/index.d.ts +0 -1
- package/lib/components/index.js +0 -1
- package/lib/css/tm-sdkui.css +1 -1
- package/lib/helper/SDKUI_Globals.d.ts +19 -14
- package/lib/helper/SDKUI_Globals.js +9 -0
- package/lib/helper/SDKUI_Localizator.d.ts +8 -0
- package/lib/helper/SDKUI_Localizator.js +98 -0
- package/lib/helper/TMIcons.d.ts +1 -0
- package/lib/helper/TMIcons.js +3 -0
- package/lib/helper/TMPdfViewer.d.ts +8 -0
- package/lib/helper/TMPdfViewer.js +187 -0
- package/lib/helper/TMUtils.d.ts +3 -1
- package/lib/helper/TMUtils.js +51 -0
- package/lib/helper/checkinCheckoutManager.d.ts +85 -0
- package/lib/helper/checkinCheckoutManager.js +348 -0
- package/lib/helper/devextremeCustomMessages.d.ts +30 -0
- package/lib/helper/devextremeCustomMessages.js +30 -0
- package/lib/helper/helpers.js +7 -1
- package/lib/helper/index.d.ts +2 -0
- package/lib/helper/index.js +2 -0
- package/lib/helper/queryHelper.js +29 -0
- package/lib/hooks/useCheckInOutOperations.d.ts +28 -0
- package/lib/hooks/useCheckInOutOperations.js +223 -0
- package/lib/services/platform_services.d.ts +1 -1
- package/package.json +5 -2
- package/lib/components/features/search/TMSearchResultCheckoutInfoForm.d.ts +0 -8
- package/lib/helper/cicoHelper.d.ts +0 -31
- package/lib/helper/cicoHelper.js +0 -155
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect } from 'react';
|
|
3
|
+
import * as S from './styles';
|
|
4
|
+
import { useIsMobile, useMenuPosition, useIsIOS } from './hooks';
|
|
5
|
+
import { IconArrowLeft } from '../../../helper';
|
|
6
|
+
const TMContextMenu = ({ items, trigger = 'right', children, externalControl, keepOpenOnClick = false }) => {
|
|
7
|
+
const [menuState, setMenuState] = useState({
|
|
8
|
+
visible: false,
|
|
9
|
+
position: { x: 0, y: 0 },
|
|
10
|
+
submenuStack: [items],
|
|
11
|
+
parentNames: [],
|
|
12
|
+
});
|
|
13
|
+
const [hoveredSubmenus, setHoveredSubmenus] = useState([]);
|
|
14
|
+
const isMobile = useIsMobile();
|
|
15
|
+
const isIOS = useIsIOS();
|
|
16
|
+
const menuRef = useRef(null);
|
|
17
|
+
const triggerRef = useRef(null);
|
|
18
|
+
const submenuTimeoutRef = useRef(null);
|
|
19
|
+
const longPressTimeoutRef = useRef(null);
|
|
20
|
+
const touchStartPos = useRef(null);
|
|
21
|
+
const { openLeft, openUp, isCalculated } = useMenuPosition(menuRef, menuState.position);
|
|
22
|
+
const handleClose = () => {
|
|
23
|
+
if (externalControl) {
|
|
24
|
+
externalControl.onClose();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
setMenuState(prev => ({
|
|
28
|
+
...prev,
|
|
29
|
+
visible: false,
|
|
30
|
+
submenuStack: [items],
|
|
31
|
+
parentNames: [],
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
setHoveredSubmenus([]);
|
|
35
|
+
};
|
|
36
|
+
// Sync with external control when provided
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (externalControl) {
|
|
39
|
+
setMenuState(prev => ({
|
|
40
|
+
...prev,
|
|
41
|
+
visible: externalControl.visible,
|
|
42
|
+
position: externalControl.position,
|
|
43
|
+
submenuStack: [items],
|
|
44
|
+
parentNames: [],
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
}, [externalControl, items]);
|
|
48
|
+
// Update items when they change while menu is visible (for keepOpenOnClick behavior)
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!keepOpenOnClick)
|
|
51
|
+
return;
|
|
52
|
+
if (!externalControl && menuState.visible) {
|
|
53
|
+
setMenuState(prev => ({
|
|
54
|
+
...prev,
|
|
55
|
+
submenuStack: [items],
|
|
56
|
+
}));
|
|
57
|
+
// Update hoveredSubmenus with fresh items while keeping them open
|
|
58
|
+
setHoveredSubmenus(prev => {
|
|
59
|
+
if (prev.length === 0)
|
|
60
|
+
return prev;
|
|
61
|
+
// Rebuild hoveredSubmenus with updated items from the new items structure
|
|
62
|
+
return prev.map(submenu => {
|
|
63
|
+
// Find the matching submenu in the new items structure
|
|
64
|
+
const findSubmenuInItems = (searchItems) => {
|
|
65
|
+
for (const item of searchItems) {
|
|
66
|
+
if (item.submenu && item.submenu.length > 0) {
|
|
67
|
+
// Check if this submenu matches (compare first item name as identifier)
|
|
68
|
+
if (submenu.items.length > 0 && item.submenu.length > 0 &&
|
|
69
|
+
item.submenu[0].name === submenu.items[0].name) {
|
|
70
|
+
return item.submenu;
|
|
71
|
+
}
|
|
72
|
+
// Recursively search in nested submenus
|
|
73
|
+
const found = findSubmenuInItems(item.submenu);
|
|
74
|
+
if (found)
|
|
75
|
+
return found;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
};
|
|
80
|
+
const updatedItems = findSubmenuInItems(items);
|
|
81
|
+
return {
|
|
82
|
+
...submenu,
|
|
83
|
+
items: updatedItems || submenu.items, // Use updated items if found, otherwise keep old
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}, [items, menuState.visible, externalControl, keepOpenOnClick]);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (!menuState.visible)
|
|
91
|
+
return;
|
|
92
|
+
const handleClickOutside = (event) => {
|
|
93
|
+
const target = event.target;
|
|
94
|
+
// Check if click is inside main menu
|
|
95
|
+
if (menuRef.current?.contains(target)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// Check if click is inside any submenu
|
|
99
|
+
const submenus = document.querySelectorAll('[data-submenu="true"]');
|
|
100
|
+
for (const submenu of Array.from(submenus)) {
|
|
101
|
+
if (submenu.contains(target)) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// Click is outside all menus, close them
|
|
106
|
+
handleClose();
|
|
107
|
+
};
|
|
108
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
109
|
+
document.addEventListener('touchstart', handleClickOutside);
|
|
110
|
+
return () => {
|
|
111
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
112
|
+
document.removeEventListener('touchstart', handleClickOutside);
|
|
113
|
+
};
|
|
114
|
+
}, [menuState.visible]);
|
|
115
|
+
const handleContextMenu = (e) => {
|
|
116
|
+
if (trigger === 'right') {
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
setMenuState({
|
|
119
|
+
visible: true,
|
|
120
|
+
position: { x: e.clientX, y: e.clientY },
|
|
121
|
+
submenuStack: [items],
|
|
122
|
+
parentNames: [],
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const handleClick = (e) => {
|
|
127
|
+
if (trigger === 'left') {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
setMenuState({
|
|
130
|
+
visible: true,
|
|
131
|
+
position: { x: e.clientX, y: e.clientY },
|
|
132
|
+
submenuStack: [items],
|
|
133
|
+
parentNames: [],
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
// iOS-specific touch handlers for long press
|
|
138
|
+
const handleTouchStart = (e) => {
|
|
139
|
+
if (!isIOS || trigger !== 'right')
|
|
140
|
+
return;
|
|
141
|
+
const touch = e.touches[0];
|
|
142
|
+
touchStartPos.current = { x: touch.clientX, y: touch.clientY };
|
|
143
|
+
if (longPressTimeoutRef.current) {
|
|
144
|
+
clearTimeout(longPressTimeoutRef.current);
|
|
145
|
+
}
|
|
146
|
+
longPressTimeoutRef.current = setTimeout(() => {
|
|
147
|
+
if (touchStartPos.current) {
|
|
148
|
+
if ('vibrate' in navigator) {
|
|
149
|
+
navigator.vibrate(50);
|
|
150
|
+
}
|
|
151
|
+
setMenuState({
|
|
152
|
+
visible: true,
|
|
153
|
+
position: { x: touchStartPos.current.x, y: touchStartPos.current.y },
|
|
154
|
+
submenuStack: [items],
|
|
155
|
+
parentNames: [],
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}, 500);
|
|
159
|
+
};
|
|
160
|
+
const handleTouchMove = (e) => {
|
|
161
|
+
if (!isIOS || !touchStartPos.current)
|
|
162
|
+
return;
|
|
163
|
+
const touch = e.touches[0];
|
|
164
|
+
const moveThreshold = 10; // pixels
|
|
165
|
+
// If finger moved too much, cancel long press
|
|
166
|
+
const deltaX = Math.abs(touch.clientX - touchStartPos.current.x);
|
|
167
|
+
const deltaY = Math.abs(touch.clientY - touchStartPos.current.y);
|
|
168
|
+
if (deltaX > moveThreshold || deltaY > moveThreshold) {
|
|
169
|
+
if (longPressTimeoutRef.current) {
|
|
170
|
+
clearTimeout(longPressTimeoutRef.current);
|
|
171
|
+
longPressTimeoutRef.current = null;
|
|
172
|
+
}
|
|
173
|
+
touchStartPos.current = null;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
const handleTouchEnd = () => {
|
|
177
|
+
if (!isIOS)
|
|
178
|
+
return;
|
|
179
|
+
// Clear long press timeout if touch ended before long press completed
|
|
180
|
+
if (longPressTimeoutRef.current) {
|
|
181
|
+
clearTimeout(longPressTimeoutRef.current);
|
|
182
|
+
longPressTimeoutRef.current = null;
|
|
183
|
+
}
|
|
184
|
+
touchStartPos.current = null;
|
|
185
|
+
};
|
|
186
|
+
const handleItemClick = (item) => {
|
|
187
|
+
if (item.disabled)
|
|
188
|
+
return;
|
|
189
|
+
// Always execute onClick if present
|
|
190
|
+
if (item.onClick) {
|
|
191
|
+
item.onClick();
|
|
192
|
+
}
|
|
193
|
+
if (item.submenu && item.submenu.length > 0) {
|
|
194
|
+
if (isMobile) {
|
|
195
|
+
// Mobile: Push submenu to stack
|
|
196
|
+
setMenuState(prev => ({
|
|
197
|
+
...prev,
|
|
198
|
+
submenuStack: [...prev.submenuStack, item.submenu],
|
|
199
|
+
parentNames: [...prev.parentNames, item.name],
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
202
|
+
// Desktop: Submenus are handled by hover, don't close menu
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
// No submenu: close menu after executing action (unless keepOpenOnClick is true)
|
|
206
|
+
if (!keepOpenOnClick) {
|
|
207
|
+
handleClose();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const handleBack = () => {
|
|
212
|
+
setMenuState(prev => ({
|
|
213
|
+
...prev,
|
|
214
|
+
submenuStack: prev.submenuStack.slice(0, -1),
|
|
215
|
+
parentNames: prev.parentNames.slice(0, -1),
|
|
216
|
+
}));
|
|
217
|
+
};
|
|
218
|
+
const handleMouseEnter = (item, event, depth = 0) => {
|
|
219
|
+
if (isMobile || !item.submenu || item.submenu.length === 0)
|
|
220
|
+
return;
|
|
221
|
+
if (submenuTimeoutRef.current) {
|
|
222
|
+
clearTimeout(submenuTimeoutRef.current);
|
|
223
|
+
submenuTimeoutRef.current = null;
|
|
224
|
+
}
|
|
225
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
226
|
+
// Calculate if submenu should open upward based on available space
|
|
227
|
+
// Estimate submenu height: ~35px per item (accounting for smaller padding) + container padding
|
|
228
|
+
const estimatedSubmenuHeight = (item.submenu.length * 35) + 8;
|
|
229
|
+
const spaceBelow = window.innerHeight - rect.top;
|
|
230
|
+
const spaceAbove = rect.bottom;
|
|
231
|
+
// Open upward only if there's not enough space below AND there's more space above
|
|
232
|
+
const shouldOpenUp = spaceBelow < estimatedSubmenuHeight && spaceAbove > spaceBelow;
|
|
233
|
+
// Remove all submenus at this depth and deeper
|
|
234
|
+
setHoveredSubmenus(prev => {
|
|
235
|
+
const filtered = prev.filter(sub => sub.depth < depth);
|
|
236
|
+
if (!item.submenu)
|
|
237
|
+
return filtered;
|
|
238
|
+
return [
|
|
239
|
+
...filtered,
|
|
240
|
+
{
|
|
241
|
+
items: item.submenu,
|
|
242
|
+
parentRect: rect,
|
|
243
|
+
depth: depth,
|
|
244
|
+
openUp: shouldOpenUp,
|
|
245
|
+
}
|
|
246
|
+
];
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
const handleMouseLeave = (depth = 0) => {
|
|
250
|
+
if (isMobile)
|
|
251
|
+
return;
|
|
252
|
+
if (submenuTimeoutRef.current) {
|
|
253
|
+
clearTimeout(submenuTimeoutRef.current);
|
|
254
|
+
}
|
|
255
|
+
const targetDepth = depth;
|
|
256
|
+
submenuTimeoutRef.current = setTimeout(() => {
|
|
257
|
+
setHoveredSubmenus(prev => prev.filter(sub => sub.depth < targetDepth));
|
|
258
|
+
}, 300);
|
|
259
|
+
};
|
|
260
|
+
const handleSubmenuMouseEnter = () => {
|
|
261
|
+
if (submenuTimeoutRef.current) {
|
|
262
|
+
clearTimeout(submenuTimeoutRef.current);
|
|
263
|
+
submenuTimeoutRef.current = null;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
useEffect(() => {
|
|
267
|
+
return () => {
|
|
268
|
+
if (submenuTimeoutRef.current) {
|
|
269
|
+
clearTimeout(submenuTimeoutRef.current);
|
|
270
|
+
}
|
|
271
|
+
if (longPressTimeoutRef.current) {
|
|
272
|
+
clearTimeout(longPressTimeoutRef.current);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}, []);
|
|
276
|
+
const renderMenuItems = (menuItems, depth = 0) => {
|
|
277
|
+
return menuItems
|
|
278
|
+
.filter(item => item.visible !== false)
|
|
279
|
+
.map((item, idx) => {
|
|
280
|
+
const itemKey = `${item.name}-${idx}`.replaceAll(/\s+/g, '-');
|
|
281
|
+
const handleClick = (e) => {
|
|
282
|
+
if (item.disabled)
|
|
283
|
+
return;
|
|
284
|
+
e.stopPropagation();
|
|
285
|
+
handleItemClick(item);
|
|
286
|
+
};
|
|
287
|
+
const handleRightIconClick = (e) => {
|
|
288
|
+
e.stopPropagation();
|
|
289
|
+
// if (item.disabled) return;
|
|
290
|
+
item.onRightIconClick?.();
|
|
291
|
+
};
|
|
292
|
+
return (_jsxs(S.MenuItem, { "$disabled": item.disabled, "$hasSubmenu": !!item.submenu && item.submenu.length > 0, "$beginGroup": item.beginGroup, onMouseDown: handleClick, onMouseEnter: (e) => !isMobile && handleMouseEnter(item, e, depth + 1), onMouseLeave: () => !isMobile && handleMouseLeave(depth + 1), title: item.tooltip, children: [_jsxs(S.MenuItemContent, { children: [item.icon && _jsx(S.IconWrapper, { children: item.icon }), _jsx(S.MenuItemName, { children: item.name })] }), item.rightIcon && item.onRightIconClick && (_jsx(S.RightIconButton, { onClick: handleRightIconClick, onMouseDown: (e) => e.stopPropagation(), "aria-label": `Action for ${item.name}`, children: item.rightIcon })), item.submenu && item.submenu.length > 0 && (_jsx(S.SubmenuIndicator, { "$isMobile": isMobile, children: isMobile ? '›' : '▸' }))] }, itemKey));
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
const currentMenu = menuState.submenuStack.at(-1) || items;
|
|
296
|
+
const currentParentName = menuState.parentNames.at(-1) || '';
|
|
297
|
+
return (_jsxs(_Fragment, { children: [!externalControl && children && (_jsx("div", { ref: triggerRef, onContextMenu: handleContextMenu, onClick: handleClick, onTouchStart: handleTouchStart, onTouchMove: handleTouchMove, onTouchEnd: handleTouchEnd, onTouchCancel: handleTouchEnd, onKeyDown: (e) => {
|
|
298
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
299
|
+
handleClick(e);
|
|
300
|
+
}
|
|
301
|
+
}, role: "button", tabIndex: 0, style: {
|
|
302
|
+
display: 'inline-block',
|
|
303
|
+
WebkitTouchCallout: isIOS ? 'none' : undefined,
|
|
304
|
+
WebkitUserSelect: isIOS ? 'none' : undefined,
|
|
305
|
+
}, children: children })), menuState.visible && (_jsxs(_Fragment, { children: [_jsxs(S.MenuContainer, { ref: menuRef, "$x": menuState.position.x, "$y": menuState.position.y, "$openLeft": openLeft, "$openUp": openUp, "$isPositioned": isCalculated, "$externalControl": !!externalControl, children: [isMobile && menuState.parentNames.length > 0 && (_jsxs(S.MobileMenuHeader, { children: [_jsx(S.BackButton, { onClick: handleBack, "aria-label": "Go back", children: _jsx(IconArrowLeft, {}) }), _jsx(S.HeaderTitle, { children: currentParentName })] })), renderMenuItems(currentMenu, 0)] }), !isMobile && hoveredSubmenus.map((submenu, idx) => (_jsx(S.Submenu, { "$parentRect": submenu.parentRect, "$openUp": submenu.openUp, "data-submenu": "true", onMouseEnter: handleSubmenuMouseEnter, onMouseLeave: () => handleMouseLeave(submenu.depth), children: renderMenuItems(submenu.items, submenu.depth) }, `submenu-${submenu.depth}-${idx}`)))] }))] }));
|
|
306
|
+
};
|
|
307
|
+
export default TMContextMenu;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const useIsIOS: () => boolean;
|
|
2
|
+
export declare const useIsMobile: () => boolean;
|
|
3
|
+
export declare const useClickOutside: (callback: () => void) => import("react").RefObject<HTMLDivElement>;
|
|
4
|
+
interface Position {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const useMenuPosition: (menuRef: React.RefObject<HTMLDivElement | null>, position: Position) => {
|
|
9
|
+
isCalculated: boolean;
|
|
10
|
+
openLeft: boolean;
|
|
11
|
+
openUp: boolean;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useState, useEffect, useLayoutEffect, useRef } from 'react';
|
|
2
|
+
export const useIsIOS = () => {
|
|
3
|
+
const [isIOS, setIsIOS] = useState(false);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) ||
|
|
6
|
+
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
|
|
7
|
+
setIsIOS(iOS);
|
|
8
|
+
}, []);
|
|
9
|
+
return isIOS;
|
|
10
|
+
};
|
|
11
|
+
export const useIsMobile = () => {
|
|
12
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const checkMobile = () => {
|
|
15
|
+
const mobile = globalThis.innerWidth <= 768 || 'ontouchstart' in globalThis;
|
|
16
|
+
setIsMobile(mobile);
|
|
17
|
+
};
|
|
18
|
+
checkMobile();
|
|
19
|
+
window.addEventListener('resize', checkMobile);
|
|
20
|
+
return () => window.removeEventListener('resize', checkMobile);
|
|
21
|
+
}, []);
|
|
22
|
+
return isMobile;
|
|
23
|
+
};
|
|
24
|
+
export const useClickOutside = (callback) => {
|
|
25
|
+
const ref = useRef(null);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const handleClick = (event) => {
|
|
28
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
29
|
+
callback();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
document.addEventListener('mousedown', handleClick);
|
|
33
|
+
document.addEventListener('touchstart', handleClick);
|
|
34
|
+
return () => {
|
|
35
|
+
document.removeEventListener('mousedown', handleClick);
|
|
36
|
+
document.removeEventListener('touchstart', handleClick);
|
|
37
|
+
};
|
|
38
|
+
}, [callback]);
|
|
39
|
+
return ref;
|
|
40
|
+
};
|
|
41
|
+
export const useMenuPosition = (menuRef, position) => {
|
|
42
|
+
const [adjustedPosition, setAdjustedPosition] = useState({ openLeft: false, openUp: false });
|
|
43
|
+
const [isCalculated, setIsCalculated] = useState(false);
|
|
44
|
+
useLayoutEffect(() => {
|
|
45
|
+
if (!menuRef.current) {
|
|
46
|
+
setIsCalculated(false);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const menuRect = menuRef.current.getBoundingClientRect();
|
|
50
|
+
const viewportWidth = window.innerWidth;
|
|
51
|
+
const viewportHeight = window.innerHeight;
|
|
52
|
+
const spaceRight = viewportWidth - position.x;
|
|
53
|
+
const spaceBottom = viewportHeight - position.y;
|
|
54
|
+
setAdjustedPosition({
|
|
55
|
+
openLeft: spaceRight < menuRect.width + 20,
|
|
56
|
+
openUp: spaceBottom < menuRect.height + 20,
|
|
57
|
+
});
|
|
58
|
+
setIsCalculated(true);
|
|
59
|
+
}, [position, menuRef]);
|
|
60
|
+
return { ...adjustedPosition, isCalculated };
|
|
61
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ContextMenu } from './TMContextMenu';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const MenuContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
2
|
+
$x: number;
|
|
3
|
+
$y: number;
|
|
4
|
+
$openLeft: boolean;
|
|
5
|
+
$openUp: boolean;
|
|
6
|
+
$isPositioned: boolean;
|
|
7
|
+
$externalControl?: boolean;
|
|
8
|
+
}>> & string;
|
|
9
|
+
export declare const MenuItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
10
|
+
$disabled?: boolean;
|
|
11
|
+
$hasSubmenu?: boolean;
|
|
12
|
+
$beginGroup?: boolean;
|
|
13
|
+
}>> & string;
|
|
14
|
+
export declare const MenuItemContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
15
|
+
export declare const IconWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
16
|
+
export declare const MenuItemName: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
17
|
+
export declare const RightIconButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
18
|
+
ref?: ((instance: HTMLButtonElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
19
|
+
}>, never>, never>> & string;
|
|
20
|
+
export declare const SubmenuIndicator: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {
|
|
21
|
+
$isMobile?: boolean;
|
|
22
|
+
}>> & string;
|
|
23
|
+
export declare const Submenu: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
24
|
+
$parentRect: DOMRect;
|
|
25
|
+
$openUp?: boolean;
|
|
26
|
+
}>> & string;
|
|
27
|
+
export declare const MobileMenuHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
28
|
+
export declare const BackButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
|
|
29
|
+
export declare const HeaderTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>> & string;
|
|
30
|
+
export declare const MenuDivider: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
31
|
+
export declare const Overlay: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|