@annotorious/react 3.1.1 → 3.1.3

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 (49) hide show
  1. package/dist/annotorious-react.es10.js +5 -5
  2. package/dist/annotorious-react.es10.js.map +1 -1
  3. package/dist/annotorious-react.es11.js +8 -6
  4. package/dist/annotorious-react.es11.js.map +1 -1
  5. package/dist/annotorious-react.es12.js +266 -8
  6. package/dist/annotorious-react.es12.js.map +1 -1
  7. package/dist/annotorious-react.es13.js +7 -264
  8. package/dist/annotorious-react.es13.js.map +1 -1
  9. package/dist/annotorious-react.es14.js +195 -7
  10. package/dist/annotorious-react.es14.js.map +1 -1
  11. package/dist/annotorious-react.es15.js +379 -185
  12. package/dist/annotorious-react.es15.js.map +1 -1
  13. package/dist/annotorious-react.es16.js +13 -390
  14. package/dist/annotorious-react.es16.js.map +1 -1
  15. package/dist/annotorious-react.es17.js +127 -12
  16. package/dist/annotorious-react.es17.js.map +1 -1
  17. package/dist/annotorious-react.es18.js +7 -2
  18. package/dist/annotorious-react.es18.js.map +1 -1
  19. package/dist/annotorious-react.es19.js +2 -33
  20. package/dist/annotorious-react.es19.js.map +1 -1
  21. package/dist/annotorious-react.es2.js +19 -19
  22. package/dist/annotorious-react.es2.js.map +1 -1
  23. package/dist/annotorious-react.es20.js +10 -405
  24. package/dist/annotorious-react.es20.js.map +1 -1
  25. package/dist/annotorious-react.es21.js +120 -123
  26. package/dist/annotorious-react.es21.js.map +1 -1
  27. package/dist/annotorious-react.es22.js +466 -2
  28. package/dist/annotorious-react.es22.js.map +1 -1
  29. package/dist/annotorious-react.es4.js +33 -33
  30. package/dist/annotorious-react.es4.js.map +1 -1
  31. package/dist/annotorious-react.es5.js +22 -22
  32. package/dist/annotorious-react.es5.js.map +1 -1
  33. package/dist/annotorious-react.es8.js +14 -14
  34. package/dist/annotorious-react.es8.js.map +1 -1
  35. package/dist/annotorious-react.es9.js +43 -43
  36. package/dist/annotorious-react.es9.js.map +1 -1
  37. package/package.json +4 -4
  38. package/dist/annotorious-react.es23.js +0 -5
  39. package/dist/annotorious-react.es23.js.map +0 -1
  40. package/dist/annotorious-react.es24.js +0 -10
  41. package/dist/annotorious-react.es24.js.map +0 -1
  42. package/dist/annotorious-react.es25.js +0 -5
  43. package/dist/annotorious-react.es25.js.map +0 -1
  44. package/dist/annotorious-react.es26.js +0 -14
  45. package/dist/annotorious-react.es26.js.map +0 -1
  46. package/dist/annotorious-react.es27.js +0 -129
  47. package/dist/annotorious-react.es27.js.map +0 -1
  48. package/dist/annotorious-react.es28.js +0 -469
  49. package/dist/annotorious-react.es28.js.map +0 -1
@@ -1,12 +1,12 @@
1
- import { j as g } from "./annotorious-react.es11.js";
2
- import { useState as E, useRef as C, useEffect as A } from "react";
3
- import { useFloating as D, FloatingArrow as O } from "./annotorious-react.es13.js";
4
- import { useAnnotator as j, useSelection as L } from "./annotorious-react.es2.js";
5
- import { toClientRects as S } from "./annotorious-react.es14.js";
6
- import { inline as U, offset as F, flip as M, shift as P, arrow as b } from "./annotorious-react.es15.js";
7
- import { autoUpdate as k } from "./annotorious-react.es16.js";
8
- import w from "./annotorious-react.es17.js";
9
- const z = (i, t) => {
1
+ import { jsxs as x, jsx as C } from "react/jsx-runtime";
2
+ import { useState as E, useRef as A, useEffect as D } from "react";
3
+ import { useFloating as O, FloatingArrow as L } from "./annotorious-react.es12.js";
4
+ import { useAnnotator as S, useSelection as U } from "./annotorious-react.es2.js";
5
+ import { toClientRects as F } from "./annotorious-react.es13.js";
6
+ import { inline as M, offset as P, flip as b, shift as j, arrow as k } from "./annotorious-react.es14.js";
7
+ import { autoUpdate as z } from "./annotorious-react.es15.js";
8
+ import g from "./annotorious-react.es16.js";
9
+ const H = (i, t) => {
10
10
  const n = t.querySelector("img"), { left: a, top: d } = n.getBoundingClientRect(), s = n.offsetWidth / n.naturalWidth, c = n.offsetHeight / n.naturalHeight, { minX: o, minY: l, maxX: p, maxY: u } = i.bounds;
11
11
  return new DOMRect(
12
12
  a + s * o,
@@ -14,35 +14,35 @@ const z = (i, t) => {
14
14
  s * (p - o),
15
15
  c * (u - l)
16
16
  );
17
- }, K = (i) => {
17
+ }, Q = (i) => {
18
18
  var m, f;
19
- const t = j(), [n, a] = E(!1), d = C(null), { selected: s, event: c } = L(), o = (m = s[0]) == null ? void 0 : m.annotation, l = (f = s[0]) == null ? void 0 : f.editable, { refs: p, floatingStyles: u, context: h, update: H } = D({
19
+ const t = S(), [n, a] = E(!1), d = A(null), { selected: s, event: c } = U(), o = (m = s[0]) == null ? void 0 : m.annotation, l = (f = s[0]) == null ? void 0 : f.editable, { refs: p, floatingStyles: u, context: w, update: I } = O({
20
20
  open: n,
21
21
  onOpenChange: a,
22
22
  middleware: [
23
- U(),
24
- F(10),
25
- M({ crossAxis: !0 }),
26
- P({
23
+ M(),
24
+ P(10),
25
+ b({ crossAxis: !0 }),
26
+ j({
27
27
  crossAxis: !0,
28
28
  padding: { right: 5, left: 5, top: 10, bottom: 10 }
29
29
  }),
30
- b({
30
+ k({
31
31
  element: d,
32
32
  padding: 5
33
33
  })
34
34
  ],
35
- whileElementsMounted: k
35
+ whileElementsMounted: z
36
36
  });
37
- A(() => {
37
+ D(() => {
38
38
  if (s.length === 0)
39
39
  a(!1);
40
40
  else {
41
41
  const e = () => {
42
- const r = z(o.target.selector.geometry, t.element);
42
+ const r = H(o.target.selector.geometry, t.element);
43
43
  p.setReference({
44
44
  getBoundingClientRect: () => r,
45
- getClientRects: () => S(r)
45
+ getClientRects: () => F(r)
46
46
  });
47
47
  };
48
48
  return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), e(), a(!0), () => {
@@ -50,8 +50,8 @@ const z = (i, t) => {
50
50
  };
51
51
  }
52
52
  }, [t, i.popup, s]);
53
- const x = (e) => {
54
- const r = e.id || w();
53
+ const h = (e) => {
54
+ const r = e.id || g();
55
55
  t.state.store.addBody({
56
56
  ...e,
57
57
  id: r,
@@ -61,28 +61,28 @@ const z = (i, t) => {
61
61
  });
62
62
  }, y = (e) => {
63
63
  t.state.store.deleteBody({ id: e, annotation: o.id });
64
- }, R = (e, r) => {
65
- const v = r.id || w(), B = {
64
+ }, v = (e, r) => {
65
+ const B = r.id || g(), R = {
66
66
  updated: /* @__PURE__ */ new Date(),
67
67
  updatedBy: t.getUser(),
68
68
  ...r,
69
- id: v,
69
+ id: B,
70
70
  annotation: o.id
71
71
  };
72
- t.state.store.updateBody(e, B);
72
+ t.state.store.updateBody(e, R);
73
73
  };
74
- return n && o ? /* @__PURE__ */ g.jsxs(
74
+ return n && o ? /* @__PURE__ */ x(
75
75
  "div",
76
76
  {
77
77
  className: "a9s-popup a9s-image-popup",
78
78
  ref: p.setFloating,
79
79
  style: u,
80
80
  children: [
81
- i.arrow && /* @__PURE__ */ g.jsx(
82
- O,
81
+ i.arrow && /* @__PURE__ */ C(
82
+ L,
83
83
  {
84
84
  ref: d,
85
- context: h,
85
+ context: w,
86
86
  ...i.arrowProps || {}
87
87
  }
88
88
  ),
@@ -90,15 +90,15 @@ const z = (i, t) => {
90
90
  annotation: o,
91
91
  editable: l,
92
92
  event: c,
93
- onCreateBody: x,
93
+ onCreateBody: h,
94
94
  onDeleteBody: y,
95
- onUpdateBody: R
95
+ onUpdateBody: v
96
96
  })
97
97
  ]
98
98
  }
99
99
  ) : null;
100
100
  };
101
101
  export {
102
- K as ImageAnnotationPopup
102
+ Q as ImageAnnotationPopup
103
103
  };
104
104
  //# sourceMappingURL=annotorious-react.es4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es4.js","sources":["../src/ImageAnnotationPopup.tsx"],"sourcesContent":["import { ReactNode, useEffect, useRef, useState } from 'react';\nimport { v4 as uuidv4 } from 'uuid';\nimport { AnnotationBody, Geometry } from '@annotorious/annotorious';\nimport {\n useFloating,\n arrow,\n shift,\n inline,\n autoUpdate,\n flip,\n offset,\n FloatingArrow,\n FloatingArrowProps\n} from '@floating-ui/react';\nimport { useAnnotator, useSelection } from './Annotorious';\nimport { PopupProps } from './PopupProps';\nimport { toClientRects } from './utils/toClientRects';\nimport { ImageAnnotator } from '@annotorious/openseadragon';\n\nconst toDOMRect = (geometry: Geometry, container: HTMLDivElement) => {\n const img = container.querySelector('img');\n\n const { left, top } = img.getBoundingClientRect();\n\n const kx = img.offsetWidth / img.naturalWidth;\n const ky = img.offsetHeight / img.naturalHeight;\n\n const { minX, minY, maxX, maxY } = geometry.bounds;\n\n return new DOMRect(\n left + kx * minX,\n top + ky * minY,\n kx * (maxX - minX),\n ky * (maxY - minY)\n );\n}\n\ninterface ImageAnnotationPopupProps {\n\n arrow?: boolean;\n\n arrowProps?: Omit<FloatingArrowProps, 'context' | 'ref'>;\n\n popup: (props: PopupProps) => ReactNode;\n\n}\n\nexport const ImageAnnotationPopup = (props: ImageAnnotationPopupProps) => {\n\n const anno = useAnnotator<ImageAnnotator>();\n\n const [isOpen, setIsOpen] = useState(false);\n\n const arrowRef = useRef(null);\n\n const { selected, event } = useSelection();\n\n const annotation = selected[0]?.annotation;\n\n const editable = selected[0]?.editable;\n\n const { refs, floatingStyles, context, update } = useFloating({\n open: isOpen,\n onOpenChange: setIsOpen,\n middleware: [\n inline(), \n offset(10),\n flip({ crossAxis: true }),\n shift({ \n crossAxis: true,\n padding: { right: 5, left: 5, top: 10, bottom: 10 }\n }),\n arrow({\n element: arrowRef,\n padding: 5\n })\n ],\n whileElementsMounted: autoUpdate\n });\n\n useEffect(() => {\n if (selected.length === 0) {\n setIsOpen(false);\n } else {\n const setPosition = () => { \n const rect = toDOMRect(annotation.target.selector.geometry, anno.element);\n\n refs.setReference({\n getBoundingClientRect: () => rect,\n getClientRects: () => toClientRects(rect)\n });\n }\n\n window.addEventListener('scroll', setPosition, true);\n window.addEventListener('resize', setPosition);\n\n setPosition();\n\n setIsOpen(true);\n\n return () => {\n window.removeEventListener('scroll', setPosition, true);\n window.removeEventListener('resize', setPosition);\n };\n }\n }, [anno, props.popup, selected]);\n\n const onCreateBody = (body: Partial<AnnotationBody>) => {\n const id = body.id || uuidv4();\n \n anno.state.store.addBody({\n ...body,\n id,\n annotation: annotation.id,\n created: body.created || new Date(),\n creator: anno.getUser()\n });\n }\n\n const onDeleteBody = (id: string) => {\n anno.state.store.deleteBody({ id, annotation: annotation.id });\n }\n\n const onUpdateBody = (current: AnnotationBody, next: AnnotationBody) => {\n const id = next.id || uuidv4();\n\n const updated: AnnotationBody = {\n updated: new Date(),\n updatedBy: anno.getUser(),\n ...next,\n id,\n annotation: annotation.id\n }\n\n anno.state.store.updateBody(current, updated);\n }\n\n return (isOpen && annotation) ? (\n <div\n className=\"a9s-popup a9s-image-popup\"\n ref={refs.setFloating}\n style={floatingStyles}>\n\n {props.arrow && (\n <FloatingArrow \n ref={arrowRef} \n context={context} \n {...(props.arrowProps || {})} />\n )}\n\n {props.popup({ \n annotation, \n editable, \n event,\n onCreateBody,\n onDeleteBody,\n onUpdateBody\n })}\n </div>\n ) : null;\n\n}\n"],"names":["toDOMRect","geometry","container","img","left","top","kx","ky","minX","minY","maxX","maxY","ImageAnnotationPopup","props","anno","useAnnotator","isOpen","setIsOpen","useState","arrowRef","useRef","selected","event","useSelection","annotation","_a","editable","_b","refs","floatingStyles","context","update","useFloating","inline","offset","flip","shift","arrow","autoUpdate","useEffect","setPosition","rect","toClientRects","onCreateBody","body","id","uuidv4","onDeleteBody","onUpdateBody","current","next","updated","jsxs","jsx","FloatingArrow"],"mappings":";;;;;;;;AAmBA,MAAMA,IAAY,CAACC,GAAoBC,MAA8B;AAC7D,QAAAC,IAAMD,EAAU,cAAc,KAAK,GAEnC,EAAE,MAAAE,GAAM,KAAAC,MAAQF,EAAI,sBAAsB,GAE1CG,IAAKH,EAAI,cAAcA,EAAI,cAC3BI,IAAKJ,EAAI,eAAeA,EAAI,eAE5B,EAAE,MAAAK,GAAM,MAAAC,GAAM,MAAAC,GAAM,MAAAC,EAAA,IAASV,EAAS;AAE5C,SAAO,IAAI;AAAA,IACTG,IAAOE,IAAKE;AAAA,IACZ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AA,UACX,YAAAW;AAAA,UACA,UAAAE;AAAA,UACA,OAAAJ;AAAA,UACA,cAAAqB;AAAA,UACA,cAAAI;AAAA,UACA,cAAAC;AAAA,QACD,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,IAED;AAEN;"}
1
+ {"version":3,"file":"annotorious-react.es4.js","sources":["../src/ImageAnnotationPopup.tsx"],"sourcesContent":["import { ReactNode, useEffect, useRef, useState } from 'react';\nimport { v4 as uuidv4 } from 'uuid';\nimport { AnnotationBody, Geometry } from '@annotorious/annotorious';\nimport {\n useFloating,\n arrow,\n shift,\n inline,\n autoUpdate,\n flip,\n offset,\n FloatingArrow,\n FloatingArrowProps\n} from '@floating-ui/react';\nimport { useAnnotator, useSelection } from './Annotorious';\nimport { PopupProps } from './PopupProps';\nimport { toClientRects } from './utils/toClientRects';\nimport { ImageAnnotator } from '@annotorious/openseadragon';\n\nconst toDOMRect = (geometry: Geometry, container: HTMLDivElement) => {\n const img = container.querySelector('img');\n\n const { left, top } = img.getBoundingClientRect();\n\n const kx = img.offsetWidth / img.naturalWidth;\n const ky = img.offsetHeight / img.naturalHeight;\n\n const { minX, minY, maxX, maxY } = geometry.bounds;\n\n return new DOMRect(\n left + kx * minX,\n top + ky * minY,\n kx * (maxX - minX),\n ky * (maxY - minY)\n );\n}\n\ninterface ImageAnnotationPopupProps {\n\n arrow?: boolean;\n\n arrowProps?: Omit<FloatingArrowProps, 'context' | 'ref'>;\n\n popup: (props: PopupProps) => ReactNode;\n\n}\n\nexport const ImageAnnotationPopup = (props: ImageAnnotationPopupProps) => {\n\n const anno = useAnnotator<ImageAnnotator>();\n\n const [isOpen, setIsOpen] = useState(false);\n\n const arrowRef = useRef(null);\n\n const { selected, event } = useSelection();\n\n const annotation = selected[0]?.annotation;\n\n const editable = selected[0]?.editable;\n\n const { refs, floatingStyles, context, update } = useFloating({\n open: isOpen,\n onOpenChange: setIsOpen,\n middleware: [\n inline(), \n offset(10),\n flip({ crossAxis: true }),\n shift({ \n crossAxis: true,\n padding: { right: 5, left: 5, top: 10, bottom: 10 }\n }),\n arrow({\n element: arrowRef,\n padding: 5\n })\n ],\n whileElementsMounted: autoUpdate\n });\n\n useEffect(() => {\n if (selected.length === 0) {\n setIsOpen(false);\n } else {\n const setPosition = () => { \n const rect = toDOMRect(annotation.target.selector.geometry, anno.element);\n\n refs.setReference({\n getBoundingClientRect: () => rect,\n getClientRects: () => toClientRects(rect)\n });\n }\n\n window.addEventListener('scroll', setPosition, true);\n window.addEventListener('resize', setPosition);\n\n setPosition();\n\n setIsOpen(true);\n\n return () => {\n window.removeEventListener('scroll', setPosition, true);\n window.removeEventListener('resize', setPosition);\n };\n }\n }, [anno, props.popup, selected]);\n\n const onCreateBody = (body: Partial<AnnotationBody>) => {\n const id = body.id || uuidv4();\n \n anno.state.store.addBody({\n ...body,\n id,\n annotation: annotation.id,\n created: body.created || new Date(),\n creator: anno.getUser()\n });\n }\n\n const onDeleteBody = (id: string) => {\n anno.state.store.deleteBody({ id, annotation: annotation.id });\n }\n\n const onUpdateBody = (current: AnnotationBody, next: AnnotationBody) => {\n const id = next.id || uuidv4();\n\n const updated: AnnotationBody = {\n updated: new Date(),\n updatedBy: anno.getUser(),\n ...next,\n id,\n annotation: annotation.id\n }\n\n anno.state.store.updateBody(current, updated);\n }\n\n return (isOpen && annotation) ? (\n <div\n className=\"a9s-popup a9s-image-popup\"\n ref={refs.setFloating}\n style={floatingStyles}>\n\n {props.arrow && (\n <FloatingArrow \n ref={arrowRef} \n context={context} \n {...(props.arrowProps || {})} />\n )}\n\n {props.popup({ \n annotation, \n editable, \n event,\n onCreateBody,\n onDeleteBody,\n onUpdateBody\n })}\n </div>\n ) : null;\n\n}\n"],"names":["toDOMRect","geometry","container","img","left","top","kx","ky","minX","minY","maxX","maxY","ImageAnnotationPopup","props","anno","useAnnotator","isOpen","setIsOpen","useState","arrowRef","useRef","selected","event","useSelection","annotation","_a","editable","_b","refs","floatingStyles","context","update","useFloating","inline","offset","flip","shift","arrow","autoUpdate","useEffect","setPosition","rect","toClientRects","onCreateBody","body","id","uuidv4","onDeleteBody","onUpdateBody","current","next","updated","jsxs","jsx","FloatingArrow"],"mappings":";;;;;;;;AAmBA,MAAMA,IAAY,CAACC,GAAoBC,MAA8B;AAC7D,QAAAC,IAAMD,EAAU,cAAc,KAAK,GAEnC,EAAE,MAAAE,GAAM,KAAAC,MAAQF,EAAI,sBAAsB,GAE1CG,IAAKH,EAAI,cAAcA,EAAI,cAC3BI,IAAKJ,EAAI,eAAeA,EAAI,eAE5B,EAAE,MAAAK,GAAM,MAAAC,GAAM,MAAAC,GAAM,MAAAC,EAAA,IAASV,EAAS;AAE5C,SAAO,IAAI;AAAA,IACTG,IAAOE,IAAKE;AAAA,IACZH,IAAME,IAAKE;AAAA,IACXH,KAAMI,IAAOF;AAAA,IACbD,KAAMI,IAAOF;AAAA,EACf;AACF,GAYaG,IAAuB,CAACC,MAAqC;;AAExE,QAAMC,IAAOC,EAA6B,GAEpC,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GAEpCC,IAAWC,EAAO,IAAI,GAEtB,EAAE,UAAAC,GAAU,OAAAC,EAAM,IAAIC,EAAa,GAEnCC,KAAaC,IAAAJ,EAAS,CAAC,MAAV,gBAAAI,EAAa,YAE1BC,KAAWC,IAAAN,EAAS,CAAC,MAAV,gBAAAM,EAAa,UAExB,EAAE,MAAAC,GAAM,gBAAAC,GAAgB,SAAAC,GAAS,QAAAC,EAAA,IAAWC,EAAY;AAAA,IAC5D,MAAMhB;AAAA,IACN,cAAcC;AAAA,IACd,YAAY;AAAA,MACVgB,EAAO;AAAA,MACPC,EAAO,EAAE;AAAA,MACTC,EAAK,EAAE,WAAW,IAAM;AAAA,MACxBC,EAAM;AAAA,QACJ,WAAW;AAAA,QACX,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,IAAI,QAAQ,GAAG;AAAA,MAAA,CACnD;AAAA,MACDC,EAAM;AAAA,QACJ,SAASlB;AAAA,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oC;AAAA,MACH,IAAAL;AAAA,MACA,YAAYrB,EAAW;AAAA,IACzB;AAEA,IAAAV,EAAK,MAAM,MAAM,WAAWmC,GAASE,CAAO;AAAA,EAC9C;AAEA,SAAQnC,KAAUQ,IAChB,gBAAA4B;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,KAAKxB,EAAK;AAAA,MACV,OAAOC;AAAA,MAEN,UAAA;AAAA,QAAAhB,EAAM,SACL,gBAAAwC;AAAA,UAACC;AAAA,UAAA;AAAA,YACC,KAAKnC;AAAA,YACL,SAAAW;AAAA,YACC,GAAIjB,EAAM,cAAc,CAAA;AAAA,UAAC;AAAA,QAAI;AAAA,QAGjCA,EAAM,MAAM;AAAA,UACX,YAAAW;AAAA,UACA,UAAAE;AAAA,UACA,OAAAJ;AAAA,UACA,cAAAqB;AAAA,UACA,cAAAI;AAAA,UACA,cAAAC;AAAA,QACD,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,IAED;AAEN;"}
@@ -1,29 +1,29 @@
1
- import { j as i } from "./annotorious-react.es11.js";
2
- import { Children as g, useContext as u, useEffect as n, cloneElement as x } from "react";
3
- import { createImageAnnotator as A } from "@annotorious/annotorious";
4
- import { AnnotoriousContext as C } from "./annotorious-react.es2.js";
5
- const N = (e) => {
6
- const { children: a, tool: o, ...l } = e, r = g.only(a), { anno: t, setAnno: c } = u(C), s = (m) => {
7
- if (!t) {
8
- const f = m.target, d = A(f, l);
9
- c(d);
1
+ import { jsx as d, Fragment as g } from "react/jsx-runtime";
2
+ import { Children as u, useContext as A, useEffect as n, cloneElement as C } from "react";
3
+ import { createImageAnnotator as x } from "@annotorious/annotorious";
4
+ import { AnnotoriousContext as E } from "./annotorious-react.es2.js";
5
+ const S = (t) => {
6
+ const { children: i, tool: o, ...a } = t, l = u.only(i), { anno: e, setAnno: c } = A(E), r = (s) => {
7
+ if (!e) {
8
+ const m = s.target, f = x(m, a);
9
+ c(f);
10
10
  }
11
11
  };
12
12
  return n(() => {
13
- !t || !e.containerClassName || (t.element.className = e.containerClassName);
14
- }, [e.containerClassName, t]), n(() => {
15
- t && t.setDrawingEnabled(e.drawingEnabled);
16
- }, [e.drawingEnabled]), n(() => {
17
- t && t.setFilter(e.filter);
18
- }, [e.filter]), n(() => {
19
- t && t.setStyle(e.style);
20
- }, [e.style]), n(() => {
21
- o && t && t.setDrawingTool(e.tool);
22
- }, [o, t]), n(() => {
23
- t && t.setUserSelectAction(e.userSelectAction);
24
- }, [e.userSelectAction]), /* @__PURE__ */ i.jsx(i.Fragment, { children: x(r, { onLoad: s }) });
13
+ !e || !t.containerClassName || (e.element.className = t.containerClassName);
14
+ }, [t.containerClassName, e]), n(() => {
15
+ e && e.setDrawingEnabled(t.drawingEnabled);
16
+ }, [t.drawingEnabled]), n(() => {
17
+ e && e.setFilter(t.filter);
18
+ }, [t.filter]), n(() => {
19
+ e && e.setStyle(t.style);
20
+ }, [t.style]), n(() => {
21
+ o && e && e.setDrawingTool(t.tool);
22
+ }, [o, e]), n(() => {
23
+ e && e.setUserSelectAction(t.userSelectAction);
24
+ }, [t.userSelectAction]), /* @__PURE__ */ d(g, { children: C(l, { onLoad: r }) });
25
25
  };
26
26
  export {
27
- N as ImageAnnotator
27
+ S as ImageAnnotator
28
28
  };
29
29
  //# sourceMappingURL=annotorious-react.es5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es5.js","sources":["../src/ImageAnnotator.tsx"],"sourcesContent":["import { Children, ReactElement, cloneElement, useContext, useEffect } from 'react';\nimport { AnnotoriousOpts, createImageAnnotator } from '@annotorious/annotorious';\nimport type { DrawingTool, Filter, ImageAnnotation } from '@annotorious/annotorious';\nimport { AnnotoriousContext } from './Annotorious';\n\nexport interface ImageAnnotatorProps<E extends unknown> extends AnnotoriousOpts<ImageAnnotation, E> {\n\n children: ReactElement<HTMLImageElement>;\n\n containerClassName?: string;\n\n filter?: Filter<ImageAnnotation>;\n\n tool?: DrawingTool;\n\n}\n\nexport const ImageAnnotator = <E extends unknown>(props: ImageAnnotatorProps<E>) => {\n\n const { children, tool, ...opts } = props;\n\n const child = Children.only(children);\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n const onLoad = (evt: Event) => {\n if (!anno) {\n const img = evt.target as HTMLImageElement;\n\n const next = createImageAnnotator(img, opts);\n setAnno(next); \n }\n };\n\n useEffect(() => {\n if (!anno || !props.containerClassName) return;\n anno.element.className = props.containerClassName;\n }, [props.containerClassName, anno]);\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 (tool && anno) anno.setDrawingTool(props.tool);\n }, [tool, anno]);\n\n useEffect(() => {\n if (anno) anno.setUserSelectAction(props.userSelectAction);\n }, [props.userSelectAction]);\n \n return <>{cloneElement(child, { onLoad } as Partial<HTMLImageElement>)}</>\n\n}\n"],"names":["ImageAnnotator","props","children","tool","opts","child","Children","anno","setAnno","useContext","AnnotoriousContext","onLoad","evt","img","next","createImageAnnotator","useEffect","cloneElement"],"mappings":";;;;AAiBa,MAAAA,IAAiB,CAAoBC,MAAkC;AAElF,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,EAAS,IAAAH,GAE9BI,IAAQC,EAAS,KAAKJ,CAAQ,GAE9B,EAAE,MAAAK,GAAM,SAAAC,MAAYC,EAAWC,CAAkB,GAEjDC,IAAS,CAACC,MAAe;AAC7B,QAAI,CAACL,GAAM;AACT,YAAMM,IAAMD,EAAI,QAEVE,IAAOC,EAAqBF,GAAKT,CAAI;AAC3C,MAAAI,EAAQM,CAAI;AAAA,IAAA;AAAA,EAEhB;AAEA,SAAAE,EAAU,MAAM;AACd,IAAI,CAACT,KAAQ,CAACN,EAAM,uBACfM,EAAA,QAAQ,YAAYN,EAAM;AAAA,EAC9B,GAAA,CAACA,EAAM,oBAAoBM,CAAI,CAAC,GAEnCS,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,kBAAkBN,EAAM,cAAc;AAAA,EAAA,GACpD,CAACA,EAAM,cAAc,CAAC,GAEzBe,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,UAAUN,EAAM,MAAM;AAAA,EAAA,GACpC,CAACA,EAAM,MAAM,CAAC,GAEjBe,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,SAASN,EAAM,KAAK;AAAA,EAAA,GAClC,CAACA,EAAM,KAAK,CAAC,GAEhBe,EAAU,MAAM;AACd,IAAIb,KAAQI,KAAWA,EAAA,eAAeN,EAAM,IAAI;AAAA,EAAA,GAC/C,CAACE,GAAMI,CAAI,CAAC,GAEfS,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,oBAAoBN,EAAM,gBAAgB;AAAA,EAAA,GACxD,CAACA,EAAM,gBAAgB,CAAC,uCAEjB,UAAagB,EAAAZ,GAAO,EAAE,QAAAM,EAAsC,CAAA,GAAE;AAE1E;"}
1
+ {"version":3,"file":"annotorious-react.es5.js","sources":["../src/ImageAnnotator.tsx"],"sourcesContent":["import { Children, ReactElement, cloneElement, useContext, useEffect } from 'react';\nimport { AnnotoriousOpts, createImageAnnotator } from '@annotorious/annotorious';\nimport type { DrawingTool, Filter, ImageAnnotation } from '@annotorious/annotorious';\nimport { AnnotoriousContext } from './Annotorious';\n\nexport interface ImageAnnotatorProps<E extends unknown> extends AnnotoriousOpts<ImageAnnotation, E> {\n\n children: ReactElement<HTMLImageElement>;\n\n containerClassName?: string;\n\n filter?: Filter<ImageAnnotation>;\n\n tool?: DrawingTool;\n\n}\n\nexport const ImageAnnotator = <E extends unknown>(props: ImageAnnotatorProps<E>) => {\n\n const { children, tool, ...opts } = props;\n\n const child = Children.only(children);\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n const onLoad = (evt: Event) => {\n if (!anno) {\n const img = evt.target as HTMLImageElement;\n\n const next = createImageAnnotator(img, opts);\n setAnno(next); \n }\n };\n\n useEffect(() => {\n if (!anno || !props.containerClassName) return;\n anno.element.className = props.containerClassName;\n }, [props.containerClassName, anno]);\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 (tool && anno) anno.setDrawingTool(props.tool);\n }, [tool, anno]);\n\n useEffect(() => {\n if (anno) anno.setUserSelectAction(props.userSelectAction);\n }, [props.userSelectAction]);\n \n return <>{cloneElement(child, { onLoad } as Partial<HTMLImageElement>)}</>\n\n}\n"],"names":["ImageAnnotator","props","children","tool","opts","child","Children","anno","setAnno","useContext","AnnotoriousContext","onLoad","evt","img","next","createImageAnnotator","useEffect","cloneElement"],"mappings":";;;;AAiBa,MAAAA,IAAiB,CAAoBC,MAAkC;AAElF,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,EAAS,IAAAH,GAE9BI,IAAQC,EAAS,KAAKJ,CAAQ,GAE9B,EAAE,MAAAK,GAAM,SAAAC,MAAYC,EAAWC,CAAkB,GAEjDC,IAAS,CAACC,MAAe;AAC7B,QAAI,CAACL,GAAM;AACT,YAAMM,IAAMD,EAAI,QAEVE,IAAOC,EAAqBF,GAAKT,CAAI;AAC3C,MAAAI,EAAQM,CAAI;AAAA,IAAA;AAAA,EAEhB;AAEA,SAAAE,EAAU,MAAM;AACd,IAAI,CAACT,KAAQ,CAACN,EAAM,uBACfM,EAAA,QAAQ,YAAYN,EAAM;AAAA,EAC9B,GAAA,CAACA,EAAM,oBAAoBM,CAAI,CAAC,GAEnCS,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,kBAAkBN,EAAM,cAAc;AAAA,EAAA,GACpD,CAACA,EAAM,cAAc,CAAC,GAEzBe,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,UAAUN,EAAM,MAAM;AAAA,EAAA,GACpC,CAACA,EAAM,MAAM,CAAC,GAEjBe,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,SAASN,EAAM,KAAK;AAAA,EAAA,GAClC,CAACA,EAAM,KAAK,CAAC,GAEhBe,EAAU,MAAM;AACd,IAAIb,KAAQI,KAAWA,EAAA,eAAeN,EAAM,IAAI;AAAA,EAAA,GAC/C,CAACE,GAAMI,CAAI,CAAC,GAEfS,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,oBAAoBN,EAAM,gBAAgB;AAAA,EAAA,GACxD,CAACA,EAAM,gBAAgB,CAAC,0BAEjB,UAAagB,EAAAZ,GAAO,EAAE,QAAAM,EAAsC,CAAA,GAAE;AAE1E;"}
@@ -1,13 +1,13 @@
1
- import { j as d } from "./annotorious-react.es11.js";
2
- import { createContext as m, forwardRef as S, useState as w, useContext as s, useImperativeHandle as A, useEffect as n } from "react";
3
- import { createAnonymousGuest as x } from "@annotorious/core";
4
- import { createOSDAnnotator as g } from "@annotorious/openseadragon";
1
+ import { jsx as d } from "react/jsx-runtime";
2
+ import { createContext as m, forwardRef as S, useState as w, useContext as a, useImperativeHandle as A, useEffect as n } from "react";
3
+ import { createAnonymousGuest as g } from "@annotorious/core";
4
+ import { createOSDAnnotator as x } from "@annotorious/openseadragon";
5
5
  import { AnnotoriousContext as y } from "./annotorious-react.es2.js";
6
- const a = m({ viewer: null, setViewer: null }), D = S((t, c) => {
7
- const { children: E, tool: o, ...u } = t, [r, f] = w(), { anno: e, setAnno: i } = s(y);
6
+ const s = m({ viewer: null, setViewer: null }), O = S((t, c) => {
7
+ const { children: v, tool: o, ...f } = t, [r, u] = w(), { anno: e, setAnno: i } = a(y);
8
8
  return A(c, () => e, [e]), n(() => {
9
9
  if (r != null && r.element) {
10
- const l = g(r, u);
10
+ const l = x(r, f);
11
11
  return i(l), () => {
12
12
  l.destroy(), i(void 0);
13
13
  };
@@ -23,17 +23,17 @@ const a = m({ viewer: null, setViewer: null }), D = S((t, c) => {
23
23
  }, [e, o]), n(() => {
24
24
  e && e.setModalSelect(t.modalSelect);
25
25
  }, [e, t.modalSelect]), n(() => {
26
- e && (t.user ? e.setUser(t.user) : e.setUser(x()));
26
+ e && (t.user ? e.setUser(t.user) : e.setUser(g()));
27
27
  }, [e, t.user]), n(() => {
28
28
  e && e.setUserSelectAction(t.userSelectAction);
29
- }, [e, t.userSelectAction]), /* @__PURE__ */ d.jsx(a.Provider, { value: { viewer: r, setViewer: f }, children: t.children });
30
- }), O = () => {
31
- const { viewer: t } = s(a);
29
+ }, [e, t.userSelectAction]), /* @__PURE__ */ d(s.Provider, { value: { viewer: r, setViewer: u }, children: t.children });
30
+ }), U = () => {
31
+ const { viewer: t } = a(s);
32
32
  return t;
33
33
  };
34
34
  export {
35
- D as OpenSeadragonAnnotator,
36
- a as OpenSeadragonAnnotatorContext,
37
- O as useViewer
35
+ O as OpenSeadragonAnnotator,
36
+ s as OpenSeadragonAnnotatorContext,
37
+ U as useViewer
38
38
  };
39
39
  //# sourceMappingURL=annotorious-react.es8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es8.js","sources":["../src/openseadragon/OpenSeadragonAnnotator.tsx"],"sourcesContent":["import { createContext, forwardRef, ReactNode, useContext, useEffect, useImperativeHandle, useState } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { createAnonymousGuest } from '@annotorious/core';\nimport { createOSDAnnotator } from '@annotorious/openseadragon';\nimport { Annotation, AnnotoriousOpts, DrawingStyle, Filter, User} from '@annotorious/annotorious';\nimport { AnnotoriousContext } from '../Annotorious';\nimport { AnnotoriousOpenSeadragonAnnotator } from '.';\n\nexport const OpenSeadragonAnnotatorContext = createContext<{ \n viewer: OpenSeadragon.Viewer,\n setViewer(viewer: OpenSeadragon.Viewer): void\n}>({ viewer: null, setViewer: null });\n\nexport type OpenSeadragonAnnotatorProps<I extends Annotation, E extends unknown> = AnnotoriousOpts<I, E> & {\n\n children?: ReactNode;\n\n filter?: Filter<I>;\n\n style?: DrawingStyle | ((annotation: I) => DrawingStyle);\n\n tool?: string | null;\n\n user?: User;\n\n}\n\nexport const OpenSeadragonAnnotator = forwardRef(<I extends Annotation, E extends unknown>(\n props: OpenSeadragonAnnotatorProps<I, E>, \n ref: React.ForwardedRef<AnnotoriousOpenSeadragonAnnotator<I, E> | null>\n) => {\n const { children, tool, ...opts } = props;\n\n const [viewer, setViewer] = useState<OpenSeadragon.Viewer>();\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n useImperativeHandle(ref, () => anno as AnnotoriousOpenSeadragonAnnotator<I, E> | null, [anno]);\n\n useEffect(() => {\n if (viewer?.element) {\n const anno = createOSDAnnotator<I, E>(viewer, opts as AnnotoriousOpts<I, E>);\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 }, [anno, props.drawingEnabled]);\n\n useEffect(() => {\n if (anno) anno.setFilter(props.filter);\n }, [anno, props.filter]);\n\n useEffect(() => {\n if (anno) anno.setStyle(props.style);\n }, [anno, props.style]);\n\n useEffect(() => {\n if (anno) anno.setDrawingTool(tool || 'rectangle');\n }, [anno, tool]);\n\n useEffect(() => {\n if (anno) anno.setModalSelect(props.modalSelect);\n }, [anno, props.modalSelect]);\n\n useEffect(() => {\n if (!anno) return;\n \n if (props.user)\n anno.setUser(props.user);\n else \n anno.setUser(createAnonymousGuest());\n }, [anno, props.user]);\n\n useEffect(() => {\n if (anno) anno.setUserSelectAction(props.userSelectAction);\n }, [anno, props.userSelectAction]);\n\n return (\n <OpenSeadragonAnnotatorContext.Provider value={{ viewer, setViewer }}>\n {props.children}\n </OpenSeadragonAnnotatorContext.Provider>\n )\n\n}) as <I extends Annotation, E extends unknown> (\n props: OpenSeadragonAnnotatorProps<I, E> & { ref?: React.ForwardedRef<AnnotoriousOpenSeadragonAnnotator<I, E> | null> }\n) => React.ReactElement;\n\nexport const useViewer = () => {\n const { viewer } = useContext(OpenSeadragonAnnotatorContext);\n return viewer;\n}"],"names":["OpenSeadragonAnnotatorContext","createContext","OpenSeadragonAnnotator","forwardRef","props","ref","children","tool","opts","viewer","setViewer","useState","anno","setAnno","useContext","AnnotoriousContext","useImperativeHandle","useEffect","createOSDAnnotator","createAnonymousGuest","jsx","useViewer"],"mappings":";;;;;AAQO,MAAMA,IAAgCC,EAG1C,EAAE,QAAQ,MAAM,WAAW,KAAM,CAAA,GAgBvBC,IAAyBC,EAAW,CAC/CC,GACAC,MACG;AACH,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,EAAS,IAAAJ,GAE9B,CAACK,GAAQC,CAAS,IAAIC,EAA+B,GAErD,EAAE,MAAAC,GAAM,SAAAC,MAAYC,EAAWC,CAAkB;AAEvD,SAAAC,EAAoBX,GAAK,MAAMO,GAAwD,CAACA,CAAI,CAAC,GAE7FK,EAAU,MAAM;AACd,QAAIR,KAAA,QAAAA,EAAQ,SAAS;AACbG,YAAAA,IAAOM,EAAyBT,GAAQD,CAA6B;AAC3E,aAAAK,EAAQD,CAAI,GAEL,MAAM;AACXA,QAAAA,EAAK,QAAQ,GACbC,EAAQ,MAAS;AAAA,MACnB;AAAA,IAAA;AAAA,EACF,GACC,CAACJ,CAAM,CAAC,GAEXQ,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,kBAAkBR,EAAM,cAAc;AAAA,EACpD,GAAA,CAACQ,GAAMR,EAAM,cAAc,CAAC,GAE/Ba,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,UAAUR,EAAM,MAAM;AAAA,EACpC,GAAA,CAACQ,GAAMR,EAAM,MAAM,CAAC,GAEvBa,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,SAASR,EAAM,KAAK;AAAA,EAClC,GAAA,CAACQ,GAAMR,EAAM,KAAK,CAAC,GAEtBa,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,eAAeL,KAAQ,WAAW;AAAA,EAAA,GAChD,CAACK,GAAML,CAAI,CAAC,GAEfU,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,eAAeR,EAAM,WAAW;AAAA,EAC9C,GAAA,CAACQ,GAAMR,EAAM,WAAW,CAAC,GAE5Ba,EAAU,MAAM;AACd,IAAKL,MAEDR,EAAM,OACHQ,EAAA,QAAQR,EAAM,IAAI,IAElBQ,EAAA,QAAQO,GAAsB;AAAA,EACpC,GAAA,CAACP,GAAMR,EAAM,IAAI,CAAC,GAErBa,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,oBAAoBR,EAAM,gBAAgB;AAAA,EACxD,GAAA,CAACQ,GAAMR,EAAM,gBAAgB,CAAC,GAG/BgB,gBAAAA,MAACpB,EAA8B,UAA9B,EAAuC,OAAO,EAAE,QAAAS,GAAQ,WAAAC,KACtD,UAAAN,EAAM,SACT,CAAA;AAGJ,CAAC,GAIYiB,IAAY,MAAM;AAC7B,QAAM,EAAE,QAAAZ,EAAA,IAAWK,EAAWd,CAA6B;AACpD,SAAAS;AACT;"}
1
+ {"version":3,"file":"annotorious-react.es8.js","sources":["../src/openseadragon/OpenSeadragonAnnotator.tsx"],"sourcesContent":["import { createContext, forwardRef, ReactNode, useContext, useEffect, useImperativeHandle, useState } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { createAnonymousGuest } from '@annotorious/core';\nimport { createOSDAnnotator } from '@annotorious/openseadragon';\nimport { Annotation, AnnotoriousOpts, DrawingStyle, Filter, User} from '@annotorious/annotorious';\nimport { AnnotoriousContext } from '../Annotorious';\nimport { AnnotoriousOpenSeadragonAnnotator } from '.';\n\nexport const OpenSeadragonAnnotatorContext = createContext<{ \n viewer: OpenSeadragon.Viewer,\n setViewer(viewer: OpenSeadragon.Viewer): void\n}>({ viewer: null, setViewer: null });\n\nexport type OpenSeadragonAnnotatorProps<I extends Annotation, E extends unknown> = AnnotoriousOpts<I, E> & {\n\n children?: ReactNode;\n\n filter?: Filter<I>;\n\n style?: DrawingStyle | ((annotation: I) => DrawingStyle);\n\n tool?: string | null;\n\n user?: User;\n\n}\n\nexport const OpenSeadragonAnnotator = forwardRef(<I extends Annotation, E extends unknown>(\n props: OpenSeadragonAnnotatorProps<I, E>, \n ref: React.ForwardedRef<AnnotoriousOpenSeadragonAnnotator<I, E> | null>\n) => {\n const { children, tool, ...opts } = props;\n\n const [viewer, setViewer] = useState<OpenSeadragon.Viewer>();\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n useImperativeHandle(ref, () => anno as AnnotoriousOpenSeadragonAnnotator<I, E> | null, [anno]);\n\n useEffect(() => {\n if (viewer?.element) {\n const anno = createOSDAnnotator<I, E>(viewer, opts as AnnotoriousOpts<I, E>);\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 }, [anno, props.drawingEnabled]);\n\n useEffect(() => {\n if (anno) anno.setFilter(props.filter);\n }, [anno, props.filter]);\n\n useEffect(() => {\n if (anno) anno.setStyle(props.style);\n }, [anno, props.style]);\n\n useEffect(() => {\n if (anno) anno.setDrawingTool(tool || 'rectangle');\n }, [anno, tool]);\n\n useEffect(() => {\n if (anno) anno.setModalSelect(props.modalSelect);\n }, [anno, props.modalSelect]);\n\n useEffect(() => {\n if (!anno) return;\n \n if (props.user)\n anno.setUser(props.user);\n else \n anno.setUser(createAnonymousGuest());\n }, [anno, props.user]);\n\n useEffect(() => {\n if (anno) anno.setUserSelectAction(props.userSelectAction);\n }, [anno, props.userSelectAction]);\n\n return (\n <OpenSeadragonAnnotatorContext.Provider value={{ viewer, setViewer }}>\n {props.children}\n </OpenSeadragonAnnotatorContext.Provider>\n )\n\n}) as <I extends Annotation, E extends unknown> (\n props: OpenSeadragonAnnotatorProps<I, E> & { ref?: React.ForwardedRef<AnnotoriousOpenSeadragonAnnotator<I, E> | null> }\n) => React.ReactElement;\n\nexport const useViewer = () => {\n const { viewer } = useContext(OpenSeadragonAnnotatorContext);\n return viewer;\n}"],"names":["OpenSeadragonAnnotatorContext","createContext","OpenSeadragonAnnotator","forwardRef","props","ref","children","tool","opts","viewer","setViewer","useState","anno","setAnno","useContext","AnnotoriousContext","useImperativeHandle","useEffect","createOSDAnnotator","createAnonymousGuest","jsx","useViewer"],"mappings":";;;;;AAQO,MAAMA,IAAgCC,EAG1C,EAAE,QAAQ,MAAM,WAAW,KAAM,CAAA,GAgBvBC,IAAyBC,EAAW,CAC/CC,GACAC,MACG;AACH,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,EAAS,IAAAJ,GAE9B,CAACK,GAAQC,CAAS,IAAIC,EAA+B,GAErD,EAAE,MAAAC,GAAM,SAAAC,MAAYC,EAAWC,CAAkB;AAEvD,SAAAC,EAAoBX,GAAK,MAAMO,GAAwD,CAACA,CAAI,CAAC,GAE7FK,EAAU,MAAM;AACd,QAAIR,KAAA,QAAAA,EAAQ,SAAS;AACbG,YAAAA,IAAOM,EAAyBT,GAAQD,CAA6B;AAC3E,aAAAK,EAAQD,CAAI,GAEL,MAAM;AACXA,QAAAA,EAAK,QAAQ,GACbC,EAAQ,MAAS;AAAA,MACnB;AAAA,IAAA;AAAA,EACF,GACC,CAACJ,CAAM,CAAC,GAEXQ,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,kBAAkBR,EAAM,cAAc;AAAA,EACpD,GAAA,CAACQ,GAAMR,EAAM,cAAc,CAAC,GAE/Ba,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,UAAUR,EAAM,MAAM;AAAA,EACpC,GAAA,CAACQ,GAAMR,EAAM,MAAM,CAAC,GAEvBa,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,SAASR,EAAM,KAAK;AAAA,EAClC,GAAA,CAACQ,GAAMR,EAAM,KAAK,CAAC,GAEtBa,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,eAAeL,KAAQ,WAAW;AAAA,EAAA,GAChD,CAACK,GAAML,CAAI,CAAC,GAEfU,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,eAAeR,EAAM,WAAW;AAAA,EAC9C,GAAA,CAACQ,GAAMR,EAAM,WAAW,CAAC,GAE5Ba,EAAU,MAAM;AACd,IAAKL,MAEDR,EAAM,OACHQ,EAAA,QAAQR,EAAM,IAAI,IAElBQ,EAAA,QAAQO,GAAsB;AAAA,EACpC,GAAA,CAACP,GAAMR,EAAM,IAAI,CAAC,GAErBa,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,oBAAoBR,EAAM,gBAAgB;AAAA,EACxD,GAAA,CAACQ,GAAMR,EAAM,gBAAgB,CAAC,GAG/B,gBAAAgB,EAACpB,EAA8B,UAA9B,EAAuC,OAAO,EAAE,QAAAS,GAAQ,WAAAC,KACtD,UAAAN,EAAM,SACT,CAAA;AAGJ,CAAC,GAIYiB,IAAY,MAAM;AAC7B,QAAM,EAAE,QAAAZ,EAAA,IAAWK,EAAWd,CAA6B;AACpD,SAAAS;AACT;"}
@@ -1,57 +1,57 @@
1
- import { j as g } from "./annotorious-react.es11.js";
2
- import { useState as O, useRef as A, useEffect as D } from "react";
3
- import w from "openseadragon";
4
- import { useAnnotator as L, useSelection as P } from "./annotorious-react.es2.js";
1
+ import { jsxs as h, jsx as O } from "react/jsx-runtime";
2
+ import { useState as A, useRef as D, useEffect as L } from "react";
3
+ import g from "openseadragon";
4
+ import { useAnnotator as P, useSelection as S } from "./annotorious-react.es2.js";
5
5
  /* empty css */
6
6
  /* empty css */
7
7
  import "@annotorious/core";
8
8
  import "@annotorious/annotorious";
9
- import { toClientRects as S } from "./annotorious-react.es14.js";
10
- import { useFloating as b, FloatingArrow as j } from "./annotorious-react.es13.js";
11
- import { useViewer as U } from "./annotorious-react.es8.js";
12
- import { inline as F, offset as M, flip as V, shift as z, arrow as H } from "./annotorious-react.es15.js";
13
- import { autoUpdate as T } from "./annotorious-react.es16.js";
14
- import x from "./annotorious-react.es17.js";
15
- const X = (n, r) => {
16
- const { minX: d, minY: a, maxX: o, maxY: m } = r.bounds, { top: s, left: l } = n.element.getBoundingClientRect(), t = n.viewport.imageToViewerElementCoordinates(new w.Point(d, a)), p = n.viewport.imageToViewerElementCoordinates(new w.Point(o, m));
9
+ import { toClientRects as b } from "./annotorious-react.es13.js";
10
+ import { useFloating as U, FloatingArrow as F } from "./annotorious-react.es12.js";
11
+ import { useViewer as M } from "./annotorious-react.es8.js";
12
+ import { inline as V, offset as j, flip as z, shift as H, arrow as T } from "./annotorious-react.es14.js";
13
+ import { autoUpdate as X } from "./annotorious-react.es15.js";
14
+ import w from "./annotorious-react.es16.js";
15
+ const Y = (n, r) => {
16
+ const { minX: d, minY: a, maxX: o, maxY: l } = r.bounds, { top: s, left: p } = n.element.getBoundingClientRect(), t = n.viewport.imageToViewerElementCoordinates(new g.Point(d, a)), m = n.viewport.imageToViewerElementCoordinates(new g.Point(o, l));
17
17
  return new DOMRect(
18
- t.x + l,
18
+ t.x + p,
19
19
  t.y + s,
20
- p.x - t.x,
21
- p.y - t.y
20
+ m.x - t.x,
21
+ m.y - t.y
22
22
  );
23
- }, te = (n) => {
23
+ }, oe = (n) => {
24
24
  var u, f;
25
- const r = L(), [d, a] = O(!1), o = U(), m = A(null), { selected: s, event: l } = P(), t = (u = s[0]) == null ? void 0 : u.annotation, p = (f = s[0]) == null ? void 0 : f.editable, { refs: c, floatingStyles: y, context: v } = b({
25
+ const r = P(), [d, a] = A(!1), o = M(), l = D(null), { selected: s, event: p } = S(), t = (u = s[0]) == null ? void 0 : u.annotation, m = (f = s[0]) == null ? void 0 : f.editable, { refs: c, floatingStyles: y, context: v } = U({
26
26
  open: d,
27
27
  onOpenChange: a,
28
28
  placement: n.placement,
29
29
  middleware: [
30
- F(),
31
- M(10),
32
- V({ crossAxis: !0 }),
33
- z({
30
+ V(),
31
+ j(10),
32
+ z({ crossAxis: !0 }),
33
+ H({
34
34
  crossAxis: !0,
35
35
  boundary: o == null ? void 0 : o.element,
36
36
  padding: { right: 5, left: 5, top: 10, bottom: 10 }
37
37
  }),
38
- H({
39
- element: m,
38
+ T({
39
+ element: l,
40
40
  padding: 5
41
41
  })
42
42
  ],
43
- whileElementsMounted: T
43
+ whileElementsMounted: X
44
44
  });
45
- D(() => {
45
+ L(() => {
46
46
  if (s.length === 0)
47
47
  a(!1);
48
48
  else {
49
49
  const e = () => {
50
50
  if (!o.element) return;
51
- const i = X(o, t.target.selector.geometry);
51
+ const i = Y(o, t.target.selector.geometry);
52
52
  c.setReference({
53
53
  getBoundingClientRect: () => i,
54
- getClientRects: () => S(i)
54
+ getClientRects: () => b(i)
55
55
  });
56
56
  };
57
57
  return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), o.addHandler("update-viewport", e), e(), a(!0), () => {
@@ -59,8 +59,8 @@ const X = (n, r) => {
59
59
  };
60
60
  }
61
61
  }, [n.popup, s, o]);
62
- const R = (e) => {
63
- const i = e.id || x();
62
+ const x = (e) => {
63
+ const i = e.id || w();
64
64
  r.state.store.addBody({
65
65
  ...e,
66
66
  id: i,
@@ -68,46 +68,46 @@ const X = (n, r) => {
68
68
  created: e.created || /* @__PURE__ */ new Date(),
69
69
  creator: r.getUser()
70
70
  });
71
- }, B = (e) => {
71
+ }, R = (e) => {
72
72
  r.state.store.deleteBody({ id: e, annotation: t.id });
73
- }, E = (e, i) => {
74
- const C = i.id || x(), h = {
73
+ }, B = (e, i) => {
74
+ const C = i.id || w(), E = {
75
75
  updated: /* @__PURE__ */ new Date(),
76
76
  updatedBy: r.getUser(),
77
77
  ...i,
78
78
  id: C,
79
79
  annotation: t.id
80
80
  };
81
- r.state.store.updateBody(e, h);
81
+ r.state.store.updateBody(e, E);
82
82
  };
83
- return d && t ? /* @__PURE__ */ g.jsxs(
83
+ return d && t ? /* @__PURE__ */ h(
84
84
  "div",
85
85
  {
86
86
  className: "a9s-popup a9s-image-popup",
87
87
  ref: c.setFloating,
88
88
  style: y,
89
89
  children: [
90
- n.arrow && /* @__PURE__ */ g.jsx(
91
- j,
90
+ n.arrow && /* @__PURE__ */ O(
91
+ F,
92
92
  {
93
- ref: m,
93
+ ref: l,
94
94
  context: v,
95
95
  ...n.arrowProps || {}
96
96
  }
97
97
  ),
98
98
  n.popup({
99
99
  annotation: t,
100
- editable: p,
101
- event: l,
102
- onCreateBody: R,
103
- onDeleteBody: B,
104
- onUpdateBody: E
100
+ editable: m,
101
+ event: p,
102
+ onCreateBody: x,
103
+ onDeleteBody: R,
104
+ onUpdateBody: B
105
105
  })
106
106
  ]
107
107
  }
108
108
  ) : null;
109
109
  };
110
110
  export {
111
- te as OpenSeadragonAnnotationPopup
111
+ oe as OpenSeadragonAnnotationPopup
112
112
  };
113
113
  //# sourceMappingURL=annotorious-react.es9.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es9.js","sources":["../src/openseadragon/OpenSeadragonAnnotationPopup.tsx"],"sourcesContent":["import { ReactNode, useEffect, useRef, useState } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { v4 as uuidv4 } from 'uuid';\nimport { useAnnotator, useSelection, useViewer} from '@annotorious/react';\nimport type { PopupProps } from '@annotorious/react';\nimport type { AnnotationBody, Annotator, Geometry, ImageAnnotation } from '@annotorious/annotorious';\nimport { toClientRects } from '../utils/toClientRects';\nimport {\n useFloating,\n arrow,\n shift,\n inline,\n autoUpdate,\n flip,\n offset,\n FloatingArrow,\n FloatingArrowProps,\n Placement\n} from '@floating-ui/react';\n\nconst toDOMRect = (viewer: OpenSeadragon.Viewer, geometry: Geometry) => {\n const { minX, minY, maxX, maxY } = geometry.bounds;\n\n const { top, left } = viewer.element.getBoundingClientRect();\n\n const topLeft = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(minX, minY));\n const bottomRight = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(maxX, maxY));\n\n return new DOMRect(\n topLeft.x + left,\n topLeft.y + top,\n bottomRight.x - topLeft.x,\n bottomRight.y - topLeft.y\n );\n}\n\ninterface OpenSeadragonAnnotationPopupProps {\n\n arrow?: boolean;\n\n arrowProps?: Omit<FloatingArrowProps, 'context' | 'ref'>;\n\n placement?: Placement;\n\n popup: (props: PopupProps) => ReactNode;\n\n}\n\nexport const OpenSeadragonAnnotationPopup = (props: OpenSeadragonAnnotationPopupProps) => {\n \n const anno = useAnnotator<Annotator<ImageAnnotation>>();\n\n const [isOpen, setIsOpen] = useState(false);\n\n const viewer = useViewer();\n\n const arrowRef = useRef(null);\n\n const { selected, event } = useSelection();\n\n const annotation = selected[0]?.annotation;\n\n const editable = selected[0]?.editable;\n\n const { refs, floatingStyles, context } = useFloating({\n open: isOpen,\n onOpenChange: setIsOpen,\n placement: props.placement,\n middleware: [\n inline(), \n offset(10),\n flip({ crossAxis: true }),\n shift({ \n crossAxis: true,\n boundary: viewer?.element,\n padding: { right: 5, left: 5, top: 10, bottom: 10 }\n }),\n arrow({\n element: arrowRef,\n padding: 5\n })\n ],\n whileElementsMounted: autoUpdate\n });\n\n useEffect(() => {\n if (selected.length === 0) {\n setIsOpen(false);\n } else { \n const setPosition = () => { \n // This avoids issues when new viewer instances are mounted/unmounted \n // while the popup is open\n if (!viewer.element) return;\n\n const rect = toDOMRect(viewer, annotation.target.selector.geometry);\n \n refs.setReference({\n getBoundingClientRect: () => rect,\n getClientRects: () => toClientRects(rect)\n });\n }\n\n window.addEventListener('scroll', setPosition, true);\n window.addEventListener('resize', setPosition);\n viewer.addHandler('update-viewport', setPosition);\n\n setPosition();\n\n setIsOpen(true);\n\n return () => {\n window.removeEventListener('scroll', setPosition, true);\n window.removeEventListener('resize', setPosition);\n viewer.removeHandler('update-viewport', setPosition);\n };\n }\n }, [props.popup, selected, viewer]);\n\n const onCreateBody = (body: Partial<AnnotationBody>) => {\n const id = body.id || uuidv4();\n \n anno.state.store.addBody({\n ...body,\n id,\n annotation: annotation.id,\n created: body.created || new Date(),\n creator: anno.getUser()\n });\n }\n\n const onDeleteBody = (id: string) => {\n anno.state.store.deleteBody({ id, annotation: annotation.id });\n }\n\n const onUpdateBody = (current: AnnotationBody, next: AnnotationBody) => {\n const id = next.id || uuidv4();\n\n const updated: AnnotationBody = {\n updated: new Date(),\n updatedBy: anno.getUser(),\n ...next,\n id,\n annotation: annotation.id\n }\n\n anno.state.store.updateBody(current, updated);\n }\n\n return (isOpen && annotation) ? (\n <div\n className=\"a9s-popup a9s-image-popup\"\n ref={refs.setFloating}\n style={floatingStyles}>\n \n {props.arrow && (\n <FloatingArrow \n ref={arrowRef} \n context={context} \n {...(props.arrowProps || {})} />\n )}\n\n {props.popup({ \n annotation, \n editable, \n event,\n onCreateBody,\n onDeleteBody,\n onUpdateBody\n })}\n </div>\n ) : null;\n\n}"],"names":["toDOMRect","viewer","geometry","minX","minY","maxX","maxY","top","left","topLeft","OpenSeadragon","bottomRight","OpenSeadragonAnnotationPopup","props","anno","useAnnotator","isOpen","setIsOpen","useState","useViewer","arrowRef","useRef","selected","event","useSelection","annotation","_a","editable","_b","refs","floatingStyles","context","useFloating","inline","offset","flip","shift","arrow","autoUpdate","useEffect","setPosition","rect","toClientRects","onCreateBody","body","id","uuidv4","onDeleteBody","onUpdateBody","current","next","updated","jsxs","jsx","FloatingArrow"],"mappings":";;;;;;;;;;;;;;AAoBA,MAAMA,IAAY,CAACC,GAA8BC,MAAuB;AACtE,QAAM,EAAE,MAAAC,GAAM,MAAAC,GAAM,MAAAC,GAAM,MAAAC,EAAA,IAASJ,EAAS,QAEtC,EAAE,KAAAK,GAAK,MAAAC,EAAA,IAASP,EAAO,QAAQ,sBAAsB,GAErDQ,IAAUR,EAAO,SAAS,gCAAgC,IAAIS,EAAc,MAAMP,GAAMC,CAAI,CAAC,GAC7FO,IAAcV,EAAO,SAAS,gCAAgC,IAAIS,EAAc,MAAML,GAAMC,CAAI,CAAC;AAEvG,SAAO,IAAI;AAAA,IACTG,EAAQ,IAAID;AAAA,IACZC,EAAQ,IAAIF;AAAA,IACZI,EAAY,IAAKF,EAA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AA,UAACC;AAAA,UAAA;AAAA,YACC,KAAKlC;AAAA,YACL,SAAAW;AAAA,YACC,GAAIlB,EAAM,cAAc,CAAA;AAAA,UAAC;AAAA,QAAI;AAAA,QAGjCA,EAAM,MAAM;AAAA,UACX,YAAAY;AAAA,UACA,UAAAE;AAAA,UACA,OAAAJ;AAAA,UACA,cAAAoB;AAAA,UACA,cAAAI;AAAA,UACA,cAAAC;AAAA,QACD,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,IAED;AAEN;"}
1
+ {"version":3,"file":"annotorious-react.es9.js","sources":["../src/openseadragon/OpenSeadragonAnnotationPopup.tsx"],"sourcesContent":["import { ReactNode, useEffect, useRef, useState } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { v4 as uuidv4 } from 'uuid';\nimport { useAnnotator, useSelection, useViewer} from '@annotorious/react';\nimport type { PopupProps } from '@annotorious/react';\nimport type { AnnotationBody, Annotator, Geometry, ImageAnnotation } from '@annotorious/annotorious';\nimport { toClientRects } from '../utils/toClientRects';\nimport {\n useFloating,\n arrow,\n shift,\n inline,\n autoUpdate,\n flip,\n offset,\n FloatingArrow,\n FloatingArrowProps,\n Placement\n} from '@floating-ui/react';\n\nconst toDOMRect = (viewer: OpenSeadragon.Viewer, geometry: Geometry) => {\n const { minX, minY, maxX, maxY } = geometry.bounds;\n\n const { top, left } = viewer.element.getBoundingClientRect();\n\n const topLeft = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(minX, minY));\n const bottomRight = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(maxX, maxY));\n\n return new DOMRect(\n topLeft.x + left,\n topLeft.y + top,\n bottomRight.x - topLeft.x,\n bottomRight.y - topLeft.y\n );\n}\n\ninterface OpenSeadragonAnnotationPopupProps {\n\n arrow?: boolean;\n\n arrowProps?: Omit<FloatingArrowProps, 'context' | 'ref'>;\n\n placement?: Placement;\n\n popup: (props: PopupProps) => ReactNode;\n\n}\n\nexport const OpenSeadragonAnnotationPopup = (props: OpenSeadragonAnnotationPopupProps) => {\n \n const anno = useAnnotator<Annotator<ImageAnnotation>>();\n\n const [isOpen, setIsOpen] = useState(false);\n\n const viewer = useViewer();\n\n const arrowRef = useRef(null);\n\n const { selected, event } = useSelection();\n\n const annotation = selected[0]?.annotation;\n\n const editable = selected[0]?.editable;\n\n const { refs, floatingStyles, context } = useFloating({\n open: isOpen,\n onOpenChange: setIsOpen,\n placement: props.placement,\n middleware: [\n inline(), \n offset(10),\n flip({ crossAxis: true }),\n shift({ \n crossAxis: true,\n boundary: viewer?.element,\n padding: { right: 5, left: 5, top: 10, bottom: 10 }\n }),\n arrow({\n element: arrowRef,\n padding: 5\n })\n ],\n whileElementsMounted: autoUpdate\n });\n\n useEffect(() => {\n if (selected.length === 0) {\n setIsOpen(false);\n } else { \n const setPosition = () => { \n // This avoids issues when new viewer instances are mounted/unmounted \n // while the popup is open\n if (!viewer.element) return;\n\n const rect = toDOMRect(viewer, annotation.target.selector.geometry);\n \n refs.setReference({\n getBoundingClientRect: () => rect,\n getClientRects: () => toClientRects(rect)\n });\n }\n\n window.addEventListener('scroll', setPosition, true);\n window.addEventListener('resize', setPosition);\n viewer.addHandler('update-viewport', setPosition);\n\n setPosition();\n\n setIsOpen(true);\n\n return () => {\n window.removeEventListener('scroll', setPosition, true);\n window.removeEventListener('resize', setPosition);\n viewer.removeHandler('update-viewport', setPosition);\n };\n }\n }, [props.popup, selected, viewer]);\n\n const onCreateBody = (body: Partial<AnnotationBody>) => {\n const id = body.id || uuidv4();\n \n anno.state.store.addBody({\n ...body,\n id,\n annotation: annotation.id,\n created: body.created || new Date(),\n creator: anno.getUser()\n });\n }\n\n const onDeleteBody = (id: string) => {\n anno.state.store.deleteBody({ id, annotation: annotation.id });\n }\n\n const onUpdateBody = (current: AnnotationBody, next: AnnotationBody) => {\n const id = next.id || uuidv4();\n\n const updated: AnnotationBody = {\n updated: new Date(),\n updatedBy: anno.getUser(),\n ...next,\n id,\n annotation: annotation.id\n }\n\n anno.state.store.updateBody(current, updated);\n }\n\n return (isOpen && annotation) ? (\n <div\n className=\"a9s-popup a9s-image-popup\"\n ref={refs.setFloating}\n style={floatingStyles}>\n \n {props.arrow && (\n <FloatingArrow \n ref={arrowRef} \n context={context} \n {...(props.arrowProps || {})} />\n )}\n\n {props.popup({ \n annotation, \n editable, \n event,\n onCreateBody,\n onDeleteBody,\n onUpdateBody\n })}\n </div>\n ) : null;\n\n}"],"names":["toDOMRect","viewer","geometry","minX","minY","maxX","maxY","top","left","topLeft","OpenSeadragon","bottomRight","OpenSeadragonAnnotationPopup","props","anno","useAnnotator","isOpen","setIsOpen","useState","useViewer","arrowRef","useRef","selected","event","useSelection","annotation","_a","editable","_b","refs","floatingStyles","context","useFloating","inline","offset","flip","shift","arrow","autoUpdate","useEffect","setPosition","rect","toClientRects","onCreateBody","body","id","uuidv4","onDeleteBody","onUpdateBody","current","next","updated","jsxs","jsx","FloatingArrow"],"mappings":";;;;;;;;;;;;;;AAoBA,MAAMA,IAAY,CAACC,GAA8BC,MAAuB;AACtE,QAAM,EAAE,MAAAC,GAAM,MAAAC,GAAM,MAAAC,GAAM,MAAAC,EAAA,IAASJ,EAAS,QAEtC,EAAE,KAAAK,GAAK,MAAAC,EAAA,IAASP,EAAO,QAAQ,sBAAsB,GAErDQ,IAAUR,EAAO,SAAS,gCAAgC,IAAIS,EAAc,MAAMP,GAAMC,CAAI,CAAC,GAC7FO,IAAcV,EAAO,SAAS,gCAAgC,IAAIS,EAAc,MAAML,GAAMC,CAAI,CAAC;AAEvG,SAAO,IAAI;AAAA,IACTG,EAAQ,IAAID;AAAA,IACZC,EAAQ,IAAIF;AAAA,IACZI,EAAY,IAAKF,EAAQ;AAAA,IACzBE,EAAY,IAAIF,EAAQ;AAAA,EAC1B;AACF,GAcaG,KAA+B,CAACC,MAA6C;;AAExF,QAAMC,IAAOC,EAAyC,GAEhD,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GAEpCjB,IAASkB,EA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A,OAAAJ;AAAA,UACA,cAAAoB;AAAA,UACA,cAAAI;AAAA,UACA,cAAAC;AAAA,QACD,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,IAED;AAEN;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@annotorious/react",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "description": "Annotorious React bindings",
5
5
  "author": "Rainer Simon",
6
6
  "license": "BSD-3-Clause",
@@ -45,9 +45,9 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@annotorious/annotorious": "3.1.1",
49
- "@annotorious/core": "3.1.1",
50
- "@annotorious/openseadragon": "3.1.1",
48
+ "@annotorious/annotorious": "3.1.3",
49
+ "@annotorious/core": "3.1.3",
50
+ "@annotorious/openseadragon": "3.1.3",
51
51
  "@floating-ui/react": "^0.27.3",
52
52
  "zustand": "^5.0.3"
53
53
  },
@@ -1,5 +0,0 @@
1
- var e = {};
2
- export {
3
- e as __exports
4
- };
5
- //# sourceMappingURL=annotorious-react.es23.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"annotorious-react.es23.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,10 +0,0 @@
1
- const i = [];
2
- for (let n = 0; n < 256; ++n)
3
- i.push((n + 256).toString(16).slice(1));
4
- function c(n, u = 0) {
5
- return (i[n[u + 0]] + i[n[u + 1]] + i[n[u + 2]] + i[n[u + 3]] + "-" + i[n[u + 4]] + i[n[u + 5]] + "-" + i[n[u + 6]] + i[n[u + 7]] + "-" + i[n[u + 8]] + i[n[u + 9]] + "-" + i[n[u + 10]] + i[n[u + 11]] + i[n[u + 12]] + i[n[u + 13]] + i[n[u + 14]] + i[n[u + 15]]).toLowerCase();
6
- }
7
- export {
8
- c as unsafeStringify
9
- };
10
- //# sourceMappingURL=annotorious-react.es24.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"annotorious-react.es24.js","sources":["../../../node_modules/uuid/dist/esm-browser/stringify.js"],"sourcesContent":["import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n"],"names":["byteToHex","i","unsafeStringify","arr","offset"],"mappings":"AACA,MAAMA,IAAY,CAAE;AACpB,SAASC,IAAI,GAAGA,IAAI,KAAK,EAAEA;AACvB,EAAAD,EAAU,MAAMC,IAAI,KAAO,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AAE7C,SAASC,EAAgBC,GAAKC,IAAS,GAAG;AAC7C,UAAQJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IAC7BJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IACzBJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IACzBJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IACzB,MACAJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IACzBJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IACzB,MACAJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IACzBJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IACzB,MACAJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IACzBJ,EAAUG,EAAIC,IAAS,CAAC,CAAC,IACzB,MACAJ,EAAUG,EAAIC,IAAS,EAAE,CAAC,IAC1BJ,EAAUG,EAAIC,IAAS,EAAE,CAAC,IAC1BJ,EAAUG,EAAIC,IAAS,EAAE,CAAC,IAC1BJ,EAAUG,EAAIC,IAAS,EAAE,CAAC,IAC1BJ,EAAUG,EAAIC,IAAS,EAAE,CAAC,IAC1BJ,EAAUG,EAAIC,IAAS,EAAE,CAAC,GAAG,YAAa;AAClD;","x_google_ignoreList":[0]}
@@ -1,5 +0,0 @@
1
- const o = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), t = { randomUUID: o };
2
- export {
3
- t as default
4
- };
5
- //# sourceMappingURL=annotorious-react.es25.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"annotorious-react.es25.js","sources":["../../../node_modules/uuid/dist/esm-browser/native.js"],"sourcesContent":["const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default { randomUUID };\n"],"names":["randomUUID","native"],"mappings":"AAAA,MAAMA,IAAa,OAAO,SAAW,OAAe,OAAO,cAAc,OAAO,WAAW,KAAK,MAAM,GACvFC,IAAA,EAAE,YAAAD,EAAY;","x_google_ignoreList":[0]}
@@ -1,14 +0,0 @@
1
- let t;
2
- const e = new Uint8Array(16);
3
- function o() {
4
- if (!t) {
5
- if (typeof crypto > "u" || !crypto.getRandomValues)
6
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
7
- t = crypto.getRandomValues.bind(crypto);
8
- }
9
- return t(e);
10
- }
11
- export {
12
- o as default
13
- };
14
- //# sourceMappingURL=annotorious-react.es26.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"annotorious-react.es26.js","sources":["../../../node_modules/uuid/dist/esm-browser/rng.js"],"sourcesContent":["let getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n if (!getRandomValues) {\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n getRandomValues = crypto.getRandomValues.bind(crypto);\n }\n return getRandomValues(rnds8);\n}\n"],"names":["getRandomValues","rnds8","rng"],"mappings":"AAAA,IAAIA;AACJ,MAAMC,IAAQ,IAAI,WAAW,EAAE;AAChB,SAASC,IAAM;AAC1B,MAAI,CAACF,GAAiB;AAClB,QAAI,OAAO,SAAW,OAAe,CAAC,OAAO;AACzC,YAAM,IAAI,MAAM,0GAA0G;AAE9H,IAAAA,IAAkB,OAAO,gBAAgB,KAAK,MAAM;AAAA,EAC5D;AACI,SAAOA,EAAgBC,CAAK;AAChC;","x_google_ignoreList":[0]}