@papyrus-sdk/ui-react-native 0.2.22 → 0.2.24

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.
@@ -1,4 +1,9 @@
1
1
  // gesture/selectionInteraction.ts
2
+ var shouldAcceptSelectionRect = ({
3
+ width,
4
+ height,
5
+ minimumSize = 6
6
+ }) => width >= minimumSize || height >= minimumSize;
2
7
  var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
3
8
  var DRAG_SELECTION_TOOLS = /* @__PURE__ */ new Set([
4
9
  "highlight",
@@ -54,10 +59,11 @@ var getSelectionEdgeAutoscroll = ({
54
59
  });
55
60
 
56
61
  export {
62
+ shouldAcceptSelectionRect,
57
63
  shouldEnableViewerScroll,
58
64
  shouldEnableSelectionDrag,
59
65
  isToolDockToolSelected,
60
66
  getToolDockDismissState,
61
67
  getSelectionEdgeAutoscroll
62
68
  };
63
- //# sourceMappingURL=chunk-KXNP73MZ.mjs.map
69
+ //# sourceMappingURL=chunk-B25KK4VL.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 const shouldAcceptSelectionRect = ({\n width,\n height,\n minimumSize = 6,\n}: {\n width: number;\n height: number;\n minimumSize?: number;\n}) => width >= minimumSize || height >= minimumSize;\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":";AA4CO,IAAM,4BAA4B,CAAC;AAAA,EACxC;AAAA,EACA;AAAA,EACA,cAAc;AAChB,MAIM,SAAS,eAAe,UAAU;AAExC,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":[]}
@@ -26,10 +26,15 @@ type SelectionEdgeAutoscroll = {
26
26
  dx: number;
27
27
  dy: number;
28
28
  };
29
+ declare const shouldAcceptSelectionRect: ({ width, height, minimumSize, }: {
30
+ width: number;
31
+ height: number;
32
+ minimumSize?: number;
33
+ }) => boolean;
29
34
  declare const shouldEnableViewerScroll: ({ selectionDragActive, gestureScrollLockActive, }: ViewerScrollState) => boolean;
30
35
  declare const shouldEnableSelectionDrag: ({ activeTool, interactionMode, }: SelectionGestureActivationInput) => boolean;
31
36
  declare const isToolDockToolSelected: ({ activeTool, interactionMode, toolId, }: ToolDockSelectionState) => boolean;
32
37
  declare const getToolDockDismissState: ({ activeTool: _activeTool, interactionMode: _interactionMode, }: SelectionGestureActivationInput) => ToolDockDismissState;
33
38
  declare const getSelectionEdgeAutoscroll: ({ x, y, width, height, threshold, maxStep, }: SelectionEdgeAutoscrollInput) => SelectionEdgeAutoscroll;
34
39
 
35
- export { type SelectionEdgeAutoscroll, type SelectionEdgeAutoscrollInput, type SelectionGestureActivationInput, type SelectionGestureTool, type SelectionInteractionMode, type ToolDockDismissState, type ToolDockSelectionState, type ViewerScrollState, getSelectionEdgeAutoscroll, getToolDockDismissState, isToolDockToolSelected, shouldEnableSelectionDrag, shouldEnableViewerScroll };
40
+ export { type SelectionEdgeAutoscroll, type SelectionEdgeAutoscrollInput, type SelectionGestureActivationInput, type SelectionGestureTool, type SelectionInteractionMode, type ToolDockDismissState, type ToolDockSelectionState, type ViewerScrollState, getSelectionEdgeAutoscroll, getToolDockDismissState, isToolDockToolSelected, shouldAcceptSelectionRect, shouldEnableSelectionDrag, shouldEnableViewerScroll };
@@ -26,10 +26,15 @@ type SelectionEdgeAutoscroll = {
26
26
  dx: number;
27
27
  dy: number;
28
28
  };
29
+ declare const shouldAcceptSelectionRect: ({ width, height, minimumSize, }: {
30
+ width: number;
31
+ height: number;
32
+ minimumSize?: number;
33
+ }) => boolean;
29
34
  declare const shouldEnableViewerScroll: ({ selectionDragActive, gestureScrollLockActive, }: ViewerScrollState) => boolean;
30
35
  declare const shouldEnableSelectionDrag: ({ activeTool, interactionMode, }: SelectionGestureActivationInput) => boolean;
31
36
  declare const isToolDockToolSelected: ({ activeTool, interactionMode, toolId, }: ToolDockSelectionState) => boolean;
32
37
  declare const getToolDockDismissState: ({ activeTool: _activeTool, interactionMode: _interactionMode, }: SelectionGestureActivationInput) => ToolDockDismissState;
33
38
  declare const getSelectionEdgeAutoscroll: ({ x, y, width, height, threshold, maxStep, }: SelectionEdgeAutoscrollInput) => SelectionEdgeAutoscroll;
34
39
 
35
- export { type SelectionEdgeAutoscroll, type SelectionEdgeAutoscrollInput, type SelectionGestureActivationInput, type SelectionGestureTool, type SelectionInteractionMode, type ToolDockDismissState, type ToolDockSelectionState, type ViewerScrollState, getSelectionEdgeAutoscroll, getToolDockDismissState, isToolDockToolSelected, shouldEnableSelectionDrag, shouldEnableViewerScroll };
40
+ export { type SelectionEdgeAutoscroll, type SelectionEdgeAutoscrollInput, type SelectionGestureActivationInput, type SelectionGestureTool, type SelectionInteractionMode, type ToolDockDismissState, type ToolDockSelectionState, type ViewerScrollState, getSelectionEdgeAutoscroll, getToolDockDismissState, isToolDockToolSelected, shouldAcceptSelectionRect, shouldEnableSelectionDrag, shouldEnableViewerScroll };
@@ -22,10 +22,16 @@ __export(selectionInteraction_exports, {
22
22
  getSelectionEdgeAutoscroll: () => getSelectionEdgeAutoscroll,
23
23
  getToolDockDismissState: () => getToolDockDismissState,
24
24
  isToolDockToolSelected: () => isToolDockToolSelected,
25
+ shouldAcceptSelectionRect: () => shouldAcceptSelectionRect,
25
26
  shouldEnableSelectionDrag: () => shouldEnableSelectionDrag,
26
27
  shouldEnableViewerScroll: () => shouldEnableViewerScroll
27
28
  });
28
29
  module.exports = __toCommonJS(selectionInteraction_exports);
30
+ var shouldAcceptSelectionRect = ({
31
+ width,
32
+ height,
33
+ minimumSize = 6
34
+ }) => width >= minimumSize || height >= minimumSize;
29
35
  var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
30
36
  var DRAG_SELECTION_TOOLS = /* @__PURE__ */ new Set([
31
37
  "highlight",
@@ -84,6 +90,7 @@ var getSelectionEdgeAutoscroll = ({
84
90
  getSelectionEdgeAutoscroll,
85
91
  getToolDockDismissState,
86
92
  isToolDockToolSelected,
93
+ shouldAcceptSelectionRect,
87
94
  shouldEnableSelectionDrag,
88
95
  shouldEnableViewerScroll
89
96
  });
@@ -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;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":[]}
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 const shouldAcceptSelectionRect = ({\n width,\n height,\n minimumSize = 6,\n}: {\n width: number;\n height: number;\n minimumSize?: number;\n}) => width >= minimumSize || height >= minimumSize;\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;AAAA;AA4CO,IAAM,4BAA4B,CAAC;AAAA,EACxC;AAAA,EACA;AAAA,EACA,cAAc;AAChB,MAIM,SAAS,eAAe,UAAU;AAExC,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":[]}
@@ -2,14 +2,16 @@ import {
2
2
  getSelectionEdgeAutoscroll,
3
3
  getToolDockDismissState,
4
4
  isToolDockToolSelected,
5
+ shouldAcceptSelectionRect,
5
6
  shouldEnableSelectionDrag,
6
7
  shouldEnableViewerScroll
7
- } from "../chunk-KXNP73MZ.mjs";
8
+ } from "../chunk-B25KK4VL.mjs";
8
9
  import "../chunk-ZD7AOCMD.mjs";
9
10
  export {
10
11
  getSelectionEdgeAutoscroll,
11
12
  getToolDockDismissState,
12
13
  isToolDockToolSelected,
14
+ shouldAcceptSelectionRect,
13
15
  shouldEnableSelectionDrag,
14
16
  shouldEnableViewerScroll
15
17
  };
package/dist/index.d.mts CHANGED
@@ -19,6 +19,7 @@ interface ViewerProps {
19
19
  text: string;
20
20
  pageIndex: number;
21
21
  }) => void;
22
+ selectionActionLabel?: string;
22
23
  }
23
24
  declare const Viewer: React.FC<ViewerProps>;
24
25
 
@@ -42,6 +43,7 @@ interface PageRendererProps {
42
43
  text: string;
43
44
  pageIndex: number;
44
45
  }) => void;
46
+ selectionActionLabel?: string;
45
47
  gestureScrollLockActive?: boolean;
46
48
  lastPinchEndedAt?: number | null;
47
49
  requestSelectionVerticalAutoscroll?: (absoluteY: number) => number;
@@ -117,8 +119,13 @@ declare function ReadingShell({ engine, title, documentType, thumbsInitialCount,
117
119
 
118
120
  type DedicatedAndroidPdfViewerProps = {
119
121
  engine: DocumentEngine;
122
+ onDefineSelection?: (payload: {
123
+ text: string;
124
+ pageIndex: number;
125
+ }) => void;
126
+ selectionActionLabel?: string;
120
127
  };
121
- declare function DedicatedAndroidPdfViewer({ engine, }: DedicatedAndroidPdfViewerProps): react_jsx_runtime.JSX.Element;
128
+ declare function DedicatedAndroidPdfViewer({ engine, onDefineSelection, selectionActionLabel, }: DedicatedAndroidPdfViewerProps): react_jsx_runtime.JSX.Element;
122
129
 
123
130
  type OverflowSheetProps = {
124
131
  visible: boolean;
package/dist/index.d.ts CHANGED
@@ -19,6 +19,7 @@ interface ViewerProps {
19
19
  text: string;
20
20
  pageIndex: number;
21
21
  }) => void;
22
+ selectionActionLabel?: string;
22
23
  }
23
24
  declare const Viewer: React.FC<ViewerProps>;
24
25
 
@@ -42,6 +43,7 @@ interface PageRendererProps {
42
43
  text: string;
43
44
  pageIndex: number;
44
45
  }) => void;
46
+ selectionActionLabel?: string;
45
47
  gestureScrollLockActive?: boolean;
46
48
  lastPinchEndedAt?: number | null;
47
49
  requestSelectionVerticalAutoscroll?: (absoluteY: number) => number;
@@ -117,8 +119,13 @@ declare function ReadingShell({ engine, title, documentType, thumbsInitialCount,
117
119
 
118
120
  type DedicatedAndroidPdfViewerProps = {
119
121
  engine: DocumentEngine;
122
+ onDefineSelection?: (payload: {
123
+ text: string;
124
+ pageIndex: number;
125
+ }) => void;
126
+ selectionActionLabel?: string;
120
127
  };
121
- declare function DedicatedAndroidPdfViewer({ engine, }: DedicatedAndroidPdfViewerProps): react_jsx_runtime.JSX.Element;
128
+ declare function DedicatedAndroidPdfViewer({ engine, onDefineSelection, selectionActionLabel, }: DedicatedAndroidPdfViewerProps): react_jsx_runtime.JSX.Element;
122
129
 
123
130
  type OverflowSheetProps = {
124
131
  visible: boolean;
package/dist/index.js CHANGED
@@ -21951,6 +21951,11 @@ var shouldSuppressPressAfterPinch = (lastPinchEndedAt, now = Date.now(), windowM
21951
21951
  };
21952
21952
 
21953
21953
  // gesture/selectionInteraction.ts
21954
+ var shouldAcceptSelectionRect = ({
21955
+ width,
21956
+ height,
21957
+ minimumSize = 6
21958
+ }) => width >= minimumSize || height >= minimumSize;
21954
21959
  var clamp2 = (value, min, max) => Math.min(max, Math.max(min, value));
21955
21960
  var DRAG_SELECTION_TOOLS = /* @__PURE__ */ new Set([
21956
21961
  "highlight",
@@ -22173,6 +22178,7 @@ var PageRenderer = ({
22173
22178
  onSelectionDragActiveChange,
22174
22179
  onTextSelected,
22175
22180
  onDefineSelection,
22181
+ selectionActionLabel,
22176
22182
  gestureScrollLockActive = false,
22177
22183
  lastPinchEndedAt = null,
22178
22184
  requestSelectionVerticalAutoscroll
@@ -22695,8 +22701,7 @@ var PageRenderer = ({
22695
22701
  }
22696
22702
  setIsSelecting(false);
22697
22703
  selectionStart.current = null;
22698
- const minSize = 6;
22699
- if (rect.width < minSize || rect.height < minSize) {
22704
+ if (!shouldAcceptSelectionRect(rect)) {
22700
22705
  clearSelection();
22701
22706
  return;
22702
22707
  }
@@ -23475,7 +23480,7 @@ var PageRenderer = ({
23475
23480
  });
23476
23481
  },
23477
23482
  style: [styles.selectionAction, styles.defineSelectionAction],
23478
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { style: styles.defineSelectionText, children: "Definir" })
23483
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { style: styles.defineSelectionText, children: selectionActionLabel ?? "Definir" })
23479
23484
  }
23480
23485
  ) : null,
23481
23486
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -23817,7 +23822,7 @@ var styles = import_react_native.StyleSheet.create({
23817
23822
  borderRadius: 3
23818
23823
  }
23819
23824
  });
23820
- var arePageRendererPropsEqual = (previous, next) => previous.engine === next.engine && previous.pageIndex === next.pageIndex && previous.scale === next.scale && previous.PageViewComponent === next.PageViewComponent && previous.availableWidth === next.availableWidth && previous.pageViewportWidth === next.pageViewportWidth && previous.horizontalPadding === next.horizontalPadding && previous.spacing === next.spacing && previous.onSelectionDragActiveChange === next.onSelectionDragActiveChange && previous.onTextSelected === next.onTextSelected && previous.onDefineSelection === next.onDefineSelection && previous.gestureScrollLockActive === next.gestureScrollLockActive && previous.lastPinchEndedAt === next.lastPinchEndedAt && previous.requestSelectionVerticalAutoscroll === next.requestSelectionVerticalAutoscroll;
23825
+ var arePageRendererPropsEqual = (previous, next) => previous.engine === next.engine && previous.pageIndex === next.pageIndex && previous.scale === next.scale && previous.PageViewComponent === next.PageViewComponent && previous.availableWidth === next.availableWidth && previous.pageViewportWidth === next.pageViewportWidth && previous.horizontalPadding === next.horizontalPadding && previous.spacing === next.spacing && previous.onSelectionDragActiveChange === next.onSelectionDragActiveChange && previous.onTextSelected === next.onTextSelected && previous.onDefineSelection === next.onDefineSelection && previous.selectionActionLabel === next.selectionActionLabel && previous.gestureScrollLockActive === next.gestureScrollLockActive && previous.lastPinchEndedAt === next.lastPinchEndedAt && previous.requestSelectionVerticalAutoscroll === next.requestSelectionVerticalAutoscroll;
23821
23826
  var PageRenderer_default = (0, import_react.memo)(PageRenderer, arePageRendererPropsEqual);
23822
23827
 
23823
23828
  // components/WebViewViewer.tsx
@@ -24646,6 +24651,11 @@ var IconCommentBubble = ({
24646
24651
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_svg2.Circle, { cx: "15", cy: "11", r: "1", fill: color })
24647
24652
  ] });
24648
24653
 
24654
+ // components/selectionToolbarModel.ts
24655
+ var getSelectionToolbarActions = (label = "Definir") => [
24656
+ { id: "dictionary", label }
24657
+ ];
24658
+
24649
24659
  // components/DedicatedAndroidPdfViewer.tsx
24650
24660
  var import_jsx_runtime4 = require("react/jsx-runtime");
24651
24661
  var TEXT_MARKUP_TOOLS2 = /* @__PURE__ */ new Set(["highlight", "underline", "squiggly", "strikeout"]);
@@ -24658,7 +24668,9 @@ var getDedicatedAndroidPdfEngineId = (engine) => {
24658
24668
  return typeof engineId === "string" && engineId.length > 0 ? engineId : null;
24659
24669
  };
24660
24670
  function DedicatedAndroidPdfViewer({
24661
- engine
24671
+ engine,
24672
+ onDefineSelection,
24673
+ selectionActionLabel
24662
24674
  }) {
24663
24675
  const pageTheme = (0, import_core3.useViewerStore)((state) => state.pageTheme);
24664
24676
  const zoom = (0, import_core3.useViewerStore)((state) => state.zoom);
@@ -24841,6 +24853,27 @@ function DedicatedAndroidPdfViewer({
24841
24853
  }
24842
24854
  ),
24843
24855
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native3.View, { style: styles3.selectionToolbar, pointerEvents: "box-none", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native3.View, { style: styles3.toolbarContent, children: [
24856
+ onDefineSelection && getSelectionToolbarActions(selectionActionLabel).map((action) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
24857
+ import_react_native3.Pressable,
24858
+ {
24859
+ accessibilityRole: "button",
24860
+ accessibilityLabel: action.label,
24861
+ onPress: () => {
24862
+ const currentSelection = selectionRef.current;
24863
+ if (!currentSelection) return;
24864
+ onDefineSelection({
24865
+ text: currentSelection.text,
24866
+ pageIndex: currentSelection.pageIndex
24867
+ });
24868
+ },
24869
+ style: [styles3.toolbarButton, styles3.dictionaryButton],
24870
+ children: [
24871
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IconInfo, { size: 16, color: "#fff" }),
24872
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native3.Text, { style: styles3.toolbarButtonText, children: action.label })
24873
+ ]
24874
+ },
24875
+ action.id
24876
+ )),
24844
24877
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
24845
24878
  import_react_native3.Pressable,
24846
24879
  {
@@ -24922,6 +24955,11 @@ var styles3 = import_react_native3.StyleSheet.create({
24922
24955
  alignItems: "center",
24923
24956
  justifyContent: "center"
24924
24957
  },
24958
+ dictionaryButton: {
24959
+ width: 118,
24960
+ flexDirection: "row",
24961
+ gap: 6
24962
+ },
24925
24963
  overlay: {
24926
24964
  ...import_react_native3.StyleSheet.absoluteFillObject,
24927
24965
  zIndex: 40
@@ -24973,7 +25011,8 @@ var Viewer = ({
24973
25011
  useDedicatedAndroidPdfViewer,
24974
25012
  viewerMode,
24975
25013
  onTextSelected,
24976
- onDefineSelection
25014
+ onDefineSelection,
25015
+ selectionActionLabel
24977
25016
  }) => {
24978
25017
  const pageCount = (0, import_core4.useViewerStore)((state) => state.pageCount);
24979
25018
  const currentPage = (0, import_core4.useViewerStore)((state) => state.currentPage);
@@ -26111,6 +26150,7 @@ var Viewer = ({
26111
26150
  onSelectionDragActiveChange: setSelectionDragActive,
26112
26151
  onTextSelected,
26113
26152
  onDefineSelection,
26153
+ selectionActionLabel,
26114
26154
  gestureScrollLockActive,
26115
26155
  lastPinchEndedAt,
26116
26156
  requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
@@ -26129,6 +26169,7 @@ var Viewer = ({
26129
26169
  onSelectionDragActiveChange: setSelectionDragActive,
26130
26170
  onTextSelected,
26131
26171
  onDefineSelection,
26172
+ selectionActionLabel,
26132
26173
  gestureScrollLockActive,
26133
26174
  lastPinchEndedAt,
26134
26175
  requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
@@ -26150,6 +26191,7 @@ var Viewer = ({
26150
26191
  onSelectionDragActiveChange: setSelectionDragActive,
26151
26192
  onTextSelected,
26152
26193
  onDefineSelection,
26194
+ selectionActionLabel,
26153
26195
  gestureScrollLockActive,
26154
26196
  lastPinchEndedAt,
26155
26197
  requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
@@ -26173,7 +26215,14 @@ var Viewer = ({
26173
26215
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native4.View, { style: [styles4.container, isDark && styles4.containerDark], children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(WebViewViewer_default, { engine }) });
26174
26216
  }
26175
26217
  if (isNativePdfViewer) {
26176
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native4.View, { style: [styles4.container, isDark && styles4.containerDark], children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DedicatedAndroidPdfViewer, { engine }) });
26218
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native4.View, { style: [styles4.container, isDark && styles4.containerDark], children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
26219
+ DedicatedAndroidPdfViewer,
26220
+ {
26221
+ engine,
26222
+ onDefineSelection,
26223
+ selectionActionLabel
26224
+ }
26225
+ ) });
26177
26226
  }
26178
26227
  if (isSingle) {
26179
26228
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native4.View, { style: [styles4.container, isDark && styles4.containerDark], children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native_gesture_handler2.GestureDetector, { gesture: viewerPinchGesture, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
@@ -26241,6 +26290,7 @@ var Viewer = ({
26241
26290
  onSelectionDragActiveChange: setSelectionDragActive,
26242
26291
  onTextSelected,
26243
26292
  onDefineSelection,
26293
+ selectionActionLabel,
26244
26294
  gestureScrollLockActive,
26245
26295
  lastPinchEndedAt,
26246
26296
  requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll