@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.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["engineTarget: string","sdkVersion: string","mergedStyle: CSSProperties | undefined"],"sources":["../src/utils.ts","../src/Template.tsx","../src/engine-target.ts","../src/sdk-version.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/types.ts"],"sourcesContent":["// react's attribute order is not guaranteed, so rel and as are matched independently\nconst IMAGE_PRELOAD_LINK = /<link\\b(?=[^>]*\\brel=\"preload\")(?=[^>]*\\bas=\"image\")[^>]*>/g\n\n/**\n * Removes the `<link rel=\"preload\" as=\"image\">` tags that React's server\n * renderer emits ahead of every eager `<img>`. The engine allows a `<link>`\n * only when its `rel` is `stylesheet`, and fails the render with an\n * `INVALID_HTML_LINK_ELEMENT` 400 otherwise.\n */\nexport function stripImagePreloads(html: string): string {\n\treturn html.replace(IMAGE_PRELOAD_LINK, '')\n}\n\n/**\n * Tagged template for authoring CSS, typically inside a `<style>` element.\n * Returns the string from the raw segments, so CSS escapes (`\\2014`,\n * icon-font codepoints, escaped selectors) survive intact. Interpolated\n * `null`, `undefined`, and `false` collapse to an empty string for clean\n * conditional rules. The `css` name also lets editors and the Format docs\n * highlighter treat the contents as CSS.\n */\nexport function css(parts: TemplateStringsArray, ...vals: unknown[]): string {\n\tlet out = parts.raw[0] ?? ''\n\tfor (let i = 0; i < vals.length; i++) {\n\t\tconst v = vals[i]\n\t\tout += (v == null || v === false ? '' : String(v)) + parts.raw[i + 1]!\n\t}\n\treturn out\n}\n","import type { PropsWithChildren } from 'react'\nimport { renderToStaticMarkup } from 'react-dom/server'\nimport { stripImagePreloads } from './utils'\n\nexport type TemplateProps = React.HTMLAttributes<HTMLTemplateElement>\n\nexport function Template({ children, ...props }: PropsWithChildren<TemplateProps>) {\n\tconst html = stripImagePreloads(renderToStaticMarkup(children))\n\treturn <template {...props} dangerouslySetInnerHTML={{ __html: html }} />\n}\n","// The released engine version targeted by documents built from this package.\n// Each build supplies `FORMAT_ENGINE_TARGET` for itself, so the same source can\n// be built against different engines. It has to arrive as a free identifier,\n// because `define` substitutes those and not import bindings; see\n// build/release/README.md.\ndeclare const FORMAT_ENGINE_TARGET: string\n\nexport const engineTarget: string = FORMAT_ENGINE_TARGET\n","// The Format release this package belongs to, written into every document it\n// renders as `data-sdk`. It names the SDK/toolchain that produced the markup,\n// which is a different question from the engine that will lay it out\n// (`data-engine`) and from the client that will submit it.\n//\n// Each build supplies `FORMAT_JS_VERSION` for itself, so the same source can be\n// built at different release numbers. It has to arrive as a free identifier,\n// because `define` substitutes those and not import bindings; see\n// build/release/README.md.\ndeclare const FORMAT_JS_VERSION: string\n\nexport const sdkVersion: string = FORMAT_JS_VERSION\n","import type { PropsWithChildren } from 'react'\nimport { Template } from './Template'\nimport type { FontMode } from './types'\nimport { engineTarget } from './engine-target'\nimport { sdkVersion } from './sdk-version'\n\nexport interface DocumentProps {\n\ttitle: string\n\tsubject?: string\n\tauthor?: string\n\tkeywords?: string[]\n\t/**\n\t * How the PDF embeds its fonts — file size against rendering quality. Leave\n\t * unset for most documents; set `'fidelity'` when exact text rendering\n\t * matters more than file size.\n\t *\n\t * - Compact (the default) keeps files small: the fonts embed as subset CID\n\t * instances, so the optical size is fixed and strokes can look slightly\n\t * heavier in some viewers (for example macOS Preview).\n\t * - Fidelity gives the best-looking output: text keeps its exact optical\n\t * sizing and renders at the same weight in every PDF viewer. The cost is a\n\t * larger file, since the fonts embed as Type 3.\n\t */\n\tfonts?: FontMode\n}\n\n/**\n * Props the Format runtime passes to a document entry function. The\n * generic parameter is the shape of the active data variant.\n *\n * ```tsx\n * import type { Invoice } from './types'\n *\n * export default function InvoiceDocument({ data }: RenderProps<Invoice>) {\n * return <Document title={`Invoice #${data.id}`}>{/* ... *\\/}</Document>\n * }\n * ```\n */\nexport interface RenderProps<T = unknown> {\n\tdata: T\n}\n\nexport function Document({ title, subject, author, keywords, fonts, children }: PropsWithChildren<DocumentProps>) {\n\tconst keywordsString = keywords?.join(', ')\n\n\treturn (\n\t\t<Template\n\t\t\tdata-sdk={sdkVersion}\n\t\t\tdata-engine={engineTarget}\n\t\t\tdata-type='document'\n\t\t\tdata-title={title}\n\t\t\tdata-subject={subject}\n\t\t\tdata-author={author}\n\t\t\tdata-keywords={keywordsString}\n\t\t\tdata-fonts={fonts}>\n\t\t\t{children}\n\t\t</Template>\n\t)\n}\n","import type { PropsWithChildren } from 'react'\nimport { Template } from './Template'\nimport type { PaginationStrategy, SplitGranularity } from './types'\n\nexport interface LayoutProps {\n\t/** Design label, mirrored to each page as `data-layout-id` for CSS. Optional:\n\t * when omitted, the engine generates one from the Layout's document position. */\n\tid?: string\n\twidth: number\n\theight: number\n\tpaginationStrategy?: PaginationStrategy\n\tsplitGranularity?: SplitGranularity\n}\n\nexport function Layout({\n\tid,\n\twidth,\n\theight,\n\tpaginationStrategy,\n\tsplitGranularity,\n\tchildren\n}: PropsWithChildren<LayoutProps>) {\n\treturn (\n\t\t<Template\n\t\t\tdata-type='layout'\n\t\t\tdata-id={id}\n\t\t\tdata-width={`${width}px`}\n\t\t\tdata-height={`${height}px`}\n\t\t\tdata-pagination-strategy={paginationStrategy}\n\t\t\tdata-split-granularity={splitGranularity}>\n\t\t\t{children}\n\t\t</Template>\n\t)\n}\n","import type { PropsWithChildren } from 'react'\nimport { Template } from './Template'\nimport type { PaginationStrategy, SplitGranularity } from './types'\n\nexport interface FlowProps {\n\t/** How content breaks when it doesn't fit the current page. When unset, it\n\t * inherits from the enclosing Flow, then the Layout, then defaults to `none`. */\n\tsplitGranularity?: SplitGranularity\n\t/** Whether this Flow paginates on overflow (`auto`) or only at PageBreak\n\t * markers (`manual`). Inherits the owning Layout's strategy when unset. */\n\tpaginationStrategy?: PaginationStrategy\n\t/** Opens a numbering scope of this counter name around the Flow's content, so\n\t * a counter nested inside restarts per Flow instance (e.g. `1.1`, `1.2`). */\n\tscope?: string\n}\n\n/**\n * A Flow is a region whose content paginates across pages. Everything inside the\n * Flow that isn't its Stream is scaffolding that repeats on every page the\n * content spans; the stream's items appear once and flow.\n *\n * Author the stream two ways:\n *\n * - **bare** — `<Flow>{items}</Flow>`: the Flow's own children are the stream,\n * injected with no wrapper element.\n * - **scaffolded** — wrap the stream in a `<Stream>` inside surrounding markup,\n * e.g. `<Flow><table><thead/><Stream>{rows}</Stream><tfoot/></table></Flow>`:\n * the table, thead, and tfoot repeat per page; the rows flow.\n *\n * Flows nest: a Flow placed inside another Flow's stream paginates against the\n * nearest enclosing sealing region (a Frame, else the page), re-cloning its own\n * scaffolding on each page its content reaches.\n */\nexport function Flow({ splitGranularity, paginationStrategy, scope, children }: PropsWithChildren<FlowProps>) {\n\treturn (\n\t\t<Template\n\t\t\tdata-type='flow'\n\t\t\tdata-split-granularity={splitGranularity}\n\t\t\tdata-pagination-strategy={paginationStrategy}\n\t\t\tdata-scope={scope}>\n\t\t\t{children}\n\t\t</Template>\n\t)\n}\n","import type { PropsWithChildren } from 'react'\nimport { Template } from './Template'\n\n/**\n * A Stream marks where a scaffolded Flow's items land. Use it when a Flow wraps\n * its content in repeating scaffolding (a table's header and footer, a titled\n * panel) and you need to say where in that scaffolding the stream flows in:\n *\n * ```tsx\n * <Flow>\n * <table>\n * <thead>…</thead>\n * <Stream>{rows}</Stream>\n * <tfoot>…</tfoot>\n * </table>\n * </Flow>\n * ```\n *\n * Omit it for a bare Flow, where the Flow's own children are the stream.\n */\nexport function Stream({ children }: PropsWithChildren) {\n\treturn <Template data-type='stream'>{children}</Template>\n}\n","export function PageBreak() {\n\treturn <template data-type='page-break' />\n}\n","import type { CSSProperties, ElementType, HTMLAttributes } from 'react'\nimport type { CounterStyle } from './types'\n\nexport interface PageCounterBaseProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n\t/**\n\t * HTML tag to render. Defaults to `span`. Use `div` (or another block-level\n\t * element) when the counter needs its own line.\n\t */\n\tas?: ElementType\n\t/**\n\t * CSS `<counter-style>` used to format the counter — e.g. `decimal`,\n\t * `lower-roman`, `upper-alpha`, or a custom `@counter-style` name. Sets\n\t * `--page-counter-style` inline; defaults to `decimal` from the base\n\t * stylesheet when omitted.\n\t */\n\tcounterStyle?: CounterStyle\n}\n\ninterface PageCounterProps extends PageCounterBaseProps {\n\ttype: 'page-number' | 'page-count'\n}\n\nexport function PageCounter({ type, as: Tag = 'span', counterStyle, style, ...rest }: PageCounterProps) {\n\tconst mergedStyle: CSSProperties | undefined = counterStyle\n\t\t? ({ ...style, '--page-counter-style': counterStyle } as CSSProperties)\n\t\t: style\n\treturn <Tag data-type={type} style={mergedStyle} {...rest} />\n}\n","import { PageCounter, type PageCounterBaseProps } from './PageCounter'\n\nexport type PageNumberProps = PageCounterBaseProps\n\nexport function PageNumber(props: PageNumberProps) {\n\treturn <PageCounter {...props} type='page-number' />\n}\n","import { PageCounter, type PageCounterBaseProps } from './PageCounter'\n\nexport type PageCountProps = PageCounterBaseProps\n\nexport function PageCount(props: PageCountProps) {\n\treturn <PageCounter {...props} type='page-count' />\n}\n","import type { ElementType, HTMLAttributes } from 'react'\nimport type { CounterStyle } from './types'\n\ninterface CounterBase extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n\t/**\n\t * The counter to read or advance. Counters are created on first use, so any\n\t * name works — `figure`, `table`, `step`. The same name shares one running\n\t * value across the whole document.\n\t */\n\tname: string\n\t/**\n\t * Read the current value without advancing it. Use this to refer back to a\n\t * number you already showed, e.g. \"see Figure <Counter name='figure' peek />\".\n\t */\n\tpeek?: boolean\n\t/**\n\t * Reset the counter to 0 at this point and render nothing — the start of a\n\t * fresh run (a new chapter restarting its figures).\n\t */\n\treset?: boolean\n\t/**\n\t * Join the whole nested chain of this counter with the given separator — the\n\t * `counters()` read, for nested lists: `join=\".\"` shows `1.2.1`. Without it,\n\t * only the innermost value is shown.\n\t */\n\tjoin?: string\n\t/**\n\t * HTML tag to render. Defaults to `span`.\n\t */\n\tas?: ElementType\n\t/**\n\t * CSS `<counter-style>` used to format the value — e.g. `decimal`,\n\t * `lower-roman`, `upper-alpha`. Defaults to `decimal`.\n\t */\n\tcounterStyle?: CounterStyle\n}\n\n/**\n * `set` and `by` are mutually exclusive: `set` jumps to an exact value, `by`\n * advances. Passing both is a contradiction the type rejects.\n */\nexport type CounterProps = CounterBase &\n\t(\n\t\t| {\n\t\t\t\tset?: undefined\n\t\t\t\t/** How much to advance by before showing the value. Defaults to 1. */\n\t\t\t\tby?: number\n\t\t }\n\t\t| {\n\t\t\t\t/** Set the counter to an exact value and show it. */\n\t\t\t\tset: number\n\t\t\t\tby?: undefined\n\t\t }\n\t)\n\n/**\n * A counter whose value survives pagination. Unlike a CSS counter, which resets\n * on every page, this is resolved by Format before pages are split, so the\n * number stays correct wherever the content lands.\n *\n * By default it advances the counter and shows the new value — the usual \"this\n * is Figure N\" case. `peek` reads without advancing, `set` jumps to a value, and\n * `reset` starts the count over. These three are mutually exclusive; when more\n * than one is set, `reset` wins, then `set`, then `peek`. `by` applies only to\n * the default advance.\n *\n * Give the counter an `id` to make it referenceable. A `<Ref to=\"that-id\" />`\n * then prints the exact value this counter showed, and `<Ref to=\"that-id\" page />`\n * the page it landed on — the same way a heading's id yields its section number.\n */\nexport function Counter({ name, peek, reset, set, by, join, as: Tag = 'span', counterStyle, ...rest }: CounterProps) {\n\tif (\n\t\ttypeof process !== 'undefined' &&\n\t\tprocess.env?.NODE_ENV !== 'production' &&\n\t\tset !== undefined &&\n\t\tby !== undefined\n\t) {\n\t\tconsole.error(\n\t\t\t'<Counter>: `set` and `by` are mutually exclusive; `set` jumps to an exact value and wins, `by` is ignored.'\n\t\t)\n\t}\n\tconst action = reset ? 'reset' : set !== undefined ? 'set' : peek ? 'peek' : 'next'\n\t// data-value seeds both actions: the exact value for `set`, the step size for `next`\n\tconst value = set !== undefined ? set : action === 'next' ? by : undefined\n\n\treturn (\n\t\t<Tag\n\t\t\tdata-type='counter'\n\t\t\tdata-name={name}\n\t\t\tdata-action={action}\n\t\t\tdata-value={value}\n\t\t\tdata-join={join}\n\t\t\tdata-counter-style={counterStyle}\n\t\t\t{...rest}\n\t\t/>\n\t)\n}\n","import type { PropsWithChildren } from 'react'\nimport { Template } from './Template'\nimport type { CounterStyle } from './types'\n\ninterface NumberingRuleBase {\n\t/**\n\t * CSS selector for the elements this rule numbers, e.g. `h2`, `figure figcaption`,\n\t * `.step`. Every match advances the counter in document order.\n\t */\n\tmatch: string\n\t/**\n\t * The counter this rule advances. Defaults to the selector, so a single-tag\n\t * rule needs no separate name.\n\t */\n\tcounter?: string\n\t/**\n\t * The text inserted into each match, with `{counter}` placeholders. For\n\t * example `Figure {figure}: ` or `{chapter:upper-roman}. `. A placeholder may\n\t * carry its own style after a colon. When omitted, the rule advances the\n\t * counter but inserts nothing — pair it with a <Counter> read.\n\t */\n\tformat?: string\n\t/**\n\t * Default `<counter-style>` for placeholders in `format`. Defaults to `decimal`.\n\t */\n\tcounterStyle?: CounterStyle\n\t/**\n\t * Where the formatted number goes relative to the matched element:\n\t * `before` its content (the default), `after` it, or `none` to only keep the\n\t * counter running. To restart a counter under another, declare it with\n\t * `<CounterDef resetEach>`; to nest a counter, mark the container `data-scope`.\n\t */\n\tinsert?: 'before' | 'after' | 'none'\n}\n\n/**\n * `set` and `increment` are mutually exclusive: `set` forces an exact value on\n * each match, `increment` advances. Passing both is a contradiction the type\n * rejects.\n */\nexport type NumberingRuleProps = NumberingRuleBase &\n\t(\n\t\t| {\n\t\t\t\tset?: undefined\n\t\t\t\t/**\n\t\t\t\t * How much to advance the counter on each match. Defaults to 1. Set to `0` when a\n\t\t\t\t * rule should not advance a counter of its own, e.g. a rule whose only job is to\n\t\t\t\t * reset another counter (a nested-list rule that opens a fresh scope for the\n\t\t\t\t * counter you read).\n\t\t\t\t */\n\t\t\t\tincrement?: number\n\t\t }\n\t\t| {\n\t\t\t\t/** Set the counter to this exact value on each match instead of advancing it. */\n\t\t\t\tset: number\n\t\t\t\tincrement?: undefined\n\t\t }\n\t)\n\nexport interface NumberingProps {\n\t/**\n\t * The default counter style for every counter the document numbers. Per-rule,\n\t * per-Counter, and per-Footnotes styles override it. Defaults to `decimal`.\n\t */\n\tcounterStyle?: CounterStyle\n}\n\n/**\n * Turns on document-wide numbering. With no children it numbers headings `h1`\n * through `h6` hierarchically — `1`, `1.1`, `1.1.1` — with each level resetting\n * the ones beneath it. Add <NumberingRule> children to number other things or\n * change the format.\n *\n * Numbers are resolved before pages are split, so they stay correct across page\n * breaks where plain CSS counters would reset.\n *\n * ```tsx\n * <Document title=\"Report\">\n * <Numbering />\n * ...\n * </Document>\n * ```\n */\nexport function Numbering({ counterStyle, children }: PropsWithChildren<NumberingProps>) {\n\treturn (\n\t\t<Template data-type='numbering' data-counter-style={counterStyle}>\n\t\t\t{children}\n\t\t</Template>\n\t)\n}\n\n/**\n * One numbering rule, used as `<NumberingRule>` inside `<Numbering>`. Each rule\n * matches a selector and advances (and optionally inserts) a counter. Add rules\n * to number things beyond the default headings, or to change the heading format.\n */\nexport function NumberingRule({ match, counter, format, increment, set, counterStyle, insert }: NumberingRuleProps) {\n\tif (\n\t\ttypeof process !== 'undefined' &&\n\t\tprocess.env?.NODE_ENV !== 'production' &&\n\t\tset !== undefined &&\n\t\tincrement !== undefined\n\t) {\n\t\tconsole.error(\n\t\t\t'<NumberingRule>: `set` and `increment` are mutually exclusive; `set` forces an exact value and wins, `increment` is ignored.'\n\t\t)\n\t}\n\treturn (\n\t\t<Template\n\t\t\tdata-type='numbering-rule'\n\t\t\tdata-match={match}\n\t\t\tdata-counter={counter}\n\t\t\tdata-format={format}\n\t\t\tdata-increment={increment}\n\t\t\tdata-set={set}\n\t\t\tdata-counter-style={counterStyle}\n\t\t\tdata-insert={insert}\n\t\t/>\n\t)\n}\n\nexport interface CounterDefProps {\n\t/** The counter this defines. Shared by name across the document. */\n\tname: string\n\t/**\n\t * The counter this one restarts under, if any: whenever that owner advances, this\n\t * counter returns to 0. A `figure` set to restart under `chapter` reads \"Figure 2.1\".\n\t * The restart cascades, so a new chapter zeros section and, under section, figure.\n\t */\n\tresetEach?: string\n}\n\n/**\n * Declares one counter's behaviour, used as `<CounterDef>` inside `<Numbering>`. Name\n * the counter and, optionally, the owner counter it restarts under. A counter with an\n * owner returns to 0 every time the owner's value changes; one with no owner restarts\n * only when you reset or set it yourself.\n *\n * ```tsx\n * <Numbering>\n * <CounterDef name=\"figure\" resetEach=\"chapter\" />\n * <NumberingRule match=\"figcaption\" counter=\"figure\" format=\"Figure {chapter}.{figure}: \" />\n * </Numbering>\n * ```\n */\nexport function CounterDef({ name, resetEach }: CounterDefProps) {\n\treturn <Template data-type='counter-def' data-name={name} data-reset-each={resetEach} />\n}\n","import type { PropsWithChildren } from 'react'\nimport { Template } from './Template'\n\nexport interface ScopeProps {\n\t/**\n\t * The counter to open a fresh nested instance for across this wrapper's content — a\n\t * level of a nested list. Pass several space-separated to scope more than one. A\n\t * `<Counter join>` inside reads the whole open stack.\n\t */\n\tcounter: string\n}\n\n/**\n * Opens a counter scope around its children and adds no element to the output: a\n * `<Scope>` is the fallback for nesting content that has no element of its own to carry\n * the scope. When the content already sits in a container or a `<Flow>`, mark that\n * directly (`<ol data-scope=\"item\">`, `<Flow scope=\"item\">`) instead of wrapping.\n *\n * ```tsx\n * <Scope counter=\"item\">\n * <Counter name=\"item\" join=\".\" /> First\n * <Scope counter=\"item\">\n * <Counter name=\"item\" join=\".\" /> Nested\n * </Scope>\n * </Scope>\n * ```\n */\nexport function Scope({ counter, children }: PropsWithChildren<ScopeProps>) {\n\treturn <Template data-scope={counter}>{children}</Template>\n}\n","import type { ElementType, HTMLAttributes } from 'react'\nimport type { CounterStyle } from './types'\n\nexport interface RefProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n\t/**\n\t * The `id` to point at. Put an id on a heading to reference its section number,\n\t * or on a `<Counter>` to reference the value that counter printed. The target\n\t * can appear anywhere in the document, before or after this reference.\n\t */\n\tto: string\n\t/**\n\t * Read a named counter's value as it stood at the target, e.g. `counter=\"figure\"`\n\t * for the figure count at that point in the document. Omit it to show the\n\t * target's own number — a heading's section number, or the value a\n\t * `<Counter id=\"…\">` printed.\n\t */\n\tcounter?: string\n\t/**\n\t * Show the page the target landed on, e.g. \"see page 12\". Resolved after\n\t * pagination. Takes precedence over `counter`.\n\t */\n\tpage?: boolean\n\t/**\n\t * HTML tag to render. Defaults to `span`.\n\t */\n\tas?: ElementType\n\t/**\n\t * CSS `<counter-style>` used to format the value. Defaults to `decimal`.\n\t */\n\tcounterStyle?: CounterStyle\n}\n\n/**\n * A cross-reference to a numbered element — \"see Section 2.1\" or \"Figure 3\".\n * Point it at an `id`: a heading's id yields its section number, a `<Counter>`'s\n * id yields the value that counter printed. Add `page` for the page the target\n * landed on, or `counter` to read a named counter's running value at the target.\n *\n * References resolve before pages are split and can point forward to an element\n * that appears later in the document.\n *\n * ```tsx\n * <figcaption>Figure <Counter name=\"figure\" id=\"flow\" />: the data flow</figcaption>\n * // ...anywhere else in the document:\n * <p>The method (see Section <Ref to=\"method\" />) reads Figure <Ref to=\"flow\" />,\n * shown in full on page <Ref to=\"flow\" page />.</p>\n * ```\n */\nexport function Ref({ to, counter, page, as: Tag = 'span', counterStyle, ...rest }: RefProps) {\n\treturn (\n\t\t<Tag\n\t\t\tdata-type='ref'\n\t\t\tdata-to={to}\n\t\t\tdata-counter={page ? undefined : counter}\n\t\t\tdata-page={page ? '' : undefined}\n\t\t\tdata-counter-style={counterStyle}\n\t\t\t{...rest}\n\t\t/>\n\t)\n}\n","import type { CSSProperties, ReactNode } from 'react'\nimport { Template } from './Template'\nimport type { TocLeader } from './types'\n\nexport interface TableOfContentsProps {\n\t/**\n\t * CSS selector for the headings to list. Defaults to `h1, h2, h3`.\n\t */\n\tcollect?: string\n\t/**\n\t * The dot leader between each entry's title and its page number. The default,\n\t * `dots`, draws it; `none` leaves the run between them blank.\n\t */\n\tleader?: TocLeader\n\t/**\n\t * Repeat the leading content with the nav on every page the contents spans, like a\n\t * running header. Off by default: the leading content shows once, above the entries.\n\t */\n\trepeatHead?: boolean\n\t/**\n\t * Leading content rendered at the top of the contents, above the entries — a\n\t * \"Contents\" heading, an intro line, a rule. Shown once by default; set `repeatHead`\n\t * to repeat it with the nav on every page the contents spans.\n\t */\n\tchildren?: ReactNode\n\t/**\n\t * A class on the rendered `<nav>`. Style the contents with your own CSS, or use\n\t * `styled(TableOfContents)`.\n\t */\n\tclassName?: string\n\t/** An inline style on the rendered `<nav>`. */\n\tstyle?: CSSProperties\n}\n\n/**\n * A table of contents. Format fills it after laying out the document: one entry\n * per heading the `collect` selector matches, each with the heading's number, its\n * title, and the page it landed on.\n *\n * The entries are flat anchors in a `<div data-type=\"toc-entries\">` inside a\n * `<nav data-type=\"toc\">`: each is an `<a data-type=\"toc-entry\" data-depth=\"N\">`\n * (depth 0 at the top of the outline) holding `toc-number`, `toc-title`, and\n * `toc-page` spans. Depth is data, not nesting, so the stylesheet indents and sizes\n * by depth and a long contents paginates by breaking between anchors. Style it through\n * the `data-type` hooks and the `--toc-*` custom properties (root size, per-depth size\n * and indent, page-number size, leader, and vertical rhythm), or set a `className` (or\n * `styled(TableOfContents)`) on the nav. Set `leader=\"none\"` to omit the dot leader\n * entirely, so no leader is drawn between a title and its page number.\n *\n * Children are leading content shown above the entries — put a \"Contents\" heading there.\n * It shows once by default; set `repeatHead` to repeat it with the nav on every page.\n *\n * Give a collected heading a `data-toc-description` and its entry gains a\n * `toc-description` line under the title (a one-line summary, as on a magazine or\n * report contents):\n *\n * ```tsx\n * <TableOfContents collect=\"h1, h2\">\n * <h2>Contents</h2>\n * </TableOfContents>\n *\n * <h1 data-toc-description=\"Defining the studio's personality and direction.\">\n * Visual Positioning\n * </h1>\n * ```\n */\nexport function TableOfContents({ collect, leader, repeatHead, className, style, children }: TableOfContentsProps) {\n\treturn (\n\t\t<Template\n\t\t\tdata-type='toc'\n\t\t\tdata-collect={collect}\n\t\t\tdata-leader={leader}\n\t\t\tdata-repeat-head={repeatHead === undefined ? undefined : repeatHead ? 'true' : 'false'}\n\t\t\tclassName={className}\n\t\t\tstyle={style}>\n\t\t\t{children}\n\t\t</Template>\n\t)\n}\n","import type { PropsWithChildren } from 'react'\nimport { Template } from './Template'\n\n/**\n * A footnote. Write the note's text as the children, at the point it's\n * referenced; Format leaves a numbered marker inline and moves the text to the\n * footer of whichever page the marker lands on. Footnotes are numbered\n * continuously through the document.\n *\n * Pair it with a `<Footnotes />` region in the Layout to control where the notes\n * sit; without one, Format adds a footer area to each page that needs it.\n *\n * ```tsx\n * <p>The result holds<Footnote>under the stated assumptions</Footnote>.</p>\n * ```\n */\nexport function Footnote({ children }: PropsWithChildren) {\n\t// a `<template>` so the note's text stays inert and out of the inline flow until\n\t// the engine moves it to the footer, leaving just the marker behind\n\treturn <Template data-type='footnote'>{children}</Template>\n}\n","import type { CSSProperties, PropsWithChildren } from 'react'\nimport { Template } from './Template'\nimport type { CounterStyle } from './types'\n\nexport interface FootnotesProps {\n\t/**\n\t * The counter style for the note numbers and their inline markers. Defaults to\n\t * the document's numbering style, or `decimal`.\n\t */\n\tcounterStyle?: CounterStyle\n\t/**\n\t * Restart the numbering on each page, so every page's footer reads 1, 2, 3 rather\n\t * than a count that runs the whole document. For a per-page footer in a Layout; the\n\t * inline markers renumber to match. Off by default (continuous numbering).\n\t */\n\trestartEachPage?: boolean\n\t/**\n\t * Whether the leading content (a heading, a rule) repeats in every page's footer. On by\n\t * default for a per-page Layout footer; an inline endnotes block shows it once. Set `false`\n\t * to show a Layout footer's head on its first page only.\n\t */\n\trepeatHead?: boolean\n\t/** A class name passed through to the wrapping footnotes container. */\n\tclassName?: string\n\t/** An inline style passed through to the wrapping footnotes container. */\n\tstyle?: CSSProperties\n}\n\n/**\n * The region that collects a page's footnotes, authored as a `<template>` Format\n * fills. In a Layout it is a per-page footer gathering the notes whose markers\n * landed there; in a flow's content it is an endnotes list. Format renders it as an\n * `<aside data-type=\"footnotes\">` holding a `<dl data-type=\"footnote-entries\">`, where\n * each note is a `<dt data-type=\"footnote-number\">` term and a\n * `<dd data-type=\"footnote-content\">` definition; style the list as a grid with your\n * own CSS.\n *\n * Put a heading or rule inside `<Footnotes>` to render it above the generated list,\n * the way a table of contents renders its leading content above the entries:\n *\n * ```tsx\n * <Footnotes>\n * <h4>Notes</h4>\n * </Footnotes>\n * ```\n *\n * Omit it and Format adds a plain footer to each page that has footnotes.\n */\nexport function Footnotes({\n\tcounterStyle,\n\trestartEachPage,\n\trepeatHead,\n\tclassName,\n\tstyle,\n\tchildren\n}: PropsWithChildren<FootnotesProps>) {\n\treturn (\n\t\t<Template\n\t\t\tdata-type='footnotes'\n\t\t\tdata-counter-style={counterStyle}\n\t\t\tdata-restart-each-page={restartEachPage ? '' : undefined}\n\t\t\tdata-repeat-head={repeatHead === undefined ? undefined : repeatHead ? 'true' : 'false'}\n\t\t\tclassName={className}\n\t\t\tstyle={style}>\n\t\t\t{children}\n\t\t</Template>\n\t)\n}\n","/**\n * How a Flow splits content that overflows a page: at a `sentence`, `word`, or\n * `grapheme` boundary, or `none` to keep the block whole and move it to the next\n * page intact. Use the constant (`SplitGranularity.None`) or the plain string\n * (`'none'`); both are accepted.\n */\nexport const SplitGranularity = {\n\tSentence: 'sentence',\n\tWord: 'word',\n\tGrapheme: 'grapheme',\n\tNone: 'none'\n} as const\n\nexport type SplitGranularity = (typeof SplitGranularity)[keyof typeof SplitGranularity]\n\n/**\n * The dot leader between a contents entry's title and its page number. The default,\n * `dots`, draws it; `none` leaves the run between them blank. Use the constant\n * (`TocLeader.None`) or the plain string (`'none'`); both are accepted.\n */\nexport const TocLeader = {\n\tDots: 'dots',\n\tNone: 'none'\n} as const\n\nexport type TocLeader = (typeof TocLeader)[keyof typeof TocLeader]\n\n/** How a Layout or Flow decides where pages break: `auto` on overflow\n * and at PageBreak markers, `manual` at PageBreak markers only. */\nexport type PaginationStrategy = 'auto' | 'manual'\n\n/**\n * How the PDF embeds its fonts. Mirrors `FontMode` in `@format.dev/fonts`, which owns\n * the canonical list and the default.\n */\nexport type FontMode = 'fidelity' | 'compact'\n\n/**\n * A CSS `<counter-style>` name. The predefined styles autocomplete; any custom\n * `@counter-style` name you define is accepted too.\n */\nexport type CounterStyle =\n\t| 'decimal'\n\t| 'decimal-leading-zero'\n\t| 'lower-roman'\n\t| 'upper-roman'\n\t| 'lower-alpha'\n\t| 'upper-alpha'\n\t| 'lower-latin'\n\t| 'upper-latin'\n\t| 'lower-greek'\n\t| (string & {})\n"],"mappings":";;;;AACA,MAAM,qBAAqB;;;;;;;AAQ3B,SAAgB,mBAAmB,MAAsB;AACxD,QAAO,KAAK,QAAQ,oBAAoB,GAAG;;;;;;;;;;AAW5C,SAAgB,IAAI,OAA6B,GAAG,MAAyB;CAC5E,IAAI,MAAM,MAAM,IAAI,MAAM;AAC1B,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACrC,MAAM,IAAI,KAAK;AACf,UAAQ,KAAK,QAAQ,MAAM,QAAQ,KAAK,OAAO,EAAE,IAAI,MAAM,IAAI,IAAI;;AAEpE,QAAO;;;;;ACrBR,SAAgB,SAAS,EAAE,UAAU,GAAG,SAA2C;CAClF,MAAM,OAAO,mBAAmB,qBAAqB,SAAS,CAAC;AAC/D,QAAO,oBAAC;EAAS,GAAI;EAAO,yBAAyB,EAAE,QAAQ,MAAM;GAAI;;;;;ACD1E,MA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AI;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACSJ,SAAgB,gBAAgB,EAAE,SAAS,QAAQ,YAAY,WAAW,OAAO,YAAkC;AAClH,QACC,oBAAC;EACA,aAAU;EACV,gBAAc;EACd,eAAa;EACb,oBAAkB,eAAe,SAAY,SAAY,aAAa,SAAS;EACpE;EACJ;EACN;GACS;;;;;;;;;;;;;;;;;;AC5Db,SAAgB,SAAS,EAAE,YAA+B;AAGzD,QAAO,oBAAC;EAAS,aAAU;EAAY;GAAoB;;;;;;;;;;;;;;;;;;;;;;;;;AC6B5D,SAAgB,UAAU,EACzB,cACA,iBACA,YACA,WACA,OACA,YACqC;AACrC,QACC,oBAAC;EACA,aAAU;EACV,sBAAoB;EACpB,0BAAwB,kBAAkB,KAAK;EAC/C,oBAAkB,eAAe,SAAY,SAAY,aAAa,SAAS;EACpE;EACJ;EACN;GACS;;;;;;;;;;;AC3Db,MAAa,mBAAmB;CAC/B,UAAU;CACV,MAAM;CACN,UAAU;CACV,MAAM;CACN;;;;;;AASD,MAAa,YAAY;CACxB,MAAM;CACN,MAAM;CACN"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["engineTarget: string","sdkVersion: string","mergedStyle: CSSProperties | undefined"],"sources":["../src/utils.ts","../src/Template.tsx","../src/engine-target.ts","../src/sdk-version.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/types.ts"],"sourcesContent":["// react's attribute order is not guaranteed, so rel and as are matched independently\nconst IMAGE_PRELOAD_LINK = /<link\\b(?=[^>]*\\brel=\"preload\")(?=[^>]*\\bas=\"image\")[^>]*>/g\n\n/**\n * Removes the `<link rel=\"preload\" as=\"image\">` tags that React's server\n * renderer emits ahead of every eager `<img>`. The engine allows a `<link>`\n * only when its `rel` is `stylesheet`, and fails the render with an\n * `INVALID_HTML_LINK_ELEMENT` 400 otherwise.\n */\nexport function stripImagePreloads(html: string): string {\n\treturn html.replace(IMAGE_PRELOAD_LINK, '')\n}\n\n/**\n * Tagged template for authoring CSS, typically inside a `<style>` element.\n * Returns the string from the raw segments, so CSS escapes (`\\2014`,\n * icon-font codepoints, escaped selectors) survive intact. Interpolated\n * `null`, `undefined`, and `false` collapse to an empty string for clean\n * conditional rules. The `css` name also lets editors and the Format docs\n * highlighter treat the contents as CSS.\n */\nexport function css(parts: TemplateStringsArray, ...vals: unknown[]): string {\n\tlet out = parts.raw[0] ?? ''\n\tfor (let i = 0; i < vals.length; i++) {\n\t\tconst v = vals[i]\n\t\tout += (v == null || v === false ? '' : String(v)) + parts.raw[i + 1]!\n\t}\n\treturn out\n}\n","import type { PropsWithChildren } from 'react'\nimport { renderToStaticMarkup } from 'react-dom/server'\nimport { stripImagePreloads } from './utils'\n\nexport type TemplateProps = React.HTMLAttributes<HTMLTemplateElement>\n\nexport function Template({ children, ...props }: PropsWithChildren<TemplateProps>) {\n\tconst html = stripImagePreloads(renderToStaticMarkup(children))\n\treturn <template {...props} dangerouslySetInnerHTML={{ __html: html }} />\n}\n","// The released engine version targeted by documents built from this package.\n// Each build supplies `FORMAT_ENGINE_TARGET` for itself, so the same source can\n// be built against different engines. It has to arrive as a free identifier,\n// because `define` substitutes those and not import bindings; see\n// build/release/README.md.\ndeclare const FORMAT_ENGINE_TARGET: string\n\nexport const engineTarget: string = FORMAT_ENGINE_TARGET\n","// The Format release this package belongs to, written into every document it\n// renders as `data-sdk`. It names the SDK/toolchain that produced the markup,\n// which is a different question from the engine that will lay it out\n// (`data-engine`) and from the client that will submit it.\n//\n// Each build supplies `FORMAT_JS_VERSION` for itself, so the same source can be\n// built at different release numbers. It has to arrive as a free identifier,\n// because `define` substitutes those and not import bindings; see\n// build/release/README.md.\ndeclare const FORMAT_JS_VERSION: string\n\nexport const sdkVersion: string = FORMAT_JS_VERSION\n","import type { PropsWithChildren } from 'react'\nimport { Template } from './Template'\nimport type { FontMode } from './types'\nimport { engineTarget } from './engine-target'\nimport { sdkVersion } from './sdk-version'\n\nexport interface DocumentProps {\n\ttitle: string\n\tsubject?: string\n\tauthor?: string\n\tkeywords?: string[]\n\t/**\n\t * The language the document is written in, as a BCP 47 language tag such as\n\t * `'fr'` or `'pt-BR'`. Format adds it to your PDF, and screen readers use it to\n\t * choose the right voice and pronunciation. Format also applies that language's\n\t * conventions for quotation marks and letter case to every page. Set it on\n\t * every document: without it, your PDF has no language and doesn't meet\n\t * accessibility standards such as WCAG and PDF/UA. Format ignores invalid tags,\n\t * such as `'en_US'` or `'english'`. To mark a passage in a different language,\n\t * add a `lang` attribute to its element.\n\t */\n\tlang?: string\n\t/**\n\t * Selects the versions of Format's built-in Sans, Serif, and Mono fonts.\n\t * `compact` (default) uses static fonts for smaller PDFs. `fidelity` uses\n\t * variable fonts, preserving optical sizing where supported, but typically\n\t * produces larger PDFs. Custom fonts are used as supplied in either mode.\n\t */\n\tfonts?: FontMode\n}\n\n/**\n * Props the Format runtime passes to a document entry function. The\n * generic parameter is the shape of the active data variant.\n *\n * ```tsx\n * import type { Invoice } from './types'\n *\n * export default function InvoiceDocument({ data }: RenderProps<Invoice>) {\n * return <Document title={`Invoice #${data.id}`} lang=\"en\">{/* ... *\\/}</Document>\n * }\n * ```\n */\nexport interface RenderProps<T = unknown> {\n\tdata: T\n}\n\nexport function Document({\n\ttitle,\n\tsubject,\n\tauthor,\n\tkeywords,\n\tlang,\n\tfonts,\n\tchildren\n}: PropsWithChildren<DocumentProps>) {\n\tconst keywordsString = keywords?.join(', ')\n\n\treturn (\n\t\t<Template\n\t\t\tdata-sdk={sdkVersion}\n\t\t\tdata-engine={engineTarget}\n\t\t\tdata-type='document'\n\t\t\tdata-title={title}\n\t\t\tdata-subject={subject}\n\t\t\tdata-author={author}\n\t\t\tdata-keywords={keywordsString}\n\t\t\tdata-lang={lang}\n\t\t\tdata-fonts={fonts}>\n\t\t\t{children}\n\t\t</Template>\n\t)\n}\n","import type { PropsWithChildren } from 'react'\nimport { Template } from './Template'\nimport type { PaginationStrategy, SplitGranularity } from './types'\n\nexport interface LayoutProps {\n\t/** Design label, mirrored to each page as `data-layout-id` for CSS. Optional:\n\t * when omitted, the engine generates one from the Layout's document position. */\n\tid?: string\n\twidth: number\n\theight: number\n\tpaginationStrategy?: PaginationStrategy\n\tsplitGranularity?: SplitGranularity\n}\n\nexport function Layout({\n\tid,\n\twidth,\n\theight,\n\tpaginationStrategy,\n\tsplitGranularity,\n\tchildren\n}: PropsWithChildren<LayoutProps>) {\n\treturn (\n\t\t<Template\n\t\t\tdata-type='layout'\n\t\t\tdata-id={id}\n\t\t\tdata-width={`${width}px`}\n\t\t\tdata-height={`${height}px`}\n\t\t\tdata-pagination-strategy={paginationStrategy}\n\t\t\tdata-split-granularity={splitGranularity}>\n\t\t\t{children}\n\t\t</Template>\n\t)\n}\n","import type { PropsWithChildren } from 'react'\nimport { Template } from './Template'\nimport type { PaginationStrategy, SplitGranularity } from './types'\n\nexport interface FlowProps {\n\t/** How content breaks when it doesn't fit the current page. When unset, it\n\t * inherits from the enclosing Flow, then the Layout, then defaults to `none`. */\n\tsplitGranularity?: SplitGranularity\n\t/** Whether this Flow paginates on overflow (`auto`) or only at PageBreak\n\t * markers (`manual`). Inherits the owning Layout's strategy when unset. */\n\tpaginationStrategy?: PaginationStrategy\n\t/** Opens a numbering scope of this counter name around the Flow's content, so\n\t * a counter nested inside restarts per Flow instance (e.g. `1.1`, `1.2`). */\n\tscope?: string\n}\n\n/**\n * A Flow is a region whose content paginates across pages. Everything inside the\n * Flow that isn't its Stream is scaffolding that repeats on every page the\n * content spans; the stream's items appear once and flow.\n *\n * Author the stream two ways:\n *\n * - **bare** — `<Flow>{items}</Flow>`: the Flow's own children are the stream,\n * injected with no wrapper element.\n * - **scaffolded** — wrap the stream in a `<Stream>` inside surrounding markup,\n * e.g. `<Flow><table><thead/><Stream>{rows}</Stream><tfoot/></table></Flow>`:\n * the table, thead, and tfoot repeat per page; the rows flow.\n *\n * Flows nest: a Flow placed inside another Flow's stream paginates against the\n * nearest enclosing sealing region (a Frame, else the page), re-cloning its own\n * scaffolding on each page its content reaches.\n */\nexport function Flow({ splitGranularity, paginationStrategy, scope, children }: PropsWithChildren<FlowProps>) {\n\treturn (\n\t\t<Template\n\t\t\tdata-type='flow'\n\t\t\tdata-split-granularity={splitGranularity}\n\t\t\tdata-pagination-strategy={paginationStrategy}\n\t\t\tdata-scope={scope}>\n\t\t\t{children}\n\t\t</Template>\n\t)\n}\n","import type { PropsWithChildren } from 'react'\nimport { Template } from './Template'\n\n/**\n * A Stream marks where a scaffolded Flow's items land. Use it when a Flow wraps\n * its content in repeating scaffolding (a table's header and footer, a titled\n * panel) and you need to say where in that scaffolding the stream flows in:\n *\n * ```tsx\n * <Flow>\n * <table>\n * <thead>…</thead>\n * <Stream>{rows}</Stream>\n * <tfoot>…</tfoot>\n * </table>\n * </Flow>\n * ```\n *\n * Omit it for a bare Flow, where the Flow's own children are the stream.\n */\nexport function Stream({ children }: PropsWithChildren) {\n\treturn <Template data-type='stream'>{children}</Template>\n}\n","export function PageBreak() {\n\treturn <template data-type='page-break' />\n}\n","import type { CSSProperties, ElementType, HTMLAttributes } from 'react'\nimport type { CounterStyle } from './types'\n\nexport interface PageCounterBaseProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n\t/**\n\t * HTML tag to render. Defaults to `span`. Use `div` (or another block-level\n\t * element) when the counter needs its own line.\n\t */\n\tas?: ElementType\n\t/**\n\t * CSS `<counter-style>` used to format the counter — e.g. `decimal`,\n\t * `lower-roman`, `upper-alpha`, or a custom `@counter-style` name. Sets\n\t * `--page-counter-style` inline; defaults to `decimal` from the base\n\t * stylesheet when omitted.\n\t */\n\tcounterStyle?: CounterStyle\n}\n\ninterface PageCounterProps extends PageCounterBaseProps {\n\ttype: 'page-number' | 'page-count'\n}\n\nexport function PageCounter({ type, as: Tag = 'span', counterStyle, style, ...rest }: PageCounterProps) {\n\tconst mergedStyle: CSSProperties | undefined = counterStyle\n\t\t? ({ ...style, '--page-counter-style': counterStyle } as CSSProperties)\n\t\t: style\n\treturn <Tag data-type={type} style={mergedStyle} {...rest} />\n}\n","import { PageCounter, type PageCounterBaseProps } from './PageCounter'\n\nexport type PageNumberProps = PageCounterBaseProps\n\nexport function PageNumber(props: PageNumberProps) {\n\treturn <PageCounter {...props} type='page-number' />\n}\n","import { PageCounter, type PageCounterBaseProps } from './PageCounter'\n\nexport type PageCountProps = PageCounterBaseProps\n\nexport function PageCount(props: PageCountProps) {\n\treturn <PageCounter {...props} type='page-count' />\n}\n","import type { ElementType, HTMLAttributes } from 'react'\nimport type { CounterStyle } from './types'\n\ninterface CounterBase extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n\t/**\n\t * The counter to read or advance. Counters are created on first use, so any\n\t * name works — `figure`, `table`, `step`. The same name shares one running\n\t * value across the whole document.\n\t */\n\tname: string\n\t/**\n\t * Read the current value without advancing it. Use this to refer back to a\n\t * number you already showed, e.g. \"see Figure <Counter name='figure' peek />\".\n\t */\n\tpeek?: boolean\n\t/**\n\t * Reset the counter to 0 at this point and render nothing — the start of a\n\t * fresh run (a new chapter restarting its figures).\n\t */\n\treset?: boolean\n\t/**\n\t * Join the whole nested chain of this counter with the given separator — the\n\t * `counters()` read, for nested lists: `join=\".\"` shows `1.2.1`. Without it,\n\t * only the innermost value is shown.\n\t */\n\tjoin?: string\n\t/**\n\t * HTML tag to render. Defaults to `span`.\n\t */\n\tas?: ElementType\n\t/**\n\t * CSS `<counter-style>` used to format the value — e.g. `decimal`,\n\t * `lower-roman`, `upper-alpha`. Defaults to `decimal`.\n\t */\n\tcounterStyle?: CounterStyle\n}\n\n/**\n * `set` and `by` are mutually exclusive: `set` jumps to an exact value, `by`\n * advances. Passing both is a contradiction the type rejects.\n */\nexport type CounterProps = CounterBase &\n\t(\n\t\t| {\n\t\t\t\tset?: undefined\n\t\t\t\t/** How much to advance by before showing the value. Defaults to 1. */\n\t\t\t\tby?: number\n\t\t }\n\t\t| {\n\t\t\t\t/** Set the counter to an exact value and show it. */\n\t\t\t\tset: number\n\t\t\t\tby?: undefined\n\t\t }\n\t)\n\n/**\n * A counter whose value survives pagination. Unlike a CSS counter, which resets\n * on every page, this is resolved by Format before pages are split, so the\n * number stays correct wherever the content lands.\n *\n * By default it advances the counter and shows the new value — the usual \"this\n * is Figure N\" case. `peek` reads without advancing, `set` jumps to a value, and\n * `reset` starts the count over. These three are mutually exclusive; when more\n * than one is set, `reset` wins, then `set`, then `peek`. `by` applies only to\n * the default advance.\n *\n * Give the counter an `id` to make it referenceable. A `<Ref to=\"that-id\" />`\n * then prints the exact value this counter showed, and `<Ref to=\"that-id\" page />`\n * the page it landed on — the same way a heading's id yields its section number.\n */\nexport function Counter({ name, peek, reset, set, by, join, as: Tag = 'span', counterStyle, ...rest }: CounterProps) {\n\tif (\n\t\ttypeof process !== 'undefined' &&\n\t\tprocess.env?.NODE_ENV !== 'production' &&\n\t\tset !== undefined &&\n\t\tby !== undefined\n\t) {\n\t\tconsole.error(\n\t\t\t'<Counter>: `set` and `by` are mutually exclusive; `set` jumps to an exact value and wins, `by` is ignored.'\n\t\t)\n\t}\n\tconst action = reset ? 'reset' : set !== undefined ? 'set' : peek ? 'peek' : 'next'\n\t// data-value seeds both actions: the exact value for `set`, the step size for `next`\n\tconst value = set !== undefined ? set : action === 'next' ? by : undefined\n\n\treturn (\n\t\t<Tag\n\t\t\tdata-type='counter'\n\t\t\tdata-name={name}\n\t\t\tdata-action={action}\n\t\t\tdata-value={value}\n\t\t\tdata-join={join}\n\t\t\tdata-counter-style={counterStyle}\n\t\t\t{...rest}\n\t\t/>\n\t)\n}\n","import type { PropsWithChildren } from 'react'\nimport { Template } from './Template'\nimport type { CounterStyle } from './types'\n\ninterface NumberingRuleBase {\n\t/**\n\t * CSS selector for the elements this rule numbers, e.g. `h2`, `figure figcaption`,\n\t * `.step`. Every match advances the counter in document order. It matches the\n\t * content that flows across pages, without the Layout or Flow scaffolding around\n\t * it: when a Layout wraps its Flow in `<main>`, `main h2` matches nothing.\n\t */\n\tmatch: string\n\t/**\n\t * The counter this rule advances. Defaults to the selector, so a single-tag\n\t * rule needs no separate name.\n\t */\n\tcounter?: string\n\t/**\n\t * The text inserted into each match, with `{counter}` placeholders. For\n\t * example `Figure {figure}: ` or `{chapter:upper-roman}. `. A placeholder may\n\t * carry its own style after a colon. When omitted, the rule advances the\n\t * counter but inserts nothing — pair it with a <Counter> read.\n\t */\n\tformat?: string\n\t/**\n\t * Default `<counter-style>` for placeholders in `format`. Defaults to `decimal`.\n\t */\n\tcounterStyle?: CounterStyle\n\t/**\n\t * Where the formatted number goes relative to the matched element:\n\t * `before` its content (the default), `after` it, or `none` to only keep the\n\t * counter running. To restart a counter under another, declare it with\n\t * `<CounterDef resetEach>`; to nest a counter, mark the container `data-scope`.\n\t */\n\tinsert?: 'before' | 'after' | 'none'\n}\n\n/**\n * `set` and `increment` are mutually exclusive: `set` forces an exact value on\n * each match, `increment` advances. Passing both is a contradiction the type\n * rejects.\n */\nexport type NumberingRuleProps = NumberingRuleBase &\n\t(\n\t\t| {\n\t\t\t\tset?: undefined\n\t\t\t\t/**\n\t\t\t\t * How much to advance the counter on each match. Defaults to 1. Set to `0` when a\n\t\t\t\t * rule should not advance a counter of its own, e.g. a rule whose only job is to\n\t\t\t\t * reset another counter (a nested-list rule that opens a fresh scope for the\n\t\t\t\t * counter you read).\n\t\t\t\t */\n\t\t\t\tincrement?: number\n\t\t }\n\t\t| {\n\t\t\t\t/** Set the counter to this exact value on each match instead of advancing it. */\n\t\t\t\tset: number\n\t\t\t\tincrement?: undefined\n\t\t }\n\t)\n\nexport interface NumberingProps {\n\t/**\n\t * The default counter style for every counter the document numbers. Per-rule,\n\t * per-Counter, and per-Footnotes styles override it. Defaults to `decimal`.\n\t */\n\tcounterStyle?: CounterStyle\n\t/**\n\t * Whether headings `h1` through `h6` get the built-in hierarchical numbers. On by\n\t * default. Set `false` when your own rules number the headings; that removes the\n\t * built-in restarts between heading levels as well as the built-in numbers.\n\t */\n\tdefaultHeadings?: boolean\n}\n\n/**\n * Turns on document-wide numbering. By default it numbers headings `h1` through\n * `h6` hierarchically — `1`, `1.1`, `1.1.1` — with each level resetting the ones\n * beneath it. Add <NumberingRule> children to number other things; they add to the\n * default headings. To number headings your own way, set `defaultHeadings={false}`\n * and write rules for them.\n *\n * Numbers are resolved before pages are split, so they stay correct across page\n * breaks where plain CSS counters would reset.\n *\n * ```tsx\n * <Document title=\"Report\" lang=\"en\">\n * <Numbering />\n * ...\n * </Document>\n * ```\n */\nexport function Numbering({ counterStyle, defaultHeadings, children }: PropsWithChildren<NumberingProps>) {\n\treturn (\n\t\t<Template\n\t\t\tdata-type='numbering'\n\t\t\tdata-counter-style={counterStyle}\n\t\t\tdata-default-headings={defaultHeadings === undefined ? undefined : defaultHeadings ? 'true' : 'false'}>\n\t\t\t{children}\n\t\t</Template>\n\t)\n}\n\n/**\n * One numbering rule, used as `<NumberingRule>` inside `<Numbering>`. Each rule\n * matches a selector and advances (and optionally inserts) a counter. Rules add to\n * the default headings; to change the heading format, set\n * `<Numbering defaultHeadings={false}>` and number the headings with rules.\n */\nexport function NumberingRule({ match, counter, format, increment, set, counterStyle, insert }: NumberingRuleProps) {\n\tif (\n\t\ttypeof process !== 'undefined' &&\n\t\tprocess.env?.NODE_ENV !== 'production' &&\n\t\tset !== undefined &&\n\t\tincrement !== undefined\n\t) {\n\t\tconsole.error(\n\t\t\t'<NumberingRule>: `set` and `increment` are mutually exclusive; `set` forces an exact value and wins, `increment` is ignored.'\n\t\t)\n\t}\n\treturn (\n\t\t<Template\n\t\t\tdata-type='numbering-rule'\n\t\t\tdata-match={match}\n\t\t\tdata-counter={counter}\n\t\t\tdata-format={format}\n\t\t\tdata-increment={increment}\n\t\t\tdata-set={set}\n\t\t\tdata-counter-style={counterStyle}\n\t\t\tdata-insert={insert}\n\t\t/>\n\t)\n}\n\nexport interface CounterDefProps {\n\t/** The counter this defines. Shared by name across the document. */\n\tname: string\n\t/**\n\t * The counter this one restarts under, if any: whenever that owner advances, this\n\t * counter returns to 0. A `figure` set to restart under `chapter` reads \"Figure 2.1\".\n\t * The restart cascades, so a new chapter zeros section and, under section, figure.\n\t */\n\tresetEach?: string\n}\n\n/**\n * Declares one counter's behaviour, used as `<CounterDef>` inside `<Numbering>`. Name\n * the counter and, optionally, the owner counter it restarts under. A counter with an\n * owner returns to 0 every time the owner's value changes; one with no owner restarts\n * only when you reset or set it yourself.\n *\n * ```tsx\n * <Numbering>\n * <CounterDef name=\"figure\" resetEach=\"chapter\" />\n * <NumberingRule match=\"figcaption\" counter=\"figure\" format=\"Figure {chapter}.{figure}: \" />\n * </Numbering>\n * ```\n */\nexport function CounterDef({ name, resetEach }: CounterDefProps) {\n\treturn <Template data-type='counter-def' data-name={name} data-reset-each={resetEach} />\n}\n","import { Template } from './Template'\n\nexport interface BookmarksProps {\n\t/**\n\t * Whether bookmarks include the numbers `<Numbering>` adds to headings. On by\n\t * default. Set `false` to show titles alone, such as \"Fees\" instead of \"3 Fees\".\n\t * Text you write in a heading always stays, including digits and the value of a\n\t * `<Counter>`.\n\t */\n\tnumbers?: boolean\n\t/**\n\t * The text between each number and its title, such as `\". \"` for \"3. Fees\".\n\t * Defaults to a space, as on the page. An empty string joins them, as in \"3Fees\".\n\t */\n\tseparator?: string\n}\n\n/**\n * Controls how heading numbers appear in the PDF's bookmarks, the clickable outline\n * that PDF viewers show beside the pages. By default, each bookmark matches its\n * heading, number included. Set `numbers={false}` to leave the numbers out, or set\n * `separator` to change the text between each number and its title. The pages, the\n * table of contents, and the running heads keep their numbers. Place one directly\n * inside `<Document>`.\n *\n * ```tsx\n * <Document title=\"Handbook\">\n * <Numbering />\n * <Bookmarks separator=\". \" />\n * ...\n * </Document>\n * ```\n */\nexport function Bookmarks({ numbers, separator }: BookmarksProps) {\n\treturn (\n\t\t<Template\n\t\t\tdata-type='bookmarks'\n\t\t\tdata-numbers={numbers === undefined ? undefined : numbers ? 'true' : 'false'}\n\t\t\tdata-separator={separator}\n\t\t/>\n\t)\n}\n","import type { PropsWithChildren } from 'react'\nimport { Template } from './Template'\n\nexport interface ScopeProps {\n\t/**\n\t * The counter to open a fresh nested instance for across this wrapper's content — a\n\t * level of a nested list. Pass several space-separated to scope more than one. A\n\t * `<Counter join>` inside reads the whole open stack.\n\t */\n\tcounter: string\n}\n\n/**\n * Opens a counter scope around its children and adds no element to the output: a\n * `<Scope>` is the fallback for nesting content that has no element of its own to carry\n * the scope. When the content already sits in a container or a `<Flow>`, mark that\n * directly (`<ol data-scope=\"item\">`, `<Flow scope=\"item\">`) instead of wrapping.\n *\n * ```tsx\n * <Scope counter=\"item\">\n * <Counter name=\"item\" join=\".\" /> First\n * <Scope counter=\"item\">\n * <Counter name=\"item\" join=\".\" /> Nested\n * </Scope>\n * </Scope>\n * ```\n */\nexport function Scope({ counter, children }: PropsWithChildren<ScopeProps>) {\n\treturn <Template data-scope={counter}>{children}</Template>\n}\n","import type { ElementType, HTMLAttributes } from 'react'\nimport type { CounterStyle } from './types'\n\nexport interface RefProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n\t/**\n\t * The `id` to point at. Put an id on a heading to reference its section number,\n\t * or on a `<Counter>` to reference the value that counter printed. The target\n\t * can appear anywhere in the document, before or after this reference.\n\t */\n\tto: string\n\t/**\n\t * Read a named counter's value as it stood at the target, e.g. `counter=\"figure\"`\n\t * for the figure count at that point in the document. Omit it to show the\n\t * target's own number — a heading's section number, or the value a\n\t * `<Counter id=\"…\">` printed.\n\t */\n\tcounter?: string\n\t/**\n\t * Show the page the target landed on, e.g. \"see page 12\". Resolved after\n\t * pagination. Takes precedence over `counter`.\n\t */\n\tpage?: boolean\n\t/**\n\t * HTML tag to render. Defaults to `span`.\n\t */\n\tas?: ElementType\n\t/**\n\t * CSS `<counter-style>` used to format the value. Defaults to `decimal`.\n\t */\n\tcounterStyle?: CounterStyle\n}\n\n/**\n * A cross-reference to a numbered element — \"see Section 2.1\" or \"Figure 3\".\n * Point it at an `id`: a heading's id yields its section number, a `<Counter>`'s\n * id yields the value that counter printed. Add `page` for the page the target\n * landed on, or `counter` to read a named counter's running value at the target.\n *\n * References resolve before pages are split and can point forward to an element\n * that appears later in the document.\n *\n * ```tsx\n * <figcaption>Figure <Counter name=\"figure\" id=\"flow\" />: the data flow</figcaption>\n * // ...anywhere else in the document:\n * <p>The method (see Section <Ref to=\"method\" />) reads Figure <Ref to=\"flow\" />,\n * shown in full on page <Ref to=\"flow\" page />.</p>\n * ```\n */\nexport function Ref({ to, counter, page, as: Tag = 'span', counterStyle, ...rest }: RefProps) {\n\treturn (\n\t\t<Tag\n\t\t\tdata-type='ref'\n\t\t\tdata-to={to}\n\t\t\tdata-counter={page ? undefined : counter}\n\t\t\tdata-page={page ? '' : undefined}\n\t\t\tdata-counter-style={counterStyle}\n\t\t\t{...rest}\n\t\t/>\n\t)\n}\n","import type { HTMLAttributes } from 'react'\nimport type { CounterStyle, RunningHeadElement, RunningHeadShow } from './types'\n\nexport interface RunningHeadProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n\t/**\n\t * CSS selector for the headings to follow, e.g. `h1`. Like a `<NumberingRule>`'s\n\t * `match`, it matches the content that flows across pages, without the scaffolding\n\t * around it: select on the heading itself, e.g. `h1` rather than `main h1`.\n\t */\n\tmatch: string\n\t/**\n\t * Which match to show on each page. `first` (the default) shows the first match on\n\t * the page; `start` shows the match the page opens with, else the section the page\n\t * continues; `last` shows the last match; `firstExcept` shows nothing on a page\n\t * where a match appears; `range` shows the first and last section the page holds.\n\t * A page with no match shows the section carried over from earlier pages.\n\t */\n\tshow?: RunningHeadShow\n\t/**\n\t * CSS selector for the headings that enclose the followed ones, e.g. `h1` for a\n\t * running head that follows `h2` sections. A match ends the current section, and\n\t * only sections of the chapter in effect are shown. A chapter running head and a\n\t * section running head on one page agree when they use the same `show` other\n\t * than `range`, or when the chapter uses `start` beside a section `range`.\n\t */\n\twithin?: string\n\t/**\n\t * The number to show, with `{counter}` placeholders read where the heading sits,\n\t * e.g. `{h1:decimal-leading-zero}.`. Defaults to the number the heading shows.\n\t */\n\tformat?: string\n\t/**\n\t * Default `<counter-style>` for placeholders in `format`. Defaults to the\n\t * document's numbering style, or `decimal`.\n\t */\n\tcounterStyle?: CounterStyle\n\t/**\n\t * The text between the first and last section when `show` is `range`. Defaults to\n\t * an en dash with a space either side.\n\t */\n\trangeSeparator?: string\n\t/**\n\t * HTML tag to render: `span` (the default), `div`, `p`, a heading, or a sectioning\n\t * element such as `header`. The text goes in a shadow root, which only these\n\t * elements can hold.\n\t */\n\tas?: RunningHeadElement\n}\n\n/**\n * Names, in a page's header or footer, the section the page belongs to: the title\n * of the heading `match` picks out, with its number. Place it in a Layout's\n * scaffolding, and Format fills it on every page once the page's content is placed,\n * so a chapter that starts halfway down a page is named correctly. The heading, its\n * table of contents entry, and the running head always show the same number and\n * title.\n *\n * Set `data-running-head` on a heading to show a shorter title (an empty value shows\n * nothing for it), and `data-running-head-reset` on any element to end the current\n * section, e.g. on an appendix's title page. For the heading's PDF bookmark, set\n * `data-bookmark` the same way.\n *\n * The box keeps one size whatever text lands in it: one line tall, or as many lines\n * as `--running-head-lines` sets. Give it a width in your layout, such as a grid\n * column; text that doesn't fit is cut off, with an ellipsis when the box holds its\n * lines. The text sits in the box's own shadow root, where your selectors don't\n * reach: style it with `::part()`, such as `::part(title)`.\n *\n * ```tsx\n * <Numbering>\n * <NumberingRule match=\"h1\" format=\"{h1:decimal-leading-zero}.\" />\n * </Numbering>\n * <Layout id=\"page\" width={595} height={842}>\n * <header>\n * <RunningHead match=\"h1\" show=\"start\" />\n * <PageNumber />\n * </header>\n * <Flow>\n * <h1>General information</h1>\n * ...\n * </Flow>\n * </Layout>\n * ```\n */\nexport function RunningHead({\n\tmatch,\n\tshow,\n\twithin,\n\tformat,\n\tcounterStyle,\n\trangeSeparator,\n\tas: Tag = 'span',\n\t...rest\n}: RunningHeadProps) {\n\treturn (\n\t\t<Tag\n\t\t\tdata-type='running-head'\n\t\t\tdata-match={match}\n\t\t\tdata-show={show}\n\t\t\tdata-within={within}\n\t\t\tdata-format={format}\n\t\t\tdata-counter-style={counterStyle}\n\t\t\tdata-range-separator={rangeSeparator}\n\t\t\t{...rest}\n\t\t/>\n\t)\n}\n","import type { CSSProperties, ReactNode } from 'react'\nimport { Template } from './Template'\nimport type { TocLeader } from './types'\n\nexport interface TableOfContentsProps {\n\t/**\n\t * CSS selector for the headings to list. Defaults to `h1, h2, h3`. Like a\n\t * `<NumberingRule>`'s `match`, it matches the content that flows across pages,\n\t * without the scaffolding around it.\n\t */\n\tcollect?: string\n\t/**\n\t * The dot leader between each entry's title and its page number. The default,\n\t * `dots`, draws it; `none` leaves the run between them blank.\n\t */\n\tleader?: TocLeader\n\t/**\n\t * Repeat the leading content with the nav on every page the contents spans, like a\n\t * running header. Off by default: the leading content shows once, above the entries.\n\t */\n\trepeatHead?: boolean\n\t/**\n\t * CSS selector for the headings that enclose the listed ones, e.g. `h1` for a\n\t * chapter's list of its sections. Place the contents after the chapter's heading:\n\t * it lists the headings up to the next match. It runs independently of every other\n\t * contents, so a book's contents can list every chapter while each chapter lists\n\t * its own sections. Without it, a contents runs to the next contents without\n\t * `within`.\n\t */\n\twithin?: string\n\t/**\n\t * Leading content rendered at the top of the contents, above the entries — a\n\t * \"Contents\" heading, an intro line, a rule. Shown once by default; set `repeatHead`\n\t * to repeat it with the nav on every page the contents spans.\n\t */\n\tchildren?: ReactNode\n\t/**\n\t * A class on the rendered `<nav>`. Style the contents with your own CSS, or use\n\t * `styled(TableOfContents)`.\n\t */\n\tclassName?: string\n\t/** An inline style on the rendered `<nav>`. */\n\tstyle?: CSSProperties\n}\n\n/**\n * A table of contents. Format fills it after laying out the document: one entry\n * per heading the `collect` selector matches, each with the heading's number, its\n * title, and the page it landed on.\n *\n * The entries are flat anchors in a `<div data-type=\"toc-entries\">` inside a\n * `<nav data-type=\"toc\">`: each is an `<a data-type=\"toc-entry\" data-depth=\"N\">`\n * (depth 0 at the top of the outline) holding `toc-number`, `toc-title`, and\n * `toc-page` spans. Depth is data, not nesting, so the stylesheet indents and sizes\n * by depth and a long contents paginates by breaking between anchors. Style it through\n * the `data-type` hooks and the `--toc-*` custom properties (root size, per-depth size\n * and indent, page-number size, leader, and vertical rhythm), or set a `className` (or\n * `styled(TableOfContents)`) on the nav. Set `leader=\"none\"` to omit the dot leader\n * entirely, so no leader is drawn between a title and its page number.\n *\n * Children are leading content shown above the entries — put a \"Contents\" heading there.\n * It shows once by default; set `repeatHead` to repeat it with the nav on every page.\n *\n * Place it directly in a `<Flow>` or its `<Stream>`. Inside other content, such as a\n * `<section>`, it renders nothing.\n *\n * A contents lists the headings after it, up to the next contents without `within`.\n * Set `within` to give one its own section instead, such as a chapter's sections\n * beside the book's chapters:\n *\n * ```tsx\n * <TableOfContents collect=\"h1\">…</TableOfContents>\n *\n * <h1>Admissions</h1>\n * <TableOfContents collect=\"h2\" within=\"h1\" />\n * <h2>Requirements</h2>\n * ```\n *\n * Give a collected heading a `data-toc-description` and its entry gains a\n * `toc-description` line under the title (a one-line summary, as on a magazine or\n * report contents):\n *\n * ```tsx\n * <TableOfContents collect=\"h1, h2\">\n * <h2>Contents</h2>\n * </TableOfContents>\n *\n * <h1 data-toc-description=\"Defining the studio's personality and direction.\">\n * Visual Positioning\n * </h1>\n * ```\n */\nexport function TableOfContents({\n\tcollect,\n\tleader,\n\trepeatHead,\n\twithin,\n\tclassName,\n\tstyle,\n\tchildren\n}: TableOfContentsProps) {\n\treturn (\n\t\t<Template\n\t\t\tdata-type='toc'\n\t\t\tdata-collect={collect}\n\t\t\tdata-leader={leader}\n\t\t\tdata-repeat-head={repeatHead === undefined ? undefined : repeatHead ? 'true' : 'false'}\n\t\t\tdata-within={within}\n\t\t\tclassName={className}\n\t\t\tstyle={style}>\n\t\t\t{children}\n\t\t</Template>\n\t)\n}\n","import type { PropsWithChildren } from 'react'\nimport { Template } from './Template'\n\n/**\n * A footnote. Write the note's text as the children, at the point it's\n * referenced; Format leaves a numbered marker inline and moves the text to the\n * footer of whichever page the marker lands on. Footnotes are numbered\n * continuously through the document.\n *\n * Pair it with a `<Footnotes />` region in the Layout to control where the notes\n * sit; without one, Format adds a footer area to each page that needs it.\n *\n * ```tsx\n * <p>The result holds<Footnote>under the stated assumptions</Footnote>.</p>\n * ```\n */\nexport function Footnote({ children }: PropsWithChildren) {\n\t// a `<template>` so the note's text stays inert and out of the inline flow until\n\t// the engine moves it to the footer, leaving just the marker behind\n\treturn <Template data-type='footnote'>{children}</Template>\n}\n","import type { CSSProperties, PropsWithChildren } from 'react'\nimport { Template } from './Template'\nimport type { CounterStyle } from './types'\n\nexport interface FootnotesProps {\n\t/**\n\t * The counter style for the note numbers and their inline markers. Defaults to\n\t * the document's numbering style, or `decimal`.\n\t */\n\tcounterStyle?: CounterStyle\n\t/**\n\t * Restart the numbering on each page, so every page's footer reads 1, 2, 3 rather\n\t * than a count that runs the whole document. For a per-page footer in a Layout; the\n\t * inline markers renumber to match. Off by default (continuous numbering).\n\t */\n\trestartEachPage?: boolean\n\t/**\n\t * Whether the leading content (a heading, a rule) repeats in every page's footer. On by\n\t * default for a per-page Layout footer; an inline endnotes block shows it once. Set `false`\n\t * to show a Layout footer's head on its first page only.\n\t */\n\trepeatHead?: boolean\n\t/** A class name passed through to the wrapping footnotes container. */\n\tclassName?: string\n\t/** An inline style passed through to the wrapping footnotes container. */\n\tstyle?: CSSProperties\n}\n\n/**\n * The region that collects a page's footnotes, authored as a `<template>` Format\n * fills. In a Layout it is a per-page footer gathering the notes whose markers\n * landed there; in a flow's content it is an endnotes list. Format renders it as an\n * `<aside data-type=\"footnotes\">` holding a `<dl data-type=\"footnote-entries\">`, where\n * each note is a `<dt data-type=\"footnote-number\">` term and a\n * `<dd data-type=\"footnote-content\">` definition; style the list as a grid with your\n * own CSS.\n *\n * Put a heading or rule inside `<Footnotes>` to render it above the generated list,\n * the way a table of contents renders its leading content above the entries:\n *\n * ```tsx\n * <Footnotes>\n * <h4>Notes</h4>\n * </Footnotes>\n * ```\n *\n * Omit it and Format adds a plain footer to each page that has footnotes.\n */\nexport function Footnotes({\n\tcounterStyle,\n\trestartEachPage,\n\trepeatHead,\n\tclassName,\n\tstyle,\n\tchildren\n}: PropsWithChildren<FootnotesProps>) {\n\treturn (\n\t\t<Template\n\t\t\tdata-type='footnotes'\n\t\t\tdata-counter-style={counterStyle}\n\t\t\tdata-restart-each-page={restartEachPage ? '' : undefined}\n\t\t\tdata-repeat-head={repeatHead === undefined ? undefined : repeatHead ? 'true' : 'false'}\n\t\t\tclassName={className}\n\t\t\tstyle={style}>\n\t\t\t{children}\n\t\t</Template>\n\t)\n}\n","/**\n * How a Flow splits content that overflows a page: at a `sentence`, `word`, or\n * `grapheme` boundary, or `none` to keep the block whole and move it to the next\n * page intact. Use the constant (`SplitGranularity.None`) or the plain string\n * (`'none'`); both are accepted.\n */\nexport const SplitGranularity = {\n\tSentence: 'sentence',\n\tWord: 'word',\n\tGrapheme: 'grapheme',\n\tNone: 'none'\n} as const\n\nexport type SplitGranularity = (typeof SplitGranularity)[keyof typeof SplitGranularity]\n\n/**\n * The dot leader between a contents entry's title and its page number. The default,\n * `dots`, draws it; `none` leaves the run between them blank. Use the constant\n * (`TocLeader.None`) or the plain string (`'none'`); both are accepted.\n */\nexport const TocLeader = {\n\tDots: 'dots',\n\tNone: 'none'\n} as const\n\nexport type TocLeader = (typeof TocLeader)[keyof typeof TocLeader]\n\n/** How a Layout or Flow decides where pages break: `auto` on overflow\n * and at PageBreak markers, `manual` at PageBreak markers only. */\nexport type PaginationStrategy = 'auto' | 'manual'\n\n/**\n * Which matched heading a `<RunningHead>` shows on a page: the `first` or `last`\n * match on the page, the one the page `start`s with, `firstExcept` to show nothing\n * on a page where a match appears, or the `range` of sections the page holds. On a\n * page with no match, each shows the section carried over from earlier pages.\n */\nexport type RunningHeadShow = 'first' | 'start' | 'last' | 'firstExcept' | 'range'\n\n/**\n * The elements a `<RunningHead>` can render as: those that can hold a shadow root,\n * where its text goes.\n */\nexport type RunningHeadElement =\n\t| 'span'\n\t| 'div'\n\t| 'p'\n\t| 'h1'\n\t| 'h2'\n\t| 'h3'\n\t| 'h4'\n\t| 'h5'\n\t| 'h6'\n\t| 'header'\n\t| 'footer'\n\t| 'nav'\n\t| 'section'\n\t| 'article'\n\t| 'aside'\n\t| 'blockquote'\n\t| 'main'\n\t| 'body'\n\n/**\n * How the PDF embeds its fonts. Mirrors `FontMode` in `@format.dev/fonts`, which owns\n * the canonical list and the default.\n */\nexport type FontMode = 'fidelity' | 'compact'\n\n/**\n * A CSS `<counter-style>` name. The predefined styles autocomplete; any custom\n * `@counter-style` name you define is accepted too.\n */\nexport type CounterStyle =\n\t| 'decimal'\n\t| 'decimal-leading-zero'\n\t| 'lower-roman'\n\t| 'upper-roman'\n\t| 'lower-alpha'\n\t| 'upper-alpha'\n\t| 'lower-latin'\n\t| 'upper-latin'\n\t| 'lower-greek'\n\t| (string & {})\n"],"mappings":";;;;AACA,MAAM,qBAAqB;;;;;;;AAQ3B,SAAgB,mBAAmB,MAAsB;AACxD,QAAO,KAAK,QAAQ,oBAAoB,GAAG;;;;;;;;;;AAW5C,SAAgB,IAAI,OAA6B,GAAG,MAAyB;CAC5E,IAAI,MAAM,MAAM,IAAI,MAAM;AAC1B,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACrC,MAAM,IAAI,KAAK;AACf,UAAQ,KAAK,QAAQ,MAAM,QAAQ,KAAK,OAAO,EAAE,IAAI,MAAM,IAAI,IAAI;;AAEpE,QAAO;;;;;ACrBR,SAAgB,SAAS,EAAE,UAAU,GAAG,SAA2C;CAClF,MAAM,OAAO,mBAAmB,qBAAqB,SAAS,CAAC;AAC/D,QAAO,oBAAC;EAAS,GAAI;E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