@insync-stageplayer/annotations 0.5.32 → 0.5.35-beta.1
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.
- package/lib/components/AnnotationContent.d.ts +37 -37
- package/lib/components/AnnotationContent.js +59 -59
- package/lib/components/AnnotationEditForm.d.ts +26 -26
- package/lib/components/AnnotationEditForm.js +146 -146
- package/lib/components/AnnotationsModuleProvider.d.ts +36 -36
- package/lib/components/AnnotationsModuleProvider.js +20 -20
- package/lib/components/AnnotationsViewer.d.ts +15 -15
- package/lib/components/AnnotationsViewer.js +107 -107
- package/lib/components/DraggablePosition.d.ts +31 -31
- package/lib/components/DraggablePosition.js +62 -62
- package/lib/components/MeasurementDisplayDataContext.d.ts +10 -10
- package/lib/components/MeasurementDisplayDataContext.js +2 -2
- package/lib/components/MeasurementDisplayDataProvider.d.ts +15 -15
- package/lib/components/MeasurementDisplayDataProvider.d.ts.map +1 -1
- package/lib/components/MeasurementDisplayDataProvider.js +45 -45
- package/lib/components/MeasurementDisplayDataProvider.js.map +1 -1
- package/lib/components/MeasurementDisplayEditor.d.ts +19 -19
- package/lib/components/MeasurementDisplayEditor.js +136 -136
- package/lib/components/MeasurementDisplayElement.d.ts +18 -18
- package/lib/components/MeasurementDisplayElement.d.ts.map +1 -1
- package/lib/components/MeasurementDisplayElement.js +65 -97
- package/lib/components/MeasurementDisplayElement.js.map +1 -1
- package/lib/components/ModalAnnotationEditor.d.ts +12 -12
- package/lib/components/ModalAnnotationEditor.js +37 -37
- package/lib/formatNumber.d.ts +29 -29
- package/lib/formatNumber.js +12 -12
- package/lib/hooks/useMeasurementDisplayData.d.ts +15 -0
- package/lib/hooks/useMeasurementDisplayData.d.ts.map +1 -0
- package/lib/hooks/useMeasurementDisplayData.js +40 -0
- package/lib/hooks/useMeasurementDisplayData.js.map +1 -0
- package/lib/index.d.ts +8 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -7
- package/lib/index.js.map +1 -1
- package/lib/redux/actions.d.ts +1 -1
- package/lib/redux/actions.js +1 -1
- package/lib/redux/annotationEditor.slice.d.ts +37 -37
- package/lib/redux/annotationEditor.slice.d.ts.map +1 -1
- package/lib/redux/annotationEditor.slice.js +122 -122
- package/lib/redux/annotations.slice.d.ts +31 -31
- package/lib/redux/annotations.slice.d.ts.map +1 -1
- package/lib/redux/annotations.slice.js +65 -65
- package/lib/redux/measurementDisplayEditor.slice.d.ts +25 -25
- package/lib/redux/measurementDisplayEditor.slice.d.ts.map +1 -1
- package/lib/redux/measurementDisplayEditor.slice.js +36 -36
- package/lib/redux/measurementDisplays.slice.d.ts +25 -25
- package/lib/redux/measurementDisplays.slice.d.ts.map +1 -1
- package/lib/redux/measurementDisplays.slice.js +22 -22
- package/lib/redux/reducer.d.ts +51 -51
- package/lib/redux/reducer.js +65 -65
- package/lib/useBoundingRect.d.ts +8 -8
- package/lib/useBoundingRect.js +27 -27
- package/lib/util.d.ts +5 -5
- package/lib/util.js +7 -7
- package/package.json +5 -5
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { createEntityAdapter, createSlice, configureStore, } from "@reduxjs/toolkit";
|
|
2
|
-
export const measurementDisplaysAdapter = createEntityAdapter();
|
|
3
|
-
const measurementDisplaysSlice = createSlice({
|
|
4
|
-
name: "measurementDisplays",
|
|
5
|
-
initialState: measurementDisplaysAdapter.getInitialState(),
|
|
6
|
-
reducers: {
|
|
7
|
-
createMeasurementDisplay: measurementDisplaysAdapter.addOne,
|
|
8
|
-
updateMeasurementDisplay: measurementDisplaysAdapter.updateOne,
|
|
9
|
-
deleteMeasurementDisplay: measurementDisplaysAdapter.removeOne,
|
|
10
|
-
deleteMeasurementDisplays: measurementDisplaysAdapter.removeMany,
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
const store = configureStore({
|
|
14
|
-
reducer: {
|
|
15
|
-
measurementDisplays: measurementDisplaysSlice.reducer,
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
const measurementDisplaySelectors = measurementDisplaysAdapter.getSelectors((state) => state.measurementDisplays);
|
|
19
|
-
// And then use the selectors to retrieve values
|
|
20
|
-
export const selectAllMeasurementDisplays = measurementDisplaySelectors.selectAll(store.getState());
|
|
21
|
-
export const { createMeasurementDisplay, updateMeasurementDisplay, deleteMeasurementDisplay, deleteMeasurementDisplays, } = measurementDisplaysSlice.actions;
|
|
22
|
-
export default measurementDisplaysSlice.reducer;
|
|
1
|
+
import { createEntityAdapter, createSlice, configureStore, } from "@reduxjs/toolkit";
|
|
2
|
+
export const measurementDisplaysAdapter = createEntityAdapter();
|
|
3
|
+
const measurementDisplaysSlice = createSlice({
|
|
4
|
+
name: "measurementDisplays",
|
|
5
|
+
initialState: measurementDisplaysAdapter.getInitialState(),
|
|
6
|
+
reducers: {
|
|
7
|
+
createMeasurementDisplay: measurementDisplaysAdapter.addOne,
|
|
8
|
+
updateMeasurementDisplay: measurementDisplaysAdapter.updateOne,
|
|
9
|
+
deleteMeasurementDisplay: measurementDisplaysAdapter.removeOne,
|
|
10
|
+
deleteMeasurementDisplays: measurementDisplaysAdapter.removeMany,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
const store = configureStore({
|
|
14
|
+
reducer: {
|
|
15
|
+
measurementDisplays: measurementDisplaysSlice.reducer,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
const measurementDisplaySelectors = measurementDisplaysAdapter.getSelectors((state) => state.measurementDisplays);
|
|
19
|
+
// And then use the selectors to retrieve values
|
|
20
|
+
export const selectAllMeasurementDisplays = measurementDisplaySelectors.selectAll(store.getState());
|
|
21
|
+
export const { createMeasurementDisplay, updateMeasurementDisplay, deleteMeasurementDisplay, deleteMeasurementDisplays, } = measurementDisplaysSlice.actions;
|
|
22
|
+
export default measurementDisplaysSlice.reducer;
|
|
23
23
|
//# sourceMappingURL=measurementDisplays.slice.js.map
|
package/lib/redux/reducer.d.ts
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { Annotation } from "./annotations.slice";
|
|
2
|
-
export declare type AnnotationsModuleState = ReturnType<typeof slicesReducer>;
|
|
3
|
-
declare const slicesReducer: import("redux").Reducer<import("redux").CombinedState<{
|
|
4
|
-
annotations: import("@reduxjs/toolkit").EntityState<Annotation> & {
|
|
5
|
-
editingAnnotation: string | undefined;
|
|
6
|
-
};
|
|
7
|
-
measurementDisplays: import("@reduxjs/toolkit").EntityState<import("./measurementDisplays.slice").MeasurementDisplay>;
|
|
8
|
-
annotationEditor: {
|
|
9
|
-
annotation: Omit<Annotation, "id"> & {
|
|
10
|
-
id: string | undefined;
|
|
11
|
-
};
|
|
12
|
-
displays: {
|
|
13
|
-
added: string[];
|
|
14
|
-
deleted: string[];
|
|
15
|
-
};
|
|
16
|
-
pickingMeasurement: boolean;
|
|
17
|
-
chosenMeasurement: string | null;
|
|
18
|
-
pickingMeasurementError: Error | null;
|
|
19
|
-
editingMeasurementDisplay: string | null;
|
|
20
|
-
};
|
|
21
|
-
measurementDisplayEditor: {
|
|
22
|
-
editingDisplay: string | undefined;
|
|
23
|
-
deletedDisplays: string[];
|
|
24
|
-
createdDisplays: string[];
|
|
25
|
-
};
|
|
26
|
-
}>, import("redux").AnyAction>;
|
|
27
|
-
export declare const annotationsModuleReducer: import("reduce-reducers").Reducer<import("redux").CombinedState<{
|
|
28
|
-
annotations: import("@reduxjs/toolkit").EntityState<Annotation> & {
|
|
29
|
-
editingAnnotation: string | undefined;
|
|
30
|
-
};
|
|
31
|
-
measurementDisplays: import("@reduxjs/toolkit").EntityState<import("./measurementDisplays.slice").MeasurementDisplay>;
|
|
32
|
-
annotationEditor: {
|
|
33
|
-
annotation: Omit<Annotation, "id"> & {
|
|
34
|
-
id: string | undefined;
|
|
35
|
-
};
|
|
36
|
-
displays: {
|
|
37
|
-
added: string[];
|
|
38
|
-
deleted: string[];
|
|
39
|
-
};
|
|
40
|
-
pickingMeasurement: boolean;
|
|
41
|
-
chosenMeasurement: string | null;
|
|
42
|
-
pickingMeasurementError: Error | null;
|
|
43
|
-
editingMeasurementDisplay: string | null;
|
|
44
|
-
};
|
|
45
|
-
measurementDisplayEditor: {
|
|
46
|
-
editingDisplay: string | undefined;
|
|
47
|
-
deletedDisplays: string[];
|
|
48
|
-
createdDisplays: string[];
|
|
49
|
-
};
|
|
50
|
-
}>>;
|
|
51
|
-
export {};
|
|
1
|
+
import { Annotation } from "./annotations.slice";
|
|
2
|
+
export declare type AnnotationsModuleState = ReturnType<typeof slicesReducer>;
|
|
3
|
+
declare const slicesReducer: import("redux").Reducer<import("redux").CombinedState<{
|
|
4
|
+
annotations: import("@reduxjs/toolkit").EntityState<Annotation> & {
|
|
5
|
+
editingAnnotation: string | undefined;
|
|
6
|
+
};
|
|
7
|
+
measurementDisplays: import("@reduxjs/toolkit").EntityState<import("./measurementDisplays.slice").MeasurementDisplay>;
|
|
8
|
+
annotationEditor: {
|
|
9
|
+
annotation: Omit<Annotation, "id"> & {
|
|
10
|
+
id: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
displays: {
|
|
13
|
+
added: string[];
|
|
14
|
+
deleted: string[];
|
|
15
|
+
};
|
|
16
|
+
pickingMeasurement: boolean;
|
|
17
|
+
chosenMeasurement: string | null;
|
|
18
|
+
pickingMeasurementError: Error | null;
|
|
19
|
+
editingMeasurementDisplay: string | null;
|
|
20
|
+
};
|
|
21
|
+
measurementDisplayEditor: {
|
|
22
|
+
editingDisplay: string | undefined;
|
|
23
|
+
deletedDisplays: string[];
|
|
24
|
+
createdDisplays: string[];
|
|
25
|
+
};
|
|
26
|
+
}>, import("redux").AnyAction>;
|
|
27
|
+
export declare const annotationsModuleReducer: import("reduce-reducers").Reducer<import("redux").CombinedState<{
|
|
28
|
+
annotations: import("@reduxjs/toolkit").EntityState<Annotation> & {
|
|
29
|
+
editingAnnotation: string | undefined;
|
|
30
|
+
};
|
|
31
|
+
measurementDisplays: import("@reduxjs/toolkit").EntityState<import("./measurementDisplays.slice").MeasurementDisplay>;
|
|
32
|
+
annotationEditor: {
|
|
33
|
+
annotation: Omit<Annotation, "id"> & {
|
|
34
|
+
id: string | undefined;
|
|
35
|
+
};
|
|
36
|
+
displays: {
|
|
37
|
+
added: string[];
|
|
38
|
+
deleted: string[];
|
|
39
|
+
};
|
|
40
|
+
pickingMeasurement: boolean;
|
|
41
|
+
chosenMeasurement: string | null;
|
|
42
|
+
pickingMeasurementError: Error | null;
|
|
43
|
+
editingMeasurementDisplay: string | null;
|
|
44
|
+
};
|
|
45
|
+
measurementDisplayEditor: {
|
|
46
|
+
editingDisplay: string | undefined;
|
|
47
|
+
deletedDisplays: string[];
|
|
48
|
+
createdDisplays: string[];
|
|
49
|
+
};
|
|
50
|
+
}>>;
|
|
51
|
+
export {};
|
|
52
52
|
//# sourceMappingURL=reducer.d.ts.map
|
package/lib/redux/reducer.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { combineReducers } from "redux";
|
|
2
|
-
import { createReducer } from "@reduxjs/toolkit";
|
|
3
|
-
import reduceReducers from "reduce-reducers";
|
|
4
|
-
import annotationEditorSlice from "./annotationEditor.slice";
|
|
5
|
-
import annotationsSlice, { editAnnotationCancel, editAnnotationDelete, editAnnotationSubmit, } from "./annotations.slice";
|
|
6
|
-
import measurementDisplayEditorSlice from "./measurementDisplayEditor.slice";
|
|
7
|
-
import measurementDisplaysSlice, { measurementDisplaysAdapter, } from "./measurementDisplays.slice";
|
|
8
|
-
const slicesReducer = combineReducers({
|
|
9
|
-
annotations: annotationsSlice,
|
|
10
|
-
measurementDisplays: measurementDisplaysSlice,
|
|
11
|
-
annotationEditor: annotationEditorSlice,
|
|
12
|
-
measurementDisplayEditor: measurementDisplayEditorSlice,
|
|
13
|
-
});
|
|
14
|
-
/**
|
|
15
|
-
* An annotation can contain measurementDisplay elements in its content. The content consists of SlateJS nodes which
|
|
16
|
-
* is a nested structure. This function returns a list of all measurementDisplays contained in this annotation.
|
|
17
|
-
* @param annotation
|
|
18
|
-
* @returns The ids of the measurementDisplays contained in this Annotation.
|
|
19
|
-
*/
|
|
20
|
-
const getMeasurementDisplaysForAnnotation = (annotation) => {
|
|
21
|
-
// The recursive function that goes through the nodes.
|
|
22
|
-
const go = (node) => {
|
|
23
|
-
if (node.type === "measurementDisplay") {
|
|
24
|
-
return [node.measurementDisplayId];
|
|
25
|
-
}
|
|
26
|
-
if (Array.isArray(node.children)) {
|
|
27
|
-
return node.children.reduce((acc, c) => [...acc, ...go(c)], []);
|
|
28
|
-
}
|
|
29
|
-
return [];
|
|
30
|
-
};
|
|
31
|
-
// Transforming the Annotation to a SlateJS node.
|
|
32
|
-
return go({ children: annotation.content });
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* This reducer is in charge of cascading changes between entities.
|
|
36
|
-
*/
|
|
37
|
-
const moduleReducer = createReducer({}, (builder) => {
|
|
38
|
-
// When editing an annotation is canceled, any added measurement displays during editing should be deleted
|
|
39
|
-
builder.addCase(editAnnotationCancel, (state) => {
|
|
40
|
-
if (state.annotationEditor.displays.added.length > 0) {
|
|
41
|
-
measurementDisplaysAdapter.removeMany(state.measurementDisplays, state.annotationEditor.displays.added);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
//When submitting an annotation after editing, any deletions of measurement displays during editing should be persisted.
|
|
45
|
-
builder.addCase(editAnnotationSubmit, (state) => {
|
|
46
|
-
if (state.annotationEditor.displays.deleted.length > 0) {
|
|
47
|
-
measurementDisplaysAdapter.removeMany(state.measurementDisplays, state.annotationEditor.displays.deleted);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
// When an annotation is deleted, any measurement displays associated with it should also be deleted.
|
|
51
|
-
builder.addCase(editAnnotationDelete, (state) => {
|
|
52
|
-
if (!state.annotations.editingAnnotation)
|
|
53
|
-
return;
|
|
54
|
-
const annotation = state.annotations.entities[state.annotations.editingAnnotation];
|
|
55
|
-
if (!annotation)
|
|
56
|
-
return;
|
|
57
|
-
const annotationDisplays = getMeasurementDisplaysForAnnotation(annotation);
|
|
58
|
-
const allDisplays = [
|
|
59
|
-
...state.annotationEditor.displays.added,
|
|
60
|
-
...annotationDisplays,
|
|
61
|
-
];
|
|
62
|
-
measurementDisplaysAdapter.removeMany(state.measurementDisplays, allDisplays);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
export const annotationsModuleReducer = reduceReducers(moduleReducer, slicesReducer);
|
|
1
|
+
import { combineReducers } from "redux";
|
|
2
|
+
import { createReducer } from "@reduxjs/toolkit";
|
|
3
|
+
import reduceReducers from "reduce-reducers";
|
|
4
|
+
import annotationEditorSlice from "./annotationEditor.slice";
|
|
5
|
+
import annotationsSlice, { editAnnotationCancel, editAnnotationDelete, editAnnotationSubmit, } from "./annotations.slice";
|
|
6
|
+
import measurementDisplayEditorSlice from "./measurementDisplayEditor.slice";
|
|
7
|
+
import measurementDisplaysSlice, { measurementDisplaysAdapter, } from "./measurementDisplays.slice";
|
|
8
|
+
const slicesReducer = combineReducers({
|
|
9
|
+
annotations: annotationsSlice,
|
|
10
|
+
measurementDisplays: measurementDisplaysSlice,
|
|
11
|
+
annotationEditor: annotationEditorSlice,
|
|
12
|
+
measurementDisplayEditor: measurementDisplayEditorSlice,
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* An annotation can contain measurementDisplay elements in its content. The content consists of SlateJS nodes which
|
|
16
|
+
* is a nested structure. This function returns a list of all measurementDisplays contained in this annotation.
|
|
17
|
+
* @param annotation
|
|
18
|
+
* @returns The ids of the measurementDisplays contained in this Annotation.
|
|
19
|
+
*/
|
|
20
|
+
const getMeasurementDisplaysForAnnotation = (annotation) => {
|
|
21
|
+
// The recursive function that goes through the nodes.
|
|
22
|
+
const go = (node) => {
|
|
23
|
+
if (node.type === "measurementDisplay") {
|
|
24
|
+
return [node.measurementDisplayId];
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(node.children)) {
|
|
27
|
+
return node.children.reduce((acc, c) => [...acc, ...go(c)], []);
|
|
28
|
+
}
|
|
29
|
+
return [];
|
|
30
|
+
};
|
|
31
|
+
// Transforming the Annotation to a SlateJS node.
|
|
32
|
+
return go({ children: annotation.content });
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* This reducer is in charge of cascading changes between entities.
|
|
36
|
+
*/
|
|
37
|
+
const moduleReducer = createReducer({}, (builder) => {
|
|
38
|
+
// When editing an annotation is canceled, any added measurement displays during editing should be deleted
|
|
39
|
+
builder.addCase(editAnnotationCancel, (state) => {
|
|
40
|
+
if (state.annotationEditor.displays.added.length > 0) {
|
|
41
|
+
measurementDisplaysAdapter.removeMany(state.measurementDisplays, state.annotationEditor.displays.added);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
//When submitting an annotation after editing, any deletions of measurement displays during editing should be persisted.
|
|
45
|
+
builder.addCase(editAnnotationSubmit, (state) => {
|
|
46
|
+
if (state.annotationEditor.displays.deleted.length > 0) {
|
|
47
|
+
measurementDisplaysAdapter.removeMany(state.measurementDisplays, state.annotationEditor.displays.deleted);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
// When an annotation is deleted, any measurement displays associated with it should also be deleted.
|
|
51
|
+
builder.addCase(editAnnotationDelete, (state) => {
|
|
52
|
+
if (!state.annotations.editingAnnotation)
|
|
53
|
+
return;
|
|
54
|
+
const annotation = state.annotations.entities[state.annotations.editingAnnotation];
|
|
55
|
+
if (!annotation)
|
|
56
|
+
return;
|
|
57
|
+
const annotationDisplays = getMeasurementDisplaysForAnnotation(annotation);
|
|
58
|
+
const allDisplays = [
|
|
59
|
+
...state.annotationEditor.displays.added,
|
|
60
|
+
...annotationDisplays,
|
|
61
|
+
];
|
|
62
|
+
measurementDisplaysAdapter.removeMany(state.measurementDisplays, allDisplays);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
export const annotationsModuleReducer = reduceReducers(moduleReducer, slicesReducer);
|
|
66
66
|
//# sourceMappingURL=reducer.js.map
|
package/lib/useBoundingRect.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
declare type MeasureCallback = (el: HTMLElement | null) => void;
|
|
2
|
-
declare type UseMeasureHookValue = [MeasureCallback, DOMRect | undefined];
|
|
3
|
-
/**
|
|
4
|
-
* React hook that uses ResizeObserver to keep track of size of element.
|
|
5
|
-
* @returns An array that with a callback to pass element, and the ClientRect for that element with it's current size.
|
|
6
|
-
*/
|
|
7
|
-
export declare const useBoundingRect: () => UseMeasureHookValue;
|
|
8
|
-
export {};
|
|
1
|
+
declare type MeasureCallback = (el: HTMLElement | null) => void;
|
|
2
|
+
declare type UseMeasureHookValue = [MeasureCallback, DOMRect | undefined];
|
|
3
|
+
/**
|
|
4
|
+
* React hook that uses ResizeObserver to keep track of size of element.
|
|
5
|
+
* @returns An array that with a callback to pass element, and the ClientRect for that element with it's current size.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useBoundingRect: () => UseMeasureHookValue;
|
|
8
|
+
export {};
|
|
9
9
|
//# sourceMappingURL=useBoundingRect.d.ts.map
|
package/lib/useBoundingRect.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { useRef, useEffect, useCallback, useState } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* React hook that uses ResizeObserver to keep track of size of element.
|
|
4
|
-
* @returns An array that with a callback to pass element, and the ClientRect for that element with it's current size.
|
|
5
|
-
*/
|
|
6
|
-
export const useBoundingRect = () => {
|
|
7
|
-
const resizeObserver = useRef();
|
|
8
|
-
const [boundingRect, setBoundingRect] = useState();
|
|
9
|
-
useEffect(() => () => {
|
|
10
|
-
if (resizeObserver.current != undefined)
|
|
11
|
-
resizeObserver.current.disconnect();
|
|
12
|
-
resizeObserver.current = undefined;
|
|
13
|
-
}, []);
|
|
14
|
-
const ref = useCallback((node) => {
|
|
15
|
-
if (!node || !node.getBoundingClientRect)
|
|
16
|
-
return;
|
|
17
|
-
if (resizeObserver.current) {
|
|
18
|
-
resizeObserver.current.disconnect();
|
|
19
|
-
resizeObserver.current = undefined;
|
|
20
|
-
}
|
|
21
|
-
resizeObserver.current = new ResizeObserver(() => {
|
|
22
|
-
setBoundingRect(node.getBoundingClientRect());
|
|
23
|
-
});
|
|
24
|
-
resizeObserver.current.observe(node);
|
|
25
|
-
}, []);
|
|
26
|
-
return [ref, boundingRect];
|
|
27
|
-
};
|
|
1
|
+
import { useRef, useEffect, useCallback, useState } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* React hook that uses ResizeObserver to keep track of size of element.
|
|
4
|
+
* @returns An array that with a callback to pass element, and the ClientRect for that element with it's current size.
|
|
5
|
+
*/
|
|
6
|
+
export const useBoundingRect = () => {
|
|
7
|
+
const resizeObserver = useRef();
|
|
8
|
+
const [boundingRect, setBoundingRect] = useState();
|
|
9
|
+
useEffect(() => () => {
|
|
10
|
+
if (resizeObserver.current != undefined)
|
|
11
|
+
resizeObserver.current.disconnect();
|
|
12
|
+
resizeObserver.current = undefined;
|
|
13
|
+
}, []);
|
|
14
|
+
const ref = useCallback((node) => {
|
|
15
|
+
if (!node || !node.getBoundingClientRect)
|
|
16
|
+
return;
|
|
17
|
+
if (resizeObserver.current) {
|
|
18
|
+
resizeObserver.current.disconnect();
|
|
19
|
+
resizeObserver.current = undefined;
|
|
20
|
+
}
|
|
21
|
+
resizeObserver.current = new ResizeObserver(() => {
|
|
22
|
+
setBoundingRect(node.getBoundingClientRect());
|
|
23
|
+
});
|
|
24
|
+
resizeObserver.current.observe(node);
|
|
25
|
+
}, []);
|
|
26
|
+
return [ref, boundingRect];
|
|
27
|
+
};
|
|
28
28
|
//# sourceMappingURL=useBoundingRect.js.map
|
package/lib/util.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a unique id.
|
|
3
|
-
* @returns
|
|
4
|
-
*/
|
|
5
|
-
export declare const createId: () => string;
|
|
1
|
+
/**
|
|
2
|
+
* Creates a unique id.
|
|
3
|
+
* @returns
|
|
4
|
+
*/
|
|
5
|
+
export declare const createId: () => string;
|
|
6
6
|
//# sourceMappingURL=util.d.ts.map
|
package/lib/util.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a unique id.
|
|
3
|
-
* @returns
|
|
4
|
-
*/
|
|
5
|
-
export const createId = () => {
|
|
6
|
-
return "_" + Math.random().toString(36).substr(2, 9);
|
|
7
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Creates a unique id.
|
|
3
|
+
* @returns
|
|
4
|
+
*/
|
|
5
|
+
export const createId = () => {
|
|
6
|
+
return "_" + Math.random().toString(36).substr(2, 9);
|
|
7
|
+
};
|
|
8
8
|
//# sourceMappingURL=util.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@insync-stageplayer/annotations",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.35-beta.1",
|
|
4
4
|
"description": "Annotations module for stageplayer",
|
|
5
5
|
"author": "David Ammeraal <david.ammeraal@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/Noterik/insync-stageplayer#readme",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"url": "https://github.com/Noterik/insync-stageplayer/issues"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@insync-stageplayer/measurements": "^0.5.
|
|
36
|
-
"@insync-stageplayer/time": "^0.5.
|
|
37
|
-
"@insync-stageplayer/ui-components": "^0.5.
|
|
35
|
+
"@insync-stageplayer/measurements": "^0.5.35-beta.1",
|
|
36
|
+
"@insync-stageplayer/time": "^0.5.35-beta.1",
|
|
37
|
+
"@insync-stageplayer/ui-components": "^0.5.35-beta.1",
|
|
38
38
|
"@reduxjs/toolkit": "^1.5.0",
|
|
39
39
|
"@types/deep-diff": "^1.0.0",
|
|
40
40
|
"classnames": "^2.3.1",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"rxjs": "^6.6.6"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "fe08aec602a5b4c25ca1e115631381501d16f9d4"
|
|
56
56
|
}
|