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

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 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.
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
@@ -22173,6 +22173,7 @@ var PageRenderer = ({
22173
22173
  onSelectionDragActiveChange,
22174
22174
  onTextSelected,
22175
22175
  onDefineSelection,
22176
+ selectionActionLabel,
22176
22177
  gestureScrollLockActive = false,
22177
22178
  lastPinchEndedAt = null,
22178
22179
  requestSelectionVerticalAutoscroll
@@ -23475,7 +23476,7 @@ var PageRenderer = ({
23475
23476
  });
23476
23477
  },
23477
23478
  style: [styles.selectionAction, styles.defineSelectionAction],
23478
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { style: styles.defineSelectionText, children: "Definir" })
23479
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { style: styles.defineSelectionText, children: selectionActionLabel ?? "Definir" })
23479
23480
  }
23480
23481
  ) : null,
23481
23482
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -23817,7 +23818,7 @@ var styles = import_react_native.StyleSheet.create({
23817
23818
  borderRadius: 3
23818
23819
  }
23819
23820
  });
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;
23821
+ 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
23822
  var PageRenderer_default = (0, import_react.memo)(PageRenderer, arePageRendererPropsEqual);
23822
23823
 
23823
23824
  // components/WebViewViewer.tsx
@@ -24646,6 +24647,11 @@ var IconCommentBubble = ({
24646
24647
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_svg2.Circle, { cx: "15", cy: "11", r: "1", fill: color })
24647
24648
  ] });
24648
24649
 
24650
+ // components/selectionToolbarModel.ts
24651
+ var getSelectionToolbarActions = (label = "Definir") => [
24652
+ { id: "dictionary", label }
24653
+ ];
24654
+
24649
24655
  // components/DedicatedAndroidPdfViewer.tsx
24650
24656
  var import_jsx_runtime4 = require("react/jsx-runtime");
24651
24657
  var TEXT_MARKUP_TOOLS2 = /* @__PURE__ */ new Set(["highlight", "underline", "squiggly", "strikeout"]);
@@ -24658,7 +24664,9 @@ var getDedicatedAndroidPdfEngineId = (engine) => {
24658
24664
  return typeof engineId === "string" && engineId.length > 0 ? engineId : null;
24659
24665
  };
24660
24666
  function DedicatedAndroidPdfViewer({
24661
- engine
24667
+ engine,
24668
+ onDefineSelection,
24669
+ selectionActionLabel
24662
24670
  }) {
24663
24671
  const pageTheme = (0, import_core3.useViewerStore)((state) => state.pageTheme);
24664
24672
  const zoom = (0, import_core3.useViewerStore)((state) => state.zoom);
@@ -24841,6 +24849,27 @@ function DedicatedAndroidPdfViewer({
24841
24849
  }
24842
24850
  ),
24843
24851
  /* @__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: [
24852
+ onDefineSelection && getSelectionToolbarActions(selectionActionLabel).map((action) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
24853
+ import_react_native3.Pressable,
24854
+ {
24855
+ accessibilityRole: "button",
24856
+ accessibilityLabel: action.label,
24857
+ onPress: () => {
24858
+ const currentSelection = selectionRef.current;
24859
+ if (!currentSelection) return;
24860
+ onDefineSelection({
24861
+ text: currentSelection.text,
24862
+ pageIndex: currentSelection.pageIndex
24863
+ });
24864
+ },
24865
+ style: [styles3.toolbarButton, styles3.dictionaryButton],
24866
+ children: [
24867
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IconInfo, { size: 16, color: "#fff" }),
24868
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native3.Text, { style: styles3.toolbarButtonText, children: action.label })
24869
+ ]
24870
+ },
24871
+ action.id
24872
+ )),
24844
24873
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
24845
24874
  import_react_native3.Pressable,
24846
24875
  {
@@ -24922,6 +24951,11 @@ var styles3 = import_react_native3.StyleSheet.create({
24922
24951
  alignItems: "center",
24923
24952
  justifyContent: "center"
24924
24953
  },
24954
+ dictionaryButton: {
24955
+ width: 118,
24956
+ flexDirection: "row",
24957
+ gap: 6
24958
+ },
24925
24959
  overlay: {
24926
24960
  ...import_react_native3.StyleSheet.absoluteFillObject,
24927
24961
  zIndex: 40
@@ -24973,7 +25007,8 @@ var Viewer = ({
24973
25007
  useDedicatedAndroidPdfViewer,
24974
25008
  viewerMode,
24975
25009
  onTextSelected,
24976
- onDefineSelection
25010
+ onDefineSelection,
25011
+ selectionActionLabel
24977
25012
  }) => {
24978
25013
  const pageCount = (0, import_core4.useViewerStore)((state) => state.pageCount);
24979
25014
  const currentPage = (0, import_core4.useViewerStore)((state) => state.currentPage);
@@ -26111,6 +26146,7 @@ var Viewer = ({
26111
26146
  onSelectionDragActiveChange: setSelectionDragActive,
26112
26147
  onTextSelected,
26113
26148
  onDefineSelection,
26149
+ selectionActionLabel,
26114
26150
  gestureScrollLockActive,
26115
26151
  lastPinchEndedAt,
26116
26152
  requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
@@ -26129,6 +26165,7 @@ var Viewer = ({
26129
26165
  onSelectionDragActiveChange: setSelectionDragActive,
26130
26166
  onTextSelected,
26131
26167
  onDefineSelection,
26168
+ selectionActionLabel,
26132
26169
  gestureScrollLockActive,
26133
26170
  lastPinchEndedAt,
26134
26171
  requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
@@ -26150,6 +26187,7 @@ var Viewer = ({
26150
26187
  onSelectionDragActiveChange: setSelectionDragActive,
26151
26188
  onTextSelected,
26152
26189
  onDefineSelection,
26190
+ selectionActionLabel,
26153
26191
  gestureScrollLockActive,
26154
26192
  lastPinchEndedAt,
26155
26193
  requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
@@ -26173,7 +26211,14 @@ var Viewer = ({
26173
26211
  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
26212
  }
26175
26213
  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 }) });
26214
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native4.View, { style: [styles4.container, isDark && styles4.containerDark], children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
26215
+ DedicatedAndroidPdfViewer,
26216
+ {
26217
+ engine,
26218
+ onDefineSelection,
26219
+ selectionActionLabel
26220
+ }
26221
+ ) });
26177
26222
  }
26178
26223
  if (isSingle) {
26179
26224
  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 +26286,7 @@ var Viewer = ({
26241
26286
  onSelectionDragActiveChange: setSelectionDragActive,
26242
26287
  onTextSelected,
26243
26288
  onDefineSelection,
26289
+ selectionActionLabel,
26244
26290
  gestureScrollLockActive,
26245
26291
  lastPinchEndedAt,
26246
26292
  requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll