@cosmicdrift/kumiko-renderer 0.406.0 → 0.410.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.
Files changed (143) hide show
  1. package/dist/app/action-form-body.js +23 -8
  2. package/dist/app/action-form-support.d.ts +7 -0
  3. package/dist/app/action-form-support.js +14 -1
  4. package/dist/app/config-edit-action-row.d.ts +7 -0
  5. package/dist/app/config-edit-action-row.js +45 -0
  6. package/dist/app/config-edit-body.js +32 -4
  7. package/dist/app/entity-list-screen.js +8 -11
  8. package/dist/app/nav.js +2 -1
  9. package/dist/app/projection-detail-body.js +3 -1
  10. package/dist/app/projection-detail-header.d.ts +1 -0
  11. package/dist/app/projection-detail-header.js +1 -1
  12. package/dist/app/projection-detail-navigation.d.ts +2 -1
  13. package/dist/app/projection-detail-navigation.js +6 -3
  14. package/dist/app/projection-detail-shim.js +3 -1
  15. package/dist/app/projection-list-render-props.d.ts +1 -1
  16. package/dist/app/projection-list-render-props.js +4 -2
  17. package/dist/app/projection-list-render.js +1 -1
  18. package/dist/app/screen-access.js +4 -2
  19. package/dist/app/screen-shared.d.ts +3 -2
  20. package/dist/app/screen-shared.js +30 -2
  21. package/dist/app/use-embedded-screen.d.ts +2 -0
  22. package/dist/app/use-embedded-screen.js +7 -1
  23. package/dist/components/edit-mounts.d.ts +3 -1
  24. package/dist/components/edit-mounts.js +3 -3
  25. package/dist/components/related-list-section.d.ts +3 -1
  26. package/dist/components/related-list-section.js +2 -2
  27. package/dist/components/render-edit-field-grid.d.ts +2 -2
  28. package/dist/components/render-edit-field-grid.js +12 -4
  29. package/dist/components/render-edit-fields-section.js +6 -7
  30. package/dist/components/render-edit-helpers.d.ts +4 -0
  31. package/dist/components/render-edit-helpers.js +5 -0
  32. package/dist/components/render-edit-section-kinds.js +6 -4
  33. package/dist/components/render-edit-submit.js +18 -1
  34. package/dist/components/render-edit-titles.js +6 -6
  35. package/dist/components/render-edit-types.d.ts +6 -0
  36. package/dist/components/render-field-control.d.ts +2 -0
  37. package/dist/components/render-field-control.js +23 -1
  38. package/dist/components/render-field-write-only.d.ts +1 -1
  39. package/dist/components/render-field-write-only.js +12 -2
  40. package/dist/components/render-field.js +2 -1
  41. package/dist/components/use-render-edit-sections.js +4 -4
  42. package/dist/format-when.d.ts +1 -1
  43. package/dist/format-when.js +2 -2
  44. package/dist/headless/format/escape.js +3 -2
  45. package/dist/headless/view-model/edit.js +0 -2
  46. package/dist/headless/view-model/types.d.ts +0 -3
  47. package/dist/i18n-defaults.js +38 -0
  48. package/dist/index.d.ts +2 -1
  49. package/dist/index.js +1 -0
  50. package/dist/primitives.d.ts +30 -7
  51. package/dist/primitives.js +1 -51
  52. package/dist/status-tone.d.ts +6 -0
  53. package/dist/status-tone.js +51 -0
  54. package/dist/toggle-set-member.d.ts +1 -0
  55. package/dist/toggle-set-member.js +8 -0
  56. package/dist/web/app/dashboard-header.js +5 -1
  57. package/dist/web/app/dashboard-screen-tiles.js +19 -3
  58. package/dist/web/icons.d.ts +2 -0
  59. package/dist/web/icons.js +3 -1
  60. package/dist/web/index.d.ts +3 -2
  61. package/dist/web/index.js +2 -1
  62. package/dist/web/layout/default-app-shell.d.ts +4 -1
  63. package/dist/web/layout/default-app-shell.js +5 -2
  64. package/dist/web/layout/focus-aware-sidebar.d.ts +27 -0
  65. package/dist/web/layout/focus-aware-sidebar.js +23 -0
  66. package/dist/web/layout/focus-rail.d.ts +16 -0
  67. package/dist/web/layout/focus-rail.js +61 -0
  68. package/dist/web/layout/nav-tree.d.ts +2 -1
  69. package/dist/web/layout/nav-tree.js +3 -9
  70. package/dist/web/layout/shell-focus.d.ts +19 -0
  71. package/dist/web/layout/shell-focus.js +35 -0
  72. package/dist/web/layout/shell-header.d.ts +1 -1
  73. package/dist/web/layout/shell-header.js +12 -9
  74. package/dist/web/layout/sidebar-brand.js +1 -1
  75. package/dist/web/layout/workspace-shell.d.ts +4 -1
  76. package/dist/web/layout/workspace-shell.js +5 -2
  77. package/dist/web/primitives/banner.js +3 -1
  78. package/dist/web/primitives/data-table/toolbar.js +2 -2
  79. package/dist/web/primitives/default-form.js +12 -5
  80. package/dist/web/primitives/field.js +4 -1
  81. package/dist/web/primitives/input-text-kinds.js +8 -2
  82. package/dist/web/primitives/layout-elements.js +2 -4
  83. package/dist/web/primitives/tabs.d.ts +1 -1
  84. package/dist/web/primitives/tabs.js +21 -4
  85. package/dist/web/theme-plugin.d.ts +1 -1
  86. package/dist/web/theme-plugin.js +7 -0
  87. package/dist/web/ui/sidebar.js +5 -2
  88. package/dist/web/widgets/ai-text-end-action.d.ts +12 -0
  89. package/dist/web/widgets/ai-text-end-action.js +15 -0
  90. package/dist/web/widgets/ai-text-field.d.ts +3 -0
  91. package/dist/web/widgets/ai-text-field.js +4 -3
  92. package/dist/web/widgets/attachment-card.d.ts +6 -0
  93. package/dist/web/widgets/attachment-card.js +11 -0
  94. package/dist/web/widgets/attachment-chip.d.ts +8 -0
  95. package/dist/web/widgets/attachment-chip.js +21 -0
  96. package/dist/web/widgets/clamped-text.d.ts +11 -0
  97. package/dist/web/widgets/clamped-text.js +38 -0
  98. package/dist/web/widgets/html-mail-frame.d.ts +17 -0
  99. package/dist/web/widgets/html-mail-frame.js +56 -0
  100. package/dist/web/widgets/index.d.ts +10 -1
  101. package/dist/web/widgets/index.js +9 -1
  102. package/dist/web/widgets/infinity-list.d.ts +3 -1
  103. package/dist/web/widgets/infinity-list.js +2 -2
  104. package/dist/web/widgets/message-body-view.d.ts +10 -0
  105. package/dist/web/widgets/message-body-view.js +36 -0
  106. package/dist/web/widgets/message-reader.d.ts +4 -0
  107. package/dist/web/widgets/message-reader.js +31 -0
  108. package/dist/web/widgets/message-thread.d.ts +5 -0
  109. package/dist/web/widgets/message-thread.js +66 -0
  110. package/dist/web/widgets/message-types.d.ts +68 -0
  111. package/dist/web/widgets/message-types.js +1 -0
  112. package/dist/web/widgets/mobile-top-bar.d.ts +21 -0
  113. package/dist/web/widgets/mobile-top-bar.js +8 -0
  114. package/dist/web/widgets/pdf-document.d.ts +19 -0
  115. package/dist/web/widgets/pdf-document.js +70 -0
  116. package/dist/web/widgets/pdf-page.d.ts +35 -0
  117. package/dist/web/widgets/pdf-page.js +155 -0
  118. package/dist/web/widgets/pdf-preview.d.ts +27 -7
  119. package/dist/web/widgets/pdf-preview.js +21 -133
  120. package/dist/web/widgets/pdf-search.d.ts +43 -0
  121. package/dist/web/widgets/pdf-search.js +178 -0
  122. package/dist/web/widgets/pdf-thumbnails.d.ts +10 -0
  123. package/dist/web/widgets/pdf-thumbnails.js +35 -0
  124. package/dist/web/widgets/pdf-viewer-toolbar.d.ts +22 -0
  125. package/dist/web/widgets/pdf-viewer-toolbar.js +35 -0
  126. package/dist/web/widgets/pdf-viewer.d.ts +21 -0
  127. package/dist/web/widgets/pdf-viewer.js +176 -0
  128. package/dist/web/widgets/quoted-text.d.ts +16 -0
  129. package/dist/web/widgets/quoted-text.js +76 -0
  130. package/dist/web/widgets/status-badge.js +3 -1
  131. package/dist/web/widgets/step-list-fit.d.ts +25 -0
  132. package/dist/web/widgets/step-list-fit.js +79 -0
  133. package/dist/web/widgets/step-list-row.d.ts +50 -0
  134. package/dist/web/widgets/step-list-row.js +97 -0
  135. package/dist/web/widgets/step-list.d.ts +33 -0
  136. package/dist/web/widgets/step-list.js +36 -0
  137. package/dist/web/widgets/surfaces.d.ts +23 -0
  138. package/dist/web/widgets/surfaces.js +15 -0
  139. package/dist/web/widgets/use-in-view.d.ts +5 -0
  140. package/dist/web/widgets/use-in-view.js +18 -0
  141. package/package.json +5 -5
  142. package/src/changes.json +192 -0
  143. package/src/web/styles.css +22 -0
@@ -0,0 +1,56 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback, useMemo, useRef, useState } from "react";
3
+ function stripMarkup(value) {
4
+ return value.replace(/[<>]/g, "");
5
+ }
6
+ export function buildMailSrcDoc(html, options) {
7
+ const imageSources = options.allowRemoteImages ? "img-src data: https: http:" : "img-src data:";
8
+ const csp = `default-src 'none'; style-src 'unsafe-inline'; ${imageSources}`;
9
+ const { fontFamily, color } = options.style;
10
+ const hideBlockedImages = options.allowRemoteImages
11
+ ? ""
12
+ : 'img:not([src^="data:"]){display:none}';
13
+ const tableStyle = "table{border-collapse:collapse;border:0}td,th{border:0;border-top:1px solid color-mix(in srgb,currentColor 15%,transparent);padding:4px 8px 4px 0;text-align:left;font-variant-numeric:tabular-nums}tr:first-child>td,tr:first-child>th{border-top-color:currentColor}";
14
+ const baseStyle = `html,body{margin:0;background:transparent}body>:first-child,body>:first-child>:first-child{margin-top:0}body>:last-child,body>:last-child>:last-child{margin-bottom:0}body{font-family:${stripMarkup(fontFamily)};font-size:15px;line-height:1.55;color:${stripMarkup(color)};overflow-wrap:anywhere}img{max-width:100%;height:auto}${hideBlockedImages}${tableStyle}a{color:inherit}`;
15
+ return [
16
+ '<!doctype html><html><head><meta charset="utf-8">',
17
+ `<meta http-equiv="Content-Security-Policy" content="${csp}">`,
18
+ '<base target="_blank"><style>',
19
+ baseStyle,
20
+ "</style></head><body>",
21
+ html,
22
+ "</body></html>",
23
+ ].join("");
24
+ }
25
+ function pageStyle() {
26
+ if (typeof document === "undefined" || typeof getComputedStyle === "undefined") {
27
+ return { fontFamily: "sans-serif", color: "inherit" };
28
+ }
29
+ const computed = getComputedStyle(document.body);
30
+ return { fontFamily: computed.fontFamily || "sans-serif", color: computed.color || "inherit" };
31
+ }
32
+ /** Renders server-sanitized mail HTML in a script-free sandboxed iframe that grows to its content. */
33
+ export function HtmlMailFrame({ html, title, allowRemoteImages, testId, }) {
34
+ const [height, setHeight] = useState(undefined);
35
+ const observerRef = useRef(null);
36
+ const srcDoc = useMemo(() => buildMailSrcDoc(html, { allowRemoteImages, style: pageStyle() }), [html, allowRemoteImages]);
37
+ const measureContent = useCallback((frame) => {
38
+ observerRef.current?.disconnect();
39
+ const contentDocument = frame.contentDocument;
40
+ if (contentDocument === null)
41
+ return;
42
+ const measure = () => setHeight(contentDocument.documentElement.scrollHeight);
43
+ measure();
44
+ const observer = new ResizeObserver(measure);
45
+ observer.observe(contentDocument.body);
46
+ observerRef.current = observer;
47
+ }, []);
48
+ const releaseObserverOnUnmount = useCallback((frame) => {
49
+ if (frame === null)
50
+ return undefined;
51
+ return () => observerRef.current?.disconnect();
52
+ }, []);
53
+ return (_jsx("iframe", { ref: releaseObserverOnUnmount, title: title, "data-testid": testId,
54
+ // allow-same-origin only lets the parent measure the content height; without allow-scripts nothing in the frame runs.
55
+ sandbox: "allow-same-origin allow-popups allow-popups-to-escape-sandbox", srcDoc: srcDoc, onLoad: (event) => measureContent(event.currentTarget), className: "block w-full border-0", style: height === undefined ? undefined : { height } }));
56
+ }
@@ -1,7 +1,11 @@
1
+ export type { AiTextEndAction } from "./ai-text-end-action.tsx";
1
2
  export { AiTextArea, type AiTextAreaProps, AiTextField, type AiTextFieldProps, } from "./ai-text-field.tsx";
3
+ export { AttachmentCard } from "./attachment-card.tsx";
4
+ export { AttachmentChip } from "./attachment-chip.tsx";
2
5
  export type { StackedAreaDateFormat, StackedAreaInitialWindow, StackedAreaRangeOption, StackedAreaRanges, StackedAreaWindowSelection, } from "./chart-window.ts";
3
6
  export { type ChartMarker, type ChartSeries, type ChartTone, SegmentBarChart, type SegmentBarRow, StackedAreaChart, StackedBarChart, StatusBarChart, type StatusBarEntry, smoothPath, TimeseriesChart, type TimeseriesHeight, type TimeseriesPoint, type TimeseriesReferenceLine, type TimeseriesXAxis, type TimeseriesYAxis, } from "./charts.tsx";
4
7
  export { ChoiceCards } from "./choice-cards.tsx";
8
+ export { ClampedText } from "./clamped-text.tsx";
5
9
  export { CollapsibleSection } from "./collapsible-section.tsx";
6
10
  export { type DashboardListColumn, DashboardListTable } from "./dashboard-list.tsx";
7
11
  export { DetailList } from "./detail-list.tsx";
@@ -10,8 +14,11 @@ export { FeedList, type FeedRow } from "./feed-list.tsx";
10
14
  export { FloatingPanel, type FloatingPanelGeometry, type FloatingPanelProps, } from "./floating-panel.tsx";
11
15
  export { BooleanField, type BooleanFieldProps, DateField, type DateFieldProps, FileField, type FileFieldProps, MoneyField, NumberField, type NumberFieldProps, PercentField, RangeField, type RangeFieldProps, SelectField, type SelectFieldProps, TextareaField, type TextareaFieldProps, TextField, type TextFieldProps, } from "./form-fields.tsx";
12
16
  export { InfinityList, type InfinityListProps, type InfinityListSelection, } from "./infinity-list.tsx";
17
+ export { MessageReader } from "./message-reader.tsx";
18
+ export { type MessageAttachment, type MessageBody, type MessageReaderProps, type MessageReaderTab, MessageThread, type MessageThreadProps, type ThreadMessage, } from "./message-thread.tsx";
19
+ export { MobileTopBar, type MobileTopBarProps } from "./mobile-top-bar.tsx";
13
20
  export { ModeSwitch, type ModeSwitchVariant } from "./mode-switch.tsx";
14
- export { PdfPreview, type PdfPreviewSource } from "./pdf-preview.tsx";
21
+ export { type PdfMatchInfo, PdfPreview, type PdfPreviewProps, type PdfPreviewSource, } from "./pdf-preview.tsx";
15
22
  export { type PhotoSlotSpec, PhotoSlots, type PhotoSlotsProps } from "./photo-slots.tsx";
16
23
  export { PlanCard, type PlanCardActionSlot, type PlanCardLinkSlot, type PlanCardPrice, type PlanCardProps, PlanGrid, type PlanGridProps, } from "./plan-card.tsx";
17
24
  export { ProgressBar } from "./progress-bar.tsx";
@@ -25,5 +32,7 @@ export { MiniStat, Sparkline, StatCard, type StatDelta, StatStripCell, type Stat
25
32
  export { EmptyState, ErrorState, LoadingState } from "./states.tsx";
26
33
  export { STATUS_TONE_TEXT, StatusBadge, type StatusBadgeTone, type StatusTone, } from "./status-badge.tsx";
27
34
  export { StepBar } from "./step-bar.tsx";
35
+ export { type StepAction, StepList, type StepListItem, type StepListProps, type StepSource, type StepStatus, type StepTag, } from "./step-list.tsx";
36
+ export { AiSurface, SenderFrame, SenderSheet } from "./surfaces.tsx";
28
37
  export { UploadZone, type UploadZoneProps } from "./upload-zone.tsx";
29
38
  export { useDraft } from "./use-draft.ts";
@@ -3,8 +3,11 @@
3
3
  // Catalog: docs.kumiko.rocks → Guides → Widgets; visual overview in the
4
4
  // styleguide sample.
5
5
  export { AiTextArea, AiTextField, } from "./ai-text-field.js";
6
+ export { AttachmentCard } from "./attachment-card.js";
7
+ export { AttachmentChip } from "./attachment-chip.js";
6
8
  export { SegmentBarChart, StackedAreaChart, StackedBarChart, StatusBarChart, smoothPath, TimeseriesChart, } from "./charts.js";
7
9
  export { ChoiceCards } from "./choice-cards.js";
10
+ export { ClampedText } from "./clamped-text.js";
8
11
  export { CollapsibleSection } from "./collapsible-section.js";
9
12
  export { DashboardListTable } from "./dashboard-list.js";
10
13
  export { DetailList } from "./detail-list.js";
@@ -13,8 +16,11 @@ export { FeedList } from "./feed-list.js";
13
16
  export { FloatingPanel, } from "./floating-panel.js";
14
17
  export { BooleanField, DateField, FileField, MoneyField, NumberField, PercentField, RangeField, SelectField, TextareaField, TextField, } from "./form-fields.js";
15
18
  export { InfinityList, } from "./infinity-list.js";
19
+ export { MessageReader } from "./message-reader.js";
20
+ export { MessageThread, } from "./message-thread.js";
21
+ export { MobileTopBar } from "./mobile-top-bar.js";
16
22
  export { ModeSwitch } from "./mode-switch.js";
17
- export { PdfPreview } from "./pdf-preview.js";
23
+ export { PdfPreview, } from "./pdf-preview.js";
18
24
  export { PhotoSlots } from "./photo-slots.js";
19
25
  export { PlanCard, PlanGrid, } from "./plan-card.js";
20
26
  export { ProgressBar } from "./progress-bar.js";
@@ -28,5 +34,7 @@ export { MiniStat, Sparkline, StatCard, StatStripCell, } from "./stat.js";
28
34
  export { EmptyState, ErrorState, LoadingState } from "./states.js";
29
35
  export { STATUS_TONE_TEXT, StatusBadge, } from "./status-badge.js";
30
36
  export { StepBar } from "./step-bar.js";
37
+ export { StepList, } from "./step-list.js";
38
+ export { AiSurface, SenderFrame, SenderSheet } from "./surfaces.js";
31
39
  export { UploadZone } from "./upload-zone.js";
32
40
  export { useDraft } from "./use-draft.js";
@@ -22,6 +22,8 @@ export type InfinityListProps<TData = unknown, TRow = Readonly<Record<string, un
22
22
  readonly rowId: (row: TRow, index: number) => string;
23
23
  readonly renderRow: (row: TRow) => ReactNode;
24
24
  readonly emptyState?: ReactNode;
25
+ /** Scrolls with the rows, after the last loaded one, e.g. a hint under search hits. Not shown with the empty state. */
26
+ readonly endContent?: ReactNode;
25
27
  readonly className?: string;
26
28
  readonly testId?: string;
27
29
  /** Subscribe to SSE events for the entity parsed from `query`
@@ -43,4 +45,4 @@ export type InfinityListProps<TData = unknown, TRow = Readonly<Record<string, un
43
45
  * instead of a pager bar like QueryTable/entityList. The query handler
44
46
  * receives `{ ...payload, limit, cursor? }` and returns rows plus the next
45
47
  * cursor (same cursor convention as the audit-log screen). */
46
- export declare function InfinityList<TData = unknown, TRow = Readonly<Record<string, unknown>>>({ query, payload, pageSize, rows, nextCursor, rowId, renderRow, emptyState, className, testId, live, selectedId, onSelectionChange, }: InfinityListProps<TData, TRow>): ReactNode;
48
+ export declare function InfinityList<TData = unknown, TRow = Readonly<Record<string, unknown>>>({ query, payload, pageSize, rows, nextCursor, rowId, renderRow, emptyState, endContent, className, testId, live, selectedId, onSelectionChange, }: InfinityListProps<TData, TRow>): ReactNode;
@@ -8,7 +8,7 @@ import { EmptyState, ErrorState, LoadingState } from "./states.js";
8
8
  * instead of a pager bar like QueryTable/entityList. The query handler
9
9
  * receives `{ ...payload, limit, cursor? }` and returns rows plus the next
10
10
  * cursor (same cursor convention as the audit-log screen). */
11
- export function InfinityList({ query, payload, pageSize = 50, rows, nextCursor, rowId, renderRow, emptyState, className, testId, live = false, selectedId, onSelectionChange, }) {
11
+ export function InfinityList({ query, payload, pageSize = 50, rows, nextCursor, rowId, renderRow, emptyState, endContent, className, testId, live = false, selectedId, onSelectionChange, }) {
12
12
  const dispatcher = useDispatcher();
13
13
  const t = useTranslation();
14
14
  const subscribeLive = useLiveEvents();
@@ -221,5 +221,5 @@ export function InfinityList({ query, payload, pageSize = 50, rows, nextCursor,
221
221
  return _jsx(ErrorState, { error: state.error, onRetry: () => void load(null), testId: testId });
222
222
  if (state.rows.length === 0)
223
223
  return _jsx(_Fragment, { children: emptyState ?? _jsx(EmptyState, { title: t("kumiko.list.no-entries"), testId: testId }) });
224
- return (_jsxs("div", { "data-testid": testId, className: className ?? "flex flex-col overflow-y-auto", children: [state.rows.map((row, index) => (_jsx("div", { children: renderRow(row) }, rowId(row, index)))), _jsx("div", { ref: sentinelRef, className: "h-px" })] }));
224
+ return (_jsxs("div", { "data-testid": testId, className: className ?? "flex flex-col overflow-y-auto", children: [state.rows.map((row, index) => (_jsx("div", { children: renderRow(row) }, rowId(row, index)))), _jsx("div", { ref: sentinelRef, className: "h-px" }), endContent] }));
225
225
  }
@@ -0,0 +1,10 @@
1
+ import { type ReactNode } from "react";
2
+ import type { MessageBody } from "./message-types.ts";
3
+ export declare function MessageBodyView({ body, title, clampLines, remoteImages, moreLabelKey, }: {
4
+ readonly body: MessageBody;
5
+ readonly title: string;
6
+ readonly clampLines: number;
7
+ readonly remoteImages: "blocked" | "allowed";
8
+ /** Only a folded phone thread sets it; then an html mail is cut short too. */
9
+ readonly moreLabelKey?: string;
10
+ }): ReactNode;
@@ -0,0 +1,36 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useState } from "react";
3
+ import { usePrimitives, useTranslation } from "../../index.js";
4
+ import { ClampedText } from "./clamped-text.js";
5
+ import { HtmlMailFrame } from "./html-mail-frame.js";
6
+ import { hasRemoteImages, splitQuotedHtml, splitQuotedText } from "./quoted-text.js";
7
+ function QuoteToggle({ lines, open, onToggle, }) {
8
+ const t = useTranslation();
9
+ const { Button } = usePrimitives();
10
+ return (_jsx(Button, { variant: "secondary", size: "sm", expanded: open, onClick: onToggle, children: open
11
+ ? t("kumiko.widget.message-thread.hideQuoted")
12
+ : t("kumiko.widget.message-thread.showQuoted", { lines }) }));
13
+ }
14
+ function TextBody({ text, clampLines, moreLabelKey, }) {
15
+ const [quoteOpen, setQuoteOpen] = useState(false);
16
+ const split = useMemo(() => splitQuotedText(text), [text]);
17
+ return (_jsxs("div", { className: "flex flex-col items-start gap-3 text-[15px] leading-[1.55]", children: [_jsx(ClampedText, { lines: clampLines, ...(moreLabelKey !== undefined && { moreLabelKey }), children: _jsx("p", { className: "m-0 whitespace-pre-wrap", children: split.main }) }), split.quoted !== null && (_jsxs(_Fragment, { children: [_jsx(QuoteToggle, { lines: split.quotedLineCount, open: quoteOpen, onToggle: () => setQuoteOpen((open) => !open) }), quoteOpen && (_jsx("p", { "data-testid": "message-quoted", className: "m-0 w-full whitespace-pre-wrap border-l-2 border-border pl-3 text-[13px] text-muted-foreground", children: split.quoted }))] }))] }));
18
+ }
19
+ // The frame sets its text at 15px with a 1.55 line height.
20
+ const HTML_MAIL_LINE_PX = 15 * 1.55;
21
+ function HtmlBody({ html, title, remoteImages, clamp, }) {
22
+ const t = useTranslation();
23
+ const [quoteOpen, setQuoteOpen] = useState(false);
24
+ const [imagesAllowed, setImagesAllowed] = useState(remoteImages === "allowed");
25
+ const split = useMemo(() => splitQuotedHtml(html), [html]);
26
+ const showImageBar = useMemo(() => !imagesAllowed && hasRemoteImages(html), [html, imagesAllowed]);
27
+ const content = (_jsxs(_Fragment, { children: [_jsx("div", { className: "w-full", children: _jsx(HtmlMailFrame, { html: split.main, title: title, allowRemoteImages: imagesAllowed }) }), showImageBar && (_jsxs("p", { role: "note", "data-testid": "message-images-bar", className: "m-0 text-xs text-muted-foreground", children: [t("kumiko.widget.message-thread.imagesBlocked"), " ", _jsx("button", { type: "button", className: "cursor-pointer border-0 bg-transparent p-0 text-xs text-primary underline hover:text-primary/80", onClick: () => setImagesAllowed(true), children: t("kumiko.widget.message-thread.showImages") })] })), split.quoted !== null && (_jsxs(_Fragment, { children: [_jsx(QuoteToggle, { lines: split.quotedLineCount, open: quoteOpen, onToggle: () => setQuoteOpen((open) => !open) }), quoteOpen && (_jsx("div", { className: "w-full border-l-2 border-border pl-3", children: _jsx(HtmlMailFrame, { html: split.quoted, title: title, allowRemoteImages: imagesAllowed }) }))] }))] }));
28
+ if (clamp === undefined) {
29
+ return _jsx("div", { className: "flex flex-col items-start gap-3", children: content });
30
+ }
31
+ // The quote toggle sits inside the cut: it only matters once the whole mail is open.
32
+ return (_jsx(ClampedText, { maxHeightPx: clamp.lines * HTML_MAIL_LINE_PX, moreLabelKey: clamp.moreLabelKey, children: _jsx("div", { className: "flex flex-col items-start gap-3", children: content }) }));
33
+ }
34
+ export function MessageBodyView({ body, title, clampLines, remoteImages, moreLabelKey, }) {
35
+ return body.kind === "text" ? (_jsx(TextBody, { text: body.text, clampLines: clampLines, moreLabelKey: moreLabelKey })) : (_jsx(HtmlBody, { html: body.html, title: title, remoteImages: remoteImages, clamp: moreLabelKey === undefined ? undefined : { lines: clampLines, moreLabelKey } }));
36
+ }
@@ -0,0 +1,4 @@
1
+ import { type ReactNode } from "react";
2
+ import type { MessageReaderProps } from "./message-types.ts";
3
+ /** Mail thread with an optional tab per attachment; the tab bar only exists when there are attachment tabs. */
4
+ export declare function MessageReader({ thread, attachmentTabs, activeTabId, onTabChange, testId, }: MessageReaderProps): ReactNode;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Mail } from "lucide-react";
3
+ import { useState } from "react";
4
+ import { useTranslation } from "../../index.js";
5
+ import { DefaultTabs } from "../primitives/tabs.js";
6
+ import { MessageThread } from "./message-thread.js";
7
+ const MAIL_TAB_ID = "mail";
8
+ /** Mail thread with an optional tab per attachment; the tab bar only exists when there are attachment tabs. */
9
+ export function MessageReader({ thread, attachmentTabs = [], activeTabId, onTabChange, testId = "message-reader", }) {
10
+ const t = useTranslation();
11
+ const [uncontrolledTabId, setUncontrolledTabId] = useState(MAIL_TAB_ID);
12
+ const currentTabId = activeTabId ?? uncontrolledTabId;
13
+ const activeTab = attachmentTabs.find((tab) => tab.id === currentTabId);
14
+ const selectTab = (id) => {
15
+ setUncontrolledTabId(id);
16
+ onTabChange?.(id);
17
+ };
18
+ return (_jsxs("div", { "data-testid": testId, className: "flex flex-col gap-4", children: [attachmentTabs.length > 0 && (_jsx(DefaultTabs, { items: [
19
+ {
20
+ id: MAIL_TAB_ID,
21
+ label: t("kumiko.widget.message-reader.mail"),
22
+ icon: _jsx(Mail, {}),
23
+ },
24
+ ...attachmentTabs.map((tab) => ({
25
+ id: tab.id,
26
+ label: tab.label,
27
+ ...(tab.icon !== undefined && { icon: tab.icon }),
28
+ ...(tab.detail !== undefined && { detail: tab.detail }),
29
+ })),
30
+ ], appearance: "plain", activeId: activeTab === undefined ? MAIL_TAB_ID : currentTabId, onSelect: selectTab })), activeTab === undefined ? _jsx(MessageThread, { ...thread }) : activeTab.render()] }));
31
+ }
@@ -0,0 +1,5 @@
1
+ import { type ReactNode } from "react";
2
+ import type { MessageThreadProps } from "./message-types.ts";
3
+ export type { MessageAttachment, MessageBody, MessageReaderProps, MessageReaderTab, MessageThreadProps, ThreadMessage, } from "./message-types.ts";
4
+ /** Mail conversation, oldest first: older messages fold to one line, the last one is open on a sheet. */
5
+ export declare function MessageThread({ messages, clampLines, remoteImages, showHeaders, foldOlderTogether, testId, }: MessageThreadProps): ReactNode;
@@ -0,0 +1,66 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ChevronRight, CornerUpLeft } from "lucide-react";
3
+ import { useState } from "react";
4
+ import { usePrimitives, useTranslation } from "../../index.js";
5
+ import { cn } from "../lib/cn.js";
6
+ import { AttachmentCard } from "./attachment-card.js";
7
+ import { AttachmentChip } from "./attachment-chip.js";
8
+ import { MessageBodyView } from "./message-body-view.js";
9
+ import { plainTextOfHtml } from "./quoted-text.js";
10
+ import { SENDER_FRAME_CLASS, SenderSheet } from "./surfaces.js";
11
+ const DEFAULT_CLAMP_LINES = 16;
12
+ const PREVIEW_SOURCE_CHARS = 300;
13
+ // Joined across lines: a mail's first line is usually only the greeting ("Guten Tag,").
14
+ // The row truncates with CSS; the slice only keeps long bodies out of the DOM.
15
+ function previewOf(message) {
16
+ const text = message.body.kind === "text"
17
+ ? message.body.text
18
+ : (message.body.fallbackText ?? plainTextOfHtml(message.body.html));
19
+ return text.slice(0, PREVIEW_SOURCE_CHARS).replace(/\s+/g, " ").trim();
20
+ }
21
+ function CollapsedRow({ message, onExpand, }) {
22
+ return (_jsxs("button", { type: "button", "data-testid": `message-row-${message.id}`, onClick: onExpand,
23
+ // The negative inset lets the hover band reach past the text without shifting it.
24
+ className: "-mx-2 flex w-[calc(100%+1rem)] cursor-pointer items-center gap-2.5 border-0 border-b border-sender-frame-border bg-transparent px-2 py-2.5 text-left text-foreground hover:bg-muted/50", children: [_jsxs("span", { className: "inline-flex shrink-0 items-center gap-1.5 font-semibold", children: [message.direction === "outgoing" && (_jsx(CornerUpLeft, { "aria-hidden": "true", className: "size-3.5", "data-testid": "message-outgoing-icon" })), message.author] }), _jsx("span", { className: "min-w-0 grow truncate text-muted-foreground", children: previewOf(message) }), _jsx("span", { className: "shrink-0 text-xs text-muted-foreground", children: message.timeLabel }), _jsx(ChevronRight, { "aria-hidden": "true", className: "size-4 shrink-0 text-muted-foreground", "data-testid": "message-row-chevron" })] }));
25
+ }
26
+ // Beyond any real mail, so the body shows whole once the reader asked for it.
27
+ const UNCLAMPED_LINES = 10_000;
28
+ function TeaserBody({ teaser, clampLines, moreLabelKey, onReadWhole, }) {
29
+ const t = useTranslation();
30
+ const { Button } = usePrimitives();
31
+ return (_jsxs("div", { className: "flex flex-col items-start gap-1", children: [_jsx("p", { "data-testid": "message-teaser", className: "m-0 w-full whitespace-pre-wrap text-[15px] leading-[1.55] max-md:text-[14px] max-md:leading-[22px]", style: {
32
+ display: "-webkit-box",
33
+ WebkitBoxOrient: "vertical",
34
+ WebkitLineClamp: clampLines,
35
+ overflow: "hidden",
36
+ }, children: teaser }), _jsx(Button, { variant: "link", size: "sm", onClick: onReadWhole, children: t(moreLabelKey) })] }));
37
+ }
38
+ function OpenMessage({ message, clampLines, remoteImages, showHeader, moreLabelKey, attachmentsBelow, }) {
39
+ const attachments = attachmentsBelow ? [] : (message.attachments ?? []);
40
+ const [wholeMailRequested, setWholeMailRequested] = useState(false);
41
+ const showTeaser = moreLabelKey !== undefined &&
42
+ message.teaser !== undefined &&
43
+ message.teaser !== "" &&
44
+ !wholeMailRequested;
45
+ return (_jsxs("div", { "data-testid": `message-open-${message.id}`, className: "flex flex-col gap-3", children: [showHeader && (_jsxs("div", { "data-testid": `message-header-${message.id}`, className: "flex items-baseline gap-2", children: [_jsx("span", { className: "shrink-0 whitespace-nowrap font-semibold", children: message.author }), message.address !== undefined && (_jsx("span", { className: "min-w-0 truncate text-[13px] text-muted-foreground", children: message.address })), _jsx("span", { className: "grow" }), _jsx("span", { className: "shrink-0 whitespace-nowrap text-[13px] text-muted-foreground", children: message.timeLabel })] })), showTeaser ? (_jsx(TeaserBody, { teaser: message.teaser, clampLines: clampLines, moreLabelKey: moreLabelKey, onReadWhole: () => setWholeMailRequested(true) })) : (_jsx(MessageBodyView, { body: message.body, title: message.author, clampLines: wholeMailRequested ? UNCLAMPED_LINES : clampLines, remoteImages: remoteImages, ...(moreLabelKey !== undefined && !wholeMailRequested && { moreLabelKey }) })), attachments.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-2", children: attachments.map((attachment) => (_jsx(AttachmentChip, { ...attachment }, attachment.id))) }))] }));
46
+ }
47
+ /** Mail conversation, oldest first: older messages fold to one line, the last one is open on a sheet. */
48
+ export function MessageThread({ messages, clampLines = DEFAULT_CLAMP_LINES, remoteImages = "blocked", showHeaders = true, foldOlderTogether = false, testId = "message-thread", }) {
49
+ const t = useTranslation();
50
+ const [expandedIds, setExpandedIds] = useState(new Set());
51
+ const [olderShown, setOlderShown] = useState(false);
52
+ const lastIndex = messages.length - 1;
53
+ const hasOlder = messages.length > 1;
54
+ const olderFolded = foldOlderTogether && hasOlder && !olderShown;
55
+ const cardAttachments = foldOlderTogether ? (messages[lastIndex]?.attachments ?? []) : [];
56
+ return (_jsxs(_Fragment, { children: [_jsxs("section", { "data-testid": testId, className: cn(SENDER_FRAME_CLASS, "flex flex-col", foldOlderTogether ? "px-2.5 pb-2.5" : "px-4 pb-4", hasOlder ? "pt-1" : "pt-4"), children: [olderFolded && (_jsx("button", { type: "button", "data-testid": `${testId}-earlier`, onClick: () => setOlderShown(true), className: "border-0 bg-transparent py-2.5 text-left text-[13px] text-foreground-secondary", children: lastIndex === 1
57
+ ? t("kumiko.widget.message-thread.showEarlierOne")
58
+ : t("kumiko.widget.message-thread.showEarlier", { count: lastIndex }) })), (olderFolded ? messages.slice(lastIndex) : messages).map((message, offset) => {
59
+ const index = olderFolded ? lastIndex : offset;
60
+ const open = index === lastIndex || expandedIds.has(message.id);
61
+ if (!open) {
62
+ return (_jsx(CollapsedRow, { message: message, onExpand: () => setExpandedIds((ids) => new Set(ids).add(message.id)) }, message.id));
63
+ }
64
+ return (_jsx("div", { className: index > 0 ? "mt-3" : undefined, children: _jsx(SenderSheet, { compact: foldOlderTogether, children: _jsx(OpenMessage, { message: message, clampLines: clampLines, remoteImages: remoteImages, showHeader: showHeaders, attachmentsBelow: foldOlderTogether, moreLabelKey: foldOlderTogether ? "kumiko.widget.message-thread.readWholeMail" : undefined }) }) }, message.id));
65
+ })] }), cardAttachments.length > 0 && (_jsx("div", { "data-testid": `${testId}-attachments`, className: "mt-2.5 flex flex-col gap-2.5", children: cardAttachments.map(({ id, ...attachment }) => (_jsx(AttachmentCard, { ...attachment }, id))) }))] }));
66
+ }
@@ -0,0 +1,68 @@
1
+ import type { ReactNode } from "react";
2
+ export type MessageAttachment = {
3
+ readonly id: string;
4
+ readonly name: string;
5
+ /** Second line, e.g. "Foto, 1,2 MB" or "PDF, 4 Seiten". */
6
+ readonly meta?: string;
7
+ /** Icon only. */
8
+ readonly kind?: "image" | "pdf" | "file";
9
+ readonly onOpen?: () => void;
10
+ readonly href?: string;
11
+ /** Preview image; AttachmentCard shows it instead of the kind icon. */
12
+ readonly thumbnailUrl?: string;
13
+ };
14
+ export type MessageBody = {
15
+ readonly kind: "text";
16
+ readonly text: string;
17
+ }
18
+ /** html MUST be server-sanitized (inbound-mail-foundation bodyHtml). Shown in a sandboxed iframe, no scripts. */
19
+ | {
20
+ readonly kind: "html";
21
+ readonly html: string;
22
+ readonly fallbackText?: string;
23
+ };
24
+ export type ThreadMessage = {
25
+ readonly id: string;
26
+ /** "Anna Schneider" or the caller's "Du". */
27
+ readonly author: string;
28
+ readonly address?: string;
29
+ /** Outgoing messages get the reply icon in the collapsed row. */
30
+ readonly direction: "incoming" | "outgoing";
31
+ /** Preformatted by the caller ("Heute 09:41"). */
32
+ readonly timeLabel: string;
33
+ readonly body: MessageBody;
34
+ readonly attachments?: readonly MessageAttachment[];
35
+ /** Plain-text preview the host derived, e.g. without the greeting; shown instead of the clamped body while a folded thread has the mail closed. */
36
+ readonly teaser?: string;
37
+ };
38
+ export type MessageThreadProps = {
39
+ /** Oldest first. All but the last start collapsed to one line (author, first line, time); click expands. */
40
+ readonly messages: readonly ThreadMessage[];
41
+ /** Lines before "Mehr anzeigen" on a long text body. Default 16. A folded thread also cuts an html mail to these lines. */
42
+ readonly clampLines?: number;
43
+ /** External images in html bodies. Default "blocked" with a "Bilder anzeigen" bar. */
44
+ readonly remoteImages?: "blocked" | "allowed";
45
+ /** false drops author, address and time above open messages, for hosts whose page head already names them. */
46
+ readonly showHeaders?: boolean;
47
+ /** Phone reading: older messages fold into one "n earlier mails" toggle instead of a row each, and a clamped mail offers "read the whole mail". */
48
+ readonly foldOlderTogether?: boolean;
49
+ readonly testId?: string;
50
+ };
51
+ export type MessageReaderTab = {
52
+ readonly id: string;
53
+ readonly label: string;
54
+ /** Shown before the label in the tab strip. */
55
+ readonly icon?: ReactNode;
56
+ /** Small muted text after the label, e.g. "4 Seiten". */
57
+ readonly detail?: string;
58
+ readonly render: () => ReactNode;
59
+ };
60
+ export type MessageReaderProps = {
61
+ readonly thread: MessageThreadProps;
62
+ /** One tab per attachment ("Anhang 1: Vertrag.pdf"); without tabs no tab bar is shown. */
63
+ readonly attachmentTabs?: readonly MessageReaderTab[];
64
+ /** "mail" = the thread; default "mail". */
65
+ readonly activeTabId?: string;
66
+ readonly onTabChange?: (id: string) => void;
67
+ readonly testId?: string;
68
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { ReactNode } from "react";
2
+ import { type StatusBadgeTone } from "./status-badge.tsx";
3
+ export type MobileTopBarProps = {
4
+ /** Screen label, e.g. "Posteingang · 1 von 5 offen". */
5
+ readonly label: string;
6
+ /** Chevron button before the label; label is its aria-label. */
7
+ readonly back?: {
8
+ readonly label: string;
9
+ readonly onClick: () => void;
10
+ };
11
+ /** Chip before the actions, e.g. "KI an". */
12
+ readonly status?: {
13
+ readonly label: string;
14
+ readonly tone: StatusBadgeTone;
15
+ };
16
+ /** Trailing controls, e.g. an overflow menu trigger. */
17
+ readonly actions?: ReactNode;
18
+ readonly testId?: string;
19
+ };
20
+ /** Phone-only bar for focused screens: the shell header is hidden there, so the screen brings its own. */
21
+ export declare function MobileTopBar({ label, back, status, actions, testId, }: MobileTopBarProps): ReactNode;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ChevronLeft } from "lucide-react";
3
+ import { cn } from "../lib/cn.js";
4
+ import { StatusBadge } from "./status-badge.js";
5
+ /** Phone-only bar for focused screens: the shell header is hidden there, so the screen brings its own. */
6
+ export function MobileTopBar({ label, back, status, actions, testId = "mobile-top-bar", }) {
7
+ return (_jsxs("div", { "data-testid": testId, className: "flex h-13 shrink-0 items-center gap-1 border-b border-border bg-card px-2 md:hidden", children: [back !== undefined && (_jsx("button", { type: "button", "aria-label": back.label, "data-testid": `${testId}-back`, onClick: back.onClick, className: "inline-flex size-10 shrink-0 items-center justify-center rounded-md text-foreground hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", children: _jsx(ChevronLeft, { className: "size-5", "aria-hidden": "true" }) })), _jsx("span", { className: cn("min-w-0 flex-1 truncate text-[13px] font-normal text-foreground-secondary", back === undefined && "pl-2"), children: label }), status !== undefined && (_jsx(StatusBadge, { tone: status.tone, testId: `${testId}-status`, children: status.label })), actions] }));
8
+ }
@@ -0,0 +1,19 @@
1
+ import type { PDFDocumentLoadingTask, PDFDocumentProxy, PDFPageProxy } from "pdfjs-dist";
2
+ export type PdfPreviewSource = {
3
+ readonly base64: string;
4
+ } | {
5
+ readonly url: string;
6
+ };
7
+ export type LoadedDocument = {
8
+ readonly ok: true;
9
+ readonly document: PDFDocumentProxy;
10
+ readonly loadingTask: PDFDocumentLoadingTask;
11
+ } | {
12
+ readonly ok: false;
13
+ };
14
+ export declare const documentCache: import("./bounded-load-cache.ts").BoundedLoadCache<LoadedDocument>;
15
+ export declare function documentKey(source: PdfPreviewSource): string;
16
+ export declare function documentFor(source: PdfPreviewSource): Promise<LoadedDocument>;
17
+ export declare function pageFor(document: PDFDocumentProxy, pageNumber: number): Promise<PDFPageProxy>;
18
+ /** Text items per page (index 0 = page 1), collected once per document. */
19
+ export declare function pageTextItemsFor(document: PDFDocumentProxy): Promise<readonly (readonly string[])[]>;
@@ -0,0 +1,70 @@
1
+ import { createBoundedLoadCache } from "./bounded-load-cache.js";
2
+ const MAX_CACHED_DOCUMENTS = 4;
3
+ export const documentCache = createBoundedLoadCache(MAX_CACHED_DOCUMENTS, (loaded) => {
4
+ if (loaded.ok)
5
+ void loaded.loadingTask.destroy();
6
+ }, (loaded) => loaded.ok);
7
+ function decodeBase64(base64) {
8
+ const binary = atob(base64);
9
+ const bytes = new Uint8Array(binary.length);
10
+ for (let index = 0; index < binary.length; index++)
11
+ bytes[index] = binary.charCodeAt(index);
12
+ return bytes;
13
+ }
14
+ async function loadBytes(source) {
15
+ if ("base64" in source)
16
+ return decodeBase64(source.base64);
17
+ const res = await fetch(source.url, { credentials: "same-origin" });
18
+ if (!res.ok)
19
+ throw new Error(`pdf fetch failed (${res.status})`);
20
+ return new Uint8Array(await res.arrayBuffer());
21
+ }
22
+ async function loadDocument(source) {
23
+ try {
24
+ const [pdfjs, worker, data] = await Promise.all([
25
+ import("pdfjs-dist"),
26
+ import("pdfjs-dist/build/pdf.worker.min.mjs"),
27
+ loadBytes(source),
28
+ ]);
29
+ Object.assign(globalThis, { pdfjsWorker: worker });
30
+ const loadingTask = pdfjs.getDocument({ data });
31
+ return { ok: true, document: await loadingTask.promise, loadingTask };
32
+ }
33
+ catch {
34
+ return { ok: false };
35
+ }
36
+ }
37
+ export function documentKey(source) {
38
+ return "base64" in source ? `base64:${source.base64}` : `url:${source.url}`;
39
+ }
40
+ // The promise must be stable across renders for use().
41
+ export function documentFor(source) {
42
+ return documentCache.load(documentKey(source), () => loadDocument(source));
43
+ }
44
+ const pageCache = new WeakMap();
45
+ export function pageFor(document, pageNumber) {
46
+ let pages = pageCache.get(document);
47
+ if (pages === undefined) {
48
+ pages = new Map();
49
+ pageCache.set(document, pages);
50
+ }
51
+ let page = pages.get(pageNumber);
52
+ if (page === undefined) {
53
+ page = document.getPage(pageNumber);
54
+ pages.set(pageNumber, page);
55
+ }
56
+ return page;
57
+ }
58
+ const pageTextCache = new WeakMap();
59
+ /** Text items per page (index 0 = page 1), collected once per document. */
60
+ export function pageTextItemsFor(document) {
61
+ let texts = pageTextCache.get(document);
62
+ if (texts === undefined) {
63
+ texts = Promise.all(Array.from({ length: document.numPages }, async (_, index) => {
64
+ const content = await (await pageFor(document, index + 1)).getTextContent();
65
+ return content.items.flatMap((item) => ("str" in item ? [item.str] : []));
66
+ }));
67
+ pageTextCache.set(document, texts);
68
+ }
69
+ return texts;
70
+ }
@@ -0,0 +1,35 @@
1
+ import type { PDFDocumentProxy } from "pdfjs-dist";
2
+ import { type ReactNode } from "react";
3
+ export declare const RENDER_SCALE: number;
4
+ export type PdfTextHighlight = {
5
+ readonly term: string;
6
+ readonly activeOrdinal: number | null;
7
+ /** A passage marked by the host (not a typed search) uses the source-passage color. */
8
+ readonly source?: boolean;
9
+ };
10
+ export type PdfPageSize = {
11
+ readonly width: number;
12
+ readonly height: number;
13
+ };
14
+ /** Natural size of page 1; unrendered placeholders and thumbnails use its aspect ratio. */
15
+ export declare function useFirstPageSize(document: PDFDocumentProxy): PdfPageSize;
16
+ export type PageLayout = {
17
+ readonly variant: "stacked" | "viewer";
18
+ readonly zoom: number;
19
+ readonly highlight: PdfTextHighlight | null;
20
+ /** The page the viewer opened on: its top is brought back into view whenever its size settles, unless a search hit is active. */
21
+ readonly anchorTop?: boolean;
22
+ /** Pixel height a whole page may take (pane height minus its padding). Set, a page fits the pane in both directions instead of only its width, so a search hit shows its page whole. */
23
+ readonly fitHeight?: number;
24
+ };
25
+ export declare function fitScaleFor(availableWidth: number | null, contentWidth: number, zoom: number, height?: {
26
+ readonly available: number | undefined;
27
+ readonly content: number;
28
+ }): number;
29
+ /** One page: a sized placeholder until it nears the viewport, then the rendered sheet. */
30
+ export declare function PdfPageSlot({ document, pageNumber, firstPageSize, layout, }: {
31
+ readonly document: PDFDocumentProxy;
32
+ readonly pageNumber: number;
33
+ readonly firstPageSize: PdfPageSize;
34
+ readonly layout: PageLayout;
35
+ }): ReactNode;