@anaralabs/lector 3.5.13 → 3.6.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.
@@ -1,5 +1,4 @@
1
1
  import { ComponentPropsWithoutRef } from 'react';
2
- import { Context } from 'react';
3
2
  import type { DocumentInitParameters } from 'pdfjs-dist/types/src/display/api';
4
3
  import { ForwardRefExoticComponent } from 'react';
5
4
  import { FunctionComponent } from 'react';
@@ -97,7 +96,7 @@ declare interface AnnotationState {
97
96
  setAnnotations: (annotations: Annotation[]) => void;
98
97
  }
99
98
 
100
- export declare const AnnotationTooltip: ({ annotation, children, renderTooltipContent, hoverTooltipContent, onOpenChange, className, focusedOpenId, hoverClassName, isOpen: controlledIsOpen, hoverIsOpen: controlledHoverIsOpen, }: AnnotationTooltipProps) => JSX.Element;
99
+ export declare const AnnotationTooltip: ({ annotation, children, renderTooltipContent, hoverTooltipContent, onOpenChange, className, focusedOpenId, focusedHoverOpenId, hoverClassName, isOpen: controlledIsOpen, hoverIsOpen: controlledHoverIsOpen, }: AnnotationTooltipProps) => JSX.Element;
101
100
 
102
101
  export declare type AnnotationTooltipContentProps = {
103
102
  annotation: Annotation;
@@ -113,6 +112,7 @@ declare interface AnnotationTooltipProps {
113
112
  onOpenChange?: (open: boolean) => void;
114
113
  isOpen?: boolean;
115
114
  focusedOpenId?: string;
115
+ focusedHoverOpenId?: string;
116
116
  className?: string;
117
117
  hoverClassName?: string;
118
118
  hoverIsOpen?: boolean;
@@ -202,6 +202,7 @@ declare type HighlightRect = {
202
202
  height: number;
203
203
  width: number;
204
204
  type?: "pixels" | "percent";
205
+ style?: (rect: HighlightRect) => React_2.CSSProperties;
205
206
  };
206
207
  export { HighlightRect }
207
208
  export { HighlightRect as HighlightRect_alias_1 }
@@ -298,7 +299,7 @@ declare interface PDFState {
298
299
  currentPage: number;
299
300
  setCurrentPage: (pageNumber: number) => void;
300
301
  viewports: Array<PageViewport>;
301
- viewportRef: React.MutableRefObject<HTMLDivElement | null>;
302
+ viewportRef: React_2.MutableRefObject<HTMLDivElement | null>;
302
303
  pageProxies: PDFPageProxy[];
303
304
  textContent: TextContent[];
304
305
  setTextContent: (textContents: TextContent[]) => void;
@@ -317,9 +318,9 @@ declare interface PDFState {
317
318
 
318
319
  export declare const PDFStore: {
319
320
  useContext: () => StoreApi<PDFState>;
320
- Context: Context<StoreApi<PDFState>>;
321
+ Context: React_2.Context<StoreApi<PDFState>>;
321
322
  Provider: (props: {
322
- children?: React.ReactNode;
323
+ children?: React_2.ReactNode;
323
324
  initialValue: InitialPDFState;
324
325
  }) => JSX.Element;
325
326
  };
package/dist/index.js CHANGED
@@ -275,6 +275,7 @@ var AnnotationTooltip = ({
275
275
  onOpenChange,
276
276
  className,
277
277
  focusedOpenId,
278
+ focusedHoverOpenId,
278
279
  hoverClassName,
279
280
  isOpen: controlledIsOpen,
280
281
  hoverIsOpen: controlledHoverIsOpen
@@ -317,6 +318,7 @@ var AnnotationTooltip = ({
317
318
  }, [controlledIsOpen, isOpen, setIsOpen]);
318
319
  const handleMouseEnter = useCallback(() => {
319
320
  if (focusedOpenId && focusedOpenId !== annotation.id) return;
321
+ if (focusedHoverOpenId && focusedHoverOpenId !== annotation.id) return;
320
322
  if (hoverTooltipContent) {
321
323
  if (closeTimeoutRef.current) {
322
324
  clearTimeout(closeTimeoutRef.current);
@@ -335,6 +337,8 @@ var AnnotationTooltip = ({
335
337
  closeTimeoutRef.current = setTimeout(closeTooltip, 100);
336
338
  }, [hoverTooltipContent, closeTooltip]);
337
339
  const handleTooltipMouseEnter = useCallback(() => {
340
+ if (focusedOpenId && focusedOpenId !== annotation.id) return;
341
+ if (focusedHoverOpenId && focusedHoverOpenId !== annotation.id) return;
338
342
  isMouseInTooltipRef.current = true;
339
343
  if (closeTimeoutRef.current) {
340
344
  clearTimeout(closeTimeoutRef.current);
@@ -505,6 +509,7 @@ var AnnotationHighlightLayer = ({
505
509
  className: tooltipClassName,
506
510
  hoverClassName: hoverTooltipClassName,
507
511
  focusedOpenId: focusedAnnotationId,
512
+ focusedHoverOpenId: focusedHoverAnnotationId,
508
513
  isOpen: focusedAnnotationId === annotation.id,
509
514
  hoverIsOpen: focusedHoverAnnotationId === annotation.id,
510
515
  onOpenChange: (open) => {
@@ -1875,11 +1880,12 @@ var HighlightLayer = forwardRef(({ asChild, className, style, ...props }, ref) =
1875
1880
  const rects = highlights.filter((area) => area.pageNumber === pageNumber);
1876
1881
  if (!rects?.length) return null;
1877
1882
  return /* @__PURE__ */ jsx(Fragment, { children: rects.map((rect, index) => {
1878
- const { pageNumber: pageNumber2, type, ...coordinates } = rect;
1883
+ const { pageNumber: pageNumber2, type, style: customStyle, ...coordinates } = rect;
1879
1884
  let dimensions = coordinates;
1880
1885
  if (type === "percent") {
1881
1886
  dimensions = convertToPercentString(rect);
1882
1887
  }
1888
+ const customStyles = customStyle ? customStyle(rect) : {};
1883
1889
  return /* @__PURE__ */ jsx(
1884
1890
  Comp,
1885
1891
  {
@@ -1890,7 +1896,8 @@ var HighlightLayer = forwardRef(({ asChild, className, style, ...props }, ref) =
1890
1896
  ...dimensions,
1891
1897
  pointerEvents: "none",
1892
1898
  zIndex: 30,
1893
- ...style
1899
+ ...style,
1900
+ ...customStyles
1894
1901
  },
1895
1902
  ...props,
1896
1903
  children: props.children
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anaralabs/lector",
3
- "version": "3.5.13",
3
+ "version": "3.6.0",
4
4
  "description": "Headless PDF viewer for React",
5
5
  "author": "andrewdr (https://github.com/andrewdoro)",
6
6
  "license": "MIT",