@annotorious/react 3.4.3 → 3.4.4

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.
Files changed (42) hide show
  1. package/dist/annotorious-react.es.js +19 -17
  2. package/dist/annotorious-react.es.js.map +1 -1
  3. package/dist/annotorious-react.es10.js +31 -15
  4. package/dist/annotorious-react.es10.js.map +1 -1
  5. package/dist/annotorious-react.es11.js +16 -8
  6. package/dist/annotorious-react.es11.js.map +1 -1
  7. package/dist/annotorious-react.es12.js +7 -252
  8. package/dist/annotorious-react.es12.js.map +1 -1
  9. package/dist/annotorious-react.es13.js +251 -7
  10. package/dist/annotorious-react.es13.js.map +1 -1
  11. package/dist/annotorious-react.es14.js +9 -395
  12. package/dist/annotorious-react.es14.js.map +1 -1
  13. package/dist/annotorious-react.es15.js +383 -185
  14. package/dist/annotorious-react.es15.js.map +1 -1
  15. package/dist/annotorious-react.es16.js +196 -13
  16. package/dist/annotorious-react.es16.js.map +1 -1
  17. package/dist/annotorious-react.es17.js +13 -20
  18. package/dist/annotorious-react.es17.js.map +1 -1
  19. package/dist/annotorious-react.es18.js +19 -127
  20. package/dist/annotorious-react.es18.js.map +1 -1
  21. package/dist/annotorious-react.es19.js +128 -6
  22. package/dist/annotorious-react.es19.js.map +1 -1
  23. package/dist/annotorious-react.es2.js +1 -1
  24. package/dist/annotorious-react.es20.js +7 -2
  25. package/dist/annotorious-react.es20.js.map +1 -1
  26. package/dist/annotorious-react.es21.js +2 -11
  27. package/dist/annotorious-react.es21.js.map +1 -1
  28. package/dist/annotorious-react.es22.js +9 -124
  29. package/dist/annotorious-react.es22.js.map +1 -1
  30. package/dist/annotorious-react.es23.js +112 -456
  31. package/dist/annotorious-react.es23.js.map +1 -1
  32. package/dist/annotorious-react.es24.js +473 -0
  33. package/dist/annotorious-react.es24.js.map +1 -0
  34. package/dist/annotorious-react.es4.js +5 -5
  35. package/dist/annotorious-react.es8.js.map +1 -1
  36. package/dist/annotorious-react.es9.js +5 -5
  37. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts.map +1 -1
  38. package/dist/openseadragon/OpenSeadragonHoverTooltip.d.ts +14 -0
  39. package/dist/openseadragon/OpenSeadragonHoverTooltip.d.ts.map +1 -0
  40. package/dist/openseadragon/index.d.ts +1 -0
  41. package/dist/openseadragon/index.d.ts.map +1 -1
  42. package/package.json +4 -4
@@ -1,14 +1,15 @@
1
- import { Annotorious as r, AnnotoriousContext as a, useAnnotation as i, useAnnotationSelectAction as p, useAnnotationStore as s, useAnnotations as m, useAnnotator as u, useAnnotatorUser as A, useHover as S, useSelection as l, useViewportState as c } from "./annotorious-react.es2.js";
1
+ import { Annotorious as r, AnnotoriousContext as a, useAnnotation as i, useAnnotationSelectAction as p, useAnnotationStore as s, useAnnotations as m, useAnnotator as u, useAnnotatorUser as A, useHover as S, useSelection as l, useViewportState as g } from "./annotorious-react.es2.js";
2
2
  import { AnnotoriousPlugin as x } from "./annotorious-react.es3.js";
3
3
  import { ImageAnnotationPopup as d } from "./annotorious-react.es4.js";
4
4
  import { ImageAnnotator as I } from "./annotorious-react.es5.js";
5
5
  /* empty css */
6
6
  /* empty css */
7
- import { Origin as O, UserSelectAction as V, createAnonymousGuest as P, createBody as w, defaultColorProvider as z } from "@annotorious/core";
8
- import { ShapeType as G, W3CImageFormat as W, chainStyles as h, computeStyle as v, createImageAnnotator as U, parseFragmentSelector as B, parseSVGSelector as H, parseW3CImageAnnotation as T, serializeFragmentSelector as b, serializeSVGSelector as j, serializeW3CImageAnnotation as k } from "@annotorious/annotorious";
7
+ import { Origin as y, UserSelectAction as V, createAnonymousGuest as P, createBody as v, defaultColorProvider as w } from "@annotorious/core";
8
+ import { ShapeType as F, W3CImageFormat as G, chainStyles as W, computeStyle as h, createImageAnnotator as H, parseFragmentSelector as T, parseSVGSelector as U, parseW3CImageAnnotation as B, serializeFragmentSelector as b, serializeSVGSelector as j, serializeW3CImageAnnotation as k } from "@annotorious/annotorious";
9
9
  import { OpenSeadragonAnnotator as D, OpenSeadragonAnnotatorContext as E, useViewer as J } from "./annotorious-react.es8.js";
10
10
  import { OpenSeadragonAnnotationPopup as L } from "./annotorious-react.es9.js";
11
- import { OpenSeadragonViewer as N } from "./annotorious-react.es10.js";
11
+ import { OpenSeadragonHoverTooltip as N } from "./annotorious-react.es10.js";
12
+ import { OpenSeadragonViewer as R } from "./annotorious-react.es11.js";
12
13
  export {
13
14
  r as Annotorious,
14
15
  a as AnnotoriousContext,
@@ -18,20 +19,21 @@ export {
18
19
  L as OpenSeadragonAnnotationPopup,
19
20
  D as OpenSeadragonAnnotator,
20
21
  E as OpenSeadragonAnnotatorContext,
21
- N as OpenSeadragonViewer,
22
- O as Origin,
23
- G as ShapeType,
22
+ N as OpenSeadragonHoverTooltip,
23
+ R as OpenSeadragonViewer,
24
+ y as Origin,
25
+ F as ShapeType,
24
26
  V as UserSelectAction,
25
- W as W3CImageFormat,
26
- h as chainStyles,
27
- v as computeStyle,
27
+ G as W3CImageFormat,
28
+ W as chainStyles,
29
+ h as computeStyle,
28
30
  P as createAnonymousGuest,
29
- w as createBody,
30
- U as createImageAnnotator,
31
- z as defaultColorProvider,
32
- B as parseFragmentSelector,
33
- H as parseSVGSelector,
34
- T as parseW3CImageAnnotation,
31
+ v as createBody,
32
+ H as createImageAnnotator,
33
+ w as defaultColorProvider,
34
+ T as parseFragmentSelector,
35
+ U as parseSVGSelector,
36
+ B as parseW3CImageAnnotation,
35
37
  b as serializeFragmentSelector,
36
38
  j as serializeSVGSelector,
37
39
  k as serializeW3CImageAnnotation,
@@ -44,6 +46,6 @@ export {
44
46
  S as useHover,
45
47
  l as useSelection,
46
48
  J as useViewer,
47
- c as useViewportState
49
+ g as useViewportState
48
50
  };
49
51
  //# sourceMappingURL=annotorious-react.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
1
+ {"version":3,"file":"annotorious-react.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
@@ -1,19 +1,35 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { forwardRef as m, useRef as p, useContext as u, useLayoutEffect as c, useImperativeHandle as d } from "react";
3
- import l from "openseadragon";
4
- import { OpenSeadragonAnnotatorContext as v } from "./annotorious-react.es8.js";
5
- const S = m((n, i) => {
6
- const { className: s, options: t } = n, r = p(null), { viewer: f, setViewer: e } = u(v);
7
- return c(() => {
8
- if (r.current) {
9
- const o = l({ ...t, element: r.current });
10
- return e && e(o), () => {
11
- e && e(void 0), o.destroy();
12
- };
1
+ import { jsx as b } from "react/jsx-runtime";
2
+ import { useState as c, useEffect as E } from "react";
3
+ import { useAnnotator as h } from "./annotorious-react.es2.js";
4
+ import { useViewer as y } from "./annotorious-react.es8.js";
5
+ const v = 10, S = (n) => {
6
+ const m = n.offsetX || v, a = n.offsetY || v, e = h(), t = y(), [s, p] = c(), [r, i] = c();
7
+ return E(() => {
8
+ if (!e || !t) return;
9
+ const u = (o) => {
10
+ i(o ? e.state.store.getAnnotation(o) : void 0);
11
+ }, f = (o) => {
12
+ const { offsetX: d, offsetY: x } = o;
13
+ p({ x: d, y: x });
14
+ };
15
+ t.element.addEventListener("pointermove", f);
16
+ const l = e.state.hover.subscribe(u);
17
+ return () => {
18
+ t.element.removeEventListener("pointermove", f), l();
19
+ };
20
+ }, [e, t]), r && s && /* @__PURE__ */ b(
21
+ "div",
22
+ {
23
+ style: {
24
+ position: "absolute",
25
+ top: `${s.y + a}px`,
26
+ left: `${s.x + m}px`
27
+ },
28
+ children: n.tooltip({ annotation: r })
13
29
  }
14
- }, [JSON.stringify(t)]), d(i, () => f), /* @__PURE__ */ a("div", { className: s, ref: r });
15
- });
30
+ );
31
+ };
16
32
  export {
17
- S as OpenSeadragonViewer
33
+ S as OpenSeadragonHoverTooltip
18
34
  };
19
35
  //# sourceMappingURL=annotorious-react.es10.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es10.js","sources":["../src/openseadragon/OpenSeadragonViewer.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useImperativeHandle, useLayoutEffect, useRef } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { OpenSeadragonAnnotatorContext } from './OpenSeadragonAnnotator';\n\nexport interface OpenSeadragonViewerProps {\n\n className?: string;\n\n options: OpenSeadragon.Options;\n\n}\n\nexport const OpenSeadragonViewer = forwardRef<OpenSeadragon.Viewer, OpenSeadragonViewerProps>((props: OpenSeadragonViewerProps, ref) => {\n\n const { className, options } = props;\n\n const element = useRef<HTMLDivElement>(null);\n\n const { viewer, setViewer } = useContext(OpenSeadragonAnnotatorContext);\n\n useLayoutEffect(() => { \n if (element.current) {\n const v = OpenSeadragon({...options, element: element.current });\n\n // Checking for setViewer is just a convenience so we can\n // use this component also without an OpenSeadragonAnnotator\n if (setViewer)\n setViewer(v);\n\n return () => {\n if (setViewer)\n setViewer(undefined);\n\n v.destroy();\n }\n }\n }, [JSON.stringify(options)]);\n\n useImperativeHandle(ref, () => viewer);\n\n return (\n <div className={className} ref={element} />\n );\n\n});"],"names":["OpenSeadragonViewer","forwardRef","props","ref","className","options","element","useRef","viewer","setViewer","useContext","OpenSeadragonAnnotatorContext","useLayoutEffect","v","OpenSeadragon","useImperativeHandle","jsx"],"mappings":";;;;AAYO,MAAMA,IAAsBC,EAA2D,CAACC,GAAiCC,MAAQ;AAEhI,QAAA,EAAE,WAAAC,GAAW,SAAAC,EAAA,IAAYH,GAEzBI,IAAUC,EAAuB,IAAI,GAErC,EAAE,QAAAC,GAAQ,WAAAC,MAAcC,EAAWC,CAA6B;AAEtE,SAAAC,EAAgB,MAAM;AACpB,QAAIN,EAAQ,SAAS;AACb,YAAAO,IAAIC,EAAc,EAAC,GAAGT,GAAS,SAASC,EAAQ,SAAS;AAI3D,aAAAG,KACFA,EAAUI,CAAC,GAEN,MAAM;AACP,QAAAJ,KACFA,EAAU,MAAS,GAErBI,EAAE,QAAQ;AAAA,MACZ;AAAA,IAAA;AAAA,KAED,CAAC,KAAK,UAAUR,CAAO,CAAC,CAAC,GAERU,EAAAZ,GAAK,MAAMK,CAAM,GAGlC,gBAAAQ,EAAA,OAAA,EAAI,WAAAZ,GAAsB,KAAKE,EAAS,CAAA;AAG7C,CAAC;"}
1
+ {"version":3,"file":"annotorious-react.es10.js","sources":["../src/openseadragon/OpenSeadragonHoverTooltip.tsx"],"sourcesContent":["import { ReactNode, useEffect, useState } from 'react';\nimport { Annotation } from '@annotorious/core';\nimport { ImageAnnotation } from '@annotorious/annotorious';\nimport { useAnnotator } from '../Annotorious';\nimport { AnnotoriousOpenSeadragonAnnotator, useViewer } from '.';\n\ninterface HoverTooltipContentProps <T extends Annotation = ImageAnnotation> {\n \n annotation: T;\n\n}\n\ninterface OpenSeadragonHoverTooltipProps {\n\n offsetX?: number;\n\n offsetY?: number;\n\n tooltip: (props: HoverTooltipContentProps) => ReactNode;\n\n}\n\nconst DEFAULT_OFFSET = 10;\n\nexport const OpenSeadragonHoverTooltip = (props: OpenSeadragonHoverTooltipProps) => {\n\n const offsetX = props.offsetX || DEFAULT_OFFSET;\n const offsetY = props.offsetY || DEFAULT_OFFSET;\n\n const anno = useAnnotator<AnnotoriousOpenSeadragonAnnotator>();\n\n const viewer = useViewer();\n\n const [pos, setPos] = useState<{ x: number, y: number } | undefined>();\n\n const [hovered, setHovered] = useState<ImageAnnotation | undefined>();\n\n useEffect(() => {\n if (!anno || !viewer) return;\n\n const onHover = (id: string) => {\n if (id)\n setHovered(anno.state.store.getAnnotation(id));\n else\n setHovered(undefined);\n }\n\n const onPointerMove = (evt: PointerEvent) => {\n const { offsetX: x, offsetY: y } = evt;\n setPos({ x, y });\n }\n\n viewer.element.addEventListener('pointermove', onPointerMove);\n const unsubscribe = anno.state.hover.subscribe(onHover);\n\n return () => {\n viewer.element.removeEventListener('pointermove', onPointerMove);\n unsubscribe();\n }\n }, [anno, viewer]);\n\n return (hovered && pos) && (\n <div \n style={{ \n position: 'absolute',\n top: `${pos.y + offsetY}px`,\n left: `${pos.x + offsetX}px`\n }}>\n {props.tooltip({ annotation: hovered })}\n </div>\n )\n\n}"],"names":["DEFAULT_OFFSET","OpenSeadragonHoverTooltip","props","offsetX","offsetY","anno","useAnnotator","viewer","useViewer","pos","setPos","useState","hovered","setHovered","useEffect","onHover","id","onPointerMove","evt","x","y","unsubscribe","jsx"],"mappings":";;;;AAsBA,MAAMA,IAAiB,IAEVC,IAA4B,CAACC,MAA0C;AAE5E,QAAAC,IAAUD,EAAM,WAAWF,GAC3BI,IAAUF,EAAM,WAAWF,GAE3BK,IAAOC,EAAgD,GAEvDC,IAASC,EAAU,GAEnB,CAACC,GAAKC,CAAM,IAAIC,EAA+C,GAE/D,CAACC,GAASC,CAAU,IAAIF,EAAsC;AAEpE,SAAAG,EAAU,MAAM;AACV,QAAA,CAACT,KAAQ,CAACE,EAAQ;AAEhB,UAAAQ,IAAU,CAACC,MAAe;AAC1B,MACFH,EADEG,IACSX,EAAK,MAAM,MAAM,cAAcW,CAAE,IAEjC,MAFkC;AAAA,IAGjD,GAEMC,IAAgB,CAACC,MAAsB;AAC3C,YAAM,EAAE,SAASC,GAAG,SAASC,EAAM,IAAAF;AAC5B,MAAAR,EAAA,EAAE,GAAAS,GAAG,GAAAC,GAAG;AAAA,IACjB;AAEO,IAAAb,EAAA,QAAQ,iBAAiB,eAAeU,CAAa;AAC5D,UAAMI,IAAchB,EAAK,MAAM,MAAM,UAAUU,CAAO;AAEtD,WAAO,MAAM;AACJ,MAAAR,EAAA,QAAQ,oBAAoB,eAAeU,CAAa,GACnDI,EAAA;AAAA,IACd;AAAA,EAAA,GACC,CAAChB,GAAME,CAAM,CAAC,GAETK,KAAWH,KACjB,gBAAAa;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,UAAU;AAAA,QACV,KAAK,GAAGb,EAAI,IAAIL,CAAO;AAAA,QACvB,MAAM,GAAGK,EAAI,IAAIN,CAAO;AAAA,MAC1B;AAAA,MACC,UAAMD,EAAA,QAAQ,EAAE,YAAYU,EAAS,CAAA;AAAA,IAAA;AAAA,EACxC;AAGJ;"}
@@ -1,11 +1,19 @@
1
- import { useState as c, useRef as n, useEffect as s } from "react";
2
- const i = (e, t) => {
3
- const [u, o] = c(e), r = n(void 0);
4
- return s(() => (r.current = setTimeout(() => o(e), t), () => {
5
- clearTimeout(r.current);
6
- }), [e, t]), u;
7
- };
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { forwardRef as m, useRef as p, useContext as u, useLayoutEffect as c, useImperativeHandle as d } from "react";
3
+ import l from "openseadragon";
4
+ import { OpenSeadragonAnnotatorContext as v } from "./annotorious-react.es8.js";
5
+ const S = m((n, i) => {
6
+ const { className: s, options: t } = n, r = p(null), { viewer: f, setViewer: e } = u(v);
7
+ return c(() => {
8
+ if (r.current) {
9
+ const o = l({ ...t, element: r.current });
10
+ return e && e(o), () => {
11
+ e && e(void 0), o.destroy();
12
+ };
13
+ }
14
+ }, [JSON.stringify(t)]), d(i, () => f), /* @__PURE__ */ a("div", { className: s, ref: r });
15
+ });
8
16
  export {
9
- i as useDebounce
17
+ S as OpenSeadragonViewer
10
18
  };
11
19
  //# sourceMappingURL=annotorious-react.es11.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es11.js","sources":["../src/useDebounce.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nexport const useDebounce = (value: any, delay: number) => {\n const [debouncedValue, setDebouncedValue] = useState<any>(value);\n\n const timerRef = useRef<ReturnType<typeof setTimeout>>(undefined);\n\n useEffect(() => {\n timerRef.current = \n setTimeout(() => setDebouncedValue(value), delay);\n\n return () => {\n clearTimeout(timerRef.current);\n };\n }, [value, delay]);\n\n return debouncedValue;\n}"],"names":["useDebounce","value","delay","debouncedValue","setDebouncedValue","useState","timerRef","useRef","useEffect"],"mappings":";AAEa,MAAAA,IAAc,CAACC,GAAYC,MAAkB;AACxD,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAcJ,CAAK,GAEzDK,IAAWC,EAAsC,MAAS;AAEhE,SAAAC,EAAU,OACRF,EAAS,UACP,WAAW,MAAMF,EAAkBH,CAAK,GAAGC,CAAK,GAE3C,MAAM;AACX,iBAAaI,EAAS,OAAO;AAAA,EAC/B,IACC,CAACL,GAAOC,CAAK,CAAC,GAEVC;AACT;"}
1
+ {"version":3,"file":"annotorious-react.es11.js","sources":["../src/openseadragon/OpenSeadragonViewer.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useImperativeHandle, useLayoutEffect, useRef } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { OpenSeadragonAnnotatorContext } from './OpenSeadragonAnnotator';\n\nexport interface OpenSeadragonViewerProps {\n\n className?: string;\n\n options: OpenSeadragon.Options;\n\n}\n\nexport const OpenSeadragonViewer = forwardRef<OpenSeadragon.Viewer, OpenSeadragonViewerProps>((props: OpenSeadragonViewerProps, ref) => {\n\n const { className, options } = props;\n\n const element = useRef<HTMLDivElement>(null);\n\n const { viewer, setViewer } = useContext(OpenSeadragonAnnotatorContext);\n\n useLayoutEffect(() => { \n if (element.current) {\n const v = OpenSeadragon({...options, element: element.current });\n\n // Checking for setViewer is just a convenience so we can\n // use this component also without an OpenSeadragonAnnotator\n if (setViewer)\n setViewer(v);\n\n return () => {\n if (setViewer)\n setViewer(undefined);\n\n v.destroy();\n }\n }\n }, [JSON.stringify(options)]);\n\n useImperativeHandle(ref, () => viewer);\n\n return (\n <div className={className} ref={element} />\n );\n\n});"],"names":["OpenSeadragonViewer","forwardRef","props","ref","className","options","element","useRef","viewer","setViewer","useContext","OpenSeadragonAnnotatorContext","useLayoutEffect","v","OpenSeadragon","useImperativeHandle","jsx"],"mappings":";;;;AAYO,MAAMA,IAAsBC,EAA2D,CAACC,GAAiCC,MAAQ;AAEhI,QAAA,EAAE,WAAAC,GAAW,SAAAC,EAAA,IAAYH,GAEzBI,IAAUC,EAAuB,IAAI,GAErC,EAAE,QAAAC,GAAQ,WAAAC,MAAcC,EAAWC,CAA6B;AAEtE,SAAAC,EAAgB,MAAM;AACpB,QAAIN,EAAQ,SAAS;AACb,YAAAO,IAAIC,EAAc,EAAC,GAAGT,GAAS,SAASC,EAAQ,SAAS;AAI3D,aAAAG,KACFA,EAAUI,CAAC,GAEN,MAAM;AACP,QAAAJ,KACFA,EAAU,MAAS,GAErBI,EAAE,QAAQ;AAAA,MACZ;AAAA,IAAA;AAAA,KAED,CAAC,KAAK,UAAUR,CAAO,CAAC,CAAC,GAERU,EAAAZ,GAAK,MAAMK,CAAM,GAGlC,gBAAAQ,EAAA,OAAA,EAAI,WAAAZ,GAAsB,KAAKE,EAAS,CAAA;AAG7C,CAAC;"}
@@ -1,256 +1,11 @@
1
- import * as r from "react";
2
- import { useModernLayoutEffect as O, useEffectEvent as X } from "./annotorious-react.es17.js";
3
- import { jsxs as Y, jsx as P } from "react/jsx-runtime";
4
- import { isElement as I, getComputedStyle as q } from "./annotorious-react.es18.js";
5
- import { getOverflowAncestors as pe } from "./annotorious-react.es18.js";
6
- import "react-dom";
7
- import { useFloating as Q } from "./annotorious-react.es15.js";
8
- import { arrow as he, flip as xe, inline as ve, offset as Ce, shift as we } from "./annotorious-react.es15.js";
9
- const Z = {
10
- ...r
1
+ import { useState as c, useRef as n, useEffect as s } from "react";
2
+ const i = (e, t) => {
3
+ const [u, o] = c(e), r = n(void 0);
4
+ return s(() => (r.current = setTimeout(() => o(e), t), () => {
5
+ clearTimeout(r.current);
6
+ }), [e, t]), u;
11
7
  };
12
- let V = !1, z = 0;
13
- const W = () => (
14
- // Ensure the id is unique with multiple independent versions of Floating UI
15
- // on <React 18
16
- "floating-ui-" + Math.random().toString(36).slice(2, 6) + z++
17
- );
18
- function G() {
19
- const [t, o] = r.useState(() => V ? W() : void 0);
20
- return O(() => {
21
- t == null && o(W());
22
- }, []), r.useEffect(() => {
23
- V = !0;
24
- }, []), t;
25
- }
26
- const J = Z.useId, $ = J || G;
27
- let M;
28
- process.env.NODE_ENV !== "production" && (M = /* @__PURE__ */ new Set());
29
- function K() {
30
- for (var t, o = arguments.length, l = new Array(o), e = 0; e < o; e++)
31
- l[e] = arguments[e];
32
- const s = "Floating UI: " + l.join(" ");
33
- if (!((t = M) != null && t.has(s))) {
34
- var c;
35
- (c = M) == null || c.add(s), console.warn(s);
36
- }
37
- }
38
- function _() {
39
- for (var t, o = arguments.length, l = new Array(o), e = 0; e < o; e++)
40
- l[e] = arguments[e];
41
- const s = "Floating UI: " + l.join(" ");
42
- if (!((t = M) != null && t.has(s))) {
43
- var c;
44
- (c = M) == null || c.add(s), console.error(s);
45
- }
46
- }
47
- const ue = /* @__PURE__ */ r.forwardRef(function(o, l) {
48
- const {
49
- context: {
50
- placement: e,
51
- elements: {
52
- floating: s
53
- },
54
- middlewareData: {
55
- arrow: c,
56
- shift: u
57
- }
58
- },
59
- width: f = 14,
60
- height: a = 7,
61
- tipRadius: F = 0,
62
- strokeWidth: d = 0,
63
- staticOffset: g,
64
- stroke: R,
65
- d: n,
66
- style: {
67
- transform: p,
68
- ...h
69
- } = {},
70
- ...x
71
- } = o;
72
- process.env.NODE_ENV !== "production" && (l || K("The `ref` prop is required for `FloatingArrow`."));
73
- const v = $(), [E, i] = r.useState(!1);
74
- if (O(() => {
75
- if (!s) return;
76
- q(s).direction === "rtl" && i(!0);
77
- }, [s]), !s)
78
- return null;
79
- const [m, D] = e.split("-"), N = m === "top" || m === "bottom";
80
- let S = g;
81
- (N && u != null && u.x || !N && u != null && u.y) && (S = null);
82
- const C = d * 2, b = C / 2, T = f / 2 * (F / -8 + 1), y = a / 2 * F / 4, w = !!n, k = S && D === "end" ? "bottom" : "top";
83
- let A = S && D === "end" ? "right" : "left";
84
- S && E && (A = D === "end" ? "left" : "right");
85
- const B = (c == null ? void 0 : c.x) != null ? S || c.x : "", U = (c == null ? void 0 : c.y) != null ? S || c.y : "", L = n || "M0,0" + (" H" + f) + (" L" + (f - T) + "," + (a - y)) + (" Q" + f / 2 + "," + a + " " + T + "," + (a - y)) + " Z", H = {
86
- top: w ? "rotate(180deg)" : "",
87
- left: w ? "rotate(90deg)" : "rotate(-90deg)",
88
- bottom: w ? "" : "rotate(180deg)",
89
- right: w ? "rotate(-90deg)" : "rotate(90deg)"
90
- }[m];
91
- return /* @__PURE__ */ Y("svg", {
92
- ...x,
93
- "aria-hidden": !0,
94
- ref: l,
95
- width: w ? f : f + C,
96
- height: f,
97
- viewBox: "0 0 " + f + " " + (a > f ? a : f),
98
- style: {
99
- position: "absolute",
100
- pointerEvents: "none",
101
- [A]: B,
102
- [k]: U,
103
- [m]: N || w ? "100%" : "calc(100% - " + C / 2 + "px)",
104
- transform: [H, p].filter((j) => !!j).join(" "),
105
- ...h
106
- },
107
- children: [C > 0 && /* @__PURE__ */ P("path", {
108
- clipPath: "url(#" + v + ")",
109
- fill: "none",
110
- stroke: R,
111
- strokeWidth: C + (n ? 0 : 1),
112
- d: L
113
- }), /* @__PURE__ */ P("path", {
114
- stroke: C && !n ? x.fill : "none",
115
- d: L
116
- }), /* @__PURE__ */ P("clipPath", {
117
- id: v,
118
- children: /* @__PURE__ */ P("rect", {
119
- x: -b,
120
- y: b * (w ? -1 : 1),
121
- width: f + C,
122
- height: f
123
- })
124
- })]
125
- });
126
- });
127
- function ee() {
128
- const t = /* @__PURE__ */ new Map();
129
- return {
130
- emit(o, l) {
131
- var e;
132
- (e = t.get(o)) == null || e.forEach((s) => s(l));
133
- },
134
- on(o, l) {
135
- t.has(o) || t.set(o, /* @__PURE__ */ new Set()), t.get(o).add(l);
136
- },
137
- off(o, l) {
138
- var e;
139
- (e = t.get(o)) == null || e.delete(l);
140
- }
141
- };
142
- }
143
- const te = /* @__PURE__ */ r.createContext(null), ne = /* @__PURE__ */ r.createContext(null), oe = () => {
144
- var t;
145
- return ((t = r.useContext(te)) == null ? void 0 : t.id) || null;
146
- }, re = () => r.useContext(ne);
147
- function se(t) {
148
- const {
149
- open: o = !1,
150
- onOpenChange: l,
151
- elements: e
152
- } = t, s = $(), c = r.useRef({}), [u] = r.useState(() => ee()), f = oe() != null;
153
- if (process.env.NODE_ENV !== "production") {
154
- const n = e.reference;
155
- n && !I(n) && _("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
156
- }
157
- const [a, F] = r.useState(e.reference), d = X((n, p, h) => {
158
- c.current.openEvent = n ? p : void 0, u.emit("openchange", {
159
- open: n,
160
- event: p,
161
- reason: h,
162
- nested: f
163
- }), l == null || l(n, p, h);
164
- }), g = r.useMemo(() => ({
165
- setPositionReference: F
166
- }), []), R = r.useMemo(() => ({
167
- reference: a || e.reference || null,
168
- floating: e.floating || null,
169
- domReference: e.reference
170
- }), [a, e.reference, e.floating]);
171
- return r.useMemo(() => ({
172
- dataRef: c,
173
- open: o,
174
- onOpenChange: d,
175
- elements: R,
176
- events: u,
177
- floatingId: s,
178
- refs: g
179
- }), [o, d, R, u, s, g]);
180
- }
181
- function de(t) {
182
- t === void 0 && (t = {});
183
- const {
184
- nodeId: o
185
- } = t, l = se({
186
- ...t,
187
- elements: {
188
- reference: null,
189
- floating: null,
190
- ...t.elements
191
- }
192
- }), e = t.rootContext || l, s = e.elements, [c, u] = r.useState(null), [f, a] = r.useState(null), d = (s == null ? void 0 : s.domReference) || c, g = r.useRef(null), R = re();
193
- O(() => {
194
- d && (g.current = d);
195
- }, [d]);
196
- const n = Q({
197
- ...t,
198
- elements: {
199
- ...s,
200
- ...f && {
201
- reference: f
202
- }
203
- }
204
- }), p = r.useCallback((i) => {
205
- const m = I(i) ? {
206
- getBoundingClientRect: () => i.getBoundingClientRect(),
207
- getClientRects: () => i.getClientRects(),
208
- contextElement: i
209
- } : i;
210
- a(m), n.refs.setReference(m);
211
- }, [n.refs]), h = r.useCallback((i) => {
212
- (I(i) || i === null) && (g.current = i, u(i)), (I(n.refs.reference.current) || n.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
213
- // `null` to support `positionReference` + an unstable `reference`
214
- // callback ref.
215
- i !== null && !I(i)) && n.refs.setReference(i);
216
- }, [n.refs]), x = r.useMemo(() => ({
217
- ...n.refs,
218
- setReference: h,
219
- setPositionReference: p,
220
- domReference: g
221
- }), [n.refs, h, p]), v = r.useMemo(() => ({
222
- ...n.elements,
223
- domReference: d
224
- }), [n.elements, d]), E = r.useMemo(() => ({
225
- ...n,
226
- ...e,
227
- refs: x,
228
- elements: v,
229
- nodeId: o
230
- }), [n, x, v, o, e]);
231
- return O(() => {
232
- e.dataRef.current.floatingContext = E;
233
- const i = R == null ? void 0 : R.nodesRef.current.find((m) => m.id === o);
234
- i && (i.context = E);
235
- }), r.useMemo(() => ({
236
- ...n,
237
- context: E,
238
- refs: x,
239
- elements: v
240
- }), [n, x, v, E]);
241
- }
242
8
  export {
243
- ue as FloatingArrow,
244
- he as arrow,
245
- xe as flip,
246
- pe as getOverflowAncestors,
247
- ve as inline,
248
- Ce as offset,
249
- we as shift,
250
- de as useFloating,
251
- oe as useFloatingParentNodeId,
252
- se as useFloatingRootContext,
253
- re as useFloatingTree,
254
- $ as useId
9
+ i as useDebounce
255
10
  };
256
11
  //# sourceMappingURL=annotorious-react.es12.js.map