react-data-matrix 0.3.7 → 0.4.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.
@@ -0,0 +1,28 @@
1
+ (function(F,D){typeof exports=="object"&&typeof module<"u"?module.exports=D(require("react")):typeof define=="function"&&define.amd?define(["react"],D):(F=typeof globalThis<"u"?globalThis:F||self,F["React Data Matrix"]=D(F.React))})(this,function(F){"use strict";var D={exports:{}},K={};/**
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 ve;function ze(){if(ve)return K;ve=1;var n=F,s=Symbol.for("react.element"),b=Symbol.for("react.fragment"),d=Object.prototype.hasOwnProperty,y=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,x={key:!0,ref:!0,__self:!0,__source:!0};function T(f,v,E){var h,g={},w=null,C=null;E!==void 0&&(w=""+E),v.key!==void 0&&(w=""+v.key),v.ref!==void 0&&(C=v.ref);for(h in v)d.call(v,h)&&!x.hasOwnProperty(h)&&(g[h]=v[h]);if(f&&f.defaultProps)for(h in v=f.defaultProps,v)g[h]===void 0&&(g[h]=v[h]);return{$$typeof:s,type:f,key:w,ref:C,props:g,_owner:y.current}}return K.Fragment=b,K.jsx=T,K.jsxs=T,K}var X={};/**
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 pe;function Ve(){return pe||(pe=1,process.env.NODE_ENV!=="production"&&function(){var n=F,s=Symbol.for("react.element"),b=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),T=Symbol.for("react.provider"),f=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),C=Symbol.for("react.offscreen"),A=Symbol.iterator,O="@@iterator";function W(e){if(e===null||typeof e!="object")return null;var r=A&&e[A]||e[O];return typeof r=="function"?r:null}var $=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function _(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),a=1;a<r;a++)t[a-1]=arguments[a];Y("error",e,t)}}function Y(e,r,t){{var a=$.ReactDebugCurrentFrame,l=a.getStackAddendum();l!==""&&(r+="%s",t=t.concat([l]));var u=t.map(function(o){return String(o)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var P=!1,U=!1,B=!1,I=!1,z=!1,M;M=Symbol.for("react.module.reference");function V(e){return!!(typeof e=="string"||typeof e=="function"||e===d||e===x||z||e===y||e===E||e===h||I||e===C||P||U||B||typeof e=="object"&&e!==null&&(e.$$typeof===w||e.$$typeof===g||e.$$typeof===T||e.$$typeof===f||e.$$typeof===v||e.$$typeof===M||e.getModuleId!==void 0))}function q(e,r,t){var a=e.displayName;if(a)return a;var l=r.displayName||r.name||"";return l!==""?t+"("+l+")":t}function H(e){return e.displayName||"Context"}function S(e){if(e==null)return null;if(typeof e.tag=="number"&&_("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 d:return"Fragment";case b:return"Portal";case x:return"Profiler";case y:return"StrictMode";case E:return"Suspense";case h:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case f:var r=e;return H(r)+".Consumer";case T:var t=e;return H(t._context)+".Provider";case v:return q(e,e.render,"ForwardRef");case g:var a=e.displayName||null;return a!==null?a:S(e.type)||"Memo";case w:{var l=e,u=l._payload,o=l._init;try{return S(o(u))}catch{return null}}}return null}var L=Object.assign,Z=0,xe,Ee,Te,we,je,Ce,$e;function Pe(){}Pe.__reactDisabledLog=!0;function Xe(){{if(Z===0){xe=console.log,Ee=console.info,Te=console.warn,we=console.error,je=console.group,Ce=console.groupCollapsed,$e=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Pe,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Z++}}function Ze(){{if(Z--,Z===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:L({},e,{value:xe}),info:L({},e,{value:Ee}),warn:L({},e,{value:Te}),error:L({},e,{value:we}),group:L({},e,{value:je}),groupCollapsed:L({},e,{value:Ce}),groupEnd:L({},e,{value:$e})})}Z<0&&_("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ie=$.ReactCurrentDispatcher,oe;function ee(e,r,t){{if(oe===void 0)try{throw Error()}catch(l){var a=l.stack.trim().match(/\n( *(at )?)/);oe=a&&a[1]||""}return`
18
+ `+oe+e}}var se=!1,re;{var Qe=typeof WeakMap=="function"?WeakMap:Map;re=new Qe}function Oe(e,r){if(!e||se)return"";{var t=re.get(e);if(t!==void 0)return t}var a;se=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=ie.current,ie.current=null,Xe();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(k){a=k}Reflect.construct(e,[],o)}else{try{o.call()}catch(k){a=k}e.call(o.prototype)}}else{try{throw Error()}catch(k){a=k}e()}}catch(k){if(k&&a&&typeof k.stack=="string"){for(var i=k.stack.split(`
19
+ `),R=a.stack.split(`
20
+ `),p=i.length-1,m=R.length-1;p>=1&&m>=0&&i[p]!==R[m];)m--;for(;p>=1&&m>=0;p--,m--)if(i[p]!==R[m]){if(p!==1||m!==1)do if(p--,m--,m<0||i[p]!==R[m]){var j=`
21
+ `+i[p].replace(" at new "," at ");return e.displayName&&j.includes("<anonymous>")&&(j=j.replace("<anonymous>",e.displayName)),typeof e=="function"&&re.set(e,j),j}while(p>=1&&m>=0);break}}}finally{se=!1,ie.current=u,Ze(),Error.prepareStackTrace=l}var G=e?e.displayName||e.name:"",Ie=G?ee(G):"";return typeof e=="function"&&re.set(e,Ie),Ie}function er(e,r,t){return Oe(e,!1)}function rr(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function te(e,r,t){if(e==null)return"";if(typeof e=="function")return Oe(e,rr(e));if(typeof e=="string")return ee(e);switch(e){case E:return ee("Suspense");case h:return ee("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case v:return er(e.render);case g:return te(e.type,r,t);case w:{var a=e,l=a._payload,u=a._init;try{return te(u(l),r,t)}catch{}}}return""}var ne=Object.prototype.hasOwnProperty,Se={},ke=$.ReactDebugCurrentFrame;function ae(e){if(e){var r=e._owner,t=te(e.type,e._source,r?r.type:null);ke.setExtraStackFrame(t)}else ke.setExtraStackFrame(null)}function tr(e,r,t,a,l){{var u=Function.call.bind(ne);for(var o in e)if(u(e,o)){var i=void 0;try{if(typeof e[o]!="function"){var R=Error((a||"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 R.name="Invariant Violation",R}i=e[o](r,o,a,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(p){i=p}i&&!(i instanceof Error)&&(ae(l),_("%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).",a||"React class",t,o,typeof i),ae(null)),i instanceof Error&&!(i.message in Se)&&(Se[i.message]=!0,ae(l),_("Failed %s type: %s",t,i.message),ae(null))}}}var nr=Array.isArray;function le(e){return nr(e)}function ar(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function ir(e){try{return Ae(e),!1}catch{return!0}}function Ae(e){return""+e}function Fe(e){if(ir(e))return _("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ar(e)),Ae(e)}var Q=$.ReactCurrentOwner,or={key:!0,ref:!0,__self:!0,__source:!0},De,We,ue;ue={};function sr(e){if(ne.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function lr(e){if(ne.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function ur(e,r){if(typeof e.ref=="string"&&Q.current&&r&&Q.current.stateNode!==r){var t=S(Q.current.type);ue[t]||(_('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',S(Q.current.type),e.ref),ue[t]=!0)}}function cr(e,r){{var t=function(){De||(De=!0,_("%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 fr(e,r){{var t=function(){We||(We=!0,_("%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 dr=function(e,r,t,a,l,u,o){var i={$$typeof:s,type:e,key:r,ref:t,props:o,_owner:u};return i._store={},Object.defineProperty(i._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(i,"_self",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.defineProperty(i,"_source",{configurable:!1,enumerable:!1,writable:!1,value:l}),Object.freeze&&(Object.freeze(i.props),Object.freeze(i)),i};function vr(e,r,t,a,l){{var u,o={},i=null,R=null;t!==void 0&&(Fe(t),i=""+t),lr(r)&&(Fe(r.key),i=""+r.key),sr(r)&&(R=r.ref,ur(r,l));for(u in r)ne.call(r,u)&&!or.hasOwnProperty(u)&&(o[u]=r[u]);if(e&&e.defaultProps){var p=e.defaultProps;for(u in p)o[u]===void 0&&(o[u]=p[u])}if(i||R){var m=typeof e=="function"?e.displayName||e.name||"Unknown":e;i&&cr(o,m),R&&fr(o,m)}return dr(e,i,R,l,a,Q.current,o)}}var ce=$.ReactCurrentOwner,Ye=$.ReactDebugCurrentFrame;function J(e){if(e){var r=e._owner,t=te(e.type,e._source,r?r.type:null);Ye.setExtraStackFrame(t)}else Ye.setExtraStackFrame(null)}var fe;fe=!1;function de(e){return typeof e=="object"&&e!==null&&e.$$typeof===s}function Me(){{if(ce.current){var e=S(ce.current.type);if(e)return`
22
+
23
+ Check the render method of \``+e+"`."}return""}}function pr(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return`
24
+
25
+ Check your code at `+r+":"+t+"."}return""}}var Le={};function hr(e){{var r=Me();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 Ne(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=hr(r);if(Le[t])return;Le[t]=!0;var a="";e&&e._owner&&e._owner!==ce.current&&(a=" It was passed a child from "+S(e._owner.type)+"."),J(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,a),J(null)}}function Ue(e,r){{if(typeof e!="object")return;if(le(e))for(var t=0;t<e.length;t++){var a=e[t];de(a)&&Ne(a,r)}else if(de(e))e._store&&(e._store.validated=!0);else if(e){var l=W(e);if(typeof l=="function"&&l!==e.entries)for(var u=l.call(e),o;!(o=u.next()).done;)de(o.value)&&Ne(o.value,r)}}}function mr(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===v||r.$$typeof===g))t=r.propTypes;else return;if(t){var a=S(r);tr(t,e.props,"prop",a,e)}else if(r.PropTypes!==void 0&&!fe){fe=!0;var l=S(r);_("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",l||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&_("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function _r(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var a=r[t];if(a!=="children"&&a!=="key"){J(e),_("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",a),J(null);break}}e.ref!==null&&(J(e),_("Invalid attribute `ref` supplied to `React.Fragment`."),J(null))}}function Be(e,r,t,a,l,u){{var o=V(e);if(!o){var i="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(i+=" 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 R=pr(l);R?i+=R:i+=Me();var p;e===null?p="null":le(e)?p="array":e!==void 0&&e.$$typeof===s?(p="<"+(S(e.type)||"Unknown")+" />",i=" Did you accidentally export a JSX literal instead of a component?"):p=typeof e,_("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",p,i)}var m=vr(e,r,t,l,u);if(m==null)return m;if(o){var j=r.children;if(j!==void 0)if(a)if(le(j)){for(var G=0;G<j.length;G++)Ue(j[G],e);Object.freeze&&Object.freeze(j)}else _("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 Ue(j,e)}return e===d?_r(m):mr(m),m}}function br(e,r,t){return Be(e,r,t,!0)}function yr(e,r,t){return Be(e,r,t,!1)}var gr=yr,Rr=br;X.Fragment=d,X.jsx=gr,X.jsxs=Rr}()),X}process.env.NODE_ENV==="production"?D.exports=ze():D.exports=Ve();var c=D.exports;const N=n=>n||{},qe=(n,s)=>n?{top:"50%",left:"50%",height:"100%",textAlign:"center",position:"absolute",transform:"translate(-50%, -50%)",...s}:{...N(n)},He=n=>n?{border:"1px solid black"}:{},Je=(n,s)=>n?{width:"70rem",...s}:{...N(n)},he=(n,s)=>n?{borderWidth:"0",padding:"1rem 0 1rem 0",...s}:{...N(n)},me=(n,s)=>n?{borderColor:"black",borderStyle:"solid",padding:"10rem 0 0 0",borderWidth:"0 0 0 10px",...s}:{...N(n)},_e=(n,s)=>n?{padding:`0 ${.5}rem 0 ${.5}rem`,backgroundColor:"light-grey",border:"1px solid black",...s}:{...N(n)},be=(n,s)=>n?{fontSize:`${.9}em`,fontWeight:"normal",...s}:{...N(n)},ye=(n,s)=>{const b=new Map(Array.from(n,d=>[d[s],[]]));return n.forEach(d=>{const y=d[s];if(y!==void 0){const x=b.get(y);x&&x.push(d)}}),Array.from(b.values())},ge=n=>n.toUpperCase(),Ge=({data:n,hasInlineStyles:s=!0,headerPrimaryUpper:b=!0,thRowStyles:d={},thTitleStyles:y={},thSubTitleStyles:x={},thPrimaryTitleStyles:T={},customHeaderRowIdValue:f="",customDynamicHeaderTitleIdValue:v="",customDynamicSubHeaderTitleIdValue:E=""})=>{const h=me(s,d),g=_e(s,y),w=be(s,x),C=he(s,T),A=b?n==null?void 0:n.primary_header_title:ge(n==null?void 0:n.primary_header_title);return c.jsxs("thead",{children:[c.jsxs("tr",{id:"react-matrix-blank-headers-primary-title-row",children:[c.jsx("th",{headers:"blank",colSpan:4}),c.jsx("th",{style:C,id:"react-matrix-header-primary-title",children:A}),c.jsx("th",{headers:"blank",colSpan:2})]}),c.jsxs("tr",{style:h,id:`react-matrix-dynamic-headers-row-${f}`,children:[c.jsx("th",{headers:"blank",colSpan:2}),n.matrix_details.slice(0,n.matrix_size).map((O,W)=>c.jsxs("th",{scope:"col",style:g,id:`react-matrix-dynamic-column-header-title${v?`-${v}`:""}`,children:[O.header_title,c.jsx("div",{style:w,id:`react-matrix-dynamic-column-header-sub-title${E?`-${E}`:""}`,children:O.header_sub_title})]},`${O.id}-${W}`))]})]})},Ke=({data:n,tdStyles:s={},hasInlineStyles:b=!0,customTableDataDynamicIdValue:d=""})=>{const y=f=>{alert(`${f==null?void 0:f.description}, ${f==null?void 0:f.score_value}
28
+ ${f==null?void 0:f.response}`)},T=b?{cursor:"pointer",textAlign:"center",borderColor:"black",borderStyle:"solid",borderWidth:"1px",backgroundColor:n==null?void 0:n.colour,...s}:{...s||{}};return c.jsx(c.Fragment,{children:c.jsxs("td",{style:T,onClick:()=>y(n),id:`react-matrix-dynamic-table-data${d?`-${d}`:""}`,children:[`${n==null?void 0:n.description}`,c.jsx("br",{}),`(${n==null?void 0:n.score_value})`]})})},Re=({data:n,rowPrimaryUpper:s=!0,hasInlineStyles:b=!0,reverseMatrixValues:d=!0,trRowStyles:y={},trTitleStyles:x={},trSubTitleStyles:T={},trPrimaryTitleStyles:f={},tdStyles:v={},customRowDynamicIdValue:E="",customRowHeaderDynamicIdValue:h="",customTableDataDynamicIdValue:g=""})=>{const w=d?ye(n.matrix_values,"likelihood_descriptor").reverse().slice(0,n.matrix_size):ye(n.matrix_values,"likelihood_descriptor").slice(0,n.matrix_size),C=me(b,y),A=_e(b,x),O=be(b,T),W=he(b,f),$=s?ge(n.primary_row_header_title):n.primary_row_header_title;return c.jsxs("tbody",{children:[c.jsx("tr",{id:"react-matrix-row-primary-title",children:c.jsx("th",{scope:"row",rowSpan:6,style:W,children:$})}),w.map((_,Y)=>{var U,B,I,z,M,V;const P=d?n.matrix_size-(Y+1):Y;return c.jsxs("tr",{style:C,id:`react-matrix-dynamic-rows-${(U=n.matrix_details[P])==null?void 0:U.row_header_title}-${(B=n.matrix_details[P])==null?void 0:B.row_header_sub_title}${E?`-${E}`:""}`,children:[c.jsxs("th",{scope:"row",style:A,id:`react-matrix-dynamic-rows-${(I=n.matrix_details[P])==null?void 0:I.row_header_title}-${(z=n.matrix_details[P])==null?void 0:z.row_header_sub_title}${h?`-${h}`:""}`,children:[(M=n.matrix_details[P])==null?void 0:M.row_header_title,c.jsx("div",{style:O,children:(V=n.matrix_details[P])==null?void 0:V.row_header_sub_title})]}),_.slice(0,n.matrix_size).map((q,H)=>c.jsx(Ke,{data:q,tdStyles:v,hasInlineStyles:b,customTableDataDynamicIdValue:g},`${q.id}-${H}`))]},`row-${Y}`)})]})};return Re.defaultProps={},({data:n,tableStyles:s,hasTableBorder:b,hasInlineStyles:d,hasContainerStyles:y,tableContainerStyles:x,tableStyles:T={},hasInlineStyles:f=!0,headerPrimaryUpper:v=!0,thRowStyles:E={},thTitleStyles:h={},thSubTitleStyles:g={},thPrimaryTitleStyles:w={},customHeaderRowIdValue:C="",customDynamicHeaderTitleIdValue:A="",customDynamicSubHeaderTitleIdValue:O="",rowPrimaryUpper:W=!0,reverseMatrixValues:$=!0,trRowStyles:_={},trTitleStyles:Y={},trSubTitleStyles:P={},trPrimaryTitleStyles:U={},tdStyles:B={},customRowDynamicIdValue:I="",customRowHeaderDynamicIdValue:z="",customTableDataDynamicIdValue:M=""})=>{const V=He(!!(d&&b)),q=Je(!!(d&&s),T),H=qe(!!(d&&y),x??{});return c.jsxs("div",{style:H,children:[c.jsx("h1",{children:n.matrix_name}),c.jsx("h4",{children:n.matrix_description}),c.jsxs("table",{id:"matrix-table",style:{...q,...V},children:[c.jsx(Ge,{data:n,hasInlineStyles:f,headerPrimaryUpper:v,thRowStyles:E,thTitleStyles:h,thSubTitleStyles:g,thPrimaryTitleStyles:w,customHeaderRowIdValue:C,customDynamicHeaderTitleIdValue:A,customDynamicSubHeaderTitleIdValue:O}),c.jsx(Re,{data:n,rowPrimaryUpper:W,hasInlineStyles:f,reverseMatrixValues:$,trRowStyles:_,trTitleStyles:Y,trSubTitleStyles:P,trPrimaryTitleStyles:U,tdStyles:B,customRowDynamicIdValue:I,customRowHeaderDynamicIdValue:z,customTableDataDynamicIdValue:M})]})]})}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-data-matrix",
3
- "version": "0.3.7",
3
+ "version": "0.4.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "homepage": "https://bronz3beard.github.io/react-matrix",
@@ -17,35 +17,41 @@
17
17
  "data matrix"
18
18
  ],
19
19
  "engines": {
20
- "npm": ">=8.12.0",
21
- "node": ">=18.4.0"
20
+ "npm": ">=8.19.2",
21
+ "node": ">=18.12.0"
22
+ },
23
+ "main": "./dist/react-data-matrix.umd.js",
24
+ "module": "./dist/react-data-matrix.es.js",
25
+ "types": "./dist/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "import": "./dist/react-data-matrix.es.js",
29
+ "require": "./dist/react-data-matrix.umd.js"
30
+ }
22
31
  },
23
- "main": "dist/index.js",
24
- "module": "dist/index.js",
25
32
  "files": [
26
- "dist",
33
+ "dist/lib",
34
+ "dist/manifest.json",
35
+ "dist/react-data-matrix.es.js",
36
+ "dist/react-data-matrix.umd.js",
27
37
  "README.md"
28
38
  ],
29
39
  "repository": {
30
40
  "type": "git",
31
41
  "url": "git+https://github.com/bronz3beard/react-matrix.git"
32
42
  },
43
+ "bugs": {
44
+ "url": "https://github.com/bronz3beard/react-matrix/issues"
45
+ },
33
46
  "description": "View structured data in a matrix table (data grid), showing a value located at an X and Y coordinate.",
34
47
  "scripts": {
35
- "start": "react-scripts start",
36
- "build": "rm -rf dist && NODE_ENV=production tsc",
37
- "babel": "babel src/lib --out-dir dist --copy-files",
38
- "build:og": "react-scripts build",
39
- "test": "react-scripts test",
40
- "eject": "react-scripts eject",
41
- "predeploy": "npm run build:og",
42
- "deploy": "gh-pages -d build"
43
- },
44
- "eslintConfig": {
45
- "extends": [
46
- "react-app",
47
- "react-app/jest"
48
- ]
48
+ "dev": "vite",
49
+ "build": "tsc && vite build",
50
+ "build:watch": "tsc && vite build --watch",
51
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
52
+ "preview": "vite preview",
53
+ "mock:publish": "npm pack --dry-run",
54
+ "deploy": "vite build && gh-pages -d dist"
49
55
  },
50
56
  "browserslist": {
51
57
  "production": [
@@ -60,27 +66,25 @@
60
66
  ]
61
67
  },
62
68
  "devDependencies": {
63
- "@babel/cli": "^7.15.7",
64
- "@babel/core": "^7.15.8",
65
- "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
66
- "@babel/preset-env": "^7.15.8",
67
69
  "@fortawesome/fontawesome-svg-core": "latest",
68
70
  "@fortawesome/free-brands-svg-icons": "latest",
69
71
  "@fortawesome/react-fontawesome": "latest",
70
- "@testing-library/jest-dom": "latest",
71
- "@testing-library/react": "latest",
72
- "@testing-library/user-event": "latest",
72
+ "@types/node": "^20.4.4",
73
73
  "@types/react": "^18.2.15",
74
74
  "@types/react-dom": "^18.2.7",
75
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
76
+ "@typescript-eslint/parser": "^6.0.0",
77
+ "@vitejs/plugin-react": "^4.0.3",
78
+ "eslint": "^8.45.0",
79
+ "eslint-plugin-react": "^7.33.0",
80
+ "eslint-plugin-react-hooks": "^4.6.0",
81
+ "eslint-plugin-react-refresh": "^0.4.3",
75
82
  "gh-pages": "latest",
76
- "react": "latest",
77
- "react-dom": "latest",
78
- "react-scripts": "^5.0.1",
83
+ "react": "^18.2.0",
84
+ "react-dom": "^18.2.0",
79
85
  "sass": "latest",
80
- "typescript": "latest",
81
- "web-vitals": "latest"
82
- },
83
- "dependencies": {
84
- "react-data-matrix": "^0.3.6"
86
+ "typescript": "^5.0.2",
87
+ "vite": "^4.4.5",
88
+ "vite-plugin-dts": "^3.3.1"
85
89
  }
86
90
  }
@@ -1,38 +0,0 @@
1
- import React from "react";
2
- import { getHeaderRowStyles, getHeaderTitleStyles, getHeaderSubTitleStyles, getHeaderPrimaryTitleStyles, } from "../helpers/getStyles";
3
- import { capitaliseString } from "../utils/functions";
4
- // import "./styles/riskMatrix.scss";
5
- const MatrixHeaders = ({ data, hasInlineStyles = true, headerPrimaryUpper = true, thRowStyles = {}, thTitleStyles = {}, thSubTitleStyles = {}, thPrimaryTitleStyles = {}, customHeaderRowIdValue = "", customDynamicHeaderTitleIdValue = "", customDynamicSubHeaderTitleIdValue = "", }) => {
6
- const headerRowStyles = getHeaderRowStyles(hasInlineStyles, thRowStyles);
7
- const headerTitleStyles = getHeaderTitleStyles(hasInlineStyles, thTitleStyles);
8
- const headerSubTitleStyles = getHeaderSubTitleStyles(hasInlineStyles, thSubTitleStyles);
9
- const headerPrimaryTitleStyles = getHeaderPrimaryTitleStyles(hasInlineStyles, thPrimaryTitleStyles);
10
- const headerPrimaryTitle = !headerPrimaryUpper
11
- ? capitaliseString(data === null || data === void 0 ? void 0 : data.primary_header_title)
12
- : data === null || data === void 0 ? void 0 : data.primary_header_title;
13
- return (<thead>
14
- <tr id="react-matrix-blank-headers-primary-title-row">
15
- <th headers="blank" colSpan={4}></th>
16
- <th style={headerPrimaryTitleStyles} id="react-matrix-header-primary-title">
17
- {headerPrimaryTitle}
18
- </th>
19
- <th headers="blank" colSpan={2}></th>
20
- </tr>
21
- <tr style={headerRowStyles} id={`react-matrix-dynamic-headers-row-${customHeaderRowIdValue}`}>
22
- <th headers="blank" colSpan={2}></th>
23
- {data.matrix_details.slice(0, data.matrix_size).map((column, index) => {
24
- return (<th scope="col" style={headerTitleStyles} id={`react-matrix-dynamic-column-header-title${!customDynamicHeaderTitleIdValue
25
- ? ""
26
- : `-${customDynamicHeaderTitleIdValue}`}`} key={`${column.id}-${index}`}>
27
- {column.header_title}
28
- <div style={headerSubTitleStyles} id={`react-matrix-dynamic-column-header-sub-title${!customDynamicSubHeaderTitleIdValue
29
- ? ""
30
- : `-${customDynamicSubHeaderTitleIdValue}`}`}>
31
- {column.header_sub_title}
32
- </div>
33
- </th>);
34
- })}
35
- </tr>
36
- </thead>);
37
- };
38
- export default MatrixHeaders;
@@ -1,48 +0,0 @@
1
- import React from "react";
2
- import { getHeaderRowStyles, getHeaderTitleStyles, getHeaderSubTitleStyles, getHeaderPrimaryTitleStyles, } from "../helpers/getStyles";
3
- import { groupObjectsByProp, capitaliseString } from "../utils/functions";
4
- import TableData from "./TableData";
5
- const MatrixRows = ({ data, rowPrimaryUpper = true, hasInlineStyles = true, reverseMatrixValues = true, trRowStyles = {}, trTitleStyles = {}, trSubTitleStyles = {}, trPrimaryTitleStyles = {}, tdStyles = {}, customRowDynamicIdValue = "", customRowHeaderDynamicIdValue = "", customTableDataDynamicIdValue = "", }) => {
6
- const valuesArray = reverseMatrixValues
7
- ? groupObjectsByProp(data.matrix_values, "likelihood_descriptor")
8
- .reverse()
9
- .slice(0, data.matrix_size)
10
- : groupObjectsByProp(data.matrix_values, "likelihood_descriptor").slice(0, data.matrix_size);
11
- const tableRowStyles = getHeaderRowStyles(hasInlineStyles, trRowStyles);
12
- const tableRowHeaderTitleStyles = getHeaderTitleStyles(hasInlineStyles, trTitleStyles);
13
- const tableRowHeaderSubTitleStyles = getHeaderSubTitleStyles(hasInlineStyles, trSubTitleStyles);
14
- const rowHeaderPrimaryTitleStyles = getHeaderPrimaryTitleStyles(hasInlineStyles, trPrimaryTitleStyles);
15
- const rowPrimaryTitle = rowPrimaryUpper
16
- ? capitaliseString(data.primary_row_header_title)
17
- : data.primary_row_header_title;
18
- return (<tbody>
19
- <tr id="react-matrix-row-primary-title">
20
- <th scope="row" rowSpan={6} style={rowHeaderPrimaryTitleStyles}>
21
- {rowPrimaryTitle}
22
- </th>
23
- </tr>
24
- {valuesArray.map((row, index) => {
25
- var _a, _b, _c, _d, _e, _f;
26
- const rowHeaderOrder = reverseMatrixValues
27
- ? data.matrix_size - (index + 1)
28
- : index;
29
- return (<tr style={tableRowStyles} key={`row-${index}`} id={`react-matrix-dynamic-rows-${(_a = data.matrix_details[rowHeaderOrder]) === null || _a === void 0 ? void 0 : _a.row_header_title}-${(_b = data.matrix_details[rowHeaderOrder]) === null || _b === void 0 ? void 0 : _b.row_header_sub_title}${!customRowDynamicIdValue ? "" : `-${customRowDynamicIdValue}`}`}>
30
- <th scope="row" style={tableRowHeaderTitleStyles} id={`react-matrix-dynamic-rows-${(_c = data.matrix_details[rowHeaderOrder]) === null || _c === void 0 ? void 0 : _c.row_header_title}-${(_d = data.matrix_details[rowHeaderOrder]) === null || _d === void 0 ? void 0 : _d.row_header_sub_title}${!customRowHeaderDynamicIdValue
31
- ? ""
32
- : `-${customRowHeaderDynamicIdValue}`}`}>
33
- {(_e = data.matrix_details[rowHeaderOrder]) === null || _e === void 0 ? void 0 : _e.row_header_title}
34
- <div style={tableRowHeaderSubTitleStyles}>
35
- {(_f = data.matrix_details[rowHeaderOrder]) === null || _f === void 0 ? void 0 : _f.row_header_sub_title}
36
- </div>
37
- </th>
38
- {row
39
- .slice(0, data.matrix_size)
40
- .map((item, index) => {
41
- return (<TableData data={item} tdStyles={tdStyles} key={`${item.id}-${index}`} hasInlineStyles={hasInlineStyles} customTableDataDynamicIdValue={customTableDataDynamicIdValue}/>);
42
- })}
43
- </tr>);
44
- })}
45
- </tbody>);
46
- };
47
- MatrixRows.defaultProps = {};
48
- export default MatrixRows;
@@ -1,42 +0,0 @@
1
- import React from "react";
2
- import { getTableStyles, getTableBoarder, getContainerStyles, } from "../helpers/getStyles";
3
- import MatrixHeaders from "./MatrixHeaders";
4
- import MatrixRows from "./MatrixRows";
5
- const ReactMatrix = ({ data, matrixName, tableStyles: contextTableStyles, hasTableBorder: contextHasTableBorder, hasInlineStyles: contextHasInlineStyles, matrixDescription, hasContainerStyles: contextHasContainerStyles, tableContainerStyles: contextTableContainerStyles, tableStyles = {}, }) => {
6
- const tableBorder = getTableBoarder(!!(contextHasInlineStyles && contextHasTableBorder));
7
- const tableElmStyles = getTableStyles(!!(contextHasInlineStyles && contextTableStyles), tableStyles);
8
- const containerStyles = getContainerStyles(!!(contextHasInlineStyles && contextHasContainerStyles), contextTableContainerStyles !== null && contextTableContainerStyles !== void 0 ? contextTableContainerStyles : {});
9
- return (<div style={containerStyles}>
10
- <h1>{matrixName}</h1>
11
- <h4>{matrixDescription}</h4>
12
- <table id="matrix-table" style={Object.assign(Object.assign({}, tableElmStyles), tableBorder)}>
13
- <MatrixHeaders {...{
14
- data,
15
- hasInlineStyles: true,
16
- headerPrimaryUpper: true,
17
- thRowStyles: {},
18
- thTitleStyles: {},
19
- thSubTitleStyles: {},
20
- thPrimaryTitleStyles: {},
21
- customHeaderRowIdValue: "",
22
- customDynamicHeaderTitleIdValue: "",
23
- customDynamicSubHeaderTitleIdValue: "",
24
- }}/>
25
- <MatrixRows {...{
26
- data,
27
- rowPrimaryUpper: true,
28
- hasInlineStyles: true,
29
- reverseMatrixValues: true,
30
- trRowStyles: {},
31
- trTitleStyles: {},
32
- trSubTitleStyles: {},
33
- trPrimaryTitleStyles: {},
34
- tdStyles: {},
35
- customRowDynamicIdValue: "",
36
- customRowHeaderDynamicIdValue: "",
37
- customTableDataDynamicIdValue: "",
38
- }}/>
39
- </table>
40
- </div>);
41
- };
42
- export default ReactMatrix;
@@ -1,19 +0,0 @@
1
- import React from "react";
2
- const TableData = ({ data, tdStyles = {}, hasInlineStyles = true, customTableDataDynamicIdValue = "", }) => {
3
- const handleCellClick = (tdSelected) => {
4
- alert(`${tdSelected === null || tdSelected === void 0 ? void 0 : tdSelected.description}, ${tdSelected === null || tdSelected === void 0 ? void 0 : tdSelected.score_value} \n${tdSelected === null || tdSelected === void 0 ? void 0 : tdSelected.response}`);
5
- };
6
- const customTdStyles = !tdStyles ? {} : tdStyles;
7
- const tableDataStyles = hasInlineStyles
8
- ? Object.assign({ cursor: "pointer", textAlign: "center", borderColor: "black", borderStyle: "solid", borderWidth: `${1}px`, backgroundColor: data === null || data === void 0 ? void 0 : data.colour }, tdStyles) : Object.assign({}, customTdStyles);
9
- return (<>
10
- <td style={tableDataStyles} onClick={() => handleCellClick(data)} id={`react-matrix-dynamic-table-data${!customTableDataDynamicIdValue
11
- ? ""
12
- : `-${customTableDataDynamicIdValue}`}`}>
13
- {`${data === null || data === void 0 ? void 0 : data.description}`}
14
- <br />
15
- {`(${data === null || data === void 0 ? void 0 : data.score_value})`}
16
- </td>
17
- </>);
18
- };
19
- export default TableData;
@@ -1,16 +0,0 @@
1
- export const getCustomStyles = (hasStyle) => !hasStyle ? {} : hasStyle;
2
- export const getContainerStyles = (hasStyle, styles) =>
3
- // if custom styles are passed remove default styles by returning a spread empty object
4
- !hasStyle
5
- ? Object.assign({}, getCustomStyles(hasStyle)) : Object.assign({ top: `${50}%`, left: `${50}%`, height: `${100}%`, textAlign: "center", position: "absolute", transform: `translate(${-50}%, ${-50}%)` }, styles);
6
- export const getTableBoarder = (hasStyle) => !hasStyle ? {} : { border: `${1}px solid black` };
7
- export const getTableStyles = (hasStyle, styles) => !hasStyle
8
- ? Object.assign({}, getCustomStyles(hasStyle)) : Object.assign({ width: `${70}rem` }, styles);
9
- export const getHeaderPrimaryTitleStyles = (hasStyle, styles) => !hasStyle
10
- ? Object.assign({}, getCustomStyles(hasStyle)) : Object.assign({ borderWidth: `${0}`, padding: `${1}rem ${0} ${1}rem ${0}` }, styles);
11
- export const getHeaderRowStyles = (hasStyle, styles) => !hasStyle
12
- ? Object.assign({}, getCustomStyles(hasStyle)) : Object.assign({ borderColor: "black", borderStyle: "solid", padding: `${10}rem ${0} ${0} ${0}`, borderWidth: `${0} ${0} ${0} ${10}px` }, styles);
13
- export const getHeaderTitleStyles = (hasStyle, styles) => !hasStyle
14
- ? Object.assign({}, getCustomStyles(hasStyle)) : Object.assign({ padding: `${0} ${0.5}rem ${0} ${0.5}rem`, backgroundColor: "light-grey", border: `${1}px solid black` }, styles);
15
- export const getHeaderSubTitleStyles = (hasStyle, styles) => !hasStyle
16
- ? Object.assign({}, getCustomStyles(hasStyle)) : Object.assign({ fontSize: `${0.9}em`, fontWeight: "normal" }, styles);
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { default as ReactMatrix } from "./components/ReactMatrix";
package/dist/index.js DELETED
@@ -1 +0,0 @@
1
- export { default as ReactMatrix } from "./components/ReactMatrix";
@@ -1 +0,0 @@
1
- export {};