uhuu-components 0.3.9 → 0.3.11
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 +90 -0
- package/package.json +1 -1
- package/uhuu-components.es.js +4256 -3710
- package/uhuu-components.es.js.map +1 -1
- package/uhuu-components.umd.cjs +25 -21
- package/uhuu-components.umd.cjs.map +1 -1
package/index.d.ts
CHANGED
|
@@ -14,10 +14,53 @@ export interface StaticFlowItemMeta {
|
|
|
14
14
|
breakBefore?: boolean;
|
|
15
15
|
breakAfter?: boolean;
|
|
16
16
|
keepWithNext?: boolean | number;
|
|
17
|
+
/** Never split the item; with `groupKey`, also move its avoid-break group as one. */
|
|
17
18
|
avoidBreakInside?: boolean;
|
|
18
19
|
groupKey?: string;
|
|
20
|
+
/** An item split between the lines of its `Static.FlowText`: fewest lines on a piece that ends a page. Default 2. */
|
|
21
|
+
orphans?: number;
|
|
22
|
+
/** An item split between the lines of its `Static.FlowText`: fewest lines on the piece that starts the next page. Default 2. */
|
|
23
|
+
widows?: number;
|
|
19
24
|
}
|
|
20
25
|
|
|
26
|
+
/**
|
|
27
|
+
* The lines of an item's `Static.FlowText` (`Static.flowMeasure.readFlowTextLines`), in layout px
|
|
28
|
+
* from the item's measured origin: each line box's top and bottom, and the UTF-16 text offset
|
|
29
|
+
* (across the FlowText's text nodes in order) where it starts. `end`: the text's length.
|
|
30
|
+
*/
|
|
31
|
+
export interface StaticFlowItemLines {
|
|
32
|
+
/** `hyphen`: the line ends with a hyphen the browser drew (`hyphens: auto`, a soft hyphen). */
|
|
33
|
+
lines: Array<{ top: number; bottom: number; start: number; hyphen?: boolean }>;
|
|
34
|
+
end: number;
|
|
35
|
+
justify: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** One piece of an item split between the lines of its `Static.FlowText`. */
|
|
39
|
+
export interface StaticFlowTextSplit {
|
|
40
|
+
/** 0-based piece number. */
|
|
41
|
+
part: number;
|
|
42
|
+
parts: number;
|
|
43
|
+
/** The piece's text: UTF-16 offsets `[from, to)` across the FlowText's text. */
|
|
44
|
+
from: number;
|
|
45
|
+
to: number;
|
|
46
|
+
/** Justified text: a piece that ends mid-paragraph justifies its last line too. */
|
|
47
|
+
justify?: boolean;
|
|
48
|
+
/** The planned height of the piece's lines, in layout px. */
|
|
49
|
+
textHeight?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Text offsets where the piece's measured lines broke with a hyphen (`hyphens: auto`, a soft
|
|
52
|
+
* hyphen), its own end included: the piece breaks there again, and ends with a hyphen there.
|
|
53
|
+
*/
|
|
54
|
+
hyphens?: number[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Why an item's FlowText cannot split, or splits but may not match its plan. */
|
|
58
|
+
export type StaticFlowTextIssue =
|
|
59
|
+
| "multiple-flow-text"
|
|
60
|
+
| "inline-flow-text"
|
|
61
|
+
| "unsupported-content"
|
|
62
|
+
| "rewrapping-text-wrap";
|
|
63
|
+
|
|
21
64
|
/** A separately measured group whose header may repeat on virtual continuation pages. */
|
|
22
65
|
export interface StaticFlowItemGroup {
|
|
23
66
|
key: string;
|
|
@@ -42,6 +85,11 @@ export interface StaticFlowFragmentContext<TItem = unknown> {
|
|
|
42
85
|
isContinuation: boolean;
|
|
43
86
|
/** The group resumed from the preceding virtual page. */
|
|
44
87
|
isGroupContinuation: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Present on every piece of an item split between the lines of its `Static.FlowText`; absent for
|
|
90
|
+
* an item rendered whole and in the measurement copy, which renders the whole item.
|
|
91
|
+
*/
|
|
92
|
+
split?: { part: number; parts: number; from: number; to: number };
|
|
45
93
|
}
|
|
46
94
|
|
|
47
95
|
export interface StaticFlowUnplaceableItem {
|
|
@@ -79,6 +127,8 @@ export interface StaticFlowChunk {
|
|
|
79
127
|
groupHeaders?: StaticFlowGroupHeaderFragment[];
|
|
80
128
|
unplaceable?: StaticFlowUnplaceableItem;
|
|
81
129
|
layout?: StaticFlowLayoutFragment[];
|
|
130
|
+
/** The pieces of items split between lines on this page, by item index. */
|
|
131
|
+
splits?: Record<number, StaticFlowTextSplit>;
|
|
82
132
|
}
|
|
83
133
|
|
|
84
134
|
export interface StaticFlowColumn {
|
|
@@ -153,6 +203,22 @@ export interface StaticFlowMeasureApi {
|
|
|
153
203
|
readFlowItemElements: (root: HTMLElement) => HTMLElement[];
|
|
154
204
|
parseKeepWithNext: (value: string | undefined) => boolean | number;
|
|
155
205
|
serializeKeepWithNext: (value: StaticFlowItemMeta['keepWithNext']) => string | undefined;
|
|
206
|
+
/** `orphans` / `widows` attribute values: a positive whole number, else `undefined`. */
|
|
207
|
+
parseLineCount: (value: string | undefined) => number | undefined;
|
|
208
|
+
serializeLineCount: (value: number | undefined) => string | undefined;
|
|
209
|
+
/** The `Static.FlowText` elements of `item` itself (not those of a Flow nested in it). */
|
|
210
|
+
readItemFlowTexts: (item: HTMLElement) => HTMLElement[];
|
|
211
|
+
/**
|
|
212
|
+
* The lines of the one `Static.FlowText` in a measured item, for `planFlowChunks({ lines })`, or
|
|
213
|
+
* `undefined` when it has none or cannot split (`report` says why). `height` is the item's
|
|
214
|
+
* measured height (`getOuterHeight`, or `readUnwrappedHeights` for `asChild`).
|
|
215
|
+
*/
|
|
216
|
+
readFlowTextLines: (
|
|
217
|
+
item: HTMLElement,
|
|
218
|
+
height: number,
|
|
219
|
+
scale?: number,
|
|
220
|
+
report?: (issue: StaticFlowTextIssue, element: HTMLElement) => void
|
|
221
|
+
) => StaticFlowItemLines | undefined;
|
|
156
222
|
/** FNV-1a. For opaque change-detection tokens compared only for equality. */
|
|
157
223
|
hashString: (value: string) => string;
|
|
158
224
|
}
|
|
@@ -171,6 +237,12 @@ export interface StaticFlowPlanInput {
|
|
|
171
237
|
headerGroupRepeats?: Record<string, boolean>;
|
|
172
238
|
onUnplaceableItem?: (item: StaticFlowUnplaceableItem) => void;
|
|
173
239
|
metrics?: StaticFlowPlanMetrics;
|
|
240
|
+
/**
|
|
241
|
+
* Line metrics per item (`flowMeasure.readFlowTextLines`); `undefined` for items that do not
|
|
242
|
+
* split. An item that does not fit the room left is split at a line (chunks gain `splits`).
|
|
243
|
+
* Without `lines` the plan is item-level. `planFlowColumnChunks` does not split.
|
|
244
|
+
*/
|
|
245
|
+
lines?: Array<StaticFlowItemLines | undefined>;
|
|
174
246
|
}
|
|
175
247
|
|
|
176
248
|
/** Input for `Static.planFlowColumnChunks`, using globally indexed leaf measurements. */
|
|
@@ -854,6 +926,19 @@ export interface StaticFlowProps<TItem = unknown> {
|
|
|
854
926
|
as?: keyof HTMLElementTagNameMap;
|
|
855
927
|
}
|
|
856
928
|
|
|
929
|
+
export interface StaticFlowTextProps {
|
|
930
|
+
/**
|
|
931
|
+
* A string (may contain `\n`) or inline content: text, `span`, `strong`, `em`, `b`, `i`, `a`,
|
|
932
|
+
* `small`, `sub`, `sup`, `br` (and other inline text elements) and fragments. Anything else
|
|
933
|
+
* renders, with a development warning, but its item is not split.
|
|
934
|
+
*/
|
|
935
|
+
children?: ReactNode;
|
|
936
|
+
/** Default `div`: a block, so its line boxes are its own. */
|
|
937
|
+
as?: keyof HTMLElementTagNameMap;
|
|
938
|
+
className?: string;
|
|
939
|
+
style?: CSSProperties;
|
|
940
|
+
}
|
|
941
|
+
|
|
857
942
|
export interface StaticFlowColumnsRenderContext {
|
|
858
943
|
/** Stable identity only: column geometry callbacks must be page-invariant. */
|
|
859
944
|
flowId: string;
|
|
@@ -1000,6 +1085,11 @@ export const Static: {
|
|
|
1000
1085
|
FlowPage: ComponentType<StaticFlowPageProps>;
|
|
1001
1086
|
Flow: <TItem = unknown>(props: StaticFlowProps<TItem>) => ReactElement | null;
|
|
1002
1087
|
FlowColumns: <TItem = unknown>(props: StaticFlowColumnsProps<TItem>) => ReactElement | null;
|
|
1088
|
+
/**
|
|
1089
|
+
* Text a `Static.Flow` item may split between lines when it does not fit the room left on its
|
|
1090
|
+
* sheet (one per item; `orphans`/`widows` in the item's meta). Renders `<as data-uhuu-flow-text>`.
|
|
1091
|
+
*/
|
|
1092
|
+
FlowText: ComponentType<StaticFlowTextProps>;
|
|
1003
1093
|
planFlowChunks: (input?: StaticFlowPlanInput) => StaticFlowChunk[];
|
|
1004
1094
|
planFlowColumnChunks: (input?: StaticFlowColumnPlanInput) => StaticFlowChunk[];
|
|
1005
1095
|
createFlowPlanMetrics: () => StaticFlowPlanMetrics;
|
package/package.json
CHANGED