@topconsultnpm/sdkui-react 6.20.0-dev1.3 → 6.20.0-dev1.5
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/base/TMAccordion.js +2 -2
- package/lib/components/editors/TMHtmlEditor.js +1 -1
- 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 +8 -23
- package/lib/components/features/search/TMSearchResult.js +146 -43
- package/lib/components/features/search/TMSearchResultCheckoutInfoForm.js +3 -3
- package/lib/components/features/search/TMSearchResultsMenuItems.d.ts +1 -1
- package/lib/components/features/search/TMSearchResultsMenuItems.js +16 -16
- package/lib/helper/SDKUI_Globals.d.ts +3 -14
- package/lib/helper/SDKUI_Localizator.d.ts +7 -0
- package/lib/helper/SDKUI_Localizator.js +88 -0
- package/lib/helper/TMUtils.d.ts +3 -1
- package/lib/helper/TMUtils.js +51 -0
- package/lib/helper/checkinCheckoutManager.d.ts +55 -0
- package/lib/helper/checkinCheckoutManager.js +271 -0
- package/lib/helper/index.d.ts +1 -0
- package/lib/helper/index.js +1 -0
- package/lib/services/platform_services.d.ts +1 -1
- package/package.json +2 -2
- package/lib/components/NewComponents/ContextMenu/TMContextMenu.d.ts +0 -4
- package/lib/components/NewComponents/ContextMenu/TMContextMenu.js +0 -187
- package/lib/components/NewComponents/ContextMenu/hooks.d.ts +0 -11
- package/lib/components/NewComponents/ContextMenu/hooks.js +0 -48
- package/lib/components/NewComponents/ContextMenu/index.d.ts +0 -2
- package/lib/components/NewComponents/ContextMenu/index.js +0 -1
- package/lib/components/NewComponents/ContextMenu/styles.d.ts +0 -27
- package/lib/components/NewComponents/ContextMenu/styles.js +0 -308
- package/lib/components/NewComponents/ContextMenu/types.d.ts +0 -26
- package/lib/components/NewComponents/ContextMenu/types.js +0 -1
- package/lib/components/NewComponents/FloatingMenuBar/TMFloatingMenuBar.d.ts +0 -4
- package/lib/components/NewComponents/FloatingMenuBar/TMFloatingMenuBar.js +0 -370
- package/lib/components/NewComponents/FloatingMenuBar/index.d.ts +0 -2
- package/lib/components/NewComponents/FloatingMenuBar/index.js +0 -2
- package/lib/components/NewComponents/FloatingMenuBar/styles.d.ts +0 -38
- package/lib/components/NewComponents/FloatingMenuBar/styles.js +0 -267
- package/lib/components/NewComponents/FloatingMenuBar/types.d.ts +0 -30
- package/lib/components/NewComponents/FloatingMenuBar/types.js +0 -1
- package/lib/components/NewComponents/Notification/Notification.d.ts +0 -4
- package/lib/components/NewComponents/Notification/Notification.js +0 -60
- package/lib/components/NewComponents/Notification/NotificationContainer.d.ts +0 -8
- package/lib/components/NewComponents/Notification/NotificationContainer.js +0 -33
- package/lib/components/NewComponents/Notification/index.d.ts +0 -2
- package/lib/components/NewComponents/Notification/index.js +0 -2
- package/lib/components/NewComponents/Notification/styles.d.ts +0 -21
- package/lib/components/NewComponents/Notification/styles.js +0 -180
- package/lib/components/NewComponents/Notification/types.d.ts +0 -18
- package/lib/components/NewComponents/Notification/types.js +0 -1
- package/lib/helper/cicoHelper.d.ts +0 -31
- package/lib/helper/cicoHelper.js +0 -155
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { AccessLevels, CICO_MetadataNames, SDK_Globals } from "@topconsultnpm/sdk-ts";
|
|
3
|
+
import TMTooltip from "../components/base/TMTooltip";
|
|
4
|
+
import { Globalization, SDKUI_Globals, SDKUI_Localizator } from "./index";
|
|
5
|
+
import { DownloadTypes } from "../ts/types";
|
|
6
|
+
const findCheckOutUserName = (users, checkoutUserId) => {
|
|
7
|
+
let checkOutUser = users.find(user => user.id === checkoutUserId);
|
|
8
|
+
return checkOutUser ? checkOutUser.name : '-';
|
|
9
|
+
};
|
|
10
|
+
const colors = {
|
|
11
|
+
MEDIUM_GREEN: "#28a745",
|
|
12
|
+
};
|
|
13
|
+
export const getCicoDownloadFileName = (source, checkout, withTimestampAndExt) => {
|
|
14
|
+
const archiveID = SDK_Globals.tmSession?.SessionDescr?.archiveID;
|
|
15
|
+
if (!archiveID)
|
|
16
|
+
return '';
|
|
17
|
+
let baseName;
|
|
18
|
+
let tid;
|
|
19
|
+
let did;
|
|
20
|
+
let ext;
|
|
21
|
+
if (source.type === 'fileItem') {
|
|
22
|
+
// fileItem source
|
|
23
|
+
const { name, tid: tidValue, did: didValue, ext: extValue } = source.fileItem;
|
|
24
|
+
baseName = name.includes('.') ? name.substring(0, name.lastIndexOf('.')) : name;
|
|
25
|
+
tid = Number(tidValue);
|
|
26
|
+
did = Number(didValue);
|
|
27
|
+
ext = extValue;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// dcmtInfo source
|
|
31
|
+
const { dcmtInfo, originalFileName } = source;
|
|
32
|
+
const { TID, DID, FILEEXT } = dcmtInfo;
|
|
33
|
+
baseName = originalFileName.includes('.') ? originalFileName.substring(0, originalFileName.lastIndexOf('.')) : originalFileName;
|
|
34
|
+
tid = TID;
|
|
35
|
+
did = DID;
|
|
36
|
+
ext = FILEEXT;
|
|
37
|
+
}
|
|
38
|
+
const fileIdentifier = `${archiveID}~${baseName}~${tid}~${did}`;
|
|
39
|
+
const extension = withTimestampAndExt && ext ? `.${ext}` : '';
|
|
40
|
+
let timestamp = '';
|
|
41
|
+
if (checkout && withTimestampAndExt) {
|
|
42
|
+
const now = new Date();
|
|
43
|
+
const pad = (n) => n.toString().padStart(2, '0');
|
|
44
|
+
timestamp = `~${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
45
|
+
}
|
|
46
|
+
return `${checkout ? 'checkout~' : ''}${fileIdentifier}${timestamp}${extension}`;
|
|
47
|
+
};
|
|
48
|
+
export const cicoDownloadFilesCallback = async (sources, checkout, downloadDcmtsAsync) => {
|
|
49
|
+
const files = [];
|
|
50
|
+
sources.forEach(source => {
|
|
51
|
+
let tid;
|
|
52
|
+
let did;
|
|
53
|
+
let ext;
|
|
54
|
+
if (source.type === 'fileItem') {
|
|
55
|
+
tid = Number(source.fileItem.tid);
|
|
56
|
+
did = Number(source.fileItem.did);
|
|
57
|
+
ext = source.fileItem.ext;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
tid = source.dcmtInfo.TID;
|
|
61
|
+
did = source.dcmtInfo.DID;
|
|
62
|
+
ext = source.dcmtInfo.FILEEXT;
|
|
63
|
+
}
|
|
64
|
+
if (tid && did && ext) {
|
|
65
|
+
let fileName = getCicoDownloadFileName(source, checkout, true);
|
|
66
|
+
if (checkout) {
|
|
67
|
+
const newItem = {
|
|
68
|
+
TID: tid.toString(),
|
|
69
|
+
DID: did.toString(),
|
|
70
|
+
checkoutFolder: "",
|
|
71
|
+
checkoutName: fileName
|
|
72
|
+
};
|
|
73
|
+
updateCheckoutItem(newItem, source.type, "addOrUpdate");
|
|
74
|
+
}
|
|
75
|
+
files.push({ TID: tid, DID: did, FILEEXT: ext, fileName });
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
if (files.length > 0)
|
|
79
|
+
await downloadDcmtsAsync(files, DownloadTypes.Dcmt, "download");
|
|
80
|
+
};
|
|
81
|
+
export const updateCheckoutItem = (item, type, action = "addOrUpdate") => {
|
|
82
|
+
// Select the appropriate array based on type
|
|
83
|
+
const currentItems = type === 'dcmtInfo' ? [...SDKUI_Globals.userSettings.dcmtCheckoutInfo] : [...SDKUI_Globals.userSettings.wgDraftCheckoutInfo];
|
|
84
|
+
// Find the index of an existing item that has the same TID and DID as the new item
|
|
85
|
+
const index = currentItems.findIndex(i => i.TID === item.TID && i.DID === item.DID);
|
|
86
|
+
// If the action is to add a new item or update an existing one
|
|
87
|
+
if (action === "addOrUpdate") {
|
|
88
|
+
if (index >= 0) {
|
|
89
|
+
// If the item exists, overwrite it with the new values
|
|
90
|
+
currentItems[index] = item;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
// If the item does not exist, push it into the array
|
|
94
|
+
currentItems.push(item);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (action === "remove" && index >= 0) {
|
|
98
|
+
// If the action is to remove an item, remove it from the array
|
|
99
|
+
currentItems.splice(index, 1);
|
|
100
|
+
}
|
|
101
|
+
// Update the global array with the modified copy
|
|
102
|
+
if (type === 'dcmtInfo') {
|
|
103
|
+
SDKUI_Globals.userSettings.dcmtCheckoutInfo = currentItems;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
SDKUI_Globals.userSettings.wgDraftCheckoutInfo = currentItems;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
export const validateCicoFileName = (source, fileName) => {
|
|
110
|
+
const archiveID = SDK_Globals.tmSession?.SessionDescr?.archiveID;
|
|
111
|
+
let baseName;
|
|
112
|
+
let tid;
|
|
113
|
+
let did;
|
|
114
|
+
let ext;
|
|
115
|
+
if (source.type === 'fileItem') {
|
|
116
|
+
// fileItem source
|
|
117
|
+
const { name: originalName, tid: tidValue, did: didValue, ext: extValue } = source.fileItem;
|
|
118
|
+
baseName = originalName.includes('.') ? originalName.substring(0, originalName.lastIndexOf('.')) : originalName;
|
|
119
|
+
tid = Number(tidValue);
|
|
120
|
+
did = Number(didValue);
|
|
121
|
+
ext = extValue;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
// dcmtInfo source
|
|
125
|
+
const { dcmtInfo, originalFileName } = source;
|
|
126
|
+
const { TID, DID, FILEEXT } = dcmtInfo;
|
|
127
|
+
baseName = originalFileName.includes('.') ? originalFileName.substring(0, originalFileName.lastIndexOf('.')) : originalFileName;
|
|
128
|
+
tid = TID;
|
|
129
|
+
did = DID;
|
|
130
|
+
ext = FILEEXT;
|
|
131
|
+
}
|
|
132
|
+
// Ensure originalName has the extension
|
|
133
|
+
const normalizedExt = ext?.toLowerCase() ?? '';
|
|
134
|
+
const name = baseName.toLowerCase().endsWith(`.${normalizedExt}`) ? baseName : `${baseName}.${normalizedExt}`;
|
|
135
|
+
let fileNameToValidate = fileName;
|
|
136
|
+
const fileExtensionCheck = fileNameToValidate.split('.').pop() ?? '';
|
|
137
|
+
// Remove extension part
|
|
138
|
+
fileNameToValidate = fileNameToValidate.slice(0, -fileExtensionCheck.length - 1);
|
|
139
|
+
// Check and remove 'checkout~' prefix if present
|
|
140
|
+
const hasCheckoutPrefix = fileNameToValidate.startsWith('checkout~');
|
|
141
|
+
if (hasCheckoutPrefix) {
|
|
142
|
+
fileNameToValidate = fileNameToValidate.replace(/^checkout~/, '');
|
|
143
|
+
}
|
|
144
|
+
// Split the remaining string by underscores (~)
|
|
145
|
+
const parts = fileNameToValidate.split('~');
|
|
146
|
+
if (parts.length !== 5) {
|
|
147
|
+
return {
|
|
148
|
+
isValid: false,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
// Extract components starting from the end
|
|
152
|
+
const archiveCheck = parts[0];
|
|
153
|
+
const nameCheck = parts[1];
|
|
154
|
+
const tidCheck = parts[2];
|
|
155
|
+
const didCheck = parts[3];
|
|
156
|
+
// Validation checks
|
|
157
|
+
const expectedFullName = `${nameCheck}.${fileExtensionCheck}`.toLowerCase();
|
|
158
|
+
const isValidName = expectedFullName === name.toLowerCase();
|
|
159
|
+
const isValidDid = didCheck ? did.toString() === parseInt(didCheck, 10).toString() : false;
|
|
160
|
+
const isValidTid = tidCheck ? tid.toString() === parseInt(tidCheck, 10).toString() : false;
|
|
161
|
+
const isValidArchive = archiveCheck ? archiveCheck === archiveID : false;
|
|
162
|
+
const isValidExt = ext ? ext.toLowerCase() === fileExtensionCheck.toLowerCase() : false;
|
|
163
|
+
// Return validation results as an object
|
|
164
|
+
return {
|
|
165
|
+
isValid: !!(isValidName && isValidArchive && isValidDid && isValidTid && isValidExt),
|
|
166
|
+
validationResults: {
|
|
167
|
+
archiveID: {
|
|
168
|
+
expected: archiveID,
|
|
169
|
+
current: archiveCheck,
|
|
170
|
+
isValid: isValidArchive
|
|
171
|
+
},
|
|
172
|
+
name: {
|
|
173
|
+
expected: name.toLowerCase(),
|
|
174
|
+
current: expectedFullName,
|
|
175
|
+
isValid: isValidName
|
|
176
|
+
},
|
|
177
|
+
did: {
|
|
178
|
+
expected: did?.toString(),
|
|
179
|
+
current: didCheck,
|
|
180
|
+
isValid: isValidDid
|
|
181
|
+
},
|
|
182
|
+
tid: {
|
|
183
|
+
expected: tid.toString(),
|
|
184
|
+
current: tidCheck,
|
|
185
|
+
isValid: isValidTid
|
|
186
|
+
},
|
|
187
|
+
fileExtension: {
|
|
188
|
+
expected: ext?.toLowerCase(),
|
|
189
|
+
current: fileExtensionCheck.toLowerCase(),
|
|
190
|
+
isValid: isValidExt
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
export const renderCicoCheckInContent = (source, selectedFilename, isValid, validationItems, color = "#996300") => {
|
|
196
|
+
const fileName = source.type === 'fileItem' ? source.fileItem.name : (source.dcmtInfo.fileName ?? SDKUI_Localizator.SearchResult);
|
|
197
|
+
return _jsxs("div", { style: { width: "100%", height: "100%" }, children: [SDKUI_Localizator.CheckInElementConfirm.replaceParams(fileName), !isValid && _jsxs("div", { style: { width: "100%", height: "100%", marginTop: '15px' }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("div", { style: { fontSize: '12px', color, marginBottom: '12px' }, children: SDKUI_Localizator.ElementNameConventionError }), _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '6px' }, children: [_jsxs("div", { style: { color }, children: [_jsx("strong", { style: { color }, children: SDKUI_Localizator.Expected }), ":", ' ', _jsx("span", { style: { fontStyle: 'italic' }, children: getCicoDownloadFileName(source, true, false) })] }), _jsxs("div", { style: { color }, children: [_jsx("strong", { style: { color }, children: SDKUI_Localizator.SelectedSingular }), ":", ' ', _jsx("span", { style: { fontStyle: 'italic' }, children: selectedFilename.name })] })] })] }), validationItems && Object.entries(validationItems).filter(([_, value]) => !value.isValid).length > 0 && (_jsxs("div", { style: { width: "100%", height: "100%", marginTop: '15px' }, children: [_jsx("hr", {}), _jsxs("table", { style: { width: "100%", borderCollapse: "collapse", color }, children: [_jsx("caption", { style: { textAlign: "center", fontWeight: "bold", marginBottom: "5px" }, children: SDKUI_Localizator.Anomalies }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { style: { textAlign: "left", borderBottom: "1px solid #eee" }, children: SDKUI_Localizator.Value }), _jsx("th", { style: { textAlign: "left", borderBottom: "1px solid #eee" }, children: SDKUI_Localizator.Expected }), _jsx("th", { style: { textAlign: "left", borderBottom: "1px solid #eee" }, children: SDKUI_Localizator.Current })] }) }), _jsx("tbody", { children: Object.entries(validationItems).filter(([_, value]) => !value.isValid).map(([key, result]) => (_jsxs("tr", { children: [_jsx("td", { style: { borderBottom: "1px solid #eee" }, children: _jsx("strong", { style: { textTransform: "capitalize" }, children: key }) }), _jsxs("td", { style: { borderBottom: "1px solid #eee" }, children: [" ", result.expected || "-"] }), _jsxs("td", { style: { borderBottom: "1px solid #eee" }, children: [" ", result.current || "-"] })] }, key))) })] }), _jsx("hr", {})] })), _jsx("div", { style: { fontSize: '12px', marginTop: '15px', marginBottom: '15px' }, children: SDKUI_Localizator.ProceedAnyway })] })] });
|
|
198
|
+
};
|
|
199
|
+
const getDcmtCicoInfo = (dtd) => {
|
|
200
|
+
const cico = {
|
|
201
|
+
CICO: 0,
|
|
202
|
+
CanCICO: AccessLevels.No,
|
|
203
|
+
CanDelChronology: AccessLevels.No,
|
|
204
|
+
UserID_MID: 0,
|
|
205
|
+
Date_MID: 0,
|
|
206
|
+
Ver_MID: 0,
|
|
207
|
+
UserID_CanViewOrUpdate: AccessLevels.No,
|
|
208
|
+
Date_CanViewOrUpdate: AccessLevels.No,
|
|
209
|
+
Ver_CanViewOrUpdate: AccessLevels.No,
|
|
210
|
+
};
|
|
211
|
+
if (dtd === undefined)
|
|
212
|
+
return cico;
|
|
213
|
+
cico.CICO = dtd.cico ?? 0;
|
|
214
|
+
cico.CanCICO = dtd.perm?.canCICO ?? AccessLevels.No;
|
|
215
|
+
cico.CanDelChronology = dtd.perm?.canDelChron ?? AccessLevels.No;
|
|
216
|
+
const mdCheckout = dtd.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutUserID);
|
|
217
|
+
if (mdCheckout) {
|
|
218
|
+
cico.UserID_MID = mdCheckout.fromMID;
|
|
219
|
+
cico.UserID_CanViewOrUpdate = (mdCheckout.perm?.canView == AccessLevels.Yes || mdCheckout.perm?.canUpdate == AccessLevels.Yes) ? AccessLevels.Yes : AccessLevels.No;
|
|
220
|
+
}
|
|
221
|
+
const mdDate = dtd.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutDate);
|
|
222
|
+
if (mdDate) {
|
|
223
|
+
cico.Date_MID = mdDate.fromMID;
|
|
224
|
+
cico.Date_CanViewOrUpdate = (mdDate.perm?.canView == AccessLevels.Yes || mdDate.perm?.canUpdate == AccessLevels.Yes) ? AccessLevels.Yes : AccessLevels.No;
|
|
225
|
+
}
|
|
226
|
+
const mdVer = dtd.metadata?.find(md => md.name === CICO_MetadataNames.CICO_Version);
|
|
227
|
+
if (mdVer) {
|
|
228
|
+
cico.Ver_MID = mdVer.fromMID;
|
|
229
|
+
cico.Ver_CanViewOrUpdate = (mdVer.perm?.canView == AccessLevels.Yes || mdVer.perm?.canUpdate == AccessLevels.Yes) ? AccessLevels.Yes : AccessLevels.No;
|
|
230
|
+
}
|
|
231
|
+
return cico;
|
|
232
|
+
};
|
|
233
|
+
export const getDcmtCicoStatus = (dcmt, allUsers, dtd) => {
|
|
234
|
+
if (dcmt === undefined || dtd === undefined) {
|
|
235
|
+
return {
|
|
236
|
+
cicoEnabled: false,
|
|
237
|
+
checkoutStatus: { isCheckedOut: false, mode: '', version: 1, icon: null }
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
const cicoInfo = getDcmtCicoInfo(dtd);
|
|
241
|
+
const CICO_CheckoutUserID_Meta = dtd?.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutUserID);
|
|
242
|
+
const CICO_CheckoutDate_Meta = dtd?.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutDate);
|
|
243
|
+
const CICO_Version_Meta = dtd?.metadata?.find(md => md.name === CICO_MetadataNames.CICO_Version);
|
|
244
|
+
const keyVersion = dcmt.TID + "_" + (CICO_Version_Meta?.id ?? 0);
|
|
245
|
+
const versionRaw = CICO_Version_Meta?.id ? dcmt[keyVersion] : undefined;
|
|
246
|
+
const version = (versionRaw != null && !isNaN(Number(versionRaw))) ? Number(versionRaw) : 1;
|
|
247
|
+
let checkoutStatus = { isCheckedOut: false, mode: '', version: version, icon: null, };
|
|
248
|
+
const userID = SDK_Globals.tmSession?.SessionDescr?.userID;
|
|
249
|
+
if (dcmt && CICO_CheckoutUserID_Meta?.id) {
|
|
250
|
+
const keyUserID = dcmt.TID + "_" + CICO_CheckoutUserID_Meta.id;
|
|
251
|
+
const checkoutUserIdValue = dcmt[keyUserID];
|
|
252
|
+
const checkoutUserId = Number(checkoutUserIdValue);
|
|
253
|
+
if (userID && checkoutUserIdValue && !isNaN(checkoutUserId) && checkoutUserId > 0) {
|
|
254
|
+
// editMode: l'utente corrente è quello che ha fatto il checkout
|
|
255
|
+
// lockMode: un altro utente ha fatto il checkout
|
|
256
|
+
const mode = (userID && userID === checkoutUserId) ? 'editMode' : 'lockMode';
|
|
257
|
+
// Recupera i dati aggiuntivi per il tooltip
|
|
258
|
+
const keyDate = dcmt.TID + "_" + (CICO_CheckoutDate_Meta?.id ?? 0);
|
|
259
|
+
const checkoutDate = CICO_CheckoutDate_Meta?.id ? dcmt[keyDate] : undefined;
|
|
260
|
+
const editLockTooltipText = _jsxs(_Fragment, { children: [_jsxs("div", { style: { textAlign: "center" }, children: [mode === 'editMode' && (_jsxs(_Fragment, { children: [_jsx("i", { style: { fontSize: "18px", color: colors.MEDIUM_GREEN, fontWeight: "bold" }, className: "dx-icon-edit" }), SDKUI_Localizator.CurrentUserExtract] })), mode === 'lockMode' && (_jsxs(_Fragment, { children: [_jsx("i", { style: { fontSize: "18px", color: colors.MEDIUM_GREEN, fontWeight: "bold" }, className: "dx-icon-lock" }), SDKUI_Localizator.ExtractedFromOtherUser] }))] }), _jsx("hr", {}), _jsxs("div", { style: { textAlign: "left" }, children: [_jsxs("ul", { children: [_jsxs("li", { children: ["- ", _jsx("span", { style: { fontWeight: 'bold' }, children: SDKUI_Localizator.ExtractedBy }), ": ", findCheckOutUserName(allUsers, checkoutUserId), " (ID: ", checkoutUserId, ")"] }), _jsxs("li", { children: ["- ", _jsx("span", { style: { fontWeight: 'bold' }, children: SDKUI_Localizator.ExtractedOn }), ": ", Globalization.getDateTimeDisplayValue(checkoutDate?.toString())] })] }), _jsx("hr", {}), _jsx("ul", { children: _jsxs("li", { children: ["- ", _jsx("span", { style: { fontWeight: 'bold' }, children: SDKUI_Localizator.Version }), ": ", version ?? 1] }) })] })] });
|
|
261
|
+
const icon = mode === 'editMode'
|
|
262
|
+
? _jsx(TMTooltip, { content: editLockTooltipText, children: _jsx("i", { style: { fontSize: "18px", color: colors.MEDIUM_GREEN, fontWeight: "bold" }, className: "dx-icon-edit" }) })
|
|
263
|
+
: _jsx(TMTooltip, { content: editLockTooltipText, children: _jsx("i", { style: { fontSize: "18px", color: colors.MEDIUM_GREEN, fontWeight: "bold" }, className: "dx-icon-lock" }) });
|
|
264
|
+
checkoutStatus = { isCheckedOut: true, mode: mode, icon: icon, version: version };
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
cicoEnabled: cicoInfo.CICO === 1 && cicoInfo.CanCICO === AccessLevels.Yes,
|
|
269
|
+
checkoutStatus: checkoutStatus
|
|
270
|
+
};
|
|
271
|
+
};
|
package/lib/helper/index.d.ts
CHANGED
package/lib/helper/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export declare class PlatformObjectService {
|
|
|
6
6
|
static readonly retrieveAllAdminAsync: (objClass: ObjectClasses, jobType?: JobTypes) => Promise<import("@topconsultnpm/sdk-ts").UserDescriptor[] | DcmtTypeDescriptor[] | import("@topconsultnpm/sdk-ts").AreaDescriptor[] | import("@topconsultnpm/sdk-ts").RelationDescriptor[] | import("@topconsultnpm/sdk-ts").FEDistillerJobDescriptor[] | import("@topconsultnpm/sdk-ts").DataListDescriptor[] | import("@topconsultnpm/sdk-ts").DiskDescriptor[] | import("@topconsultnpm/sdk-ts").GroupDescriptor[] | import("@topconsultnpm/sdk-ts").LDAPDescriptor[] | import("@topconsultnpm/sdk-ts").NumeratorDescriptor[] | ProcessDescriptor[] | import("@topconsultnpm/sdk-ts").SAPLoginDescriptor[] | import("@topconsultnpm/sdk-ts").SignCertDescriptor[] | import("@topconsultnpm/sdk-ts").SignServerDescriptor[] | import("@topconsultnpm/sdk-ts").TreeDescriptor[] | import("@topconsultnpm/sdk-ts").TSADescriptor[] | import("@topconsultnpm/sdk-ts").WFDescriptor[] | undefined>;
|
|
7
7
|
private static readonly loadCacheForJobAsync;
|
|
8
8
|
private static readonly retrieveAdminJobAsync;
|
|
9
|
-
static readonly retrieveAdminAsync: (objClass: ObjectClasses, jobType: JobTypes, id: number) => Promise<import("@topconsultnpm/sdk-ts").UserDescriptor | import("@topconsultnpm/sdk-ts").MailSenderJobDescriptor |
|
|
9
|
+
static readonly retrieveAdminAsync: (objClass: ObjectClasses, jobType: JobTypes, id: number) => Promise<import("@topconsultnpm/sdk-ts").UserDescriptor | DcmtTypeDescriptor | import("@topconsultnpm/sdk-ts").MailSenderJobDescriptor | import("@topconsultnpm/sdk-ts").SavedQueryDescriptor | import("@topconsultnpm/sdk-ts").DataListDescriptor | import("@topconsultnpm/sdk-ts").AreaDescriptor | import("@topconsultnpm/sdk-ts").BasketTypeDescriptor | import("@topconsultnpm/sdk-ts").RelationDescriptor | import("@topconsultnpm/sdk-ts").TaskDescriptor | import("@topconsultnpm/sdk-ts").WorkingGroupDescriptor | import("@topconsultnpm/sdk-ts").BarcodeArchiverJobDescriptor | import("@topconsultnpm/sdk-ts").BatchUpdaterJobDescriptor | import("@topconsultnpm/sdk-ts").CassettoDoganaleJobDescriptor | import("@topconsultnpm/sdk-ts").CassettoDoganalePlusJobDescriptor | import("@topconsultnpm/sdk-ts").CassettoFiscaleQueryJobDescriptor | import("@topconsultnpm/sdk-ts").CassettoFiscaleSenderJobDescriptor | import("@topconsultnpm/sdk-ts").CheckSequenceJobDescriptor | import("@topconsultnpm/sdk-ts").COSCheckerJobDescriptor | import("@topconsultnpm/sdk-ts").DcmtConverterJobDescriptor | import("@topconsultnpm/sdk-ts").DcmtDeleterJobDescriptor | import("@topconsultnpm/sdk-ts").DcmtNoteJobDescriptor | import("@topconsultnpm/sdk-ts").DcmtPrinterJobDescriptor | import("@topconsultnpm/sdk-ts").FEAttacherJobDescriptor | import("@topconsultnpm/sdk-ts").FECreatorTxtJobDescriptor | import("@topconsultnpm/sdk-ts").FEDetacherJobDescriptor | import("@topconsultnpm/sdk-ts").FEDistillerJobDescriptor | import("@topconsultnpm/sdk-ts").FESenderWsJobDescriptor | import("@topconsultnpm/sdk-ts").FESplitterJobDescriptor | import("@topconsultnpm/sdk-ts").FEValidatorJobDescriptor | import("@topconsultnpm/sdk-ts").FileArchiverJobDescriptor | import("@topconsultnpm/sdk-ts").FileCheckerJobDescriptor | import("@topconsultnpm/sdk-ts").FileExecJobDescriptor | import("@topconsultnpm/sdk-ts").FileExportJobDescriptor | import("@topconsultnpm/sdk-ts").FileMoverJobDescriptor | import("@topconsultnpm/sdk-ts").LexJobDescriptor | import("@topconsultnpm/sdk-ts").LinkerJobDescriptor | import("@topconsultnpm/sdk-ts").MailArchiverJobDescriptor | import("@topconsultnpm/sdk-ts").MailQueryJobDescriptor | import("@topconsultnpm/sdk-ts").MigrationJobDescriptor | import("@topconsultnpm/sdk-ts").PdDCreatorJobDescriptor | import("@topconsultnpm/sdk-ts").PDFArchiverJobDescriptor | import("@topconsultnpm/sdk-ts").PdVArchiverJobDescriptor | import("@topconsultnpm/sdk-ts").PdVQueryJobDescriptor | import("@topconsultnpm/sdk-ts").PdVSenderJobDescriptor | import("@topconsultnpm/sdk-ts").PeppolQueryJobDescriptor | import("@topconsultnpm/sdk-ts").PeppolSenderJobDescriptor | import("@topconsultnpm/sdk-ts").PostelQueryJobDescriptor | import("@topconsultnpm/sdk-ts").PostelSenderJobDescriptor | import("@topconsultnpm/sdk-ts").ReplicatorJobDescriptor | import("@topconsultnpm/sdk-ts").SAPAlignerJobDescriptor | import("@topconsultnpm/sdk-ts").SAPBarcodeJobDescriptor | import("@topconsultnpm/sdk-ts").SAPDataReaderJobDescriptor | import("@topconsultnpm/sdk-ts").SAPDataWriterJobDescriptor | import("@topconsultnpm/sdk-ts").SignerJobDescriptor | import("@topconsultnpm/sdk-ts").SpoolArchiverJobDescriptor | import("@topconsultnpm/sdk-ts").UpdaterJobDescriptor | import("@topconsultnpm/sdk-ts").DiskDescriptor | import("@topconsultnpm/sdk-ts").GroupDescriptor | import("@topconsultnpm/sdk-ts").LDAPDescriptor | import("@topconsultnpm/sdk-ts").NumeratorDescriptor | ProcessDescriptor | import("@topconsultnpm/sdk-ts").SAPLoginDescriptor | import("@topconsultnpm/sdk-ts").SignCertDescriptor | import("@topconsultnpm/sdk-ts").SignServerDescriptor | import("@topconsultnpm/sdk-ts").TreeDescriptor | import("@topconsultnpm/sdk-ts").TSADescriptor | import("@topconsultnpm/sdk-ts").WFDescriptor | undefined>;
|
|
10
10
|
private static readonly updateJobAsync;
|
|
11
11
|
static readonly updateAsync: (objClass: ObjectClasses, jobType: JobTypes, d: any, ...args: any[]) => Promise<number | undefined>;
|
|
12
12
|
private static readonly createJobAsync;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topconsultnpm/sdkui-react",
|
|
3
|
-
"version": "6.20.0-dev1.
|
|
3
|
+
"version": "6.20.0-dev1.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"lib"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@topconsultnpm/sdk-ts": "6.
|
|
42
|
+
"@topconsultnpm/sdk-ts": "6.20.0-dev1.1",
|
|
43
43
|
"buffer": "^6.0.3",
|
|
44
44
|
"devextreme": "25.1.7",
|
|
45
45
|
"devextreme-react": "25.1.7",
|
|
@@ -1,187 +0,0 @@
|
|
|
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 } from './hooks';
|
|
5
|
-
const TMContextMenu = ({ items, trigger = 'right', children }) => {
|
|
6
|
-
const [menuState, setMenuState] = useState({
|
|
7
|
-
visible: false,
|
|
8
|
-
position: { x: 0, y: 0 },
|
|
9
|
-
submenuStack: [items],
|
|
10
|
-
parentNames: [],
|
|
11
|
-
});
|
|
12
|
-
const [hoveredSubmenus, setHoveredSubmenus] = useState([]);
|
|
13
|
-
const isMobile = useIsMobile();
|
|
14
|
-
const menuRef = useRef(null);
|
|
15
|
-
const triggerRef = useRef(null);
|
|
16
|
-
const submenuTimeoutRef = useRef(null);
|
|
17
|
-
const { openLeft, openUp } = useMenuPosition(menuRef, menuState.position);
|
|
18
|
-
const handleClose = () => {
|
|
19
|
-
setMenuState(prev => ({
|
|
20
|
-
...prev,
|
|
21
|
-
visible: false,
|
|
22
|
-
submenuStack: [items],
|
|
23
|
-
parentNames: [],
|
|
24
|
-
}));
|
|
25
|
-
setHoveredSubmenus([]);
|
|
26
|
-
};
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (!menuState.visible)
|
|
29
|
-
return;
|
|
30
|
-
const handleClickOutside = (event) => {
|
|
31
|
-
const target = event.target;
|
|
32
|
-
// Check if click is inside main menu
|
|
33
|
-
if (menuRef.current?.contains(target)) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
// Check if click is inside any submenu
|
|
37
|
-
const submenus = document.querySelectorAll('[data-submenu="true"]');
|
|
38
|
-
for (const submenu of Array.from(submenus)) {
|
|
39
|
-
if (submenu.contains(target)) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
// Click is outside all menus, close them
|
|
44
|
-
handleClose();
|
|
45
|
-
};
|
|
46
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
47
|
-
document.addEventListener('touchstart', handleClickOutside);
|
|
48
|
-
return () => {
|
|
49
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
50
|
-
document.removeEventListener('touchstart', handleClickOutside);
|
|
51
|
-
};
|
|
52
|
-
}, [menuState.visible]);
|
|
53
|
-
const handleContextMenu = (e) => {
|
|
54
|
-
if (trigger === 'right') {
|
|
55
|
-
e.preventDefault();
|
|
56
|
-
setMenuState({
|
|
57
|
-
visible: true,
|
|
58
|
-
position: { x: e.clientX, y: e.clientY },
|
|
59
|
-
submenuStack: [items],
|
|
60
|
-
parentNames: [],
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
const handleClick = (e) => {
|
|
65
|
-
if (trigger === 'left') {
|
|
66
|
-
e.preventDefault();
|
|
67
|
-
setMenuState({
|
|
68
|
-
visible: true,
|
|
69
|
-
position: { x: e.clientX, y: e.clientY },
|
|
70
|
-
submenuStack: [items],
|
|
71
|
-
parentNames: [],
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
const handleItemClick = (item) => {
|
|
76
|
-
if (item.disabled)
|
|
77
|
-
return;
|
|
78
|
-
// Always execute onClick if present
|
|
79
|
-
if (item.onClick) {
|
|
80
|
-
item.onClick();
|
|
81
|
-
}
|
|
82
|
-
if (item.submenu && item.submenu.length > 0) {
|
|
83
|
-
if (isMobile) {
|
|
84
|
-
// Mobile: Push submenu to stack
|
|
85
|
-
setMenuState(prev => ({
|
|
86
|
-
...prev,
|
|
87
|
-
submenuStack: [...prev.submenuStack, item.submenu],
|
|
88
|
-
parentNames: [...prev.parentNames, item.name],
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
91
|
-
// Desktop: Submenus are handled by hover, don't close menu
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
// No submenu: close menu after executing action
|
|
95
|
-
handleClose();
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
const handleBack = () => {
|
|
99
|
-
setMenuState(prev => ({
|
|
100
|
-
...prev,
|
|
101
|
-
submenuStack: prev.submenuStack.slice(0, -1),
|
|
102
|
-
parentNames: prev.parentNames.slice(0, -1),
|
|
103
|
-
}));
|
|
104
|
-
};
|
|
105
|
-
const handleMouseEnter = (item, event, depth = 0) => {
|
|
106
|
-
if (isMobile || !item.submenu || item.submenu.length === 0)
|
|
107
|
-
return;
|
|
108
|
-
if (submenuTimeoutRef.current) {
|
|
109
|
-
clearTimeout(submenuTimeoutRef.current);
|
|
110
|
-
submenuTimeoutRef.current = null;
|
|
111
|
-
}
|
|
112
|
-
const rect = event.currentTarget.getBoundingClientRect();
|
|
113
|
-
// Calculate if submenu should open upward based on available space
|
|
114
|
-
// Estimate submenu height: ~35px per item (accounting for smaller padding) + container padding
|
|
115
|
-
const estimatedSubmenuHeight = (item.submenu.length * 35) + 8;
|
|
116
|
-
const spaceBelow = window.innerHeight - rect.top;
|
|
117
|
-
const spaceAbove = rect.bottom;
|
|
118
|
-
// Open upward only if there's not enough space below AND there's more space above
|
|
119
|
-
const shouldOpenUp = spaceBelow < estimatedSubmenuHeight && spaceAbove > spaceBelow;
|
|
120
|
-
// Remove all submenus at this depth and deeper
|
|
121
|
-
setHoveredSubmenus(prev => {
|
|
122
|
-
const filtered = prev.filter(sub => sub.depth < depth);
|
|
123
|
-
if (!item.submenu)
|
|
124
|
-
return filtered;
|
|
125
|
-
return [
|
|
126
|
-
...filtered,
|
|
127
|
-
{
|
|
128
|
-
items: item.submenu,
|
|
129
|
-
parentRect: rect,
|
|
130
|
-
depth: depth,
|
|
131
|
-
openUp: shouldOpenUp,
|
|
132
|
-
}
|
|
133
|
-
];
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
const handleMouseLeave = (depth = 0) => {
|
|
137
|
-
if (isMobile)
|
|
138
|
-
return;
|
|
139
|
-
if (submenuTimeoutRef.current) {
|
|
140
|
-
clearTimeout(submenuTimeoutRef.current);
|
|
141
|
-
}
|
|
142
|
-
const targetDepth = depth;
|
|
143
|
-
submenuTimeoutRef.current = setTimeout(() => {
|
|
144
|
-
setHoveredSubmenus(prev => prev.filter(sub => sub.depth < targetDepth));
|
|
145
|
-
}, 300);
|
|
146
|
-
};
|
|
147
|
-
const handleSubmenuMouseEnter = () => {
|
|
148
|
-
if (submenuTimeoutRef.current) {
|
|
149
|
-
clearTimeout(submenuTimeoutRef.current);
|
|
150
|
-
submenuTimeoutRef.current = null;
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
useEffect(() => {
|
|
154
|
-
return () => {
|
|
155
|
-
if (submenuTimeoutRef.current) {
|
|
156
|
-
clearTimeout(submenuTimeoutRef.current);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
}, []);
|
|
160
|
-
const renderMenuItems = (menuItems, depth = 0) => {
|
|
161
|
-
return menuItems
|
|
162
|
-
.filter(item => item.visible !== false)
|
|
163
|
-
.map((item, idx) => {
|
|
164
|
-
const itemKey = `${item.name}-${idx}`.replaceAll(/\s+/g, '-');
|
|
165
|
-
const handleClick = (e) => {
|
|
166
|
-
if (item.disabled)
|
|
167
|
-
return;
|
|
168
|
-
e.stopPropagation();
|
|
169
|
-
handleItemClick(item);
|
|
170
|
-
};
|
|
171
|
-
const handleRightIconClick = (e) => {
|
|
172
|
-
e.stopPropagation();
|
|
173
|
-
// if (item.disabled) return;
|
|
174
|
-
item.onRightIconClick?.();
|
|
175
|
-
};
|
|
176
|
-
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), 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));
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
const currentMenu = menuState.submenuStack.at(-1) || items;
|
|
180
|
-
const currentParentName = menuState.parentNames.at(-1) || '';
|
|
181
|
-
return (_jsxs(_Fragment, { children: [_jsx("div", { ref: triggerRef, onContextMenu: handleContextMenu, onClick: handleClick, onKeyDown: (e) => {
|
|
182
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
183
|
-
handleClick(e);
|
|
184
|
-
}
|
|
185
|
-
}, role: "button", tabIndex: 0, style: { display: 'inline-block' }, children: children }), menuState.visible && (_jsxs(_Fragment, { children: [_jsx(S.Overlay, { onClick: handleClose }), _jsxs(S.MenuContainer, { ref: menuRef, "$x": menuState.position.x, "$y": menuState.position.y, "$openLeft": openLeft, "$openUp": openUp, children: [isMobile && menuState.parentNames.length > 0 && (_jsxs(S.MobileMenuHeader, { children: [_jsx(S.BackButton, { onClick: handleBack, "aria-label": "Go back", children: "\u2190" }), _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}`)))] }))] }));
|
|
186
|
-
};
|
|
187
|
-
export default TMContextMenu;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare const useIsMobile: () => boolean;
|
|
2
|
-
export declare const useClickOutside: (callback: () => void) => import("react").RefObject<HTMLDivElement>;
|
|
3
|
-
interface Position {
|
|
4
|
-
x: number;
|
|
5
|
-
y: number;
|
|
6
|
-
}
|
|
7
|
-
export declare const useMenuPosition: (menuRef: React.RefObject<HTMLDivElement | null>, position: Position) => {
|
|
8
|
-
openLeft: boolean;
|
|
9
|
-
openUp: boolean;
|
|
10
|
-
};
|
|
11
|
-
export {};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect, useRef } from 'react';
|
|
2
|
-
export const useIsMobile = () => {
|
|
3
|
-
const [isMobile, setIsMobile] = useState(false);
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
const checkMobile = () => {
|
|
6
|
-
const mobile = globalThis.innerWidth <= 768 || 'ontouchstart' in globalThis;
|
|
7
|
-
setIsMobile(mobile);
|
|
8
|
-
};
|
|
9
|
-
checkMobile();
|
|
10
|
-
window.addEventListener('resize', checkMobile);
|
|
11
|
-
return () => window.removeEventListener('resize', checkMobile);
|
|
12
|
-
}, []);
|
|
13
|
-
return isMobile;
|
|
14
|
-
};
|
|
15
|
-
export const useClickOutside = (callback) => {
|
|
16
|
-
const ref = useRef(null);
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
const handleClick = (event) => {
|
|
19
|
-
if (ref.current && !ref.current.contains(event.target)) {
|
|
20
|
-
callback();
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
document.addEventListener('mousedown', handleClick);
|
|
24
|
-
document.addEventListener('touchstart', handleClick);
|
|
25
|
-
return () => {
|
|
26
|
-
document.removeEventListener('mousedown', handleClick);
|
|
27
|
-
document.removeEventListener('touchstart', handleClick);
|
|
28
|
-
};
|
|
29
|
-
}, [callback]);
|
|
30
|
-
return ref;
|
|
31
|
-
};
|
|
32
|
-
export const useMenuPosition = (menuRef, position) => {
|
|
33
|
-
const [adjustedPosition, setAdjustedPosition] = useState({ openLeft: false, openUp: false });
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (!menuRef.current)
|
|
36
|
-
return;
|
|
37
|
-
const menuRect = menuRef.current.getBoundingClientRect();
|
|
38
|
-
const viewportWidth = window.innerWidth;
|
|
39
|
-
const viewportHeight = window.innerHeight;
|
|
40
|
-
const spaceRight = viewportWidth - position.x;
|
|
41
|
-
const spaceBottom = viewportHeight - position.y;
|
|
42
|
-
setAdjustedPosition({
|
|
43
|
-
openLeft: spaceRight < menuRect.width + 20,
|
|
44
|
-
openUp: spaceBottom < menuRect.height + 20,
|
|
45
|
-
});
|
|
46
|
-
}, [position, menuRef]);
|
|
47
|
-
return adjustedPosition;
|
|
48
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as ContextMenu } from './TMContextMenu';
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
}>> & string;
|
|
7
|
-
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>, {
|
|
8
|
-
$disabled?: boolean;
|
|
9
|
-
$hasSubmenu?: boolean;
|
|
10
|
-
$beginGroup?: boolean;
|
|
11
|
-
}>> & string;
|
|
12
|
-
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;
|
|
13
|
-
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;
|
|
14
|
-
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;
|
|
15
|
-
export declare const RightIconButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
|
|
16
|
-
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>, {
|
|
17
|
-
$isMobile?: boolean;
|
|
18
|
-
}>> & string;
|
|
19
|
-
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>, {
|
|
20
|
-
$parentRect: DOMRect;
|
|
21
|
-
$openUp?: boolean;
|
|
22
|
-
}>> & string;
|
|
23
|
-
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;
|
|
24
|
-
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;
|
|
25
|
-
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;
|
|
26
|
-
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;
|
|
27
|
-
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;
|