@insync-stageplayer/annotations 0.5.35-beta.1 → 0.5.37

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 (53) hide show
  1. package/lib/components/AnnotationContent.d.ts +37 -37
  2. package/lib/components/AnnotationContent.js +59 -59
  3. package/lib/components/AnnotationEditForm.d.ts +26 -26
  4. package/lib/components/AnnotationEditForm.js +146 -146
  5. package/lib/components/AnnotationsModuleProvider.d.ts +36 -36
  6. package/lib/components/AnnotationsModuleProvider.js +20 -20
  7. package/lib/components/AnnotationsViewer.d.ts +15 -15
  8. package/lib/components/AnnotationsViewer.js +107 -107
  9. package/lib/components/DraggablePosition.d.ts +31 -31
  10. package/lib/components/DraggablePosition.js +62 -62
  11. package/lib/components/MeasurementDisplayDataContext.d.ts +10 -10
  12. package/lib/components/MeasurementDisplayDataContext.js +2 -2
  13. package/lib/components/MeasurementDisplayDataProvider.d.ts +15 -15
  14. package/lib/components/MeasurementDisplayDataProvider.d.ts.map +1 -1
  15. package/lib/components/MeasurementDisplayDataProvider.js +45 -45
  16. package/lib/components/MeasurementDisplayDataProvider.js.map +1 -1
  17. package/lib/components/MeasurementDisplayEditor.d.ts +19 -19
  18. package/lib/components/MeasurementDisplayEditor.js +136 -136
  19. package/lib/components/MeasurementDisplayElement.d.ts +18 -18
  20. package/lib/components/MeasurementDisplayElement.d.ts.map +1 -1
  21. package/lib/components/MeasurementDisplayElement.js +97 -65
  22. package/lib/components/MeasurementDisplayElement.js.map +1 -1
  23. package/lib/components/ModalAnnotationEditor.d.ts +12 -12
  24. package/lib/components/ModalAnnotationEditor.js +37 -37
  25. package/lib/formatNumber.d.ts +29 -29
  26. package/lib/formatNumber.js +12 -12
  27. package/lib/hooks/useMeasurementDisplayData.d.ts +14 -14
  28. package/lib/hooks/useMeasurementDisplayData.js +39 -39
  29. package/lib/index.d.ts +7 -8
  30. package/lib/index.d.ts.map +1 -1
  31. package/lib/index.js +7 -8
  32. package/lib/index.js.map +1 -1
  33. package/lib/redux/actions.d.ts +1 -1
  34. package/lib/redux/actions.js +1 -1
  35. package/lib/redux/annotationEditor.slice.d.ts +37 -37
  36. package/lib/redux/annotationEditor.slice.d.ts.map +1 -1
  37. package/lib/redux/annotationEditor.slice.js +122 -122
  38. package/lib/redux/annotations.slice.d.ts +31 -31
  39. package/lib/redux/annotations.slice.d.ts.map +1 -1
  40. package/lib/redux/annotations.slice.js +65 -65
  41. package/lib/redux/measurementDisplayEditor.slice.d.ts +25 -25
  42. package/lib/redux/measurementDisplayEditor.slice.d.ts.map +1 -1
  43. package/lib/redux/measurementDisplayEditor.slice.js +36 -36
  44. package/lib/redux/measurementDisplays.slice.d.ts +25 -25
  45. package/lib/redux/measurementDisplays.slice.d.ts.map +1 -1
  46. package/lib/redux/measurementDisplays.slice.js +22 -22
  47. package/lib/redux/reducer.d.ts +51 -51
  48. package/lib/redux/reducer.js +65 -65
  49. package/lib/useBoundingRect.d.ts +8 -8
  50. package/lib/useBoundingRect.js +27 -27
  51. package/lib/util.d.ts +5 -5
  52. package/lib/util.js +7 -7
  53. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"annotationEditor.slice.d.ts","sourceRoot":"","sources":["../../src/redux/annotationEditor.slice.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,aAAK,iBAAiB,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG;IAChD,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;CACxB,CAAC;AAoIF,eAAO,MACL,UAAU,sHACV,aAAa,iGACb,eAAe,8FACf,qBAAqB,yGACrB,sBAAsB,0GACtB,oBAAoB,mGACpB,qBAAqB,oGACrB,mBAAmB,sGACnB,WAAW,+FACX,oBAAoB,iGACW,CAAC;;IAhIhC;;OAEG;;IAEH;;;OAGG;;;;;IAKH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;;AAwGL,wBAA6C"}
1
+ {"version":3,"file":"annotationEditor.slice.d.ts","sourceRoot":"","sources":["../../src/redux/annotationEditor.slice.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,aAAK,iBAAiB,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG;IAChD,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;CACxB,CAAC;AAoIF,eAAO,MACL,UAAU,+FACV,aAAa,uEACb,eAAe,kEACf,qBAAqB,uEACrB,sBAAsB,uEACtB,oBAAoB,kEACpB,qBAAqB,kEACrB,mBAAmB,sEACnB,WAAW,uEACX,oBAAoB,gEACW,CAAC;;IAhIhC;;OAEG;;IAEH;;;OAGG;;;;;IAKH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;;AAwGL,wBAA6C"}
@@ -1,123 +1,123 @@
1
- /**
2
- * Contains the "slice" of state for the annotation editor.
3
- */
4
- import { createSlice } from "@reduxjs/toolkit";
5
- import { diff } from "deep-diff";
6
- const defaultAnnotation = {
7
- id: undefined,
8
- // This has to be added, and is interpreted as an empty value. If you provide undefined, you'll be presented with unexpected behaviour.
9
- content: [
10
- {
11
- type: "paragraph",
12
- children: [{ text: "" }],
13
- },
14
- ],
15
- position: { x: 0, y: 0 },
16
- };
17
- const createInitialState = (annotation) => ({
18
- /**
19
- * The current annotation being edited.
20
- */
21
- annotation: annotation || defaultAnnotation,
22
- /**
23
- * The current displays added to the editor. We're tracking this so they can be added or deleted
24
- * depending on whether the editor is submitted or cancelled.
25
- */
26
- displays: {
27
- added: [],
28
- deleted: [],
29
- },
30
- /**
31
- * When set to true, will show a measurement chooser.
32
- */
33
- pickingMeasurement: false,
34
- /**
35
- * The measurement chosen in the measurement chooser.
36
- */
37
- chosenMeasurement: null,
38
- /**
39
- * An error that might have ocurred while selecting a measurement.
40
- */
41
- pickingMeasurementError: null,
42
- /**
43
- * The MeasurementDisplay currently being editted.
44
- */
45
- editingMeasurementDisplay: null,
46
- });
47
- const annotationEditorSlice = createSlice({
48
- name: "annotationEditor",
49
- initialState: createInitialState(),
50
- reducers: {
51
- initEditor: (state, action) => {
52
- state.pickingMeasurement = false;
53
- state.pickingMeasurementError = null;
54
- state.chosenMeasurement = null;
55
- state.editingMeasurementDisplay = null;
56
- state.annotation = action.payload || defaultAnnotation;
57
- state.displays = {
58
- added: [],
59
- deleted: [],
60
- };
61
- },
62
- updateContent: (state, action) => {
63
- const newContent = action.payload;
64
- // Make a deep clone of the content.
65
- const oldContent = JSON.parse(JSON.stringify(state.annotation.content));
66
- const difference = diff(oldContent, newContent) || [];
67
- // This compares the difference between the old content and new content, and checks
68
- // if any measurement displays where created or deleted. We need to keep track of these
69
- // because according to what happens with the editing annotation after the form is finished,
70
- // we might have to delete measurement displays.
71
- state.displays = difference.reduce((acc, c) => {
72
- // Detect any deleted measurementDisplays.
73
- if (c.kind === "A" &&
74
- c.item.kind === "D" &&
75
- c.item.lhs.type === "measurementDisplay") {
76
- acc.deleted.push(c.item.lhs.measurementDisplayId);
77
- acc.added.splice(acc.added.indexOf(c.item.lhs.measurementDisplayId), 1);
78
- }
79
- // Detect any added measurementDisplays.
80
- if (c.kind === "A" &&
81
- c.item.kind === "N" &&
82
- c.item.rhs.type === "measurementDisplay") {
83
- acc.added.push(c.item.rhs.measurementDisplayId);
84
- }
85
- return acc;
86
- }, state.displays);
87
- state.annotation.content = action.payload;
88
- },
89
- pickMeasurement: (state) => {
90
- state.pickingMeasurement = true;
91
- state.chosenMeasurement = null;
92
- state.pickingMeasurementError = null;
93
- },
94
- pickMeasurementSuccess: (state, action) => {
95
- state.editingMeasurementDisplay = action.payload;
96
- state.pickingMeasurement = false;
97
- state.chosenMeasurement = null;
98
- },
99
- pickMeasurementClose: (state) => {
100
- state.pickingMeasurement = false;
101
- state.chosenMeasurement = null;
102
- },
103
- pickMeasurementSubmit: (state) => {
104
- state.pickingMeasurement = false;
105
- },
106
- pickMeasurementChoose: (state, action) => {
107
- state.chosenMeasurement = action.payload;
108
- },
109
- pickMeasurementFail: (state, action) => {
110
- state.pickingMeasurement = false;
111
- state.pickingMeasurementError = action.payload;
112
- },
113
- editDisplay: (state, action) => {
114
- state.editingMeasurementDisplay = action.payload;
115
- },
116
- finishEditingDisplay: (state) => {
117
- state.editingMeasurementDisplay = null;
118
- },
119
- },
120
- });
121
- export const { initEditor, updateContent, pickMeasurement, pickMeasurementChoose, pickMeasurementSuccess, pickMeasurementClose, pickMeasurementSubmit, pickMeasurementFail, editDisplay, finishEditingDisplay, } = annotationEditorSlice.actions;
122
- export default annotationEditorSlice.reducer;
1
+ /**
2
+ * Contains the "slice" of state for the annotation editor.
3
+ */
4
+ import { createSlice } from "@reduxjs/toolkit";
5
+ import { diff } from "deep-diff";
6
+ const defaultAnnotation = {
7
+ id: undefined,
8
+ // This has to be added, and is interpreted as an empty value. If you provide undefined, you'll be presented with unexpected behaviour.
9
+ content: [
10
+ {
11
+ type: "paragraph",
12
+ children: [{ text: "" }],
13
+ },
14
+ ],
15
+ position: { x: 0, y: 0 },
16
+ };
17
+ const createInitialState = (annotation) => ({
18
+ /**
19
+ * The current annotation being edited.
20
+ */
21
+ annotation: annotation || defaultAnnotation,
22
+ /**
23
+ * The current displays added to the editor. We're tracking this so they can be added or deleted
24
+ * depending on whether the editor is submitted or cancelled.
25
+ */
26
+ displays: {
27
+ added: [],
28
+ deleted: [],
29
+ },
30
+ /**
31
+ * When set to true, will show a measurement chooser.
32
+ */
33
+ pickingMeasurement: false,
34
+ /**
35
+ * The measurement chosen in the measurement chooser.
36
+ */
37
+ chosenMeasurement: null,
38
+ /**
39
+ * An error that might have ocurred while selecting a measurement.
40
+ */
41
+ pickingMeasurementError: null,
42
+ /**
43
+ * The MeasurementDisplay currently being editted.
44
+ */
45
+ editingMeasurementDisplay: null,
46
+ });
47
+ const annotationEditorSlice = createSlice({
48
+ name: "annotationEditor",
49
+ initialState: createInitialState(),
50
+ reducers: {
51
+ initEditor: (state, action) => {
52
+ state.pickingMeasurement = false;
53
+ state.pickingMeasurementError = null;
54
+ state.chosenMeasurement = null;
55
+ state.editingMeasurementDisplay = null;
56
+ state.annotation = action.payload || defaultAnnotation;
57
+ state.displays = {
58
+ added: [],
59
+ deleted: [],
60
+ };
61
+ },
62
+ updateContent: (state, action) => {
63
+ const newContent = action.payload;
64
+ // Make a deep clone of the content.
65
+ const oldContent = JSON.parse(JSON.stringify(state.annotation.content));
66
+ const difference = diff(oldContent, newContent) || [];
67
+ // This compares the difference between the old content and new content, and checks
68
+ // if any measurement displays where created or deleted. We need to keep track of these
69
+ // because according to what happens with the editing annotation after the form is finished,
70
+ // we might have to delete measurement displays.
71
+ state.displays = difference.reduce((acc, c) => {
72
+ // Detect any deleted measurementDisplays.
73
+ if (c.kind === "A" &&
74
+ c.item.kind === "D" &&
75
+ c.item.lhs.type === "measurementDisplay") {
76
+ acc.deleted.push(c.item.lhs.measurementDisplayId);
77
+ acc.added.splice(acc.added.indexOf(c.item.lhs.measurementDisplayId), 1);
78
+ }
79
+ // Detect any added measurementDisplays.
80
+ if (c.kind === "A" &&
81
+ c.item.kind === "N" &&
82
+ c.item.rhs.type === "measurementDisplay") {
83
+ acc.added.push(c.item.rhs.measurementDisplayId);
84
+ }
85
+ return acc;
86
+ }, state.displays);
87
+ state.annotation.content = action.payload;
88
+ },
89
+ pickMeasurement: (state) => {
90
+ state.pickingMeasurement = true;
91
+ state.chosenMeasurement = null;
92
+ state.pickingMeasurementError = null;
93
+ },
94
+ pickMeasurementSuccess: (state, action) => {
95
+ state.editingMeasurementDisplay = action.payload;
96
+ state.pickingMeasurement = false;
97
+ state.chosenMeasurement = null;
98
+ },
99
+ pickMeasurementClose: (state) => {
100
+ state.pickingMeasurement = false;
101
+ state.chosenMeasurement = null;
102
+ },
103
+ pickMeasurementSubmit: (state) => {
104
+ state.pickingMeasurement = false;
105
+ },
106
+ pickMeasurementChoose: (state, action) => {
107
+ state.chosenMeasurement = action.payload;
108
+ },
109
+ pickMeasurementFail: (state, action) => {
110
+ state.pickingMeasurement = false;
111
+ state.pickingMeasurementError = action.payload;
112
+ },
113
+ editDisplay: (state, action) => {
114
+ state.editingMeasurementDisplay = action.payload;
115
+ },
116
+ finishEditingDisplay: (state) => {
117
+ state.editingMeasurementDisplay = null;
118
+ },
119
+ },
120
+ });
121
+ export const { initEditor, updateContent, pickMeasurement, pickMeasurementChoose, pickMeasurementSuccess, pickMeasurementClose, pickMeasurementSubmit, pickMeasurementFail, editDisplay, finishEditingDisplay, } = annotationEditorSlice.actions;
122
+ export default annotationEditorSlice.reducer;
123
123
  //# sourceMappingURL=annotationEditor.slice.js.map
@@ -1,32 +1,32 @@
1
- import { Node } from "slate";
2
- import { Position2D } from "@insync-stageplayer/common";
3
- /**
4
- * An annotation that can be placed on a 2D surface
5
- */
6
- export declare type Annotation = {
7
- id: string;
8
- /**
9
- * The position {x, y} of the annotation.
10
- */
11
- position: Position2D;
12
- /**
13
- * The content of the annotation, this is a slate js node.
14
- */
15
- content?: Node[];
16
- };
17
- /**
18
- * Checks if an argument is a valid annotation.
19
- * @param arg
20
- * @returns
21
- */
22
- export declare function isAnnotation(arg: unknown): arg is Annotation;
23
- /**
24
- * Please read up https://redux-toolkit.js.org/usage/usage-with-typescript#createentityadapter to understand what this is.
25
- */
26
- export declare const annotationsAdapter: import("@reduxjs/toolkit").EntityAdapter<Annotation>;
27
- export declare const editAnnotation: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "annotations/editAnnotation">, editAnnotationCancel: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"annotations/editAnnotationCancel">, editAnnotationSubmit: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "annotations/editAnnotationSubmit">, editAnnotationDelete: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"annotations/editAnnotationDelete">, createAnnotation: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "annotations/createAnnotation">, createAnnotations: import("@reduxjs/toolkit").ActionCreatorWithPayload<Record<import("@reduxjs/toolkit").EntityId, Annotation> | readonly Annotation[], "annotations/createAnnotations">, updateAnnotation: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("@reduxjs/toolkit").Update<Annotation>, "annotations/updateAnnotation">, deleteAnnotation: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("@reduxjs/toolkit").EntityId, "annotations/deleteAnnotation">;
28
- declare const _default: import("redux").Reducer<import("@reduxjs/toolkit").EntityState<Annotation> & {
29
- editingAnnotation: string | undefined;
30
- }, import("redux").AnyAction>;
31
- export default _default;
1
+ import { Node } from "slate";
2
+ import { Position2D } from "@insync-stageplayer/common";
3
+ /**
4
+ * An annotation that can be placed on a 2D surface
5
+ */
6
+ export declare type Annotation = {
7
+ id: string;
8
+ /**
9
+ * The position {x, y} of the annotation.
10
+ */
11
+ position: Position2D;
12
+ /**
13
+ * The content of the annotation, this is a slate js node.
14
+ */
15
+ content?: Node[];
16
+ };
17
+ /**
18
+ * Checks if an argument is a valid annotation.
19
+ * @param arg
20
+ * @returns
21
+ */
22
+ export declare function isAnnotation(arg: unknown): arg is Annotation;
23
+ /**
24
+ * Please read up https://redux-toolkit.js.org/usage/usage-with-typescript#createentityadapter to understand what this is.
25
+ */
26
+ export declare const annotationsAdapter: import("@reduxjs/toolkit").EntityAdapter<Annotation>;
27
+ export declare const editAnnotation: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>, editAnnotationCancel: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, editAnnotationSubmit: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, editAnnotationDelete: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, createAnnotation: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>, createAnnotations: import("@reduxjs/toolkit").ActionCreatorWithPayload<Record<import("@reduxjs/toolkit").EntityId, Annotation> | Annotation[], string>, updateAnnotation: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("@reduxjs/toolkit").Update<Annotation>, string>, deleteAnnotation: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("@reduxjs/toolkit").EntityId, string>;
28
+ declare const _default: import("redux").Reducer<import("@reduxjs/toolkit").EntityState<Annotation> & {
29
+ editingAnnotation: string | undefined;
30
+ }, import("redux").AnyAction>;
31
+ export default _default;
32
32
  //# sourceMappingURL=annotations.slice.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotations.slice.d.ts","sourceRoot":"","sources":["../../src/redux/annotations.slice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAGL,UAAU,EACX,MAAM,4BAA4B,CAAC;AAOpC;;GAEG;AACH,oBAAY,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,QAAQ,EAAE,UAAU,CAAC;IACrB;;OAEG;IACH,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC;CAClB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,UAAU,CAO5D;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,sDAAoC,CAAC;AAqDpE,eAAO,MACL,cAAc,6FACd,oBAAoB,8FACpB,oBAAoB,gGACpB,oBAAoB,8FACpB,gBAAgB,+FAChB,iBAAiB,yKACjB,gBAAgB,sIAChB,gBAAgB,0HACU,CAAC;;;;AAC7B,wBAAwC"}
1
+ {"version":3,"file":"annotations.slice.d.ts","sourceRoot":"","sources":["../../src/redux/annotations.slice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAGL,UAAU,EACX,MAAM,4BAA4B,CAAC;AAOpC;;GAEG;AACH,oBAAY,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,QAAQ,EAAE,UAAU,CAAC;IACrB;;OAEG;IACH,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC;CAClB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,UAAU,CAO5D;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,sDAAoC,CAAC;AAqDpE,eAAO,MACL,cAAc,uEACd,oBAAoB,kEACpB,oBAAoB,oEACpB,oBAAoB,kEACpB,gBAAgB,uEAChB,iBAAiB,uIACjB,gBAAgB,8GAChB,gBAAgB,kGACU,CAAC;;;;AAC7B,wBAAwC"}
@@ -1,66 +1,66 @@
1
- import { isPosition2D, isUnknownObject, } from "@insync-stageplayer/common";
2
- import { createEntityAdapter, createSlice, } from "@reduxjs/toolkit";
3
- /**
4
- * Checks if an argument is a valid annotation.
5
- * @param arg
6
- * @returns
7
- */
8
- export function isAnnotation(arg) {
9
- return (isUnknownObject(arg) &&
10
- typeof arg.id === "string" &&
11
- Array.isArray(arg.content) &&
12
- isPosition2D(arg.position));
13
- }
14
- /**
15
- * Please read up https://redux-toolkit.js.org/usage/usage-with-typescript#createentityadapter to understand what this is.
16
- */
17
- export const annotationsAdapter = createEntityAdapter();
18
- const defaultAnnotation = {
19
- /**
20
- * Place the annotation in the center of the plane.
21
- */
22
- position: {
23
- x: 0.5,
24
- y: 0.5,
25
- },
26
- content: [
27
- {
28
- type: "paragraph",
29
- children: [{ text: "" }],
30
- },
31
- ],
32
- };
33
- const annotationsSlice = createSlice({
34
- name: "annotations",
35
- initialState: annotationsAdapter.getInitialState({
36
- editingAnnotation: undefined,
37
- }),
38
- reducers: {
39
- createAnnotations: annotationsAdapter.addMany,
40
- updateAnnotation: annotationsAdapter.updateOne,
41
- deleteAnnotation: annotationsAdapter.removeOne,
42
- createAnnotation: (state, action) => {
43
- annotationsAdapter.addOne(state, Object.assign({ id: action.payload }, defaultAnnotation));
44
- state.editingAnnotation = action.payload;
45
- },
46
- editAnnotation: (state, action) => {
47
- state.editingAnnotation = action.payload;
48
- },
49
- editAnnotationCancel: (state) => {
50
- state.editingAnnotation = undefined;
51
- },
52
- editAnnotationSubmit: (state, action) => {
53
- annotationsAdapter.upsertOne(state, action);
54
- state.editingAnnotation = undefined;
55
- },
56
- editAnnotationDelete: (state) => {
57
- if (state.editingAnnotation) {
58
- annotationsAdapter.removeOne(state, state.editingAnnotation);
59
- }
60
- state.editingAnnotation = undefined;
61
- },
62
- },
63
- });
64
- export const { editAnnotation, editAnnotationCancel, editAnnotationSubmit, editAnnotationDelete, createAnnotation, createAnnotations, updateAnnotation, deleteAnnotation, } = annotationsSlice.actions;
65
- export default annotationsSlice.reducer;
1
+ import { isPosition2D, isUnknownObject, } from "@insync-stageplayer/common";
2
+ import { createEntityAdapter, createSlice, } from "@reduxjs/toolkit";
3
+ /**
4
+ * Checks if an argument is a valid annotation.
5
+ * @param arg
6
+ * @returns
7
+ */
8
+ export function isAnnotation(arg) {
9
+ return (isUnknownObject(arg) &&
10
+ typeof arg.id === "string" &&
11
+ Array.isArray(arg.content) &&
12
+ isPosition2D(arg.position));
13
+ }
14
+ /**
15
+ * Please read up https://redux-toolkit.js.org/usage/usage-with-typescript#createentityadapter to understand what this is.
16
+ */
17
+ export const annotationsAdapter = createEntityAdapter();
18
+ const defaultAnnotation = {
19
+ /**
20
+ * Place the annotation in the center of the plane.
21
+ */
22
+ position: {
23
+ x: 0.5,
24
+ y: 0.5,
25
+ },
26
+ content: [
27
+ {
28
+ type: "paragraph",
29
+ children: [{ text: "" }],
30
+ },
31
+ ],
32
+ };
33
+ const annotationsSlice = createSlice({
34
+ name: "annotations",
35
+ initialState: annotationsAdapter.getInitialState({
36
+ editingAnnotation: undefined,
37
+ }),
38
+ reducers: {
39
+ createAnnotations: annotationsAdapter.addMany,
40
+ updateAnnotation: annotationsAdapter.updateOne,
41
+ deleteAnnotation: annotationsAdapter.removeOne,
42
+ createAnnotation: (state, action) => {
43
+ annotationsAdapter.addOne(state, Object.assign({ id: action.payload }, defaultAnnotation));
44
+ state.editingAnnotation = action.payload;
45
+ },
46
+ editAnnotation: (state, action) => {
47
+ state.editingAnnotation = action.payload;
48
+ },
49
+ editAnnotationCancel: (state) => {
50
+ state.editingAnnotation = undefined;
51
+ },
52
+ editAnnotationSubmit: (state, action) => {
53
+ annotationsAdapter.upsertOne(state, action);
54
+ state.editingAnnotation = undefined;
55
+ },
56
+ editAnnotationDelete: (state) => {
57
+ if (state.editingAnnotation) {
58
+ annotationsAdapter.removeOne(state, state.editingAnnotation);
59
+ }
60
+ state.editingAnnotation = undefined;
61
+ },
62
+ },
63
+ });
64
+ export const { editAnnotation, editAnnotationCancel, editAnnotationSubmit, editAnnotationDelete, createAnnotation, createAnnotations, updateAnnotation, deleteAnnotation, } = annotationsSlice.actions;
65
+ export default annotationsSlice.reducer;
66
66
  //# sourceMappingURL=annotations.slice.js.map
@@ -1,26 +1,26 @@
1
- declare const initialState: {
2
- editingDisplay: string | undefined;
3
- /**
4
- * Keeps track of the displays we deleted, if the form is submitted, we can delete these.
5
- */
6
- deletedDisplays: string[];
7
- /**
8
- * Keeps track of displays we created, if the form is cancelled, we can remove all created displays.
9
- */
10
- createdDisplays: string[];
11
- };
12
- export declare const editMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "measurementDisplayEditor/editMeasurementDisplay">, finishEditMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"measurementDisplayEditor/finishEditMeasurementDisplay">;
13
- export declare type MeasurementDisplayEditorState = typeof initialState;
14
- declare const _default: import("redux").Reducer<{
15
- editingDisplay: string | undefined;
16
- /**
17
- * Keeps track of the displays we deleted, if the form is submitted, we can delete these.
18
- */
19
- deletedDisplays: string[];
20
- /**
21
- * Keeps track of displays we created, if the form is cancelled, we can remove all created displays.
22
- */
23
- createdDisplays: string[];
24
- }, import("redux").AnyAction>;
25
- export default _default;
1
+ declare const initialState: {
2
+ editingDisplay: string | undefined;
3
+ /**
4
+ * Keeps track of the displays we deleted, if the form is submitted, we can delete these.
5
+ */
6
+ deletedDisplays: string[];
7
+ /**
8
+ * Keeps track of displays we created, if the form is cancelled, we can remove all created displays.
9
+ */
10
+ createdDisplays: string[];
11
+ };
12
+ export declare const editMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>, finishEditMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
13
+ export declare type MeasurementDisplayEditorState = typeof initialState;
14
+ declare const _default: import("redux").Reducer<{
15
+ editingDisplay: string | undefined;
16
+ /**
17
+ * Keeps track of the displays we deleted, if the form is submitted, we can delete these.
18
+ */
19
+ deletedDisplays: string[];
20
+ /**
21
+ * Keeps track of displays we created, if the form is cancelled, we can remove all created displays.
22
+ */
23
+ createdDisplays: string[];
24
+ }, import("redux").AnyAction>;
25
+ export default _default;
26
26
  //# sourceMappingURL=measurementDisplayEditor.slice.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"measurementDisplayEditor.slice.d.ts","sourceRoot":"","sources":["../../src/redux/measurementDisplayEditor.slice.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,YAAY;;IAEhB;;OAEG;;IAEH;;OAEG;;CAEJ,CAAC;AAyBF,eAAO,MAAQ,sBAAsB,kHAAE,4BAA4B,iHAC5B,CAAC;AAExC,oBAAY,6BAA6B,GAAG,OAAO,YAAY,CAAC;;;IApC9D;;OAEG;;IAEH;;OAEG;;;AAgCL,wBAAqD"}
1
+ {"version":3,"file":"measurementDisplayEditor.slice.d.ts","sourceRoot":"","sources":["../../src/redux/measurementDisplayEditor.slice.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,YAAY;;IAEhB;;OAEG;;IAEH;;OAEG;;CAEJ,CAAC;AAyBF,eAAO,MAAQ,sBAAsB,uEAAE,4BAA4B,gEAC5B,CAAC;AAExC,oBAAY,6BAA6B,GAAG,OAAO,YAAY,CAAC;;;IApC9D;;OAEG;;IAEH;;OAEG;;;AAgCL,wBAAqD"}
@@ -1,37 +1,37 @@
1
- import { createSlice } from "@reduxjs/toolkit";
2
- const initialState = {
3
- editingDisplay: undefined,
4
- /**
5
- * Keeps track of the displays we deleted, if the form is submitted, we can delete these.
6
- */
7
- deletedDisplays: [],
8
- /**
9
- * Keeps track of displays we created, if the form is cancelled, we can remove all created displays.
10
- */
11
- createdDisplays: [],
12
- };
13
- const measurementDisplayEditorSlice = createSlice({
14
- name: "measurementDisplayEditor",
15
- initialState,
16
- reducers: {
17
- editMeasurementDisplay: (state, action) => {
18
- state.editingDisplay = action.payload;
19
- },
20
- deleteMeasurementDisplay: (state, action) => {
21
- state.deletedDisplays.push(action.payload);
22
- },
23
- finishEditMeasurementDisplay: (state) => {
24
- state.editingDisplay = undefined;
25
- },
26
- },
27
- extraReducers: (builder) => {
28
- /*
29
- builder.addCase(finishEditAnnotation, (state, action) => {
30
- state.editingDisplay = undefined;
31
- });
32
- */
33
- },
34
- });
35
- export const { editMeasurementDisplay, finishEditMeasurementDisplay } = measurementDisplayEditorSlice.actions;
36
- export default measurementDisplayEditorSlice.reducer;
1
+ import { createSlice } from "@reduxjs/toolkit";
2
+ const initialState = {
3
+ editingDisplay: undefined,
4
+ /**
5
+ * Keeps track of the displays we deleted, if the form is submitted, we can delete these.
6
+ */
7
+ deletedDisplays: [],
8
+ /**
9
+ * Keeps track of displays we created, if the form is cancelled, we can remove all created displays.
10
+ */
11
+ createdDisplays: [],
12
+ };
13
+ const measurementDisplayEditorSlice = createSlice({
14
+ name: "measurementDisplayEditor",
15
+ initialState,
16
+ reducers: {
17
+ editMeasurementDisplay: (state, action) => {
18
+ state.editingDisplay = action.payload;
19
+ },
20
+ deleteMeasurementDisplay: (state, action) => {
21
+ state.deletedDisplays.push(action.payload);
22
+ },
23
+ finishEditMeasurementDisplay: (state) => {
24
+ state.editingDisplay = undefined;
25
+ },
26
+ },
27
+ extraReducers: (builder) => {
28
+ /*
29
+ builder.addCase(finishEditAnnotation, (state, action) => {
30
+ state.editingDisplay = undefined;
31
+ });
32
+ */
33
+ },
34
+ });
35
+ export const { editMeasurementDisplay, finishEditMeasurementDisplay } = measurementDisplayEditorSlice.actions;
36
+ export default measurementDisplayEditorSlice.reducer;
37
37
  //# sourceMappingURL=measurementDisplayEditor.slice.js.map
@@ -1,26 +1,26 @@
1
- /**
2
- * An annotation that can be placed on a 2D surface
3
- */
4
- export declare type MeasurementDisplay = {
5
- /**
6
- * Id of
7
- */
8
- id: string;
9
- showX: boolean;
10
- showY: boolean;
11
- showSignal: boolean;
12
- showSigColor: boolean;
13
- padXTo?: number;
14
- padXChar?: string;
15
- padYTo?: number;
16
- padYChar?: string;
17
- decimalsX?: number;
18
- decimalsY?: number;
19
- measurementId: string;
20
- };
21
- export declare const measurementDisplaysAdapter: import("@reduxjs/toolkit").EntityAdapter<MeasurementDisplay>;
22
- export declare const selectAllMeasurementDisplays: MeasurementDisplay[];
23
- export declare const createMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithPayload<MeasurementDisplay, "measurementDisplays/createMeasurementDisplay">, updateMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("@reduxjs/toolkit").Update<MeasurementDisplay>, "measurementDisplays/updateMeasurementDisplay">, deleteMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("@reduxjs/toolkit").EntityId, "measurementDisplays/deleteMeasurementDisplay">, deleteMeasurementDisplays: import("@reduxjs/toolkit").ActionCreatorWithPayload<readonly import("@reduxjs/toolkit").EntityId[], "measurementDisplays/deleteMeasurementDisplays">;
24
- declare const _default: import("redux").Reducer<import("@reduxjs/toolkit").EntityState<MeasurementDisplay>, import("redux").AnyAction>;
25
- export default _default;
1
+ /**
2
+ * An annotation that can be placed on a 2D surface
3
+ */
4
+ export declare type MeasurementDisplay = {
5
+ /**
6
+ * Id of
7
+ */
8
+ id: string;
9
+ showX: boolean;
10
+ showY: boolean;
11
+ showSignal: boolean;
12
+ showSigColor: boolean;
13
+ padXTo?: number;
14
+ padXChar?: string;
15
+ padYTo?: number;
16
+ padYChar?: string;
17
+ decimalsX?: number;
18
+ decimalsY?: number;
19
+ measurementId: string;
20
+ };
21
+ export declare const measurementDisplaysAdapter: import("@reduxjs/toolkit").EntityAdapter<MeasurementDisplay>;
22
+ export declare const selectAllMeasurementDisplays: MeasurementDisplay[];
23
+ export declare const createMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithPayload<MeasurementDisplay, string>, updateMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("@reduxjs/toolkit").Update<MeasurementDisplay>, string>, deleteMeasurementDisplay: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("@reduxjs/toolkit").EntityId, string>, deleteMeasurementDisplays: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("@reduxjs/toolkit").EntityId[], string>;
24
+ declare const _default: import("redux").Reducer<import("@reduxjs/toolkit").EntityState<MeasurementDisplay>, import("redux").AnyAction>;
25
+ export default _default;
26
26
  //# sourceMappingURL=measurementDisplays.slice.d.ts.map