@format.dev/react 0.2.0 → 0.4.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/README.md +64 -0
- package/dist/index.cjs +104 -7
- package/dist/index.d.cts +199 -17
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +199 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +103 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -26,9 +26,26 @@ declare const TocLeader: {
|
|
|
26
26
|
readonly None: "none";
|
|
27
27
|
};
|
|
28
28
|
type TocLeader = (typeof TocLeader)[keyof typeof TocLeader];
|
|
29
|
+
/**
|
|
30
|
+
* A page dimension: a number of CSS pixels, or a length in an absolute unit, such as
|
|
31
|
+
* `'210mm'` or `'8.5in'`. The units are `mm`, `cm`, `in`, `pt`, `pc` and `px`.
|
|
32
|
+
*/
|
|
33
|
+
type PageLength = number | `${number}${'mm' | 'cm' | 'in' | 'pt' | 'pc' | 'px'}`;
|
|
29
34
|
/** How a Layout or Flow decides where pages break: `auto` on overflow
|
|
30
35
|
* and at PageBreak markers, `manual` at PageBreak markers only. */
|
|
31
36
|
type PaginationStrategy = 'auto' | 'manual';
|
|
37
|
+
/**
|
|
38
|
+
* Which matched heading a `<RunningHead>` shows on a page: the `first` or `last`
|
|
39
|
+
* match on the page, the one the page `start`s with, `firstExcept` to show nothing
|
|
40
|
+
* on a page where a match appears, or the `range` of sections the page holds. On a
|
|
41
|
+
* page with no match, each shows the section carried over from earlier pages.
|
|
42
|
+
*/
|
|
43
|
+
type RunningHeadShow = 'first' | 'start' | 'last' | 'firstExcept' | 'range';
|
|
44
|
+
/**
|
|
45
|
+
* The elements a `<RunningHead>` can render as: those that can hold a shadow root,
|
|
46
|
+
* where its text goes.
|
|
47
|
+
*/
|
|
48
|
+
type RunningHeadElement = 'span' | 'div' | 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'header' | 'footer' | 'nav' | 'section' | 'article' | 'aside' | 'blockquote' | 'main' | 'body';
|
|
32
49
|
/**
|
|
33
50
|
* How the PDF embeds its fonts. Mirrors `FontMode` in `@format.dev/fonts`, which owns
|
|
34
51
|
* the canonical list and the default.
|
|
@@ -47,16 +64,21 @@ interface DocumentProps {
|
|
|
47
64
|
author?: string;
|
|
48
65
|
keywords?: string[];
|
|
49
66
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
* The language the document is written in, as a BCP 47 language tag such as
|
|
68
|
+
* `'fr'` or `'pt-BR'`. Format adds it to your PDF, and screen readers use it to
|
|
69
|
+
* choose the right voice and pronunciation. Format also applies that language's
|
|
70
|
+
* conventions for quotation marks and letter case to every page. Set it on
|
|
71
|
+
* every document: without it, your PDF has no language and doesn't meet
|
|
72
|
+
* accessibility standards such as WCAG and PDF/UA. Format ignores invalid tags,
|
|
73
|
+
* such as `'en_US'` or `'english'`. To mark a passage in a different language,
|
|
74
|
+
* add a `lang` attribute to its element.
|
|
75
|
+
*/
|
|
76
|
+
lang?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Selects the versions of Format's built-in Sans, Serif, and Mono fonts.
|
|
79
|
+
* `compact` (default) uses static fonts for smaller PDFs. `fidelity` uses
|
|
80
|
+
* variable fonts, preserving optical sizing where supported, but typically
|
|
81
|
+
* produces larger PDFs. Custom fonts are used as supplied in either mode.
|
|
60
82
|
*/
|
|
61
83
|
fonts?: FontMode;
|
|
62
84
|
}
|
|
@@ -68,7 +90,7 @@ interface DocumentProps {
|
|
|
68
90
|
* import type { Invoice } from './types'
|
|
69
91
|
*
|
|
70
92
|
* export default function InvoiceDocument({ data }: RenderProps<Invoice>) {
|
|
71
|
-
* return <Document title={`Invoice #${data.id}`}>{/* ... *\/}</Document>
|
|
93
|
+
* return <Document title={`Invoice #${data.id}`} lang="en">{/* ... *\/}</Document>
|
|
72
94
|
* }
|
|
73
95
|
* ```
|
|
74
96
|
*/
|
|
@@ -80,6 +102,7 @@ declare function Document({
|
|
|
80
102
|
subject,
|
|
81
103
|
author,
|
|
82
104
|
keywords,
|
|
105
|
+
lang,
|
|
83
106
|
fonts,
|
|
84
107
|
children
|
|
85
108
|
}: PropsWithChildren<DocumentProps>): react0.JSX.Element;
|
|
@@ -89,8 +112,10 @@ interface LayoutProps {
|
|
|
89
112
|
/** Design label, mirrored to each page as `data-layout-id` for CSS. Optional:
|
|
90
113
|
* when omitted, the engine generates one from the Layout's document position. */
|
|
91
114
|
id?: string;
|
|
92
|
-
width: number
|
|
93
|
-
|
|
115
|
+
/** The page's width: a number of CSS pixels, or a length such as `'210mm'`. */
|
|
116
|
+
width: PageLength;
|
|
117
|
+
/** The page's height: a number of CSS pixels, or a length such as `'297mm'`. */
|
|
118
|
+
height: PageLength;
|
|
94
119
|
paginationStrategy?: PaginationStrategy;
|
|
95
120
|
splitGranularity?: SplitGranularity;
|
|
96
121
|
}
|
|
@@ -266,7 +291,9 @@ declare function Counter({
|
|
|
266
291
|
interface NumberingRuleBase {
|
|
267
292
|
/**
|
|
268
293
|
* CSS selector for the elements this rule numbers, e.g. `h2`, `figure figcaption`,
|
|
269
|
-
* `.step`. Every match advances the counter in document order.
|
|
294
|
+
* `.step`. Every match advances the counter in document order. It matches the
|
|
295
|
+
* content that flows across pages, without the Layout or Flow scaffolding around
|
|
296
|
+
* it: when a Layout wraps its Flow in `<main>`, `main h2` matches nothing.
|
|
270
297
|
*/
|
|
271
298
|
match: string;
|
|
272
299
|
/**
|
|
@@ -336,7 +363,7 @@ interface NumberingProps {
|
|
|
336
363
|
* breaks where plain CSS counters would reset.
|
|
337
364
|
*
|
|
338
365
|
* ```tsx
|
|
339
|
-
* <Document title="Report">
|
|
366
|
+
* <Document title="Report" lang="en">
|
|
340
367
|
* <Numbering />
|
|
341
368
|
* ...
|
|
342
369
|
* </Document>
|
|
@@ -390,6 +417,42 @@ declare function CounterDef({
|
|
|
390
417
|
resetEach
|
|
391
418
|
}: CounterDefProps): react0.JSX.Element;
|
|
392
419
|
//#endregion
|
|
420
|
+
//#region src/Bookmarks.d.ts
|
|
421
|
+
interface BookmarksProps {
|
|
422
|
+
/**
|
|
423
|
+
* Whether bookmarks include the numbers `<Numbering>` adds to headings. On by
|
|
424
|
+
* default. Set `false` to show titles alone, such as "Fees" instead of "3 Fees".
|
|
425
|
+
* Text you write in a heading always stays, including digits and the value of a
|
|
426
|
+
* `<Counter>`.
|
|
427
|
+
*/
|
|
428
|
+
numbers?: boolean;
|
|
429
|
+
/**
|
|
430
|
+
* The text between each number and its title, such as `". "` for "3. Fees".
|
|
431
|
+
* Defaults to a space, as on the page. An empty string joins them, as in "3Fees".
|
|
432
|
+
*/
|
|
433
|
+
separator?: string;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Controls how heading numbers appear in the PDF's bookmarks, the clickable outline
|
|
437
|
+
* that PDF viewers show beside the pages. By default, each bookmark matches its
|
|
438
|
+
* heading, number included. Set `numbers={false}` to leave the numbers out, or set
|
|
439
|
+
* `separator` to change the text between each number and its title. The pages, the
|
|
440
|
+
* table of contents, and the running heads keep their numbers. Place one directly
|
|
441
|
+
* inside `<Document>`.
|
|
442
|
+
*
|
|
443
|
+
* ```tsx
|
|
444
|
+
* <Document title="Handbook">
|
|
445
|
+
* <Numbering />
|
|
446
|
+
* <Bookmarks separator=". " />
|
|
447
|
+
* ...
|
|
448
|
+
* </Document>
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
declare function Bookmarks({
|
|
452
|
+
numbers,
|
|
453
|
+
separator
|
|
454
|
+
}: BookmarksProps): react0.JSX.Element;
|
|
455
|
+
//#endregion
|
|
393
456
|
//#region src/Scope.d.ts
|
|
394
457
|
interface ScopeProps {
|
|
395
458
|
/**
|
|
@@ -473,10 +536,104 @@ declare function Ref({
|
|
|
473
536
|
...rest
|
|
474
537
|
}: RefProps): react0.JSX.Element;
|
|
475
538
|
//#endregion
|
|
539
|
+
//#region src/RunningHead.d.ts
|
|
540
|
+
interface RunningHeadProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
|
|
541
|
+
/**
|
|
542
|
+
* CSS selector for the headings to follow, e.g. `h1`. Like a `<NumberingRule>`'s
|
|
543
|
+
* `match`, it matches the content that flows across pages, without the scaffolding
|
|
544
|
+
* around it: select on the heading itself, e.g. `h1` rather than `main h1`.
|
|
545
|
+
*/
|
|
546
|
+
match: string;
|
|
547
|
+
/**
|
|
548
|
+
* Which match to show on each page. `first` (the default) shows the first match on
|
|
549
|
+
* the page; `start` shows the match the page opens with, else the section the page
|
|
550
|
+
* continues; `last` shows the last match; `firstExcept` shows nothing on a page
|
|
551
|
+
* where a match appears; `range` shows the first and last section the page holds.
|
|
552
|
+
* A page with no match shows the section carried over from earlier pages.
|
|
553
|
+
*/
|
|
554
|
+
show?: RunningHeadShow;
|
|
555
|
+
/**
|
|
556
|
+
* CSS selector for the headings that enclose the followed ones, e.g. `h1` for a
|
|
557
|
+
* running head that follows `h2` sections. A match ends the current section, and
|
|
558
|
+
* only sections of the chapter in effect are shown. A chapter running head and a
|
|
559
|
+
* section running head on one page agree when they use the same `show` other
|
|
560
|
+
* than `range`, or when the chapter uses `start` beside a section `range`.
|
|
561
|
+
*/
|
|
562
|
+
within?: string;
|
|
563
|
+
/**
|
|
564
|
+
* The number to show, with `{counter}` placeholders read where the heading sits,
|
|
565
|
+
* e.g. `{h1:decimal-leading-zero}.`. Defaults to the number the heading shows.
|
|
566
|
+
*/
|
|
567
|
+
format?: string;
|
|
568
|
+
/**
|
|
569
|
+
* Default `<counter-style>` for placeholders in `format`. Defaults to the
|
|
570
|
+
* document's numbering style, or `decimal`.
|
|
571
|
+
*/
|
|
572
|
+
counterStyle?: CounterStyle;
|
|
573
|
+
/**
|
|
574
|
+
* The text between the first and last section when `show` is `range`. Defaults to
|
|
575
|
+
* an en dash with a space either side.
|
|
576
|
+
*/
|
|
577
|
+
rangeSeparator?: string;
|
|
578
|
+
/**
|
|
579
|
+
* HTML tag to render: `span` (the default), `div`, `p`, a heading, or a sectioning
|
|
580
|
+
* element such as `header`. The text goes in a shadow root, which only these
|
|
581
|
+
* elements can hold.
|
|
582
|
+
*/
|
|
583
|
+
as?: RunningHeadElement;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Names, in a page's header or footer, the section the page belongs to: the title
|
|
587
|
+
* of the heading `match` picks out, with its number. Place it in a Layout's
|
|
588
|
+
* scaffolding, and Format fills it on every page once the page's content is placed,
|
|
589
|
+
* so a chapter that starts halfway down a page is named correctly. The heading, its
|
|
590
|
+
* table of contents entry, and the running head always show the same number and
|
|
591
|
+
* title.
|
|
592
|
+
*
|
|
593
|
+
* Set `data-running-head` on a heading to show a shorter title (an empty value shows
|
|
594
|
+
* nothing for it), and `data-running-head-reset` on any element to end the current
|
|
595
|
+
* section, e.g. on an appendix's title page. For the heading's PDF bookmark, set
|
|
596
|
+
* `data-bookmark` the same way.
|
|
597
|
+
*
|
|
598
|
+
* The box keeps one size whatever text lands in it: one line tall, or as many lines
|
|
599
|
+
* as `--running-head-lines` sets. Give it a width in your layout, such as a grid
|
|
600
|
+
* column; text that doesn't fit is cut off, with an ellipsis when the box holds its
|
|
601
|
+
* lines. The text sits in the box's own shadow root, where your selectors don't
|
|
602
|
+
* reach: style it with `::part()`, such as `::part(title)`.
|
|
603
|
+
*
|
|
604
|
+
* ```tsx
|
|
605
|
+
* <Numbering>
|
|
606
|
+
* <NumberingRule match="h1" format="{h1:decimal-leading-zero}." />
|
|
607
|
+
* </Numbering>
|
|
608
|
+
* <Layout id="page" width={595} height={842}>
|
|
609
|
+
* <header>
|
|
610
|
+
* <RunningHead match="h1" show="start" />
|
|
611
|
+
* <PageNumber />
|
|
612
|
+
* </header>
|
|
613
|
+
* <Flow>
|
|
614
|
+
* <h1>General information</h1>
|
|
615
|
+
* ...
|
|
616
|
+
* </Flow>
|
|
617
|
+
* </Layout>
|
|
618
|
+
* ```
|
|
619
|
+
*/
|
|
620
|
+
declare function RunningHead({
|
|
621
|
+
match,
|
|
622
|
+
show,
|
|
623
|
+
within,
|
|
624
|
+
format,
|
|
625
|
+
counterStyle,
|
|
626
|
+
rangeSeparator,
|
|
627
|
+
as: Tag,
|
|
628
|
+
...rest
|
|
629
|
+
}: RunningHeadProps): react0.JSX.Element;
|
|
630
|
+
//#endregion
|
|
476
631
|
//#region src/TableOfContents.d.ts
|
|
477
632
|
interface TableOfContentsProps {
|
|
478
633
|
/**
|
|
479
|
-
* CSS selector for the headings to list. Defaults to `h1, h2, h3`.
|
|
634
|
+
* CSS selector for the headings to list. Defaults to `h1, h2, h3`. Like a
|
|
635
|
+
* `<NumberingRule>`'s `match`, it matches the content that flows across pages,
|
|
636
|
+
* without the scaffolding around it.
|
|
480
637
|
*/
|
|
481
638
|
collect?: string;
|
|
482
639
|
/**
|
|
@@ -489,6 +646,15 @@ interface TableOfContentsProps {
|
|
|
489
646
|
* running header. Off by default: the leading content shows once, above the entries.
|
|
490
647
|
*/
|
|
491
648
|
repeatHead?: boolean;
|
|
649
|
+
/**
|
|
650
|
+
* CSS selector for the headings that enclose the listed ones, e.g. `h1` for a
|
|
651
|
+
* chapter's list of its sections. Place the contents after the chapter's heading:
|
|
652
|
+
* it lists the headings up to the next match. It runs independently of every other
|
|
653
|
+
* contents, so a book's contents can list every chapter while each chapter lists
|
|
654
|
+
* its own sections. Without it, a contents runs to the next contents without
|
|
655
|
+
* `within`.
|
|
656
|
+
*/
|
|
657
|
+
within?: string;
|
|
492
658
|
/**
|
|
493
659
|
* Leading content rendered at the top of the contents, above the entries — a
|
|
494
660
|
* "Contents" heading, an intro line, a rule. Shown once by default; set `repeatHead`
|
|
@@ -521,6 +687,21 @@ interface TableOfContentsProps {
|
|
|
521
687
|
* Children are leading content shown above the entries — put a "Contents" heading there.
|
|
522
688
|
* It shows once by default; set `repeatHead` to repeat it with the nav on every page.
|
|
523
689
|
*
|
|
690
|
+
* Place it directly in a `<Flow>` or its `<Stream>`. Inside other content, such as a
|
|
691
|
+
* `<section>`, it renders nothing.
|
|
692
|
+
*
|
|
693
|
+
* A contents lists the headings after it, up to the next contents without `within`.
|
|
694
|
+
* Set `within` to give one its own section instead, such as a chapter's sections
|
|
695
|
+
* beside the book's chapters:
|
|
696
|
+
*
|
|
697
|
+
* ```tsx
|
|
698
|
+
* <TableOfContents collect="h1">…</TableOfContents>
|
|
699
|
+
*
|
|
700
|
+
* <h1>Admissions</h1>
|
|
701
|
+
* <TableOfContents collect="h2" within="h1" />
|
|
702
|
+
* <h2>Requirements</h2>
|
|
703
|
+
* ```
|
|
704
|
+
*
|
|
524
705
|
* Give a collected heading a `data-toc-description` and its entry gains a
|
|
525
706
|
* `toc-description` line under the title (a one-line summary, as on a magazine or
|
|
526
707
|
* report contents):
|
|
@@ -539,6 +720,7 @@ declare function TableOfContents({
|
|
|
539
720
|
collect,
|
|
540
721
|
leader,
|
|
541
722
|
repeatHead,
|
|
723
|
+
within,
|
|
542
724
|
className,
|
|
543
725
|
style,
|
|
544
726
|
children
|
|
@@ -626,5 +808,5 @@ declare function Footnotes({
|
|
|
626
808
|
*/
|
|
627
809
|
declare function css(parts: TemplateStringsArray, ...vals: unknown[]): string;
|
|
628
810
|
//#endregion
|
|
629
|
-
export { Counter, CounterDef, type CounterDefProps, type CounterProps, type CounterStyle, Document, type DocumentProps, Flow, type FlowProps, type FontMode, Footnote, Footnotes, type FootnotesProps, Layout, type LayoutProps, Numbering, type NumberingProps, NumberingRule, type NumberingRuleProps, PageBreak, PageCount, type PageCountProps, PageNumber, type PageNumberProps, type PaginationStrategy, Ref, type RefProps, type RenderProps, Scope, type ScopeProps, SplitGranularity, Stream, TableOfContents, type TableOfContentsProps, TocLeader, css };
|
|
811
|
+
export { Bookmarks, type BookmarksProps, Counter, CounterDef, type CounterDefProps, type CounterProps, type CounterStyle, Document, type DocumentProps, Flow, type FlowProps, type FontMode, Footnote, Footnotes, type FootnotesProps, Layout, type LayoutProps, Numbering, type NumberingProps, NumberingRule, type NumberingRuleProps, PageBreak, PageCount, type PageCountProps, type PageLength, PageNumber, type PageNumberProps, type PaginationStrategy, Ref, type RefProps, type RenderProps, RunningHead, type RunningHeadElement, type RunningHeadProps, type RunningHeadShow, Scope, type ScopeProps, SplitGranularity, Stream, TableOfContents, type TableOfContentsProps, TocLeader, css };
|
|
630
812
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/Document.tsx","../src/Layout.tsx","../src/Flow.tsx","../src/Stream.tsx","../src/PageBreak.tsx","../src/PageCounter.tsx","../src/PageNumber.tsx","../src/PageCount.tsx","../src/Counter.tsx","../src/Numbering.tsx","../src/Scope.tsx","../src/Ref.tsx","../src/TableOfContents.tsx","../src/Footnote.tsx","../src/Footnotes.tsx","../src/utils.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAMA;AAOA;AAOa,cAdA,gBAiBH,EAAA;EAEE,SAAA,QAAS,EAAA,UAAW;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/Document.tsx","../src/Layout.tsx","../src/Flow.tsx","../src/Stream.tsx","../src/PageBreak.tsx","../src/PageCounter.tsx","../src/PageNumber.tsx","../src/PageCount.tsx","../src/Counter.tsx","../src/Numbering.tsx","../src/Bookmarks.tsx","../src/Scope.tsx","../src/Ref.tsx","../src/RunningHead.tsx","../src/TableOfContents.tsx","../src/Footnote.tsx","../src/Footnotes.tsx","../src/utils.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAMA;AAOA;AAOa,cAdA,gBAiBH,EAAA;EAEE,SAAA,QAAS,EAAA,UAAW;EAMpB,SAAA,IAAU,EAAA,MAAA;EAIV,SAAA,QAAA,EAAA,UAAkB;EAQlB,SA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UAAA;EAAA,SAAA;EAAA,KAAA;EAAA;AAAA,CAAA,Ee+BE,iBf/BF,Ce+BoB,cf/BpB,CAAA,CAAA,Ee+BmC,MAAA,CAAA,GAAA,CAAA,Of/BnC;;;AFCD;AAMA;AAIA;AAQA;AAMA;AAwBA;AAMA;;iBkB1DgB,GAAA,QAAW"}
|
package/dist/index.js
CHANGED
|
@@ -41,15 +41,15 @@ function Template({ children, ...props }) {
|
|
|
41
41
|
|
|
42
42
|
//#endregion
|
|
43
43
|
//#region src/engine-target.ts
|
|
44
|
-
const engineTarget = "0.
|
|
44
|
+
const engineTarget = "0.4.0";
|
|
45
45
|
|
|
46
46
|
//#endregion
|
|
47
47
|
//#region src/sdk-version.ts
|
|
48
|
-
const sdkVersion = "0.
|
|
48
|
+
const sdkVersion = "0.4.0";
|
|
49
49
|
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region src/Document.tsx
|
|
52
|
-
function Document({ title, subject, author, keywords, fonts, children }) {
|
|
52
|
+
function Document({ title, subject, author, keywords, lang, fonts, children }) {
|
|
53
53
|
const keywordsString = keywords?.join(", ");
|
|
54
54
|
return /* @__PURE__ */ jsx(Template, {
|
|
55
55
|
"data-sdk": sdkVersion,
|
|
@@ -59,6 +59,7 @@ function Document({ title, subject, author, keywords, fonts, children }) {
|
|
|
59
59
|
"data-subject": subject,
|
|
60
60
|
"data-author": author,
|
|
61
61
|
"data-keywords": keywordsString,
|
|
62
|
+
"data-lang": lang,
|
|
62
63
|
"data-fonts": fonts,
|
|
63
64
|
children
|
|
64
65
|
});
|
|
@@ -66,12 +67,14 @@ function Document({ title, subject, author, keywords, fonts, children }) {
|
|
|
66
67
|
|
|
67
68
|
//#endregion
|
|
68
69
|
//#region src/Layout.tsx
|
|
70
|
+
/** A page dimension as the engine reads it. A bare number is CSS pixels. */
|
|
71
|
+
const pageLength = (value) => typeof value === "number" ? `${value}px` : value;
|
|
69
72
|
function Layout({ id, width, height, paginationStrategy, splitGranularity, children }) {
|
|
70
73
|
return /* @__PURE__ */ jsx(Template, {
|
|
71
74
|
"data-type": "layout",
|
|
72
75
|
"data-id": id,
|
|
73
|
-
"data-width":
|
|
74
|
-
"data-height":
|
|
76
|
+
"data-width": pageLength(width),
|
|
77
|
+
"data-height": pageLength(height),
|
|
75
78
|
"data-pagination-strategy": paginationStrategy,
|
|
76
79
|
"data-split-granularity": splitGranularity,
|
|
77
80
|
children
|
|
@@ -216,7 +219,7 @@ function Counter({ name, peek, reset, set, by, join, as: Tag = "span", counterSt
|
|
|
216
219
|
* breaks where plain CSS counters would reset.
|
|
217
220
|
*
|
|
218
221
|
* ```tsx
|
|
219
|
-
* <Document title="Report">
|
|
222
|
+
* <Document title="Report" lang="en">
|
|
220
223
|
* <Numbering />
|
|
221
224
|
* ...
|
|
222
225
|
* </Document>
|
|
@@ -270,6 +273,32 @@ function CounterDef({ name, resetEach }) {
|
|
|
270
273
|
});
|
|
271
274
|
}
|
|
272
275
|
|
|
276
|
+
//#endregion
|
|
277
|
+
//#region src/Bookmarks.tsx
|
|
278
|
+
/**
|
|
279
|
+
* Controls how heading numbers appear in the PDF's bookmarks, the clickable outline
|
|
280
|
+
* that PDF viewers show beside the pages. By default, each bookmark matches its
|
|
281
|
+
* heading, number included. Set `numbers={false}` to leave the numbers out, or set
|
|
282
|
+
* `separator` to change the text between each number and its title. The pages, the
|
|
283
|
+
* table of contents, and the running heads keep their numbers. Place one directly
|
|
284
|
+
* inside `<Document>`.
|
|
285
|
+
*
|
|
286
|
+
* ```tsx
|
|
287
|
+
* <Document title="Handbook">
|
|
288
|
+
* <Numbering />
|
|
289
|
+
* <Bookmarks separator=". " />
|
|
290
|
+
* ...
|
|
291
|
+
* </Document>
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
function Bookmarks({ numbers, separator }) {
|
|
295
|
+
return /* @__PURE__ */ jsx(Template, {
|
|
296
|
+
"data-type": "bookmarks",
|
|
297
|
+
"data-numbers": numbers === void 0 ? void 0 : numbers ? "true" : "false",
|
|
298
|
+
"data-separator": separator
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
273
302
|
//#endregion
|
|
274
303
|
//#region src/Scope.tsx
|
|
275
304
|
/**
|
|
@@ -323,6 +352,56 @@ function Ref({ to, counter, page, as: Tag = "span", counterStyle, ...rest }) {
|
|
|
323
352
|
});
|
|
324
353
|
}
|
|
325
354
|
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region src/RunningHead.tsx
|
|
357
|
+
/**
|
|
358
|
+
* Names, in a page's header or footer, the section the page belongs to: the title
|
|
359
|
+
* of the heading `match` picks out, with its number. Place it in a Layout's
|
|
360
|
+
* scaffolding, and Format fills it on every page once the page's content is placed,
|
|
361
|
+
* so a chapter that starts halfway down a page is named correctly. The heading, its
|
|
362
|
+
* table of contents entry, and the running head always show the same number and
|
|
363
|
+
* title.
|
|
364
|
+
*
|
|
365
|
+
* Set `data-running-head` on a heading to show a shorter title (an empty value shows
|
|
366
|
+
* nothing for it), and `data-running-head-reset` on any element to end the current
|
|
367
|
+
* section, e.g. on an appendix's title page. For the heading's PDF bookmark, set
|
|
368
|
+
* `data-bookmark` the same way.
|
|
369
|
+
*
|
|
370
|
+
* The box keeps one size whatever text lands in it: one line tall, or as many lines
|
|
371
|
+
* as `--running-head-lines` sets. Give it a width in your layout, such as a grid
|
|
372
|
+
* column; text that doesn't fit is cut off, with an ellipsis when the box holds its
|
|
373
|
+
* lines. The text sits in the box's own shadow root, where your selectors don't
|
|
374
|
+
* reach: style it with `::part()`, such as `::part(title)`.
|
|
375
|
+
*
|
|
376
|
+
* ```tsx
|
|
377
|
+
* <Numbering>
|
|
378
|
+
* <NumberingRule match="h1" format="{h1:decimal-leading-zero}." />
|
|
379
|
+
* </Numbering>
|
|
380
|
+
* <Layout id="page" width={595} height={842}>
|
|
381
|
+
* <header>
|
|
382
|
+
* <RunningHead match="h1" show="start" />
|
|
383
|
+
* <PageNumber />
|
|
384
|
+
* </header>
|
|
385
|
+
* <Flow>
|
|
386
|
+
* <h1>General information</h1>
|
|
387
|
+
* ...
|
|
388
|
+
* </Flow>
|
|
389
|
+
* </Layout>
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
function RunningHead({ match, show, within, format, counterStyle, rangeSeparator, as: Tag = "span", ...rest }) {
|
|
393
|
+
return /* @__PURE__ */ jsx(Tag, {
|
|
394
|
+
"data-type": "running-head",
|
|
395
|
+
"data-match": match,
|
|
396
|
+
"data-show": show,
|
|
397
|
+
"data-within": within,
|
|
398
|
+
"data-format": format,
|
|
399
|
+
"data-counter-style": counterStyle,
|
|
400
|
+
"data-range-separator": rangeSeparator,
|
|
401
|
+
...rest
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
|
|
326
405
|
//#endregion
|
|
327
406
|
//#region src/TableOfContents.tsx
|
|
328
407
|
/**
|
|
@@ -343,6 +422,21 @@ function Ref({ to, counter, page, as: Tag = "span", counterStyle, ...rest }) {
|
|
|
343
422
|
* Children are leading content shown above the entries — put a "Contents" heading there.
|
|
344
423
|
* It shows once by default; set `repeatHead` to repeat it with the nav on every page.
|
|
345
424
|
*
|
|
425
|
+
* Place it directly in a `<Flow>` or its `<Stream>`. Inside other content, such as a
|
|
426
|
+
* `<section>`, it renders nothing.
|
|
427
|
+
*
|
|
428
|
+
* A contents lists the headings after it, up to the next contents without `within`.
|
|
429
|
+
* Set `within` to give one its own section instead, such as a chapter's sections
|
|
430
|
+
* beside the book's chapters:
|
|
431
|
+
*
|
|
432
|
+
* ```tsx
|
|
433
|
+
* <TableOfContents collect="h1">…</TableOfContents>
|
|
434
|
+
*
|
|
435
|
+
* <h1>Admissions</h1>
|
|
436
|
+
* <TableOfContents collect="h2" within="h1" />
|
|
437
|
+
* <h2>Requirements</h2>
|
|
438
|
+
* ```
|
|
439
|
+
*
|
|
346
440
|
* Give a collected heading a `data-toc-description` and its entry gains a
|
|
347
441
|
* `toc-description` line under the title (a one-line summary, as on a magazine or
|
|
348
442
|
* report contents):
|
|
@@ -357,12 +451,13 @@ function Ref({ to, counter, page, as: Tag = "span", counterStyle, ...rest }) {
|
|
|
357
451
|
* </h1>
|
|
358
452
|
* ```
|
|
359
453
|
*/
|
|
360
|
-
function TableOfContents({ collect, leader, repeatHead, className, style, children }) {
|
|
454
|
+
function TableOfContents({ collect, leader, repeatHead, within, className, style, children }) {
|
|
361
455
|
return /* @__PURE__ */ jsx(Template, {
|
|
362
456
|
"data-type": "toc",
|
|
363
457
|
"data-collect": collect,
|
|
364
458
|
"data-leader": leader,
|
|
365
459
|
"data-repeat-head": repeatHead === void 0 ? void 0 : repeatHead ? "true" : "false",
|
|
460
|
+
"data-within": within,
|
|
366
461
|
className,
|
|
367
462
|
style,
|
|
368
463
|
children
|
|
@@ -450,5 +545,5 @@ const TocLeader = {
|
|
|
450
545
|
};
|
|
451
546
|
|
|
452
547
|
//#endregion
|
|
453
|
-
export { Counter, CounterDef, Document, Flow, Footnote, Footnotes, Layout, Numbering, NumberingRule, PageBreak, PageCount, PageNumber, Ref, Scope, SplitGranularity, Stream, TableOfContents, TocLeader, css };
|
|
548
|
+
export { Bookmarks, Counter, CounterDef, Document, Flow, Footnote, Footnotes, Layout, Numbering, NumberingRule, PageBreak, PageCount, PageNumber, Ref, RunningHead, Scope, SplitGranularity, Stream, TableOfContents, TocLeader, css };
|
|
454
549
|
//# sourceMappingURL=index.js.map
|