@pyreon/document-primitives 0.11.4 → 0.11.6
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/lib/index.d.ts +1 -1
- package/lib/index.js +11 -11
- package/package.json +34 -33
- package/src/DocumentPreview.ts +24 -24
- package/src/__tests__/primitives-attrs.test.ts +238 -300
- package/src/__tests__/primitives.test.ts +61 -61
- package/src/__tests__/useDocumentExport.test.ts +28 -28
- package/src/index.ts +25 -25
- package/src/primitives/DocButton.ts +17 -17
- package/src/primitives/DocCode.ts +8 -8
- package/src/primitives/DocColumn.ts +5 -5
- package/src/primitives/DocDivider.ts +6 -6
- package/src/primitives/DocDocument.ts +5 -5
- package/src/primitives/DocHeading.ts +9 -9
- package/src/primitives/DocImage.ts +6 -6
- package/src/primitives/DocLink.ts +8 -8
- package/src/primitives/DocList.ts +5 -5
- package/src/primitives/DocListItem.ts +5 -5
- package/src/primitives/DocPage.ts +7 -7
- package/src/primitives/DocPageBreak.ts +5 -5
- package/src/primitives/DocQuote.ts +9 -9
- package/src/primitives/DocRow.ts +6 -6
- package/src/primitives/DocSection.ts +8 -8
- package/src/primitives/DocSpacer.ts +5 -5
- package/src/primitives/DocTable.ts +7 -7
- package/src/primitives/DocText.ts +12 -12
- package/src/theme.ts +11 -11
- package/src/useDocumentExport.ts +3 -3
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Element } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Element } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
|
-
const DocPage = rocketstyle()({ name:
|
|
4
|
+
const DocPage = rocketstyle()({ name: 'DocPage', component: Element })
|
|
5
5
|
.theme({
|
|
6
|
-
backgroundColor:
|
|
7
|
-
padding:
|
|
6
|
+
backgroundColor: '#ffffff',
|
|
7
|
+
padding: '25mm',
|
|
8
8
|
})
|
|
9
|
-
.statics({ _documentType:
|
|
9
|
+
.statics({ _documentType: 'page' as const })
|
|
10
10
|
.attrs<{
|
|
11
11
|
size?: string
|
|
12
12
|
orientation?: string
|
|
13
13
|
tag: string
|
|
14
14
|
_documentProps: Record<string, unknown>
|
|
15
15
|
}>((props) => ({
|
|
16
|
-
tag:
|
|
16
|
+
tag: 'div',
|
|
17
17
|
_documentProps: {
|
|
18
18
|
...(props.size ? { size: props.size } : {}),
|
|
19
19
|
...(props.orientation ? { orientation: props.orientation } : {}),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Element } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Element } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
|
-
const DocPageBreak = rocketstyle()({ name:
|
|
5
|
-
.statics({ _documentType:
|
|
4
|
+
const DocPageBreak = rocketstyle()({ name: 'DocPageBreak', component: Element })
|
|
5
|
+
.statics({ _documentType: 'page-break' as const })
|
|
6
6
|
.attrs<{ tag: string; _documentProps: Record<string, unknown> }>((_props) => ({
|
|
7
|
-
tag:
|
|
7
|
+
tag: 'div',
|
|
8
8
|
_documentProps: {},
|
|
9
9
|
}))
|
|
10
10
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Element } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Element } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
|
-
const DocQuote = rocketstyle()({ name:
|
|
4
|
+
const DocQuote = rocketstyle()({ name: 'DocQuote', component: Element })
|
|
5
5
|
.theme({
|
|
6
|
-
borderColor:
|
|
7
|
-
padding:
|
|
8
|
-
fontStyle:
|
|
9
|
-
color:
|
|
6
|
+
borderColor: '#4f46e5',
|
|
7
|
+
padding: '8px 16px',
|
|
8
|
+
fontStyle: 'italic',
|
|
9
|
+
color: '#666666',
|
|
10
10
|
})
|
|
11
|
-
.statics({ _documentType:
|
|
11
|
+
.statics({ _documentType: 'quote' as const })
|
|
12
12
|
.attrs<{ borderColor?: string; tag: string; _documentProps: Record<string, unknown> }>(
|
|
13
13
|
(props) => ({
|
|
14
|
-
tag:
|
|
14
|
+
tag: 'blockquote',
|
|
15
15
|
_documentProps: props.borderColor ? { borderColor: props.borderColor } : {},
|
|
16
16
|
}),
|
|
17
17
|
)
|
package/src/primitives/DocRow.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Element } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Element } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
|
-
const DocRow = rocketstyle()({ name:
|
|
4
|
+
const DocRow = rocketstyle()({ name: 'DocRow', component: Element })
|
|
5
5
|
.theme({
|
|
6
|
-
direction:
|
|
6
|
+
direction: 'row',
|
|
7
7
|
})
|
|
8
|
-
.statics({ _documentType:
|
|
8
|
+
.statics({ _documentType: 'row' as const })
|
|
9
9
|
.attrs<{ tag: string; _documentProps: Record<string, unknown> }>((_props) => ({
|
|
10
|
-
tag:
|
|
10
|
+
tag: 'div',
|
|
11
11
|
_documentProps: {},
|
|
12
12
|
}))
|
|
13
13
|
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { Element } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Element } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
4
|
const DocSection = rocketstyle({
|
|
5
5
|
dimensions: {
|
|
6
|
-
directions:
|
|
6
|
+
directions: 'direction',
|
|
7
7
|
},
|
|
8
8
|
useBooleans: false,
|
|
9
|
-
})({ name:
|
|
9
|
+
})({ name: 'DocSection', component: Element })
|
|
10
10
|
.theme({
|
|
11
11
|
padding: 0,
|
|
12
12
|
})
|
|
13
13
|
.directions({
|
|
14
14
|
column: {},
|
|
15
|
-
row: { direction:
|
|
15
|
+
row: { direction: 'row' },
|
|
16
16
|
})
|
|
17
|
-
.statics({ _documentType:
|
|
17
|
+
.statics({ _documentType: 'section' as const })
|
|
18
18
|
.attrs<{ direction?: string; tag: string; _documentProps: { direction: string } }>((props) => ({
|
|
19
|
-
tag:
|
|
20
|
-
_documentProps: { direction: props.direction ??
|
|
19
|
+
tag: 'div',
|
|
20
|
+
_documentProps: { direction: props.direction ?? 'column' },
|
|
21
21
|
}))
|
|
22
22
|
|
|
23
23
|
export default DocSection
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Element } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Element } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
|
-
const DocSpacer = rocketstyle()({ name:
|
|
5
|
-
.statics({ _documentType:
|
|
4
|
+
const DocSpacer = rocketstyle()({ name: 'DocSpacer', component: Element })
|
|
5
|
+
.statics({ _documentType: 'spacer' as const })
|
|
6
6
|
.attrs<{ height?: number; tag: string; _documentProps: { height: number } }>((props) => ({
|
|
7
|
-
tag:
|
|
7
|
+
tag: 'div',
|
|
8
8
|
_documentProps: { height: props.height ?? 16 },
|
|
9
9
|
}))
|
|
10
10
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Element } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Element } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
4
|
const DocTable = rocketstyle({
|
|
5
5
|
dimensions: {
|
|
6
|
-
variants:
|
|
6
|
+
variants: 'variant',
|
|
7
7
|
},
|
|
8
8
|
useBooleans: true,
|
|
9
|
-
})({ name:
|
|
9
|
+
})({ name: 'DocTable', component: Element })
|
|
10
10
|
.theme({
|
|
11
11
|
fontSize: 14,
|
|
12
|
-
borderColor:
|
|
12
|
+
borderColor: '#dddddd',
|
|
13
13
|
})
|
|
14
|
-
.statics({ _documentType:
|
|
14
|
+
.statics({ _documentType: 'table' as const })
|
|
15
15
|
.attrs<{
|
|
16
16
|
columns?: unknown[]
|
|
17
17
|
rows?: unknown[]
|
|
@@ -22,7 +22,7 @@ const DocTable = rocketstyle({
|
|
|
22
22
|
tag: string
|
|
23
23
|
_documentProps: Record<string, unknown>
|
|
24
24
|
}>((props) => ({
|
|
25
|
-
tag:
|
|
25
|
+
tag: 'table',
|
|
26
26
|
_documentProps: {
|
|
27
27
|
columns: props.columns ?? [],
|
|
28
28
|
rows: props.rows ?? [],
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { Text } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Text } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
4
|
const DocText = rocketstyle({
|
|
5
5
|
dimensions: {
|
|
6
|
-
variants:
|
|
7
|
-
weights:
|
|
6
|
+
variants: 'variant',
|
|
7
|
+
weights: 'weight',
|
|
8
8
|
},
|
|
9
9
|
useBooleans: true,
|
|
10
|
-
})({ name:
|
|
10
|
+
})({ name: 'DocText', component: Text })
|
|
11
11
|
.theme({
|
|
12
|
-
color:
|
|
12
|
+
color: '#333333',
|
|
13
13
|
lineHeight: 1.5,
|
|
14
14
|
marginBottom: 8,
|
|
15
15
|
})
|
|
16
16
|
.variants({
|
|
17
17
|
body: { fontSize: 14 },
|
|
18
|
-
caption: { fontSize: 12, color:
|
|
19
|
-
label: { fontSize: 11, fontWeight:
|
|
18
|
+
caption: { fontSize: 12, color: '#666666' },
|
|
19
|
+
label: { fontSize: 11, fontWeight: 'bold' },
|
|
20
20
|
})
|
|
21
21
|
.weights({
|
|
22
|
-
normal: { fontWeight:
|
|
23
|
-
bold: { fontWeight:
|
|
22
|
+
normal: { fontWeight: 'normal' },
|
|
23
|
+
bold: { fontWeight: 'bold' },
|
|
24
24
|
})
|
|
25
|
-
.statics({ _documentType:
|
|
25
|
+
.statics({ _documentType: 'text' as const })
|
|
26
26
|
// .attrs(
|
|
27
27
|
// (props: any) =>
|
|
28
28
|
// ({
|
|
29
29
|
// tag: "p",
|
|
30
30
|
.attrs<{ tag: string; _documentProps: Record<string, unknown> }>((_props) => ({
|
|
31
|
-
tag:
|
|
31
|
+
tag: 'p',
|
|
32
32
|
_documentProps: {},
|
|
33
33
|
}))
|
|
34
34
|
|
package/src/theme.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
export const documentTheme = {
|
|
2
2
|
colors: {
|
|
3
|
-
primary:
|
|
4
|
-
text:
|
|
5
|
-
textSecondary:
|
|
6
|
-
background:
|
|
7
|
-
border:
|
|
8
|
-
headerBg:
|
|
9
|
-
headerText:
|
|
10
|
-
stripedRow:
|
|
3
|
+
primary: '#4f46e5',
|
|
4
|
+
text: '#333333',
|
|
5
|
+
textSecondary: '#666666',
|
|
6
|
+
background: '#ffffff',
|
|
7
|
+
border: '#dddddd',
|
|
8
|
+
headerBg: '#1a1a2e',
|
|
9
|
+
headerText: '#ffffff',
|
|
10
|
+
stripedRow: '#f9f9f9',
|
|
11
11
|
},
|
|
12
12
|
fonts: {
|
|
13
|
-
heading:
|
|
14
|
-
body:
|
|
15
|
-
mono:
|
|
13
|
+
heading: 'system-ui, -apple-system, sans-serif',
|
|
14
|
+
body: 'system-ui, -apple-system, sans-serif',
|
|
15
|
+
mono: 'ui-monospace, monospace',
|
|
16
16
|
},
|
|
17
17
|
sizes: {
|
|
18
18
|
h1: 32,
|
package/src/useDocumentExport.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { DocNode, ExtractOptions } from
|
|
2
|
-
import { extractDocumentTree } from
|
|
1
|
+
import type { DocNode, ExtractOptions } from '@pyreon/connector-document'
|
|
2
|
+
import { extractDocumentTree } from '@pyreon/connector-document'
|
|
3
3
|
|
|
4
4
|
export interface DocumentExportOptions extends ExtractOptions {
|
|
5
5
|
/** Theme object to provide during extraction. */
|
|
6
6
|
theme?: Record<string, unknown>
|
|
7
7
|
/** Mode: 'light' or 'dark'. */
|
|
8
|
-
mode?:
|
|
8
|
+
mode?: 'light' | 'dark'
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface DocumentExport {
|