Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 1588x 1588x 1228x 360x 360x | import { Annotation } from '../../../types';
import { isAnnotationLocked } from '../annotationLocking';
import { isAnnotationSelected } from '../annotationSelection';
import { AnnotationStyleStates } from '../../../enums';
/**
* Given a Annotation object, return the annotationStyle State that it
* should be in based on its data.
* The ordering of states is:
* * Highlighted
* * Selected
* * Locked
* * Autogenerated
* * Default
* So the first one that applies will be returned.
* For the autogenerated state, it depends on the autoGenerated flag on the
* annotation, so once that is gone/false, the annotation will go to default.
*
* @param annotation - The annotation that we want to style.
* @returns The state of the annotation whether it is Default, Highlighted, Locked, Selected, or AutoGenerated.
*/
function getState(annotation?: Annotation): AnnotationStyleStates {
Eif (annotation) {
if (annotation.data && annotation.highlighted) {
return AnnotationStyleStates.Highlighted;
}
Eif (isAnnotationSelected(annotation.annotationUID)) {
return AnnotationStyleStates.Selected;
}
// Todo: make annotation lock api not to rely on the annotation itself
if (isAnnotationLocked(annotation)) {
return AnnotationStyleStates.Locked;
}
if (annotation.data && annotation.autoGenerated) {
return AnnotationStyleStates.AutoGenerated;
}
}
return AnnotationStyleStates.Default;
}
export default getState;
|