@tap-payments/os-micro-frontend-shared 0.1.106 → 0.1.109-test.1
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/build/components/ReceiptViewer/ReceiptViewer.d.ts +2 -0
- package/build/components/ReceiptViewer/ReceiptViewer.js +256 -0
- package/build/components/ReceiptViewer/ReceiptViewerList.d.ts +9 -0
- package/build/components/ReceiptViewer/ReceiptViewerList.js +10 -0
- package/build/components/ReceiptViewer/components/FooterButton/FooterButton.d.ts +5 -0
- package/build/components/ReceiptViewer/components/FooterButton/FooterButton.js +44 -0
- package/build/components/ReceiptViewer/components/FooterButton/index.d.ts +2 -0
- package/build/components/ReceiptViewer/components/FooterButton/index.js +2 -0
- package/build/components/ReceiptViewer/components/ReceiptTitleBar/ReceiptTitleBar.d.ts +5 -0
- package/build/components/ReceiptViewer/components/ReceiptTitleBar/ReceiptTitleBar.js +9 -0
- package/build/components/ReceiptViewer/components/ReceiptTitleBar/index.d.ts +3 -0
- package/build/components/ReceiptViewer/components/ReceiptTitleBar/index.js +3 -0
- package/build/components/ReceiptViewer/components/ReceiptTitleBar/type.d.ts +14 -0
- package/build/components/ReceiptViewer/components/ReceiptTitleBar/type.js +1 -0
- package/build/components/ReceiptViewer/components/index.d.ts +2 -0
- package/build/components/ReceiptViewer/components/index.js +2 -0
- package/build/components/ReceiptViewer/context/Provider.d.ts +6 -0
- package/build/components/ReceiptViewer/context/Provider.js +42 -0
- package/build/components/ReceiptViewer/context/context.d.ts +3 -0
- package/build/components/ReceiptViewer/context/context.js +7 -0
- package/build/components/ReceiptViewer/context/index.d.ts +2 -0
- package/build/components/ReceiptViewer/context/index.js +2 -0
- package/build/components/ReceiptViewer/hooks/index.d.ts +1 -0
- package/build/components/ReceiptViewer/hooks/index.js +1 -0
- package/build/components/ReceiptViewer/hooks/useJsonViewerContext.d.ts +8 -0
- package/build/components/ReceiptViewer/hooks/useJsonViewerContext.js +18 -0
- package/build/components/ReceiptViewer/index.d.ts +7 -0
- package/build/components/ReceiptViewer/index.js +7 -0
- package/build/components/ReceiptViewer/style.d.ts +631 -0
- package/build/components/ReceiptViewer/style.js +176 -0
- package/build/components/ReceiptViewer/type.d.ts +22 -0
- package/build/components/ReceiptViewer/type.js +1 -0
- package/build/components/TableCells/CustomCells/ActionCell/constant.d.ts +1 -0
- package/build/components/TableCells/CustomCells/ActionCell/constant.js +2 -1
- package/build/components/TableCells/CustomCells/ActionCell/hooks/useActionCell.d.ts +1 -1
- package/build/components/TableCells/CustomCells/ActionCell/style.d.ts +1 -1
- package/build/utils/table.d.ts +3 -1
- package/build/utils/table.js +7 -1
- package/package.json +3 -3
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { Box, Dialog } from '@mui/material';
|
|
4
|
+
import JsonView from '@uiw/react-json-view';
|
|
5
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
6
|
+
import { Resizable } from 're-resizable';
|
|
7
|
+
import Draggable from 'react-draggable';
|
|
8
|
+
import { APP_WINDOW_Z_INDEX, codeIcon, collapseArrowsIcon, copyIcon, expandArrowsIcon, greenCheckIcon, idIcon } from '../../constants/index.js';
|
|
9
|
+
import { useMouseState, useWindowDimensions } from '../../hooks/index.js';
|
|
10
|
+
import { isSafariBrowser } from '../../utils/index.js';
|
|
11
|
+
import AnimatedButton from './components/FooterButton';
|
|
12
|
+
import JSONTitleBar from './components/ReceiptTitleBar';
|
|
13
|
+
import { ButtonsWrapper, FooterWrapper, JSONContainer, JSONViewerWrapper, SectionWrapper, StyledCopyButton, StyledHeaderWrapper, StyledTitle, jsonTheme, TITLE_BAR_HEIGHT, VIEWER_HEIGHT, FOOTER_HEIGHT, } from './style';
|
|
14
|
+
import TableFooter from '../VirtualTables/components/TableFooter';
|
|
15
|
+
const VIEWER_WIDTH = 400;
|
|
16
|
+
const animationDuration = 0.5;
|
|
17
|
+
export default function JSONViewer({ index, json, requestJson = {}, isWindowMinimized, windowOrder, onClose }) {
|
|
18
|
+
var _a, _b, _c, _d;
|
|
19
|
+
const [isMaximized, setIsMaximized] = useState(false);
|
|
20
|
+
const [isResized, setIsResized] = useState(false);
|
|
21
|
+
const [isResponseCollapsed, setIsResponseCollapsed] = useState(true);
|
|
22
|
+
const [isScrollingResponse, setIsScrollingResponse] = useState(false);
|
|
23
|
+
const [newDimensions, setNewDimensions] = useState({ width: 0, height: 0 });
|
|
24
|
+
const [isToolbarAnimationDisabled, setIsToolbarAnimationDisabled] = useState(true);
|
|
25
|
+
const [isRequestShown, setIsRequestShown] = useState(false);
|
|
26
|
+
const [isRequestCollapsed, setIsRequestCollapsed] = useState(true);
|
|
27
|
+
const [isScrollingRequest, setIsScrollingRequest] = useState(false);
|
|
28
|
+
const [viewerWidth, setViewerWidth] = useState(VIEWER_WIDTH);
|
|
29
|
+
const requestTimerRef = useRef();
|
|
30
|
+
const { onMouseEnter, onMouseLeave, isHovered } = useMouseState();
|
|
31
|
+
const { height, width } = useWindowDimensions();
|
|
32
|
+
const [position, setPosition] = useState({
|
|
33
|
+
x: width / 2 + VIEWER_WIDTH / 4 - index * 20,
|
|
34
|
+
y: height / 2 - VIEWER_HEIGHT / 2 + index * 30,
|
|
35
|
+
});
|
|
36
|
+
const resizableRef = useRef();
|
|
37
|
+
const objectPropertiesCount = useMemo(() => {
|
|
38
|
+
var _a;
|
|
39
|
+
return (_a = Object.keys(json)) === null || _a === void 0 ? void 0 : _a.length;
|
|
40
|
+
}, [json]);
|
|
41
|
+
const isSafari = isSafariBrowser();
|
|
42
|
+
const currentRequestWidth = Number((_b = (_a = resizableRef.current) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.width) || VIEWER_WIDTH;
|
|
43
|
+
const onCopied = (text) => {
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
navigator.clipboard.writeText(text || '').then(() => { });
|
|
46
|
+
}, 10);
|
|
47
|
+
};
|
|
48
|
+
const requestObjectPropertiesCount = useMemo(() => {
|
|
49
|
+
var _a;
|
|
50
|
+
return (_a = Object.keys(requestJson)) === null || _a === void 0 ? void 0 : _a.length;
|
|
51
|
+
}, [requestJson]);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (requestTimerRef.current) {
|
|
54
|
+
clearTimeout(requestTimerRef.current);
|
|
55
|
+
}
|
|
56
|
+
if (!isRequestShown) {
|
|
57
|
+
requestTimerRef.current = setTimeout(() => {
|
|
58
|
+
setViewerWidth(currentRequestWidth);
|
|
59
|
+
}, animationDuration * 1000);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
setViewerWidth(currentRequestWidth);
|
|
63
|
+
}, [isRequestShown, currentRequestWidth]);
|
|
64
|
+
return (_jsx(Draggable, Object.assign({ disabled: isMaximized, handle: "#draggable-dialog-title", cancel: '[class*="MuiDialogContent-root"]', defaultPosition: {
|
|
65
|
+
x: width / 2 - VIEWER_WIDTH / 4,
|
|
66
|
+
y: height / 2 - VIEWER_HEIGHT / 2,
|
|
67
|
+
}, position: {
|
|
68
|
+
x: width - position.x,
|
|
69
|
+
y: position.y,
|
|
70
|
+
}, onStop: (_, data) => {
|
|
71
|
+
setPosition({
|
|
72
|
+
x: width - data.x,
|
|
73
|
+
y: data.y,
|
|
74
|
+
});
|
|
75
|
+
}, bounds: {
|
|
76
|
+
top: 10,
|
|
77
|
+
} }, { children: _jsx(Dialog, Object.assign({ disableEnforceFocus: true, sx: Object.assign(Object.assign(Object.assign(Object.assign({ backgroundColor: 'transparent', zIndex: (windowOrder || 0) + APP_WINDOW_Z_INDEX + (isMaximized ? 1 : 0) }, (isWindowMinimized && {
|
|
78
|
+
display: 'none',
|
|
79
|
+
})), { transform: 'translate(180px, 14px)' }), (!isMaximized && {
|
|
80
|
+
width: isSafari ? (newDimensions === null || newDimensions === void 0 ? void 0 : newDimensions.width) || viewerWidth : 'fit-content',
|
|
81
|
+
height: isSafari ? (newDimensions === null || newDimensions === void 0 ? void 0 : newDimensions.height) || VIEWER_HEIGHT : 'fit-content',
|
|
82
|
+
})), (isMaximized && {
|
|
83
|
+
transform: 'none !important',
|
|
84
|
+
})), PaperProps: {
|
|
85
|
+
style: Object.assign(Object.assign({ margin: 0, maxHeight: '100%', maxWidth: 'none', background: 'transparent', width: !isResized ? viewerWidth : 'fit-content', height: !isResized ? VIEWER_HEIGHT : 'fit-content' }, (isMaximized && {
|
|
86
|
+
width: '100%',
|
|
87
|
+
height: '100%',
|
|
88
|
+
})), { position: 'relative' }),
|
|
89
|
+
}, onClose: () => {
|
|
90
|
+
setIsMaximized(false);
|
|
91
|
+
setIsToolbarAnimationDisabled(true);
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
setIsToolbarAnimationDisabled(false);
|
|
94
|
+
}, animationDuration * 1000);
|
|
95
|
+
}, open: true, hideBackdrop: true, fullScreen: isMaximized, "aria-labelledby": "draggable-dialog-title" }, { children: _jsx(Resizable, Object.assign({ enable: {
|
|
96
|
+
left: false,
|
|
97
|
+
right: true,
|
|
98
|
+
bottomRight: true,
|
|
99
|
+
bottom: true,
|
|
100
|
+
}, maxHeight: height - 40, maxWidth: width, minWidth: isMaximized ? '100vw' : viewerWidth, minHeight: isMaximized ? '100vh' : '300px', ref: (c) => {
|
|
101
|
+
resizableRef.current = c;
|
|
102
|
+
}, onResizeStart: () => {
|
|
103
|
+
setIsToolbarAnimationDisabled(true);
|
|
104
|
+
}, onResizeStop: () => {
|
|
105
|
+
setIsToolbarAnimationDisabled(false);
|
|
106
|
+
}, onResize: (_, __, element) => {
|
|
107
|
+
setIsResized(true);
|
|
108
|
+
setNewDimensions({
|
|
109
|
+
width: element.offsetWidth,
|
|
110
|
+
height: element.offsetHeight,
|
|
111
|
+
});
|
|
112
|
+
}, defaultSize: {
|
|
113
|
+
width: viewerWidth,
|
|
114
|
+
height: VIEWER_HEIGHT,
|
|
115
|
+
}, style: Object.assign(Object.assign({ background: 'transparent' }, (isMaximized && {
|
|
116
|
+
height: '100% !important',
|
|
117
|
+
width: '100% !important',
|
|
118
|
+
flex: 1,
|
|
119
|
+
})), (isMaximized && {
|
|
120
|
+
position: 'relative',
|
|
121
|
+
})) }, { children: _jsxs(JSONContainer, { children: [_jsx(motion.div, Object.assign({ style: Object.assign({}, (isMaximized && {
|
|
122
|
+
height: TITLE_BAR_HEIGHT,
|
|
123
|
+
position: 'fixed',
|
|
124
|
+
zIndex: 1000,
|
|
125
|
+
})), animate: Object.assign(Object.assign({ width: isRequestShown ? currentRequestWidth * 2 : currentRequestWidth }, (isMaximized && {
|
|
126
|
+
width: '100vw',
|
|
127
|
+
})), (!isMaximized && {
|
|
128
|
+
transform: `translateX(${isRequestShown ? -currentRequestWidth : 0}px)`,
|
|
129
|
+
})), transition: Object.assign({ duration: animationDuration }, (isToolbarAnimationDisabled && {
|
|
130
|
+
duration: 0,
|
|
131
|
+
})) }, { children: _jsx(JSONTitleBar, { title: isRequestShown ? 'JSON Request & Response' : 'JSON Response', onClose: () => onClose(), onMaximize: () => {
|
|
132
|
+
setIsMaximized((prev) => !prev);
|
|
133
|
+
setIsToolbarAnimationDisabled(true);
|
|
134
|
+
setTimeout(() => {
|
|
135
|
+
setIsToolbarAnimationDisabled(false);
|
|
136
|
+
}, animationDuration * 1000);
|
|
137
|
+
}, isHovered: isHovered, onMouseHover: onMouseEnter, onMouseLeave: onMouseLeave, maximized: isMaximized, id: "draggable-dialog-title", onRequestClick: () => {
|
|
138
|
+
var _a;
|
|
139
|
+
setIsRequestShown((prev) => !prev);
|
|
140
|
+
setIsToolbarAnimationDisabled(false);
|
|
141
|
+
if (!isRequestShown) {
|
|
142
|
+
(_a = resizableRef.current) === null || _a === void 0 ? void 0 : _a.updateSize({
|
|
143
|
+
width: VIEWER_WIDTH,
|
|
144
|
+
height: VIEWER_HEIGHT,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}, isRequestExpanded: isRequestShown, showRequestIcon: Boolean(requestObjectPropertiesCount) }) })), _jsxs(Box, Object.assign({ sx: {
|
|
148
|
+
display: 'flex',
|
|
149
|
+
flexDirection: 'row',
|
|
150
|
+
justifyContent: 'space-between',
|
|
151
|
+
alignItems: 'flex-start',
|
|
152
|
+
height: isMaximized
|
|
153
|
+
? `calc(100vh - ${FOOTER_HEIGHT}px)`
|
|
154
|
+
: (Number((_d = (_c = resizableRef.current) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.height) || VIEWER_HEIGHT) - FOOTER_HEIGHT + 5,
|
|
155
|
+
background: 'transparent',
|
|
156
|
+
position: 'fixed',
|
|
157
|
+
width: '100%',
|
|
158
|
+
} }, { children: [_jsx(AnimatePresence, { children: isRequestShown && (_jsxs(motion.div, Object.assign({ initial: Object.assign({ left: isMaximized ? '50vw' : 0 }, (isMaximized && {
|
|
159
|
+
position: 'relative',
|
|
160
|
+
left: '-50vw',
|
|
161
|
+
})), animate: Object.assign(Object.assign({ left: isMaximized ? '50vw' : -currentRequestWidth }, (isMaximized && {
|
|
162
|
+
position: 'relative',
|
|
163
|
+
left: '0',
|
|
164
|
+
})), (!isRequestShown && {
|
|
165
|
+
left: 0,
|
|
166
|
+
})), exit: Object.assign({ left: isMaximized ? '50vw' : 0 }, (isMaximized && {
|
|
167
|
+
position: 'relative',
|
|
168
|
+
left: '0',
|
|
169
|
+
})), transition: Object.assign({ duration: animationDuration }, (isToolbarAnimationDisabled && {
|
|
170
|
+
duration: 0,
|
|
171
|
+
})), style: {
|
|
172
|
+
flex: 1,
|
|
173
|
+
backgroundColor: '#E7E7E7B2',
|
|
174
|
+
backdropFilter: 'blur(12px)',
|
|
175
|
+
height: isMaximized ? '100vh' : '100%',
|
|
176
|
+
overflowY: 'auto',
|
|
177
|
+
position: 'absolute',
|
|
178
|
+
width: isMaximized ? '100vw' : currentRequestWidth,
|
|
179
|
+
zIndex: 19,
|
|
180
|
+
display: 'flex',
|
|
181
|
+
flexDirection: 'column',
|
|
182
|
+
borderBottomLeftRadius: '12px',
|
|
183
|
+
}, onScroll: () => {
|
|
184
|
+
setIsScrollingRequest(true);
|
|
185
|
+
setTimeout(() => {
|
|
186
|
+
setIsScrollingRequest(false);
|
|
187
|
+
}, 2000);
|
|
188
|
+
} }, { children: [_jsxs(SectionWrapper, Object.assign({ isMaximized: isMaximized, isScrollingRequest: isScrollingRequest, sx: {
|
|
189
|
+
background: '#E7E7E7B2',
|
|
190
|
+
}, isRequestShown: isRequestShown }, { children: [_jsx(StyledHeaderWrapper, { children: _jsx(StyledTitle, Object.assign({ variant: "subtitle1" }, { children: "API Request" })) }), _jsxs(ButtonsWrapper, { children: [_jsx(AnimatedButton, { disableAnimation: true, onClick: () => {
|
|
191
|
+
setIsRequestCollapsed((prev) => !prev);
|
|
192
|
+
}, icon: !isRequestCollapsed ? collapseArrowsIcon : expandArrowsIcon }), _jsx(AnimatedButton, { onClick: () => {
|
|
193
|
+
navigator.clipboard.writeText(JSON.stringify(json)).then(() => { });
|
|
194
|
+
}, icon: codeIcon }), _jsx(AnimatedButton, { onClick: () => {
|
|
195
|
+
navigator.clipboard.writeText((json === null || json === void 0 ? void 0 : json.id) || '').then(() => { });
|
|
196
|
+
}, icon: idIcon })] })] })), "Hello My Receipt", _jsx(AnimatePresence, { children: isRequestShown && (_jsx(FooterWrapper, Object.assign({ sx: {
|
|
197
|
+
flex: 1,
|
|
198
|
+
height: FOOTER_HEIGHT,
|
|
199
|
+
left: 0,
|
|
200
|
+
} }, { children: _jsx(TableFooter, { sx: {
|
|
201
|
+
paddingLeft: '12px',
|
|
202
|
+
borderBottomRightRadius: '0',
|
|
203
|
+
background: '#f8f9fb',
|
|
204
|
+
flex: 1,
|
|
205
|
+
}, totalCount: requestObjectPropertiesCount }) }))) })] }))) }), _jsxs(JSONViewerWrapper, Object.assign({ isMaximized: isMaximized, isRequestShown: isRequestShown, style: {
|
|
206
|
+
left: 0,
|
|
207
|
+
maxHeight: '100vw',
|
|
208
|
+
}, initial: Object.assign({}, (isMaximized && {
|
|
209
|
+
width: '100vw',
|
|
210
|
+
left: 0,
|
|
211
|
+
})), animate: Object.assign({}, (isMaximized && {
|
|
212
|
+
position: 'absolute',
|
|
213
|
+
left: isRequestShown ? '50vw' : '0',
|
|
214
|
+
})), transition: Object.assign({ duration: animationDuration }, (isToolbarAnimationDisabled && {
|
|
215
|
+
duration: 0,
|
|
216
|
+
})), onScroll: () => {
|
|
217
|
+
setIsScrollingResponse(true);
|
|
218
|
+
setTimeout(() => {
|
|
219
|
+
setIsScrollingResponse(false);
|
|
220
|
+
}, 2000);
|
|
221
|
+
} }, { children: [_jsxs(SectionWrapper, Object.assign({ isMaximized: isMaximized, isScrollingRequest: isScrollingResponse, isRequestShown: isRequestShown }, { children: [_jsx(StyledHeaderWrapper, { children: _jsx(StyledTitle, Object.assign({ variant: "subtitle1" }, { children: "API Response" })) }), _jsxs(ButtonsWrapper, { children: [_jsx(AnimatedButton, { disableAnimation: true, onClick: () => {
|
|
222
|
+
setIsResponseCollapsed((prev) => !prev);
|
|
223
|
+
}, icon: !isResponseCollapsed ? collapseArrowsIcon : expandArrowsIcon }), _jsx(AnimatedButton, { onClick: () => {
|
|
224
|
+
navigator.clipboard.writeText(JSON.stringify(json, null, 2)).then(() => { });
|
|
225
|
+
}, icon: codeIcon }), _jsx(AnimatedButton, { onClick: () => {
|
|
226
|
+
navigator.clipboard.writeText((json === null || json === void 0 ? void 0 : json.id) || '').then(() => { });
|
|
227
|
+
}, icon: idIcon })] })] })), _jsxs(JsonView, Object.assign({ value: json, style: jsonTheme, displayDataTypes: false, collapsed: isResponseCollapsed ? 1 : undefined, onCopied: (_, value) => {
|
|
228
|
+
if (typeof value === 'string') {
|
|
229
|
+
onCopied(value);
|
|
230
|
+
}
|
|
231
|
+
} }, { children: [_jsx(JsonView.CountInfo, { render: (_, { keyName }) => {
|
|
232
|
+
if (!keyName) {
|
|
233
|
+
return _jsx("span", {});
|
|
234
|
+
}
|
|
235
|
+
} }), _jsx(JsonView.Copied, { render: ({ 'data-copied': copied, style, onClick }, { keyName }) => {
|
|
236
|
+
if (!keyName) {
|
|
237
|
+
return _jsx("span", {});
|
|
238
|
+
}
|
|
239
|
+
return (_jsxs(StyledCopyButton, Object.assign({ style: style, onClick: (e) => {
|
|
240
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
241
|
+
} }, { children: [_jsx(AnimatePresence, { children: copied && (_jsx(motion.img, { style: {
|
|
242
|
+
height: '14px',
|
|
243
|
+
width: '14px',
|
|
244
|
+
}, initial: { opacity: 0 }, animate: { opacity: 1, position: 'absolute' }, exit: { opacity: 0 }, transition: { duration: 0.4 }, src: greenCheckIcon, alt: "icon" }, "id-icon")) }), _jsx(AnimatePresence, { children: !copied && (_jsx(motion.img, { style: {
|
|
245
|
+
height: '14px',
|
|
246
|
+
width: '14px',
|
|
247
|
+
}, initial: { opacity: 0 }, animate: { opacity: 1, position: 'absolute' }, exit: { opacity: 0 }, transition: { duration: 0.4 }, src: copyIcon, alt: "icon" }, "id-icon")) })] })));
|
|
248
|
+
} })] })), _jsx(FooterWrapper, Object.assign({ sx: {
|
|
249
|
+
flex: 1,
|
|
250
|
+
height: FOOTER_HEIGHT,
|
|
251
|
+
} }, { children: _jsx(TableFooter, { sx: {
|
|
252
|
+
borderBottomLeftRadius: isRequestShown ? 0 : '12px',
|
|
253
|
+
background: '#f8f9fb',
|
|
254
|
+
flex: 1,
|
|
255
|
+
}, totalCount: objectPropertiesCount }) }))] }))] }))] }) })) })) })));
|
|
256
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { JsonViewer } from './type';
|
|
2
|
+
type Props = {
|
|
3
|
+
list: JsonViewer[];
|
|
4
|
+
onClose: (index: number) => void;
|
|
5
|
+
isWindowMinimized: boolean;
|
|
6
|
+
windowOrder: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const ReceiptViewerList: ({ list, onClose, isWindowMinimized, windowOrder }: Props) => import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import JSONViewer from './ReceiptViewer';
|
|
3
|
+
export const ReceiptViewerList = ({ list, onClose, isWindowMinimized, windowOrder }) => {
|
|
4
|
+
if (!(list === null || list === void 0 ? void 0 : list.length)) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return (_jsx(_Fragment, { children: list.map((item, index) => (_jsx(JSONViewer, { index: index, json: item.json, requestJson: item === null || item === void 0 ? void 0 : item.requestJson, onClose: () => {
|
|
8
|
+
onClose(index);
|
|
9
|
+
}, isWindowMinimized: isWindowMinimized, windowOrder: windowOrder }, item.json.id))) }));
|
|
10
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AnimatedButtonProps } from '../../type';
|
|
3
|
+
declare function FooterButton({ onClick, icon, label, disableAnimation, ...props }: AnimatedButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare const _default: React.MemoExoticComponent<typeof FooterButton>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import React, { memo } from 'react';
|
|
14
|
+
import Box from '@mui/material/Box';
|
|
15
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
16
|
+
import { useTranslation } from 'react-i18next';
|
|
17
|
+
import { greenCheckIcon } from '../../../../constants/index.js';
|
|
18
|
+
import { StyledAnimatedButton } from '../../style';
|
|
19
|
+
function FooterButton(_a) {
|
|
20
|
+
var { onClick, icon, label, disableAnimation } = _a, props = __rest(_a, ["onClick", "icon", "label", "disableAnimation"]);
|
|
21
|
+
const [isClicked, setIsClicked] = React.useState(false);
|
|
22
|
+
const { t } = useTranslation();
|
|
23
|
+
const handleClick = (e) => {
|
|
24
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
25
|
+
if (disableAnimation)
|
|
26
|
+
return;
|
|
27
|
+
setIsClicked(true);
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
setIsClicked(false);
|
|
30
|
+
}, 2000);
|
|
31
|
+
};
|
|
32
|
+
return (_jsxs(StyledAnimatedButton, Object.assign({}, props, { onClick: handleClick }, { children: [_jsxs(Box, Object.assign({ sx: {
|
|
33
|
+
width: '16px',
|
|
34
|
+
display: 'flex',
|
|
35
|
+
overflow: 'hidden',
|
|
36
|
+
justifyContent: 'center',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
} }, { children: [_jsx(AnimatePresence, Object.assign({ mode: "wait" }, { children: isClicked && (_jsx(motion.img, { initial: { opacity: 0 }, animate: { opacity: 1, transition: { duration: 0.4 } }, exit: { opacity: 0, transition: { duration: 0.1 } }, transition: { duration: 0.4 }, src: greenCheckIcon, alt: "icon" }, "id-icon")) })), _jsx(AnimatePresence, Object.assign({ mode: "wait" }, { children: !isClicked && (_jsx(motion.img, { initial: { opacity: 0 }, animate: { opacity: 1, transition: { duration: 0.4 } }, exit: { opacity: 0, transition: { duration: 0.1 } }, transition: { duration: 0.4 }, src: icon, alt: "icon" }, "id-icon")) }))] })), label && (_jsxs(_Fragment, { children: [_jsx(AnimatePresence, { children: isClicked && (_jsx(motion.span, Object.assign({ initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0, position: 'absolute' }, transition: {
|
|
39
|
+
duration: 0.4,
|
|
40
|
+
} }, { children: t('copied') }))) }), _jsx(AnimatePresence, { children: !isClicked && (_jsx(motion.span, Object.assign({ initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0, position: 'absolute', width: '53px' }, transition: {
|
|
41
|
+
duration: 0.4,
|
|
42
|
+
} }, { children: label }))) })] }))] })));
|
|
43
|
+
}
|
|
44
|
+
export default memo(FooterButton);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ReceiptTitleBarProps } from './type';
|
|
3
|
+
declare function ReceiptTitleBar({ title, onClose, onMaximize, maximized, id, onMouseHover, onMouseLeave, onRequestClick, isRequestExpanded, showRequestIcon, isHovered, }: ReceiptTitleBarProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare const _default: import("react").MemoExoticComponent<typeof ReceiptTitleBar>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import Toolbar, { StyledHeaderWrapperStyled } from '../../../Toolbar';
|
|
4
|
+
import { CloseIcon, ExpandButton, MaximizeIcon } from '../../../ToolbarIcon';
|
|
5
|
+
import { jsonIcon } from '../../../../constants/index.js';
|
|
6
|
+
function ReceiptTitleBar({ title, onClose, onMaximize, maximized = false, id, onMouseHover, onMouseLeave, onRequestClick, isRequestExpanded = false, showRequestIcon = false, isHovered = false, }) {
|
|
7
|
+
return (_jsx(StyledHeaderWrapperStyled, Object.assign({ id: id, maximized: maximized || false, sandboxMode: false }, { children: _jsx(Toolbar, { isHovered: true, onMouseEnter: onMouseHover, onMouseLeave: onMouseLeave, isMaximized: maximized, title: title, icon: jsonIcon, leftActions: _jsxs(_Fragment, { children: [_jsx(CloseIcon, { onClick: onClose }), _jsx(MaximizeIcon, { isMaximized: maximized, onClick: onMaximize }), showRequestIcon && (_jsx(ExpandButton, Object.assign({ onClick: onRequestClick, isExpanded: isRequestExpanded, isHovered: isHovered }, { children: "Request" })))] }) }) })));
|
|
8
|
+
}
|
|
9
|
+
export default memo(ReceiptTitleBar);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SyntheticEvent } from 'react';
|
|
2
|
+
export interface ReceiptTitleBarProps {
|
|
3
|
+
title: string;
|
|
4
|
+
onClose?: (e: SyntheticEvent) => void;
|
|
5
|
+
onMaximize?: (e: SyntheticEvent) => void;
|
|
6
|
+
maximized?: boolean;
|
|
7
|
+
id?: string;
|
|
8
|
+
onRequestClick?: (e: SyntheticEvent) => void;
|
|
9
|
+
isRequestExpanded?: boolean;
|
|
10
|
+
onMouseHover: (e: SyntheticEvent) => void;
|
|
11
|
+
onMouseLeave: (e: SyntheticEvent) => void;
|
|
12
|
+
showRequestIcon?: boolean;
|
|
13
|
+
isHovered?: boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
3
|
+
import { ReceiptViewerList } from '../ReceiptViewerList';
|
|
4
|
+
import { ReceiptViewerDialogContext } from './context';
|
|
5
|
+
export const JsonViewerDialogContextProvider = ({ children }) => {
|
|
6
|
+
const [receiptViewerList, seReceiptViewerList] = useState([]);
|
|
7
|
+
const [isWindowMinimized, setIsWindowMinimized] = useState(false);
|
|
8
|
+
const [windowOrder, setWindowOrder] = useState(1);
|
|
9
|
+
const handleReceiptViewerDialogOpen = useCallback((jsonViewer) => {
|
|
10
|
+
if (receiptViewerList.length === 7) {
|
|
11
|
+
alert('Maximum allowed active Json Viewer is 7 per table.');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (receiptViewerList.some((item) => item.json.id === jsonViewer.json.id)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const jsonCopy = structuredClone(jsonViewer.json);
|
|
18
|
+
const requestData = jsonCopy.request_body;
|
|
19
|
+
const jsonViewerPreservedRequest = {
|
|
20
|
+
json: jsonCopy,
|
|
21
|
+
requestJson: jsonViewer.requestJson || requestData || undefined,
|
|
22
|
+
};
|
|
23
|
+
delete jsonViewerPreservedRequest.json.request_body;
|
|
24
|
+
seReceiptViewerList((prev) => [...prev, jsonViewerPreservedRequest]);
|
|
25
|
+
}, [receiptViewerList]);
|
|
26
|
+
const handleJsonViewerDialogClose = (index) => {
|
|
27
|
+
seReceiptViewerList((prev) => prev.filter((_, idx) => index !== idx));
|
|
28
|
+
};
|
|
29
|
+
const handleWindowMinimize = (value) => {
|
|
30
|
+
setIsWindowMinimized(value);
|
|
31
|
+
};
|
|
32
|
+
const handleWindowOrder = (value) => {
|
|
33
|
+
setWindowOrder(value);
|
|
34
|
+
};
|
|
35
|
+
const contextValue = useMemo(() => ({
|
|
36
|
+
receiptViewerList,
|
|
37
|
+
handleReceiptViewerDialogOpen,
|
|
38
|
+
handleWindowMinimize,
|
|
39
|
+
handleWindowOrder,
|
|
40
|
+
}), [receiptViewerList, handleReceiptViewerDialogOpen]);
|
|
41
|
+
return (_jsxs(ReceiptViewerDialogContext.Provider, Object.assign({ value: contextValue }, { children: [children, _jsx(ReceiptViewerList, { list: receiptViewerList, onClose: handleJsonViewerDialogClose, isWindowMinimized: isWindowMinimized, windowOrder: windowOrder })] })));
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useJsonViewerContext } from './useJsonViewerContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useJsonViewerContext } from './useJsonViewerContext';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useContext, useEffect, useCallback } from 'react';
|
|
2
|
+
import { ReceiptViewerDialogContext } from '../context';
|
|
3
|
+
export const useJsonViewerContext = ({ isWindowMinimized, windowOrder }) => {
|
|
4
|
+
const { handleReceiptViewerDialogOpen, handleWindowMinimize, handleWindowOrder } = useContext(ReceiptViewerDialogContext);
|
|
5
|
+
const onWindowMinimize = useCallback(() => {
|
|
6
|
+
handleWindowMinimize(isWindowMinimized);
|
|
7
|
+
}, [handleWindowMinimize, isWindowMinimized]);
|
|
8
|
+
const onWindowOrder = useCallback(() => {
|
|
9
|
+
handleWindowOrder(windowOrder);
|
|
10
|
+
}, [handleWindowOrder, windowOrder]);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
onWindowOrder();
|
|
13
|
+
}, [onWindowOrder]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
onWindowMinimize();
|
|
16
|
+
}, [onWindowMinimize]);
|
|
17
|
+
return { handleReceiptViewerDialogOpen };
|
|
18
|
+
};
|