@papyrus-sdk/ui-react-native 0.2.31 → 0.2.32
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/LICENSE +21 -0
- package/dist/{chunk-KXNP73MZ.mjs → chunk-G6AQ4BV5.mjs} +29 -2
- package/dist/chunk-G6AQ4BV5.mjs.map +1 -0
- package/dist/gesture/selectionInteraction.d.mts +18 -1
- package/dist/gesture/selectionInteraction.d.ts +18 -1
- package/dist/gesture/selectionInteraction.js +28 -0
- package/dist/gesture/selectionInteraction.js.map +1 -1
- package/dist/gesture/selectionInteraction.mjs +3 -1
- package/dist/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +3380 -3150
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3180 -2980
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/dist/chunk-KXNP73MZ.mjs.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Papyrus Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -52,12 +52,39 @@ var getSelectionEdgeAutoscroll = ({
|
|
|
52
52
|
dx: resolveAxisAutoscroll(x, width, threshold, maxStep),
|
|
53
53
|
dy: resolveAxisAutoscroll(y, height, threshold, maxStep)
|
|
54
54
|
});
|
|
55
|
+
var resolveSelectionDragRect = ({
|
|
56
|
+
start,
|
|
57
|
+
end,
|
|
58
|
+
width,
|
|
59
|
+
height,
|
|
60
|
+
lineThreshold
|
|
61
|
+
}) => {
|
|
62
|
+
const top = Math.max(0, Math.min(start.y, end.y));
|
|
63
|
+
const bottom = Math.min(height, Math.max(start.y, end.y));
|
|
64
|
+
const crossesLine = Math.abs(end.y - start.y) > lineThreshold;
|
|
65
|
+
if (!crossesLine) {
|
|
66
|
+
const left2 = Math.max(0, Math.min(start.x, end.x));
|
|
67
|
+
const right2 = Math.min(width, Math.max(start.x, end.x));
|
|
68
|
+
return { x: left2, y: top, width: right2 - left2, height: bottom - top };
|
|
69
|
+
}
|
|
70
|
+
const left = end.y >= start.y ? start.x : 0;
|
|
71
|
+
const right = end.y >= start.y ? width : start.x;
|
|
72
|
+
const clampedLeft = Math.max(0, Math.min(width, left));
|
|
73
|
+
const clampedRight = Math.max(clampedLeft, Math.min(width, right));
|
|
74
|
+
return {
|
|
75
|
+
x: clampedLeft,
|
|
76
|
+
y: top,
|
|
77
|
+
width: clampedRight - clampedLeft,
|
|
78
|
+
height: bottom - top
|
|
79
|
+
};
|
|
80
|
+
};
|
|
55
81
|
|
|
56
82
|
export {
|
|
57
83
|
shouldEnableViewerScroll,
|
|
58
84
|
shouldEnableSelectionDrag,
|
|
59
85
|
isToolDockToolSelected,
|
|
60
86
|
getToolDockDismissState,
|
|
61
|
-
getSelectionEdgeAutoscroll
|
|
87
|
+
getSelectionEdgeAutoscroll,
|
|
88
|
+
resolveSelectionDragRect
|
|
62
89
|
};
|
|
63
|
-
//# sourceMappingURL=chunk-
|
|
90
|
+
//# sourceMappingURL=chunk-G6AQ4BV5.mjs.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\nexport type SelectionDragPoint = {\n x: number;\n y: number;\n};\n\nexport type SelectionDragRectInput = {\n start: SelectionDragPoint;\n end: SelectionDragPoint;\n width: number;\n height: number;\n lineThreshold: 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\nexport const resolveSelectionDragRect = ({\n start,\n end,\n width,\n height,\n lineThreshold,\n}: SelectionDragRectInput) => {\n const top = Math.max(0, Math.min(start.y, end.y));\n const bottom = Math.min(height, Math.max(start.y, end.y));\n const crossesLine = Math.abs(end.y - start.y) > lineThreshold;\n\n if (!crossesLine) {\n const left = Math.max(0, Math.min(start.x, end.x));\n const right = Math.min(width, Math.max(start.x, end.x));\n return { x: left, y: top, width: right - left, height: bottom - top };\n }\n\n const left = end.y >= start.y ? start.x : 0;\n const right = end.y >= start.y ? width : start.x;\n const clampedLeft = Math.max(0, Math.min(width, left));\n const clampedRight = Math.max(clampedLeft, Math.min(width, right));\n return {\n x: clampedLeft,\n y: top,\n width: clampedRight - clampedLeft,\n height: bottom - top,\n };\n};\n"],"mappings":";AAyDA,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,6BAA6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
27
|
dy: number;
|
|
28
28
|
};
|
|
29
|
+
type SelectionDragPoint = {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
};
|
|
33
|
+
type SelectionDragRectInput = {
|
|
34
|
+
start: SelectionDragPoint;
|
|
35
|
+
end: SelectionDragPoint;
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
lineThreshold: number;
|
|
39
|
+
};
|
|
29
40
|
declare const shouldEnableViewerScroll: ({ selectionDragActive, gestureScrollLockActive, }: ViewerScrollState) => boolean;
|
|
30
41
|
declare const shouldEnableSelectionDrag: ({ activeTool, interactionMode, }: SelectionGestureActivationInput) => boolean;
|
|
31
42
|
declare const isToolDockToolSelected: ({ activeTool, interactionMode, toolId, }: ToolDockSelectionState) => boolean;
|
|
32
43
|
declare const getToolDockDismissState: ({ activeTool: _activeTool, interactionMode: _interactionMode, }: SelectionGestureActivationInput) => ToolDockDismissState;
|
|
33
44
|
declare const getSelectionEdgeAutoscroll: ({ x, y, width, height, threshold, maxStep, }: SelectionEdgeAutoscrollInput) => SelectionEdgeAutoscroll;
|
|
45
|
+
declare const resolveSelectionDragRect: ({ start, end, width, height, lineThreshold, }: SelectionDragRectInput) => {
|
|
46
|
+
x: number;
|
|
47
|
+
y: number;
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
};
|
|
34
51
|
|
|
35
|
-
export { type SelectionEdgeAutoscroll, type SelectionEdgeAutoscrollInput, type SelectionGestureActivationInput, type SelectionGestureTool, type SelectionInteractionMode, type ToolDockDismissState, type ToolDockSelectionState, type ViewerScrollState, getSelectionEdgeAutoscroll, getToolDockDismissState, isToolDockToolSelected, shouldEnableSelectionDrag, shouldEnableViewerScroll };
|
|
52
|
+
export { type SelectionDragPoint, type SelectionDragRectInput, type SelectionEdgeAutoscroll, type SelectionEdgeAutoscrollInput, type SelectionGestureActivationInput, type SelectionGestureTool, type SelectionInteractionMode, type ToolDockDismissState, type ToolDockSelectionState, type ViewerScrollState, getSelectionEdgeAutoscroll, getToolDockDismissState, isToolDockToolSelected, resolveSelectionDragRect, shouldEnableSelectionDrag, shouldEnableViewerScroll };
|
|
@@ -26,10 +26,27 @@ type SelectionEdgeAutoscroll = {
|
|
|
26
26
|
dx: number;
|
|
27
27
|
dy: number;
|
|
28
28
|
};
|
|
29
|
+
type SelectionDragPoint = {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
};
|
|
33
|
+
type SelectionDragRectInput = {
|
|
34
|
+
start: SelectionDragPoint;
|
|
35
|
+
end: SelectionDragPoint;
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
lineThreshold: number;
|
|
39
|
+
};
|
|
29
40
|
declare const shouldEnableViewerScroll: ({ selectionDragActive, gestureScrollLockActive, }: ViewerScrollState) => boolean;
|
|
30
41
|
declare const shouldEnableSelectionDrag: ({ activeTool, interactionMode, }: SelectionGestureActivationInput) => boolean;
|
|
31
42
|
declare const isToolDockToolSelected: ({ activeTool, interactionMode, toolId, }: ToolDockSelectionState) => boolean;
|
|
32
43
|
declare const getToolDockDismissState: ({ activeTool: _activeTool, interactionMode: _interactionMode, }: SelectionGestureActivationInput) => ToolDockDismissState;
|
|
33
44
|
declare const getSelectionEdgeAutoscroll: ({ x, y, width, height, threshold, maxStep, }: SelectionEdgeAutoscrollInput) => SelectionEdgeAutoscroll;
|
|
45
|
+
declare const resolveSelectionDragRect: ({ start, end, width, height, lineThreshold, }: SelectionDragRectInput) => {
|
|
46
|
+
x: number;
|
|
47
|
+
y: number;
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
};
|
|
34
51
|
|
|
35
|
-
export { type SelectionEdgeAutoscroll, type SelectionEdgeAutoscrollInput, type SelectionGestureActivationInput, type SelectionGestureTool, type SelectionInteractionMode, type ToolDockDismissState, type ToolDockSelectionState, type ViewerScrollState, getSelectionEdgeAutoscroll, getToolDockDismissState, isToolDockToolSelected, shouldEnableSelectionDrag, shouldEnableViewerScroll };
|
|
52
|
+
export { type SelectionDragPoint, type SelectionDragRectInput, type SelectionEdgeAutoscroll, type SelectionEdgeAutoscrollInput, type SelectionGestureActivationInput, type SelectionGestureTool, type SelectionInteractionMode, type ToolDockDismissState, type ToolDockSelectionState, type ViewerScrollState, getSelectionEdgeAutoscroll, getToolDockDismissState, isToolDockToolSelected, resolveSelectionDragRect, shouldEnableSelectionDrag, shouldEnableViewerScroll };
|
|
@@ -22,6 +22,7 @@ __export(selectionInteraction_exports, {
|
|
|
22
22
|
getSelectionEdgeAutoscroll: () => getSelectionEdgeAutoscroll,
|
|
23
23
|
getToolDockDismissState: () => getToolDockDismissState,
|
|
24
24
|
isToolDockToolSelected: () => isToolDockToolSelected,
|
|
25
|
+
resolveSelectionDragRect: () => resolveSelectionDragRect,
|
|
25
26
|
shouldEnableSelectionDrag: () => shouldEnableSelectionDrag,
|
|
26
27
|
shouldEnableViewerScroll: () => shouldEnableViewerScroll
|
|
27
28
|
});
|
|
@@ -79,11 +80,38 @@ var getSelectionEdgeAutoscroll = ({
|
|
|
79
80
|
dx: resolveAxisAutoscroll(x, width, threshold, maxStep),
|
|
80
81
|
dy: resolveAxisAutoscroll(y, height, threshold, maxStep)
|
|
81
82
|
});
|
|
83
|
+
var resolveSelectionDragRect = ({
|
|
84
|
+
start,
|
|
85
|
+
end,
|
|
86
|
+
width,
|
|
87
|
+
height,
|
|
88
|
+
lineThreshold
|
|
89
|
+
}) => {
|
|
90
|
+
const top = Math.max(0, Math.min(start.y, end.y));
|
|
91
|
+
const bottom = Math.min(height, Math.max(start.y, end.y));
|
|
92
|
+
const crossesLine = Math.abs(end.y - start.y) > lineThreshold;
|
|
93
|
+
if (!crossesLine) {
|
|
94
|
+
const left2 = Math.max(0, Math.min(start.x, end.x));
|
|
95
|
+
const right2 = Math.min(width, Math.max(start.x, end.x));
|
|
96
|
+
return { x: left2, y: top, width: right2 - left2, height: bottom - top };
|
|
97
|
+
}
|
|
98
|
+
const left = end.y >= start.y ? start.x : 0;
|
|
99
|
+
const right = end.y >= start.y ? width : start.x;
|
|
100
|
+
const clampedLeft = Math.max(0, Math.min(width, left));
|
|
101
|
+
const clampedRight = Math.max(clampedLeft, Math.min(width, right));
|
|
102
|
+
return {
|
|
103
|
+
x: clampedLeft,
|
|
104
|
+
y: top,
|
|
105
|
+
width: clampedRight - clampedLeft,
|
|
106
|
+
height: bottom - top
|
|
107
|
+
};
|
|
108
|
+
};
|
|
82
109
|
// Annotate the CommonJS export names for ESM import in node:
|
|
83
110
|
0 && (module.exports = {
|
|
84
111
|
getSelectionEdgeAutoscroll,
|
|
85
112
|
getToolDockDismissState,
|
|
86
113
|
isToolDockToolSelected,
|
|
114
|
+
resolveSelectionDragRect,
|
|
87
115
|
shouldEnableSelectionDrag,
|
|
88
116
|
shouldEnableViewerScroll
|
|
89
117
|
});
|
|
@@ -1 +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;
|
|
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\nexport type SelectionDragPoint = {\n x: number;\n y: number;\n};\n\nexport type SelectionDragRectInput = {\n start: SelectionDragPoint;\n end: SelectionDragPoint;\n width: number;\n height: number;\n lineThreshold: 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\nexport const resolveSelectionDragRect = ({\n start,\n end,\n width,\n height,\n lineThreshold,\n}: SelectionDragRectInput) => {\n const top = Math.max(0, Math.min(start.y, end.y));\n const bottom = Math.min(height, Math.max(start.y, end.y));\n const crossesLine = Math.abs(end.y - start.y) > lineThreshold;\n\n if (!crossesLine) {\n const left = Math.max(0, Math.min(start.x, end.x));\n const right = Math.min(width, Math.max(start.x, end.x));\n return { x: left, y: top, width: right - left, height: bottom - top };\n }\n\n const left = end.y >= start.y ? start.x : 0;\n const right = end.y >= start.y ? width : start.x;\n const clampedLeft = Math.max(0, Math.min(width, left));\n const clampedRight = Math.max(clampedLeft, Math.min(width, right));\n return {\n x: clampedLeft,\n y: top,\n width: clampedRight - clampedLeft,\n height: bottom - top,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyDA,IAAM,QAAQ,CAAC,OAAe,KAAa,QACzC,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AAEpC,IAAM,uBAAuB,oBAAI,IAA0B;AA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;AACF,MAA8B;AAC5B,QAAM,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,MAAM,GAAG,IAAI,CAAC,CAAC;AAChD,QAAM,SAAS,KAAK,IAAI,QAAQ,KAAK,IAAI,MAAM,GAAG,IAAI,CAAC,CAAC;AACxD,QAAM,cAAc,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI;AAEhD,MAAI,CAAC,aAAa;AAChB,UAAMA,QAAO,KAAK,IAAI,GAAG,KAAK,IAAI,MAAM,GAAG,IAAI,CAAC,CAAC;AACjD,UAAMC,SAAQ,KAAK,IAAI,OAAO,KAAK,IAAI,MAAM,GAAG,IAAI,CAAC,CAAC;AACtD,WAAO,EAAE,GAAGD,OAAM,GAAG,KAAK,OAAOC,SAAQD,OAAM,QAAQ,SAAS,IAAI;AAAA,EACtE;AAEA,QAAM,OAAO,IAAI,KAAK,MAAM,IAAI,MAAM,IAAI;AAC1C,QAAM,QAAQ,IAAI,KAAK,MAAM,IAAI,QAAQ,MAAM;AAC/C,QAAM,cAAc,KAAK,IAAI,GAAG,KAAK,IAAI,OAAO,IAAI,CAAC;AACrD,QAAM,eAAe,KAAK,IAAI,aAAa,KAAK,IAAI,OAAO,KAAK,CAAC;AACjE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,IACH,OAAO,eAAe;AAAA,IACtB,QAAQ,SAAS;AAAA,EACnB;AACF;","names":["left","right"]}
|
|
@@ -2,14 +2,16 @@ import {
|
|
|
2
2
|
getSelectionEdgeAutoscroll,
|
|
3
3
|
getToolDockDismissState,
|
|
4
4
|
isToolDockToolSelected,
|
|
5
|
+
resolveSelectionDragRect,
|
|
5
6
|
shouldEnableSelectionDrag,
|
|
6
7
|
shouldEnableViewerScroll
|
|
7
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-G6AQ4BV5.mjs";
|
|
8
9
|
import "../chunk-ZD7AOCMD.mjs";
|
|
9
10
|
export {
|
|
10
11
|
getSelectionEdgeAutoscroll,
|
|
11
12
|
getToolDockDismissState,
|
|
12
13
|
isToolDockToolSelected,
|
|
14
|
+
resolveSelectionDragRect,
|
|
13
15
|
shouldEnableSelectionDrag,
|
|
14
16
|
shouldEnableViewerScroll
|
|
15
17
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -197,6 +197,8 @@ declare const MOBILE_CHROME_METRICS: {
|
|
|
197
197
|
readonly topbarPageButtonSize: 30;
|
|
198
198
|
readonly bottomBarItemPaddingHorizontal: 5;
|
|
199
199
|
readonly bottomBarItemPaddingVertical: 3;
|
|
200
|
+
readonly bottomBarVisualHeight: 52;
|
|
201
|
+
readonly toolDockGap: 12;
|
|
200
202
|
readonly topbarHeight: 56;
|
|
201
203
|
readonly progressGap: 18;
|
|
202
204
|
readonly progressHorizontalOffset: 10;
|
|
@@ -208,5 +210,10 @@ type IconProps = {
|
|
|
208
210
|
strokeWidth?: number;
|
|
209
211
|
};
|
|
210
212
|
declare const IconPageNav: React.FC<IconProps>;
|
|
213
|
+
declare const IconCopy: React.FC<IconProps>;
|
|
214
|
+
declare const IconPencilLine: React.FC<IconProps>;
|
|
215
|
+
declare const IconUnderline: React.FC<IconProps>;
|
|
216
|
+
declare const IconMessageSquareQuote: React.FC<IconProps>;
|
|
217
|
+
declare const IconQuote: React.FC<IconProps>;
|
|
211
218
|
|
|
212
|
-
export { AnnotationEditor, BottomBar, CoverPreview, DocumentActionsSheet, IconPageNav, InfoSheet, MOBILE_CHROME_METRICS, MobilePerfProvider, DedicatedAndroidPdfViewer as NativePdfDocumentViewer, OverflowSheet, _default as PageRenderer, ProgressPill, ReadingShell, RightSheet, SearchOverlay, SearchResultsSheet, SettingsSheet, ToolDock, Topbar, Viewer, createPerfSession, createRunId, useMobilePerf };
|
|
219
|
+
export { AnnotationEditor, BottomBar, CoverPreview, DocumentActionsSheet, IconCopy, IconMessageSquareQuote, IconPageNav, IconPencilLine, IconQuote, IconUnderline, InfoSheet, MOBILE_CHROME_METRICS, MobilePerfProvider, DedicatedAndroidPdfViewer as NativePdfDocumentViewer, OverflowSheet, _default as PageRenderer, ProgressPill, ReadingShell, RightSheet, SearchOverlay, SearchResultsSheet, SettingsSheet, ToolDock, Topbar, Viewer, createPerfSession, createRunId, useMobilePerf };
|
package/dist/index.d.ts
CHANGED
|
@@ -197,6 +197,8 @@ declare const MOBILE_CHROME_METRICS: {
|
|
|
197
197
|
readonly topbarPageButtonSize: 30;
|
|
198
198
|
readonly bottomBarItemPaddingHorizontal: 5;
|
|
199
199
|
readonly bottomBarItemPaddingVertical: 3;
|
|
200
|
+
readonly bottomBarVisualHeight: 52;
|
|
201
|
+
readonly toolDockGap: 12;
|
|
200
202
|
readonly topbarHeight: 56;
|
|
201
203
|
readonly progressGap: 18;
|
|
202
204
|
readonly progressHorizontalOffset: 10;
|
|
@@ -208,5 +210,10 @@ type IconProps = {
|
|
|
208
210
|
strokeWidth?: number;
|
|
209
211
|
};
|
|
210
212
|
declare const IconPageNav: React.FC<IconProps>;
|
|
213
|
+
declare const IconCopy: React.FC<IconProps>;
|
|
214
|
+
declare const IconPencilLine: React.FC<IconProps>;
|
|
215
|
+
declare const IconUnderline: React.FC<IconProps>;
|
|
216
|
+
declare const IconMessageSquareQuote: React.FC<IconProps>;
|
|
217
|
+
declare const IconQuote: React.FC<IconProps>;
|
|
211
218
|
|
|
212
|
-
export { AnnotationEditor, BottomBar, CoverPreview, DocumentActionsSheet, IconPageNav, InfoSheet, MOBILE_CHROME_METRICS, MobilePerfProvider, DedicatedAndroidPdfViewer as NativePdfDocumentViewer, OverflowSheet, _default as PageRenderer, ProgressPill, ReadingShell, RightSheet, SearchOverlay, SearchResultsSheet, SettingsSheet, ToolDock, Topbar, Viewer, createPerfSession, createRunId, useMobilePerf };
|
|
219
|
+
export { AnnotationEditor, BottomBar, CoverPreview, DocumentActionsSheet, IconCopy, IconMessageSquareQuote, IconPageNav, IconPencilLine, IconQuote, IconUnderline, InfoSheet, MOBILE_CHROME_METRICS, MobilePerfProvider, DedicatedAndroidPdfViewer as NativePdfDocumentViewer, OverflowSheet, _default as PageRenderer, ProgressPill, ReadingShell, RightSheet, SearchOverlay, SearchResultsSheet, SettingsSheet, ToolDock, Topbar, Viewer, createPerfSession, createRunId, useMobilePerf };
|