@format.dev/react 0.1.3 → 0.3.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/dist/index.cjs +110 -12
- package/dist/index.d.cts +205 -21
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +205 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +109 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
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.3.0";
|
|
45
45
|
|
|
46
46
|
//#endregion
|
|
47
47
|
//#region src/sdk-version.ts
|
|
48
|
-
const sdkVersion = "0.
|
|
48
|
+
const sdkVersion = "0.3.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__ */ (0, react_jsx_runtime.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
|
});
|
|
@@ -206,32 +207,35 @@ function Counter({ name, peek, reset, set, by, join, as: Tag = "span", counterSt
|
|
|
206
207
|
//#endregion
|
|
207
208
|
//#region src/Numbering.tsx
|
|
208
209
|
/**
|
|
209
|
-
* Turns on document-wide numbering.
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
210
|
+
* Turns on document-wide numbering. By default it numbers headings `h1` through
|
|
211
|
+
* `h6` hierarchically — `1`, `1.1`, `1.1.1` — with each level resetting the ones
|
|
212
|
+
* beneath it. Add <NumberingRule> children to number other things; they add to the
|
|
213
|
+
* default headings. To number headings your own way, set `defaultHeadings={false}`
|
|
214
|
+
* and write rules for them.
|
|
213
215
|
*
|
|
214
216
|
* Numbers are resolved before pages are split, so they stay correct across page
|
|
215
217
|
* breaks where plain CSS counters would reset.
|
|
216
218
|
*
|
|
217
219
|
* ```tsx
|
|
218
|
-
* <Document title="Report">
|
|
220
|
+
* <Document title="Report" lang="en">
|
|
219
221
|
* <Numbering />
|
|
220
222
|
* ...
|
|
221
223
|
* </Document>
|
|
222
224
|
* ```
|
|
223
225
|
*/
|
|
224
|
-
function Numbering({ counterStyle, children }) {
|
|
226
|
+
function Numbering({ counterStyle, defaultHeadings, children }) {
|
|
225
227
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Template, {
|
|
226
228
|
"data-type": "numbering",
|
|
227
229
|
"data-counter-style": counterStyle,
|
|
230
|
+
"data-default-headings": defaultHeadings === void 0 ? void 0 : defaultHeadings ? "true" : "false",
|
|
228
231
|
children
|
|
229
232
|
});
|
|
230
233
|
}
|
|
231
234
|
/**
|
|
232
235
|
* One numbering rule, used as `<NumberingRule>` inside `<Numbering>`. Each rule
|
|
233
|
-
* matches a selector and advances (and optionally inserts) a counter.
|
|
234
|
-
*
|
|
236
|
+
* matches a selector and advances (and optionally inserts) a counter. Rules add to
|
|
237
|
+
* the default headings; to change the heading format, set
|
|
238
|
+
* `<Numbering defaultHeadings={false}>` and number the headings with rules.
|
|
235
239
|
*/
|
|
236
240
|
function NumberingRule({ match, counter, format, increment, set, counterStyle, insert }) {
|
|
237
241
|
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production" && set !== void 0 && increment !== void 0) console.error("<NumberingRule>: `set` and `increment` are mutually exclusive; `set` forces an exact value and wins, `increment` is ignored.");
|
|
@@ -267,6 +271,32 @@ function CounterDef({ name, resetEach }) {
|
|
|
267
271
|
});
|
|
268
272
|
}
|
|
269
273
|
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/Bookmarks.tsx
|
|
276
|
+
/**
|
|
277
|
+
* Controls how heading numbers appear in the PDF's bookmarks, the clickable outline
|
|
278
|
+
* that PDF viewers show beside the pages. By default, each bookmark matches its
|
|
279
|
+
* heading, number included. Set `numbers={false}` to leave the numbers out, or set
|
|
280
|
+
* `separator` to change the text between each number and its title. The pages, the
|
|
281
|
+
* table of contents, and the running heads keep their numbers. Place one directly
|
|
282
|
+
* inside `<Document>`.
|
|
283
|
+
*
|
|
284
|
+
* ```tsx
|
|
285
|
+
* <Document title="Handbook">
|
|
286
|
+
* <Numbering />
|
|
287
|
+
* <Bookmarks separator=". " />
|
|
288
|
+
* ...
|
|
289
|
+
* </Document>
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
function Bookmarks({ numbers, separator }) {
|
|
293
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Template, {
|
|
294
|
+
"data-type": "bookmarks",
|
|
295
|
+
"data-numbers": numbers === void 0 ? void 0 : numbers ? "true" : "false",
|
|
296
|
+
"data-separator": separator
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
270
300
|
//#endregion
|
|
271
301
|
//#region src/Scope.tsx
|
|
272
302
|
/**
|
|
@@ -320,6 +350,56 @@ function Ref({ to, counter, page, as: Tag = "span", counterStyle, ...rest }) {
|
|
|
320
350
|
});
|
|
321
351
|
}
|
|
322
352
|
|
|
353
|
+
//#endregion
|
|
354
|
+
//#region src/RunningHead.tsx
|
|
355
|
+
/**
|
|
356
|
+
* Names, in a page's header or footer, the section the page belongs to: the title
|
|
357
|
+
* of the heading `match` picks out, with its number. Place it in a Layout's
|
|
358
|
+
* scaffolding, and Format fills it on every page once the page's content is placed,
|
|
359
|
+
* so a chapter that starts halfway down a page is named correctly. The heading, its
|
|
360
|
+
* table of contents entry, and the running head always show the same number and
|
|
361
|
+
* title.
|
|
362
|
+
*
|
|
363
|
+
* Set `data-running-head` on a heading to show a shorter title (an empty value shows
|
|
364
|
+
* nothing for it), and `data-running-head-reset` on any element to end the current
|
|
365
|
+
* section, e.g. on an appendix's title page. For the heading's PDF bookmark, set
|
|
366
|
+
* `data-bookmark` the same way.
|
|
367
|
+
*
|
|
368
|
+
* The box keeps one size whatever text lands in it: one line tall, or as many lines
|
|
369
|
+
* as `--running-head-lines` sets. Give it a width in your layout, such as a grid
|
|
370
|
+
* column; text that doesn't fit is cut off, with an ellipsis when the box holds its
|
|
371
|
+
* lines. The text sits in the box's own shadow root, where your selectors don't
|
|
372
|
+
* reach: style it with `::part()`, such as `::part(title)`.
|
|
373
|
+
*
|
|
374
|
+
* ```tsx
|
|
375
|
+
* <Numbering>
|
|
376
|
+
* <NumberingRule match="h1" format="{h1:decimal-leading-zero}." />
|
|
377
|
+
* </Numbering>
|
|
378
|
+
* <Layout id="page" width={595} height={842}>
|
|
379
|
+
* <header>
|
|
380
|
+
* <RunningHead match="h1" show="start" />
|
|
381
|
+
* <PageNumber />
|
|
382
|
+
* </header>
|
|
383
|
+
* <Flow>
|
|
384
|
+
* <h1>General information</h1>
|
|
385
|
+
* ...
|
|
386
|
+
* </Flow>
|
|
387
|
+
* </Layout>
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
function RunningHead({ match, show, within, format, counterStyle, rangeSeparator, as: Tag = "span", ...rest }) {
|
|
391
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tag, {
|
|
392
|
+
"data-type": "running-head",
|
|
393
|
+
"data-match": match,
|
|
394
|
+
"data-show": show,
|
|
395
|
+
"data-within": within,
|
|
396
|
+
"data-format": format,
|
|
397
|
+
"data-counter-style": counterStyle,
|
|
398
|
+
"data-range-separator": rangeSeparator,
|
|
399
|
+
...rest
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
|
|
323
403
|
//#endregion
|
|
324
404
|
//#region src/TableOfContents.tsx
|
|
325
405
|
/**
|
|
@@ -340,6 +420,21 @@ function Ref({ to, counter, page, as: Tag = "span", counterStyle, ...rest }) {
|
|
|
340
420
|
* Children are leading content shown above the entries — put a "Contents" heading there.
|
|
341
421
|
* It shows once by default; set `repeatHead` to repeat it with the nav on every page.
|
|
342
422
|
*
|
|
423
|
+
* Place it directly in a `<Flow>` or its `<Stream>`. Inside other content, such as a
|
|
424
|
+
* `<section>`, it renders nothing.
|
|
425
|
+
*
|
|
426
|
+
* A contents lists the headings after it, up to the next contents without `within`.
|
|
427
|
+
* Set `within` to give one its own section instead, such as a chapter's sections
|
|
428
|
+
* beside the book's chapters:
|
|
429
|
+
*
|
|
430
|
+
* ```tsx
|
|
431
|
+
* <TableOfContents collect="h1">…</TableOfContents>
|
|
432
|
+
*
|
|
433
|
+
* <h1>Admissions</h1>
|
|
434
|
+
* <TableOfContents collect="h2" within="h1" />
|
|
435
|
+
* <h2>Requirements</h2>
|
|
436
|
+
* ```
|
|
437
|
+
*
|
|
343
438
|
* Give a collected heading a `data-toc-description` and its entry gains a
|
|
344
439
|
* `toc-description` line under the title (a one-line summary, as on a magazine or
|
|
345
440
|
* report contents):
|
|
@@ -354,12 +449,13 @@ function Ref({ to, counter, page, as: Tag = "span", counterStyle, ...rest }) {
|
|
|
354
449
|
* </h1>
|
|
355
450
|
* ```
|
|
356
451
|
*/
|
|
357
|
-
function TableOfContents({ collect, leader, repeatHead, className, style, children }) {
|
|
452
|
+
function TableOfContents({ collect, leader, repeatHead, within, className, style, children }) {
|
|
358
453
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Template, {
|
|
359
454
|
"data-type": "toc",
|
|
360
455
|
"data-collect": collect,
|
|
361
456
|
"data-leader": leader,
|
|
362
457
|
"data-repeat-head": repeatHead === void 0 ? void 0 : repeatHead ? "true" : "false",
|
|
458
|
+
"data-within": within,
|
|
363
459
|
className,
|
|
364
460
|
style,
|
|
365
461
|
children
|
|
@@ -447,6 +543,7 @@ const TocLeader = {
|
|
|
447
543
|
};
|
|
448
544
|
|
|
449
545
|
//#endregion
|
|
546
|
+
exports.Bookmarks = Bookmarks;
|
|
450
547
|
exports.Counter = Counter;
|
|
451
548
|
exports.CounterDef = CounterDef;
|
|
452
549
|
exports.Document = Document;
|
|
@@ -460,6 +557,7 @@ exports.PageBreak = PageBreak;
|
|
|
460
557
|
exports.PageCount = PageCount;
|
|
461
558
|
exports.PageNumber = PageNumber;
|
|
462
559
|
exports.Ref = Ref;
|
|
560
|
+
exports.RunningHead = RunningHead;
|
|
463
561
|
exports.Scope = Scope;
|
|
464
562
|
exports.SplitGranularity = SplitGranularity;
|
|
465
563
|
exports.Stream = Stream;
|
package/dist/index.d.cts
CHANGED
|
@@ -29,6 +29,18 @@ type TocLeader = (typeof TocLeader)[keyof typeof TocLeader];
|
|
|
29
29
|
/** How a Layout or Flow decides where pages break: `auto` on overflow
|
|
30
30
|
* and at PageBreak markers, `manual` at PageBreak markers only. */
|
|
31
31
|
type PaginationStrategy = 'auto' | 'manual';
|
|
32
|
+
/**
|
|
33
|
+
* Which matched heading a `<RunningHead>` shows on a page: the `first` or `last`
|
|
34
|
+
* match on the page, the one the page `start`s with, `firstExcept` to show nothing
|
|
35
|
+
* on a page where a match appears, or the `range` of sections the page holds. On a
|
|
36
|
+
* page with no match, each shows the section carried over from earlier pages.
|
|
37
|
+
*/
|
|
38
|
+
type RunningHeadShow = 'first' | 'start' | 'last' | 'firstExcept' | 'range';
|
|
39
|
+
/**
|
|
40
|
+
* The elements a `<RunningHead>` can render as: those that can hold a shadow root,
|
|
41
|
+
* where its text goes.
|
|
42
|
+
*/
|
|
43
|
+
type RunningHeadElement = 'span' | 'div' | 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'header' | 'footer' | 'nav' | 'section' | 'article' | 'aside' | 'blockquote' | 'main' | 'body';
|
|
32
44
|
/**
|
|
33
45
|
* How the PDF embeds its fonts. Mirrors `FontMode` in `@format.dev/fonts`, which owns
|
|
34
46
|
* the canonical list and the default.
|
|
@@ -47,16 +59,21 @@ interface DocumentProps {
|
|
|
47
59
|
author?: string;
|
|
48
60
|
keywords?: string[];
|
|
49
61
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
* The language the document is written in, as a BCP 47 language tag such as
|
|
63
|
+
* `'fr'` or `'pt-BR'`. Format adds it to your PDF, and screen readers use it to
|
|
64
|
+
* choose the right voice and pronunciation. Format also applies that language's
|
|
65
|
+
* conventions for quotation marks and letter case to every page. Set it on
|
|
66
|
+
* every document: without it, your PDF has no language and doesn't meet
|
|
67
|
+
* accessibility standards such as WCAG and PDF/UA. Format ignores invalid tags,
|
|
68
|
+
* such as `'en_US'` or `'english'`. To mark a passage in a different language,
|
|
69
|
+
* add a `lang` attribute to its element.
|
|
70
|
+
*/
|
|
71
|
+
lang?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Selects the versions of Format's built-in Sans, Serif, and Mono fonts.
|
|
74
|
+
* `compact` (default) uses static fonts for smaller PDFs. `fidelity` uses
|
|
75
|
+
* variable fonts, preserving optical sizing where supported, but typically
|
|
76
|
+
* produces larger PDFs. Custom fonts are used as supplied in either mode.
|
|
60
77
|
*/
|
|
61
78
|
fonts?: FontMode;
|
|
62
79
|
}
|
|
@@ -68,7 +85,7 @@ interface DocumentProps {
|
|
|
68
85
|
* import type { Invoice } from './types'
|
|
69
86
|
*
|
|
70
87
|
* export default function InvoiceDocument({ data }: RenderProps<Invoice>) {
|
|
71
|
-
* return <Document title={`Invoice #${data.id}`}>{/* ... *\/}</Document>
|
|
88
|
+
* return <Document title={`Invoice #${data.id}`} lang="en">{/* ... *\/}</Document>
|
|
72
89
|
* }
|
|
73
90
|
* ```
|
|
74
91
|
*/
|
|
@@ -80,6 +97,7 @@ declare function Document({
|
|
|
80
97
|
subject,
|
|
81
98
|
author,
|
|
82
99
|
keywords,
|
|
100
|
+
lang,
|
|
83
101
|
fonts,
|
|
84
102
|
children
|
|
85
103
|
}: PropsWithChildren<DocumentProps>): react0.JSX.Element;
|
|
@@ -266,7 +284,9 @@ declare function Counter({
|
|
|
266
284
|
interface NumberingRuleBase {
|
|
267
285
|
/**
|
|
268
286
|
* CSS selector for the elements this rule numbers, e.g. `h2`, `figure figcaption`,
|
|
269
|
-
* `.step`. Every match advances the counter in document order.
|
|
287
|
+
* `.step`. Every match advances the counter in document order. It matches the
|
|
288
|
+
* content that flows across pages, without the Layout or Flow scaffolding around
|
|
289
|
+
* it: when a Layout wraps its Flow in `<main>`, `main h2` matches nothing.
|
|
270
290
|
*/
|
|
271
291
|
match: string;
|
|
272
292
|
/**
|
|
@@ -318,18 +338,25 @@ interface NumberingProps {
|
|
|
318
338
|
* per-Counter, and per-Footnotes styles override it. Defaults to `decimal`.
|
|
319
339
|
*/
|
|
320
340
|
counterStyle?: CounterStyle;
|
|
341
|
+
/**
|
|
342
|
+
* Whether headings `h1` through `h6` get the built-in hierarchical numbers. On by
|
|
343
|
+
* default. Set `false` when your own rules number the headings; that removes the
|
|
344
|
+
* built-in restarts between heading levels as well as the built-in numbers.
|
|
345
|
+
*/
|
|
346
|
+
defaultHeadings?: boolean;
|
|
321
347
|
}
|
|
322
348
|
/**
|
|
323
|
-
* Turns on document-wide numbering.
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
349
|
+
* Turns on document-wide numbering. By default it numbers headings `h1` through
|
|
350
|
+
* `h6` hierarchically — `1`, `1.1`, `1.1.1` — with each level resetting the ones
|
|
351
|
+
* beneath it. Add <NumberingRule> children to number other things; they add to the
|
|
352
|
+
* default headings. To number headings your own way, set `defaultHeadings={false}`
|
|
353
|
+
* and write rules for them.
|
|
327
354
|
*
|
|
328
355
|
* Numbers are resolved before pages are split, so they stay correct across page
|
|
329
356
|
* breaks where plain CSS counters would reset.
|
|
330
357
|
*
|
|
331
358
|
* ```tsx
|
|
332
|
-
* <Document title="Report">
|
|
359
|
+
* <Document title="Report" lang="en">
|
|
333
360
|
* <Numbering />
|
|
334
361
|
* ...
|
|
335
362
|
* </Document>
|
|
@@ -337,12 +364,14 @@ interface NumberingProps {
|
|
|
337
364
|
*/
|
|
338
365
|
declare function Numbering({
|
|
339
366
|
counterStyle,
|
|
367
|
+
defaultHeadings,
|
|
340
368
|
children
|
|
341
369
|
}: PropsWithChildren<NumberingProps>): react0.JSX.Element;
|
|
342
370
|
/**
|
|
343
371
|
* One numbering rule, used as `<NumberingRule>` inside `<Numbering>`. Each rule
|
|
344
|
-
* matches a selector and advances (and optionally inserts) a counter.
|
|
345
|
-
*
|
|
372
|
+
* matches a selector and advances (and optionally inserts) a counter. Rules add to
|
|
373
|
+
* the default headings; to change the heading format, set
|
|
374
|
+
* `<Numbering defaultHeadings={false}>` and number the headings with rules.
|
|
346
375
|
*/
|
|
347
376
|
declare function NumberingRule({
|
|
348
377
|
match,
|
|
@@ -381,6 +410,42 @@ declare function CounterDef({
|
|
|
381
410
|
resetEach
|
|
382
411
|
}: CounterDefProps): react0.JSX.Element;
|
|
383
412
|
//#endregion
|
|
413
|
+
//#region src/Bookmarks.d.ts
|
|
414
|
+
interface BookmarksProps {
|
|
415
|
+
/**
|
|
416
|
+
* Whether bookmarks include the numbers `<Numbering>` adds to headings. On by
|
|
417
|
+
* default. Set `false` to show titles alone, such as "Fees" instead of "3 Fees".
|
|
418
|
+
* Text you write in a heading always stays, including digits and the value of a
|
|
419
|
+
* `<Counter>`.
|
|
420
|
+
*/
|
|
421
|
+
numbers?: boolean;
|
|
422
|
+
/**
|
|
423
|
+
* The text between each number and its title, such as `". "` for "3. Fees".
|
|
424
|
+
* Defaults to a space, as on the page. An empty string joins them, as in "3Fees".
|
|
425
|
+
*/
|
|
426
|
+
separator?: string;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Controls how heading numbers appear in the PDF's bookmarks, the clickable outline
|
|
430
|
+
* that PDF viewers show beside the pages. By default, each bookmark matches its
|
|
431
|
+
* heading, number included. Set `numbers={false}` to leave the numbers out, or set
|
|
432
|
+
* `separator` to change the text between each number and its title. The pages, the
|
|
433
|
+
* table of contents, and the running heads keep their numbers. Place one directly
|
|
434
|
+
* inside `<Document>`.
|
|
435
|
+
*
|
|
436
|
+
* ```tsx
|
|
437
|
+
* <Document title="Handbook">
|
|
438
|
+
* <Numbering />
|
|
439
|
+
* <Bookmarks separator=". " />
|
|
440
|
+
* ...
|
|
441
|
+
* </Document>
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
|
+
declare function Bookmarks({
|
|
445
|
+
numbers,
|
|
446
|
+
separator
|
|
447
|
+
}: BookmarksProps): react0.JSX.Element;
|
|
448
|
+
//#endregion
|
|
384
449
|
//#region src/Scope.d.ts
|
|
385
450
|
interface ScopeProps {
|
|
386
451
|
/**
|
|
@@ -464,10 +529,104 @@ declare function Ref({
|
|
|
464
529
|
...rest
|
|
465
530
|
}: RefProps): react0.JSX.Element;
|
|
466
531
|
//#endregion
|
|
532
|
+
//#region src/RunningHead.d.ts
|
|
533
|
+
interface RunningHeadProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
|
|
534
|
+
/**
|
|
535
|
+
* CSS selector for the headings to follow, e.g. `h1`. Like a `<NumberingRule>`'s
|
|
536
|
+
* `match`, it matches the content that flows across pages, without the scaffolding
|
|
537
|
+
* around it: select on the heading itself, e.g. `h1` rather than `main h1`.
|
|
538
|
+
*/
|
|
539
|
+
match: string;
|
|
540
|
+
/**
|
|
541
|
+
* Which match to show on each page. `first` (the default) shows the first match on
|
|
542
|
+
* the page; `start` shows the match the page opens with, else the section the page
|
|
543
|
+
* continues; `last` shows the last match; `firstExcept` shows nothing on a page
|
|
544
|
+
* where a match appears; `range` shows the first and last section the page holds.
|
|
545
|
+
* A page with no match shows the section carried over from earlier pages.
|
|
546
|
+
*/
|
|
547
|
+
show?: RunningHeadShow;
|
|
548
|
+
/**
|
|
549
|
+
* CSS selector for the headings that enclose the followed ones, e.g. `h1` for a
|
|
550
|
+
* running head that follows `h2` sections. A match ends the current section, and
|
|
551
|
+
* only sections of the chapter in effect are shown. A chapter running head and a
|
|
552
|
+
* section running head on one page agree when they use the same `show` other
|
|
553
|
+
* than `range`, or when the chapter uses `start` beside a section `range`.
|
|
554
|
+
*/
|
|
555
|
+
within?: string;
|
|
556
|
+
/**
|
|
557
|
+
* The number to show, with `{counter}` placeholders read where the heading sits,
|
|
558
|
+
* e.g. `{h1:decimal-leading-zero}.`. Defaults to the number the heading shows.
|
|
559
|
+
*/
|
|
560
|
+
format?: string;
|
|
561
|
+
/**
|
|
562
|
+
* Default `<counter-style>` for placeholders in `format`. Defaults to the
|
|
563
|
+
* document's numbering style, or `decimal`.
|
|
564
|
+
*/
|
|
565
|
+
counterStyle?: CounterStyle;
|
|
566
|
+
/**
|
|
567
|
+
* The text between the first and last section when `show` is `range`. Defaults to
|
|
568
|
+
* an en dash with a space either side.
|
|
569
|
+
*/
|
|
570
|
+
rangeSeparator?: string;
|
|
571
|
+
/**
|
|
572
|
+
* HTML tag to render: `span` (the default), `div`, `p`, a heading, or a sectioning
|
|
573
|
+
* element such as `header`. The text goes in a shadow root, which only these
|
|
574
|
+
* elements can hold.
|
|
575
|
+
*/
|
|
576
|
+
as?: RunningHeadElement;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Names, in a page's header or footer, the section the page belongs to: the title
|
|
580
|
+
* of the heading `match` picks out, with its number. Place it in a Layout's
|
|
581
|
+
* scaffolding, and Format fills it on every page once the page's content is placed,
|
|
582
|
+
* so a chapter that starts halfway down a page is named correctly. The heading, its
|
|
583
|
+
* table of contents entry, and the running head always show the same number and
|
|
584
|
+
* title.
|
|
585
|
+
*
|
|
586
|
+
* Set `data-running-head` on a heading to show a shorter title (an empty value shows
|
|
587
|
+
* nothing for it), and `data-running-head-reset` on any element to end the current
|
|
588
|
+
* section, e.g. on an appendix's title page. For the heading's PDF bookmark, set
|
|
589
|
+
* `data-bookmark` the same way.
|
|
590
|
+
*
|
|
591
|
+
* The box keeps one size whatever text lands in it: one line tall, or as many lines
|
|
592
|
+
* as `--running-head-lines` sets. Give it a width in your layout, such as a grid
|
|
593
|
+
* column; text that doesn't fit is cut off, with an ellipsis when the box holds its
|
|
594
|
+
* lines. The text sits in the box's own shadow root, where your selectors don't
|
|
595
|
+
* reach: style it with `::part()`, such as `::part(title)`.
|
|
596
|
+
*
|
|
597
|
+
* ```tsx
|
|
598
|
+
* <Numbering>
|
|
599
|
+
* <NumberingRule match="h1" format="{h1:decimal-leading-zero}." />
|
|
600
|
+
* </Numbering>
|
|
601
|
+
* <Layout id="page" width={595} height={842}>
|
|
602
|
+
* <header>
|
|
603
|
+
* <RunningHead match="h1" show="start" />
|
|
604
|
+
* <PageNumber />
|
|
605
|
+
* </header>
|
|
606
|
+
* <Flow>
|
|
607
|
+
* <h1>General information</h1>
|
|
608
|
+
* ...
|
|
609
|
+
* </Flow>
|
|
610
|
+
* </Layout>
|
|
611
|
+
* ```
|
|
612
|
+
*/
|
|
613
|
+
declare function RunningHead({
|
|
614
|
+
match,
|
|
615
|
+
show,
|
|
616
|
+
within,
|
|
617
|
+
format,
|
|
618
|
+
counterStyle,
|
|
619
|
+
rangeSeparator,
|
|
620
|
+
as: Tag,
|
|
621
|
+
...rest
|
|
622
|
+
}: RunningHeadProps): react0.JSX.Element;
|
|
623
|
+
//#endregion
|
|
467
624
|
//#region src/TableOfContents.d.ts
|
|
468
625
|
interface TableOfContentsProps {
|
|
469
626
|
/**
|
|
470
|
-
* CSS selector for the headings to list. Defaults to `h1, h2, h3`.
|
|
627
|
+
* CSS selector for the headings to list. Defaults to `h1, h2, h3`. Like a
|
|
628
|
+
* `<NumberingRule>`'s `match`, it matches the content that flows across pages,
|
|
629
|
+
* without the scaffolding around it.
|
|
471
630
|
*/
|
|
472
631
|
collect?: string;
|
|
473
632
|
/**
|
|
@@ -480,6 +639,15 @@ interface TableOfContentsProps {
|
|
|
480
639
|
* running header. Off by default: the leading content shows once, above the entries.
|
|
481
640
|
*/
|
|
482
641
|
repeatHead?: boolean;
|
|
642
|
+
/**
|
|
643
|
+
* CSS selector for the headings that enclose the listed ones, e.g. `h1` for a
|
|
644
|
+
* chapter's list of its sections. Place the contents after the chapter's heading:
|
|
645
|
+
* it lists the headings up to the next match. It runs independently of every other
|
|
646
|
+
* contents, so a book's contents can list every chapter while each chapter lists
|
|
647
|
+
* its own sections. Without it, a contents runs to the next contents without
|
|
648
|
+
* `within`.
|
|
649
|
+
*/
|
|
650
|
+
within?: string;
|
|
483
651
|
/**
|
|
484
652
|
* Leading content rendered at the top of the contents, above the entries — a
|
|
485
653
|
* "Contents" heading, an intro line, a rule. Shown once by default; set `repeatHead`
|
|
@@ -512,6 +680,21 @@ interface TableOfContentsProps {
|
|
|
512
680
|
* Children are leading content shown above the entries — put a "Contents" heading there.
|
|
513
681
|
* It shows once by default; set `repeatHead` to repeat it with the nav on every page.
|
|
514
682
|
*
|
|
683
|
+
* Place it directly in a `<Flow>` or its `<Stream>`. Inside other content, such as a
|
|
684
|
+
* `<section>`, it renders nothing.
|
|
685
|
+
*
|
|
686
|
+
* A contents lists the headings after it, up to the next contents without `within`.
|
|
687
|
+
* Set `within` to give one its own section instead, such as a chapter's sections
|
|
688
|
+
* beside the book's chapters:
|
|
689
|
+
*
|
|
690
|
+
* ```tsx
|
|
691
|
+
* <TableOfContents collect="h1">…</TableOfContents>
|
|
692
|
+
*
|
|
693
|
+
* <h1>Admissions</h1>
|
|
694
|
+
* <TableOfContents collect="h2" within="h1" />
|
|
695
|
+
* <h2>Requirements</h2>
|
|
696
|
+
* ```
|
|
697
|
+
*
|
|
515
698
|
* Give a collected heading a `data-toc-description` and its entry gains a
|
|
516
699
|
* `toc-description` line under the title (a one-line summary, as on a magazine or
|
|
517
700
|
* report contents):
|
|
@@ -530,6 +713,7 @@ declare function TableOfContents({
|
|
|
530
713
|
collect,
|
|
531
714
|
leader,
|
|
532
715
|
repeatHead,
|
|
716
|
+
within,
|
|
533
717
|
className,
|
|
534
718
|
style,
|
|
535
719
|
children
|
|
@@ -617,5 +801,5 @@ declare function Footnotes({
|
|
|
617
801
|
*/
|
|
618
802
|
declare function css(parts: TemplateStringsArray, ...vals: unknown[]): string;
|
|
619
803
|
//#endregion
|
|
620
|
-
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 };
|
|
804
|
+
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, 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 };
|
|
621
805
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","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;EAIpB,SAAA,IAAA,EAAA,MAAkB;
|
|
1
|
+
{"version":3,"file":"index.d.cts","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;EAIpB,SAAA,IAAA,EAAA,MAAkB;EAQlB,SAAA,QAAA,EAAe,UAAA;EAMf,SAAA,IAAA,EAAA,MAAkB;AAwB9B,CAAA;AAMY,KA5DA,gBAAA,GA4DY,CAAA,OA5De,gBA4Df,CAAA,CAAA,MAAA,OA5D8C,gBA4D9C,CAAA;;;;ACnExB;AAqCA;AAIgB,cD3BH,SC2BW,EAAA;EACvB,SAAA,IAAA,EAAA,MAAA;EACA,SAAA,IAAA,EAAA,MAAA;CACA;AACA,KD1BW,SAAA,GC0BX,CAAA,OD1B+B,SC0B/B,CAAA,CAAA,MAAA,OD1BuD,SC0BvD,CAAA;;;AAGA,KDzBW,kBAAA,GCyBX,MAAA,GAAA,QAAA;;;;;;;KDjBW,eAAA;AEjCZ;AAUA;;;AAGC,KF0BW,kBAAA,GE1BX,MAAA,GAAA,KAAA,GAAA,GAAA,GAAA,IAAA,GAAA,IAAA,GAAA,IAAA,GAAA,IAAA,GAAA,IAAA,GAAA,IAAA,GAAA,QAAA,GAAA,QAAA,GAAA,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