uhuu-components 0.4.2 → 0.4.4
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/index.d.ts +201 -23
- package/package.json +1 -1
- package/uhuu-components.es.js +4385 -4217
- package/uhuu-components.es.js.map +1 -1
- package/uhuu-components.umd.cjs +27 -27
- package/uhuu-components.umd.cjs.map +1 -1
package/index.d.ts
CHANGED
|
@@ -22,6 +22,13 @@ export interface StaticFlowItemMeta {
|
|
|
22
22
|
orphans?: number;
|
|
23
23
|
/** An item split between the lines of its `Static.FlowText`: fewest lines on the piece that starts the next page. Default 2. */
|
|
24
24
|
widows?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The screen view (`PageEditor` `view="screen"`): where print would scale the item onto a page of
|
|
27
|
+
* its own (taller than its page, and not split by a `Static.FlowText`), it is drawn whole at full
|
|
28
|
+
* size and its sheet grows to hold it. Taller than any page, it starts right under what precedes
|
|
29
|
+
* it. Print ignores it, and so does an item inside a `Static.FlowColumns` column group.
|
|
30
|
+
*/
|
|
31
|
+
growSheet?: boolean;
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
/**
|
|
@@ -69,6 +76,13 @@ export type StaticFlowTextIssue =
|
|
|
69
76
|
export interface StaticFlowItemGroup {
|
|
70
77
|
key: string;
|
|
71
78
|
repeatHeader?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* The screen view (`PageEditor` `view="screen"`): the group is one unit, its header and every item
|
|
81
|
+
* on one sheet. It fits the room left, or moves whole to a page that holds it; taller than any
|
|
82
|
+
* page, it starts right under what precedes it and its sheet grows (`--uhuu-sheet-growth`). Print
|
|
83
|
+
* ignores it, and so does a `Static.FlowColumns` column group.
|
|
84
|
+
*/
|
|
85
|
+
growSheet?: boolean;
|
|
72
86
|
}
|
|
73
87
|
|
|
74
88
|
export interface StaticFlowFragmentContext<TItem = unknown> {
|
|
@@ -133,6 +147,11 @@ export interface StaticFlowChunk {
|
|
|
133
147
|
layout?: StaticFlowLayoutFragment[];
|
|
134
148
|
/** The pieces of items split between lines on this page, by item index. */
|
|
135
149
|
splits?: Record<number, StaticFlowTextSplit>;
|
|
150
|
+
/**
|
|
151
|
+
* How much taller than its page this sheet is drawn, in px, to hold an item with `growSheet`
|
|
152
|
+
* (the screen view). The sheet exposes it as `--uhuu-sheet-growth`.
|
|
153
|
+
*/
|
|
154
|
+
growth?: number;
|
|
136
155
|
}
|
|
137
156
|
|
|
138
157
|
export interface StaticFlowColumn {
|
|
@@ -194,6 +213,11 @@ export interface StaticFlowMeasureApi {
|
|
|
194
213
|
readHeaderGroupKey: (element: HTMLElement) => string | undefined;
|
|
195
214
|
/** @internal Library measurement detail; retained for compatibility. */
|
|
196
215
|
readHeaderGroupRepeats: (itemElements: HTMLElement[]) => Record<string, boolean>;
|
|
216
|
+
/**
|
|
217
|
+
* @internal The header groups whose items carry `data-uhuu-flow-header-grow-sheet`
|
|
218
|
+
* (`getItemGroup` `growSheet`, the screen view), for `headerGroupGrows`.
|
|
219
|
+
*/
|
|
220
|
+
readHeaderGroupGrows: (itemElements: HTMLElement[]) => Record<string, boolean>;
|
|
197
221
|
/** `unwrapped`: heights from `readUnwrappedHeights`, used for the headers it covers. */
|
|
198
222
|
readHeaderGroupHeights: (
|
|
199
223
|
root: HTMLElement,
|
|
@@ -268,11 +292,14 @@ export interface StaticFlowPlanInput {
|
|
|
268
292
|
headerGroupKeys?: Array<string | null | undefined>;
|
|
269
293
|
headerGroupHeights?: Record<string, number>;
|
|
270
294
|
headerGroupRepeats?: Record<string, boolean>;
|
|
295
|
+
/** Header groups that are one unit on one sheet (`getItemGroup` `growSheet`, the screen view). */
|
|
296
|
+
headerGroupGrows?: Record<string, boolean>;
|
|
271
297
|
onUnplaceableItem?: (item: StaticFlowUnplaceableItem) => void;
|
|
298
|
+
/** @internal Filled with the planner's work counters (hosts tuning their own canvas). */
|
|
272
299
|
metrics?: StaticFlowPlanMetrics;
|
|
273
300
|
/**
|
|
274
|
-
* Line metrics per item
|
|
275
|
-
* split. An item that does not fit the room left is split at a line (chunks gain `splits`).
|
|
301
|
+
* @internal Line metrics per item, as `flowMeasure.readFlowTextLines` reads them (hosts that run
|
|
302
|
+
* their own Flow canvas); `undefined` for items that do not split. An item that does not fit the room left is split at a line (chunks gain `splits`).
|
|
276
303
|
* Without `lines` the plan is item-level. `planFlowColumnChunks` does not split.
|
|
277
304
|
*/
|
|
278
305
|
lines?: Array<StaticFlowItemLines | undefined>;
|
|
@@ -293,7 +320,8 @@ export interface StaticFlowColumnPlanInput extends StaticFlowPlanInput {
|
|
|
293
320
|
|
|
294
321
|
export interface ImageBlockDialog {
|
|
295
322
|
path: string;
|
|
296
|
-
|
|
323
|
+
/** The dialog to open. A frame message (`frameEditDialog`) has `frame` instead. */
|
|
324
|
+
type?: "image" | "satellite";
|
|
297
325
|
[key: string]: unknown;
|
|
298
326
|
}
|
|
299
327
|
|
|
@@ -317,16 +345,35 @@ export interface ImageBlockProps {
|
|
|
317
345
|
style?: CSSProperties;
|
|
318
346
|
imageStyle?: CSSProperties;
|
|
319
347
|
backgroundColor?: string;
|
|
348
|
+
/**
|
|
349
|
+
* `auto` (an image in the flow of the page), `bleed` (positioned on the page by its geometry, into
|
|
350
|
+
* the bleed where it touches an edge) or `spread` (one half of an image across two facing pages).
|
|
351
|
+
* Unset: `spread` when `side` is set, `bleed` when any of `width`, `height`, `left`, `right`,
|
|
352
|
+
* `top`, `bottom` is set, else `auto`.
|
|
353
|
+
*/
|
|
320
354
|
mode?: "bleed" | "spread" | "auto";
|
|
321
|
-
|
|
355
|
+
/**
|
|
356
|
+
* `spread`: which page of the pair this half is on: `start` (or `left`) the left page, `end` (or
|
|
357
|
+
* `right`) the right one. `left` / `right` as a cover spread's `spread.side` names them.
|
|
358
|
+
*/
|
|
359
|
+
side?: "start" | "end" | "left" | "right";
|
|
360
|
+
/** Geometry in mm from the trim box, as every page dimension: the image's width. */
|
|
322
361
|
width?: number;
|
|
362
|
+
/** Geometry in mm: the image's height. */
|
|
323
363
|
height?: number;
|
|
364
|
+
/** Geometry in mm: distance from the left trim edge (0 runs into the bleed). */
|
|
324
365
|
left?: number;
|
|
366
|
+
/** Geometry in mm: distance from the right trim edge (0 runs into the bleed). */
|
|
325
367
|
right?: number;
|
|
368
|
+
/** Geometry in mm: distance from the top trim edge (0 runs into the bleed). */
|
|
326
369
|
top?: number;
|
|
370
|
+
/** Geometry in mm: distance from the bottom trim edge (0 runs into the bleed). */
|
|
327
371
|
bottom?: number;
|
|
372
|
+
/** Page width in mm; default from the page setup (ConfigContext). */
|
|
328
373
|
pageWidth?: number;
|
|
374
|
+
/** Page height in mm; default from the page setup. */
|
|
329
375
|
pageHeight?: number;
|
|
376
|
+
/** Bleed in mm; default from the page setup. */
|
|
330
377
|
bleed?: number;
|
|
331
378
|
dialog?: ImageBlockDialog;
|
|
332
379
|
annotation?: ImageBlockAnnotation;
|
|
@@ -337,7 +384,10 @@ export interface ImageBlockProps {
|
|
|
337
384
|
* Extra props (className, handlers, data attributes) merged into the click target that `dialog`
|
|
338
385
|
* binds. Applied in `auto` mode, where ImageBlock renders that element itself. In `bleed` and
|
|
339
386
|
* `spread` modes the image is positioned on the page and its element is the library's: there
|
|
340
|
-
* `dialogProps` is not applied
|
|
387
|
+
* `dialogProps` is not applied, and neither are `className`, `style`, `imageStyle`, `imageProps`,
|
|
388
|
+
* `renderImage` and `placeholder` (development builds warn). Style the image with
|
|
389
|
+
* `imageClassName`; `children` render over it only with `dialog`, `annotation`, `overlaySvg` or
|
|
390
|
+
* `options`.
|
|
341
391
|
*/
|
|
342
392
|
dialogProps?: Record<string, unknown>;
|
|
343
393
|
placeholder?: ReactNode;
|
|
@@ -890,6 +940,7 @@ export interface BrandKitOption {
|
|
|
890
940
|
name: string;
|
|
891
941
|
}
|
|
892
942
|
|
|
943
|
+
/** @deprecated Nothing takes or returns it; use `PageItem`. Removed in 0.5.0. */
|
|
893
944
|
export interface PageEditorItem {
|
|
894
945
|
id?: string;
|
|
895
946
|
templateId?: string;
|
|
@@ -1169,30 +1220,69 @@ export interface PageEditorProps {
|
|
|
1169
1220
|
* browser and wins over this one.
|
|
1170
1221
|
*/
|
|
1171
1222
|
toolbarPosition?: ToolbarPosition;
|
|
1223
|
+
/**
|
|
1224
|
+
* What the pages are drawn for: `print` (default), the document as it prints, or `screen`, the
|
|
1225
|
+
* document read on screen (a host's "Print" switch). Pages read it with `Static.useView()` and
|
|
1226
|
+
* decide what changes (a table kept whole); a `Static.Flow` item with meta `growSheet` is drawn
|
|
1227
|
+
* whole on a taller sheet instead of scaled to fit a page. The renderer always draws `print`;
|
|
1228
|
+
* any other value draws `print` and warns.
|
|
1229
|
+
*/
|
|
1230
|
+
view?: StaticView;
|
|
1231
|
+
/** Called with the page list after every change a user makes (add, remove, reorder, rename). */
|
|
1172
1232
|
onItemsChange?: (items: PageItem[], state: PageEditorState) => void;
|
|
1233
|
+
/** Called with the saved editor state after every change, as it is written to the payload. */
|
|
1173
1234
|
onStateChange?: (state: PageEditorState) => void;
|
|
1174
1235
|
/**
|
|
1175
|
-
*
|
|
1176
|
-
*
|
|
1236
|
+
* Shows a page-management error (a page that cannot be added or removed). Default: the shell's
|
|
1237
|
+
* own notice dialog.
|
|
1177
1238
|
*/
|
|
1178
1239
|
notifyError?: (message: string) => void;
|
|
1240
|
+
/** Development only (dev tools on): draws a reference image under each page to compare against. */
|
|
1179
1241
|
referenceRenderer?: (page: StandalonePage & { pageNum: number }) => ReactNode;
|
|
1242
|
+
/** Replaces the whole sheet of each page (Pagination and Sheet included); cover spreads excepted. */
|
|
1180
1243
|
renderPage?: (args: { page: StandalonePage & { pageNum: number }; parent?: PageItem }) => ReactNode;
|
|
1244
|
+
/** Extra items in the toolbar's menu, before the shell's own. */
|
|
1181
1245
|
menuItems?: ReactNode;
|
|
1246
|
+
/**
|
|
1247
|
+
* The grid class of the reorder dialog's page thumbnails. It replaces the shell's
|
|
1248
|
+
* `uhuu-page-order-grid-cols` (it does not merge).
|
|
1249
|
+
*/
|
|
1182
1250
|
gridColsClass?: string;
|
|
1251
|
+
/**
|
|
1252
|
+
* Called with the item a user is about to add: return it (or a changed copy, async allowed) to
|
|
1253
|
+
* add it, or `null` to cancel.
|
|
1254
|
+
*/
|
|
1183
1255
|
resolveNewItem?: (draft: PageItem) => Promise<PageItem | null | void> | PageItem | null | void;
|
|
1256
|
+
/**
|
|
1257
|
+
* What prints over every page. Default: the shell's page number ("Page N / total", untranslated).
|
|
1258
|
+
* `false` or `null`: nothing, for templates that number their own pages.
|
|
1259
|
+
*/
|
|
1184
1260
|
renderOverlay?: false | null | ((context: {
|
|
1261
|
+
/** 1-based position in the flow-expanded document, as page components get it. */
|
|
1262
|
+
pageNum: number;
|
|
1263
|
+
/** Sheets in the flow-expanded document. */
|
|
1264
|
+
totalPages: number;
|
|
1265
|
+
/** @deprecated Use `pageNum`. */
|
|
1185
1266
|
pageNo: number;
|
|
1267
|
+
/** @deprecated Use `totalPages`. */
|
|
1186
1268
|
total: number;
|
|
1187
1269
|
pageId: string;
|
|
1188
1270
|
parent?: PageItem;
|
|
1189
1271
|
}) => ReactNode);
|
|
1190
1272
|
reorderTitle?: LocalizedText;
|
|
1191
1273
|
reorderDescription?: LocalizedText;
|
|
1274
|
+
/** The payload key the page list and its state are saved under. Default `uhuu_page_editor`. */
|
|
1192
1275
|
stateKey?: string;
|
|
1276
|
+
/**
|
|
1277
|
+
* Development only: the brand-kit switcher in the dev tools menu (dev tools on). It lists
|
|
1278
|
+
* `brandKits` and calls back; it does not load a kit: wire the choice to `BrandKitProvider`.
|
|
1279
|
+
*/
|
|
1193
1280
|
brandKits?: BrandKitOption[];
|
|
1281
|
+
/** Development only: the kit the dev switcher marks as active. */
|
|
1194
1282
|
activeBrandKitId?: string;
|
|
1283
|
+
/** Development only: a kit chosen in the dev switcher. */
|
|
1195
1284
|
onSelectBrandKit?: (id: string) => void;
|
|
1285
|
+
/** Development only: a kit URL or id typed into the dev switcher. */
|
|
1196
1286
|
onAddBrandKit?: (input: string) => void;
|
|
1197
1287
|
}
|
|
1198
1288
|
|
|
@@ -1211,17 +1301,47 @@ export interface TemplateDataProviderProps {
|
|
|
1211
1301
|
}
|
|
1212
1302
|
|
|
1213
1303
|
export interface IntegrationAdapterConfig {
|
|
1214
|
-
dataBinding
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1304
|
+
/** The page's `dataBinding` prop: dialog paths are built from its integration binding. */
|
|
1305
|
+
dataBinding?: PageDataBinding | Record<string, unknown>;
|
|
1306
|
+
/** The integration's data the resolver reads. */
|
|
1307
|
+
integration?: unknown;
|
|
1308
|
+
/**
|
|
1309
|
+
* Required: how `data` is read from `integration`. A map of keys to paths
|
|
1310
|
+
* (`"listing ?? pba_listing"`) or functions, or one function `(integration, payload) => data`.
|
|
1311
|
+
*/
|
|
1312
|
+
resolver?: Record<string, string | ((integration: any) => unknown)> | ((integration: any, payload?: unknown) => unknown);
|
|
1313
|
+
/** The gallery image dialogs browse: a path, or read from the integration. */
|
|
1314
|
+
galleryPath?: string | ((integration: any) => string | null);
|
|
1315
|
+
/** @deprecated Never read: `data` is what `resolver` returns. Removed in 0.5.0. */
|
|
1218
1316
|
defaults?: Record<string, unknown>;
|
|
1219
1317
|
[key: string]: unknown;
|
|
1220
1318
|
}
|
|
1221
1319
|
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1320
|
+
/** A dialog `useIntegrationAdapter` builds, its `path` under the page's integration binding. */
|
|
1321
|
+
export interface IntegrationDialog {
|
|
1322
|
+
path: string;
|
|
1323
|
+
subPath?: string | null;
|
|
1324
|
+
imageGalleryPath?: string | null;
|
|
1325
|
+
type?: string;
|
|
1326
|
+
imagePath?: string;
|
|
1327
|
+
ratio?: number;
|
|
1328
|
+
rows?: number;
|
|
1329
|
+
value?: unknown;
|
|
1330
|
+
payload?: unknown;
|
|
1331
|
+
[key: string]: unknown;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
export interface IntegrationAdapter<TData = any> {
|
|
1335
|
+
/** What `resolver` returned. */
|
|
1336
|
+
data: TData;
|
|
1337
|
+
/** The dialog for a field under the integration (`null` without an integration binding). */
|
|
1338
|
+
dialog: (subPath: string, options?: Record<string, unknown>, value?: unknown) => IntegrationDialog | null;
|
|
1339
|
+
/** `getDialogProps` of that dialog: spread onto the element that renders the field. */
|
|
1340
|
+
dialogProps: (subPath: string, options?: Record<string, unknown>, value?: unknown) => DialogBindingProps;
|
|
1341
|
+
galleryPath: string | null;
|
|
1342
|
+
/** The integration instance the page is bound to. */
|
|
1343
|
+
instanceId: string | null;
|
|
1344
|
+
integration: unknown;
|
|
1225
1345
|
[key: string]: unknown;
|
|
1226
1346
|
}
|
|
1227
1347
|
|
|
@@ -1277,7 +1397,7 @@ export const EditorShell: {
|
|
|
1277
1397
|
PageEditor: ComponentType<PageEditorProps>;
|
|
1278
1398
|
InteractiveModeProvider: ComponentType<InteractiveModeProviderProps>;
|
|
1279
1399
|
useInteractive: () => InteractiveModeContextValue;
|
|
1280
|
-
useIntegrationAdapter: (config: IntegrationAdapterConfig) => IntegrationAdapter
|
|
1400
|
+
useIntegrationAdapter: <TData = any>(config: IntegrationAdapterConfig) => IntegrationAdapter<TData>;
|
|
1281
1401
|
/**
|
|
1282
1402
|
* Document-level options for top-level payload keys, defined and drawn as page options are. A
|
|
1283
1403
|
* choice is an edit in the uhuu document editor. Joins the nearest InteractiveModeProvider's
|
|
@@ -1359,7 +1479,31 @@ export interface StaticCoverSpreadProps {
|
|
|
1359
1479
|
export interface StaticPaginationProps {
|
|
1360
1480
|
children: ReactNode;
|
|
1361
1481
|
className?: string;
|
|
1362
|
-
setup:
|
|
1482
|
+
setup: StaticPageSetup;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
/**
|
|
1486
|
+
* A page setup (`Static.Pagination` `setup`, `PageEditor` `pageFormat`), in mm. `format`
|
|
1487
|
+
* (`"A4"`, `"LETTER"`, …) with `orientation`, or `width` and `height`; a custom size outside
|
|
1488
|
+
* 10–4000 mm falls back to A4.
|
|
1489
|
+
*/
|
|
1490
|
+
export interface StaticPageSetup {
|
|
1491
|
+
format?: string;
|
|
1492
|
+
// `string & {}`: suggestions for the known values without rejecting a string variable.
|
|
1493
|
+
orientation?: "portrait" | "landscape" | (string & {});
|
|
1494
|
+
width?: number;
|
|
1495
|
+
height?: number;
|
|
1496
|
+
bleed?: number;
|
|
1497
|
+
/** Draws the bleed and trim guides on screen. */
|
|
1498
|
+
showBleed?: boolean;
|
|
1499
|
+
/** `single_page` (default) or `two_pages` (facing pages side by side). */
|
|
1500
|
+
preview?: "single_page" | "two_pages" | (string & {});
|
|
1501
|
+
/** A print stylesheet URL, or its CSS text, added for printing. */
|
|
1502
|
+
printCssUrl?: string;
|
|
1503
|
+
printCssRaw?: string;
|
|
1504
|
+
/** Perfect-binding spine/glue, for a cover spread. */
|
|
1505
|
+
binding?: BindingConfig | null;
|
|
1506
|
+
[key: string]: unknown;
|
|
1363
1507
|
}
|
|
1364
1508
|
|
|
1365
1509
|
export interface StaticFlowAreaProps {
|
|
@@ -1377,11 +1521,18 @@ export interface StaticFlowAreaProps {
|
|
|
1377
1521
|
* Room kept free at the bottom of every sheet the flow continues from, so a break never sits on
|
|
1378
1522
|
* the sheet's edge; the sheet the flow ends on keeps its full area, and a flow that fits one
|
|
1379
1523
|
* sheet lays out as without it. A CSS length with an absolute unit (`"20mm"`, `"12px"`) or a
|
|
1380
|
-
* number of px
|
|
1524
|
+
* number of px (not mm: write `"20mm"`); any other value keeps no room and warns. `Static.FlowColumns`
|
|
1525
|
+
* does not keep it.
|
|
1381
1526
|
*/
|
|
1382
1527
|
breakReserve?: number | string;
|
|
1383
1528
|
}
|
|
1384
1529
|
|
|
1530
|
+
/**
|
|
1531
|
+
* What the pages are drawn for: `print`, the document as it prints, or `screen`, the document read
|
|
1532
|
+
* on screen (`PageEditor` `view`).
|
|
1533
|
+
*/
|
|
1534
|
+
export type StaticView = "print" | "screen";
|
|
1535
|
+
|
|
1385
1536
|
export interface StaticFlowPageProps {
|
|
1386
1537
|
children: ReactNode;
|
|
1387
1538
|
header?: ReactNode;
|
|
@@ -1397,18 +1548,26 @@ export interface StaticFlowPageProps {
|
|
|
1397
1548
|
breakReserve?: number | string;
|
|
1398
1549
|
}
|
|
1399
1550
|
|
|
1400
|
-
|
|
1551
|
+
/**
|
|
1552
|
+
* `TType`: the item types `metaDefaults` keys and `getItemType` returns, so a misspelled type key is
|
|
1553
|
+
* a type error (`Static.Flow<Row, "heading" | "row">`). Default: any string.
|
|
1554
|
+
*/
|
|
1555
|
+
export interface StaticFlowProps<TItem = unknown, TType extends string = string> {
|
|
1556
|
+
/** Stable and unique within the page. */
|
|
1401
1557
|
id: string;
|
|
1402
1558
|
items: TItem[];
|
|
1403
1559
|
getKey: (item: TItem, index: number) => Key;
|
|
1560
|
+
/** The third argument describes this item's visible fragment (page, position, split piece). */
|
|
1404
1561
|
renderItem: (
|
|
1405
1562
|
item: TItem,
|
|
1406
1563
|
index: number,
|
|
1407
1564
|
fragment: StaticFlowFragmentContext<TItem>
|
|
1408
1565
|
) => ReactNode;
|
|
1409
1566
|
getItemMeta?: (item: TItem, index: number) => StaticFlowItemMeta | undefined;
|
|
1410
|
-
|
|
1411
|
-
|
|
1567
|
+
/** Meta per item type, under `getItemMeta`; the type is `getItemType`'s, else `item.type`. */
|
|
1568
|
+
metaDefaults?: Partial<Record<TType, StaticFlowItemMeta>>;
|
|
1569
|
+
getItemType?: (item: TItem, index: number) => TType | undefined;
|
|
1570
|
+
/** Opt into a separately measured, repeatable group header (`renderGroupHeader`). */
|
|
1412
1571
|
getItemGroup?: (
|
|
1413
1572
|
item: TItem,
|
|
1414
1573
|
index: number
|
|
@@ -1467,7 +1626,7 @@ export interface StaticFlowColumnsContainerProps {
|
|
|
1467
1626
|
style?: CSSProperties;
|
|
1468
1627
|
}
|
|
1469
1628
|
|
|
1470
|
-
export interface StaticFlowColumnsProps<TItem = unknown> extends StaticFlowProps<TItem> {
|
|
1629
|
+
export interface StaticFlowColumnsProps<TItem = unknown, TType extends string = string> extends StaticFlowProps<TItem, TType> {
|
|
1471
1630
|
/** One-level story layout. Recursive columns are intentionally unsupported. */
|
|
1472
1631
|
layout: StaticFlowLayoutNode[];
|
|
1473
1632
|
getColumnGroupProps?: (
|
|
@@ -1503,6 +1662,7 @@ export type MarkdownFlowItem = {
|
|
|
1503
1662
|
};
|
|
1504
1663
|
|
|
1505
1664
|
export interface StaticFlowDocumentProps {
|
|
1665
|
+
/** Rendered HTML to paginate. Convert markdown or Notion content to HTML first. */
|
|
1506
1666
|
html: string;
|
|
1507
1667
|
header?: ReactNode;
|
|
1508
1668
|
footer?: ReactNode;
|
|
@@ -1514,15 +1674,27 @@ export interface StaticFlowDocumentProps {
|
|
|
1514
1674
|
measureContinuation?: boolean;
|
|
1515
1675
|
/** See `StaticFlowAreaProps.breakReserve`. */
|
|
1516
1676
|
breakReserve?: number | string;
|
|
1677
|
+
/** Stable flow id within the page. Default `"flow-document"`. */
|
|
1517
1678
|
id?: string;
|
|
1518
1679
|
idPrefix?: string;
|
|
1519
1680
|
flowClassName?: string;
|
|
1520
1681
|
itemClassName?: string | ((item: HtmlFlowItem, index: number) => string | undefined);
|
|
1682
|
+
/**
|
|
1683
|
+
* Break meta per tag, merged over the built-in defaults (shallow, by tag): headings keep with
|
|
1684
|
+
* the next block; `table`, lists, `pre`, `blockquote`, `figure` and `img` avoid breaking inside.
|
|
1685
|
+
*/
|
|
1521
1686
|
metaDefaults?: Partial<Record<string, StaticFlowItemMeta>>;
|
|
1522
1687
|
getItemMeta?: (item: HtmlFlowItem, index: number) => StaticFlowItemMeta | undefined;
|
|
1688
|
+
/** Replaces the default renderer of sanitized HTML (to map HTML to your own components). */
|
|
1523
1689
|
renderItem?: (item: HtmlFlowItem, index: number) => ReactNode;
|
|
1690
|
+
/**
|
|
1691
|
+
* The sanitizer the default renderer applies. Default: the built-in DOM URL allow-list. Pass your
|
|
1692
|
+
* own (DOMPurify), or `false` only for trusted HTML (development warns once).
|
|
1693
|
+
*/
|
|
1524
1694
|
sanitize?: ((html: string) => string) | false;
|
|
1695
|
+
/** Wraps the body in an `Editable` with this dialog, so a click edits the HTML. */
|
|
1525
1696
|
editable?: { path: string; type?: string; [key: string]: unknown };
|
|
1697
|
+
/** A parser to use without a DOM (server rendering, tests). Default: the DOM parser. */
|
|
1526
1698
|
parseHtml?: (html: string) => unknown[];
|
|
1527
1699
|
}
|
|
1528
1700
|
|
|
@@ -1598,8 +1770,8 @@ export const Static: {
|
|
|
1598
1770
|
Sheet: ComponentType<StaticSheetProps>;
|
|
1599
1771
|
FlowArea: ComponentType<StaticFlowAreaProps>;
|
|
1600
1772
|
FlowPage: ComponentType<StaticFlowPageProps>;
|
|
1601
|
-
Flow: <TItem = unknown>(props: StaticFlowProps<TItem>) => ReactElement | null;
|
|
1602
|
-
FlowColumns: <TItem = unknown>(props: StaticFlowColumnsProps<TItem>) => ReactElement | null;
|
|
1773
|
+
Flow: <TItem = unknown, TType extends string = string>(props: StaticFlowProps<TItem, TType>) => ReactElement | null;
|
|
1774
|
+
FlowColumns: <TItem = unknown, TType extends string = string>(props: StaticFlowColumnsProps<TItem, TType>) => ReactElement | null;
|
|
1603
1775
|
/**
|
|
1604
1776
|
* Text a `Static.Flow` item may split between lines when it does not fit the room left on its
|
|
1605
1777
|
* sheet (one per item; `orphans`/`widows` in the item's meta). Renders `<as data-uhuu-flow-text>`.
|
|
@@ -1633,4 +1805,10 @@ export const Static: {
|
|
|
1633
1805
|
* stops waiting.
|
|
1634
1806
|
*/
|
|
1635
1807
|
usePaginationHold: (pending?: boolean, label?: string) => void;
|
|
1808
|
+
/**
|
|
1809
|
+
* The view the pages are drawn for (`PageEditor` `view`): `print` or `screen`. Outside a
|
|
1810
|
+
* PageEditor, and always in the renderer, `print`. A template keeps content whole on screen that
|
|
1811
|
+
* print splits across pages (a table's rows), and gives such an item meta `growSheet`.
|
|
1812
|
+
*/
|
|
1813
|
+
useView: () => StaticView;
|
|
1636
1814
|
};
|
package/package.json
CHANGED