@alveole/components 2.0.0-alpha.18 → 2.0.0-alpha.19

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 (29) hide show
  1. package/dist/generated/version.d.ts +1 -1
  2. package/dist/generated/version.js +1 -1
  3. package/dist/ui/DocumentViewer/DocumentViewer.d.ts +2 -1
  4. package/dist/ui/DocumentViewer/DocumentViewer.d.ts.map +1 -1
  5. package/dist/ui/DocumentViewer/DocumentViewer.js +13 -5
  6. package/dist/ui/DocumentViewer/DocumentViewer.stories.d.ts.map +1 -1
  7. package/dist/ui/DocumentViewer/DocumentViewer.stories.js +3 -3
  8. package/dist/ui/DocumentViewer/DocumentViewer.stories.sources.d.ts.map +1 -1
  9. package/dist/ui/DocumentViewer/DocumentViewer.stories.sources.js +2 -2
  10. package/dist/ui/DocumentViewer/DocumentViewer.types.d.ts +2 -0
  11. package/dist/ui/DocumentViewer/DocumentViewer.types.d.ts.map +1 -1
  12. package/dist/ui/DocumentViewer/DocumentViewerImage.d.ts +1 -2
  13. package/dist/ui/DocumentViewer/DocumentViewerImage.d.ts.map +1 -1
  14. package/dist/ui/DocumentViewer/DocumentViewerImage.js +5 -15
  15. package/dist/ui/DocumentViewer/DocumentViewerPDF.web.d.ts.map +1 -1
  16. package/dist/ui/DocumentViewer/DocumentViewerPDF.web.js +8 -8
  17. package/dist/ui/DocumentViewer/DocumentViewerToolbar.d.ts +3 -0
  18. package/dist/ui/DocumentViewer/DocumentViewerToolbar.d.ts.map +1 -1
  19. package/dist/ui/DocumentViewer/DocumentViewerToolbar.js +7 -3
  20. package/dist/ui/DocumentViewer/usePleinEcran.d.ts +13 -0
  21. package/dist/ui/DocumentViewer/usePleinEcran.d.ts.map +1 -0
  22. package/dist/ui/DocumentViewer/usePleinEcran.js +27 -0
  23. package/dist/ui/DocumentViewer/useZoomMolette.d.ts +24 -0
  24. package/dist/ui/DocumentViewer/useZoomMolette.d.ts.map +1 -0
  25. package/dist/ui/DocumentViewer/useZoomMolette.js +55 -0
  26. package/package.json +1 -1
  27. package/dist/ui/DocumentViewer/useSurvolAvecZoom.d.ts +0 -15
  28. package/dist/ui/DocumentViewer/useSurvolAvecZoom.d.ts.map +0 -1
  29. package/dist/ui/DocumentViewer/useSurvolAvecZoom.js +0 -27
@@ -1,2 +1,2 @@
1
- export declare const ALVEOLE_COMPONENTS_VERSION: "2.0.0-alpha.18";
1
+ export declare const ALVEOLE_COMPONENTS_VERSION: "2.0.0-alpha.19";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- export const ALVEOLE_COMPONENTS_VERSION = "2.0.0-alpha.18";
1
+ export const ALVEOLE_COMPONENTS_VERSION = "2.0.0-alpha.19";
@@ -1,3 +1,4 @@
1
+ import type React from 'react';
1
2
  import { type DocumentViewerProps } from './DocumentViewer.types';
2
- export declare const DocumentViewer: (props: DocumentViewerProps) => import("react").JSX.Element;
3
+ export declare const DocumentViewer: (props: DocumentViewerProps) => React.JSX.Element;
3
4
  //# sourceMappingURL=DocumentViewer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentViewer.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAMlE,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,gCAkDxD,CAAC"}
1
+ {"version":3,"file":"DocumentViewer.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,KAAK,mBAAmB,EAA+B,MAAM,wBAAwB,CAAC;AAO/F,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,sBA4DxD,CAAC"}
@@ -5,12 +5,20 @@ import { DocumentViewerImage } from './DocumentViewerImage';
5
5
  import { DocumentViewerPDF } from './DocumentViewerPDF';
6
6
  import { DocumentViewerToolbar } from './DocumentViewerToolbar';
7
7
  import { usePilotageDeDocument } from './usePilotageDeDocument';
8
+ import { usePleinEcran } from './usePleinEcran';
8
9
  export const DocumentViewer = (props) => {
9
- const { children, title, source, type, height = '100%', ChildrenProps, pdfErrorLabel, ...boxProps } = props;
10
+ const { children, title, source, type, height = '100%', ChildrenProps, pdfErrorLabel, allowFullscreen = false, ...boxProps } = props;
10
11
  const styles = useStyles();
11
12
  const { rotation, page, state, onPdfReady, onRotateLeft, onRotateRight, onNextPage, onPreviousPage } = usePilotageDeDocument(type);
12
- return (_jsxs(Box, { tag: "document-viewer-wrapper", height: height, style: styles.viewerWrapper, children: [_jsxs(Box, { tag: "document-viewer", flex: 1, height: '100%', minW: 0, style: { flexBasis: 0 }, ...boxProps, children: [_jsx(DocumentViewerToolbar, { title: title, state: state, withChildren: children != null, onRotateLeft: onRotateLeft, onRotateRight: onRotateRight, onNextPage: onNextPage, onPreviousPage: onPreviousPage }), _jsx(Box, { tag: "document-viewer-container", style: {
13
- ...styles.viewerContainer,
14
- ...(children ? { borderBottomRightRadius: 0 } : {}),
15
- }, children: _jsxs(Box, { flex: 1, children: [type === 'image' && _jsx(DocumentViewerImage, { source: source, rotation: rotation, height: height }), type === 'pdf' && (_jsx(DocumentViewerPDF, { source: source, page: page, rotation: rotation, height: height, onReady: onPdfReady, errorLabel: pdfErrorLabel }))] }) })] }), children && (_jsx(Box, { tag: "document-viewer-children", ...ChildrenProps, style: [styles.children, ChildrenProps?.style], children: children }))] }));
13
+ const { poserLeCadre, ...pleinEcran } = usePleinEcran(allowFullscreen);
14
+ return (_jsxs(Box, { tag: "document-viewer-wrapper", height: height, style: styles.viewerWrapper, children: [_jsxs(Box, { tag: "document-viewer", ref: poserLeCadre, flex: 1, height: '100%', minW: 0, style: { flexBasis: 0 }, ...boxProps, children: [_jsx(DocumentViewerToolbar, { title: title, state: state, withChildren: children != null, onRotateLeft: onRotateLeft, onRotateRight: onRotateRight, onNextPage: onNextPage, onPreviousPage: onPreviousPage, pleinEcran: pleinEcran.disponible ? pleinEcran.pleinEcran : undefined, onTogglePleinEcran: pleinEcran.basculer }), _jsx(ContenuDuDocument, { type: type, source: source, page: page, rotation: rotation, height: height, onPdfReady: onPdfReady, pdfErrorLabel: pdfErrorLabel, withChildren: children != null })] }), children && (_jsx(Box, { tag: "document-viewer-children", ...ChildrenProps, style: [styles.children, ChildrenProps?.style], children: children }))] }));
15
+ };
16
+ /** Le cadre du document, image ou PDF, sous la barre d'outils. */
17
+ const ContenuDuDocument = (props) => {
18
+ const { type, source, page, rotation, height, onPdfReady, pdfErrorLabel, withChildren } = props;
19
+ const styles = useStyles();
20
+ return (_jsx(Box, { tag: "document-viewer-container", style: {
21
+ ...styles.viewerContainer,
22
+ ...(withChildren ? { borderBottomRightRadius: 0 } : {}),
23
+ }, children: _jsxs(Box, { flex: 1, children: [type === 'image' && _jsx(DocumentViewerImage, { source: source, rotation: rotation, height: height }), type === 'pdf' && (_jsx(DocumentViewerPDF, { source: source, page: page, rotation: rotation, height: height, onReady: onPdfReady, errorLabel: pdfErrorLabel }))] }) }));
16
24
  };
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentViewer.stories.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewer.stories.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,wBAQkB;AAElB,eAAO,MAAM,eAAe,mCAI3B,CAAC;AAEF,eAAO,MAAM,WAAW,mCAIvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,mCAS5B,CAAC;AAEF,eAAO,MAAM,YAAY,mCAQxB,CAAC;AAEF,OAAO,KAAK,OAAO,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"DocumentViewer.stories.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewer.stories.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,wBASkB;AAElB,eAAO,MAAM,eAAe,mCAU3B,CAAC;AAEF,eAAO,MAAM,WAAW,mCAIvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,mCAS5B,CAAC;AAEF,eAAO,MAAM,YAAY,mCAQxB,CAAC;AAEF,OAAO,KAAK,OAAO,MAAM,kCAAkC,CAAC"}
@@ -8,12 +8,12 @@ export default {
8
8
  tags: ['ui'],
9
9
  experimental: false,
10
10
  webOnly: true,
11
- description: 'Viewer de documents (PDF, Image)',
11
+ description: 'Viewer de documents (PDF, Image). Ctrl/⌘ + molette pour zoomer, double-clic pour revenir à 100 %, bouton plein écran avec `allowFullscreen`.',
12
12
  component: DocumentViewer,
13
13
  styleFn: useStyles,
14
14
  };
15
- export const DocumentImageEx = () => (_jsx(Box, { width: "100%", maxW: 500, height: 500, children: _jsx(DocumentViewer, { title: "Document image", type: "image", source: "https://picsum.photos/1000/2000", height: "100%" }) }));
16
- export const DocumentPdf = () => (_jsx(Box, { width: "100%", height: 400, maxW: 500, children: _jsx(DocumentViewer, { title: "Document PDF", type: "pdf", source: "/document-exemple.pdf", height: "100%" }) }));
15
+ export const DocumentImageEx = () => (_jsx(Box, { width: "100%", maxW: 500, height: 500, children: _jsx(DocumentViewer, { title: "Document image", type: "image", allowFullscreen: true, source: "https://picsum.photos/1000/2000", height: "100%" }) }));
16
+ export const DocumentPdf = () => (_jsx(Box, { width: "100%", height: 400, maxW: 500, children: _jsx(DocumentViewer, { title: "Document PDF", type: "pdf", source: "/document-exemple.pdf", height: "100%", allowFullscreen: true }) }));
17
17
  export const DocumentPdfError = () => (_jsx(Box, { width: "100%", height: 400, maxW: 500, children: _jsx(DocumentViewer, { title: "Document PDF en erreur", type: "pdf", source: "https://example.com/document-inexistant.pdf", height: "100%" }) }));
18
18
  export const WithChildren = () => (_jsx(Box, { width: "100%", height: 600, children: _jsx(DocumentViewer, { title: "Document PDF", type: "pdf", source: "/document-exemple.pdf", height: "100%", children: _jsx(Box, { p: '2W', children: _jsx(Typography, { children: "Contenu enfant" }) }) }) }));
19
19
  export * as Sources from './DocumentViewer.stories.sources';
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentViewer.stories.sources.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewer.stories.sources.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,cAA0O,CAAC;AAEvQ,eAAO,MAAM,WAAW,cAAwN,CAAC;AAEjP,eAAO,MAAM,gBAAgB,cAA8R,CAAC;AAE5T,eAAO,MAAM,YAAY,cAAwT,CAAC;AAElV,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,YAAY,CAAC"}
1
+ {"version":3,"file":"DocumentViewer.stories.sources.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewer.stories.sources.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,cAAkS,CAAC;AAE/T,eAAO,MAAM,WAAW,cAAwO,CAAC;AAEjQ,eAAO,MAAM,gBAAgB,cAA8R,CAAC;AAE5T,eAAO,MAAM,YAAY,cAAwT,CAAC;AAElV,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,YAAY,CAAC"}
@@ -1,7 +1,7 @@
1
1
  // This file is generated. Do not edit manually.
2
2
  // Source: src/ui/DocumentViewer/DocumentViewer.stories.tsx
3
- export const DocumentImageEx = () => "export const DocumentImageEx = () => (\n <Box width=\"100%\" maxW={500} height={500}>\n <DocumentViewer title=\"Document image\" type=\"image\" source=\"https://picsum.photos/1000/2000\" height=\"100%\" />\n </Box>\n);";
4
- export const DocumentPdf = () => "export const DocumentPdf = () => (\n <Box width=\"100%\" height={400} maxW={500}>\n <DocumentViewer title=\"Document PDF\" type=\"pdf\" source=\"/document-exemple.pdf\" height=\"100%\" />\n </Box>\n);";
3
+ export const DocumentImageEx = () => "export const DocumentImageEx = () => (\n <Box width=\"100%\" maxW={500} height={500}>\n <DocumentViewer\n title=\"Document image\"\n type=\"image\"\n allowFullscreen\n source=\"https://picsum.photos/1000/2000\"\n height=\"100%\"\n />\n </Box>\n);";
4
+ export const DocumentPdf = () => "export const DocumentPdf = () => (\n <Box width=\"100%\" height={400} maxW={500}>\n <DocumentViewer title=\"Document PDF\" type=\"pdf\" source=\"/document-exemple.pdf\" height=\"100%\" allowFullscreen />\n </Box>\n);";
5
5
  export const DocumentPdfError = () => "export const DocumentPdfError = () => (\n <Box width=\"100%\" height={400} maxW={500}>\n <DocumentViewer\n title=\"Document PDF en erreur\"\n type=\"pdf\"\n source=\"https://example.com/document-inexistant.pdf\"\n height=\"100%\"\n />\n </Box>\n);";
6
6
  export const WithChildren = () => "export const WithChildren = () => (\n <Box width=\"100%\" height={600}>\n <DocumentViewer title=\"Document PDF\" type=\"pdf\" source=\"/document-exemple.pdf\" height=\"100%\">\n <Box p={'2W'}>\n <Typography>Contenu enfant</Typography>\n </Box>\n </DocumentViewer>\n </Box>\n);";
7
7
  export const storySources = {
@@ -8,5 +8,7 @@ export type DocumentViewerProps = BoxProps & {
8
8
  height?: BoxProps['height'];
9
9
  ChildrenProps?: Omit<BoxProps, 'children'>;
10
10
  pdfErrorLabel?: string;
11
+ /** Affiche le bouton plein ecran dans la barre d'outils (web, si le navigateur le permet). */
12
+ allowFullscreen?: boolean;
11
13
  };
12
14
  //# sourceMappingURL=DocumentViewer.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentViewer.types.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewer.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,MAAM,sBAAsB,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;AAExD,eAAO,MAAM,wBAAwB,GAAI,OAAO,MAAM,KAAG,KAAK,IAAI,sBAC/B,CAAC;AAEpC,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG;IAC3C,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5B,aAAa,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC"}
1
+ {"version":3,"file":"DocumentViewer.types.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewer.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,MAAM,sBAAsB,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;AAExD,eAAO,MAAM,wBAAwB,GAAI,OAAO,MAAM,KAAG,KAAK,IAAI,sBAC/B,CAAC;AAEpC,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG;IAC3C,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5B,aAAa,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8FAA8F;IAC9F,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC"}
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import { BoxProps } from '../../core/Box';
3
2
  import { DocumentViewerRotation } from './DocumentViewer.types';
4
3
  export type DocumentViewerImageProps = {
@@ -7,5 +6,5 @@ export type DocumentViewerImageProps = {
7
6
  rotation: DocumentViewerRotation;
8
7
  scale?: number;
9
8
  };
10
- export declare const DocumentViewerImage: (props: DocumentViewerImageProps) => React.JSX.Element;
9
+ export declare const DocumentViewerImage: (props: DocumentViewerImageProps) => import("react").JSX.Element;
11
10
  //# sourceMappingURL=DocumentViewerImage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentViewerImage.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewerImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAO,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAIhE,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5B,QAAQ,EAAE,sBAAsB,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,OAAO,wBAAwB,sBA6ClE,CAAC"}
1
+ {"version":3,"file":"DocumentViewerImage.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewerImage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5B,QAAQ,EAAE,sBAAsB,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,OAAO,wBAAwB,gCA6BlE,CAAC"}
@@ -1,25 +1,15 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import React from 'react';
3
2
  import { Box } from '../../core/Box';
4
3
  import { Image } from '../../core/Image';
5
4
  import { useStyles } from './DocumentViewer.styles';
6
- import { positionEnPourcentage } from './documentViewerPdfCalculs';
7
- import { lirePointeurWeb } from './pointeurWeb';
5
+ import { useZoomMolette } from './useZoomMolette';
8
6
  export const DocumentViewerImage = (props) => {
9
7
  const { source, rotation, height, scale = 1 } = props;
10
8
  const styles = useStyles();
11
- const [isHovered, setIsHovered] = React.useState(false);
12
- const [transformOrigin, setTransformOrigin] = React.useState('50% 50%');
13
- const hoveredScale = isHovered ? 2 : 1;
14
- const handlePointerMove = React.useCallback((event) => {
15
- const pointeur = lirePointeurWeb(event);
16
- if (!pointeur)
17
- return;
18
- const { x, y } = positionEnPourcentage(pointeur);
19
- const origin = getRotatedTransformOrigin(x, y, rotation);
20
- setTransformOrigin(`${origin.x}% ${origin.y}%`);
21
- }, [rotation]);
22
- return (_jsx(Box, { tag: "document-viewer-image", width: '100%', height: height, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), onPointerEnter: () => setIsHovered(true), onPointerLeave: () => setIsHovered(false), onPointerMove: handlePointerMove, style: styles.viewerImageContent, children: _jsx(Box, { width: '100%', height: '100%', p: '1V', children: _jsx(Box, { width: '100%', height: '100%', style: { transform: [{ rotate: `${rotation}deg` }] }, children: _jsx(Box, { width: '100%', height: '100%', style: [styles.viewerImageZoomLayer, { transformOrigin }, { transform: [{ scale: scale * hoveredScale }] }], children: _jsx(Image, { source: { uri: source }, contentFit: "contain", width: '100%', height: '100%', pointerEvents: "none" }) }) }) }) }));
9
+ const { poserLeCadre, ...zoom } = useZoomMolette();
10
+ const origine = getRotatedTransformOrigin(zoom.position.x, zoom.position.y, rotation);
11
+ const transformOrigin = `${origine.x}% ${origine.y}%`;
12
+ return (_jsx(Box, { tag: "document-viewer-image", width: '100%', height: height, ref: poserLeCadre, onPointerMove: zoom.onDeplacement, style: styles.viewerImageContent, children: _jsx(Box, { width: '100%', height: '100%', p: '1V', children: _jsx(Box, { width: '100%', height: '100%', style: { transform: [{ rotate: `${rotation}deg` }] }, children: _jsx(Box, { width: '100%', height: '100%', style: [styles.viewerImageZoomLayer, { transformOrigin }, { transform: [{ scale: scale * zoom.echelle }] }], children: _jsx(Image, { source: { uri: source }, contentFit: "contain", width: '100%', height: '100%', pointerEvents: "none" }) }) }) }) }));
23
13
  };
24
14
  const getRotatedTransformOrigin = (x, y, rotation) => {
25
15
  switch (rotation) {
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentViewerPDF.web.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewerPDF.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAOhE,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5B,QAAQ,EAAE,sBAAsB,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAwDF,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,sBAkC9D,CAAC"}
1
+ {"version":3,"file":"DocumentViewerPDF.web.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewerPDF.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAOhE,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5B,QAAQ,EAAE,sBAAsB,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AA+DF,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,sBAmC9D,CAAC"}
@@ -6,19 +6,19 @@ import { useStyles } from './DocumentViewer.styles';
6
6
  import { useDocumentPdfCharge } from './useDocumentPdfCharge';
7
7
  import { useEtatReinitialiseParCle } from './useEtatReinitialiseParCle';
8
8
  import { useRenduDePage } from './useRenduDePage';
9
- import { useSurvolAvecZoom } from './useSurvolAvecZoom';
10
9
  import { useTailleParResizeObserver } from './useTailleParResizeObserver';
11
- /** Le cadre du visualiseur : la mesure invisible, le canvas a l'echelle du survol, et
10
+ import { useZoomMolette } from './useZoomMolette';
11
+ /** Le cadre du visualiseur : la mesure invisible, le canvas a l'echelle du zoom, et
12
12
  * l'incrustation d'erreur quand le document ou la page n'a pas pu se rendre. */
13
- const ZonePdf = ({ mesureRef, canvasRef, tailleRendue, survol, hasError, errorLabel, height }) => {
13
+ const ZonePdf = ({ mesureRef, canvasRef, tailleRendue, poserLeCadre, zoom, hasError, errorLabel, height, }) => {
14
14
  const styles = useStyles();
15
- return (_jsxs(Box, { tag: "document-viewer-pdf", width: '100%', height: height, onMouseEnter: survol.onEntree, onMouseLeave: survol.onSortie, onPointerEnter: survol.onEntree, onPointerLeave: survol.onSortie, onPointerMove: survol.onDeplacement, style: [styles.viewerPdfContent, { position: 'relative' }], children: [_jsx("div", { ref: mesureRef, style: { position: 'absolute', inset: 0, pointerEvents: 'none' } }), _jsxs(Box, { width: '100%', height: '100%', p: '1V', style: styles.viewerPdfStage, children: [_jsx(Box, { style: [
15
+ return (_jsxs(Box, { tag: "document-viewer-pdf", width: '100%', height: height, ref: poserLeCadre, onPointerMove: zoom.onDeplacement, style: [styles.viewerPdfContent, { position: 'relative' }], children: [_jsx("div", { ref: mesureRef, style: { position: 'absolute', inset: 0, pointerEvents: 'none' } }), _jsxs(Box, { width: '100%', height: '100%', p: '1V', style: styles.viewerPdfStage, children: [_jsx(Box, { style: [
16
16
  styles.viewerPdfCanvasWrapper,
17
17
  {
18
18
  width: tailleRendue.width,
19
19
  height: tailleRendue.height,
20
- transformOrigin: survol.origine,
21
- transform: [{ scale: survol.echelle }],
20
+ transformOrigin: zoom.origine,
21
+ transform: [{ scale: zoom.echelle }],
22
22
  },
23
23
  ], children: _jsx("canvas", { ref: canvasRef, style: styles.viewerPdfCanvas }) }), hasError && (_jsx(Box, { style: styles.viewerPdfOverlay, children: _jsx(Typography, { style: styles.viewerPdfErrorLabel, children: errorLabel }) }))] })] }));
24
24
  };
@@ -33,6 +33,6 @@ export const DocumentViewerPDF = (props) => {
33
33
  const [erreurDeRendu, setErreurDeRendu] = useEtatReinitialiseParCle(source);
34
34
  const onErreurDeRendu = React.useCallback(() => setErreurDeRendu(true), [setErreurDeRendu]);
35
35
  const tailleRendue = useRenduDePage({ pdf, page, rotation, scale, cadre, canvasRef, onErreur: onErreurDeRendu });
36
- const survol = useSurvolAvecZoom();
37
- return (_jsx(ZonePdf, { mesureRef: mesureRef, canvasRef: canvasRef, tailleRendue: tailleRendue, survol: survol, hasError: erreurDeChargement || erreurDeRendu, errorLabel: errorLabel, height: height }));
36
+ const { poserLeCadre, ...zoom } = useZoomMolette();
37
+ return (_jsx(ZonePdf, { mesureRef: mesureRef, canvasRef: canvasRef, tailleRendue: tailleRendue, poserLeCadre: poserLeCadre, zoom: zoom, hasError: erreurDeChargement || erreurDeRendu, errorLabel: errorLabel, height: height }));
38
38
  };
@@ -13,6 +13,9 @@ export type DocumentViewerToolbarProps = {
13
13
  onRotateRight: () => void;
14
14
  onPreviousPage?: () => void;
15
15
  onNextPage?: () => void;
16
+ /** Absent quand le plein ecran n'est pas disponible : le bouton n'est alors pas affiche. */
17
+ pleinEcran?: boolean;
18
+ onTogglePleinEcran?: () => void;
16
19
  };
17
20
  export declare const DocumentViewerToolbar: (props: DocumentViewerToolbarProps) => import("react").JSX.Element;
18
21
  //# sourceMappingURL=DocumentViewerToolbar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentViewerToolbar.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewerToolbar.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,0BAA0B,CAAC;IAClC,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,OAAO,0BAA0B,gCAsDtE,CAAC"}
1
+ {"version":3,"file":"DocumentViewerToolbar.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewerToolbar.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,0BAA0B,CAAC;IAClC,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,4FAA4F;IAC5F,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,OAAO,0BAA0B,gCAkEtE,CAAC"}
@@ -1,10 +1,10 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Box } from '../../core/Box';
3
3
  import { Typography } from '../../core/Typography';
4
4
  import { useStyles } from './DocumentViewer.styles';
5
5
  import { ToolbarButton } from './DocumentViewerToolbarButton';
6
6
  export const DocumentViewerToolbar = (props) => {
7
- const { title, state, withChildren, onRotateLeft, onRotateRight, onNextPage, onPreviousPage } = props;
7
+ const { title, state, withChildren, onRotateLeft, onRotateRight, onNextPage, onPreviousPage, pleinEcran, onTogglePleinEcran, } = props;
8
8
  const styles = useStyles();
9
9
  const isPdf = state.fileType === 'pdf';
10
10
  const isFirstPage = state.page === 1;
@@ -13,5 +13,9 @@ export const DocumentViewerToolbar = (props) => {
13
13
  return (_jsxs(Box, { tag: "document-viewer-toolbar", style: {
14
14
  ...styles.toolbar,
15
15
  ...(withChildren ? { borderTopRightRadius: 0 } : {}),
16
- }, children: [_jsx(Box, { children: _jsx(Typography, { style: styles.toolbarTitle, children: title }) }), _jsxs(Box, { tag: "document-viewer-toolbar-actions", style: styles.toolbarAction, children: [_jsxs(Box, { display: "flex", flexDirection: "row", gap: "1,5V", children: [_jsx(ToolbarButton, { onPress: onRotateLeft, icon: "RotateCcwSquare", accessibilityLabel: "Pivoter vers la gauche" }), _jsx(ToolbarButton, { onPress: onRotateRight, icon: "RotateCwSquare", accessibilityLabel: "Pivoter vers la droite" })] }), _jsx(Box, { style: styles.toolbarDivider }), _jsxs(Box, { display: "flex", flexDirection: "row", gap: "1,5V", children: [_jsx(ToolbarButton, { onPress: onPreviousPage, disabled: isFirstPage || !hasPagination, icon: "SquareChevronLeft", accessibilityLabel: "Page precedente" }), _jsx(Box, { mt: 'auto', mb: 'auto', children: _jsxs(Typography, { style: styles.toolbarState, children: [hasPagination ? state.page : 1, " / ", hasPagination ? state.totalPages : 1] }) }), _jsx(ToolbarButton, { onPress: onNextPage, disabled: isLastPage || !hasPagination, icon: "SquareChevronRight", accessibilityLabel: "Page suivante" })] })] })] }));
16
+ }, children: [_jsx(Box, { children: _jsx(Typography, { style: styles.toolbarTitle, children: title }) }), _jsxs(Box, { tag: "document-viewer-toolbar-actions", style: styles.toolbarAction, children: [_jsxs(Box, { display: "flex", flexDirection: "row", gap: "1,5V", children: [_jsx(ToolbarButton, { onPress: onRotateLeft, icon: "RotateCcwSquare", accessibilityLabel: "Pivoter vers la gauche" }), _jsx(ToolbarButton, { onPress: onRotateRight, icon: "RotateCwSquare", accessibilityLabel: "Pivoter vers la droite" })] }), _jsx(Box, { style: styles.toolbarDivider }), _jsxs(Box, { display: "flex", flexDirection: "row", gap: "1,5V", children: [_jsx(ToolbarButton, { onPress: onPreviousPage, disabled: isFirstPage || !hasPagination, icon: "SquareChevronLeft", accessibilityLabel: "Page precedente" }), _jsx(Box, { mt: 'auto', mb: 'auto', children: _jsxs(Typography, { style: styles.toolbarState, children: [hasPagination ? state.page : 1, " / ", hasPagination ? state.totalPages : 1] }) }), _jsx(ToolbarButton, { onPress: onNextPage, disabled: isLastPage || !hasPagination, icon: "SquareChevronRight", accessibilityLabel: "Page suivante" })] }), pleinEcran !== undefined && _jsx(BoutonPleinEcran, { pleinEcran: pleinEcran, onPress: onTogglePleinEcran })] })] }));
17
+ };
18
+ const BoutonPleinEcran = ({ pleinEcran, onPress }) => {
19
+ const styles = useStyles();
20
+ return (_jsxs(_Fragment, { children: [_jsx(Box, { style: styles.toolbarDivider }), _jsx(ToolbarButton, { onPress: onPress, icon: pleinEcran ? 'Minimize' : 'Maximize', accessibilityLabel: pleinEcran ? 'Quitter le plein ecran' : 'Afficher en plein ecran' })] }));
17
21
  };
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ /**
3
+ * Le plein ecran du visualiseur, par la Fullscreen API du navigateur. Indisponible s'il n'est pas `actif`, hors du web
4
+ * ou quand le navigateur le refuse (`document.fullscreenEnabled`). La sortie par Echap passe par
5
+ * le navigateur : l'etat suit donc `fullscreenchange` plutot que les appuis sur le bouton.
6
+ */
7
+ export declare const usePleinEcran: (actif: boolean) => {
8
+ poserLeCadre: React.Dispatch<unknown>;
9
+ disponible: boolean;
10
+ pleinEcran: boolean;
11
+ basculer: () => void;
12
+ };
13
+ //# sourceMappingURL=usePleinEcran.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePleinEcran.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/usePleinEcran.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO;;;;;CAqB3C,CAAC"}
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ /**
3
+ * Le plein ecran du visualiseur, par la Fullscreen API du navigateur. Indisponible s'il n'est pas `actif`, hors du web
4
+ * ou quand le navigateur le refuse (`document.fullscreenEnabled`). La sortie par Echap passe par
5
+ * le navigateur : l'etat suit donc `fullscreenchange` plutot que les appuis sur le bouton.
6
+ */
7
+ export const usePleinEcran = (actif) => {
8
+ const [cadre, poserLeCadre] = React.useState(null);
9
+ const [pleinEcran, setPleinEcran] = React.useState(false);
10
+ const disponible = actif && typeof document !== 'undefined' && document.fullscreenEnabled === true;
11
+ React.useEffect(() => {
12
+ if (!disponible)
13
+ return;
14
+ const onChangement = () => setPleinEcran(document.fullscreenElement === cadre);
15
+ document.addEventListener('fullscreenchange', onChangement);
16
+ return () => document.removeEventListener('fullscreenchange', onChangement);
17
+ }, [cadre, disponible]);
18
+ const basculer = React.useCallback(() => {
19
+ if (!(cadre instanceof Element))
20
+ return;
21
+ if (document.fullscreenElement === cadre)
22
+ void document.exitFullscreen();
23
+ else
24
+ void cadre.requestFullscreen();
25
+ }, [cadre]);
26
+ return { poserLeCadre, disponible, pleinEcran, basculer };
27
+ };
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { type EvenementPointeur } from './pointeurWeb';
3
+ export declare const ZOOM_MIN = 1;
4
+ export declare const ZOOM_MAX = 4;
5
+ /** Le zoom suivant d'un cran de molette, borne entre `ZOOM_MIN` et `ZOOM_MAX`. */
6
+ export declare const zoomSuivant: (zoom: number, deltaY: number) => number;
7
+ /**
8
+ * Le zoom a Ctrl (ou Cmd) + molette, centre sous le pointeur ; la molette seule laisse defiler
9
+ * la page. Un double-clic revient a 100 %. Une fois zoome, l'origine suit le pointeur pour
10
+ * parcourir la page. Le listener `wheel` est pose a la main, non passif : `onWheel` de React
11
+ * est passif et ne peut pas empecher le zoom du navigateur. Hors du DOM (natif), rien n'est pose.
12
+ */
13
+ export declare const useZoomMolette: () => {
14
+ poserLeCadre: React.Dispatch<unknown>;
15
+ echelle: number;
16
+ /** La position du pointeur, en pourcentage du cadre. */
17
+ position: {
18
+ x: number;
19
+ y: number;
20
+ };
21
+ origine: string;
22
+ onDeplacement: (event: EvenementPointeur) => void;
23
+ };
24
+ //# sourceMappingURL=useZoomMolette.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useZoomMolette.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/useZoomMolette.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,iBAAiB,EAAmB,MAAM,eAAe,CAAC;AAExE,eAAO,MAAM,QAAQ,IAAI,CAAC;AAC1B,eAAO,MAAM,QAAQ,IAAI,CAAC;AAG1B,kFAAkF;AAClF,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,WACsC,CAAC;AAE/F;;;;;GAKG;AACH,eAAO,MAAM,cAAc;;;IAoCvB,wDAAwD;;;;;;2BAGjC,iBAAiB;CAI3C,CAAC"}
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import { positionEnPourcentage } from './documentViewerPdfCalculs';
3
+ import { lirePointeurWeb } from './pointeurWeb';
4
+ export const ZOOM_MIN = 1;
5
+ export const ZOOM_MAX = 4;
6
+ const PAS_DE_ZOOM = 1.25;
7
+ /** Le zoom suivant d'un cran de molette, borne entre `ZOOM_MIN` et `ZOOM_MAX`. */
8
+ export const zoomSuivant = (zoom, deltaY) => Math.max(ZOOM_MIN, Math.min(ZOOM_MAX, deltaY < 0 ? zoom * PAS_DE_ZOOM : zoom / PAS_DE_ZOOM));
9
+ /**
10
+ * Le zoom a Ctrl (ou Cmd) + molette, centre sous le pointeur ; la molette seule laisse defiler
11
+ * la page. Un double-clic revient a 100 %. Une fois zoome, l'origine suit le pointeur pour
12
+ * parcourir la page. Le listener `wheel` est pose a la main, non passif : `onWheel` de React
13
+ * est passif et ne peut pas empecher le zoom du navigateur. Hors du DOM (natif), rien n'est pose.
14
+ */
15
+ export const useZoomMolette = () => {
16
+ // Un ref par callback : le cadre est un etat, pose une fois monte, que l'effet suit.
17
+ const [cadre, poserLeCadre] = React.useState(null);
18
+ const [echelle, setEchelle] = React.useState(1);
19
+ const [position, setPosition] = React.useState({ x: 50, y: 50 });
20
+ const suivrePointeur = React.useCallback((event) => {
21
+ const pointeur = lirePointeurWeb(event);
22
+ if (!pointeur)
23
+ return;
24
+ setPosition(positionEnPourcentage(pointeur));
25
+ }, []);
26
+ React.useEffect(() => {
27
+ if (typeof Element === 'undefined' || !(cadre instanceof Element))
28
+ return;
29
+ const onWheel = (event) => {
30
+ if (!(event instanceof WheelEvent) || !(event.ctrlKey || event.metaKey))
31
+ return;
32
+ event.preventDefault();
33
+ suivrePointeur({ currentTarget: cadre, nativeEvent: event });
34
+ setEchelle(zoom => zoomSuivant(zoom, event.deltaY));
35
+ };
36
+ const onDoubleClic = () => setEchelle(1);
37
+ cadre.addEventListener('wheel', onWheel, { passive: false });
38
+ cadre.addEventListener('dblclick', onDoubleClic);
39
+ return () => {
40
+ cadre.removeEventListener('wheel', onWheel);
41
+ cadre.removeEventListener('dblclick', onDoubleClic);
42
+ };
43
+ }, [cadre, suivrePointeur]);
44
+ return {
45
+ poserLeCadre,
46
+ echelle,
47
+ /** La position du pointeur, en pourcentage du cadre. */
48
+ position,
49
+ origine: `${position.x}% ${position.y}%`,
50
+ onDeplacement: (event) => {
51
+ if (echelle > 1)
52
+ suivrePointeur(event);
53
+ },
54
+ };
55
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alveole/components",
3
- "version": "2.0.0-alpha.18",
3
+ "version": "2.0.0-alpha.19",
4
4
  "description": "Shared UI components.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,15 +0,0 @@
1
- import { type EvenementPointeur } from './pointeurWeb';
2
- /**
3
- * Le zoom qui suit le pointeur au survol : la page grossit autour du point survole, comme une
4
- * loupe. L'origine de l'agrandissement est la position du pointeur en pourcentage du cadre,
5
- * recalculee a chaque deplacement.
6
- */
7
- export declare const useSurvolAvecZoom: () => {
8
- survole: boolean;
9
- origine: string;
10
- echelle: number;
11
- onEntree: () => void;
12
- onSortie: () => void;
13
- onDeplacement: (event: EvenementPointeur) => void;
14
- };
15
- //# sourceMappingURL=useSurvolAvecZoom.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSurvolAvecZoom.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/useSurvolAvecZoom.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,iBAAiB,EAAmB,MAAM,eAAe,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;2BAIoB,iBAAiB;CAgBlE,CAAC"}
@@ -1,27 +0,0 @@
1
- import React from 'react';
2
- import { positionEnPourcentage } from './documentViewerPdfCalculs';
3
- import { lirePointeurWeb } from './pointeurWeb';
4
- /**
5
- * Le zoom qui suit le pointeur au survol : la page grossit autour du point survole, comme une
6
- * loupe. L'origine de l'agrandissement est la position du pointeur en pourcentage du cadre,
7
- * recalculee a chaque deplacement.
8
- */
9
- export const useSurvolAvecZoom = () => {
10
- const [survole, setSurvole] = React.useState(false);
11
- const [origine, setOrigine] = React.useState('50% 50%');
12
- const onDeplacement = React.useCallback((event) => {
13
- const pointeur = lirePointeurWeb(event);
14
- if (!pointeur)
15
- return;
16
- const { x, y } = positionEnPourcentage(pointeur);
17
- setOrigine(`${x}% ${y}%`);
18
- }, []);
19
- return {
20
- survole,
21
- origine,
22
- echelle: survole ? 2 : 1,
23
- onEntree: () => setSurvole(true),
24
- onSortie: () => setSurvole(false),
25
- onDeplacement,
26
- };
27
- };