@tap-payments/os-micro-frontend-shared 0.1.109-test.4 → 0.1.109-test.6

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.
@@ -1,2 +1,2 @@
1
1
  import { ReceiptViewerProps } from './type';
2
- export default function ReceiptViewer({ index, json, requestJson, isWindowMinimized, windowOrder, onClose }: ReceiptViewerProps): import("react/jsx-runtime").JSX.Element;
2
+ export default function ReceiptViewer({ index, isWindowMinimized, windowOrder, onClose }: ReceiptViewerProps): import("react/jsx-runtime").JSX.Element;
@@ -1,25 +1,22 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useMemo, useRef, useState } from 'react';
3
- import { Dialog } from '@mui/material';
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';
4
5
  import { Resizable } from 're-resizable';
5
6
  import Draggable from 'react-draggable';
6
7
  import { APP_WINDOW_Z_INDEX } from '../../constants/index.js';
7
8
  import { useMouseState, useWindowDimensions } from '../../hooks/index.js';
8
9
  import { isSafariBrowser } from '../../utils/index.js';
9
- import { VIEWER_HEIGHT, } from './style';
10
+ import JSONTitleBar from './components/ReceiptTitleBar';
11
+ import { FooterWrapper, JSONContainer, TITLE_BAR_HEIGHT, VIEWER_HEIGHT, FOOTER_HEIGHT, } from './style';
10
12
  const VIEWER_WIDTH = 400;
11
13
  const animationDuration = 0.5;
12
- export default function ReceiptViewer({ index, json, requestJson = {}, isWindowMinimized, windowOrder, onClose }) {
13
- var _a, _b;
14
+ export default function ReceiptViewer({ index, isWindowMinimized, windowOrder, onClose }) {
15
+ var _a, _b, _c, _d;
14
16
  const [isMaximized, setIsMaximized] = useState(false);
15
17
  const [isResized, setIsResized] = useState(false);
16
- const [isResponseCollapsed, setIsResponseCollapsed] = useState(true);
17
- const [isScrollingResponse, setIsScrollingResponse] = useState(false);
18
18
  const [newDimensions, setNewDimensions] = useState({ width: 0, height: 0 });
19
19
  const [isToolbarAnimationDisabled, setIsToolbarAnimationDisabled] = useState(true);
20
- const [isRequestShown, setIsRequestShown] = useState(false);
21
- const [isRequestCollapsed, setIsRequestCollapsed] = useState(true);
22
- const [isScrollingRequest, setIsScrollingRequest] = useState(false);
23
20
  const [viewerWidth, setViewerWidth] = useState(VIEWER_WIDTH);
24
21
  const requestTimerRef = useRef();
25
22
  const { onMouseEnter, onMouseLeave, isHovered } = useMouseState();
@@ -29,33 +26,14 @@ export default function ReceiptViewer({ index, json, requestJson = {}, isWindowM
29
26
  y: height / 2 - VIEWER_HEIGHT / 2 + index * 30,
30
27
  });
31
28
  const resizableRef = useRef();
32
- const objectPropertiesCount = useMemo(() => {
33
- var _a;
34
- return (_a = Object.keys(json)) === null || _a === void 0 ? void 0 : _a.length;
35
- }, [json]);
36
29
  const isSafari = isSafariBrowser();
37
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;
38
- const onCopied = (text) => {
39
- setTimeout(() => {
40
- navigator.clipboard.writeText(text || '').then(() => { });
41
- }, 10);
42
- };
43
- const requestObjectPropertiesCount = useMemo(() => {
44
- var _a;
45
- return (_a = Object.keys(requestJson)) === null || _a === void 0 ? void 0 : _a.length;
46
- }, [requestJson]);
47
31
  useEffect(() => {
48
32
  if (requestTimerRef.current) {
49
33
  clearTimeout(requestTimerRef.current);
50
34
  }
51
- if (!isRequestShown) {
52
- requestTimerRef.current = setTimeout(() => {
53
- setViewerWidth(currentRequestWidth);
54
- }, animationDuration * 1000);
55
- return;
56
- }
57
35
  setViewerWidth(currentRequestWidth);
58
- }, [isRequestShown, currentRequestWidth]);
36
+ }, [currentRequestWidth]);
59
37
  return (_jsx(Draggable, Object.assign({ disabled: isMaximized, handle: "#draggable-dialog-title", cancel: '[class*="MuiDialogContent-root"]', defaultPosition: {
60
38
  x: width / 2 - VIEWER_WIDTH / 4,
61
39
  y: height / 2 - VIEWER_HEIGHT / 2,
@@ -113,5 +91,35 @@ export default function ReceiptViewer({ index, json, requestJson = {}, isWindowM
113
91
  flex: 1,
114
92
  })), (isMaximized && {
115
93
  position: 'relative',
116
- })) }, { children: "Hello" })) })) })));
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" }) })), _jsxs(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 }) }, { children: "Here new Content" })), _jsx(FooterWrapper, Object.assign({ sx: {
122
+ flex: 1,
123
+ height: FOOTER_HEIGHT,
124
+ } }, { children: "footer" }))] }))] }) })) })) })));
117
125
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
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;
3
+ declare function ReceiptTitleBar({ title, onClose, onMaximize, maximized, id, onMouseHover, onMouseLeave, isHovered }: ReceiptTitleBarProps): import("react/jsx-runtime").JSX.Element;
4
4
  declare const _default: import("react").MemoExoticComponent<typeof ReceiptTitleBar>;
5
5
  export default _default;
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { memo } from 'react';
3
3
  import Toolbar, { StyledHeaderWrapperStyled } from '../../../Toolbar';
4
- import { CloseIcon, ExpandButton, MaximizeIcon } from '../../../ToolbarIcon';
4
+ import { CloseIcon, MaximizeIcon } from '../../../ToolbarIcon';
5
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" })))] }) }) })));
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
8
  }
9
9
  export default memo(ReceiptTitleBar);
@@ -5,10 +5,7 @@ export interface ReceiptTitleBarProps {
5
5
  onMaximize?: (e: SyntheticEvent) => void;
6
6
  maximized?: boolean;
7
7
  id?: string;
8
- onRequestClick?: (e: SyntheticEvent) => void;
9
- isRequestExpanded?: boolean;
10
8
  onMouseHover: (e: SyntheticEvent) => void;
11
9
  onMouseLeave: (e: SyntheticEvent) => void;
12
- showRequestIcon?: boolean;
13
10
  isHovered?: boolean;
14
11
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@tap-payments/os-micro-frontend-shared",
3
3
  "description": "Shared components and utilities for Tap Payments micro frontends",
4
- "version": "0.1.109-test.4",
5
- "testVersion": 4,
4
+ "version": "0.1.109-test.6",
5
+ "testVersion": 6,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",