@tap-payments/os-micro-frontend-shared 0.1.110 → 0.1.111-test.2

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.
Files changed (39) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +12 -12
  3. package/build/components/ReceiptViewer/ReceiptViewer.d.ts +2 -0
  4. package/build/components/ReceiptViewer/ReceiptViewer.js +122 -0
  5. package/build/components/ReceiptViewer/ReceiptViewerList.d.ts +9 -0
  6. package/build/components/ReceiptViewer/ReceiptViewerList.js +10 -0
  7. package/build/components/ReceiptViewer/components/FooterButton/FooterButton.d.ts +5 -0
  8. package/build/components/ReceiptViewer/components/FooterButton/FooterButton.js +44 -0
  9. package/build/components/ReceiptViewer/components/FooterButton/index.d.ts +2 -0
  10. package/build/components/ReceiptViewer/components/FooterButton/index.js +2 -0
  11. package/build/components/ReceiptViewer/components/ReceiptTitleBar/ReceiptTitleBar.d.ts +5 -0
  12. package/build/components/ReceiptViewer/components/ReceiptTitleBar/ReceiptTitleBar.js +9 -0
  13. package/build/components/ReceiptViewer/components/ReceiptTitleBar/index.d.ts +3 -0
  14. package/build/components/ReceiptViewer/components/ReceiptTitleBar/index.js +3 -0
  15. package/build/components/ReceiptViewer/components/ReceiptTitleBar/type.d.ts +11 -0
  16. package/build/components/ReceiptViewer/components/ReceiptTitleBar/type.js +1 -0
  17. package/build/components/ReceiptViewer/components/index.d.ts +2 -0
  18. package/build/components/ReceiptViewer/components/index.js +2 -0
  19. package/build/components/ReceiptViewer/context/Provider.d.ts +6 -0
  20. package/build/components/ReceiptViewer/context/Provider.js +42 -0
  21. package/build/components/ReceiptViewer/context/context.d.ts +3 -0
  22. package/build/components/ReceiptViewer/context/context.js +7 -0
  23. package/build/components/ReceiptViewer/context/index.d.ts +2 -0
  24. package/build/components/ReceiptViewer/context/index.js +2 -0
  25. package/build/components/ReceiptViewer/hooks/index.d.ts +1 -0
  26. package/build/components/ReceiptViewer/hooks/index.js +1 -0
  27. package/build/components/ReceiptViewer/hooks/useReceiptViewerContext.d.ts +8 -0
  28. package/build/components/ReceiptViewer/hooks/useReceiptViewerContext.js +18 -0
  29. package/build/components/ReceiptViewer/index.d.ts +7 -0
  30. package/build/components/ReceiptViewer/index.js +7 -0
  31. package/build/components/ReceiptViewer/style.d.ts +631 -0
  32. package/build/components/ReceiptViewer/style.js +176 -0
  33. package/build/components/ReceiptViewer/type.d.ts +22 -0
  34. package/build/components/ReceiptViewer/type.js +1 -0
  35. package/build/components/index.d.ts +1 -0
  36. package/build/components/index.js +1 -0
  37. package/build/utils/object.d.ts +1 -0
  38. package/build/utils/object.js +4 -3
  39. package/package.json +139 -139
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Tap Payments
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Tap Payments
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # os-micro-frontend-shared
2
-
3
- ## Publishing Workflow
4
-
5
- 1. Update version in package.json
6
- 2. Commit changes
7
- 3. Create and push a tag:
8
-
9
- ```bash
10
- npm version patch # or minor, major
11
- git push origin main --tags
12
- ```
1
+ # os-micro-frontend-shared
2
+
3
+ ## Publishing Workflow
4
+
5
+ 1. Update version in package.json
6
+ 2. Commit changes
7
+ 3. Create and push a tag:
8
+
9
+ ```bash
10
+ npm version patch # or minor, major
11
+ git push origin main --tags
12
+ ```
@@ -0,0 +1,2 @@
1
+ import { ReceiptViewerProps } from './type';
2
+ export default function ReceiptViewer({ index, isWindowMinimized, windowOrder, onClose }: ReceiptViewerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,122 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { Box, Dialog } from '@mui/material';
4
+ import { motion, } from 'framer-motion';
5
+ import { Resizable } from 're-resizable';
6
+ import Draggable from 'react-draggable';
7
+ import { APP_WINDOW_Z_INDEX } from '../../constants/index.js';
8
+ import { useMouseState, useWindowDimensions } from '../../hooks/index.js';
9
+ import { isSafariBrowser } from '../../utils/index.js';
10
+ import JSONTitleBar from './components/ReceiptTitleBar';
11
+ import { JSONContainer, TITLE_BAR_HEIGHT, VIEWER_HEIGHT, FOOTER_HEIGHT, } from './style';
12
+ const VIEWER_WIDTH = 400;
13
+ const animationDuration = 0.5;
14
+ export default function ReceiptViewer({ index, isWindowMinimized, windowOrder, onClose }) {
15
+ var _a, _b, _c, _d;
16
+ const [isMaximized, setIsMaximized] = useState(false);
17
+ const [isResized, setIsResized] = useState(false);
18
+ const [newDimensions, setNewDimensions] = useState({ width: 0, height: 0 });
19
+ const [isToolbarAnimationDisabled, setIsToolbarAnimationDisabled] = useState(true);
20
+ const [viewerWidth, setViewerWidth] = useState(VIEWER_WIDTH);
21
+ const requestTimerRef = useRef();
22
+ const { onMouseEnter, onMouseLeave, isHovered } = useMouseState();
23
+ const { height, width } = useWindowDimensions();
24
+ const [position, setPosition] = useState({
25
+ x: width / 2 + VIEWER_WIDTH / 4 - index * 20,
26
+ y: height / 2 - VIEWER_HEIGHT / 2 + index * 30,
27
+ });
28
+ const resizableRef = useRef();
29
+ const isSafari = isSafariBrowser();
30
+ 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;
31
+ useEffect(() => {
32
+ if (requestTimerRef.current) {
33
+ clearTimeout(requestTimerRef.current);
34
+ }
35
+ setViewerWidth(currentRequestWidth);
36
+ }, [currentRequestWidth]);
37
+ return (_jsx(Draggable, Object.assign({ disabled: isMaximized, handle: "#draggable-dialog-title", cancel: '[class*="MuiDialogContent-root"]', defaultPosition: {
38
+ x: width / 2 - VIEWER_WIDTH / 4,
39
+ y: height / 2 - VIEWER_HEIGHT / 2,
40
+ }, position: {
41
+ x: width - position.x,
42
+ y: position.y,
43
+ }, onStop: (_, data) => {
44
+ setPosition({
45
+ x: width - data.x,
46
+ y: data.y,
47
+ });
48
+ }, bounds: {
49
+ top: 10,
50
+ } }, { 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 && {
51
+ display: 'none',
52
+ })), { transform: 'translate(180px, 14px)' }), (!isMaximized && {
53
+ width: isSafari ? (newDimensions === null || newDimensions === void 0 ? void 0 : newDimensions.width) || viewerWidth : 'fit-content',
54
+ height: isSafari ? (newDimensions === null || newDimensions === void 0 ? void 0 : newDimensions.height) || VIEWER_HEIGHT : 'fit-content',
55
+ })), (isMaximized && {
56
+ transform: 'none !important',
57
+ })), PaperProps: {
58
+ 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 && {
59
+ width: '100%',
60
+ height: '100%',
61
+ })), { position: 'relative' }),
62
+ }, onClose: () => {
63
+ setIsMaximized(false);
64
+ setIsToolbarAnimationDisabled(true);
65
+ setTimeout(() => {
66
+ setIsToolbarAnimationDisabled(false);
67
+ }, animationDuration * 1000);
68
+ }, open: true, hideBackdrop: true, fullScreen: isMaximized, "aria-labelledby": "draggable-dialog-title" }, { children: _jsx(Resizable, Object.assign({ enable: {
69
+ left: false,
70
+ right: true,
71
+ bottomRight: true,
72
+ bottom: true,
73
+ }, maxHeight: height - 40, maxWidth: width, minWidth: isMaximized ? '100vw' : viewerWidth, minHeight: isMaximized ? '100vh' : '300px', ref: (c) => {
74
+ resizableRef.current = c;
75
+ }, onResizeStart: () => {
76
+ setIsToolbarAnimationDisabled(true);
77
+ }, onResizeStop: () => {
78
+ setIsToolbarAnimationDisabled(false);
79
+ }, onResize: (_, __, element) => {
80
+ setIsResized(true);
81
+ setNewDimensions({
82
+ width: element.offsetWidth,
83
+ height: element.offsetHeight,
84
+ });
85
+ }, defaultSize: {
86
+ width: viewerWidth,
87
+ height: VIEWER_HEIGHT,
88
+ }, style: Object.assign(Object.assign({ background: 'transparent' }, (isMaximized && {
89
+ height: '100% !important',
90
+ width: '100% !important',
91
+ flex: 1,
92
+ })), (isMaximized && {
93
+ position: 'relative',
94
+ })) }, { children: _jsxs(JSONContainer, { children: [_jsx(motion.div, Object.assign({ style: Object.assign({}, (isMaximized && {
95
+ height: TITLE_BAR_HEIGHT,
96
+ position: 'fixed',
97
+ zIndex: 1000,
98
+ })), animate: Object.assign(Object.assign({ width: currentRequestWidth }, (isMaximized && {
99
+ width: '100vw',
100
+ })), (!isMaximized && {
101
+ transform: 'translateX(0)',
102
+ })), transition: Object.assign({ duration: animationDuration }, (isToolbarAnimationDisabled && {
103
+ duration: 0,
104
+ })) }, { children: _jsx(JSONTitleBar, { title: "Receipt", onClose: () => onClose(), onMaximize: () => {
105
+ setIsMaximized((prev) => !prev);
106
+ setIsToolbarAnimationDisabled(true);
107
+ setTimeout(() => {
108
+ setIsToolbarAnimationDisabled(false);
109
+ }, animationDuration * 1000);
110
+ }, isHovered: isHovered, onMouseHover: onMouseEnter, onMouseLeave: onMouseLeave, maximized: isMaximized, id: "draggable-dialog-title" }) })), _jsx(Box, Object.assign({ sx: {
111
+ display: 'flex',
112
+ flexDirection: 'row',
113
+ justifyContent: 'space-between',
114
+ alignItems: 'flex-start',
115
+ height: isMaximized
116
+ ? `calc(100vh - ${FOOTER_HEIGHT}px)`
117
+ : (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,
118
+ background: 'transparent',
119
+ position: 'fixed',
120
+ width: '100%',
121
+ } }, { children: _jsx(Box, Object.assign({ sx: (theme) => ({ background: theme.palette.common.white, width: '100%', height: '100%' }) }, { children: "Here new Content" })) }))] }) })) })) })));
122
+ }
@@ -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 ReceiptViewer 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(ReceiptViewer, { 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,2 @@
1
+ import FooterButton from './FooterButton';
2
+ export default FooterButton;
@@ -0,0 +1,2 @@
1
+ import FooterButton from './FooterButton';
2
+ export default 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, 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, MaximizeIcon } from '../../../ToolbarIcon';
5
+ import { jsonIcon } from '../../../../constants/index.js';
6
+ function ReceiptTitleBar({ title, onClose, onMaximize, maximized = false, id, onMouseHover, onMouseLeave, 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 })] }) }) })));
8
+ }
9
+ export default memo(ReceiptTitleBar);
@@ -0,0 +1,3 @@
1
+ import JSONTitleBar from './ReceiptTitleBar';
2
+ export * from './type';
3
+ export default JSONTitleBar;
@@ -0,0 +1,3 @@
1
+ import JSONTitleBar from './ReceiptTitleBar';
2
+ export * from './type';
3
+ export default JSONTitleBar;
@@ -0,0 +1,11 @@
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
+ onMouseHover: (e: SyntheticEvent) => void;
9
+ onMouseLeave: (e: SyntheticEvent) => void;
10
+ isHovered?: boolean;
11
+ }
@@ -0,0 +1,2 @@
1
+ export { default as FooterButton } from './FooterButton';
2
+ export { default as ReceiptTitleBar, type ReceiptTitleBarProps } from './ReceiptTitleBar';
@@ -0,0 +1,2 @@
1
+ export { default as FooterButton } from './FooterButton';
2
+ export { default as ReceiptTitleBar } from './ReceiptTitleBar';
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from 'react';
2
+ type ReceiptViewerDialogProviderProps = {
3
+ children: ReactNode;
4
+ };
5
+ export declare const ReceiptViewerDialogContextProvider: ({ children }: ReceiptViewerDialogProviderProps) => import("react/jsx-runtime").JSX.Element;
6
+ 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 ReceiptViewerDialogContextProvider = ({ 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,3 @@
1
+ /// <reference types="react" />
2
+ import type { ReceiptViewerContext } from '../type';
3
+ export declare const ReceiptViewerDialogContext: import("react").Context<ReceiptViewerContext>;
@@ -0,0 +1,7 @@
1
+ import { createContext } from 'react';
2
+ export const ReceiptViewerDialogContext = createContext({
3
+ receiptViewerList: [],
4
+ handleReceiptViewerDialogOpen: () => { },
5
+ handleWindowMinimize: () => { },
6
+ handleWindowOrder: () => { },
7
+ });
@@ -0,0 +1,2 @@
1
+ export * from './context';
2
+ export { ReceiptViewerDialogContextProvider } from './Provider';
@@ -0,0 +1,2 @@
1
+ export * from './context';
2
+ export { ReceiptViewerDialogContextProvider } from './Provider';
@@ -0,0 +1 @@
1
+ export { useReceiptViewerContext } from './useReceiptViewerContext';
@@ -0,0 +1 @@
1
+ export { useReceiptViewerContext } from './useReceiptViewerContext';
@@ -0,0 +1,8 @@
1
+ type Props = {
2
+ isWindowMinimized: boolean;
3
+ windowOrder: number;
4
+ };
5
+ export declare const useReceiptViewerContext: ({ isWindowMinimized, windowOrder }: Props) => {
6
+ handleReceiptViewerDialogOpen: (jsonViewer: import("..").JsonViewer) => void;
7
+ };
8
+ export {};
@@ -0,0 +1,18 @@
1
+ import { useContext, useEffect, useCallback } from 'react';
2
+ import { ReceiptViewerDialogContext } from '../context';
3
+ export const useReceiptViewerContext = ({ 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
+ };
@@ -0,0 +1,7 @@
1
+ import JSONViewer from './ReceiptViewer';
2
+ export * from './context';
3
+ export * from './type';
4
+ export * from './hooks';
5
+ export * from './ReceiptViewerList';
6
+ export * from './components';
7
+ export default JSONViewer;
@@ -0,0 +1,7 @@
1
+ import JSONViewer from './ReceiptViewer';
2
+ export * from './context';
3
+ export * from './type';
4
+ export * from './hooks';
5
+ export * from './ReceiptViewerList';
6
+ export * from './components';
7
+ export default JSONViewer;