@papyrus-sdk/ui-react-native 0.2.11 → 0.2.13-beta.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.
@@ -0,0 +1,90 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // gesture/selectionInteraction.ts
20
+ var selectionInteraction_exports = {};
21
+ __export(selectionInteraction_exports, {
22
+ getSelectionEdgeAutoscroll: () => getSelectionEdgeAutoscroll,
23
+ getToolDockDismissState: () => getToolDockDismissState,
24
+ isToolDockToolSelected: () => isToolDockToolSelected,
25
+ shouldEnableSelectionDrag: () => shouldEnableSelectionDrag,
26
+ shouldEnableViewerScroll: () => shouldEnableViewerScroll
27
+ });
28
+ module.exports = __toCommonJS(selectionInteraction_exports);
29
+ var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
30
+ var DRAG_SELECTION_TOOLS = /* @__PURE__ */ new Set([
31
+ "highlight",
32
+ "underline",
33
+ "squiggly",
34
+ "strikeout"
35
+ ]);
36
+ var resolveAxisAutoscroll = (coordinate, size, threshold, maxStep) => {
37
+ if (size <= 0 || threshold <= 0 || maxStep <= 0) return 0;
38
+ const startDistance = clamp(coordinate, 0, size);
39
+ if (startDistance < threshold) {
40
+ const intensity = 1 - startDistance / threshold;
41
+ return -Math.round(maxStep * intensity);
42
+ }
43
+ const endDistance = clamp(size - coordinate, 0, size);
44
+ if (endDistance < threshold) {
45
+ const intensity = 1 - endDistance / threshold;
46
+ return Math.round(maxStep * intensity);
47
+ }
48
+ return 0;
49
+ };
50
+ var shouldEnableViewerScroll = ({
51
+ selectionDragActive,
52
+ gestureScrollLockActive = false
53
+ }) => !selectionDragActive && !gestureScrollLockActive;
54
+ var shouldEnableSelectionDrag = ({
55
+ activeTool,
56
+ interactionMode
57
+ }) => DRAG_SELECTION_TOOLS.has(activeTool) || activeTool === "select" && interactionMode === "select";
58
+ var isToolDockToolSelected = ({
59
+ activeTool,
60
+ interactionMode,
61
+ toolId
62
+ }) => toolId === "select" ? activeTool === "select" && interactionMode === "select" : activeTool === toolId;
63
+ var getToolDockDismissState = ({
64
+ activeTool: _activeTool,
65
+ interactionMode: _interactionMode
66
+ }) => ({
67
+ toolDockOpen: false,
68
+ activeTool: "select",
69
+ interactionMode: "pan"
70
+ });
71
+ var getSelectionEdgeAutoscroll = ({
72
+ x,
73
+ y,
74
+ width,
75
+ height,
76
+ threshold,
77
+ maxStep
78
+ }) => ({
79
+ dx: resolveAxisAutoscroll(x, width, threshold, maxStep),
80
+ dy: resolveAxisAutoscroll(y, height, threshold, maxStep)
81
+ });
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ getSelectionEdgeAutoscroll,
85
+ getToolDockDismissState,
86
+ isToolDockToolSelected,
87
+ shouldEnableSelectionDrag,
88
+ shouldEnableViewerScroll
89
+ });
90
+ //# sourceMappingURL=selectionInteraction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../gesture/selectionInteraction.ts"],"sourcesContent":["export type ViewerScrollState = {\n selectionDragActive: boolean;\n gestureScrollLockActive?: boolean;\n};\n\nexport type SelectionGestureTool =\n | \"select\"\n | \"highlight\"\n | \"underline\"\n | \"squiggly\"\n | \"strikeout\"\n | \"text\"\n | \"comment\"\n | \"ink\";\n\nexport type SelectionInteractionMode = \"pan\" | \"select\";\n\nexport type SelectionGestureActivationInput = {\n activeTool: SelectionGestureTool;\n interactionMode: SelectionInteractionMode;\n};\n\nexport type ToolDockSelectionState = SelectionGestureActivationInput & {\n toolId: SelectionGestureTool;\n};\n\nexport type ToolDockDismissState = SelectionGestureActivationInput & {\n toolDockOpen: boolean;\n};\n\nexport type SelectionEdgeAutoscrollInput = {\n x: number;\n y: number;\n width: number;\n height: number;\n threshold: number;\n maxStep: number;\n};\n\nexport type SelectionEdgeAutoscroll = {\n dx: number;\n dy: number;\n};\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\n\nconst DRAG_SELECTION_TOOLS = new Set<SelectionGestureTool>([\n \"highlight\",\n \"underline\",\n \"squiggly\",\n \"strikeout\",\n]);\n\nconst resolveAxisAutoscroll = (\n coordinate: number,\n size: number,\n threshold: number,\n maxStep: number\n) => {\n if (size <= 0 || threshold <= 0 || maxStep <= 0) return 0;\n\n const startDistance = clamp(coordinate, 0, size);\n if (startDistance < threshold) {\n const intensity = 1 - startDistance / threshold;\n return -Math.round(maxStep * intensity);\n }\n\n const endDistance = clamp(size - coordinate, 0, size);\n if (endDistance < threshold) {\n const intensity = 1 - endDistance / threshold;\n return Math.round(maxStep * intensity);\n }\n\n return 0;\n};\n\nexport const shouldEnableViewerScroll = ({\n selectionDragActive,\n gestureScrollLockActive = false,\n}: ViewerScrollState) => !selectionDragActive && !gestureScrollLockActive;\n\nexport const shouldEnableSelectionDrag = ({\n activeTool,\n interactionMode,\n}: SelectionGestureActivationInput) =>\n DRAG_SELECTION_TOOLS.has(activeTool) ||\n (activeTool === \"select\" && interactionMode === \"select\");\n\nexport const isToolDockToolSelected = ({\n activeTool,\n interactionMode,\n toolId,\n}: ToolDockSelectionState) =>\n toolId === \"select\"\n ? activeTool === \"select\" && interactionMode === \"select\"\n : activeTool === toolId;\n\nexport const getToolDockDismissState = ({\n activeTool: _activeTool,\n interactionMode: _interactionMode,\n}: SelectionGestureActivationInput): ToolDockDismissState => ({\n toolDockOpen: false,\n activeTool: \"select\",\n interactionMode: \"pan\",\n});\n\nexport const getSelectionEdgeAutoscroll = ({\n x,\n y,\n width,\n height,\n threshold,\n maxStep,\n}: SelectionEdgeAutoscrollInput): SelectionEdgeAutoscroll => ({\n dx: resolveAxisAutoscroll(x, width, threshold, maxStep),\n dy: resolveAxisAutoscroll(y, height, threshold, maxStep),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4CA,IAAM,QAAQ,CAAC,OAAe,KAAa,QACzC,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AAEpC,IAAM,uBAAuB,oBAAI,IAA0B;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,wBAAwB,CAC5B,YACA,MACA,WACA,YACG;AACH,MAAI,QAAQ,KAAK,aAAa,KAAK,WAAW,EAAG,QAAO;AAExD,QAAM,gBAAgB,MAAM,YAAY,GAAG,IAAI;AAC/C,MAAI,gBAAgB,WAAW;AAC7B,UAAM,YAAY,IAAI,gBAAgB;AACtC,WAAO,CAAC,KAAK,MAAM,UAAU,SAAS;AAAA,EACxC;AAEA,QAAM,cAAc,MAAM,OAAO,YAAY,GAAG,IAAI;AACpD,MAAI,cAAc,WAAW;AAC3B,UAAM,YAAY,IAAI,cAAc;AACpC,WAAO,KAAK,MAAM,UAAU,SAAS;AAAA,EACvC;AAEA,SAAO;AACT;AAEO,IAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA,0BAA0B;AAC5B,MAAyB,CAAC,uBAAuB,CAAC;AAE3C,IAAM,4BAA4B,CAAC;AAAA,EACxC;AAAA,EACA;AACF,MACE,qBAAqB,IAAI,UAAU,KAClC,eAAe,YAAY,oBAAoB;AAE3C,IAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACF,MACE,WAAW,WACP,eAAe,YAAY,oBAAoB,WAC/C,eAAe;AAEd,IAAM,0BAA0B,CAAC;AAAA,EACtC,YAAY;AAAA,EACZ,iBAAiB;AACnB,OAA8D;AAAA,EAC5D,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,iBAAiB;AACnB;AAEO,IAAM,6BAA6B,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,OAA8D;AAAA,EAC5D,IAAI,sBAAsB,GAAG,OAAO,WAAW,OAAO;AAAA,EACtD,IAAI,sBAAsB,GAAG,QAAQ,WAAW,OAAO;AACzD;","names":[]}
@@ -0,0 +1,16 @@
1
+ import {
2
+ getSelectionEdgeAutoscroll,
3
+ getToolDockDismissState,
4
+ isToolDockToolSelected,
5
+ shouldEnableSelectionDrag,
6
+ shouldEnableViewerScroll
7
+ } from "../chunk-KXNP73MZ.mjs";
8
+ import "../chunk-ZD7AOCMD.mjs";
9
+ export {
10
+ getSelectionEdgeAutoscroll,
11
+ getToolDockDismissState,
12
+ isToolDockToolSelected,
13
+ shouldEnableSelectionDrag,
14
+ shouldEnableViewerScroll
15
+ };
16
+ //# sourceMappingURL=selectionInteraction.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
- import { DocumentEngine, DocumentSource, DocumentType } from '@papyrus-sdk/types';
2
+ import { DocumentEngine, DocumentType, MobilePrimaryDestination, DocumentSource } from '@papyrus-sdk/types';
3
3
  import { PapyrusPageViewProps } from '@papyrus-sdk/engine-native';
4
4
  import { StyleProp, ViewStyle } from 'react-native';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
6
 
6
7
  interface ViewerProps {
7
8
  engine: DocumentEngine;
@@ -16,20 +17,32 @@ interface PageRendererProps {
16
17
  engine: DocumentEngine;
17
18
  pageIndex: number;
18
19
  scale?: number;
20
+ pageAspectRatio?: number;
19
21
  PageViewComponent?: PageViewComponentType;
20
22
  availableWidth?: number;
21
23
  horizontalPadding?: number;
22
24
  spacing?: number;
25
+ onSelectionDragActiveChange?: (active: boolean) => void;
26
+ gestureScrollLockActive?: boolean;
27
+ lastPinchEndedAt?: number | null;
28
+ onHorizontalScrollOffsetChange?: (pageIndex: number, offsetX: number) => void;
29
+ horizontalScrollRestore?: {
30
+ requestId: number;
31
+ offsetX: number;
32
+ } | null;
33
+ requestSelectionVerticalAutoscroll?: (absoluteY: number) => number;
23
34
  }
24
35
  declare const _default: React.NamedExoticComponent<PageRendererProps>;
25
36
 
26
37
  interface TopbarProps {
27
38
  engine: DocumentEngine;
28
39
  onOpenSettings?: () => void;
40
+ onOpenOverflow?: () => void;
29
41
  title?: string;
30
42
  logo?: React.ReactNode;
31
43
  onLogoPress?: () => void;
32
44
  logoAccessibilityLabel?: string;
45
+ showPageNavigationControls?: boolean;
33
46
  }
34
47
  declare const Topbar: React.FC<TopbarProps>;
35
48
 
@@ -37,13 +50,20 @@ declare const ToolDock: React.FC;
37
50
 
38
51
  interface RightSheetProps {
39
52
  engine: DocumentEngine;
53
+ documentType: DocumentType;
40
54
  thumbsInitialCount?: number;
41
55
  }
42
56
  declare const RightSheet: React.FC<RightSheetProps>;
43
57
 
44
58
  declare const AnnotationEditor: React.FC;
45
59
 
46
- declare const BottomBar: React.FC;
60
+ type BottomBarProps = {
61
+ documentType: DocumentType;
62
+ onOpenInfo: () => void;
63
+ onOpenSettings: () => void;
64
+ onOpenDestination: (destination: MobilePrimaryDestination) => void;
65
+ };
66
+ declare const BottomBar: React.FC<BottomBarProps>;
47
67
 
48
68
  interface SettingsSheetProps {
49
69
  engine: DocumentEngine;
@@ -70,4 +90,56 @@ type CoverPreviewProps = {
70
90
  };
71
91
  declare const CoverPreview: React.FC<CoverPreviewProps>;
72
92
 
73
- export { AnnotationEditor, BottomBar, CoverPreview, _default as PageRenderer, RightSheet, SettingsSheet, ToolDock, Topbar, Viewer };
93
+ type ReadingShellProps = {
94
+ engine: DocumentEngine;
95
+ title?: string;
96
+ documentType?: DocumentType;
97
+ thumbsInitialCount?: number;
98
+ viewerProps?: React.ComponentProps<typeof Viewer>;
99
+ };
100
+ declare function ReadingShell({ engine, title, documentType, thumbsInitialCount, viewerProps, }: ReadingShellProps): react_jsx_runtime.JSX.Element;
101
+
102
+ type OverflowSheetProps = {
103
+ visible: boolean;
104
+ onClose: () => void;
105
+ onOpenActions: () => void;
106
+ };
107
+ declare function OverflowSheet({ visible, onClose, onOpenActions, }: OverflowSheetProps): react_jsx_runtime.JSX.Element;
108
+
109
+ type InfoSheetProps = {
110
+ visible: boolean;
111
+ title?: string;
112
+ documentType: DocumentType;
113
+ onClose: () => void;
114
+ };
115
+ declare function InfoSheet({ visible, title, documentType, onClose, }: InfoSheetProps): react_jsx_runtime.JSX.Element;
116
+
117
+ type DocumentActionsSheetProps = {
118
+ visible: boolean;
119
+ onClose: () => void;
120
+ };
121
+ declare function DocumentActionsSheet({ visible, onClose, }: DocumentActionsSheetProps): react_jsx_runtime.JSX.Element;
122
+
123
+ type ProgressPillProps = {
124
+ documentType: DocumentType;
125
+ onPress: () => void;
126
+ };
127
+ declare function ProgressPill({ documentType, onPress }: ProgressPillProps): react_jsx_runtime.JSX.Element;
128
+
129
+ type SearchOverlayProps = {
130
+ engine: DocumentEngine;
131
+ documentType: DocumentType;
132
+ visible: boolean;
133
+ onClose: () => void;
134
+ onOpenResults: () => void;
135
+ };
136
+ declare function SearchOverlay({ engine, documentType, visible, onClose, onOpenResults, }: SearchOverlayProps): react_jsx_runtime.JSX.Element;
137
+
138
+ type SearchResultsSheetProps = {
139
+ documentType: DocumentType;
140
+ visible: boolean;
141
+ onClose: () => void;
142
+ };
143
+ declare function SearchResultsSheet({ documentType, visible, onClose, }: SearchResultsSheetProps): react_jsx_runtime.JSX.Element;
144
+
145
+ export { AnnotationEditor, BottomBar, CoverPreview, DocumentActionsSheet, InfoSheet, OverflowSheet, _default as PageRenderer, ProgressPill, ReadingShell, RightSheet, SearchOverlay, SearchResultsSheet, SettingsSheet, ToolDock, Topbar, Viewer };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
- import { DocumentEngine, DocumentSource, DocumentType } from '@papyrus-sdk/types';
2
+ import { DocumentEngine, DocumentType, MobilePrimaryDestination, DocumentSource } from '@papyrus-sdk/types';
3
3
  import { PapyrusPageViewProps } from '@papyrus-sdk/engine-native';
4
4
  import { StyleProp, ViewStyle } from 'react-native';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
6
 
6
7
  interface ViewerProps {
7
8
  engine: DocumentEngine;
@@ -16,20 +17,32 @@ interface PageRendererProps {
16
17
  engine: DocumentEngine;
17
18
  pageIndex: number;
18
19
  scale?: number;
20
+ pageAspectRatio?: number;
19
21
  PageViewComponent?: PageViewComponentType;
20
22
  availableWidth?: number;
21
23
  horizontalPadding?: number;
22
24
  spacing?: number;
25
+ onSelectionDragActiveChange?: (active: boolean) => void;
26
+ gestureScrollLockActive?: boolean;
27
+ lastPinchEndedAt?: number | null;
28
+ onHorizontalScrollOffsetChange?: (pageIndex: number, offsetX: number) => void;
29
+ horizontalScrollRestore?: {
30
+ requestId: number;
31
+ offsetX: number;
32
+ } | null;
33
+ requestSelectionVerticalAutoscroll?: (absoluteY: number) => number;
23
34
  }
24
35
  declare const _default: React.NamedExoticComponent<PageRendererProps>;
25
36
 
26
37
  interface TopbarProps {
27
38
  engine: DocumentEngine;
28
39
  onOpenSettings?: () => void;
40
+ onOpenOverflow?: () => void;
29
41
  title?: string;
30
42
  logo?: React.ReactNode;
31
43
  onLogoPress?: () => void;
32
44
  logoAccessibilityLabel?: string;
45
+ showPageNavigationControls?: boolean;
33
46
  }
34
47
  declare const Topbar: React.FC<TopbarProps>;
35
48
 
@@ -37,13 +50,20 @@ declare const ToolDock: React.FC;
37
50
 
38
51
  interface RightSheetProps {
39
52
  engine: DocumentEngine;
53
+ documentType: DocumentType;
40
54
  thumbsInitialCount?: number;
41
55
  }
42
56
  declare const RightSheet: React.FC<RightSheetProps>;
43
57
 
44
58
  declare const AnnotationEditor: React.FC;
45
59
 
46
- declare const BottomBar: React.FC;
60
+ type BottomBarProps = {
61
+ documentType: DocumentType;
62
+ onOpenInfo: () => void;
63
+ onOpenSettings: () => void;
64
+ onOpenDestination: (destination: MobilePrimaryDestination) => void;
65
+ };
66
+ declare const BottomBar: React.FC<BottomBarProps>;
47
67
 
48
68
  interface SettingsSheetProps {
49
69
  engine: DocumentEngine;
@@ -70,4 +90,56 @@ type CoverPreviewProps = {
70
90
  };
71
91
  declare const CoverPreview: React.FC<CoverPreviewProps>;
72
92
 
73
- export { AnnotationEditor, BottomBar, CoverPreview, _default as PageRenderer, RightSheet, SettingsSheet, ToolDock, Topbar, Viewer };
93
+ type ReadingShellProps = {
94
+ engine: DocumentEngine;
95
+ title?: string;
96
+ documentType?: DocumentType;
97
+ thumbsInitialCount?: number;
98
+ viewerProps?: React.ComponentProps<typeof Viewer>;
99
+ };
100
+ declare function ReadingShell({ engine, title, documentType, thumbsInitialCount, viewerProps, }: ReadingShellProps): react_jsx_runtime.JSX.Element;
101
+
102
+ type OverflowSheetProps = {
103
+ visible: boolean;
104
+ onClose: () => void;
105
+ onOpenActions: () => void;
106
+ };
107
+ declare function OverflowSheet({ visible, onClose, onOpenActions, }: OverflowSheetProps): react_jsx_runtime.JSX.Element;
108
+
109
+ type InfoSheetProps = {
110
+ visible: boolean;
111
+ title?: string;
112
+ documentType: DocumentType;
113
+ onClose: () => void;
114
+ };
115
+ declare function InfoSheet({ visible, title, documentType, onClose, }: InfoSheetProps): react_jsx_runtime.JSX.Element;
116
+
117
+ type DocumentActionsSheetProps = {
118
+ visible: boolean;
119
+ onClose: () => void;
120
+ };
121
+ declare function DocumentActionsSheet({ visible, onClose, }: DocumentActionsSheetProps): react_jsx_runtime.JSX.Element;
122
+
123
+ type ProgressPillProps = {
124
+ documentType: DocumentType;
125
+ onPress: () => void;
126
+ };
127
+ declare function ProgressPill({ documentType, onPress }: ProgressPillProps): react_jsx_runtime.JSX.Element;
128
+
129
+ type SearchOverlayProps = {
130
+ engine: DocumentEngine;
131
+ documentType: DocumentType;
132
+ visible: boolean;
133
+ onClose: () => void;
134
+ onOpenResults: () => void;
135
+ };
136
+ declare function SearchOverlay({ engine, documentType, visible, onClose, onOpenResults, }: SearchOverlayProps): react_jsx_runtime.JSX.Element;
137
+
138
+ type SearchResultsSheetProps = {
139
+ documentType: DocumentType;
140
+ visible: boolean;
141
+ onClose: () => void;
142
+ };
143
+ declare function SearchResultsSheet({ documentType, visible, onClose, }: SearchResultsSheetProps): react_jsx_runtime.JSX.Element;
144
+
145
+ export { AnnotationEditor, BottomBar, CoverPreview, DocumentActionsSheet, InfoSheet, OverflowSheet, _default as PageRenderer, ProgressPill, ReadingShell, RightSheet, SearchOverlay, SearchResultsSheet, SettingsSheet, ToolDock, Topbar, Viewer };