Skip to content

Commit e257f7e

Browse files
committed
fix: font store types
1 parent b95a6dc commit e257f7e

File tree

44 files changed

+2693
-19
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2693
-19
lines changed

.changeset/wet-wasps-doubt.md

+6
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
declare module '*.jpg' {
2+
const src: string;
3+
export default src;
4+
}
5+
6+
declare module '*.jpeg' {
7+
const src: string;
8+
export default src;
9+
}
10+
11+
declare module '*.png' {
12+
const src: string;
13+
export default src;
14+
}
15+
16+
declare module '*.ttf' {
17+
const src: string;
18+
export default src;
19+
}

packages/examples/vite/src/examples/svg/Pattern.tsx

+2,623
Large diffs are not rendered by default.

packages/examples/vite/src/examples/svg/index.jsx packages/examples/vite/src/examples/svg/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Svg2 from './Svg2';
77
import Svg4 from './Svg4';
88
import Star from './Star';
99
import Heart from './Heart';
10+
import Pattern from './Pattern';
1011

1112
const styles = StyleSheet.create({
1213
page: {
@@ -26,6 +27,7 @@ const App = () => {
2627
<Svg2 />
2728
<Svg4 />
2829
<Heart />
30+
<Pattern />
2931
</Page>
3032
</Document>
3133
);

packages/examples/vite/src/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
</head>
99
<body>
1010
<div id="root"></div>
11-
<script type="module" src="/index.jsx"></script>
11+
<script type="module" src="/index.tsx"></script>
1212
</body>
1313
</html>
File renamed without changes.

packages/font/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class FontStore {
200200
getRegisteredFontFamilies = (): string[] => Object.keys(this.fontFamilies);
201201
}
202202

203-
export type FontStoreType = typeof FontStore;
203+
export type FontStoreType = FontStore;
204204

205205
export * from './types';
206206

packages/layout/src/types/document.ts

+39-2
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,59 @@ import * as P from '@react-pdf/primitives';
22

33
import { PageNode, SafePageNode } from './page';
44
import { YogaInstance } from './base';
5+
import { SafeStyle, Style } from '@react-pdf/stylesheet';
6+
7+
export type PDFVersion = '1.3' | '1.4' | '1.5' | '1.6' | '1.7' | '1.7ext3';
8+
9+
export type PageLayout =
10+
| 'singlePage'
11+
| 'oneColumn'
12+
| 'twoColumnLeft'
13+
| 'twoColumnRight'
14+
| 'twoPageLeft'
15+
| 'twoPageRight';
16+
17+
export type PageMode =
18+
| 'useNone'
19+
| 'useOutlines'
20+
| 'useThumbs'
21+
| 'fullScreen'
22+
| 'useOC'
23+
| 'useAttachments';
24+
25+
export interface OnRenderProps {
26+
blob?: Blob;
27+
}
528

629
export type DocumentProps = {
730
bookmark?: never;
31+
title?: string;
32+
author?: string;
33+
subject?: string;
34+
creator?: string;
35+
keywords?: string;
36+
producer?: string;
37+
language?: string;
38+
creationDate?: Date;
39+
modificationDate?: Date;
40+
pdfVersion?: PDFVersion;
41+
pageMode?: PageMode;
42+
pageLayout?: PageLayout;
43+
onRender?: (props: OnRenderProps) => any;
844
};
945

1046
export type DocumentNode = {
1147
type: typeof P.Document;
1248
props: DocumentProps;
1349
box?: never;
1450
origin?: never;
15-
style?: never;
51+
style?: Style | Style[];
1652
yoga?: YogaInstance;
1753
yogaNode?: never;
1854
children: PageNode[];
1955
};
2056

21-
export type SafeDocumentNode = Omit<DocumentNode, 'children'> & {
57+
export type SafeDocumentNode = Omit<DocumentNode, 'style' | 'children'> & {
58+
style: SafeStyle;
2259
children: SafePageNode[];
2360
};

packages/layout/src/types/select.ts

+1-15
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,14 @@ import { YogaNode } from 'yoga-layout/load';
44

55
import { Box, FormCommonProps, Origin } from './base';
66

7-
interface SelectAndListPropsBase extends FormCommonProps {
7+
interface SelectAndListProps extends FormCommonProps {
88
sort?: boolean;
99
edit?: boolean;
1010
multiSelect?: boolean;
1111
noSpell?: boolean;
1212
select?: string[];
1313
}
1414

15-
type SelectAndListPropsWithEdit = SelectAndListPropsBase & {
16-
edit: true | false;
17-
noSpell: boolean;
18-
};
19-
20-
type SelectAndListPropsWithNoSpell = SelectAndListPropsBase & {
21-
edit: boolean;
22-
noSpell: true | false;
23-
};
24-
25-
type SelectAndListProps =
26-
| SelectAndListPropsWithEdit
27-
| SelectAndListPropsWithNoSpell;
28-
2915
export type SelectNode = {
3016
type: typeof P.Select;
3117
props: SelectAndListProps;

packages/layout/src/types/text-input.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ interface TextInputFormatting {
2222
currency?: string;
2323
currencyPrepend?: boolean;
2424
}
25+
2526
// see http://pdfkit.org/docs/forms.html#text_field_formatting
2627
interface TextInputProps extends FormCommonProps {
2728
align?: 'left' | 'center' | 'right';

0 commit comments

Comments
 (0)