mario-education 2.4.175-level → 2.4.176-level

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31223,7 +31223,7 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31223
31223
  }, {
31224
31224
  label: "STRAIN",
31225
31225
  value: studentPressure.strainStudent,
31226
- tooltip: "Manageable levels of stress allowing me to perform at my best."
31226
+ tooltip: "Still in control but starting to feel the pressure."
31227
31227
  }, {
31228
31228
  label: "OVERWHELMED",
31229
31229
  value: studentPressure.burnoutStudent,
@@ -31235,8 +31235,8 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31235
31235
  tooltipVisible = _useState[0],
31236
31236
  setTooltipVisible = _useState[1];
31237
31237
 
31238
- var _useState2 = useState(false),
31239
- isInfoTooltip = _useState2[0],
31238
+ var _useState2 = useState(""),
31239
+ infoTooltip = _useState2[0],
31240
31240
  setInfoTooltip = _useState2[1];
31241
31241
 
31242
31242
  var _useState3 = useState(0),
@@ -31262,7 +31262,7 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31262
31262
  dummyElement.style.whiteSpace = "wrap";
31263
31263
  dummyElement.style.fontSize = fontSize;
31264
31264
  dummyElement.style.width = "162px";
31265
- dummyElement.style.padding = "5px 5px 5px 10px";
31265
+ dummyElement.style.padding = "5px 5px 5px 8px";
31266
31266
  dummyElement.innerHTML = text;
31267
31267
  document.body.appendChild(dummyElement);
31268
31268
  var height = dummyElement.offsetHeight;
@@ -31270,24 +31270,38 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31270
31270
  return height;
31271
31271
  };
31272
31272
 
31273
+ var getWidthFromText = function getWidthFromText(text, fontSize, fontWeight) {
31274
+ var dummyElement = document.createElement("span");
31275
+ dummyElement.style.visibility = "hidden";
31276
+ dummyElement.style.position = "absolute";
31277
+ dummyElement.style.whiteSpace = "nowrap";
31278
+ dummyElement.style.fontSize = fontSize;
31279
+ dummyElement.style.fontWeight = fontWeight;
31280
+ dummyElement.innerHTML = text;
31281
+ document.body.appendChild(dummyElement);
31282
+ var width = dummyElement.offsetWidth;
31283
+ document.body.removeChild(dummyElement);
31284
+ return width;
31285
+ };
31286
+
31273
31287
  var handleDotHover = function handleDotHover(students, x, y, label, color) {
31274
31288
  setTooltipStudents(Array.from(new Set(students)));
31275
- setTooltipX(isMobileScreen && label == "OVERWHELMED" ? x - 45 : x);
31289
+ setTooltipX(isMobileScreen && label == data[data.length - 1].label ? x - 45 : x);
31276
31290
  setTooltipY(y);
31277
31291
  setTooltipVisible(label);
31278
31292
  setColorTooltip(color);
31279
31293
  };
31280
31294
 
31281
- var handleEnterInfoIcon = function handleEnterInfoIcon(x, y, tip) {
31282
- setTooltipVisible(tip);
31283
- setInfoTooltip(true);
31284
- setTooltipX(x);
31295
+ var handleEnterInfoIcon = function handleEnterInfoIcon(x, y, tip, label) {
31296
+ setTooltipVisible(label);
31297
+ setInfoTooltip(tip);
31298
+ setTooltipX(isMobileScreen && label == data[data.length - 1].label ? x - 15 : x);
31285
31299
  setTooltipY(y);
31286
31300
  };
31287
31301
 
31288
31302
  var handleLeaveInfoIcon = function handleLeaveInfoIcon() {
31289
31303
  setTooltipVisible("");
31290
- setInfoTooltip(false);
31304
+ setInfoTooltip("");
31291
31305
  };
31292
31306
 
31293
31307
  var handleDotLeave = function handleDotLeave() {
@@ -31363,7 +31377,7 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31363
31377
  var circleY = !isMobileScreen ? chartHeight - 30 : chartHeight - 24;
31364
31378
 
31365
31379
  var _loop = function _loop(i) {
31366
- var _data3, _data3$value, _data3$value$length, _data6, _data7;
31380
+ var _data3, _data4, _data5, _data5$value, _data5$value$length, _data8, _data9;
31367
31381
 
31368
31382
  var circleX = circleSpacing * i + alignment;
31369
31383
  var radius = !isMobileScreen ? 15 : 12;
@@ -31372,12 +31386,17 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31372
31386
  circle.setAttribute("cy", "" + circleY);
31373
31387
  circle.setAttribute("r", "" + radius);
31374
31388
  circle.setAttribute("fill", colors[i - 1]);
31389
+ circle.style.cursor = "pointer";
31375
31390
  circle.addEventListener("mouseenter", function () {
31376
31391
  var _data, _data2;
31377
31392
 
31378
31393
  handleDotHover((_data = data[i - 1]) === null || _data === void 0 ? void 0 : _data.value, circleX, circleY, (_data2 = data[i - 1]) === null || _data2 === void 0 ? void 0 : _data2.label, colors[i - 1]);
31379
31394
  });
31380
- circle.addEventListener("mouseleave", handleDotLeave);
31395
+ var lineHeight = 20;
31396
+ var tooltipHeight = ((_data3 = data[i - 1]) === null || _data3 === void 0 ? void 0 : _data3.value.length) * lineHeight * 6;
31397
+ var widthLabel = getWidthFromText((_data4 = data[i - 1]) === null || _data4 === void 0 ? void 0 : _data4.label, "9px", "bold");
31398
+ var isScrollStudents = tooltipHeight + 30 > chartHeight - 100 - (isMobileScreen ? widthLabel : 0);
31399
+ if (isScrollStudents) circle.addEventListener("click", handleDotLeave);else circle.addEventListener("mouseleave", handleDotLeave);
31381
31400
  svg.appendChild(circle);
31382
31401
  var text = document.createElementNS("http://www.w3.org/2000/svg", "text");
31383
31402
  text.setAttribute("x", "" + circleX);
@@ -31387,15 +31406,17 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31387
31406
  text.setAttribute("text-anchor", "middle");
31388
31407
  text.setAttribute("dominant-baseline", "middle");
31389
31408
  text.setAttribute("style", "cursor: default");
31390
- text.textContent = (_data3 = data[i - 1]) === null || _data3 === void 0 ? void 0 : (_data3$value = _data3.value) === null || _data3$value === void 0 ? void 0 : (_data3$value$length = _data3$value.length) === null || _data3$value$length === void 0 ? void 0 : _data3$value$length.toString();
31409
+ text.textContent = (_data5 = data[i - 1]) === null || _data5 === void 0 ? void 0 : (_data5$value = _data5.value) === null || _data5$value === void 0 ? void 0 : (_data5$value$length = _data5$value.length) === null || _data5$value$length === void 0 ? void 0 : _data5$value$length.toString();
31410
+ text.style.cursor = "pointer";
31391
31411
  text.addEventListener("mouseenter", function () {
31392
- var _data4, _data5;
31412
+ var _data6, _data7;
31393
31413
 
31394
- handleDotHover((_data4 = data[i - 1]) === null || _data4 === void 0 ? void 0 : _data4.value, circleX, circleY, (_data5 = data[i - 1]) === null || _data5 === void 0 ? void 0 : _data5.label, colors[i - 1]);
31414
+ handleDotHover((_data6 = data[i - 1]) === null || _data6 === void 0 ? void 0 : _data6.value, circleX, circleY, (_data7 = data[i - 1]) === null || _data7 === void 0 ? void 0 : _data7.label, colors[i - 1]);
31395
31415
  });
31416
+ if (isScrollStudents) text.addEventListener("click", handleDotLeave);else text.addEventListener("mouseleave", handleDotLeave);
31396
31417
  svg.appendChild(text);
31397
- var label = (_data6 = data[i - 1]) === null || _data6 === void 0 ? void 0 : _data6.label;
31398
- var tooltip = (_data7 = data[i - 1]) === null || _data7 === void 0 ? void 0 : _data7.tooltip;
31418
+ var label = (_data8 = data[i - 1]) === null || _data8 === void 0 ? void 0 : _data8.label;
31419
+ var tooltip = (_data9 = data[i - 1]) === null || _data9 === void 0 ? void 0 : _data9.tooltip;
31399
31420
  var infoIconContainer = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");
31400
31421
  var infoIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
31401
31422
  infoIcon.innerHTML = "<rect width=\"256\" height=\"256\" fill=\"none\"></rect><circle cx=\"128\" cy=\"128\" r=\"96\" fill=\"none\" stroke=\"#000\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"16\"></circle><polyline fill=\"none\" stroke=\"#000\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"16\" points=\"120 120 128 120 128 176 136 176\"></polyline><circle cx=\"128\" cy=\"84\" r=\"12\"></circle>";
@@ -31421,13 +31442,14 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31421
31442
 
31422
31443
  labelText.textContent = label;
31423
31444
  svg.appendChild(labelText);
31424
- infoIconContainer.setAttribute("x", "" + (circleX + 8 + labelText.getBoundingClientRect().width / 2));
31425
- infoIconContainer.setAttribute("y", "" + (circleY - radius - 20 - labelText.getBoundingClientRect().height / 2));
31445
+ var infoX = isMobileScreen ? circleX - 8 : circleX + 8 + labelText.getBoundingClientRect().width / 2;
31446
+ var infoY = isMobileScreen ? circleY - radius - 32 - labelText.getBoundingClientRect().height : circleY - radius - 20 - labelText.getBoundingClientRect().height / 2;
31447
+ infoIconContainer.setAttribute("x", "" + infoX);
31448
+ infoIconContainer.setAttribute("y", "" + infoY);
31426
31449
  infoIconContainer.addEventListener("mouseenter", function () {
31427
- return handleEnterInfoIcon(circleX + 8 + labelText.getBoundingClientRect().width / 2, circleY - radius - 16 - labelText.getBoundingClientRect().height / 2, tooltip);
31450
+ return handleEnterInfoIcon(infoX, infoY + 4, tooltip, label);
31428
31451
  });
31429
31452
  infoIconContainer.addEventListener("mouseleave", handleLeaveInfoIcon);
31430
- labelText.getBoundingClientRect();
31431
31453
  svg.appendChild(infoIconContainer);
31432
31454
  };
31433
31455
 
@@ -31446,29 +31468,42 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31446
31468
  }
31447
31469
  };
31448
31470
 
31449
- while (svg.firstChild) {
31450
- svg.firstChild.remove();
31451
- }
31471
+ try {
31472
+ while (svg.firstChild) {
31473
+ while (svg.firstChild.firstChild) {
31474
+ svg.firstChild.firstChild.remove();
31475
+ }
31476
+
31477
+ svg.firstChild.remove();
31478
+ }
31452
31479
 
31453
- drawChart();
31480
+ drawChart();
31481
+ } catch (err) {
31482
+ console.log("err: ", err);
31483
+ }
31454
31484
  }
31455
- }, [chartWidth, studentPressure]);
31485
+ }, [chartWidth, chartHeight, JSON.stringify(studentPressure)]);
31486
+ var widthLabel = useMemo(function () {
31487
+ if (!!tooltipVisible) return getWidthFromText(tooltipVisible, "9px", "bold");
31488
+ return 0;
31489
+ }, [tooltipVisible]);
31456
31490
  var lineHeight = 20;
31457
- var tooltipHeight = tooltipStudents.length * lineHeight;
31458
- var maxHeightTooltip = tooltipHeight + 30 > chartHeight - 50 ? chartHeight - 50 : tooltipHeight + 30;
31491
+ var tooltipHeight = tooltipStudents.length * lineHeight * 6;
31492
+ var isScrollStudents = tooltipHeight + 30 > chartHeight - 100 - (isMobileScreen ? widthLabel : 0);
31493
+ var maxHeightTooltip = isScrollStudents ? chartHeight - 100 - (isMobileScreen ? widthLabel : 0) : tooltipHeight + 30;
31459
31494
  var heightInfoTooltip = useMemo(function () {
31460
- if (isInfoTooltip && tooltipVisible) return getHeightFromText(tooltipVisible, "12px");
31495
+ if (!!infoTooltip && !!tooltipVisible) return getHeightFromText(infoTooltip, "12px");
31461
31496
  return 0;
31462
- }, [isInfoTooltip, tooltipVisible]);
31497
+ }, [infoTooltip, tooltipVisible]);
31463
31498
  return React.createElement("svg", {
31464
31499
  ref: svgRef,
31465
31500
  width: chartWidth,
31466
31501
  height: chartHeight + 50
31467
31502
  }, !!tooltipVisible && React.createElement("g", {
31468
- transform: "translate(" + (isInfoTooltip ? tooltipX - 81 : tooltipX - 100) + "," + Math.max(0, isInfoTooltip ? tooltipY - heightInfoTooltip - 30 : tooltipY - tooltipHeight - 100) + ")"
31503
+ transform: "translate(" + (infoTooltip ? tooltipX - 81 : tooltipX - 100) + "," + Math.max(0, infoTooltip ? tooltipY - heightInfoTooltip - 30 : isMobileScreen ? tooltipY - tooltipHeight - 100 - widthLabel : tooltipY - tooltipHeight - 100) + ")"
31469
31504
  }, React.createElement("rect", {
31470
- width: isInfoTooltip ? 162 : 200,
31471
- height: isInfoTooltip ? heightInfoTooltip + 10 : maxHeightTooltip + 10,
31505
+ width: infoTooltip ? 162 : 200,
31506
+ height: infoTooltip ? heightInfoTooltip + 10 : maxHeightTooltip + 10,
31472
31507
  fill: "rgba(36, 36, 36, 0.8)",
31473
31508
  rx: "5"
31474
31509
  }), React.createElement("text", {
@@ -31477,10 +31512,10 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31477
31512
  fill: "#fff",
31478
31513
  fontSize: "12px",
31479
31514
  textAnchor: "start"
31480
- }, !isInfoTooltip && tooltipStudents.length + " students are " + tooltipVisible), isInfoTooltip && React.createElement("foreignObject", {
31515
+ }, !infoTooltip && tooltipStudents.length + " students are " + tooltipVisible), !!infoTooltip && React.createElement("foreignObject", {
31481
31516
  x: "0",
31482
31517
  y: "10",
31483
- width: isInfoTooltip ? 162 : 200,
31518
+ width: infoTooltip ? 162 : 200,
31484
31519
  height: heightInfoTooltip
31485
31520
  }, React.createElement("div", {
31486
31521
  style: {
@@ -31488,7 +31523,7 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31488
31523
  color: "#fff",
31489
31524
  fontSize: "12px"
31490
31525
  }
31491
- }, tooltipVisible)), !isInfoTooltip && React.createElement("foreignObject", {
31526
+ }, infoTooltip)), !infoTooltip && React.createElement("foreignObject", {
31492
31527
  x: "0",
31493
31528
  y: "30",
31494
31529
  width: "200",
@@ -31496,12 +31531,12 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31496
31531
  }, React.createElement("div", {
31497
31532
  style: {
31498
31533
  overflowY: "auto",
31499
- maxHeight: maxHeightTooltip - 20 + "px",
31534
+ maxHeight: (isScrollStudents ? maxHeightTooltip - 30 : maxHeightTooltip - 20) + "px",
31500
31535
  padding: "5px 5px 5px 10px",
31501
31536
  color: "#fff",
31502
31537
  fontSize: "12px"
31503
31538
  }
31504
- }, tooltipStudents.map(function (label, index) {
31539
+ }, [].concat(tooltipStudents, tooltipStudents, tooltipStudents, tooltipStudents, tooltipStudents, tooltipStudents).map(function (label, index) {
31505
31540
  return React.createElement("div", {
31506
31541
  key: index
31507
31542
  }, React.createElement("span", {
@@ -31515,8 +31550,8 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31515
31550
  }
31516
31551
  }), React.createElement("span", null, label));
31517
31552
  }))), React.createElement("foreignObject", {
31518
- y: isInfoTooltip ? heightInfoTooltip + 10 : tooltipHeight + 40,
31519
- x: isInfoTooltip ? 82 : 94,
31553
+ y: infoTooltip ? heightInfoTooltip + 10 : Math.min(tooltipHeight + 40, maxHeightTooltip + 10),
31554
+ x: infoTooltip ? isMobileScreen && tooltipVisible === data[data.length - 1].label ? 99 : 84 : isMobileScreen && tooltipVisible === "OVERWHELMED" ? 139 : 94,
31520
31555
  width: 10,
31521
31556
  height: 10
31522
31557
  }, React.createElement("div", {