@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
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { TMContextMenuItemProps } from '../ContextMenu';
|
|
2
|
-
export interface TMFloatingMenuItem {
|
|
3
|
-
id: string;
|
|
4
|
-
name: string;
|
|
5
|
-
icon: React.ReactNode;
|
|
6
|
-
onClick: () => void;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
isPinned?: boolean;
|
|
9
|
-
originalMenuItem?: TMContextMenuItemProps;
|
|
10
|
-
}
|
|
11
|
-
export interface TMFloatingMenuBarProps {
|
|
12
|
-
containerRef: React.RefObject<HTMLElement | null>;
|
|
13
|
-
contextMenuItems?: TMContextMenuItemProps[];
|
|
14
|
-
storageKey?: string;
|
|
15
|
-
isConstrained?: boolean;
|
|
16
|
-
defaultPosition?: Position;
|
|
17
|
-
maxItems?: number;
|
|
18
|
-
}
|
|
19
|
-
export interface Position {
|
|
20
|
-
x: number;
|
|
21
|
-
y: number;
|
|
22
|
-
}
|
|
23
|
-
export interface TMFloatingMenuBarState {
|
|
24
|
-
position: Position;
|
|
25
|
-
isDragging: boolean;
|
|
26
|
-
isConfigMode: boolean;
|
|
27
|
-
orientation: 'horizontal' | 'vertical';
|
|
28
|
-
items: TMFloatingMenuItem[];
|
|
29
|
-
draggedItemIndex: number | null;
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useEffect, useRef } from 'react';
|
|
3
|
-
import * as S from './styles';
|
|
4
|
-
const Notification = ({ title, message, mode = 'info', position = 'top-right', duration = 3000, closable = false, stopOnMouseEnter = true, hasProgress = true, onClose, }) => {
|
|
5
|
-
const [state, setState] = useState({
|
|
6
|
-
visible: true,
|
|
7
|
-
isPaused: false,
|
|
8
|
-
progress: 100,
|
|
9
|
-
});
|
|
10
|
-
const timeoutRef = useRef(undefined);
|
|
11
|
-
const remainingTimeRef = useRef(duration);
|
|
12
|
-
const pauseTimeRef = useRef(0);
|
|
13
|
-
const closeNotification = () => {
|
|
14
|
-
setState(prev => ({ ...prev, visible: false }));
|
|
15
|
-
setTimeout(() => {
|
|
16
|
-
onClose?.();
|
|
17
|
-
}, 300);
|
|
18
|
-
};
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
// Set up auto-close timer
|
|
21
|
-
timeoutRef.current = setTimeout(() => {
|
|
22
|
-
closeNotification();
|
|
23
|
-
}, duration);
|
|
24
|
-
return () => {
|
|
25
|
-
if (timeoutRef.current) {
|
|
26
|
-
clearTimeout(timeoutRef.current);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}, [duration]);
|
|
30
|
-
const handleMouseEnter = () => {
|
|
31
|
-
if (!stopOnMouseEnter)
|
|
32
|
-
return;
|
|
33
|
-
// Pause the timer
|
|
34
|
-
if (timeoutRef.current) {
|
|
35
|
-
clearTimeout(timeoutRef.current);
|
|
36
|
-
pauseTimeRef.current = Date.now();
|
|
37
|
-
}
|
|
38
|
-
setState(prev => ({ ...prev, isPaused: true }));
|
|
39
|
-
};
|
|
40
|
-
const handleMouseLeave = () => {
|
|
41
|
-
if (!stopOnMouseEnter)
|
|
42
|
-
return;
|
|
43
|
-
// Resume the timer with remaining time
|
|
44
|
-
const pauseDuration = Date.now() - pauseTimeRef.current;
|
|
45
|
-
remainingTimeRef.current = Math.max(0, remainingTimeRef.current - pauseDuration);
|
|
46
|
-
timeoutRef.current = setTimeout(() => {
|
|
47
|
-
closeNotification();
|
|
48
|
-
}, remainingTimeRef.current);
|
|
49
|
-
setState(prev => ({ ...prev, isPaused: false }));
|
|
50
|
-
};
|
|
51
|
-
const handleClose = (e) => {
|
|
52
|
-
e.stopPropagation();
|
|
53
|
-
if (timeoutRef.current) {
|
|
54
|
-
clearTimeout(timeoutRef.current);
|
|
55
|
-
}
|
|
56
|
-
closeNotification();
|
|
57
|
-
};
|
|
58
|
-
return (_jsxs(S.NotificationContainer, { "$position": position, "$mode": mode, "$visible": state.visible, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, role: "alert", "aria-live": "assertive", children: [_jsxs(S.NotificationContent, { children: [_jsx(S.NotificationTitle, { children: title }), _jsx(S.NotificationMessage, { children: message })] }), closable && (_jsx(S.CloseButton, { onClick: handleClose, "aria-label": "Close notification", children: "\u00D7" })), hasProgress && (_jsx(S.ProgressBar, { "$duration": duration, "$mode": mode, "$isPaused": state.isPaused }))] }));
|
|
59
|
-
};
|
|
60
|
-
export default Notification;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { NotificationPosition } from './types';
|
|
3
|
-
interface NotificationContainerProps {
|
|
4
|
-
position: NotificationPosition;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
}
|
|
7
|
-
declare const NotificationContainer: React.FC<NotificationContainerProps>;
|
|
8
|
-
export default NotificationContainer;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
const Container = styled.div `
|
|
4
|
-
position: fixed;
|
|
5
|
-
z-index: 10002;
|
|
6
|
-
display: flex;
|
|
7
|
-
flex-direction: column;
|
|
8
|
-
gap: 12px;
|
|
9
|
-
pointer-events: none;
|
|
10
|
-
|
|
11
|
-
${props => {
|
|
12
|
-
const isTop = props.$position.startsWith('top');
|
|
13
|
-
const isBottom = props.$position.startsWith('bottom');
|
|
14
|
-
const isLeft = props.$position.endsWith('left');
|
|
15
|
-
const isRight = props.$position.endsWith('right');
|
|
16
|
-
const isCenter = props.$position.endsWith('center');
|
|
17
|
-
return `
|
|
18
|
-
${isTop ? 'top: 24px;' : ''}
|
|
19
|
-
${isBottom ? 'bottom: 24px;' : ''}
|
|
20
|
-
${isLeft ? 'left: 24px;' : ''}
|
|
21
|
-
${isRight ? 'right: 24px;' : ''}
|
|
22
|
-
${isCenter ? 'left: 50%; transform: translateX(-50%);' : ''}
|
|
23
|
-
`;
|
|
24
|
-
}}
|
|
25
|
-
|
|
26
|
-
& > * {
|
|
27
|
-
pointer-events: auto;
|
|
28
|
-
}
|
|
29
|
-
`;
|
|
30
|
-
const NotificationContainer = ({ position, children }) => {
|
|
31
|
-
return _jsx(Container, { "$position": position, children: children });
|
|
32
|
-
};
|
|
33
|
-
export default NotificationContainer;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { NotificationMode, NotificationPosition } from './types';
|
|
2
|
-
export declare const NotificationContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
3
|
-
$position: NotificationPosition;
|
|
4
|
-
$mode: NotificationMode;
|
|
5
|
-
$visible: boolean;
|
|
6
|
-
}>> & string;
|
|
7
|
-
export declare const NotificationContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
8
|
-
export declare const NotificationTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
9
|
-
export declare const NotificationMessage: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
10
|
-
export declare const CloseButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
|
|
11
|
-
export declare const ProgressBar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("styled-components/dist/types").Substitute<import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
12
|
-
ref?: ((instance: HTMLDivElement | 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<HTMLDivElement> | null | undefined;
|
|
13
|
-
}>, {
|
|
14
|
-
$duration: number;
|
|
15
|
-
$mode: NotificationMode;
|
|
16
|
-
$isPaused: boolean;
|
|
17
|
-
}>, {
|
|
18
|
-
$duration: number;
|
|
19
|
-
$mode: NotificationMode;
|
|
20
|
-
$isPaused: boolean;
|
|
21
|
-
}>> & string;
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import styled, { keyframes } from 'styled-components';
|
|
2
|
-
const slideInFromTop = keyframes `
|
|
3
|
-
from {
|
|
4
|
-
opacity: 0;
|
|
5
|
-
transform: translateY(-100%);
|
|
6
|
-
}
|
|
7
|
-
to {
|
|
8
|
-
opacity: 1;
|
|
9
|
-
transform: translateY(0);
|
|
10
|
-
}
|
|
11
|
-
`;
|
|
12
|
-
const slideInFromBottom = keyframes `
|
|
13
|
-
from {
|
|
14
|
-
opacity: 0;
|
|
15
|
-
transform: translateY(100%);
|
|
16
|
-
}
|
|
17
|
-
to {
|
|
18
|
-
opacity: 1;
|
|
19
|
-
transform: translateY(0);
|
|
20
|
-
}
|
|
21
|
-
`;
|
|
22
|
-
const slideOut = keyframes `
|
|
23
|
-
from {
|
|
24
|
-
opacity: 1;
|
|
25
|
-
transform: scale(1);
|
|
26
|
-
}
|
|
27
|
-
to {
|
|
28
|
-
opacity: 0;
|
|
29
|
-
transform: scale(0.9);
|
|
30
|
-
}
|
|
31
|
-
`;
|
|
32
|
-
const getModeColors = (mode) => {
|
|
33
|
-
const colors = {
|
|
34
|
-
success: {
|
|
35
|
-
bg: '#10b981',
|
|
36
|
-
bgDark: '#059669',
|
|
37
|
-
border: '#34d399',
|
|
38
|
-
text: '#ffffff',
|
|
39
|
-
},
|
|
40
|
-
error: {
|
|
41
|
-
bg: '#ef4444',
|
|
42
|
-
bgDark: '#dc2626',
|
|
43
|
-
border: '#f87171',
|
|
44
|
-
text: '#ffffff',
|
|
45
|
-
},
|
|
46
|
-
warning: {
|
|
47
|
-
bg: '#f59e0b',
|
|
48
|
-
bgDark: '#d97706',
|
|
49
|
-
border: '#fbbf24',
|
|
50
|
-
text: '#ffffff',
|
|
51
|
-
},
|
|
52
|
-
info: {
|
|
53
|
-
bg: '#3b82f6',
|
|
54
|
-
bgDark: '#2563eb',
|
|
55
|
-
border: '#60a5fa',
|
|
56
|
-
text: '#ffffff',
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
return colors[mode];
|
|
60
|
-
};
|
|
61
|
-
export const NotificationContainer = styled.div `
|
|
62
|
-
position: relative;
|
|
63
|
-
z-index: 1;
|
|
64
|
-
min-width: 320px;
|
|
65
|
-
max-width: 420px;
|
|
66
|
-
background: ${props => getModeColors(props.$mode).bg};
|
|
67
|
-
border-radius: 12px;
|
|
68
|
-
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2),
|
|
69
|
-
0 4px 12px rgba(0, 0, 0, 0.15);
|
|
70
|
-
padding: 16px 20px;
|
|
71
|
-
animation: ${props => {
|
|
72
|
-
if (!props.$visible)
|
|
73
|
-
return slideOut;
|
|
74
|
-
return props.$position.startsWith('top') ? slideInFromTop : slideInFromBottom;
|
|
75
|
-
}} 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
|
|
76
|
-
backdrop-filter: blur(10px);
|
|
77
|
-
border: 2px solid ${props => getModeColors(props.$mode).border};
|
|
78
|
-
color: ${props => getModeColors(props.$mode).text};
|
|
79
|
-
overflow: hidden;
|
|
80
|
-
|
|
81
|
-
[data-theme='dark'] & {
|
|
82
|
-
background: ${props => getModeColors(props.$mode).bgDark};
|
|
83
|
-
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4),
|
|
84
|
-
0 4px 12px rgba(0, 0, 0, 0.3);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
@media (max-width: 768px) {
|
|
88
|
-
min-width: 280px;
|
|
89
|
-
max-width: calc(100vw - 48px);
|
|
90
|
-
}
|
|
91
|
-
`;
|
|
92
|
-
export const NotificationContent = styled.div `
|
|
93
|
-
display: flex;
|
|
94
|
-
flex-direction: column;
|
|
95
|
-
gap: 6px;
|
|
96
|
-
padding-right: 24px;
|
|
97
|
-
`;
|
|
98
|
-
export const NotificationTitle = styled.div `
|
|
99
|
-
font-size: 16px;
|
|
100
|
-
font-weight: 600;
|
|
101
|
-
line-height: 1.4;
|
|
102
|
-
letter-spacing: -0.01em;
|
|
103
|
-
`;
|
|
104
|
-
export const NotificationMessage = styled.div `
|
|
105
|
-
font-size: 14px;
|
|
106
|
-
font-weight: 400;
|
|
107
|
-
line-height: 1.5;
|
|
108
|
-
opacity: 0.95;
|
|
109
|
-
`;
|
|
110
|
-
export const CloseButton = styled.button `
|
|
111
|
-
position: absolute;
|
|
112
|
-
top: 12px;
|
|
113
|
-
right: 12px;
|
|
114
|
-
background: transparent;
|
|
115
|
-
border: none;
|
|
116
|
-
color: inherit;
|
|
117
|
-
cursor: pointer;
|
|
118
|
-
width: 24px;
|
|
119
|
-
height: 24px;
|
|
120
|
-
display: flex;
|
|
121
|
-
align-items: center;
|
|
122
|
-
justify-content: center;
|
|
123
|
-
border-radius: 6px;
|
|
124
|
-
transition: all 0.15s ease;
|
|
125
|
-
font-size: 18px;
|
|
126
|
-
line-height: 1;
|
|
127
|
-
padding: 0;
|
|
128
|
-
opacity: 0.8;
|
|
129
|
-
|
|
130
|
-
&:hover {
|
|
131
|
-
opacity: 1;
|
|
132
|
-
background: rgba(255, 255, 255, 0.2);
|
|
133
|
-
transform: scale(1.1);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
&:active {
|
|
137
|
-
transform: scale(0.95);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
&:focus {
|
|
141
|
-
outline: 2px solid rgba(255, 255, 255, 0.5);
|
|
142
|
-
outline-offset: 2px;
|
|
143
|
-
}
|
|
144
|
-
`;
|
|
145
|
-
export const ProgressBar = styled.div.attrs(props => ({
|
|
146
|
-
style: {
|
|
147
|
-
animationDuration: `${props.$duration}ms`,
|
|
148
|
-
},
|
|
149
|
-
})) `
|
|
150
|
-
position: absolute;
|
|
151
|
-
bottom: 0;
|
|
152
|
-
left: 0;
|
|
153
|
-
height: 4px;
|
|
154
|
-
width: 100%;
|
|
155
|
-
background: ${props => getModeColors(props.$mode).border};
|
|
156
|
-
border-radius: 0 0 0 10px;
|
|
157
|
-
box-shadow: 0 0 8px ${props => getModeColors(props.$mode).border};
|
|
158
|
-
transform-origin: left;
|
|
159
|
-
animation: progress-shrink linear forwards;
|
|
160
|
-
animation-play-state: ${props => props.$isPaused ? 'paused' : 'running'};
|
|
161
|
-
|
|
162
|
-
@keyframes progress-shrink {
|
|
163
|
-
from {
|
|
164
|
-
transform: scaleX(1);
|
|
165
|
-
}
|
|
166
|
-
to {
|
|
167
|
-
transform: scaleX(0);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
&::after {
|
|
172
|
-
content: '';
|
|
173
|
-
position: absolute;
|
|
174
|
-
top: 0;
|
|
175
|
-
right: 0;
|
|
176
|
-
width: 20px;
|
|
177
|
-
height: 100%;
|
|
178
|
-
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4));
|
|
179
|
-
}
|
|
180
|
-
`;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type NotificationMode = 'warning' | 'info' | 'error' | 'success';
|
|
2
|
-
export type NotificationPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
3
|
-
export interface NotificationProps {
|
|
4
|
-
title: string;
|
|
5
|
-
message: string;
|
|
6
|
-
mode?: NotificationMode;
|
|
7
|
-
position?: NotificationPosition;
|
|
8
|
-
duration?: number;
|
|
9
|
-
closable?: boolean;
|
|
10
|
-
stopOnMouseEnter?: boolean;
|
|
11
|
-
hasProgress?: boolean;
|
|
12
|
-
onClose?: () => void;
|
|
13
|
-
}
|
|
14
|
-
export interface NotificationState {
|
|
15
|
-
visible: boolean;
|
|
16
|
-
isPaused: boolean;
|
|
17
|
-
progress: number;
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { AccessLevels, DcmtTypeDescriptor, FileDescriptor, UserDescriptor } from "@topconsultnpm/sdk-ts";
|
|
3
|
-
import { DcmtCheckoutInfo } from "./index";
|
|
4
|
-
import { DcmtInfo, DownloadModes, DownloadTypes } from "../ts/types";
|
|
5
|
-
export interface CheckInCheckOutInfo {
|
|
6
|
-
CICO: number;
|
|
7
|
-
CanCICO: AccessLevels;
|
|
8
|
-
CanDelChronology: AccessLevels;
|
|
9
|
-
UserID_MID: number;
|
|
10
|
-
Date_MID: number;
|
|
11
|
-
Ver_MID: number;
|
|
12
|
-
UserID_CanViewOrUpdate: AccessLevels;
|
|
13
|
-
Date_CanViewOrUpdate: AccessLevels;
|
|
14
|
-
Ver_CanViewOrUpdate: AccessLevels;
|
|
15
|
-
}
|
|
16
|
-
export declare const colors: {
|
|
17
|
-
MEDIUM_GREEN: string;
|
|
18
|
-
};
|
|
19
|
-
export interface CheckoutStatusResult {
|
|
20
|
-
isCheckedOut: boolean;
|
|
21
|
-
mode: 'editMode' | 'lockMode' | '';
|
|
22
|
-
version: number;
|
|
23
|
-
icon: React.ReactNode | null;
|
|
24
|
-
}
|
|
25
|
-
export declare const cicoIsEnabled: (dcmt: any, allUsers: Array<UserDescriptor>, dtd: DcmtTypeDescriptor | undefined) => {
|
|
26
|
-
cicoEnabled: boolean;
|
|
27
|
-
checkoutStatus: CheckoutStatusResult;
|
|
28
|
-
};
|
|
29
|
-
export declare const getCicoDownloadFileName: (originalFileName: string, fileItem: DcmtInfo | undefined, checkout: boolean, withTimestampAndExt: boolean) => string;
|
|
30
|
-
export declare const updateDcmtCheckoutItem: (item: DcmtCheckoutInfo, action?: "addOrUpdate" | "remove") => void;
|
|
31
|
-
export declare const downloadFilesCallback: (originalFileName: string, dcmt: Array<DcmtInfo>, checkout: boolean, downloadDcmtsAsync: (inputDcmts: Array<DcmtInfo> | undefined, downloadType?: DownloadTypes, downloadMode?: DownloadModes, onFileDownloaded?: (dcmtFile: File) => void, confirmAttachments?: (list: FileDescriptor[]) => Promise<string[] | undefined>, skipConfirmation?: boolean) => Promise<void>) => Promise<void>;
|
package/lib/helper/cicoHelper.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } 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
|
-
export const colors = {
|
|
7
|
-
MEDIUM_GREEN: "#28a745",
|
|
8
|
-
};
|
|
9
|
-
const getCicoInfo = (dtd) => {
|
|
10
|
-
const cico = {
|
|
11
|
-
CICO: 0,
|
|
12
|
-
CanCICO: AccessLevels.No,
|
|
13
|
-
CanDelChronology: AccessLevels.No,
|
|
14
|
-
UserID_MID: 0,
|
|
15
|
-
Date_MID: 0,
|
|
16
|
-
Ver_MID: 0,
|
|
17
|
-
UserID_CanViewOrUpdate: AccessLevels.No,
|
|
18
|
-
Date_CanViewOrUpdate: AccessLevels.No,
|
|
19
|
-
Ver_CanViewOrUpdate: AccessLevels.No,
|
|
20
|
-
};
|
|
21
|
-
if (dtd === undefined)
|
|
22
|
-
return cico;
|
|
23
|
-
cico.CICO = dtd.cico ?? 0;
|
|
24
|
-
cico.CanCICO = dtd.perm?.canCICO ?? AccessLevels.No;
|
|
25
|
-
cico.CanDelChronology = dtd.perm?.canDelChron ?? AccessLevels.No;
|
|
26
|
-
const mdCheckout = dtd.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutUserID);
|
|
27
|
-
if (mdCheckout) {
|
|
28
|
-
cico.UserID_MID = mdCheckout.fromMID;
|
|
29
|
-
cico.UserID_CanViewOrUpdate = (mdCheckout.perm?.canView == AccessLevels.Yes || mdCheckout.perm?.canUpdate == AccessLevels.Yes) ? AccessLevels.Yes : AccessLevels.No;
|
|
30
|
-
}
|
|
31
|
-
const mdDate = dtd.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutDate);
|
|
32
|
-
if (mdDate) {
|
|
33
|
-
cico.Date_MID = mdDate.fromMID;
|
|
34
|
-
cico.Date_CanViewOrUpdate = (mdDate.perm?.canView == AccessLevels.Yes || mdDate.perm?.canUpdate == AccessLevels.Yes) ? AccessLevels.Yes : AccessLevels.No;
|
|
35
|
-
}
|
|
36
|
-
const mdVer = dtd.metadata?.find(md => md.name === CICO_MetadataNames.CICO_Version);
|
|
37
|
-
if (mdVer) {
|
|
38
|
-
cico.Ver_MID = mdVer.fromMID;
|
|
39
|
-
cico.Ver_CanViewOrUpdate = (mdVer.perm?.canView == AccessLevels.Yes || mdVer.perm?.canUpdate == AccessLevels.Yes) ? AccessLevels.Yes : AccessLevels.No;
|
|
40
|
-
}
|
|
41
|
-
return cico;
|
|
42
|
-
};
|
|
43
|
-
const findCheckOutUserName = (allUsers, checkoutUserId) => {
|
|
44
|
-
let checkOutUser = allUsers.find(user => user.id === checkoutUserId);
|
|
45
|
-
return checkOutUser ? checkOutUser.name : '-';
|
|
46
|
-
};
|
|
47
|
-
export const cicoIsEnabled = (dcmt, allUsers, dtd) => {
|
|
48
|
-
if (dcmt === undefined || dtd === undefined) {
|
|
49
|
-
return {
|
|
50
|
-
cicoEnabled: false,
|
|
51
|
-
checkoutStatus: { isCheckedOut: false, mode: '', version: 1, icon: null }
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
const cicoInfo = getCicoInfo(dtd);
|
|
55
|
-
const CICO_CheckoutUserID_Meta = dtd?.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutUserID);
|
|
56
|
-
const CICO_CheckoutDate_Meta = dtd?.metadata?.find(md => md.name === CICO_MetadataNames.CICO_CheckoutDate);
|
|
57
|
-
const CICO_Version_Meta = dtd?.metadata?.find(md => md.name === CICO_MetadataNames.CICO_Version);
|
|
58
|
-
const keyVersion = dcmt.TID + "_" + (CICO_Version_Meta?.id ?? 0);
|
|
59
|
-
const versionRaw = CICO_Version_Meta?.id ? dcmt[keyVersion] : undefined;
|
|
60
|
-
const version = (versionRaw != null && !isNaN(Number(versionRaw))) ? Number(versionRaw) : 1;
|
|
61
|
-
let checkoutStatus = { isCheckedOut: false, mode: '', version: version, icon: null, };
|
|
62
|
-
const userID = SDK_Globals.tmSession?.SessionDescr?.userID;
|
|
63
|
-
if (dcmt && CICO_CheckoutUserID_Meta?.id) {
|
|
64
|
-
const keyUserID = dcmt.TID + "_" + CICO_CheckoutUserID_Meta.id;
|
|
65
|
-
const checkoutUserIdValue = dcmt[keyUserID];
|
|
66
|
-
const checkoutUserId = Number(checkoutUserIdValue);
|
|
67
|
-
if (userID && checkoutUserIdValue && !isNaN(checkoutUserId) && checkoutUserId > 0) {
|
|
68
|
-
// editMode: l'utente corrente è quello che ha fatto il checkout
|
|
69
|
-
// lockMode: un altro utente ha fatto il checkout
|
|
70
|
-
const mode = (userID && userID === checkoutUserId) ? 'editMode' : 'lockMode';
|
|
71
|
-
// Recupera i dati aggiuntivi per il tooltip
|
|
72
|
-
const keyDate = dcmt.TID + "_" + (CICO_CheckoutDate_Meta?.id ?? 0);
|
|
73
|
-
const checkoutDate = CICO_CheckoutDate_Meta?.id ? dcmt[keyDate] : undefined;
|
|
74
|
-
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] }) })] })] });
|
|
75
|
-
const icon = mode === 'editMode'
|
|
76
|
-
? _jsx(TMTooltip, { content: editLockTooltipText, children: _jsx("i", { style: { fontSize: "18px", color: colors.MEDIUM_GREEN, fontWeight: "bold" }, className: "dx-icon-edit" }) })
|
|
77
|
-
: _jsx(TMTooltip, { content: editLockTooltipText, children: _jsx("i", { style: { fontSize: "18px", color: colors.MEDIUM_GREEN, fontWeight: "bold" }, className: "dx-icon-lock" }) });
|
|
78
|
-
checkoutStatus = { isCheckedOut: true, mode: mode, icon: icon, version: version };
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
cicoEnabled: cicoInfo.CICO === 1 && cicoInfo.CanCICO === AccessLevels.Yes,
|
|
83
|
-
checkoutStatus: checkoutStatus
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
export const getCicoDownloadFileName = (originalFileName, fileItem, checkout, withTimestampAndExt) => {
|
|
87
|
-
// If no fileItem is provided, return an empty string immediately
|
|
88
|
-
if (fileItem === undefined)
|
|
89
|
-
return '';
|
|
90
|
-
// Retrieve the archiveID from the global session object
|
|
91
|
-
const archiveID = SDK_Globals.tmSession?.SessionDescr?.archiveID;
|
|
92
|
-
// Destructure the fileItem object into properties
|
|
93
|
-
const { DID, TID, FILEEXT } = fileItem;
|
|
94
|
-
// Determine the base name of the file (without its extension)
|
|
95
|
-
// If the file name contains '.', only take the substring before the last dot
|
|
96
|
-
const baseName = originalFileName.includes('.') ? originalFileName.substring(0, originalFileName.lastIndexOf('.')) : originalFileName;
|
|
97
|
-
// Construct a unique identifier for the file combining archiveID, baseName, tid, and did.
|
|
98
|
-
const fileIdentifier = `${archiveID}~${baseName}~${TID}~${DID}`;
|
|
99
|
-
// Determine the extension to append to the file name
|
|
100
|
-
const extension = withTimestampAndExt && FILEEXT ? `.${FILEEXT}` : '';
|
|
101
|
-
// Initialize an empty string for the timestamp (to be appended if needed)
|
|
102
|
-
let timestamp = '';
|
|
103
|
-
// If this is a checkout and timestamps should be added, generate a formatted timestamp
|
|
104
|
-
if (checkout && withTimestampAndExt) {
|
|
105
|
-
const now = new Date();
|
|
106
|
-
const pad = (n) => n.toString().padStart(2, '0');
|
|
107
|
-
// Format the timestamp as YYYYMMDDHHMMSS and prefix with '~'
|
|
108
|
-
timestamp = `~${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
109
|
-
}
|
|
110
|
-
// Construct and return the final file name: [archiveID]~[name]~[tid]~[did]~[timestamp].[extension]
|
|
111
|
-
return `${checkout ? 'checkout~' : ''}${fileIdentifier}${timestamp}${extension}`;
|
|
112
|
-
};
|
|
113
|
-
export const updateDcmtCheckoutItem = (item, action = "addOrUpdate") => {
|
|
114
|
-
// Make a shallow copy of the global draft checkout items array to avoid direct mutation
|
|
115
|
-
const currentItems = [...SDKUI_Globals.userSettings.dcmtCheckoutInfo];
|
|
116
|
-
// Find the index of an existing item that has the same TID and DID as the new item
|
|
117
|
-
const index = currentItems.findIndex(i => i.TID === item.TID && i.DID === item.DID);
|
|
118
|
-
// If the action is to add a new item or update an existing one
|
|
119
|
-
if (action === "addOrUpdate") {
|
|
120
|
-
if (index >= 0) {
|
|
121
|
-
// If the item exists, overwrite it with the new values
|
|
122
|
-
currentItems[index] = item;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
// If the item does not exist, push it into the array
|
|
126
|
-
currentItems.push(item);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
else if (action === "remove" && index >= 0) { // If the action is to remove an item
|
|
130
|
-
// Remove the item from the array
|
|
131
|
-
currentItems.splice(index, 1);
|
|
132
|
-
}
|
|
133
|
-
// Update the global array with the modified copy
|
|
134
|
-
SDKUI_Globals.userSettings.dcmtCheckoutInfo = currentItems;
|
|
135
|
-
};
|
|
136
|
-
export const downloadFilesCallback = async (originalFileName, dcmt, checkout, downloadDcmtsAsync) => {
|
|
137
|
-
const files = [];
|
|
138
|
-
dcmt.forEach(file => {
|
|
139
|
-
if (file.TID && file.DID && file.FILEEXT) {
|
|
140
|
-
let fileName = getCicoDownloadFileName(originalFileName, file, checkout, true);
|
|
141
|
-
if (checkout) {
|
|
142
|
-
const newItem = {
|
|
143
|
-
TID: file.TID.toString(),
|
|
144
|
-
DID: file.DID.toString(),
|
|
145
|
-
checkoutFolder: "",
|
|
146
|
-
checkoutName: fileName
|
|
147
|
-
};
|
|
148
|
-
updateDcmtCheckoutItem(newItem, "addOrUpdate");
|
|
149
|
-
}
|
|
150
|
-
files.push({ TID: file.TID, DID: file.DID, FILEEXT: file.FILEEXT, fileName });
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
if (files.length > 0)
|
|
154
|
-
await downloadDcmtsAsync(files, DownloadTypes.Dcmt, "download");
|
|
155
|
-
};
|