@linkurious/ogma-annotations-react 1.1.9 → 1.1.12

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.
@@ -1,27 +0,0 @@
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.production.min.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(){if(se)return W;se=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 W.Fragment=g,W.jsx=_,W.jsxs=_,W}var N={};/**
10
- * @license React
11
- * react-jsx-runtime.development.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var le;function Me(){return le||(le=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`
18
- `+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(`
19
- `),m=n.stack.split(`
20
- `),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=`
21
- `+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`
22
-
23
- Check the render method of \``+e+"`."}return""}}function Rr(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return`
24
-
25
- 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=`
26
-
27
- 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;N.Fragment=O,N.jsx=wr,N.jsxs=Pr}()),N}process.env.NODE_ENV==="production"?X.exports=Ye():X.exports=Me();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],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"})});