react-data-matrix 0.3.7 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{components → lib/components}/MatrixHeaders.d.ts +2 -2
- package/dist/{components → lib/components}/MatrixRows.d.ts +2 -2
- package/dist/{components → lib/components}/TableData.d.ts +2 -2
- package/dist/lib/index.d.ts +2 -0
- package/dist/{types → lib/types}/index.d.ts +0 -2
- package/dist/{utils → lib/utils}/data.d.ts +1 -1
- package/dist/lib/utils/functions.d.ts +4 -0
- package/dist/manifest.json +7 -0
- package/dist/react-data-matrix.es.js +627 -0
- package/dist/react-data-matrix.umd.js +27 -0
- package/package.json +39 -35
- package/README.md +0 -350
- package/dist/components/MatrixHeaders.jsx +0 -38
- package/dist/components/MatrixRows.jsx +0 -48
- package/dist/components/ReactMatrix.d.ts +0 -4
- package/dist/components/ReactMatrix.jsx +0 -42
- package/dist/components/TableData.jsx +0 -19
- package/dist/helpers/getStyles.js +0 -16
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/types/index.js +0 -1
- package/dist/utils/data.js +0 -342
- package/dist/utils/functions.d.ts +0 -4
- package/dist/utils/functions.js +0 -18
- /package/dist/{helpers → lib/helpers}/getStyles.d.ts +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
(function(m,g){typeof exports=="object"&&typeof module<"u"?g(require("react")):typeof define=="function"&&define.amd?define(["react"],g):(m=typeof globalThis<"u"?globalThis:m||self,g(m.React))})(this,function(m){"use strict";var g={};/**
|
|
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 X;function Oe(){if(X)return g;X=1;var V=m,j=Symbol.for("react.element"),M=Symbol.for("react.fragment"),T=Object.prototype.hasOwnProperty,F=V.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,A={key:!0,ref:!0,__self:!0,__source:!0};function x(y,l,O){var v,h={},_=null,I=null;O!==void 0&&(_=""+O),l.key!==void 0&&(_=""+l.key),l.ref!==void 0&&(I=l.ref);for(v in l)T.call(l,v)&&!A.hasOwnProperty(v)&&(h[v]=l[v]);if(y&&y.defaultProps)for(v in l=y.defaultProps,l)h[v]===void 0&&(h[v]=l[v]);return{$$typeof:j,type:y,key:_,ref:I,props:h,_owner:F.current}}return g.Fragment=M,g.jsx=x,g.jsxs=x,g}var w={};/**
|
|
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 Z;function Ce(){return Z||(Z=1,process.env.NODE_ENV!=="production"&&function(){var V=m,j=Symbol.for("react.element"),M=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),x=Symbol.for("react.provider"),y=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),I=Symbol.for("react.offscreen"),Q=Symbol.iterator,Pe="@@iterator";function Se(e){if(e===null||typeof e!="object")return null;var r=Q&&e[Q]||e[Pe];return typeof r=="function"?r:null}var C=V.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function c(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];we("error",e,t)}}function we(e,r,t){{var n=C.ReactDebugCurrentFrame,o=n.getStackAddendum();o!==""&&(r+="%s",t=t.concat([o]));var u=t.map(function(i){return String(i)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var je=!1,xe=!1,ke=!1,De=!1,Fe=!1,ee;ee=Symbol.for("react.module.reference");function Ae(e){return!!(typeof e=="string"||typeof e=="function"||e===T||e===A||Fe||e===F||e===O||e===v||De||e===I||je||xe||ke||typeof e=="object"&&e!==null&&(e.$$typeof===_||e.$$typeof===h||e.$$typeof===x||e.$$typeof===y||e.$$typeof===l||e.$$typeof===ee||e.getModuleId!==void 0))}function Ie(e,r,t){var n=e.displayName;if(n)return n;var o=r.displayName||r.name||"";return o!==""?t+"("+o+")":t}function re(e){return e.displayName||"Context"}function b(e){if(e==null)return null;if(typeof e.tag=="number"&&c("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 T:return"Fragment";case M:return"Portal";case A:return"Profiler";case F:return"StrictMode";case O:return"Suspense";case v:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case y:var r=e;return re(r)+".Consumer";case x:var t=e;return re(t._context)+".Provider";case l:return Ie(e,e.render,"ForwardRef");case h:var n=e.displayName||null;return n!==null?n:b(e.type)||"Memo";case _:{var o=e,u=o._payload,i=o._init;try{return b(i(u))}catch{return null}}}return null}var R=Object.assign,k=0,te,ne,ae,ie,oe,ue,fe;function se(){}se.__reactDisabledLog=!0;function We(){{if(k===0){te=console.log,ne=console.info,ae=console.warn,ie=console.error,oe=console.group,ue=console.groupCollapsed,fe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:se,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}k++}}function Ye(){{if(k--,k===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:R({},e,{value:te}),info:R({},e,{value:ne}),warn:R({},e,{value:ae}),error:R({},e,{value:ie}),group:R({},e,{value:oe}),groupCollapsed:R({},e,{value:ue}),groupEnd:R({},e,{value:fe})})}k<0&&c("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var U=C.ReactCurrentDispatcher,B;function W(e,r,t){{if(B===void 0)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);B=n&&n[1]||""}return`
|
|
18
|
+
`+B+e}}var q=!1,Y;{var $e=typeof WeakMap=="function"?WeakMap:Map;Y=new $e}function le(e,r){if(!e||q)return"";{var t=Y.get(e);if(t!==void 0)return t}var n;q=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=U.current,U.current=null,We();try{if(r){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(E){n=E}Reflect.construct(e,[],i)}else{try{i.call()}catch(E){n=E}e.call(i.prototype)}}else{try{throw Error()}catch(E){n=E}e()}}catch(E){if(E&&n&&typeof E.stack=="string"){for(var a=E.stack.split(`
|
|
19
|
+
`),d=n.stack.split(`
|
|
20
|
+
`),f=a.length-1,s=d.length-1;f>=1&&s>=0&&a[f]!==d[s];)s--;for(;f>=1&&s>=0;f--,s--)if(a[f]!==d[s]){if(f!==1||s!==1)do if(f--,s--,s<0||a[f]!==d[s]){var p=`
|
|
21
|
+
`+a[f].replace(" at new "," at ");return e.displayName&&p.includes("<anonymous>")&&(p=p.replace("<anonymous>",e.displayName)),typeof e=="function"&&Y.set(e,p),p}while(f>=1&&s>=0);break}}}finally{q=!1,U.current=u,Ye(),Error.prepareStackTrace=o}var S=e?e.displayName||e.name:"",Te=S?W(S):"";return typeof e=="function"&&Y.set(e,Te),Te}function Le(e,r,t){return le(e,!1)}function Ne(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function $(e,r,t){if(e==null)return"";if(typeof e=="function")return le(e,Ne(e));if(typeof e=="string")return W(e);switch(e){case O:return W("Suspense");case v:return W("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case l:return Le(e.render);case h:return $(e.type,r,t);case _:{var n=e,o=n._payload,u=n._init;try{return $(u(o),r,t)}catch{}}}return""}var L=Object.prototype.hasOwnProperty,ce={},de=C.ReactDebugCurrentFrame;function N(e){if(e){var r=e._owner,t=$(e.type,e._source,r?r.type:null);de.setExtraStackFrame(t)}else de.setExtraStackFrame(null)}function Ve(e,r,t,n,o){{var u=Function.call.bind(L);for(var i in e)if(u(e,i)){var a=void 0;try{if(typeof e[i]!="function"){var d=Error((n||"React class")+": "+t+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw d.name="Invariant Violation",d}a=e[i](r,i,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(f){a=f}a&&!(a instanceof Error)&&(N(o),c("%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,i,typeof a),N(null)),a instanceof Error&&!(a.message in ce)&&(ce[a.message]=!0,N(o),c("Failed %s type: %s",t,a.message),N(null))}}}var Me=Array.isArray;function J(e){return Me(e)}function Ue(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function Be(e){try{return ve(e),!1}catch{return!0}}function ve(e){return""+e}function pe(e){if(Be(e))return c("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ue(e)),ve(e)}var D=C.ReactCurrentOwner,qe={key:!0,ref:!0,__self:!0,__source:!0},ge,he,G;G={};function Je(e){if(L.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function Ge(e){if(L.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function ze(e,r){if(typeof e.ref=="string"&&D.current&&r&&D.current.stateNode!==r){var t=b(D.current.type);G[t]||(c('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',b(D.current.type),e.ref),G[t]=!0)}}function Ke(e,r){{var t=function(){ge||(ge=!0,c("%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 He(e,r){{var t=function(){he||(he=!0,c("%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 Xe=function(e,r,t,n,o,u,i){var a={$$typeof:j,type:e,key:r,ref:t,props:i,_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:o}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function Ze(e,r,t,n,o){{var u,i={},a=null,d=null;t!==void 0&&(pe(t),a=""+t),Ge(r)&&(pe(r.key),a=""+r.key),Je(r)&&(d=r.ref,ze(r,o));for(u in r)L.call(r,u)&&!qe.hasOwnProperty(u)&&(i[u]=r[u]);if(e&&e.defaultProps){var f=e.defaultProps;for(u in f)i[u]===void 0&&(i[u]=f[u])}if(a||d){var s=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&Ke(i,s),d&&He(i,s)}return Xe(e,a,d,o,n,D.current,i)}}var z=C.ReactCurrentOwner,be=C.ReactDebugCurrentFrame;function P(e){if(e){var r=e._owner,t=$(e.type,e._source,r?r.type:null);be.setExtraStackFrame(t)}else be.setExtraStackFrame(null)}var K;K=!1;function H(e){return typeof e=="object"&&e!==null&&e.$$typeof===j}function Ee(){{if(z.current){var e=b(z.current.type);if(e)return`
|
|
22
|
+
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function Qe(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return`
|
|
24
|
+
|
|
25
|
+
Check your code at `+r+":"+t+"."}return""}}var ye={};function er(e){{var r=Ee();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 _e(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=er(r);if(ye[t])return;ye[t]=!0;var n="";e&&e._owner&&e._owner!==z.current&&(n=" It was passed a child from "+b(e._owner.type)+"."),P(e),c('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),P(null)}}function Re(e,r){{if(typeof e!="object")return;if(J(e))for(var t=0;t<e.length;t++){var n=e[t];H(n)&&_e(n,r)}else if(H(e))e._store&&(e._store.validated=!0);else if(e){var o=Se(e);if(typeof o=="function"&&o!==e.entries)for(var u=o.call(e),i;!(i=u.next()).done;)H(i.value)&&_e(i.value,r)}}}function rr(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===l||r.$$typeof===h))t=r.propTypes;else return;if(t){var n=b(r);Ve(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!K){K=!0;var o=b(r);c("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",o||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&c("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function tr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){P(e),c("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),P(null);break}}e.ref!==null&&(P(e),c("Invalid attribute `ref` supplied to `React.Fragment`."),P(null))}}function me(e,r,t,n,o,u){{var i=Ae(e);if(!i){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 d=Qe(o);d?a+=d:a+=Ee();var f;e===null?f="null":J(e)?f="array":e!==void 0&&e.$$typeof===j?(f="<"+(b(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):f=typeof e,c("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",f,a)}var s=Ze(e,r,t,o,u);if(s==null)return s;if(i){var p=r.children;if(p!==void 0)if(n)if(J(p)){for(var S=0;S<p.length;S++)Re(p[S],e);Object.freeze&&Object.freeze(p)}else c("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 Re(p,e)}return e===T?tr(s):rr(s),s}}function nr(e,r,t){return me(e,r,t,!0)}function ar(e,r,t){return me(e,r,t,!1)}var ir=ar,or=nr;w.Fragment=T,w.jsx=ir,w.jsxs=or}()),w}process.env.NODE_ENV==="production"?Oe():Ce()});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-data-matrix",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
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.
|
|
21
|
-
"node": ">=18.
|
|
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
|
-
"
|
|
36
|
-
"build": "
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
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
|
-
"@
|
|
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": "
|
|
77
|
-
"react-dom": "
|
|
78
|
-
"react-scripts": "^5.0.1",
|
|
83
|
+
"react": "^18.2.0",
|
|
84
|
+
"react-dom": "^18.2.0",
|
|
79
85
|
"sass": "latest",
|
|
80
|
-
"typescript": "
|
|
81
|
-
"
|
|
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
|
}
|
package/README.md
DELETED
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
# React Matrix [](https://badge.fury.io/js/react-data-matrix)
|
|
2
|
-
|
|
3
|
-
[React Matrix Demo](https://bronz3beard.github.io/react-matrix)
|
|
4
|
-
|
|
5
|
-
React Matrix table shows relationships between two or more variables in a data set in grid format.
|
|
6
|
-
|
|
7
|
-
The most common usage for a table like React Matrix, is to display the **likelihood** and **consequence** "scores" of **risks/hazards**, this can be for anything from Corporate, Work Health Safety and Environment risks, and more.
|
|
8
|
-
|
|
9
|
-
# PR's
|
|
10
|
-
|
|
11
|
-
- Have a look at the [PR template doc](https://github.com/bronz3beard/react-matrix/blob/main/docs) for best approach to getting your pr merged.
|
|
12
|
-
|
|
13
|
-
# Usage
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import { ReactMatrix } from "react-data-matrix";
|
|
17
|
-
|
|
18
|
-
const App: FC = () => {
|
|
19
|
-
...
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<ReactMatrix
|
|
23
|
-
{...{
|
|
24
|
-
matrixName: "",
|
|
25
|
-
matrixDescription: "",
|
|
26
|
-
hasTableBorder: true,
|
|
27
|
-
rowPrimaryUpper: true,
|
|
28
|
-
hasInlineStyles: true,
|
|
29
|
-
matrixSizeSelected: 5,
|
|
30
|
-
headerPrimaryUpper: true,
|
|
31
|
-
hasContainerStyles: true,
|
|
32
|
-
reverseMatrixValues: true,
|
|
33
|
-
|
|
34
|
-
tableContainerStyles: {},
|
|
35
|
-
tableStyles: {},
|
|
36
|
-
|
|
37
|
-
thRowStyles: {},
|
|
38
|
-
thTitleStyles: {},
|
|
39
|
-
thSubTitleStyles: {},
|
|
40
|
-
thPrimaryTitleStyles: {},
|
|
41
|
-
|
|
42
|
-
trRowStyles: {},
|
|
43
|
-
trTitleStyles: {},
|
|
44
|
-
trSubTitleStyles: {},
|
|
45
|
-
trPrimaryTitleStyles: {},
|
|
46
|
-
|
|
47
|
-
tdStyles: {},
|
|
48
|
-
|
|
49
|
-
customHeaderRowIdValue: "",
|
|
50
|
-
customRowDynamicIdValue: "",
|
|
51
|
-
customTableDataDynamicIdValue: "",
|
|
52
|
-
customRowHeaderDynamicIdValue: "",
|
|
53
|
-
customDynamicHeaderTitleIdValue: "",
|
|
54
|
-
customDynamicSubHeaderTitleIdValue: "",
|
|
55
|
-
data,
|
|
56
|
-
}}
|
|
57
|
-
/>
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
# Expected Data Structure
|
|
63
|
-
|
|
64
|
-
- See [`./src/lib/utils/data.ts`](https://github.com/bronz3beard/react-matrix/blob/main/src/lib/utils/data.ts) for an example of the data, this can be used for testing if needed,
|
|
65
|
-
or an example of how to construct/deconstruct your data objects from your api.
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
const data = {
|
|
69
|
-
id: 1,
|
|
70
|
-
matrix_size: 5,
|
|
71
|
-
matrix_name: "React Matrix",
|
|
72
|
-
matrix_description: "Risk Matrix Template",
|
|
73
|
-
matrix_details: [
|
|
74
|
-
{
|
|
75
|
-
id: 1,
|
|
76
|
-
likelihood: "LIKELIHOOD VALUE",
|
|
77
|
-
consequence: CONSEQUENCE VALUE,
|
|
78
|
-
header_title: "Title",
|
|
79
|
-
header_sub_title: "Sub-title/description.",
|
|
80
|
-
row_header_title: "Row Title",
|
|
81
|
-
row_header_sub_title: "Row Sub-title/description.",
|
|
82
|
-
}, {
|
|
83
|
-
id: 2,
|
|
84
|
-
...
|
|
85
|
-
} {
|
|
86
|
-
id: 3,
|
|
87
|
-
...
|
|
88
|
-
} {
|
|
89
|
-
id: 4,
|
|
90
|
-
...
|
|
91
|
-
} {
|
|
92
|
-
id: 5,
|
|
93
|
-
...
|
|
94
|
-
}
|
|
95
|
-
],
|
|
96
|
-
matrix_values: [
|
|
97
|
-
{
|
|
98
|
-
id: 1,
|
|
99
|
-
position: 1,
|
|
100
|
-
matrix_id: 1,
|
|
101
|
-
score_value: 1,
|
|
102
|
-
colour: "green",
|
|
103
|
-
description: "low",
|
|
104
|
-
consequence_descriptor: 1,
|
|
105
|
-
likelihood_descriptor: "E",
|
|
106
|
-
response: "Business as usual",
|
|
107
|
-
}, {
|
|
108
|
-
id: 2,
|
|
109
|
-
...
|
|
110
|
-
},
|
|
111
|
-
...,
|
|
112
|
-
...,
|
|
113
|
-
, {
|
|
114
|
-
id: 25,
|
|
115
|
-
...
|
|
116
|
-
},
|
|
117
|
-
]
|
|
118
|
-
}
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
# Types
|
|
122
|
-
|
|
123
|
-
```ts
|
|
124
|
-
export interface MatrixDetail {
|
|
125
|
-
id: number;
|
|
126
|
-
position: number;
|
|
127
|
-
matrix_type: string;
|
|
128
|
-
likelihood: string;
|
|
129
|
-
consequence: number;
|
|
130
|
-
header_title: string;
|
|
131
|
-
header_sub_title: string;
|
|
132
|
-
row_header_title: string;
|
|
133
|
-
row_header_sub_title: string;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export interface MatrixValue {
|
|
137
|
-
id: number;
|
|
138
|
-
matrix_id: number;
|
|
139
|
-
description: string;
|
|
140
|
-
score_value: number;
|
|
141
|
-
colour: string;
|
|
142
|
-
position: number;
|
|
143
|
-
likelihood_descriptor: string;
|
|
144
|
-
consequence_descriptor: number;
|
|
145
|
-
response: string;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export interface MatrixData {
|
|
149
|
-
id: number;
|
|
150
|
-
matrix_size: number;
|
|
151
|
-
matrix_name: string;
|
|
152
|
-
primary_header_title: string;
|
|
153
|
-
primary_row_header_title: string;
|
|
154
|
-
matrix_description: string;
|
|
155
|
-
matrix_details: MatrixDetail[];
|
|
156
|
-
matrix_values: MatrixValue[];
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export interface ReactMatrixProps {
|
|
160
|
-
data: MatrixData;
|
|
161
|
-
hasTableBorder?: boolean;
|
|
162
|
-
hasInlineStyles?: boolean;
|
|
163
|
-
hasContainerStyles?: boolean;
|
|
164
|
-
reverseMatrixValues?: boolean;
|
|
165
|
-
matrixSizeSelected?: number;
|
|
166
|
-
rowPrimaryUpper?: boolean;
|
|
167
|
-
headerPrimaryUpper?: boolean;
|
|
168
|
-
tableContainerStyles?: React.CSSProperties;
|
|
169
|
-
tableStyles?: React.CSSProperties;
|
|
170
|
-
thRowStyles?: React.CSSProperties;
|
|
171
|
-
thTitleStyles?: React.CSSProperties;
|
|
172
|
-
thSubTitleStyles?: React.CSSProperties;
|
|
173
|
-
thPrimaryTitleStyles?: React.CSSProperties;
|
|
174
|
-
trRowStyles?: React.CSSProperties;
|
|
175
|
-
trTitleStyles?: React.CSSProperties;
|
|
176
|
-
trSubTitleStyles?: React.CSSProperties;
|
|
177
|
-
trPrimaryTitleStyles?: React.CSSProperties;
|
|
178
|
-
tdStyles?: React.CSSProperties;
|
|
179
|
-
customHeaderRowIdValue?: string;
|
|
180
|
-
customDynamicHeaderTitleIdValue?: string;
|
|
181
|
-
customDynamicSubHeaderTitleIdValue?: string;
|
|
182
|
-
customRowDynamicIdValue?: string;
|
|
183
|
-
customRowHeaderDynamicIdValue?: string;
|
|
184
|
-
customTableDataDynamicIdValue?: string;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export interface TableDataProps {
|
|
188
|
-
data: {
|
|
189
|
-
id: number;
|
|
190
|
-
colour: string;
|
|
191
|
-
position: number;
|
|
192
|
-
matrix_id: number;
|
|
193
|
-
score_value: number;
|
|
194
|
-
description: string;
|
|
195
|
-
response: string;
|
|
196
|
-
likelihood_descriptor: string;
|
|
197
|
-
consequence_descriptor: number;
|
|
198
|
-
};
|
|
199
|
-
tdStyles?: React.CSSProperties;
|
|
200
|
-
hasInlineStyles?: boolean;
|
|
201
|
-
customTableDataDynamicIdValue?: string;
|
|
202
|
-
}
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
```ts
|
|
206
|
-
defaultProps = {
|
|
207
|
-
matrixName: "",
|
|
208
|
-
matrixDescription: "",
|
|
209
|
-
hasTableBorder: true,
|
|
210
|
-
rowPrimaryUpper: true,
|
|
211
|
-
hasInlineStyles: true,
|
|
212
|
-
matrixSizeSelected: 5,
|
|
213
|
-
headerPrimaryUpper: true,
|
|
214
|
-
hasContainerStyles: true,
|
|
215
|
-
reverseMatrixValues: true,
|
|
216
|
-
|
|
217
|
-
tableContainerStyles: {},
|
|
218
|
-
tableStyles: {},
|
|
219
|
-
|
|
220
|
-
thRowStyles: {},
|
|
221
|
-
thTitleStyles: {},
|
|
222
|
-
thSubTitleStyles: {},
|
|
223
|
-
thPrimaryTitleStyles: {},
|
|
224
|
-
|
|
225
|
-
trRowStyles: {},
|
|
226
|
-
trTitleStyles: {},
|
|
227
|
-
trSubTitleStyles: {},
|
|
228
|
-
trPrimaryTitleStyles: {},
|
|
229
|
-
|
|
230
|
-
tdStyles: {},
|
|
231
|
-
|
|
232
|
-
customHeaderRowIdValue: "",
|
|
233
|
-
customRowDynamicIdValue: "",
|
|
234
|
-
customTableDataDynamicIdValue: "",
|
|
235
|
-
customRowHeaderDynamicIdValue: "",
|
|
236
|
-
customDynamicHeaderTitleIdValue: "",
|
|
237
|
-
customDynamicSubHeaderTitleIdValue: "",
|
|
238
|
-
};
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
# Available Properties
|
|
242
|
-
|
|
243
|
-
- **hasInlineStyles**
|
|
244
|
-
- Default is true.
|
|
245
|
-
- If false all inline styles are removed.
|
|
246
|
-
|
|
247
|
-
---
|
|
248
|
-
|
|
249
|
-
- **hasTableBorder**
|
|
250
|
-
- Default is true.
|
|
251
|
-
- If false the most outer border is removed.
|
|
252
|
-
|
|
253
|
-
---
|
|
254
|
-
|
|
255
|
-
- **hasContainerStyles**
|
|
256
|
-
- Default is true.
|
|
257
|
-
- This will center the matrix in the middle of the page.
|
|
258
|
-
|
|
259
|
-
---
|
|
260
|
-
|
|
261
|
-
- **reverseMatrixValues**
|
|
262
|
-
- Default is true.
|
|
263
|
-
- When true the lowest value will be in the bottom left and the highest value will be in the top right, with all sequential values in-between.
|
|
264
|
-
- When false the values will be reversed, lowest value top left highest value bottom right.
|
|
265
|
-
|
|
266
|
-
---
|
|
267
|
-
|
|
268
|
-
- **rowPrimaryUpper**
|
|
269
|
-
- Default is true.
|
|
270
|
-
- If false string formatting will be removed.
|
|
271
|
-
|
|
272
|
-
---
|
|
273
|
-
|
|
274
|
-
- **headerPrimaryUpper**
|
|
275
|
-
- Default is true.
|
|
276
|
-
- If false string formatting will be removed.
|
|
277
|
-
|
|
278
|
-
---
|
|
279
|
-
|
|
280
|
-
- **customHeaderRowIdValue**
|
|
281
|
-
- Default is empty string.
|
|
282
|
-
- can be used to target element through id prop.
|
|
283
|
-
|
|
284
|
-
---
|
|
285
|
-
|
|
286
|
-
- **customDynamicHeaderTitleIdValue**
|
|
287
|
-
- Default is empty string.
|
|
288
|
-
- can be used to target element through id prop.
|
|
289
|
-
|
|
290
|
-
---
|
|
291
|
-
|
|
292
|
-
- **customDynamicSubHeaderTitleIdValue**
|
|
293
|
-
- Default is empty string.
|
|
294
|
-
- can be used to target element through id prop.
|
|
295
|
-
|
|
296
|
-
---
|
|
297
|
-
|
|
298
|
-
- **customRowDynamicIdValue**
|
|
299
|
-
- Default is empty string.
|
|
300
|
-
- can be used to target element through id prop.
|
|
301
|
-
|
|
302
|
-
---
|
|
303
|
-
|
|
304
|
-
- **customRowHeaderDynamicIdValue**
|
|
305
|
-
- Default is empty string.
|
|
306
|
-
- can be used to target element through id prop.
|
|
307
|
-
|
|
308
|
-
---
|
|
309
|
-
|
|
310
|
-
- **customTableDataDynamicIdValue**
|
|
311
|
-
- Default is empty string.
|
|
312
|
-
- can be used to target element through id prop.
|
|
313
|
-
|
|
314
|
-
---
|
|
315
|
-
|
|
316
|
-
# Styling Properties
|
|
317
|
-
|
|
318
|
-
### Inline
|
|
319
|
-
|
|
320
|
-
**These styles can be added to the current styles or,
|
|
321
|
-
if you make `hasInlineStyles = false`, then add these values with your own styles, you can have full control over styling inline.**
|
|
322
|
-
|
|
323
|
-
**ReactMatrix**
|
|
324
|
-
|
|
325
|
-
- tableContainerStyles={{}}
|
|
326
|
-
- tableStyles={{}}
|
|
327
|
-
|
|
328
|
-
**MatrixHeaders**
|
|
329
|
-
|
|
330
|
-
- thRowStyles={{}}
|
|
331
|
-
- thTitleStyles={{}}
|
|
332
|
-
- thSubTitleStyles={{}}
|
|
333
|
-
- thPrimaryTitleStyles={{}}
|
|
334
|
-
|
|
335
|
-
**MatrixRows**
|
|
336
|
-
|
|
337
|
-
- trRowStyles={{}},
|
|
338
|
-
- trTitleStyles={{}},
|
|
339
|
-
- trSubTitleStyles={{}},
|
|
340
|
-
- trPrimaryTitleStyles={{}},
|
|
341
|
-
|
|
342
|
-
**TableData**
|
|
343
|
-
|
|
344
|
-
- tdStyles={{}},
|
|
345
|
-
|
|
346
|
-
---
|
|
347
|
-
|
|
348
|
-
# Create React App
|
|
349
|
-
|
|
350
|
-
- This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
|
@@ -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;
|