@pdfme/ui 3.0.1 → 3.1.0-dev.1
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/__mocks__/assetsTransformer.js +7 -0
- package/__mocks__/pdfjs-dist.js +15 -0
- package/dist/__vite-browser-external-jWVCDlBL.js +4 -0
- package/dist/index.js +1115 -3
- package/dist/path2d-polyfill.esm-yIGK7UQJ.js +214 -0
- package/dist/style.css +1 -0
- package/dist/types/class.d.ts +3 -3
- package/dist/types/components/AppContextProvider.d.ts +11 -0
- package/dist/types/components/{CtlBar/index.d.ts → CtlBar.d.ts} +2 -2
- package/dist/types/components/Designer/Canvas/Selecto.d.ts +3 -2
- package/dist/types/components/Designer/Sidebar/DetailView/AlignWidget.d.ts +1 -1
- package/dist/types/components/Designer/Sidebar/ListView/SelectableSortableContainer.d.ts +1 -1
- package/dist/types/components/Renderer.d.ts +1 -1
- package/dist/types/components/UnitPager.d.ts +1 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/contexts.d.ts +46 -4
- package/dist/types/helper.d.ts +2 -1
- package/dist/types/hooks.d.ts +19 -2
- package/dist/types/i18n.d.ts +3 -27
- package/dist/types/theme.d.ts +2 -0
- package/package.json +17 -11
- package/src/Designer.tsx +27 -53
- package/src/Form.tsx +22 -23
- package/src/Viewer.tsx +10 -11
- package/src/class.ts +5 -5
- package/src/components/AppContextProvider.tsx +63 -0
- package/src/components/CtlBar.tsx +125 -0
- package/src/components/Designer/Canvas/Guides.tsx +18 -23
- package/src/components/Designer/Canvas/Mask.tsx +2 -1
- package/src/components/Designer/Canvas/Moveable.tsx +60 -60
- package/src/components/Designer/Canvas/Selecto.tsx +33 -20
- package/src/components/Designer/Canvas/index.tsx +21 -15
- package/src/components/Designer/Sidebar/DetailView/AlignWidget.tsx +53 -89
- package/src/components/Designer/Sidebar/DetailView/index.tsx +41 -30
- package/src/components/Designer/Sidebar/ListView/Item.tsx +30 -19
- package/src/components/Designer/Sidebar/ListView/SelectableSortableContainer.tsx +9 -6
- package/src/components/Designer/Sidebar/ListView/SelectableSortableItem.tsx +4 -1
- package/src/components/Designer/Sidebar/ListView/index.tsx +76 -71
- package/src/components/Designer/Sidebar/index.tsx +25 -49
- package/src/components/Designer/index.tsx +24 -82
- package/src/components/ErrorScreen.tsx +13 -11
- package/src/components/Preview.tsx +5 -2
- package/src/components/Renderer.tsx +10 -6
- package/src/components/Root.tsx +2 -8
- package/src/components/Spinner.tsx +12 -31
- package/src/components/UnitPager.tsx +72 -55
- package/src/constants.ts +2 -0
- package/src/contexts.ts +4 -5
- package/src/helper.ts +8 -5
- package/src/hooks.ts +136 -3
- package/src/i18n.ts +168 -59
- package/src/theme.ts +20 -0
- package/tsconfig.json +35 -13
- package/vite.config.ts +27 -0
- package/dist/index.js.LICENSE.txt +0 -142
- package/dist/index.js.map +0 -1
- package/dist/types/components/CtlBar/Pager.d.ts +0 -8
- package/dist/types/components/CtlBar/Zoom.d.ts +0 -7
- package/dist/types/components/Divider.d.ts +0 -3
- package/src/components/CtlBar/Pager.tsx +0 -53
- package/src/components/CtlBar/Zoom.tsx +0 -56
- package/src/components/CtlBar/index.tsx +0 -46
- package/src/components/Divider.tsx +0 -7
- package/webpack.config.js +0 -40
@@ -1,53 +0,0 @@
|
|
1
|
-
import React, { useContext } from 'react';
|
2
|
-
import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/24/outline';
|
3
|
-
import { I18nContext } from '../../contexts';
|
4
|
-
|
5
|
-
const btnStyle: React.CSSProperties = {
|
6
|
-
cursor: 'pointer',
|
7
|
-
border: 'none',
|
8
|
-
background: 'none',
|
9
|
-
display: 'flex',
|
10
|
-
alignItems: 'center',
|
11
|
-
};
|
12
|
-
|
13
|
-
type Props = {
|
14
|
-
pageCursor: number;
|
15
|
-
pageNum: number;
|
16
|
-
setPageCursor: (page: number) => void;
|
17
|
-
};
|
18
|
-
|
19
|
-
const Pager = ({ pageCursor, pageNum, setPageCursor }: Props) => {
|
20
|
-
const i18n = useContext(I18nContext);
|
21
|
-
|
22
|
-
return (
|
23
|
-
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
24
|
-
<button
|
25
|
-
style={{
|
26
|
-
paddingLeft: '0.5rem',
|
27
|
-
...btnStyle,
|
28
|
-
cursor: pageCursor <= 0 ? 'not-allowed' : 'pointer',
|
29
|
-
}}
|
30
|
-
disabled={pageCursor <= 0}
|
31
|
-
onClick={() => setPageCursor(pageCursor - 1)}
|
32
|
-
>
|
33
|
-
<ChevronLeftIcon width={20} height={20} color={'#fff'} />
|
34
|
-
</button>
|
35
|
-
<strong style={{ color: 'white', fontSize: '0.9rem', minWidth: 45, textAlign: 'center' }}>
|
36
|
-
{pageCursor + 1}/{pageNum}
|
37
|
-
</strong>
|
38
|
-
<button
|
39
|
-
style={{
|
40
|
-
paddingRight: '0.5rem',
|
41
|
-
...btnStyle,
|
42
|
-
cursor: pageCursor + 1 >= pageNum ? 'not-allowed' : 'pointer',
|
43
|
-
}}
|
44
|
-
disabled={pageCursor + 1 >= pageNum}
|
45
|
-
onClick={() => setPageCursor(pageCursor + 1)}
|
46
|
-
>
|
47
|
-
<ChevronRightIcon width={20} height={20} color={'#fff'} />
|
48
|
-
</button>
|
49
|
-
</div>
|
50
|
-
);
|
51
|
-
};
|
52
|
-
|
53
|
-
export default Pager;
|
@@ -1,56 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { MinusIcon, PlusIcon } from '@heroicons/react/24/outline';
|
3
|
-
|
4
|
-
const btnStyle: React.CSSProperties = {
|
5
|
-
cursor: 'pointer',
|
6
|
-
border: 'none',
|
7
|
-
background: 'none',
|
8
|
-
display: 'flex',
|
9
|
-
alignItems: 'center',
|
10
|
-
};
|
11
|
-
|
12
|
-
const zoomStep = 0.25;
|
13
|
-
const maxZoom = 2;
|
14
|
-
const minZoom = 0.25;
|
15
|
-
|
16
|
-
type Props = {
|
17
|
-
zoomLevel: number;
|
18
|
-
setZoomLevel: (zoom: number) => void;
|
19
|
-
};
|
20
|
-
|
21
|
-
const Pager = ({ zoomLevel, setZoomLevel }: Props) => {
|
22
|
-
const nextZoomOut = zoomLevel - zoomStep;
|
23
|
-
const nextZoomIn = zoomLevel + zoomStep;
|
24
|
-
|
25
|
-
return (
|
26
|
-
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
27
|
-
<button
|
28
|
-
style={{
|
29
|
-
paddingLeft: '0.5rem',
|
30
|
-
...btnStyle,
|
31
|
-
cursor: minZoom >= nextZoomOut ? 'not-allowed' : 'pointer',
|
32
|
-
}}
|
33
|
-
disabled={minZoom >= nextZoomOut}
|
34
|
-
onClick={() => setZoomLevel(nextZoomOut)}
|
35
|
-
>
|
36
|
-
<MinusIcon width={20} height={20} color={'#fff'} />
|
37
|
-
</button>
|
38
|
-
<strong style={{ color: 'white', fontSize: '0.9rem', minWidth: 50, textAlign: 'center' }}>
|
39
|
-
{Math.round(zoomLevel * 100)}%
|
40
|
-
</strong>
|
41
|
-
<button
|
42
|
-
style={{
|
43
|
-
paddingRight: '0.5rem',
|
44
|
-
...btnStyle,
|
45
|
-
cursor: maxZoom < nextZoomIn ? 'not-allowed' : 'pointer',
|
46
|
-
}}
|
47
|
-
disabled={maxZoom < nextZoomIn}
|
48
|
-
onClick={() => setZoomLevel(nextZoomIn)}
|
49
|
-
>
|
50
|
-
<PlusIcon width={20} height={20} color={'#fff'} />
|
51
|
-
</button>
|
52
|
-
</div>
|
53
|
-
);
|
54
|
-
};
|
55
|
-
|
56
|
-
export default Pager;
|
@@ -1,46 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import Pager from './Pager';
|
3
|
-
import Zoom from './Zoom';
|
4
|
-
import { Size } from '@pdfme/common';
|
5
|
-
|
6
|
-
type Props = {
|
7
|
-
size: Size;
|
8
|
-
pageCursor: number;
|
9
|
-
pageNum: number;
|
10
|
-
setPageCursor: (page: number) => void;
|
11
|
-
zoomLevel: number;
|
12
|
-
setZoomLevel: (zoom: number) => void;
|
13
|
-
};
|
14
|
-
|
15
|
-
const barWidth = 250;
|
16
|
-
|
17
|
-
const CtlBar = (props: Props) => {
|
18
|
-
const { size, pageCursor, pageNum, setPageCursor, zoomLevel, setZoomLevel } = props;
|
19
|
-
const width = pageNum > 1 ? barWidth : barWidth / 2;
|
20
|
-
return (
|
21
|
-
<div style={{ position: 'absolute', top: 'auto', bottom: '6%', width: size.width }}>
|
22
|
-
<div
|
23
|
-
style={{
|
24
|
-
display: 'flex',
|
25
|
-
alignItems: 'center',
|
26
|
-
justifyContent: 'center',
|
27
|
-
gap: '15px',
|
28
|
-
position: 'relative',
|
29
|
-
zIndex: 1,
|
30
|
-
left: `calc(50% - ${width / 2}px)`,
|
31
|
-
width,
|
32
|
-
background: '#777777e6',
|
33
|
-
borderRadius: 2,
|
34
|
-
padding: '0.5rem',
|
35
|
-
}}
|
36
|
-
>
|
37
|
-
{pageNum > 1 && (
|
38
|
-
<Pager pageCursor={pageCursor} pageNum={pageNum} setPageCursor={setPageCursor} />
|
39
|
-
)}
|
40
|
-
<Zoom zoomLevel={zoomLevel} setZoomLevel={setZoomLevel} />
|
41
|
-
</div>
|
42
|
-
</div>
|
43
|
-
);
|
44
|
-
};
|
45
|
-
|
46
|
-
export default CtlBar;
|
package/webpack.config.js
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
const path = require('path');
|
2
|
-
const webpack = require('webpack');
|
3
|
-
const pkg = require('./package.json');
|
4
|
-
|
5
|
-
const isProduction = process.env.NODE_ENV === 'production';
|
6
|
-
|
7
|
-
const BANNER = [
|
8
|
-
'@name ' + pkg.name,
|
9
|
-
'@version ' + pkg.version + ' | ' + new Date().toDateString(),
|
10
|
-
'@author ' + pkg.author,
|
11
|
-
'@license ' + pkg.license,
|
12
|
-
].join('\n');
|
13
|
-
|
14
|
-
const config = {
|
15
|
-
optimization: { minimize: isProduction },
|
16
|
-
resolve: {
|
17
|
-
extensions: ['.ts', '.tsx', '.js'],
|
18
|
-
alias: { process: 'process/browser' },
|
19
|
-
},
|
20
|
-
plugins: [
|
21
|
-
// new BundleAnalyzerPlugin(),
|
22
|
-
new webpack.ProvidePlugin({ process: 'process/browser' }),
|
23
|
-
new webpack.BannerPlugin({ banner: BANNER, entryOnly: true }),
|
24
|
-
],
|
25
|
-
devtool: 'source-map',
|
26
|
-
entry: './src/index.ts',
|
27
|
-
output: {
|
28
|
-
path: path.resolve(__dirname, 'dist'),
|
29
|
-
filename: 'index.js',
|
30
|
-
globalObject: 'this',
|
31
|
-
library: { type: 'umd' },
|
32
|
-
},
|
33
|
-
module: {
|
34
|
-
rules: [
|
35
|
-
{ test: /\.tsx?$/, use: 'ts-loader' },
|
36
|
-
{ test: /\.css$/i, use: ['style-loader', 'css-loader'] }
|
37
|
-
]
|
38
|
-
},
|
39
|
-
};
|
40
|
-
module.exports = config;
|