@annotorious/react 3.0.0-rc.15 → 3.0.0-rc.16
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 +0 -8
- package/dist/Annotorious.d.ts.map +1 -1
- package/dist/annotorious-react.es.js +27 -28
- package/dist/annotorious-react.es10.js +1 -1
- package/dist/annotorious-react.es15.js +3 -3
- package/dist/annotorious-react.es16.js +21039 -2
- package/dist/annotorious-react.es16.js.map +1 -1
- package/dist/annotorious-react.es17.js +32 -30
- package/dist/annotorious-react.es17.js.map +1 -1
- package/dist/annotorious-react.es18.js +2 -599
- package/dist/annotorious-react.es18.js.map +1 -1
- package/dist/annotorious-react.es19.js +25 -21004
- package/dist/annotorious-react.es19.js.map +1 -1
- package/dist/annotorious-react.es2.js +39 -40
- package/dist/annotorious-react.es2.js.map +1 -1
- package/dist/annotorious-react.es20.js +599 -32
- package/dist/annotorious-react.es20.js.map +1 -1
- package/dist/annotorious-react.es8.js +10 -10
- package/dist/annotorious-react.es8.js.map +1 -1
- package/dist/annotorious-react.es9.js +22 -26
- package/dist/annotorious-react.es9.js.map +1 -1
- package/dist/openseadragon/OpenSeadragonAnnotator.d.ts.map +1 -1
- package/dist/openseadragon/annotorious-react-osd.es10.js +3 -3
- package/dist/openseadragon/annotorious-react-osd.es11.js +2 -153
- package/dist/openseadragon/annotorious-react-osd.es11.js.map +1 -1
- package/dist/openseadragon/annotorious-react-osd.es12.js +30 -2
- package/dist/openseadragon/annotorious-react-osd.es12.js.map +1 -1
- package/dist/openseadragon/annotorious-react-osd.es13.js +590 -21
- package/dist/openseadragon/annotorious-react-osd.es13.js.map +1 -1
- package/dist/openseadragon/annotorious-react-osd.es14.js +151 -597
- package/dist/openseadragon/annotorious-react-osd.es14.js.map +1 -1
- package/dist/openseadragon/annotorious-react-osd.es2.js +17 -17
- package/dist/openseadragon/annotorious-react-osd.es2.js.map +1 -1
- package/dist/openseadragon/annotorious-react-osd.es6.js +2374 -2344
- package/dist/openseadragon/annotorious-react-osd.es6.js.map +1 -1
- package/dist/openseadragon/annotorious-react-osd.es7.js +28 -29
- package/dist/openseadragon/annotorious-react-osd.es7.js.map +1 -1
- package/dist/openseadragon/annotorious-react-osd.es8.js +1 -1
- package/dist/openseadragon/annotorious-react-osd.es9.js +2 -2
- package/package.json +1 -1
|
@@ -1,51 +1,50 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
const
|
|
1
|
+
import { jsx as j } from "./annotorious-react-osd.es5.js";
|
|
2
|
+
import { createContext as E, forwardRef as H, useState as i, useImperativeHandle as I, useEffect as O, useContext as P } from "react";
|
|
3
|
+
const b = E({
|
|
4
4
|
anno: void 0,
|
|
5
5
|
setAnno: void 0,
|
|
6
6
|
annotations: [],
|
|
7
7
|
selection: { selected: [] }
|
|
8
8
|
});
|
|
9
|
-
|
|
10
|
-
const [
|
|
11
|
-
return
|
|
12
|
-
if (
|
|
13
|
-
const { selection: h, store: e } =
|
|
9
|
+
H((s, m) => {
|
|
10
|
+
const [n, p] = i(null), [x, l] = i([]), [S, a] = i({ selected: [] });
|
|
11
|
+
return I(m, () => n), O(() => {
|
|
12
|
+
if (n) {
|
|
13
|
+
const { selection: h, store: e } = n.state;
|
|
14
14
|
e.all().length > 0 && l(e.all());
|
|
15
|
-
const
|
|
16
|
-
e.observe(
|
|
15
|
+
const u = (r) => l(() => e.all());
|
|
16
|
+
e.observe(u);
|
|
17
17
|
let o;
|
|
18
|
-
const
|
|
18
|
+
const A = h.subscribe(({ selected: r, pointerEvent: g }) => {
|
|
19
19
|
o && e.unobserve(o);
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const { updated: c } =
|
|
23
|
-
|
|
24
|
-
selected:
|
|
25
|
-
const
|
|
26
|
-
return
|
|
20
|
+
const C = (r || []).map(({ id: t, editable: c }) => ({ annotation: e.getAnnotation(t), editable: c }));
|
|
21
|
+
a({ selected: C, pointerEvent: g }), o = (t) => {
|
|
22
|
+
const { updated: c } = t.changes;
|
|
23
|
+
a(({ selected: w }) => ({
|
|
24
|
+
selected: w.map(({ annotation: d, editable: v }) => {
|
|
25
|
+
const f = c.find((V) => V.oldValue.id === d.id);
|
|
26
|
+
return f ? { annotation: f.newValue, editable: v } : { annotation: d, editable: v };
|
|
27
27
|
})
|
|
28
28
|
}));
|
|
29
|
-
}, e.observe(o, { annotations: r.map(({ id:
|
|
29
|
+
}, e.observe(o, { annotations: r.map(({ id: t }) => t) });
|
|
30
30
|
});
|
|
31
31
|
return () => {
|
|
32
|
-
e.unobserve(
|
|
32
|
+
e.unobserve(u), A();
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
}, [
|
|
36
|
-
anno:
|
|
37
|
-
setAnno:
|
|
35
|
+
}, [n]), /* @__PURE__ */ j(b.Provider, { value: {
|
|
36
|
+
anno: n,
|
|
37
|
+
setAnno: p,
|
|
38
38
|
annotations: x,
|
|
39
|
-
selection:
|
|
39
|
+
selection: S
|
|
40
40
|
}, children: s.children });
|
|
41
41
|
});
|
|
42
|
-
const q = () =>
|
|
43
|
-
const { selection: s } =
|
|
42
|
+
const q = () => {
|
|
43
|
+
const { selection: s } = P(b);
|
|
44
44
|
return s;
|
|
45
45
|
};
|
|
46
46
|
export {
|
|
47
|
-
|
|
48
|
-
q as
|
|
49
|
-
y as useSelection
|
|
47
|
+
b as AnnotoriousContext,
|
|
48
|
+
q as useSelection
|
|
50
49
|
};
|
|
51
50
|
//# sourceMappingURL=annotorious-react-osd.es7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react-osd.es7.js","sources":["../../src/Annotorious.tsx"],"sourcesContent":["import { createContext, forwardRef, ReactNode} from 'react';\nimport { useContext, useEffect, useImperativeHandle, useState } from 'react';\nimport { Annotation, Annotator, Store, StoreChangeEvent } from '@annotorious/annotorious';\nimport { useDebounce } from './useDebounce';\n\ninterface Selection<T extends Annotation = Annotation> {\n\n selected: { annotation: T, editable?: boolean }[];\n\n pointerEvent?: PointerEvent;\n\n}\n\nexport interface AnnotoriousContextState {\n\n anno: Annotator;\n\n setAnno(anno: Annotator<Annotation, unknown>): void;\n\n annotations: Annotation[];\n\n selection: Selection;\n\n}\n\nexport const AnnotoriousContext = createContext({ \n\n anno: undefined, \n\n setAnno: undefined, \n\n annotations: [], \n\n selection: { selected: [] }\n\n});\n\nexport const Annotorious = forwardRef<Annotator, { children: ReactNode }>((props: { children: ReactNode }, ref) => {\n\n const [anno, setAnno] = useState<Annotator>(null);\n\n const [annotations, setAnnotations] = useState<Annotation[]>([]);\n\n const [selection, setSelection] = useState<Selection>({ selected: [] });\n\n useImperativeHandle(ref, () => anno);\n\n useEffect(() => {\n if (anno) {\n const { selection, store } = anno.state;\n\n // Components below <Annotorious /> may have\n // loaded annotations into the store already! \n if (store.all().length > 0)\n setAnnotations(store.all());\n\n // Keeps annotations in sync with a React state,\n // so clients can render components the usual React way.\n const onStoreChange = (event: StoreChangeEvent<Annotation>) =>\n setAnnotations(() => store.all());\n\n store.observe(onStoreChange);\n\n // Keep selection in sync with a react state, and resolve them\n // from IDs to annotations automatically, for convenience\n let selectionStoreObserver: (event: StoreChangeEvent<Annotation>) => void;\n\n const unsubscribeSelection = selection.subscribe(({ selected, pointerEvent }) => {\n if (selectionStoreObserver) \n store.unobserve(selectionStoreObserver);\n\n const resolved = (selected || [])\n .map(({ id, editable }) => ({ annotation: store.getAnnotation(id), editable }));\n\n setSelection({ selected: resolved, pointerEvent });\n\n selectionStoreObserver = event => {\n const { updated } = event.changes;\n\n setSelection(({ selected }) => ({\n selected: selected.map(({ annotation, editable }) => {\n const next = updated.find(u => u.oldValue.id === annotation.id);\n return next ? { annotation: next.newValue, editable } : { annotation, editable };\n })\n }));\n }\n\n store.observe(selectionStoreObserver, { annotations: selected.map(({ id }) => id) });\n });\n\n return () => {\n store.unobserve(onStoreChange);\n unsubscribeSelection();\n }\n }\n }, [anno]);\n\n return (\n <AnnotoriousContext.Provider value={{ \n anno, \n setAnno,\n annotations, \n selection \n }}>\n {props.children}\n </AnnotoriousContext.Provider>\n )\n\n});\n\nexport const
|
|
1
|
+
{"version":3,"file":"annotorious-react-osd.es7.js","sources":["../../src/Annotorious.tsx"],"sourcesContent":["import { createContext, forwardRef, ReactNode} from 'react';\nimport { useContext, useEffect, useImperativeHandle, useState } from 'react';\nimport { Annotation, Annotator, Store, StoreChangeEvent } from '@annotorious/annotorious';\nimport { useDebounce } from './useDebounce';\n\ninterface Selection<T extends Annotation = Annotation> {\n\n selected: { annotation: T, editable?: boolean }[];\n\n pointerEvent?: PointerEvent;\n\n}\n\nexport interface AnnotoriousContextState {\n\n anno: Annotator;\n\n setAnno(anno: Annotator<Annotation, unknown>): void;\n\n annotations: Annotation[];\n\n selection: Selection;\n\n}\n\nexport const AnnotoriousContext = createContext({ \n\n anno: undefined, \n\n setAnno: undefined, \n\n annotations: [], \n\n selection: { selected: [] }\n\n});\n\nexport const Annotorious = forwardRef<Annotator, { children: ReactNode }>((props: { children: ReactNode }, ref) => {\n\n const [anno, setAnno] = useState<Annotator>(null);\n\n const [annotations, setAnnotations] = useState<Annotation[]>([]);\n\n const [selection, setSelection] = useState<Selection>({ selected: [] });\n\n useImperativeHandle(ref, () => anno);\n\n useEffect(() => {\n if (anno) {\n const { selection, store } = anno.state;\n\n // Components below <Annotorious /> may have\n // loaded annotations into the store already! \n if (store.all().length > 0)\n setAnnotations(store.all());\n\n // Keeps annotations in sync with a React state,\n // so clients can render components the usual React way.\n const onStoreChange = (event: StoreChangeEvent<Annotation>) =>\n setAnnotations(() => store.all());\n\n store.observe(onStoreChange);\n\n // Keep selection in sync with a react state, and resolve them\n // from IDs to annotations automatically, for convenience\n let selectionStoreObserver: (event: StoreChangeEvent<Annotation>) => void;\n\n const unsubscribeSelection = selection.subscribe(({ selected, pointerEvent }) => {\n if (selectionStoreObserver) \n store.unobserve(selectionStoreObserver);\n\n const resolved = (selected || [])\n .map(({ id, editable }) => ({ annotation: store.getAnnotation(id), editable }));\n\n setSelection({ selected: resolved, pointerEvent });\n\n selectionStoreObserver = event => {\n const { updated } = event.changes;\n\n setSelection(({ selected }) => ({\n selected: selected.map(({ annotation, editable }) => {\n const next = updated.find(u => u.oldValue.id === annotation.id);\n return next ? { annotation: next.newValue, editable } : { annotation, editable };\n })\n }));\n }\n\n store.observe(selectionStoreObserver, { annotations: selected.map(({ id }) => id) });\n });\n\n return () => {\n store.unobserve(onStoreChange);\n unsubscribeSelection();\n }\n }\n }, [anno]);\n\n return (\n <AnnotoriousContext.Provider value={{ \n anno, \n setAnno,\n annotations, \n selection \n }}>\n {props.children}\n </AnnotoriousContext.Provider>\n )\n\n});\n\nexport const useAnnotator = <T extends Annotator<any, unknown>>() => {\n const { anno } = useContext(AnnotoriousContext);\n return anno as T;\n}\n\nexport const useAnnotationStore = <T extends Store<Annotation>>() => {\n const { anno } = useContext(AnnotoriousContext);\n return anno?.state.store as T | undefined;\n}\n\nconst _useAnnotations = <T extends Annotation>() => {\n const { annotations } = useContext(AnnotoriousContext);\n return annotations as T[];\n}\n\nconst _useAnnotationsDebouced = <T extends Annotation>(debounce: number) => {\n const { annotations } = useContext(AnnotoriousContext);\n return useDebounce(annotations, debounce) as T[];\n}\n\nexport const useAnnotations = <T extends Annotation>(debounce?: number) =>\n debounce ? _useAnnotationsDebouced<T>(debounce) : _useAnnotations<T>();\n\nexport const useSelection = <T extends Annotation>() => {\n const { selection } = useContext(AnnotoriousContext);\n return selection as Selection<T>;\n}\n\nexport const useAnnotatorUser = () => {\n const { anno } = useContext(AnnotoriousContext);\n return anno?.getUser();\n}\n\nconst _useViewportState = <T extends Annotation>() => {\n const { anno } = useContext(AnnotoriousContext);\n\n const [inViewport, setInViewport] = useState<T[]>([]);\n\n useEffect(() => {\n if (anno) {\n const { store, viewport } = anno.state;\n\n if (!viewport)\n return;\n\n // Keep viewport annotations in sync with a react state, and resolve them\n // from IDs to annotations automatically, for convenience\n let viewportStoreObserver: (event: StoreChangeEvent<T>) => void;\n\n const unsubscribeViewport = viewport.subscribe(ids => {\n if (viewportStoreObserver) \n store.unobserve(viewportStoreObserver);\n\n const resolved = ids.map(id => store.getAnnotation(id)) as T[];\n setInViewport(resolved);\n\n viewportStoreObserver = event => {\n const { updated } = event.changes;\n\n setInViewport(annotations => annotations.map(annotation => {\n const next = updated.find(u => u.oldValue.id === annotation.id);\n return next ? next.newValue : annotation;\n }));\n }\n\n store.observe(viewportStoreObserver, { annotations: ids });\n });\n\n return () => {\n unsubscribeViewport();\n }\n }\n }, [anno]);\n\n return inViewport;\n}\n\nconst _useViewportStateDebounced = <T extends Annotation>(debounce: number) => {\n const inViewport = _useViewportState();\n return useDebounce(inViewport, debounce) as T[];\n}\n\nexport const useViewportState = <T extends Annotation>(debounce?: number) =>\n debounce ? _useViewportStateDebounced<T>(debounce) : _useViewportState<T>();\n"],"names":["AnnotoriousContext","createContext","forwardRef","props","ref","anno","setAnno","useState","annotations","setAnnotations","selection","setSelection","useImperativeHandle","useEffect","store","onStoreChange","event","selectionStoreObserver","unsubscribeSelection","selected","pointerEvent","resolved","id","editable","updated","annotation","next","u","jsx","useSelection","useContext"],"mappings":";;AAyBO,MAAMA,IAAqBC,EAAc;AAAA,EAE9C,MAAM;AAAA,EAEN,SAAS;AAAA,EAET,aAAa,CAAC;AAAA,EAEd,WAAW,EAAE,UAAU,GAAG;AAE5B,CAAC;AAE0BC,EAA+C,CAACC,GAAgCC,MAAQ;AAEjH,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAoB,IAAI,GAE1C,CAACC,GAAaC,CAAc,IAAIF,EAAuB,CAAE,CAAA,GAEzD,CAACG,GAAWC,CAAY,IAAIJ,EAAoB,EAAE,UAAU,CAAC,EAAA,CAAG;AAElD,SAAAK,EAAAR,GAAK,MAAMC,CAAI,GAEnCQ,EAAU,MAAM;AACd,QAAIR,GAAM;AACR,YAAM,EAAE,WAAAK,GAAW,OAAAI,EAAA,IAAUT,EAAK;AAI9B,MAAAS,EAAM,MA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EACF,GACI,YAAM,SACV,CAAA;AAGJ,CAAC;AAyBM,MAAMmB,IAAe,MAA4B;AACtD,QAAM,EAAE,WAAAnB,EAAA,IAAcoB,EAAW9B,CAAkB;AAC5C,SAAAU;AACT;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as s } from "./annotorious-react-osd.es5.js";
|
|
2
2
|
import { forwardRef as g } from "react";
|
|
3
|
-
import { useDraggable as i } from "./annotorious-react-osd.
|
|
3
|
+
import { useDraggable as i } from "./annotorious-react-osd.es14.js";
|
|
4
4
|
const d = g((r, o) => {
|
|
5
5
|
const { children: a, className: t, onDragStart: n, onDragEnd: e } = r;
|
|
6
6
|
return i(o, { onDragStart: n, onDragEnd: e, cancel: "button, .no-drag" }), /* @__PURE__ */ s(
|
|
@@ -9,7 +9,7 @@ const L = (i, h) => {
|
|
|
9
9
|
width: x.x - s.x,
|
|
10
10
|
height: x.y - s.y
|
|
11
11
|
};
|
|
12
|
-
},
|
|
12
|
+
}, X = (i, h, e, n = 5) => {
|
|
13
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
14
|
e.style.left = `${t.x}px`, e.style.top = `${t.y - n - o.height}px`;
|
|
15
15
|
}, f = () => {
|
|
@@ -30,6 +30,6 @@ const L = (i, h) => {
|
|
|
30
30
|
m === 0 ? y > r ? $() : f() : m === 1 ? g > a ? C() : v() : m === 2 ? y > r ? A() : E() : g > a ? R() : B();
|
|
31
31
|
};
|
|
32
32
|
export {
|
|
33
|
-
|
|
33
|
+
X as setPosition
|
|
34
34
|
};
|
|
35
35
|
//# sourceMappingURL=annotorious-react-osd.es9.js.map
|