@annotorious/react 3.0.0 → 3.0.2

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 (69) hide show
  1. package/dist/Annotorious.d.ts +6 -6
  2. package/dist/Annotorious.d.ts.map +1 -1
  3. package/dist/AnnotoriousPlugin.d.ts +6 -3
  4. package/dist/AnnotoriousPlugin.d.ts.map +1 -1
  5. package/dist/ImageAnnotationPopup.d.ts +9 -0
  6. package/dist/ImageAnnotationPopup.d.ts.map +1 -0
  7. package/dist/ImageAnnotator.d.ts +2 -2
  8. package/dist/ImageAnnotator.d.ts.map +1 -1
  9. package/dist/PopupProps.d.ts +10 -0
  10. package/dist/PopupProps.d.ts.map +1 -0
  11. package/dist/annotorious-react.es.js +20 -20
  12. package/dist/annotorious-react.es.js.map +1 -1
  13. package/dist/annotorious-react.es11.js +3 -3
  14. package/dist/annotorious-react.es13.js +264 -126
  15. package/dist/annotorious-react.es13.js.map +1 -1
  16. package/dist/annotorious-react.es14.js +9 -32
  17. package/dist/annotorious-react.es14.js.map +1 -1
  18. package/dist/annotorious-react.es15.js +193 -2
  19. package/dist/annotorious-react.es15.js.map +1 -1
  20. package/dist/annotorious-react.es16.js +368 -25
  21. package/dist/annotorious-react.es16.js.map +1 -1
  22. package/dist/annotorious-react.es17.js +10 -605
  23. package/dist/annotorious-react.es17.js.map +1 -1
  24. package/dist/annotorious-react.es18.js +2 -2
  25. package/dist/annotorious-react.es19.js +26 -2
  26. package/dist/annotorious-react.es19.js.map +1 -1
  27. package/dist/annotorious-react.es2.js.map +1 -1
  28. package/dist/annotorious-react.es20.js +609 -0
  29. package/dist/annotorious-react.es20.js.map +1 -0
  30. package/dist/annotorious-react.es21.js +129 -0
  31. package/dist/annotorious-react.es21.js.map +1 -0
  32. package/dist/annotorious-react.es22.js +5 -0
  33. package/dist/annotorious-react.es22.js.map +1 -0
  34. package/dist/annotorious-react.es23.js +5 -0
  35. package/dist/annotorious-react.es23.js.map +1 -0
  36. package/dist/annotorious-react.es24.js +10 -0
  37. package/dist/annotorious-react.es24.js.map +1 -0
  38. package/dist/annotorious-react.es25.js +8 -0
  39. package/dist/annotorious-react.es25.js.map +1 -0
  40. package/dist/annotorious-react.es26.js +10 -0
  41. package/dist/annotorious-react.es26.js.map +1 -0
  42. package/dist/annotorious-react.es27.js +129 -0
  43. package/dist/annotorious-react.es27.js.map +1 -0
  44. package/dist/annotorious-react.es28.js +466 -0
  45. package/dist/annotorious-react.es28.js.map +1 -0
  46. package/dist/annotorious-react.es3.js +12 -12
  47. package/dist/annotorious-react.es3.js.map +1 -1
  48. package/dist/annotorious-react.es4.js +96 -12
  49. package/dist/annotorious-react.es4.js.map +1 -1
  50. package/dist/annotorious-react.es5.js +15 -13
  51. package/dist/annotorious-react.es5.js.map +1 -1
  52. package/dist/annotorious-react.es8.js.map +1 -1
  53. package/dist/annotorious-react.es9.js +105 -32
  54. package/dist/annotorious-react.es9.js.map +1 -1
  55. package/dist/index.d.ts +3 -2
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/openseadragon/OpenSeadragonAnnotationPopup.d.ts +9 -0
  58. package/dist/openseadragon/OpenSeadragonAnnotationPopup.d.ts.map +1 -0
  59. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts +5 -6
  60. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts.map +1 -1
  61. package/dist/openseadragon/index.d.ts +1 -1
  62. package/dist/openseadragon/index.d.ts.map +1 -1
  63. package/dist/utils/toClientRects.d.ts +6 -0
  64. package/dist/utils/toClientRects.d.ts.map +1 -0
  65. package/package.json +7 -7
  66. package/dist/AnnotoriousPopup.d.ts +0 -16
  67. package/dist/AnnotoriousPopup.d.ts.map +0 -1
  68. package/dist/openseadragon/OpenSeadragonPopup.d.ts +0 -11
  69. package/dist/openseadragon/OpenSeadragonPopup.d.ts.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { StoreObserveOptions, UserSelectActionExpression } from '@annotorious/core';
2
2
  import { ReactNode } from 'react';
3
- import { Annotation, Annotator, Selection as CoreSelection, Store, User } from '@annotorious/annotorious';
3
+ import { Annotation, Annotator, Selection as CoreSelection, ImageAnnotation, Store, User } from '@annotorious/annotorious';
4
4
  interface Selection<T extends Annotation = Annotation> extends Omit<CoreSelection, 'selected'> {
5
5
  selected: {
6
6
  annotation: T;
@@ -20,11 +20,11 @@ export declare const Annotorious: import('react').ForwardRefExoticComponent<{
20
20
  } & import('react').RefAttributes<Annotator<Annotation, Annotation>>>;
21
21
  export declare const useAnnotator: <T extends unknown = Annotator<any, unknown>>() => T;
22
22
  export declare const useAnnotationStore: <T extends unknown = Store<Annotation>>() => T | undefined;
23
- export declare const useAnnotations: <T extends Annotation>(debounce?: number) => T[];
24
- export declare const useAnnotation: <T extends Annotation>(id: string, options?: Omit<StoreObserveOptions, "annotations">) => T;
25
- export declare const useAnnotationSelectAction: <T extends Annotation>(id: string, action: UserSelectActionExpression<T>) => import('@annotorious/core').UserSelectAction;
26
- export declare const useSelection: <T extends Annotation>() => Selection<T>;
23
+ export declare const useAnnotations: <T extends Annotation = ImageAnnotation>(debounce?: number) => T[];
24
+ export declare const useAnnotation: <T extends Annotation = ImageAnnotation>(id: string, options?: Omit<StoreObserveOptions, "annotations">) => T;
25
+ export declare const useAnnotationSelectAction: <T extends Annotation = ImageAnnotation>(id: string, action: UserSelectActionExpression<T>) => import('@annotorious/core').UserSelectAction;
26
+ export declare const useSelection: <T extends Annotation = ImageAnnotation>() => Selection<T>;
27
27
  export declare const useAnnotatorUser: () => User;
28
- export declare const useViewportState: <T extends Annotation>(debounce?: number) => T[];
28
+ export declare const useViewportState: <T extends Annotation = ImageAnnotation>(debounce?: number) => T[];
29
29
  export {};
30
30
  //# sourceMappingURL=Annotorious.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Annotorious.d.ts","sourceRoot":"","sources":["../src/Annotorious.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,0BAA0B,EAAC,MAAM,mBAAmB,CAAC;AAExF,OAAO,EAGL,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,SAAS,IAAI,aAAa,EAC1B,KAAK,EAEL,IAAI,EACL,MAAM,0BAA0B,CAAC;AAElC,UAAU,SAAS,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,CAAE,SAAQ,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC;IAE5F,QAAQ,EAAE;QAAE,UAAU,EAAE,CAAC,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CAEnD;AAED,eAAO,MAAM,kBAAkB;;;;;;;EAU7B,CAAC;AAEH,eAAO,MAAM,WAAW;cAAqC,SAAS;qEAuEpE,CAAC;AAEH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,OAAO,iCAE7B,CAChB,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,OAAO,2BAEtB,CAAC,GAAG,SACjC,CAAA;AAYD,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,UAAU,aAAa,MAAM,QACG,CAAC;AAE1E,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,MAAM,MAAM,YAAY,IAAI,CAAC,mBAAmB,EAAE,aAAa,CAAC,MAsBjH,CAAA;AAED,eAAO,MAAM,yBAAyB,GAAI,CAAC,SAAS,UAAU,MAAM,MAAM,UAAU,0BAA0B,CAAC,CAAC,CAAC,iDAGhH,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,UAAU,OAE3B,SAAS,CAAC,CAAC,CAChC,CAAA;AAED,eAAO,MAAM,gBAAgB,QAAO,IAGnC,CAAA;AAmDD,eAAO,MAAM,gBAAgB,GAAK,CAAC,SAAS,UAAU,aAAa,MAAM,QACI,CAAC"}
1
+ {"version":3,"file":"Annotorious.d.ts","sourceRoot":"","sources":["../src/Annotorious.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,0BAA0B,EAAC,MAAM,mBAAmB,CAAC;AAExF,OAAO,EAGL,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,SAAS,IAAI,aAAa,EAC1B,eAAe,EACf,KAAK,EAEL,IAAI,EACL,MAAM,0BAA0B,CAAC;AAElC,UAAU,SAAS,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,CAAE,SAAQ,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC;IAE5F,QAAQ,EAAE;QAAE,UAAU,EAAE,CAAC,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CAEnD;AAED,eAAO,MAAM,kBAAkB;;;;;;;EAU7B,CAAC;AAEH,eAAO,MAAM,WAAW;cAAqC,SAAS;qEAuEpE,CAAC;AAEH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,OAAO,iCAE7B,CAChB,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,OAAO,2BAEtB,CAAC,GAAG,SACjC,CAAA;AAYD,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,UAAU,+BAA+B,MAAM,QACf,CAAC;AAE1E,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,wBAC5C,MAAM,YACA,IAAI,CAAC,mBAAmB,EAAE,aAAa,CAAC,MAuBnD,CAAA;AAED,eAAO,MAAM,yBAAyB,GAAI,CAAC,SAAS,UAAU,wBAAwB,MAAM,UAAU,0BAA0B,CAAC,CAAC,CAAC,iDAGlI,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,UAAU,yBAE3B,SAAS,CAAC,CAAC,CAChC,CAAA;AAED,eAAO,MAAM,gBAAgB,QAAO,IAGnC,CAAA;AAmDD,eAAO,MAAM,gBAAgB,GAAK,CAAC,SAAS,UAAU,+BAA+B,MAAM,QACd,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { MutableRefObject } from 'react';
1
2
  import { Annotator } from '@annotorious/annotorious';
2
3
  export type AnnotatorPlugin<T extends unknown = Annotator<any, unknown>> = (anno: T, opts?: Object) => ({
3
4
  unmount?: () => void;
@@ -6,7 +7,9 @@ export interface AnnotoriousPluginProps<T extends unknown = Annotator<any, unkno
6
7
  plugin: AnnotatorPlugin<T>;
7
8
  opts?: Object;
8
9
  }
9
- export declare const AnnotoriousPlugin: import('react').ForwardRefExoticComponent<AnnotoriousPluginProps<unknown> & import('react').RefAttributes<void | {
10
- unmount?: () => void;
11
- }>>;
10
+ type PluginReturnType<T> = ReturnType<AnnotatorPlugin<T>>;
11
+ export declare const AnnotoriousPlugin: <T extends unknown = Annotator<any, unknown>>(props: AnnotoriousPluginProps<T> & {
12
+ ref?: MutableRefObject<PluginReturnType<T>>;
13
+ }) => any;
14
+ export {};
12
15
  //# sourceMappingURL=AnnotoriousPlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnnotoriousPlugin.d.ts","sourceRoot":"","sources":["../src/AnnotoriousPlugin.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAGrD,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,IACrE,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC,GAAG,IAAI,CAAC;AAEhE,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,OAAO,GAAG,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC;IAEjF,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAE3B,IAAI,CAAC,EAAE,MAAM,CAAC;CAEf;AAID,eAAO,MAAM,iBAAiB;cAZa,MAAM,IAAI;GAwCnD,CAAC"}
1
+ {"version":3,"file":"AnnotoriousPlugin.d.ts","sourceRoot":"","sources":["../src/AnnotoriousPlugin.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyB,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAGrD,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,IACrE,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC,GAAG,IAAI,CAAC;AAEhE,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,OAAO,GAAG,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC;IAEjF,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAE3B,IAAI,CAAC,EAAE,MAAM,CAAC;CAEf;AAED,KAAK,gBAAgB,CAAC,CAAC,IAAI,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1D,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,OAAO,mCAC1C,sBAAsB,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAA;CAAE,QA0BnF,CAAA"}
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ import { PopupProps } from './PopupProps';
3
+ interface ImageAnnotationPopupProps {
4
+ arrow?: boolean;
5
+ popup: (props: PopupProps) => ReactNode;
6
+ }
7
+ export declare const ImageAnnotationPopup: (props: ImageAnnotationPopupProps) => import("react/jsx-runtime").JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=ImageAnnotationPopup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageAnnotationPopup.d.ts","sourceRoot":"","sources":["../src/ImageAnnotationPopup.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAc/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAsB1C,UAAU,yBAAyB;IAEjC,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,KAAK,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,SAAS,CAAC;CAEzC;AAED,eAAO,MAAM,oBAAoB,UAAW,yBAAyB,4CA+GpE,CAAA"}
@@ -1,9 +1,9 @@
1
1
  import { ReactElement } from 'react';
2
- import { AnnotoriousOpts, DrawingStyle, DrawingTool, Filter, ImageAnnotation } from '@annotorious/annotorious';
2
+ import { AnnotoriousOpts, DrawingTool, Filter, ImageAnnotation } from '@annotorious/annotorious';
3
3
  export interface ImageAnnotatorProps<E extends unknown> extends AnnotoriousOpts<ImageAnnotation, E> {
4
4
  children: ReactElement<HTMLImageElement>;
5
+ containerClassName?: string;
5
6
  filter?: Filter<ImageAnnotation>;
6
- style?: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle);
7
7
  tool?: DrawingTool;
8
8
  }
9
9
  export declare const ImageAnnotator: <E extends unknown>(props: ImageAnnotatorProps<E>) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"ImageAnnotator.d.ts","sourceRoot":"","sources":["../src/ImageAnnotator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,YAAY,EAAuC,MAAM,OAAO,CAAC;AACpF,OAAO,EAAE,eAAe,EAAwB,MAAM,0BAA0B,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGnG,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,OAAO,CAAE,SAAQ,eAAe,CAAC,eAAe,EAAE,CAAC,CAAC;IAEjG,QAAQ,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAEzC,MAAM,CAAC,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;IAEjC,KAAK,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,UAAU,EAAE,eAAe,KAAK,YAAY,CAAC,CAAC;IAEvE,IAAI,CAAC,EAAE,WAAW,CAAC;CAEpB;AAED,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,OAAO,SAAS,mBAAmB,CAAC,CAAC,CAAC,4CAmC9E,CAAA"}
1
+ {"version":3,"file":"ImageAnnotator.d.ts","sourceRoot":"","sources":["../src/ImageAnnotator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,YAAY,EAAuC,MAAM,OAAO,CAAC;AACpF,OAAO,EAAE,eAAe,EAAwB,MAAM,0BAA0B,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGrF,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,OAAO,CAAE,SAAQ,eAAe,CAAC,eAAe,EAAE,CAAC,CAAC;IAEjG,QAAQ,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAEzC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,MAAM,CAAC,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;IAEjC,IAAI,CAAC,EAAE,WAAW,CAAC;CAEpB;AAED,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,OAAO,SAAS,mBAAmB,CAAC,CAAC,CAAC,4CAwC9E,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { AnnotationBody, ImageAnnotation } from '@annotorious/annotorious';
2
+ export interface PopupProps {
3
+ annotation: ImageAnnotation;
4
+ editable?: boolean;
5
+ event?: PointerEvent;
6
+ onCreateBody(body: AnnotationBody): void;
7
+ onDeleteBody(id: string): void;
8
+ onUpdateBody(current: AnnotationBody, next: AnnotationBody): void;
9
+ }
10
+ //# sourceMappingURL=PopupProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PopupProps.d.ts","sourceRoot":"","sources":["../src/PopupProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3E,MAAM,WAAW,UAAU;IAEzB,UAAU,EAAE,eAAe,CAAC;IAE5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,KAAK,CAAC,EAAE,YAAY,CAAC;IAErB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IAEzC,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;CAEnE"}
@@ -1,24 +1,24 @@
1
- import { Annotorious as A, AnnotoriousContext as g, useAnnotation as c, useAnnotationSelectAction as S, useAnnotationStore as f, useAnnotations as x, useAnnotator as l, useAnnotatorUser as I, useSelection as d, useViewportState as y } from "./annotorious-react.es2.js";
1
+ import { Annotorious as u, AnnotoriousContext as c, useAnnotation as g, useAnnotationSelectAction as S, useAnnotationStore as f, useAnnotations as x, useAnnotator as I, useAnnotatorUser as d, useSelection as l, useViewportState as y } from "./annotorious-react.es2.js";
2
2
  import { AnnotoriousPlugin as O } from "./annotorious-react.es3.js";
3
- import { Draggable as w } from "./annotorious-react.es4.js";
4
- import { ImageAnnotator as P } from "./annotorious-react.es5.js";
3
+ import { ImageAnnotationPopup as h } from "./annotorious-react.es4.js";
4
+ import { ImageAnnotator as F } from "./annotorious-react.es5.js";
5
5
  /* empty css */
6
6
  /* empty css */
7
- import { Origin as V, UserSelectAction as W, createAnonymousGuest as $, createBody as U, defaultColorProvider as b } from "@annotorious/core";
7
+ import { Origin as V, UserSelectAction as W, createAnonymousGuest as $, createBody as U, defaultColorProvider as v } from "@annotorious/core";
8
8
  import { createImageAnnotator as o, ShapeType as e, W3CImageFormat as t } from "@annotorious/annotorious";
9
- import { OpenSeadragonAnnotator as B, useViewer as D } from "./annotorious-react.es8.js";
10
- import { OpenSeadragonPopup as j } from "./annotorious-react.es9.js";
11
- import { OpenSeadragonViewer as q } from "./annotorious-react.es10.js";
9
+ import { OpenSeadragonAnnotator as G, useViewer as b } from "./annotorious-react.es8.js";
10
+ import { OpenSeadragonAnnotationPopup as k } from "./annotorious-react.es9.js";
11
+ import { OpenSeadragonViewer as z } from "./annotorious-react.es10.js";
12
12
  const p = o, m = e, s = t;
13
13
  export {
14
- A as Annotorious,
15
- g as AnnotoriousContext,
14
+ u as Annotorious,
15
+ c as AnnotoriousContext,
16
16
  O as AnnotoriousPlugin,
17
- w as Draggable,
18
- P as ImageAnnotator,
19
- B as OpenSeadragonAnnotator,
20
- j as OpenSeadragonPopup,
21
- q as OpenSeadragonViewer,
17
+ h as ImageAnnotationPopup,
18
+ F as ImageAnnotator,
19
+ k as OpenSeadragonAnnotationPopup,
20
+ G as OpenSeadragonAnnotator,
21
+ z as OpenSeadragonViewer,
22
22
  V as Origin,
23
23
  m as ShapeType,
24
24
  W as UserSelectAction,
@@ -26,15 +26,15 @@ export {
26
26
  $ as createAnonymousGuest,
27
27
  U as createBody,
28
28
  p as createImageAnnotator,
29
- b as defaultColorProvider,
30
- c as useAnnotation,
29
+ v as defaultColorProvider,
30
+ g as useAnnotation,
31
31
  S as useAnnotationSelectAction,
32
32
  f as useAnnotationStore,
33
33
  x as useAnnotations,
34
- l as useAnnotator,
35
- I as useAnnotatorUser,
36
- d as useSelection,
37
- D as useViewer,
34
+ I as useAnnotator,
35
+ d as useAnnotatorUser,
36
+ l as useSelection,
37
+ b as useViewer,
38
38
  y as useViewportState
39
39
  };
40
40
  //# 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 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 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 UserSelectAction as _UserSelectAction\n} from '@annotorious/core';\n\nexport { _createAnonymousGuest as createAnonymousGuest };\nexport { _createBody as createBody };\nexport { _defaultColorProvider as defaultColorProvider };\nexport { _Origin as Origin };\nexport { _UserSelectAction as UserSelectAction };\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 W3CImageFormatAdapter, \n W3CImageFormatAdapterOpts\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":";;;;;;;;;;;AAkFO,MAAMA,IAAuBC,GACvBC,IAAYC,GACZC,IAAiBC;"}
1
+ {"version":3,"file":"annotorious-react.es.js","sources":["../src/index.ts"],"sourcesContent":["export * from './Annotorious';\nexport * from './AnnotoriousPlugin';\nexport * from './ImageAnnotationPopup';\nexport * from './ImageAnnotator';\nexport * from './PopupProps';\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 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 UserSelectAction as _UserSelectAction\n} from '@annotorious/core';\n\nexport { _createAnonymousGuest as createAnonymousGuest };\nexport { _createBody as createBody };\nexport { _defaultColorProvider as defaultColorProvider };\nexport { _Origin as Origin };\nexport { _UserSelectAction as UserSelectAction };\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 W3CImageFormatAdapter, \n W3CImageFormatAdapterOpts\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":";;;;;;;;;;;AAmFO,MAAMA,IAAuBC,GACvBC,IAAYC,GACZC,IAAiBC;"}
@@ -1,6 +1,6 @@
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";
1
+ import { __module as e } from "./annotorious-react.es18.js";
2
+ import { __require as r } from "./annotorious-react.es19.js";
3
+ import { __require as o } from "./annotorious-react.es20.js";
4
4
  process.env.NODE_ENV === "production" ? e.exports = r() : e.exports = o();
5
5
  var m = e.exports;
6
6
  export {
@@ -1,137 +1,275 @@
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" : ""}`);
1
+ import * as o from "react";
2
+ import { useLayoutEffect as Y, useEffect as q } from "react";
3
+ import { getComputedStyle as Q, isElement as I } from "./annotorious-react.es21.js";
4
+ import { getOverflowAncestors as Re } from "./annotorious-react.es21.js";
5
+ import "react-dom";
6
+ import { useFloating as Z } from "./annotorious-react.es15.js";
7
+ import { arrow as xe, flip as Ee, inline as we, offset as Ce, shift as Se } from "./annotorious-react.es15.js";
8
+ const W = {
9
+ ...o
10
+ }, z = W.useInsertionEffect, G = z || ((t) => t());
11
+ function J(t) {
12
+ const n = o.useRef(() => {
13
+ if (process.env.NODE_ENV !== "production")
14
+ throw new Error("Cannot call an event handler while rendering.");
15
+ });
16
+ return G(() => {
17
+ n.current = t;
18
+ }), o.useCallback(function() {
19
+ for (var s = arguments.length, e = new Array(s), r = 0; r < s; r++)
20
+ e[r] = arguments[r];
21
+ return n.current == null ? void 0 : n.current(...e);
22
+ }, []);
23
+ }
24
+ var b = typeof document < "u" ? Y : q;
25
+ function D() {
26
+ return D = Object.assign ? Object.assign.bind() : function(t) {
27
+ for (var n = 1; n < arguments.length; n++) {
28
+ var s = arguments[n];
29
+ for (var e in s)
30
+ Object.prototype.hasOwnProperty.call(s, e) && (t[e] = s[e]);
16
31
  }
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) return;
31
- if (k.add(n.pointerId), B && k.size > 1) return n.preventDefault();
32
- if (b.dragStart && (y = Z(c, e)), V(S) && V(D) && S === D) throw new Error("`handle` selector can't be same as `cancel` selector");
33
- if (v.add(E), X = function(r, h) {
34
- if (!r) return [h];
35
- if (_(r)) return [r];
36
- if (Array.isArray(r)) return r;
37
- const w = h.querySelectorAll(r);
38
- if (w === null) throw new Error("Selector passed for `handle` option should be child of the element on which the action is applied");
39
- return Array.from(w.values());
40
- }(S, e), F = function(r, h) {
41
- if (!r) return [];
42
- if (_(r)) return [r];
43
- if (Array.isArray(r)) return r;
44
- const w = h.querySelectorAll(r);
45
- if (w === null) throw new Error("Selector passed for `cancel` option should be child of the element on which the action is applied");
46
- return Array.from(w.values());
47
- }(D, e), o = /(both|x)/.test(m), l = /(both|y)/.test(m), le(F, X)) throw new Error("Element being dragged can't be a child of the element on which `cancel` is applied");
48
- const a = n.composedPath()[0];
49
- if (!X.some((r) => {
50
- var h;
51
- return r.contains(a) || ((h = r.shadowRoot) == null ? void 0 : h.contains(a));
52
- }) || le(F, [a])) return;
53
- 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);
54
- const { clientX: s, clientY: d } = n, p = re();
55
- o && (L = s - q / p), l && (T = d - P / p), y && (W = s - C.left, j = d - C.top);
32
+ return t;
33
+ }, D.apply(this, arguments);
34
+ }
35
+ let V = !1, K = 0;
36
+ const j = () => (
37
+ // Ensure the id is unique with multiple independent versions of Floating UI
38
+ // on <React 18
39
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + K++
40
+ );
41
+ function k() {
42
+ const [t, n] = o.useState(() => V ? j() : void 0);
43
+ return b(() => {
44
+ t == null && n(j());
45
+ }, []), o.useEffect(() => {
46
+ V = !0;
47
+ }, []), t;
48
+ }
49
+ const _ = W.useId, $ = _ || k;
50
+ let P;
51
+ process.env.NODE_ENV !== "production" && (P = /* @__PURE__ */ new Set());
52
+ function ee() {
53
+ for (var t, n = arguments.length, s = new Array(n), e = 0; e < n; e++)
54
+ s[e] = arguments[e];
55
+ const r = "Floating UI: " + s.join(" ");
56
+ if (!((t = P) != null && t.has(r))) {
57
+ var l;
58
+ (l = P) == null || l.add(r), console.warn(r);
56
59
  }
57
- function oe(n) {
58
- 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);
60
+ }
61
+ function te() {
62
+ for (var t, n = arguments.length, s = new Array(n), e = 0; e < n; e++)
63
+ s[e] = arguments[e];
64
+ const r = "Floating UI: " + s.join(" ");
65
+ if (!((t = P) != null && t.has(r))) {
66
+ var l;
67
+ (l = P) == null || l.add(r), console.error(r);
59
68
  }
60
- function ae(n) {
61
- if (!Y || B && k.size > 1) return;
62
- b.drag && (y = Z(c, e)), v.add(i), n.preventDefault(), C = e.getBoundingClientRect();
63
- let a = n.clientX, s = n.clientY;
64
- const d = re();
65
- if (y) {
66
- const p = { left: y.left + W, top: y.top + j, right: y.right + W - C.width, bottom: y.bottom + j - C.height };
67
- a = de(a, p.left, p.right), s = de(s, p.top, p.bottom);
69
+ }
70
+ const me = /* @__PURE__ */ o.forwardRef(function(n, s) {
71
+ const {
72
+ context: {
73
+ placement: e,
74
+ elements: {
75
+ floating: r
76
+ },
77
+ middlewareData: {
78
+ arrow: l,
79
+ shift: u
80
+ }
81
+ },
82
+ width: i = 14,
83
+ height: a = 7,
84
+ tipRadius: O = 0,
85
+ strokeWidth: d = 0,
86
+ staticOffset: p,
87
+ stroke: h,
88
+ d: c,
89
+ style: {
90
+ transform: m,
91
+ ...R
92
+ } = {},
93
+ ...v
94
+ } = n;
95
+ process.env.NODE_ENV !== "production" && (s || ee("The `ref` prop is required for `FloatingArrow`."));
96
+ const x = $(), [C, f] = o.useState(!1);
97
+ if (b(() => {
98
+ if (!r) return;
99
+ Q(r).direction === "rtl" && f(!0);
100
+ }, [r]), !r)
101
+ return null;
102
+ const [g, F] = e.split("-"), M = g === "top" || g === "bottom";
103
+ let S = p;
104
+ (M && u != null && u.x || !M && u != null && u.y) && (S = null);
105
+ const E = d * 2, N = E / 2, A = i / 2 * (O / -8 + 1), T = a / 2 * O / 4, w = !!c, B = S && F === "end" ? "bottom" : "top";
106
+ let y = S && F === "end" ? "right" : "left";
107
+ S && C && (y = F === "end" ? "left" : "right");
108
+ const U = (l == null ? void 0 : l.x) != null ? S || l.x : "", H = (l == null ? void 0 : l.y) != null ? S || l.y : "", L = c || "M0,0" + (" H" + i) + (" L" + (i - A) + "," + (a - T)) + (" Q" + i / 2 + "," + a + " " + A + "," + (a - T)) + " Z", X = {
109
+ top: w ? "rotate(180deg)" : "",
110
+ left: w ? "rotate(90deg)" : "rotate(-90deg)",
111
+ bottom: w ? "" : "rotate(180deg)",
112
+ right: w ? "rotate(-90deg)" : "rotate(90deg)"
113
+ }[g];
114
+ return /* @__PURE__ */ o.createElement("svg", D({}, v, {
115
+ "aria-hidden": !0,
116
+ ref: s,
117
+ width: w ? i : i + E,
118
+ height: i,
119
+ viewBox: "0 0 " + i + " " + (a > i ? a : i),
120
+ style: {
121
+ position: "absolute",
122
+ pointerEvents: "none",
123
+ [y]: U,
124
+ [B]: H,
125
+ [g]: M || w ? "100%" : "calc(100% - " + E / 2 + "px)",
126
+ transform: "" + X + (m ?? ""),
127
+ ...R
68
128
  }
69
- if (Array.isArray(H)) {
70
- let [p, r] = H;
71
- if (isNaN(+p) || p < 0) throw new Error("1st argument of `grid` must be a valid positive number");
72
- if (isNaN(+r) || r < 0) throw new Error("2nd argument of `grid` must be a valid positive number");
73
- let h = a - L, w = s - T;
74
- [h, w] = me([p / d, r / d], h, w), a = L + h, s = T + w;
129
+ }), E > 0 && /* @__PURE__ */ o.createElement("path", {
130
+ clipPath: "url(#" + x + ")",
131
+ fill: "none",
132
+ stroke: h,
133
+ strokeWidth: E + (c ? 0 : 1),
134
+ d: L
135
+ }), /* @__PURE__ */ o.createElement("path", {
136
+ stroke: E && !c ? v.fill : "none",
137
+ d: L
138
+ }), /* @__PURE__ */ o.createElement("clipPath", {
139
+ id: x
140
+ }, /* @__PURE__ */ o.createElement("rect", {
141
+ x: -N,
142
+ y: N * (w ? -1 : 1),
143
+ width: i + E,
144
+ height: i
145
+ })));
146
+ });
147
+ function ne() {
148
+ const t = /* @__PURE__ */ new Map();
149
+ return {
150
+ emit(n, s) {
151
+ var e;
152
+ (e = t.get(n)) == null || e.forEach((r) => r(s));
153
+ },
154
+ on(n, s) {
155
+ t.set(n, [...t.get(n) || [], s]);
156
+ },
157
+ off(n, s) {
158
+ var e;
159
+ t.set(n, ((e = t.get(n)) == null ? void 0 : e.filter((r) => r !== s)) || []);
75
160
  }
76
- o && (x = Math.round((a - L) * d)), l && (A = Math.round((s - T) * d)), q = x, P = A, K("neodrag", ue), J();
77
- }
78
- return { destroy: () => {
79
- const n = removeEventListener;
80
- n("pointerdown", te, !1), n("pointerup", oe, !1), n("pointermove", ae, !1);
81
- }, update: (n) => {
82
- var s, d;
83
- 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;
84
- const a = v.contains(g);
85
- 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());
86
- } };
87
- }, de = (e, t, o) => Math.min(Math.max(e, t), o), V = (e) => typeof e == "string", me = ([e, t], o, l) => {
88
- const c = (m, f) => f === 0 ? 0 : Math.ceil(m / f) * f;
89
- return [c(o, e), c(l, t)];
90
- }, le = (e, t) => e.some((o) => t.some((l) => o.contains(l)));
91
- function Z(e, t) {
92
- if (e === void 0) return;
93
- if (_(e)) return e.getBoundingClientRect();
94
- if (typeof e == "object") {
95
- const { top: l = 0, left: c = 0, right: m = 0, bottom: f = 0 } = e;
96
- return { top: l, right: window.innerWidth - m, bottom: window.innerHeight - f, left: c };
97
- }
98
- if (e === "parent") return t.parentNode.getBoundingClientRect();
99
- const o = document.querySelector(e);
100
- if (o === null) throw new Error("The selector provided for bound doesn't exists in the document.");
101
- return o.getBoundingClientRect();
102
- }
103
- var z = (e, t, o) => e.style.setProperty(t, o), _ = (e) => e instanceof HTMLElement;
104
- function I(e) {
105
- 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;
161
+ };
106
162
  }
107
- function we(e, t = {}) {
108
- const o = pe(), [l, c] = ie(!1), [m, f] = ie();
109
- let { onDragStart: R, onDrag: M, onDragEnd: N, handle: $, cancel: B } = t, b = I($), H = I(B);
110
- function u(i, g) {
111
- f(i), g == null || g(i);
112
- }
113
- function D(i) {
114
- c(!0), u(i, R);
115
- }
116
- function S(i) {
117
- u(i, M);
163
+ const oe = /* @__PURE__ */ o.createContext(null), re = /* @__PURE__ */ o.createContext(null), se = () => {
164
+ var t;
165
+ return ((t = o.useContext(oe)) == null ? void 0 : t.id) || null;
166
+ }, ce = () => o.useContext(re);
167
+ function le(t) {
168
+ const {
169
+ open: n = !1,
170
+ onOpenChange: s,
171
+ elements: e
172
+ } = t, r = $(), l = o.useRef({}), [u] = o.useState(() => ne()), i = se() != null;
173
+ if (process.env.NODE_ENV !== "production") {
174
+ const c = e.reference;
175
+ c && !I(c) && te("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
118
176
  }
119
- function E(i) {
120
- c(!1), u(i, N);
121
- }
122
- return se(() => {
123
- if (typeof window > "u") return;
124
- const i = e.current;
125
- if (!i) return;
126
- ({ onDragStart: R, onDrag: M, onDragEnd: N } = t);
127
- const { update: g, destroy: U } = he(i, { ...t, handle: b, cancel: H, onDragStart: D, onDrag: S, onDragEnd: E });
128
- return o.current = g, U;
129
- }, []), se(() => {
130
- var i;
131
- (i = o.current) == null || i.call(o, { ...t, handle: I($), cancel: I(B), onDragStart: D, onDrag: S, onDragEnd: E });
132
- }, [t]), { isDragging: l, dragState: m };
177
+ const [a, O] = o.useState(e.reference), d = J((c, m, R) => {
178
+ l.current.openEvent = c ? m : void 0, u.emit("openchange", {
179
+ open: c,
180
+ event: m,
181
+ reason: R,
182
+ nested: i
183
+ }), s == null || s(c, m, R);
184
+ }), p = o.useMemo(() => ({
185
+ setPositionReference: O
186
+ }), []), h = o.useMemo(() => ({
187
+ reference: a || e.reference || null,
188
+ floating: e.floating || null,
189
+ domReference: e.reference
190
+ }), [a, e.reference, e.floating]);
191
+ return o.useMemo(() => ({
192
+ dataRef: l,
193
+ open: n,
194
+ onOpenChange: d,
195
+ elements: h,
196
+ events: u,
197
+ floatingId: r,
198
+ refs: p
199
+ }), [n, d, h, u, r, p]);
200
+ }
201
+ function ge(t) {
202
+ t === void 0 && (t = {});
203
+ const {
204
+ nodeId: n
205
+ } = t, s = le({
206
+ ...t,
207
+ elements: {
208
+ reference: null,
209
+ floating: null,
210
+ ...t.elements
211
+ }
212
+ }), e = t.rootContext || s, r = e.elements, [l, u] = o.useState(null), [i, a] = o.useState(null), d = (r == null ? void 0 : r.reference) || l, p = o.useRef(null), h = ce();
213
+ b(() => {
214
+ d && (p.current = d);
215
+ }, [d]);
216
+ const c = Z({
217
+ ...t,
218
+ elements: {
219
+ ...r,
220
+ ...i && {
221
+ reference: i
222
+ }
223
+ }
224
+ }), m = o.useCallback((f) => {
225
+ const g = I(f) ? {
226
+ getBoundingClientRect: () => f.getBoundingClientRect(),
227
+ contextElement: f
228
+ } : f;
229
+ a(g), c.refs.setReference(g);
230
+ }, [c.refs]), R = o.useCallback((f) => {
231
+ (I(f) || f === null) && (p.current = f, u(f)), (I(c.refs.reference.current) || c.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
232
+ // `null` to support `positionReference` + an unstable `reference`
233
+ // callback ref.
234
+ f !== null && !I(f)) && c.refs.setReference(f);
235
+ }, [c.refs]), v = o.useMemo(() => ({
236
+ ...c.refs,
237
+ setReference: R,
238
+ setPositionReference: m,
239
+ domReference: p
240
+ }), [c.refs, R, m]), x = o.useMemo(() => ({
241
+ ...c.elements,
242
+ domReference: d
243
+ }), [c.elements, d]), C = o.useMemo(() => ({
244
+ ...c,
245
+ ...e,
246
+ refs: v,
247
+ elements: x,
248
+ nodeId: n
249
+ }), [c, v, x, n, e]);
250
+ return b(() => {
251
+ e.dataRef.current.floatingContext = C;
252
+ const f = h == null ? void 0 : h.nodesRef.current.find((g) => g.id === n);
253
+ f && (f.context = C);
254
+ }), o.useMemo(() => ({
255
+ ...c,
256
+ context: C,
257
+ refs: v,
258
+ elements: x
259
+ }), [c, v, x, C]);
133
260
  }
134
261
  export {
135
- we as useDraggable
262
+ me as FloatingArrow,
263
+ xe as arrow,
264
+ Ee as flip,
265
+ Re as getOverflowAncestors,
266
+ we as inline,
267
+ Ce as offset,
268
+ Se as shift,
269
+ ge as useFloating,
270
+ se as useFloatingParentNodeId,
271
+ le as useFloatingRootContext,
272
+ ce as useFloatingTree,
273
+ $ as useId
136
274
  };
137
275
  //# sourceMappingURL=annotorious-react.es13.js.map