@dloizides/ui-layout 1.36.1 → 1.38.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
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.37.0
4
+
5
+ INVOICE-FU-9 "INVOICE-5 shared look leftovers", AC-PAGE-1.
6
+
7
+ - New `PageFrame`: lays children out at a fixed page size (`A4_PAGE` 794x1123 by default, `pageSize` configurable) and scales the page down to the container width, never up, so line breaks match the printed page.
8
+ - New `pageScale` / `scaledFrame` helpers for the scale math.
9
+
3
10
  ## 1.34.0
4
11
 
5
12
  INVOICE-3 "Invoice interface over a user-chosen folder": extracted from invoice-web.
package/dist/index.d.mts CHANGED
@@ -119,6 +119,33 @@ declare function isKeyboardOpen(visibleHeight: number, tallestHeight: number): b
119
119
  /** Tracks the Visual Viewport offset and keyboard state; stays at its initial value where the API is absent. */
120
120
  declare function useVisibleViewport(): VisibleViewport;
121
121
 
122
+ interface PageSize {
123
+ width: number;
124
+ height: number;
125
+ }
126
+ interface ScaledFrame {
127
+ scale: number;
128
+ height: number;
129
+ offsetX: number;
130
+ offsetY: number;
131
+ }
132
+ /** A4 at 96 CSS px per inch: 210 x 297 mm. */
133
+ declare const A4_PAGE: PageSize;
134
+ /** The factor that fits a page of `pageWidth` into `containerWidth`, never above 1; 1 while unmeasured. */
135
+ declare const pageScale: (containerWidth: number, pageWidth: number) => number;
136
+ /** The scale, outer height and the offsets that pin a centre-scaled page to the top-left corner. */
137
+ declare const scaledFrame: (containerWidth: number, page: PageSize) => ScaledFrame;
138
+
139
+ interface PageFrameProps {
140
+ children: React.ReactNode;
141
+ pageSize?: PageSize;
142
+ testID?: string;
143
+ /** When true, a press or Enter on the preview opens the page at full size in an overlay. */
144
+ enlargeable?: boolean;
145
+ }
146
+ /** Lays children out at a fixed page size and scales the page down to the container width, never up. */
147
+ declare const PageFrame: ({ children, pageSize, testID, enlargeable, }: PageFrameProps) => React.ReactElement;
148
+
122
149
  /**
123
150
  * SegmentedControl — a single rounded pill *track* holding N mutually-exclusive segments
124
151
  * (the iOS-style segmented / tab toggle). The selected segment lifts onto a raised surface
@@ -412,8 +439,9 @@ declare const ModalShell: ({ visible, onCancel, title, children, contentStyle, s
412
439
  * - `sm` — compact confirmations / short forms.
413
440
  * - `md` (default) — the general dialog.
414
441
  * - `lg` — wide editors.
442
+ * - `xl` — a full document page (an A4 sheet at scale 1).
415
443
  */
416
- type ModalSize = 'sm' | 'md' | 'lg';
444
+ type ModalSize = 'sm' | 'md' | 'lg' | 'xl';
417
445
 
418
446
  /**
419
447
  * Modal — a themed, CENTERED dialog overlay for RN + RN-web.
@@ -843,6 +871,7 @@ declare const LAYOUT_TEST_IDS: {
843
871
  readonly headingText: "heading-text";
844
872
  readonly statusLabel: "status-label";
845
873
  readonly stickyPreview: "sticky-preview";
874
+ readonly pageFrame: "page-frame";
846
875
  readonly upgradePrompt: "upgrade-prompt";
847
876
  readonly upgradePromptCta: "upgrade-prompt-cta";
848
877
  readonly upgradePromptDismiss: "upgrade-prompt-dismiss";
@@ -899,6 +928,9 @@ declare const LAYOUT_I18N: {
899
928
  readonly closeHeading: "close";
900
929
  /** `Modal`: accessible name + web tooltip of the top-right ✕ close button. */
901
930
  readonly dialogClose: "common.close";
931
+ /** `PageFrame` (`enlargeable`): accessible name + hint of the preview that opens the full-size page. */
932
+ readonly pageEnlarge: "common.pageEnlarge";
933
+ readonly pageEnlargeHint: "common.pageEnlargeHint";
902
934
  /** `ConfirmDialog`: default Confirm button label (overridable via `confirmLabel`) + its hint. */
903
935
  readonly confirm: "common.confirm";
904
936
  readonly confirmHint: "common.confirmHint";
@@ -1017,4 +1049,4 @@ interface RowLook {
1017
1049
  /** Resolves a row's container style and text colours from its selected style and state. */
1018
1050
  declare function resolveRowLook(style: RowSelectedStyle, state: RowState, palette: RowPalette): RowLook;
1019
1051
 
1020
- export { API_COMMIT_SEPARATOR, Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, AppText, type AppTextProps, BUILD_INFO_PREFIX, BuildInfoFooter, type BuildInfoFooterProps, COPY_FEEDBACK_MS, ConfirmDialog, type ConfirmDialogProps, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingLevel, type HeadingProps, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListRow, type ListRowProps, type ListRowTone, MIN_TARGET_PX, Modal, ModalDropdown, type ModalDropdownProps, type ModalProps, ModalShell, type ModalShellProps, type ModalSize, type RowLook, type RowPalette, RowSelectedStyle, type RowState, ScreenColumn, type ScreenColumnProps, Section, type SectionProps, SectionVariant, SegmentedControl, type SegmentedControlProps, type SegmentedOption, SelectedMarker, StatusBadge, type StatusBadgeProps, StickyPreview, type StickyPreviewProps, TYPE_SCALE_BREAKPOINT, type TabDescriptor, Tabs, TabsCollapsedTrigger, type TabsProps, TextKind, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, type VersionResponse, type VisibleViewport, copyText, formatBuildInfo, formatUrlForDisplay, isKeyboardOpen, isWideWebViewport, resolveRowLook, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useVisibleViewport };
1052
+ export { A4_PAGE, API_COMMIT_SEPARATOR, Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, AppText, type AppTextProps, BUILD_INFO_PREFIX, BuildInfoFooter, type BuildInfoFooterProps, COPY_FEEDBACK_MS, ConfirmDialog, type ConfirmDialogProps, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingLevel, type HeadingProps, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListRow, type ListRowProps, type ListRowTone, MIN_TARGET_PX, Modal, ModalDropdown, type ModalDropdownProps, type ModalProps, ModalShell, type ModalShellProps, type ModalSize, PageFrame, type PageFrameProps, type PageSize, type RowLook, type RowPalette, RowSelectedStyle, type RowState, type ScaledFrame, ScreenColumn, type ScreenColumnProps, Section, type SectionProps, SectionVariant, SegmentedControl, type SegmentedControlProps, type SegmentedOption, SelectedMarker, StatusBadge, type StatusBadgeProps, StickyPreview, type StickyPreviewProps, TYPE_SCALE_BREAKPOINT, type TabDescriptor, Tabs, TabsCollapsedTrigger, type TabsProps, TextKind, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, type VersionResponse, type VisibleViewport, copyText, formatBuildInfo, formatUrlForDisplay, isKeyboardOpen, isWideWebViewport, pageScale, resolveRowLook, scaledFrame, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useVisibleViewport };
package/dist/index.d.ts CHANGED
@@ -119,6 +119,33 @@ declare function isKeyboardOpen(visibleHeight: number, tallestHeight: number): b
119
119
  /** Tracks the Visual Viewport offset and keyboard state; stays at its initial value where the API is absent. */
120
120
  declare function useVisibleViewport(): VisibleViewport;
121
121
 
122
+ interface PageSize {
123
+ width: number;
124
+ height: number;
125
+ }
126
+ interface ScaledFrame {
127
+ scale: number;
128
+ height: number;
129
+ offsetX: number;
130
+ offsetY: number;
131
+ }
132
+ /** A4 at 96 CSS px per inch: 210 x 297 mm. */
133
+ declare const A4_PAGE: PageSize;
134
+ /** The factor that fits a page of `pageWidth` into `containerWidth`, never above 1; 1 while unmeasured. */
135
+ declare const pageScale: (containerWidth: number, pageWidth: number) => number;
136
+ /** The scale, outer height and the offsets that pin a centre-scaled page to the top-left corner. */
137
+ declare const scaledFrame: (containerWidth: number, page: PageSize) => ScaledFrame;
138
+
139
+ interface PageFrameProps {
140
+ children: React.ReactNode;
141
+ pageSize?: PageSize;
142
+ testID?: string;
143
+ /** When true, a press or Enter on the preview opens the page at full size in an overlay. */
144
+ enlargeable?: boolean;
145
+ }
146
+ /** Lays children out at a fixed page size and scales the page down to the container width, never up. */
147
+ declare const PageFrame: ({ children, pageSize, testID, enlargeable, }: PageFrameProps) => React.ReactElement;
148
+
122
149
  /**
123
150
  * SegmentedControl — a single rounded pill *track* holding N mutually-exclusive segments
124
151
  * (the iOS-style segmented / tab toggle). The selected segment lifts onto a raised surface
@@ -412,8 +439,9 @@ declare const ModalShell: ({ visible, onCancel, title, children, contentStyle, s
412
439
  * - `sm` — compact confirmations / short forms.
413
440
  * - `md` (default) — the general dialog.
414
441
  * - `lg` — wide editors.
442
+ * - `xl` — a full document page (an A4 sheet at scale 1).
415
443
  */
416
- type ModalSize = 'sm' | 'md' | 'lg';
444
+ type ModalSize = 'sm' | 'md' | 'lg' | 'xl';
417
445
 
418
446
  /**
419
447
  * Modal — a themed, CENTERED dialog overlay for RN + RN-web.
@@ -843,6 +871,7 @@ declare const LAYOUT_TEST_IDS: {
843
871
  readonly headingText: "heading-text";
844
872
  readonly statusLabel: "status-label";
845
873
  readonly stickyPreview: "sticky-preview";
874
+ readonly pageFrame: "page-frame";
846
875
  readonly upgradePrompt: "upgrade-prompt";
847
876
  readonly upgradePromptCta: "upgrade-prompt-cta";
848
877
  readonly upgradePromptDismiss: "upgrade-prompt-dismiss";
@@ -899,6 +928,9 @@ declare const LAYOUT_I18N: {
899
928
  readonly closeHeading: "close";
900
929
  /** `Modal`: accessible name + web tooltip of the top-right ✕ close button. */
901
930
  readonly dialogClose: "common.close";
931
+ /** `PageFrame` (`enlargeable`): accessible name + hint of the preview that opens the full-size page. */
932
+ readonly pageEnlarge: "common.pageEnlarge";
933
+ readonly pageEnlargeHint: "common.pageEnlargeHint";
902
934
  /** `ConfirmDialog`: default Confirm button label (overridable via `confirmLabel`) + its hint. */
903
935
  readonly confirm: "common.confirm";
904
936
  readonly confirmHint: "common.confirmHint";
@@ -1017,4 +1049,4 @@ interface RowLook {
1017
1049
  /** Resolves a row's container style and text colours from its selected style and state. */
1018
1050
  declare function resolveRowLook(style: RowSelectedStyle, state: RowState, palette: RowPalette): RowLook;
1019
1051
 
1020
- export { API_COMMIT_SEPARATOR, Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, AppText, type AppTextProps, BUILD_INFO_PREFIX, BuildInfoFooter, type BuildInfoFooterProps, COPY_FEEDBACK_MS, ConfirmDialog, type ConfirmDialogProps, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingLevel, type HeadingProps, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListRow, type ListRowProps, type ListRowTone, MIN_TARGET_PX, Modal, ModalDropdown, type ModalDropdownProps, type ModalProps, ModalShell, type ModalShellProps, type ModalSize, type RowLook, type RowPalette, RowSelectedStyle, type RowState, ScreenColumn, type ScreenColumnProps, Section, type SectionProps, SectionVariant, SegmentedControl, type SegmentedControlProps, type SegmentedOption, SelectedMarker, StatusBadge, type StatusBadgeProps, StickyPreview, type StickyPreviewProps, TYPE_SCALE_BREAKPOINT, type TabDescriptor, Tabs, TabsCollapsedTrigger, type TabsProps, TextKind, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, type VersionResponse, type VisibleViewport, copyText, formatBuildInfo, formatUrlForDisplay, isKeyboardOpen, isWideWebViewport, resolveRowLook, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useVisibleViewport };
1052
+ export { A4_PAGE, API_COMMIT_SEPARATOR, Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, AppText, type AppTextProps, BUILD_INFO_PREFIX, BuildInfoFooter, type BuildInfoFooterProps, COPY_FEEDBACK_MS, ConfirmDialog, type ConfirmDialogProps, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingLevel, type HeadingProps, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListRow, type ListRowProps, type ListRowTone, MIN_TARGET_PX, Modal, ModalDropdown, type ModalDropdownProps, type ModalProps, ModalShell, type ModalShellProps, type ModalSize, PageFrame, type PageFrameProps, type PageSize, type RowLook, type RowPalette, RowSelectedStyle, type RowState, type ScaledFrame, ScreenColumn, type ScreenColumnProps, Section, type SectionProps, SectionVariant, SegmentedControl, type SegmentedControlProps, type SegmentedOption, SelectedMarker, StatusBadge, type StatusBadgeProps, StickyPreview, type StickyPreviewProps, TYPE_SCALE_BREAKPOINT, type TabDescriptor, Tabs, TabsCollapsedTrigger, type TabsProps, TextKind, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, type VersionResponse, type VisibleViewport, copyText, formatBuildInfo, formatUrlForDisplay, isKeyboardOpen, isWideWebViewport, pageScale, resolveRowLook, scaledFrame, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useVisibleViewport };