@annotorious/react 3.0.0-rc.1

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 (90) hide show
  1. package/dist/Annotorious.d.ts +58 -0
  2. package/dist/Annotorious.d.ts.map +1 -0
  3. package/dist/AnnotoriousPlugin.d.ts +9 -0
  4. package/dist/AnnotoriousPlugin.d.ts.map +1 -0
  5. package/dist/AnnotoriousPopup.d.ts +16 -0
  6. package/dist/AnnotoriousPopup.d.ts.map +1 -0
  7. package/dist/ImageAnnotator.d.ts +9 -0
  8. package/dist/ImageAnnotator.d.ts.map +1 -0
  9. package/dist/annotorious-react.css +1 -0
  10. package/dist/annotorious-react.es.js +39 -0
  11. package/dist/annotorious-react.es.js.map +1 -0
  12. package/dist/annotorious-react.es10.js +5 -0
  13. package/dist/annotorious-react.es10.js.map +1 -0
  14. package/dist/annotorious-react.es11.js +12 -0
  15. package/dist/annotorious-react.es11.js.map +1 -0
  16. package/dist/annotorious-react.es12.js +5 -0
  17. package/dist/annotorious-react.es12.js.map +1 -0
  18. package/dist/annotorious-react.es13.js +3759 -0
  19. package/dist/annotorious-react.es13.js.map +1 -0
  20. package/dist/annotorious-react.es14.js +28 -0
  21. package/dist/annotorious-react.es14.js.map +1 -0
  22. package/dist/annotorious-react.es15.js +39 -0
  23. package/dist/annotorious-react.es15.js.map +1 -0
  24. package/dist/annotorious-react.es16.js +19 -0
  25. package/dist/annotorious-react.es16.js.map +1 -0
  26. package/dist/annotorious-react.es17.js +7 -0
  27. package/dist/annotorious-react.es17.js.map +1 -0
  28. package/dist/annotorious-react.es18.js +11 -0
  29. package/dist/annotorious-react.es18.js.map +1 -0
  30. package/dist/annotorious-react.es19.js +156 -0
  31. package/dist/annotorious-react.es19.js.map +1 -0
  32. package/dist/annotorious-react.es2.js +97 -0
  33. package/dist/annotorious-react.es2.js.map +1 -0
  34. package/dist/annotorious-react.es20.js +9 -0
  35. package/dist/annotorious-react.es20.js.map +1 -0
  36. package/dist/annotorious-react.es21.js +20596 -0
  37. package/dist/annotorious-react.es21.js.map +1 -0
  38. package/dist/annotorious-react.es22.js +35 -0
  39. package/dist/annotorious-react.es22.js.map +1 -0
  40. package/dist/annotorious-react.es23.js +5 -0
  41. package/dist/annotorious-react.es23.js.map +1 -0
  42. package/dist/annotorious-react.es24.js +33 -0
  43. package/dist/annotorious-react.es24.js.map +1 -0
  44. package/dist/annotorious-react.es25.js +602 -0
  45. package/dist/annotorious-react.es25.js.map +1 -0
  46. package/dist/annotorious-react.es26.js +5 -0
  47. package/dist/annotorious-react.es26.js.map +1 -0
  48. package/dist/annotorious-react.es27.js +5 -0
  49. package/dist/annotorious-react.es27.js.map +1 -0
  50. package/dist/annotorious-react.es28.js +20 -0
  51. package/dist/annotorious-react.es28.js.map +1 -0
  52. package/dist/annotorious-react.es29.js +24 -0
  53. package/dist/annotorious-react.es29.js.map +1 -0
  54. package/dist/annotorious-react.es3.js +17 -0
  55. package/dist/annotorious-react.es3.js.map +1 -0
  56. package/dist/annotorious-react.es30.js +5 -0
  57. package/dist/annotorious-react.es30.js.map +1 -0
  58. package/dist/annotorious-react.es31.js +7 -0
  59. package/dist/annotorious-react.es31.js.map +1 -0
  60. package/dist/annotorious-react.es32.js +11 -0
  61. package/dist/annotorious-react.es32.js.map +1 -0
  62. package/dist/annotorious-react.es33.js +10 -0
  63. package/dist/annotorious-react.es33.js.map +1 -0
  64. package/dist/annotorious-react.es4.js +19 -0
  65. package/dist/annotorious-react.es4.js.map +1 -0
  66. package/dist/annotorious-react.es5.js +21 -0
  67. package/dist/annotorious-react.es5.js.map +1 -0
  68. package/dist/annotorious-react.es6.js +5 -0
  69. package/dist/annotorious-react.es6.js.map +1 -0
  70. package/dist/annotorious-react.es7.js +5 -0
  71. package/dist/annotorious-react.es7.js.map +1 -0
  72. package/dist/annotorious-react.es8.js +12 -0
  73. package/dist/annotorious-react.es8.js.map +1 -0
  74. package/dist/annotorious-react.es9.js +3 -0
  75. package/dist/annotorious-react.es9.js.map +1 -0
  76. package/dist/index.d.ts +23 -0
  77. package/dist/index.d.ts.map +1 -0
  78. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts +15 -0
  79. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts.map +1 -0
  80. package/dist/openseadragon/OpenSeadragonPopup.d.ts +11 -0
  81. package/dist/openseadragon/OpenSeadragonPopup.d.ts.map +1 -0
  82. package/dist/openseadragon/OpenSeadragonViewer.d.ts +8 -0
  83. package/dist/openseadragon/OpenSeadragonViewer.d.ts.map +1 -0
  84. package/dist/openseadragon/index.d.ts +6 -0
  85. package/dist/openseadragon/index.d.ts.map +1 -0
  86. package/dist/openseadragon/setPosition.d.ts +4 -0
  87. package/dist/openseadragon/setPosition.d.ts.map +1 -0
  88. package/dist/useDebounce.d.ts +2 -0
  89. package/dist/useDebounce.d.ts.map +1 -0
  90. package/package.json +44 -0
@@ -0,0 +1,35 @@
1
+ import w from "openseadragon";
2
+ const L = (i, h) => {
3
+ const e = i.element.getBoundingClientRect(), { minX: n, minY: l, maxX: t, maxY: c } = h.target.selector.geometry.bounds, s = i.viewport.imageToViewerElementCoordinates(new w.Point(n, l)), x = i.viewport.imageToViewerElementCoordinates(new w.Point(t, c));
4
+ return {
5
+ x: s.x + e.x,
6
+ right: x.x + e.x,
7
+ y: s.y + e.y,
8
+ bottom: x.y + e.y,
9
+ width: x.x - s.x,
10
+ height: x.y - s.y
11
+ };
12
+ }, T = (i, h, e, n = 5) => {
13
+ const l = i.element.getBoundingClientRect(), t = L(i, h), c = t.y - l.y, s = l.right - t.x, x = l.bottom - t.bottom, d = t.x - l.left, o = e.firstElementChild.getBoundingClientRect(), g = c / o.height, y = s / o.width, a = x / o.height, r = d / o.width, $ = () => {
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
+ }, B = () => {
18
+ e.style.left = `${t.x - o.width - n}px`, e.style.top = `${t.y}px`;
19
+ }, v = () => {
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
+ }, b = [g, y, a, r], m = b.indexOf(Math.max(...b));
30
+ m === 0 ? y > r ? $() : f() : m === 1 ? g > a ? C() : v() : m === 2 ? y > r ? A() : E() : g > a ? R() : B();
31
+ };
32
+ export {
33
+ T as setPosition
34
+ };
35
+ //# sourceMappingURL=annotorious-react.es22.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotorious-react.es22.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 const viewerBounds = viewer.element.getBoundingClientRect();\n \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 + viewerBounds.x,\n right: bottomRight.x + viewerBounds.x,\n y: topLeft.y + viewerBounds.y,\n bottom: bottomRight.y + viewerBounds.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","viewerBounds","minX","minY","maxX","maxY","topLeft","OpenSeadragon","bottomRight","setPosition","popup","sideOffset","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;AACpF,QAAAC,IAAeF,EAAO,QAAQ,sBAAsB,GAGpD,EAAE,MAAAG,GAAM,MAAAC,GAAM,MAAAC,GAAM,MAAAC,MAASL,EAAW,OAAO,SAAS,SAAS,QAGjEM,IAAUP,EAAO,SAAS,gCAAgC,IAAIQ,EAAc,MAAML,GAAMC,CAAI,CAAC,GAC7FK,IAAcT,EAAO,SAAS,gCAAgC,IAAIQ,EAAc,MAAMH,GAAMC,CAAI,CAAC;AAGhG,SAAA;AAAA,IACL,GAAGC,EAAQ,IAAIL,EAAa;AAAA,IAC5B,OAAOO,EAAY,IAAIP,EAAa;AAAA,IACpC,GAAGK,EAAQ,IAAIL,EAAa;AAAA,IAC5B,QAAQO,EAAY,IAAIP,EAAa;AAAA,IACrC,OAAOO,EAAY,IAAIF,EAAQ;AAAA,IAC/B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,GAGvDU,IAAU,MAAM;AACpB,IAAAjB,EAAM,MAAM,OAAO,GAAGE,EAAW,IAAIA,EAAW,QAAQD,CAAU,MAClED,EAAM,MAAM,MAAM,GAAGE,EAAW,SAASK,EAAY,MAAM;AAAA,EAAA,GAGvDW,IAAa,MAAM;AACvB,IAAAlB,EAAM,MAAM,OAAO,GAAGE,EAAW,CAAC,MAClCF,EAAM,MAAM,MAAM,GAAGE,EAAW,SAASD,CAAU;AAAA,EAAA,GAG/CkB,IAAc,MAAM;AACxB,IAAAnB,EAAM,MAAM,OAAO,GAAGE,EAAW,QAAQK,EAAY,KAAK,MAC1DP,EAAM,MAAM,MAAM,GAAGE,EAAW,SAASD,CAAU;AAAA,EAAA,GAG/CmB,IAAS,CAACZ,GAAYC,GAAYC,GAAYC,CAAS,GACvDU,IAASD,EAAO,QAAQ,KAAK,IAAI,GAAGA,CAAM,CAAC;AAEjD,EAAIC,MAAW,IAETZ,IAAaE,IACPC,MAECC,MACFQ,MAAW,IAEhBb,IAAaE,IACPO,MAEEF,MACHM,MAAW,IAEhBZ,IAAaE,IACJO,MAECC,MAGVX,IAAaE,IACRM,MAEEF;AAEf;"}
@@ -0,0 +1,5 @@
1
+ var e = { exports: {} };
2
+ export {
3
+ e as __module
4
+ };
5
+ //# sourceMappingURL=annotorious-react.es23.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotorious-react.es23.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,33 @@
1
+ import { __exports as t } from "./annotorious-react.es26.js";
2
+ import R from "react";
3
+ /**
4
+ * @license React
5
+ * react-jsx-runtime.production.min.js
6
+ *
7
+ * Copyright (c) Facebook, Inc. and its affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+ var p;
13
+ function v() {
14
+ if (p)
15
+ return t;
16
+ p = 1;
17
+ var s = R, m = Symbol.for("react.element"), l = Symbol.for("react.fragment"), c = Object.prototype.hasOwnProperty, d = s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, y = { key: !0, ref: !0, __self: !0, __source: !0 };
18
+ function i(o, r, u) {
19
+ var e, n = {}, _ = null, f = null;
20
+ u !== void 0 && (_ = "" + u), r.key !== void 0 && (_ = "" + r.key), r.ref !== void 0 && (f = r.ref);
21
+ for (e in r)
22
+ c.call(r, e) && !y.hasOwnProperty(e) && (n[e] = r[e]);
23
+ if (o && o.defaultProps)
24
+ for (e in r = o.defaultProps, r)
25
+ n[e] === void 0 && (n[e] = r[e]);
26
+ return { $$typeof: m, type: o, key: _, ref: f, props: n, _owner: d.current };
27
+ }
28
+ return t.Fragment = l, t.jsx = i, t.jsxs = i, t;
29
+ }
30
+ export {
31
+ v as __require
32
+ };
33
+ //# sourceMappingURL=annotorious-react.es24.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotorious-react.es24.js","sources":["../../../node_modules/react/cjs/react-jsx-runtime.production.min.js"],"sourcesContent":["/**\n * @license React\n * react-jsx-runtime.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var f=require(\"react\"),k=Symbol.for(\"react.element\"),l=Symbol.for(\"react.fragment\"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};\nfunction q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=\"\"+g);void 0!==a.key&&(e=\"\"+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}exports.Fragment=l;exports.jsx=q;exports.jsxs=q;\n"],"names":["f","require$$0","k","m","n","p","q","c","a","g","b","d","e","h","reactJsxRuntime_production_min"],"mappings":";;;;;;;;;;;;;;;;AASa,MAAIA,IAAEC,GAAiBC,IAAE,OAAO,IAAI,eAAe,GAAE,IAAE,OAAO,IAAI,gBAAgB,GAAEC,IAAE,OAAO,UAAU,gBAAeC,IAAEJ,EAAE,mDAAmD,mBAAkBK,IAAE,EAAC,KAAI,IAAG,KAAI,IAAG,QAAO,IAAG,UAAS,GAAE;AAClP,WAASC,EAAEC,GAAEC,GAAEC,GAAE;AAAC,QAAIC,GAAEC,IAAE,IAAGC,IAAE,MAAKC,IAAE;AAAK,IAASJ,MAAT,WAAaG,IAAE,KAAGH,IAAYD,EAAE,QAAX,WAAiBI,IAAE,KAAGJ,EAAE,MAAcA,EAAE,QAAX,WAAiBK,IAAEL,EAAE;AAAK,SAAIE,KAAKF;AAAE,MAAAL,EAAE,KAAKK,GAAEE,CAAC,KAAG,CAACL,EAAE,eAAeK,CAAC,MAAIC,EAAED,CAAC,IAAEF,EAAEE,CAAC;AAAG,QAAGH,KAAGA,EAAE;AAAa,WAAIG,KAAKF,IAAED,EAAE,cAAaC;AAAE,QAASG,EAAED,CAAC,MAAZ,WAAgBC,EAAED,CAAC,IAAEF,EAAEE,CAAC;AAAG,WAAM,EAAC,UAASR,GAAE,MAAKK,GAAE,KAAIK,GAAE,KAAIC,GAAE,OAAMF,GAAE,QAAOP,EAAE,QAAO;AAAA,EAAC;AAAC,SAAAU,aAAiB,GAAEA,EAAW,MAACR,GAAEQ,EAAA,OAAaR;;","x_google_ignoreList":[0]}