@astral/ui 4.44.0 → 4.45.0
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/components/PageContent/constants.d.ts +1 -0
- package/components/PageContent/constants.js +1 -0
- package/components/PageContent/styles.js +13 -0
- package/components/PdfViewer/List/styles.js +4 -0
- package/components/PdfViewer/PdfDocument/styles.js +5 -0
- package/components/PdfViewer/PdfPage/styles.js +10 -0
- package/components/PdfViewer/styles.js +4 -0
- package/components/PdfViewer/useLogic/useLogic.js +15 -1
- package/node/components/PageContent/constants.d.ts +1 -0
- package/node/components/PageContent/constants.js +1 -0
- package/node/components/PageContent/styles.js +13 -0
- package/node/components/PdfViewer/List/styles.js +4 -0
- package/node/components/PdfViewer/PdfDocument/styles.js +5 -0
- package/node/components/PdfViewer/PdfPage/styles.js +10 -0
- package/node/components/PdfViewer/styles.js +4 -0
- package/node/components/PdfViewer/useLogic/useLogic.js +15 -1
- package/package.json +1 -1
|
@@ -4,5 +4,6 @@ export const pageContentClassnames = {
|
|
|
4
4
|
content: createUIKitClassname('page-content__content'),
|
|
5
5
|
contentHasHeader: createUIKitClassname('page-content__content_has-header'),
|
|
6
6
|
animation: createUIKitClassname('page-content_animation'),
|
|
7
|
+
withPdfViewer: createUIKitClassname('page-content_with-pdf-viewer'),
|
|
7
8
|
};
|
|
8
9
|
export const PAGE_CONTENT_ANIMATION = 'white-flash';
|
|
@@ -106,4 +106,17 @@ export const Content = styled.div `
|
|
|
106
106
|
padding: ${({ theme }) => theme.spacing(4, 4, 3)};
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
+
|
|
110
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
111
|
+
&&.${pageContentClassnames.withPdfViewer} {
|
|
112
|
+
margin: 0;
|
|
113
|
+
padding-top: 0;
|
|
114
|
+
padding-right: 0;
|
|
115
|
+
padding-left: 0;
|
|
116
|
+
|
|
117
|
+
background-color: ${({ theme }) => theme.palette.background.body};
|
|
118
|
+
border: unset;
|
|
119
|
+
border-radius: 0;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
109
122
|
`;
|
|
@@ -21,6 +21,16 @@ export const Wrapper = styled.div `
|
|
|
21
21
|
height: ${({ $height }) => $height}px;
|
|
22
22
|
padding-top: 0;
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
26
|
+
border-top: ${({ $isViewerLite, theme }) => ($isViewerLite ? 'unset' : `1px solid ${theme.palette.grey[300]}`)};
|
|
27
|
+
border-radius: ${({ $isViewerLite }) => !$isViewerLite && 0};
|
|
28
|
+
box-shadow: ${({ $isViewerLite }) => !$isViewerLite && 'none'};
|
|
29
|
+
|
|
30
|
+
&:last-child {
|
|
31
|
+
border-bottom: ${({ $isViewerLite, theme }) => ($isViewerLite ? 'unset' : `1px solid ${theme.palette.grey[300]}`)};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
24
34
|
`;
|
|
25
35
|
export const StyledTag = styled(Tag) `
|
|
26
36
|
top: ${({ theme }) => theme.spacing(3)};
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { ConfigContext } from '../../ConfigProvider';
|
|
3
|
+
import { pageContentClassnames } from '../../PageContent/constants';
|
|
4
|
+
import { useViewportType } from '../../useViewportType';
|
|
3
5
|
import { useZoom } from '../hooks/useZoom';
|
|
4
6
|
import { getPageHeightList } from '../utils';
|
|
5
7
|
export const useLogic = ({ file, scrollRef, paginationRef, isFullHeight, isCentered, renderPageRange, isHidePersonalData, isViewerLite, enabledZoom = true, options, ...props }) => {
|
|
6
8
|
const [containerWidth, setContainerWidth] = useState(1);
|
|
9
|
+
const { isMobile } = useViewportType();
|
|
7
10
|
const scrollContainerRef = useRef(null);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const el = scrollRef?.current;
|
|
13
|
+
if (!el) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const isPageContentScroll = el.classList.contains(pageContentClassnames.content);
|
|
17
|
+
if (!isPageContentScroll) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
el.classList.add(pageContentClassnames.withPdfViewer);
|
|
21
|
+
}, [scrollRef]);
|
|
8
22
|
const { zoomOut, scale, zoomIn, shouldAnimateZoom } = useZoom({
|
|
9
23
|
scrollContainerRef,
|
|
10
|
-
enabledZoom,
|
|
24
|
+
enabledZoom: enabledZoom && !isMobile,
|
|
11
25
|
});
|
|
12
26
|
const [isError, setIsError] = useState(false);
|
|
13
27
|
const [errorData, setErrorData] = useState();
|
|
@@ -7,5 +7,6 @@ exports.pageContentClassnames = {
|
|
|
7
7
|
content: (0, createUIKitClassname_1.createUIKitClassname)('page-content__content'),
|
|
8
8
|
contentHasHeader: (0, createUIKitClassname_1.createUIKitClassname)('page-content__content_has-header'),
|
|
9
9
|
animation: (0, createUIKitClassname_1.createUIKitClassname)('page-content_animation'),
|
|
10
|
+
withPdfViewer: (0, createUIKitClassname_1.createUIKitClassname)('page-content_with-pdf-viewer'),
|
|
10
11
|
};
|
|
11
12
|
exports.PAGE_CONTENT_ANIMATION = 'white-flash';
|
|
@@ -109,4 +109,17 @@ exports.Content = styled_1.styled.div `
|
|
|
109
109
|
padding: ${({ theme }) => theme.spacing(4, 4, 3)};
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
+
|
|
113
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
114
|
+
&&.${constants_2.pageContentClassnames.withPdfViewer} {
|
|
115
|
+
margin: 0;
|
|
116
|
+
padding-top: 0;
|
|
117
|
+
padding-right: 0;
|
|
118
|
+
padding-left: 0;
|
|
119
|
+
|
|
120
|
+
background-color: ${({ theme }) => theme.palette.background.body};
|
|
121
|
+
border: unset;
|
|
122
|
+
border-radius: 0;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
112
125
|
`;
|
|
@@ -24,6 +24,16 @@ exports.Wrapper = styled_1.styled.div `
|
|
|
24
24
|
height: ${({ $height }) => $height}px;
|
|
25
25
|
padding-top: 0;
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
29
|
+
border-top: ${({ $isViewerLite, theme }) => ($isViewerLite ? 'unset' : `1px solid ${theme.palette.grey[300]}`)};
|
|
30
|
+
border-radius: ${({ $isViewerLite }) => !$isViewerLite && 0};
|
|
31
|
+
box-shadow: ${({ $isViewerLite }) => !$isViewerLite && 'none'};
|
|
32
|
+
|
|
33
|
+
&:last-child {
|
|
34
|
+
border-bottom: ${({ $isViewerLite, theme }) => ($isViewerLite ? 'unset' : `1px solid ${theme.palette.grey[300]}`)};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
27
37
|
`;
|
|
28
38
|
exports.StyledTag = (0, styled_1.styled)(ControlBar_1.StyledTag) `
|
|
29
39
|
top: ${({ theme }) => theme.spacing(3)};
|
|
@@ -22,4 +22,8 @@ exports.ScrollContainer = styled_1.styled.div `
|
|
|
22
22
|
overflow: ${({ $isViewerLite, $enabledZoom }) => $isViewerLite || !$enabledZoom ? 'unset' : 'auto'};
|
|
23
23
|
|
|
24
24
|
height: 100%;
|
|
25
|
+
|
|
26
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
27
|
+
scrollbar-gutter: unset;
|
|
28
|
+
}
|
|
25
29
|
`;
|
|
@@ -3,14 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useLogic = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const ConfigProvider_1 = require("../../ConfigProvider");
|
|
6
|
+
const constants_1 = require("../../PageContent/constants");
|
|
7
|
+
const useViewportType_1 = require("../../useViewportType");
|
|
6
8
|
const useZoom_1 = require("../hooks/useZoom");
|
|
7
9
|
const utils_1 = require("../utils");
|
|
8
10
|
const useLogic = ({ file, scrollRef, paginationRef, isFullHeight, isCentered, renderPageRange, isHidePersonalData, isViewerLite, enabledZoom = true, options, ...props }) => {
|
|
9
11
|
const [containerWidth, setContainerWidth] = (0, react_1.useState)(1);
|
|
12
|
+
const { isMobile } = (0, useViewportType_1.useViewportType)();
|
|
10
13
|
const scrollContainerRef = (0, react_1.useRef)(null);
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
const el = scrollRef?.current;
|
|
16
|
+
if (!el) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const isPageContentScroll = el.classList.contains(constants_1.pageContentClassnames.content);
|
|
20
|
+
if (!isPageContentScroll) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
el.classList.add(constants_1.pageContentClassnames.withPdfViewer);
|
|
24
|
+
}, [scrollRef]);
|
|
11
25
|
const { zoomOut, scale, zoomIn, shouldAnimateZoom } = (0, useZoom_1.useZoom)({
|
|
12
26
|
scrollContainerRef,
|
|
13
|
-
enabledZoom,
|
|
27
|
+
enabledZoom: enabledZoom && !isMobile,
|
|
14
28
|
});
|
|
15
29
|
const [isError, setIsError] = (0, react_1.useState)(false);
|
|
16
30
|
const [errorData, setErrorData] = (0, react_1.useState)();
|