@pyreon/document-primitives 0.11.1 → 0.11.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyreon/document-primitives",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/pyreon/pyreon",
@@ -24,7 +24,8 @@
24
24
  "!lib/**/*.map",
25
25
  "!lib/analysis",
26
26
  "README.md",
27
- "LICENSE"
27
+ "LICENSE",
28
+ "src"
28
29
  ],
29
30
  "engines": {
30
31
  "node": ">= 22"
@@ -43,23 +44,23 @@
43
44
  "typecheck": "tsc --noEmit"
44
45
  },
45
46
  "peerDependencies": {
46
- "@pyreon/core": "^0.11.1",
47
- "@pyreon/document": "^0.11.1",
48
- "@pyreon/elements": "^0.11.1",
49
- "@pyreon/rocketstyle": "^0.11.1",
50
- "@pyreon/styler": "^0.11.1",
51
- "@pyreon/ui-core": "^0.11.1"
47
+ "@pyreon/core": "^0.11.3",
48
+ "@pyreon/document": "^0.11.3",
49
+ "@pyreon/elements": "^0.11.3",
50
+ "@pyreon/rocketstyle": "^0.11.3",
51
+ "@pyreon/styler": "^0.11.3",
52
+ "@pyreon/ui-core": "^0.11.3"
52
53
  },
53
54
  "dependencies": {
54
- "@pyreon/connector-document": "^0.11.1"
55
+ "@pyreon/connector-document": "^0.11.3"
55
56
  },
56
57
  "devDependencies": {
57
- "@pyreon/core": "^0.11.1",
58
- "@pyreon/elements": "^0.11.1",
59
- "@pyreon/rocketstyle": "^0.11.1",
60
- "@pyreon/styler": "^0.11.1",
61
- "@pyreon/ui-core": "^0.11.1",
58
+ "@pyreon/core": "^0.11.3",
59
+ "@pyreon/elements": "^0.11.3",
60
+ "@pyreon/rocketstyle": "^0.11.3",
61
+ "@pyreon/styler": "^0.11.3",
62
+ "@pyreon/ui-core": "^0.11.3",
62
63
  "@vitus-labs/tools-rolldown": "^1.15.4",
63
- "@pyreon/typescript": "^0.11.1"
64
+ "@pyreon/typescript": "^0.11.3"
64
65
  }
65
66
  }
@@ -0,0 +1,50 @@
1
+ import { Element } from "@pyreon/elements"
2
+ import rocketstyle from "@pyreon/rocketstyle"
3
+
4
+ const DocumentPreview = rocketstyle({
5
+ dimensions: {
6
+ sizes: "size",
7
+ },
8
+ useBooleans: true,
9
+ })({ name: "DocumentPreview", component: Element })
10
+ .theme({
11
+ backgroundColor: "#f5f5f5",
12
+ padding: 40,
13
+ })
14
+ .sizes({
15
+ A4: { width: "210mm", minHeight: "297mm" },
16
+ A3: { width: "297mm", minHeight: "420mm" },
17
+ A5: { width: "148mm", minHeight: "210mm" },
18
+ letter: { width: "8.5in", minHeight: "11in" },
19
+ legal: { width: "8.5in", minHeight: "14in" },
20
+ })
21
+ .styles(
22
+ (css: any) => css`
23
+ display: flex;
24
+ flex-direction: column;
25
+ align-items: center;
26
+ min-height: 100vh;
27
+
28
+ & > * {
29
+ background: white;
30
+ padding: 25mm;
31
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
32
+ margin: 20px 0;
33
+ }
34
+ `,
35
+ )
36
+ .statics({ _documentType: "document" as const })
37
+ .attrs<{
38
+ size?: string
39
+ showPageBreaks?: boolean
40
+ tag: string
41
+ _documentProps: Record<string, unknown>
42
+ }>((props) => ({
43
+ tag: "div",
44
+ _documentProps: {
45
+ ...(props.size ? { size: props.size } : { size: "A4" }),
46
+ ...(props.showPageBreaks ? { showPageBreaks: props.showPageBreaks } : {}),
47
+ },
48
+ }))
49
+
50
+ export default DocumentPreview
@@ -0,0 +1,566 @@
1
+ import { popContext, pushContext } from "@pyreon/core"
2
+ import { context } from "@pyreon/rocketstyle"
3
+ import { config } from "@pyreon/ui-core"
4
+ import { afterAll, beforeAll, describe, expect, it } from "vitest"
5
+
6
+ // Mock styled function that returns the component unchanged
7
+ const mockStyled = (component: any) => {
8
+ const taggedTemplate = (_strings: any, ..._args: any[]) => component
9
+ return taggedTemplate
10
+ }
11
+
12
+ const mockCss = (_strings: any, ..._args: any[]) => ""
13
+
14
+ const originalStyled = config.styled
15
+ const originalCss = config.css
16
+
17
+ beforeAll(() => {
18
+ config.init({
19
+ css: mockCss as any,
20
+ styled: mockStyled as any,
21
+ component: "div",
22
+ textComponent: "span",
23
+ })
24
+ })
25
+
26
+ afterAll(() => {
27
+ config.styled = originalStyled
28
+ config.css = originalCss
29
+ })
30
+
31
+ /** Push a theme context and call fn, then pop context. */
32
+ const withThemeContext = (fn: () => any) => {
33
+ pushContext(
34
+ new Map([
35
+ [
36
+ context.id,
37
+ {
38
+ theme: { rootSize: 16 },
39
+ mode: "light",
40
+ isDark: false,
41
+ isLight: true,
42
+ },
43
+ ],
44
+ ]),
45
+ )
46
+ try {
47
+ return fn()
48
+ } finally {
49
+ popContext()
50
+ }
51
+ }
52
+
53
+ /** Call a rocketstyle component and return its rendered VNode props. */
54
+ const renderProps = (Component: any, props: Record<string, any> = {}) => {
55
+ return withThemeContext(() => {
56
+ const vnode = Component(props) as any
57
+ return vnode?.props ?? vnode
58
+ })
59
+ }
60
+
61
+ // Helper: Text-based components convert `tag` to `as` through the Text component;
62
+ // Element-based components keep `tag` as-is.
63
+ // Both pass `_documentProps` through to the rendered output.
64
+
65
+ // --------------------------------------------------------
66
+ // DocDocument (Element-based)
67
+ // --------------------------------------------------------
68
+ describe("DocDocument attrs", () => {
69
+ it("sets tag to div", async () => {
70
+ const DocDocument = (await import("../primitives/DocDocument")).default
71
+ const result = renderProps(DocDocument, { children: "test" })
72
+ expect(result.tag).toBe("div")
73
+ })
74
+
75
+ it("passes title to _documentProps", async () => {
76
+ const DocDocument = (await import("../primitives/DocDocument")).default
77
+ const result = renderProps(DocDocument, { title: "My Doc", children: "test" })
78
+ expect(result._documentProps.title).toBe("My Doc")
79
+ })
80
+
81
+ it("passes author to _documentProps", async () => {
82
+ const DocDocument = (await import("../primitives/DocDocument")).default
83
+ const result = renderProps(DocDocument, { author: "Jane", children: "test" })
84
+ expect(result._documentProps.author).toBe("Jane")
85
+ })
86
+
87
+ it("passes subject to _documentProps", async () => {
88
+ const DocDocument = (await import("../primitives/DocDocument")).default
89
+ const result = renderProps(DocDocument, { subject: "Report", children: "test" })
90
+ expect(result._documentProps.subject).toBe("Report")
91
+ })
92
+
93
+ it("omits missing optional fields from _documentProps", async () => {
94
+ const DocDocument = (await import("../primitives/DocDocument")).default
95
+ const result = renderProps(DocDocument, { children: "test" })
96
+ expect(result._documentProps).toEqual({})
97
+ })
98
+ })
99
+
100
+ // --------------------------------------------------------
101
+ // DocHeading (Text-based: tag -> as)
102
+ // --------------------------------------------------------
103
+ describe("DocHeading attrs", () => {
104
+ it("defaults to h1", async () => {
105
+ const DocHeading = (await import("../primitives/DocHeading")).default
106
+ const result = renderProps(DocHeading, { children: "Hello" })
107
+ expect(result.as).toBe("h1")
108
+ expect(result._documentProps.level).toBe(1)
109
+ })
110
+
111
+ it("sets tag to h2 when level is h2", async () => {
112
+ const DocHeading = (await import("../primitives/DocHeading")).default
113
+ const result = renderProps(DocHeading, { level: "h2", children: "Hello" })
114
+ expect(result.as).toBe("h2")
115
+ expect(result._documentProps.level).toBe(2)
116
+ })
117
+
118
+ it("parses level h6", async () => {
119
+ const DocHeading = (await import("../primitives/DocHeading")).default
120
+ const result = renderProps(DocHeading, { level: "h6", children: "Hello" })
121
+ expect(result.as).toBe("h6")
122
+ expect(result._documentProps.level).toBe(6)
123
+ })
124
+ })
125
+
126
+ // --------------------------------------------------------
127
+ // DocText (Text-based: tag -> as)
128
+ // --------------------------------------------------------
129
+ describe("DocText attrs", () => {
130
+ it("sets tag to p", async () => {
131
+ const DocText = (await import("../primitives/DocText")).default
132
+ const result = renderProps(DocText, { children: "Hello" })
133
+ expect(result.as).toBe("p")
134
+ expect(result._documentProps).toEqual({})
135
+ })
136
+ })
137
+
138
+ // --------------------------------------------------------
139
+ // DocLink (Text-based: tag -> as)
140
+ // --------------------------------------------------------
141
+ describe("DocLink attrs", () => {
142
+ it("sets tag to a", async () => {
143
+ const DocLink = (await import("../primitives/DocLink")).default
144
+ const result = renderProps(DocLink, { children: "Click" })
145
+ expect(result.as).toBe("a")
146
+ })
147
+
148
+ it("passes href to _documentProps", async () => {
149
+ const DocLink = (await import("../primitives/DocLink")).default
150
+ const result = renderProps(DocLink, { href: "https://example.com", children: "Click" })
151
+ expect(result._documentProps.href).toBe("https://example.com")
152
+ })
153
+
154
+ it("defaults href to # when not provided", async () => {
155
+ const DocLink = (await import("../primitives/DocLink")).default
156
+ const result = renderProps(DocLink, { children: "Click" })
157
+ expect(result._documentProps.href).toBe("#")
158
+ })
159
+ })
160
+
161
+ // --------------------------------------------------------
162
+ // DocImage (Element-based)
163
+ // --------------------------------------------------------
164
+ describe("DocImage attrs", () => {
165
+ it("sets tag to img", async () => {
166
+ const DocImage = (await import("../primitives/DocImage")).default
167
+ const result = renderProps(DocImage, { children: null })
168
+ expect(result.tag).toBe("img")
169
+ })
170
+
171
+ it("passes src to _documentProps", async () => {
172
+ const DocImage = (await import("../primitives/DocImage")).default
173
+ const result = renderProps(DocImage, { src: "photo.png", children: null })
174
+ expect(result._documentProps.src).toBe("photo.png")
175
+ })
176
+
177
+ it("defaults src to empty string", async () => {
178
+ const DocImage = (await import("../primitives/DocImage")).default
179
+ const result = renderProps(DocImage, { children: null })
180
+ expect(result._documentProps.src).toBe("")
181
+ })
182
+
183
+ it("passes alt, width, height, caption when provided", async () => {
184
+ const DocImage = (await import("../primitives/DocImage")).default
185
+ const result = renderProps(DocImage, {
186
+ src: "photo.png",
187
+ alt: "A photo",
188
+ width: 200,
189
+ height: 100,
190
+ caption: "My photo",
191
+ children: null,
192
+ })
193
+ expect(result._documentProps.alt).toBe("A photo")
194
+ expect(result._documentProps.width).toBe(200)
195
+ expect(result._documentProps.height).toBe(100)
196
+ expect(result._documentProps.caption).toBe("My photo")
197
+ })
198
+
199
+ it("omits alt, width, height, caption when not provided", async () => {
200
+ const DocImage = (await import("../primitives/DocImage")).default
201
+ const result = renderProps(DocImage, { children: null })
202
+ expect(result._documentProps.alt).toBeUndefined()
203
+ expect(result._documentProps.width).toBeUndefined()
204
+ expect(result._documentProps.height).toBeUndefined()
205
+ expect(result._documentProps.caption).toBeUndefined()
206
+ })
207
+ })
208
+
209
+ // --------------------------------------------------------
210
+ // DocTable (Element-based)
211
+ // --------------------------------------------------------
212
+ describe("DocTable attrs", () => {
213
+ it("sets tag to table", async () => {
214
+ const DocTable = (await import("../primitives/DocTable")).default
215
+ const result = renderProps(DocTable, { children: null })
216
+ expect(result.tag).toBe("table")
217
+ })
218
+
219
+ it("defaults columns and rows to empty arrays", async () => {
220
+ const DocTable = (await import("../primitives/DocTable")).default
221
+ const result = renderProps(DocTable, { children: null })
222
+ expect(result._documentProps.columns).toEqual([])
223
+ expect(result._documentProps.rows).toEqual([])
224
+ })
225
+
226
+ it("passes all table options when provided", async () => {
227
+ const DocTable = (await import("../primitives/DocTable")).default
228
+ const result = renderProps(DocTable, {
229
+ columns: [{ header: "Name" }],
230
+ rows: [["Alice"]],
231
+ headerStyle: { fontWeight: "bold" },
232
+ striped: true,
233
+ bordered: true,
234
+ caption: "Users",
235
+ children: null,
236
+ })
237
+ expect(result._documentProps.columns).toEqual([{ header: "Name" }])
238
+ expect(result._documentProps.rows).toEqual([["Alice"]])
239
+ expect(result._documentProps.headerStyle).toEqual({ fontWeight: "bold" })
240
+ expect(result._documentProps.striped).toBe(true)
241
+ expect(result._documentProps.bordered).toBe(true)
242
+ expect(result._documentProps.caption).toBe("Users")
243
+ })
244
+ })
245
+
246
+ // --------------------------------------------------------
247
+ // DocList (Element-based)
248
+ // --------------------------------------------------------
249
+ describe("DocList attrs", () => {
250
+ it("sets tag to ul by default", async () => {
251
+ const DocList = (await import("../primitives/DocList")).default
252
+ const result = renderProps(DocList, { children: null })
253
+ expect(result.tag).toBe("ul")
254
+ })
255
+
256
+ it("sets tag to ol when ordered is true", async () => {
257
+ const DocList = (await import("../primitives/DocList")).default
258
+ const result = renderProps(DocList, { ordered: true, children: null })
259
+ expect(result.tag).toBe("ol")
260
+ expect(result._documentProps.ordered).toBe(true)
261
+ })
262
+
263
+ it("has empty _documentProps when not ordered", async () => {
264
+ const DocList = (await import("../primitives/DocList")).default
265
+ const result = renderProps(DocList, { children: null })
266
+ expect(result._documentProps).toEqual({})
267
+ })
268
+ })
269
+
270
+ // --------------------------------------------------------
271
+ // DocListItem (Text-based: tag -> as)
272
+ // --------------------------------------------------------
273
+ describe("DocListItem attrs", () => {
274
+ it("sets tag to li", async () => {
275
+ const DocListItem = (await import("../primitives/DocListItem")).default
276
+ const result = renderProps(DocListItem, { children: "item" })
277
+ expect(result.as).toBe("li")
278
+ expect(result._documentProps).toEqual({})
279
+ })
280
+ })
281
+
282
+ // --------------------------------------------------------
283
+ // DocCode (Text-based: tag -> as)
284
+ // --------------------------------------------------------
285
+ describe("DocCode attrs", () => {
286
+ it("sets tag to pre", async () => {
287
+ const DocCode = (await import("../primitives/DocCode")).default
288
+ const result = renderProps(DocCode, { children: "code" })
289
+ expect(result.as).toBe("pre")
290
+ })
291
+
292
+ it("passes language to _documentProps when provided", async () => {
293
+ const DocCode = (await import("../primitives/DocCode")).default
294
+ const result = renderProps(DocCode, { language: "typescript", children: "code" })
295
+ expect(result._documentProps.language).toBe("typescript")
296
+ })
297
+
298
+ it("has empty _documentProps when no language", async () => {
299
+ const DocCode = (await import("../primitives/DocCode")).default
300
+ const result = renderProps(DocCode, { children: "code" })
301
+ expect(result._documentProps).toEqual({})
302
+ })
303
+ })
304
+
305
+ // --------------------------------------------------------
306
+ // DocDivider (Element-based)
307
+ // --------------------------------------------------------
308
+ describe("DocDivider attrs", () => {
309
+ it("sets tag to hr", async () => {
310
+ const DocDivider = (await import("../primitives/DocDivider")).default
311
+ const result = renderProps(DocDivider, { children: null })
312
+ expect(result.tag).toBe("hr")
313
+ })
314
+
315
+ it("passes color and thickness when provided", async () => {
316
+ const DocDivider = (await import("../primitives/DocDivider")).default
317
+ const result = renderProps(DocDivider, { color: "red", thickness: 2, children: null })
318
+ expect(result._documentProps.color).toBe("red")
319
+ expect(result._documentProps.thickness).toBe(2)
320
+ })
321
+
322
+ it("omits color and thickness when not provided", async () => {
323
+ const DocDivider = (await import("../primitives/DocDivider")).default
324
+ const result = renderProps(DocDivider, { children: null })
325
+ expect(result._documentProps).toEqual({})
326
+ })
327
+ })
328
+
329
+ // --------------------------------------------------------
330
+ // DocPage (Element-based)
331
+ // --------------------------------------------------------
332
+ describe("DocPage attrs", () => {
333
+ it("sets tag to div", async () => {
334
+ const DocPage = (await import("../primitives/DocPage")).default
335
+ const result = renderProps(DocPage, { children: "page" })
336
+ expect(result.tag).toBe("div")
337
+ })
338
+
339
+ it("passes size and orientation when provided", async () => {
340
+ const DocPage = (await import("../primitives/DocPage")).default
341
+ const result = renderProps(DocPage, {
342
+ size: "A4",
343
+ orientation: "landscape",
344
+ children: "page",
345
+ })
346
+ expect(result._documentProps.size).toBe("A4")
347
+ expect(result._documentProps.orientation).toBe("landscape")
348
+ })
349
+
350
+ it("omits size and orientation when not provided", async () => {
351
+ const DocPage = (await import("../primitives/DocPage")).default
352
+ const result = renderProps(DocPage, { children: "page" })
353
+ expect(result._documentProps).toEqual({})
354
+ })
355
+ })
356
+
357
+ // --------------------------------------------------------
358
+ // DocPageBreak (Element-based)
359
+ // --------------------------------------------------------
360
+ describe("DocPageBreak attrs", () => {
361
+ it("sets tag to div with empty _documentProps", async () => {
362
+ const DocPageBreak = (await import("../primitives/DocPageBreak")).default
363
+ const result = renderProps(DocPageBreak, { children: null })
364
+ expect(result.tag).toBe("div")
365
+ expect(result._documentProps).toEqual({})
366
+ })
367
+ })
368
+
369
+ // --------------------------------------------------------
370
+ // DocQuote (Element-based)
371
+ // --------------------------------------------------------
372
+ describe("DocQuote attrs", () => {
373
+ it("sets tag to blockquote", async () => {
374
+ const DocQuote = (await import("../primitives/DocQuote")).default
375
+ const result = renderProps(DocQuote, { children: "quote" })
376
+ expect(result.tag).toBe("blockquote")
377
+ })
378
+
379
+ it("passes borderColor when provided", async () => {
380
+ const DocQuote = (await import("../primitives/DocQuote")).default
381
+ const result = renderProps(DocQuote, { borderColor: "#ff0000", children: "quote" })
382
+ expect(result._documentProps.borderColor).toBe("#ff0000")
383
+ })
384
+
385
+ it("has empty _documentProps when no borderColor", async () => {
386
+ const DocQuote = (await import("../primitives/DocQuote")).default
387
+ const result = renderProps(DocQuote, { children: "quote" })
388
+ expect(result._documentProps).toEqual({})
389
+ })
390
+ })
391
+
392
+ // --------------------------------------------------------
393
+ // DocRow (Element-based)
394
+ // --------------------------------------------------------
395
+ describe("DocRow attrs", () => {
396
+ it("sets tag to div with empty _documentProps", async () => {
397
+ const DocRow = (await import("../primitives/DocRow")).default
398
+ const result = renderProps(DocRow, { children: null })
399
+ expect(result.tag).toBe("div")
400
+ expect(result._documentProps).toEqual({})
401
+ })
402
+ })
403
+
404
+ // --------------------------------------------------------
405
+ // DocColumn (Element-based)
406
+ // --------------------------------------------------------
407
+ describe("DocColumn attrs", () => {
408
+ it("sets tag to div", async () => {
409
+ const DocColumn = (await import("../primitives/DocColumn")).default
410
+ const result = renderProps(DocColumn, { children: null })
411
+ expect(result.tag).toBe("div")
412
+ })
413
+
414
+ it("passes width to _documentProps when provided", async () => {
415
+ const DocColumn = (await import("../primitives/DocColumn")).default
416
+ const result = renderProps(DocColumn, { width: "50%", children: null })
417
+ expect(result._documentProps.width).toBe("50%")
418
+ })
419
+
420
+ it("has empty _documentProps when no width", async () => {
421
+ const DocColumn = (await import("../primitives/DocColumn")).default
422
+ const result = renderProps(DocColumn, { children: null })
423
+ expect(result._documentProps).toEqual({})
424
+ })
425
+ })
426
+
427
+ // --------------------------------------------------------
428
+ // DocSpacer (Element-based)
429
+ // --------------------------------------------------------
430
+ describe("DocSpacer attrs", () => {
431
+ it("sets tag to div", async () => {
432
+ const DocSpacer = (await import("../primitives/DocSpacer")).default
433
+ const result = renderProps(DocSpacer, { children: null })
434
+ expect(result.tag).toBe("div")
435
+ })
436
+
437
+ it("defaults height to 16", async () => {
438
+ const DocSpacer = (await import("../primitives/DocSpacer")).default
439
+ const result = renderProps(DocSpacer, { children: null })
440
+ expect(result._documentProps.height).toBe(16)
441
+ })
442
+
443
+ it("passes custom height", async () => {
444
+ const DocSpacer = (await import("../primitives/DocSpacer")).default
445
+ const result = renderProps(DocSpacer, { height: 32, children: null })
446
+ expect(result._documentProps.height).toBe(32)
447
+ })
448
+ })
449
+
450
+ // --------------------------------------------------------
451
+ // DocSection (Element-based)
452
+ // --------------------------------------------------------
453
+ describe("DocSection attrs", () => {
454
+ it("sets tag to div", async () => {
455
+ const DocSection = (await import("../primitives/DocSection")).default
456
+ const result = renderProps(DocSection, { children: null })
457
+ expect(result.tag).toBe("div")
458
+ })
459
+
460
+ it("defaults direction to column", async () => {
461
+ const DocSection = (await import("../primitives/DocSection")).default
462
+ const result = renderProps(DocSection, { children: null })
463
+ expect(result._documentProps.direction).toBe("column")
464
+ })
465
+
466
+ it("passes direction when provided", async () => {
467
+ const DocSection = (await import("../primitives/DocSection")).default
468
+ const result = renderProps(DocSection, { direction: "row", children: null })
469
+ expect(result._documentProps.direction).toBe("row")
470
+ })
471
+ })
472
+
473
+ // --------------------------------------------------------
474
+ // DocButton (Text-based: tag -> as)
475
+ // --------------------------------------------------------
476
+ describe("DocButton attrs", () => {
477
+ it("sets tag to a", async () => {
478
+ const DocButton = (await import("../primitives/DocButton")).default
479
+ const result = renderProps(DocButton, { children: "Click" })
480
+ expect(result.as).toBe("a")
481
+ })
482
+
483
+ it("passes href to _documentProps", async () => {
484
+ const DocButton = (await import("../primitives/DocButton")).default
485
+ const result = renderProps(DocButton, { href: "https://example.com", children: "Click" })
486
+ expect(result._documentProps.href).toBe("https://example.com")
487
+ })
488
+
489
+ it("defaults href to # when not provided", async () => {
490
+ const DocButton = (await import("../primitives/DocButton")).default
491
+ const result = renderProps(DocButton, { children: "Click" })
492
+ expect(result._documentProps.href).toBe("#")
493
+ })
494
+ })
495
+
496
+ // --------------------------------------------------------
497
+ // DocumentPreview (Element-based)
498
+ // --------------------------------------------------------
499
+ describe("DocumentPreview attrs", () => {
500
+ it("sets tag to div", async () => {
501
+ const DocumentPreview = (await import("../DocumentPreview")).default
502
+ const result = renderProps(DocumentPreview, { children: null })
503
+ expect(result.tag).toBe("div")
504
+ })
505
+
506
+ it("defaults size to A4 when not provided", async () => {
507
+ const DocumentPreview = (await import("../DocumentPreview")).default
508
+ const result = renderProps(DocumentPreview, { children: null })
509
+ expect(result._documentProps.size).toBe("A4")
510
+ })
511
+
512
+ it("passes custom size", async () => {
513
+ const DocumentPreview = (await import("../DocumentPreview")).default
514
+ const result = renderProps(DocumentPreview, { size: "letter", children: null })
515
+ expect(result._documentProps.size).toBe("letter")
516
+ })
517
+
518
+ it("passes showPageBreaks when provided", async () => {
519
+ const DocumentPreview = (await import("../DocumentPreview")).default
520
+ const result = renderProps(DocumentPreview, { showPageBreaks: true, children: null })
521
+ expect(result._documentProps.showPageBreaks).toBe(true)
522
+ })
523
+ })
524
+
525
+ // --------------------------------------------------------
526
+ // All primitives: displayName and IS_ROCKETSTYLE coverage
527
+ // --------------------------------------------------------
528
+ describe("all primitives have correct displayName and IS_ROCKETSTYLE", () => {
529
+ const primitivePairs = [
530
+ ["DocButton", "../primitives/DocButton"],
531
+ ["DocCode", "../primitives/DocCode"],
532
+ ["DocColumn", "../primitives/DocColumn"],
533
+ ["DocDivider", "../primitives/DocDivider"],
534
+ ["DocDocument", "../primitives/DocDocument"],
535
+ ["DocHeading", "../primitives/DocHeading"],
536
+ ["DocImage", "../primitives/DocImage"],
537
+ ["DocLink", "../primitives/DocLink"],
538
+ ["DocList", "../primitives/DocList"],
539
+ ["DocListItem", "../primitives/DocListItem"],
540
+ ["DocPage", "../primitives/DocPage"],
541
+ ["DocPageBreak", "../primitives/DocPageBreak"],
542
+ ["DocQuote", "../primitives/DocQuote"],
543
+ ["DocRow", "../primitives/DocRow"],
544
+ ["DocSection", "../primitives/DocSection"],
545
+ ["DocSpacer", "../primitives/DocSpacer"],
546
+ ["DocTable", "../primitives/DocTable"],
547
+ ["DocText", "../primitives/DocText"],
548
+ ] as const
549
+
550
+ for (const [name, path] of primitivePairs) {
551
+ it(`${name} has displayName = "${name}"`, async () => {
552
+ const mod = await import(path)
553
+ expect(mod.default.displayName).toBe(name)
554
+ })
555
+
556
+ it(`${name} is a function`, async () => {
557
+ const mod = await import(path)
558
+ expect(typeof mod.default).toBe("function")
559
+ })
560
+
561
+ it(`${name} has IS_ROCKETSTYLE = true`, async () => {
562
+ const mod = await import(path)
563
+ expect(mod.default.IS_ROCKETSTYLE).toBe(true)
564
+ })
565
+ }
566
+ })