box-annotations 4.1.1-beta.4 → 5.0.0

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 (37) hide show
  1. package/dist/annotations.css +1 -1
  2. package/dist/annotations.js +2 -1
  3. package/dist/annotations.js.LICENSE.txt +89 -0
  4. package/i18n/en-US.js +1 -0
  5. package/i18n/en-US.properties +2 -0
  6. package/i18n/json/src/components/Popups/messages.json +1 -1
  7. package/package.json +47 -43
  8. package/src/@types/global.ts +1 -4
  9. package/src/common/BaseAnnotator.scss +1 -14
  10. package/src/common/BaseManager.ts +10 -6
  11. package/src/common/DeselectManager.tsx +6 -3
  12. package/src/common/useAutoScroll/useAutoScroll.tsx +1 -1
  13. package/src/components/Popups/Popper.ts +18 -0
  14. package/src/components/Popups/PopupBase.tsx +1 -1
  15. package/src/components/Popups/PopupCursor.tsx +3 -10
  16. package/src/components/Popups/PopupHighlight.tsx +2 -9
  17. package/src/components/Popups/PopupHighlightError.tsx +2 -9
  18. package/src/components/Popups/PopupReply.tsx +7 -10
  19. package/src/components/Popups/messages.ts +5 -0
  20. package/src/components/ReplyField/ReplyField.tsx +5 -1
  21. package/src/components/ReplyForm/ReplyButton.tsx +1 -1
  22. package/src/components/ReplyForm/ReplyForm.tsx +9 -1
  23. package/src/drawing/DrawingAnnotations.tsx +1 -1
  24. package/src/drawing/DrawingCreator.tsx +1 -1
  25. package/src/drawing/DrawingManager.tsx +6 -2
  26. package/src/drawing/actions.ts +0 -2
  27. package/src/drawing/drawingUtil.ts +0 -1
  28. package/src/highlight/HighlightManager.tsx +6 -2
  29. package/src/highlight/actions.ts +0 -1
  30. package/src/popup/PopupLayer.tsx +2 -2
  31. package/src/popup/PopupManager.tsx +6 -2
  32. package/src/region/RegionCreationManager.tsx +6 -2
  33. package/src/region/RegionManager.tsx +6 -2
  34. package/src/region/actions.ts +0 -1
  35. package/src/store/highlight/actions.ts +1 -1
  36. package/src/store/users/actions.ts +3 -3
  37. package/src/common/usePrevious.ts +0 -13
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import * as ReactDOM from 'react-dom';
2
+ import * as ReactDOM from 'react-dom/client';
3
3
  import BaseManager, { Props } from '../common/BaseManager';
4
4
  import DrawingAnnotationsContainer from './DrawingAnnotationsContainer';
5
5
 
@@ -10,6 +10,10 @@ export default class DrawingListManager extends BaseManager {
10
10
  }
11
11
 
12
12
  render(props: Props): void {
13
- ReactDOM.render(<DrawingAnnotationsContainer location={this.location} {...props} />, this.reactEl);
13
+ if (!this.root) {
14
+ this.root = ReactDOM.createRoot(this.reactEl);
15
+ }
16
+
17
+ this.root.render(<DrawingAnnotationsContainer location={this.location} {...props} />);
14
18
  }
15
19
  }
@@ -18,7 +18,6 @@ export const createDrawingAction = (arg: CreateArg) => (dispatch: AppThunkDispat
18
18
  message,
19
19
  type: 'reply' as const,
20
20
  },
21
- // eslint-disable-next-line @typescript-eslint/camelcase
22
21
  file_version: {
23
22
  id: getFileVersionId(state),
24
23
  },
@@ -27,7 +26,6 @@ export const createDrawingAction = (arg: CreateArg) => (dispatch: AppThunkDispat
27
26
  type: 'page' as const,
28
27
  value: location,
29
28
  },
30
- // eslint-disable-next-line @typescript-eslint/camelcase
31
29
  path_groups: pathGroups,
32
30
  type: 'drawing' as const,
33
31
  },
@@ -20,7 +20,6 @@ export function formatDrawing(annotation: AnnotationDrawing): AnnotationDrawing
20
20
 
21
21
  return {
22
22
  target: {
23
- // eslint-disable-next-line @typescript-eslint/camelcase
24
23
  path_groups: pathGroups.map(pathGroup => addClientIds(pathGroup)),
25
24
  ...targetRest,
26
25
  },
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import * as ReactDOM from 'react-dom';
2
+ import * as ReactDOM from 'react-dom/client';
3
3
  import BaseManager, { Props } from '../common/BaseManager';
4
4
  import HighlightContainer from './HighlightContainer';
5
5
 
@@ -10,6 +10,10 @@ export default class HighlightManager extends BaseManager {
10
10
  }
11
11
 
12
12
  render(props: Props): void {
13
- ReactDOM.render(<HighlightContainer location={this.location} {...props} />, this.reactEl);
13
+ if (!this.root) {
14
+ this.root = ReactDOM.createRoot(this.reactEl);
15
+ }
16
+
17
+ this.root.render(<HighlightContainer location={this.location} {...props} />);
14
18
  }
15
19
  }
@@ -18,7 +18,6 @@ export const createHighlightAction = (arg: CreateArg) => (dispatch: AppThunkDisp
18
18
  message,
19
19
  type: 'reply' as const,
20
20
  },
21
- // eslint-disable-next-line @typescript-eslint/camelcase
22
21
  file_version: {
23
22
  id: getFileVersionId(state),
24
23
  },
@@ -30,7 +30,7 @@ export type Props = {
30
30
  status: CreatorStatus;
31
31
  };
32
32
 
33
- const modeStagedMap: { [M in Mode]?: Function } = {
33
+ const modeStagedMap: { [M in Mode]?: (staged: CreatorItem | null) => boolean } = {
34
34
  [Mode.DRAWING]: isCreatorStagedDrawing,
35
35
  [Mode.HIGHLIGHT]: isCreatorStagedHighlight,
36
36
  [Mode.REGION]: isCreatorStagedRegion,
@@ -52,7 +52,7 @@ const PopupLayer = (props: Props): JSX.Element | null => {
52
52
  } = props;
53
53
 
54
54
  const [reference, setReference] = React.useState<PopupReference | null>(null);
55
- const canCreate = (modeStagedMap[mode] || noop)(staged) || isPromoting;
55
+ const canCreate = (modeStagedMap[mode]?.(staged ?? null) ?? false) || isPromoting;
56
56
  const canReply = status !== CreatorStatus.started && status !== CreatorStatus.init;
57
57
  const isPending = status === CreatorStatus.pending;
58
58
 
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import * as ReactDOM from 'react-dom';
2
+ import * as ReactDOM from 'react-dom/client';
3
3
  import BaseManager, { Props } from '../common/BaseManager';
4
4
  import PopupContainer from './PopupContainer';
5
5
 
@@ -10,6 +10,10 @@ export default class PopupManager extends BaseManager {
10
10
  }
11
11
 
12
12
  render(props: Props): void {
13
- ReactDOM.render(<PopupContainer location={this.location} {...props} />, this.reactEl);
13
+ if (!this.root) {
14
+ this.root = ReactDOM.createRoot(this.reactEl);
15
+ }
16
+
17
+ this.root.render(<PopupContainer location={this.location} {...props} />);
14
18
  }
15
19
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import * as ReactDOM from 'react-dom';
2
+ import * as ReactDOM from 'react-dom/client';
3
3
  import BaseManager, { Props } from '../common/BaseManager';
4
4
  import RegionCreationContainer from './RegionCreationContainer';
5
5
 
@@ -10,6 +10,10 @@ export default class RegionManager extends BaseManager {
10
10
  }
11
11
 
12
12
  render(props: Props): void {
13
- ReactDOM.render(<RegionCreationContainer location={this.location} {...props} />, this.reactEl);
13
+ if (!this.root) {
14
+ this.root = ReactDOM.createRoot(this.reactEl);
15
+ }
16
+
17
+ this.root.render(<RegionCreationContainer location={this.location} {...props} />);
14
18
  }
15
19
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import * as ReactDOM from 'react-dom';
2
+ import * as ReactDOM from 'react-dom/client';
3
3
  import BaseManager, { Props } from '../common/BaseManager';
4
4
  import RegionAnnotationsContainer from './RegionAnnotationsContainer';
5
5
 
@@ -10,6 +10,10 @@ export default class RegionListManager extends BaseManager {
10
10
  }
11
11
 
12
12
  render(props: Props): void {
13
- ReactDOM.render(<RegionAnnotationsContainer location={this.location} {...props} />, this.reactEl);
13
+ if (!this.root) {
14
+ this.root = ReactDOM.createRoot(this.reactEl);
15
+ }
16
+
17
+ this.root.render(<RegionAnnotationsContainer location={this.location} {...props} />);
14
18
  }
15
19
  }
@@ -17,7 +17,6 @@ export const createRegionAction = (arg: CreateArg) => (dispatch: AppThunkDispatc
17
17
  message,
18
18
  type: 'reply' as const,
19
19
  },
20
- // eslint-disable-next-line @typescript-eslint/camelcase
21
20
  file_version: {
22
21
  id: getFileVersionId(state),
23
22
  },
@@ -19,7 +19,7 @@ declare global {
19
19
  createNodeIterator(
20
20
  root: Node,
21
21
  whatToShow?: number,
22
- filter?: NodeFilter | Function,
22
+ filter?: NodeFilter | ((node: Node) => number | null),
23
23
  entityReferenceExpansion?: boolean,
24
24
  ): NodeIterator;
25
25
  }
@@ -20,9 +20,9 @@ export const fetchCollaboratorsAction = createAsyncThunk<APICollection<Collabora
20
20
  // Wrap the client request in a promise to allow it to be returned and cancelled
21
21
  return new Promise<APICollection<Collaborator>>((resolve, reject) => {
22
22
  client.getFileCollaborators(fileId, resolve, reject, {
23
- filter_term: searchString, // eslint-disable-line @typescript-eslint/camelcase
24
- include_groups: false, // eslint-disable-line @typescript-eslint/camelcase
25
- include_uploader_collabs: false, // eslint-disable-line @typescript-eslint/camelcase
23
+ filter_term: searchString,
24
+ include_groups: false,
25
+ include_uploader_collabs: false,
26
26
  });
27
27
  });
28
28
  },
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
-
3
- // Returns the last provided value, then caches the new value via an effect
4
- export default function usePrevious<T>(value: T): T | undefined {
5
- const ref = React.useRef<T>();
6
-
7
- // The useEffect callback is only invoked after the parent component has rendered
8
- React.useEffect(() => {
9
- ref.current = value;
10
- }, [value]);
11
-
12
- return ref.current;
13
- }