@uiw/react-heat-map
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -142,9 +142,2 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/***/ 211: | ||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => { | ||
module.exports = __webpack_require__.p + "4a9219c4d09b5da45d7c.less"; | ||
/***/ }), | ||
/***/ 787: | ||
@@ -208,14 +201,2 @@ /***/ ((module) => { | ||
/******/ | ||
/******/ /* webpack/runtime/global */ | ||
/******/ (() => { | ||
/******/ __webpack_require__.g = (function() { | ||
/******/ if (typeof globalThis === 'object') return globalThis; | ||
/******/ try { | ||
/******/ return this || new Function('return this')(); | ||
/******/ } catch (e) { | ||
/******/ if (typeof window === 'object') return window; | ||
/******/ } | ||
/******/ })(); | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/hasOwnProperty shorthand */ | ||
@@ -237,22 +218,2 @@ /******/ (() => { | ||
/******/ | ||
/******/ /* webpack/runtime/publicPath */ | ||
/******/ (() => { | ||
/******/ var scriptUrl; | ||
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; | ||
/******/ var document = __webpack_require__.g.document; | ||
/******/ if (!scriptUrl && document) { | ||
/******/ if (document.currentScript) | ||
/******/ scriptUrl = document.currentScript.src | ||
/******/ if (!scriptUrl) { | ||
/******/ var scripts = document.getElementsByTagName("script"); | ||
/******/ if(scripts.length) scriptUrl = scripts[scripts.length - 1].src | ||
/******/ } | ||
/******/ } | ||
/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration | ||
/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic. | ||
/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); | ||
/******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); | ||
/******/ __webpack_require__.p = scriptUrl; | ||
/******/ })(); | ||
/******/ | ||
/************************************************************************/ | ||
@@ -452,4 +413,5 @@ var __webpack_exports__ = {}; | ||
var SVG_excluded=["rectSize","legendCellSize","space","startDate","endDate","rectProps","rectRender","legendRender","value","weekLabels","monthLabels","panelColors"];function SVG(props){var _ref=props||{},_ref$rectSize=_ref.rectSize,rectSize=_ref$rectSize===void 0?11:_ref$rectSize,_ref$legendCellSize=_ref.legendCellSize,legendCellSize=_ref$legendCellSize===void 0?11:_ref$legendCellSize,_ref$space=_ref.space,space=_ref$space===void 0?2:_ref$space,_ref$startDate=_ref.startDate,startDate=_ref$startDate===void 0?new Date():_ref$startDate,endDate=_ref.endDate,rectProps=_ref.rectProps,rectRender=_ref.rectRender,legendRender=_ref.legendRender,_ref$value=_ref.value,value=_ref$value===void 0?[]:_ref$value,_ref$weekLabels=_ref.weekLabels,weekLabels=_ref$weekLabels===void 0?['Sun','Mon','Tue','Wed','Thu','Fri','Sat']:_ref$weekLabels,_ref$monthLabels=_ref.monthLabels,monthLabels=_ref$monthLabels===void 0?['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']:_ref$monthLabels,_ref$panelColors=_ref.panelColors,panelColors=_ref$panelColors===void 0?{0:'#EBEDF0',8:'#7BC96F',4:'#C6E48B',12:'#239A3B',32:'#196127'}:_ref$panelColors,other=_objectWithoutProperties(_ref,SVG_excluded);var _useState=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(0),_useState2=_slicedToArray(_useState,2),gridNum=_useState2[0],setGridNum=_useState2[1];var _useState3=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(!!weekLabels?28:5),_useState4=_slicedToArray(_useState3,2),leftPad=_useState4[0],setLeftPad=_useState4[1];var _useState5=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(!!monthLabels?20:5),_useState6=_slicedToArray(_useState5,2),topPad=_useState6[0],setTopPad=_useState6[1];var svgRef=/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();var nums=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return numberSort(Object.keys(panelColors).map(function(item){return parseInt(item,10);}));},[panelColors]);var data=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return formatData(value);},[value]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){return setLeftPad(!!weekLabels?28:5);},[weekLabels]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(svgRef.current){var width=svgRef.current.clientWidth-leftPad||0;setGridNum(Math.floor(width/(rectSize+space))||0);}},[rectSize,svgRef,space,leftPad]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){setTopPad(!!monthLabels?20:5);},[monthLabels]);var initStartDate=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){if(isValidDate(startDate)){return!startDate.getDay()?startDate:new Date(startDate.getTime()-startDate.getDay()*oneDayTime);}else{var newDate=new Date();return new Date(newDate.getTime()-newDate.getDay()*oneDayTime);}},[startDate]);return/*#__PURE__*/(0,jsx_runtime.jsxs)("svg",_objectSpread2(_objectSpread2({ref:svgRef},other),{},{children:[legendCellSize!==0&&/*#__PURE__*/(0,jsx_runtime.jsx)(Legend,{legendRender:legendRender,panelColors:panelColors,rectSize:rectSize,legendCellSize:legendCellSize,leftPad:leftPad,topPad:topPad,space:space}),/*#__PURE__*/(0,jsx_runtime.jsx)(LabelsWeek,{weekLabels:weekLabels,rectSize:rectSize,space:space,topPad:topPad}),/*#__PURE__*/(0,jsx_runtime.jsx)(LabelsMonth,{monthLabels:monthLabels,rectSize:rectSize,space:space,leftPad:leftPad,colNum:gridNum,startDate:initStartDate}),/*#__PURE__*/(0,jsx_runtime.jsx)("g",{transform:"translate(".concat(leftPad,", ").concat(topPad,")"),children:gridNum>0&&_toConsumableArray(Array(gridNum)).map(function(_,idx){return/*#__PURE__*/(0,jsx_runtime.jsx)("g",{"data-column":idx,children:_toConsumableArray(Array(7)).map(function(_,cidx){var dayProps=_objectSpread2(_objectSpread2({},rectProps),{},{key:cidx,fill:'#EBEDF0',width:rectSize,height:rectSize,x:idx*(rectSize+space),y:(rectSize+space)*cidx});var currentDate=new Date(initStartDate.getTime()+oneDayTime*(idx*7+cidx));var date=getDateToString(currentDate);var dataProps=_objectSpread2(_objectSpread2({},data[date]),{},{date:date,row:cidx,column:idx,index:idx*7+cidx});if(endDate instanceof Date&¤tDate.getTime()>endDate.getTime()){return null;}if(date&&data[date]&&panelColors&&Object.keys(panelColors).length>0){dayProps.fill=existColor(data[date].count||0,nums,panelColors);}else if(panelColors&&panelColors[0]){dayProps.fill=panelColors[0];}if(rectRender&&typeof rectRender==='function'){var elm=rectRender(_objectSpread2(_objectSpread2({},dayProps),{},{key:cidx}),dataProps);if(elm&&/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().isValidElement(elm)){return elm;}}return/*#__PURE__*/(0,jsx_runtime.jsx)(Rect,_objectSpread2(_objectSpread2({},dayProps),{},{"data-date":date,"data-index":dataProps.index,"data-row":dataProps.row,"data-column":dataProps.column}));})},idx);})})]}));} | ||
// EXTERNAL MODULE: ./src/style/index.less | ||
var style = __webpack_require__(211); | ||
;// CONCATENATED MODULE: ./src/style/index.less | ||
// extracted by mini-css-extract-plugin | ||
/* harmony default export */ const style = ({}); | ||
;// CONCATENATED MODULE: ./src/index.tsx | ||
@@ -456,0 +418,0 @@ var src_excluded=["prefixCls","className"];function HeatMap(props){var _props$prefixCls=props.prefixCls,prefixCls=_props$prefixCls===void 0?'w-heatmap':_props$prefixCls,className=props.className,others=_objectWithoutProperties(props,src_excluded);var cls=[className,prefixCls].filter(Boolean).join(' ');return/*#__PURE__*/(0,jsx_runtime.jsx)(SVG,_objectSpread2({className:cls},others));} |
/*! For license information please see heat-map.min.js.LICENSE.txt */ | ||
!function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("react")):"function"===typeof define&&define.amd?define(["react"],t):"object"===typeof exports?exports["@uiw/react-heat-map"]=t(require("react")):e["@uiw/react-heat-map"]=t(e.React)}(self,(function(e){return(()=>{"use strict";var t={323:e=>{var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function o(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(o){return!1}}()?Object.assign:function(e,a){for(var i,c,u=o(e),l=1;l<arguments.length;l++){for(var f in i=Object(arguments[l]))r.call(i,f)&&(u[f]=i[f]);if(t){c=t(i);for(var s=0;s<c.length;s++)n.call(i,c[s])&&(u[c[s]]=i[c[s]])}}return u}},638:(e,t,r)=>{r(323);var n=r(787),o=60103;if(60107,"function"===typeof Symbol&&Symbol.for){var a=Symbol.for;o=a("react.element"),a("react.fragment")}var i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c=Object.prototype.hasOwnProperty,u={key:!0,ref:!0,__self:!0,__source:!0};function l(e,t,r){var n,a={},l=null,f=null;for(n in void 0!==r&&(l=""+r),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(f=t.ref),t)c.call(t,n)&&!u.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===a[n]&&(a[n]=t[n]);return{$$typeof:o,type:e,key:l,ref:f,props:a,_owner:i.current}}t.jsx=l,t.jsxs=l},724:(e,t,r)=>{e.exports=r(638)},211:(e,t,r)=>{e.exports=r.p+"4a9219c4d09b5da45d7c.less"},787:t=>{t.exports=e}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var a=r[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+"");var t=n.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");r.length&&(e=r[r.length-1].src)}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})();var o={};return(()=>{function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function r(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}function a(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}n.r(o),n.d(o,{default:()=>x});var i=n(787),c=n.n(i);function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function l(e,t){if(e){if("string"===typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}function f(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||l(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(u){c=!0,o=u}finally{try{i||null==r.return||r.return()}finally{if(c)throw o}}return a}}(e,t)||l(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var d=n(724),p=function(e){var t=e.weekLabels,r=void 0===t?[]:t,n=e.rectSize,o=void 0===n?0:n,a=e.topPad,c=void 0===a?0:a,u=e.space,l=void 0===u?0:u;return(0,i.useMemo)((function(){return(0,d.jsx)(i.Fragment,{children:f(Array(7)).map((function(e,t){return r&&r[t]?(0,d.jsx)("text",{x:15,y:c,dy:(t+1)*(o+l)-5,children:r[t]},t):null}))})}),[o,l,c,r])},y=864e5;function m(e){return e instanceof Date&&!isNaN(e.getTime())}function v(e){return"".concat(e.getFullYear(),"/").concat(e.getMonth()+1,"/").concat(e.getDate())}var b=function(e){var t=e.monthLabels,r=void 0===t?[]:t,n=e.rectSize,o=void 0===n?0:n,a=e.space,c=void 0===a?0:a,u=e.leftPad,l=void 0===u?0:u,s=e.colNum,p=void 0===s?0:s,m=e.startDate,v=(0,i.useMemo)((function(){return!1===r||p<1?[]:f(Array(7*p)).map((function(e,t){if(t/7%1===0){var n=new Date(m.getTime()+t*y),o=n.getMonth();return{col:t/7,index:t,month:o,day:n.getDate(),monthStr:r[o],date:n}}return null})).filter(Boolean).filter((function(e,t,r){return r[t-1]&&r[t-1].month!==e.month}))}),[p,r,m]);return(0,i.useMemo)((function(){return(0,d.jsx)(i.Fragment,{children:f(v).map((function(e,t){return(0,d.jsx)("text",{"data-size":o,x:l+c+c,y:15,dx:e.col*(o+c),textAnchor:"start",children:e.monthStr},t)}))})}),[v,l,o,c])},g=function(e){return(0,d.jsx)("rect",r({},e))},h=["panelColors","leftPad","topPad","space","rectSize","legendCellSize","legendRender"];function j(e){var t=e.panelColors,n=e.leftPad,o=void 0===n?0:n,c=e.topPad,u=void 0===c?0:c,l=(e.space,e.rectSize),f=void 0===l?0:l,s=e.legendCellSize,p=void 0===s?0:s,y=e.legendRender,m=a(e,h),v=p||f;return(0,i.useMemo)((function(){return(0,d.jsx)(i.Fragment,{children:Object.keys(t||{}).map((function(e,n){var a=r(r({},m),{},{key:n,x:(v+1)*n+o,y:u+8*f+6,fill:t[Number(e)],width:v,height:v});return y?y(a):(0,d.jsx)(g,r({},a))}))})}),[t,m,v,o,u,f,y])}var O=["rectSize","legendCellSize","space","startDate","endDate","rectProps","rectRender","legendRender","value","weekLabels","monthLabels","panelColors"];function w(e){var t=e||{},n=t.rectSize,o=void 0===n?11:n,u=t.legendCellSize,l=void 0===u?11:u,h=t.space,w=void 0===h?2:h,S=t.startDate,x=void 0===S?new Date:S,P=t.endDate,D=t.rectProps,E=t.rectRender,_=t.legendRender,k=t.value,T=void 0===k?[]:k,A=t.weekLabels,C=void 0===A?["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]:A,M=t.monthLabels,z=void 0===M?["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]:M,N=t.panelColors,R=void 0===N?{0:"#EBEDF0",8:"#7BC96F",4:"#C6E48B",12:"#239A3B",32:"#196127"}:N,F=a(t,O),I=s((0,i.useState)(0),2),L=I[0],B=I[1],$=s((0,i.useState)(C?28:5),2),q=$[0],J=$[1],U=s((0,i.useState)(z?20:5),2),W=U[0],Y=U[1],V=c().createRef(),G=(0,i.useMemo)((function(){return function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).sort((function(e,t){return e<t?-1:e>t?1:0}))}(Object.keys(R).map((function(e){return parseInt(e,10)})))}),[R]),H=(0,i.useMemo)((function(){return function(){var e={};return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach((function(t){t.date&&m(new Date(t.date))&&(t.date=v(new Date(t.date)),e[t.date]=t)})),e}(T)}),[T]);(0,i.useEffect)((function(){return J(C?28:5)}),[C]),(0,i.useEffect)((function(){if(V.current){var e=V.current.clientWidth-q||0;B(Math.floor(e/(o+w))||0)}}),[o,V,w,q]),(0,i.useEffect)((function(){Y(z?20:5)}),[z]);var K=(0,i.useMemo)((function(){if(m(x))return x.getDay()?new Date(x.getTime()-x.getDay()*y):x;var e=new Date;return new Date(e.getTime()-e.getDay()*y)}),[x]);return(0,d.jsxs)("svg",r(r({ref:V},F),{},{children:[0!==l&&(0,d.jsx)(j,{legendRender:_,panelColors:R,rectSize:o,legendCellSize:l,leftPad:q,topPad:W,space:w}),(0,d.jsx)(p,{weekLabels:C,rectSize:o,space:w,topPad:W}),(0,d.jsx)(b,{monthLabels:z,rectSize:o,space:w,leftPad:q,colNum:L,startDate:K}),(0,d.jsx)("g",{transform:"translate(".concat(q,", ").concat(W,")"),children:L>0&&f(Array(L)).map((function(e,t){return(0,d.jsx)("g",{"data-column":t,children:f(Array(7)).map((function(e,n){var a=r(r({},D),{},{key:n,fill:"#EBEDF0",width:o,height:o,x:t*(o+w),y:(o+w)*n}),i=new Date(K.getTime()+y*(7*t+n)),u=v(i),l=r(r({},H[u]),{},{date:u,row:n,column:t,index:7*t+n});if(P instanceof Date&&i.getTime()>P.getTime())return null;if(u&&H[u]&&R&&Object.keys(R).length>0?a.fill=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="",o=0;o<t.length;o+=1){if(t[o]>e){n=r[t[o]];break}n=r[t[o]]}return n}(H[u].count||0,G,R):R&&R[0]&&(a.fill=R[0]),E&&"function"===typeof E){var f=E(r(r({},a),{},{key:n}),l);if(f&&c().isValidElement(f))return f}return(0,d.jsx)(g,r(r({},a),{},{"data-date":u,"data-index":l.index,"data-row":l.row,"data-column":l.column}))}))},t)}))})]}))}n(211);var S=["prefixCls","className"];function x(e){var t=e.prefixCls,n=void 0===t?"w-heatmap":t,o=e.className,i=a(e,S),c=[o,n].filter(Boolean).join(" ");return(0,d.jsx)(w,r({className:c},i))}})(),o})()})); | ||
!function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("react")):"function"===typeof define&&define.amd?define(["react"],t):"object"===typeof exports?exports["@uiw/react-heat-map"]=t(require("react")):e["@uiw/react-heat-map"]=t(e.React)}(self,(function(e){return(()=>{"use strict";var t={323:e=>{var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function o(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(o){return!1}}()?Object.assign:function(e,a){for(var i,u,c=o(e),l=1;l<arguments.length;l++){for(var f in i=Object(arguments[l]))r.call(i,f)&&(c[f]=i[f]);if(t){u=t(i);for(var s=0;s<u.length;s++)n.call(i,u[s])&&(c[u[s]]=i[u[s]])}}return c}},638:(e,t,r)=>{r(323);var n=r(787),o=60103;if(60107,"function"===typeof Symbol&&Symbol.for){var a=Symbol.for;o=a("react.element"),a("react.fragment")}var i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u=Object.prototype.hasOwnProperty,c={key:!0,ref:!0,__self:!0,__source:!0};function l(e,t,r){var n,a={},l=null,f=null;for(n in void 0!==r&&(l=""+r),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(f=t.ref),t)u.call(t,n)&&!c.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===a[n]&&(a[n]=t[n]);return{$$typeof:o,type:e,key:l,ref:f,props:a,_owner:i.current}}t.jsx=l,t.jsxs=l},724:(e,t,r)=>{e.exports=r(638)},787:t=>{t.exports=e}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var a=r[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function r(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}function a(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}n.r(o),n.d(o,{default:()=>x});var i=n(787),u=n.n(i);function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function l(e,t){if(e){if("string"===typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}function f(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||l(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],i=!0,u=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(c){u=!0,o=c}finally{try{i||null==r.return||r.return()}finally{if(u)throw o}}return a}}(e,t)||l(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var d=n(724),p=function(e){var t=e.weekLabels,r=void 0===t?[]:t,n=e.rectSize,o=void 0===n?0:n,a=e.topPad,u=void 0===a?0:a,c=e.space,l=void 0===c?0:c;return(0,i.useMemo)((function(){return(0,d.jsx)(i.Fragment,{children:f(Array(7)).map((function(e,t){return r&&r[t]?(0,d.jsx)("text",{x:15,y:u,dy:(t+1)*(o+l)-5,children:r[t]},t):null}))})}),[o,l,u,r])},y=864e5;function v(e){return e instanceof Date&&!isNaN(e.getTime())}function m(e){return"".concat(e.getFullYear(),"/").concat(e.getMonth()+1,"/").concat(e.getDate())}var b=function(e){var t=e.monthLabels,r=void 0===t?[]:t,n=e.rectSize,o=void 0===n?0:n,a=e.space,u=void 0===a?0:a,c=e.leftPad,l=void 0===c?0:c,s=e.colNum,p=void 0===s?0:s,v=e.startDate,m=(0,i.useMemo)((function(){return!1===r||p<1?[]:f(Array(7*p)).map((function(e,t){if(t/7%1===0){var n=new Date(v.getTime()+t*y),o=n.getMonth();return{col:t/7,index:t,month:o,day:n.getDate(),monthStr:r[o],date:n}}return null})).filter(Boolean).filter((function(e,t,r){return r[t-1]&&r[t-1].month!==e.month}))}),[p,r,v]);return(0,i.useMemo)((function(){return(0,d.jsx)(i.Fragment,{children:f(m).map((function(e,t){return(0,d.jsx)("text",{"data-size":o,x:l+u+u,y:15,dx:e.col*(o+u),textAnchor:"start",children:e.monthStr},t)}))})}),[m,l,o,u])},g=function(e){return(0,d.jsx)("rect",r({},e))},h=["panelColors","leftPad","topPad","space","rectSize","legendCellSize","legendRender"];function j(e){var t=e.panelColors,n=e.leftPad,o=void 0===n?0:n,u=e.topPad,c=void 0===u?0:u,l=(e.space,e.rectSize),f=void 0===l?0:l,s=e.legendCellSize,p=void 0===s?0:s,y=e.legendRender,v=a(e,h),m=p||f;return(0,i.useMemo)((function(){return(0,d.jsx)(i.Fragment,{children:Object.keys(t||{}).map((function(e,n){var a=r(r({},v),{},{key:n,x:(m+1)*n+o,y:c+8*f+6,fill:t[Number(e)],width:m,height:m});return y?y(a):(0,d.jsx)(g,r({},a))}))})}),[t,v,m,o,c,f,y])}var O=["rectSize","legendCellSize","space","startDate","endDate","rectProps","rectRender","legendRender","value","weekLabels","monthLabels","panelColors"];function w(e){var t=e||{},n=t.rectSize,o=void 0===n?11:n,c=t.legendCellSize,l=void 0===c?11:c,h=t.space,w=void 0===h?2:h,S=t.startDate,x=void 0===S?new Date:S,P=t.endDate,D=t.rectProps,E=t.rectRender,_=t.legendRender,k=t.value,C=void 0===k?[]:k,A=t.weekLabels,M=void 0===A?["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]:A,T=t.monthLabels,z=void 0===T?["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]:T,N=t.panelColors,R=void 0===N?{0:"#EBEDF0",8:"#7BC96F",4:"#C6E48B",12:"#239A3B",32:"#196127"}:N,I=a(t,O),L=s((0,i.useState)(0),2),F=L[0],B=L[1],q=s((0,i.useState)(M?28:5),2),J=q[0],U=q[1],W=s((0,i.useState)(z?20:5),2),$=W[0],Y=W[1],V=u().createRef(),G=(0,i.useMemo)((function(){return function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).sort((function(e,t){return e<t?-1:e>t?1:0}))}(Object.keys(R).map((function(e){return parseInt(e,10)})))}),[R]),H=(0,i.useMemo)((function(){return function(){var e={};return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach((function(t){t.date&&v(new Date(t.date))&&(t.date=m(new Date(t.date)),e[t.date]=t)})),e}(C)}),[C]);(0,i.useEffect)((function(){return U(M?28:5)}),[M]),(0,i.useEffect)((function(){if(V.current){var e=V.current.clientWidth-J||0;B(Math.floor(e/(o+w))||0)}}),[o,V,w,J]),(0,i.useEffect)((function(){Y(z?20:5)}),[z]);var K=(0,i.useMemo)((function(){if(v(x))return x.getDay()?new Date(x.getTime()-x.getDay()*y):x;var e=new Date;return new Date(e.getTime()-e.getDay()*y)}),[x]);return(0,d.jsxs)("svg",r(r({ref:V},I),{},{children:[0!==l&&(0,d.jsx)(j,{legendRender:_,panelColors:R,rectSize:o,legendCellSize:l,leftPad:J,topPad:$,space:w}),(0,d.jsx)(p,{weekLabels:M,rectSize:o,space:w,topPad:$}),(0,d.jsx)(b,{monthLabels:z,rectSize:o,space:w,leftPad:J,colNum:F,startDate:K}),(0,d.jsx)("g",{transform:"translate(".concat(J,", ").concat($,")"),children:F>0&&f(Array(F)).map((function(e,t){return(0,d.jsx)("g",{"data-column":t,children:f(Array(7)).map((function(e,n){var a=r(r({},D),{},{key:n,fill:"#EBEDF0",width:o,height:o,x:t*(o+w),y:(o+w)*n}),i=new Date(K.getTime()+y*(7*t+n)),c=m(i),l=r(r({},H[c]),{},{date:c,row:n,column:t,index:7*t+n});if(P instanceof Date&&i.getTime()>P.getTime())return null;if(c&&H[c]&&R&&Object.keys(R).length>0?a.fill=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="",o=0;o<t.length;o+=1){if(t[o]>e){n=r[t[o]];break}n=r[t[o]]}return n}(H[c].count||0,G,R):R&&R[0]&&(a.fill=R[0]),E&&"function"===typeof E){var f=E(r(r({},a),{},{key:n}),l);if(f&&u().isValidElement(f))return f}return(0,d.jsx)(g,r(r({},a),{},{"data-date":c,"data-index":l.index,"data-row":l.row,"data-column":l.column}))}))},t)}))})]}))}var S=["prefixCls","className"];function x(e){var t=e.prefixCls,n=void 0===t?"w-heatmap":t,o=e.className,i=a(e,S),u=[o,n].filter(Boolean).join(" ");return(0,d.jsx)(w,r({className:u},i))}})(),o})()})); |
{ | ||
"name": "@uiw/react-heat-map", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "React component create calendar heatmap to visualize time series data, a la github contribution graph.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://uiwjs.github.io/react-heat-map/", |
@@ -306,4 +306,14 @@ HeatMap 日历热图 | ||
## Contributors | ||
As always, thanks to our amazing contributors! | ||
<a href="https://github.com/uiwjs/react-heat-map/graphs/contributors"> | ||
<img src="https://uiwjs.github.io/react-heat-map/CONTRIBUTORS.svg" /> | ||
</a> | ||
Made with [github-action-contributors](https://github.com/jaywcjlove/github-action-contributors). | ||
## License | ||
Licensed under the MIT License. |
{ | ||
"extends": "../tsconfig", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "../cjs", | ||
"emitDeclarationOnly": true, | ||
"noEmit": false | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
319
0
145556
1663