@annotorious/react 3.0.0-rc.7 → 3.0.0-rc.9

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 (52) hide show
  1. package/dist/Annotorious.d.ts +15 -15
  2. package/dist/Annotorious.d.ts.map +1 -1
  3. package/dist/AnnotoriousPlugin.d.ts +1 -1
  4. package/dist/AnnotoriousPlugin.d.ts.map +1 -1
  5. package/dist/AnnotoriousPopup.d.ts +1 -1
  6. package/dist/AnnotoriousPopup.d.ts.map +1 -1
  7. package/dist/ImageAnnotator.d.ts +2 -2
  8. package/dist/ImageAnnotator.d.ts.map +1 -1
  9. package/dist/annotorious-react.es.js +24 -21
  10. package/dist/annotorious-react.es10.js +35 -28
  11. package/dist/annotorious-react.es10.js.map +1 -1
  12. package/dist/annotorious-react.es11.js +16 -36
  13. package/dist/annotorious-react.es11.js.map +1 -1
  14. package/dist/annotorious-react.es12.js +4 -16
  15. package/dist/annotorious-react.es12.js.map +1 -1
  16. package/dist/annotorious-react.es13.js +8 -4
  17. package/dist/annotorious-react.es13.js.map +1 -1
  18. package/dist/annotorious-react.es14.js +153 -8
  19. package/dist/annotorious-react.es14.js.map +1 -1
  20. package/dist/annotorious-react.es15.js +6 -153
  21. package/dist/annotorious-react.es15.js.map +1 -1
  22. package/dist/annotorious-react.es16.js +22155 -6
  23. package/dist/annotorious-react.es16.js.map +1 -1
  24. package/dist/annotorious-react.es17.js +32 -2
  25. package/dist/annotorious-react.es17.js.map +1 -1
  26. package/dist/annotorious-react.es18.js +2 -30
  27. package/dist/annotorious-react.es18.js.map +1 -1
  28. package/dist/annotorious-react.es19.js +21 -590
  29. package/dist/annotorious-react.es19.js.map +1 -1
  30. package/dist/annotorious-react.es2.js +2 -2
  31. package/dist/annotorious-react.es2.js.map +1 -1
  32. package/dist/annotorious-react.es20.js +542 -20653
  33. package/dist/annotorious-react.es20.js.map +1 -1
  34. package/dist/annotorious-react.es21.js +2 -32
  35. package/dist/annotorious-react.es21.js.map +1 -1
  36. package/dist/annotorious-react.es22.js +2 -2
  37. package/dist/annotorious-react.es3.js.map +1 -1
  38. package/dist/annotorious-react.es4.js +2 -2
  39. package/dist/annotorious-react.es4.js.map +1 -1
  40. package/dist/annotorious-react.es5.js +12 -9
  41. package/dist/annotorious-react.es5.js.map +1 -1
  42. package/dist/annotorious-react.es8.js +78 -19
  43. package/dist/annotorious-react.es8.js.map +1 -1
  44. package/dist/annotorious-react.es9.js +25 -3922
  45. package/dist/annotorious-react.es9.js.map +1 -1
  46. package/dist/index.d.ts +7 -3
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts +1 -1
  49. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts.map +1 -1
  50. package/package.json +2 -1
  51. package/dist/annotorious-react.es23.js +0 -5
  52. package/dist/annotorious-react.es23.js.map +0 -1
@@ -1,5 +1,35 @@
1
- var e = { exports: {} };
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
+ };
2
32
  export {
3
- e as __module
33
+ T as setPosition
4
34
  };
5
35
  //# sourceMappingURL=annotorious-react.es17.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es17.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"annotorious-react.es17.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,EA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W,IAAIK,EAAY,QAAQN,CAAU,MACnED,EAAM,MAAM,MAAM,GAAGE,EAAW,SAASK,EAAY,MAAM;AAAA,EAAA,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;"}
@@ -1,33 +1,5 @@
1
- import { __exports as t } from "./annotorious-react.es22.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
- }
1
+ var e = { exports: {} };
30
2
  export {
31
- v as __require
3
+ e as __module
32
4
  };
33
5
  //# sourceMappingURL=annotorious-react.es18.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es18.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]}
1
+ {"version":3,"file":"annotorious-react.es18.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}