uhuu-components 0.2.78 → 0.2.80

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 CHANGED
@@ -17,6 +17,82 @@ export interface StaticFlowItemMeta {
17
17
  groupKey?: string;
18
18
  }
19
19
 
20
+ /** A separately measured group whose header may repeat on virtual continuation pages. */
21
+ export interface StaticFlowItemGroup {
22
+ key: string;
23
+ repeatHeader?: boolean;
24
+ }
25
+
26
+ export interface StaticFlowFragmentContext<TItem = unknown> {
27
+ flowId: string;
28
+ pageIndex: number;
29
+ pageCount: number;
30
+ itemIndex: number;
31
+ itemKey: Key;
32
+ item: TItem;
33
+ groupKey?: string;
34
+ isFirst: boolean;
35
+ isLast: boolean;
36
+ isFirstInFragment: boolean;
37
+ isLastInFragment: boolean;
38
+ isFirstInGroup: boolean;
39
+ isFirstInGroupOnPage: boolean;
40
+ /** The item is on a continuation page of the Flow. */
41
+ isContinuation: boolean;
42
+ /** The group resumed from the preceding virtual page. */
43
+ isGroupContinuation: boolean;
44
+ }
45
+
46
+ export interface StaticFlowUnplaceableItem {
47
+ index: number;
48
+ key: string;
49
+ height: number;
50
+ headerHeight: number;
51
+ requiredHeight: number;
52
+ availableHeight: number;
53
+ groupKey?: string;
54
+ reason: "item-too-tall" | "item-with-header-too-tall";
55
+ }
56
+
57
+ export interface StaticFlowUnplaceableContext {
58
+ flowId: string;
59
+ pageIndex: number;
60
+ pageCount: number;
61
+ }
62
+
63
+ /** A repeatable group-header insertion point in one measured flow chunk. */
64
+ export interface StaticFlowGroupHeaderFragment {
65
+ groupKey: string;
66
+ itemIndex: number;
67
+ isContinuation: boolean;
68
+ }
69
+
70
+ export interface StaticFlowChunk {
71
+ indexes: number[];
72
+ keys: string[];
73
+ groupHeaders?: StaticFlowGroupHeaderFragment[];
74
+ unplaceable?: StaticFlowUnplaceableItem;
75
+ }
76
+
77
+ export interface StaticFlowMeasurement {
78
+ flowId: string;
79
+ chunks: StaticFlowChunk[];
80
+ signature: string;
81
+ unplaceableItems?: StaticFlowUnplaceableItem[];
82
+ }
83
+
84
+ /** Input for `Static.planFlowChunks`, using heights measured by the consumer. */
85
+ export interface StaticFlowPlanInput {
86
+ heights?: number[];
87
+ keys?: string[];
88
+ metas?: StaticFlowItemMeta[];
89
+ availableHeight?: number;
90
+ headerGroupKeys?: Array<string | null | undefined>;
91
+ headerGroupHeights?: Record<string, number>;
92
+ headerGroupRepeats?: Record<string, boolean>;
93
+ onUnplaceableItem?: (item: StaticFlowUnplaceableItem) => void;
94
+ }
95
+
20
96
  export interface ImageBlockDialog {
21
97
  path: string;
22
98
  type: "image" | "satellite";
@@ -195,6 +271,7 @@ export interface StaticFlowAreaProps {
195
271
  children: ReactNode;
196
272
  className?: string;
197
273
  style?: CSSProperties;
274
+ onFlowMeasurement?: (measurement: StaticFlowMeasurement) => void;
198
275
  }
199
276
 
200
277
  export interface StaticFlowPageProps {
@@ -205,18 +282,39 @@ export interface StaticFlowPageProps {
205
282
  style?: CSSProperties;
206
283
  flowAreaClassName?: string;
207
284
  flowAreaStyle?: CSSProperties;
285
+ onFlowMeasurement?: (measurement: StaticFlowMeasurement) => void;
208
286
  }
209
287
 
210
288
  export interface StaticFlowProps<TItem = unknown> {
211
289
  id: string;
212
290
  items: TItem[];
213
291
  getKey: (item: TItem, index: number) => Key;
214
- renderItem: (item: TItem, index: number) => ReactNode;
292
+ renderItem: (
293
+ item: TItem,
294
+ index: number,
295
+ fragment: StaticFlowFragmentContext<TItem>
296
+ ) => ReactNode;
215
297
  getItemMeta?: (item: TItem, index: number) => StaticFlowItemMeta | undefined;
216
298
  metaDefaults?: Partial<Record<string, StaticFlowItemMeta>>;
217
299
  getItemType?: (item: TItem, index: number) => string | undefined;
300
+ getItemGroup?: (
301
+ item: TItem,
302
+ index: number
303
+ ) => StaticFlowItemGroup | string | null | undefined;
304
+ renderGroupHeader?: (
305
+ group: StaticFlowItemGroup,
306
+ fragment: StaticFlowFragmentContext<TItem>
307
+ ) => ReactNode;
218
308
  className?: string;
219
309
  itemClassName?: string | ((item: TItem, index: number) => string | undefined);
310
+ groupHeaderClassName?: string | ((
311
+ group: StaticFlowItemGroup,
312
+ fragment: StaticFlowFragmentContext<TItem>
313
+ ) => string | undefined);
314
+ renderUnplaceableItem?: (
315
+ item: StaticFlowUnplaceableItem,
316
+ context: StaticFlowUnplaceableContext
317
+ ) => ReactNode;
220
318
  }
221
319
 
222
320
  export type HtmlFlowItem = {
@@ -252,6 +350,7 @@ export const Static: {
252
350
  FlowArea: ComponentType<StaticFlowAreaProps>;
253
351
  FlowPage: ComponentType<StaticFlowPageProps>;
254
352
  Flow: <TItem = unknown>(props: StaticFlowProps<TItem>) => ReactElement | null;
353
+ planFlowChunks: (input?: StaticFlowPlanInput) => StaticFlowChunk[];
255
354
  FlowDocument: ComponentType<StaticFlowDocumentProps>;
256
355
  markdownToFlowItems: (
257
356
  markdown?: string,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.78",
2
+ "version": "0.2.80",
3
3
  "name": "uhuu-components",
4
4
  "main": "uhuu-components.umd.js",
5
5
  "module": "uhuu-components.es.js",