@linkurious/ogma-annotations-react 1.0.5

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.
@@ -0,0 +1,31 @@
1
+ import { Context, ReactElement } from "react";
2
+ import { AnnotationCollection, AnnotationFeature, ArrowStyles, TextStyle, Control as AnnotationsEditor, Annotation } from "@linkurious/ogma-annotations";
3
+ interface IAnnotationsContext {
4
+ annotations: AnnotationCollection;
5
+ updateAnnotations: React.Dispatch<AnnotationAction>;
6
+ currentAnnotation: AnnotationFeature | null;
7
+ setCurrentAnnotation: (annotation: AnnotationFeature | null) => void;
8
+ arrowStyle: ArrowStyles;
9
+ arrowWidthFactor: number;
10
+ setArrowWidthFactor: (arrowWidthFactor: number) => void;
11
+ setArrowStyle: (arrowStyle: ArrowStyles) => void;
12
+ textStyle: TextStyle;
13
+ textSizeFactor: number;
14
+ setTextSizeFactor: (textSizeFactor: number) => void;
15
+ setTextStyle: (textStyle: TextStyle) => void;
16
+ editor: AnnotationsEditor;
17
+ setEditor: (editor: AnnotationsEditor) => void;
18
+ }
19
+ export declare function createAnnotationsContext(): Context<IAnnotationsContext | null>;
20
+ export declare const AnnotationsContext: Context<IAnnotationsContext>;
21
+ export declare const useAnnotationsContext: () => IAnnotationsContext;
22
+ interface Props {
23
+ children: ReactElement;
24
+ }
25
+ type AnnotationActionType = "add" | "remove" | "update";
26
+ type AnnotationAction = {
27
+ type: AnnotationActionType;
28
+ payload: Annotation;
29
+ };
30
+ export declare const AnnotationsContextProvider: ({ children }: Props) => import("react/jsx-runtime").JSX.Element;
31
+ export {};
@@ -0,0 +1,9 @@
1
+ import { ArrowStyles, TextStyle } from "@linkurious/ogma-annotations";
2
+ export declare const fontSizes: number[];
3
+ export declare const TRANSPARENT = "none";
4
+ export declare const BLACK = "#333333";
5
+ export declare const defaultColors: string[];
6
+ export declare const fonts: string[];
7
+ export declare const defaultArrowStyle: ArrowStyles;
8
+ export declare const RELATIVE_PADDING = 0.25;
9
+ export declare const defaultTextStyle: TextStyle;
@@ -0,0 +1,3 @@
1
+ export * from './AnnotationsContext';
2
+ export * from './constants';
3
+ export * from './utils';
@@ -0,0 +1,772 @@
1
+ import Ae, { createContext as je, useContext as vr, useReducer as pr, useState as D, useEffect as re } from "react";
2
+ import { Control as yr, isArrow as gr, isText as Er } from "@linkurious/ogma-annotations";
3
+ import { useOgma as hr } from "@linkurious/ogma-react";
4
+ var te = { exports: {} }, $ = {};
5
+ /**
6
+ * @license React
7
+ * react-jsx-runtime.development.js
8
+ *
9
+ * Copyright (c) Facebook, Inc. and its affiliates.
10
+ *
11
+ * This source code is licensed under the MIT license found in the
12
+ * LICENSE file in the root directory of this source tree.
13
+ */
14
+ var xe;
15
+ function mr() {
16
+ return xe || (xe = 1, process.env.NODE_ENV !== "production" && function() {
17
+ var f = Ae, s = Symbol.for("react.element"), y = Symbol.for("react.portal"), S = Symbol.for("react.fragment"), g = Symbol.for("react.strict_mode"), x = Symbol.for("react.profiler"), b = Symbol.for("react.provider"), R = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), C = Symbol.for("react.suspense"), l = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), _ = Symbol.for("react.lazy"), P = Symbol.for("react.offscreen"), N = Symbol.iterator, Y = "@@iterator";
18
+ function M(e) {
19
+ if (e === null || typeof e != "object")
20
+ return null;
21
+ var r = N && e[N] || e[Y];
22
+ return typeof r == "function" ? r : null;
23
+ }
24
+ var O = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
25
+ function p(e) {
26
+ {
27
+ for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
28
+ t[n - 1] = arguments[n];
29
+ F("error", e, t);
30
+ }
31
+ }
32
+ function F(e, r, t) {
33
+ {
34
+ var n = O.ReactDebugCurrentFrame, i = n.getStackAddendum();
35
+ i !== "" && (r += "%s", t = t.concat([i]));
36
+ var u = t.map(function(o) {
37
+ return String(o);
38
+ });
39
+ u.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, u);
40
+ }
41
+ }
42
+ var We = !1, Ie = !1, $e = !1, Le = !1, Ne = !1, ne;
43
+ ne = Symbol.for("react.module.reference");
44
+ function Ye(e) {
45
+ return !!(typeof e == "string" || typeof e == "function" || e === S || e === x || Ne || e === g || e === C || e === l || Le || e === P || We || Ie || $e || typeof e == "object" && e !== null && (e.$$typeof === _ || e.$$typeof === h || e.$$typeof === b || e.$$typeof === R || e.$$typeof === v || // This needs to include all possible module reference object
46
+ // types supported by any Flight configuration anywhere since
47
+ // we don't know which Flight build this will end up being used
48
+ // with.
49
+ e.$$typeof === ne || e.getModuleId !== void 0));
50
+ }
51
+ function Me(e, r, t) {
52
+ var n = e.displayName;
53
+ if (n)
54
+ return n;
55
+ var i = r.displayName || r.name || "";
56
+ return i !== "" ? t + "(" + i + ")" : t;
57
+ }
58
+ function ae(e) {
59
+ return e.displayName || "Context";
60
+ }
61
+ function T(e) {
62
+ if (e == null)
63
+ return null;
64
+ if (typeof e.tag == "number" && p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
65
+ return e.displayName || e.name || null;
66
+ if (typeof e == "string")
67
+ return e;
68
+ switch (e) {
69
+ case S:
70
+ return "Fragment";
71
+ case y:
72
+ return "Portal";
73
+ case x:
74
+ return "Profiler";
75
+ case g:
76
+ return "StrictMode";
77
+ case C:
78
+ return "Suspense";
79
+ case l:
80
+ return "SuspenseList";
81
+ }
82
+ if (typeof e == "object")
83
+ switch (e.$$typeof) {
84
+ case R:
85
+ var r = e;
86
+ return ae(r) + ".Consumer";
87
+ case b:
88
+ var t = e;
89
+ return ae(t._context) + ".Provider";
90
+ case v:
91
+ return Me(e, e.render, "ForwardRef");
92
+ case h:
93
+ var n = e.displayName || null;
94
+ return n !== null ? n : T(e.type) || "Memo";
95
+ case _: {
96
+ var i = e, u = i._payload, o = i._init;
97
+ try {
98
+ return T(o(u));
99
+ } catch {
100
+ return null;
101
+ }
102
+ }
103
+ }
104
+ return null;
105
+ }
106
+ var A = Object.assign, W = 0, oe, ie, ue, se, le, fe, ce;
107
+ function de() {
108
+ }
109
+ de.__reactDisabledLog = !0;
110
+ function Ve() {
111
+ {
112
+ if (W === 0) {
113
+ oe = console.log, ie = console.info, ue = console.warn, se = console.error, le = console.group, fe = console.groupCollapsed, ce = console.groupEnd;
114
+ var e = {
115
+ configurable: !0,
116
+ enumerable: !0,
117
+ value: de,
118
+ writable: !0
119
+ };
120
+ Object.defineProperties(console, {
121
+ info: e,
122
+ log: e,
123
+ warn: e,
124
+ error: e,
125
+ group: e,
126
+ groupCollapsed: e,
127
+ groupEnd: e
128
+ });
129
+ }
130
+ W++;
131
+ }
132
+ }
133
+ function Ue() {
134
+ {
135
+ if (W--, W === 0) {
136
+ var e = {
137
+ configurable: !0,
138
+ enumerable: !0,
139
+ writable: !0
140
+ };
141
+ Object.defineProperties(console, {
142
+ log: A({}, e, {
143
+ value: oe
144
+ }),
145
+ info: A({}, e, {
146
+ value: ie
147
+ }),
148
+ warn: A({}, e, {
149
+ value: ue
150
+ }),
151
+ error: A({}, e, {
152
+ value: se
153
+ }),
154
+ group: A({}, e, {
155
+ value: le
156
+ }),
157
+ groupCollapsed: A({}, e, {
158
+ value: fe
159
+ }),
160
+ groupEnd: A({}, e, {
161
+ value: ce
162
+ })
163
+ });
164
+ }
165
+ W < 0 && p("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
166
+ }
167
+ }
168
+ var G = O.ReactCurrentDispatcher, J;
169
+ function V(e, r, t) {
170
+ {
171
+ if (J === void 0)
172
+ try {
173
+ throw Error();
174
+ } catch (i) {
175
+ var n = i.stack.trim().match(/\n( *(at )?)/);
176
+ J = n && n[1] || "";
177
+ }
178
+ return `
179
+ ` + J + e;
180
+ }
181
+ }
182
+ var H = !1, U;
183
+ {
184
+ var ze = typeof WeakMap == "function" ? WeakMap : Map;
185
+ U = new ze();
186
+ }
187
+ function ve(e, r) {
188
+ if (!e || H)
189
+ return "";
190
+ {
191
+ var t = U.get(e);
192
+ if (t !== void 0)
193
+ return t;
194
+ }
195
+ var n;
196
+ H = !0;
197
+ var i = Error.prepareStackTrace;
198
+ Error.prepareStackTrace = void 0;
199
+ var u;
200
+ u = G.current, G.current = null, Ve();
201
+ try {
202
+ if (r) {
203
+ var o = function() {
204
+ throw Error();
205
+ };
206
+ if (Object.defineProperty(o.prototype, "props", {
207
+ set: function() {
208
+ throw Error();
209
+ }
210
+ }), typeof Reflect == "object" && Reflect.construct) {
211
+ try {
212
+ Reflect.construct(o, []);
213
+ } catch (w) {
214
+ n = w;
215
+ }
216
+ Reflect.construct(e, [], o);
217
+ } else {
218
+ try {
219
+ o.call();
220
+ } catch (w) {
221
+ n = w;
222
+ }
223
+ e.call(o.prototype);
224
+ }
225
+ } else {
226
+ try {
227
+ throw Error();
228
+ } catch (w) {
229
+ n = w;
230
+ }
231
+ e();
232
+ }
233
+ } catch (w) {
234
+ if (w && n && typeof w.stack == "string") {
235
+ for (var a = w.stack.split(`
236
+ `), E = n.stack.split(`
237
+ `), c = a.length - 1, d = E.length - 1; c >= 1 && d >= 0 && a[c] !== E[d]; )
238
+ d--;
239
+ for (; c >= 1 && d >= 0; c--, d--)
240
+ if (a[c] !== E[d]) {
241
+ if (c !== 1 || d !== 1)
242
+ do
243
+ if (c--, d--, d < 0 || a[c] !== E[d]) {
244
+ var m = `
245
+ ` + a[c].replace(" at new ", " at ");
246
+ return e.displayName && m.includes("<anonymous>") && (m = m.replace("<anonymous>", e.displayName)), typeof e == "function" && U.set(e, m), m;
247
+ }
248
+ while (c >= 1 && d >= 0);
249
+ break;
250
+ }
251
+ }
252
+ } finally {
253
+ H = !1, G.current = u, Ue(), Error.prepareStackTrace = i;
254
+ }
255
+ var k = e ? e.displayName || e.name : "", Se = k ? V(k) : "";
256
+ return typeof e == "function" && U.set(e, Se), Se;
257
+ }
258
+ function Be(e, r, t) {
259
+ return ve(e, !1);
260
+ }
261
+ function qe(e) {
262
+ var r = e.prototype;
263
+ return !!(r && r.isReactComponent);
264
+ }
265
+ function z(e, r, t) {
266
+ if (e == null)
267
+ return "";
268
+ if (typeof e == "function")
269
+ return ve(e, qe(e));
270
+ if (typeof e == "string")
271
+ return V(e);
272
+ switch (e) {
273
+ case C:
274
+ return V("Suspense");
275
+ case l:
276
+ return V("SuspenseList");
277
+ }
278
+ if (typeof e == "object")
279
+ switch (e.$$typeof) {
280
+ case v:
281
+ return Be(e.render);
282
+ case h:
283
+ return z(e.type, r, t);
284
+ case _: {
285
+ var n = e, i = n._payload, u = n._init;
286
+ try {
287
+ return z(u(i), r, t);
288
+ } catch {
289
+ }
290
+ }
291
+ }
292
+ return "";
293
+ }
294
+ var B = Object.prototype.hasOwnProperty, pe = {}, ye = O.ReactDebugCurrentFrame;
295
+ function q(e) {
296
+ if (e) {
297
+ var r = e._owner, t = z(e.type, e._source, r ? r.type : null);
298
+ ye.setExtraStackFrame(t);
299
+ } else
300
+ ye.setExtraStackFrame(null);
301
+ }
302
+ function Ge(e, r, t, n, i) {
303
+ {
304
+ var u = Function.call.bind(B);
305
+ for (var o in e)
306
+ if (u(e, o)) {
307
+ var a = void 0;
308
+ try {
309
+ if (typeof e[o] != "function") {
310
+ var E = Error((n || "React class") + ": " + t + " type `" + o + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[o] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
311
+ throw E.name = "Invariant Violation", E;
312
+ }
313
+ a = e[o](r, o, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
314
+ } catch (c) {
315
+ a = c;
316
+ }
317
+ a && !(a instanceof Error) && (q(i), p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, o, typeof a), q(null)), a instanceof Error && !(a.message in pe) && (pe[a.message] = !0, q(i), p("Failed %s type: %s", t, a.message), q(null));
318
+ }
319
+ }
320
+ }
321
+ var Je = Array.isArray;
322
+ function K(e) {
323
+ return Je(e);
324
+ }
325
+ function He(e) {
326
+ {
327
+ var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
328
+ return t;
329
+ }
330
+ }
331
+ function Ke(e) {
332
+ try {
333
+ return ge(e), !1;
334
+ } catch {
335
+ return !0;
336
+ }
337
+ }
338
+ function ge(e) {
339
+ return "" + e;
340
+ }
341
+ function Ee(e) {
342
+ if (Ke(e))
343
+ return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", He(e)), ge(e);
344
+ }
345
+ var I = O.ReactCurrentOwner, Xe = {
346
+ key: !0,
347
+ ref: !0,
348
+ __self: !0,
349
+ __source: !0
350
+ }, he, me, X;
351
+ X = {};
352
+ function Ze(e) {
353
+ if (B.call(e, "ref")) {
354
+ var r = Object.getOwnPropertyDescriptor(e, "ref").get;
355
+ if (r && r.isReactWarning)
356
+ return !1;
357
+ }
358
+ return e.ref !== void 0;
359
+ }
360
+ function Qe(e) {
361
+ if (B.call(e, "key")) {
362
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
363
+ if (r && r.isReactWarning)
364
+ return !1;
365
+ }
366
+ return e.key !== void 0;
367
+ }
368
+ function er(e, r) {
369
+ if (typeof e.ref == "string" && I.current && r && I.current.stateNode !== r) {
370
+ var t = T(I.current.type);
371
+ X[t] || (p('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', T(I.current.type), e.ref), X[t] = !0);
372
+ }
373
+ }
374
+ function rr(e, r) {
375
+ {
376
+ var t = function() {
377
+ he || (he = !0, p("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
378
+ };
379
+ t.isReactWarning = !0, Object.defineProperty(e, "key", {
380
+ get: t,
381
+ configurable: !0
382
+ });
383
+ }
384
+ }
385
+ function tr(e, r) {
386
+ {
387
+ var t = function() {
388
+ me || (me = !0, p("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
389
+ };
390
+ t.isReactWarning = !0, Object.defineProperty(e, "ref", {
391
+ get: t,
392
+ configurable: !0
393
+ });
394
+ }
395
+ }
396
+ var nr = function(e, r, t, n, i, u, o) {
397
+ var a = {
398
+ // This tag allows us to uniquely identify this as a React Element
399
+ $$typeof: s,
400
+ // Built-in properties that belong on the element
401
+ type: e,
402
+ key: r,
403
+ ref: t,
404
+ props: o,
405
+ // Record the component responsible for creating this element.
406
+ _owner: u
407
+ };
408
+ return a._store = {}, Object.defineProperty(a._store, "validated", {
409
+ configurable: !1,
410
+ enumerable: !1,
411
+ writable: !0,
412
+ value: !1
413
+ }), Object.defineProperty(a, "_self", {
414
+ configurable: !1,
415
+ enumerable: !1,
416
+ writable: !1,
417
+ value: n
418
+ }), Object.defineProperty(a, "_source", {
419
+ configurable: !1,
420
+ enumerable: !1,
421
+ writable: !1,
422
+ value: i
423
+ }), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
424
+ };
425
+ function ar(e, r, t, n, i) {
426
+ {
427
+ var u, o = {}, a = null, E = null;
428
+ t !== void 0 && (Ee(t), a = "" + t), Qe(r) && (Ee(r.key), a = "" + r.key), Ze(r) && (E = r.ref, er(r, i));
429
+ for (u in r)
430
+ B.call(r, u) && !Xe.hasOwnProperty(u) && (o[u] = r[u]);
431
+ if (e && e.defaultProps) {
432
+ var c = e.defaultProps;
433
+ for (u in c)
434
+ o[u] === void 0 && (o[u] = c[u]);
435
+ }
436
+ if (a || E) {
437
+ var d = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
438
+ a && rr(o, d), E && tr(o, d);
439
+ }
440
+ return nr(e, a, E, i, n, I.current, o);
441
+ }
442
+ }
443
+ var Z = O.ReactCurrentOwner, be = O.ReactDebugCurrentFrame;
444
+ function j(e) {
445
+ if (e) {
446
+ var r = e._owner, t = z(e.type, e._source, r ? r.type : null);
447
+ be.setExtraStackFrame(t);
448
+ } else
449
+ be.setExtraStackFrame(null);
450
+ }
451
+ var Q;
452
+ Q = !1;
453
+ function ee(e) {
454
+ return typeof e == "object" && e !== null && e.$$typeof === s;
455
+ }
456
+ function Re() {
457
+ {
458
+ if (Z.current) {
459
+ var e = T(Z.current.type);
460
+ if (e)
461
+ return `
462
+
463
+ Check the render method of \`` + e + "`.";
464
+ }
465
+ return "";
466
+ }
467
+ }
468
+ function or(e) {
469
+ {
470
+ if (e !== void 0) {
471
+ var r = e.fileName.replace(/^.*[\\\/]/, ""), t = e.lineNumber;
472
+ return `
473
+
474
+ Check your code at ` + r + ":" + t + ".";
475
+ }
476
+ return "";
477
+ }
478
+ }
479
+ var _e = {};
480
+ function ir(e) {
481
+ {
482
+ var r = Re();
483
+ if (!r) {
484
+ var t = typeof e == "string" ? e : e.displayName || e.name;
485
+ t && (r = `
486
+
487
+ Check the top-level render call using <` + t + ">.");
488
+ }
489
+ return r;
490
+ }
491
+ }
492
+ function Ce(e, r) {
493
+ {
494
+ if (!e._store || e._store.validated || e.key != null)
495
+ return;
496
+ e._store.validated = !0;
497
+ var t = ir(r);
498
+ if (_e[t])
499
+ return;
500
+ _e[t] = !0;
501
+ var n = "";
502
+ e && e._owner && e._owner !== Z.current && (n = " It was passed a child from " + T(e._owner.type) + "."), j(e), p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), j(null);
503
+ }
504
+ }
505
+ function Te(e, r) {
506
+ {
507
+ if (typeof e != "object")
508
+ return;
509
+ if (K(e))
510
+ for (var t = 0; t < e.length; t++) {
511
+ var n = e[t];
512
+ ee(n) && Ce(n, r);
513
+ }
514
+ else if (ee(e))
515
+ e._store && (e._store.validated = !0);
516
+ else if (e) {
517
+ var i = M(e);
518
+ if (typeof i == "function" && i !== e.entries)
519
+ for (var u = i.call(e), o; !(o = u.next()).done; )
520
+ ee(o.value) && Ce(o.value, r);
521
+ }
522
+ }
523
+ }
524
+ function ur(e) {
525
+ {
526
+ var r = e.type;
527
+ if (r == null || typeof r == "string")
528
+ return;
529
+ var t;
530
+ if (typeof r == "function")
531
+ t = r.propTypes;
532
+ else if (typeof r == "object" && (r.$$typeof === v || // Note: Memo only checks outer props here.
533
+ // Inner props are checked in the reconciler.
534
+ r.$$typeof === h))
535
+ t = r.propTypes;
536
+ else
537
+ return;
538
+ if (t) {
539
+ var n = T(r);
540
+ Ge(t, e.props, "prop", n, e);
541
+ } else if (r.PropTypes !== void 0 && !Q) {
542
+ Q = !0;
543
+ var i = T(r);
544
+ p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", i || "Unknown");
545
+ }
546
+ typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
547
+ }
548
+ }
549
+ function sr(e) {
550
+ {
551
+ for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
552
+ var n = r[t];
553
+ if (n !== "children" && n !== "key") {
554
+ j(e), p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), j(null);
555
+ break;
556
+ }
557
+ }
558
+ e.ref !== null && (j(e), p("Invalid attribute `ref` supplied to `React.Fragment`."), j(null));
559
+ }
560
+ }
561
+ function we(e, r, t, n, i, u) {
562
+ {
563
+ var o = Ye(e);
564
+ if (!o) {
565
+ var a = "";
566
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
567
+ var E = or(i);
568
+ E ? a += E : a += Re();
569
+ var c;
570
+ e === null ? c = "null" : K(e) ? c = "array" : e !== void 0 && e.$$typeof === s ? (c = "<" + (T(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : c = typeof e, p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", c, a);
571
+ }
572
+ var d = ar(e, r, t, i, u);
573
+ if (d == null)
574
+ return d;
575
+ if (o) {
576
+ var m = r.children;
577
+ if (m !== void 0)
578
+ if (n)
579
+ if (K(m)) {
580
+ for (var k = 0; k < m.length; k++)
581
+ Te(m[k], e);
582
+ Object.freeze && Object.freeze(m);
583
+ } else
584
+ p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
585
+ else
586
+ Te(m, e);
587
+ }
588
+ return e === S ? sr(d) : ur(d), d;
589
+ }
590
+ }
591
+ function lr(e, r, t) {
592
+ return we(e, r, t, !0);
593
+ }
594
+ function fr(e, r, t) {
595
+ return we(e, r, t, !1);
596
+ }
597
+ var cr = fr, dr = lr;
598
+ $.Fragment = S, $.jsx = cr, $.jsxs = dr;
599
+ }()), $;
600
+ }
601
+ var L = {};
602
+ /**
603
+ * @license React
604
+ * react-jsx-runtime.production.min.js
605
+ *
606
+ * Copyright (c) Facebook, Inc. and its affiliates.
607
+ *
608
+ * This source code is licensed under the MIT license found in the
609
+ * LICENSE file in the root directory of this source tree.
610
+ */
611
+ var Oe;
612
+ function br() {
613
+ if (Oe)
614
+ return L;
615
+ Oe = 1;
616
+ var f = Ae, s = Symbol.for("react.element"), y = Symbol.for("react.fragment"), S = Object.prototype.hasOwnProperty, g = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, x = { key: !0, ref: !0, __self: !0, __source: !0 };
617
+ function b(R, v, C) {
618
+ var l, h = {}, _ = null, P = null;
619
+ C !== void 0 && (_ = "" + C), v.key !== void 0 && (_ = "" + v.key), v.ref !== void 0 && (P = v.ref);
620
+ for (l in v)
621
+ S.call(v, l) && !x.hasOwnProperty(l) && (h[l] = v[l]);
622
+ if (R && R.defaultProps)
623
+ for (l in v = R.defaultProps, v)
624
+ h[l] === void 0 && (h[l] = v[l]);
625
+ return { $$typeof: s, type: R, key: _, ref: P, props: h, _owner: g.current };
626
+ }
627
+ return L.Fragment = y, L.jsx = b, L.jsxs = b, L;
628
+ }
629
+ process.env.NODE_ENV === "production" ? te.exports = br() : te.exports = mr();
630
+ var Rr = te.exports;
631
+ const Pe = [8, 10, 12, 14, 16, 24, 32, 48, 64, 72], Fe = "none", ke = "#333333", Fr = [
632
+ "#FFFFFF",
633
+ "#F44E3B",
634
+ "#FE9200",
635
+ "#FCDC00",
636
+ "#A4DD00",
637
+ "#68CCCA",
638
+ "#73D8FF",
639
+ "#AEA1FF",
640
+ "#1E88E5",
641
+ "#333333",
642
+ "#808080",
643
+ "#cccccc"
644
+ ], Ar = [
645
+ "Roboto",
646
+ "Helvetica Neue",
647
+ "Helvetica",
648
+ "Arial",
649
+ "sans-serif",
650
+ "Georgia, serif",
651
+ "Menlo",
652
+ "Monaco",
653
+ "Consolas",
654
+ "Courier New",
655
+ "monospace"
656
+ ].sort((f, s) => f.toLocaleLowerCase().localeCompare(s.toLocaleLowerCase())), _r = {
657
+ head: "arrow",
658
+ strokeColor: ke,
659
+ strokeWidth: 5
660
+ }, Cr = 0.25, Tr = {
661
+ font: "Roboto",
662
+ fontSize: Pe[2].toString(),
663
+ padding: Pe[2] * Cr,
664
+ color: ke,
665
+ strokeType: Fe,
666
+ background: Fe
667
+ };
668
+ function wr(f) {
669
+ return f.reduce((s, y) => s + y, 0) / f.length;
670
+ }
671
+ function jr(f, s = 0, y = 1) {
672
+ return s + (y - s) * f;
673
+ }
674
+ function kr(f, s = 0, y = 1) {
675
+ return (f - s) / (y - s);
676
+ }
677
+ function Dr() {
678
+ return je(null);
679
+ }
680
+ const De = je(
681
+ void 0
682
+ ), Wr = () => vr(De), Sr = (f, s) => {
683
+ switch (s.type) {
684
+ case "add":
685
+ return {
686
+ ...f,
687
+ features: [...f.features, s.payload]
688
+ };
689
+ case "remove":
690
+ return {
691
+ ...f,
692
+ features: f.features.filter((y) => y.id !== s.payload.id)
693
+ };
694
+ case "update":
695
+ return {
696
+ ...f,
697
+ features: f.features.map(
698
+ (y) => y.id === s.payload.id ? s.payload : y
699
+ )
700
+ };
701
+ default:
702
+ return f;
703
+ }
704
+ }, Ir = ({ children: f }) => {
705
+ const s = hr(), [y, S] = pr(Sr, {
706
+ type: "FeatureCollection",
707
+ features: []
708
+ }), [g, x] = D(null), [b, R] = D(_r), [v, C] = D(Tr), [l, h] = D(), [_, P] = D(1), [N, Y] = D(1);
709
+ return re(() => {
710
+ if (!s)
711
+ return;
712
+ const M = new yr(s, {
713
+ minArrowHeight: 1
714
+ }), O = wr(s.getNodes().getAttribute("radius")) / 5, p = _;
715
+ return R({
716
+ ...b,
717
+ strokeWidth: (b.strokeWidth || 1) * p
718
+ }), P(p), Y(O), M.on("select", (F) => {
719
+ gr(F) ? R({
720
+ ...F.properties.style || {}
721
+ }) : Er(F) && C({
722
+ ...F.properties.style || {}
723
+ }), x(F);
724
+ }).on("unselect", () => {
725
+ x(null);
726
+ }), h(M), () => {
727
+ l == null || l.destroy();
728
+ };
729
+ }, [s]), re(() => {
730
+ l && g && (g == null ? void 0 : g.properties.type) === "arrow" && l.updateStyle(g.id, b);
731
+ }, [l, b]), re(() => {
732
+ l && g && (g == null ? void 0 : g.properties.type) === "text" && l.updateStyle(g.id, v);
733
+ }, [l, v]), /* @__PURE__ */ Rr.jsx(
734
+ De.Provider,
735
+ {
736
+ value: {
737
+ annotations: y,
738
+ updateAnnotations: S,
739
+ currentAnnotation: g,
740
+ setCurrentAnnotation: x,
741
+ textStyle: v,
742
+ setTextStyle: C,
743
+ arrowStyle: b,
744
+ setArrowStyle: R,
745
+ arrowWidthFactor: _,
746
+ setArrowWidthFactor: P,
747
+ textSizeFactor: N,
748
+ setTextSizeFactor: Y,
749
+ editor: l,
750
+ setEditor: h
751
+ },
752
+ children: f
753
+ }
754
+ );
755
+ };
756
+ export {
757
+ De as AnnotationsContext,
758
+ Ir as AnnotationsContextProvider,
759
+ ke as BLACK,
760
+ Cr as RELATIVE_PADDING,
761
+ Fe as TRANSPARENT,
762
+ Dr as createAnnotationsContext,
763
+ _r as defaultArrowStyle,
764
+ Fr as defaultColors,
765
+ Tr as defaultTextStyle,
766
+ Pe as fontSizes,
767
+ Ar as fonts,
768
+ jr as interpolate,
769
+ wr as mean,
770
+ kr as normalize,
771
+ Wr as useAnnotationsContext
772
+ };
@@ -0,0 +1,27 @@
1
+ (function(f,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("react"),require("@linkurious/ogma-annotations"),require("@linkurious/ogma-react")):typeof define=="function"&&define.amd?define(["exports","react","@linkurious/ogma-annotations","@linkurious/ogma-react"],p):(f=typeof globalThis<"u"?globalThis:f||self,p(f.index={},f.react,f.ogmaAnnotations,f.ogmaReact))})(this,function(f,p,K,Le){"use strict";var X={exports:{}},W={};/**
2
+ * @license React
3
+ * react-jsx-runtime.development.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var se;function Ye(){return se||(se=1,process.env.NODE_ENV!=="production"&&function(){var c=p,s=Symbol.for("react.element"),g=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),_=Symbol.for("react.provider"),C=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),l=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),F=Symbol.for("react.offscreen"),M=Symbol.iterator,V="@@iterator";function U(e){if(e===null||typeof e!="object")return null;var r=M&&e[M]||e[V];return typeof r=="function"?r:null}var A=c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function E(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];j("error",e,t)}}function j(e,r,t){{var n=A.ReactDebugCurrentFrame,i=n.getStackAddendum();i!==""&&(r+="%s",t=t.concat([i]));var u=t.map(function(o){return String(o)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var Ze=!1,Qe=!1,qe=!1,$e=!1,er=!1,pe;pe=Symbol.for("react.module.reference");function rr(e){return!!(typeof e=="string"||typeof e=="function"||e===O||e===x||er||e===h||e===S||e===l||$e||e===F||Ze||Qe||qe||typeof e=="object"&&e!==null&&(e.$$typeof===T||e.$$typeof===R||e.$$typeof===_||e.$$typeof===C||e.$$typeof===y||e.$$typeof===pe||e.getModuleId!==void 0))}function tr(e,r,t){var n=e.displayName;if(n)return n;var i=r.displayName||r.name||"";return i!==""?t+"("+i+")":t}function ye(e){return e.displayName||"Context"}function w(e){if(e==null)return null;if(typeof e.tag=="number"&&E("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case O:return"Fragment";case g:return"Portal";case x:return"Profiler";case h:return"StrictMode";case S:return"Suspense";case l:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case C:var r=e;return ye(r)+".Consumer";case _:var t=e;return ye(t._context)+".Provider";case y:return tr(e,e.render,"ForwardRef");case R:var n=e.displayName||null;return n!==null?n:w(e.type)||"Memo";case T:{var i=e,u=i._payload,o=i._init;try{return w(o(u))}catch{return null}}}return null}var k=Object.assign,L=0,Ee,ge,he,me,Re,be,_e;function Ce(){}Ce.__reactDisabledLog=!0;function nr(){{if(L===0){Ee=console.log,ge=console.info,he=console.warn,me=console.error,Re=console.group,be=console.groupCollapsed,_e=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ce,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}L++}}function ar(){{if(L--,L===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:k({},e,{value:Ee}),info:k({},e,{value:ge}),warn:k({},e,{value:he}),error:k({},e,{value:me}),group:k({},e,{value:Re}),groupCollapsed:k({},e,{value:be}),groupEnd:k({},e,{value:_e})})}L<0&&E("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ee=A.ReactCurrentDispatcher,re;function z(e,r,t){{if(re===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);re=n&&n[1]||""}return`
10
+ `+re+e}}var te=!1,B;{var or=typeof WeakMap=="function"?WeakMap:Map;B=new or}function Te(e,r){if(!e||te)return"";{var t=B.get(e);if(t!==void 0)return t}var n;te=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=ee.current,ee.current=null,nr();try{if(r){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(P){n=P}Reflect.construct(e,[],o)}else{try{o.call()}catch(P){n=P}e.call(o.prototype)}}else{try{throw Error()}catch(P){n=P}e()}}catch(P){if(P&&n&&typeof P.stack=="string"){for(var a=P.stack.split(`
11
+ `),m=n.stack.split(`
12
+ `),d=a.length-1,v=m.length-1;d>=1&&v>=0&&a[d]!==m[v];)v--;for(;d>=1&&v>=0;d--,v--)if(a[d]!==m[v]){if(d!==1||v!==1)do if(d--,v--,v<0||a[d]!==m[v]){var b=`
13
+ `+a[d].replace(" at new "," at ");return e.displayName&&b.includes("<anonymous>")&&(b=b.replace("<anonymous>",e.displayName)),typeof e=="function"&&B.set(e,b),b}while(d>=1&&v>=0);break}}}finally{te=!1,ee.current=u,ar(),Error.prepareStackTrace=i}var I=e?e.displayName||e.name:"",Ne=I?z(I):"";return typeof e=="function"&&B.set(e,Ne),Ne}function ir(e,r,t){return Te(e,!1)}function ur(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function G(e,r,t){if(e==null)return"";if(typeof e=="function")return Te(e,ur(e));if(typeof e=="string")return z(e);switch(e){case S:return z("Suspense");case l:return z("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case y:return ir(e.render);case R:return G(e.type,r,t);case T:{var n=e,i=n._payload,u=n._init;try{return G(u(i),r,t)}catch{}}}return""}var J=Object.prototype.hasOwnProperty,Se={},we=A.ReactDebugCurrentFrame;function H(e){if(e){var r=e._owner,t=G(e.type,e._source,r?r.type:null);we.setExtraStackFrame(t)}else we.setExtraStackFrame(null)}function sr(e,r,t,n,i){{var u=Function.call.bind(J);for(var o in e)if(u(e,o)){var a=void 0;try{if(typeof e[o]!="function"){var m=Error((n||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw m.name="Invariant Violation",m}a=e[o](r,o,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(d){a=d}a&&!(a instanceof Error)&&(H(i),E("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,o,typeof a),H(null)),a instanceof Error&&!(a.message in Se)&&(Se[a.message]=!0,H(i),E("Failed %s type: %s",t,a.message),H(null))}}}var lr=Array.isArray;function ne(e){return lr(e)}function fr(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function cr(e){try{return Pe(e),!1}catch{return!0}}function Pe(e){return""+e}function Oe(e){if(cr(e))return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",fr(e)),Pe(e)}var Y=A.ReactCurrentOwner,dr={key:!0,ref:!0,__self:!0,__source:!0},xe,Ae,ae;ae={};function vr(e){if(J.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function pr(e){if(J.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function yr(e,r){if(typeof e.ref=="string"&&Y.current&&r&&Y.current.stateNode!==r){var t=w(Y.current.type);ae[t]||(E('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',w(Y.current.type),e.ref),ae[t]=!0)}}function Er(e,r){{var t=function(){xe||(xe=!0,E("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function gr(e,r){{var t=function(){Ae||(Ae=!0,E("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var hr=function(e,r,t,n,i,u,o){var a={$$typeof:s,type:e,key:r,ref:t,props:o,_owner:u};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function mr(e,r,t,n,i){{var u,o={},a=null,m=null;t!==void 0&&(Oe(t),a=""+t),pr(r)&&(Oe(r.key),a=""+r.key),vr(r)&&(m=r.ref,yr(r,i));for(u in r)J.call(r,u)&&!dr.hasOwnProperty(u)&&(o[u]=r[u]);if(e&&e.defaultProps){var d=e.defaultProps;for(u in d)o[u]===void 0&&(o[u]=d[u])}if(a||m){var v=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&Er(o,v),m&&gr(o,v)}return hr(e,a,m,i,n,Y.current,o)}}var oe=A.ReactCurrentOwner,Fe=A.ReactDebugCurrentFrame;function D(e){if(e){var r=e._owner,t=G(e.type,e._source,r?r.type:null);Fe.setExtraStackFrame(t)}else Fe.setExtraStackFrame(null)}var ie;ie=!1;function ue(e){return typeof e=="object"&&e!==null&&e.$$typeof===s}function je(){{if(oe.current){var e=w(oe.current.type);if(e)return`
14
+
15
+ Check the render method of \``+e+"`."}return""}}function Rr(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return`
16
+
17
+ Check your code at `+r+":"+t+"."}return""}}var ke={};function br(e){{var r=je();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
18
+
19
+ Check the top-level render call using <`+t+">.")}return r}}function De(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=br(r);if(ke[t])return;ke[t]=!0;var n="";e&&e._owner&&e._owner!==oe.current&&(n=" It was passed a child from "+w(e._owner.type)+"."),D(e),E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),D(null)}}function Ie(e,r){{if(typeof e!="object")return;if(ne(e))for(var t=0;t<e.length;t++){var n=e[t];ue(n)&&De(n,r)}else if(ue(e))e._store&&(e._store.validated=!0);else if(e){var i=U(e);if(typeof i=="function"&&i!==e.entries)for(var u=i.call(e),o;!(o=u.next()).done;)ue(o.value)&&De(o.value,r)}}}function _r(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===y||r.$$typeof===R))t=r.propTypes;else return;if(t){var n=w(r);sr(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!ie){ie=!0;var i=w(r);E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",i||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Cr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){D(e),E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),D(null);break}}e.ref!==null&&(D(e),E("Invalid attribute `ref` supplied to `React.Fragment`."),D(null))}}function We(e,r,t,n,i,u){{var o=rr(e);if(!o){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var m=Rr(i);m?a+=m:a+=je();var d;e===null?d="null":ne(e)?d="array":e!==void 0&&e.$$typeof===s?(d="<"+(w(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):d=typeof e,E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",d,a)}var v=mr(e,r,t,i,u);if(v==null)return v;if(o){var b=r.children;if(b!==void 0)if(n)if(ne(b)){for(var I=0;I<b.length;I++)Ie(b[I],e);Object.freeze&&Object.freeze(b)}else E("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ie(b,e)}return e===O?Cr(v):_r(v),v}}function Tr(e,r,t){return We(e,r,t,!0)}function Sr(e,r,t){return We(e,r,t,!1)}var wr=Sr,Pr=Tr;W.Fragment=O,W.jsx=wr,W.jsxs=Pr}()),W}var N={};/**
20
+ * @license React
21
+ * react-jsx-runtime.production.min.js
22
+ *
23
+ * Copyright (c) Facebook, Inc. and its affiliates.
24
+ *
25
+ * This source code is licensed under the MIT license found in the
26
+ * LICENSE file in the root directory of this source tree.
27
+ */var le;function Me(){if(le)return N;le=1;var c=p,s=Symbol.for("react.element"),g=Symbol.for("react.fragment"),O=Object.prototype.hasOwnProperty,h=c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,x={key:!0,ref:!0,__self:!0,__source:!0};function _(C,y,S){var l,R={},T=null,F=null;S!==void 0&&(T=""+S),y.key!==void 0&&(T=""+y.key),y.ref!==void 0&&(F=y.ref);for(l in y)O.call(y,l)&&!x.hasOwnProperty(l)&&(R[l]=y[l]);if(C&&C.defaultProps)for(l in y=C.defaultProps,y)R[l]===void 0&&(R[l]=y[l]);return{$$typeof:s,type:C,key:T,ref:F,props:R,_owner:h.current}}return N.Fragment=g,N.jsx=_,N.jsxs=_,N}process.env.NODE_ENV==="production"?X.exports=Me():X.exports=Ye();var Ve=X.exports;const Z=[8,10,12,14,16,24,32,48,64,72],Q="none",q="#333333",Ue=["#FFFFFF","#F44E3B","#FE9200","#FCDC00","#A4DD00","#68CCCA","#73D8FF","#AEA1FF","#1E88E5","#333333","#808080","#cccccc"],ze=["Roboto","Helvetica Neue","Helvetica","Arial","sans-serif","Georgia, serif","Menlo","Monaco","Consolas","Courier New","monospace"].sort((c,s)=>c.toLocaleLowerCase().localeCompare(s.toLocaleLowerCase())),fe={head:"arrow",strokeColor:q,strokeWidth:5},ce=.25,de={font:"Roboto",fontSize:Z[2].toString(),padding:Z[2]*ce,color:q,strokeType:Q,background:Q};function ve(c){return c.reduce((s,g)=>s+g,0)/c.length}function Be(c,s=0,g=1){return s+(g-s)*c}function Ge(c,s=0,g=1){return(c-s)/(g-s)}function Je(){return p.createContext(null)}const $=p.createContext(void 0),He=()=>p.useContext($),Ke=(c,s)=>{switch(s.type){case"add":return{...c,features:[...c.features,s.payload]};case"remove":return{...c,features:c.features.filter(g=>g.id!==s.payload.id)};case"update":return{...c,features:c.features.map(g=>g.id===s.payload.id?s.payload:g)};default:return c}},Xe=({children:c})=>{const s=Le.useOgma(),[g,O]=p.useReducer(Ke,{type:"FeatureCollection",features:[]}),[h,x]=p.useState(null),[_,C]=p.useState(fe),[y,S]=p.useState(de),[l,R]=p.useState(),[T,F]=p.useState(1),[M,V]=p.useState(1);return p.useEffect(()=>{if(!s)return;const U=new K.Control(s,{minArrowHeight:1}),A=ve(s.getNodes().getAttribute("radius"))/5,E=T;return C({..._,strokeWidth:(_.strokeWidth||1)*E}),F(E),V(A),U.on("select",j=>{K.isArrow(j)?C({...j.properties.style||{}}):K.isText(j)&&S({...j.properties.style||{}}),x(j)}).on("unselect",()=>{x(null)}),R(U),()=>{l==null||l.destroy()}},[s]),p.useEffect(()=>{l&&h&&(h==null?void 0:h.properties.type)==="arrow"&&l.updateStyle(h.id,_)},[l,_]),p.useEffect(()=>{l&&h&&(h==null?void 0:h.properties.type)==="text"&&l.updateStyle(h.id,y)},[l,y]),Ve.jsx($.Provider,{value:{annotations:g,updateAnnotations:O,currentAnnotation:h,setCurrentAnnotation:x,textStyle:y,setTextStyle:S,arrowStyle:_,setArrowStyle:C,arrowWidthFactor:T,setArrowWidthFactor:F,textSizeFactor:M,setTextSizeFactor:V,editor:l,setEditor:R},children:c})};f.AnnotationsContext=$,f.AnnotationsContextProvider=Xe,f.BLACK=q,f.RELATIVE_PADDING=ce,f.TRANSPARENT=Q,f.createAnnotationsContext=Je,f.defaultArrowStyle=fe,f.defaultColors=Ue,f.defaultTextStyle=de,f.fontSizes=Z,f.fonts=ze,f.interpolate=Be,f.mean=ve,f.normalize=Ge,f.useAnnotationsContext=He,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,3 @@
1
+ export declare function mean(array: number[]): number;
2
+ export declare function interpolate(t: number, min?: number, max?: number): number;
3
+ export declare function normalize(t: number, min?: number, max?: number): number;
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@linkurious/ogma-annotations-react",
3
+ "version": "1.0.5",
4
+ "description": "A react component to add ogma annotations with react",
5
+ "main": "dist/ogma-annotations-react.mjs",
6
+ "module": "dist/ogma-annotations-react.mjs",
7
+ "browser": "dist/ogma-annotations-react.umd.js",
8
+ "types": "dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "sideEffects": [
13
+ "dist/**/*.css"
14
+ ],
15
+ "exports": {
16
+ ".": {
17
+ "import": "./dist/ogma-annotations-react.mjs",
18
+ "require": "./dist/ogma-annotations-react.umd.js",
19
+ "default": "./dist/ogma-annotations-react.mjs",
20
+ "types": "./dist/index.d.ts"
21
+ },
22
+ "./umd": "./dist/ogma-annotations-react.umd.js",
23
+ "./esm": "./dist/ogma-annotations-react.mjs"
24
+ },
25
+ "scripts": {
26
+ "dev": "vite -c web/vite.config.ts",
27
+ "build": "tsc --p ./tsconfig-build.json && vite build",
28
+ "docs:build": "vite build -c web/vite.config.ts",
29
+ "postdocs:build": "bash scripts/postdocs.sh",
30
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "private": false,
36
+ "keywords": [
37
+ "react",
38
+ "ogma",
39
+ "annotations",
40
+ "text",
41
+ "arrow"
42
+ ],
43
+ "author": "Linkurious SAS",
44
+ "license": "Apache-2.0",
45
+ "peerDependencies": {
46
+ "@linkurious/ogma": ">=4.5.6",
47
+ "@linkurious/ogma-annotations": "^1.0.0",
48
+ "@linkurious/ogma-react": ">=4.6.1",
49
+ "react": "^18.2.0"
50
+ },
51
+ "dependencies": {},
52
+ "devDependencies": {
53
+ "@geist-ui/react": "^2.2.5",
54
+ "@geist-ui/react-icons": "^1.0.1",
55
+ "@types/react": "^18.2.39",
56
+ "@types/react-dom": "^18.2.17",
57
+ "@typescript-eslint/eslint-plugin": "^6.13.1",
58
+ "@typescript-eslint/parser": "^6.13.1",
59
+ "@vitejs/plugin-react": "^4.2.0",
60
+ "eslint": "^8.54.0",
61
+ "eslint-plugin-react-hooks": "^4.6.0",
62
+ "eslint-plugin-react-refresh": "^0.4.4",
63
+ "typescript": "5.3.2",
64
+ "vite": "^5.0.2",
65
+ "vite-plugin-dts": "^3.6.3",
66
+ "vite-plugin-lib-inject-css": "^1.3.0",
67
+ "vitest": "^0.34.6"
68
+ }
69
+ }