@nxgt/material-core 0.1.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/LICENSE +21 -0
- package/README.md +335 -0
- package/dist/chunks/index-0xc5q9tp.js +81 -0
- package/dist/chunks/index-0xc5q9tp.js.map +10 -0
- package/dist/chunks/index-2gcgcmc0.js +36 -0
- package/dist/chunks/index-2gcgcmc0.js.map +10 -0
- package/dist/chunks/index-3ca6xe71.js +36 -0
- package/dist/chunks/index-3ca6xe71.js.map +10 -0
- package/dist/chunks/index-5r6rzp43.js +90 -0
- package/dist/chunks/index-5r6rzp43.js.map +10 -0
- package/dist/chunks/index-6tn0wjsb.js +13 -0
- package/dist/chunks/index-6tn0wjsb.js.map +10 -0
- package/dist/chunks/index-8gf9e2d4.js +76 -0
- package/dist/chunks/index-8gf9e2d4.js.map +11 -0
- package/dist/chunks/index-eh0e5ex7.js +61 -0
- package/dist/chunks/index-eh0e5ex7.js.map +10 -0
- package/dist/chunks/index-g7rh8fpv.js +57 -0
- package/dist/chunks/index-g7rh8fpv.js.map +10 -0
- package/dist/chunks/index-h3vjydz7.js +113 -0
- package/dist/chunks/index-h3vjydz7.js.map +10 -0
- package/dist/chunks/index-paaaedrm.js +37 -0
- package/dist/chunks/index-paaaedrm.js.map +10 -0
- package/dist/chunks/index-w3ajz57t.js +72 -0
- package/dist/chunks/index-w3ajz57t.js.map +10 -0
- package/dist/chunks/index-z3yjh0a8.js +642 -0
- package/dist/chunks/index-z3yjh0a8.js.map +18 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +133 -0
- package/dist/index.js.map +9 -0
- package/dist/lib/currency-digits.d.ts +8 -0
- package/dist/lib/currency-digits.d.ts.map +1 -0
- package/dist/lib/currency-digits.js +24 -0
- package/dist/lib/currency-digits.js.map +10 -0
- package/dist/lib/field-blur-layers.d.ts +35 -0
- package/dist/lib/field-blur-layers.d.ts.map +1 -0
- package/dist/lib/field-blur-layers.js +52 -0
- package/dist/lib/field-blur-layers.js.map +10 -0
- package/dist/lib/pdf-download.d.ts +36 -0
- package/dist/lib/pdf-download.d.ts.map +1 -0
- package/dist/lib/pdf-download.js +15 -0
- package/dist/lib/pdf-download.js.map +9 -0
- package/dist/lib/pdf-file-name.d.ts +10 -0
- package/dist/lib/pdf-file-name.d.ts.map +1 -0
- package/dist/lib/pdf-file-name.js +12 -0
- package/dist/lib/pdf-file-name.js.map +9 -0
- package/dist/lib/pdf-source.d.ts +58 -0
- package/dist/lib/pdf-source.d.ts.map +1 -0
- package/dist/lib/pdf-source.js +21 -0
- package/dist/lib/pdf-source.js.map +9 -0
- package/dist/lib/print-format.utils.d.ts +72 -0
- package/dist/lib/print-format.utils.d.ts.map +1 -0
- package/dist/lib/print-format.utils.js +14 -0
- package/dist/lib/print-format.utils.js.map +9 -0
- package/dist/lib/print-fraction-digits.d.ts +13 -0
- package/dist/lib/print-fraction-digits.d.ts.map +1 -0
- package/dist/lib/print-fraction-digits.js +11 -0
- package/dist/lib/print-fraction-digits.js.map +9 -0
- package/dist/lib/print-table.utils.d.ts +69 -0
- package/dist/lib/print-table.utils.d.ts.map +1 -0
- package/dist/lib/print-table.utils.js +15 -0
- package/dist/lib/print-table.utils.js.map +9 -0
- package/dist/lib/print-value.utils.d.ts +41 -0
- package/dist/lib/print-value.utils.d.ts.map +1 -0
- package/dist/lib/print-value.utils.js +13 -0
- package/dist/lib/print-value.utils.js.map +9 -0
- package/dist/pdf/file-loader.d.ts +19 -0
- package/dist/pdf/file-loader.d.ts.map +1 -0
- package/dist/pdf/file-loader.js +11 -0
- package/dist/pdf/file-loader.js.map +9 -0
- package/dist/pdf/http.d.ts +23 -0
- package/dist/pdf/http.d.ts.map +1 -0
- package/dist/pdf/http.js +13 -0
- package/dist/pdf/http.js.map +9 -0
- package/dist/pdf/index.d.ts +12 -0
- package/dist/pdf/index.d.ts.map +1 -0
- package/dist/pdf/index.js +99 -0
- package/dist/pdf/index.js.map +9 -0
- package/dist/pdf/model/builders.d.ts +59 -0
- package/dist/pdf/model/builders.d.ts.map +1 -0
- package/dist/pdf/model/data-table.d.ts +25 -0
- package/dist/pdf/model/data-table.d.ts.map +1 -0
- package/dist/pdf/model/index.d.ts +5 -0
- package/dist/pdf/model/index.d.ts.map +1 -0
- package/dist/pdf/model/index.js +60 -0
- package/dist/pdf/model/index.js.map +9 -0
- package/dist/pdf/model/nodes.d.ts +135 -0
- package/dist/pdf/model/nodes.d.ts.map +1 -0
- package/dist/pdf/model/theme.d.ts +17 -0
- package/dist/pdf/model/theme.d.ts.map +1 -0
- package/dist/pdf/model/types.d.ts +124 -0
- package/dist/pdf/model/types.d.ts.map +1 -0
- package/dist/pdf/render/context.d.ts +51 -0
- package/dist/pdf/render/context.d.ts.map +1 -0
- package/dist/pdf/render/document.d.ts +22 -0
- package/dist/pdf/render/document.d.ts.map +1 -0
- package/dist/pdf/render/index.d.ts +9 -0
- package/dist/pdf/render/index.d.ts.map +1 -0
- package/dist/pdf/render/index.js +44 -0
- package/dist/pdf/render/index.js.map +9 -0
- package/dist/pdf/render/nodes/blocks.d.ts +20 -0
- package/dist/pdf/render/nodes/blocks.d.ts.map +1 -0
- package/dist/pdf/render/nodes/header.d.ts +15 -0
- package/dist/pdf/render/nodes/header.d.ts.map +1 -0
- package/dist/pdf/render/nodes/layout.d.ts +45 -0
- package/dist/pdf/render/nodes/layout.d.ts.map +1 -0
- package/dist/pdf/render/nodes/table.d.ts +15 -0
- package/dist/pdf/render/nodes/table.d.ts.map +1 -0
- package/dist/pdf/render/page.d.ts +31 -0
- package/dist/pdf/render/page.d.ts.map +1 -0
- package/dist/pdf/render/render-node.d.ts +11 -0
- package/dist/pdf/render/render-node.d.ts.map +1 -0
- package/dist/pdf/render/styles.d.ts +304 -0
- package/dist/pdf/render/styles.d.ts.map +1 -0
- package/dist/pdf-viewer/index.d.ts +14 -0
- package/dist/pdf-viewer/index.d.ts.map +1 -0
- package/dist/pdf-viewer/index.js +380 -0
- package/dist/pdf-viewer/index.js.map +15 -0
- package/dist/pdf-viewer/pdf-document-search.d.ts +44 -0
- package/dist/pdf-viewer/pdf-document-search.d.ts.map +1 -0
- package/dist/pdf-viewer/pdf-escape.d.ts +7 -0
- package/dist/pdf-viewer/pdf-escape.d.ts.map +1 -0
- package/dist/pdf-viewer/pdf-page-geometry.d.ts +62 -0
- package/dist/pdf-viewer/pdf-page-geometry.d.ts.map +1 -0
- package/dist/pdf-viewer/pdf-page-sizes.d.ts +38 -0
- package/dist/pdf-viewer/pdf-page-sizes.d.ts.map +1 -0
- package/dist/pdf-viewer/pdf-scroll-spy.d.ts +43 -0
- package/dist/pdf-viewer/pdf-scroll-spy.d.ts.map +1 -0
- package/dist/pdf-viewer/pdf-text-search.d.ts +26 -0
- package/dist/pdf-viewer/pdf-text-search.d.ts.map +1 -0
- package/dist/vite/index.d.ts +81 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +31 -0
- package/dist/vite/index.js.map +10 -0
- package/docs/README.md +9 -0
- package/docs/roadmap.md +35 -0
- package/docs/troubleshooting.md +105 -0
- package/package.json +187 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/pdf/render/context.ts", "../src/pdf/render/styles.ts", "../src/pdf/render/document.ts", "../src/pdf/render/page.ts", "../src/pdf/render/nodes/blocks.ts", "../src/pdf/render/render-node.ts", "../src/pdf/render/nodes/header.ts", "../src/pdf/render/nodes/layout.ts", "../src/pdf/render/nodes/table.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { IntlMessageFormat } from 'intl-messageformat';\nimport type { ReactNode } from 'react';\nimport {\n\tformatPrintValue,\n\ttype PrintValue,\n\ttype PrintValueOptions,\n} from '../../lib/print-value.utils';\nimport { type PdfTheme, resolvePdfTheme } from '../model/theme';\nimport type { PdfNode, PdfThemeOverrides } from '../model/types';\nimport { createPdfStyles, type PdfStyles } from './styles';\n\n/** Translates a built-in string: its key, English fallback and values. */\nexport type PdfTranslate = (\n\tkey: string,\n\tfallback: string,\n\tvalues?: Record<string, string | number>,\n) => string;\n\n/** Renders a `{ type: 'custom' }` node registered under its `name`. */\nexport type PdfCustomRenderer = (\n\tprops: Record<string, unknown>,\n\tcontext: PdfRenderContext,\n) => ReactNode;\n\n/**\n * Everything a node renderer needs, resolved once per document. It is plain\n * data and functions — never a hook — because react-pdf calls the `render`\n * callbacks of page numbers and fixed elements at layout time, outside React,\n * where a hook throws.\n */\nexport type PdfRenderContext = {\n\tlanguage: string;\n\tlocale?: string;\n\ttimeZone?: string;\n\ttheme: PdfTheme;\n\tstyles: PdfStyles;\n\tt: PdfTranslate;\n\t/**\n\t * Formats a value with the document's locale and time zone, as text the\n\t * standard fonts can print ({@link toPdfText}).\n\t */\n\tformat: (\n\t\tvalue: PrintValue,\n\t\toptions?: Pick<PrintValueOptions, 'empty'>,\n\t) => string;\n\t/** Renders child nodes; set by `createPdfRenderContext`. */\n\trenderNodes: (nodes: PdfNode[] | undefined) => ReactNode[];\n\tcustom: Record<string, PdfCustomRenderer>;\n};\n\nexport type PdfRenderOptions = {\n\t/** `'en'` or `'fr'` pick the built-in strings; `'en'` by default. */\n\tlanguage?: string;\n\t/** Formats amounts and dates; defaults to `language`. */\n\tlocale?: string;\n\ttimeZone?: string;\n\ttheme?: PdfThemeOverrides;\n\t/**\n\t * Translates the built-in strings (`material.print.*` keys); without it,\n\t * the English fallbacks are printed.\n\t */\n\ttranslate?: PdfTranslate;\n\t/** Renderers for `{ type: 'custom', name }` nodes. */\n\tcustom?: Record<string, PdfCustomRenderer>;\n};\n\nexport const DEFAULT_PDF_LANGUAGE = 'en';\n\n// Characters `Intl` emits that the PDF standard fonts (WinAnsi) lack: the\n// narrow no-break space French puts in `1 234,50 €` prints as `/` in\n// Helvetica, and the thin space and minus sign as nothing.\nconst NOT_IN_STANDARD_FONTS = /[\\u202f\\u2009\\u2212]/g;\nconst REPLACEMENTS: Record<string, string> = {\n\t'\\u202f': '\\u00a0',\n\t'\\u2009': ' ',\n\t'\\u2212': '-',\n};\n\n/** Text with the characters the standard fonts lack replaced by ones they have. */\nexport function toPdfText(text: string): string {\n\treturn text.replace(NOT_IN_STANDARD_FONTS, (c) => REPLACEMENTS[c] ?? c);\n}\n\n/**\n * The English fallback of a built-in string, formatted with its values. The\n * keys are translated only when the caller passes `translate` (the libraries\n * pass their own `translateMaterial`): this folder imports nothing from the\n * i18n module, so it can move into a package of its own unchanged.\n */\nfunction formatEnglish(\n\tfallback: string,\n\tlanguage: string,\n\tvalues?: Record<string, string | number>,\n): string {\n\tif (!values) return fallback;\n\ttry {\n\t\treturn String(new IntlMessageFormat(fallback, language).format(values));\n\t} catch {\n\t\treturn fallback;\n\t}\n}\n\nexport function createPdfRenderContext(\n\toptions: PdfRenderOptions,\n\trenderNodes: (\n\t\tnodes: PdfNode[] | undefined,\n\t\tcontext: PdfRenderContext,\n\t) => ReactNode[],\n): PdfRenderContext {\n\tconst language = options.language || DEFAULT_PDF_LANGUAGE;\n\tconst locale = options.locale ?? language;\n\tconst theme = resolvePdfTheme(options.theme);\n\tconst context: PdfRenderContext = {\n\t\tlanguage,\n\t\tlocale,\n\t\ttimeZone: options.timeZone,\n\t\ttheme,\n\t\tstyles: createPdfStyles(theme),\n\t\tt: (key, fallback, values) =>\n\t\t\ttoPdfText(\n\t\t\t\toptions.translate\n\t\t\t\t\t? options.translate(key, fallback, values)\n\t\t\t\t\t: formatEnglish(fallback, language, values),\n\t\t\t),\n\t\tformat: (value, formatOptions) =>\n\t\t\ttoPdfText(\n\t\t\t\tformatPrintValue(value, {\n\t\t\t\t\tlocale,\n\t\t\t\t\ttimeZone: options.timeZone,\n\t\t\t\t\t...formatOptions,\n\t\t\t\t}),\n\t\t\t),\n\t\trenderNodes: (nodes) => renderNodes(nodes, context),\n\t\tcustom: options.custom ?? {},\n\t};\n\treturn context;\n}\n",
|
|
6
|
+
"import type { Styles } from '@react-pdf/renderer';\nimport type { PdfTheme } from '../model/theme';\n\n/** One react-pdf style object. */\nexport type PdfElementStyle = Styles[string];\n\n/**\n * Plain react-pdf styles for every block, from a theme. The keys shared with\n * `commonPrintStyles` hold exactly what `tw(commonPrintStyles.x)` gives in\n * `@nxgt/material/print` (a test there compares them), so a document built\n * from the model looks like one written with the JSX blocks.\n */\nexport function createPdfStyles({ colors: c, fonts }: PdfTheme) {\n\tconst pad = (y: number, x: number) => ({\n\t\tpaddingTop: y,\n\t\tpaddingBottom: y,\n\t\tpaddingLeft: x,\n\t\tpaddingRight: x,\n\t});\n\treturn {\n\t\tpage: {\n\t\t\tfontFamily: fonts.sans,\n\t\t\tfontSize: '9pt',\n\t\t\tcolor: c.text,\n\t\t\t...pad(21, 24),\n\t\t\tflexDirection: 'column',\n\t\t\tgap: 0,\n\t\t},\n\t\theader: { flexDirection: 'row', alignItems: 'center', marginBottom: 12 },\n\t\theaderTitle: {\n\t\t\tfontSize: '18pt',\n\t\t\tfontWeight: 700,\n\t\t\tcolor: c.text,\n\t\t\tletterSpacing: -0.3,\n\t\t},\n\t\theaderRef: { fontSize: '10pt', color: c.secondary, marginTop: 1.5 },\n\t\tdivider: {\n\t\t\tborderBottomWidth: 1,\n\t\t\tborderColor: c.border,\n\t\t\tmarginBottom: 10.5,\n\t\t},\n\t\tsectionTitle: {\n\t\t\tfontSize: '9pt',\n\t\t\tfontWeight: 700,\n\t\t\tcolor: c.secondary,\n\t\t\tmarginBottom: 4.5,\n\t\t\ttextTransform: 'uppercase',\n\t\t\tletterSpacing: 0.3,\n\t\t},\n\t\tinfoGrid: { flexDirection: 'row', gap: 12, marginBottom: 10.5 },\n\t\tinfoCol: { flex: '1 1 0%', flexDirection: 'column', gap: 4.5 },\n\t\tinfoRow: { flexDirection: 'row', gap: 3 },\n\t\tinfoLabel: { fontSize: '8pt', color: c.muted, fontWeight: 700, width: 96 },\n\t\tinfoValue: { fontSize: '9pt', color: c.text, flex: '1 1 0%' },\n\t\ttableSection: { marginBottom: 10.5 },\n\t\ttableHeader: {\n\t\t\tflexDirection: 'row',\n\t\t\tbackgroundColor: c.headerBg,\n\t\t\tborderRadius: 2,\n\t\t\t...pad(4.5, 4.5),\n\t\t\tgap: 4.5,\n\t\t\tmarginBottom: 1.5,\n\t\t},\n\t\ttableHeaderCell: { fontSize: '8pt', fontWeight: 700, color: c.headerText },\n\t\ttableRow: {\n\t\t\tflexDirection: 'row',\n\t\t\t...pad(4.5, 4.5),\n\t\t\tgap: 4.5,\n\t\t\tborderBottomWidth: 1,\n\t\t\tborderColor: c.border,\n\t\t},\n\t\ttableRowAlt: { backgroundColor: c.rowAlt },\n\t\ttableCell: { fontSize: '8pt', color: c.text },\n\t\ttotalsSection: { alignItems: 'flex-end', marginBottom: 10.5 },\n\t\ttotalsTable: {\n\t\t\twidth: '220pt',\n\t\t\tborderWidth: 1,\n\t\t\tborderColor: c.border,\n\t\t\tborderRadius: 3,\n\t\t},\n\t\ttotalsRow: {\n\t\t\tflexDirection: 'row',\n\t\t\tjustifyContent: 'space-between',\n\t\t\t...pad(3, 7.5),\n\t\t\tborderBottomWidth: 1,\n\t\t\tborderColor: c.border,\n\t\t},\n\t\ttotalsRowLast: {\n\t\t\tflexDirection: 'row',\n\t\t\tjustifyContent: 'space-between',\n\t\t\t...pad(4.5, 7.5),\n\t\t\tbackgroundColor: c.headerBg,\n\t\t\tborderRadius: 2,\n\t\t},\n\t\ttotalsLabel: { fontSize: '8pt', color: c.secondary },\n\t\ttotalsValue: { fontSize: '8pt', color: c.text, fontWeight: 700 },\n\t\ttotalsLabelBold: { fontSize: '9pt', color: c.headerText, fontWeight: 700 },\n\t\ttotalsValueBold: { fontSize: '9pt', color: c.headerText, fontWeight: 700 },\n\t\tnotesSection: {\n\t\t\tborderWidth: 1,\n\t\t\tborderColor: c.border,\n\t\t\tborderRadius: 6,\n\t\t\tpadding: 7.5,\n\t\t},\n\t\tnotesText: { fontSize: '8pt', color: c.secondary, lineHeight: 1.5 },\n\t\tbadge: { borderRadius: 9, ...pad(4.5, 12), alignSelf: 'flex-start' },\n\t\tbadgeText: { fontSize: '8pt', fontWeight: 700, color: c.headerText },\n\t\t// Blocks the JSX components never had.\n\t\tsection: { marginBottom: 10.5 },\n\t\tlogoBox: {\n\t\t\twidth: '72pt',\n\t\t\theight: '48pt',\n\t\t\tborderRadius: 2,\n\t\t\tjustifyContent: 'center',\n\t\t\talignItems: 'center',\n\t\t},\n\t\tlogoText: {\n\t\t\tfontSize: '11pt',\n\t\t\tfontWeight: 700,\n\t\t\tcolor: c.secondary,\n\t\t\tletterSpacing: 2,\n\t\t\ttextTransform: 'uppercase',\n\t\t},\n\t\theaderCentre: {\n\t\t\tflex: '1 1 0%',\n\t\t\tflexDirection: 'column',\n\t\t\talignItems: 'center',\n\t\t},\n\t\theaderSubtitle: { fontSize: '10pt', color: c.muted, marginTop: 1.5 },\n\t\tqrBox: { width: '60pt', height: '60pt', borderRadius: 2 },\n\t\theading1: {\n\t\t\tfontSize: '16pt',\n\t\t\tfontWeight: 700,\n\t\t\tcolor: c.text,\n\t\t\tmarginBottom: 6,\n\t\t},\n\t\theading2: {\n\t\t\tfontSize: '12pt',\n\t\t\tfontWeight: 700,\n\t\t\tcolor: c.text,\n\t\t\tmarginBottom: 4.5,\n\t\t},\n\t\theading3: {\n\t\t\tfontSize: '10pt',\n\t\t\tfontWeight: 700,\n\t\t\tcolor: c.secondary,\n\t\t\tmarginBottom: 3,\n\t\t},\n\t\ttextBody: { fontSize: '9pt', color: c.text },\n\t\ttextMuted: { fontSize: '9pt', color: c.muted },\n\t\ttextCaption: { fontSize: '7pt', color: c.muted },\n\t\ttextLabel: {\n\t\t\tfontSize: '7pt',\n\t\t\tfontWeight: 700,\n\t\t\tcolor: c.muted,\n\t\t\ttextTransform: 'uppercase',\n\t\t},\n\t\tlink: { color: c.secondary, textDecoration: 'underline' },\n\t\ttableEmpty: { fontSize: '8pt', color: c.muted, fontStyle: 'italic' },\n\t\ttableFooter: { flexDirection: 'row', ...pad(4.5, 4.5), gap: 4.5 },\n\t\ttableFooterCell: { fontSize: '8pt', fontWeight: 700, color: c.text },\n\t\tmetric: {\n\t\t\tflex: '1 1 0%',\n\t\t\tborderWidth: 1,\n\t\t\tborderColor: c.border,\n\t\t\tborderRadius: 3,\n\t\t\tpadding: 7.5,\n\t\t\tgap: 3,\n\t\t},\n\t\tmetricValue: { fontSize: '14pt', fontWeight: 700, color: c.text },\n\t\tdeltaUp: { fontSize: '8pt', color: c.success },\n\t\tdeltaDown: { fontSize: '8pt', color: c.error },\n\t\tpageNumber: { fontSize: '8pt', color: c.muted },\n\t} satisfies Record<string, PdfElementStyle>;\n}\n\nexport type PdfStyles = ReturnType<typeof createPdfStyles>;\nexport type PdfStyleName = keyof PdfStyles;\n",
|
|
7
|
+
"import { Document, type DocumentProps } from '@react-pdf/renderer';\nimport { createElement as h, type ReactElement, type ReactNode } from 'react';\nimport type { PdfDocument, PdfMeta } from '../model/types';\nimport {\n\tcreatePdfRenderContext,\n\ttype PdfRenderContext,\n\ttype PdfRenderOptions,\n} from './context';\nimport { renderPdfPage } from './page';\nimport { renderPdfNodes } from './render-node';\n\n/** A render context for a document, or for blocks outside of one. */\nexport function createPdfContext(options: PdfRenderOptions = {}) {\n\treturn createPdfRenderContext(options, renderPdfNodes);\n}\n\nexport type PdfDocumentShellOptions = PdfMeta & {\n\t/** Written to the PDF as its language, such as `'fr'`. */\n\tlanguage?: string;\n};\n\n/** The react-pdf `Document`: metadata and the pages. */\nexport function renderPdfDocumentShell(\n\toptions: PdfDocumentShellOptions,\n\tpages: ReactNode[],\n): ReactElement<DocumentProps> {\n\tconst { title, author, subject, keywords, creator, producer, language } =\n\t\toptions;\n\treturn h(\n\t\tDocument,\n\t\t{\n\t\t\ttitle,\n\t\t\tauthor,\n\t\t\tsubject,\n\t\t\tkeywords,\n\t\t\tcreator,\n\t\t\tproducer: producer ?? creator,\n\t\t\tlanguage,\n\t\t},\n\t\t...pages,\n\t);\n}\n\nexport type RenderPdfElementOptions = Pick<\n\tPdfRenderOptions,\n\t'translate' | 'custom'\n> & {\n\t/** `creator` and `producer` when the document's `meta` names none. */\n\tdefaultCreator?: string;\n};\n\n/**\n * Turns a model document into the react-pdf element tree that `pdf()`,\n * `renderToBuffer()` or `PDFViewer` take.\n */\nexport function renderPdfElement(\n\tdoc: PdfDocument,\n\toptions: RenderPdfElementOptions = {},\n): ReactElement<DocumentProps> {\n\tif (doc.version !== 1) {\n\t\tthrow new Error(\n\t\t\t`[pdf] Unsupported document version ${String(doc.version)}: this version renders version 1.`,\n\t\t);\n\t}\n\tconst context: PdfRenderContext = createPdfContext({\n\t\tlanguage: doc.language,\n\t\tlocale: doc.locale,\n\t\ttimeZone: doc.timeZone,\n\t\ttheme: doc.theme,\n\t\t...options,\n\t});\n\tconst pages = doc.pages.map((page) =>\n\t\trenderPdfPage(\n\t\t\tpage,\n\t\t\t{\n\t\t\t\theader: page.header?.length\n\t\t\t\t\t? context.renderNodes(page.header)\n\t\t\t\t\t: undefined,\n\t\t\t\tfooter: page.footer?.length\n\t\t\t\t\t? context.renderNodes(page.footer)\n\t\t\t\t\t: undefined,\n\t\t\t\tbody: context.renderNodes(page.body),\n\t\t\t},\n\t\t\tcontext,\n\t\t),\n\t);\n\treturn renderPdfDocumentShell(\n\t\t{\n\t\t\t...doc.meta,\n\t\t\tcreator: doc.meta?.creator ?? options.defaultCreator,\n\t\t\tlanguage: doc.language,\n\t\t},\n\t\tpages,\n\t);\n}\n",
|
|
8
|
+
"import { Page, Text, View } from '@react-pdf/renderer';\nimport { createElement as h, type ReactNode } from 'react';\nimport { resolvePdfColor } from '../model/theme';\nimport type { PdfBox, PdfPageOptions } from '../model/types';\nimport { type PdfRenderContext, toPdfText } from './context';\nimport { renderPageNumber } from './nodes/blocks';\n\nexport const DEFAULT_PDF_MARGINS = { top: 21, right: 24, bottom: 21, left: 24 };\nexport const DEFAULT_FOOTER_HEIGHT = 24;\n\nexport type PdfMargins = typeof DEFAULT_PDF_MARGINS;\n\n/**\n * Margins in points from a number or a box: a side wins over its axis\n * (`x`, `y`), which wins over the default.\n */\nexport function resolvePdfMargins(margins?: number | PdfBox): PdfMargins {\n\tif (typeof margins === 'number') {\n\t\treturn { top: margins, right: margins, bottom: margins, left: margins };\n\t}\n\tconst box = margins ?? {};\n\tconst d = DEFAULT_PDF_MARGINS;\n\treturn {\n\t\ttop: box.top ?? box.y ?? d.top,\n\t\tright: box.right ?? box.x ?? d.right,\n\t\tbottom: box.bottom ?? box.y ?? d.bottom,\n\t\tleft: box.left ?? box.x ?? d.left,\n\t};\n}\n\nexport type PdfPageParts = {\n\t/** Repeated at the top of every page, in the flow. */\n\theader?: ReactNode;\n\t/** Repeated at the bottom of every page, in the space kept for it. */\n\tfooter?: ReactNode;\n\tbody: ReactNode[];\n};\n\nfunction renderWatermark(\n\twatermark: NonNullable<PdfPageOptions['watermark']>,\n\tctx: PdfRenderContext,\n) {\n\tconst mark = typeof watermark === 'string' ? { text: watermark } : watermark;\n\treturn h(\n\t\tView,\n\t\t{\n\t\t\tfixed: true,\n\t\t\tstyle: {\n\t\t\t\tposition: 'absolute',\n\t\t\t\ttop: 0,\n\t\t\t\tright: 0,\n\t\t\t\tbottom: 0,\n\t\t\t\tleft: 0,\n\t\t\t\tjustifyContent: 'center',\n\t\t\t\talignItems: 'center',\n\t\t\t},\n\t\t},\n\t\th(\n\t\t\tText,\n\t\t\t{\n\t\t\t\tstyle: {\n\t\t\t\t\tfontSize: mark.fontSize ?? 72,\n\t\t\t\t\tfontWeight: 700,\n\t\t\t\t\tcolor: resolvePdfColor(mark.color ?? 'muted', ctx.theme),\n\t\t\t\t\topacity: mark.opacity ?? 0.08,\n\t\t\t\t\ttransform: `rotate(${-(mark.angle ?? 35)}deg)`,\n\t\t\t\t},\n\t\t\t},\n\t\t\ttoPdfText(mark.text),\n\t\t),\n\t);\n}\n\n/**\n * The footer and the page number in one fixed row, in the space kept at the\n * bottom, so they never draw over each other. With a footer, the number sits\n * after it, or before it when aligned left; alone, it takes the whole row.\n */\nfunction renderFooterRow(\n\tfooter: ReactNode,\n\tpageNumber: ReactNode,\n\tnumberFirst: boolean,\n\tmargins: PdfMargins,\n\theight: number,\n) {\n\tconst parts = [\n\t\t...(footer ? [h(View, { key: 'footer', style: { flex: 1 } }, footer)] : []),\n\t\t...(pageNumber\n\t\t\t? [\n\t\t\t\t\th(\n\t\t\t\t\t\tView,\n\t\t\t\t\t\t{ key: 'number', style: footer ? { marginLeft: 12 } : { flex: 1 } },\n\t\t\t\t\t\tpageNumber,\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t: []),\n\t];\n\tif (numberFirst && footer && pageNumber) {\n\t\tparts.reverse();\n\t\tparts[0] = h(\n\t\t\tView,\n\t\t\t{ key: 'number', style: { marginRight: 12 } },\n\t\t\tpageNumber,\n\t\t);\n\t}\n\treturn h(\n\t\tView,\n\t\t{\n\t\t\tfixed: true,\n\t\t\tstyle: {\n\t\t\t\tposition: 'absolute',\n\t\t\t\tleft: margins.left,\n\t\t\t\tright: margins.right,\n\t\t\t\tbottom: margins.bottom,\n\t\t\t\theight,\n\t\t\t\tflexDirection: 'row',\n\t\t\t\talignItems: 'flex-end',\n\t\t\t},\n\t\t},\n\t\t...parts,\n\t);\n}\n\n/**\n * One react-pdf `Page`: size, orientation and margins, the header fixed at\n * the top of each page, the footer and page number fixed in the space kept\n * at the bottom, and the watermark behind everything.\n */\nexport function renderPdfPage(\n\toptions: PdfPageOptions,\n\tparts: PdfPageParts,\n\tctx: PdfRenderContext,\n) {\n\tconst margins = resolvePdfMargins(options.margins);\n\tconst numbers = options.pageNumbers;\n\tconst hasFooter = Boolean(parts.footer) || Boolean(numbers);\n\tconst footerHeight = options.footerHeight ?? DEFAULT_FOOTER_HEIGHT;\n\tconst pageNumber =\n\t\tnumbers &&\n\t\trenderPageNumber(\n\t\t\t{\n\t\t\t\ttype: 'pageNumber',\n\t\t\t\t...(typeof numbers === 'object' ? numbers : {}),\n\t\t\t},\n\t\t\tctx,\n\t\t);\n\tconst numberFirst = typeof numbers === 'object' && numbers.align === 'left';\n\treturn h(\n\t\tPage,\n\t\t{\n\t\t\tsize: options.size ?? 'A4',\n\t\t\torientation: options.orientation ?? 'portrait',\n\t\t\twrap: true,\n\t\t\tstyle: {\n\t\t\t\t...ctx.styles.page,\n\t\t\t\tpaddingTop: margins.top,\n\t\t\t\tpaddingRight: margins.right,\n\t\t\t\tpaddingLeft: margins.left,\n\t\t\t\tpaddingBottom: margins.bottom + (hasFooter ? footerHeight : 0),\n\t\t\t},\n\t\t},\n\t\t...(options.watermark ? [renderWatermark(options.watermark, ctx)] : []),\n\t\t...(parts.header ? [h(View, { fixed: true }, parts.header)] : []),\n\t\t...parts.body,\n\t\t...(hasFooter\n\t\t\t? [\n\t\t\t\t\trenderFooterRow(\n\t\t\t\t\t\tparts.footer,\n\t\t\t\t\t\tpageNumber,\n\t\t\t\t\t\tnumberFirst,\n\t\t\t\t\t\tmargins,\n\t\t\t\t\t\tfooterHeight,\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t: []),\n\t);\n}\n",
|
|
9
|
+
"import { Text, View } from '@react-pdf/renderer';\nimport { createElement as h } from 'react';\nimport { isEmptyPrintValue } from '../../../lib/print-value.utils';\nimport { resolvePdfColor } from '../../model/theme';\nimport type { PdfNode } from '../../model/types';\nimport { type PdfRenderContext, toPdfText } from '../context';\n\ntype NodeOf<T extends PdfNode['type']> = Extract<PdfNode, { type: T }>;\n\n/** Label and value pairs, in one or two columns; empty values are skipped. */\nexport function renderKeyValue(\n\tnode: NodeOf<'keyValue'>,\n\tctx: PdfRenderContext,\n) {\n\tconst { styles } = ctx;\n\tconst items = node.keepEmpty\n\t\t? node.items\n\t\t: node.items.filter((item) => !isEmptyPrintValue(item.value));\n\tif (items.length === 0) return null;\n\tconst pair = (item: (typeof items)[number]) =>\n\t\th(\n\t\t\tView,\n\t\t\t{ style: styles.infoRow, wrap: false },\n\t\t\th(Text, { style: styles.infoLabel }, toPdfText(item.label)),\n\t\t\th(Text, { style: styles.infoValue }, ctx.format(item.value)),\n\t\t);\n\tif ((node.columns ?? 1) === 1) {\n\t\treturn h(\n\t\t\tView,\n\t\t\t{ style: [styles.infoCol, { marginBottom: 10.5 }] },\n\t\t\t...items.map(pair),\n\t\t);\n\t}\n\tconst half = Math.ceil(items.length / 2);\n\treturn h(\n\t\tView,\n\t\t{ style: styles.infoGrid },\n\t\th(View, { style: styles.infoCol }, ...items.slice(0, half).map(pair)),\n\t\th(View, { style: styles.infoCol }, ...items.slice(half).map(pair)),\n\t);\n}\n\n/** A right-aligned box of totals; an `emphasis` row is the dark last row. */\nexport function renderTotals(node: NodeOf<'totals'>, ctx: PdfRenderContext) {\n\tconst { styles } = ctx;\n\treturn h(\n\t\tView,\n\t\t{ style: styles.totalsSection, wrap: false },\n\t\th(\n\t\t\tView,\n\t\t\t{ style: styles.totalsTable },\n\t\t\t...node.rows.map((row) =>\n\t\t\t\th(\n\t\t\t\t\tView,\n\t\t\t\t\t{ style: row.emphasis ? styles.totalsRowLast : styles.totalsRow },\n\t\t\t\t\th(\n\t\t\t\t\t\tText,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstyle: row.emphasis ? styles.totalsLabelBold : styles.totalsLabel,\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttoPdfText(row.label),\n\t\t\t\t\t),\n\t\t\t\t\th(\n\t\t\t\t\t\tText,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstyle: row.emphasis ? styles.totalsValueBold : styles.totalsValue,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tctx.format(row.value),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t),\n\t);\n}\n\n/** `+4%` / `-2%`, in the document's locale: an ASCII minus, which the standard fonts have (not U+2212). */\nfunction formatDelta(delta: number, ctx: PdfRenderContext) {\n\tconst text = ctx.format({\n\t\tnumber: Math.abs(delta) / 100,\n\t\tstyle: 'percent',\n\t\tfractionDigits: 1,\n\t});\n\treturn `${delta >= 0 ? '+' : '-'}${text}`;\n}\n\n/** One figure with its label, an optional hint and change. */\nexport function renderMetric(node: NodeOf<'metric'>, ctx: PdfRenderContext) {\n\tconst { styles } = ctx;\n\treturn h(\n\t\tView,\n\t\t{ style: styles.metric, wrap: false },\n\t\th(Text, { style: styles.textLabel }, toPdfText(node.label)),\n\t\th(Text, { style: styles.metricValue }, ctx.format(node.value)),\n\t\t...(node.delta !== undefined\n\t\t\t? [\n\t\t\t\t\th(\n\t\t\t\t\t\tText,\n\t\t\t\t\t\t{ style: node.delta >= 0 ? styles.deltaUp : styles.deltaDown },\n\t\t\t\t\t\tformatDelta(node.delta, ctx),\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t: []),\n\t\t...(node.hint\n\t\t\t? [h(Text, { style: styles.textCaption }, toPdfText(node.hint))]\n\t\t\t: []),\n\t);\n}\n\nexport function renderBadge(node: NodeOf<'badge'>, ctx: PdfRenderContext) {\n\treturn h(\n\t\tView,\n\t\t{\n\t\t\tstyle: [\n\t\t\t\tctx.styles.badge,\n\t\t\t\t{\n\t\t\t\t\tbackgroundColor: resolvePdfColor(node.color ?? 'primary', ctx.theme),\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\th(Text, { style: ctx.styles.badgeText }, toPdfText(node.text)),\n\t);\n}\n\n/**\n * \"Page 2 of 5\" (or \"Page 2\"), translated. react-pdf calls `render` at layout\n * time, outside React, so it only uses what the context already resolved.\n */\nexport function renderPageNumber(\n\tnode: NodeOf<'pageNumber'>,\n\tctx: PdfRenderContext,\n) {\n\tconst pageOf = node.format !== 'page';\n\treturn h(Text, {\n\t\tstyle: [ctx.styles.pageNumber, { textAlign: node.align ?? 'center' }],\n\t\tfixed: true,\n\t\trender: ({\n\t\t\tpageNumber,\n\t\t\ttotalPages,\n\t\t}: {\n\t\t\tpageNumber: number;\n\t\t\ttotalPages: number;\n\t\t}) =>\n\t\t\tpageOf\n\t\t\t\t? ctx.t('material.print.page-of', 'Page {page} of {pages}', {\n\t\t\t\t\t\tpage: pageNumber,\n\t\t\t\t\t\tpages: totalPages,\n\t\t\t\t\t})\n\t\t\t\t: ctx.t('material.print.page', 'Page {page}', { page: pageNumber }),\n\t});\n}\n",
|
|
10
|
+
"import { createElement, Fragment, type ReactNode } from 'react';\nimport type { PdfNode } from '../model/types';\nimport type { PdfRenderContext } from './context';\nimport {\n\trenderBadge,\n\trenderKeyValue,\n\trenderMetric,\n\trenderPageNumber,\n\trenderTotals,\n} from './nodes/blocks';\nimport { renderHeader } from './nodes/header';\nimport {\n\trenderDivider,\n\trenderHeading,\n\trenderImage,\n\trenderLink,\n\trenderPageBreak,\n\trenderRow,\n\trenderSection,\n\trenderSpacer,\n\trenderStack,\n\trenderText,\n} from './nodes/layout';\nimport { renderTable } from './nodes/table';\n\n// Own keys only: a document is data, and `\"constructor\"` or `\"toString\"` as a\n// type or a name must not reach an inherited property.\nconst own = (record: object, key: string) => Object.keys(record).includes(key);\n\ntype Renderers = {\n\t[T in PdfNode['type']]: (\n\t\tnode: Extract<PdfNode, { type: T }>,\n\t\tcontext: PdfRenderContext,\n\t) => ReactNode;\n};\n\nconst RENDERERS: Renderers = {\n\tstack: renderStack,\n\trow: renderRow,\n\ttext: renderText,\n\theading: renderHeading,\n\tsection: renderSection,\n\timage: renderImage,\n\tlink: renderLink,\n\tspacer: renderSpacer,\n\tdivider: renderDivider,\n\tpageBreak: renderPageBreak,\n\ttable: renderTable,\n\tkeyValue: renderKeyValue,\n\ttotals: renderTotals,\n\tmetric: renderMetric,\n\tbadge: renderBadge,\n\theader: renderHeader,\n\tpageNumber: renderPageNumber,\n\tcustom: (node, context) => {\n\t\tconst render = own(context.custom, node.name)\n\t\t\t? context.custom[node.name]\n\t\t\t: undefined;\n\t\tif (!render) {\n\t\t\tthrow new Error(\n\t\t\t\t`[pdf] No renderer for the custom node \"${node.name}\": pass it in \\`custom\\` when rendering.`,\n\t\t\t);\n\t\t}\n\t\treturn render(node.props ?? {}, context);\n\t},\n};\n\n/**\n * Renders one model node as react-pdf elements. An unknown `type` throws: a\n * document from a newer version, or a typo in hand-written JSON.\n */\nexport function renderPdfNode(node: PdfNode, context: PdfRenderContext) {\n\tconst render = own(RENDERERS, node.type)\n\t\t? (RENDERERS[node.type] as (\n\t\t\t\tnode: PdfNode,\n\t\t\t\tcontext: PdfRenderContext,\n\t\t\t) => ReactNode)\n\t\t: undefined;\n\tif (!render) {\n\t\tthrow new Error(\n\t\t\t`[pdf] Unknown node type \"${(node as { type: string }).type}\".`,\n\t\t);\n\t}\n\treturn render(node, context);\n}\n\n/** Renders a list of nodes, each under its index as key. */\nexport function renderPdfNodes(\n\tnodes: PdfNode[] | undefined,\n\tcontext: PdfRenderContext,\n): ReactNode[] {\n\treturn (nodes ?? []).map((node, index) =>\n\t\tcreateElement(Fragment, { key: index }, renderPdfNode(node, context)),\n\t);\n}\n",
|
|
11
|
+
"import { Image, Text, View } from '@react-pdf/renderer';\nimport { createElement as h } from 'react';\nimport type { PdfNode } from '../../model/types';\nimport { type PdfRenderContext, toPdfText } from '../context';\n\ntype HeaderNode = Extract<PdfNode, { type: 'header' }>;\n\nconst LOGO = { width: 72, height: 48 };\nconst QR = 60;\n\nfunction logoBox(node: HeaderNode, ctx: PdfRenderContext) {\n\tconst { styles, theme } = ctx;\n\tif (node.logo) {\n\t\tconst logo = typeof node.logo === 'string' ? { src: node.logo } : node.logo;\n\t\tconst width = logo.width ?? LOGO.width;\n\t\tconst height = logo.height ?? LOGO.height;\n\t\treturn h(Image, {\n\t\t\tsrc: logo.src,\n\t\t\tstyle: { width, height, objectFit: 'contain', objectPosition: 'left' },\n\t\t});\n\t}\n\tif (node.logoText) {\n\t\treturn h(\n\t\t\tView,\n\t\t\t{ style: [styles.logoBox, { backgroundColor: theme.colors.logoBg }] },\n\t\t\th(Text, { style: styles.logoText }, toPdfText(node.logoText)),\n\t\t);\n\t}\n\treturn null;\n}\n\n/**\n * The title block: logo (an image, or `logoText` in a box) on the left, the\n * title, subtitle and reference centred, a QR code on the right. A side with\n * nothing to show keeps an empty box of the other side's width, so the title\n * stays centred; with neither, the title is centred on the page.\n */\nexport function renderHeader(node: HeaderNode, ctx: PdfRenderContext) {\n\tconst { styles } = ctx;\n\tconst logo = logoBox(node, ctx);\n\tconst qr = node.qrDataUrl\n\t\t? h(Image, { src: node.qrDataUrl, style: styles.qrBox })\n\t\t: null;\n\tconst logoWidth =\n\t\tnode.logo && typeof node.logo === 'object'\n\t\t\t? (node.logo.width ?? LOGO.width)\n\t\t\t: LOGO.width;\n\tconst side = Math.max(logo ? logoWidth : 0, qr ? QR : 0);\n\tconst spacer = h(View, { style: { width: side } });\n\tconst reference = node.reference\n\t\t? toPdfText(`${node.referencePrefix ?? '#'}${node.reference}`)\n\t\t: null;\n\n\treturn h(\n\t\tView,\n\t\t{ style: styles.header },\n\t\t...(side ? [h(View, { style: { width: side } }, logo ?? spacer)] : []),\n\t\th(\n\t\t\tView,\n\t\t\t{ style: styles.headerCentre },\n\t\t\th(Text, { style: styles.headerTitle }, toPdfText(node.title)),\n\t\t\t...(node.subtitle\n\t\t\t\t? [h(Text, { style: styles.headerSubtitle }, toPdfText(node.subtitle))]\n\t\t\t\t: []),\n\t\t\t...(reference ? [h(Text, { style: styles.headerRef }, reference)] : []),\n\t\t),\n\t\t...(side\n\t\t\t? [\n\t\t\t\t\th(\n\t\t\t\t\t\tView,\n\t\t\t\t\t\t{ style: { width: side, alignItems: 'flex-end' } },\n\t\t\t\t\t\tqr ?? spacer,\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t: []),\n\t);\n}\n",
|
|
12
|
+
"import { Image, Link, Text, View } from '@react-pdf/renderer';\nimport { createElement as h } from 'react';\nimport { resolvePdfColor } from '../../model/theme';\nimport type { PdfInline, PdfNode, PdfStyle } from '../../model/types';\nimport { type PdfRenderContext, toPdfText } from '../context';\nimport type { PdfElementStyle } from '../styles';\n\ntype NodeOf<T extends PdfNode['type']> = Extract<PdfNode, { type: T }>;\n\n/** A model style with its theme colours and font resolved. */\nexport function toStyle(style: PdfStyle | undefined, ctx: PdfRenderContext) {\n\tif (!style) return {};\n\tconst { color, backgroundColor, borderColor, fontFamily, ...rest } = style;\n\treturn {\n\t\t...rest,\n\t\t...(fontFamily &&\n\t\t\tObject.keys(ctx.theme.fonts).includes(fontFamily) && {\n\t\t\t\tfontFamily: ctx.theme.fonts[fontFamily],\n\t\t\t}),\n\t\t...(color && { color: resolvePdfColor(color, ctx.theme) }),\n\t\t...(backgroundColor && {\n\t\t\tbackgroundColor: resolvePdfColor(backgroundColor, ctx.theme),\n\t\t}),\n\t\t...(borderColor && {\n\t\t\tborderColor: resolvePdfColor(borderColor, ctx.theme),\n\t\t}),\n\t};\n}\n\nconst ALIGN = {\n\tstart: 'flex-start',\n\tcenter: 'center',\n\tend: 'flex-end',\n\tstretch: 'stretch',\n} as const;\nconst JUSTIFY = {\n\tstart: 'flex-start',\n\tcenter: 'center',\n\tend: 'flex-end',\n\tbetween: 'space-between',\n} as const;\n\nexport const renderStack = (node: NodeOf<'stack'>, ctx: PdfRenderContext) =>\n\th(\n\t\tView,\n\t\t{\n\t\t\tstyle: {\n\t\t\t\tflexDirection: 'column',\n\t\t\t\tgap: node.gap ?? 0,\n\t\t\t\t...toStyle(node.style, ctx),\n\t\t\t},\n\t\t},\n\t\t...ctx.renderNodes(node.children),\n\t);\n\nexport const renderRow = (node: NodeOf<'row'>, ctx: PdfRenderContext) =>\n\th(\n\t\tView,\n\t\t{\n\t\t\tstyle: {\n\t\t\t\tflexDirection: 'row',\n\t\t\t\tgap: node.gap ?? 12,\n\t\t\t\t...(node.align && { alignItems: ALIGN[node.align] }),\n\t\t\t\t...(node.justify && { justifyContent: JUSTIFY[node.justify] }),\n\t\t\t\t...toStyle(node.style, ctx),\n\t\t\t},\n\t\t},\n\t\t...ctx.renderNodes(node.children),\n\t);\n\nfunction renderInline(inline: PdfInline, ctx: PdfRenderContext) {\n\tif (typeof inline === 'string') return toPdfText(inline);\n\tconst style: PdfElementStyle = {\n\t\t...(inline.bold && { fontWeight: 700 }),\n\t\t...(inline.italic && { fontStyle: 'italic' as const }),\n\t\t...(inline.color && { color: resolvePdfColor(inline.color, ctx.theme) }),\n\t\t...(inline.href && ctx.styles.link),\n\t};\n\treturn inline.href\n\t\t? h(Link, { src: inline.href, style }, toPdfText(inline.text))\n\t\t: h(Text, { style }, toPdfText(inline.text));\n}\n\nconst TEXT_VARIANTS = {\n\tbody: 'textBody',\n\tmuted: 'textMuted',\n\tcaption: 'textCaption',\n\tlabel: 'textLabel',\n} as const;\n\nexport const renderText = (node: NodeOf<'text'>, ctx: PdfRenderContext) =>\n\th(\n\t\tText,\n\t\t{\n\t\t\tstyle: {\n\t\t\t\t...ctx.styles[TEXT_VARIANTS[node.variant ?? 'body']],\n\t\t\t\t...toStyle(node.style, ctx),\n\t\t\t},\n\t\t},\n\t\t...(typeof node.content === 'string'\n\t\t\t? [toPdfText(node.content)]\n\t\t\t: node.content.map((inline) => renderInline(inline, ctx))),\n\t);\n\nexport const renderHeading = (node: NodeOf<'heading'>, ctx: PdfRenderContext) =>\n\th(\n\t\tText,\n\t\t{\n\t\t\tstyle: ctx.styles[`heading${node.level ?? 1}`],\n\t\t\tminPresenceAhead: 24,\n\t\t},\n\t\ttoPdfText(node.text),\n\t);\n\nexport const renderSection = (node: NodeOf<'section'>, ctx: PdfRenderContext) =>\n\th(\n\t\tView,\n\t\t{ style: ctx.styles.section },\n\t\th(\n\t\t\tText,\n\t\t\t{ style: ctx.styles.sectionTitle, minPresenceAhead: 24 },\n\t\t\ttoPdfText(node.title),\n\t\t),\n\t\t...ctx.renderNodes(node.children),\n\t);\n\nexport const renderImage = (node: NodeOf<'image'>) =>\n\th(Image, {\n\t\tsrc: node.src,\n\t\tstyle: {\n\t\t\t...(node.width !== undefined && { width: node.width }),\n\t\t\t...(node.height !== undefined && { height: node.height }),\n\t\t\tobjectFit: node.fit ?? 'contain',\n\t\t},\n\t});\n\nexport const renderLink = (node: NodeOf<'link'>, ctx: PdfRenderContext) =>\n\th(\n\t\tText,\n\t\tnull,\n\t\th(Link, { src: node.href, style: ctx.styles.link }, toPdfText(node.text)),\n\t);\n\nexport const renderSpacer = (node: NodeOf<'spacer'>) =>\n\th(View, { style: { height: node.size } });\n\nexport const renderDivider = (\n\t_node: NodeOf<'divider'>,\n\tctx: PdfRenderContext,\n) => h(View, { style: ctx.styles.divider });\n\nexport const renderPageBreak = () => h(View, { break: true });\n",
|
|
13
|
+
"import { Text, View } from '@react-pdf/renderer';\nimport { createElement as h } from 'react';\nimport type { PrintValue } from '../../../lib/print-value.utils';\nimport type { PdfNode, PdfTableColumn } from '../../model/types';\nimport { type PdfRenderContext, toPdfText } from '../context';\nimport type { PdfElementStyle } from '../styles';\n\ntype TableNode = Extract<PdfNode, { type: 'table' }>;\n\n/** A column's share of the row: a fixed width, or a flex share. */\nfunction columnBox(column: PdfTableColumn) {\n\tif (column.width !== undefined) {\n\t\treturn { width: column.width, flexGrow: 0, flexShrink: 0 };\n\t}\n\treturn { flex: column.flex ?? 1 };\n}\n\nfunction cells(\n\tcolumns: PdfTableColumn[],\n\tvalues: PrintValue[],\n\tcellStyle: PdfElementStyle,\n\tctx: PdfRenderContext,\n) {\n\treturn columns.map((column, index) =>\n\t\th(\n\t\t\tText,\n\t\t\t{\n\t\t\t\tstyle: [\n\t\t\t\t\tcellStyle,\n\t\t\t\t\tcolumnBox(column),\n\t\t\t\t\t{ textAlign: column.align ?? 'left' },\n\t\t\t\t],\n\t\t\t},\n\t\t\tctx.format(values[index]),\n\t\t),\n\t);\n}\n\n/**\n * Footer rows (totals), kept together. With `labelTotals`, an empty first\n * cell reads \"Total\", translated.\n */\nfunction renderFooter(node: TableNode, ctx: PdfRenderContext) {\n\tconst { footer = [], columns, labelTotals } = node;\n\tif (footer.length === 0) return [];\n\tconst total = ctx.t('material.print.table.total', 'Total');\n\treturn [\n\t\th(\n\t\t\tView,\n\t\t\t{ wrap: false },\n\t\t\t...footer.map(([first, ...rest]) =>\n\t\t\t\th(\n\t\t\t\t\tView,\n\t\t\t\t\t{ style: ctx.styles.tableFooter },\n\t\t\t\t\t...cells(\n\t\t\t\t\t\tcolumns,\n\t\t\t\t\t\t[labelTotals && first == null ? total : first, ...rest],\n\t\t\t\t\t\tctx.styles.tableFooterCell,\n\t\t\t\t\t\tctx,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t),\n\t];\n}\n\n/**\n * A table: a header row that repeats at the top of each page the table\n * crosses, body rows that never split (and stripe), then footer rows (totals)\n * kept together. With no rows, the header and one muted row, or nothing with\n * `hideWhenEmpty`.\n */\nexport function renderTable(node: TableNode, ctx: PdfRenderContext) {\n\tconst { styles } = ctx;\n\tconst {\n\t\tcolumns,\n\t\trows,\n\t\tstriped = true,\n\t\trepeatHeader = true,\n\t\tkeepRowsWhole = true,\n\t} = node;\n\tif (rows.length === 0 && node.hideWhenEmpty) return null;\n\n\tconst headerRow = h(\n\t\tView,\n\t\t{ style: styles.tableHeader, fixed: repeatHeader, minPresenceAhead: 24 },\n\t\t...columns.map((column) =>\n\t\t\th(\n\t\t\t\tText,\n\t\t\t\t{\n\t\t\t\t\tstyle: [\n\t\t\t\t\t\tstyles.tableHeaderCell,\n\t\t\t\t\t\tcolumnBox(column),\n\t\t\t\t\t\t{ textAlign: column.align ?? 'left' },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\ttoPdfText(column.label),\n\t\t\t),\n\t\t),\n\t);\n\n\tconst bodyRows =\n\t\trows.length === 0\n\t\t\t? [\n\t\t\t\t\th(\n\t\t\t\t\t\tView,\n\t\t\t\t\t\t{ style: styles.tableRow, wrap: false },\n\t\t\t\t\t\th(\n\t\t\t\t\t\t\tText,\n\t\t\t\t\t\t\t{ style: [styles.tableEmpty, { flex: 1 }] },\n\t\t\t\t\t\t\tnode.emptyText !== undefined\n\t\t\t\t\t\t\t\t? toPdfText(node.emptyText)\n\t\t\t\t\t\t\t\t: ctx.t('material.print.table.empty', 'No rows'),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t: rows.map((values, index) =>\n\t\t\t\t\th(\n\t\t\t\t\t\tView,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstyle: [\n\t\t\t\t\t\t\t\tstyles.tableRow,\n\t\t\t\t\t\t\t\tstriped && index % 2 === 1 ? styles.tableRowAlt : {},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\twrap: !keepRowsWhole,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...cells(columns, values, styles.tableCell, ctx),\n\t\t\t\t\t),\n\t\t\t\t);\n\n\tconst footerRows = renderFooter(node, ctx);\n\n\treturn h(\n\t\tView,\n\t\t{ style: styles.tableSection },\n\t\theaderRow,\n\t\t...bodyRows,\n\t\t...footerRows,\n\t);\n}\n"
|
|
14
|
+
],
|
|
15
|
+
"mappings": ";;;;;;;;;;AAAA;;;ACYO,SAAS,gBAAe,GAAG,QAAQ,GAAG,SAAmB;AAAA,EAC/D,MAAM,MAAM,CAAC,GAAW,OAAe;AAAA,IACtC,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,aAAa;AAAA,IACb,cAAc;AAAA,EACf;AAAA,EACA,OAAO;AAAA,IACN,MAAM;AAAA,MACL,YAAY,MAAM;AAAA,MAClB,UAAU;AAAA,MACV,OAAO,EAAE;AAAA,SACN,IAAI,IAAI,EAAE;AAAA,MACb,eAAe;AAAA,MACf,KAAK;AAAA,IACN;AAAA,IACA,QAAQ,EAAE,eAAe,OAAO,YAAY,UAAU,cAAc,GAAG;AAAA,IACvE,aAAa;AAAA,MACZ,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,OAAO,EAAE;AAAA,MACT,eAAe;AAAA,IAChB;AAAA,IACA,WAAW,EAAE,UAAU,QAAQ,OAAO,EAAE,WAAW,WAAW,IAAI;AAAA,IAClE,SAAS;AAAA,MACR,mBAAmB;AAAA,MACnB,aAAa,EAAE;AAAA,MACf,cAAc;AAAA,IACf;AAAA,IACA,cAAc;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,KAAK,QAAQ,SAClB,QAAQ,YAAY,KAAK,MAAM,IAC/B;AAAA,IACH,QAAQ,KAAK,QAAQ,SAClB,QAAQ,YAAY,KAAK,MAAM,IAC/B;AAAA,IACH,MAAM,QAAQ,YAAY,KAAK,IAAI;AAAA,EACpC,GACA,OACD,CACD;AAAA,EACA,OAAO,wBACN;AAAA,OACI,IAAI;AAAA,IACP,SAAS,IAAI,MAAM,WAAW,QAAQ;AAAA,IACtC,UAAU,IAAI;AAAA,EACf,GACA,KACD;AAAA;",
|
|
16
|
+
"debugId": "EA542ADA03C5516564756E2164756E21",
|
|
17
|
+
"names": []
|
|
18
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@nxgt/material-core` — what `@nxgt/material` (React) and
|
|
3
|
+
* `@nxgt/material-vue` (Vue) share, framework-free.
|
|
4
|
+
*
|
|
5
|
+
* This entry holds what imports nothing from React: the PDF document model,
|
|
6
|
+
* the print formatters and the PDF file helpers. The renderer is on
|
|
7
|
+
* `@nxgt/material-core/pdf/render` (it imports `react` and
|
|
8
|
+
* `@react-pdf/renderer`, optional peers), and the pdfkit fonts plugin on
|
|
9
|
+
* `@nxgt/material-core/vite`.
|
|
10
|
+
*/
|
|
11
|
+
export * from './lib/pdf-download';
|
|
12
|
+
export * from './lib/pdf-file-name';
|
|
13
|
+
export * from './lib/pdf-source';
|
|
14
|
+
export * from './lib/print-format.utils';
|
|
15
|
+
export * from './lib/print-fraction-digits';
|
|
16
|
+
export * from './lib/print-table.utils';
|
|
17
|
+
export * from './lib/print-value.utils';
|
|
18
|
+
export * from './pdf/file-loader';
|
|
19
|
+
export * from './pdf/http';
|
|
20
|
+
export * from './pdf/model';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isBlob2,
|
|
3
|
+
isPdfUrlSource2,
|
|
4
|
+
pdfSourceUrl2,
|
|
5
|
+
pdfSourceKey2,
|
|
6
|
+
copyPdfData2,
|
|
7
|
+
toPdfjsSource2,
|
|
8
|
+
toPdfjsParams2
|
|
9
|
+
} from "./chunks/index-5r6rzp43.js";
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_PDF_FILE_NAME2,
|
|
12
|
+
resolvePdfFileName2
|
|
13
|
+
} from "./chunks/index-paaaedrm.js";
|
|
14
|
+
import {
|
|
15
|
+
OBJECT_URL_TTL_MS2,
|
|
16
|
+
downloadPdfFile2,
|
|
17
|
+
printPdfFile2
|
|
18
|
+
} from "./chunks/index-h3vjydz7.js";
|
|
19
|
+
import {
|
|
20
|
+
MAX_FRACTION_DIGITS2,
|
|
21
|
+
fractionDigitsOption2
|
|
22
|
+
} from "./chunks/index-6tn0wjsb.js";
|
|
23
|
+
import {
|
|
24
|
+
formatAmount2,
|
|
25
|
+
formatDate2,
|
|
26
|
+
createFormatters2
|
|
27
|
+
} from "./chunks/index-w3ajz57t.js";
|
|
28
|
+
import {
|
|
29
|
+
definePrintColumns2,
|
|
30
|
+
toPrintValue2,
|
|
31
|
+
resolvePrintTable2,
|
|
32
|
+
resolvePrintFields2
|
|
33
|
+
} from "./chunks/index-0xc5q9tp.js";
|
|
34
|
+
import {
|
|
35
|
+
isEmptyPrintValue2,
|
|
36
|
+
formatPrintValue2
|
|
37
|
+
} from "./chunks/index-eh0e5ex7.js";
|
|
38
|
+
import {
|
|
39
|
+
IDLE_PDF_FILE2,
|
|
40
|
+
createPdfFileLoader2
|
|
41
|
+
} from "./chunks/index-g7rh8fpv.js";
|
|
42
|
+
import {
|
|
43
|
+
contentDisposition2,
|
|
44
|
+
pdfBytesResponse2,
|
|
45
|
+
toWebStream2
|
|
46
|
+
} from "./chunks/index-2gcgcmc0.js";
|
|
47
|
+
import {
|
|
48
|
+
text2,
|
|
49
|
+
heading2,
|
|
50
|
+
stack2,
|
|
51
|
+
row2,
|
|
52
|
+
section2,
|
|
53
|
+
image2,
|
|
54
|
+
link2,
|
|
55
|
+
spacer2,
|
|
56
|
+
divider2,
|
|
57
|
+
pageBreak2,
|
|
58
|
+
table2,
|
|
59
|
+
keyValue2,
|
|
60
|
+
totals2,
|
|
61
|
+
metric2,
|
|
62
|
+
badge2,
|
|
63
|
+
header2,
|
|
64
|
+
pageNumber2,
|
|
65
|
+
page2,
|
|
66
|
+
pdfDocument2,
|
|
67
|
+
definePdfDocument2,
|
|
68
|
+
dataTable2,
|
|
69
|
+
keyValueOf2
|
|
70
|
+
} from "./chunks/index-8gf9e2d4.js";
|
|
71
|
+
import {
|
|
72
|
+
defaultPdfTheme2,
|
|
73
|
+
resolvePdfTheme2,
|
|
74
|
+
resolvePdfColor2
|
|
75
|
+
} from "./chunks/index-3ca6xe71.js";
|
|
76
|
+
export {
|
|
77
|
+
DEFAULT_PDF_FILE_NAME2 as DEFAULT_PDF_FILE_NAME,
|
|
78
|
+
IDLE_PDF_FILE2 as IDLE_PDF_FILE,
|
|
79
|
+
MAX_FRACTION_DIGITS2 as MAX_FRACTION_DIGITS,
|
|
80
|
+
OBJECT_URL_TTL_MS2 as OBJECT_URL_TTL_MS,
|
|
81
|
+
badge2 as badge,
|
|
82
|
+
contentDisposition2 as contentDisposition,
|
|
83
|
+
copyPdfData2 as copyPdfData,
|
|
84
|
+
createFormatters2 as createFormatters,
|
|
85
|
+
createPdfFileLoader2 as createPdfFileLoader,
|
|
86
|
+
dataTable2 as dataTable,
|
|
87
|
+
defaultPdfTheme2 as defaultPdfTheme,
|
|
88
|
+
definePdfDocument2 as definePdfDocument,
|
|
89
|
+
definePrintColumns2 as definePrintColumns,
|
|
90
|
+
divider2 as divider,
|
|
91
|
+
downloadPdfFile2 as downloadPdfFile,
|
|
92
|
+
formatAmount2 as formatAmount,
|
|
93
|
+
formatDate2 as formatDate,
|
|
94
|
+
formatPrintValue2 as formatPrintValue,
|
|
95
|
+
fractionDigitsOption2 as fractionDigitsOption,
|
|
96
|
+
header2 as header,
|
|
97
|
+
heading2 as heading,
|
|
98
|
+
image2 as image,
|
|
99
|
+
isBlob2 as isBlob,
|
|
100
|
+
isEmptyPrintValue2 as isEmptyPrintValue,
|
|
101
|
+
isPdfUrlSource2 as isPdfUrlSource,
|
|
102
|
+
keyValue2 as keyValue,
|
|
103
|
+
keyValueOf2 as keyValueOf,
|
|
104
|
+
link2 as link,
|
|
105
|
+
metric2 as metric,
|
|
106
|
+
page2 as page,
|
|
107
|
+
pageBreak2 as pageBreak,
|
|
108
|
+
pageNumber2 as pageNumber,
|
|
109
|
+
pdfBytesResponse2 as pdfBytesResponse,
|
|
110
|
+
pdfDocument2 as pdfDocument,
|
|
111
|
+
pdfSourceKey2 as pdfSourceKey,
|
|
112
|
+
pdfSourceUrl2 as pdfSourceUrl,
|
|
113
|
+
printPdfFile2 as printPdfFile,
|
|
114
|
+
resolvePdfColor2 as resolvePdfColor,
|
|
115
|
+
resolvePdfFileName2 as resolvePdfFileName,
|
|
116
|
+
resolvePdfTheme2 as resolvePdfTheme,
|
|
117
|
+
resolvePrintFields2 as resolvePrintFields,
|
|
118
|
+
resolvePrintTable2 as resolvePrintTable,
|
|
119
|
+
row2 as row,
|
|
120
|
+
section2 as section,
|
|
121
|
+
spacer2 as spacer,
|
|
122
|
+
stack2 as stack,
|
|
123
|
+
table2 as table,
|
|
124
|
+
text2 as text,
|
|
125
|
+
toPdfjsParams2 as toPdfjsParams,
|
|
126
|
+
toPdfjsSource2 as toPdfjsSource,
|
|
127
|
+
toPrintValue2 as toPrintValue,
|
|
128
|
+
toWebStream2 as toWebStream,
|
|
129
|
+
totals2 as totals
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
//# debugId=1DC0C9D608FB064D64756E2164756E21
|
|
133
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The decimals `CurrencyField` shows: `fractionDigits` when given (0 to 20;
|
|
3
|
+
* `NaN` or `Infinity` counts as not given), else the currency's own (ISO
|
|
4
|
+
* 4217: JPY 0, EUR 2, KWD 3), else 2 for a code `Intl` does not know. The
|
|
5
|
+
* same rule as `formatAmount` (`fractionDigitsOption`).
|
|
6
|
+
*/
|
|
7
|
+
export declare function currencyFractionDigits(currency: string, fractionDigits?: number): number;
|
|
8
|
+
//# sourceMappingURL=currency-digits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currency-digits.d.ts","sourceRoot":"","sources":["../../src/lib/currency-digits.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,MAAM,GACrB,MAAM,CAaR"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fractionDigitsOption2
|
|
3
|
+
} from "../chunks/index-6tn0wjsb.js";
|
|
4
|
+
|
|
5
|
+
// src/lib/currency-digits.ts
|
|
6
|
+
function currencyFractionDigits(currency, fractionDigits) {
|
|
7
|
+
const given = fractionDigitsOption2(fractionDigits);
|
|
8
|
+
if (given !== undefined)
|
|
9
|
+
return given;
|
|
10
|
+
try {
|
|
11
|
+
return new Intl.NumberFormat("en", {
|
|
12
|
+
style: "currency",
|
|
13
|
+
currency
|
|
14
|
+
}).resolvedOptions().maximumFractionDigits ?? 2;
|
|
15
|
+
} catch {
|
|
16
|
+
return 2;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
currencyFractionDigits
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//# debugId=5D8FC020291EA13D64756E2164756E21
|
|
24
|
+
//# sourceMappingURL=currency-digits.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lib/currency-digits.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { fractionDigitsOption } from './print-fraction-digits';\n\n/**\n * The decimals `CurrencyField` shows: `fractionDigits` when given (0 to 20;\n * `NaN` or `Infinity` counts as not given), else the currency's own (ISO\n * 4217: JPY 0, EUR 2, KWD 3), else 2 for a code `Intl` does not know. The\n * same rule as `formatAmount` (`fractionDigitsOption`).\n */\nexport function currencyFractionDigits(\n\tcurrency: string,\n\tfractionDigits?: number,\n): number {\n\tconst given = fractionDigitsOption(fractionDigits);\n\tif (given !== undefined) return given;\n\ttry {\n\t\treturn (\n\t\t\tnew Intl.NumberFormat('en', {\n\t\t\t\tstyle: 'currency',\n\t\t\t\tcurrency,\n\t\t\t}).resolvedOptions().maximumFractionDigits ?? 2\n\t\t);\n\t} catch {\n\t\treturn 2;\n\t}\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;AAQO,SAAS,sBAAsB,CACrC,UACA,gBACS;AAAA,EACT,MAAM,QAAQ,sBAAqB,cAAc;AAAA,EACjD,IAAI,UAAU;AAAA,IAAW,OAAO;AAAA,EAChC,IAAI;AAAA,IACH,OACC,IAAI,KAAK,aAAa,MAAM;AAAA,MAC3B,OAAO;AAAA,MACP;AAAA,IACD,CAAC,EAAE,gBAAgB,EAAE,yBAAyB;AAAA,IAE9C,MAAM;AAAA,IACP,OAAO;AAAA;AAAA;",
|
|
8
|
+
"debugId": "5D8FC020291EA13D64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The top-level layer a node is in: its ancestor that is a child of `<body>`.
|
|
3
|
+
* An overlay rendered into `<body>` (a popover, a listbox, a dialog) is a
|
|
4
|
+
* layer of its own; the page is another. `null` for a node no longer in the
|
|
5
|
+
* document.
|
|
6
|
+
*/
|
|
7
|
+
export declare function layerOf(node: Node): Node | null;
|
|
8
|
+
/** What a field knows about the layers of the page since focus entered it. */
|
|
9
|
+
export type FieldLayers = {
|
|
10
|
+
/** The layers of the page when focus entered the field. */
|
|
11
|
+
before: Set<Node>;
|
|
12
|
+
/** The layers the field itself is in (the page, or the sheet it is in). */
|
|
13
|
+
home: Set<Node | null>;
|
|
14
|
+
/** The layers focus reached since entering that are the field's overlays. */
|
|
15
|
+
opened: Set<Node>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Who opened `layer`, going by the controls that name an element of it as
|
|
19
|
+
* the popup they control (`aria-controls`, `aria-owns`), as a select, a
|
|
20
|
+
* popover or a dialog trigger does:
|
|
21
|
+
* - `'ours'`: a control of the field (inside `roots`), or a control inside
|
|
22
|
+
* an overlay of the field — one focus already reached, or one mounted since
|
|
23
|
+
* focus entered that nothing else opened (the field's dialog, which leaves
|
|
24
|
+
* focus on the button that opened it, and the select inside it). Such a
|
|
25
|
+
* layer is the field's even when it was mounted before focus entered the
|
|
26
|
+
* field: a mouse-opened select mounts its list before its trigger has focus.
|
|
27
|
+
* - `'theirs'`: only a control of something else — another field whose
|
|
28
|
+
* overlay opened while focus was still here (a mouse-opened select, a
|
|
29
|
+
* Safari button that takes no focus on click).
|
|
30
|
+
* - `null`: nothing names it.
|
|
31
|
+
* A control inside `layer` itself (a tab naming its panel) says nothing about
|
|
32
|
+
* who opened it.
|
|
33
|
+
*/
|
|
34
|
+
export declare function openerOf(roots: Element[], layers: FieldLayers, layer: Node, seen?: Set<Node>): 'ours' | 'theirs' | null;
|
|
35
|
+
//# sourceMappingURL=field-blur-layers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-blur-layers.d.ts","sourceRoot":"","sources":["../../src/lib/field-blur-layers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAO/C;AAED,8EAA8E;AAC9E,MAAM,MAAM,WAAW,GAAG;IACzB,2DAA2D;IAC3D,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IAClB,2EAA2E;IAC3E,IAAI,EAAE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IACvB,6EAA6E;IAC7E,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CACvB,KAAK,EAAE,OAAO,EAAE,EAChB,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,IAAI,EACX,IAAI,GAAE,GAAG,CAAC,IAAI,CAAa,GACzB,MAAM,GAAG,QAAQ,GAAG,IAAI,CAW1B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/lib/field-blur-layers.ts
|
|
2
|
+
function layerOf(node) {
|
|
3
|
+
const body = node.ownerDocument?.body;
|
|
4
|
+
let current = node;
|
|
5
|
+
while (current?.parentNode && current.parentNode !== body) {
|
|
6
|
+
current = current.parentNode;
|
|
7
|
+
}
|
|
8
|
+
return current?.parentNode === body ? current : null;
|
|
9
|
+
}
|
|
10
|
+
function openerOf(roots, layers, layer, seen = new Set) {
|
|
11
|
+
const doc = layer.ownerDocument;
|
|
12
|
+
if (!doc)
|
|
13
|
+
return null;
|
|
14
|
+
seen.add(layer);
|
|
15
|
+
let claim = null;
|
|
16
|
+
for (const owner of doc.querySelectorAll("[aria-controls], [aria-owns]")) {
|
|
17
|
+
if (layer.contains(owner) || !namesInto(owner, layer))
|
|
18
|
+
continue;
|
|
19
|
+
if (isOurs(roots, layers, owner, seen))
|
|
20
|
+
return "ours";
|
|
21
|
+
claim = "theirs";
|
|
22
|
+
}
|
|
23
|
+
return claim;
|
|
24
|
+
}
|
|
25
|
+
function isOurs(roots, layers, owner, seen) {
|
|
26
|
+
if (roots.some((root) => root.contains(owner)))
|
|
27
|
+
return true;
|
|
28
|
+
const layer = layerOf(owner);
|
|
29
|
+
if (layer === null)
|
|
30
|
+
return false;
|
|
31
|
+
if (layers.opened.has(layer))
|
|
32
|
+
return true;
|
|
33
|
+
if (layers.before.has(layer) || layers.home.has(layer) || seen.has(layer)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return openerOf(roots, layers, layer, seen) !== "theirs";
|
|
37
|
+
}
|
|
38
|
+
function namesInto(owner, layer) {
|
|
39
|
+
const doc = layer.ownerDocument;
|
|
40
|
+
const ids = `${owner.getAttribute("aria-controls") ?? ""} ${owner.getAttribute("aria-owns") ?? ""}`;
|
|
41
|
+
return ids.split(/\s+/).some((id) => {
|
|
42
|
+
const popup = id && doc?.getElementById(id);
|
|
43
|
+
return Boolean(popup && layer.contains(popup));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
layerOf,
|
|
48
|
+
openerOf
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//# debugId=8FAE3C51CB9B30DC64756E2164756E21
|
|
52
|
+
//# sourceMappingURL=field-blur-layers.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lib/field-blur-layers.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * The top-level layer a node is in: its ancestor that is a child of `<body>`.\n * An overlay rendered into `<body>` (a popover, a listbox, a dialog) is a\n * layer of its own; the page is another. `null` for a node no longer in the\n * document.\n */\nexport function layerOf(node: Node): Node | null {\n\tconst body = node.ownerDocument?.body;\n\tlet current: Node | null = node;\n\twhile (current?.parentNode && current.parentNode !== body) {\n\t\tcurrent = current.parentNode;\n\t}\n\treturn current?.parentNode === body ? current : null;\n}\n\n/** What a field knows about the layers of the page since focus entered it. */\nexport type FieldLayers = {\n\t/** The layers of the page when focus entered the field. */\n\tbefore: Set<Node>;\n\t/** The layers the field itself is in (the page, or the sheet it is in). */\n\thome: Set<Node | null>;\n\t/** The layers focus reached since entering that are the field's overlays. */\n\topened: Set<Node>;\n};\n\n/**\n * Who opened `layer`, going by the controls that name an element of it as\n * the popup they control (`aria-controls`, `aria-owns`), as a select, a\n * popover or a dialog trigger does:\n * - `'ours'`: a control of the field (inside `roots`), or a control inside\n * an overlay of the field — one focus already reached, or one mounted since\n * focus entered that nothing else opened (the field's dialog, which leaves\n * focus on the button that opened it, and the select inside it). Such a\n * layer is the field's even when it was mounted before focus entered the\n * field: a mouse-opened select mounts its list before its trigger has focus.\n * - `'theirs'`: only a control of something else — another field whose\n * overlay opened while focus was still here (a mouse-opened select, a\n * Safari button that takes no focus on click).\n * - `null`: nothing names it.\n * A control inside `layer` itself (a tab naming its panel) says nothing about\n * who opened it.\n */\nexport function openerOf(\n\troots: Element[],\n\tlayers: FieldLayers,\n\tlayer: Node,\n\tseen: Set<Node> = new Set(),\n): 'ours' | 'theirs' | null {\n\tconst doc = layer.ownerDocument;\n\tif (!doc) return null;\n\tseen.add(layer);\n\tlet claim: 'theirs' | null = null;\n\tfor (const owner of doc.querySelectorAll('[aria-controls], [aria-owns]')) {\n\t\tif (layer.contains(owner) || !namesInto(owner, layer)) continue;\n\t\tif (isOurs(roots, layers, owner, seen)) return 'ours';\n\t\tclaim = 'theirs';\n\t}\n\treturn claim;\n}\n\nfunction isOurs(\n\troots: Element[],\n\tlayers: FieldLayers,\n\towner: Element,\n\tseen: Set<Node>,\n): boolean {\n\tif (roots.some((root) => root.contains(owner))) return true;\n\tconst layer = layerOf(owner);\n\tif (layer === null) return false;\n\tif (layers.opened.has(layer)) return true;\n\tif (layers.before.has(layer) || layers.home.has(layer) || seen.has(layer)) {\n\t\treturn false;\n\t}\n\treturn openerOf(roots, layers, layer, seen) !== 'theirs';\n}\n\nfunction namesInto(owner: Element, layer: Node): boolean {\n\tconst doc = layer.ownerDocument;\n\tconst ids = `${owner.getAttribute('aria-controls') ?? ''} ${\n\t\towner.getAttribute('aria-owns') ?? ''\n\t}`;\n\treturn ids.split(/\\s+/).some((id) => {\n\t\tconst popup = id && doc?.getElementById(id);\n\t\treturn Boolean(popup && layer.contains(popup));\n\t});\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AAMO,SAAS,OAAO,CAAC,MAAyB;AAAA,EAChD,MAAM,OAAO,KAAK,eAAe;AAAA,EACjC,IAAI,UAAuB;AAAA,EAC3B,OAAO,SAAS,cAAc,QAAQ,eAAe,MAAM;AAAA,IAC1D,UAAU,QAAQ;AAAA,EACnB;AAAA,EACA,OAAO,SAAS,eAAe,OAAO,UAAU;AAAA;AA8B1C,SAAS,QAAQ,CACvB,OACA,QACA,OACA,OAAkB,IAAI,KACK;AAAA,EAC3B,MAAM,MAAM,MAAM;AAAA,EAClB,IAAI,CAAC;AAAA,IAAK,OAAO;AAAA,EACjB,KAAK,IAAI,KAAK;AAAA,EACd,IAAI,QAAyB;AAAA,EAC7B,WAAW,SAAS,IAAI,iBAAiB,8BAA8B,GAAG;AAAA,IACzE,IAAI,MAAM,SAAS,KAAK,KAAK,CAAC,UAAU,OAAO,KAAK;AAAA,MAAG;AAAA,IACvD,IAAI,OAAO,OAAO,QAAQ,OAAO,IAAI;AAAA,MAAG,OAAO;AAAA,IAC/C,QAAQ;AAAA,EACT;AAAA,EACA,OAAO;AAAA;AAGR,SAAS,MAAM,CACd,OACA,QACA,OACA,MACU;AAAA,EACV,IAAI,MAAM,KAAK,CAAC,SAAS,KAAK,SAAS,KAAK,CAAC;AAAA,IAAG,OAAO;AAAA,EACvD,MAAM,QAAQ,QAAQ,KAAK;AAAA,EAC3B,IAAI,UAAU;AAAA,IAAM,OAAO;AAAA,EAC3B,IAAI,OAAO,OAAO,IAAI,KAAK;AAAA,IAAG,OAAO;AAAA,EACrC,IAAI,OAAO,OAAO,IAAI,KAAK,KAAK,OAAO,KAAK,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,GAAG;AAAA,IAC1E,OAAO;AAAA,EACR;AAAA,EACA,OAAO,SAAS,OAAO,QAAQ,OAAO,IAAI,MAAM;AAAA;AAGjD,SAAS,SAAS,CAAC,OAAgB,OAAsB;AAAA,EACxD,MAAM,MAAM,MAAM;AAAA,EAClB,MAAM,MAAM,GAAG,MAAM,aAAa,eAAe,KAAK,MACrD,MAAM,aAAa,WAAW,KAAK;AAAA,EAEpC,OAAO,IAAI,MAAM,KAAK,EAAE,KAAK,CAAC,OAAO;AAAA,IACpC,MAAM,QAAQ,MAAM,KAAK,eAAe,EAAE;AAAA,IAC1C,OAAO,QAAQ,SAAS,MAAM,SAAS,KAAK,CAAC;AAAA,GAC7C;AAAA;",
|
|
8
|
+
"debugId": "8FAE3C51CB9B30DC64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type PdfSource } from './pdf-source';
|
|
2
|
+
/**
|
|
3
|
+
* How long an object URL outlives the click that started its download or
|
|
4
|
+
* opened its tab. Revoking it synchronously cancels the download in Firefox
|
|
5
|
+
* and Safari, which read the URL after `click()` returns.
|
|
6
|
+
*/
|
|
7
|
+
export declare const OBJECT_URL_TTL_MS = 60000;
|
|
8
|
+
export type PdfFileOptions = {
|
|
9
|
+
/** Name of the saved file; `.pdf` is added when missing. */
|
|
10
|
+
fileName?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Name used when neither `fileName`, a `File`'s name nor the URL gives
|
|
13
|
+
* one: `document`, or its translation.
|
|
14
|
+
*/
|
|
15
|
+
defaultName?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Bytes of the document the reader already loaded. Saving them needs no
|
|
18
|
+
* second request, and works for a cross-origin URL, where the `download`
|
|
19
|
+
* attribute is ignored.
|
|
20
|
+
*/
|
|
21
|
+
getData?: () => Uint8Array | null | undefined | Promise<Uint8Array | null | undefined>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Downloads the PDF under its resolved name. A URL is saved from the loaded
|
|
25
|
+
* bytes or fetched; when neither works (CORS), it opens in a new tab, which
|
|
26
|
+
* a popup blocker may stop once the click's activation has expired. A URL
|
|
27
|
+
* with headers never opens in a tab: it would load without them.
|
|
28
|
+
*/
|
|
29
|
+
export declare function downloadPdfFile(source: PdfSource, options?: PdfFileOptions): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Prints the PDF from a same-origin object URL in a hidden frame. When the
|
|
32
|
+
* browser refuses (a PDF plugin that blocks `print()`, a cross-origin URL
|
|
33
|
+
* that could not be fetched), the document opens in a new tab instead.
|
|
34
|
+
*/
|
|
35
|
+
export declare function printPdfFile(source: PdfSource, options?: Pick<PdfFileOptions, 'getData'>): Promise<void>;
|
|
36
|
+
//# sourceMappingURL=pdf-download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf-download.d.ts","sourceRoot":"","sources":["../../src/lib/pdf-download.ts"],"names":[],"mappings":"AACA,OAAO,EAIN,KAAK,SAAS,EAEd,MAAM,cAAc,CAAC;AAEtB;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAS,CAAC;AAExC,MAAM,MAAM,cAAc,GAAG;IAC5B,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MACP,UAAU,GACV,IAAI,GACJ,SAAS,GACT,OAAO,CAAC,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;CAC1C,CAAC;AA8EF;;;;;GAKG;AACH,wBAAsB,eAAe,CACpC,MAAM,EAAE,SAAS,EACjB,OAAO,GAAE,cAAmB,iBAW5B;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CACjC,MAAM,EAAE,SAAS,EACjB,OAAO,GAAE,IAAI,CAAC,cAAc,EAAE,SAAS,CAAM,iBA8B7C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OBJECT_URL_TTL_MS2,
|
|
3
|
+
downloadPdfFile2,
|
|
4
|
+
printPdfFile2
|
|
5
|
+
} from "../chunks/index-h3vjydz7.js";
|
|
6
|
+
import"../chunks/index-paaaedrm.js";
|
|
7
|
+
import"../chunks/index-5r6rzp43.js";
|
|
8
|
+
export {
|
|
9
|
+
OBJECT_URL_TTL_MS2 as OBJECT_URL_TTL_MS,
|
|
10
|
+
downloadPdfFile2 as downloadPdfFile,
|
|
11
|
+
printPdfFile2 as printPdfFile
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//# debugId=A31116C0601A104A64756E2164756E21
|
|
15
|
+
//# sourceMappingURL=pdf-download.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PdfSource } from './pdf-source';
|
|
2
|
+
/** The name a download takes when nothing else gives one, before `.pdf`. */
|
|
3
|
+
export declare const DEFAULT_PDF_FILE_NAME = "document";
|
|
4
|
+
/**
|
|
5
|
+
* The saved file's name: `fileName`, then the `File`'s own name, then the
|
|
6
|
+
* last segment of the URL's path, then `fallback` (`document`, or its
|
|
7
|
+
* translation). `.pdf` is added when missing.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolvePdfFileName(source: PdfSource, fileName?: string, fallback?: string): string;
|
|
10
|
+
//# sourceMappingURL=pdf-file-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf-file-name.d.ts","sourceRoot":"","sources":["../../src/lib/pdf-file-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,SAAS,EAAgB,MAAM,cAAc,CAAC;AAEpE,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB,aAAa,CAAC;AA6BhD;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,SAAS,EACjB,QAAQ,CAAC,EAAE,MAAM,EACjB,QAAQ,GAAE,MAA8B,UAIxC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_PDF_FILE_NAME2,
|
|
3
|
+
resolvePdfFileName2
|
|
4
|
+
} from "../chunks/index-paaaedrm.js";
|
|
5
|
+
import"../chunks/index-5r6rzp43.js";
|
|
6
|
+
export {
|
|
7
|
+
DEFAULT_PDF_FILE_NAME2 as DEFAULT_PDF_FILE_NAME,
|
|
8
|
+
resolvePdfFileName2 as resolvePdfFileName
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
//# debugId=AD7DC74D4989C3CC64756E2164756E21
|
|
12
|
+
//# sourceMappingURL=pdf-file-name.js.map
|