@particle-academy/last-word-ui 0.5.0 → 0.6.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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { CSSProperties } from 'react';
2
+ import { ReactNode, CSSProperties } from 'react';
3
3
 
4
4
  /**
5
5
  * The last-word Doc as this viewer reads it.
@@ -224,6 +224,38 @@ interface Doc {
224
224
  [key: string]: unknown;
225
225
  }
226
226
 
227
+ /** What `renderChart` is given for one chart block. */
228
+ interface ChartRenderArgs {
229
+ /** The block as it is in the Doc. */
230
+ block: ChartBlock;
231
+ /**
232
+ * The block's ECharts option laid out for a page: a transparent background,
233
+ * last-word's default palette, no animation and a grid that keeps axis labels
234
+ * inside the box. Every key the block sets wins.
235
+ */
236
+ option: Record<string, unknown>;
237
+ /** CSS px at 100% (before the page's scale), as the page lays the block out. */
238
+ width: number;
239
+ height: number;
240
+ /** The chart's title, or its alt text, or "". */
241
+ title: string;
242
+ }
243
+ /**
244
+ * Draws a chart block instead of the built-in renderer. Return `undefined` to
245
+ * leave that chart to the default (fancy-echarts when installed, else the
246
+ * placeholder). Draw at exactly `width` x `height`: the page was laid out for it.
247
+ */
248
+ type RenderChart = (chart: ChartRenderArgs) => ReactNode | undefined;
249
+ /** last-word's default chart palette (Office's), so an unstyled chart is the colour it is in Word. */
250
+ declare const OFFICE_PALETTE: string[];
251
+ /**
252
+ * A block's option as a page draws it. Defaults only: the block's own keys win.
253
+ * The sheet is white paper in every app colour scheme, so the background is
254
+ * transparent (the paper shows through), and animation is off so a printed or
255
+ * captured page is never caught mid-transition.
256
+ */
257
+ declare function pageChartOption(option: unknown): Record<string, unknown>;
258
+
227
259
  interface DocViewerLayout {
228
260
  /** Number of pages the document laid out to. */
229
261
  pages: number;
@@ -289,6 +321,14 @@ interface DocViewerProps {
289
321
  * `@particle-academy/last-word-ui/styles.css` instead.
290
322
  */
291
323
  injectStyles?: boolean;
324
+ /**
325
+ * Draws a chart block instead of the default, given the block, its option laid
326
+ * out for a page, and its size in CSS px. Return `undefined` to leave a chart
327
+ * to the default. The default draws with `@particle-academy/fancy-echarts`'
328
+ * `EChart` when it is installed (an optional peer) and a sized placeholder
329
+ * when it is not.
330
+ */
331
+ renderChart?: RenderChart;
292
332
  id?: string;
293
333
  className?: string;
294
334
  style?: CSSProperties;
@@ -311,7 +351,7 @@ interface DocViewerProps {
311
351
  * `{time}`, `{date:FORMAT}`, `{time:FORMAT}` -- drawn as plain text. In the
312
352
  * body they stay literal.
313
353
  */
314
- declare function DocViewer({ doc, fit, scale: fixedScale, maxScale, gap, filename, now, onLayout, injectStyles, id, className, style, }: DocViewerProps): react.JSX.Element;
354
+ declare function DocViewer({ doc, fit, scale: fixedScale, maxScale, gap, filename, now, onLayout, injectStyles, renderChart, id, className, style, }: DocViewerProps): react.JSX.Element;
315
355
 
316
356
  /** The package-unique family the bundled Carlito is declared under (`fonts.ts`). */
317
357
  declare const CARLITO_FAMILY = "LW Carlito";
@@ -704,4 +744,4 @@ interface FootnoteNumbering {
704
744
  */
705
745
  declare function numberFootnotes(doc: Doc): FootnoteNumbering;
706
746
 
707
- export { type Align, type Band, type BandHeights, type BandKind, type BandSlot, type Block, type BlockFragment, type BlockItem, type BlocksBand, type BodyBox, type Border, type BorderStyle, type BoxBorders, type BoxSides, type BreakItem, CARLITO_FACES, CARLITO_FAMILY, type ChartBlock, type CodeBlock, type Doc, type DocMeta, DocViewer, type DocViewerLayout, type DocViewerProps, FONT_LOAD_TIMEOUT_MS, type Footnote, type FootnoteMark, type FootnoteNumbering, type Fragment, type HeadingBlock, type HrBlock, type ImageBlock, LAYOUT_NOTICE, type ListBlock, type ListItem, type Orientation, PAGE_BAND_DISTANCE_DEFAULT, PAGE_MARGIN_DEFAULT, PAGE_SIZES_PT, PX_PER_PT, type PackInput, type PackItem, type PackOptions, type Page, type PageBreakBlock, type PageClass, type PageFields, type PageGeometry, type PageLayout, type PageMargins, type PageSize, type ParagraphBlock, type ParagraphProps, type QuoteBlock, type ResolvedMargins, type Run, type Stretch, type TableBlock, type TableBorders, type TableCell, type TableFragment, type TableItem, type TableRow, type TableRowItem, type VAlign, type ViewerFont, bandSlot, blockStretches, bodyBox, carlitoFaces, docFromReader, docStretches, fontFaceCss, formatDatePicture, numberFootnotes, packInput, pageBand, pageBodyBoxes, pageCapacity, pageClass, pageClassIn, pageGeometry, pageMargins, paginate, resolveNow, substituteFields, unshownLayout };
747
+ export { type Align, type Band, type BandHeights, type BandKind, type BandSlot, type Block, type BlockFragment, type BlockItem, type BlocksBand, type BodyBox, type Border, type BorderStyle, type BoxBorders, type BoxSides, type BreakItem, CARLITO_FACES, CARLITO_FAMILY, type ChartBlock, type ChartRenderArgs, type CodeBlock, type Doc, type DocMeta, DocViewer, type DocViewerLayout, type DocViewerProps, FONT_LOAD_TIMEOUT_MS, type Footnote, type FootnoteMark, type FootnoteNumbering, type Fragment, type HeadingBlock, type HrBlock, type ImageBlock, LAYOUT_NOTICE, type ListBlock, type ListItem, OFFICE_PALETTE, type Orientation, PAGE_BAND_DISTANCE_DEFAULT, PAGE_MARGIN_DEFAULT, PAGE_SIZES_PT, PX_PER_PT, type PackInput, type PackItem, type PackOptions, type Page, type PageBreakBlock, type PageClass, type PageFields, type PageGeometry, type PageLayout, type PageMargins, type PageSize, type ParagraphBlock, type ParagraphProps, type QuoteBlock, type RenderChart, type ResolvedMargins, type Run, type Stretch, type TableBlock, type TableBorders, type TableCell, type TableFragment, type TableItem, type TableRow, type TableRowItem, type VAlign, type ViewerFont, bandSlot, blockStretches, bodyBox, carlitoFaces, docFromReader, docStretches, fontFaceCss, formatDatePicture, numberFootnotes, packInput, pageBand, pageBodyBoxes, pageCapacity, pageChartOption, pageClass, pageClassIn, pageGeometry, pageMargins, paginate, resolveNow, substituteFields, unshownLayout };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { CSSProperties } from 'react';
2
+ import { ReactNode, CSSProperties } from 'react';
3
3
 
4
4
  /**
5
5
  * The last-word Doc as this viewer reads it.
@@ -224,6 +224,38 @@ interface Doc {
224
224
  [key: string]: unknown;
225
225
  }
226
226
 
227
+ /** What `renderChart` is given for one chart block. */
228
+ interface ChartRenderArgs {
229
+ /** The block as it is in the Doc. */
230
+ block: ChartBlock;
231
+ /**
232
+ * The block's ECharts option laid out for a page: a transparent background,
233
+ * last-word's default palette, no animation and a grid that keeps axis labels
234
+ * inside the box. Every key the block sets wins.
235
+ */
236
+ option: Record<string, unknown>;
237
+ /** CSS px at 100% (before the page's scale), as the page lays the block out. */
238
+ width: number;
239
+ height: number;
240
+ /** The chart's title, or its alt text, or "". */
241
+ title: string;
242
+ }
243
+ /**
244
+ * Draws a chart block instead of the built-in renderer. Return `undefined` to
245
+ * leave that chart to the default (fancy-echarts when installed, else the
246
+ * placeholder). Draw at exactly `width` x `height`: the page was laid out for it.
247
+ */
248
+ type RenderChart = (chart: ChartRenderArgs) => ReactNode | undefined;
249
+ /** last-word's default chart palette (Office's), so an unstyled chart is the colour it is in Word. */
250
+ declare const OFFICE_PALETTE: string[];
251
+ /**
252
+ * A block's option as a page draws it. Defaults only: the block's own keys win.
253
+ * The sheet is white paper in every app colour scheme, so the background is
254
+ * transparent (the paper shows through), and animation is off so a printed or
255
+ * captured page is never caught mid-transition.
256
+ */
257
+ declare function pageChartOption(option: unknown): Record<string, unknown>;
258
+
227
259
  interface DocViewerLayout {
228
260
  /** Number of pages the document laid out to. */
229
261
  pages: number;
@@ -289,6 +321,14 @@ interface DocViewerProps {
289
321
  * `@particle-academy/last-word-ui/styles.css` instead.
290
322
  */
291
323
  injectStyles?: boolean;
324
+ /**
325
+ * Draws a chart block instead of the default, given the block, its option laid
326
+ * out for a page, and its size in CSS px. Return `undefined` to leave a chart
327
+ * to the default. The default draws with `@particle-academy/fancy-echarts`'
328
+ * `EChart` when it is installed (an optional peer) and a sized placeholder
329
+ * when it is not.
330
+ */
331
+ renderChart?: RenderChart;
292
332
  id?: string;
293
333
  className?: string;
294
334
  style?: CSSProperties;
@@ -311,7 +351,7 @@ interface DocViewerProps {
311
351
  * `{time}`, `{date:FORMAT}`, `{time:FORMAT}` -- drawn as plain text. In the
312
352
  * body they stay literal.
313
353
  */
314
- declare function DocViewer({ doc, fit, scale: fixedScale, maxScale, gap, filename, now, onLayout, injectStyles, id, className, style, }: DocViewerProps): react.JSX.Element;
354
+ declare function DocViewer({ doc, fit, scale: fixedScale, maxScale, gap, filename, now, onLayout, injectStyles, renderChart, id, className, style, }: DocViewerProps): react.JSX.Element;
315
355
 
316
356
  /** The package-unique family the bundled Carlito is declared under (`fonts.ts`). */
317
357
  declare const CARLITO_FAMILY = "LW Carlito";
@@ -704,4 +744,4 @@ interface FootnoteNumbering {
704
744
  */
705
745
  declare function numberFootnotes(doc: Doc): FootnoteNumbering;
706
746
 
707
- export { type Align, type Band, type BandHeights, type BandKind, type BandSlot, type Block, type BlockFragment, type BlockItem, type BlocksBand, type BodyBox, type Border, type BorderStyle, type BoxBorders, type BoxSides, type BreakItem, CARLITO_FACES, CARLITO_FAMILY, type ChartBlock, type CodeBlock, type Doc, type DocMeta, DocViewer, type DocViewerLayout, type DocViewerProps, FONT_LOAD_TIMEOUT_MS, type Footnote, type FootnoteMark, type FootnoteNumbering, type Fragment, type HeadingBlock, type HrBlock, type ImageBlock, LAYOUT_NOTICE, type ListBlock, type ListItem, type Orientation, PAGE_BAND_DISTANCE_DEFAULT, PAGE_MARGIN_DEFAULT, PAGE_SIZES_PT, PX_PER_PT, type PackInput, type PackItem, type PackOptions, type Page, type PageBreakBlock, type PageClass, type PageFields, type PageGeometry, type PageLayout, type PageMargins, type PageSize, type ParagraphBlock, type ParagraphProps, type QuoteBlock, type ResolvedMargins, type Run, type Stretch, type TableBlock, type TableBorders, type TableCell, type TableFragment, type TableItem, type TableRow, type TableRowItem, type VAlign, type ViewerFont, bandSlot, blockStretches, bodyBox, carlitoFaces, docFromReader, docStretches, fontFaceCss, formatDatePicture, numberFootnotes, packInput, pageBand, pageBodyBoxes, pageCapacity, pageClass, pageClassIn, pageGeometry, pageMargins, paginate, resolveNow, substituteFields, unshownLayout };
747
+ export { type Align, type Band, type BandHeights, type BandKind, type BandSlot, type Block, type BlockFragment, type BlockItem, type BlocksBand, type BodyBox, type Border, type BorderStyle, type BoxBorders, type BoxSides, type BreakItem, CARLITO_FACES, CARLITO_FAMILY, type ChartBlock, type ChartRenderArgs, type CodeBlock, type Doc, type DocMeta, DocViewer, type DocViewerLayout, type DocViewerProps, FONT_LOAD_TIMEOUT_MS, type Footnote, type FootnoteMark, type FootnoteNumbering, type Fragment, type HeadingBlock, type HrBlock, type ImageBlock, LAYOUT_NOTICE, type ListBlock, type ListItem, OFFICE_PALETTE, type Orientation, PAGE_BAND_DISTANCE_DEFAULT, PAGE_MARGIN_DEFAULT, PAGE_SIZES_PT, PX_PER_PT, type PackInput, type PackItem, type PackOptions, type Page, type PageBreakBlock, type PageClass, type PageFields, type PageGeometry, type PageLayout, type PageMargins, type PageSize, type ParagraphBlock, type ParagraphProps, type QuoteBlock, type RenderChart, type ResolvedMargins, type Run, type Stretch, type TableBlock, type TableBorders, type TableCell, type TableFragment, type TableItem, type TableRow, type TableRowItem, type VAlign, type ViewerFont, bandSlot, blockStretches, bodyBox, carlitoFaces, docFromReader, docStretches, fontFaceCss, formatDatePicture, numberFootnotes, packInput, pageBand, pageBodyBoxes, pageCapacity, pageChartOption, pageClass, pageClassIn, pageGeometry, pageMargins, paginate, resolveNow, substituteFields, unshownLayout };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createContext, useMemo, useRef, useState, useEffect, useLayoutEffect, useContext } from 'react';
1
+ import { createContext, useMemo, useRef, useState, useEffect, useLayoutEffect, useContext, useSyncExternalStore } from 'react';
2
2
  import { Callout, Text, Separator, Heading, Table, ImageViewer } from '@particle-academy/react-fancy';
3
3
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
4
4
 
@@ -50,6 +50,122 @@ function bodyBox(g, headerHeight, footerHeight) {
50
50
  const bottom = Math.max(g.margins.bottom, footerHeight > 0 ? g.margins.footer + footerHeight : 0);
51
51
  return { top, bottom, height: Math.max(1, g.height - top - bottom) };
52
52
  }
53
+ var OFFICE_PALETTE = ["#4472C4", "#ED7D31", "#A5A5A5", "#FFC000", "#5B9BD5", "#70AD47", "#264478", "#9E480E"];
54
+ var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
55
+ function pageChartOption(option) {
56
+ const o = isObj(option) ? option : {};
57
+ const hasAxes = o.xAxis !== void 0 || o.yAxis !== void 0;
58
+ const legendShown = isObj(o.legend) && o.legend.show !== false;
59
+ return {
60
+ backgroundColor: "transparent",
61
+ color: OFFICE_PALETTE,
62
+ animation: false,
63
+ ...o,
64
+ ...hasAxes ? {
65
+ grid: o.grid ?? {
66
+ top: o.title ? 36 : 16,
67
+ right: 16,
68
+ bottom: 8 + (legendShown ? 28 : 0),
69
+ left: 8,
70
+ outerBoundsMode: "same",
71
+ outerBoundsContain: "all"
72
+ }
73
+ } : {}
74
+ };
75
+ }
76
+ function chartTitle(block) {
77
+ const title = isObj(block.option) ? block.option.title : void 0;
78
+ if (typeof title === "string") return title;
79
+ if (isObj(title) && typeof title.text === "string") return title.text;
80
+ return typeof block.alt === "string" ? block.alt : "";
81
+ }
82
+ var PENDING = { status: "pending" };
83
+ var MISSING = { status: "missing" };
84
+ var peer = PENDING;
85
+ var loading = null;
86
+ var listeners = /* @__PURE__ */ new Set();
87
+ function loadPeer() {
88
+ if (loading) return;
89
+ loading = import('@particle-academy/fancy-echarts').then((ns) => {
90
+ const mod = ns;
91
+ const EChart = mod.EChart;
92
+ if (typeof EChart !== "function" && typeof EChart !== "object") return MISSING;
93
+ mod.registerAll?.();
94
+ return { status: "ready", EChart };
95
+ }).catch(() => MISSING).then((state) => {
96
+ peer = state;
97
+ listeners.forEach((l) => l());
98
+ });
99
+ }
100
+ function subscribe(listener) {
101
+ listeners.add(listener);
102
+ loadPeer();
103
+ return () => listeners.delete(listener);
104
+ }
105
+ var getSnapshot = () => peer;
106
+ var getServerSnapshot = () => PENDING;
107
+ var warned = false;
108
+ function warnMissing() {
109
+ if (warned) return;
110
+ const env = globalThis.process?.env;
111
+ if (env?.NODE_ENV === "production") return;
112
+ warned = true;
113
+ console.warn(
114
+ "[last-word-ui] This document has charts, but @particle-academy/fancy-echarts is not installed, so they draw as placeholders. Install it (npm i @particle-academy/fancy-echarts echarts) to draw them, or pass DocViewer a renderChart prop."
115
+ );
116
+ }
117
+ var PAPER_THEME = {};
118
+ function ChartBox({ block, width, height: height2, measuring, renderChart }) {
119
+ const title = chartTitle(block);
120
+ return /* @__PURE__ */ jsx(
121
+ "div",
122
+ {
123
+ "data-lw-chart": "",
124
+ role: measuring ? void 0 : "img",
125
+ "aria-label": measuring || !title ? void 0 : title,
126
+ style: { width, height: height2, overflow: "hidden" },
127
+ children: measuring ? null : /* @__PURE__ */ jsx(ChartContent, { block, width, height: height2, title, renderChart })
128
+ }
129
+ );
130
+ }
131
+ function ChartContent({ block, width, height: height2, title, renderChart }) {
132
+ const option = useMemo(() => pageChartOption(block.option), [block.option]);
133
+ if (renderChart) {
134
+ const custom = renderChart({ block, option, width, height: height2, title });
135
+ if (custom !== void 0) return /* @__PURE__ */ jsx(Fragment, { children: custom });
136
+ }
137
+ return /* @__PURE__ */ jsx(DefaultChart, { option, width, height: height2, title });
138
+ }
139
+ function DefaultChart({ option, width, height: height2, title }) {
140
+ const state = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
141
+ if (state.status === "ready") {
142
+ const { EChart } = state;
143
+ return /* @__PURE__ */ jsx(EChart, { option, theme: PAPER_THEME, renderer: "svg", autoResize: false, style: { width, height: height2 } });
144
+ }
145
+ if (state.status === "missing") return /* @__PURE__ */ jsx(Placeholder, { width, height: height2, title });
146
+ return null;
147
+ }
148
+ function Placeholder({ width, height: height2, title }) {
149
+ useEffect(warnMissing, []);
150
+ return /* @__PURE__ */ jsx(
151
+ "div",
152
+ {
153
+ "data-lw-chart-placeholder": "",
154
+ style: {
155
+ width,
156
+ height: height2,
157
+ border: "0.75pt dashed #9CA3AF",
158
+ color: "#6B7280",
159
+ fontSize: "9pt",
160
+ display: "flex",
161
+ alignItems: "center",
162
+ justifyContent: "center",
163
+ boxSizing: "border-box"
164
+ },
165
+ children: title ? `Chart: ${title}` : "Chart"
166
+ }
167
+ );
168
+ }
53
169
 
54
170
  // src/fields.ts
55
171
  var FIELD = /\{(?:(page|pages|section|sectionpages|author|title|filename)|(date|time)(?::([^{}"\\]+))?)\}/g;
@@ -533,7 +649,7 @@ function BlockView({ block }) {
533
649
  case "image":
534
650
  return /* @__PURE__ */ jsx(ImageView, { block });
535
651
  case "chart":
536
- return /* @__PURE__ */ jsx(ChartPlaceholder, { block });
652
+ return /* @__PURE__ */ jsx(ChartView, { block });
537
653
  case "hr":
538
654
  return /* @__PURE__ */ jsx("div", { "data-lw-kind": "hr", style: { display: "flow-root", paddingBottom: pt(ctx.spaceAfter) }, children: /* @__PURE__ */ jsx("div", { style: { height: pt(ctx.size * SINGLE_LINE), display: "flex", alignItems: "flex-end" }, children: /* @__PURE__ */ jsx(Separator, { className: "w-full" }) }) });
539
655
  case "pageBreak":
@@ -585,7 +701,7 @@ function ImageView({ block }) {
585
701
  }
586
702
  ) });
587
703
  }
588
- function ChartPlaceholder({ block }) {
704
+ function ChartView({ block }) {
589
705
  const ctx = useContext(RenderCtx);
590
706
  const maxPx = ctx.contentWidth * PX_PER_PT;
591
707
  const width = Math.min(
@@ -593,26 +709,7 @@ function ChartPlaceholder({ block }) {
593
709
  num(block.widthPx, typeof block.width === "number" && block.width > 0 ? maxPx * Math.min(100, block.width) / 100 : maxPx)
594
710
  );
595
711
  const height2 = num(block.heightPx, width * 0.6);
596
- const option = block.option ?? {};
597
- const title = typeof option.title === "string" ? option.title : option.title && typeof option.title.text === "string" ? option.title.text : typeof block.alt === "string" ? block.alt : "";
598
- return /* @__PURE__ */ jsx("div", { "data-lw-kind": "chart", style: { display: "flow-root", paddingBottom: pt(ctx.spaceAfter) }, children: /* @__PURE__ */ jsx(
599
- "div",
600
- {
601
- "data-lw-chart-placeholder": "",
602
- style: {
603
- width,
604
- height: height2,
605
- border: "0.75pt dashed #9CA3AF",
606
- color: "#6B7280",
607
- fontSize: pt(9),
608
- display: "flex",
609
- alignItems: "center",
610
- justifyContent: "center",
611
- boxSizing: "border-box"
612
- },
613
- children: title ? `Chart: ${title}` : "Chart"
614
- }
615
- ) });
712
+ return /* @__PURE__ */ jsx("div", { "data-lw-kind": "chart", style: { display: "flow-root", paddingBottom: pt(ctx.spaceAfter) }, children: /* @__PURE__ */ jsx(ChartBox, { block, width, height: height2, measuring: ctx.measuring, renderChart: ctx.renderChart }) });
616
713
  }
617
714
  var DEFAULT_TABLE_BORDER = { style: "single", width: 0.5 };
618
715
  var DEFAULT_CELL_PADDING = { top: 3, right: 5.4, bottom: 3, left: 5.4 };
@@ -1381,6 +1478,7 @@ function DocViewer({
1381
1478
  now,
1382
1479
  onLayout,
1383
1480
  injectStyles = true,
1481
+ renderChart,
1384
1482
  id,
1385
1483
  className,
1386
1484
  style
@@ -1424,9 +1522,10 @@ function DocViewer({
1424
1522
  marks: numbering.marks,
1425
1523
  size: num(doc?.defaultSize, DEFAULT_SIZE),
1426
1524
  spaceAfter: DEFAULT_SPACE_AFTER,
1427
- contentWidth: geometry.contentWidth
1525
+ contentWidth: geometry.contentWidth,
1526
+ ...renderChart ? { renderChart } : {}
1428
1527
  }),
1429
- [numbering, doc, geometry]
1528
+ [numbering, doc, geometry, renderChart]
1430
1529
  );
1431
1530
  const ctxOf = (k) => ({ ...ctx, contentWidth: stretches[k].geometry.contentWidth });
1432
1531
  useEffect(() => {
@@ -1497,6 +1596,7 @@ function DocViewer({
1497
1596
  "data-lw-viewer": "",
1498
1597
  "data-lw-pages": ready && pageCount || void 0,
1499
1598
  "data-lw-font": ready ? font : void 0,
1599
+ "aria-busy": ready ? void 0 : true,
1500
1600
  className,
1501
1601
  style: { position: "relative", ...style },
1502
1602
  children: [
@@ -1526,7 +1626,7 @@ function DocViewer({
1526
1626
  if (!hasBand(band)) return null;
1527
1627
  const n = slot === "even" ? 2 : 1;
1528
1628
  const at = k === 0 ? `${kind}:${slot}` : `${k + 1}:${kind}:${slot}`;
1529
- return /* @__PURE__ */ jsx("div", { "data-lw-measure-band": at, style: stretches.length > 1 ? { width: pt(stretch.geometry.contentWidth) } : void 0, children: /* @__PURE__ */ jsx(RenderCtx.Provider, { value: { ...ctxOf(k), fields: { ...docFields, section: k + 1, page: n, pages: n } }, children: /* @__PURE__ */ jsx(BandView, { band }) }) }, at);
1629
+ return /* @__PURE__ */ jsx("div", { "data-lw-measure-band": at, style: stretches.length > 1 ? { width: pt(stretch.geometry.contentWidth) } : void 0, children: /* @__PURE__ */ jsx(RenderCtx.Provider, { value: { ...ctxOf(k), measuring: true, fields: { ...docFields, section: k + 1, page: n, pages: n } }, children: /* @__PURE__ */ jsx(BandView, { band }) }) }, at);
1530
1630
  })
1531
1631
  )
1532
1632
  ),
@@ -1537,19 +1637,31 @@ function DocViewer({
1537
1637
  {
1538
1638
  "data-lw-measure-block": i,
1539
1639
  style: { display: "flow-root", ...stretches.length > 1 ? { width: pt(stretches[k].geometry.contentWidth) } : {} },
1540
- children: /* @__PURE__ */ jsx(RenderCtx.Provider, { value: ctxOf(k), children: /* @__PURE__ */ jsx(BlockView, { block: b }) })
1640
+ children: /* @__PURE__ */ jsx(RenderCtx.Provider, { value: { ...ctxOf(k), measuring: true }, children: /* @__PURE__ */ jsx(BlockView, { block: b }) })
1541
1641
  },
1542
1642
  i
1543
1643
  );
1544
1644
  }),
1545
1645
  numbering.notes.map((n) => {
1546
1646
  const k = noteStretch.get(n.id) ?? 0;
1547
- return /* @__PURE__ */ jsx("div", { "data-lw-measure-footnote": n.id, style: stretches.length > 1 ? { width: pt(stretches[k].geometry.contentWidth) } : void 0, children: /* @__PURE__ */ jsx(RenderCtx.Provider, { value: ctxOf(k), children: /* @__PURE__ */ jsx(FootnoteView, { id: n.id, footnote: n.footnote }) }) }, n.id);
1647
+ return /* @__PURE__ */ jsx("div", { "data-lw-measure-footnote": n.id, style: stretches.length > 1 ? { width: pt(stretches[k].geometry.contentWidth) } : void 0, children: /* @__PURE__ */ jsx(RenderCtx.Provider, { value: { ...ctxOf(k), measuring: true }, children: /* @__PURE__ */ jsx(FootnoteView, { id: n.id, footnote: n.footnote }) }) }, n.id);
1548
1648
  }),
1549
1649
  numbering.notes.length > 0 && /* @__PURE__ */ jsx("div", { "data-lw-measure-separator": "", children: /* @__PURE__ */ jsx(FootnoteSeparator, { height: pt(FOOTNOTE_SEPARATOR_PT) }) })
1550
1650
  ] })
1551
1651
  }
1552
1652
  ),
1653
+ !ready && /* @__PURE__ */ jsx(
1654
+ "div",
1655
+ {
1656
+ "data-lw-pending": "",
1657
+ style: {
1658
+ width: px(stretches[0].geometry.width * PX_PER_PT * scale),
1659
+ maxWidth: "100%",
1660
+ height: px(stretches[0].geometry.height * PX_PER_PT * scale),
1661
+ margin: "0 auto"
1662
+ }
1663
+ }
1664
+ ),
1553
1665
  ready && layout && /* @__PURE__ */ jsx("div", { "data-lw-page-stack": "", style: { display: "flex", flexDirection: "column", alignItems: "center", gap }, children: layout.pages.map((p) => {
1554
1666
  const k = p.stretch ?? 0;
1555
1667
  const inStretch = layout.pages.filter((x) => (x.stretch ?? 0) === k);
@@ -1706,6 +1818,6 @@ function docFromReader(output) {
1706
1818
  return value;
1707
1819
  }
1708
1820
 
1709
- export { CARLITO_FACES, CARLITO_FAMILY, DocViewer, FONT_LOAD_TIMEOUT_MS, LAYOUT_NOTICE, PAGE_BAND_DISTANCE_DEFAULT, PAGE_MARGIN_DEFAULT, PAGE_SIZES_PT, PX_PER_PT, bandSlot, blockStretches, bodyBox, carlitoFaces, docFromReader, docStretches, fontFaceCss, formatDatePicture, numberFootnotes, packInput, pageBand, pageBodyBoxes, pageCapacity, pageClass, pageClassIn, pageGeometry, pageMargins, paginate, resolveNow, substituteFields, unshownLayout };
1821
+ export { CARLITO_FACES, CARLITO_FAMILY, DocViewer, FONT_LOAD_TIMEOUT_MS, LAYOUT_NOTICE, OFFICE_PALETTE, PAGE_BAND_DISTANCE_DEFAULT, PAGE_MARGIN_DEFAULT, PAGE_SIZES_PT, PX_PER_PT, bandSlot, blockStretches, bodyBox, carlitoFaces, docFromReader, docStretches, fontFaceCss, formatDatePicture, numberFootnotes, packInput, pageBand, pageBodyBoxes, pageCapacity, pageChartOption, pageClass, pageClassIn, pageGeometry, pageMargins, paginate, resolveNow, substituteFields, unshownLayout };
1710
1822
  //# sourceMappingURL=index.js.map
1711
1823
  //# sourceMappingURL=index.js.map