@uiw/react-heat-map
Advanced tools
Comparing version 2.0.5 to 2.1.0
@@ -15,3 +15,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/***/ 298: | ||
/***/ 349: | ||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => { | ||
@@ -35,3 +35,3 @@ | ||
/***/ 605: | ||
/***/ 501: | ||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => { | ||
@@ -42,3 +42,3 @@ | ||
if (true) { | ||
module.exports = __webpack_require__(298); | ||
module.exports = __webpack_require__(349); | ||
} else {} | ||
@@ -135,4 +135,35 @@ | ||
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/typeof.js | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { | ||
return typeof obj; | ||
} : function (obj) { | ||
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}, _typeof(obj); | ||
} | ||
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js | ||
function _toPrimitive(input, hint) { | ||
if (_typeof(input) !== "object" || input === null) return input; | ||
var prim = input[Symbol.toPrimitive]; | ||
if (prim !== undefined) { | ||
var res = prim.call(input, hint || "default"); | ||
if (_typeof(res) !== "object") return res; | ||
throw new TypeError("@@toPrimitive must return a primitive value."); | ||
} | ||
return (hint === "string" ? String : Number)(input); | ||
} | ||
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js | ||
function _toPropertyKey(arg) { | ||
var key = _toPrimitive(arg, "string"); | ||
return _typeof(key) === "symbol" ? key : String(key); | ||
} | ||
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/defineProperty.js | ||
function _defineProperty(obj, key, value) { | ||
key = _toPropertyKey(key); | ||
if (key in obj) { | ||
@@ -209,5 +240,3 @@ Object.defineProperty(obj, key, { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) { | ||
arr2[i] = arr[i]; | ||
} | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
@@ -252,24 +281,27 @@ } | ||
function _iterableToArrayLimit(arr, i) { | ||
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; | ||
if (_i == null) return; | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _s, _e; | ||
try { | ||
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; | ||
if (null != _i) { | ||
var _s, | ||
_e, | ||
_x, | ||
_r, | ||
_arr = [], | ||
_n = !0, | ||
_d = !1; | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
if (_x = (_i = _i.call(arr)).next, 0 === i) { | ||
if (Object(_i) !== _i) return; | ||
_n = !1; | ||
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); | ||
} catch (err) { | ||
_d = !0, _e = err; | ||
} finally { | ||
if (_d) throw _e; | ||
try { | ||
if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
return _arr; | ||
} | ||
@@ -289,15 +321,15 @@ ;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/nonIterableRest.js | ||
// EXTERNAL MODULE: ../node_modules/react/jsx-runtime.js | ||
var jsx_runtime = __webpack_require__(605); | ||
var jsx_runtime = __webpack_require__(501); | ||
;// CONCATENATED MODULE: ./src/LabelsWeek.tsx | ||
var LabelsWeek=function LabelsWeek(_ref){var _ref$weekLabels=_ref.weekLabels,weekLabels=_ref$weekLabels===void 0?[]:_ref$weekLabels,_ref$rectSize=_ref.rectSize,rectSize=_ref$rectSize===void 0?0:_ref$rectSize,_ref$topPad=_ref.topPad,topPad=_ref$topPad===void 0?0:_ref$topPad,_ref$space=_ref.space,space=_ref$space===void 0?0:_ref$space;return (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return/*#__PURE__*/(0,jsx_runtime.jsx)(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment,{children:_toConsumableArray(Array(7)).map(function(_,idx){if(weekLabels&&weekLabels[idx]){return/*#__PURE__*/(0,jsx_runtime.jsx)("text",{x:15,y:topPad,dy:(idx+1)*(rectSize+space)-5,children:weekLabels[idx]},idx);}return null;})});},[rectSize,space,topPad,weekLabels]);}; | ||
var textStyle={textAnchor:'middle',fontSize:'inherit',fill:'currentColor'};var LabelsWeek=function LabelsWeek(_ref){var _ref$weekLabels=_ref.weekLabels,weekLabels=_ref$weekLabels===void 0?[]:_ref$weekLabels,_ref$rectSize=_ref.rectSize,rectSize=_ref$rectSize===void 0?0:_ref$rectSize,_ref$topPad=_ref.topPad,topPad=_ref$topPad===void 0?0:_ref$topPad,_ref$space=_ref.space,space=_ref$space===void 0?0:_ref$space;return (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return/*#__PURE__*/(0,jsx_runtime.jsx)(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment,{children:_toConsumableArray(Array(7)).map(function(_,idx){if(weekLabels&&weekLabels[idx]){return/*#__PURE__*/(0,jsx_runtime.jsx)("text",{className:"w-heatmap-week",x:15,y:topPad,dy:(idx+1)*(rectSize+space)-5,style:textStyle,children:weekLabels[idx]},idx);}return null;})});},[rectSize,space,topPad,weekLabels]);}; | ||
;// CONCATENATED MODULE: ./src/utils.ts | ||
var oneDayTime=24*60*60*1000;function isValidDate(date){return date instanceof Date&&!isNaN(date.getTime());}function getDateToString(date){return"".concat(date.getFullYear(),"/").concat(date.getMonth()+1,"/").concat(date.getDate());}function formatData(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var result={};data.forEach(function(item){if(item.date&&isValidDate(new Date(item.date))){item.date=getDateToString(new Date(item.date));result[item.date]=item;}});return result;}/** 排序 比较函数 */function numberSort(){var keys=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];return keys.sort(function(x,y){if(x<y)return-1;else if(x>y)return 1;return 0;});}function existColor(){var num=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0;var nums=arguments.length>1?arguments[1]:undefined;var panelColors=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var color='';for(var a=0;a<nums.length;a+=1){if(nums[a]>num){color=panelColors[nums[a]];break;}color=panelColors[nums[a]];}return color;} | ||
;// CONCATENATED MODULE: ./src/LabelsMonth.tsx | ||
var LabelsMonth=function LabelsMonth(_ref){var _ref$monthLabels=_ref.monthLabels,monthLabels=_ref$monthLabels===void 0?[]:_ref$monthLabels,_ref$rectSize=_ref.rectSize,rectSize=_ref$rectSize===void 0?0:_ref$rectSize,_ref$space=_ref.space,space=_ref$space===void 0?0:_ref$space,_ref$leftPad=_ref.leftPad,leftPad=_ref$leftPad===void 0?0:_ref$leftPad,_ref$colNum=_ref.colNum,colNum=_ref$colNum===void 0?0:_ref$colNum,startDate=_ref.startDate;var data=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){if(monthLabels===false||colNum<1)return[];return _toConsumableArray(Array(colNum*7)).map(function(_,idx){if(idx/7%1===0){var date=new Date(startDate.getTime()+idx*oneDayTime);var month=date.getMonth();return{col:idx/7,index:idx,month:month,day:date.getDate(),monthStr:monthLabels[month],date:date};}return null;}).filter(Boolean).filter(function(item,idx,list){return list[idx-1]&&list[idx-1].month!==item.month;});},[colNum,monthLabels,startDate]);return (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return/*#__PURE__*/(0,jsx_runtime.jsx)(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment,{children:_toConsumableArray(data).map(function(item,idx){return/*#__PURE__*/(0,jsx_runtime.jsx)("text",{"data-size":rectSize,x:leftPad+space+space,y:15,dx:item.col*(rectSize+space),textAnchor:"start",children:item.monthStr},idx);})});},[data,leftPad,rectSize,space]);}; | ||
var LabelsMonth=function LabelsMonth(_ref){var _ref$monthLabels=_ref.monthLabels,monthLabels=_ref$monthLabels===void 0?[]:_ref$monthLabels,_ref$rectSize=_ref.rectSize,rectSize=_ref$rectSize===void 0?0:_ref$rectSize,_ref$space=_ref.space,space=_ref$space===void 0?0:_ref$space,_ref$leftPad=_ref.leftPad,leftPad=_ref$leftPad===void 0?0:_ref$leftPad,_ref$colNum=_ref.colNum,colNum=_ref$colNum===void 0?0:_ref$colNum,startDate=_ref.startDate;var data=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){if(monthLabels===false||colNum<1)return[];return _toConsumableArray(Array(colNum*7)).map(function(_,idx){if(idx/7%1===0){var date=new Date(startDate.getTime()+idx*oneDayTime);var month=date.getMonth();return{col:idx/7,index:idx,month:month,day:date.getDate(),monthStr:monthLabels[month],date:date};}return null;}).filter(Boolean).filter(function(item,idx,list){return list[idx-1]&&list[idx-1].month!==item.month;});},[colNum,monthLabels,startDate]);return (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return/*#__PURE__*/(0,jsx_runtime.jsx)(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment,{children:_toConsumableArray(data).map(function(item,idx){return/*#__PURE__*/(0,jsx_runtime.jsx)("text",{"data-size":rectSize,x:leftPad+space+space,y:15,dx:item.col*(rectSize+space),textAnchor:"start",style:textStyle,children:item.monthStr},idx);})});},[data,leftPad,rectSize,space]);}; | ||
;// CONCATENATED MODULE: ./src/Rect.tsx | ||
var Rect=function Rect(props){return/*#__PURE__*/(0,jsx_runtime.jsx)("rect",_objectSpread2({},props));}; | ||
var _excluded=["style","value","render","key"];var rectStyle={display:'block',cursor:'pointer'};var Rect=function Rect(props){var style=props.style,value=props.value,render=props.render,key=props.key,reset=_objectWithoutProperties(props,_excluded);var rectProps=_objectSpread2(_objectSpread2({},reset),{},{style:_objectSpread2({display:'block',cursor:'pointer'},style)});if(render&&typeof render==='function'){var elm=render(_objectSpread2({},rectProps),value);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({},rectProps));}; | ||
;// CONCATENATED MODULE: ./src/Legend.tsx | ||
var _excluded=["panelColors","leftPad","topPad","space","rectSize","legendCellSize","legendRender"];function Legend(_ref){var panelColors=_ref.panelColors,_ref$leftPad=_ref.leftPad,leftPad=_ref$leftPad===void 0?0:_ref$leftPad,_ref$topPad=_ref.topPad,topPad=_ref$topPad===void 0?0:_ref$topPad,_ref$space=_ref.space,space=_ref$space===void 0?0:_ref$space,_ref$rectSize=_ref.rectSize,rectSize=_ref$rectSize===void 0?0:_ref$rectSize,_ref$legendCellSize=_ref.legendCellSize,legendCellSize=_ref$legendCellSize===void 0?0:_ref$legendCellSize,legendRender=_ref.legendRender,props=_objectWithoutProperties(_ref,_excluded);var size=legendCellSize||rectSize;return (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return/*#__PURE__*/(0,jsx_runtime.jsx)(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment,{children:Object.keys(panelColors||{}).map(function(num,key){var rectProps=_objectSpread2(_objectSpread2({},props),{},{key:key,x:(size+1)*key+leftPad,y:topPad+rectSize*8+6,fill:panelColors[Number(num)],width:size,height:size});if(legendRender)return legendRender(rectProps);return/*#__PURE__*/(0,jsx_runtime.jsx)(Rect,_objectSpread2({},rectProps));})});},[panelColors,props,size,leftPad,topPad,rectSize,legendRender]);} | ||
var Legend_excluded=["panelColors","leftPad","topPad","space","rectSize","legendCellSize","legendRender"];function Legend(_ref){var panelColors=_ref.panelColors,_ref$leftPad=_ref.leftPad,leftPad=_ref$leftPad===void 0?0:_ref$leftPad,_ref$topPad=_ref.topPad,topPad=_ref$topPad===void 0?0:_ref$topPad,_ref$space=_ref.space,space=_ref$space===void 0?0:_ref$space,_ref$rectSize=_ref.rectSize,rectSize=_ref$rectSize===void 0?0:_ref$rectSize,_ref$legendCellSize=_ref.legendCellSize,legendCellSize=_ref$legendCellSize===void 0?0:_ref$legendCellSize,legendRender=_ref.legendRender,props=_objectWithoutProperties(_ref,Legend_excluded);var size=legendCellSize||rectSize;return (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return/*#__PURE__*/(0,jsx_runtime.jsx)(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment,{children:Object.keys(panelColors||{}).map(function(num,key){var rectProps=_objectSpread2(_objectSpread2({},props),{},{key:key,x:(size+1)*key+leftPad,y:topPad+rectSize*8+6,fill:panelColors[Number(num)],width:size,height:size});if(legendRender)return legendRender(rectProps);return/*#__PURE__*/(0,jsx_runtime.jsx)(Rect,_objectSpread2({},rectProps));})});},[panelColors,props,size,leftPad,topPad,rectSize,legendRender]);} | ||
;// CONCATENATED MODULE: ./src/SVG.tsx | ||
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);})})]}));} | ||
var SVG_excluded=["rectSize","legendCellSize","space","startDate","endDate","rectProps","rectRender","legendRender","value","weekLabels","monthLabels","panelColors","style"];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:'var(--rhm-rect, #EBEDF0)',8:'#7BC96F',4:'#C6E48B',12:'#239A3B',32:'#196127'}:_ref$panelColors,style=_ref.style,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]);var styl={color:'var(--rhm-text-color, #24292e)',userSelect:'none',display:'block',fontSize:10};return/*#__PURE__*/(0,jsx_runtime.jsxs)("svg",_objectSpread2(_objectSpread2({ref:svgRef,style:_objectSpread2(_objectSpread2({},styl),style)},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 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});var dayProps=_objectSpread2(_objectSpread2({},rectProps),{},{key:cidx,fill:'var(--rhm-rect, #EBEDF0)',width:rectSize,height:rectSize,x:idx*(rectSize+space),y:(rectSize+space)*cidx,render:rectRender,value:dataProps});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];}return/*#__PURE__*/(0,jsx_runtime.jsx)(Rect,_objectSpread2(_objectSpread2({},dayProps),{},{value:dataProps,"data-date":date,"data-index":dataProps.index,"data-row":dataProps.row,"data-column":dataProps.column}));})},idx);})})]}));} | ||
;// CONCATENATED MODULE: ./src/style/index.less | ||
@@ -304,0 +336,0 @@ // extracted by mini-css-extract-plugin |
/*! 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,(e=>(()=>{"use strict";var t={298:(e,t,r)=>{var n=r(787),o=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,u=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,a={},c=null,f=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(f=t.ref),t)i.call(t,n)&&!l.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:c,ref:f,props:a,_owner:u.current}}t.jsx=c,t.jsxs=c},605:(e,t,r)=>{e.exports=r(298)},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:()=>w});var i=n(787),u=n.n(i);function l(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 c(e,t){if(e){if("string"===typeof e)return l(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)?l(e,t):void 0}}function f(e){return function(e){if(Array.isArray(e))return l(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(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(l){u=!0,o=l}finally{try{i||null==r.return||r.return()}finally{if(u)throw o}}return a}}(e,t)||c(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(605),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,l=e.space,c=void 0===l?0:l;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+c)-5,children:r[t]},t):null}))})}),[o,c,u,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,u=void 0===a?0:a,l=e.leftPad,c=void 0===l?0:l,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:c+u+u,y:15,dx:e.col*(o+u),textAnchor:"start",children:e.monthStr},t)}))})}),[v,c,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,l=void 0===u?0:u,c=(e.space,e.rectSize),f=void 0===c?0:c,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:l+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,l,f,y])}var O=["rectSize","legendCellSize","space","startDate","endDate","rectProps","rectRender","legendRender","value","weekLabels","monthLabels","panelColors"];function x(e){var t=e||{},n=t.rectSize,o=void 0===n?11:n,l=t.legendCellSize,c=void 0===l?11:l,h=t.space,x=void 0===h?2:h,S=t.startDate,w=void 0===S?new Date:S,P=t.endDate,D=t.rectProps,E=t.rectRender,_=t.legendRender,A=t.value,k=void 0===A?[]:A,C=t.weekLabels,M=void 0===C?["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]:C,T=t.monthLabels,z=void 0===T?["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]:T,R=t.panelColors,N=void 0===R?{0:"#EBEDF0",8:"#7BC96F",4:"#C6E48B",12:"#239A3B",32:"#196127"}:R,L=a(t,O),F=s((0,i.useState)(0),2),I=F[0],B=F[1],J=s((0,i.useState)(M?28:5),2),U=J[0],W=J[1],$=s((0,i.useState)(z?20:5),2),q=$[0],Y=$[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(N).map((function(e){return parseInt(e,10)})))}),[N]),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}(k)}),[k]);(0,i.useEffect)((function(){return W(M?28:5)}),[M]),(0,i.useEffect)((function(){if(V.current){var e=V.current.clientWidth-U||0;B(Math.floor(e/(o+x))||0)}}),[o,V,x,U]),(0,i.useEffect)((function(){Y(z?20:5)}),[z]);var K=(0,i.useMemo)((function(){if(m(w))return w.getDay()?new Date(w.getTime()-w.getDay()*y):w;var e=new Date;return new Date(e.getTime()-e.getDay()*y)}),[w]);return(0,d.jsxs)("svg",r(r({ref:V},L),{},{children:[0!==c&&(0,d.jsx)(j,{legendRender:_,panelColors:N,rectSize:o,legendCellSize:c,leftPad:U,topPad:q,space:x}),(0,d.jsx)(p,{weekLabels:M,rectSize:o,space:x,topPad:q}),(0,d.jsx)(b,{monthLabels:z,rectSize:o,space:x,leftPad:U,colNum:I,startDate:K}),(0,d.jsx)("g",{transform:"translate(".concat(U,", ").concat(q,")"),children:I>0&&f(Array(I)).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+x),y:(o+x)*n}),i=new Date(K.getTime()+y*(7*t+n)),l=v(i),c=r(r({},H[l]),{},{date:l,row:n,column:t,index:7*t+n});if(P instanceof Date&&i.getTime()>P.getTime())return null;if(l&&H[l]&&N&&Object.keys(N).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[l].count||0,G,N):N&&N[0]&&(a.fill=N[0]),E&&"function"===typeof E){var f=E(r(r({},a),{},{key:n}),c);if(f&&u().isValidElement(f))return f}return(0,d.jsx)(g,r(r({},a),{},{"data-date":l,"data-index":c.index,"data-row":c.row,"data-column":c.column}))}))},t)}))})]}))}var S=["prefixCls","className"];function w(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)(x,r({className:u},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,(e=>(()=>{"use strict";var t={349:(e,t,r)=>{var n=r(787),o=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,l=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,a={},c=null,f=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(f=t.ref),t)i.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:c,ref:f,props:a,_owner:l.current}}t.jsx=c,t.jsxs=c},501:(e,t,r)=>{e.exports=r(349)},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(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t){var r=function(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,r||"default");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"===e(r)?r:String(r)}function r(e,r,n){return(r=t(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function a(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 i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(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:()=>k});var u=n(787),c=n.n(u);function f(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 s(e,t){if(e){if("string"===typeof e)return f(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)?f(e,t):void 0}}function d(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||s(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 y(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,l=[],u=!0,c=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(l.push(n.value),l.length!==t);u=!0);}catch(f){c=!0,o=f}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(e,t)||s(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 p=n(501),m={textAnchor:"middle",fontSize:"inherit",fill:"currentColor"},v=function(e){var t=e.weekLabels,r=void 0===t?[]:t,n=e.rectSize,o=void 0===n?0:n,a=e.topPad,i=void 0===a?0:a,l=e.space,c=void 0===l?0:l;return(0,u.useMemo)((function(){return(0,p.jsx)(u.Fragment,{children:d(Array(7)).map((function(e,t){return r&&r[t]?(0,p.jsx)("text",{className:"w-heatmap-week",x:15,y:i,dy:(t+1)*(o+c)-5,style:m,children:r[t]},t):null}))})}),[o,c,i,r])},b=864e5;function g(e){return e instanceof Date&&!isNaN(e.getTime())}function h(e){return"".concat(e.getFullYear(),"/").concat(e.getMonth()+1,"/").concat(e.getDate())}var S=function(e){var t=e.monthLabels,r=void 0===t?[]:t,n=e.rectSize,o=void 0===n?0:n,a=e.space,i=void 0===a?0:a,l=e.leftPad,c=void 0===l?0:l,f=e.colNum,s=void 0===f?0:f,y=e.startDate,v=(0,u.useMemo)((function(){return!1===r||s<1?[]:d(Array(7*s)).map((function(e,t){if(t/7%1===0){var n=new Date(y.getTime()+t*b),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}))}),[s,r,y]);return(0,u.useMemo)((function(){return(0,p.jsx)(u.Fragment,{children:d(v).map((function(e,t){return(0,p.jsx)("text",{"data-size":o,x:c+i+i,y:15,dx:e.col*(o+i),textAnchor:"start",style:m,children:e.monthStr},t)}))})}),[v,c,o,i])},j=["style","value","render","key"],O=function(e){var t=e.style,r=e.value,n=e.render,o=(e.key,i(i({},l(e,j)),{},{style:i({display:"block",cursor:"pointer"},t)}));if(n&&"function"===typeof n){var a=n(i({},o),r);if(a&&c().isValidElement(a))return a}return(0,p.jsx)("rect",i({},o))},x=["panelColors","leftPad","topPad","space","rectSize","legendCellSize","legendRender"];function w(e){var t=e.panelColors,r=e.leftPad,n=void 0===r?0:r,o=e.topPad,a=void 0===o?0:o,c=(e.space,e.rectSize),f=void 0===c?0:c,s=e.legendCellSize,d=void 0===s?0:s,y=e.legendRender,m=l(e,x),v=d||f;return(0,u.useMemo)((function(){return(0,p.jsx)(u.Fragment,{children:Object.keys(t||{}).map((function(e,r){var o=i(i({},m),{},{key:r,x:(v+1)*r+n,y:a+8*f+6,fill:t[Number(e)],width:v,height:v});return y?y(o):(0,p.jsx)(O,i({},o))}))})}),[t,m,v,n,a,f,y])}var P=["rectSize","legendCellSize","space","startDate","endDate","rectProps","rectRender","legendRender","value","weekLabels","monthLabels","panelColors","style"];function D(e){var t=e||{},r=t.rectSize,n=void 0===r?11:r,o=t.legendCellSize,a=void 0===o?11:o,f=t.space,s=void 0===f?2:f,m=t.startDate,j=void 0===m?new Date:m,x=t.endDate,D=t.rectProps,E=t.rectRender,k=t.legendRender,_=t.value,A=void 0===_?[]:_,C=t.weekLabels,z=void 0===C?["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]:C,M=t.monthLabels,T=void 0===M?["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]:M,N=t.panelColors,R=void 0===N?{0:"var(--rhm-rect, #EBEDF0)",8:"#7BC96F",4:"#C6E48B",12:"#239A3B",32:"#196127"}:N,L=t.style,F=l(t,P),I=y((0,u.useState)(0),2),B=I[0],J=I[1],U=y((0,u.useState)(z?28:5),2),W=U[0],$=U[1],q=y((0,u.useState)(T?20:5),2),Y=q[0],V=q[1],G=c().createRef(),H=(0,u.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]),K=(0,u.useMemo)((function(){return function(){var e={};return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach((function(t){t.date&&g(new Date(t.date))&&(t.date=h(new Date(t.date)),e[t.date]=t)})),e}(A)}),[A]);(0,u.useEffect)((function(){return $(z?28:5)}),[z]),(0,u.useEffect)((function(){if(G.current){var e=G.current.clientWidth-W||0;J(Math.floor(e/(n+s))||0)}}),[n,G,s,W]),(0,u.useEffect)((function(){V(T?20:5)}),[T]);var Q=(0,u.useMemo)((function(){if(g(j))return j.getDay()?new Date(j.getTime()-j.getDay()*b):j;var e=new Date;return new Date(e.getTime()-e.getDay()*b)}),[j]);return(0,p.jsxs)("svg",i(i({ref:G,style:i(i({},{color:"var(--rhm-text-color, #24292e)",userSelect:"none",display:"block",fontSize:10}),L)},F),{},{children:[0!==a&&(0,p.jsx)(w,{legendRender:k,panelColors:R,rectSize:n,legendCellSize:a,leftPad:W,topPad:Y,space:s}),(0,p.jsx)(v,{weekLabels:z,rectSize:n,space:s,topPad:Y}),(0,p.jsx)(S,{monthLabels:T,rectSize:n,space:s,leftPad:W,colNum:B,startDate:Q}),(0,p.jsx)("g",{transform:"translate(".concat(W,", ").concat(Y,")"),children:B>0&&d(Array(B)).map((function(e,t){return(0,p.jsx)("g",{"data-column":t,children:d(Array(7)).map((function(e,r){var o=new Date(Q.getTime()+b*(7*t+r)),a=h(o),l=i(i({},K[a]),{},{date:a,row:r,column:t,index:7*t+r}),u=i(i({},D),{},{key:r,fill:"var(--rhm-rect, #EBEDF0)",width:n,height:n,x:t*(n+s),y:(n+s)*r,render:E,value:l});return x instanceof Date&&o.getTime()>x.getTime()?null:(a&&K[a]&&R&&Object.keys(R).length>0?u.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}(K[a].count||0,H,R):R&&R[0]&&(u.fill=R[0]),(0,p.jsx)(O,i(i({},u),{},{value:l,"data-date":a,"data-index":l.index,"data-row":l.row,"data-column":l.column})))}))},t)}))})]}))}var E=["prefixCls","className"];function k(e){var t=e.prefixCls,r=void 0===t?"w-heatmap":t,n=e.className,o=l(e,E),a=[n,r].filter(Boolean).join(" ");return(0,p.jsx)(D,i({className:a},o))}})(),o})())); |
@@ -1,2 +0,1 @@ | ||
/// <reference types="react" /> | ||
import { SVGProps } from './SVG'; | ||
@@ -8,2 +7,2 @@ import './style/index.less'; | ||
} | ||
export default function HeatMap(props: HeatMapProps): JSX.Element; | ||
export default function HeatMap(props: HeatMapProps): import("react/jsx-runtime").JSX.Element; |
@@ -19,3 +19,2 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
}, others)); | ||
} | ||
//# sourceMappingURL=index.js.map | ||
} |
@@ -11,2 +11,2 @@ import React from 'react'; | ||
} | ||
export declare const LabelsMonth: ({ monthLabels, rectSize, space, leftPad, colNum, startDate, }: LablesMonthProps) => JSX.Element; | ||
export declare const LabelsMonth: ({ monthLabels, rectSize, space, leftPad, colNum, startDate, }: LablesMonthProps) => import("react/jsx-runtime").JSX.Element; |
import React, { Fragment, useMemo } from 'react'; | ||
import { oneDayTime } from './utils'; | ||
import { textStyle } from './LabelsWeek'; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
@@ -39,2 +40,3 @@ export var LabelsMonth = _ref => { | ||
textAnchor: "start", | ||
style: textStyle, | ||
children: item.monthStr | ||
@@ -44,3 +46,2 @@ }, idx); | ||
}), [data, leftPad, rectSize, space]); | ||
}; | ||
//# sourceMappingURL=LabelsMonth.js.map | ||
}; |
@@ -0,3 +1,5 @@ | ||
import type { CSSProperties } from 'react'; | ||
import React from 'react'; | ||
import { SVGProps } from './SVG'; | ||
export declare const textStyle: CSSProperties; | ||
export interface LablesWeekProps extends React.SVGProps<SVGTextElement> { | ||
@@ -9,2 +11,2 @@ weekLabels: SVGProps['weekLabels']; | ||
} | ||
export declare const LabelsWeek: ({ weekLabels, rectSize, topPad, space }: LablesWeekProps) => JSX.Element; | ||
export declare const LabelsWeek: ({ weekLabels, rectSize, topPad, space }: LablesWeekProps) => import("react/jsx-runtime").JSX.Element; |
import React, { Fragment, useMemo } from 'react'; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
export var textStyle = { | ||
textAnchor: 'middle', | ||
fontSize: 'inherit', | ||
fill: 'currentColor' | ||
}; | ||
export var LabelsWeek = _ref => { | ||
@@ -14,5 +19,7 @@ var { | ||
return /*#__PURE__*/_jsx("text", { | ||
className: "w-heatmap-week", | ||
x: 15, | ||
y: topPad, | ||
dy: (idx + 1) * (rectSize + space) - 5, | ||
style: textStyle, | ||
children: weekLabels[idx] | ||
@@ -24,3 +31,2 @@ }, idx); | ||
}), [rectSize, space, topPad, weekLabels]); | ||
}; | ||
//# sourceMappingURL=LabelsWeek.js.map | ||
}; |
@@ -13,2 +13,2 @@ import React from 'react'; | ||
} | ||
export default function Legend({ panelColors, leftPad, topPad, space, rectSize, legendCellSize, legendRender, ...props }: LegendProps): JSX.Element; | ||
export default function Legend({ panelColors, leftPad, topPad, space, rectSize, legendCellSize, legendRender, ...props }: LegendProps): import("react/jsx-runtime").JSX.Element; |
@@ -33,3 +33,2 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
}), [panelColors, props, size, leftPad, topPad, rectSize, legendRender]); | ||
} | ||
//# sourceMappingURL=Legend.js.map | ||
} |
@@ -0,4 +1,13 @@ | ||
import type { CSSProperties } from 'react'; | ||
import type { HeatMapValue, SVGProps } from './SVG'; | ||
import React from 'react'; | ||
export declare const rectStyle: CSSProperties; | ||
export interface RectProps extends React.SVGProps<SVGRectElement> { | ||
value?: HeatMapValue & { | ||
column: number; | ||
row: number; | ||
index: number; | ||
}; | ||
render?: SVGProps['rectRender']; | ||
} | ||
export declare const Rect: (props: RectProps) => JSX.Element; | ||
export declare const Rect: (props: RectProps) => import("react/jsx-runtime").JSX.Element; |
import _extends from "@babel/runtime/helpers/extends"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; | ||
var _excluded = ["style", "value", "render", "key"]; | ||
import React from 'react'; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
export var Rect = props => /*#__PURE__*/_jsx("rect", _extends({}, props)); | ||
//# sourceMappingURL=Rect.js.map | ||
export var rectStyle = { | ||
display: 'block', | ||
cursor: 'pointer' | ||
}; | ||
export var Rect = props => { | ||
var { | ||
style, | ||
value, | ||
render | ||
} = props, | ||
reset = _objectWithoutPropertiesLoose(props, _excluded); | ||
var rectProps = _extends({}, reset, { | ||
style: _extends({ | ||
display: 'block', | ||
cursor: 'pointer' | ||
}, style) | ||
}); | ||
if (render && typeof render === 'function') { | ||
var elm = render(_extends({}, rectProps), value); | ||
if (elm && /*#__PURE__*/React.isValidElement(elm)) { | ||
return elm; | ||
} | ||
} | ||
return /*#__PURE__*/_jsx("rect", _extends({}, rectProps)); | ||
}; |
import React from 'react'; | ||
import { RectProps } from './Rect'; | ||
import { LegendProps } from './Legend'; | ||
export declare type HeatMapValue = { | ||
export type HeatMapValue = { | ||
date: string; | ||
@@ -8,3 +9,2 @@ content: string | string[] | React.ReactNode; | ||
}; | ||
export declare type RectProps<T = SVGRectElement> = React.SVGProps<T>; | ||
export interface SVGProps extends React.SVGProps<SVGSVGElement> { | ||
@@ -18,5 +18,3 @@ startDate?: Date; | ||
legendRender?: LegendProps['legendRender']; | ||
rectRender?: <E = SVGRectElement>(data: E & { | ||
key: number; | ||
}, valueItem: HeatMapValue & { | ||
rectRender?: (data: React.SVGProps<SVGRectElement>, valueItem: HeatMapValue & { | ||
column: number; | ||
@@ -31,2 +29,2 @@ row: number; | ||
} | ||
export default function SVG(props: SVGProps): JSX.Element; | ||
export default function SVG(props: SVGProps): import("react/jsx-runtime").JSX.Element; |
import _extends from "@babel/runtime/helpers/extends"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; | ||
var _excluded = ["rectSize", "legendCellSize", "space", "startDate", "endDate", "rectProps", "rectRender", "legendRender", "value", "weekLabels", "monthLabels", "panelColors"]; | ||
var _excluded = ["rectSize", "legendCellSize", "space", "startDate", "endDate", "rectProps", "rectRender", "legendRender", "value", "weekLabels", "monthLabels", "panelColors", "style"]; | ||
import React, { useEffect, useMemo, useState } from 'react'; | ||
@@ -27,3 +27,3 @@ import { LabelsWeek } from './LabelsWeek'; | ||
panelColors = { | ||
0: '#EBEDF0', | ||
0: 'var(--rhm-rect, #EBEDF0)', | ||
8: '#7BC96F', | ||
@@ -33,3 +33,4 @@ 4: '#C6E48B', | ||
32: '#196127' | ||
} | ||
}, | ||
style | ||
} = _ref, | ||
@@ -61,4 +62,11 @@ other = _objectWithoutPropertiesLoose(_ref, _excluded); | ||
}, [startDate]); | ||
var styl = { | ||
color: 'var(--rhm-text-color, #24292e)', | ||
userSelect: 'none', | ||
display: 'block', | ||
fontSize: 10 | ||
}; | ||
return /*#__PURE__*/_jsxs("svg", _extends({ | ||
ref: svgRef | ||
ref: svgRef, | ||
style: _extends({}, styl, style) | ||
}, other, { | ||
@@ -91,10 +99,2 @@ children: [legendCellSize !== 0 && /*#__PURE__*/_jsx(Legend, { | ||
children: [...Array(7)].map((_, cidx) => { | ||
var dayProps = _extends({}, 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)); | ||
@@ -108,2 +108,12 @@ var date = getDateToString(currentDate); | ||
}); | ||
var dayProps = _extends({}, rectProps, { | ||
key: cidx, | ||
fill: 'var(--rhm-rect, #EBEDF0)', | ||
width: rectSize, | ||
height: rectSize, | ||
x: idx * (rectSize + space), | ||
y: (rectSize + space) * cidx, | ||
render: rectRender, | ||
value: dataProps | ||
}); | ||
if (endDate instanceof Date && currentDate.getTime() > endDate.getTime()) { | ||
@@ -117,11 +127,4 @@ return null; | ||
} | ||
if (rectRender && typeof rectRender === 'function') { | ||
var elm = rectRender(_extends({}, dayProps, { | ||
key: cidx | ||
}), dataProps); | ||
if (elm && /*#__PURE__*/React.isValidElement(elm)) { | ||
return elm; | ||
} | ||
} | ||
return /*#__PURE__*/_jsx(Rect, _extends({}, dayProps, { | ||
value: dataProps, | ||
"data-date": date, | ||
@@ -137,3 +140,2 @@ "data-index": dataProps.index, | ||
})); | ||
} | ||
//# sourceMappingURL=SVG.js.map | ||
} |
@@ -48,3 +48,2 @@ export var oneDayTime = 24 * 60 * 60 * 1000; | ||
return color; | ||
} | ||
//# sourceMappingURL=utils.js.map | ||
} |
@@ -1,2 +0,1 @@ | ||
/// <reference types="react" /> | ||
import { SVGProps } from './SVG'; | ||
@@ -8,2 +7,2 @@ import './style/index.less'; | ||
} | ||
export default function HeatMap(props: HeatMapProps): JSX.Element; | ||
export default function HeatMap(props: HeatMapProps): import("react/jsx-runtime").JSX.Element; |
@@ -36,3 +36,2 @@ "use strict"; | ||
}, others)); | ||
} | ||
//# sourceMappingURL=index.js.map | ||
} |
@@ -11,2 +11,2 @@ import React from 'react'; | ||
} | ||
export declare const LabelsMonth: ({ monthLabels, rectSize, space, leftPad, colNum, startDate, }: LablesMonthProps) => JSX.Element; | ||
export declare const LabelsMonth: ({ monthLabels, rectSize, space, leftPad, colNum, startDate, }: LablesMonthProps) => import("react/jsx-runtime").JSX.Element; |
@@ -12,2 +12,3 @@ "use strict"; | ||
var _utils = require("./utils"); | ||
var _LabelsWeek = require("./LabelsWeek"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
@@ -55,2 +56,3 @@ var LabelsMonth = function LabelsMonth(_ref) { | ||
textAnchor: "start", | ||
style: _LabelsWeek.textStyle, | ||
children: item.monthStr | ||
@@ -62,3 +64,2 @@ }, idx); | ||
}; | ||
exports.LabelsMonth = LabelsMonth; | ||
//# sourceMappingURL=LabelsMonth.js.map | ||
exports.LabelsMonth = LabelsMonth; |
@@ -0,3 +1,5 @@ | ||
import type { CSSProperties } from 'react'; | ||
import React from 'react'; | ||
import { SVGProps } from './SVG'; | ||
export declare const textStyle: CSSProperties; | ||
export interface LablesWeekProps extends React.SVGProps<SVGTextElement> { | ||
@@ -9,2 +11,2 @@ weekLabels: SVGProps['weekLabels']; | ||
} | ||
export declare const LabelsWeek: ({ weekLabels, rectSize, topPad, space }: LablesWeekProps) => JSX.Element; | ||
export declare const LabelsWeek: ({ weekLabels, rectSize, topPad, space }: LablesWeekProps) => import("react/jsx-runtime").JSX.Element; |
@@ -8,6 +8,12 @@ "use strict"; | ||
}); | ||
exports.LabelsWeek = void 0; | ||
exports.textStyle = exports.LabelsWeek = void 0; | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
var textStyle = { | ||
textAnchor: 'middle', | ||
fontSize: 'inherit', | ||
fill: 'currentColor' | ||
}; | ||
exports.textStyle = textStyle; | ||
var LabelsWeek = function LabelsWeek(_ref) { | ||
@@ -27,5 +33,7 @@ var _ref$weekLabels = _ref.weekLabels, | ||
return /*#__PURE__*/(0, _jsxRuntime.jsx)("text", { | ||
className: "w-heatmap-week", | ||
x: 15, | ||
y: topPad, | ||
dy: (idx + 1) * (rectSize + space) - 5, | ||
style: textStyle, | ||
children: weekLabels[idx] | ||
@@ -39,3 +47,2 @@ }, idx); | ||
}; | ||
exports.LabelsWeek = LabelsWeek; | ||
//# sourceMappingURL=LabelsWeek.js.map | ||
exports.LabelsWeek = LabelsWeek; |
@@ -13,2 +13,2 @@ import React from 'react'; | ||
} | ||
export default function Legend({ panelColors, leftPad, topPad, space, rectSize, legendCellSize, legendRender, ...props }: LegendProps): JSX.Element; | ||
export default function Legend({ panelColors, leftPad, topPad, space, rectSize, legendCellSize, legendRender, ...props }: LegendProps): import("react/jsx-runtime").JSX.Element; |
@@ -47,3 +47,2 @@ "use strict"; | ||
} | ||
module.exports = exports.default; | ||
//# sourceMappingURL=Legend.js.map | ||
module.exports = exports.default; |
@@ -0,4 +1,13 @@ | ||
import type { CSSProperties } from 'react'; | ||
import type { HeatMapValue, SVGProps } from './SVG'; | ||
import React from 'react'; | ||
export declare const rectStyle: CSSProperties; | ||
export interface RectProps extends React.SVGProps<SVGRectElement> { | ||
value?: HeatMapValue & { | ||
column: number; | ||
row: number; | ||
index: number; | ||
}; | ||
render?: SVGProps['rectRender']; | ||
} | ||
export declare const Rect: (props: RectProps) => JSX.Element; | ||
export declare const Rect: (props: RectProps) => import("react/jsx-runtime").JSX.Element; |
@@ -7,10 +7,33 @@ "use strict"; | ||
}); | ||
exports.Rect = void 0; | ||
exports.rectStyle = exports.Rect = void 0; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
var _excluded = ["style", "value", "render", "key"]; | ||
var rectStyle = { | ||
display: 'block', | ||
cursor: 'pointer' | ||
}; | ||
exports.rectStyle = rectStyle; | ||
var Rect = function Rect(props) { | ||
return /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", (0, _objectSpread2["default"])({}, props)); | ||
var style = props.style, | ||
value = props.value, | ||
render = props.render, | ||
key = props.key, | ||
reset = (0, _objectWithoutProperties2["default"])(props, _excluded); | ||
var rectProps = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, { | ||
style: (0, _objectSpread2["default"])({ | ||
display: 'block', | ||
cursor: 'pointer' | ||
}, style) | ||
}); | ||
if (render && typeof render === 'function') { | ||
var elm = render((0, _objectSpread2["default"])({}, rectProps), value); | ||
if (elm && /*#__PURE__*/_react["default"].isValidElement(elm)) { | ||
return elm; | ||
} | ||
} | ||
return /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", (0, _objectSpread2["default"])({}, rectProps)); | ||
}; | ||
exports.Rect = Rect; | ||
//# sourceMappingURL=Rect.js.map | ||
exports.Rect = Rect; |
import React from 'react'; | ||
import { RectProps } from './Rect'; | ||
import { LegendProps } from './Legend'; | ||
export declare type HeatMapValue = { | ||
export type HeatMapValue = { | ||
date: string; | ||
@@ -8,3 +9,2 @@ content: string | string[] | React.ReactNode; | ||
}; | ||
export declare type RectProps<T = SVGRectElement> = React.SVGProps<T>; | ||
export interface SVGProps extends React.SVGProps<SVGSVGElement> { | ||
@@ -18,5 +18,3 @@ startDate?: Date; | ||
legendRender?: LegendProps['legendRender']; | ||
rectRender?: <E = SVGRectElement>(data: E & { | ||
key: number; | ||
}, valueItem: HeatMapValue & { | ||
rectRender?: (data: React.SVGProps<SVGRectElement>, valueItem: HeatMapValue & { | ||
column: number; | ||
@@ -31,2 +29,2 @@ row: number; | ||
} | ||
export default function SVG(props: SVGProps): JSX.Element; | ||
export default function SVG(props: SVGProps): import("react/jsx-runtime").JSX.Element; |
@@ -9,4 +9,4 @@ "use strict"; | ||
exports["default"] = SVG; | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
@@ -21,3 +21,3 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
var _excluded = ["rectSize", "legendCellSize", "space", "startDate", "endDate", "rectProps", "rectRender", "legendRender", "value", "weekLabels", "monthLabels", "panelColors"]; | ||
var _excluded = ["rectSize", "legendCellSize", "space", "startDate", "endDate", "rectProps", "rectRender", "legendRender", "value", "weekLabels", "monthLabels", "panelColors", "style"]; | ||
function SVG(props) { | ||
@@ -45,3 +45,3 @@ var _ref = props || {}, | ||
panelColors = _ref$panelColors === void 0 ? { | ||
0: '#EBEDF0', | ||
0: 'var(--rhm-rect, #EBEDF0)', | ||
8: '#7BC96F', | ||
@@ -52,2 +52,3 @@ 4: '#C6E48B', | ||
} : _ref$panelColors, | ||
style = _ref.style, | ||
other = (0, _objectWithoutProperties2["default"])(_ref, _excluded); | ||
@@ -95,4 +96,11 @@ var _useState = (0, _react.useState)(0), | ||
}, [startDate]); | ||
var styl = { | ||
color: 'var(--rhm-text-color, #24292e)', | ||
userSelect: 'none', | ||
display: 'block', | ||
fontSize: 10 | ||
}; | ||
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({ | ||
ref: svgRef | ||
ref: svgRef, | ||
style: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, styl), style) | ||
}, other), {}, { | ||
@@ -125,10 +133,2 @@ children: [legendCellSize !== 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Legend["default"], { | ||
children: (0, _toConsumableArray2["default"])(Array(7)).map(function (_, cidx) { | ||
var dayProps = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, rectProps), {}, { | ||
key: cidx, | ||
fill: '#EBEDF0', | ||
width: rectSize, | ||
height: rectSize, | ||
x: idx * (rectSize + space), | ||
y: (rectSize + space) * cidx | ||
}); | ||
var currentDate = new Date(initStartDate.getTime() + _utils.oneDayTime * (idx * 7 + cidx)); | ||
@@ -142,2 +142,12 @@ var date = (0, _utils.getDateToString)(currentDate); | ||
}); | ||
var dayProps = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, rectProps), {}, { | ||
key: cidx, | ||
fill: 'var(--rhm-rect, #EBEDF0)', | ||
width: rectSize, | ||
height: rectSize, | ||
x: idx * (rectSize + space), | ||
y: (rectSize + space) * cidx, | ||
render: rectRender, | ||
value: dataProps | ||
}); | ||
if (endDate instanceof Date && currentDate.getTime() > endDate.getTime()) { | ||
@@ -151,11 +161,4 @@ return null; | ||
} | ||
if (rectRender && typeof rectRender === 'function') { | ||
var elm = rectRender((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, dayProps), {}, { | ||
key: cidx | ||
}), dataProps); | ||
if (elm && /*#__PURE__*/_react["default"].isValidElement(elm)) { | ||
return elm; | ||
} | ||
} | ||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Rect.Rect, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, dayProps), {}, { | ||
value: dataProps, | ||
"data-date": date, | ||
@@ -172,3 +175,2 @@ "data-index": dataProps.index, | ||
} | ||
module.exports = exports.default; | ||
//# sourceMappingURL=SVG.js.map | ||
module.exports = exports.default; |
@@ -53,3 +53,2 @@ "use strict"; | ||
return color; | ||
} | ||
//# sourceMappingURL=utils.js.map | ||
} |
{ | ||
"name": "@uiw/react-heat-map", | ||
"version": "2.0.5", | ||
"version": "2.1.0", | ||
"description": "React component create calendar heatmap to visualize time series data, a la github contribution graph.", | ||
@@ -18,4 +18,4 @@ "homepage": "https://uiwjs.github.io/react-heat-map/", | ||
"bundle:min": "ncc build src/index.tsx --target web --filename heat-map --minify", | ||
"watch": "tsbb watch & npm run css:watch", | ||
"build": "tsbb build && npm run css:build && npm run css:build:dist", | ||
"watch": "tsbb watch src/*.tsx --use-babel & npm run css:watch", | ||
"build": "tsbb build src/*.tsx --use-babel && npm run css:build && npm run css:build:dist", | ||
"type-check": "tsc --noEmit", | ||
@@ -22,0 +22,0 @@ "test": "tsbb test --env=jsdom", |
@@ -83,3 +83,3 @@ HeatMap 日历热图 | ||
width={600} | ||
style={{ color: '#ad001d' }} | ||
style={{ color: '#ad001d', '--rhm-rect-active': 'red' }} | ||
startDate={new Date('2016/01/01')} | ||
@@ -128,2 +128,3 @@ panelColors={{ | ||
width={600} | ||
style={{ '--rhm-rect': '#b9b9b9' }} | ||
startDate={new Date('2016/01/01')} | ||
@@ -171,3 +172,3 @@ legendRender={(props) => <rect {...props} y={props.y + 10} rx={range} />} | ||
return ( | ||
<Tooltip key={props.key} placement="top" content={`count: ${data.count || 0}`}> | ||
<Tooltip placement="top" content={`count: ${data.count || 0}`}> | ||
<rect {...props} /> | ||
@@ -174,0 +175,0 @@ </Tooltip> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1683
326
95546
47