@alveole/components 0.34.8 → 0.35.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/dist/pdfjs/pdf.min.mjs +21 -0
- package/dist/pdfjs/pdf.worker.min.mjs +21 -0
- package/dist/scripts/sync-pdfjs-web-assets.mjs +16 -0
- package/dist/ui/Badge/Badge.styles.js +2 -2
- package/dist/ui/DocumentViewer/DocumentViewerPDF.d.ts +1 -1
- package/dist/ui/DocumentViewer/DocumentViewerPDF.d.ts.map +1 -1
- package/dist/ui/DocumentViewer/DocumentViewerPDF.js +1 -1
- package/dist/ui/DocumentViewer/DocumentViewerPDF.native.d.ts +14 -0
- package/dist/ui/DocumentViewer/DocumentViewerPDF.native.d.ts.map +1 -0
- package/dist/ui/DocumentViewer/DocumentViewerPDF.native.js +14 -0
- package/dist/ui/DocumentViewer/DocumentViewerPDF.web.d.ts +38 -0
- package/dist/ui/DocumentViewer/DocumentViewerPDF.web.d.ts.map +1 -0
- package/dist/ui/DocumentViewer/DocumentViewerPDF.web.js +156 -0
- package/dist/ui/ListItem/ListItem.d.ts.map +1 -1
- package/dist/ui/ListItem/ListItem.js +1 -1
- package/dist/ui/ListItem/ListItem.stories.d.ts +1 -0
- package/dist/ui/ListItem/ListItem.stories.d.ts.map +1 -1
- package/dist/ui/ListItem/ListItem.stories.js +23 -7
- package/package.json +7 -4
- package/scripts/postinstall.mjs +26 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { copyFileSync, mkdirSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
const packageRoot = resolve(import.meta.dirname, '../..');
|
|
5
|
+
const files = [
|
|
6
|
+
['dist/pdfjs/pdf.min.mjs', 'public/pdf.min.mjs'],
|
|
7
|
+
['dist/pdfjs/pdf.worker.min.mjs', 'public/pdf.worker.min.mjs'],
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
for (const [source, target] of files) {
|
|
11
|
+
const absoluteSource = resolve(packageRoot, source);
|
|
12
|
+
const absoluteTarget = resolve(process.cwd(), target);
|
|
13
|
+
mkdirSync(dirname(absoluteTarget), { recursive: true });
|
|
14
|
+
copyFileSync(absoluteSource, absoluteTarget);
|
|
15
|
+
console.log(`synced ${target}`);
|
|
16
|
+
}
|
|
@@ -35,13 +35,13 @@ export const useStyles = makeStyles(({ radius, text, color, spacing }) => ({
|
|
|
35
35
|
},
|
|
36
36
|
// Sizes
|
|
37
37
|
badgeSm: {
|
|
38
|
-
paddingLeft: spacing('
|
|
38
|
+
paddingLeft: spacing('1,5V'),
|
|
39
39
|
paddingRight: spacing('1,5V'),
|
|
40
40
|
gap: spacing('1V'),
|
|
41
41
|
...text['Corps de texte'].XS.CapsBold,
|
|
42
42
|
},
|
|
43
43
|
badgeMd: {
|
|
44
|
-
paddingLeft: spacing('
|
|
44
|
+
paddingLeft: spacing('1W'),
|
|
45
45
|
paddingRight: spacing('1W'),
|
|
46
46
|
gap: spacing('1V'),
|
|
47
47
|
...text['Corps de texte'].SM.CapsBold,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BoxProps } from '@alveole/components';
|
|
2
2
|
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
3
|
-
import 'pdfjs-dist/build/pdf.worker.
|
|
3
|
+
import 'pdfjs-dist/legacy/build/pdf.worker.min.mjs';
|
|
4
4
|
import { DocumentViewerRotation } from './DocumentViewer';
|
|
5
5
|
export type DocumentViewerPDFProps = {
|
|
6
6
|
source: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentViewerPDF.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewerPDF.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,
|
|
1
|
+
{"version":3,"file":"DocumentViewerPDF.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewerPDF.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,4CAA4C,CAAC;AAGpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,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,gBAAgB,KAAK,IAAI,CAAC;CAC7C,CAAC;AAWF,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,4CA6J9D,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Box } from '@alveole/components';
|
|
3
3
|
import * as pdfjs from 'pdfjs-dist';
|
|
4
|
-
import 'pdfjs-dist/build/pdf.worker.
|
|
4
|
+
import 'pdfjs-dist/legacy/build/pdf.worker.min.mjs';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { Platform } from 'react-native';
|
|
7
7
|
import { useStyles } from './DocumentViewer.styles';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type BoxProps } from '@alveole/components';
|
|
2
|
+
import { DocumentViewerRotation } from './DocumentViewer';
|
|
3
|
+
export type DocumentViewerPDFProps = {
|
|
4
|
+
source: string;
|
|
5
|
+
page: number;
|
|
6
|
+
height?: BoxProps['height'];
|
|
7
|
+
rotation: DocumentViewerRotation;
|
|
8
|
+
scale?: number;
|
|
9
|
+
onReady?: (_state: {
|
|
10
|
+
numPages: number;
|
|
11
|
+
}) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const DocumentViewerPDF: (props: DocumentViewerPDFProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=DocumentViewerPDF.native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocumentViewerPDF.native.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewerPDF.native.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,QAAQ,EAAc,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,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,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAClD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,4CAsB9D,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Typography } from '@alveole/components';
|
|
3
|
+
import { useStyles } from './DocumentViewer.styles';
|
|
4
|
+
export const DocumentViewerPDF = (props) => {
|
|
5
|
+
const { height = '100%' } = props;
|
|
6
|
+
const styles = useStyles();
|
|
7
|
+
return (_jsx(Box, { tag: "document-viewer-pdf", width: '100%', height: height, style: styles.viewerPdfContent, children: _jsx(Box, { width: '100%', height: '100%', p: '1V', style: [
|
|
8
|
+
styles.viewerPdfStage,
|
|
9
|
+
{
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
justifyContent: 'center',
|
|
12
|
+
},
|
|
13
|
+
], children: _jsx(Typography, { children: "Not implemented" }) }) }));
|
|
14
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type BoxProps } from '@alveole/components';
|
|
2
|
+
import { DocumentViewerRotation } from './DocumentViewer';
|
|
3
|
+
type PDFDocumentProxyLike = {
|
|
4
|
+
destroy?: () => void | Promise<void>;
|
|
5
|
+
getPage: (page: number) => Promise<{
|
|
6
|
+
getViewport: (options: {
|
|
7
|
+
scale: number;
|
|
8
|
+
rotation: DocumentViewerRotation;
|
|
9
|
+
}) => {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
};
|
|
13
|
+
render: (options: {
|
|
14
|
+
canvasContext: CanvasRenderingContext2D;
|
|
15
|
+
viewport: {
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
};
|
|
19
|
+
transform?: [number, number, number, number, number, number];
|
|
20
|
+
}) => {
|
|
21
|
+
promise: Promise<void>;
|
|
22
|
+
cancel?: () => void;
|
|
23
|
+
} | null;
|
|
24
|
+
cleanup?: () => void;
|
|
25
|
+
}>;
|
|
26
|
+
numPages: number;
|
|
27
|
+
};
|
|
28
|
+
export type DocumentViewerPDFProps = {
|
|
29
|
+
source: string;
|
|
30
|
+
page: number;
|
|
31
|
+
height?: BoxProps['height'];
|
|
32
|
+
rotation: DocumentViewerRotation;
|
|
33
|
+
scale?: number;
|
|
34
|
+
onReady?: (state: PDFDocumentProxyLike) => void;
|
|
35
|
+
};
|
|
36
|
+
export declare const DocumentViewerPDF: (props: DocumentViewerPDFProps) => import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=DocumentViewerPDF.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocumentViewerPDF.web.d.ts","sourceRoot":"","sources":["../../../src/ui/DocumentViewer/DocumentViewerPDF.web.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,KAAK,oBAAoB,GAAG;IAC1B,OAAO,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;QACjC,WAAW,EAAE,CAAC,OAAO,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,sBAAsB,CAAA;SAAE,KAAK;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;QACjH,MAAM,EAAE,CAAC,OAAO,EAAE;YAChB,aAAa,EAAE,wBAAwB,CAAC;YACxC,QAAQ,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,MAAM,EAAE,MAAM,CAAA;aAAE,CAAC;YAC5C,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;SAC9D,KAAK;YAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;SAAE,GAAG,IAAI,CAAC;QAC7D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;KACtB,CAAC,CAAC;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAUF,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;CACjD,CAAC;AAmCF,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,4CAsK9D,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from '@alveole/components';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { useStyles } from './DocumentViewer.styles';
|
|
5
|
+
const isPdfCancellationError = (error) => {
|
|
6
|
+
if (!(error instanceof Error))
|
|
7
|
+
return false;
|
|
8
|
+
return (['RenderingCancelledException', 'AbortException', 'UnknownErrorException'].includes(error.name) ||
|
|
9
|
+
error.message.includes('Worker was terminated'));
|
|
10
|
+
};
|
|
11
|
+
const loadPdfJs = (() => {
|
|
12
|
+
let promise = null;
|
|
13
|
+
return () => {
|
|
14
|
+
if (typeof window === 'undefined') {
|
|
15
|
+
return Promise.reject(new Error('PDF.js is only available in the browser.'));
|
|
16
|
+
}
|
|
17
|
+
if (promise)
|
|
18
|
+
return promise;
|
|
19
|
+
const dynamicImport = new Function('url', 'return import(url);');
|
|
20
|
+
promise = dynamicImport('/pdf.min.mjs').then(module => {
|
|
21
|
+
const pdfjs = (module.default ?? module);
|
|
22
|
+
pdfjs.GlobalWorkerOptions.workerSrc = `${window.location.origin}/pdf.worker.min.mjs`;
|
|
23
|
+
return pdfjs;
|
|
24
|
+
});
|
|
25
|
+
return promise;
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
export const DocumentViewerPDF = (props) => {
|
|
29
|
+
const { source, page, rotation, height = '100%', scale = 1, onReady } = props;
|
|
30
|
+
const styles = useStyles();
|
|
31
|
+
const [pdf, setPdf] = React.useState(null);
|
|
32
|
+
const [viewerSize, setViewerSize] = React.useState({ width: 0, height: 0 });
|
|
33
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
34
|
+
const [transformOrigin, setTransformOrigin] = React.useState('50% 50%');
|
|
35
|
+
const [renderedPageSize, setRenderedPageSize] = React.useState({ width: 0, height: 0 });
|
|
36
|
+
const canvasRef = React.useRef(null);
|
|
37
|
+
const onReadyRef = React.useRef(onReady);
|
|
38
|
+
const hoveredScale = isHovered ? 2 : 1;
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
onReadyRef.current = onReady;
|
|
41
|
+
}, [onReady]);
|
|
42
|
+
const onPdfLoadedSuccess = React.useCallback((documentPdf, active) => {
|
|
43
|
+
if (!active)
|
|
44
|
+
return void documentPdf.destroy?.();
|
|
45
|
+
setPdf(currentPdf => {
|
|
46
|
+
void currentPdf?.destroy?.();
|
|
47
|
+
return documentPdf;
|
|
48
|
+
});
|
|
49
|
+
onReadyRef.current?.(documentPdf);
|
|
50
|
+
}, []);
|
|
51
|
+
const onPdfLoadedError = React.useCallback((active) => {
|
|
52
|
+
if (!active)
|
|
53
|
+
return;
|
|
54
|
+
setPdf(null);
|
|
55
|
+
}, []);
|
|
56
|
+
const onPageLoadedSuccess = React.useCallback(async (pagePdf, active) => {
|
|
57
|
+
if (!active || !canvasRef.current)
|
|
58
|
+
return null;
|
|
59
|
+
const baseViewport = pagePdf.getViewport({ scale: 1, rotation });
|
|
60
|
+
const fittedScale = Math.min(viewerSize.width / baseViewport.width, viewerSize.height / baseViewport.height);
|
|
61
|
+
const viewport = pagePdf.getViewport({ scale: fittedScale * scale, rotation });
|
|
62
|
+
const canvas = canvasRef.current;
|
|
63
|
+
const context = canvas.getContext('2d');
|
|
64
|
+
if (context == null)
|
|
65
|
+
return null;
|
|
66
|
+
const pixelRatio = window.devicePixelRatio || 1;
|
|
67
|
+
canvas.width = Math.floor(viewport.width * pixelRatio);
|
|
68
|
+
canvas.height = Math.floor(viewport.height * pixelRatio);
|
|
69
|
+
canvas.style.width = `${viewport.width}px`;
|
|
70
|
+
canvas.style.height = `${viewport.height}px`;
|
|
71
|
+
setRenderedPageSize({ width: viewport.width, height: viewport.height });
|
|
72
|
+
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
73
|
+
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
74
|
+
return pagePdf.render({
|
|
75
|
+
canvasContext: context,
|
|
76
|
+
viewport,
|
|
77
|
+
transform: pixelRatio === 1 ? undefined : [pixelRatio, 0, 0, pixelRatio, 0, 0],
|
|
78
|
+
});
|
|
79
|
+
}, [rotation, scale, viewerSize.height, viewerSize.width]);
|
|
80
|
+
React.useEffect(() => {
|
|
81
|
+
let isActive = true;
|
|
82
|
+
let loadingTask = null;
|
|
83
|
+
loadPdfJs()
|
|
84
|
+
.then(pdfjs => {
|
|
85
|
+
if (!isActive)
|
|
86
|
+
return;
|
|
87
|
+
loadingTask = pdfjs.getDocument(source);
|
|
88
|
+
return loadingTask.promise
|
|
89
|
+
.then(nextPdf => onPdfLoadedSuccess(nextPdf, isActive))
|
|
90
|
+
.catch(error => {
|
|
91
|
+
if (!isActive || isPdfCancellationError(error))
|
|
92
|
+
return;
|
|
93
|
+
onPdfLoadedError(true);
|
|
94
|
+
});
|
|
95
|
+
})
|
|
96
|
+
.catch(error => {
|
|
97
|
+
if (!isActive || isPdfCancellationError(error))
|
|
98
|
+
return;
|
|
99
|
+
onPdfLoadedError(true);
|
|
100
|
+
});
|
|
101
|
+
return () => {
|
|
102
|
+
isActive = false;
|
|
103
|
+
loadingTask?.destroy();
|
|
104
|
+
};
|
|
105
|
+
}, [source, onPdfLoadedError, onPdfLoadedSuccess]);
|
|
106
|
+
React.useEffect(() => {
|
|
107
|
+
if (!pdf || !canvasRef.current || viewerSize.width <= 0 || viewerSize.height <= 0)
|
|
108
|
+
return;
|
|
109
|
+
let isActive = true;
|
|
110
|
+
let renderTask = null;
|
|
111
|
+
pdf
|
|
112
|
+
.getPage(page)
|
|
113
|
+
.then(async (pdfPage) => {
|
|
114
|
+
renderTask = await onPageLoadedSuccess(pdfPage, isActive);
|
|
115
|
+
return renderTask?.promise.then(() => {
|
|
116
|
+
if (!isActive)
|
|
117
|
+
return;
|
|
118
|
+
pdfPage.cleanup?.();
|
|
119
|
+
});
|
|
120
|
+
})
|
|
121
|
+
.catch(error => {
|
|
122
|
+
if (!isActive || isPdfCancellationError(error))
|
|
123
|
+
return;
|
|
124
|
+
onPdfLoadedError(true);
|
|
125
|
+
});
|
|
126
|
+
return () => {
|
|
127
|
+
isActive = false;
|
|
128
|
+
renderTask?.cancel?.();
|
|
129
|
+
};
|
|
130
|
+
}, [pdf, page, rotation, scale, viewerSize, onPageLoadedSuccess, onPdfLoadedError]);
|
|
131
|
+
const handleLayout = React.useCallback((event) => {
|
|
132
|
+
const nextWidth = event?.nativeEvent?.layout?.width;
|
|
133
|
+
const nextHeight = event?.nativeEvent?.layout?.height;
|
|
134
|
+
if (typeof nextWidth === 'number' && nextWidth > 0 && typeof nextHeight === 'number' && nextHeight > 0) {
|
|
135
|
+
setViewerSize({ width: nextWidth, height: nextHeight });
|
|
136
|
+
}
|
|
137
|
+
}, []);
|
|
138
|
+
const handlePointerMove = React.useCallback((event) => {
|
|
139
|
+
const rect = event.currentTarget?.getBoundingClientRect?.();
|
|
140
|
+
if (!rect)
|
|
141
|
+
return;
|
|
142
|
+
const x = ((event.clientX - rect.left) / rect.width) * 100;
|
|
143
|
+
const y = ((event.clientY - rect.top) / rect.height) * 100;
|
|
144
|
+
setTransformOrigin(`${Math.max(0, Math.min(100, x))}% ${Math.max(0, Math.min(100, y))}%`);
|
|
145
|
+
}, []);
|
|
146
|
+
React.useEffect(() => () => void pdf?.destroy?.(), [pdf]);
|
|
147
|
+
return (_jsx(Box, { tag: "document-viewer-pdf", width: '100%', height: height, onLayout: handleLayout, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), onPointerEnter: () => setIsHovered(true), onPointerLeave: () => setIsHovered(false), onPointerMove: handlePointerMove, style: styles.viewerPdfContent, children: _jsx(Box, { width: '100%', height: '100%', p: '1V', style: styles.viewerPdfStage, children: _jsx(Box, { style: [
|
|
148
|
+
styles.viewerPdfCanvasWrapper,
|
|
149
|
+
{
|
|
150
|
+
width: renderedPageSize.width,
|
|
151
|
+
height: renderedPageSize.height,
|
|
152
|
+
transformOrigin,
|
|
153
|
+
transform: [{ scale: hoveredScale }],
|
|
154
|
+
},
|
|
155
|
+
], children: _jsx("canvas", { ref: canvasRef, style: styles.viewerPdfCanvas }) }) }) }));
|
|
156
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../src/ui/ListItem/ListItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAO,QAAQ,EAAqB,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAU,WAAW,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,SAAS,EAAc,MAAM,eAAe,CAAC;AAGtD,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,cAAc,GAAG,KAAK,CAAC,CAAC;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,KAAK,CAAC,SAAS,CAAC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO,aAAa,
|
|
1
|
+
{"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../src/ui/ListItem/ListItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAO,QAAQ,EAAqB,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAU,WAAW,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,SAAS,EAAc,MAAM,eAAe,CAAC;AAGtD,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,cAAc,GAAG,KAAK,CAAC,CAAC;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,KAAK,CAAC,SAAS,CAAC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO,aAAa,4CA6D5C,CAAC"}
|
|
@@ -7,5 +7,5 @@ import { useStyles } from './ListItem.styles';
|
|
|
7
7
|
export const ListItem = (props) => {
|
|
8
8
|
const { children, title, description, style, AvatarProps, IconProps, preview_url, trailing, loading = false, showSeparateur = true, ...itemProps } = props;
|
|
9
9
|
const styles = useStyles();
|
|
10
|
-
return (_jsxs(Box, { children: [_jsxs(Box, { tag: "resource-item", style: [styles.item, style], hoverStyle: styles.itemHover, ...itemProps, children: [preview_url ? (_jsx(Box, { style: styles.previewContainer, children: _jsx(Image, { source: { uri: preview_url }, width: styles.preview.width, height: styles.preview.height, contentFit: "contain" }) })) : (_jsxs(_Fragment, { children: [IconProps && _jsx(LucideIcon, { size: "sm", color: styles.defaultIcon.color, ...IconProps }), AvatarProps && _jsx(Avatar, { size: "xs", ...AvatarProps })] })), _jsxs(Box, { style: styles.detail, children: [showSeparateur && _jsx(Box, { style: styles.separateur }), _jsxs(Box, { style: styles.principal, children: [_jsx(Typography, { style: styles.title, children: title }), description && _jsx(Typography, { style: styles.description, children: description })] }), trailing && trailing()] }), loading && (_jsx(Box, { style: styles.loading, children: _jsx(ActivityIndicator, { size: "small", color: styles.loading.color }) }))] }), children] }));
|
|
10
|
+
return (_jsxs(Box, { children: [_jsxs(Box, { tag: "resource-item", style: [styles.item, style], hoverStyle: itemProps['onPress'] ? styles.itemHover : {}, ...itemProps, children: [preview_url ? (_jsx(Box, { style: styles.previewContainer, children: _jsx(Image, { source: { uri: preview_url }, width: styles.preview.width, height: styles.preview.height, contentFit: "contain" }) })) : (_jsxs(_Fragment, { children: [IconProps && _jsx(LucideIcon, { size: "sm", color: styles.defaultIcon.color, ...IconProps }), AvatarProps && _jsx(Avatar, { size: "xs", ...AvatarProps })] })), _jsxs(Box, { style: styles.detail, children: [showSeparateur && _jsx(Box, { style: styles.separateur }), _jsxs(Box, { style: styles.principal, children: [_jsx(Typography, { style: styles.title, children: title }), description && _jsx(Typography, { style: styles.description, children: description })] }), trailing && trailing()] }), loading && (_jsx(Box, { style: styles.loading, children: _jsx(ActivityIndicator, { size: "small", color: styles.loading.color }) }))] }), children] }));
|
|
11
11
|
};
|
|
@@ -101,4 +101,5 @@ export declare const WithoutSeparator: () => import("react/jsx-runtime").JSX.Ele
|
|
|
101
101
|
export declare const WithIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
102
102
|
export declare const WithAvatar: () => import("react/jsx-runtime").JSX.Element;
|
|
103
103
|
export declare const WithPreviewImage: () => import("react/jsx-runtime").JSX.Element;
|
|
104
|
+
export declare const withoutHover: import("react/jsx-runtime").JSX.Element;
|
|
104
105
|
//# sourceMappingURL=ListItem.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.stories.d.ts","sourceRoot":"","sources":["../../../src/ui/ListItem/ListItem.stories.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ListItem.stories.d.ts","sourceRoot":"","sources":["../../../src/ui/ListItem/ListItem.stories.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,wBAQkB;AAElB,eAAO,MAAM,OAAO,+CAQnB,CAAC;AAEF,eAAO,MAAM,YAAY,+CASxB,CAAC;AAEF,eAAO,MAAM,WAAW,+CASvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,+CAS5B,CAAC;AAEF,eAAO,MAAM,QAAQ,+CASpB,CAAC;AAEF,eAAO,MAAM,UAAU,+CAYtB,CAAC;AAEF,eAAO,MAAM,gBAAgB,+CAS5B,CAAC;AAEF,eAAO,MAAM,YAAY,yCAKxB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Typography } from '../../core';
|
|
2
3
|
import { ButtonIcon } from '../Button';
|
|
3
4
|
import { ListItem } from './ListItem';
|
|
4
5
|
import { useStyles } from './ListItem.styles';
|
|
@@ -11,13 +12,28 @@ export default {
|
|
|
11
12
|
component: ListItem,
|
|
12
13
|
styleFn: useStyles,
|
|
13
14
|
};
|
|
14
|
-
export const Default = () => _jsx(ListItem, { title: "Titre", description: "Description"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export const
|
|
18
|
-
|
|
15
|
+
export const Default = () => (_jsx(ListItem, { title: "Titre", description: "Description", onPress: () => {
|
|
16
|
+
window.alert('click !');
|
|
17
|
+
} }));
|
|
18
|
+
export const WithTrailing = () => (_jsx(ListItem, { title: "Titre", description: "Description", trailing: () => _jsx(ButtonIcon, { variant: "tertiary", icon: "CircleX", onPress: () => console.log('remove') }), onPress: () => {
|
|
19
|
+
window.alert('click !');
|
|
20
|
+
} }));
|
|
21
|
+
export const WithLoading = () => (_jsx(ListItem, { title: "Titre", description: "Description", loading: true, onPress: () => {
|
|
22
|
+
window.alert('click !');
|
|
23
|
+
} }));
|
|
24
|
+
export const WithoutSeparator = () => (_jsx(ListItem, { title: "Titre", description: "Description", showSeparateur: false, onPress: () => {
|
|
25
|
+
window.alert('click !');
|
|
26
|
+
} }));
|
|
27
|
+
export const WithIcon = () => (_jsx(ListItem, { title: "Titre", description: "Description", IconProps: { name: 'Settings', color: 'primary' }, onPress: () => {
|
|
28
|
+
window.alert('click !');
|
|
29
|
+
} }));
|
|
19
30
|
export const WithAvatar = () => (_jsx(ListItem, { title: "Titre", description: "Description", AvatarProps: {
|
|
20
31
|
fallbackText: 'Jean Pierre',
|
|
21
32
|
src: 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=400',
|
|
33
|
+
}, onPress: () => {
|
|
34
|
+
window.alert('click !');
|
|
35
|
+
} }));
|
|
36
|
+
export const WithPreviewImage = () => (_jsx(ListItem, { title: "Titre", description: "Description", preview_url: "https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=400", onPress: () => {
|
|
37
|
+
window.alert('click !');
|
|
22
38
|
} }));
|
|
23
|
-
export const
|
|
39
|
+
export const withoutHover = (_jsxs(Box, { children: [_jsx(Typography, { children: "Sans props openPress, l\u2019effet de Hover n\u2019apparait pas" }), _jsx(ListItem, { title: "Titre", description: "Description" })] }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alveole/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "Shared UI components.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,16 +13,19 @@
|
|
|
13
13
|
"types": "./dist/stories/index.d.ts",
|
|
14
14
|
"default": "./dist/stories/index.js"
|
|
15
15
|
},
|
|
16
|
-
"./package.json": "./package.json"
|
|
16
|
+
"./package.json": "./package.json",
|
|
17
|
+
"./sync-pdfjs-web-assets": "./dist/scripts/sync-pdfjs-web-assets.mjs"
|
|
17
18
|
},
|
|
18
19
|
"files": [
|
|
19
20
|
"dist",
|
|
21
|
+
"scripts/postinstall.mjs",
|
|
20
22
|
"README.md"
|
|
21
23
|
],
|
|
22
24
|
"sideEffects": false,
|
|
23
25
|
"scripts": {
|
|
24
|
-
"build": "tsc -p tsconfig.build.json",
|
|
26
|
+
"build": "tsc -p tsconfig.build.json && node ./scripts/prepare-pdfjs-web-assets.mjs",
|
|
25
27
|
"lint": "eslint .",
|
|
28
|
+
"postinstall": "node ./scripts/postinstall.mjs",
|
|
26
29
|
"typecheck": "tsc -p tsconfig.typecheck.json --noEmit"
|
|
27
30
|
},
|
|
28
31
|
"devDependencies": {
|
|
@@ -62,7 +65,7 @@
|
|
|
62
65
|
"expo-linear-gradient": "*",
|
|
63
66
|
"expo-constants": "*",
|
|
64
67
|
"lottie-react-native": "*",
|
|
65
|
-
"pdfjs-dist": "^
|
|
68
|
+
"pdfjs-dist": "^4.0.0",
|
|
66
69
|
"@lottiefiles/dotlottie-react": "*"
|
|
67
70
|
},
|
|
68
71
|
"publishConfig": {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { copyFileSync, existsSync, mkdirSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
const packageRoot = resolve(import.meta.dirname, '..');
|
|
5
|
+
const projectRoot = process.env.INIT_CWD ? resolve(process.env.INIT_CWD) : null;
|
|
6
|
+
|
|
7
|
+
if (projectRoot == null || projectRoot === packageRoot) {
|
|
8
|
+
process.exit(0);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const files = [
|
|
12
|
+
['dist/pdfjs/pdf.min.mjs', 'public/pdf.min.mjs'],
|
|
13
|
+
['dist/pdfjs/pdf.worker.min.mjs', 'public/pdf.worker.min.mjs'],
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
for (const [source, target] of files) {
|
|
17
|
+
const absoluteSource = resolve(packageRoot, source);
|
|
18
|
+
if (!existsSync(absoluteSource)) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const absoluteTarget = resolve(projectRoot, target);
|
|
23
|
+
mkdirSync(dirname(absoluteTarget), { recursive: true });
|
|
24
|
+
copyFileSync(absoluteSource, absoluteTarget);
|
|
25
|
+
console.log(`synced ${target}`);
|
|
26
|
+
}
|