@annotorious/react 3.0.0-rc.21 → 3.0.0-rc.22

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 (35) hide show
  1. package/dist/annotorious-react.css +1 -1
  2. package/dist/annotorious-react.es.js +23 -23
  3. package/dist/annotorious-react.es10.js +14 -27
  4. package/dist/annotorious-react.es10.js.map +1 -1
  5. package/dist/annotorious-react.es11.js +6 -36
  6. package/dist/annotorious-react.es11.js.map +1 -1
  7. package/dist/annotorious-react.es12.js +8 -16
  8. package/dist/annotorious-react.es12.js.map +1 -1
  9. package/dist/annotorious-react.es13.js +153 -6
  10. package/dist/annotorious-react.es13.js.map +1 -1
  11. package/dist/annotorious-react.es14.js +31 -7
  12. package/dist/annotorious-react.es14.js.map +1 -1
  13. package/dist/annotorious-react.es15.js +2 -153
  14. package/dist/annotorious-react.es15.js.map +1 -1
  15. package/dist/annotorious-react.es16.js +29 -27435
  16. package/dist/annotorious-react.es16.js.map +1 -1
  17. package/dist/annotorious-react.es17.js +599 -32
  18. package/dist/annotorious-react.es17.js.map +1 -1
  19. package/dist/annotorious-react.es18.js +2 -2
  20. package/dist/annotorious-react.es19.js +2 -30
  21. package/dist/annotorious-react.es19.js.map +1 -1
  22. package/dist/annotorious-react.es2.js +2 -2
  23. package/dist/annotorious-react.es4.js +2 -2
  24. package/dist/annotorious-react.es5.js +8 -8
  25. package/dist/annotorious-react.es8.js +27 -86
  26. package/dist/annotorious-react.es8.js.map +1 -1
  27. package/dist/annotorious-react.es9.js +30 -4233
  28. package/dist/annotorious-react.es9.js.map +1 -1
  29. package/package.json +8 -8
  30. package/dist/annotorious-react.es20.js +0 -602
  31. package/dist/annotorious-react.es20.js.map +0 -1
  32. package/dist/annotorious-react.es21.js +0 -5
  33. package/dist/annotorious-react.es21.js.map +0 -1
  34. package/dist/annotorious-react.es22.js +0 -5
  35. package/dist/annotorious-react.es22.js.map +0 -1
@@ -1 +1 @@
1
- canvas.a9s-gl-canvas{height:100%;left:0;position:absolute;top:0;width:100%}canvas.a9s-gl-canvas.hover{cursor:pointer!important}svg.svelte-190cqdf.svelte-190cqdf{pointer-events:none}svg.drawing.svelte-190cqdf.svelte-190cqdf{pointer-events:all}svg.svelte-190cqdf .svelte-190cqdf{pointer-events:all}text.svelte-1rehw2p{fill:#fff;font-family:Arial,Helvetica,sans-serif;font-weight:600}rect.svelte-1rehw2p{stroke-width:1.2;vector-effect:non-scaling-stroke}polygon.svelte-fgq4n0{stroke-width:1.2;vector-effect:non-scaling-stroke}rect.svelte-gze948{stroke-width:1.2;vector-effect:non-scaling-stroke}svg.svelte-1krwc4m{position:absolute;top:0;left:0;width:100%;height:100%;outline:none;pointer-events:none}.a9s-touch-halo.svelte-1sgkh33{fill:transparent;stroke-width:0}.a9s-touch-halo.touched.svelte-1sgkh33{fill:#ffffff40}.a9s-annotationlayer{box-sizing:border-box;height:100%;left:0;outline:none;position:absolute;top:0;touch-action:none;width:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.a9s-annotationlayer ellipse,.a9s-annotationlayer polygon,.a9s-annotationlayer rect{fill:transparent;shape-rendering:geometricPrecision;vector-effect:non-scaling-stroke}.a9s-edge-handle{fill:transparent;stroke:transparent;stroke-width:6px}.a9s-shape-handle,.a9s-handle{cursor:move}.a9s-edge-handle-top{cursor:n-resize}.a9s-edge-handle-right{cursor:e-resize}.a9s-edge-handle-bottom{cursor:s-resize}.a9s-edge-handle-left{cursor:w-resize}.a9s-handle.a9s-corner-handle-topleft{cursor:nw-resize}.a9s-handle.a9s-corner-handle-topright{cursor:ne-resize}.a9s-handle.a9s-corner-handle-bottomright{cursor:se-resize}.a9s-handle.a9s-corner-handle-bottomleft{cursor:sw-resize}.a9s-annotationlayer .a9s-outer,div[data-theme=dark] .a9s-annotationlayer .a9s-outer{display:none}.a9s-annotationlayer .a9s-inner,div[data-theme=dark] .a9s-annotationlayer .a9s-inner{fill:#0000001f;stroke:#000;stroke-width:1px}rect.a9s-handle,div[data-theme=dark] rect.a9s-handle{fill:#000;rx:2px}rect.a9s-close-polygon-handle,div[data-theme=dark] rect.a9s-close-polygon-handle{fill:#000;rx:1px}.a9s-annotationlayer .a9s-outer,div[data-theme=light] .a9s-annotationlayer .a9s-outer{display:block;stroke:#00000040;stroke-width:3.5px}.a9s-annotationlayer .a9s-inner,div[data-theme=light] .a9s-annotationlayer .a9s-inner{fill:#ffffff26;stroke:#fff;stroke-width:1.5px}rect.a9s-handle,div[data-theme=light] rect.a9s-handle{fill:#fff;rx:1px;stroke:#00000073;stroke-width:1px}rect.a9s-close-polygon-handle,div[data-theme=light] rect.a9s-close-polygon-handle{fill:#fff;rx:1px;stroke:#00000073;stroke-width:1px}
1
+ canvas.a9s-gl-canvas{height:100%;left:0;position:absolute;top:0;width:100%}canvas.a9s-gl-canvas.hidden{display:none}canvas.a9s-gl-canvas.hover{cursor:pointer!important}svg.svelte-190cqdf.svelte-190cqdf{pointer-events:none}svg.drawing.svelte-190cqdf.svelte-190cqdf{pointer-events:all}svg.svelte-190cqdf .svelte-190cqdf{pointer-events:all}text.svelte-1rehw2p{fill:#fff;font-family:Arial,Helvetica,sans-serif;font-weight:600}rect.svelte-1rehw2p{stroke-width:1.2;vector-effect:non-scaling-stroke}polygon.svelte-fgq4n0{stroke-width:1.2;vector-effect:non-scaling-stroke}rect.svelte-gze948{stroke-width:1.2;vector-effect:non-scaling-stroke}svg.svelte-1krwc4m{position:absolute;top:0;left:0;width:100%;height:100%;outline:none;pointer-events:none}.a9s-touch-halo.svelte-1sgkh33{fill:transparent;stroke-width:0}.a9s-touch-halo.touched.svelte-1sgkh33{fill:#ffffff40}.a9s-annotationlayer{box-sizing:border-box;height:100%;left:0;outline:none;position:absolute;top:0;touch-action:none;width:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.a9s-annotationlayer.hidden{display:none}.a9s-annotationlayer ellipse,.a9s-annotationlayer polygon,.a9s-annotationlayer rect{fill:transparent;shape-rendering:geometricPrecision;vector-effect:non-scaling-stroke}.a9s-edge-handle{fill:transparent;stroke:transparent;stroke-width:6px}.a9s-shape-handle,.a9s-handle{cursor:move}.a9s-edge-handle-top{cursor:n-resize}.a9s-edge-handle-right{cursor:e-resize}.a9s-edge-handle-bottom{cursor:s-resize}.a9s-edge-handle-left{cursor:w-resize}.a9s-handle.a9s-corner-handle-topleft{cursor:nw-resize}.a9s-handle.a9s-corner-handle-topright{cursor:ne-resize}.a9s-handle.a9s-corner-handle-bottomright{cursor:se-resize}.a9s-handle.a9s-corner-handle-bottomleft{cursor:sw-resize}.a9s-annotationlayer .a9s-outer,div[data-theme=dark] .a9s-annotationlayer .a9s-outer{display:none}.a9s-annotationlayer .a9s-inner,div[data-theme=dark] .a9s-annotationlayer .a9s-inner{fill:#0000001f;stroke:#000;stroke-width:1px}rect.a9s-handle,div[data-theme=dark] rect.a9s-handle{fill:#000;rx:2px}rect.a9s-close-polygon-handle,div[data-theme=dark] rect.a9s-close-polygon-handle{fill:#000;rx:1px}.a9s-annotationlayer .a9s-outer,div[data-theme=light] .a9s-annotationlayer .a9s-outer{display:block;stroke:#00000040;stroke-width:3.5px}.a9s-annotationlayer .a9s-inner,div[data-theme=light] .a9s-annotationlayer .a9s-inner{fill:#ffffff26;stroke:#fff;stroke-width:1.5px}rect.a9s-handle,div[data-theme=light] rect.a9s-handle{fill:#fff;rx:1px;stroke:#00000073;stroke-width:1px}rect.a9s-close-polygon-handle,div[data-theme=light] rect.a9s-close-polygon-handle{fill:#fff;rx:1px;stroke:#00000073;stroke-width:1px}
@@ -1,38 +1,38 @@
1
- import { Annotorious as A, AnnotoriousContext as g, useAnnotationStore as c, useAnnotations as f, useAnnotator as x, useAnnotatorUser as S, useSelection as d, useViewportState as l } from "./annotorious-react.es2.js";
1
+ import { Annotorious as g, AnnotoriousContext as A, useAnnotationStore as c, useAnnotations as f, useAnnotator as x, useAnnotatorUser as S, useSelection as I, useViewportState as d } from "./annotorious-react.es2.js";
2
2
  import { AnnotoriousPlugin as y } from "./annotorious-react.es3.js";
3
3
  import { Draggable as O } from "./annotorious-react.es4.js";
4
- import { ImageAnnotator as w } from "./annotorious-react.es5.js";
4
+ import { ImageAnnotator as h } from "./annotorious-react.es5.js";
5
5
  import "./annotorious-react.es6.js";
6
6
  import "./annotorious-react.es7.js";
7
- import { Origin as h, PointerSelectAction as D, createAnonymousGuest as F, createBody as T, defaultColorProvider as W } from "./annotorious-react.es8.js";
8
- import { createImageAnnotator as o, ShapeType as e, W3CImageFormat as t } from "./annotorious-react.es9.js";
9
- import { OpenSeadragonAnnotator as j, useViewer as v } from "./annotorious-react.es10.js";
10
- import { OpenSeadragonPopup as G } from "./annotorious-react.es11.js";
11
- import { OpenSeadragonViewer as Y } from "./annotorious-react.es12.js";
12
- const p = o, i = e, m = t;
7
+ import { Origin as F, PointerSelectAction as T, createAnonymousGuest as V, createBody as W, defaultColorProvider as $ } from "@annotorious/core";
8
+ import { createImageAnnotator as o, ShapeType as e, W3CImageFormat as t } from "@annotorious/annotorious";
9
+ import { OpenSeadragonAnnotator as v, useViewer as B } from "./annotorious-react.es8.js";
10
+ import { OpenSeadragonPopup as G } from "./annotorious-react.es9.js";
11
+ import { OpenSeadragonViewer as j } from "./annotorious-react.es10.js";
12
+ const p = o, m = e, s = t;
13
13
  export {
14
- A as Annotorious,
15
- g as AnnotoriousContext,
14
+ g as Annotorious,
15
+ A as AnnotoriousContext,
16
16
  y as AnnotoriousPlugin,
17
17
  O as Draggable,
18
- w as ImageAnnotator,
19
- j as OpenSeadragonAnnotator,
18
+ h as ImageAnnotator,
19
+ v as OpenSeadragonAnnotator,
20
20
  G as OpenSeadragonPopup,
21
- Y as OpenSeadragonViewer,
22
- h as Origin,
23
- D as PointerSelectAction,
24
- i as ShapeType,
25
- m as W3CImageFormat,
26
- F as createAnonymousGuest,
27
- T as createBody,
21
+ j as OpenSeadragonViewer,
22
+ F as Origin,
23
+ T as PointerSelectAction,
24
+ m as ShapeType,
25
+ s as W3CImageFormat,
26
+ V as createAnonymousGuest,
27
+ W as createBody,
28
28
  p as createImageAnnotator,
29
- W as defaultColorProvider,
29
+ $ as defaultColorProvider,
30
30
  c as useAnnotationStore,
31
31
  f as useAnnotations,
32
32
  x as useAnnotator,
33
33
  S as useAnnotatorUser,
34
- d as useSelection,
35
- v as useViewer,
36
- l as useViewportState
34
+ I as useSelection,
35
+ B as useViewer,
36
+ d as useViewportState
37
37
  };
38
38
  //# sourceMappingURL=annotorious-react.es.js.map
@@ -1,32 +1,19 @@
1
- import { j as c } from "./annotorious-react.es13.js";
2
- import { createContext as w, useState as u, useContext as a, useEffect as i } from "react";
3
- import { createOSDAnnotator as g } from "./annotorious-react.es16.js";
4
- import { AnnotoriousContext as m } from "./annotorious-react.es2.js";
5
- const s = w({ viewer: null, setViewer: null }), S = (e) => {
6
- const { children: E, tool: r, ...d } = e, [o, f] = u(), { anno: t, setAnno: l } = a(m);
7
- return i(() => {
8
- if (o) {
9
- const n = g(o, d);
10
- return e.drawingEnabled !== void 0 && n.setDrawingEnabled(e.drawingEnabled), e.filter && n.setFilter(e.filter), e.style && n.setStyle(e.style), e.tool && n.setDrawingTool(e.tool), l(n), () => {
11
- n.destroy(), l(void 0);
1
+ import { j as a } from "./annotorious-react.es11.js";
2
+ import { forwardRef as m, useRef as p, useContext as u, useEffect as c, useImperativeHandle as d } from "react";
3
+ import l from "openseadragon";
4
+ import { OpenSeadragonAnnotatorContext as x } from "./annotorious-react.es8.js";
5
+ const S = m((n, s) => {
6
+ const { className: i, options: t } = n, r = p(null), { viewer: f, setViewer: e } = u(x);
7
+ return c(() => {
8
+ if (r.current) {
9
+ const o = l({ ...t, element: r.current });
10
+ return e && e(o), () => {
11
+ o.destroy(), e && e(void 0);
12
12
  };
13
13
  }
14
- }, [o]), i(() => {
15
- t && t.setDrawingEnabled(e.drawingEnabled);
16
- }, [e.drawingEnabled]), i(() => {
17
- t && t.setFilter(e.filter);
18
- }, [e.filter]), i(() => {
19
- t && t.setStyle(e.style);
20
- }, [e.style]), i(() => {
21
- t && t.setDrawingTool(r);
22
- }, [r]), /* @__PURE__ */ c.jsx(s.Provider, { value: { viewer: o, setViewer: f }, children: e.children });
23
- }, A = () => {
24
- const { viewer: e } = a(s);
25
- return e;
26
- };
14
+ }, [JSON.stringify(t)]), d(s, () => f), /* @__PURE__ */ a.jsx("div", { className: i, ref: r });
15
+ });
27
16
  export {
28
- S as OpenSeadragonAnnotator,
29
- s as OpenSeadragonAnnotatorContext,
30
- A as useViewer
17
+ S as OpenSeadragonViewer
31
18
  };
32
19
  //# sourceMappingURL=annotorious-react.es10.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es10.js","sources":["../src/openseadragon/OpenSeadragonAnnotator.tsx"],"sourcesContent":["import { createContext, ReactNode, useContext, useEffect, useState } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { createOSDAnnotator } from '@annotorious/openseadragon';\nimport { AnnotoriousOpts, DrawingStyle, Filter, ImageAnnotation } from '@annotorious/annotorious';\nimport { AnnotoriousContext } from '../Annotorious';\n\nexport const OpenSeadragonAnnotatorContext = createContext<{ \n viewer: OpenSeadragon.Viewer,\n setViewer(viewer: OpenSeadragon.Viewer): void\n}>({ viewer: null, setViewer: null });\n\nexport type OpenSeadragonAnnotatorProps<E extends unknown> = AnnotoriousOpts<ImageAnnotation, E> & {\n\n children?: ReactNode;\n\n drawingEnabled?: boolean;\n\n filter?: Filter<ImageAnnotation>;\n\n style?: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle);\n\n tool?: string | null;\n\n}\n\nexport const OpenSeadragonAnnotator = <E extends unknown>(props: OpenSeadragonAnnotatorProps<E>) => {\n\n const { children, tool, ...opts } = props;\n\n const [viewer, setViewer] = useState<OpenSeadragon.Viewer>();\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n useEffect(() => {\n if (viewer) {\n const anno = createOSDAnnotator<E>(viewer, opts);\n\n if (props.drawingEnabled !== undefined) anno.setDrawingEnabled(props.drawingEnabled);\n if (props.filter) anno.setFilter(props.filter);\n if (props.style) anno.setStyle(props.style);\n if (props.tool) anno.setDrawingTool(props.tool);\n\n setAnno(anno);\n\n return () => {\n anno.destroy();\n setAnno(undefined);\n }\n }\n }, [viewer]);\n\n useEffect(() => {\n if (anno) anno.setDrawingEnabled(props.drawingEnabled);\n }, [props.drawingEnabled]);\n\n useEffect(() => {\n if (anno) anno.setFilter(props.filter);\n }, [props.filter]);\n\n useEffect(() => {\n if (anno) anno.setStyle(props.style);\n }, [props.style]);\n\n useEffect(() => {\n if (anno) anno.setDrawingTool(tool);\n }, [tool]);\n\n return (\n <OpenSeadragonAnnotatorContext.Provider value={{ viewer, setViewer }}>\n {props.children}\n </OpenSeadragonAnnotatorContext.Provider>\n )\n\n}\n\nexport const useViewer = () => {\n const { viewer } = useContext(OpenSeadragonAnnotatorContext);\n return viewer;\n}"],"names":["OpenSeadragonAnnotatorContext","createContext","OpenSeadragonAnnotator","props","children","tool","opts","viewer","setViewer","useState","anno","setAnno","useContext","AnnotoriousContext","useEffect","createOSDAnnotator","jsx","useViewer"],"mappings":";;;;AAMO,MAAMA,IAAgCC,EAG1C,EAAE,QAAQ,MAAM,WAAW,MAAM,GAgBvBC,IAAyB,CAAoBC,MAA0C;AAElG,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,MAASH,GAE9B,CAACI,GAAQC,CAAS,IAAIC,EAA+B,GAErD,EAAE,MAAAC,GAAM,SAAAC,EAAQ,IAAIC,EAAWC,CAAkB;AAEvD,SAAAC,EAAU,MAAM;AACd,QAAIP,GAAQ;AACJG,YAAAA,IAAOK,EAAsBR,GAAQD,CAAI;AAE/C,aAAIH,EAAM,mBAAmB,UAAWO,EAAK,kBAAkBP,EAAM,cAAc,GAC/EA,EAAM,UAAQO,EAAK,UAAUP,EAAM,MAAM,GACzCA,EAAM,SAAOO,EAAK,SAASP,EAAM,KAAK,GACtCA,EAAM,QAAMO,EAAK,eAAeP,EAAM,IAAI,GAE9CQ,EAAQD,CAAI,GAEL,MAAM;AACXA,QAAAA,EAAK,QAAQ,GACbC,EAAQ,MAAS;AAAA,MAAA;AAAA,IAErB;AAAA,EAAA,GACC,CAACJ,CAAM,CAAC,GAEXO,EAAU,MAAM;AACV,IAAAJ,KAAWA,EAAA,kBAAkBP,EAAM,cAAc;AAAA,EAAA,GACpD,CAACA,EAAM,cAAc,CAAC,GAEzBW,EAAU,MAAM;AACV,IAAAJ,KAAWA,EAAA,UAAUP,EAAM,MAAM;AAAA,EAAA,GACpC,CAACA,EAAM,MAAM,CAAC,GAEjBW,EAAU,MAAM;AACV,IAAAJ,KAAWA,EAAA,SAASP,EAAM,KAAK;AAAA,EAAA,GAClC,CAACA,EAAM,KAAK,CAAC,GAEhBW,EAAU,MAAM;AACV,IAAAJ,KAAMA,EAAK,eAAeL,CAAI;AAAA,EAAA,GACjC,CAACA,CAAI,CAAC,GAGPW,gBAAAA,MAAChB,EAA8B,UAA9B,EAAuC,OAAO,EAAE,QAAAO,GAAQ,WAAAC,EACtD,GAAA,UAAAL,EAAM,SACT,CAAA;AAGJ,GAEac,IAAY,MAAM;AAC7B,QAAM,EAAE,QAAAV,EAAA,IAAWK,EAAWZ,CAA6B;AACpD,SAAAO;AACT;"}
1
+ {"version":3,"file":"annotorious-react.es10.js","sources":["../src/openseadragon/OpenSeadragonViewer.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useImperativeHandle, 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 useEffect(() => { \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 v.destroy();\n\n if (setViewer) \n setViewer(undefined);\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","useEffect","v","OpenSeadragon","useImperativeHandle","jsx"],"mappings":";;;;AAYO,MAAMA,IAAsBC,EAA2D,CAACC,GAAiCC,MAAQ;AAEhI,QAAA,EAAE,WAAAC,GAAW,SAAAC,EAAY,IAAAH,GAEzBI,IAAUC,EAAuB,IAAI,GAErC,EAAE,QAAAC,GAAQ,WAAAC,EAAU,IAAIC,EAAWC,CAA6B;AAEtE,SAAAC,EAAU,MAAM;AACd,QAAIN,EAAQ,SAAS;AACb,YAAAO,IAAIC,EAAc,EAAC,GAAGT,GAAS,SAASC,EAAQ,SAAS;AAI3D,aAAAG,KACFA,EAAUI,CAAC,GAEN,MAAM;AACX,QAAAA,EAAE,QAAQ,GAENJ,KACFA,EAAU,MAAS;AAAA,MAAA;AAAA,IAEzB;AAAA,KACC,CAAC,KAAK,UAAUJ,CAAO,CAAC,CAAC,GAERU,EAAAZ,GAAK,MAAMK,CAAM,GAGlCQ,gBAAAA,EAAAA,IAAA,OAAA,EAAI,WAAAZ,GAAsB,KAAKE,EAAS,CAAA;AAG7C,CAAC;"}
@@ -1,39 +1,9 @@
1
- import { j as v } from "./annotorious-react.es13.js";
2
- import { useRef as w, useState as d, useEffect as u } from "react";
3
- import { Draggable as x } from "./annotorious-react.es4.js";
4
- import { useViewer as S } from "./annotorious-react.es10.js";
5
- import { useSelection as j } from "./annotorious-react.es2.js";
6
- import { setPosition as D } from "./annotorious-react.es17.js";
7
- const R = (c) => {
8
- const n = w(null), o = S(), { selected: t } = j(), [l, m] = d([]), [s, i] = d(!1), f = () => i(!0), p = () => {
9
- const e = t[0].annotation;
10
- D(o, e, n.current);
11
- }, g = (e, r) => e.every((a) => r.includes(a)) && r.every((a) => e.includes(a));
12
- return u(() => {
13
- const e = t.map(({ annotation: r }) => r.id);
14
- g(l, e) || (i(!1), m(e));
15
- }, [t]), u(() => {
16
- if (!n.current)
17
- return;
18
- s || p();
19
- const e = () => {
20
- s || p();
21
- };
22
- return o.addHandler("update-viewport", e), () => {
23
- o.removeHandler("update-viewport", e);
24
- };
25
- }, [t, s]), t.length > 0 ? /* @__PURE__ */ v.jsx(
26
- x,
27
- {
28
- ref: n,
29
- className: "a9s-popup a9s-osd-popup",
30
- onDragStart: f,
31
- children: c.popup({ viewer: o, selected: t })
32
- },
33
- t.map(({ annotation: e }) => e.id).join("-")
34
- ) : null;
35
- };
1
+ import { __module as e } from "./annotorious-react.es15.js";
2
+ import { __require as r } from "./annotorious-react.es16.js";
3
+ import { __require as o } from "./annotorious-react.es17.js";
4
+ process.env.NODE_ENV === "production" ? e.exports = r() : e.exports = o();
5
+ var m = e.exports;
36
6
  export {
37
- R as OpenSeadragonPopup
7
+ m as j
38
8
  };
39
9
  //# sourceMappingURL=annotorious-react.es11.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es11.js","sources":["../src/openseadragon/OpenSeadragonPopup.tsx"],"sourcesContent":["import { ReactNode, useEffect, useRef, useState } from 'react';\nimport { ImageAnnotation } from '@annotorious/annotorious';\nimport OpenSeadragon from 'openseadragon';\nimport { AnnotoriousPopupProps, Draggable } from '../AnnotoriousPopup';\nimport { useViewer } from './OpenSeadragonAnnotator';\nimport { useSelection } from '../Annotorious';\nimport { setPosition } from './setPosition';\n\nexport type OpenSeadragonPopupProps = AnnotoriousPopupProps & {\n\n viewer: OpenSeadragon.Viewer\n\n}\n\nexport type OpenSeadragonPopupContainerProps = {\n\n popup(props: OpenSeadragonPopupProps): ReactNode\n\n}\n\nexport const OpenSeadragonPopup = (props: OpenSeadragonPopupContainerProps) => {\n\n const el = useRef<HTMLDivElement>(null);\n\n const viewer = useViewer();\n\n const { selected } = useSelection<ImageAnnotation>();\n\n const [selectedIds, setSelectedIds] = useState<string[]>([]);\n\n const [dragged, setDragged] = useState(false);\n\n const onDragStart = () => setDragged(true);\n\n const updatePosition = () => {\n // Note: this popup only supports a single selection\n const annotation = selected[0].annotation;\n setPosition(viewer, annotation, el.current);\n }\n\n const equal = (a: string[], b: string[]) => \n a.every(str => b.includes(str)) && b.every(str => a.includes(str));\n\n useEffect(() => {\n // Reset drag flag if selected IDs have changed\n const nextIds = selected.map(({ annotation }) => annotation.id);\n\n if (!equal(selectedIds, nextIds)) {\n setDragged(false);\n setSelectedIds(nextIds);\n }\n }, [selected]);\n\n useEffect(() => {\n if (!el.current) return;\n\n if (!dragged) updatePosition();\n\n const onUpdateViewport = () => {\n if (!dragged) updatePosition();\n }\n\n viewer.addHandler('update-viewport', onUpdateViewport);\n\n return () => {\n viewer.removeHandler('update-viewport', onUpdateViewport);\n }\n }, [selected, dragged]);\n \n return selected.length > 0 ? (\n <Draggable \n ref={el} \n key={selected.map(({ annotation }) => annotation.id).join('-')} \n className=\"a9s-popup a9s-osd-popup\" \n onDragStart={onDragStart}>\n\n {props.popup({ viewer, selected })}\n \n </Draggable>\n ) : null;\n\n}"],"names":["OpenSeadragonPopup","props","el","useRef","viewer","useViewer","selected","useSelection","selectedIds","setSelectedIds","useState","dragged","setDragged","onDragStart","updatePosition","annotation","setPosition","equal","a","b","str","useEffect","nextIds","onUpdateViewport","jsx","Draggable"],"mappings":";;;;;;AAoBa,MAAAA,IAAqB,CAACC,MAA4C;AAEvE,QAAAC,IAAKC,EAAuB,IAAI,GAEhCC,IAASC,KAET,EAAE,UAAAC,MAAaC,KAEf,CAACC,GAAaC,CAAc,IAAIC,EAAmB,CAAE,CAAA,GAErD,CAACC,GAASC,CAAU,IAAIF,EAAS,EAAK,GAEtCG,IAAc,MAAMD,EAAW,EAAI,GAEnCE,IAAiB,MAAM;AAErB,UAAAC,IAAaT,EAAS,CAAC,EAAE;AACnB,IAAAU,EAAAZ,GAAQW,GAAYb,EAAG,OAAO;AAAA,EAAA,GAGtCe,IAAQ,CAACC,GAAaC,MAC1BD,EAAE,MAAM,OAAOC,EAAE,SAASC,CAAG,CAAC,KAAKD,EAAE,MAAM,OAAOD,EAAE,SAASE,CAAG,CAAC;AAEnE,SAAAC,EAAU,MAAM;AAER,UAAAC,IAAUhB,EAAS,IAAI,CAAC,EAAE,YAAAS,QAAiBA,EAAW,EAAE;AAE9D,IAAKE,EAAMT,GAAac,CAAO,MAC7BV,EAAW,EAAK,GAChBH,EAAea,CAAO;AAAA,EACxB,GACC,CAAChB,CAAQ,CAAC,GAEbe,EAAU,MAAM;AACd,QAAI,CAACnB,EAAG;AAAS;AAEjB,IAAKS,KAAwBG;AAE7B,UAAMS,IAAmB,MAAM;AAC7B,MAAKZ,KAAwBG;IAAA;AAGxB,WAAAV,EAAA,WAAW,mBAAmBmB,CAAgB,GAE9C,MAAM;AACJ,MAAAnB,EAAA,cAAc,mBAAmBmB,CAAgB;AAAA,IAAA;AAAA,EAC1D,GACC,CAACjB,GAAUK,CAAO,CAAC,GAEfL,EAAS,SAAS,IACvBkB,gBAAAA,EAAA;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,KAAKvB;AAAA,MAEL,WAAU;AAAA,MACV,aAAAW;AAAA,MAEC,UAAMZ,EAAA,MAAM,EAAE,QAAAG,GAAQ,UAAAE,GAAU;AAAA,IAAA;AAAA,IAJ5BA,EAAS,IAAI,CAAC,EAAE,YAAAS,EAAA,MAAiBA,EAAW,EAAE,EAAE,KAAK,GAAG;AAAA,EAO7D,IAAA;AAEN;"}
1
+ {"version":3,"file":"annotorious-react.es11.js","sources":["../../../node_modules/react/jsx-runtime.js"],"sourcesContent":["'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n"],"names":["jsxRuntimeModule","require$$0","require$$1"],"mappings":";;;AAEI,QAAQ,IAAI,aAAa,eAC3BA,EAAA,UAAiBC,MAEjBD,EAAA,UAAiBE;;","x_google_ignoreList":[0]}
@@ -1,19 +1,11 @@
1
- import { j as m } from "./annotorious-react.es13.js";
2
- import { forwardRef as a, useRef as u, useContext as p, useEffect as c, useImperativeHandle as d } from "react";
3
- import l from "openseadragon";
4
- import { OpenSeadragonAnnotatorContext as x } from "./annotorious-react.es10.js";
5
- const O = a((n, s) => {
6
- const { className: i, options: t } = n, r = u(null), { viewer: f, setViewer: e } = p(x);
7
- return c(() => {
8
- if (r.current) {
9
- const o = l({ ...t, element: r.current });
10
- return e && e(o), () => {
11
- o.destroy(), e && e(void 0);
12
- };
13
- }
14
- }, [JSON.stringify(t)]), d(s, () => f), /* @__PURE__ */ m.jsx("div", { className: i, ref: r });
15
- });
1
+ import { useState as c, useRef as n, useEffect as s } from "react";
2
+ const m = (e, t) => {
3
+ const [u, o] = c(e), r = n();
4
+ return s(() => (r.current = setTimeout(() => o(e), t), () => {
5
+ clearTimeout(r.current);
6
+ }), [e, t]), u;
7
+ };
16
8
  export {
17
- O as OpenSeadragonViewer
9
+ m as useDebounce
18
10
  };
19
11
  //# sourceMappingURL=annotorious-react.es12.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es12.js","sources":["../src/openseadragon/OpenSeadragonViewer.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useImperativeHandle, 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 useEffect(() => { \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 v.destroy();\n\n if (setViewer) \n setViewer(undefined);\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","useEffect","v","OpenSeadragon","useImperativeHandle","jsx"],"mappings":";;;;AAYO,MAAMA,IAAsBC,EAA2D,CAACC,GAAiCC,MAAQ;AAEhI,QAAA,EAAE,WAAAC,GAAW,SAAAC,EAAY,IAAAH,GAEzBI,IAAUC,EAAuB,IAAI,GAErC,EAAE,QAAAC,GAAQ,WAAAC,EAAU,IAAIC,EAAWC,CAA6B;AAEtE,SAAAC,EAAU,MAAM;AACd,QAAIN,EAAQ,SAAS;AACb,YAAAO,IAAIC,EAAc,EAAC,GAAGT,GAAS,SAASC,EAAQ,SAAS;AAI3D,aAAAG,KACFA,EAAUI,CAAC,GAEN,MAAM;AACX,QAAAA,EAAE,QAAQ,GAENJ,KACFA,EAAU,MAAS;AAAA,MAAA;AAAA,IAEzB;AAAA,KACC,CAAC,KAAK,UAAUJ,CAAO,CAAC,CAAC,GAERU,EAAAZ,GAAK,MAAMK,CAAM,GAGlCQ,gBAAAA,EAAAA,IAAA,OAAA,EAAI,WAAAZ,GAAsB,KAAKE,EAAS,CAAA;AAG7C,CAAC;"}
1
+ {"version":3,"file":"annotorious-react.es12.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>>();\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;AAEjB,SAAAC,EAAU,OACRF,EAAS,UACP,WAAW,MAAMF,EAAkBH,CAAK,GAAGC,CAAK,GAE3C,MAAM;AACX,iBAAaI,EAAS,OAAO;AAAA,EAAA,IAE9B,CAACL,GAAOC,CAAK,CAAC,GAEVC;AACT;"}
@@ -1,9 +1,156 @@
1
- import { __module as e } from "./annotorious-react.es18.js";
2
- import { __require as r } from "./annotorious-react.es19.js";
3
- import { __require as o } from "./annotorious-react.es20.js";
4
- process.env.NODE_ENV === "production" ? e.exports = r() : e.exports = o();
5
- var m = e.exports;
1
+ import { useRef as ge, useState as ae, useEffect as ie } from "react";
2
+ var O = { dragStart: !0 }, he = (e, t = {}) => {
3
+ let o, c, { bounds: l, axis: m = "both", gpuAcceleration: f = !0, legacyTranslate: B = !0, transform: M, applyUserSelectHack: N = !0, disabled: R = !1, ignoreMultitouch: $ = !1, recomputeBounds: b = O, grid: H, position: u, cancel: D, handle: E, defaultClass: S = "neodrag", defaultClassDragging: i = "neodrag-dragging", defaultClassDragged: g = "neodrag-dragged", defaultPosition: W = { x: 0, y: 0 }, onDragStart: ce, onDrag: le, onDragEnd: ue } = t, X = !1, x = 0, A = 0, L = 0, T = 0, j = 0, z = 0, { x: Y, y: q } = u ? { x: (u == null ? void 0 : u.x) ?? 0, y: (u == null ? void 0 : u.y) ?? 0 } : W;
4
+ I(Y, q);
5
+ let y, C, P, F, _, ee = "", fe = !!u;
6
+ b = { ...O, ...b };
7
+ const G = document.body.style, v = e.classList;
8
+ function I(n = x, a = A) {
9
+ if (!M) {
10
+ if (B) {
11
+ let d = `${+n}px, ${+a}px`;
12
+ return k(e, "transform", f ? `translate3d(${d}, 0)` : `translate(${d})`);
13
+ }
14
+ return k(e, "translate", `${+n}px ${+a}px ${f ? "1px" : ""}`);
15
+ }
16
+ const s = M({ offsetX: n, offsetY: a, rootNode: e });
17
+ Q(s) && k(e, "transform", s);
18
+ }
19
+ const J = (n, a) => {
20
+ const s = { offsetX: x, offsetY: A, rootNode: e, currentNode: _ };
21
+ e.dispatchEvent(new CustomEvent(n, { detail: s })), a == null || a(s);
22
+ }, K = addEventListener;
23
+ K("pointerdown", re, !1), K("pointerup", te, !1), K("pointermove", oe, !1), k(e, "touch-action", "none");
24
+ const ne = () => {
25
+ let n = e.offsetWidth / C.width;
26
+ return isNaN(n) && (n = 1), n;
27
+ };
28
+ function re(n) {
29
+ if (R || n.button === 2 || $ && !n.isPrimary)
30
+ return;
31
+ if (b.dragStart && (y = V(l, e)), Q(E) && Q(D) && E === D)
32
+ throw new Error("`handle` selector can't be same as `cancel` selector");
33
+ if (v.add(S), P = function(r, p) {
34
+ if (!r)
35
+ return [p];
36
+ if (Z(r))
37
+ return [r];
38
+ if (Array.isArray(r))
39
+ return r;
40
+ const w = p.querySelectorAll(r);
41
+ if (w === null)
42
+ throw new Error("Selector passed for `handle` option should be child of the element on which the action is applied");
43
+ return Array.from(w.values());
44
+ }(E, e), F = function(r, p) {
45
+ if (!r)
46
+ return [];
47
+ if (Z(r))
48
+ return [r];
49
+ if (Array.isArray(r))
50
+ return r;
51
+ const w = p.querySelectorAll(r);
52
+ if (w === null)
53
+ throw new Error("Selector passed for `cancel` option should be child of the element on which the action is applied");
54
+ return Array.from(w.values());
55
+ }(D, e), o = /(both|x)/.test(m), c = /(both|y)/.test(m), de(F, P))
56
+ throw new Error("Element being dragged can't be a child of the element on which `cancel` is applied");
57
+ const a = n.composedPath()[0];
58
+ if (!P.some((r) => {
59
+ var p;
60
+ return r.contains(a) || ((p = r.shadowRoot) == null ? void 0 : p.contains(a));
61
+ }) || de(F, [a]))
62
+ return;
63
+ _ = P.length === 1 ? e : P.find((r) => r.contains(a)), X = !0, C = e.getBoundingClientRect(), N && (ee = G.userSelect, G.userSelect = "none"), J("neodrag:start", ce);
64
+ const { clientX: s, clientY: d } = n, h = ne();
65
+ o && (L = s - Y / h), c && (T = d - q / h), y && (j = s - C.left, z = d - C.top);
66
+ }
67
+ function te() {
68
+ X && (b.dragEnd && (y = V(l, e)), v.remove(i), v.add(g), N && (G.userSelect = ee), J("neodrag:end", ue), o && (L = x), c && (T = A), X = !1);
69
+ }
70
+ function oe(n) {
71
+ if (!X)
72
+ return;
73
+ b.drag && (y = V(l, e)), v.add(i), n.preventDefault(), C = e.getBoundingClientRect();
74
+ let a = n.clientX, s = n.clientY;
75
+ const d = ne();
76
+ if (y) {
77
+ const h = { left: y.left + j, top: y.top + z, right: y.right + j - C.width, bottom: y.bottom + z - C.height };
78
+ a = se(a, h.left, h.right), s = se(s, h.top, h.bottom);
79
+ }
80
+ if (Array.isArray(H)) {
81
+ let [h, r] = H;
82
+ if (isNaN(+h) || h < 0)
83
+ throw new Error("1st argument of `grid` must be a valid positive number");
84
+ if (isNaN(+r) || r < 0)
85
+ throw new Error("2nd argument of `grid` must be a valid positive number");
86
+ let p = a - L, w = s - T;
87
+ [p, w] = pe([h / d, r / d], p, w), a = L + p, s = T + w;
88
+ }
89
+ o && (x = Math.round((a - L) * d)), c && (A = Math.round((s - T) * d)), Y = x, q = A, J("neodrag", le), I();
90
+ }
91
+ return { destroy: () => {
92
+ const n = removeEventListener;
93
+ n("pointerdown", re, !1), n("pointerup", te, !1), n("pointermove", oe, !1);
94
+ }, update: (n) => {
95
+ var s, d;
96
+ m = n.axis || "both", R = n.disabled ?? !1, $ = n.ignoreMultitouch ?? !1, E = n.handle, l = n.bounds, b = n.recomputeBounds ?? O, D = n.cancel, N = n.applyUserSelectHack ?? !0, H = n.grid, f = n.gpuAcceleration ?? !0, B = n.legacyTranslate ?? !0, M = n.transform;
97
+ const a = v.contains(g);
98
+ v.remove(S, g), S = n.defaultClass ?? "neodrag", i = n.defaultClassDragging ?? "neodrag-dragging", g = n.defaultClassDragged ?? "neodrag-dragged", v.add(S), a && v.add(g), fe && (Y = x = ((s = n.position) == null ? void 0 : s.x) ?? x, q = A = ((d = n.position) == null ? void 0 : d.y) ?? A, I());
99
+ } };
100
+ }, se = (e, t, o) => Math.min(Math.max(e, t), o), Q = (e) => typeof e == "string", pe = ([e, t], o, c) => {
101
+ const l = (m, f) => f === 0 ? 0 : Math.ceil(m / f) * f;
102
+ return [l(o, e), l(c, t)];
103
+ }, de = (e, t) => e.some((o) => t.some((c) => o.contains(c)));
104
+ function V(e, t) {
105
+ if (e === void 0)
106
+ return;
107
+ if (Z(e))
108
+ return e.getBoundingClientRect();
109
+ if (typeof e == "object") {
110
+ const { top: c = 0, left: l = 0, right: m = 0, bottom: f = 0 } = e;
111
+ return { top: c, right: window.innerWidth - m, bottom: window.innerHeight - f, left: l };
112
+ }
113
+ if (e === "parent")
114
+ return t.parentNode.getBoundingClientRect();
115
+ const o = document.querySelector(e);
116
+ if (o === null)
117
+ throw new Error("The selector provided for bound doesn't exists in the document.");
118
+ return o.getBoundingClientRect();
119
+ }
120
+ var k = (e, t, o) => e.style.setProperty(t, o), Z = (e) => e instanceof HTMLElement;
121
+ function U(e) {
122
+ return e == null || typeof e == "string" || e instanceof HTMLElement ? e : "current" in e ? e.current : Array.isArray(e) ? e.map((t) => t instanceof HTMLElement ? t : t.current) : void 0;
123
+ }
124
+ function ye(e, t = {}) {
125
+ const o = ge(), [c, l] = ae(!1), [m, f] = ae();
126
+ let { onDragStart: B, onDrag: M, onDragEnd: N, handle: R, cancel: $ } = t, b = U(R), H = U($);
127
+ function u(i, g) {
128
+ f(i), g == null || g(i);
129
+ }
130
+ function D(i) {
131
+ l(!0), u(i, B);
132
+ }
133
+ function E(i) {
134
+ u(i, M);
135
+ }
136
+ function S(i) {
137
+ l(!1), u(i, N);
138
+ }
139
+ return ie(() => {
140
+ if (typeof window > "u")
141
+ return;
142
+ const i = e.current;
143
+ if (!i)
144
+ return;
145
+ ({ onDragStart: B, onDrag: M, onDragEnd: N } = t);
146
+ const { update: g, destroy: W } = he(i, { ...t, handle: b, cancel: H, onDragStart: D, onDrag: E, onDragEnd: S });
147
+ return o.current = g, W;
148
+ }, []), ie(() => {
149
+ var i;
150
+ (i = o.current) == null || i.call(o, { ...t, handle: U(R), cancel: U($), onDragStart: D, onDrag: E, onDragEnd: S });
151
+ }, [t]), { isDragging: c, dragState: m };
152
+ }
6
153
  export {
7
- m as j
154
+ ye as useDraggable
8
155
  };
9
156
  //# sourceMappingURL=annotorious-react.es13.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es13.js","sources":["../../../node_modules/react/jsx-runtime.js"],"sourcesContent":["'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n"],"names":["jsxRuntimeModule","require$$0","require$$1"],"mappings":";;;AAEI,QAAQ,IAAI,aAAa,eAC3BA,EAAA,UAAiBC,MAEjBD,EAAA,UAAiBE;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"annotorious-react.es13.js","sources":["../../../node_modules/@neodrag/react/dist/min/index.js"],"sourcesContent":["import{useRef as t,useState as e,useEffect as n}from\"react\";var r={dragStart:!0},o=(t,e={})=>{let n,o,{bounds:f,axis:g=\"both\",gpuAcceleration:h=!0,legacyTranslate:p=!0,transform:m,applyUserSelectHack:y=!0,disabled:w=!1,ignoreMultitouch:b=!1,recomputeBounds:v=r,grid:D,position:E,cancel:S,handle:x,defaultClass:A=\"neodrag\",defaultClassDragging:C=\"neodrag-dragging\",defaultClassDragged:M=\"neodrag-dragged\",defaultPosition:N={x:0,y:0},onDragStart:B,onDrag:$,onDragEnd:H}=e,L=!1,R=0,T=0,P=0,X=0,Y=0,q=0,{x:k,y:U}=E?{x:E?.x??0,y:E?.y??0}:N;Q(k,U);let W,j,z,F,G,I=\"\",J=!!E;v={...r,...v};const K=document.body.style,O=t.classList;function Q(e=R,n=T){if(!m){if(p){let r=`${+e}px, ${+n}px`;return l(t,\"transform\",h?`translate3d(${r}, 0)`:`translate(${r})`)}return l(t,\"translate\",`${+e}px ${+n}px ${h?\"1px\":\"\"}`)}const r=m({offsetX:e,offsetY:n,rootNode:t});i(r)&&l(t,\"transform\",r)}const V=(e,n)=>{const r={offsetX:R,offsetY:T,rootNode:t,currentNode:G};t.dispatchEvent(new CustomEvent(e,{detail:r})),n?.(r)};const Z=addEventListener;Z(\"pointerdown\",tt,!1),Z(\"pointerup\",et,!1),Z(\"pointermove\",nt,!1),l(t,\"touch-action\",\"none\");const _=()=>{let e=t.offsetWidth/j.width;return isNaN(e)&&(e=1),e};function tt(e){if(w)return;if(2===e.button)return;if(b&&!e.isPrimary)return;if(v.dragStart&&(W=c(f,t)),i(x)&&i(S)&&x===S)throw new Error(\"`handle` selector can't be same as `cancel` selector\");if(O.add(A),z=function(t,e){if(!t)return[e];if(u(t))return[t];if(Array.isArray(t))return t;const n=e.querySelectorAll(t);if(null===n)throw new Error(\"Selector passed for `handle` option should be child of the element on which the action is applied\");return Array.from(n.values())}(x,t),F=function(t,e){if(!t)return[];if(u(t))return[t];if(Array.isArray(t))return t;const n=e.querySelectorAll(t);if(null===n)throw new Error(\"Selector passed for `cancel` option should be child of the element on which the action is applied\");return Array.from(n.values())}(S,t),n=/(both|x)/.test(g),o=/(both|y)/.test(g),d(F,z))throw new Error(\"Element being dragged can't be a child of the element on which `cancel` is applied\");const r=e.composedPath()[0];if(!z.some((t=>t.contains(r)||t.shadowRoot?.contains(r)))||d(F,[r]))return;G=1===z.length?t:z.find((t=>t.contains(r))),L=!0,j=t.getBoundingClientRect(),y&&(I=K.userSelect,K.userSelect=\"none\"),V(\"neodrag:start\",B);const{clientX:a,clientY:s}=e,l=_();n&&(P=a-k/l),o&&(X=s-U/l),W&&(Y=a-j.left,q=s-j.top)}function et(){L&&(v.dragEnd&&(W=c(f,t)),O.remove(C),O.add(M),y&&(K.userSelect=I),V(\"neodrag:end\",H),n&&(P=R),o&&(X=T),L=!1)}function nt(e){if(!L)return;v.drag&&(W=c(f,t)),O.add(C),e.preventDefault(),j=t.getBoundingClientRect();let r=e.clientX,i=e.clientY;const d=_();if(W){const t={left:W.left+Y,top:W.top+q,right:W.right+Y-j.width,bottom:W.bottom+q-j.height};r=a(r,t.left,t.right),i=a(i,t.top,t.bottom)}if(Array.isArray(D)){let[t,e]=D;if(isNaN(+t)||t<0)throw new Error(\"1st argument of `grid` must be a valid positive number\");if(isNaN(+e)||e<0)throw new Error(\"2nd argument of `grid` must be a valid positive number\");let n=r-P,o=i-X;[n,o]=s([t/d,e/d],n,o),r=P+n,i=X+o}n&&(R=Math.round((r-P)*d)),o&&(T=Math.round((i-X)*d)),k=R,U=T,V(\"neodrag\",$),Q()}return{destroy:()=>{const t=removeEventListener;t(\"pointerdown\",tt,!1),t(\"pointerup\",et,!1),t(\"pointermove\",nt,!1)},update:t=>{g=t.axis||\"both\",w=t.disabled??!1,b=t.ignoreMultitouch??!1,x=t.handle,f=t.bounds,v=t.recomputeBounds??r,S=t.cancel,y=t.applyUserSelectHack??!0,D=t.grid,h=t.gpuAcceleration??!0,p=t.legacyTranslate??!0,m=t.transform;const e=O.contains(M);O.remove(A,M),A=t.defaultClass??\"neodrag\",C=t.defaultClassDragging??\"neodrag-dragging\",M=t.defaultClassDragged??\"neodrag-dragged\",O.add(A),e&&O.add(M),J&&(k=R=t.position?.x??R,U=T=t.position?.y??T,Q())}}},a=(t,e,n)=>Math.min(Math.max(t,e),n),i=t=>\"string\"==typeof t,s=([t,e],n,r)=>{const o=(t,e)=>0===e?0:Math.ceil(t/e)*e;return[o(n,t),o(r,e)]};var d=(t,e)=>t.some((t=>e.some((e=>t.contains(e)))));function c(t,e){if(void 0===t)return;if(u(t))return t.getBoundingClientRect();if(\"object\"==typeof t){const{top:e=0,left:n=0,right:r=0,bottom:o=0}=t;return{top:e,right:window.innerWidth-r,bottom:window.innerHeight-o,left:n}}if(\"parent\"===t)return e.parentNode.getBoundingClientRect();const n=document.querySelector(t);if(null===n)throw new Error(\"The selector provided for bound doesn't exists in the document.\");return n.getBoundingClientRect()}var l=(t,e,n)=>t.style.setProperty(e,n),u=t=>t instanceof HTMLElement;function f(t){return null==t||\"string\"==typeof t||t instanceof HTMLElement?t:\"current\"in t?t.current:Array.isArray(t)?t.map((t=>t instanceof HTMLElement?t:t.current)):void 0}function g(r,a={}){const i=t(),[s,d]=e(!1),[c,l]=e();let{onDragStart:u,onDrag:g,onDragEnd:h,handle:p,cancel:m}=a,y=f(p),w=f(m);function b(t,e){l(t),e?.(t)}function v(t){d(!0),b(t,u)}function D(t){b(t,g)}function E(t){d(!1),b(t,h)}return n((()=>{if(\"undefined\"==typeof window)return;const t=r.current;if(!t)return;({onDragStart:u,onDrag:g,onDragEnd:h}=a);const{update:e,destroy:n}=o(t,{...a,handle:y,cancel:w,onDragStart:v,onDrag:D,onDragEnd:E});return i.current=e,n}),[]),n((()=>{i.current?.({...a,handle:f(p),cancel:f(m),onDragStart:v,onDrag:D,onDragEnd:E})}),[a]),{isDragging:s,dragState:c}}export{g as useDraggable};"],"names":["r","o","t","e","n","f","g","h","p","m","y","w","b","v","D","E","S","x","A","C","M","N","B","$","H","L","R","T","P","X","Y","q","k","U","Q","W","j","z","G","I","J","K","O","l","i","V","Z","tt","et","nt","_","c","u","d","_a","a","s","_b"],"mappings":";AAA4D,IAAIA,IAAE,EAAC,WAAU,GAAE,GAAEC,KAAE,CAACC,GAAEC,IAAE,CAAE,MAAG;AAAC,MAAIC,GAAEH,GAAE,EAAC,QAAOI,GAAE,MAAKC,IAAE,QAAO,iBAAgBC,IAAE,IAAG,iBAAgBC,IAAE,IAAG,WAAUC,GAAE,qBAAoBC,IAAE,IAAG,UAASC,IAAE,IAAG,k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E,WAAUL,EAAC;AAAC;","x_google_ignoreList":[0]}
@@ -1,11 +1,35 @@
1
- import { useState as c, useRef as n, useEffect as s } from "react";
2
- const m = (e, t) => {
3
- const [u, o] = c(e), r = n();
4
- return s(() => (r.current = setTimeout(() => o(e), t), () => {
5
- clearTimeout(r.current);
6
- }), [e, t]), u;
1
+ import b from "openseadragon";
2
+ const L = (h, x) => {
3
+ const { minX: e, minY: n, maxX: i, maxY: t } = x.target.selector.geometry.bounds, l = h.viewport.imageToViewerElementCoordinates(new b.Point(e, n)), s = h.viewport.imageToViewerElementCoordinates(new b.Point(i, t));
4
+ return {
5
+ x: l.x,
6
+ right: s.x,
7
+ y: l.y,
8
+ bottom: s.y,
9
+ width: s.x - l.x,
10
+ height: s.y - l.y
11
+ };
12
+ }, T = (h, x, e, n = 5) => {
13
+ const i = h.element.getBoundingClientRect(), t = L(h, x), l = t.y - i.y, s = i.right - t.x, w = i.bottom - t.bottom, $ = t.x - i.left, o = e.firstElementChild.getBoundingClientRect(), a = l / o.height, c = s / o.width, g = w / o.height, r = $ / o.width, d = () => {
14
+ e.style.left = `${t.x}px`, e.style.top = `${t.y - n - o.height}px`;
15
+ }, f = () => {
16
+ e.style.left = `${t.right - o.width}px`, e.style.top = `${t.y - n - o.height}px`;
17
+ }, v = () => {
18
+ e.style.left = `${t.x - o.width - n}px`, e.style.top = `${t.y}px`;
19
+ }, B = () => {
20
+ e.style.left = `${t.right + n}px`, e.style.top = `${t.y}px`;
21
+ }, R = () => {
22
+ e.style.left = `${t.x - o.width - n}px`, e.style.top = `${t.bottom - o.height}px`;
23
+ }, C = () => {
24
+ e.style.left = `${t.x + t.width + n}px`, e.style.top = `${t.bottom - o.height}px`;
25
+ }, A = () => {
26
+ e.style.left = `${t.x}px`, e.style.top = `${t.bottom + n}px`;
27
+ }, E = () => {
28
+ e.style.left = `${t.right - o.width}px`, e.style.top = `${t.bottom + n}px`;
29
+ }, m = [a, c, g, r], y = m.indexOf(Math.max(...m));
30
+ y === 0 ? c > r ? d() : f() : y === 1 ? a > g ? C() : B() : y === 2 ? c > r ? A() : E() : a > g ? R() : v();
7
31
  };
8
32
  export {
9
- m as useDebounce
33
+ T as setPosition
10
34
  };
11
35
  //# sourceMappingURL=annotorious-react.es14.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es14.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>>();\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;AAEjB,SAAAC,EAAU,OACRF,EAAS,UACP,WAAW,MAAMF,EAAkBH,CAAK,GAAGC,CAAK,GAE3C,MAAM;AACX,iBAAaI,EAAS,OAAO;AAAA,EAAA,IAE9B,CAACL,GAAOC,CAAK,CAAC,GAEVC;AACT;"}
1
+ {"version":3,"file":"annotorious-react.es14.js","sources":["../src/openseadragon/setPosition.ts"],"sourcesContent":["import { ImageAnnotation } from '@annotorious/annotorious';\nimport OpenSeadragon from 'openseadragon';\n\nconst getAnnotationDomRect = (viewer: OpenSeadragon.Viewer, annotation: ImageAnnotation) => {\n // Annotation bounds (image coordinates)\n const { minX, minY, maxX, maxY } = annotation.target.selector.geometry.bounds;\n\n // Annotation coordinates - viewer element coordinates\n const topLeft = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(minX, minY));\n const bottomRight = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(maxX, maxY));\n\n // Account for viewer element offset\n return {\n x: topLeft.x,\n right: bottomRight.x,\n y: topLeft.y, \n bottom: bottomRight.y,\n width: bottomRight.x - topLeft.x,\n height: bottomRight.y - topLeft.y,\n };\n}\n\nexport const setPosition = (\n viewer: OpenSeadragon.Viewer, \n annotation: ImageAnnotation, \n popup: HTMLElement,\n sideOffset: number = 5\n) => {\n const viewerBounds = viewer.element.getBoundingClientRect();\n const annoBounds = getAnnotationDomRect(viewer, annotation);\n\n // Available space above, right, below, left the annotation in the viewport\n const availableAbove = annoBounds.y - viewerBounds.y;\n const availableRight = viewerBounds.right - annoBounds.x;\n const availableBelow = viewerBounds.bottom - annoBounds.bottom;\n const availableLeft = annoBounds.x - viewerBounds.left;\n\n // Popup element bounds\n const popupBounds = popup.firstElementChild.getBoundingClientRect();\n\n // Eight possible base alignment anchor points\n //\n // topleft topright\n // * *\n // leftdown * |---------------------| * rightdown\n // | |\n // | |\n // | |\n // leftup * |---------------------| * rightup\n // * * \n // bottomleft bottomright\n //\n // We'll position the popup at the cardinal direction\n // with the highest ratio: available space vs. popup size.\n const ratioAbove = availableAbove / popupBounds.height;\n const ratioRight = availableRight / popupBounds.width;\n const ratioBelow = availableBelow / popupBounds.height;\n const ratioLeft = availableLeft / popupBounds.width;\n\n const topleft = () => {\n popup.style.left = `${annoBounds.x}px`;\n popup.style.top = `${annoBounds.y - sideOffset - popupBounds.height}px`;\n }\n\n const topright = () => {\n popup.style.left = `${annoBounds.right - popupBounds.width}px`;\n popup.style.top = `${annoBounds.y - sideOffset - popupBounds.height}px`;\n }\n\n const leftdown = () => {\n popup.style.left = `${annoBounds.x - popupBounds.width - sideOffset}px`;\n popup.style.top = `${annoBounds.y}px`;\n } \n\n const rightdown = () => {\n popup.style.left = `${annoBounds.right + sideOffset}px`;\n popup.style.top = `${annoBounds.y}px`;\n }\n\n const leftup = () => {\n popup.style.left = `${annoBounds.x - popupBounds.width - sideOffset}px`;\n popup.style.top = `${annoBounds.bottom - popupBounds.height}px`;\n }\n\n const rightup = () => {\n popup.style.left = `${annoBounds.x + annoBounds.width + sideOffset}px`;\n popup.style.top = `${annoBounds.bottom - popupBounds.height}px`;\n }\n\n const bottomleft = () => {\n popup.style.left = `${annoBounds.x}px`;\n popup.style.top = `${annoBounds.bottom + sideOffset}px`;\n }\n\n const bottomright = () => {\n popup.style.left = `${annoBounds.right - popupBounds.width}px`;\n popup.style.top = `${annoBounds.bottom + sideOffset}px`;\n }\n\n const ratios = [ratioAbove, ratioRight, ratioBelow, ratioLeft];\n const maxIdx = ratios.indexOf(Math.max(...ratios));\n\n if (maxIdx === 0) {\n // Main orientation: above\n if (ratioRight > ratioLeft)\n topleft();\n else \n topright();\n } else if (maxIdx === 1) {\n // Main orientation: right\n if (ratioAbove > ratioBelow)\n rightup();\n else\n rightdown();\n } else if (maxIdx === 2) {\n // Main orientation: below\n if (ratioRight > ratioLeft)\n bottomleft();\n else\n bottomright();\n } else {\n // Main orientation: left\n if (ratioAbove > ratioBelow)\n leftup();\n else \n leftdown();\n }\n}"],"names":["getAnnotationDomRect","viewer","annotation","minX","minY","maxX","maxY","topLeft","OpenSeadragon","bottomRight","setPosition","popup","sideOffset","viewerBounds","annoBounds","availableAbove","availableRight","availableBelow","availableLeft","popupBounds","ratioAbove","ratioRight","ratioBelow","ratioLeft","topleft","topright","leftdown","rightdown","leftup","rightup","bottomleft","bottomright","ratios","maxIdx"],"mappings":";AAGA,MAAMA,IAAuB,CAACC,GAA8BC,MAAgC;AAEpF,QAAA,EAAE,MAAAC,GAAM,MAAAC,GAAM,MAAAC,GAAM,MAAAC,MAASJ,EAAW,OAAO,SAAS,SAAS,QAGjEK,IAAUN,EAAO,SAAS,gCAAgC,IAAIO,EAAc,MAAML,GAAMC,CAAI,CAAC,GAC7FK,IAAcR,EAAO,SAAS,gCAAgC,IAAIO,EAAc,MAAMH,GAAMC,CAAI,CAAC;AAGhG,SAAA;AAAA,IACL,GAAGC,EAAQ;AAAA,IACX,OAAOE,EAAY;AAAA,I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