@annotorious/react 3.0.0-rc.21 → 3.0.0-rc.23
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 +5 -4
- package/dist/AnnotoriousPlugin.d.ts +1 -0
- package/dist/AnnotoriousPopup.d.ts +3 -2
- package/dist/ImageAnnotator.d.ts +2 -2
- package/dist/annotorious-react.css +1 -1
- package/dist/annotorious-react.es.js +23 -23
- package/dist/annotorious-react.es.js.map +1 -1
- package/dist/annotorious-react.es10.js +14 -27
- package/dist/annotorious-react.es10.js.map +1 -1
- package/dist/annotorious-react.es11.js +6 -36
- package/dist/annotorious-react.es11.js.map +1 -1
- package/dist/annotorious-react.es12.js +8 -16
- package/dist/annotorious-react.es12.js.map +1 -1
- package/dist/annotorious-react.es13.js +156 -6
- package/dist/annotorious-react.es13.js.map +1 -1
- package/dist/annotorious-react.es14.js +31 -7
- package/dist/annotorious-react.es14.js.map +1 -1
- package/dist/annotorious-react.es15.js +2 -153
- package/dist/annotorious-react.es15.js.map +1 -1
- package/dist/annotorious-react.es16.js +29 -27435
- package/dist/annotorious-react.es16.js.map +1 -1
- package/dist/annotorious-react.es17.js +591 -32
- package/dist/annotorious-react.es17.js.map +1 -1
- package/dist/annotorious-react.es18.js +2 -2
- package/dist/annotorious-react.es19.js +2 -30
- package/dist/annotorious-react.es19.js.map +1 -1
- package/dist/annotorious-react.es2.js +2 -2
- package/dist/annotorious-react.es4.js +2 -2
- package/dist/annotorious-react.es5.js +8 -8
- package/dist/annotorious-react.es8.js +27 -86
- package/dist/annotorious-react.es8.js.map +1 -1
- package/dist/annotorious-react.es9.js +30 -4233
- package/dist/annotorious-react.es9.js.map +1 -1
- package/dist/index.d.ts +6 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/openseadragon/OpenSeadragonAnnotator.d.ts +4 -3
- package/dist/openseadragon/OpenSeadragonPopup.d.ts +3 -2
- package/dist/openseadragon/OpenSeadragonViewer.d.ts +3 -3
- package/dist/openseadragon/setPosition.d.ts +2 -1
- package/package.json +11 -11
- package/dist/annotorious-react.es20.js +0 -602
- package/dist/annotorious-react.es20.js.map +0 -1
- package/dist/annotorious-react.es21.js +0 -5
- package/dist/annotorious-react.es21.js.map +0 -1
- package/dist/annotorious-react.es22.js +0 -5
- package/dist/annotorious-react.es22.js.map +0 -1
package/dist/Annotorious.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
1
|
import { Annotation, Annotator, Store } from '@annotorious/annotorious';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
3
4
|
interface Selection<T extends Annotation = Annotation> {
|
|
4
5
|
selected: {
|
|
5
6
|
annotation: T;
|
|
@@ -13,7 +14,7 @@ export interface AnnotoriousContextState {
|
|
|
13
14
|
annotations: Annotation[];
|
|
14
15
|
selection: Selection;
|
|
15
16
|
}
|
|
16
|
-
export declare const AnnotoriousContext: import(
|
|
17
|
+
export declare const AnnotoriousContext: import('react').Context<{
|
|
17
18
|
anno: any;
|
|
18
19
|
setAnno: any;
|
|
19
20
|
annotations: any[];
|
|
@@ -21,9 +22,9 @@ export declare const AnnotoriousContext: import("react").Context<{
|
|
|
21
22
|
selected: any[];
|
|
22
23
|
};
|
|
23
24
|
}>;
|
|
24
|
-
export declare const Annotorious: import(
|
|
25
|
+
export declare const Annotorious: import('react').ForwardRefExoticComponent<{
|
|
25
26
|
children: ReactNode;
|
|
26
|
-
} & import(
|
|
27
|
+
} & import('react').RefAttributes<Annotator<Annotation, Annotation>>>;
|
|
27
28
|
export declare const useAnnotator: <T extends unknown = Annotator<any, unknown>>() => T;
|
|
28
29
|
export declare const useAnnotationStore: <T extends unknown = Store<Annotation>>() => T;
|
|
29
30
|
export declare const useAnnotations: <T extends Annotation>(debounce?: number) => T[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
1
|
import { ImageAnnotation } from '@annotorious/annotorious';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
3
4
|
export interface AnnotoriousPopupProps {
|
|
4
5
|
selected: {
|
|
5
6
|
annotation: ImageAnnotation;
|
|
@@ -12,5 +13,5 @@ export interface DraggableProps {
|
|
|
12
13
|
onDragStart?(): void;
|
|
13
14
|
onDragEnd?(): void;
|
|
14
15
|
}
|
|
15
|
-
export declare const Draggable: import(
|
|
16
|
+
export declare const Draggable: import('react').ForwardRefExoticComponent<DraggableProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
16
17
|
//# sourceMappingURL=AnnotoriousPopup.d.ts.map
|
package/dist/ImageAnnotator.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { AnnotoriousOpts, DrawingStyle, DrawingTool, Filter, ImageAnnotation } from '@annotorious/annotorious';
|
|
1
2
|
import { ReactElement } from 'react';
|
|
2
|
-
|
|
3
|
-
import type { DrawingStyle, DrawingTool, Filter, ImageAnnotation } from '@annotorious/annotorious';
|
|
3
|
+
|
|
4
4
|
export interface ImageAnnotatorProps<E extends unknown> extends AnnotoriousOpts<ImageAnnotation, E> {
|
|
5
5
|
children: ReactElement<HTMLImageElement>;
|
|
6
6
|
filter?: Filter<ImageAnnotation>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
canvas.a9s-gl-canvas{height:100%;left:0;position:absolute;top:0;width:100%}canvas.a9s-gl-canvas.hover{cursor:pointer!important}svg.svelte-190cqdf.svelte-190cqdf{pointer-events:none}svg.drawing.svelte-190cqdf.svelte-190cqdf{pointer-events:all}svg.svelte-190cqdf .svelte-190cqdf{pointer-events:all}text.svelte-1rehw2p{fill:#fff;font-family:Arial,Helvetica,sans-serif;font-weight:600}rect.svelte-1rehw2p{stroke-width:1.2;vector-effect:non-scaling-stroke}polygon.svelte-fgq4n0{stroke-width:1.2;vector-effect:non-scaling-stroke}rect.svelte-gze948{stroke-width:1.2;vector-effect:non-scaling-stroke}svg.svelte-1krwc4m{position:absolute;top:0;left:0;width:100%;height:100%;outline:none;pointer-events:none}.a9s-touch-halo.svelte-1sgkh33{fill:transparent;stroke-width:0}.a9s-touch-halo.touched.svelte-1sgkh33{fill:#ffffff40}.a9s-annotationlayer{box-sizing:border-box;height:100%;left:0;outline:none;position:absolute;top:0;touch-action:none;width:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.a9s-annotationlayer ellipse,.a9s-annotationlayer polygon,.a9s-annotationlayer rect{fill:transparent;shape-rendering:geometricPrecision;vector-effect:non-scaling-stroke}.a9s-edge-handle{fill:transparent;stroke:transparent;stroke-width:6px}.a9s-shape-handle,.a9s-handle{cursor:move}.a9s-edge-handle-top{cursor:n-resize}.a9s-edge-handle-right{cursor:e-resize}.a9s-edge-handle-bottom{cursor:s-resize}.a9s-edge-handle-left{cursor:w-resize}.a9s-handle.a9s-corner-handle-topleft{cursor:nw-resize}.a9s-handle.a9s-corner-handle-topright{cursor:ne-resize}.a9s-handle.a9s-corner-handle-bottomright{cursor:se-resize}.a9s-handle.a9s-corner-handle-bottomleft{cursor:sw-resize}.a9s-annotationlayer .a9s-outer,div[data-theme=dark] .a9s-annotationlayer .a9s-outer{display:none}.a9s-annotationlayer .a9s-inner,div[data-theme=dark] .a9s-annotationlayer .a9s-inner{fill:#0000001f;stroke:#000;stroke-width:1px}rect.a9s-handle,div[data-theme=dark] rect.a9s-handle{fill:#000;rx:2px}rect.a9s-close-polygon-handle,div[data-theme=dark] rect.a9s-close-polygon-handle{fill:#000;rx:1px}.a9s-annotationlayer .a9s-outer,div[data-theme=light] .a9s-annotationlayer .a9s-outer{display:block;stroke:#00000040;stroke-width:3.5px}.a9s-annotationlayer .a9s-inner,div[data-theme=light] .a9s-annotationlayer .a9s-inner{fill:#ffffff26;stroke:#fff;stroke-width:1.5px}rect.a9s-handle,div[data-theme=light] rect.a9s-handle{fill:#fff;rx:1px;stroke:#00000073;stroke-width:1px}rect.a9s-close-polygon-handle,div[data-theme=light] rect.a9s-close-polygon-handle{fill:#fff;rx:1px;stroke:#00000073;stroke-width:1px}
|
|
1
|
+
canvas.a9s-gl-canvas{height:100%;left:0;position:absolute;top:0;width:100%}canvas.a9s-gl-canvas.hidden{display:none}canvas.a9s-gl-canvas.hover{cursor:pointer!important}svg.svelte-190cqdf.svelte-190cqdf{pointer-events:none}svg.drawing.svelte-190cqdf.svelte-190cqdf{pointer-events:all}svg.svelte-190cqdf .svelte-190cqdf{pointer-events:all}text.svelte-1rehw2p{fill:#fff;font-family:Arial,Helvetica,sans-serif;font-weight:600}rect.svelte-1rehw2p{stroke-width:1.2;vector-effect:non-scaling-stroke}polygon.svelte-fgq4n0{stroke-width:1.2;vector-effect:non-scaling-stroke}rect.svelte-gze948{stroke-width:1.2;vector-effect:non-scaling-stroke}svg.svelte-1krwc4m{position:absolute;top:0;left:0;width:100%;height:100%;outline:none;pointer-events:none}.a9s-touch-halo.svelte-1sgkh33{fill:transparent;stroke-width:0}.a9s-touch-halo.touched.svelte-1sgkh33{fill:#ffffff40}.a9s-annotationlayer{box-sizing:border-box;height:100%;left:0;outline:none;position:absolute;top:0;touch-action:none;width:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.a9s-annotationlayer.hidden{display:none}.a9s-annotationlayer ellipse,.a9s-annotationlayer polygon,.a9s-annotationlayer rect{fill:transparent;shape-rendering:geometricPrecision;vector-effect:non-scaling-stroke}.a9s-edge-handle{fill:transparent;stroke:transparent;stroke-width:6px}.a9s-shape-handle,.a9s-handle{cursor:move}.a9s-edge-handle-top{cursor:n-resize}.a9s-edge-handle-right{cursor:e-resize}.a9s-edge-handle-bottom{cursor:s-resize}.a9s-edge-handle-left{cursor:w-resize}.a9s-handle.a9s-corner-handle-topleft{cursor:nw-resize}.a9s-handle.a9s-corner-handle-topright{cursor:ne-resize}.a9s-handle.a9s-corner-handle-bottomright{cursor:se-resize}.a9s-handle.a9s-corner-handle-bottomleft{cursor:sw-resize}.a9s-annotationlayer .a9s-outer,div[data-theme=dark] .a9s-annotationlayer .a9s-outer{display:none}.a9s-annotationlayer .a9s-inner,div[data-theme=dark] .a9s-annotationlayer .a9s-inner{fill:#0000001f;stroke:#000;stroke-width:1px}rect.a9s-handle,div[data-theme=dark] rect.a9s-handle{fill:#000;rx:2px}rect.a9s-close-polygon-handle,div[data-theme=dark] rect.a9s-close-polygon-handle{fill:#000;rx:1px}.a9s-annotationlayer .a9s-outer,div[data-theme=light] .a9s-annotationlayer .a9s-outer{display:block;stroke:#00000040;stroke-width:3.5px}.a9s-annotationlayer .a9s-inner,div[data-theme=light] .a9s-annotationlayer .a9s-inner{fill:#ffffff26;stroke:#fff;stroke-width:1.5px}rect.a9s-handle,div[data-theme=light] rect.a9s-handle{fill:#fff;rx:1px;stroke:#00000073;stroke-width:1px}rect.a9s-close-polygon-handle,div[data-theme=light] rect.a9s-close-polygon-handle{fill:#fff;rx:1px;stroke:#00000073;stroke-width:1px}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { Annotorious as
|
|
1
|
+
import { Annotorious as g, AnnotoriousContext as A, useAnnotationStore as c, useAnnotations as f, useAnnotator as x, useAnnotatorUser as S, useSelection as I, useViewportState as d } from "./annotorious-react.es2.js";
|
|
2
2
|
import { AnnotoriousPlugin as y } from "./annotorious-react.es3.js";
|
|
3
3
|
import { Draggable as O } from "./annotorious-react.es4.js";
|
|
4
|
-
import { ImageAnnotator as
|
|
4
|
+
import { ImageAnnotator as h } from "./annotorious-react.es5.js";
|
|
5
5
|
import "./annotorious-react.es6.js";
|
|
6
6
|
import "./annotorious-react.es7.js";
|
|
7
|
-
import { Origin as
|
|
8
|
-
import { createImageAnnotator as o, ShapeType as e, W3CImageFormat as t } from "
|
|
9
|
-
import { OpenSeadragonAnnotator as
|
|
10
|
-
import { OpenSeadragonPopup as G } from "./annotorious-react.
|
|
11
|
-
import { OpenSeadragonViewer as
|
|
12
|
-
const p = o,
|
|
7
|
+
import { Origin as F, PointerSelectAction as T, createAnonymousGuest as V, createBody as W, defaultColorProvider as $ } from "@annotorious/core";
|
|
8
|
+
import { createImageAnnotator as o, ShapeType as e, W3CImageFormat as t } from "@annotorious/annotorious";
|
|
9
|
+
import { OpenSeadragonAnnotator as v, useViewer as B } from "./annotorious-react.es8.js";
|
|
10
|
+
import { OpenSeadragonPopup as G } from "./annotorious-react.es9.js";
|
|
11
|
+
import { OpenSeadragonViewer as j } from "./annotorious-react.es10.js";
|
|
12
|
+
const p = o, m = e, s = t;
|
|
13
13
|
export {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
g as Annotorious,
|
|
15
|
+
A as AnnotoriousContext,
|
|
16
16
|
y as AnnotoriousPlugin,
|
|
17
17
|
O as Draggable,
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
h as ImageAnnotator,
|
|
19
|
+
v as OpenSeadragonAnnotator,
|
|
20
20
|
G as OpenSeadragonPopup,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
j as OpenSeadragonViewer,
|
|
22
|
+
F as Origin,
|
|
23
|
+
T as PointerSelectAction,
|
|
24
|
+
m as ShapeType,
|
|
25
|
+
s as W3CImageFormat,
|
|
26
|
+
V as createAnonymousGuest,
|
|
27
|
+
W as createBody,
|
|
28
28
|
p as createImageAnnotator,
|
|
29
|
-
|
|
29
|
+
$ as defaultColorProvider,
|
|
30
30
|
c as useAnnotationStore,
|
|
31
31
|
f as useAnnotations,
|
|
32
32
|
x as useAnnotator,
|
|
33
33
|
S as useAnnotatorUser,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
I as useSelection,
|
|
35
|
+
B as useViewer,
|
|
36
|
+
d as useViewportState
|
|
37
37
|
};
|
|
38
38
|
//# sourceMappingURL=annotorious-react.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es.js","sources":["../src/index.ts"],"sourcesContent":["export * from './Annotorious';\nexport * from './AnnotoriousPlugin';\nexport * from './AnnotoriousPopup';\nexport * from './ImageAnnotator';\n\nexport * from './openseadragon';\n\n// This ensures the Annotorious stylesheet gets packaged into annotorious-react\nimport '@annotorious/annotorious/annotorious.css';\nimport '@annotorious/openseadragon/annotorious-openseadragon.css';\n\n// Essential re-exports from @annotorious/core\nexport type {\n Annotation,\n AnnotationBody,\n AnnotationTarget,\n Annotator,\n AnnotatorState,\n Appearance,\n AppearanceProvider,\n Color,\n DrawingStyle,\n Filter,\n FormatAdapter,\n HoverState,\n LifecycleEvents,\n ParseResult,\n PresentUser,\n Purpose,\n Selection,\n SelectionState,\n Store,\n StoreChangeEvent,\n StoreObserver,\n User,\n W3CAnnotation,\n W3CAnnotationBody,\n W3CAnnotationTarget\n} from '@annotorious/core';\n\nimport {\n createAnonymousGuest as _createAnonymousGuest, \n createBody as _createBody,\n defaultColorProvider as _defaultColorProvider,\n Origin as _Origin,\n PointerSelectAction as _PointerSelectAction\n} from '@annotorious/core';\n\nexport { _createAnonymousGuest as createAnonymousGuest };\nexport { _createBody as createBody };\nexport { _defaultColorProvider as defaultColorProvider };\nexport { _Origin as Origin };\nexport { _PointerSelectAction as PointerSelectAction };\n\n// Essential re-exports from @annotorious/annotorious \nexport type {\n AnnotoriousOpts,\n DrawingMode,\n DrawingTool,\n FragmentSelector,\n ImageAnnotator as AnnotoriousImageAnnotator,\n ImageAnnotation,\n
|
|
1
|
+
{"version":3,"file":"annotorious-react.es.js","sources":["../src/index.ts"],"sourcesContent":["export * from './Annotorious';\nexport * from './AnnotoriousPlugin';\nexport * from './AnnotoriousPopup';\nexport * from './ImageAnnotator';\n\nexport * from './openseadragon';\n\n// This ensures the Annotorious stylesheet gets packaged into annotorious-react\nimport '@annotorious/annotorious/annotorious.css';\nimport '@annotorious/openseadragon/annotorious-openseadragon.css';\n\n// Essential re-exports from @annotorious/core\nexport type {\n Annotation,\n AnnotationBody,\n AnnotationState,\n AnnotationTarget,\n Annotator,\n AnnotatorState,\n Appearance,\n AppearanceProvider,\n Color,\n DrawingStyle,\n DrawingStyleExpression,\n Filter,\n FormatAdapter,\n HoverState,\n LifecycleEvents,\n ParseResult,\n PresentUser,\n Purpose,\n Selection,\n SelectionState,\n Store,\n StoreChangeEvent,\n StoreObserver,\n User,\n W3CAnnotation,\n W3CAnnotationBody,\n W3CAnnotationTarget\n} from '@annotorious/core';\n\nimport {\n createAnonymousGuest as _createAnonymousGuest, \n createBody as _createBody,\n defaultColorProvider as _defaultColorProvider,\n Origin as _Origin,\n PointerSelectAction as _PointerSelectAction\n} from '@annotorious/core';\n\nexport { _createAnonymousGuest as createAnonymousGuest };\nexport { _createBody as createBody };\nexport { _defaultColorProvider as defaultColorProvider };\nexport { _Origin as Origin };\nexport { _PointerSelectAction as PointerSelectAction };\n\n// Essential re-exports from @annotorious/annotorious \nexport type {\n AnnotoriousOpts,\n DrawingMode,\n DrawingTool,\n FragmentSelector,\n ImageAnnotator as AnnotoriousImageAnnotator,\n ImageAnnotation,\n ImageAnnotatorState,\n Polygon,\n PolygonGeometry,\n Rectangle,\n RectangleGeometry,\n Shape,\n SVGSelector,\n W3CImageAnnotation,\n W3CImageAnnotationTarget\n} from '@annotorious/annotorious';\n\nimport { \n createImageAnnotator as _createImageAnnotator,\n ShapeType as _ShapeType,\n W3CImageFormat as _W3CImageFormat\n} from '@annotorious/annotorious';\n\nexport const createImageAnnotator = _createImageAnnotator;\nexport const ShapeType = _ShapeType;\nexport const W3CImageFormat = _W3CImageFormat;\n\n// Essential re-exports from @annotorious/openseadragon \nexport type {\n OpenSeadragonAnnotator as AnnotoriousOpenSeadragonAnnotator\n} from '@annotorious/openseadragon';\n\nexport type { Viewer } from 'openseadragon';\n"],"names":["createImageAnnotator","_createImageAnnotator","ShapeType","_ShapeType","W3CImageFormat","_W3CImageFormat"],"mappings":";;;;;;;;;;;AAiFO,MAAMA,IAAuBC,GACvBC,IAAYC,GACZC,IAAiBC;"}
|
|
@@ -1,32 +1,19 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
const
|
|
6
|
-
const {
|
|
7
|
-
return
|
|
8
|
-
if (
|
|
9
|
-
const
|
|
10
|
-
return e
|
|
11
|
-
|
|
1
|
+
import { j as a } from "./annotorious-react.es11.js";
|
|
2
|
+
import { forwardRef as m, useRef as p, useContext as u, useEffect as c, useImperativeHandle as d } from "react";
|
|
3
|
+
import l from "openseadragon";
|
|
4
|
+
import { OpenSeadragonAnnotatorContext as x } from "./annotorious-react.es8.js";
|
|
5
|
+
const S = m((n, s) => {
|
|
6
|
+
const { className: i, options: t } = n, r = p(null), { viewer: f, setViewer: e } = u(x);
|
|
7
|
+
return c(() => {
|
|
8
|
+
if (r.current) {
|
|
9
|
+
const o = l({ ...t, element: r.current });
|
|
10
|
+
return e && e(o), () => {
|
|
11
|
+
o.destroy(), e && e(void 0);
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
}, [
|
|
15
|
-
|
|
16
|
-
}, [e.drawingEnabled]), i(() => {
|
|
17
|
-
t && t.setFilter(e.filter);
|
|
18
|
-
}, [e.filter]), i(() => {
|
|
19
|
-
t && t.setStyle(e.style);
|
|
20
|
-
}, [e.style]), i(() => {
|
|
21
|
-
t && t.setDrawingTool(r);
|
|
22
|
-
}, [r]), /* @__PURE__ */ c.jsx(s.Provider, { value: { viewer: o, setViewer: f }, children: e.children });
|
|
23
|
-
}, A = () => {
|
|
24
|
-
const { viewer: e } = a(s);
|
|
25
|
-
return e;
|
|
26
|
-
};
|
|
14
|
+
}, [JSON.stringify(t)]), d(s, () => f), /* @__PURE__ */ a.jsx("div", { className: i, ref: r });
|
|
15
|
+
});
|
|
27
16
|
export {
|
|
28
|
-
S as
|
|
29
|
-
s as OpenSeadragonAnnotatorContext,
|
|
30
|
-
A as useViewer
|
|
17
|
+
S as OpenSeadragonViewer
|
|
31
18
|
};
|
|
32
19
|
//# sourceMappingURL=annotorious-react.es10.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es10.js","sources":["../src/openseadragon/
|
|
1
|
+
{"version":3,"file":"annotorious-react.es10.js","sources":["../src/openseadragon/OpenSeadragonViewer.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useImperativeHandle, useRef } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { OpenSeadragonAnnotatorContext } from './OpenSeadragonAnnotator';\n\nexport interface OpenSeadragonViewerProps {\n\n className?: string;\n\n options: OpenSeadragon.Options;\n\n}\n\nexport const OpenSeadragonViewer = forwardRef<OpenSeadragon.Viewer, OpenSeadragonViewerProps>((props: OpenSeadragonViewerProps, ref) => {\n\n const { className, options } = props;\n\n const element = useRef<HTMLDivElement>(null);\n\n const { viewer, setViewer } = useContext(OpenSeadragonAnnotatorContext);\n\n useEffect(() => { \n if (element.current) {\n const v = OpenSeadragon({...options, element: element.current });\n\n // Checking for setViewer is just a convenience so we can\n // use this component also without an OpenSeadragonAnnotator\n if (setViewer)\n setViewer(v);\n\n return () => {\n v.destroy();\n\n if (setViewer) \n setViewer(undefined);\n }\n }\n }, [JSON.stringify(options)]);\n\n useImperativeHandle(ref, () => viewer);\n\n return (\n <div className={className} ref={element} />\n );\n\n});"],"names":["OpenSeadragonViewer","forwardRef","props","ref","className","options","element","useRef","viewer","setViewer","useContext","OpenSeadragonAnnotatorContext","useEffect","v","OpenSeadragon","useImperativeHandle","jsx"],"mappings":";;;;AAYO,MAAMA,IAAsBC,EAA2D,CAACC,GAAiCC,MAAQ;AAEhI,QAAA,EAAE,WAAAC,GAAW,SAAAC,EAAY,IAAAH,GAEzBI,IAAUC,EAAuB,IAAI,GAErC,EAAE,QAAAC,GAAQ,WAAAC,EAAU,IAAIC,EAAWC,CAA6B;AAEtE,SAAAC,EAAU,MAAM;AACd,QAAIN,EAAQ,SAAS;AACb,YAAAO,IAAIC,EAAc,EAAC,GAAGT,GAAS,SAASC,EAAQ,SAAS;AAI3D,aAAAG,KACFA,EAAUI,CAAC,GAEN,MAAM;AACX,QAAAA,EAAE,QAAQ,GAENJ,KACFA,EAAU,MAAS;AAAA,MAAA;AAAA,IAEzB;AAAA,KACC,CAAC,KAAK,UAAUJ,CAAO,CAAC,CAAC,GAERU,EAAAZ,GAAK,MAAMK,CAAM,GAGlCQ,gBAAAA,EAAAA,IAAA,OAAA,EAAI,WAAAZ,GAAsB,KAAKE,EAAS,CAAA;AAG7C,CAAC;"}
|
|
@@ -1,39 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { setPosition as D } from "./annotorious-react.es17.js";
|
|
7
|
-
const R = (c) => {
|
|
8
|
-
const n = w(null), o = S(), { selected: t } = j(), [l, m] = d([]), [s, i] = d(!1), f = () => i(!0), p = () => {
|
|
9
|
-
const e = t[0].annotation;
|
|
10
|
-
D(o, e, n.current);
|
|
11
|
-
}, g = (e, r) => e.every((a) => r.includes(a)) && r.every((a) => e.includes(a));
|
|
12
|
-
return u(() => {
|
|
13
|
-
const e = t.map(({ annotation: r }) => r.id);
|
|
14
|
-
g(l, e) || (i(!1), m(e));
|
|
15
|
-
}, [t]), u(() => {
|
|
16
|
-
if (!n.current)
|
|
17
|
-
return;
|
|
18
|
-
s || p();
|
|
19
|
-
const e = () => {
|
|
20
|
-
s || p();
|
|
21
|
-
};
|
|
22
|
-
return o.addHandler("update-viewport", e), () => {
|
|
23
|
-
o.removeHandler("update-viewport", e);
|
|
24
|
-
};
|
|
25
|
-
}, [t, s]), t.length > 0 ? /* @__PURE__ */ v.jsx(
|
|
26
|
-
x,
|
|
27
|
-
{
|
|
28
|
-
ref: n,
|
|
29
|
-
className: "a9s-popup a9s-osd-popup",
|
|
30
|
-
onDragStart: f,
|
|
31
|
-
children: c.popup({ viewer: o, selected: t })
|
|
32
|
-
},
|
|
33
|
-
t.map(({ annotation: e }) => e.id).join("-")
|
|
34
|
-
) : null;
|
|
35
|
-
};
|
|
1
|
+
import { __module as e } from "./annotorious-react.es15.js";
|
|
2
|
+
import { __require as r } from "./annotorious-react.es16.js";
|
|
3
|
+
import { __require as o } from "./annotorious-react.es17.js";
|
|
4
|
+
process.env.NODE_ENV === "production" ? e.exports = r() : e.exports = o();
|
|
5
|
+
var m = e.exports;
|
|
36
6
|
export {
|
|
37
|
-
|
|
7
|
+
m as j
|
|
38
8
|
};
|
|
39
9
|
//# sourceMappingURL=annotorious-react.es11.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es11.js","sources":["
|
|
1
|
+
{"version":3,"file":"annotorious-react.es11.js","sources":["../../../node_modules/react/jsx-runtime.js"],"sourcesContent":["'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n"],"names":["jsxRuntimeModule","require$$0","require$$1"],"mappings":";;;AAEI,QAAQ,IAAI,aAAa,eAC3BA,EAAA,UAAiBC,MAEjBD,EAAA,UAAiBE;;","x_google_ignoreList":[0]}
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (r.current) {
|
|
9
|
-
const o = l({ ...t, element: r.current });
|
|
10
|
-
return e && e(o), () => {
|
|
11
|
-
o.destroy(), e && e(void 0);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}, [JSON.stringify(t)]), d(s, () => f), /* @__PURE__ */ m.jsx("div", { className: i, ref: r });
|
|
15
|
-
});
|
|
1
|
+
import { useState as c, useRef as n, useEffect as s } from "react";
|
|
2
|
+
const m = (e, t) => {
|
|
3
|
+
const [u, o] = c(e), r = n();
|
|
4
|
+
return s(() => (r.current = setTimeout(() => o(e), t), () => {
|
|
5
|
+
clearTimeout(r.current);
|
|
6
|
+
}), [e, t]), u;
|
|
7
|
+
};
|
|
16
8
|
export {
|
|
17
|
-
|
|
9
|
+
m as useDebounce
|
|
18
10
|
};
|
|
19
11
|
//# sourceMappingURL=annotorious-react.es12.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es12.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"annotorious-react.es12.js","sources":["../src/useDebounce.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nexport const useDebounce = (value: any, delay: number) => {\n const [debouncedValue, setDebouncedValue] = useState<any>(value);\n\n const timerRef = useRef<ReturnType<typeof setTimeout>>();\n\n useEffect(() => {\n timerRef.current = \n setTimeout(() => setDebouncedValue(value), delay);\n\n return () => {\n clearTimeout(timerRef.current);\n };\n }, [value, delay]);\n\n return debouncedValue;\n}"],"names":["useDebounce","value","delay","debouncedValue","setDebouncedValue","useState","timerRef","useRef","useEffect"],"mappings":";AAEa,MAAAA,IAAc,CAACC,GAAYC,MAAkB;AACxD,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAcJ,CAAK,GAEzDK,IAAWC;AAEjB,SAAAC,EAAU,OACRF,EAAS,UACP,WAAW,MAAMF,EAAkBH,CAAK,GAAGC,CAAK,GAE3C,MAAM;AACX,iBAAaI,EAAS,OAAO;AAAA,EAAA,IAE9B,CAACL,GAAOC,CAAK,CAAC,GAEVC;AACT;"}
|
|
@@ -1,9 +1,159 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { useRef as pe, useState as ie, useEffect as se } from "react";
|
|
2
|
+
var Q = { dragStart: !0 }, he = (e, t = {}) => {
|
|
3
|
+
let o, l, { bounds: c, axis: m = "both", gpuAcceleration: f = !0, legacyTranslate: R = !0, transform: M, applyUserSelectHack: N = !0, disabled: $ = !1, ignoreMultitouch: B = !1, recomputeBounds: b = Q, grid: H, position: u, cancel: D, handle: S, defaultClass: E = "neodrag", defaultClassDragging: i = "neodrag-dragging", defaultClassDragged: g = "neodrag-dragged", defaultPosition: U = { x: 0, y: 0 }, onDragStart: ce, onDrag: ue, onDragEnd: fe } = t, Y = !1, x = 0, A = 0, L = 0, T = 0, W = 0, j = 0, { x: q, y: P } = u ? { x: (u == null ? void 0 : u.x) ?? 0, y: (u == null ? void 0 : u.y) ?? 0 } : U;
|
|
4
|
+
J(q, P);
|
|
5
|
+
let y, C, X, F, ee, ne = "", ge = !!u;
|
|
6
|
+
b = { ...Q, ...b };
|
|
7
|
+
let k = /* @__PURE__ */ new Set();
|
|
8
|
+
const G = document.body.style, v = e.classList;
|
|
9
|
+
function J(n = x, a = A) {
|
|
10
|
+
if (!M) {
|
|
11
|
+
if (R) {
|
|
12
|
+
let d = `${+n}px, ${+a}px`;
|
|
13
|
+
return z(e, "transform", f ? `translate3d(${d}, 0)` : `translate(${d})`);
|
|
14
|
+
}
|
|
15
|
+
return z(e, "translate", `${+n}px ${+a}px ${f ? "1px" : ""}`);
|
|
16
|
+
}
|
|
17
|
+
const s = M({ offsetX: n, offsetY: a, rootNode: e });
|
|
18
|
+
V(s) && z(e, "transform", s);
|
|
19
|
+
}
|
|
20
|
+
const K = (n, a) => {
|
|
21
|
+
const s = { offsetX: x, offsetY: A, rootNode: e, currentNode: ee };
|
|
22
|
+
e.dispatchEvent(new CustomEvent(n, { detail: s })), a == null || a(s);
|
|
23
|
+
}, O = addEventListener;
|
|
24
|
+
O("pointerdown", te, !1), O("pointerup", oe, !1), O("pointermove", ae, !1), z(e, "touch-action", "none");
|
|
25
|
+
const re = () => {
|
|
26
|
+
let n = e.offsetWidth / C.width;
|
|
27
|
+
return isNaN(n) && (n = 1), n;
|
|
28
|
+
};
|
|
29
|
+
function te(n) {
|
|
30
|
+
if ($ || n.button === 2)
|
|
31
|
+
return;
|
|
32
|
+
if (k.add(n.pointerId), B && k.size > 1)
|
|
33
|
+
return n.preventDefault();
|
|
34
|
+
if (b.dragStart && (y = Z(c, e)), V(S) && V(D) && S === D)
|
|
35
|
+
throw new Error("`handle` selector can't be same as `cancel` selector");
|
|
36
|
+
if (v.add(E), X = function(r, h) {
|
|
37
|
+
if (!r)
|
|
38
|
+
return [h];
|
|
39
|
+
if (_(r))
|
|
40
|
+
return [r];
|
|
41
|
+
if (Array.isArray(r))
|
|
42
|
+
return r;
|
|
43
|
+
const w = h.querySelectorAll(r);
|
|
44
|
+
if (w === null)
|
|
45
|
+
throw new Error("Selector passed for `handle` option should be child of the element on which the action is applied");
|
|
46
|
+
return Array.from(w.values());
|
|
47
|
+
}(S, e), F = function(r, h) {
|
|
48
|
+
if (!r)
|
|
49
|
+
return [];
|
|
50
|
+
if (_(r))
|
|
51
|
+
return [r];
|
|
52
|
+
if (Array.isArray(r))
|
|
53
|
+
return r;
|
|
54
|
+
const w = h.querySelectorAll(r);
|
|
55
|
+
if (w === null)
|
|
56
|
+
throw new Error("Selector passed for `cancel` option should be child of the element on which the action is applied");
|
|
57
|
+
return Array.from(w.values());
|
|
58
|
+
}(D, e), o = /(both|x)/.test(m), l = /(both|y)/.test(m), le(F, X))
|
|
59
|
+
throw new Error("Element being dragged can't be a child of the element on which `cancel` is applied");
|
|
60
|
+
const a = n.composedPath()[0];
|
|
61
|
+
if (!X.some((r) => {
|
|
62
|
+
var h;
|
|
63
|
+
return r.contains(a) || ((h = r.shadowRoot) == null ? void 0 : h.contains(a));
|
|
64
|
+
}) || le(F, [a]))
|
|
65
|
+
return;
|
|
66
|
+
ee = X.length === 1 ? e : X.find((r) => r.contains(a)), Y = !0, C = e.getBoundingClientRect(), N && (ne = G.userSelect, G.userSelect = "none"), K("neodrag:start", ce);
|
|
67
|
+
const { clientX: s, clientY: d } = n, p = re();
|
|
68
|
+
o && (L = s - q / p), l && (T = d - P / p), y && (W = s - C.left, j = d - C.top);
|
|
69
|
+
}
|
|
70
|
+
function oe(n) {
|
|
71
|
+
k.delete(n.pointerId), Y && (b.dragEnd && (y = Z(c, e)), v.remove(i), v.add(g), N && (G.userSelect = ne), K("neodrag:end", fe), o && (L = x), l && (T = A), Y = !1);
|
|
72
|
+
}
|
|
73
|
+
function ae(n) {
|
|
74
|
+
if (!Y || B && k.size > 1)
|
|
75
|
+
return;
|
|
76
|
+
b.drag && (y = Z(c, e)), v.add(i), n.preventDefault(), C = e.getBoundingClientRect();
|
|
77
|
+
let a = n.clientX, s = n.clientY;
|
|
78
|
+
const d = re();
|
|
79
|
+
if (y) {
|
|
80
|
+
const p = { left: y.left + W, top: y.top + j, right: y.right + W - C.width, bottom: y.bottom + j - C.height };
|
|
81
|
+
a = de(a, p.left, p.right), s = de(s, p.top, p.bottom);
|
|
82
|
+
}
|
|
83
|
+
if (Array.isArray(H)) {
|
|
84
|
+
let [p, r] = H;
|
|
85
|
+
if (isNaN(+p) || p < 0)
|
|
86
|
+
throw new Error("1st argument of `grid` must be a valid positive number");
|
|
87
|
+
if (isNaN(+r) || r < 0)
|
|
88
|
+
throw new Error("2nd argument of `grid` must be a valid positive number");
|
|
89
|
+
let h = a - L, w = s - T;
|
|
90
|
+
[h, w] = me([p / d, r / d], h, w), a = L + h, s = T + w;
|
|
91
|
+
}
|
|
92
|
+
o && (x = Math.round((a - L) * d)), l && (A = Math.round((s - T) * d)), q = x, P = A, K("neodrag", ue), J();
|
|
93
|
+
}
|
|
94
|
+
return { destroy: () => {
|
|
95
|
+
const n = removeEventListener;
|
|
96
|
+
n("pointerdown", te, !1), n("pointerup", oe, !1), n("pointermove", ae, !1);
|
|
97
|
+
}, update: (n) => {
|
|
98
|
+
var s, d;
|
|
99
|
+
m = n.axis || "both", $ = n.disabled ?? !1, B = n.ignoreMultitouch ?? !1, S = n.handle, c = n.bounds, b = n.recomputeBounds ?? Q, D = n.cancel, N = n.applyUserSelectHack ?? !0, H = n.grid, f = n.gpuAcceleration ?? !0, R = n.legacyTranslate ?? !0, M = n.transform;
|
|
100
|
+
const a = v.contains(g);
|
|
101
|
+
v.remove(E, g), E = n.defaultClass ?? "neodrag", i = n.defaultClassDragging ?? "neodrag-dragging", g = n.defaultClassDragged ?? "neodrag-dragged", v.add(E), a && v.add(g), ge && (q = x = ((s = n.position) == null ? void 0 : s.x) ?? x, P = A = ((d = n.position) == null ? void 0 : d.y) ?? A, J());
|
|
102
|
+
} };
|
|
103
|
+
}, de = (e, t, o) => Math.min(Math.max(e, t), o), V = (e) => typeof e == "string", me = ([e, t], o, l) => {
|
|
104
|
+
const c = (m, f) => f === 0 ? 0 : Math.ceil(m / f) * f;
|
|
105
|
+
return [c(o, e), c(l, t)];
|
|
106
|
+
}, le = (e, t) => e.some((o) => t.some((l) => o.contains(l)));
|
|
107
|
+
function Z(e, t) {
|
|
108
|
+
if (e === void 0)
|
|
109
|
+
return;
|
|
110
|
+
if (_(e))
|
|
111
|
+
return e.getBoundingClientRect();
|
|
112
|
+
if (typeof e == "object") {
|
|
113
|
+
const { top: l = 0, left: c = 0, right: m = 0, bottom: f = 0 } = e;
|
|
114
|
+
return { top: l, right: window.innerWidth - m, bottom: window.innerHeight - f, left: c };
|
|
115
|
+
}
|
|
116
|
+
if (e === "parent")
|
|
117
|
+
return t.parentNode.getBoundingClientRect();
|
|
118
|
+
const o = document.querySelector(e);
|
|
119
|
+
if (o === null)
|
|
120
|
+
throw new Error("The selector provided for bound doesn't exists in the document.");
|
|
121
|
+
return o.getBoundingClientRect();
|
|
122
|
+
}
|
|
123
|
+
var z = (e, t, o) => e.style.setProperty(t, o), _ = (e) => e instanceof HTMLElement;
|
|
124
|
+
function I(e) {
|
|
125
|
+
return e == null || typeof e == "string" || e instanceof HTMLElement ? e : "current" in e ? e.current : Array.isArray(e) ? e.map((t) => t instanceof HTMLElement ? t : t.current) : void 0;
|
|
126
|
+
}
|
|
127
|
+
function we(e, t = {}) {
|
|
128
|
+
const o = pe(), [l, c] = ie(!1), [m, f] = ie();
|
|
129
|
+
let { onDragStart: R, onDrag: M, onDragEnd: N, handle: $, cancel: B } = t, b = I($), H = I(B);
|
|
130
|
+
function u(i, g) {
|
|
131
|
+
f(i), g == null || g(i);
|
|
132
|
+
}
|
|
133
|
+
function D(i) {
|
|
134
|
+
c(!0), u(i, R);
|
|
135
|
+
}
|
|
136
|
+
function S(i) {
|
|
137
|
+
u(i, M);
|
|
138
|
+
}
|
|
139
|
+
function E(i) {
|
|
140
|
+
c(!1), u(i, N);
|
|
141
|
+
}
|
|
142
|
+
return se(() => {
|
|
143
|
+
if (typeof window > "u")
|
|
144
|
+
return;
|
|
145
|
+
const i = e.current;
|
|
146
|
+
if (!i)
|
|
147
|
+
return;
|
|
148
|
+
({ onDragStart: R, onDrag: M, onDragEnd: N } = t);
|
|
149
|
+
const { update: g, destroy: U } = he(i, { ...t, handle: b, cancel: H, onDragStart: D, onDrag: S, onDragEnd: E });
|
|
150
|
+
return o.current = g, U;
|
|
151
|
+
}, []), se(() => {
|
|
152
|
+
var i;
|
|
153
|
+
(i = o.current) == null || i.call(o, { ...t, handle: I($), cancel: I(B), onDragStart: D, onDrag: S, onDragEnd: E });
|
|
154
|
+
}, [t]), { isDragging: l, dragState: m };
|
|
155
|
+
}
|
|
6
156
|
export {
|
|
7
|
-
|
|
157
|
+
we as useDraggable
|
|
8
158
|
};
|
|
9
159
|
//# sourceMappingURL=annotorious-react.es13.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es13.js","sources":["../../../node_modules/react/jsx-runtime.js"],"sourcesContent":["'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n"],"names":["jsxRuntimeModule","require$$0","require$$1"],"mappings":";;;AAEI,QAAQ,IAAI,aAAa,eAC3BA,EAAA,UAAiBC,MAEjBD,EAAA,UAAiBE;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"annotorious-react.es13.js","sources":["../../../node_modules/@neodrag/react/dist/min/index.js"],"sourcesContent":["import{useRef as t,useState as e,useEffect as n}from\"react\";var r={dragStart:!0},o=(t,e={})=>{let n,o,{bounds:f,axis:g=\"both\",gpuAcceleration:p=!0,legacyTranslate:h=!0,transform:m,applyUserSelectHack:y=!0,disabled:w=!1,ignoreMultitouch:b=!1,recomputeBounds:v=r,grid:D,position:E,cancel:S,handle:x,defaultClass:A=\"neodrag\",defaultClassDragging:C=\"neodrag-dragging\",defaultClassDragged:M=\"neodrag-dragged\",defaultPosition:N={x:0,y:0},onDragStart:B,onDrag:$,onDragEnd:H}=e,L=!1,R=0,T=0,X=0,Y=0,q=0,P=0,{x:k,y:z}=E?{x:E?.x??0,y:E?.y??0}:N;V(k,z);let I,U,W,j,F,G=\"\",J=!!E;v={...r,...v};let K=new Set;const O=document.body.style,Q=t.classList;function V(e=R,n=T){if(!m){if(h){let r=`${+e}px, ${+n}px`;return c(t,\"transform\",p?`translate3d(${r}, 0)`:`translate(${r})`)}return c(t,\"translate\",`${+e}px ${+n}px ${p?\"1px\":\"\"}`)}const r=m({offsetX:e,offsetY:n,rootNode:t});i(r)&&c(t,\"transform\",r)}const Z=(e,n)=>{const r={offsetX:R,offsetY:T,rootNode:t,currentNode:F};t.dispatchEvent(new CustomEvent(e,{detail:r})),n?.(r)};const _=addEventListener;_(\"pointerdown\",et,!1),_(\"pointerup\",nt,!1),_(\"pointermove\",rt,!1),c(t,\"touch-action\",\"none\");const tt=()=>{let e=t.offsetWidth/U.width;return isNaN(e)&&(e=1),e};function et(e){if(w)return;if(2===e.button)return;if(K.add(e.pointerId),b&&K.size>1)return e.preventDefault();if(v.dragStart&&(I=l(f,t)),i(x)&&i(S)&&x===S)throw new Error(\"`handle` selector can't be same as `cancel` selector\");if(Q.add(A),W=function(t,e){if(!t)return[e];if(u(t))return[t];if(Array.isArray(t))return t;const n=e.querySelectorAll(t);if(null===n)throw new Error(\"Selector passed for `handle` option should be child of the element on which the action is applied\");return Array.from(n.values())}(x,t),j=function(t,e){if(!t)return[];if(u(t))return[t];if(Array.isArray(t))return t;const n=e.querySelectorAll(t);if(null===n)throw new Error(\"Selector passed for `cancel` option should be child of the element on which the action is applied\");return Array.from(n.values())}(S,t),n=/(both|x)/.test(g),o=/(both|y)/.test(g),s(j,W))throw new Error(\"Element being dragged can't be a child of the element on which `cancel` is applied\");const r=e.composedPath()[0];if(!W.some((t=>t.contains(r)||t.shadowRoot?.contains(r)))||s(j,[r]))return;F=1===W.length?t:W.find((t=>t.contains(r))),L=!0,U=t.getBoundingClientRect(),y&&(G=O.userSelect,O.userSelect=\"none\"),Z(\"neodrag:start\",B);const{clientX:a,clientY:d}=e,c=tt();n&&(X=a-k/c),o&&(Y=d-z/c),I&&(q=a-U.left,P=d-U.top)}function nt(e){K.delete(e.pointerId),L&&(v.dragEnd&&(I=l(f,t)),Q.remove(C),Q.add(M),y&&(O.userSelect=G),Z(\"neodrag:end\",H),n&&(X=R),o&&(Y=T),L=!1)}function rt(e){if(!L||b&&K.size>1)return;v.drag&&(I=l(f,t)),Q.add(C),e.preventDefault(),U=t.getBoundingClientRect();let r=e.clientX,i=e.clientY;const s=tt();if(I){const t={left:I.left+q,top:I.top+P,right:I.right+q-U.width,bottom:I.bottom+P-U.height};r=a(r,t.left,t.right),i=a(i,t.top,t.bottom)}if(Array.isArray(D)){let[t,e]=D;if(isNaN(+t)||t<0)throw new Error(\"1st argument of `grid` must be a valid positive number\");if(isNaN(+e)||e<0)throw new Error(\"2nd argument of `grid` must be a valid positive number\");let n=r-X,o=i-Y;[n,o]=d([t/s,e/s],n,o),r=X+n,i=Y+o}n&&(R=Math.round((r-X)*s)),o&&(T=Math.round((i-Y)*s)),k=R,z=T,Z(\"neodrag\",$),V()}return{destroy:()=>{const t=removeEventListener;t(\"pointerdown\",et,!1),t(\"pointerup\",nt,!1),t(\"pointermove\",rt,!1)},update:t=>{g=t.axis||\"both\",w=t.disabled??!1,b=t.ignoreMultitouch??!1,x=t.handle,f=t.bounds,v=t.recomputeBounds??r,S=t.cancel,y=t.applyUserSelectHack??!0,D=t.grid,p=t.gpuAcceleration??!0,h=t.legacyTranslate??!0,m=t.transform;const e=Q.contains(M);Q.remove(A,M),A=t.defaultClass??\"neodrag\",C=t.defaultClassDragging??\"neodrag-dragging\",M=t.defaultClassDragged??\"neodrag-dragged\",Q.add(A),e&&Q.add(M),J&&(k=R=t.position?.x??R,z=T=t.position?.y??T,V())}}},a=(t,e,n)=>Math.min(Math.max(t,e),n),i=t=>\"string\"==typeof t,d=([t,e],n,r)=>{const o=(t,e)=>0===e?0:Math.ceil(t/e)*e;return[o(n,t),o(r,e)]};var s=(t,e)=>t.some((t=>e.some((e=>t.contains(e)))));function l(t,e){if(void 0===t)return;if(u(t))return t.getBoundingClientRect();if(\"object\"==typeof t){const{top:e=0,left:n=0,right:r=0,bottom:o=0}=t;return{top:e,right:window.innerWidth-r,bottom:window.innerHeight-o,left:n}}if(\"parent\"===t)return e.parentNode.getBoundingClientRect();const n=document.querySelector(t);if(null===n)throw new Error(\"The selector provided for bound doesn't exists in the document.\");return n.getBoundingClientRect()}var c=(t,e,n)=>t.style.setProperty(e,n),u=t=>t instanceof HTMLElement;function f(t){return null==t||\"string\"==typeof t||t instanceof HTMLElement?t:\"current\"in t?t.current:Array.isArray(t)?t.map((t=>t instanceof HTMLElement?t:t.current)):void 0}function g(r,a={}){const i=t(),[d,s]=e(!1),[l,c]=e();let{onDragStart:u,onDrag:g,onDragEnd:p,handle:h,cancel:m}=a,y=f(h),w=f(m);function b(t,e){c(t),e?.(t)}function v(t){s(!0),b(t,u)}function D(t){b(t,g)}function E(t){s(!1),b(t,p)}return n((()=>{if(\"undefined\"==typeof window)return;const t=r.current;if(!t)return;({onDragStart:u,onDrag:g,onDragEnd:p}=a);const{update:e,destroy:n}=o(t,{...a,handle:y,cancel:w,onDragStart:v,onDrag:D,onDragEnd:E});return i.current=e,n}),[]),n((()=>{i.current?.({...a,handle:f(h),cancel:f(m),onDragStart:v,onDrag:D,onDragEnd:E})}),[a]),{isDragging:d,dragState:l}}export{g as useDraggable};"],"names":["r","o","t","e","n","f","g","p","h","m","y","w","b","v","D","E","S","x","A","C","M","N","B","$","H","L","R","T","X","Y","q","P","k","z","V","I","U","W","j","F","G","J","K","O","Q","c","i","Z","_","et","nt","rt","tt","l","u","s","_a","a","d","_b"],"mappings":";AAA4D,IAAIA,IAAE,EAAC,WAAU,GAAE,GAAEC,KAAE,CAACC,GAAEC,IAAE,CAAA,MAAK;AAAC,MAAIC,GAAEH,GAAE,EAAC,QAAOI,GAAE,MAAKC,IAAE,QAAO,iBAAgBC,IAAE,IAAG,iBAAgBC,IAAE,IAAG,WAAUC,GAAE,qBAAoBC,IAAE,IAAG,UAASC,IAAE,IAAG,kBAAiBC,IAAE,IAAG,iBAAgBC,IAAEb,GAAE,MAAKc,GAAE,UAASC,GAAE,QAAOC,GAAE,QAAOC,GAAE,cAAaC,IAAE,WAAU,sBAAqBC,IAAE,oBAAmB,qBAAoBC,IAAE,mBAAkB,iBAAgBC,IAAE,EAAC,GAAE,GAAE,GAAE,EAAC,GAAE,aAAYC,IAAE,QAAOC,IAAE,WAAUC,GAAC,IAAErB,GAAEsB,IAAE,IAAGC,IAAE,GAAEC,IAAE,GAAEC,IAAE,GAAEC,IAAE,GAAEC,IAAE,GAAEC,IAAE,GAAE,EAAC,GAAEC,GAAE,GAAEC,EAAC,IAAElB,IAAE,EAAC,IAAEA,KAAA,gBAAAA,EAAG,MAAG,GAAE,IAAEA,KAAA,gBAAAA,EAAG,MAAG,EAAC,IAAEM;AAAE,EAAAa,EAAEF,GAAEC,CAAC;AAAE,MAAIE,GAAEC,GAAEC,GAAEC,GAAEC,IAAEC,KAAE,IAAGC,KAAE,CAAC,CAAC1B;AAAE,EAAAF,IAAE,EAAC,GAAGb,GAAE,GAAGa,EAAC;AAAE,MAAI6B,IAAE,oBAAI;AAAI,QAAMC,IAAE,SAAS,KAAK,OAAMC,IAAE1C,EAAE;AAAU,WAASgC,EAAE/B,IAAEuB,GAAEtB,IAAEuB,GAAE;AAAC,QAAG,CAAClB,GAAE;AAAC,UAAG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IAAEF,EAAE;AAAQ,QAAG,CAACE;AAAE;AAAO,KAAC,EAAC,aAAYoD,GAAE,QAAOhD,GAAE,WAAUC,EAAC,IAAEkD;AAAG,UAAK,EAAC,QAAOtD,GAAE,SAAQC,EAAC,IAAEH,GAAEC,GAAE,EAAC,GAAGuD,GAAE,QAAO/C,GAAE,QAAOC,GAAE,aAAYE,GAAE,QAAOC,GAAE,WAAU,EAAC,CAAC;AAAE,WAAOgC,EAAE,UAAQ3C,GAAEC;AAAA,EAAC,GAAG,CAAE,CAAA,GAAEA,GAAG,MAAI;;AAAC,KAAAoD,IAAAV,EAAE,YAAF,QAAAU,EAAA,KAAAV,GAAY,EAAC,GAAGW,GAAE,QAAOpD,EAAEG,CAAC,GAAE,QAAOH,EAAEI,CAAC,GAAE,aAAYI,GAAE,QAAOC,GAAE,WAAU,EAAC;AAAA,EAAE,GAAG,CAAC2C,CAAC,CAAC,GAAE,EAAC,YAAWC,GAAE,WAAUL,EAAC;AAAC;","x_google_ignoreList":[0]}
|
|
@@ -1,11 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import b from "openseadragon";
|
|
2
|
+
const L = (h, x) => {
|
|
3
|
+
const { minX: e, minY: n, maxX: i, maxY: t } = x.target.selector.geometry.bounds, l = h.viewport.imageToViewerElementCoordinates(new b.Point(e, n)), s = h.viewport.imageToViewerElementCoordinates(new b.Point(i, t));
|
|
4
|
+
return {
|
|
5
|
+
x: l.x,
|
|
6
|
+
right: s.x,
|
|
7
|
+
y: l.y,
|
|
8
|
+
bottom: s.y,
|
|
9
|
+
width: s.x - l.x,
|
|
10
|
+
height: s.y - l.y
|
|
11
|
+
};
|
|
12
|
+
}, T = (h, x, e, n = 5) => {
|
|
13
|
+
const i = h.element.getBoundingClientRect(), t = L(h, x), l = t.y - i.y, s = i.right - t.x, w = i.bottom - t.bottom, $ = t.x - i.left, o = e.firstElementChild.getBoundingClientRect(), a = l / o.height, c = s / o.width, g = w / o.height, r = $ / o.width, d = () => {
|
|
14
|
+
e.style.left = `${t.x}px`, e.style.top = `${t.y - n - o.height}px`;
|
|
15
|
+
}, f = () => {
|
|
16
|
+
e.style.left = `${t.right - o.width}px`, e.style.top = `${t.y - n - o.height}px`;
|
|
17
|
+
}, v = () => {
|
|
18
|
+
e.style.left = `${t.x - o.width - n}px`, e.style.top = `${t.y}px`;
|
|
19
|
+
}, B = () => {
|
|
20
|
+
e.style.left = `${t.right + n}px`, e.style.top = `${t.y}px`;
|
|
21
|
+
}, R = () => {
|
|
22
|
+
e.style.left = `${t.x - o.width - n}px`, e.style.top = `${t.bottom - o.height}px`;
|
|
23
|
+
}, C = () => {
|
|
24
|
+
e.style.left = `${t.x + t.width + n}px`, e.style.top = `${t.bottom - o.height}px`;
|
|
25
|
+
}, A = () => {
|
|
26
|
+
e.style.left = `${t.x}px`, e.style.top = `${t.bottom + n}px`;
|
|
27
|
+
}, E = () => {
|
|
28
|
+
e.style.left = `${t.right - o.width}px`, e.style.top = `${t.bottom + n}px`;
|
|
29
|
+
}, m = [a, c, g, r], y = m.indexOf(Math.max(...m));
|
|
30
|
+
y === 0 ? c > r ? d() : f() : y === 1 ? a > g ? C() : B() : y === 2 ? c > r ? A() : E() : a > g ? R() : v();
|
|
7
31
|
};
|
|
8
32
|
export {
|
|
9
|
-
|
|
33
|
+
T as setPosition
|
|
10
34
|
};
|
|
11
35
|
//# sourceMappingURL=annotorious-react.es14.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es14.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"annotorious-react.es14.js","sources":["../src/openseadragon/setPosition.ts"],"sourcesContent":["import { ImageAnnotation } from '@annotorious/annotorious';\nimport OpenSeadragon from 'openseadragon';\n\nconst getAnnotationDomRect = (viewer: OpenSeadragon.Viewer, annotation: ImageAnnotation) => {\n // Annotation bounds (image coordinates)\n const { minX, minY, maxX, maxY } = annotation.target.selector.geometry.bounds;\n\n // Annotation coordinates - viewer element coordinates\n const topLeft = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(minX, minY));\n const bottomRight = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(maxX, maxY));\n\n // Account for viewer element offset\n return {\n x: topLeft.x,\n right: bottomRight.x,\n y: topLeft.y, \n bottom: bottomRight.y,\n width: bottomRight.x - topLeft.x,\n height: bottomRight.y - topLeft.y,\n };\n}\n\nexport const setPosition = (\n viewer: OpenSeadragon.Viewer, \n annotation: ImageAnnotation, \n popup: HTMLElement,\n sideOffset: number = 5\n) => {\n const viewerBounds = viewer.element.getBoundingClientRect();\n const annoBounds = getAnnotationDomRect(viewer, annotation);\n\n // Available space above, right, below, left the annotation in the viewport\n const availableAbove = annoBounds.y - viewerBounds.y;\n const availableRight = viewerBounds.right - annoBounds.x;\n const availableBelow = viewerBounds.bottom - annoBounds.bottom;\n const availableLeft = annoBounds.x - viewerBounds.left;\n\n // Popup element bounds\n const popupBounds = popup.firstElementChild.getBoundingClientRect();\n\n // Eight possible base alignment anchor points\n //\n // topleft topright\n // * *\n // leftdown * |---------------------| * rightdown\n // | |\n // | |\n // | |\n // leftup * |---------------------| * rightup\n // * * \n // bottomleft bottomright\n //\n // We'll position the popup at the cardinal direction\n // with the highest ratio: available space vs. popup size.\n const ratioAbove = availableAbove / popupBounds.height;\n const ratioRight = availableRight / popupBounds.width;\n const ratioBelow = availableBelow / popupBounds.height;\n const ratioLeft = availableLeft / popupBounds.width;\n\n const topleft = () => {\n popup.style.left = `${annoBounds.x}px`;\n popup.style.top = `${annoBounds.y - sideOffset - popupBounds.height}px`;\n }\n\n const topright = () => {\n popup.style.left = `${annoBounds.right - popupBounds.width}px`;\n popup.style.top = `${annoBounds.y - sideOffset - popupBounds.height}px`;\n }\n\n const leftdown = () => {\n popup.style.left = `${annoBounds.x - popupBounds.width - sideOffset}px`;\n popup.style.top = `${annoBounds.y}px`;\n } \n\n const rightdown = () => {\n popup.style.left = `${annoBounds.right + sideOffset}px`;\n popup.style.top = `${annoBounds.y}px`;\n }\n\n const leftup = () => {\n popup.style.left = `${annoBounds.x - popupBounds.width - sideOffset}px`;\n popup.style.top = `${annoBounds.bottom - popupBounds.height}px`;\n }\n\n const rightup = () => {\n popup.style.left = `${annoBounds.x + annoBounds.width + sideOffset}px`;\n popup.style.top = `${annoBounds.bottom - popupBounds.height}px`;\n }\n\n const bottomleft = () => {\n popup.style.left = `${annoBounds.x}px`;\n popup.style.top = `${annoBounds.bottom + sideOffset}px`;\n }\n\n const bottomright = () => {\n popup.style.left = `${annoBounds.right - popupBounds.width}px`;\n popup.style.top = `${annoBounds.bottom + sideOffset}px`;\n }\n\n const ratios = [ratioAbove, ratioRight, ratioBelow, ratioLeft];\n const maxIdx = ratios.indexOf(Math.max(...ratios));\n\n if (maxIdx === 0) {\n // Main orientation: above\n if (ratioRight > ratioLeft)\n topleft();\n else \n topright();\n } else if (maxIdx === 1) {\n // Main orientation: right\n if (ratioAbove > ratioBelow)\n rightup();\n else\n rightdown();\n } else if (maxIdx === 2) {\n // Main orientation: below\n if (ratioRight > ratioLeft)\n bottomleft();\n else\n bottomright();\n } else {\n // Main orientation: left\n if (ratioAbove > ratioBelow)\n leftup();\n else \n leftdown();\n }\n}"],"names":["getAnnotationDomRect","viewer","annotation","minX","minY","maxX","maxY","topLeft","OpenSeadragon","bottomRight","setPosition","popup","sideOffset","viewerBounds","annoBounds","availableAbove","availableRight","availableBelow","availableLeft","popupBounds","ratioAbove","ratioRight","ratioBelow","ratioLeft","topleft","topright","leftdown","rightdown","leftup","rightup","bottomleft","bottomright","ratios","maxIdx"],"mappings":";AAGA,MAAMA,IAAuB,CAACC,GAA8BC,MAAgC;AAEpF,QAAA,EAAE,MAAAC,GAAM,MAAAC,GAAM,MAAAC,GAAM,MAAAC,MAASJ,EAAW,OAAO,SAAS,SAAS,QAGjEK,IAAUN,EAAO,SAAS,gCAAgC,IAAI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