box-ui-elements 23.4.0-beta.15 → 23.4.0-beta.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.
Files changed (40) hide show
  1. package/dist/explorer.js +1 -1
  2. package/dist/picker.js +1 -1
  3. package/dist/preview.js +1 -1
  4. package/dist/preview.js.LICENSE.txt +10 -0
  5. package/dist/sharing.js +1 -1
  6. package/dist/sidebar.js +1 -1
  7. package/dist/sidebar.js.LICENSE.txt +10 -0
  8. package/dist/uploader.js +1 -1
  9. package/es/elements/common/annotator-context/types.js.flow +2 -2
  10. package/es/elements/common/annotator-context/types.js.map +1 -1
  11. package/es/elements/common/annotator-context/withAnnotations.js +29 -10
  12. package/es/elements/common/annotator-context/withAnnotations.js.flow +10 -3
  13. package/es/elements/common/annotator-context/withAnnotations.js.map +1 -1
  14. package/es/elements/common/annotator-context/withAnnotatorContext.js +47 -23
  15. package/es/elements/common/annotator-context/withAnnotatorContext.js.flow +1 -0
  16. package/es/elements/common/annotator-context/withAnnotatorContext.js.map +1 -1
  17. package/es/elements/common/types/SidebarNavigation.flow.js +14 -0
  18. package/es/elements/common/types/SidebarNavigation.flow.js.flow +52 -0
  19. package/es/elements/common/types/SidebarNavigation.flow.js.map +1 -0
  20. package/es/elements/common/types/SidebarNavigation.js +16 -0
  21. package/es/elements/common/types/SidebarNavigation.js.map +1 -0
  22. package/es/elements/content-sidebar/stories/tests/MetadataSidebarRedesign-visual.stories.js +4 -13
  23. package/es/elements/content-sidebar/stories/tests/MetadataSidebarRedesign-visual.stories.js.map +1 -1
  24. package/es/src/elements/common/annotator-context/types.d.ts +2 -2
  25. package/es/src/elements/common/annotator-context/withAnnotations.d.ts +5 -0
  26. package/es/src/elements/common/annotator-context/withAnnotatorContext.d.ts +4 -1
  27. package/es/src/elements/common/types/SidebarNavigation.d.ts +37 -0
  28. package/package.json +35 -37
  29. package/src/elements/common/annotator-context/__tests__/withAnnotations.test.tsx +46 -0
  30. package/src/elements/common/annotator-context/__tests__/withAnnotatorContext.test.tsx +116 -20
  31. package/src/elements/common/annotator-context/types.js.flow +2 -2
  32. package/src/elements/common/annotator-context/types.ts +2 -2
  33. package/src/elements/common/annotator-context/withAnnotations.js.flow +10 -3
  34. package/src/elements/common/annotator-context/withAnnotations.tsx +35 -6
  35. package/src/elements/common/annotator-context/withAnnotatorContext.js.flow +1 -0
  36. package/src/elements/common/annotator-context/withAnnotatorContext.tsx +61 -29
  37. package/src/elements/common/types/SidebarNavigation.flow.js +52 -0
  38. package/src/elements/common/types/SidebarNavigation.ts +47 -0
  39. package/src/elements/content-sidebar/stories/tests/MetadataSidebarRedesign-visual.stories.tsx +5 -13
  40. package/i18n.config.js +0 -9
@@ -74,8 +74,8 @@ export interface AnnotatorContext {
74
74
  annotation: Object,
75
75
  isStartEvent?: boolean
76
76
  ) => void;
77
- getAnnotationsMatchPath: GetMatchPath;
78
- getAnnotationsPath: (fileVersionId?: string, annotationId?: string) => string;
77
+ getAnnotationsMatchPath?: GetMatchPath;
78
+ getAnnotationsPath?: (fileVersionId?: string, annotationId?: string) => string;
79
79
  state: AnnotatorState;
80
80
  }
81
81
  declare export var Status: {|
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["CREATE","Action","Status"],"sources":["../../../../src/elements/common/annotator-context/types.ts"],"sourcesContent":["import { Location } from 'history';\nimport { match } from 'react-router-dom';\n\nexport const CREATE = 'create';\n\nexport enum Action {\n CREATE_START = 'create_start',\n CREATE_END = 'create_end',\n DELETE_START = 'delete_start',\n DELETE_END = 'delete_end',\n SET_ACTIVE = 'set_active',\n UPDATE_START = 'update_start',\n UPDATE_END = 'update_end',\n REPLY_CREATE_START = 'reply_create_start',\n REPLY_CREATE_END = 'reply_create_end',\n REPLY_DELETE_START = 'reply_delete_start',\n REPLY_DELETE_END = 'reply_delete_end',\n REPLY_UPDATE_START = 'reply_update_start',\n REPLY_UPDATE_END = 'reply_update_end',\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport interface Annotator {\n addListener: (event: string | symbol, listener: (...args: any[]) => void) => void;\n emit: (event: string | symbol, ...args: any[]) => void;\n removeAllListeners: () => void;\n removeListener: (event: string | symbol, listener: (...args: any[]) => void) => void;\n}\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\nexport interface AnnotatorState {\n activeAnnotationFileVersionId?: string | null;\n activeAnnotationId?: string | null;\n annotation?: { id?: string } | null;\n annotationReply?: { id?: string } | null;\n action?: Action | null;\n error?: Error | null;\n meta?: Metadata | null;\n origin?: string;\n}\n\nexport type GetMatchPath = (location?: Location) => match<MatchParams> | null;\n\nexport interface AnnotatorContext {\n emitActiveAnnotationChangeEvent?: (id: string) => void;\n emitAnnotationRemoveEvent?: (id: string, isStartEvent?: boolean) => void;\n emitAnnotationReplyCreateEvent?: (\n reply: Object,\n requestId: string,\n annotationId: string,\n isStartEvent?: boolean,\n ) => void;\n emitAnnotationReplyDeleteEvent?: (id: string, annotationId: string, isStartEvent?: boolean) => void;\n emitAnnotationReplyUpdateEvent?: (reply: Object, annotationId: string, isStartEvent?: boolean) => void;\n emitAnnotationUpdateEvent?: (annotation: Object, isStartEvent?: boolean) => void;\n getAnnotationsMatchPath: GetMatchPath;\n getAnnotationsPath: (fileVersionId?: string, annotationId?: string) => string;\n state: AnnotatorState;\n}\n\nexport enum Status {\n ERROR = 'error',\n PENDING = 'pending',\n SUCCESS = 'success',\n}\n\nexport type MatchParams = {\n annotationId?: string;\n fileVersionId?: string;\n};\n\nexport interface Metadata {\n requestId?: string;\n status: Status;\n}\n\nexport interface AnnotationActionEvent {\n annotation?: Object;\n annotationReply?: Object;\n error?: Error;\n meta: Metadata;\n}\n"],"mappings":"AAGA,OAAO,MAAMA,MAAM,GAAG,QAAQ;AAE9B,WAAYC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA;;AAgBlB;;AAOA;;AAgCA,WAAYC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":["CREATE","Action","Status"],"sources":["../../../../src/elements/common/annotator-context/types.ts"],"sourcesContent":["import { Location } from 'history';\nimport { match } from 'react-router-dom';\n\nexport const CREATE = 'create';\n\nexport enum Action {\n CREATE_START = 'create_start',\n CREATE_END = 'create_end',\n DELETE_START = 'delete_start',\n DELETE_END = 'delete_end',\n SET_ACTIVE = 'set_active',\n UPDATE_START = 'update_start',\n UPDATE_END = 'update_end',\n REPLY_CREATE_START = 'reply_create_start',\n REPLY_CREATE_END = 'reply_create_end',\n REPLY_DELETE_START = 'reply_delete_start',\n REPLY_DELETE_END = 'reply_delete_end',\n REPLY_UPDATE_START = 'reply_update_start',\n REPLY_UPDATE_END = 'reply_update_end',\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport interface Annotator {\n addListener: (event: string | symbol, listener: (...args: any[]) => void) => void;\n emit: (event: string | symbol, ...args: any[]) => void;\n removeAllListeners: () => void;\n removeListener: (event: string | symbol, listener: (...args: any[]) => void) => void;\n}\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\nexport interface AnnotatorState {\n activeAnnotationFileVersionId?: string | null;\n activeAnnotationId?: string | null;\n annotation?: { id?: string } | null;\n annotationReply?: { id?: string } | null;\n action?: Action | null;\n error?: Error | null;\n meta?: Metadata | null;\n origin?: string;\n}\n\nexport type GetMatchPath = (location?: Location) => match<MatchParams> | null;\n\nexport interface AnnotatorContext {\n emitActiveAnnotationChangeEvent?: (id: string) => void;\n emitAnnotationRemoveEvent?: (id: string, isStartEvent?: boolean) => void;\n emitAnnotationReplyCreateEvent?: (\n reply: Object,\n requestId: string,\n annotationId: string,\n isStartEvent?: boolean,\n ) => void;\n emitAnnotationReplyDeleteEvent?: (id: string, annotationId: string, isStartEvent?: boolean) => void;\n emitAnnotationReplyUpdateEvent?: (reply: Object, annotationId: string, isStartEvent?: boolean) => void;\n emitAnnotationUpdateEvent?: (annotation: Object, isStartEvent?: boolean) => void;\n getAnnotationsMatchPath?: GetMatchPath;\n getAnnotationsPath?: (fileVersionId?: string, annotationId?: string) => string;\n state: AnnotatorState;\n}\n\nexport enum Status {\n ERROR = 'error',\n PENDING = 'pending',\n SUCCESS = 'success',\n}\n\nexport type MatchParams = {\n annotationId?: string;\n fileVersionId?: string;\n};\n\nexport interface Metadata {\n requestId?: string;\n status: Status;\n}\n\nexport interface AnnotationActionEvent {\n annotation?: Object;\n annotationReply?: Object;\n error?: Error;\n meta: Metadata;\n}\n"],"mappings":"AAGA,OAAO,MAAMA,MAAM,GAAG,QAAQ;AAE9B,WAAYC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA;;AAgBlB;;AAOA;;AAgCA,WAAYC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA","ignoreList":[]}
@@ -8,7 +8,9 @@ import * as React from 'react';
8
8
  import getProp from 'lodash/get';
9
9
  import { generatePath, matchPath } from 'react-router-dom';
10
10
  import AnnotatorContext from './AnnotatorContext';
11
+ import { isFeatureEnabled } from '../feature-checking';
11
12
  import { Action, Status } from './types';
13
+ import { FeedEntryType } from '../types/SidebarNavigation';
12
14
  const ANNOTATIONS_PATH = '/:sidebar/annotations/:fileVersionId/:annotationId?';
13
15
  const defaultState = {
14
16
  action: null,
@@ -23,8 +25,6 @@ export default function withAnnotations(WrappedComponent) {
23
25
  class ComponentWithAnnotations extends React.Component {
24
26
  constructor(props) {
25
27
  super(props);
26
-
27
- // Determine by url if there is already a deeply linked annotation
28
28
  _defineProperty(this, "annotator", null);
29
29
  _defineProperty(this, "emitActiveAnnotationChangeEvent", id => {
30
30
  const {
@@ -238,10 +238,23 @@ export default function withAnnotations(WrappedComponent) {
238
238
  this.annotator = null;
239
239
  });
240
240
  const {
241
- location
241
+ routerDisabled,
242
+ sidebarNavigation
242
243
  } = props;
243
- const match = this.getMatchPath(location);
244
- const activeAnnotationId = getProp(match, 'params.annotationId', null);
244
+ let activeAnnotationId = null;
245
+ const isRouterDisabled = routerDisabled || isFeatureEnabled(props?.features, 'routerDisabled.value');
246
+ if (isRouterDisabled) {
247
+ if (sidebarNavigation && 'activeFeedEntryType' in sidebarNavigation && sidebarNavigation.activeFeedEntryType === FeedEntryType.ANNOTATIONS && 'activeFeedEntryId' in sidebarNavigation) {
248
+ activeAnnotationId = sidebarNavigation.activeFeedEntryId;
249
+ }
250
+ } else {
251
+ // Determine by url if there is already a deeply linked annotation
252
+ const {
253
+ location
254
+ } = props;
255
+ const match = this.getMatchPath(location);
256
+ activeAnnotationId = getProp(match, 'params.annotationId', null);
257
+ }
245
258
 
246
259
  // Seed the initial state with the activeAnnotationId if any from the location path
247
260
  this.state = _objectSpread(_objectSpread({}, defaultState), {}, {
@@ -306,6 +319,8 @@ export default function withAnnotations(WrappedComponent) {
306
319
  fileVersionId
307
320
  });
308
321
  }
322
+
323
+ // remove this method with routerDisabled switch
309
324
  getMatchPath(location) {
310
325
  const pathname = getProp(location, 'pathname', '');
311
326
  return matchPath(pathname, {
@@ -314,18 +329,22 @@ export default function withAnnotations(WrappedComponent) {
314
329
  });
315
330
  }
316
331
  render() {
332
+ const isRouterDisabled = this.props?.routerDisabled || isFeatureEnabled(this.props?.features, 'routerDisabled.value');
333
+ const annotationsRouterProps = isRouterDisabled ? {} : {
334
+ getAnnotationsMatchPath: this.getMatchPath,
335
+ getAnnotationsPath: this.getAnnotationsPath
336
+ };
317
337
  return /*#__PURE__*/React.createElement(AnnotatorContext.Provider, {
318
- value: {
338
+ value: _objectSpread(_objectSpread({
319
339
  emitActiveAnnotationChangeEvent: this.emitActiveAnnotationChangeEvent,
320
340
  emitAnnotationRemoveEvent: this.emitAnnotationRemoveEvent,
321
341
  emitAnnotationReplyCreateEvent: this.emitAnnotationReplyCreateEvent,
322
342
  emitAnnotationReplyDeleteEvent: this.emitAnnotationReplyDeleteEvent,
323
343
  emitAnnotationReplyUpdateEvent: this.emitAnnotationReplyUpdateEvent,
324
- emitAnnotationUpdateEvent: this.emitAnnotationUpdateEvent,
325
- getAnnotationsMatchPath: this.getMatchPath,
326
- getAnnotationsPath: this.getAnnotationsPath,
344
+ emitAnnotationUpdateEvent: this.emitAnnotationUpdateEvent
345
+ }, annotationsRouterProps), {}, {
327
346
  state: this.state
328
- }
347
+ })
329
348
  }, /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, this.props, {
330
349
  onAnnotator: this.handleAnnotator,
331
350
  onPreviewDestroy: this.handlePreviewDestroy
@@ -18,6 +18,10 @@ import {
18
18
  MatchParams,
19
19
  Status
20
20
  } from "./types";
21
+ import { SidebarNavigation } from '../types/SidebarNavigation';
22
+ import { type FeatureConfig } from '../feature-checking';
23
+
24
+
21
25
  export type ActiveChangeEvent = {
22
26
  annotationId: string | null,
23
27
  fileVersionId: string,
@@ -48,11 +52,11 @@ export type ComponentWithAnnotations = {
48
52
  isStartEvent?: boolean
49
53
  ) => void,
50
54
  getAction: (eventData: AnnotationActionEvent) => Action,
51
- getAnnotationsPath: (
55
+ getAnnotationsPath?: (
52
56
  fileVersionId?: string,
53
57
  annotationId?: string | null
54
58
  ) => string,
55
- getMatchPath: GetMatchPath,
59
+ getMatchPath?: GetMatchPath,
56
60
  handleActiveChange: ActiveChangeEventHandler,
57
61
  handleAnnotationChangeEvent: (id: string | null) => void,
58
62
  handleAnnotationCreate: (eventData: AnnotationActionEvent) => void,
@@ -70,6 +74,7 @@ export type ComponentWithAnnotations = {
70
74
  ...
71
75
  };
72
76
  export type WithAnnotationsProps = {
77
+ features?: FeatureConfig;
73
78
  location?: Location,
74
79
  onAnnotator: (annotator: Annotator) => void,
75
80
  onError?: (
@@ -78,7 +83,9 @@ export type WithAnnotationsProps = {
78
83
  contextInfo?: { [key: string]: mixed, ... }
79
84
  ) => void,
80
85
  onPreviewDestroy: (shouldReset?: boolean) => void,
81
- ...
86
+ routerDisabled?: boolean;
87
+ sidebarNavigation?: SidebarNavigation;
88
+ ...
82
89
  };
83
90
  export type WithAnnotationsComponent<P> = React.ComponentClass<
84
91
  P & WithAnnotationsProps
@@ -1 +1 @@
1
- {"version":3,"file":"withAnnotations.js","names":["React","getProp","generatePath","matchPath","AnnotatorContext","Action","Status","ANNOTATIONS_PATH","defaultState","action","activeAnnotationFileVersionId","activeAnnotationId","annotation","annotationReply","error","meta","withAnnotations","WrappedComponent","ComponentWithAnnotations","Component","constructor","props","_defineProperty","id","annotator","emit","isStartEvent","event","reply","requestId","annotationId","eventData","onError","showNotification","setState","_objectSpread","state","getAction","getDeleteAction","getUpdateAction","getReplyCreateAction","getReplyDeleteAction","getReplyUpdateAction","fileVersionId","addListener","handleActiveChange","handleAnnotationCreate","handleAnnotationDelete","handleAnnotationFetchError","handleAnnotationUpdate","handleAnnotationReplyCreate","handleAnnotationReplyDelete","handleAnnotationReplyUpdate","shouldReset","removeListener","location","match","getMatchPath","status","SUCCESS","CREATE_END","CREATE_START","DELETE_END","DELETE_START","UPDATE_END","UPDATE_START","REPLY_CREATE_END","REPLY_CREATE_START","REPLY_DELETE_END","REPLY_DELETE_START","REPLY_UPDATE_END","REPLY_UPDATE_START","getAnnotationsPath","sidebar","undefined","pathname","path","exact","render","createElement","Provider","value","emitActiveAnnotationChangeEvent","emitAnnotationRemoveEvent","emitAnnotationReplyCreateEvent","emitAnnotationReplyDeleteEvent","emitAnnotationReplyUpdateEvent","emitAnnotationUpdateEvent","getAnnotationsMatchPath","_extends","onAnnotator","handleAnnotator","onPreviewDestroy","handlePreviewDestroy","displayName","name"],"sources":["../../../../src/elements/common/annotator-context/withAnnotations.tsx"],"sourcesContent":["import * as React from 'react';\nimport getProp from 'lodash/get';\nimport { generatePath, match as matchType, matchPath } from 'react-router-dom';\nimport { Location } from 'history';\nimport AnnotatorContext from './AnnotatorContext';\nimport { Action, Annotator, AnnotationActionEvent, AnnotatorState, GetMatchPath, MatchParams, Status } from './types';\n\nexport type ActiveChangeEvent = {\n annotationId: string | null;\n fileVersionId: string;\n};\n\nexport type ActiveChangeEventHandler = (event: ActiveChangeEvent) => void;\n\nexport type ComponentWithAnnotations = {\n emitActiveAnnotationChangeEvent: (id: string | null) => void;\n emitAnnotationRemoveEvent: (id: string, isStartEvent?: boolean) => void;\n emitAnnotationReplyCreateEvent: (\n reply: Object,\n requestId: string,\n annotationId: string,\n isStartEvent?: boolean,\n ) => void;\n emitAnnotationReplyDeleteEvent: (id: string, annotationId: string, isStartEvent?: boolean) => void;\n emitAnnotationReplyUpdateEvent: (reply: Object, annotationId: string, isStartEvent?: boolean) => void;\n emitAnnotationUpdateEvent: (annotation: Object, isStartEvent?: boolean) => void;\n getAction: (eventData: AnnotationActionEvent) => Action;\n getAnnotationsPath: (fileVersionId?: string, annotationId?: string | null) => string;\n getMatchPath: GetMatchPath;\n handleActiveChange: ActiveChangeEventHandler;\n handleAnnotationChangeEvent: (id: string | null) => void;\n handleAnnotationCreate: (eventData: AnnotationActionEvent) => void;\n handleAnnotationDelete: (eventData: AnnotationActionEvent) => void;\n handleAnnotationFetchError: ({ error }: { error: Error }) => void;\n handleAnnotationReplyCreate: (eventData: AnnotationActionEvent) => void;\n handleAnnotationReplyDelete: (eventData: AnnotationActionEvent) => void;\n handleAnnotationReplyUpdate: (eventData: AnnotationActionEvent) => void;\n handleAnnotationUpdate: (eventData: AnnotationActionEvent) => void;\n handleAnnotator: (annotator: Annotator) => void;\n handlePreviewDestroy: (shouldReset?: boolean) => void;\n};\n\nexport type WithAnnotationsProps = {\n location?: Location;\n onAnnotator: (annotator: Annotator) => void;\n onError?: (error: Error, code: string, contextInfo?: Record<string, unknown>) => void;\n onPreviewDestroy: (shouldReset?: boolean) => void;\n};\n\nexport type WithAnnotationsComponent<P> = React.ComponentClass<P & WithAnnotationsProps>;\n\nconst ANNOTATIONS_PATH = '/:sidebar/annotations/:fileVersionId/:annotationId?';\nconst defaultState: AnnotatorState = {\n action: null,\n activeAnnotationFileVersionId: null,\n activeAnnotationId: null,\n annotation: null,\n annotationReply: null,\n error: null,\n meta: null,\n};\n\nexport default function withAnnotations<P extends object>(\n WrappedComponent: React.ComponentType<P>,\n): WithAnnotationsComponent<P> {\n class ComponentWithAnnotations extends React.Component<P & WithAnnotationsProps, AnnotatorState> {\n static displayName: string;\n\n annotator: Annotator | null = null;\n\n constructor(props: P & WithAnnotationsProps) {\n super(props);\n\n // Determine by url if there is already a deeply linked annotation\n const { location } = props;\n const match = this.getMatchPath(location);\n const activeAnnotationId = getProp(match, 'params.annotationId', null);\n\n // Seed the initial state with the activeAnnotationId if any from the location path\n this.state = { ...defaultState, activeAnnotationId };\n }\n\n emitActiveAnnotationChangeEvent = (id: string | null) => {\n const { annotator } = this;\n\n if (!annotator) {\n return;\n }\n\n annotator.emit('annotations_active_set', id);\n };\n\n emitAnnotationRemoveEvent = (id: string, isStartEvent = false) => {\n const { annotator } = this;\n\n if (!annotator) {\n return;\n }\n\n // Event name does not include \"sidebar\" namespace because of backwards compatibility with Preview\n const event = isStartEvent ? 'annotations_remove_start' : 'annotations_remove';\n\n annotator.emit(event, id);\n };\n\n emitAnnotationUpdateEvent = (annotation: Object, isStartEvent = false) => {\n const { annotator } = this;\n\n if (!annotator) {\n return;\n }\n\n const event = isStartEvent ? 'sidebar.annotations_update_start' : 'sidebar.annotations_update';\n\n annotator.emit(event, annotation);\n };\n\n emitAnnotationReplyCreateEvent = (\n reply: Object,\n requestId: string,\n annotationId: string,\n isStartEvent = false,\n ) => {\n const { annotator } = this;\n\n if (!annotator) {\n return;\n }\n\n const event = isStartEvent ? 'sidebar.annotations_reply_create_start' : 'sidebar.annotations_reply_create';\n\n annotator.emit(event, { annotationId, reply, requestId });\n };\n\n emitAnnotationReplyDeleteEvent = (id: string, annotationId: string, isStartEvent = false) => {\n const { annotator } = this;\n\n if (!annotator) {\n return;\n }\n\n const event = isStartEvent ? 'sidebar.annotations_reply_delete_start' : 'sidebar.annotations_reply_delete';\n\n annotator.emit(event, { annotationId, id });\n };\n\n emitAnnotationReplyUpdateEvent = (reply: Object, annotationId: string, isStartEvent = false) => {\n const { annotator } = this;\n\n if (!annotator) {\n return;\n }\n\n const event = isStartEvent ? 'sidebar.annotations_reply_update_start' : 'sidebar.annotations_reply_update';\n\n annotator.emit(event, { annotationId, reply });\n };\n\n getAction({ meta: { status }, error }: AnnotationActionEvent): Action {\n return status === Status.SUCCESS || error ? Action.CREATE_END : Action.CREATE_START;\n }\n\n getDeleteAction({ meta: { status }, error }: AnnotationActionEvent): Action {\n return status === Status.SUCCESS || error ? Action.DELETE_END : Action.DELETE_START;\n }\n\n getUpdateAction({ meta: { status }, error }: AnnotationActionEvent): Action {\n return status === Status.SUCCESS || error ? Action.UPDATE_END : Action.UPDATE_START;\n }\n\n getReplyCreateAction({ meta: { status }, error }: AnnotationActionEvent): Action {\n return status === Status.SUCCESS || error ? Action.REPLY_CREATE_END : Action.REPLY_CREATE_START;\n }\n\n getReplyDeleteAction({ meta: { status }, error }: AnnotationActionEvent): Action {\n return status === Status.SUCCESS || error ? Action.REPLY_DELETE_END : Action.REPLY_DELETE_START;\n }\n\n getReplyUpdateAction({ meta: { status }, error }: AnnotationActionEvent): Action {\n return status === Status.SUCCESS || error ? Action.REPLY_UPDATE_END : Action.REPLY_UPDATE_START;\n }\n\n getAnnotationsPath(fileVersionId?: string, annotationId?: string | null): string {\n if (!fileVersionId) {\n return '/activity';\n }\n\n return generatePath(ANNOTATIONS_PATH, {\n sidebar: 'activity',\n annotationId: annotationId || undefined,\n fileVersionId,\n });\n }\n\n getMatchPath(location?: Location): matchType<MatchParams> | null {\n const pathname = getProp(location, 'pathname', '');\n return matchPath<MatchParams>(pathname, {\n path: ANNOTATIONS_PATH,\n exact: true,\n });\n }\n\n handleAnnotationCreate = (eventData: AnnotationActionEvent): void => {\n const { annotation = null, error = null, meta = null } = eventData;\n const { onError } = this.props;\n\n if (onError && error) {\n onError(error, 'create_annotation_error', { showNotification: true });\n }\n\n this.setState({\n ...this.state,\n action: this.getAction(eventData),\n annotation,\n error,\n meta,\n });\n };\n\n handleAnnotationDelete = (eventData: AnnotationActionEvent) => {\n const { annotation = null, error = null, meta = null } = eventData;\n\n this.setState({\n action: this.getDeleteAction(eventData),\n annotation,\n error,\n meta,\n });\n };\n\n handleAnnotationUpdate = (eventData: AnnotationActionEvent) => {\n const { annotation = null, error = null, meta = null } = eventData;\n\n this.setState({\n action: this.getUpdateAction(eventData),\n annotation,\n error,\n meta,\n });\n };\n\n handleAnnotationReplyCreate = (eventData: AnnotationActionEvent) => {\n const { annotation = null, annotationReply = null, error = null, meta = null } = eventData;\n\n this.setState({\n action: this.getReplyCreateAction(eventData),\n annotation,\n annotationReply,\n error,\n meta,\n });\n };\n\n handleAnnotationReplyDelete = (eventData: AnnotationActionEvent) => {\n const { annotation = null, annotationReply = null, error = null, meta = null } = eventData;\n\n this.setState({\n action: this.getReplyDeleteAction(eventData),\n annotation,\n annotationReply,\n error,\n meta,\n });\n };\n\n handleAnnotationReplyUpdate = (eventData: AnnotationActionEvent) => {\n const { annotation = null, annotationReply = null, error = null, meta = null } = eventData;\n\n this.setState({\n action: this.getReplyUpdateAction(eventData),\n annotation,\n annotationReply,\n error,\n meta,\n });\n };\n\n handleActiveChange: ActiveChangeEventHandler = ({ annotationId, fileVersionId }): void => {\n this.setState({ activeAnnotationFileVersionId: fileVersionId, activeAnnotationId: annotationId });\n };\n\n handleAnnotationFetchError = ({ error }: { error: Error }): void => {\n const { onError } = this.props;\n\n if (onError && error) {\n onError(error, 'fetch_annotations_error', { showNotification: true });\n }\n };\n\n handleAnnotator = (annotator: Annotator): void => {\n this.annotator = annotator;\n this.annotator.addListener('annotations_active_change', this.handleActiveChange);\n this.annotator.addListener('annotations_create', this.handleAnnotationCreate);\n this.annotator.addListener('annotations_delete', this.handleAnnotationDelete);\n this.annotator.addListener('annotations_fetch_error', this.handleAnnotationFetchError);\n this.annotator.addListener('annotations_update', this.handleAnnotationUpdate);\n this.annotator.addListener('annotations_reply_create', this.handleAnnotationReplyCreate);\n this.annotator.addListener('annotations_reply_delete', this.handleAnnotationReplyDelete);\n this.annotator.addListener('annotations_reply_update', this.handleAnnotationReplyUpdate);\n };\n\n handlePreviewDestroy = (shouldReset = true): void => {\n if (shouldReset) {\n this.setState(defaultState);\n }\n\n if (this.annotator) {\n this.annotator.removeListener('annotations_active_change', this.handleActiveChange);\n this.annotator.removeListener('annotations_create', this.handleAnnotationCreate);\n this.annotator.removeListener('annotations_delete', this.handleAnnotationDelete);\n this.annotator.removeListener('annotations_fetch_error', this.handleAnnotationFetchError);\n this.annotator.removeListener('annotations_update', this.handleAnnotationUpdate);\n this.annotator.removeListener('annotations_reply_create', this.handleAnnotationReplyCreate);\n this.annotator.removeListener('annotations_reply_delete', this.handleAnnotationReplyDelete);\n this.annotator.removeListener('annotations_reply_update', this.handleAnnotationReplyUpdate);\n }\n\n this.annotator = null;\n };\n\n render(): JSX.Element {\n return (\n <AnnotatorContext.Provider\n value={{\n emitActiveAnnotationChangeEvent: this.emitActiveAnnotationChangeEvent,\n emitAnnotationRemoveEvent: this.emitAnnotationRemoveEvent,\n emitAnnotationReplyCreateEvent: this.emitAnnotationReplyCreateEvent,\n emitAnnotationReplyDeleteEvent: this.emitAnnotationReplyDeleteEvent,\n emitAnnotationReplyUpdateEvent: this.emitAnnotationReplyUpdateEvent,\n emitAnnotationUpdateEvent: this.emitAnnotationUpdateEvent,\n getAnnotationsMatchPath: this.getMatchPath,\n getAnnotationsPath: this.getAnnotationsPath,\n state: this.state,\n }}\n >\n <WrappedComponent\n {...this.props}\n onAnnotator={this.handleAnnotator}\n onPreviewDestroy={this.handlePreviewDestroy}\n />\n </AnnotatorContext.Provider>\n );\n }\n }\n\n const displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';\n ComponentWithAnnotations.displayName = `WithAnnotations(${displayName})`;\n\n return ComponentWithAnnotations;\n}\n"],"mappings":";;;;;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,OAAO,MAAM,YAAY;AAChC,SAASC,YAAY,EAAsBC,SAAS,QAAQ,kBAAkB;AAE9E,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,SAASC,MAAM,EAA+EC,MAAM,QAAQ,SAAS;AA8CrH,MAAMC,gBAAgB,GAAG,qDAAqD;AAC9E,MAAMC,YAA4B,GAAG;EACjCC,MAAM,EAAE,IAAI;EACZC,6BAA6B,EAAE,IAAI;EACnCC,kBAAkB,EAAE,IAAI;EACxBC,UAAU,EAAE,IAAI;EAChBC,eAAe,EAAE,IAAI;EACrBC,KAAK,EAAE,IAAI;EACXC,IAAI,EAAE;AACV,CAAC;AAED,eAAe,SAASC,eAAeA,CACnCC,gBAAwC,EACb;EAC3B,MAAMC,wBAAwB,SAASlB,KAAK,CAACmB,SAAS,CAA2C;IAK7FC,WAAWA,CAACC,KAA+B,EAAE;MACzC,KAAK,CAACA,KAAK,CAAC;;MAEZ;MAAAC,eAAA,oBAL0B,IAAI;MAAAA,eAAA,0CAcCC,EAAiB,IAAK;QACrD,MAAM;UAAEC;QAAU,CAAC,GAAG,IAAI;QAE1B,IAAI,CAACA,SAAS,EAAE;UACZ;QACJ;QAEAA,SAAS,CAACC,IAAI,CAAC,wBAAwB,EAAEF,EAAE,CAAC;MAChD,CAAC;MAAAD,eAAA,oCAE2B,CAACC,EAAU,EAAEG,YAAY,GAAG,KAAK,KAAK;QAC9D,MAAM;UAAEF;QAAU,CAAC,GAAG,IAAI;QAE1B,IAAI,CAACA,SAAS,EAAE;UACZ;QACJ;;QAEA;QACA,MAAMG,KAAK,GAAGD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E,wBAAwB;AACnC","ignoreList":[]}
1
+ {"version":3,"file":"withAnnotations.js","names":["React","getProp","generatePath","matchPath","AnnotatorContext","isFeatureEnabled","Action","Status","FeedEntryType","ANNOTATIONS_PATH","defaultState","action","activeAnnotationFileVersionId","activeAnnotationId","annotation","annotationReply","error","meta","withAnnotations","WrappedComponent","ComponentWithAnnotations","Component","constructor","props","_defineProperty","id","annotator","emit","isStartEvent","event","reply","requestId","annotationId","eventData","onError","showNotification","setState","_objectSpread","state","getAction","getDeleteAction","getUpdateAction","getReplyCreateAction","getReplyDeleteAction","getReplyUpdateAction","fileVersionId","addListener","handleActiveChange","handleAnnotationCreate","handleAnnotationDelete","handleAnnotationFetchError","handleAnnotationUpdate","handleAnnotationReplyCreate","handleAnnotationReplyDelete","handleAnnotationReplyUpdate","shouldReset","removeListener","routerDisabled","sidebarNavigation","isRouterDisabled","features","activeFeedEntryType","ANNOTATIONS","activeFeedEntryId","location","match","getMatchPath","status","SUCCESS","CREATE_END","CREATE_START","DELETE_END","DELETE_START","UPDATE_END","UPDATE_START","REPLY_CREATE_END","REPLY_CREATE_START","REPLY_DELETE_END","REPLY_DELETE_START","REPLY_UPDATE_END","REPLY_UPDATE_START","getAnnotationsPath","sidebar","undefined","pathname","path","exact","render","annotationsRouterProps","getAnnotationsMatchPath","createElement","Provider","value","emitActiveAnnotationChangeEvent","emitAnnotationRemoveEvent","emitAnnotationReplyCreateEvent","emitAnnotationReplyDeleteEvent","emitAnnotationReplyUpdateEvent","emitAnnotationUpdateEvent","_extends","onAnnotator","handleAnnotator","onPreviewDestroy","handlePreviewDestroy","displayName","name"],"sources":["../../../../src/elements/common/annotator-context/withAnnotations.tsx"],"sourcesContent":["import * as React from 'react';\nimport getProp from 'lodash/get';\nimport { generatePath, match as matchType, matchPath } from 'react-router-dom';\nimport { Location } from 'history';\nimport AnnotatorContext from './AnnotatorContext';\nimport { isFeatureEnabled, type FeatureConfig } from '../feature-checking';\nimport { Action, Annotator, AnnotationActionEvent, AnnotatorState, GetMatchPath, MatchParams, Status } from './types';\nimport { FeedEntryType, SidebarNavigation } from '../types/SidebarNavigation';\n\nexport type ActiveChangeEvent = {\n annotationId: string | null;\n fileVersionId: string;\n};\n\nexport type ActiveChangeEventHandler = (event: ActiveChangeEvent) => void;\n\nexport type ComponentWithAnnotations = {\n emitActiveAnnotationChangeEvent: (id: string | null) => void;\n emitAnnotationRemoveEvent: (id: string, isStartEvent?: boolean) => void;\n emitAnnotationReplyCreateEvent: (\n reply: Object,\n requestId: string,\n annotationId: string,\n isStartEvent?: boolean,\n ) => void;\n emitAnnotationReplyDeleteEvent: (id: string, annotationId: string, isStartEvent?: boolean) => void;\n emitAnnotationReplyUpdateEvent: (reply: Object, annotationId: string, isStartEvent?: boolean) => void;\n emitAnnotationUpdateEvent: (annotation: Object, isStartEvent?: boolean) => void;\n getAction: (eventData: AnnotationActionEvent) => Action;\n getAnnotationsPath: (fileVersionId?: string, annotationId?: string | null) => string;\n getMatchPath: GetMatchPath;\n handleActiveChange: ActiveChangeEventHandler;\n handleAnnotationChangeEvent: (id: string | null) => void;\n handleAnnotationCreate: (eventData: AnnotationActionEvent) => void;\n handleAnnotationDelete: (eventData: AnnotationActionEvent) => void;\n handleAnnotationFetchError: ({ error }: { error: Error }) => void;\n handleAnnotationReplyCreate: (eventData: AnnotationActionEvent) => void;\n handleAnnotationReplyDelete: (eventData: AnnotationActionEvent) => void;\n handleAnnotationReplyUpdate: (eventData: AnnotationActionEvent) => void;\n handleAnnotationUpdate: (eventData: AnnotationActionEvent) => void;\n handleAnnotator: (annotator: Annotator) => void;\n handlePreviewDestroy: (shouldReset?: boolean) => void;\n};\n\nexport type WithAnnotationsProps = {\n features?: FeatureConfig;\n location?: Location;\n onAnnotator: (annotator: Annotator) => void;\n onError?: (error: Error, code: string, contextInfo?: Record<string, unknown>) => void;\n onPreviewDestroy: (shouldReset?: boolean) => void;\n routerDisabled?: boolean;\n sidebarNavigation?: SidebarNavigation;\n};\n\nexport type WithAnnotationsComponent<P> = React.ComponentClass<P & WithAnnotationsProps>;\n\nconst ANNOTATIONS_PATH = '/:sidebar/annotations/:fileVersionId/:annotationId?';\nconst defaultState: AnnotatorState = {\n action: null,\n activeAnnotationFileVersionId: null,\n activeAnnotationId: null,\n annotation: null,\n annotationReply: null,\n error: null,\n meta: null,\n};\n\nexport default function withAnnotations<P extends object>(\n WrappedComponent: React.ComponentType<P>,\n): WithAnnotationsComponent<P> {\n class ComponentWithAnnotations extends React.Component<P & WithAnnotationsProps, AnnotatorState> {\n static displayName: string;\n\n annotator: Annotator | null = null;\n\n constructor(props: P & WithAnnotationsProps) {\n super(props);\n\n const { routerDisabled, sidebarNavigation } = props;\n let activeAnnotationId = null;\n\n const isRouterDisabled = routerDisabled || isFeatureEnabled(props?.features, 'routerDisabled.value');\n\n if (isRouterDisabled) {\n if (\n sidebarNavigation &&\n 'activeFeedEntryType' in sidebarNavigation &&\n sidebarNavigation.activeFeedEntryType === FeedEntryType.ANNOTATIONS &&\n 'activeFeedEntryId' in sidebarNavigation\n ) {\n activeAnnotationId = sidebarNavigation.activeFeedEntryId;\n }\n } else {\n // Determine by url if there is already a deeply linked annotation\n const { location } = props;\n const match = this.getMatchPath(location);\n activeAnnotationId = getProp(match, 'params.annotationId', null);\n }\n\n // Seed the initial state with the activeAnnotationId if any from the location path\n this.state = { ...defaultState, activeAnnotationId };\n }\n\n emitActiveAnnotationChangeEvent = (id: string | null) => {\n const { annotator } = this;\n\n if (!annotator) {\n return;\n }\n\n annotator.emit('annotations_active_set', id);\n };\n\n emitAnnotationRemoveEvent = (id: string, isStartEvent = false) => {\n const { annotator } = this;\n\n if (!annotator) {\n return;\n }\n\n // Event name does not include \"sidebar\" namespace because of backwards compatibility with Preview\n const event = isStartEvent ? 'annotations_remove_start' : 'annotations_remove';\n\n annotator.emit(event, id);\n };\n\n emitAnnotationUpdateEvent = (annotation: Object, isStartEvent = false) => {\n const { annotator } = this;\n\n if (!annotator) {\n return;\n }\n\n const event = isStartEvent ? 'sidebar.annotations_update_start' : 'sidebar.annotations_update';\n\n annotator.emit(event, annotation);\n };\n\n emitAnnotationReplyCreateEvent = (\n reply: Object,\n requestId: string,\n annotationId: string,\n isStartEvent = false,\n ) => {\n const { annotator } = this;\n\n if (!annotator) {\n return;\n }\n\n const event = isStartEvent ? 'sidebar.annotations_reply_create_start' : 'sidebar.annotations_reply_create';\n\n annotator.emit(event, { annotationId, reply, requestId });\n };\n\n emitAnnotationReplyDeleteEvent = (id: string, annotationId: string, isStartEvent = false) => {\n const { annotator } = this;\n\n if (!annotator) {\n return;\n }\n\n const event = isStartEvent ? 'sidebar.annotations_reply_delete_start' : 'sidebar.annotations_reply_delete';\n\n annotator.emit(event, { annotationId, id });\n };\n\n emitAnnotationReplyUpdateEvent = (reply: Object, annotationId: string, isStartEvent = false) => {\n const { annotator } = this;\n\n if (!annotator) {\n return;\n }\n\n const event = isStartEvent ? 'sidebar.annotations_reply_update_start' : 'sidebar.annotations_reply_update';\n\n annotator.emit(event, { annotationId, reply });\n };\n\n getAction({ meta: { status }, error }: AnnotationActionEvent): Action {\n return status === Status.SUCCESS || error ? Action.CREATE_END : Action.CREATE_START;\n }\n\n getDeleteAction({ meta: { status }, error }: AnnotationActionEvent): Action {\n return status === Status.SUCCESS || error ? Action.DELETE_END : Action.DELETE_START;\n }\n\n getUpdateAction({ meta: { status }, error }: AnnotationActionEvent): Action {\n return status === Status.SUCCESS || error ? Action.UPDATE_END : Action.UPDATE_START;\n }\n\n getReplyCreateAction({ meta: { status }, error }: AnnotationActionEvent): Action {\n return status === Status.SUCCESS || error ? Action.REPLY_CREATE_END : Action.REPLY_CREATE_START;\n }\n\n getReplyDeleteAction({ meta: { status }, error }: AnnotationActionEvent): Action {\n return status === Status.SUCCESS || error ? Action.REPLY_DELETE_END : Action.REPLY_DELETE_START;\n }\n\n getReplyUpdateAction({ meta: { status }, error }: AnnotationActionEvent): Action {\n return status === Status.SUCCESS || error ? Action.REPLY_UPDATE_END : Action.REPLY_UPDATE_START;\n }\n\n getAnnotationsPath(fileVersionId?: string, annotationId?: string | null): string {\n if (!fileVersionId) {\n return '/activity';\n }\n\n return generatePath(ANNOTATIONS_PATH, {\n sidebar: 'activity',\n annotationId: annotationId || undefined,\n fileVersionId,\n });\n }\n\n // remove this method with routerDisabled switch\n getMatchPath(location?: Location): matchType<MatchParams> | null {\n const pathname = getProp(location, 'pathname', '');\n return matchPath<MatchParams>(pathname, {\n path: ANNOTATIONS_PATH,\n exact: true,\n });\n }\n\n handleAnnotationCreate = (eventData: AnnotationActionEvent): void => {\n const { annotation = null, error = null, meta = null } = eventData;\n const { onError } = this.props;\n\n if (onError && error) {\n onError(error, 'create_annotation_error', { showNotification: true });\n }\n\n this.setState({\n ...this.state,\n action: this.getAction(eventData),\n annotation,\n error,\n meta,\n });\n };\n\n handleAnnotationDelete = (eventData: AnnotationActionEvent) => {\n const { annotation = null, error = null, meta = null } = eventData;\n\n this.setState({\n action: this.getDeleteAction(eventData),\n annotation,\n error,\n meta,\n });\n };\n\n handleAnnotationUpdate = (eventData: AnnotationActionEvent) => {\n const { annotation = null, error = null, meta = null } = eventData;\n\n this.setState({\n action: this.getUpdateAction(eventData),\n annotation,\n error,\n meta,\n });\n };\n\n handleAnnotationReplyCreate = (eventData: AnnotationActionEvent) => {\n const { annotation = null, annotationReply = null, error = null, meta = null } = eventData;\n\n this.setState({\n action: this.getReplyCreateAction(eventData),\n annotation,\n annotationReply,\n error,\n meta,\n });\n };\n\n handleAnnotationReplyDelete = (eventData: AnnotationActionEvent) => {\n const { annotation = null, annotationReply = null, error = null, meta = null } = eventData;\n\n this.setState({\n action: this.getReplyDeleteAction(eventData),\n annotation,\n annotationReply,\n error,\n meta,\n });\n };\n\n handleAnnotationReplyUpdate = (eventData: AnnotationActionEvent) => {\n const { annotation = null, annotationReply = null, error = null, meta = null } = eventData;\n\n this.setState({\n action: this.getReplyUpdateAction(eventData),\n annotation,\n annotationReply,\n error,\n meta,\n });\n };\n\n handleActiveChange: ActiveChangeEventHandler = ({ annotationId, fileVersionId }): void => {\n this.setState({ activeAnnotationFileVersionId: fileVersionId, activeAnnotationId: annotationId });\n };\n\n handleAnnotationFetchError = ({ error }: { error: Error }): void => {\n const { onError } = this.props;\n\n if (onError && error) {\n onError(error, 'fetch_annotations_error', { showNotification: true });\n }\n };\n\n handleAnnotator = (annotator: Annotator): void => {\n this.annotator = annotator;\n this.annotator.addListener('annotations_active_change', this.handleActiveChange);\n this.annotator.addListener('annotations_create', this.handleAnnotationCreate);\n this.annotator.addListener('annotations_delete', this.handleAnnotationDelete);\n this.annotator.addListener('annotations_fetch_error', this.handleAnnotationFetchError);\n this.annotator.addListener('annotations_update', this.handleAnnotationUpdate);\n this.annotator.addListener('annotations_reply_create', this.handleAnnotationReplyCreate);\n this.annotator.addListener('annotations_reply_delete', this.handleAnnotationReplyDelete);\n this.annotator.addListener('annotations_reply_update', this.handleAnnotationReplyUpdate);\n };\n\n handlePreviewDestroy = (shouldReset = true): void => {\n if (shouldReset) {\n this.setState(defaultState);\n }\n\n if (this.annotator) {\n this.annotator.removeListener('annotations_active_change', this.handleActiveChange);\n this.annotator.removeListener('annotations_create', this.handleAnnotationCreate);\n this.annotator.removeListener('annotations_delete', this.handleAnnotationDelete);\n this.annotator.removeListener('annotations_fetch_error', this.handleAnnotationFetchError);\n this.annotator.removeListener('annotations_update', this.handleAnnotationUpdate);\n this.annotator.removeListener('annotations_reply_create', this.handleAnnotationReplyCreate);\n this.annotator.removeListener('annotations_reply_delete', this.handleAnnotationReplyDelete);\n this.annotator.removeListener('annotations_reply_update', this.handleAnnotationReplyUpdate);\n }\n\n this.annotator = null;\n };\n\n render(): JSX.Element {\n const isRouterDisabled =\n this.props?.routerDisabled || isFeatureEnabled(this.props?.features, 'routerDisabled.value');\n const annotationsRouterProps = isRouterDisabled\n ? {}\n : {\n getAnnotationsMatchPath: this.getMatchPath,\n getAnnotationsPath: this.getAnnotationsPath,\n };\n return (\n <AnnotatorContext.Provider\n value={{\n emitActiveAnnotationChangeEvent: this.emitActiveAnnotationChangeEvent,\n emitAnnotationRemoveEvent: this.emitAnnotationRemoveEvent,\n emitAnnotationReplyCreateEvent: this.emitAnnotationReplyCreateEvent,\n emitAnnotationReplyDeleteEvent: this.emitAnnotationReplyDeleteEvent,\n emitAnnotationReplyUpdateEvent: this.emitAnnotationReplyUpdateEvent,\n emitAnnotationUpdateEvent: this.emitAnnotationUpdateEvent,\n ...annotationsRouterProps,\n state: this.state,\n }}\n >\n <WrappedComponent\n {...this.props}\n onAnnotator={this.handleAnnotator}\n onPreviewDestroy={this.handlePreviewDestroy}\n />\n </AnnotatorContext.Provider>\n );\n }\n }\n\n const displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';\n ComponentWithAnnotations.displayName = `WithAnnotations(${displayName})`;\n\n return ComponentWithAnnotations;\n}\n"],"mappings":";;;;;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,OAAO,MAAM,YAAY;AAChC,SAASC,YAAY,EAAsBC,SAAS,QAAQ,kBAAkB;AAE9E,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,SAASC,gBAAgB,QAA4B,qBAAqB;AAC1E,SAASC,MAAM,EAA+EC,MAAM,QAAQ,SAAS;AACrH,SAASC,aAAa,QAA2B,4BAA4B;AAiD7E,MAAMC,gBAAgB,GAAG,qDAAqD;AAC9E,MAAMC,YAA4B,GAAG;EACjCC,MAAM,EAAE,IAAI;EACZC,6BAA6B,EAAE,IAAI;EACnCC,kBAAkB,EAAE,IAAI;EACxBC,UAAU,EAAE,IAAI;EAChBC,eAAe,EAAE,IAAI;EACrBC,KAAK,EAAE,IAAI;EACXC,IAAI,EAAE;AACV,CAAC;AAED,eAAe,SAASC,eAAeA,CACnCC,gBAAwC,EACb;EAC3B,MAAMC,wBAAwB,SAASpB,KAAK,CAACqB,SAAS,CAA2C;IAK7FC,WAAWA,CAACC,KAA+B,EAAE;MACzC,KAAK,CAACA,KAAK,CAAC;MAACC,eAAA,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MA,CAAA,EAAgB;MAClB,MAAM5B,gBAAgB,GAClB,IAAI,CAACpC,KAAK,EAAEkC,cAAc,IAAIpD,gBAAgB,CAAC,IAAI,CAACkB,KAAK,EAAEqC,QAAQ,EAAE,sBAAsB,CAAC;MAChG,MAAM4B,sBAAsB,GAAG7B,gBAAgB,GACzC,CAAC,CAAC,GACF;QACI8B,uBAAuB,EAAE,IAAI,CAACvB,YAAY;QAC1Ce,kBAAkB,EAAE,IAAI,CAACA;MAC7B,CAAC;MACP,oBACIjF,KAAA,CAAA0F,aAAA,CAACtF,gBAAgB,CAACuF,QAAQ;QACtBC,KAAK,EAAAvD,aAAA,CAAAA,aAAA;UACDwD,+BAA+B,EAAE,IAAI,CAACA,+BAA+B;UACrEC,yBAAyB,EAAE,IAAI,CAACA,yBAAyB;UACzDC,8BAA8B,EAAE,IAAI,CAACA,8BAA8B;UACnEC,8BAA8B,EAAE,IAAI,CAACA,8BAA8B;UACnEC,8BAA8B,EAAE,IAAI,CAACA,8BAA8B;UACnEC,yBAAyB,EAAE,IAAI,CAACA;QAAyB,GACtDV,sBAAsB;UACzBlD,KAAK,EAAE,IAAI,CAACA;QAAK;MACnB,gBAEFtC,KAAA,CAAA0F,aAAA,CAACvE,gBAAgB,EAAAgF,QAAA,KACT,IAAI,CAAC5E,KAAK;QACd6E,WAAW,EAAE,IAAI,CAACC,eAAgB;QAClCC,gBAAgB,EAAE,IAAI,CAACC;MAAqB,EAC/C,CACsB,CAAC;IAEpC;EACJ;EAEA,MAAMC,WAAW,GAAGrF,gBAAgB,CAACqF,WAAW,IAAIrF,gBAAgB,CAACsF,IAAI,IAAI,WAAW;EACxFrF,wBAAwB,CAACoF,WAAW,GAAG,mBAAmBA,WAAW,GAAG;EAExE,OAAOpF,wBAAwB;AACnC","ignoreList":[]}
@@ -1,29 +1,53 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import * as React from 'react';
3
3
  import AnnotatorContext from './AnnotatorContext';
4
+ import { isFeatureEnabled } from '../feature-checking';
4
5
  export default function withAnnotatorContext(WrappedComponent) {
5
- return /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(AnnotatorContext.Consumer, null, ({
6
- emitActiveAnnotationChangeEvent,
7
- emitAnnotationRemoveEvent,
8
- emitAnnotationReplyCreateEvent,
9
- emitAnnotationReplyDeleteEvent,
10
- emitAnnotationReplyUpdateEvent,
11
- emitAnnotationUpdateEvent,
12
- getAnnotationsMatchPath,
13
- getAnnotationsPath,
14
- state
15
- }) => /*#__PURE__*/React.createElement(WrappedComponent, _extends({
16
- ref: ref
17
- }, props, {
18
- annotatorState: state,
19
- emitActiveAnnotationChangeEvent: emitActiveAnnotationChangeEvent,
20
- emitAnnotationRemoveEvent: emitAnnotationRemoveEvent,
21
- emitAnnotationReplyCreateEvent: emitAnnotationReplyCreateEvent,
22
- emitAnnotationReplyDeleteEvent: emitAnnotationReplyDeleteEvent,
23
- emitAnnotationReplyUpdateEvent: emitAnnotationReplyUpdateEvent,
24
- emitAnnotationUpdateEvent: emitAnnotationUpdateEvent,
25
- getAnnotationsMatchPath: getAnnotationsMatchPath,
26
- getAnnotationsPath: getAnnotationsPath
27
- }))));
6
+ return /*#__PURE__*/React.forwardRef((props, ref) => {
7
+ if (props?.routerDisabled === true || isFeatureEnabled(props?.features, 'routerDisabled.value')) {
8
+ return /*#__PURE__*/React.createElement(AnnotatorContext.Consumer, null, ({
9
+ emitActiveAnnotationChangeEvent,
10
+ emitAnnotationRemoveEvent,
11
+ emitAnnotationReplyCreateEvent,
12
+ emitAnnotationReplyDeleteEvent,
13
+ emitAnnotationReplyUpdateEvent,
14
+ emitAnnotationUpdateEvent,
15
+ state
16
+ }) => /*#__PURE__*/React.createElement(WrappedComponent, _extends({
17
+ ref: ref
18
+ }, props, {
19
+ annotatorState: state,
20
+ emitActiveAnnotationChangeEvent: emitActiveAnnotationChangeEvent,
21
+ emitAnnotationRemoveEvent: emitAnnotationRemoveEvent,
22
+ emitAnnotationReplyCreateEvent: emitAnnotationReplyCreateEvent,
23
+ emitAnnotationReplyDeleteEvent: emitAnnotationReplyDeleteEvent,
24
+ emitAnnotationReplyUpdateEvent: emitAnnotationReplyUpdateEvent,
25
+ emitAnnotationUpdateEvent: emitAnnotationUpdateEvent
26
+ })));
27
+ }
28
+ return /*#__PURE__*/React.createElement(AnnotatorContext.Consumer, null, ({
29
+ emitActiveAnnotationChangeEvent,
30
+ emitAnnotationRemoveEvent,
31
+ emitAnnotationReplyCreateEvent,
32
+ emitAnnotationReplyDeleteEvent,
33
+ emitAnnotationReplyUpdateEvent,
34
+ emitAnnotationUpdateEvent,
35
+ getAnnotationsMatchPath,
36
+ getAnnotationsPath,
37
+ state
38
+ }) => /*#__PURE__*/React.createElement(WrappedComponent, _extends({
39
+ ref: ref
40
+ }, props, {
41
+ annotatorState: state,
42
+ emitActiveAnnotationChangeEvent: emitActiveAnnotationChangeEvent,
43
+ emitAnnotationRemoveEvent: emitAnnotationRemoveEvent,
44
+ emitAnnotationReplyCreateEvent: emitAnnotationReplyCreateEvent,
45
+ emitAnnotationReplyDeleteEvent: emitAnnotationReplyDeleteEvent,
46
+ emitAnnotationReplyUpdateEvent: emitAnnotationReplyUpdateEvent,
47
+ emitAnnotationUpdateEvent: emitAnnotationUpdateEvent,
48
+ getAnnotationsMatchPath: getAnnotationsMatchPath,
49
+ getAnnotationsPath: getAnnotationsPath
50
+ })));
51
+ });
28
52
  }
29
53
  //# sourceMappingURL=withAnnotatorContext.js.map
@@ -7,6 +7,7 @@
7
7
  import * as React from "react";
8
8
  import AnnotatorContext from "./AnnotatorContext";
9
9
  import { AnnotatorState, GetMatchPath } from "./types";
10
+
10
11
  export interface WithAnnotatorContextProps {
11
12
  annotatorState?: AnnotatorState;
12
13
  emitActiveAnnotationChangeEvent?: (id: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"withAnnotatorContext.js","names":["React","AnnotatorContext","withAnnotatorContext","WrappedComponent","forwardRef","props","ref","createElement","Consumer","emitActiveAnnotationChangeEvent","emitAnnotationRemoveEvent","emitAnnotationReplyCreateEvent","emitAnnotationReplyDeleteEvent","emitAnnotationReplyUpdateEvent","emitAnnotationUpdateEvent","getAnnotationsMatchPath","getAnnotationsPath","state","_extends","annotatorState"],"sources":["../../../../src/elements/common/annotator-context/withAnnotatorContext.tsx"],"sourcesContent":["import * as React from 'react';\nimport AnnotatorContext from './AnnotatorContext';\nimport { AnnotatorState, GetMatchPath } from './types';\n\nexport interface WithAnnotatorContextProps {\n annotatorState?: AnnotatorState;\n emitActiveAnnotationChangeEvent?: (id: string) => void;\n emitAnnotationRemoveEvent?: (id: string, isStartEvent?: boolean) => void;\n emitAnnotationReplyCreateEvent?: (\n reply: Object,\n requestId: string,\n annotationId: string,\n isStartEvent?: boolean,\n ) => void;\n emitAnnotationReplyDeleteEvent?: (id: string, annotationId: string, isStartEvent?: boolean) => void;\n emitAnnotationReplyUpdateEvent?: (reply: Object, annotationId: string, isStartEvent?: boolean) => void;\n emitAnnotationUpdateEvent?: (annotation: Object, isStartEvent?: boolean) => void;\n getAnnotationsMatchPath?: GetMatchPath;\n getAnnotationsPath?: (fileVersionId?: string, annotationId?: string) => string;\n}\n\nexport default function withAnnotatorContext<P extends {}>(WrappedComponent: React.ComponentType<P>) {\n return React.forwardRef<React.ComponentType<P>, P>((props, ref) => (\n <AnnotatorContext.Consumer>\n {({\n emitActiveAnnotationChangeEvent,\n emitAnnotationRemoveEvent,\n emitAnnotationReplyCreateEvent,\n emitAnnotationReplyDeleteEvent,\n emitAnnotationReplyUpdateEvent,\n emitAnnotationUpdateEvent,\n getAnnotationsMatchPath,\n getAnnotationsPath,\n state,\n }) => (\n <WrappedComponent\n ref={ref}\n {...props}\n annotatorState={state}\n emitActiveAnnotationChangeEvent={emitActiveAnnotationChangeEvent}\n emitAnnotationRemoveEvent={emitAnnotationRemoveEvent}\n emitAnnotationReplyCreateEvent={emitAnnotationReplyCreateEvent}\n emitAnnotationReplyDeleteEvent={emitAnnotationReplyDeleteEvent}\n emitAnnotationReplyUpdateEvent={emitAnnotationReplyUpdateEvent}\n emitAnnotationUpdateEvent={emitAnnotationUpdateEvent}\n getAnnotationsMatchPath={getAnnotationsMatchPath}\n getAnnotationsPath={getAnnotationsPath}\n />\n )}\n </AnnotatorContext.Consumer>\n ));\n}\n"],"mappings":";AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,gBAAgB,MAAM,oBAAoB;AAoBjD,eAAe,SAASC,oBAAoBA,CAAeC,gBAAwC,EAAE;EACjG,oBAAOH,KAAK,CAACI,UAAU,CAA4B,CAACC,KAAK,EAAEC,GAAG,kBAC1DN,KAAA,CAAAO,aAAA,CAACN,gBAAgB,CAACO,QAAQ,QACrB,CAAC;IACEC,+BAA+B;IAC/BC,yBAAyB;IACzBC,8BAA8B;IAC9BC,8BAA8B;IAC9BC,8BAA8B;IAC9BC,yBAAyB;IACzBC,uBAAuB;IACvBC,kBAAkB;IAClBC;EACJ,CAAC,kBACGjB,KAAA,CAAAO,aAAA,CAACJ,gBAAgB,EAAAe,QAAA;IACbZ,GAAG,EAAEA;EAAI,GACLD,KAAK;IACTc,cAAc,EAAEF,KAAM;IACtBR,+BAA+B,EAAEA,+BAAgC;IACjEC,yBAAyB,EAAEA,yBAA0B;IACrDC,8BAA8B,EAAEA,8BAA+B;IAC/DC,8BAA8B,EAAEA,8BAA+B;IAC/DC,8BAA8B,EAAEA,8BAA+B;IAC/DC,yBAAyB,EAAEA,yBAA0B;IACrDC,uBAAuB,EAAEA,uBAAwB;IACjDC,kBAAkB,EAAEA;EAAmB,EAC1C,CAEkB,CAC9B,CAAC;AACN","ignoreList":[]}
1
+ {"version":3,"file":"withAnnotatorContext.js","names":["React","AnnotatorContext","isFeatureEnabled","withAnnotatorContext","WrappedComponent","forwardRef","props","ref","routerDisabled","features","createElement","Consumer","emitActiveAnnotationChangeEvent","emitAnnotationRemoveEvent","emitAnnotationReplyCreateEvent","emitAnnotationReplyDeleteEvent","emitAnnotationReplyUpdateEvent","emitAnnotationUpdateEvent","state","_extends","annotatorState","getAnnotationsMatchPath","getAnnotationsPath"],"sources":["../../../../src/elements/common/annotator-context/withAnnotatorContext.tsx"],"sourcesContent":["import * as React from 'react';\nimport AnnotatorContext from './AnnotatorContext';\nimport { isFeatureEnabled, type FeatureConfig } from '../feature-checking';\nimport { AnnotatorState, GetMatchPath } from './types';\n\nexport interface WithAnnotatorContextProps {\n annotatorState?: AnnotatorState;\n emitActiveAnnotationChangeEvent?: (id: string) => void;\n emitAnnotationRemoveEvent?: (id: string, isStartEvent?: boolean) => void;\n emitAnnotationReplyCreateEvent?: (\n reply: Object,\n requestId: string,\n annotationId: string,\n isStartEvent?: boolean,\n ) => void;\n emitAnnotationReplyDeleteEvent?: (id: string, annotationId: string, isStartEvent?: boolean) => void;\n emitAnnotationReplyUpdateEvent?: (reply: Object, annotationId: string, isStartEvent?: boolean) => void;\n emitAnnotationUpdateEvent?: (annotation: Object, isStartEvent?: boolean) => void;\n getAnnotationsMatchPath?: GetMatchPath;\n getAnnotationsPath?: (fileVersionId?: string, annotationId?: string) => string;\n}\n\nexport default function withAnnotatorContext<P extends {}>(WrappedComponent: React.ComponentType<P>) {\n return React.forwardRef<React.ComponentType<P>, P & { routerDisabled?: boolean; features?: FeatureConfig }>(\n (props, ref) => {\n if (props?.routerDisabled === true || isFeatureEnabled(props?.features, 'routerDisabled.value')) {\n return (\n <AnnotatorContext.Consumer>\n {({\n emitActiveAnnotationChangeEvent,\n emitAnnotationRemoveEvent,\n emitAnnotationReplyCreateEvent,\n emitAnnotationReplyDeleteEvent,\n emitAnnotationReplyUpdateEvent,\n emitAnnotationUpdateEvent,\n state,\n }) => (\n <WrappedComponent\n ref={ref}\n {...props}\n annotatorState={state}\n emitActiveAnnotationChangeEvent={emitActiveAnnotationChangeEvent}\n emitAnnotationRemoveEvent={emitAnnotationRemoveEvent}\n emitAnnotationReplyCreateEvent={emitAnnotationReplyCreateEvent}\n emitAnnotationReplyDeleteEvent={emitAnnotationReplyDeleteEvent}\n emitAnnotationReplyUpdateEvent={emitAnnotationReplyUpdateEvent}\n emitAnnotationUpdateEvent={emitAnnotationUpdateEvent}\n />\n )}\n </AnnotatorContext.Consumer>\n );\n }\n return (\n <AnnotatorContext.Consumer>\n {({\n emitActiveAnnotationChangeEvent,\n emitAnnotationRemoveEvent,\n emitAnnotationReplyCreateEvent,\n emitAnnotationReplyDeleteEvent,\n emitAnnotationReplyUpdateEvent,\n emitAnnotationUpdateEvent,\n getAnnotationsMatchPath,\n getAnnotationsPath,\n state,\n }) => (\n <WrappedComponent\n ref={ref}\n {...props}\n annotatorState={state}\n emitActiveAnnotationChangeEvent={emitActiveAnnotationChangeEvent}\n emitAnnotationRemoveEvent={emitAnnotationRemoveEvent}\n emitAnnotationReplyCreateEvent={emitAnnotationReplyCreateEvent}\n emitAnnotationReplyDeleteEvent={emitAnnotationReplyDeleteEvent}\n emitAnnotationReplyUpdateEvent={emitAnnotationReplyUpdateEvent}\n emitAnnotationUpdateEvent={emitAnnotationUpdateEvent}\n getAnnotationsMatchPath={getAnnotationsMatchPath}\n getAnnotationsPath={getAnnotationsPath}\n />\n )}\n </AnnotatorContext.Consumer>\n );\n },\n );\n}\n"],"mappings":";AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,SAASC,gBAAgB,QAA4B,qBAAqB;AAoB1E,eAAe,SAASC,oBAAoBA,CAAeC,gBAAwC,EAAE;EACjG,oBAAOJ,KAAK,CAACK,UAAU,CACnB,CAACC,KAAK,EAAEC,GAAG,KAAK;IACZ,IAAID,KAAK,EAAEE,cAAc,KAAK,IAAI,IAAIN,gBAAgB,CAACI,KAAK,EAAEG,QAAQ,EAAE,sBAAsB,CAAC,EAAE;MAC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',
3
+ SKILLS: 'skills',
4
+ ACTIVITY: 'activity',
5
+ DETAILS: 'details',
6
+ METADATA: 'metadata',
7
+ DOCGEN: 'docgen'
8
+ });
9
+ export const FeedEntryType = Object.freeze({
10
+ ANNOTATIONS: 'annotations',
11
+ COMMENTS: 'comments',
12
+ TASKS: 'tasks'
13
+ });
14
+ //# sourceMappingURL=SidebarNavigation.flow.js.map
@@ -0,0 +1,52 @@
1
+ /* @flow */
2
+
3
+ export const ViewType = Object.freeze({
4
+ BOXAI: 'boxai',
5
+ SKILLS: 'skills',
6
+ ACTIVITY: 'activity',
7
+ DETAILS: 'details',
8
+ METADATA: 'metadata',
9
+ DOCGEN: 'docgen',
10
+ });
11
+
12
+ export const FeedEntryType = Object.freeze({
13
+ ANNOTATIONS: 'annotations',
14
+ COMMENTS: 'comments',
15
+ TASKS: 'tasks',
16
+ });
17
+
18
+ export type ViewTypeValues = $Values<typeof ViewType>;
19
+ export type FeedEntryTypeValues = $Values<typeof FeedEntryType>;
20
+
21
+ type VersionSidebarView = {
22
+ sidebar: 'activity' | 'details',
23
+ versionId: string,
24
+ };
25
+
26
+ export type ActivityAnnotationsSidebarView = {
27
+ sidebar: 'activity',
28
+ activeFeedEntryType: 'annotations',
29
+ fileVersionId: string,
30
+ activeFeedEntryId: string,
31
+ };
32
+ type ActivityCommentsSidebarView = {
33
+ sidebar: 'activity',
34
+ activeFeedEntryType: 'comments' | 'tasks',
35
+ activeFeedEntryId: string,
36
+ };
37
+
38
+ export type SidebarNavigation =
39
+ | {|
40
+ sidebar: ViewTypeValues,
41
+ |}
42
+ | VersionSidebarView
43
+ | ActivityCommentsSidebarView
44
+ | ActivityAnnotationsSidebarView;
45
+
46
+ export type InternalSidebarNavigation = SidebarNavigation & {
47
+ open: boolean,
48
+ };
49
+
50
+ export type SidebarNavigationHandler = (sidebar: SidebarNavigation, replace?: boolean) => void;
51
+
52
+ export type InternalSidebarNavigationHandler = (sidebar: InternalSidebarNavigation, replace?: boolean) => void;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidebarNavigation.flow.js","names":["ViewType","Object","freeze","BOXAI","SKILLS","ACTIVITY","DETAILS","METADATA","DOCGEN","FeedEntryType","ANNOTATIONS","COMMENTS","TASKS"],"sources":["../../../../src/elements/common/types/SidebarNavigation.flow.js"],"sourcesContent":["/* @flow */\n\nexport const ViewType = Object.freeze({\n BOXAI: 'boxai',\n SKILLS: 'skills',\n ACTIVITY: 'activity',\n DETAILS: 'details',\n METADATA: 'metadata',\n DOCGEN: 'docgen',\n});\n\nexport const FeedEntryType = Object.freeze({\n ANNOTATIONS: 'annotations',\n COMMENTS: 'comments',\n TASKS: 'tasks',\n});\n\nexport type ViewTypeValues = $Values<typeof ViewType>;\nexport type FeedEntryTypeValues = $Values<typeof FeedEntryType>;\n\ntype VersionSidebarView = {\n sidebar: 'activity' | 'details',\n versionId: string,\n};\n\nexport type ActivityAnnotationsSidebarView = {\n sidebar: 'activity',\n activeFeedEntryType: 'annotations',\n fileVersionId: string,\n activeFeedEntryId: string,\n};\ntype ActivityCommentsSidebarView = {\n sidebar: 'activity',\n activeFeedEntryType: 'comments' | 'tasks',\n activeFeedEntryId: string,\n};\n\nexport type SidebarNavigation =\n | {|\n sidebar: ViewTypeValues,\n |}\n | VersionSidebarView\n | ActivityCommentsSidebarView\n | ActivityAnnotationsSidebarView;\n\nexport type InternalSidebarNavigation = SidebarNavigation & {\n open: boolean,\n};\n\nexport type SidebarNavigationHandler = (sidebar: SidebarNavigation, replace?: boolean) => void;\n\nexport type InternalSidebarNavigationHandler = (sidebar: InternalSidebarNavigation, replace?: boolean) => void;\n"],"mappings":"AAEA,OAAO,MAAMA,QAAQ,GAAGC,MAAM,CAACC,MAAM,CAAC;EAClCC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE,QAAQ;EAChBC,QAAQ,EAAE,UAAU;EACpBC,OAAO,EAAE,SAAS;EAClBC,QAAQ,EAAE,UAAU;EACpBC,MAAM,EAAE;AACZ,CAAC,CAAC;AAEF,OAAO,MAAMC,aAAa,GAAGR,MAAM,CAACC,MAAM,CAAC;EACvCQ,WAAW,EAAE,aAAa;EAC1BC,QAAQ,EAAE,UAAU;EACpBC,KAAK,EAAE;AACX,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ export let ViewType = /*#__PURE__*/function (ViewType) {
2
+ ViewType["BOXAI"] = "boxai";
3
+ ViewType["SKILLS"] = "skills";
4
+ ViewType["ACTIVITY"] = "activity";
5
+ ViewType["DETAILS"] = "details";
6
+ ViewType["METADATA"] = "metadata";
7
+ ViewType["DOCGEN"] = "docgen";
8
+ return ViewType;
9
+ }({});
10
+ export let FeedEntryType = /*#__PURE__*/function (FeedEntryType) {
11
+ FeedEntryType["ANNOTATIONS"] = "annotations";
12
+ FeedEntryType["COMMENTS"] = "comments";
13
+ FeedEntryType["TASKS"] = "tasks";
14
+ return FeedEntryType;
15
+ }({});
16
+ //# sourceMappingURL=SidebarNavigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidebarNavigation.js","names":["ViewType","FeedEntryType"],"sources":["../../../../src/elements/common/types/SidebarNavigation.ts"],"sourcesContent":["export enum ViewType {\n BOXAI = 'boxai',\n SKILLS = 'skills',\n ACTIVITY = 'activity',\n DETAILS = 'details',\n METADATA = 'metadata',\n DOCGEN = 'docgen',\n}\n\nexport enum FeedEntryType {\n ANNOTATIONS = 'annotations',\n COMMENTS = 'comments',\n TASKS = 'tasks',\n}\n\ntype VersionSidebarView = {\n sidebar: ViewType.ACTIVITY | ViewType.DETAILS;\n versionId: string;\n};\n\nexport type ActivityAnnotationsSidebarView = {\n sidebar: ViewType.ACTIVITY;\n activeFeedEntryType: FeedEntryType.ANNOTATIONS;\n fileVersionId: string;\n activeFeedEntryId: string;\n};\ntype ActivityCommentsSidebarView = {\n sidebar: ViewType.ACTIVITY;\n activeFeedEntryType: FeedEntryType.COMMENTS | FeedEntryType.TASKS;\n activeFeedEntryId: string;\n};\n\nexport type SidebarNavigation =\n | {\n sidebar: ViewType;\n }\n | VersionSidebarView\n | ActivityCommentsSidebarView\n | ActivityAnnotationsSidebarView;\n\nexport type InternalSidebarNavigation = SidebarNavigation & {\n open: boolean;\n};\n\nexport type SidebarNavigationHandler = (sidebar: SidebarNavigation, replace?: boolean) => void;\n\nexport type InternalSidebarNavigationHandler = (sidebar: InternalSidebarNavigation, replace?: boolean) => void;\n"],"mappings":"AAAA,WAAYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AASpB,WAAYC,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA","ignoreList":[]}
@@ -3,7 +3,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
3
3
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
4
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
5
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
- import { act } from 'react';
7
6
  import { http, HttpResponse } from 'msw';
8
7
  import { expect, userEvent, waitFor, within, fn, screen } from '@storybook/test';
9
8
  import ContentSidebar from '../../ContentSidebar';
@@ -235,15 +234,11 @@ export const MetadataInstanceEditorWithCustomTemplate = {
235
234
  }, {
236
235
  timeout: 2000
237
236
  });
238
- await act(async () => {
239
- await userEvent.click(addTemplateButton);
240
- });
237
+ await userEvent.click(addTemplateButton);
241
238
  const customMetadataOption = canvas.getByRole('option', {
242
239
  name: 'Custom Metadata'
243
240
  });
244
- await act(async () => {
245
- await userEvent.click(customMetadataOption);
246
- });
241
+ await userEvent.click(customMetadataOption);
247
242
  }
248
243
  };
249
244
  export const MetadataInstanceEditorCancelChanges = {
@@ -292,16 +287,12 @@ export const DeleteButtonIsDisabledWhenAddingNewMetadataTemplate = {
292
287
  name: 'Add template'
293
288
  });
294
289
  expect(addTemplateButton).toBeInTheDocument();
295
- await act(async () => {
296
- await userEvent.click(addTemplateButton);
297
- });
290
+ await userEvent.click(addTemplateButton);
298
291
  const customMetadataOption = canvas.getByRole('option', {
299
292
  name: 'Virus Scan'
300
293
  });
301
294
  expect(customMetadataOption).toBeInTheDocument();
302
- await act(async () => {
303
- await userEvent.click(customMetadataOption);
304
- });
295
+ await userEvent.click(customMetadataOption);
305
296
  const deleteButton = await canvas.findByRole('button', {
306
297
  name: 'Delete'
307
298
  });