@annotorious/react 3.0.0-rc.20 → 3.0.0-rc.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.
- package/dist/Annotorious.d.ts +28 -3
- package/dist/Annotorious.d.ts.map +1 -1
- package/dist/AnnotoriousPlugin.d.ts +6 -7
- package/dist/AnnotoriousPlugin.d.ts.map +1 -1
- package/dist/ImageAnnotator.d.ts.map +1 -1
- package/dist/annotorious-react.css +1 -1
- package/dist/annotorious-react.es.js +50 -33
- package/dist/annotorious-react.es.js.map +1 -1
- package/dist/annotorious-react.es10.js +3 -29
- package/dist/annotorious-react.es10.js.map +1 -1
- package/dist/annotorious-react.es11.js +27 -36
- package/dist/annotorious-react.es11.js.map +1 -1
- package/dist/annotorious-react.es12.js +20 -16
- package/dist/annotorious-react.es12.js.map +1 -1
- package/dist/annotorious-react.es13.js +54 -6
- package/dist/annotorious-react.es13.js.map +1 -1
- package/dist/annotorious-react.es14.js +17 -8
- package/dist/annotorious-react.es14.js.map +1 -1
- package/dist/annotorious-react.es15.js +21 -152
- package/dist/annotorious-react.es15.js.map +1 -1
- package/dist/annotorious-react.es16.js +2 -27436
- package/dist/annotorious-react.es16.js.map +1 -1
- package/dist/annotorious-react.es17.js +2 -32
- package/dist/annotorious-react.es17.js.map +1 -1
- package/dist/annotorious-react.es18.js +3859 -2
- package/dist/annotorious-react.es18.js.map +1 -1
- package/dist/annotorious-react.es19.js +29 -30
- package/dist/annotorious-react.es19.js.map +1 -1
- package/dist/annotorious-react.es2.js +32 -32
- package/dist/annotorious-react.es2.js.map +1 -1
- package/dist/annotorious-react.es20.js +35 -598
- package/dist/annotorious-react.es20.js.map +1 -1
- package/dist/annotorious-react.es21.js +16 -2
- package/dist/annotorious-react.es21.js.map +1 -1
- package/dist/annotorious-react.es22.js +4 -2
- package/dist/annotorious-react.es22.js.map +1 -1
- package/dist/annotorious-react.es23.js +11 -0
- package/dist/annotorious-react.es23.js.map +1 -0
- package/dist/annotorious-react.es24.js +156 -0
- package/dist/annotorious-react.es24.js.map +1 -0
- package/dist/annotorious-react.es25.js +9 -0
- package/dist/annotorious-react.es25.js.map +1 -0
- package/dist/annotorious-react.es26.js +20665 -0
- package/dist/annotorious-react.es26.js.map +1 -0
- package/dist/annotorious-react.es27.js +35 -0
- package/dist/annotorious-react.es27.js.map +1 -0
- package/dist/annotorious-react.es28.js +5 -0
- package/dist/annotorious-react.es28.js.map +1 -0
- package/dist/annotorious-react.es29.js +33 -0
- package/dist/annotorious-react.es29.js.map +1 -0
- package/dist/annotorious-react.es3.js +7 -7
- package/dist/annotorious-react.es3.js.map +1 -1
- package/dist/annotorious-react.es30.js +602 -0
- package/dist/annotorious-react.es30.js.map +1 -0
- package/dist/annotorious-react.es31.js +5 -0
- package/dist/annotorious-react.es31.js.map +1 -0
- package/dist/annotorious-react.es32.js +5 -0
- package/dist/annotorious-react.es32.js.map +1 -0
- package/dist/annotorious-react.es33.js +20 -0
- package/dist/annotorious-react.es33.js.map +1 -0
- package/dist/annotorious-react.es34.js +30 -0
- package/dist/annotorious-react.es34.js.map +1 -0
- package/dist/annotorious-react.es35.js +19 -0
- package/dist/annotorious-react.es35.js.map +1 -0
- package/dist/annotorious-react.es36.js +24 -0
- package/dist/annotorious-react.es36.js.map +1 -0
- package/dist/annotorious-react.es37.js +19 -0
- package/dist/annotorious-react.es37.js.map +1 -0
- package/dist/annotorious-react.es38.js +7 -0
- package/dist/annotorious-react.es38.js.map +1 -0
- package/dist/annotorious-react.es39.js +11 -0
- package/dist/annotorious-react.es39.js.map +1 -0
- package/dist/annotorious-react.es4.js +8 -8
- package/dist/annotorious-react.es4.js.map +1 -1
- package/dist/annotorious-react.es40.js +10 -0
- package/dist/annotorious-react.es40.js.map +1 -0
- package/dist/annotorious-react.es5.js +10 -10
- package/dist/annotorious-react.es5.js.map +1 -1
- package/dist/annotorious-react.es6.js +4 -1
- package/dist/annotorious-react.es6.js.map +1 -1
- package/dist/annotorious-react.es7.js +4 -1
- package/dist/annotorious-react.es7.js.map +1 -1
- package/dist/annotorious-react.es8.js +46 -85
- package/dist/annotorious-react.es8.js.map +1 -1
- package/dist/annotorious-react.es9.js +10 -4237
- package/dist/annotorious-react.es9.js.map +1 -1
- package/dist/index.d.ts +10 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/openseadragon/OpenSeadragonAnnotator.d.ts.map +1 -1
- package/dist/openseadragon/setPosition.d.ts.map +1 -1
- package/package.json +8 -16
|
@@ -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
|
+
}, E = () => {
|
|
26
|
+
e.style.left = `${t.x}px`, e.style.top = `${t.bottom + n}px`;
|
|
27
|
+
}, A = () => {
|
|
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 ? E() : A() : g > a ? R() : B();
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
T as setPosition
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=annotorious-react.es27.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotorious-react.es27.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":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotorious-react.es28.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { __exports as t } from "./annotorious-react.es31.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.es29.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotorious-react.es29.js","sources":["../../../node_modules/.pnpm/react@18.2.0/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,14 +1,14 @@
|
|
|
1
1
|
import { useEffect as i } from "react";
|
|
2
2
|
import { useAnnotator as s } from "./annotorious-react.es2.js";
|
|
3
3
|
const m = (t) => {
|
|
4
|
-
const { plugin:
|
|
4
|
+
const { plugin: u, opts: r } = t, n = s();
|
|
5
5
|
return i(() => {
|
|
6
|
-
if (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
6
|
+
if (n) {
|
|
7
|
+
const o = u(n, r);
|
|
8
|
+
return () => {
|
|
9
|
+
o && "unmount" in o && o.unmount();
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
12
|
}, [n]), null;
|
|
13
13
|
};
|
|
14
14
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es3.js","sources":["../src/AnnotoriousPlugin.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { Annotator } from '@annotorious/annotorious';\nimport { useAnnotator } from './Annotorious';\n\nexport
|
|
1
|
+
{"version":3,"file":"annotorious-react.es3.js","sources":["../src/AnnotoriousPlugin.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { Annotation, Annotator } from '@annotorious/annotorious';\nimport { useAnnotator } from './Annotorious';\n\nexport interface AnnotoriousPluginProps <I extends Annotation, E extends unknown> {\n\n plugin: (anno: Annotator<I, E>, opts?: Object) => ({ unmount?: () => void }) | void;\n\n opts?: Object;\n\n}\n\nexport const AnnotoriousPlugin = <I extends Annotation = Annotation, E extends unknown = unknown>(props: AnnotoriousPluginProps<I, E>) => {\n const { plugin, opts } = props;\n\n const anno = useAnnotator<Annotator<I, E>>();\n\n useEffect(() => {\n if (anno) {\n const p = plugin(anno, opts);\n\n return () => {\n if (p && 'unmount' in p)\n p.unmount();\n }\n }\n }, [anno]);\n\n return null;\n\n}"],"names":["AnnotoriousPlugin","props","plugin","opts","anno","useAnnotator","useEffect","p"],"mappings":";;AAYa,MAAAA,IAAoB,CAAiEC,MAAwC;AAClI,QAAA,EAAE,QAAAC,GAAQ,MAAAC,EAAS,IAAAF,GAEnBG,IAAOC;AAEb,SAAAC,EAAU,MAAM;AACd,QAAIF,GAAM;AACF,YAAAG,IAAIL,EAAOE,GAAMD,CAAI;AAE3B,aAAO,MAAM;AACX,QAAII,KAAK,aAAaA,KACpBA,EAAE,QAAQ;AAAA,MAAA;AAAA,IAEhB;AAAA,EAAA,GACC,CAACH,CAAI,CAAC,GAEF;AAET;"}
|