@particle-academy/last-word-ui 0.1.1 → 0.2.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/CHANGELOG.md CHANGED
@@ -10,6 +10,44 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.2.0] - 2026-11-01
14
+
15
+ Renders last-word 0.16.0's band variants and field tokens. **Consumer action:
16
+ none.** Both new props are optional, and a document without the new page keys
17
+ or tokens renders exactly as it did on 0.1.1. Pass `filename` and `now` only
18
+ if your bands use `{filename}`, `{date}` or `{time}`.
19
+
20
+ ### Added
21
+
22
+ - **First-page and even-page bands:** `page.firstHeader`, `page.firstFooter`,
23
+ `page.evenHeader` and `page.evenFooter`, in the same forms as `page.header`
24
+ (a one-line band or `{blocks}`). Page 1 draws the first variant when
25
+ present, even pages (2, 4, ...) the even variant, every other page the
26
+ default. `{"blocks": []}` as a variant blanks that page's band. Each band
27
+ carries `data-lw-band-variant` (`default`, `first` or `even`).
28
+ - **Per-page body heights.** Each page's body is sized by the bands it
29
+ actually draws, so a tall first-page letterhead moves only page 1's body
30
+ down. `paginate()` takes optional `firstPageHeight` and `evenPageHeight`
31
+ beside `pageHeight`, and each `PageLayout` reports its `capacity`. Without
32
+ the new options, pagination is unchanged.
33
+ - **Field tokens in band text:** `{section}` and `{sectionpages}` (a Doc is one
34
+ section: `1` and the page total), `{author}` (`doc.meta.author`), `{title}`
35
+ (the top-level `doc.title`; there is no `meta.title`), `{filename}`, and
36
+ `{date}` / `{time}` in the browser locale, or `{date:FORMAT}` /
37
+ `{time:FORMAT}` with a Word date-time picture (d to dddd, M to MMMM, yy,
38
+ yyyy, h, hh, H, HH, m, mm, s, ss, am/pm, AM/PM, single-quoted literals,
39
+ English names). Tokens follow last-word's grammar exactly; anything else in
40
+ braces stays literal. In the body every token stays literal text. Values
41
+ render as plain text only.
42
+ - **Props:** `filename` (what `{filename}` shows; empty when absent) and `now`
43
+ (a Date or an ISO string; the moment `{date}` / `{time}` show, for
44
+ deterministic output).
45
+ - **Exports:** `pageCapacity`, `pageBand`, `pageClass`, `bandSlot`,
46
+ `pageBodyBoxes`, `formatDatePicture`, `resolveNow`, and the `BandKind`,
47
+ `BandSlot`, `PageClass`, `BandHeights` and `DocMeta` types. `PageFields`
48
+ gains optional `section`, `sectionPages`, `author`, `title`, `filename` and
49
+ `now`; `substituteFields(text, { page, pages })` still works as before.
50
+
13
51
  ## [0.1.1] - 2026-11-01
14
52
 
15
53
  ### Changed
package/README.md CHANGED
@@ -49,6 +49,8 @@ so a deep clone between numbering and render would lose the marks.
49
49
  | `scale` | `number` | | a fixed scale; overrides `fit` |
50
50
  | `maxScale` | `number` | `1` | the most `fit` will enlarge a page |
51
51
  | `gap` | `number` | `16` | px between pages |
52
+ | `filename` | `string` | `""` | what a `{filename}` band field shows |
53
+ | `now` | `Date \| string` | first render | the moment `{date}` / `{time}` show; an ISO string is fine |
52
54
  | `onLayout` | `(l) => void` | | `{ pages, pageWidth, pageHeight, scale }`, JSON |
53
55
  | `injectStyles` | `boolean` | `true` | see *Styles* |
54
56
  | `id`, `className`, `style` | | | on the root |
@@ -58,7 +60,8 @@ so a deep clone between numbering and render would lose the marks.
58
60
  The root carries `data-lw-viewer`. Each page carries `data-page` (1-based), each
59
61
  block or fragment of a block carries `data-block` (`b0`, `b1`, ... in document
60
62
  order), each footnote carries `data-footnote`, and the bands carry
61
- `data-lw-band="header" | "footer"`. Table fragments carry `data-lw-rows`, plus
63
+ `data-lw-band="header" | "footer"`, with `data-lw-band-variant="default" |
64
+ "first" | "even"` naming the band drawn. Table fragments carry `data-lw-rows`, plus
62
65
  `data-lw-repeated-header` on continuation pages.
63
66
 
64
67
  ### Styles
@@ -86,8 +89,22 @@ import "@particle-academy/last-word-ui/styles.css";
86
89
  edge (36pt when absent). They are either a left / centre / right band or
87
90
  blocks (a letterhead logo, address lines). A tall header pushes the body down,
88
91
  as in Word.
89
- - **Page numbers:** `{page}` and `{pages}` become live numbers on each page,
90
- in bands only. In the body they stay literal text, as in the file.
92
+ - **First-page and even-page bands** (last-word 0.16.0): page 1 draws
93
+ `page.firstHeader` / `page.firstFooter` when present, even pages (2, 4, ...)
94
+ `page.evenHeader` / `page.evenFooter`, and every other page the default.
95
+ `{"blocks": []}` as a variant blanks that page's band. Each page's body is
96
+ sized by the bands it actually draws, so a tall first-page letterhead moves
97
+ only page 1's body down.
98
+ - **Fields in bands:** `{page}`, `{pages}`; `{section}` and `{sectionpages}`
99
+ (a Doc is one section, so `1` and the page total); `{author}`
100
+ (`doc.meta.author`); `{title}` (the top-level `doc.title`; there is no
101
+ `meta.title`); `{filename}` (the `filename` prop); `{date}` and `{time}` in
102
+ the browser's locale, or `{date:FORMAT}` / `{time:FORMAT}` with a Word
103
+ picture (`d dd ddd dddd M MM MMM MMMM yy yyyy h hh H HH m mm s ss am/pm
104
+ AM/PM`, text in single quotes literal, English names). Unknown values are
105
+ empty. Names are lower-case and exact; anything else in braces stays
106
+ literal. All of it is drawn as plain text. In the body every token stays
107
+ literal text, as in the file.
91
108
  - **Footnotes:** numbered 1, 2, 3 in document order and set at the foot of the
92
109
  mark's page, under a short rule. Their height comes off that page's body.
93
110
  - **Content:** tables (widths, header rows, cell shading, borders, padding,