uhuu-components 0.3.8 → 0.3.10

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
@@ -137,7 +137,18 @@ export interface StaticFlowMeasureApi {
137
137
  readItemMeta: (element: HTMLElement) => StaticFlowItemMeta;
138
138
  readHeaderGroupKey: (element: HTMLElement) => string | undefined;
139
139
  readHeaderGroupRepeats: (itemElements: HTMLElement[]) => Record<string, boolean>;
140
- readHeaderGroupHeights: (root: HTMLElement, scale?: number) => Record<string, number>;
140
+ /** `unwrapped`: heights from `readUnwrappedHeights`, used for the headers it covers. */
141
+ readHeaderGroupHeights: (
142
+ root: HTMLElement,
143
+ scale?: number,
144
+ unwrapped?: ReadonlyMap<HTMLElement, number>
145
+ ) => Record<string, number>;
146
+ /**
147
+ * Heights of the items and group headers an `asChild` Flow renders as direct children of its
148
+ * root, from positions: margins collapse without a wrapper, so each item is the distance from
149
+ * the bottom of the element before it (the area's top for the first) to its own bottom.
150
+ */
151
+ readUnwrappedHeights: (area: HTMLElement, flow: HTMLElement, scale?: number) => Map<HTMLElement, number>;
141
152
  /** Every measured leaf under `root`, in document order. */
142
153
  readFlowItemElements: (root: HTMLElement) => HTMLElement[];
143
154
  parseKeepWithNext: (value: string | undefined) => boolean | number;
@@ -151,7 +162,10 @@ export interface StaticFlowPlanInput {
151
162
  heights?: number[];
152
163
  keys?: string[];
153
164
  metas?: StaticFlowItemMeta[];
165
+ /** The first page's region height. */
154
166
  availableHeight?: number;
167
+ /** The region height of every later page (`measureContinuation`). Default: `availableHeight`. */
168
+ continuationHeight?: number;
155
169
  headerGroupKeys?: Array<string | null | undefined>;
156
170
  headerGroupHeights?: Record<string, number>;
157
171
  headerGroupRepeats?: Record<string, boolean>;
@@ -538,6 +552,51 @@ export interface PageEditorState {
538
552
  [key: string]: unknown;
539
553
  }
540
554
 
555
+ /**
556
+ * The `page` a PageEditor page component receives: its page item (id, component key, saved
557
+ * page-option values) and the sheet being rendered. A `hasFlow` page renders one sheet per flow
558
+ * chunk; its continuation sheets share the page's `id`.
559
+ */
560
+ export interface PageEditorPage {
561
+ id: string;
562
+ componentKey?: string;
563
+ templateId?: string;
564
+ label?: LocalizedText;
565
+ hasFlow?: boolean;
566
+ /** The sheet's position among the page's sheets: `0` on the first, `n` on its n-th continuation. */
567
+ virtualPageIndex: number;
568
+ /**
569
+ * How many sheets the page renders: its longest flow's chunk count, `1` without flow. The last
570
+ * sheet is `virtualPageIndex === virtualPageCount - 1`. PageEditor's hidden measurement copy
571
+ * renders the logical page, `0` of `1` (the continuation copy of `measureContinuation`: `1` of
572
+ * `2`), as `totalPages` there is the logical total; see docs/static-flow-pagination.md.
573
+ */
574
+ virtualPageCount: number;
575
+ [key: string]: unknown;
576
+ }
577
+
578
+ /** The props PageEditor passes to a page component. */
579
+ export interface PageComponentProps {
580
+ payload?: Record<string, unknown>;
581
+ /** The page's own payload slot (`payload.pages[...]`). */
582
+ pagePayload?: Record<string, unknown>;
583
+ /** Integration data for this page (its group's, else its own). */
584
+ integration?: Record<string, unknown>;
585
+ pageId?: string;
586
+ templateId?: string;
587
+ componentKey?: string;
588
+ /** 1-based position in the flow-expanded document. */
589
+ pageNum?: number;
590
+ /** Sheets in the flow-expanded document. */
591
+ totalPages?: number;
592
+ page?: PageEditorPage;
593
+ parentGroup?: PageEditorItem;
594
+ /** Dialog path helpers and defaults (docs/page-data-binding.md). */
595
+ dataBinding?: Record<string, unknown>;
596
+ /** Set while the page is a panel of a perfect-binding cover spread. */
597
+ spread?: SpreadInfo;
598
+ }
599
+
541
600
  export interface PageFilterConfig {
542
601
  mode?: "all" | "cover" | "text" | "custom" | string;
543
602
  coverPageCount?: number;
@@ -732,6 +791,12 @@ export interface StaticFlowAreaProps {
732
791
  className?: string;
733
792
  style?: CSSProperties;
734
793
  onFlowMeasurement?: (measurement: StaticFlowMeasurement) => void;
794
+ /**
795
+ * Continuation sheets lay this area out at another height than the first (a title on the first
796
+ * sheet only): PageEditor also measures the page as a continuation (`page.virtualPageIndex` 1)
797
+ * and plans every later sheet with that height. Default: every sheet has the first one's height.
798
+ */
799
+ measureContinuation?: boolean;
735
800
  }
736
801
 
737
802
  export interface StaticFlowPageProps {
@@ -743,6 +808,8 @@ export interface StaticFlowPageProps {
743
808
  flowAreaClassName?: string;
744
809
  flowAreaStyle?: CSSProperties;
745
810
  onFlowMeasurement?: (measurement: StaticFlowMeasurement) => void;
811
+ /** See `StaticFlowAreaProps.measureContinuation`. */
812
+ measureContinuation?: boolean;
746
813
  }
747
814
 
748
815
  export interface StaticFlowProps<TItem = unknown> {
@@ -775,6 +842,16 @@ export interface StaticFlowProps<TItem = unknown> {
775
842
  item: StaticFlowUnplaceableItem,
776
843
  context: StaticFlowUnplaceableContext
777
844
  ) => ReactNode;
845
+ /**
846
+ * Render each item as the element `renderItem` returns, carrying the flow's attributes, class
847
+ * names and key, instead of inside a wrapper `<div>`; group headers and a custom unplaceable
848
+ * fallback too. Each callback must return one element: a DOM element, or a component that passes
849
+ * the props it receives on to its root DOM element. Anything else renders in the wrapper, with a
850
+ * development warning; items whose element drops the attributes are `unmarked-flow-item` errors.
851
+ */
852
+ asChild?: boolean;
853
+ /** The Flow's root element. Default `div`; `tbody`, `ul` or `ol` for table rows or list items. */
854
+ as?: keyof HTMLElementTagNameMap;
778
855
  }
779
856
 
780
857
  export interface StaticFlowColumnsRenderContext {
@@ -835,6 +912,8 @@ export interface StaticFlowDocumentProps {
835
912
  style?: CSSProperties;
836
913
  flowAreaClassName?: string;
837
914
  flowAreaStyle?: CSSProperties;
915
+ /** See `StaticFlowAreaProps.measureContinuation`. */
916
+ measureContinuation?: boolean;
838
917
  id?: string;
839
918
  idPrefix?: string;
840
919
  flowClassName?: string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.3.8",
2
+ "version": "0.3.10",
3
3
  "name": "uhuu-components",
4
4
  "main": "uhuu-components.umd.cjs",
5
5
  "module": "uhuu-components.es.js",