@linkurious/ogma-annotations-react 1.1.23 → 1.1.25

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.
@@ -2,9 +2,8 @@ import { Annotation } from '@linkurious/ogma-annotations';
2
2
  import { AnnotationCollection } from '@linkurious/ogma-annotations';
3
3
  import { AnnotationFeature } from '@linkurious/ogma-annotations';
4
4
  import { ArrowStyles } from '@linkurious/ogma-annotations';
5
- import { Context } from 'react';
6
5
  import { Control } from '@linkurious/ogma-annotations';
7
- import { JSX as JSX_2 } from 'react/jsx-runtime';
6
+ import { default as default_2 } from 'react';
8
7
  import { ReactElement } from 'react';
9
8
  import { TextStyle } from '@linkurious/ogma-annotations';
10
9
 
@@ -15,38 +14,94 @@ declare type AnnotationAction = {
15
14
 
16
15
  declare type AnnotationActionType = "add" | "remove" | "update";
17
16
 
18
- export declare const AnnotationsContext: Context<IAnnotationsContext>;
19
-
20
- export declare const AnnotationsContextProvider: ({ children }: Props) => JSX_2.Element;
17
+ /**
18
+ * Creates a React context for managing annotations with type safety.
19
+ *
20
+ * @type {Context<IAnnotationsContext>} A typed context for annotation-related
21
+ * state and operations
22
+ */
23
+ export declare const AnnotationsContext: default_2.Context<IAnnotationsContext>;
24
+
25
+ /**
26
+ * Provides a context provider for managing annotations in a graph visualization.
27
+ *
28
+ * This component handles the state and interactions for creating, selecting,
29
+ * and styling annotations, including arrow and text annotations.
30
+ *
31
+ * @param {Props} props - The component props containing child elements
32
+ * @returns {ReactElement} A context provider with annotation management capabilities
33
+ */
34
+ export declare const AnnotationsContextProvider: ({ children }: Props) => default_2.JSX.Element;
21
35
 
22
36
  export declare const BLACK = "#333333";
23
37
 
24
- export declare function createAnnotationsContext(): Context<IAnnotationsContext | null>;
25
-
38
+ /**
39
+ * Creates a React context for managing annotations with optional type safety.
40
+ *
41
+ * @returns {Context<IAnnotationsContext | null>} A context for annotation-related state and operations that can be null
42
+ */
43
+ export declare function createAnnotationsContext(): default_2.Context<IAnnotationsContext | null>;
44
+
45
+ /**
46
+ * Default arrow style for annotations.
47
+ * @type {ArrowStyles}
48
+ */
26
49
  export declare const defaultArrowStyle: ArrowStyles;
27
50
 
51
+ /**
52
+ * List of default colors for annotations.
53
+ * @type {string[]}
54
+ */
28
55
  export declare const defaultColors: string[];
29
56
 
57
+ /**
58
+ * Default text style for annotations.
59
+ * @type {TextStyle}
60
+ */
30
61
  export declare const defaultTextStyle: TextStyle;
31
62
 
63
+ /**
64
+ * List of available fonts for annotations.
65
+ */
32
66
  export declare const fonts: string[];
33
67
 
34
68
  export declare const fontSizes: number[];
35
69
 
36
- declare interface IAnnotationsContext {
70
+ /**
71
+ * Defines the context interface for managing annotations in a React application.
72
+ *
73
+ * @interface
74
+ * @description Provides state and methods for handling annotation collections,
75
+ * current annotation selection, styling, and editor control.
76
+ */
77
+ export declare interface IAnnotationsContext {
78
+ /** Current annotations in the application. */
37
79
  annotations: AnnotationCollection;
38
- updateAnnotations: React.Dispatch<AnnotationAction>;
80
+ /** Updates the annotations in the application. */
81
+ updateAnnotations: default_2.Dispatch<AnnotationAction>;
82
+ /** The currently selected annotation in the application. */
39
83
  currentAnnotation: AnnotationFeature | null;
84
+ /** Sets the currently selected annotation in the application. */
40
85
  setCurrentAnnotation: (annotation: AnnotationFeature | null) => void;
86
+ /** The current arrow style for annotations. */
41
87
  arrowStyle: ArrowStyles;
88
+ /** The current width factor for arrow annotations. */
42
89
  arrowWidthFactor: number;
90
+ /** Sets the width factor for arrow annotations. */
43
91
  setArrowWidthFactor: (arrowWidthFactor: number) => void;
92
+ /** Sets the current arrow style for annotations. */
44
93
  setArrowStyle: (arrowStyle: ArrowStyles) => void;
94
+ /** The current text style for annotations. */
45
95
  textStyle: TextStyle;
96
+ /** The current size factor for text annotations in regards to node sizes. */
46
97
  textSizeFactor: number;
98
+ /** Sets the size factor for text annotations. */
47
99
  setTextSizeFactor: (textSizeFactor: number) => void;
100
+ /** Sets the current text style for annotations. */
48
101
  setTextStyle: (textStyle: TextStyle) => void;
102
+ /** The annotations editor for managing annotations. See {@link AnnotationsEditor} */
49
103
  editor: Control;
104
+ /** Sets the current annotations editor for managing annotations. */
50
105
  setEditor: (editor: Control) => void;
51
106
  }
52
107
 
@@ -60,10 +115,19 @@ declare interface Props {
60
115
  children: ReactElement;
61
116
  }
62
117
 
118
+ /**
119
+ * Default relative padding for text annotations.
120
+ */
63
121
  export declare const RELATIVE_PADDING = 0.25;
64
122
 
65
123
  export declare const TRANSPARENT = "none";
66
124
 
125
+ /**
126
+ * Retrieves the current annotations context for accessing and managing annotations.
127
+ *
128
+ * @returns {IAnnotationsContext} The current annotations context with methods and
129
+ * state for annotation management
130
+ */
67
131
  export declare const useAnnotationsContext: () => IAnnotationsContext;
68
132
 
69
133
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linkurious/ogma-annotations-react",
3
- "version": "1.1.23",
3
+ "version": "1.1.25",
4
4
  "description": "A react component to add ogma annotations with react",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "scripts": {
27
27
  "dev": "vite -c web/vite.config.mts",
28
- "build": "tsc --p ./tsconfig-build.json && vite build",
28
+ "build": "tsc --p ./tsconfig-build.json && vite build --mode production",
29
29
  "postversion": "npm i --save-peer @linkurious/ogma-annotations@${npm_new_version}",
30
30
  "bump:patch": "bump2version patch && npm version --no-git-tag-version patch",
31
31
  "bump:minor": "bump2version minor && npm version --no-git-tag-version minor",
@@ -34,7 +34,8 @@
34
34
  "postdocs:build": "bash scripts/postdocs.sh",
35
35
  "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
36
36
  "lint:ci": "eslint -f checkstyle -o reports/checkstyle.xml --ext ts,tsx src",
37
- "test:unit": ""
37
+ "test:unit": "vitest run",
38
+ "test": "npm run test:unit"
38
39
  },
39
40
  "publishConfig": {
40
41
  "access": "public"
@@ -51,15 +52,16 @@
51
52
  "license": "Apache-2.0",
52
53
  "peerDependencies": {
53
54
  "@linkurious/ogma": ">=4.5.6 || ^5.0.0",
54
- "@linkurious/ogma-annotations": "^1.1.23",
55
+ "@linkurious/ogma-annotations": "^1.1.25",
55
56
  "@linkurious/ogma-react": ">=5",
56
57
  "react": ">=17"
57
58
  },
58
59
  "devDependencies": {
59
60
  "@linkurious/eslint-config-ogma": "^1.0.14",
61
+ "@testing-library/react": "16.2.0",
60
62
  "@types/react": "18.3.1",
61
63
  "@types/react-dom": "18.3.1",
62
- "@vitejs/plugin-react": "4.3.4",
64
+ "@vitejs/plugin-react": "4.5.1",
63
65
  "eslint": "8.56.0",
64
66
  "eslint-plugin-react-hooks": "4.6.0",
65
67
  "eslint-plugin-react-refresh": "0.4.5",
@@ -67,7 +69,7 @@
67
69
  "react": "18.3.1",
68
70
  "react-dom": "18.3.1",
69
71
  "typescript": "5.3.3",
70
- "vite": "6.2.0",
72
+ "vite": "6.3.5",
71
73
  "vite-plugin-dts": "4.5.1",
72
74
  "vite-plugin-lib-inject-css": "1.3.0",
73
75
  "vitest": "3.0.7"